[PATCH] D91840: OpaquePtr: Require byval on x86_intrcc parameter 0

2020-11-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/test/Bitcode/compatibility-6.0.ll:439
 ; CHECK: declare hhvm_ccc void @f.hhvm_ccc()
-declare cc83 void @f.cc83()
+declare cc83 void @f.cc83(i8* byval(i8))
 ; CHECK: declare x86_intrcc void @f.cc83()

Why do we need to change arguments here? Isn't no arguments allowed?



Comment at: llvm/test/Bitcode/compatibility-6.0.ll:441
 ; CHECK: declare x86_intrcc void @f.cc83()
-declare x86_intrcc void @f.x86_intrcc()
+declare x86_intrcc void @f.x86_intrcc())
 ; CHECK: declare x86_intrcc void @f.x86_intrcc()

What's this extra parenthese for?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91840/new/

https://reviews.llvm.org/D91840

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 776f92e - [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-20 Thread via cfe-commits

Author: Liu, Chen3
Date: 2020-11-20T16:20:19+08:00
New Revision: 776f92e06759e2491018f66ea334adb687337f1c

URL: 
https://github.com/llvm/llvm-project/commit/776f92e06759e2491018f66ea334adb687337f1c
DIFF: 
https://github.com/llvm/llvm-project/commit/776f92e06759e2491018f66ea334adb687337f1c.diff

LOG: [X86] Add support for vex, vex2, vex3, and evex for MASM

For MASM syntax, the prefixes are not enclosed in braces.
The assembly code should like:
  "evex vcvtps2pd xmm0, xmm1"

Differential Revision: https://reviews.llvm.org/D90441

Added: 
clang/test/CodeGen/X86/ms-inline-asm-prefix.c

Modified: 
clang/lib/AST/Stmt.cpp
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Removed: 




diff  --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index 8b2564d7fc96..83821ea6f5fc 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -791,7 +791,27 @@ std::string GCCAsmStmt::generateAsmString(const ASTContext 
&C) const {
 /// Assemble final IR asm string (MS-style).
 std::string MSAsmStmt::generateAsmString(const ASTContext &C) const {
   // FIXME: This needs to be translated into the IR string representation.
-  return std::string(AsmStr);
+  SmallVector Pieces;
+  AsmStr.split(Pieces, "\n\t");
+  std::string MSAsmString;
+  for (size_t I = 0, E = Pieces.size(); I < E; ++I) {
+StringRef Instruction = Pieces[I];
+// For vex/vex2/vex3/evex masm style prefix, convert it to att style
+// since we don't support masm style prefix in backend.
+if (Instruction.startswith("vex "))
+  MSAsmString += '{' + Instruction.substr(0, 3).str() + '}' +
+ Instruction.substr(3).str();
+else if (Instruction.startswith("vex2 ") ||
+ Instruction.startswith("vex3 ") || Instruction.startswith("evex 
"))
+  MSAsmString += '{' + Instruction.substr(0, 4).str() + '}' +
+ Instruction.substr(4).str();
+else
+  MSAsmString += Instruction.str();
+// If this is not the last instruction, adding back the '\n\t'.
+if (I < E - 1)
+  MSAsmString += "\n\t";
+  }
+  return MSAsmString;
 }
 
 Expr *MSAsmStmt::getOutputExpr(unsigned i) {

diff  --git a/clang/test/CodeGen/X86/ms-inline-asm-prefix.c 
b/clang/test/CodeGen/X86/ms-inline-asm-prefix.c
new file mode 100644
index ..bb89599877ec
--- /dev/null
+++ b/clang/test/CodeGen/X86/ms-inline-asm-prefix.c
@@ -0,0 +1,14 @@
+// REQUIRES: x86-registered-target
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-windows-msvc 
-target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl 
-fasm-blocks -mllvm -x86-asm-syntax=intel -S -emit-llvm -o -  | FileCheck %s 
-check-prefix=INTEL
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-windows-msvc 
-target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl 
-fasm-blocks -mllvm -x86-asm-syntax=att -S -emit-llvm -o -  | FileCheck %s 
-check-prefix=ATT
+
+void check_inline_prefix(void) {
+  __asm {
+// INTEL: call void asm sideeffect inteldialect "{vex} vcvtps2pd xmm0, 
xmm1\0A\09{vex2} vcvtps2pd xmm0, xmm1\0A\09{vex3} vcvtps2pd xmm0, 
xmm1\0A\09{evex} vcvtps2pd xmm0, xmm1", "~{xmm0},~{dirflag},~{fpsr},~{flags}"()
+// ATT: call void asm sideeffect inteldialect "{vex} vcvtps2pd xmm0, 
xmm1\0A\09{vex2} vcvtps2pd xmm0, xmm1\0A\09{vex3} vcvtps2pd xmm0, 
xmm1\0A\09{evex} vcvtps2pd xmm0, xmm1", "~{xmm0},~{dirflag},~{fpsr},~{flags}"()
+vex vcvtps2pd xmm0, xmm1
+vex2 vcvtps2pd xmm0, xmm1
+vex3 vcvtps2pd xmm0, xmm1
+evex vcvtps2pd xmm0, xmm1
+  }
+}

diff  --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp 
b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 03956deb5595..21771e9d4171 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3064,7 +3064,26 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo 
&Info, StringRef Name,
   }
   continue;
 }
+// Parse MASM style pseudo prefixes.
+if (isParsingMSInlineAsm()) {
+  if (Name.equals_lower("vex"))
+ForcedVEXEncoding = VEXEncoding_VEX;
+  else if (Name.equals_lower("vex2"))
+ForcedVEXEncoding = VEXEncoding_VEX2;
+  else if (Name.equals_lower("vex3"))
+ForcedVEXEncoding = VEXEncoding_VEX3;
+  else if (Name.equals_lower("evex"))
+ForcedVEXEncoding = VEXEncoding_EVEX;
 
+  if (ForcedVEXEncoding != VEXEncoding_Default) {
+if (getLexer().isNot(AsmToken::Identifier))
+  return Error(Parser.getTok().getLoc(), "Expected identifier");
+// FIXME: The mnemonic won't match correctly if its not in lower case.
+Name = Parser.getTok().getString();
+NameLoc = Parser.getTok().getLoc();
+Parser.Lex();
+  }
+}
 break;
   }
 
@@ -4370,10 +4389,16 @@ bool X86AsmParser::MatchAndEmitIntelInstruction(SMLoc 
IDLoc, unsigned &Opcode,
 
   MCInst Inst;
 
-  // If VEX3 encod

[PATCH] D90441: [X86] Add support for vex, vex2, vex3, and evex for MASM

2020-11-20 Thread LiuChen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG776f92e06759: [X86] Add support for vex, vex2, vex3, and 
evex for MASM (authored by LiuChen3).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90441/new/

https://reviews.llvm.org/D90441

Files:
  clang/lib/AST/Stmt.cpp
  clang/test/CodeGen/X86/ms-inline-asm-prefix.c
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3064,7 +3064,26 @@
   }
   continue;
 }
+// Parse MASM style pseudo prefixes.
+if (isParsingMSInlineAsm()) {
+  if (Name.equals_lower("vex"))
+ForcedVEXEncoding = VEXEncoding_VEX;
+  else if (Name.equals_lower("vex2"))
+ForcedVEXEncoding = VEXEncoding_VEX2;
+  else if (Name.equals_lower("vex3"))
+ForcedVEXEncoding = VEXEncoding_VEX3;
+  else if (Name.equals_lower("evex"))
+ForcedVEXEncoding = VEXEncoding_EVEX;
 
+  if (ForcedVEXEncoding != VEXEncoding_Default) {
+if (getLexer().isNot(AsmToken::Identifier))
+  return Error(Parser.getTok().getLoc(), "Expected identifier");
+// FIXME: The mnemonic won't match correctly if its not in lower case.
+Name = Parser.getTok().getString();
+NameLoc = Parser.getTok().getLoc();
+Parser.Lex();
+  }
+}
 break;
   }
 
@@ -4370,10 +4389,16 @@
 
   MCInst Inst;
 
-  // If VEX3 encoding is forced, we need to pass the USE_VEX3 flag to the
-  // encoder.
-  if (ForcedVEXEncoding == VEXEncoding_VEX3)
+  // If VEX/EVEX encoding is forced, we need to pass the USE_* flag to the
+  // encoder and printer.
+  if (ForcedVEXEncoding == VEXEncoding_VEX)
+Prefixes |= X86::IP_USE_VEX;
+  else if (ForcedVEXEncoding == VEXEncoding_VEX2)
+Prefixes |= X86::IP_USE_VEX2;
+  else if (ForcedVEXEncoding == VEXEncoding_VEX3)
 Prefixes |= X86::IP_USE_VEX3;
+  else if (ForcedVEXEncoding == VEXEncoding_EVEX)
+Prefixes |= X86::IP_USE_EVEX;
 
   // Set encoded flags for {disp8} and {disp32}.
   if (ForcedDispEncoding == DispEncoding_Disp8)
Index: clang/test/CodeGen/X86/ms-inline-asm-prefix.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/ms-inline-asm-prefix.c
@@ -0,0 +1,14 @@
+// REQUIRES: x86-registered-target
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-windows-msvc -target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl -fasm-blocks -mllvm -x86-asm-syntax=intel -S -emit-llvm -o -  | FileCheck %s -check-prefix=INTEL
+// RUN:%clang_cc1 %s -ferror-limit 0 -triple=x86_64-pc-windows-msvc -target-feature +avx512f -target-feature +avx2 -target-feature +avx512vl -fasm-blocks -mllvm -x86-asm-syntax=att -S -emit-llvm -o -  | FileCheck %s -check-prefix=ATT
+
+void check_inline_prefix(void) {
+  __asm {
+// INTEL: call void asm sideeffect inteldialect "{vex} vcvtps2pd xmm0, xmm1\0A\09{vex2} vcvtps2pd xmm0, xmm1\0A\09{vex3} vcvtps2pd xmm0, xmm1\0A\09{evex} vcvtps2pd xmm0, xmm1", "~{xmm0},~{dirflag},~{fpsr},~{flags}"()
+// ATT: call void asm sideeffect inteldialect "{vex} vcvtps2pd xmm0, xmm1\0A\09{vex2} vcvtps2pd xmm0, xmm1\0A\09{vex3} vcvtps2pd xmm0, xmm1\0A\09{evex} vcvtps2pd xmm0, xmm1", "~{xmm0},~{dirflag},~{fpsr},~{flags}"()
+vex vcvtps2pd xmm0, xmm1
+vex2 vcvtps2pd xmm0, xmm1
+vex3 vcvtps2pd xmm0, xmm1
+evex vcvtps2pd xmm0, xmm1
+  }
+}
Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -791,7 +791,27 @@
 /// Assemble final IR asm string (MS-style).
 std::string MSAsmStmt::generateAsmString(const ASTContext &C) const {
   // FIXME: This needs to be translated into the IR string representation.
-  return std::string(AsmStr);
+  SmallVector Pieces;
+  AsmStr.split(Pieces, "\n\t");
+  std::string MSAsmString;
+  for (size_t I = 0, E = Pieces.size(); I < E; ++I) {
+StringRef Instruction = Pieces[I];
+// For vex/vex2/vex3/evex masm style prefix, convert it to att style
+// since we don't support masm style prefix in backend.
+if (Instruction.startswith("vex "))
+  MSAsmString += '{' + Instruction.substr(0, 3).str() + '}' +
+ Instruction.substr(3).str();
+else if (Instruction.startswith("vex2 ") ||
+ Instruction.startswith("vex3 ") || Instruction.startswith("evex "))
+  MSAsmString += '{' + Instruction.substr(0, 4).str() + '}' +
+ Instruction.substr(4).str();
+else
+  MSAsmString += Instruction.str();
+// If this is not the last instruction, adding back the '\n\t'.
+if (I < E - 1)
+  MSAsmString += "\n\t";
+  }
+  return MSAsmS

[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 306615.
kadircet marked 6 inline comments as done.
kadircet added a comment.

- Internalize synchronization of indexstorage rather than using Memoize


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90750/new/

https://reviews.llvm.org/D90750

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/ProjectAware.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp

Index: clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ProjectAwareIndexTests.cpp
@@ -0,0 +1,86 @@
+//===-- ProjectAwareIndexTests.cpp  ---*- C++ -*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Config.h"
+#include "TestIndex.h"
+#include "index/Index.h"
+#include "index/MemIndex.h"
+#include "index/ProjectAware.h"
+#include "index/Ref.h"
+#include "index/Relation.h"
+#include "support/Context.h"
+#include "support/Threading.h"
+#include "llvm/ADT/StringRef.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+using testing::ElementsAre;
+using testing::IsEmpty;
+
+std::unique_ptr createIndex() {
+  std::vector Symbols = {symbol("1")};
+  return std::make_unique(std::move(Symbols), RefSlab(),
+RelationSlab());
+}
+
+TEST(ProjectAware, Test) {
+  IndexFactory Gen = [](const Config::ExternalIndexSpec &, AsyncTaskRunner &) {
+return createIndex();
+  };
+
+  auto Idx = createProjectAwareIndex(std::move(Gen));
+  FuzzyFindRequest Req;
+  Req.Query = "1";
+  Req.AnyScope = true;
+
+  EXPECT_THAT(match(*Idx, Req), IsEmpty());
+
+  Config C;
+  C.Index.External.emplace();
+  C.Index.External->Location = "test";
+  WithContextValue With(Config::Key, std::move(C));
+  EXPECT_THAT(match(*Idx, Req), ElementsAre("1"));
+  return;
+}
+
+TEST(ProjectAware, CreatedOnce) {
+  unsigned InvocationCount = 0;
+  IndexFactory Gen = [&](const Config::ExternalIndexSpec &, AsyncTaskRunner &) {
+++InvocationCount;
+return createIndex();
+  };
+
+  auto Idx = createProjectAwareIndex(std::move(Gen));
+  // No invocation at start.
+  EXPECT_EQ(InvocationCount, 0U);
+  FuzzyFindRequest Req;
+  Req.Query = "1";
+  Req.AnyScope = true;
+
+  // Cannot invoke without proper config.
+  match(*Idx, Req);
+  EXPECT_EQ(InvocationCount, 0U);
+
+  Config C;
+  C.Index.External.emplace();
+  C.Index.External->Location = "test";
+  WithContextValue With(Config::Key, std::move(C));
+  match(*Idx, Req);
+  // Now it should be created.
+  EXPECT_EQ(InvocationCount, 1U);
+  match(*Idx, Req);
+  // It is cached afterwards.
+  EXPECT_EQ(InvocationCount, 1U);
+  return;
+}
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -73,6 +73,7 @@
   PathMappingTests.cpp
   PreambleTests.cpp
   PrintASTTests.cpp
+  ProjectAwareIndexTests.cpp
   QualityTests.cpp
   RenameTests.cpp
   RIFFTests.cpp
Index: clang-tools-extra/clangd/index/ProjectAware.h
===
--- /dev/null
+++ clang-tools-extra/clangd/index/ProjectAware.h
@@ -0,0 +1,34 @@
+//===--- ProjectAware.h --*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_PROJECT_AWARE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_PROJECT_AWARE_H
+
+#include "Config.h"
+#include "index/Index.h"
+#include "support/Threading.h"
+#include 
+#include 
+namespace clang {
+namespace clangd {
+
+/// A functor to create an index for an external index specification. Functor
+/// should perform any high latency operation in a separate thread through
+/// AsyncTaskRunner.
+using IndexFactory = std::function(
+const Config::ExternalIndexSpec &, AsyncTaskRunner &)>;
+
+/// Returns an index that answers queries using external indices. IndexGenerator
+/// can be used to customize how to generate an index from an external source.
+/// The default implementation lo

[PATCH] D90751: [clangd] Use ProjectAwareIndex

2020-11-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 306621.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90751/new/

https://reviews.llvm.org/D90751

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -13,6 +13,9 @@
 #include "Protocol.h"
 #include "Transport.h"
 #include "index/Background.h"
+#include "index/Index.h"
+#include "index/Merge.h"
+#include "index/ProjectAware.h"
 #include "index/Serialization.h"
 #include "index/remote/Client.h"
 #include "refactor/Rename.h"
@@ -40,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef _WIN32
 #include 
@@ -726,6 +730,7 @@
 Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   Opts.CollectMainFileRefs = CollectMainFileRefs;
+  std::vector> IdxStack;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
   if (EnableIndex && !IndexFile.empty()) {
@@ -757,7 +762,15 @@
   }
 #endif
   Opts.BackgroundIndex = EnableBackgroundIndex;
-  Opts.StaticIndex = StaticIdx.get();
+  auto PAI = createProjectAwareIndex();
+  if (StaticIdx) {
+IdxStack.emplace_back(std::move(StaticIdx));
+IdxStack.emplace_back(
+std::make_unique(PAI.get(), IdxStack.back().get()));
+Opts.StaticIndex = IdxStack.back().get();
+  } else {
+Opts.StaticIndex = PAI.get();
+  }
   Opts.AsyncThreadsCount = WorkerThreadsCount;
   Opts.BuildRecoveryAST = RecoveryAST;
   Opts.PreserveRecoveryASTType = RecoveryASTType;


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -13,6 +13,9 @@
 #include "Protocol.h"
 #include "Transport.h"
 #include "index/Background.h"
+#include "index/Index.h"
+#include "index/Merge.h"
+#include "index/ProjectAware.h"
 #include "index/Serialization.h"
 #include "index/remote/Client.h"
 #include "refactor/Rename.h"
@@ -40,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifndef _WIN32
 #include 
@@ -726,6 +730,7 @@
 Opts.ResourceDir = ResourceDir;
   Opts.BuildDynamicSymbolIndex = EnableIndex;
   Opts.CollectMainFileRefs = CollectMainFileRefs;
+  std::vector> IdxStack;
   std::unique_ptr StaticIdx;
   std::future AsyncIndexLoad; // Block exit while loading the index.
   if (EnableIndex && !IndexFile.empty()) {
@@ -757,7 +762,15 @@
   }
 #endif
   Opts.BackgroundIndex = EnableBackgroundIndex;
-  Opts.StaticIndex = StaticIdx.get();
+  auto PAI = createProjectAwareIndex();
+  if (StaticIdx) {
+IdxStack.emplace_back(std::move(StaticIdx));
+IdxStack.emplace_back(
+std::make_unique(PAI.get(), IdxStack.back().get()));
+Opts.StaticIndex = IdxStack.back().get();
+  } else {
+Opts.StaticIndex = PAI.get();
+  }
   Opts.AsyncThreadsCount = WorkerThreadsCount;
   Opts.BuildRecoveryAST = RecoveryAST;
   Opts.PreserveRecoveryASTType = RecoveryASTType;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] da14ae2 - [clangd] NFC: Reorder headers in tests accordig to Clang-Tidy

2020-11-20 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2020-11-20T10:38:41+01:00
New Revision: da14ae23a54783a4bb2e20651af434530510e704

URL: 
https://github.com/llvm/llvm-project/commit/da14ae23a54783a4bb2e20651af434530510e704
DIFF: 
https://github.com/llvm/llvm-project/commit/da14ae23a54783a4bb2e20651af434530510e704.diff

LOG: [clangd] NFC: Reorder headers in tests accordig to Clang-Tidy

Added: 


Modified: 
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 876262a463a5..68a6a666a895 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -17,9 +17,9 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include 
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
-#include 
 
 namespace clang {
 namespace clangd {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91605: [sanitizers] Implement GetTls on Solaris

2020-11-20 Thread Rainer Orth via Phabricator via cfe-commits
ro added inline comments.



Comment at: clang/tools/driver/CMakeLists.txt:123
+
+check_linker_flag("-Wl,-z,relax=transtls" LINKER_SUPPORTS_Z_RELAX_TRANSTLS)

MaskRay wrote:
> ro wrote:
> > MaskRay wrote:
> > > GNU ld reports a warning instead of an error when an unknown `-z` is 
> > > seen. The warning remains a warning even with `--fatal-warnings`.
> > > GNU ld reports a warning instead of an error when an unknown `-z` is 
> > > seen. The warning remains a warning even with `--fatal-warnings`.
> > 
> > Thanks for reminding me about that misfeature of GNU `ld`.  I guess 
> > `check_linker_flags` needs to be updated to handle that.
> > In the case at hand, it won't matter either way: the flag is only passed to 
> > `ld`, which on Solaris is guaranteed to be the native linker.  Once (if at 
> > all) I get around to completing D85309, I can deal with that.  For now, 
> > other targets won't see linker warnings about this flag, other than when 
> > the flag is used at build time.
> OK. Then I guess you can condition this when the OS is Solaris?
> OK. Then I guess you can condition this when the OS is Solaris?

I fear not: `LINKER_SUPPORTS_Z_RELAX_TRANSTLS` is tested inside an `if` in 
`Solaris.cpp`: this code is also compiled on non-Solaris hosts.  Why are you 
worried about the definition being always present?



Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:455-520
+#if SANITIZER_SOLARIS
+// dlpi_tls_modid is only available since Solaris 11.4 SRU 10.  Use
+// dlinfo(RTLD_DI_LINKMAP) instead which works on both Solaris 11.3 and 
Illumos.
+
+// Beginning of declaration from OpenSolaris/Illumos
+// $SRC/cmd/sgs/include/rtld.h.
+typedef struct {

vitalybuka wrote:
> ro wrote:
> > vitalybuka wrote:
> > > can this go into sanitizer_platform_limits_solaris.h ?
> > > 
> > I don't think it belongs there: AFAICS that header is for types used by the 
> > interceptors.
> > 
> > I've been following what other targets do here, like declaring internal 
> > types and functions, and adding helpers like `GetSizeFromHdr`.  It would 
> > only be confusing if Solaris were treated differently.  It certainly helped 
> > me a lot being able to see what other targets do in once place.
> Chech xdl_iterate_phdr and sanitizer_freebsd.h
> I think it's better to move this into some sanitizer_solaris.h/cpp as well
> Chech xdl_iterate_phdr and sanitizer_freebsd.h
> I think it's better to move this into some sanitizer_solaris.h/cpp as well

Nice: this removes the clutter in common code.

What about `GetSizeFromHdr`, though?  It still lives in 
`sanitizer_linux_libcdep.cpp` on FreeBSD.  I feel like it's better to keep the 
two ports similar in this respect.



Comment at: compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp:461
+// $SRC/cmd/sgs/include/rtld.h.
+typedef struct {
+  Link_map rt_public;

MaskRay wrote:
> In C++ you can just write `struct  { ... }`, not need for typedef
> In C++ you can just write `struct  { ... }`, not need for typedef

Thanks for the reminder: I keep forgetting about this, being primarily a C guy.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91605/new/

https://reviews.llvm.org/D91605

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91806: [SVE] Remove warnings from release notes example on SVE ACLE.

2020-11-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 306626.
fpetrogalli added a comment.

I updated the RUN lines of the `.ll` test to prevent the failure at 
https://reviews.llvm.org/harbormaster/unit/view/196899/.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91806/new/

https://reviews.llvm.org/D91806

Files:
  clang/test/CodeGen/aarch64-sve-acle-rel-note.c
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  
llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll

Index: llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
@@ -0,0 +1,42 @@
+; RUN: opt -mtriple aarch64-gnu-linux -mattr=+sve -instcombine -S < %s 2>%t | FileCheck %s
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; If this check fails please read
+; clang/test/CodeGen/aarch64-sve-intrinsics/README for instructions on
+; how to resolve it.
+
+; WARN-NOT: warning
+
+; CHECK-LABEL: @debug_local_scalable(
+define  @debug_local_scalable( %tostore) {
+  %vx = alloca , align 16
+  call void @llvm.dbg.declare(metadata * %vx, metadata !5, metadata !DIExpression()), !dbg !15
+  store  %tostore, * %vx, align 16
+  %ret = call  @f(* %vx)
+  ret  %ret
+}
+
+declare  @f(*)
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp/")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !DILocalVariable(name: "vx", scope: !6, file: !7, line: 26, type: !8)
+!6 = distinct !DISubprogram(name: "debug_local_scalable", scope: null, file: !1, line: 25, scopeLine: 25, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
+!7 = !DIFile(filename: "test.c", directory: "/tmp/")
+!8 = !DIDerivedType(tag: DW_TAG_typedef, name: "svfloat64_t", file: !9, line: 56, baseType: !10)
+!9 = !DIFile(filename: "arm_sve.h", directory: "/tmp/")
+!10 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVFloat64_t", file: !1, baseType: !11)
+!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, flags: DIFlagVector, elements: !13)
+!12 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
+!13 = !{!14}
+!14 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
+!15 = !DILocation(line: 26, column: 15, scope: !6)
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1368,16 +1368,16 @@
 /// least n bits.
 static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
   const DataLayout &DL = DII->getModule()->getDataLayout();
-  uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
-  if (auto FragmentSize = DII->getFragmentSizeInBits())
-return ValueSize >= *FragmentSize;
+  TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
+  if (Optional FragmentSize = DII->getFragmentSizeInBits())
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
   // We can't always calculate the size of the DI variable (e.g. if it is a
   // VLA). Try to use the size of the alloca that the dbg intrinsic describes
   // intead.
   if (DII->isAddressOfVariable())
 if (auto *AI = dyn_cast_or_null(DII->getVariableLocation()))
-  if (auto FragmentSize = AI->getAllocationSizeInBits(DL))
-return ValueSize >= *FragmentSize;
+  if (Optional FragmentSize = AI->getAllocationSizeInBits(DL))
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
   // Could not determine size of variable. Conservatively return false.
   return false;
 }
Index: llvm/lib/Transforms/Utils/Debugify.cpp
===
--- llvm/lib/Transforms/Utils/Debugify.cpp
+++ llvm/lib/Transforms/Utils/Debugify.cpp
@@ -44,8 +44,9 @@
 
 raw_ostream &dbg() { return Quiet ? nulls() : errs(); }
 
-uint64_t getAllocSizeInBits(Module &M, Type *Ty) {
-  return Ty->isSized() ? M.getDataLayout().getTypeAllocSizeInBits(Ty) : 0;
+TypeSize getAllocSizeInBits(Module &M, Type *Ty) {
+  return Ty->isSized() ? M.getDataLayout().getTypeAll

[PATCH] D91186: [clangd] Add documentation for building and testing clangd

2020-11-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 306633.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Mention assertions and ninja


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91186/new/

https://reviews.llvm.org/D91186

Files:
  clang-tools-extra/clangd/README.md


Index: clang-tools-extra/clangd/README.md
===
--- clang-tools-extra/clangd/README.md
+++ clang-tools-extra/clangd/README.md
@@ -17,3 +17,22 @@
   channel](https://discord.gg/xS7Z362).
 - user questions and feature requests can be asked in the clangd topic on [LLVM
   Discussion Forums](https://llvm.discourse.group/c/llvm-project/clangd/34)
+
+### Building and testing clangd
+
+For a minimal setup on building clangd:
+- Clone the LLVM repo to `$LLVM_ROOT`.
+- Create a build directory, for example at `$LLVM_ROOT/build`.
+- Inside the build directory run: `cmake $LLVM_ROOT/llvm/
+  -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"`.
+
+  - We suggest building in `Release` mode as building DEBUG binaries requires
+considerably more resources. You can check
+[Building LLVM with CMake documentation](https://llvm.org/docs/CMake.html)
+for more details about cmake flags.
+  - In addition to that using `Ninja` as a generator rather than default `make`
+is preferred. To do that consider passing `-G Ninja` to cmake invocation.
+  - Finally, you can turn on assertions via `-DLLVM_ENABLE_ASSERTS=On`.
+
+- Afterwards you can build clangd with `cmake --build $LLVM_ROOT/build --target
+  clangd`, similarly run tests by changing target to `check-clangd`.


Index: clang-tools-extra/clangd/README.md
===
--- clang-tools-extra/clangd/README.md
+++ clang-tools-extra/clangd/README.md
@@ -17,3 +17,22 @@
   channel](https://discord.gg/xS7Z362).
 - user questions and feature requests can be asked in the clangd topic on [LLVM
   Discussion Forums](https://llvm.discourse.group/c/llvm-project/clangd/34)
+
+### Building and testing clangd
+
+For a minimal setup on building clangd:
+- Clone the LLVM repo to `$LLVM_ROOT`.
+- Create a build directory, for example at `$LLVM_ROOT/build`.
+- Inside the build directory run: `cmake $LLVM_ROOT/llvm/
+  -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"`.
+
+  - We suggest building in `Release` mode as building DEBUG binaries requires
+considerably more resources. You can check
+[Building LLVM with CMake documentation](https://llvm.org/docs/CMake.html)
+for more details about cmake flags.
+  - In addition to that using `Ninja` as a generator rather than default `make`
+is preferred. To do that consider passing `-G Ninja` to cmake invocation.
+  - Finally, you can turn on assertions via `-DLLVM_ENABLE_ASSERTS=On`.
+
+- Afterwards you can build clangd with `cmake --build $LLVM_ROOT/build --target
+  clangd`, similarly run tests by changing target to `check-clangd`.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91186: [clangd] Add documentation for building and testing clangd

2020-11-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/README.md:26
+- Create a build directory, for example at `$LLVM_ROOT/build`.
+- Inside the build directory run: `cmake $LLVM_ROOT/llvm/
+  -DCMAKE_BUILD_TYPE=RELEASE -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra"`.

sammccall wrote:
> this will work, though won't it use make by default with no parallelism?
> 
> If we're recommending more flags, i'd suggest -DLLVM_ENABLE_ASSERTS=On, and 
> -G Ninja...
i wanted to keep it to a bare minimum, hence no mentions of ninja and asserts. 
i am adding a paragraph below to suggest adding those.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91186/new/

https://reviews.llvm.org/D91186

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91639: Add documentation illustrating use of IgnoreUnlessSpelledInSource

2020-11-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire added inline comments.



Comment at: clang/docs/LibASTMatchersReference.html:91-94
+This mode is hard to use correctly and
+requires more development iteration because it means
+that the user must write AST Matchers to explicitly traverse or ignore nodes
+which are not visible.

aaron.ballman wrote:
> I was trying to reword this to avoid making a judgmental statement that the 
> default mode is hard to use correctly -- I'd strike this part of the 
> paragraph. WDYT?
Oops, that's what I was trying to do, but accidentally left the previous stuff 
behind. Gone now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91639/new/

https://reviews.llvm.org/D91639

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91639: Add documentation illustrating use of IgnoreUnlessSpelledInSource

2020-11-20 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 306634.
steveire added a comment.

Update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91639/new/

https://reviews.llvm.org/D91639

Files:
  clang/docs/LibASTMatchersReference.html

Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -17,6 +17,12 @@
   color: blue;
   cursor: pointer;
 }
+span.mono { font-family: monospace; }
+
+.traverse_compare, .traverse_compare td, .traverse_compare th {
+  border: 1px solid black;
+  border-collapse: collapse;
+}
 
 

[PATCH] D91104: APINotes: add property models for YAML attributes

2020-11-20 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

Thanks, looks good to me!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91104/new/

https://reviews.llvm.org/D91104

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91806: [SVE] Remove warnings from release notes example on SVE ACLE.

2020-11-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

FYI: I am trying to figure out this failure that does not appear on my machine: 
https://reviews.llvm.org/harbormaster/unit/view/196974/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91806/new/

https://reviews.llvm.org/D91806

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90750: [clangd] Introduce ProjectAwareIndex

2020-11-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/Config.h:95
+  static inline ExternalIndexSpec getEmptyKey() {
+static ExternalIndexSpec E{ExternalIndexSpec::File, "", ""};
+return E;

(nit: static isn't saving anything here I think: cost of constructing == cost 
of copying)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90750/new/

https://reviews.llvm.org/D90750

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91806: [SVE] Remove warnings from release notes example on SVE ACLE.

2020-11-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 306643.
fpetrogalli added a comment.

This last change is trying to remove the failure at 
https://reviews.llvm.org/harbormaster/unit/view/196974/
I haven’t been able to reproduce such failure on my dev machine, so I just 
changed the RUN lines in the test (added `-c`, used `2>%t`) to see if the bot 
is going to be happy with the new invocation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91806/new/

https://reviews.llvm.org/D91806

Files:
  clang/test/CodeGen/aarch64-sve-acle-rel-note.c
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  
llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll

Index: llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
@@ -0,0 +1,42 @@
+; RUN: opt -mtriple aarch64-gnu-linux -mattr=+sve -instcombine -S < %s 2>%t | FileCheck %s
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; If this check fails please read
+; clang/test/CodeGen/aarch64-sve-intrinsics/README for instructions on
+; how to resolve it.
+
+; WARN-NOT: warning
+
+; CHECK-LABEL: @debug_local_scalable(
+define  @debug_local_scalable( %tostore) {
+  %vx = alloca , align 16
+  call void @llvm.dbg.declare(metadata * %vx, metadata !5, metadata !DIExpression()), !dbg !15
+  store  %tostore, * %vx, align 16
+  %ret = call  @f(* %vx)
+  ret  %ret
+}
+
+declare  @f(*)
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp/")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !DILocalVariable(name: "vx", scope: !6, file: !7, line: 26, type: !8)
+!6 = distinct !DISubprogram(name: "debug_local_scalable", scope: null, file: !1, line: 25, scopeLine: 25, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
+!7 = !DIFile(filename: "test.c", directory: "/tmp/")
+!8 = !DIDerivedType(tag: DW_TAG_typedef, name: "svfloat64_t", file: !9, line: 56, baseType: !10)
+!9 = !DIFile(filename: "arm_sve.h", directory: "/tmp/")
+!10 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVFloat64_t", file: !1, baseType: !11)
+!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, flags: DIFlagVector, elements: !13)
+!12 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
+!13 = !{!14}
+!14 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
+!15 = !DILocation(line: 26, column: 15, scope: !6)
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1368,16 +1368,16 @@
 /// least n bits.
 static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
   const DataLayout &DL = DII->getModule()->getDataLayout();
-  uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
-  if (auto FragmentSize = DII->getFragmentSizeInBits())
-return ValueSize >= *FragmentSize;
+  TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
+  if (Optional FragmentSize = DII->getFragmentSizeInBits())
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
   // We can't always calculate the size of the DI variable (e.g. if it is a
   // VLA). Try to use the size of the alloca that the dbg intrinsic describes
   // intead.
   if (DII->isAddressOfVariable())
 if (auto *AI = dyn_cast_or_null(DII->getVariableLocation()))
-  if (auto FragmentSize = AI->getAllocationSizeInBits(DL))
-return ValueSize >= *FragmentSize;
+  if (Optional FragmentSize = AI->getAllocationSizeInBits(DL))
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
   // Could not determine size of variable. Conservatively return false.
   return false;
 }
Index: llvm/lib/Transforms/Utils/Debugify.cpp
===
--- llvm/lib/Transforms/Utils/Debugify.cpp
+++ llvm/lib/Transforms/Utils/Debugify.cpp
@@ -44,8 +44,9 @@
 
 raw_ostream &dbg() { return Quiet ? nulls() : errs(); }
 
-uint64_t getAllocSizeInBits(Module &M, Type *Ty) 

[clang-tools-extra] 44c96be - Fix MSVC "not all control paths return a value" warnings. NFCI.

2020-11-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-20T11:41:20Z
New Revision: 44c96becc9734fa23b7f38688a8f5c72e1f2e891

URL: 
https://github.com/llvm/llvm-project/commit/44c96becc9734fa23b7f38688a8f5c72e1f2e891
DIFF: 
https://github.com/llvm/llvm-project/commit/44c96becc9734fa23b7f38688a8f5c72e1f2e891.diff

LOG: Fix MSVC "not all control paths return a value" warnings. NFCI.

Added: 


Modified: 
clang-tools-extra/clangd/DumpAST.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index f9371ecf6374..9ea17e876de7 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -145,6 +145,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_ARGUMENT_KIND(TemplateExpansion);
 #undef TEMPLATE_ARGUMENT_KIND
 }
+llvm_unreachable("Unhandled ArgKind enum");
   }
   std::string getKind(const NestedNameSpecifierLoc &NNSL) {
 assert(NNSL.getNestedNameSpecifier());
@@ -161,6 +162,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   NNS_KIND(NamespaceAlias);
 #undef NNS_KIND
 }
+llvm_unreachable("Unhandled SpecifierKind enum");
   }
   std::string getKind(const CXXCtorInitializer *CCI) {
 if (CCI->isBaseInitializer())
@@ -185,6 +187,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_KIND(SubstTemplateTemplateParmPack);
 #undef TEMPLATE_KIND
 }
+llvm_unreachable("Unhandled NameKind enum");
   }
   std::string getKind(const Attr *A) {
 switch (A->getKind()) {
@@ -194,6 +197,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
 #include "clang/Basic/AttrList.inc"
 #undef ATTR
 }
+llvm_unreachable("Unhandled attr::Kind enum");
   }
   std::string getKind(const CXXBaseSpecifier &CBS) {
 // There aren't really any variants of CXXBaseSpecifier.



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91696: [AArch64][SVE] Allow lax conversion between VLATs and GNU vectors

2020-11-20 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes accepted this revision.
c-rhodes added a comment.

In D91696#2405082 , @joechrisellis 
wrote:

> Address @c-rhodes's comments regarding lax conversion when 
> __ARM_FEATURE_SVE_BITS != N for GNU vectors.

Cheers, LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91696/new/

https://reviews.llvm.org/D91696

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91859: [clangd] Fix shared-lib builds

2020-11-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added reviewers: sammccall, kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, arphaman, mgorny.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91859

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt


Index: clang-tools-extra/clangd/index/remote/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -3,6 +3,10 @@
   generate_protos(RemoteIndexServiceProto "Service.proto"
 DEPENDS "Index.proto"
 GRPC)
+  target_link_libraries(RemoteIndexServiceProto
+PRIVATE
+RemoteIndexProto
+)
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 
@@ -20,6 +24,8 @@
 clangdRemoteMarshalling
 protobuf
 grpc++
+clangBasic
+clangDaemon
 clangdSupport
 
 DEPENDS


Index: clang-tools-extra/clangd/index/remote/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -3,6 +3,10 @@
   generate_protos(RemoteIndexServiceProto "Service.proto"
 DEPENDS "Index.proto"
 GRPC)
+  target_link_libraries(RemoteIndexServiceProto
+PRIVATE
+RemoteIndexProto
+)
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 
@@ -20,6 +24,8 @@
 clangdRemoteMarshalling
 protobuf
 grpc++
+clangBasic
+clangDaemon
 clangdSupport
 
 DEPENDS
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91860: [clangd] Move remote-index dependency from clangDaemon to ClangdMain

2020-11-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, mgorny.
Herald added a project: clang.
kadircet requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This is a hack to prevent cyclic dependency between clangDaemon and
remote-index-marshalling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91860

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/ProjectAware.cpp
  clang-tools-extra/clangd/index/ProjectAware.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -555,6 +555,29 @@
 const char TestScheme::TestDir[] = "/clangd-test";
 #endif
 
+// We define this function here as depending on clangdRemoteIndex within
+// clangDaemon introduces a cyclic dependency.
+std::unique_ptr
+projectAwareIndexFactory(const Config::ExternalIndexSpec &External,
+ AsyncTaskRunner &Tasks) {
+  switch (External.Kind) {
+  case Config::ExternalIndexSpec::Server:
+log("Associating {0} with remote index at {1}.", External.MountPoint,
+External.Location);
+return remote::getClient(External.Location, External.MountPoint);
+  case Config::ExternalIndexSpec::File:
+log("Associating {0} with monolithic index at {1}.", External.MountPoint,
+External.Location);
+auto NewIndex = std::make_unique(std::make_unique());
+Tasks.runAsync("Load-index:" + External.Location,
+   [File = External.Location, PlaceHolder = NewIndex.get()] {
+ if (auto Idx = loadIndex(File, /*UseDex=*/true))
+   PlaceHolder->reset(std::move(Idx));
+   });
+return std::move(NewIndex);
+  }
+  llvm_unreachable("Invalid ExternalIndexKind.");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
@@ -762,7 +785,7 @@
   }
 #endif
   Opts.BackgroundIndex = EnableBackgroundIndex;
-  auto PAI = createProjectAwareIndex();
+  auto PAI = createProjectAwareIndex(projectAwareIndexFactory);
   if (StaticIdx) {
 IdxStack.emplace_back(std::move(StaticIdx));
 IdxStack.emplace_back(
Index: clang-tools-extra/clangd/index/ProjectAware.h
===
--- clang-tools-extra/clangd/index/ProjectAware.h
+++ clang-tools-extra/clangd/index/ProjectAware.h
@@ -25,9 +25,7 @@
 
 /// Returns an index that answers queries using external indices. IndexGenerator
 /// can be used to customize how to generate an index from an external source.
-/// The default implementation loads the index asynchronously on the
-/// AsyncTaskRunner. The index will appear empty until loaded.
-std::unique_ptr createProjectAwareIndex(IndexFactory = nullptr);
+std::unique_ptr createProjectAwareIndex(IndexFactory);
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/index/ProjectAware.cpp
===
--- clang-tools-extra/clangd/index/ProjectAware.cpp
+++ clang-tools-extra/clangd/index/ProjectAware.cpp
@@ -15,7 +15,6 @@
 #include "index/Serialization.h"
 #include "index/Symbol.h"
 #include "index/SymbolID.h"
-#include "index/remote/Client.h"
 #include "support/Logger.h"
 #include "support/Threading.h"
 #include "support/Trace.h"
@@ -124,33 +123,11 @@
 Entry.first->getSecond() = Gen(External, Tasks);
   return Entry.first->second.get();
 }
-
-std::unique_ptr
-defaultFactory(const Config::ExternalIndexSpec &External,
-   AsyncTaskRunner &Tasks) {
-  switch (External.Kind) {
-  case Config::ExternalIndexSpec::Server:
-log("Associating {0} with remote index at {1}.", External.MountPoint,
-External.Location);
-return remote::getClient(External.Location, External.MountPoint);
-  case Config::ExternalIndexSpec::File:
-log("Associating {0} with monolithic index at {1}.", External.MountPoint,
-External.Location);
-auto NewIndex = std::make_unique(std::make_unique());
-Tasks.runAsync("Load-index:" + External.Location,
-   [File = External.Location, PlaceHolder = NewIndex.get()] {
- if (auto Idx = loadIndex(File, /*UseDex=*/true))
-   PlaceHolder->reset(std::move(Idx));
-   });
-return std::move(NewIndex);
-  }
-  llvm_unreachable("Invalid ExternalIndexKind.");
-}
 } // namespace
 
 std::unique_ptr createProjectAwareIndex(IndexFactory Gen) {
-  return std::make_unique(Gen ? std::move(Gen)
- : defaultFactory);
+  assert(Gen);
+  return std::make_unique(std::move(Gen));
 }
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/CMakeLists.txt
===

[clang] 2f1fe9a - [clang][CodeGen] Move riscv specific tests to RISCV subtarget folder

2020-11-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-20T12:03:28Z
New Revision: 2f1fe9a3a60d6f18998c5f3b7e643d4cbaa4e65d

URL: 
https://github.com/llvm/llvm-project/commit/2f1fe9a3a60d6f18998c5f3b7e643d4cbaa4e65d
DIFF: 
https://github.com/llvm/llvm-project/commit/2f1fe9a3a60d6f18998c5f3b7e643d4cbaa4e65d.diff

LOG: [clang][CodeGen] Move riscv specific tests to RISCV subtarget folder

Minor cleanup to move more target specific tests out of the root codegen test 
folder

Added: 
clang/test/CodeGen/RISCV/riscv-atomics.c
clang/test/CodeGen/RISCV/riscv-inline-asm.c
clang/test/CodeGen/RISCV/riscv-metadata.c
clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c
clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32f-abi.c
clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
clang/test/CodeGen/RISCV/riscv64-lp64f-lp64d-abi.c

Modified: 


Removed: 
clang/test/CodeGen/riscv-atomics.c
clang/test/CodeGen/riscv-inline-asm.c
clang/test/CodeGen/riscv-metadata.c
clang/test/CodeGen/riscv-sdata-module-flag.c
clang/test/CodeGen/riscv32-ilp32-abi.c
clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c
clang/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c
clang/test/CodeGen/riscv32-ilp32d-abi.c
clang/test/CodeGen/riscv32-ilp32f-abi.c
clang/test/CodeGen/riscv32-ilp32f-ilp32d-abi.c
clang/test/CodeGen/riscv64-lp64-abi.c
clang/test/CodeGen/riscv64-lp64-lp64f-abi.c
clang/test/CodeGen/riscv64-lp64-lp64f-lp64d-abi.c
clang/test/CodeGen/riscv64-lp64d-abi.c
clang/test/CodeGen/riscv64-lp64f-lp64d-abi.c



diff  --git a/clang/test/CodeGen/riscv-atomics.c 
b/clang/test/CodeGen/RISCV/riscv-atomics.c
similarity index 100%
rename from clang/test/CodeGen/riscv-atomics.c
rename to clang/test/CodeGen/RISCV/riscv-atomics.c

diff  --git a/clang/test/CodeGen/riscv-inline-asm.c 
b/clang/test/CodeGen/RISCV/riscv-inline-asm.c
similarity index 100%
rename from clang/test/CodeGen/riscv-inline-asm.c
rename to clang/test/CodeGen/RISCV/riscv-inline-asm.c

diff  --git a/clang/test/CodeGen/riscv-metadata.c 
b/clang/test/CodeGen/RISCV/riscv-metadata.c
similarity index 100%
rename from clang/test/CodeGen/riscv-metadata.c
rename to clang/test/CodeGen/RISCV/riscv-metadata.c

diff  --git a/clang/test/CodeGen/riscv-sdata-module-flag.c 
b/clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c
similarity index 100%
rename from clang/test/CodeGen/riscv-sdata-module-flag.c
rename to clang/test/CodeGen/RISCV/riscv-sdata-module-flag.c

diff  --git a/clang/test/CodeGen/riscv32-ilp32-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
similarity index 100%
rename from clang/test/CodeGen/riscv32-ilp32-abi.c
rename to clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c

diff  --git a/clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c
similarity index 100%
rename from clang/test/CodeGen/riscv32-ilp32-ilp32f-abi.c
rename to clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c

diff  --git a/clang/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
similarity index 100%
rename from clang/test/CodeGen/riscv32-ilp32-ilp32f-ilp32d-abi.c
rename to clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c

diff  --git a/clang/test/CodeGen/riscv32-ilp32d-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
similarity index 100%
rename from clang/test/CodeGen/riscv32-ilp32d-abi.c
rename to clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c

diff  --git a/clang/test/CodeGen/riscv32-ilp32f-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32f-abi.c
similarity index 100%
rename from clang/test/CodeGen/riscv32-ilp32f-abi.c
rename to clang/test/CodeGen/RISCV/riscv32-ilp32f-abi.c

diff  --git a/clang/test/CodeGen/riscv32-ilp32f-ilp32d-abi.c 
b/clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
similarity index 100%
rename from clang/test/CodeGen/riscv32-ilp32f-ilp32d-abi.c
rename to clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c

diff  --git a/clang/test/CodeGen/riscv64-lp64-abi.c 
b/clang/test/CodeGen/RISCV/riscv64-lp64-abi.c
similarity index 100%
rename from clang/test/CodeGen/riscv64-lp64-abi.c
rename to clang/test/CodeGen/RISCV/riscv64-lp64-abi.c

diff  --git a/clang/test/CodeGen/riscv64-lp64-lp64f-abi.c 
b/clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-abi.c
similarity index 100%
rename from clang/test/CodeGen/riscv64-lp64-lp64f-abi.c
rename to clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-abi.c

diff  --git a/clang/test/CodeGen/riscv64-lp64-lp64f

[clang] 822c5c5 - [clang][CodeGen] Move WebAssembly specific tests to WebAssembly subtarget folder

2020-11-20 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-11-20T12:03:28Z
New Revision: 822c5c50849a1f762c920d59baaa6a6edbb657ee

URL: 
https://github.com/llvm/llvm-project/commit/822c5c50849a1f762c920d59baaa6a6edbb657ee
DIFF: 
https://github.com/llvm/llvm-project/commit/822c5c50849a1f762c920d59baaa6a6edbb657ee.diff

LOG: [clang][CodeGen] Move WebAssembly specific tests to WebAssembly subtarget 
folder

Minor cleanup to move more target specific tests out of the root codegen test 
folder

Added: 
clang/test/CodeGen/WebAssembly/wasm-arguments.c
clang/test/CodeGen/WebAssembly/wasm-call-main.c
clang/test/CodeGen/WebAssembly/wasm-export-name.c
clang/test/CodeGen/WebAssembly/wasm-import-module.c
clang/test/CodeGen/WebAssembly/wasm-import-name.c
clang/test/CodeGen/WebAssembly/wasm-main.c
clang/test/CodeGen/WebAssembly/wasm-main_argc_argv.c
clang/test/CodeGen/WebAssembly/wasm-regparm.c
clang/test/CodeGen/WebAssembly/wasm-varargs.c

Modified: 


Removed: 
clang/test/CodeGen/wasm-arguments.c
clang/test/CodeGen/wasm-call-main.c
clang/test/CodeGen/wasm-export-name.c
clang/test/CodeGen/wasm-import-module.c
clang/test/CodeGen/wasm-import-name.c
clang/test/CodeGen/wasm-main.c
clang/test/CodeGen/wasm-main_argc_argv.c
clang/test/CodeGen/wasm-regparm.c
clang/test/CodeGen/wasm-varargs.c



diff  --git a/clang/test/CodeGen/wasm-arguments.c 
b/clang/test/CodeGen/WebAssembly/wasm-arguments.c
similarity index 100%
rename from clang/test/CodeGen/wasm-arguments.c
rename to clang/test/CodeGen/WebAssembly/wasm-arguments.c

diff  --git a/clang/test/CodeGen/wasm-call-main.c 
b/clang/test/CodeGen/WebAssembly/wasm-call-main.c
similarity index 100%
rename from clang/test/CodeGen/wasm-call-main.c
rename to clang/test/CodeGen/WebAssembly/wasm-call-main.c

diff  --git a/clang/test/CodeGen/wasm-export-name.c 
b/clang/test/CodeGen/WebAssembly/wasm-export-name.c
similarity index 100%
rename from clang/test/CodeGen/wasm-export-name.c
rename to clang/test/CodeGen/WebAssembly/wasm-export-name.c

diff  --git a/clang/test/CodeGen/wasm-import-module.c 
b/clang/test/CodeGen/WebAssembly/wasm-import-module.c
similarity index 100%
rename from clang/test/CodeGen/wasm-import-module.c
rename to clang/test/CodeGen/WebAssembly/wasm-import-module.c

diff  --git a/clang/test/CodeGen/wasm-import-name.c 
b/clang/test/CodeGen/WebAssembly/wasm-import-name.c
similarity index 100%
rename from clang/test/CodeGen/wasm-import-name.c
rename to clang/test/CodeGen/WebAssembly/wasm-import-name.c

diff  --git a/clang/test/CodeGen/wasm-main.c 
b/clang/test/CodeGen/WebAssembly/wasm-main.c
similarity index 100%
rename from clang/test/CodeGen/wasm-main.c
rename to clang/test/CodeGen/WebAssembly/wasm-main.c

diff  --git a/clang/test/CodeGen/wasm-main_argc_argv.c 
b/clang/test/CodeGen/WebAssembly/wasm-main_argc_argv.c
similarity index 100%
rename from clang/test/CodeGen/wasm-main_argc_argv.c
rename to clang/test/CodeGen/WebAssembly/wasm-main_argc_argv.c

diff  --git a/clang/test/CodeGen/wasm-regparm.c 
b/clang/test/CodeGen/WebAssembly/wasm-regparm.c
similarity index 100%
rename from clang/test/CodeGen/wasm-regparm.c
rename to clang/test/CodeGen/WebAssembly/wasm-regparm.c

diff  --git a/clang/test/CodeGen/wasm-varargs.c 
b/clang/test/CodeGen/WebAssembly/wasm-varargs.c
similarity index 100%
rename from clang/test/CodeGen/wasm-varargs.c
rename to clang/test/CodeGen/WebAssembly/wasm-varargs.c



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91861: [clang][cli] Split DefaultAnyOf into a default value and ImpliedByAnyOf

2020-11-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
Herald added subscribers: llvm-commits, cfe-commits, dang.
Herald added projects: clang, LLVM.
jansvoboda11 requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91861

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/unittests/Option/OptionMarshallingTest.cpp
  llvm/unittests/Option/Opts.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -71,6 +71,8 @@
   StringRef KeyPath;
   StringRef DefaultValue;
   StringRef NormalizedValuesScope;
+  StringRef ImpliedCheck;
+  StringRef ImpliedValue;
   StringRef Normalizer;
   StringRef Denormalizer;
   StringRef ValueMerger;
@@ -113,6 +115,10 @@
 OS << ", ";
 emitScopedNormalizedValue(OS, DefaultValue);
 OS << ", ";
+OS << ImpliedCheck;
+OS << ", ";
+emitScopedNormalizedValue(OS, ImpliedValue);
+OS << ", ";
 OS << Normalizer;
 OS << ", ";
 OS << Denormalizer;
@@ -188,6 +194,9 @@
   Ret->KeyPath = R.getValueAsString("KeyPath");
   Ret->DefaultValue = R.getValueAsString("DefaultValue");
   Ret->NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
+  Ret->ImpliedCheck = R.getValueAsString("ImpliedCheck");
+  Ret->ImpliedValue =
+  R.getValueAsOptionalString("ImpliedValue").getValueOr(Ret->DefaultValue);
 
   Ret->Normalizer = R.getValueAsString("Normalizer");
   Ret->Denormalizer = R.getValueAsString("Denormalizer");
Index: llvm/unittests/Option/Opts.td
===
--- llvm/unittests/Option/Opts.td
+++ llvm/unittests/Option/Opts.td
@@ -46,10 +46,13 @@
 def DashDash : Option<["--"], "", KIND_REMAINING_ARGS>;
 
 def marshalled_flag_d : Flag<["-"], "marshalled-flag-d">,
-  MarshallingInfoFlag<"MarshalledFlagD", DefaultAnyOf<[]>>;
+  MarshallingInfoFlag<"MarshalledFlagD">;
 def marshalled_flag_c : Flag<["-"], "marshalled-flag-c">,
-  MarshallingInfoFlag<"MarshalledFlagC", DefaultAnyOf<[marshalled_flag_d]>>;
+  MarshallingInfoFlag<"MarshalledFlagC">,
+  ImpliedByAnyOf<[marshalled_flag_d], "true">;
 def marshalled_flag_b : Flag<["-"], "marshalled-flag-b">,
-  MarshallingInfoFlag<"MarshalledFlagB", DefaultAnyOf<[marshalled_flag_d]>>;
+  MarshallingInfoFlag<"MarshalledFlagB">,
+  ImpliedByAnyOf<[marshalled_flag_d], "true">;
 def marshalled_flag_a : Flag<["-"], "marshalled-flag-a">,
-  MarshallingInfoFlag<"MarshalledFlagA", DefaultAnyOf<[marshalled_flag_c, marshalled_flag_b]>>;
+  MarshallingInfoFlag<"MarshalledFlagA">,
+  ImpliedByAnyOf<[marshalled_flag_c, marshalled_flag_b]>;
Index: llvm/unittests/Option/OptionMarshallingTest.cpp
===
--- llvm/unittests/Option/OptionMarshallingTest.cpp
+++ llvm/unittests/Option/OptionMarshallingTest.cpp
@@ -11,15 +11,17 @@
 struct OptionWithMarshallingInfo {
   const char *Name;
   const char *KeyPath;
-  const char *DefaultValue;
+  const char *ImpliedCheck;
+  const char *ImpliedValue;
 };
 
 static const OptionWithMarshallingInfo MarshallingTable[] = {
 #define OPTION_WITH_MARSHALLING(   \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
 HELPTEXT, METAVAR, VALUES, SPELLING, ALWAYS_EMIT, KEYPATH, DEFAULT_VALUE,  \
-NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, TABLE_INDEX)  \
-  {NAME, #KEYPATH, #DEFAULT_VALUE},
+IMPLIED_CHECK, IMPLIED_VALUE, NORMALIZER, DENORMALIZER, MERGER, EXTRACTOR, \
+TABLE_INDEX)   \
+  {NAME, #KEYPATH, #IMPLIED_CHECK, #IMPLIED_VALUE},
 #include "Opts.inc"
 #undef OPTION_WITH_MARSHALLING
 };
@@ -38,10 +40,16 @@
   ASSERT_STREQ(MarshallingTable[3].KeyPath, "MarshalledFlagA");
 }
 
-TEST(OptionMarshalling, DefaultAnyOfConstructedDisjunctionOfKeypaths) {
-  ASSERT_STREQ(MarshallingTable[0].DefaultValue, "false");
-  ASSERT_STREQ(MarshallingTable[1].DefaultValue, "false || MarshalledFlagD");
-  ASSERT_STREQ(MarshallingTable[2].DefaultValue, "false || MarshalledFlagD");
-  ASSERT_STREQ(MarshallingTable[3].DefaultValue,
-"false || MarshalledFlagC || MarshalledFlagB");
+TEST(OptionMarshalling, ImpliedCheckContainsDisjunctionOfKeypaths) {
+  ASSERT_STREQ(MarshallingTable[0].ImpliedCheck, "false");
+
+  ASSERT_STREQ(MarshallingTable[1].ImpliedCheck, "false || MarshalledFlagD");
+  ASSERT_STREQ(MarshallingTable[1].ImpliedValue, "true");
+
+  ASSERT_STREQ(MarshallingTable[2].ImpliedCheck, "false || MarshalledFlagD");
+  ASSERT_STREQ(MarshallingTable[2].ImpliedValue, "true");
+
+  ASSERT_STREQ(MarshallingTable[3].ImpliedCheck,
+   "false || MarshalledFlagC || MarshalledFlagB");
+  ASSERT_STREQ(

[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-20 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie updated this revision to Diff 306590.
OikawaKirie added a comment.

1. Replace fatal errors with assertions.

>> In D91410#2400018 , @tejohnson 
>> wrote:
>
> If these are not likely due to user input issues, then perhaps they should 
> all be assert so that they are compiled out in release compilers?



2. Fix clang-format errors in llvm/tools/llvm-objdump/MachODump.cpp


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91410/new/

https://reviews.llvm.org/D91410

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  clang/tools/driver/cc1as_main.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/lib/CodeGen/ParallelCG.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/LTOModule.cpp
  llvm/lib/LTO/ThinLTOCodeGenerator.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/tools/llvm-exegesis/lib/LlvmState.cpp
  llvm/tools/llvm-exegesis/llvm-exegesis.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-objdump/MachODump.cpp
  llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
  mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
  mlir/lib/ExecutionEngine/ExecutionEngine.cpp

Index: mlir/lib/ExecutionEngine/ExecutionEngine.cpp
===
--- mlir/lib/ExecutionEngine/ExecutionEngine.cpp
+++ mlir/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -130,6 +130,10 @@
 
   std::unique_ptr machine(target->createTargetMachine(
   targetTriple, cpu, features.getString(), {}, {}));
+  if (!machine) {
+errs() << "Unable to create target machine\n";
+return true;
+  }
   llvmModule->setDataLayout(machine->createDataLayout());
   llvmModule->setTargetTriple(targetTriple);
   return false;
Index: mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
===
--- mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
+++ mlir/lib/Conversion/GPUCommon/ConvertKernelFuncToBlob.cpp
@@ -130,6 +130,10 @@
 }
 targetMachine.reset(target->createTargetMachine(triple.str(), targetChip,
 features, {}, {}));
+if (targetMachine == nullptr) {
+  emitError(loc, "connot initialize target machine");
+  return {};
+}
   }
 
   llvmModule.setDataLayout(targetMachine->createDataLayout());
Index: llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
===
--- llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -764,6 +764,8 @@
 ErrorAndExit("Unable to create disassembler!");
 
   std::unique_ptr MII(TheTarget->createMCInstrInfo());
+  if (!MII)
+ErrorAndExit("Unable to create target instruction info!");
 
   std::unique_ptr InstPrinter(
   TheTarget->createMCInstPrinter(Triple(TripleName), 0, *MAI, *MII, *MRI));
Index: llvm/tools/llvm-objdump/MachODump.cpp
===
--- llvm/tools/llvm-objdump/MachODump.cpp
+++ llvm/tools/llvm-objdump/MachODump.cpp
@@ -7200,10 +7200,32 @@
   else
 MachOMCPU = MCPU;
 
+#define CHECK_TARGET_INFO_CREATION(NAME)   \
+  do { \
+if (!NAME) {   \
+  WithColor::error(errs(), "llvm-objdump") \
+  << "couldn't initialize disassembler for target " << TripleName  \
+  << '\n'; \
+  return;  \
+}  \
+  } while (false)
+#define CHECK_THUMB_TARGET_INFO_CREATION(NAME) \
+  do { \
+if (!NAME) {   \
+  WithColor::error(errs(), "llvm-objdump") \
+  << "couldn't initialize disassembler for target " << ThumbTripleName \
+  << '\n'; \
+  return;  \
+}  \
+  } while (false)
+
   std::unique_ptr InstrInfo(TheTarget->createMCInstrInfo());
+  CHECK_TARGET_INFO_CREATION(InstrInfo);
   std::unique_ptr ThumbInstrInfo;
-  if (ThumbTarget)
+  if (ThumbTarget) {
 ThumbInstrInfo.reset(ThumbTarget->createMCInstrInfo());
+CHECK_THUMB_TARGET_INFO_CREATION(ThumbInstrInfo);
+  }
 
   

[PATCH] D91410: [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref

2020-11-20 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson accepted this revision.
tejohnson added a comment.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91410/new/

https://reviews.llvm.org/D91410

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91859: [clangd] Fix shared-lib builds

2020-11-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev requested changes to this revision.
kbobyrev added a comment.
This revision now requires changes to proceed.

Thank you for taking care of thiis!

The complete fix, however, should include two more things:

1. Moving this

  if (CLANGD_ENABLE_REMOTE)
include(FindGRPC)
  endif()

before that

  if(CLANG_INCLUDE_TESTS)
  add_subdirectory(test)
  add_subdirectory(unittests)
  endif()

Otherwise by the time unittests are compiled the include paths are not set 
appropriately and we will see the errors with Protobuf version mismatch through 
transitive includes etc.

2. `ClangdTests` should be linked against `RemoteIndexProto`, I didn't notice 
this problem before since linking `clangdRemoteMarshalling` already did the 
trick for static index builds but now we need to do that explicitly in 
`clangd/unittests/CMakeLists.txt`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91859/new/

https://reviews.llvm.org/D91859

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91859: [clangd] Fix shared-lib builds

2020-11-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

Actually, it would be safer if `FindGRPC` was also higher than 
`add_subdirectory(tool)`: right now it only includes `remote/index/Client.h` 
and `Client.h` does not depend on any gRPC/Protobuf headers for now but that 
might change at some point and break builds unexpectedly. I would suggest just 
moving it as high as possible, there is no harm in that apart from decoupling 
`FindGRPC` from `add_subdirectory(index/remote)` and related code but we kind 
of have to do that anyway.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91859/new/

https://reviews.llvm.org/D91859

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83694: Port DependencyOutput option flags to new option parsing system

2020-11-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a reviewer: dexonsmith.
jansvoboda11 added a comment.

Taking over this revision as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83694/new/

https://reviews.llvm.org/D83694

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83694: Port DependencyOutput option flags to new option parsing system

2020-11-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 306668.
jansvoboda11 added a comment.

Rebase, undo the move of options, introduce makeFlagToValueNormalizer


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83694/new/

https://reviews.llvm.org/D83694

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -134,20 +134,28 @@
   return None;
 }
 
+template 
 void denormalizeSimpleFlag(SmallVectorImpl &Args,
const char *Spelling,
CompilerInvocation::StringAllocator SA,
-   unsigned TableIndex, unsigned Value) {
+   unsigned TableIndex, T Value) {
   Args.push_back(Spelling);
 }
 
-template 
-static llvm::Optional
-normalizeFlagToValue(OptSpecifier Opt, unsigned TableIndex, const ArgList &Args,
- DiagnosticsEngine &Diags) {
-  if (Args.hasArg(Opt))
-return Value;
-  return None;
+template  struct FlagToValueNormalizer {
+  T Value;
+
+  llvm::Optional operator()(OptSpecifier Opt, unsigned TableIndex,
+   const ArgList &Args, DiagnosticsEngine &Diags) {
+if (Args.hasArg(Opt))
+  return Value;
+return None;
+  }
+};
+
+template 
+FlagToValueNormalizer makeFlagToValueNormalizer(T Value) {
+  return FlagToValueNormalizer{std::move(Value)};
 }
 
 static Optional normalizeBooleanFlag(OptSpecifier PosOpt,
@@ -1552,13 +1560,8 @@
   ArgList &Args) {
   Opts.OutputFile = std::string(Args.getLastArgValue(OPT_dependency_file));
   Opts.Targets = Args.getAllArgValues(OPT_MT);
-  Opts.IncludeSystemHeaders = Args.hasArg(OPT_sys_header_deps);
-  Opts.IncludeModuleFiles = Args.hasArg(OPT_module_file_deps);
-  Opts.UsePhonyTargets = Args.hasArg(OPT_MP);
-  Opts.ShowHeaderIncludes = Args.hasArg(OPT_H);
   Opts.HeaderIncludeOutputFile =
   std::string(Args.getLastArgValue(OPT_header_include_file));
-  Opts.AddMissingHeaderDeps = Args.hasArg(OPT_MG);
   if (Args.hasArg(OPT_show_includes)) {
 // Writing both /showIncludes and preprocessor output to stdout
 // would produce interleaved output, so use stderr for /showIncludes.
@@ -1573,8 +1576,6 @@
   Opts.DOTOutputFile = std::string(Args.getLastArgValue(OPT_dependency_dot));
   Opts.ModuleDependencyOutputDir =
   std::string(Args.getLastArgValue(OPT_module_dependency_dir));
-  if (Args.hasArg(OPT_MV))
-Opts.OutputFormat = DependencyOutputFormat::NMake;
   // Add sanitizer blacklists as extra dependencies.
   // They won't be discovered by the regular preprocessor, so
   // we let make / ninja to know about this implicit dependency.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -429,7 +429,8 @@
 "into small data section (MIPS / Hexagon)">;
 def G_EQ : Joined<["-"], "G=">, Flags<[NoXarchOption]>, Group, Alias;
 def H : Flag<["-"], "H">, Flags<[CC1Option]>, Group,
-HelpText<"Show header includes and nesting depth">;
+HelpText<"Show header includes and nesting depth">,
+MarshallingInfoFlag<"DependencyOutputOpts.ShowHeaderIncludes">;
 def I_ : Flag<["-"], "I-">, Group,
 HelpText<"Restrict all prior -I flags to double-quoted inclusion and "
  "remove current directory from include path">;
@@ -455,17 +456,21 @@
 HelpText<"Write depfile output from -MMD, -MD, -MM, or -M to ">,
 MetaVarName<"">;
 def MG : Flag<["-"], "MG">, Group, Flags<[CC1Option]>,
-HelpText<"Add missing headers to depfile">;
+HelpText<"Add missing headers to depfile">,
+MarshallingInfoFlag<"DependencyOutputOpts.AddMissingHeaderDeps">;
 def MJ : JoinedOrSeparate<["-"], "MJ">, Group,
 HelpText<"Write a compilation database entry per input">;
 def MP : Flag<["-"], "MP">, Group, Flags<[CC1Option]>,
-HelpText<"Create phony target for each dependency (other than main file)">;
+HelpText<"Create phony target for each dependency (other than main file)">,
+MarshallingInfoFlag<"DependencyOutputOpts.UsePhonyTargets">;
 def MQ : JoinedOrSeparate<["-"], "MQ">, Group, Flags<[CC1Option]>,
 HelpText<"Specify name of main file output to quote in depfile">;
 def MT : JoinedOrSeparate<["-"], "MT">, Group, Flags<[CC1Option]>,
 HelpText<"Specify name of main file output in depfile">;
 def MV : Flag<["-"], "MV">, Group, Flags<[CC1Option]>,
-HelpText<"Use NMake/Jom format for the depfile">;
+HelpText<"Use NMake/Jom format for the depfile">,
+MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", "DependencyOutputFormat::Make">,
+Normalizer<"makeFlagToValueNormalizer(DependencyOutputFormat::NMake)">;

[PATCH] D83694: [clang][cli] Port DependencyOutput option flags to new option parsing system

2020-11-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:473
+MarshallingInfoFlag<"DependencyOutputOpts.OutputFormat", 
"DependencyOutputFormat::Make">,
+Normalizer<"makeFlagToValueNormalizer(DependencyOutputFormat::NMake)">;
 def Mach : Flag<["-"], "Mach">, Group;

The original patch used the following normalizer:
`(normalizeFlagToValue)`.

I wanted to remove the parenthesis and redundant type argument, hence 
`makeFlagToValueNormalizer`. This could be useful later on when normalizing 
flags to non-literal types.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83694/new/

https://reviews.llvm.org/D83694

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91639: Add documentation illustrating use of IgnoreUnlessSpelledInSource

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the new documentation!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91639/new/

https://reviews.llvm.org/D91639

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2033fa2 - Add documentation illustrating use of IgnoreUnlessSpelledInSource

2020-11-20 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-11-20T13:49:25Z
New Revision: 2033fa29b09f9402a9f09f9de20414e82f7d174c

URL: 
https://github.com/llvm/llvm-project/commit/2033fa29b09f9402a9f09f9de20414e82f7d174c
DIFF: 
https://github.com/llvm/llvm-project/commit/2033fa29b09f9402a9f09f9de20414e82f7d174c.diff

LOG: Add documentation illustrating use of IgnoreUnlessSpelledInSource

Differential Revision: https://reviews.llvm.org/D91639

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index d9fa3c2830fb..fbc53ed743a2 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -17,6 +17,12 @@
   color: blue;
   cursor: pointer;
 }
+span.mono { font-family: monospace; }
+
+.traverse_compare, .traverse_compare td, .traverse_compare th {
+  border: 1px solid black;
+  border-collapse: collapse;
+}
 
 

[PATCH] D91639: Add documentation illustrating use of IgnoreUnlessSpelledInSource

2020-11-20 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2033fa29b09f: Add documentation illustrating use of 
IgnoreUnlessSpelledInSource (authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91639/new/

https://reviews.llvm.org/D91639

Files:
  clang/docs/LibASTMatchersReference.html

Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -17,6 +17,12 @@
   color: blue;
   cursor: pointer;
 }
+span.mono { font-family: monospace; }
+
+.traverse_compare, .traverse_compare td, .traverse_compare th {
+  border: 1px solid black;
+  border-collapse: collapse;
+}
 
 

[clang] 2ce6352 - Add a call super attribute plugin example

2020-11-20 Thread Aaron Ballman via cfe-commits

Author: Yafei Liu
Date: 2020-11-20T08:51:12-05:00
New Revision: 2ce6352e46344d97fed6a3ca6de7228345956191

URL: 
https://github.com/llvm/llvm-project/commit/2ce6352e46344d97fed6a3ca6de7228345956191
DIFF: 
https://github.com/llvm/llvm-project/commit/2ce6352e46344d97fed6a3ca6de7228345956191.diff

LOG: Add a call super attribute plugin example

If a virtual method is marked as call_super, the
override method must call it, simpler feature like @CallSuper
in Android Java.

Added: 
clang/examples/CallSuperAttribute/CMakeLists.txt
clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
clang/test/Frontend/plugin-call-super.cpp

Modified: 
clang/examples/CMakeLists.txt
clang/test/CMakeLists.txt

Removed: 




diff  --git a/clang/examples/CMakeLists.txt b/clang/examples/CMakeLists.txt
index c014b3ddfe97..300d8d795c67 100644
--- a/clang/examples/CMakeLists.txt
+++ b/clang/examples/CMakeLists.txt
@@ -7,3 +7,4 @@ add_subdirectory(clang-interpreter)
 add_subdirectory(PrintFunctionNames)
 add_subdirectory(AnnotateFunctions)
 add_subdirectory(Attribute)
+add_subdirectory(CallSuperAttribute)

diff  --git a/clang/examples/CallSuperAttribute/CMakeLists.txt 
b/clang/examples/CallSuperAttribute/CMakeLists.txt
new file mode 100644
index ..922f0cfa797a
--- /dev/null
+++ b/clang/examples/CallSuperAttribute/CMakeLists.txt
@@ -0,0 +1,13 @@
+add_llvm_library(CallSuperAttr MODULE CallSuperAttrInfo.cpp PLUGIN_TOOL clang)
+
+if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  set(LLVM_LINK_COMPONENTS
+Support
+  )
+  clang_target_link_libraries(CallSuperAttr PRIVATE
+clangAST
+clangBasic
+clangFrontend
+clangLex
+)
+endif()

diff  --git a/clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp 
b/clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
new file mode 100644
index ..331f63508045
--- /dev/null
+++ b/clang/examples/CallSuperAttribute/CallSuperAttrInfo.cpp
@@ -0,0 +1,190 @@
+//===- AnnotateFunctions.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Attribute plugin to mark a virtual method as ``call_super``, subclasses must
+// call it in the overridden method.
+//
+// This example shows that attribute plugins combined with ``PluginASTAction``
+// in Clang can do some of the same things which Java Annotations do.
+//
+// Unlike the other attribute plugin examples, this one does not attach an
+// attribute AST node to the declaration AST node. Instead, it keeps a separate
+// list of attributed declarations, which may be faster than using
+// ``Decl::getAttr()`` in some cases. The disadvantage of this approach is
+// that the attribute is not part of the AST, which means that dumping the AST
+// will lose the attribute information, pretty printing the AST won't write the
+// attribute back out to source, and AST matchers will not be able to match
+// against the attribute on the declaration.
+//
+//===--===//
+
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Attr.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/Frontend/FrontendPluginRegistry.h"
+#include "clang/Sema/ParsedAttr.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Sema/SemaDiagnostic.h"
+#include "llvm/ADT/SmallPtrSet.h"
+using namespace clang;
+
+namespace {
+// Cached methods which are marked as 'call_super'.
+llvm::SmallPtrSet MarkedMethods;
+bool isMarkedAsCallSuper(const CXXMethodDecl *D) {
+  // Uses this way to avoid add an annotation attr to the AST.
+  return MarkedMethods.contains(D);
+}
+
+class MethodUsageVisitor : public RecursiveASTVisitor {
+public:
+  bool IsOverriddenUsed = false;
+  explicit MethodUsageVisitor(
+  llvm::SmallPtrSet &MustCalledMethods)
+  : MustCalledMethods(MustCalledMethods) {}
+  bool VisitCallExpr(CallExpr *CallExpr) {
+const CXXMethodDecl *Callee = nullptr;
+for (const auto &MustCalled : MustCalledMethods) {
+  if (CallExpr->getCalleeDecl() == MustCalled) {
+// Super is called.
+// Notice that we cannot do delete or insert in the iteration
+// when using SmallPtrSet.
+Callee = MustCalled;
+  }
+}
+if (Callee)
+  MustCalledMethods.erase(Callee);
+
+return true;
+  }
+
+private:
+  llvm::SmallPtrSet &MustCalledMethods;
+};
+
+class CallSuperVisitor : public RecursiveASTVisitor {
+public:
+  CallSuperVisitor(DiagnosticsEngine &Diags) : Diags(Diags) {
+WarningSuperNotCalled = Diags.getCustomDiagID(
+DiagnosticsEngine::Warning,
+"virtual function %q0 is marked as 'call_super' but this overriding "
+

[PATCH] D91047: Add a call super attribute plugin example

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

In D91047#2407091 , @psionic12 wrote:

> @aaron.ballman That would be nice if your could help, and `Yafei Liu 
> ` is okay.

Thank you for the new example, I've commit on your behalf in 
2ce6352e46344d97fed6a3ca6de7228345956191 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91047/new/

https://reviews.llvm.org/D91047

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83697: Port Frontend option flags to new option parsing system

2020-11-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
jansvoboda11 added a reviewer: dexonsmith.
jansvoboda11 added a comment.

Taking over this patch as Daniel is no longer involved.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83697/new/

https://reviews.llvm.org/D83697

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83697: Port Frontend option flags to new option parsing system

2020-11-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 306675.
jansvoboda11 added a comment.
Herald added a reviewer: sscalpone.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Rebase, undo move of options, implement IsNegative.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83697/new/

https://reviews.llvm.org/D83697

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/Option/OptParser.td

Index: llvm/include/llvm/Option/OptParser.td
===
--- llvm/include/llvm/Option/OptParser.td
+++ llvm/include/llvm/Option/OptParser.td
@@ -187,7 +187,7 @@
 // Mixins for additional marshalling attributes.
 
 class IsNegative {
-  // todo: create & apply a normalizer for negative flags
+  code Normalizer = "normalizeSimpleNegativeFlag";
 }
 class AlwaysEmit { bit ShouldAlwaysEmit = true; }
 class Normalizer { code Normalizer = normalizer; }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -134,6 +134,14 @@
   return None;
 }
 
+static llvm::Optional
+normalizeSimpleNegativeFlag(OptSpecifier Opt, unsigned TableIndex,
+const ArgList &Args, DiagnosticsEngine &Diags) {
+  if (Args.hasArg(Opt))
+return false;
+  return None;
+}
+
 void denormalizeSimpleFlag(SmallVectorImpl &Args,
const char *Spelling,
CompilerInvocation::StringAllocator SA,
@@ -276,9 +284,11 @@
   LangOptions &LangOpts = *Invocation.getLangOpts();
   DiagnosticOptions &DiagOpts = Invocation.getDiagnosticOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
+  FrontendOptions &FrontendOpts = Invocation.getFrontendOpts();
   CodeGenOpts.XRayInstrumentFunctions = LangOpts.XRayInstrument;
   CodeGenOpts.XRayAlwaysEmitCustomEvents = LangOpts.XRayAlwaysEmitCustomEvents;
   CodeGenOpts.XRayAlwaysEmitTypedEvents = LangOpts.XRayAlwaysEmitTypedEvents;
+  FrontendOpts.GenerateGlobalModuleIndex = FrontendOpts.UseGlobalModuleIndex;
 
   llvm::sys::Process::UseANSIEscapeCodes(DiagOpts.UseANSIEscapeCodes);
 }
@@ -1988,32 +1998,16 @@
   Diags.Report(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
   }
-  Opts.DisableFree = Args.hasArg(OPT_disable_free);
 
   Opts.OutputFile = std::string(Args.getLastArgValue(OPT_o));
   Opts.Plugins = Args.getAllArgValues(OPT_load);
-  Opts.RelocatablePCH = Args.hasArg(OPT_relocatable_pch);
-  Opts.ShowHelp = Args.hasArg(OPT_help);
-  Opts.ShowStats = Args.hasArg(OPT_print_stats);
-  Opts.ShowTimers = Args.hasArg(OPT_ftime_report);
-  Opts.PrintSupportedCPUs = Args.hasArg(OPT_print_supported_cpus);
-  Opts.TimeTrace = Args.hasArg(OPT_ftime_trace);
   Opts.TimeTraceGranularity = getLastArgIntValue(
   Args, OPT_ftime_trace_granularity_EQ, Opts.TimeTraceGranularity, Diags);
-  Opts.ShowVersion = Args.hasArg(OPT_version);
   Opts.ASTMergeFiles = Args.getAllArgValues(OPT_ast_merge);
   Opts.LLVMArgs = Args.getAllArgValues(OPT_mllvm);
-  Opts.FixWhatYouCan = Args.hasArg(OPT_fix_what_you_can);
-  Opts.FixOnlyWarnings = Args.hasArg(OPT_fix_only_warnings);
-  Opts.FixAndRecompile = Args.hasArg(OPT_fixit_recompile);
-  Opts.FixToTemporaries = Args.hasArg(OPT_fixit_to_temp);
   Opts.ASTDumpDecls = Args.hasArg(OPT_ast_dump, OPT_ast_dump_EQ);
   Opts.ASTDumpAll = Args.hasArg(OPT_ast_dump_all, OPT_ast_dump_all_EQ);
   Opts.ASTDumpFilter = std::string(Args.getLastArgValue(OPT_ast_dump_filter));
-  Opts.ASTDumpLookups = Args.hasArg(OPT_ast_dump_lookups);
-  Opts.ASTDumpDeclTypes = Args.hasArg(OPT_ast_dump_decl_types);
-  Opts.UseGlobalModuleIndex = !Args.hasArg(OPT_fno_modules_global_index);
-  Opts.GenerateGlobalModuleIndex = Opts.UseGlobalModuleIndex;
   Opts.ModuleMapFiles = Args.getAllArgValues(OPT_fmodule_map_file);
   // Only the -fmodule-file= form.
   for (const auto *A : Args.filtered(OPT_fmodule_file)) {
@@ -2022,29 +2016,12 @@
   Opts.ModuleFiles.push_back(std::string(Val));
   }
   Opts.ModulesEmbedFiles = Args.getAllArgValues(OPT_fmodules_embed_file_EQ);
-  Opts.ModulesEmbedAllFiles = Args.hasArg(OPT_fmodules_embed_all_files);
-  Opts.IncludeTimestamps = !Args.hasArg(OPT_fno_pch_timestamp);
-  Opts.UseTemporary = !Args.hasArg(OPT_fno_temp_file);
-  Opts.IsSystemModule = Args.hasArg(OPT_fsystem_module);
   Opts.AllowPCMWithCompilerErrors = Args.hasArg(OPT_fallow_pcm_with_errors);
 
   if (Opts.ProgramAction != frontend::GenerateModule && Opts.IsSystemModule)
 Diags.Report(diag::err_drv_argument_only_allowed_with) << "-fsystem-module"
<< "-emit-module";
 
-  Opts.CodeCompleteOpts.IncludeMacros
-= Args.hasArg(OPT_code_completion_macros);
-  Opts.CodeCompleteOpts.IncludeCodePatterns
-= Args.has

[PATCH] D91009: [clang-tidy] Include std::basic_string_view in readability-redundant-string-init.

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91009/new/

https://reviews.llvm.org/D91009

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91860: [clangd] Move remote-index dependency from clangDaemon to ClangdMain

2020-11-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/index/ProjectAware.h:27
 /// Returns an index that answers queries using external indices. 
IndexGenerator
 /// can be used to customize how to generate an index from an external source.
+std::unique_ptr createProjectAwareIndex(IndexFactory);

while here, IndexGenerator -> IndexFactory, and "can be use to customize" --> 
"specifies" now that it's mandatory



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:558
 
+// We define this function here as depending on clangdRemoteIndex within
+// clangDaemon introduces a cyclic dependency.

This sort of a comment seems to be rebutting the previous version of the code, 
which is important today but probably not in the long run.

It may not be needed at all - this factoring actually looks more natural than I 
expected!
If it is, I think it belongs on createProjectAwareIndex rather than here, as an 
aside.
`(IndexFactory must be injected because this code cannot depend on the remote 
index client)`



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:561
+std::unique_ptr
+projectAwareIndexFactory(const Config::ExternalIndexSpec &External,
+ AsyncTaskRunner &Tasks) {

maybe just loadExternalIndex, which more clearly describes what it *does* as 
opposed to where it's passed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91860/new/

https://reviews.llvm.org/D91860

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91840: OpaquePtr: Require byval on x86_intrcc parameter 0

2020-11-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/test/Bitcode/compatibility-6.0.ll:439
 ; CHECK: declare hhvm_ccc void @f.hhvm_ccc()
-declare cc83 void @f.cc83()
+declare cc83 void @f.cc83(i8* byval(i8))
 ; CHECK: declare x86_intrcc void @f.cc83()

craig.topper wrote:
> Why do we need to change arguments here? Isn't no arguments allowed?
It is allowed, although I'm not sure if it should be. Clang just ignores the 
attribute on functions with no arguments



Comment at: llvm/test/Bitcode/compatibility-6.0.ll:441
 ; CHECK: declare x86_intrcc void @f.cc83()
-declare x86_intrcc void @f.x86_intrcc()
+declare x86_intrcc void @f.x86_intrcc())
 ; CHECK: declare x86_intrcc void @f.x86_intrcc()

craig.topper wrote:
> What's this extra parenthese for?
To surprise us that this actually parses


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91840/new/

https://reviews.llvm.org/D91840

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91859: [clangd] Fix shared-lib builds

2020-11-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm not totally following the discussion on the more complete fix (LMK if you 
want me to dig into that), but if the build is broken in some configurations we 
should likely prioritize fixing that over ensuring the fix is conceptually 
complete.

> Otherwise by the time unittests are compiled the include paths are not set 
> appropriately and we will see the errors with Protobuf version mismatch 
> through transitive includes etc.

I don't think that's how CMake works, the whole CMakeLists tree is parsed 
before anything is compiled, so it shouldn't race like that.




Comment at: clang-tools-extra/clangd/index/remote/CMakeLists.txt:6
 GRPC)
+  target_link_libraries(RemoteIndexServiceProto
+PRIVATE

oh, this is sad, because we specify the proto dependencies to generate_protos 
but it doesn't actually set up all the dep relationships we need (and can't 
because we specify the filename, not the rule).

Can you add a "FIXME: move this into generate_protos somehow"?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91859/new/

https://reviews.llvm.org/D91859

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 95ce9fb - [clang] Do not crash on pointer wchar_t pointer assignment.

2020-11-20 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2020-11-20T15:27:15+01:00
New Revision: 95ce9fbc235a467b84b2ffa2571f1d1a45af9427

URL: 
https://github.com/llvm/llvm-project/commit/95ce9fbc235a467b84b2ffa2571f1d1a45af9427
DIFF: 
https://github.com/llvm/llvm-project/commit/95ce9fbc235a467b84b2ffa2571f1d1a45af9427.diff

LOG: [clang] Do not crash on pointer wchar_t pointer assignment.

wchar_t can be signed (thus hasSignedIntegerRepresentation() returns
true), but it doesn't have an unsigned type, which would lead to a crash
when trying to get it.

With this fix, we special-case WideChar types in the pointer assignment
code.

Differential Revision: https://reviews.llvm.org/D91625

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/test/SemaCXX/wchar_t.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 836065291fea..f54916babed7 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -10007,6 +10007,11 @@ QualType 
ASTContext::getCorrespondingUnsignedType(QualType T) const {
 return UnsignedLongLongTy;
   case BuiltinType::Int128:
 return UnsignedInt128Ty;
+  // wchar_t is special. It is either signed or not, but when it's signed,
+  // there's no matching "unsigned wchar_t". Therefore we return the unsigned
+  // version of it's underlying type instead.
+  case BuiltinType::WChar_S:
+return getUnsignedWCharType();
 
   case BuiltinType::ShortAccum:
 return UnsignedShortAccumTy;

diff  --git a/clang/test/SemaCXX/wchar_t.cpp b/clang/test/SemaCXX/wchar_t.cpp
index f8e9addf27b7..cc7c6de7b37f 100644
--- a/clang/test/SemaCXX/wchar_t.cpp
+++ b/clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@ int t(void) {
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' 
from 'wchar_t *'}}
+}
+#endif



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91625: [clang] Do not crash on pointer wchar_t pointer assignment.

2020-11-20 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95ce9fbc235a: [clang] Do not crash on pointer wchar_t 
pointer assignment. (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91625/new/

https://reviews.llvm.org/D91625

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/SemaCXX/wchar_t.cpp


Index: clang/test/SemaCXX/wchar_t.cpp
===
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar 
-verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' 
from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -10007,6 +10007,11 @@
 return UnsignedLongLongTy;
   case BuiltinType::Int128:
 return UnsignedInt128Ty;
+  // wchar_t is special. It is either signed or not, but when it's signed,
+  // there's no matching "unsigned wchar_t". Therefore we return the unsigned
+  // version of it's underlying type instead.
+  case BuiltinType::WChar_S:
+return getUnsignedWCharType();
 
   case BuiltinType::ShortAccum:
 return UnsignedShortAccumTy;


Index: clang/test/SemaCXX/wchar_t.cpp
===
--- clang/test/SemaCXX/wchar_t.cpp
+++ clang/test/SemaCXX/wchar_t.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed %s
+// RUN: %clang_cc1 -fsyntax-only -Wno-signed-unsigned-wchar -verify=allow-signed -DSKIP_ERROR_TESTS %s
 // allow-signed-no-diagnostics
 wchar_t x;
 
@@ -32,3 +32,10 @@
 // rdar://8040728
 wchar_t in[] = L"\x434" "\x434";  // No warning
 
+#ifndef SKIP_ERROR_TESTS
+// Verify that we do not crash when assigning wchar_t* to another pointer type.
+void assignment(wchar_t *x) {
+  char *y;
+  y = x; // expected-error {{incompatible pointer types assigning to 'char *' from 'wchar_t *'}}
+}
+#endif
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -10007,6 +10007,11 @@
 return UnsignedLongLongTy;
   case BuiltinType::Int128:
 return UnsignedInt128Ty;
+  // wchar_t is special. It is either signed or not, but when it's signed,
+  // there's no matching "unsigned wchar_t". Therefore we return the unsigned
+  // version of it's underlying type instead.
+  case BuiltinType::WChar_S:
+return getUnsignedWCharType();
 
   case BuiltinType::ShortAccum:
 return UnsignedShortAccumTy;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89651: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-11-20 Thread Gabor Bencze via Phabricator via cfe-commits
gbencze updated this revision to Diff 306679.
gbencze added a comment.
Herald added a subscriber: jfb.

Address comments:

- add new test case for `_Atomic` (with a FIXME comment)
- fix string literal formatting
- update docs


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89651/new/

https://reviews.llvm.org/D89651

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousMemoryComparisonCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-memory-comparison.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-exp42-c.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-flp37-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-memory-comparison.cpp
@@ -0,0 +1,231 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-memory-comparison %t \
+// RUN: -- -- -target x86_64-unknown-unknown
+
+namespace std {
+typedef __SIZE_TYPE__ size_t;
+int memcmp(const void *lhs, const void *rhs, size_t count);
+} // namespace std
+
+namespace sei_cert_example_oop57_cpp {
+class C {
+  int i;
+
+public:
+  virtual void f();
+};
+
+void f(C &c1, C &c2) {
+  if (!std::memcmp(&c1, &c2, sizeof(C))) {
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: comparing object representation of non-standard-layout type 'sei_cert_example_oop57_cpp::C'; consider using a comparison operator instead
+  }
+}
+} // namespace sei_cert_example_oop57_cpp
+
+namespace inner_padding_64bit_only {
+struct S {
+  int x;
+  int *y;
+};
+
+void test() {
+  S a, b;
+  std::memcmp(&a, &b, sizeof(S));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'inner_padding_64bit_only::S' which does not have a unique object representation; consider comparing the members of the object manually
+}
+} // namespace inner_padding_64bit_only
+
+namespace padding_in_base {
+class Base {
+  char c;
+  int i;
+};
+
+class Derived : public Base {};
+
+class Derived2 : public Derived {};
+
+void testDerived() {
+  Derived a, b;
+  std::memcmp(&a, &b, sizeof(Base));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'padding_in_base::Derived' which does not have a unique object representation; consider comparing the members of the object manually
+  std::memcmp(&a, &b, sizeof(Derived));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'padding_in_base::Derived' which does not have a unique object representation; consider comparing the members of the object manually
+}
+
+void testDerived2() {
+  Derived2 a, b;
+  std::memcmp(&a, &b, sizeof(Base));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'padding_in_base::Derived2' which does not have a unique object representation; consider comparing the members of the object manually
+  std::memcmp(&a, &b, sizeof(Derived2));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of type 'padding_in_base::Derived2' which does not have a unique object representation; consider comparing the members of the object manually
+}
+
+} // namespace padding_in_base
+
+namespace no_padding_in_base {
+class Base {
+  int a, b;
+};
+
+class Derived : public Base {};
+
+class Derived2 : public Derived {};
+
+void testDerived() {
+  Derived a, b;
+  std::memcmp(&a, &b, sizeof(Base));
+  std::memcmp(&a, &b, sizeof(Derived));
+}
+
+void testDerived2() {
+  Derived2 a, b;
+  std::memcmp(&a, &b, sizeof(char));
+  std::memcmp(&a, &b, sizeof(Base));
+  std::memcmp(&a, &b, sizeof(Derived2));
+}
+} // namespace no_padding_in_base
+
+namespace non_standard_layout {
+class C {
+private:
+  int x;
+
+public:
+  int y;
+};
+
+void test() {
+  C a, b;
+  std::memcmp(&a, &b, sizeof(C));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: comparing object representation of non-standard-layout type 'non_standard_layout::C'; consider using a comparison operator instead
+}
+
+} // namespace non_standard_layout
+
+namespace static_ignored {
+struct S {
+  static char c;
+  int i;
+};
+
+void test() {
+  S a, b;
+  std::memcmp(&a, &b, sizeof(S));
+}
+} // namespace static_ignored
+
+namespace operator_void_ptr {
+struct S {
+  operator void *() const;
+};
+
+void test() {
+  S s;
+  std::mem

[PATCH] D89046: [AST] Build recovery expression by default for all language.

2020-11-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 306680.
hokein added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89046/new/

https://reviews.llvm.org/D89046

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector2-error.c
  clang/test/CodeGen/SystemZ/builtins-systemz-zvector3-error.c
  clang/test/CodeGen/builtins-ppc-error.c
  clang/test/Index/complete-switch.c
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/Parser/objc-foreach-syntax.m
  clang/test/Sema/__try.c
  clang/test/Sema/enum.c
  clang/test/Sema/typo-correction.c

Index: clang/test/Sema/typo-correction.c
===
--- clang/test/Sema/typo-correction.c
+++ clang/test/Sema/typo-correction.c
@@ -14,9 +14,9 @@
   // expected-error {{use of undeclared identifier 'b'}}
 
 int foobar;  // expected-note {{'foobar' declared here}}
-a = goobar ?: 4;  // expected-warning {{type specifier missing, defaults to 'int'}} \
-  // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
-  // expected-error {{initializer element is not a compile-time constant}}
+new_a = goobar ?: 4; // expected-warning {{type specifier missing, defaults to 'int'}} \
+  // expected-error {{use of undeclared identifier 'goobar'; did you mean 'foobar'?}} \
+  // expected-error {{initializer element is not a compile-time constant}}
 
 struct ContainerStuct {
   enum { SOME_ENUM }; // expected-note {{'SOME_ENUM' declared here}}
@@ -50,10 +50,10 @@
   cabs(errij);  // expected-error {{use of undeclared identifier 'errij'}}
 }
 
-extern long afunction(int); // expected-note {{'afunction' declared here}}
+extern long afunction(int);
 void fn2() {
-  f(THIS_IS_AN_ERROR, // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
-afunction(afunction_));  // expected-error {{use of undeclared identifier 'afunction_'; did you mean 'afunction'?}}
+  f(THIS_IS_AN_ERROR,   // expected-error {{use of undeclared identifier 'THIS_IS_AN_ERROR'}}
+afunction(afunction_)); // expected-error {{use of undeclared identifier 'afunction_'}}
 }
 
 int d = X ? d : L; // expected-error 2 {{use of undeclared identifier}}
Index: clang/test/Sema/enum.c
===
--- clang/test/Sema/enum.c
+++ clang/test/Sema/enum.c
@@ -100,7 +100,8 @@
 // PR7911
 extern enum PR7911T PR7911V; // expected-warning{{ISO C forbids forward references to 'enum' types}}
 void PR7911F() {
-  switch (PR7911V); // expected-error {{statement requires expression of integer type}}
+  switch (PR7911V) // expected-error {{statement requires expression of integer type}}
+;
 }
 
 char test5[__has_feature(enumerator_attributes) ? 1 : -1];
Index: clang/test/Sema/__try.c
===
--- clang/test/Sema/__try.c
+++ clang/test/Sema/__try.c
@@ -50,9 +50,9 @@
 }  // expected-error{{expected '__except' or '__finally' block}}
 
 void TEST() {
-  __except ( FilterExpression() ) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
-// expected-error{{too few arguments to function call, expected 1, have 0}}
-
+  __except (FilterExpression()) { // expected-warning{{implicit declaration of function '__except' is invalid in C99}} \
+// expected-error{{too few arguments to function call, expected 1, have 0}} \
+// expected-error{{expected ';' after expression}}
   }
 }
 
Index: clang/test/Parser/objc-foreach-syntax.m
===
--- clang/test/Parser/objc-foreach-syntax.m
+++ clang/test/Parser/objc-foreach-syntax.m
@@ -21,5 +21,8 @@
 
 
 static int test7(id keys) {
-  for (id key; in keys) ;  // expected-error {{use of undeclared identifier 'in'}}
+  // FIXME: would be nice to suppress the secondary diagnostics.
+  for (id key; in keys) ;  // expected-error {{use of undeclared identifier 'in'}} \
+   // expected-error {{expected ';' in 'for' statement specifier}} \
+   // expected-warning {{expression result unused}}
 }
Index: clang/test/OpenMP/declare_variant_messages.c
===
--- clang/test/OpenMP/declare_variant_messages.c
+++ clang/test/OpenMP/declare_variant_messages.c
@@ -10,7 +10,7 @@
 #pragma omp declare variant // expected-error {{expected '(' after 'declare variant'}}
 #pragma omp declare variant( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
 #pragma omp declare variant(foo // expected-error {{expected '

[PATCH] D91868: [clangd] Mention when CXXThis is implicit in exposed AST.

2020-11-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
sammccall requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Seeing an implicit this in the AST is pretty confusing I think.
While here, also mention when `this` is const.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91868

Files:
  clang-tools-extra/clangd/DumpAST.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp

Index: clang-tools-extra/clangd/unittests/DumpASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/DumpASTTests.cpp
+++ clang-tools-extra/clangd/unittests/DumpASTTests.cpp
@@ -76,29 +76,32 @@
   type: Record - S
   )"},
   {R"cpp(
-template  int root() {
-  (void)root();
+namespace root {
+template  int tmpl() {
+  (void)tmpl();
   return T::value;
+}
 }
   )cpp",
R"(
-declaration: FunctionTemplate - root
-  declaration: TemplateTypeParm - T
-  declaration: Function - root
-type: FunctionProto
-  type: Builtin - int
-statement: Compound
-  expression: CStyleCast - ToVoid
-type: Builtin - void
-expression: Call
-  expression: ImplicitCast - FunctionToPointerDecay
-expression: DeclRef - root
-  template argument: Type
-type: Builtin - unsigned int
-  statement: Return
-expression: DependentScopeDeclRef - value
-  specifier: TypeSpec
-type: TemplateTypeParm - T
+declaration: Namespace - root
+  declaration: FunctionTemplate - tmpl
+declaration: TemplateTypeParm - T
+declaration: Function - tmpl
+  type: FunctionProto
+type: Builtin - int
+  statement: Compound
+expression: CStyleCast - ToVoid
+  type: Builtin - void
+  expression: Call
+expression: ImplicitCast - FunctionToPointerDecay
+  expression: DeclRef - tmpl
+template argument: Type
+  type: Builtin - unsigned int
+statement: Return
+  expression: DependentScopeDeclRef - value
+specifier: TypeSpec
+  type: TemplateTypeParm - T
   )"},
   {R"cpp(
 struct Foo { char operator+(int); };
@@ -116,10 +119,28 @@
   type: Record - Foo
   expression: IntegerLiteral - 42
   )"},
+  {R"cpp(
+struct Bar {
+  int x;
+  int root() const {
+return x;
+  }
+};
+  )cpp",
+   R"(
+declaration: CXXMethod - root
+  type: FunctionProto
+type: Builtin - int
+  statement: Compound
+statement: Return
+  expression: ImplicitCast - LValueToRValue
+expression: Member - x
+  expression: CXXThis - const, implicit
+  )"},
   };
   for (const auto &Case : Cases) {
 ParsedAST AST = TestTU::withCode(Case.first).build();
-auto Node = dumpAST(DynTypedNode::create(findDecl(AST, "root")),
+auto Node = dumpAST(DynTypedNode::create(findUnqualifiedDecl(AST, "root")),
 AST.getTokens(), AST.getASTContext());
 EXPECT_EQ(llvm::StringRef(Case.second).trim(),
   llvm::StringRef(llvm::to_string(Node)).trim());
Index: clang-tools-extra/clangd/DumpAST.cpp
===
--- clang-tools-extra/clangd/DumpAST.cpp
+++ clang-tools-extra/clangd/DumpAST.cpp
@@ -230,6 +230,13 @@
   return UnaryOperator::getOpcodeStr(UO->getOpcode()).str();
 if (const auto *CCO = dyn_cast(S))
   return CCO->getConstructor()->getNameAsString();
+if (const auto *CTE = dyn_cast(S)) {
+  bool Const = CTE->getType()->getPointeeType().isLocalConstQualified();
+  if (CTE->isImplicit())
+return Const ? "const, implicit" : "implicit";
+  if (Const)
+return "const";
+}
 if (isa(S) || isa(S) ||
 isa(S) || isa(S) ||
 isa(S) || isa(S))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89046: [AST] Build recovery expression by default for all language.

2020-11-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

should be ready to go -- from our internal experiment, we don't see any super 
crashes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89046/new/

https://reviews.llvm.org/D89046

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88676: [PPC][AIX] Add vector callee saved registers for AIX extended vector ABI

2020-11-20 Thread Sean Fertile via Phabricator via cfe-commits
sfertile accepted this revision.
sfertile added a comment.
This revision is now accepted and ready to land.

LGTM.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88676/new/

https://reviews.llvm.org/D88676

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91806: [SVE] Remove warnings from release notes example on SVE ACLE.

2020-11-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 306684.
fpetrogalli added a comment.

I have removed the C test, as the LL test is enough to test the changes I have 
done in `Local.cpp`.

I can confirm that with this patch, the release note ton'r raise any warnings 
when compiling with debug info:

  frapet01@man-08:~/projects/upstream-clang/build-clang$ cat ../release-notes.c
  #include 
  
  void VLA_add_arrays(double *x, double *y, double *out, unsigned N) {
for (unsigned i = 0; i < N; i += svcntd()) {
  svbool_t Pg = svwhilelt_b64(i, N);
  svfloat64_t vx = svld1(Pg, &x[i]);
  svfloat64_t vy = svld1(Pg, &y[i]);
  svfloat64_t vout = svadd_x(Pg, vx, vy);
  svst1(Pg, &out[i], vout);
}
  }
  frapet01@man-08:~/projects/upstream-clang/build-clang$ ./bin/clang 
--target=aarch64-gnu-linux -march=armv8-a+sve -c -g -S -O3 -o /dev/null 
../release-notes.c
  frapet01@man-08:~/projects/upstream-clang/build-clang$

When the patch will end up into a nightly build of compiler explorer, the 
compilation at this link should not raise any warnings: 
https://godbolt.org/z/zebzKM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91806/new/

https://reviews.llvm.org/D91806

Files:
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  
llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll

Index: llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
@@ -0,0 +1,42 @@
+; RUN: opt -mtriple aarch64-gnu-linux -mattr=+sve -instcombine -S < %s 2>%t | FileCheck %s
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; If this check fails please read
+; clang/test/CodeGen/aarch64-sve-intrinsics/README for instructions on
+; how to resolve it.
+
+; WARN-NOT: warning
+
+; CHECK-LABEL: @debug_local_scalable(
+define  @debug_local_scalable( %tostore) {
+  %vx = alloca , align 16
+  call void @llvm.dbg.declare(metadata * %vx, metadata !5, metadata !DIExpression()), !dbg !15
+  store  %tostore, * %vx, align 16
+  %ret = call  @f(* %vx)
+  ret  %ret
+}
+
+declare  @f(*)
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp/")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !DILocalVariable(name: "vx", scope: !6, file: !7, line: 26, type: !8)
+!6 = distinct !DISubprogram(name: "debug_local_scalable", scope: null, file: !1, line: 25, scopeLine: 25, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
+!7 = !DIFile(filename: "test.c", directory: "/tmp/")
+!8 = !DIDerivedType(tag: DW_TAG_typedef, name: "svfloat64_t", file: !9, line: 56, baseType: !10)
+!9 = !DIFile(filename: "arm_sve.h", directory: "/tmp/")
+!10 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVFloat64_t", file: !1, baseType: !11)
+!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, flags: DIFlagVector, elements: !13)
+!12 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
+!13 = !{!14}
+!14 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
+!15 = !DILocation(line: 26, column: 15, scope: !6)
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1368,16 +1368,16 @@
 /// least n bits.
 static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
   const DataLayout &DL = DII->getModule()->getDataLayout();
-  uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
-  if (auto FragmentSize = DII->getFragmentSizeInBits())
-return ValueSize >= *FragmentSize;
+  TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
+  if (Optional FragmentSize = DII->getFragmentSizeInBits())
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
   // We can't always calculate the size of the DI variable (e.g. if it is a
   // VLA). Try to use the size of the alloca that the dbg intrinsic describes
   // intead.
   if (DII->isAddressOfVariable())
 if (auto *AI = dyn_cast_or_null(DII-

[PATCH] D87974: [Builtin] Add __builtin_zero_non_value_bits.

2020-11-20 Thread Jonathan Wakely via Phabricator via cfe-commits
jwakely added a comment.

As of a few hours ago, GCC has 
[`__builtin_clear_padding`](https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fclear_005fpadding)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87974/new/

https://reviews.llvm.org/D87974

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91009: [clang-tidy] Include std::basic_string_view in readability-redundant-string-init.

2020-11-20 Thread Chris Kennelly via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe4f9b5d442a2: [clang-tidy] Include std::basic_string_view in 
readability-redundant-string… (authored by ckennelly).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91009/new/

https://reviews.llvm.org/D91009

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -1,7 +1,7 @@
 // RUN: %check_clang_tidy -std=c++11,c++14 %s readability-redundant-string-init %t \
 // RUN:   -config="{CheckOptions: \
 // RUN: [{key: readability-redundant-string-init.StringNames, \
-// RUN:   value: '::std::basic_string;our::TestString'}] \
+// RUN:   value: '::std::basic_string;::std::basic_string_view;our::TestString'}] \
 // RUN: }"
 // FIXME: Fix the checker to work in C++17 mode.
 
@@ -19,6 +19,20 @@
 };
 typedef basic_string string;
 typedef basic_string wstring;
+
+template , typename A = std::allocator>
+struct basic_string_view {
+  using size_type = decltype(sizeof(0));
+
+  basic_string_view();
+  basic_string_view(const basic_string_view &);
+  basic_string_view(const C *, size_type);
+  basic_string_view(const C *);
+  template 
+  basic_string_view(It, End);
+};
+typedef basic_string_view string_view;
+typedef basic_string_view wstring_view;
 }
 
 void f() {
@@ -48,6 +62,33 @@
   std::string z;
 }
 
+void fview() {
+  std::string_view a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: redundant string initialization [readability-redundant-string-init]
+  // CHECK-FIXES: std::string_view a;
+  std::string_view b("");
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: redundant string initialization
+  // CHECK-FIXES: std::string_view b;
+  std::string_view c = R"()";
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: redundant string initialization
+  // CHECK-FIXES: std::string_view c;
+  std::string_view d(R"()");
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: redundant string initialization
+  // CHECK-FIXES: std::string_view d;
+  std::string_view e{""};
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: redundant string initialization
+  // CHECK-FIXES: std::string_view e;
+  std::string_view f = {""};
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: redundant string initialization
+  // CHECK-FIXES: std::string_view f;
+
+  std::string_view u = "u";
+  std::string_view w("w");
+  std::string_view x = R"(x)";
+  std::string_view y(R"(y)");
+  std::string_view z;
+}
+
 void g() {
   std::wstring a = L"";
   // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant string initialization
@@ -69,6 +110,33 @@
   std::wstring z;
 }
 
+void gview() {
+  std::wstring_view a = L"";
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: redundant string initialization [readability-redundant-string-init]
+  // CHECK-FIXES: std::wstring_view a;
+  std::wstring_view b(L"");
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring_view b;
+  std::wstring_view c = L"";
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring_view c;
+  std::wstring_view d(L"");
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring_view d;
+  std::wstring_view e{L""};
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring_view e;
+  std::wstring_view f = {L""};
+  // CHECK-MESSAGES: [[@LINE-1]]:21: warning: redundant string initialization
+  // CHECK-FIXES: std::wstring_view f;
+
+  std::wstring_view u = L"u";
+  std::wstring_view w(L"w");
+  std::wstring_view x = LR"(x)";
+  std::wstring_view y(LR"(y)");
+  std::wstring_view z;
+}
+
 template 
 void templ() {
   std::string s = "";
@@ -274,7 +342,6 @@
   // CHECK-MESSAGES: [[@LINE-2]]:23: warning: redundant string initialization
   // CHECK-FIXES:  Foo(float)  {}
 
-
   // Check how it handles removing some redundant initializers while leaving
   // valid initializers intact.
   Foo(std::string Arg) : A(Arg), B(""), C("NonEmpty"), D(R"()"), E("") {}
Index: clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
+++ clang-tools-extra/doc

[PATCH] D91806: [SVE] Remove warning from debug info on scalable vector.

2020-11-20 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

This patch needs to be retitled to what this is actually doing: changing the 
getTypeAllocationSizeInBits and getFragmentSizeInBits to return a TypeSize 
instead of `unsigned`.
It would be even better if you can split those up into two patches with 
separate tests for each one of them.




Comment at: clang/test/CodeGen/aarch64-sve-acle-rel-note.c:1
+// REQUIRES: aarch64-registered-target
+// RUN: %clang --target=aarch64-linux-gnu -march=armv8-a+sve -S -emit-llvm -o 
- -c %s -Werror -Wall -g -O0 2>%t | FileCheck %s

I'm not entirely sure if it is acceptable to have a clang test that generates 
assembly, but in any case I think this test needs to be added in a separate 
patch.



Comment at: llvm/lib/IR/IntrinsicInst.cpp:56
+Optional DbgVariableIntrinsic::getFragmentSizeInBits() const {
+  if (Optional Fragment =
+  getExpression()->getFragmentInfo())

Change back to `auto` ?



Comment at: llvm/lib/Transforms/Utils/Local.cpp:1373
+  if (Optional FragmentSize = DII->getFragmentSizeInBits())
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
   // We can't always calculate the size of the DI variable (e.g. if it is a

Should the scalable flag match? Same question for all the other cases in this 
patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91806/new/

https://reviews.llvm.org/D91806

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] e4f9b5d - [clang-tidy] Include std::basic_string_view in readability-redundant-string-init.

2020-11-20 Thread Chris Kennelly via cfe-commits

Author: Chris Kennelly
Date: 2020-11-20T10:06:57-05:00
New Revision: e4f9b5d442a260dd78b3de581cec1e90567a2aac

URL: 
https://github.com/llvm/llvm-project/commit/e4f9b5d442a260dd78b3de581cec1e90567a2aac
DIFF: 
https://github.com/llvm/llvm-project/commit/e4f9b5d442a260dd78b3de581cec1e90567a2aac.diff

LOG: [clang-tidy] Include std::basic_string_view in 
readability-redundant-string-init.

std::string_view("") produces a string_view instance that compares
equal to std::string_view(), but requires more complex initialization
(storing the address of the string literal, rather than zeroing).

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D91009

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst

clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
index e5825bc4f0e3..24defc80f161 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -18,7 +18,8 @@ namespace clang {
 namespace tidy {
 namespace readability {
 
-const char DefaultStringNames[] = "::std::basic_string";
+const char DefaultStringNames[] =
+"::std::basic_string_view;::std::basic_string";
 
 static ast_matchers::internal::Matcher
 hasAnyNameStdString(std::vector Names) {

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index cc9de109900b..5e78de2b0edc 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -152,6 +152,11 @@ Changes in existing checks
 - Removed `google-runtime-references` check because the rule it checks does
   not exist in the Google Style Guide anymore.
 
+- Improved :doc:`readability-redundant-string-init
+  ` check.
+
+  Added `std::basic_string_view` to default list of ``string``-like types.
+
 Improvements to include-fixer
 -
 

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
index c4556887f89a..dc3dfacb15d5 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
@@ -19,12 +19,21 @@ Examples
   std::string a;
   std::string b;
 
+  // Initializing a string_view with an empty string literal produces an
+  // instance that compares equal to string_view().
+  std::string_view a = "";
+  std::string_view b("");
+
+  // becomes
+  std::string_view a;
+  std::string_view b;
+
 Options
 ---
 
 .. option:: StringNames
 
-Default is `::std::basic_string`.
+Default is `::std::basic_string;::std::basic_string_view`.
 
 Semicolon-delimited list of class names to apply this check to.
 By default `::std::basic_string` applies to ``std::string`` and

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
index c33d1a7d5f2a..ed3d90ca307e 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
@@ -1,7 +1,7 @@
 // RUN: %check_clang_tidy -std=c++11,c++14 %s 
readability-redundant-string-init %t \
 // RUN:   -config="{CheckOptions: \
 // RUN: [{key: readability-redundant-string-init.StringNames, \
-// RUN:   value: '::std::basic_string;our::TestString'}] \
+// RUN:   value: 
'::std::basic_string;::std::basic_string_view;our::TestString'}] \
 // RUN: }"
 // FIXME: Fix the checker to work in C++17 mode.
 
@@ -19,6 +19,20 @@ struct basic_string {
 };
 typedef basic_string string;
 typedef basic_string wstring;
+
+template , typename A = 
std::allocator>
+struct basic_string_view {
+  using size_type = decltype(sizeof(0));
+
+  basic_string_view();
+  basic_string_view(const basic_string_view &);
+  basic_string_view(const C *, size_type);
+  basic_string_view(const C *);
+  template 
+  basic_string_view(It, End);
+};
+typedef basic_string_view string_view;
+typedef basic_string_view wstring_view;
 }
 
 void f() {
@@ -48,6 +62,33 @@ void f() {
   std::string z;
 }
 
+void fview() {
+  std::string_view a = "";
+  // CHECK-MESSAGES: [[@LINE-1]]:20: warning: redundant string initialization 
[readability-redundant-string-init]
+  // CHECK-FIXES: std::string_view a;
+  std::str

[PATCH] D91035: [NFC, Refactor] Convert FunctionDefinitionKind from DeclSpech.h to a scoped enum

2020-11-20 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

*ping*


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91035/new/

https://reviews.llvm.org/D91035

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90282: [clang-tidy] Add IgnoreShortNames config to identifier naming checks

2020-11-20 Thread Shane via Phabricator via cfe-commits
smhc updated this revision to Diff 306686.
smhc added a comment.

Updated diff to use 'IgnoredRegexp'
I see that a regexp has been used elsewhere for some other checks (macro usage, 
AllowedRegexp).

(as a side note, I see that AllowedRegexp string is getting compiled on every 
match rather than pre-compiling, the lack of a copy constructor on llvm::Regex 
makes it trickier to work with)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90282/new/

https://reviews.llvm.org/D90282

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignore-regexp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignore-regexp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignore-regexp.cpp
@@ -0,0 +1,43 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.ParameterIgnoredRegexp, value: "^[a-z]{1,2}$"}, \
+// RUN: {key: readability-identifier-naming.ClassCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.ClassIgnoredRegexp, value: "^fo$|^fooo$"}, \
+// RUN: {key: readability-identifier-naming.StructCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.StructIgnoredRegexp, value: "sooo|so|soo|$o["} \
+// RUN:  ]}'
+
+int testFunc(int a, char **b);
+int testFunc(int ab, char **ba);
+int testFunc(int abc, char **cba);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'abc'
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'cba'
+// CHECK-FIXES: {{^}}int testFunc(int Abc, char **Cba);{{$}}
+int testFunc(int Abc, char **Cba);
+
+class fo {
+};
+
+class fofo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'fofo'
+  // CHECK-FIXES: {{^}}class Fofo {{{$}}
+};
+
+class foo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'foo'
+  // CHECK-FIXES: {{^}}class Foo {{{$}}
+};
+
+class fooo {
+};
+
+class afooo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'afooo'
+  // CHECK-FIXES: {{^}}class Afooo {{{$}}
+};
+
+struct soo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'soo'
+  // CHECK-FIXES: {{^}}struct Soo {{{$}}
+};
Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -20,7 +20,8 @@
  - ``aNy_CasE``.
 
 It also supports a fixed prefix and suffix that will be prepended or appended
-to the identifiers, regardless of the casing.
+to the identifiers, regardless of the casing. A threshold for the length of
+the identifer may be specified to suppress the checks for short names.
 
 Many configuration options are available, in order to be able to create
 different rules for different kinds of identifiers. In general, the rules are
@@ -35,60 +36,60 @@
 
 The following options are describe below:
 
- - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`
+ - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`
  - :option:`AggressiveDependentMemberLookup`
- - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`
- - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`
- - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`
- - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix`
- - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`ConstantSuffix`
- - :option:`ConstantMemberCase`, :option:`ConstantMemberPrefix`, :option:`ConstantMemberSuffix`
- - :option:`ConstantParameterCase`, :option:`ConstantParameterPrefix`, :option:`ConstantParameterSuffix`
- - :option:`ConstantPointerParameterCase`, :option:`ConstantPointerParameterPrefix`, :option:`ConstantPointerParameterSuffix`
- - :option:`ConstexprFunctionCase`, :option:`ConstexprFunctionPrefix`, :option:`ConstexprFunctionSuffix`
- - :option:`ConstexprMethodCase`, :option:`ConstexprMethodPrefix`, :option:`ConstexprMethodSuffix`
- - :option:`ConstexprVariableCase`, :option:`ConstexprVariablePrefix`, :option:`ConstexprVariableSuffix`
- - :option:`EnumCase`, :option:`

[PATCH] D90282: [clang-tidy] Add IgnoreShortNames config to identifier naming checks

2020-11-20 Thread Shane via Phabricator via cfe-commits
smhc updated this revision to Diff 306687.
smhc added a comment.

removed notes on short length threshold


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90282/new/

https://reviews.llvm.org/D90282

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignore-regexp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignore-regexp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignore-regexp.cpp
@@ -0,0 +1,43 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.ParameterIgnoredRegexp, value: "^[a-z]{1,2}$"}, \
+// RUN: {key: readability-identifier-naming.ClassCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.ClassIgnoredRegexp, value: "^fo$|^fooo$"}, \
+// RUN: {key: readability-identifier-naming.StructCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.StructIgnoredRegexp, value: "sooo|so|soo|$o["} \
+// RUN:  ]}'
+
+int testFunc(int a, char **b);
+int testFunc(int ab, char **ba);
+int testFunc(int abc, char **cba);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'abc'
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'cba'
+// CHECK-FIXES: {{^}}int testFunc(int Abc, char **Cba);{{$}}
+int testFunc(int Abc, char **Cba);
+
+class fo {
+};
+
+class fofo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'fofo'
+  // CHECK-FIXES: {{^}}class Fofo {{{$}}
+};
+
+class foo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'foo'
+  // CHECK-FIXES: {{^}}class Foo {{{$}}
+};
+
+class fooo {
+};
+
+class afooo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'afooo'
+  // CHECK-FIXES: {{^}}class Afooo {{{$}}
+};
+
+struct soo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'soo'
+  // CHECK-FIXES: {{^}}struct Soo {{{$}}
+};
Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -35,60 +35,60 @@
 
 The following options are describe below:
 
- - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`
+ - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`
  - :option:`AggressiveDependentMemberLookup`
- - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`
- - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`
- - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`
- - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix`
- - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`ConstantSuffix`
- - :option:`ConstantMemberCase`, :option:`ConstantMemberPrefix`, :option:`ConstantMemberSuffix`
- - :option:`ConstantParameterCase`, :option:`ConstantParameterPrefix`, :option:`ConstantParameterSuffix`
- - :option:`ConstantPointerParameterCase`, :option:`ConstantPointerParameterPrefix`, :option:`ConstantPointerParameterSuffix`
- - :option:`ConstexprFunctionCase`, :option:`ConstexprFunctionPrefix`, :option:`ConstexprFunctionSuffix`
- - :option:`ConstexprMethodCase`, :option:`ConstexprMethodPrefix`, :option:`ConstexprMethodSuffix`
- - :option:`ConstexprVariableCase`, :option:`ConstexprVariablePrefix`, :option:`ConstexprVariableSuffix`
- - :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix`
- - :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix`
- - :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix`
+ - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`, :option:`ClassIgnoredRegexp`
+ - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`, :option:`ClassConstantIgnoredRegexp`
+ - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`, :option:`ClassMemberIgnoredRegexp`
+ - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix`, :option:`ClassMethodIgnoredRegexp`
+ - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`Const

[PATCH] D91035: [NFC, Refactor] Convert FunctionDefinitionKind from DeclSpech.h to a scoped enum

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Sema/DeclSpec.h:1756
 /// a function.
-enum FunctionDefinitionKind {
-  FDK_Declaration,
-  FDK_Definition,
-  FDK_Defaulted,
-  FDK_Deleted
+enum class FunctionDefinitionKind : unsigned char {
+  Declaration,

We don't gain a whole lot by making this `unsigned char` since we're not 
storing it anywhere -- leave as the default `int` and change the 
`static_cast<>`s?



Comment at: clang/lib/Sema/SemaDecl.cpp:9163
 switch (D.getFunctionDefinitionKind()) {
-  case FDK_Declaration:
-  case FDK_Definition:
+  case FunctionDefinitionKind::Declaration:
+  case FunctionDefinitionKind::Definition:

Might as well hit these formatting fixes since we're touching the lines anyway.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91035/new/

https://reviews.llvm.org/D91035

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-11-20 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis updated this revision to Diff 306690.
abelkocsis added a comment.

Fix, `MacroName == "__unix__"` seems really necessary. Without that, it throws 
a warning for me on Linux.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75229/new/

https://reviews.llvm.org/D75229

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-in-multithreaded-program.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con37-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-std_thread.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-thrd_create.c
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-std_thread.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-thrd_create.c

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-thrd_create.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-thrd_create.c
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t
+
+typedef unsigned long int thrd_t;
+typedef int (*thrd_start_t)(void *);
+typedef int sig_atomic_t;
+#define SIGUSR1 30
+#define NULL 0
+
+void (*signal(int sig, void (*handler)(int)))(int);
+
+int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) { return 0; };
+enum {
+  thrd_success = 0,
+};
+
+volatile sig_atomic_t flag = 0;
+
+void handler(int signum) {
+  flag = 1;
+}
+
+int func(void *data) {
+  while (!flag) {
+  }
+  return 0;
+}
+
+int main(void) {
+  signal(SIGUSR1, handler);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: signal function should not be called in a multithreaded program [bugprone-signal-in-multithreaded-program]
+  thrd_t tid;
+
+  if (thrd_success != thrd_create(&tid, func, NULL)) {
+  }
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-std_thread.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-std_thread.cpp
@@ -0,0 +1,35 @@
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t
+
+typedef int sig_atomic_t;
+#define SIGUSR1 30
+#define NULL 0
+
+void (*signal(int sig, void (*handler)(int)))(int);
+
+volatile sig_atomic_t flag = 0;
+
+void handler(int signum) {
+  flag = 1;
+}
+
+void threadFunction() {}
+
+namespace std {
+class thread {
+public:
+  thread() noexcept;
+  template 
+  explicit thread(Function &&f, Args &&... args);
+  thread(const thread &) = delete;
+  thread(thread &&) noexcept;
+};
+} // namespace std
+
+int main() {
+  signal(SIGUSR1, handler);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: signal function should not be called in a multithreaded program [bugprone-signal-in-multithreaded-program]
+
+  std::thread threadObj(threadFunction);
+
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-thrd_create.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-thrd_create.c
@@ -0,0 +1,38 @@
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: bugprone-signal-in-multithreaded-program.ThreadList, value: "thrd_create"}]}'
+
+typedef unsigned long int thrd_t;
+typedef int (*thrd_start_t)(void *);
+typedef int sig_atomic_t;
+#define SIGUSR1 30
+#define NULL 0
+
+void (*signal(int sig, void (*handler)(int)))(int);
+
+int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) { return 0; };
+enum {
+  thrd_success = 0,
+};
+
+volatile sig_atomic_t flag = 0;
+
+void handler(int signum) {
+  flag = 1;
+}
+
+int func(void *data) {
+  while (!flag) {
+  }
+  return 0;
+}
+
+int main(void) {
+  signal(SIGUSR1, handler);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: signal function should not be called in a multithreaded program [bugprone-signal-in-multithreaded-program]
+  thrd_t tid;
+
+  if (thrd_success != thrd_create(&tid, func, NULL)) {
+  }
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-std_thread.cpp
=

[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-11-20 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis added a comment.

In D75229#2406758 , @jfb wrote:

> Most of the tests as written should be failing right now, at least on macOS 
> and Linux, because they likely should be identified as POSIX, right?

Yes, now it fails on my system too. What would be the solution?


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75229/new/

https://reviews.llvm.org/D75229

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91373: [OpenMP5.0] Support more kinds of lvalues in map clauses

2020-11-20 Thread Jacob Weightman via Phabricator via cfe-commits
jacobdweightman added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91373/new/

https://reviews.llvm.org/D91373

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 51e09e1 - [AMDGPU] Set the default globals address space to 1

2020-11-20 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2020-11-20T15:46:53Z
New Revision: 51e09e1d5aa43296cf8baf26a74793fd86b0b0d2

URL: 
https://github.com/llvm/llvm-project/commit/51e09e1d5aa43296cf8baf26a74793fd86b0b0d2
DIFF: 
https://github.com/llvm/llvm-project/commit/51e09e1d5aa43296cf8baf26a74793fd86b0b0d2.diff

LOG: [AMDGPU] Set the default globals address space to 1

This will ensure that passes that add new global variables will create them
in address space 1 once the passes have been updated to no longer default
to the implicit address space zero.
This also changes AutoUpgrade.cpp to add -G1 to the DataLayout if it wasn't
already to present to ensure bitcode backwards compatibility.

Reviewed by: arsenm

Differential Revision: https://reviews.llvm.org/D84345

Added: 


Modified: 
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGVTT.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGen/target-data.c
clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index 9b88dff7c4af..91c1e83f61cb 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -31,12 +31,12 @@ namespace targets {
 
 static const char *const DataLayoutStringR600 =
 "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
-"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5";
+"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1";
 
 static const char *const DataLayoutStringAMDGCN =
 "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
 "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
-"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
+"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1"
 "-ni:7";
 
 const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {

diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index c41650ad2b3b..5bd484eb1464 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -2508,12 +2508,16 @@ void CodeGenFunction::InitializeVTablePointer(const 
VPtr &Vptr) {
 
   // Finally, store the address point. Use the same LLVM types as the field to
   // support optimization.
+  unsigned GlobalsAS = CGM.getDataLayout().getDefaultGlobalsAddressSpace();
+  unsigned ProgAS = CGM.getDataLayout().getProgramAddressSpace();
   llvm::Type *VTablePtrTy =
   llvm::FunctionType::get(CGM.Int32Ty, /*isVarArg=*/true)
-  ->getPointerTo()
-  ->getPointerTo();
-  VTableField = Builder.CreateBitCast(VTableField, 
VTablePtrTy->getPointerTo());
-  VTableAddressPoint = Builder.CreateBitCast(VTableAddressPoint, VTablePtrTy);
+  ->getPointerTo(ProgAS)
+  ->getPointerTo(GlobalsAS);
+  VTableField = Builder.CreatePointerBitCastOrAddrSpaceCast(
+  VTableField, VTablePtrTy->getPointerTo(GlobalsAS));
+  VTableAddressPoint = Builder.CreatePointerBitCastOrAddrSpaceCast(
+  VTableAddressPoint, VTablePtrTy);
 
   llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, 
VTableField);
   TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTablePtrTy);

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index ced45eca4ba6..84733369a4a1 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -3075,11 +3075,12 @@ void CGOpenMPRuntime::createOffloadEntry(
   llvm::GlobalValue::InternalLinkage, StrPtrInit, StringName);
   Str->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
 
-  llvm::Constant *Data[] = {llvm::ConstantExpr::getBitCast(ID, CGM.VoidPtrTy),
-llvm::ConstantExpr::getBitCast(Str, CGM.Int8PtrTy),
-llvm::ConstantInt::get(CGM.SizeTy, Size),
-llvm::ConstantInt::get(CGM.Int32Ty, Flags),
-llvm::ConstantInt::get(CGM.Int32Ty, 0)};
+  llvm::Constant *Data[] = {
+  llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(ID, CGM.VoidPtrTy),
+  llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(Str, CGM.Int8PtrTy),
+  llvm::ConstantInt::get(CGM.SizeTy, Size),
+  llvm::ConstantInt::get(CGM.Int32Ty, Flags),
+  llvm::ConstantInt::get(CGM.Int32Ty, 0)};
   std::string EntryName = getName({"omp_offloading", "entry", ""});
   llvm::GlobalVariable *Entry = createGlobalStruct(
   CGM, getTgtOffloadEntryQTy(), /*IsConstant=*/true, Data,

diff  --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp
index e79f3f3dd8bc..564d9f354e64 100644
--- a/clang/lib/Cod

[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-11-20 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG51e09e1d5aa4: [AMDGPU] Set the default globals address space 
to 1 (authored by arichardson).

Changed prior to commit:
  https://reviews.llvm.org/D84345?vs=289235&id=306693#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84345/new/

https://reviews.llvm.org/D84345

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGVTT.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp

Index: llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
===
--- llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
+++ llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
@@ -27,6 +27,10 @@
  "-f80:32-n8:16:32-S32");
   EXPECT_EQ(DL3, "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128"
  "-n32:64-S128");
+
+  // Check that AMDGPU targets add -G1 if it's not present.
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:32:32", "r600"), "e-p:32:32-G1");
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:64:64", "amdgcn"), "e-p:64:64-G1");
 }
 
 TEST(DataLayoutUpgradeTest, NoDataLayoutUpgrade) {
@@ -46,6 +50,13 @@
   EXPECT_EQ(DL2, "e-p:32:32");
   EXPECT_EQ(DL3, "e-m:e-i64:64-n32:64");
   EXPECT_EQ(DL4, "e-m:o-i64:64-i128:128-n32:64-S128");
+
+  // Check that AMDGPU targets don't add -G1 if there is already a -G flag.
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:32:32-G2", "r600"), "e-p:32:32-G2");
+  EXPECT_EQ(UpgradeDataLayoutString("G2", "r600"), "G2");
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:64:64-G2", "amdgcn"), "e-p:64:64-G2");
+  EXPECT_EQ(UpgradeDataLayoutString("G2-e-p:64:64", "amdgcn"), "G2-e-p:64:64");
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:64:64-G0", "amdgcn"), "e-p:64:64-G0");
 }
 
 TEST(DataLayoutUpgradeTest, EmptyDataLayout) {
@@ -54,6 +65,10 @@
   "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128", "");
   EXPECT_EQ(DL1, "");
   EXPECT_EQ(DL2, "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128");
+
+  // Check that AMDGPU targets add G1 if it's not present.
+  EXPECT_EQ(UpgradeDataLayoutString("", "r600"), "G1");
+  EXPECT_EQ(UpgradeDataLayoutString("", "amdgcn"), "G1");
 }
 
 } // end namespace
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -342,15 +342,15 @@
 static StringRef computeDataLayout(const Triple &TT) {
   if (TT.getArch() == Triple::r600) {
 // 32-bit pointers.
-  return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
- "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5";
+return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
+   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1";
   }
 
   // 32-bit private, local, and region pointers. 64-bit global, constant and
   // flat, non-integral buffer fat pointers.
-return "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
+  return "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
  "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
- "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
+ "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1"
  "-ni:7";
 }
 
Index: llvm/lib/IR/AutoUpgrade.cpp
===
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -4380,11 +4380,17 @@
 }
 
 std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
-  StringRef AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
+  Triple T(TT);
+  // For AMDGPU we uprgrade older DataLayouts to include the default globals
+  // address space of 1.
+  if (T.isAMDGPU() && !DL.contains("-G") && !DL.startswith("G")) {
+return DL.empty() ? std::string("G1") : (DL + "-G1").str();
+  }
 
+  std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
   // If X86, and the datalayout matches the expected format, add pointer size
   // address spaces to the datalayout.
-  if (!Triple(TT).isX86() || DL.contains(AddrSpaces))
+  if (!T.isX86() || DL.contains(AddrSpaces))
 return std::string(DL);
 
   SmallVector Groups;
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -215,7 +215,7 @@
 GV->setAlignment(Align(8));
 Ident = GV;
   }
-  return Ident;
+  return Builder

[PATCH] D89684: [AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.

2020-11-20 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked 5 inline comments as done.
ZarkoCA added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1443
 
+  if (Arg *A =
+  Args.getLastArg(OPT_mabi_EQ_vec_default, OPT_mabi_EQ_vec_extabi)) {

Xiangling_L wrote:
> Should we also check if target feature altivec[`-target-feature +altivec`] is 
> enabled when using these two options? If so, we should also add related 
> testcases.
Both of these options require that -maltivec is also selected which sets 
`-target-feature +altivec`.



Comment at: clang/test/CodeGen/altivec.c:2
 // RUN: %clang_cc1 -target-feature +altivec -triple powerpc-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s
-
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple 
powerpc-unknown-aix -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -target-feature +altivec -mabi=vec-extabi -triple 
powerpc64-unknown-aix -emit-llvm %s -o - | FileCheck %s

Xiangling_L wrote:
> ZarkoCA wrote:
> > Xiangling_L wrote:
> > > Based on the code added in `BackendUtil:551`, should we also add a case 
> > > for compiling a source to assembly?
> > Added in lines 15-18
> > Added in lines 15-18
> 
> Sorry, I should make my point clearer. Based on current testcases, there are 
> two things:
> 
> 1. line 15-18 are actually duplication to 10,11, 13. 14. Because all of them 
> are testing if the driver will emit error when not specifying -maltivec with 
> -mabi=vec-default/-mabi=vec-extabi, i.e compiling from .c to .ll and .c to .s 
> won't affect how driver works,
> 
> 2. `BackendUtil:551` The code I mentioned is actually affecting how BE 
> behaves when we enable AIX altivec in the FE[or driver]. So the testcase I am 
> looking for is something like:
> 
> ```
> // RUN:  %clang -target powerpc-unknown-aix -S -maltivec -mabi=vec-extabi %s  
> | FileCheck  %s
> // CHECK: LLVM ERROR: the extended Altivec AIX ABI is not yet supported
> ```
As far as I understand, testing the assembly path is a bit tricky mainly due to 
how Altivec is determined to be on for all powerpc targets.  

The tests in this file won't trigger the Altivec ABI errors because they are 
calling convention ABIs and there is no parameter passing or returns.  In fact, 
they will generate assembly because the default CPU has the Altivec attribute 
enabled.

I wrote tests that will use the Altivec calling convention ABI in those cases 
we  trigger earlier errors such as "vector type is unimplemented on AIX". 

But, I did a test which shows that the driver passes the `-mabi=vec-extabi` 
option. 



Comment at: llvm/test/CodeGen/PowerPC/aix-func-dsc-gen.ll:2
-; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff 
-filetype=obj -o %t.o < %s
+; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mattr=-altivec -mtriple 
powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s
 ; RUN: llvm-readobj  --symbols %t.o | FileCheck %s
 

Xiangling_L wrote:
> I am not sure if this is for all testcases where you add `-mattr=-altivec`, 
> but I tried the first three. They all passed without this option. Could you 
> double check this?
You're right,it doesn't look like it's needed any longer. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89684/new/

https://reviews.llvm.org/D89684

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89684: [AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.

2020-11-20 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 306696.
ZarkoCA marked an inline comment as done.
ZarkoCA added a comment.

Addressed comments and added a test to check whether the driver passes these 
options.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89684/new/

https://reviews.llvm.org/D89684

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/altivec.c
  clang/test/CodeGen/ppc64-vector.c
  clang/test/Driver/aix-vec-extabi.c
  clang/test/Preprocessor/aix-vec_extabi.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/aix-vec-abi.ll

Index: llvm/test/CodeGen/PowerPC/aix-vec-abi.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-vec-abi.ll
@@ -0,0 +1,12 @@
+; RUN: not --crash llc < %s -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr8 2>&1 | FileCheck %s --check-prefix=DFLTERROR
+; RUN: not --crash llc < %s -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr8 2>&1 | FileCheck %s --check-prefix=DFLTERROR
+
+; RUN: not --crash llc < %s -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr8 -vec-extabi 2>&1 | FileCheck %s --check-prefix=VEXTERROR
+; RUN: not --crash llc < %s -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr8 -vec-extabi 2>&1 | FileCheck %s --check-prefix=VEXTERROR
+
+define void @vec_callee(<4 x i32> %vec1) {
+ret void 
+}
+
+; DFLTERROR:  LLVM ERROR: the default Altivec AIX ABI is not yet supported
+; VEXTERROR:  LLVM ERROR: the extended Altivec AIX ABI is not yet supported
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -6968,6 +6968,16 @@
   const Align PtrAlign = IsPPC64 ? Align(8) : Align(4);
   const MVT RegVT = IsPPC64 ? MVT::i64 : MVT::i32;
 
+  if (ValVT.isVector() && !State.getMachineFunction()
+   .getTarget()
+   .Options.EnableAIXExtendedAltivecABI)
+report_fatal_error("the default Altivec AIX ABI is not yet supported");
+
+  if (ValVT.isVector() && State.getMachineFunction()
+  .getTarget()
+  .Options.EnableAIXExtendedAltivecABI)
+report_fatal_error("the extended Altivec AIX ABI is not yet supported");
+
   assert((!ValVT.isInteger() ||
   (ValVT.getFixedSizeInBits() <= RegVT.getFixedSizeInBits())) &&
  "Integer argument exceeds register size: should have been legalized");
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -58,6 +58,7 @@
 CGOPT(bool, EnableNoNaNsFPMath)
 CGOPT(bool, EnableNoSignedZerosFPMath)
 CGOPT(bool, EnableNoTrappingFPMath)
+CGOPT(bool, EnableAIXExtendedAltivecABI)
 CGOPT(DenormalMode::DenormalModeKind, DenormalFPMath)
 CGOPT(DenormalMode::DenormalModeKind, DenormalFP32Math)
 CGOPT(bool, EnableHonorSignDependentRoundingFPMath)
@@ -282,6 +283,11 @@
   cl::init(false));
   CGBINDOPT(DontPlaceZerosInBSS);
 
+  static cl::opt EnableAIXExtendedAltivecABI(
+  "vec-extabi", cl::desc("Enable the AIX Extended Altivec ABI."),
+  cl::init(false));
+  CGBINDOPT(EnableAIXExtendedAltivecABI);
+
   static cl::opt EnableGuaranteedTailCallOpt(
   "tailcallopt",
   cl::desc(
@@ -516,6 +522,7 @@
   getEnableHonorSignDependentRoundingFPMath();
   if (getFloatABIForCalls() != FloatABI::Default)
 Options.FloatABIType = getFloatABIForCalls();
+  Options.EnableAIXExtendedAltivecABI = getEnableAIXExtendedAltivecABI();
   Options.NoZerosInBSS = getDontPlaceZerosInBSS();
   Options.GuaranteedTailCallOpt = getEnableGuaranteedTailCallOpt();
   Options.StackAlignmentOverride = getOverrideStackAlignment();
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -124,6 +124,7 @@
 TargetOptions()
 : UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false),
   NoTrappingFPMath(true), NoSignedZerosFPMath(false),
+  EnableAIXExtendedAltivecABI(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
   EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
@@ -175,6 +176,12 @@
 /// argument

[PATCH] D90928: [OpenCL] Check for extension string extension lookup

2020-11-20 Thread Erik Tomusk via Phabricator via cfe-commits
erik2020 added a comment.

In D90928#2405796 , @Anastasia wrote:

> Do you think we could improve testing? I presume there is something that 
> triggers a failure without your change...

I'm not really sure how to test this code. Best I can tell, there's no way for 
the `clang` executable to call these functions with invalid strings. I only ran 
into the seg faults when I was programmatically setting options using the clang 
API.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90928/new/

https://reviews.llvm.org/D90928

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91872: [libTooling] Update Transformer's `node` combinator to include the trailing semicolon for decls.

2020-11-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: tdl-g.
Herald added a project: clang.
ymandel requested review of this revision.

Currently, `node` only includes the semicolon for (some) statements. However,
declarations have the same issue of trailing semicolons, so `node` should behave
the same for them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91872

Files:
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/lib/Tooling/Transformer/RangeSelector.cpp


Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -142,7 +142,8 @@
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
   return Node.takeError();
-return Node->get() != nullptr && Node->get() == nullptr
+return (Node->get() != nullptr ||
+(Node->get() != nullptr && Node->get() == nullptr))
? tooling::getExtendedRange(*Node, tok::TokenKind::semi,
*Result.Context)
: CharSourceRange::getTokenRange(Node->getSourceRange());
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -61,8 +61,8 @@
   return enclose(after(std::move(R1)), before(std::move(R2)));
 }
 
-/// Selects a node, including trailing semicolon (for non-expression
-/// statements). \p ID is the node's binding in the match result.
+/// Selects a node, including trailing semicolon (for declarations and
+/// non-expression statements). \p ID is the node's binding in the match 
result.
 RangeSelector node(std::string ID);
 
 /// Selects a node, including trailing semicolon (always). Useful for selecting


Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -142,7 +142,8 @@
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
   return Node.takeError();
-return Node->get() != nullptr && Node->get() == nullptr
+return (Node->get() != nullptr ||
+(Node->get() != nullptr && Node->get() == nullptr))
? tooling::getExtendedRange(*Node, tok::TokenKind::semi,
*Result.Context)
: CharSourceRange::getTokenRange(Node->getSourceRange());
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -61,8 +61,8 @@
   return enclose(after(std::move(R1)), before(std::move(R2)));
 }
 
-/// Selects a node, including trailing semicolon (for non-expression
-/// statements). \p ID is the node's binding in the match result.
+/// Selects a node, including trailing semicolon (for declarations and
+/// non-expression statements). \p ID is the node's binding in the match result.
 RangeSelector node(std::string ID);
 
 /// Selects a node, including trailing semicolon (always). Useful for selecting
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89651: [clang-tidy] Add bugprone-suspicious-memory-comparison check

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for the new check!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89651/new/

https://reviews.llvm.org/D89651

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91872: [libTooling] Update Transformer's `node` combinator to include the trailing semicolon for decls.

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Drive-by question from the peanut gallery, sorry if this is an ignorant one -- 
not all declarations have a trailing semicolon; is that handled properly? e.g., 
`int x;` has a trailing semicolon but `int x, y;` only has a trailing semicolon 
for one of the two declarations. Relatedly, in `int f(int x);`, the declaration 
of `f` has a trailing semicolon, but the declaration of `x` does not.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91872/new/

https://reviews.llvm.org/D91872

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91806: [SVE] Remove warning from debug info on scalable vector.

2020-11-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli marked an inline comment as done.
fpetrogalli added a comment.

Thank you for the review @sdesmalen

1. I have replied to the comment about `auto` with my reason for removing it.
2. I removed the C test, as the LL file is enough.
3. The third comment requires more investigation, I'll get back to you to see 
the use of the `TypeSize` comparisons.

Thank you!




Comment at: llvm/lib/IR/IntrinsicInst.cpp:56
+Optional DbgVariableIntrinsic::getFragmentSizeInBits() const {
+  if (Optional Fragment =
+  getExpression()->getFragmentInfo())

sdesmalen wrote:
> Change back to `auto` ?
I'd like to keep this, because it seems to me the use of auto in this case 
didn't fit in the cases mentioned in 
https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable.
 There is no direct type deduction from the context around the initialization 
of the variable `Fragment`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91806/new/

https://reviews.llvm.org/D91806

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91874: [GNU ObjC] Fix a regression listing methods twice.

2020-11-20 Thread David Chisnall via Phabricator via cfe-commits
theraven created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
theraven requested review of this revision.

Methods synthesized from declared properties were being added to the
method lists twice.  This came from the change to list them in the
class's method list, which missed removing the place in CGObjCGNU that
added them again.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91874

Files:
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/test/CodeGenObjC/gnu-method-only-once.m


Index: clang/test/CodeGenObjC/gnu-method-only-once.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/gnu-method-only-once.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm 
-fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s -check-prefix=CHECK-NEW
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm 
-fobjc-runtime=gnustep-1.8 -o - %s | FileCheck %s -check-prefix=CHECK-OLD
+
+// Clang 9 or 10 changed the handling of method lists so that methods provided
+// from synthesised properties showed up in the method list, where previously
+// CGObjCGNU had to collect them and merge them.  One of the places where this
+// merging happened was missed in the move and so we ended up emitting two
+// copies of method metadata for everything that appeared in the 
+
+// This class has only instance properties and only one pair of synthesized
+// methods from the property and so we should synthesize only one method list,
+// with precisely two methods on it.
+@interface X
+@property (retain) id iProp;
+@end
+
+@implementation X
+@synthesize iProp;
+@end
+
+// Check that the method list has precisely 2 methods.
+// CHECK-NEW: @.objc_method_list = internal global { i8*, i32, i64, [2 x
+// CHECK-OLD: @.objc_method_list = internal global { i8*, i32, [2 x
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -3512,19 +3512,6 @@
   ClassMethods.insert(ClassMethods.begin(), OID->classmeth_begin(),
   OID->classmeth_end());
 
-  // Collect the same information about synthesized properties, which don't
-  // show up in the instance method lists.
-  for (auto *propertyImpl : OID->property_impls())
-if (propertyImpl->getPropertyImplementation() ==
-ObjCPropertyImplDecl::Synthesize) {
-  auto addPropertyMethod = [&](const ObjCMethodDecl *accessor) {
-if (accessor)
-  InstanceMethods.push_back(accessor);
-  };
-  addPropertyMethod(propertyImpl->getGetterMethodDecl());
-  addPropertyMethod(propertyImpl->getSetterMethodDecl());
-}
-
   llvm::Constant *Properties = GeneratePropertyList(OID, ClassDecl);
 
   // Collect the names of referenced protocols


Index: clang/test/CodeGenObjC/gnu-method-only-once.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/gnu-method-only-once.m
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm -fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s -check-prefix=CHECK-NEW
+// RUN: %clang_cc1 -triple x86_64-unknown-freebsd -S -emit-llvm -fobjc-runtime=gnustep-1.8 -o - %s | FileCheck %s -check-prefix=CHECK-OLD
+
+// Clang 9 or 10 changed the handling of method lists so that methods provided
+// from synthesised properties showed up in the method list, where previously
+// CGObjCGNU had to collect them and merge them.  One of the places where this
+// merging happened was missed in the move and so we ended up emitting two
+// copies of method metadata for everything that appeared in the 
+
+// This class has only instance properties and only one pair of synthesized
+// methods from the property and so we should synthesize only one method list,
+// with precisely two methods on it.
+@interface X
+@property (retain) id iProp;
+@end
+
+@implementation X
+@synthesize iProp;
+@end
+
+// Check that the method list has precisely 2 methods.
+// CHECK-NEW: @.objc_method_list = internal global { i8*, i32, i64, [2 x
+// CHECK-OLD: @.objc_method_list = internal global { i8*, i32, [2 x
Index: clang/lib/CodeGen/CGObjCGNU.cpp
===
--- clang/lib/CodeGen/CGObjCGNU.cpp
+++ clang/lib/CodeGen/CGObjCGNU.cpp
@@ -3512,19 +3512,6 @@
   ClassMethods.insert(ClassMethods.begin(), OID->classmeth_begin(),
   OID->classmeth_end());
 
-  // Collect the same information about synthesized properties, which don't
-  // show up in the instance method lists.
-  for (auto *propertyImpl : OID->property_impls())
-if (propertyImpl->getPropertyImplementation() ==
-ObjCPropertyImplDecl::Synthesize) {
-  auto addPropertyMethod = [&](const ObjCMethodDecl *accessor) {
-if (accessor)
-  InstanceMethods.push_back(accessor);
-  };
-  addPropertyMethod(propert

[PATCH] D91874: [GNU ObjC] Fix a regression listing methods twice.

2020-11-20 Thread David Chisnall via Phabricator via cfe-commits
theraven added a comment.

This was caught with the GNUstep runtime's test suite, which apparently had not 
been run with anything newer than clang 8 until recently.  With this patch, all 
of the runtime's tests now pass again (a few others failed in 10 but appear to 
have been fixed in 11 or 12).  We've now configured our CI to test with the 
nightly builds on Linux, so should catch these things sooner in the future.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91874/new/

https://reviews.llvm.org/D91874

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91872: [libTooling] Update Transformer's `node` combinator to include the trailing semicolon for decls.

2020-11-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 306707.
ymandel added a comment.

Clarified that semicolons are only removed if present. Fixed test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91872/new/

https://reviews.llvm.org/D91872

Files:
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/lib/Tooling/Transformer/RangeSelector.cpp


Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -142,7 +142,8 @@
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
   return Node.takeError();
-return Node->get() != nullptr && Node->get() == nullptr
+return (Node->get() != nullptr ||
+(Node->get() != nullptr && Node->get() == nullptr))
? tooling::getExtendedRange(*Node, tok::TokenKind::semi,
*Result.Context)
: CharSourceRange::getTokenRange(Node->getSourceRange());
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -61,8 +61,8 @@
   return enclose(after(std::move(R1)), before(std::move(R2)));
 }
 
-/// Selects a node, including trailing semicolon (for non-expression
-/// statements). \p ID is the node's binding in the match result.
+/// Selects a node, including trailing semicolon, if any (for declarations and
+/// non-expression statements). \p ID is the node's binding in the match 
result.
 RangeSelector node(std::string ID);
 
 /// Selects a node, including trailing semicolon (always). Useful for selecting
Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -148,7 +148,7 @@
   if (Options.get("Skip", "false") == "true")
 return None;
   return tooling::makeRule(clang::ast_matchers::functionDecl(),
-   change(cat("void nothing()")), cat("no message"));
+   changeTo(cat("void nothing();")), cat("no 
message"));
 }
 
 class ConfigurableCheck : public TransformerClangTidyCheck {


Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -142,7 +142,8 @@
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
   return Node.takeError();
-return Node->get() != nullptr && Node->get() == nullptr
+return (Node->get() != nullptr ||
+(Node->get() != nullptr && Node->get() == nullptr))
? tooling::getExtendedRange(*Node, tok::TokenKind::semi,
*Result.Context)
: CharSourceRange::getTokenRange(Node->getSourceRange());
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -61,8 +61,8 @@
   return enclose(after(std::move(R1)), before(std::move(R2)));
 }
 
-/// Selects a node, including trailing semicolon (for non-expression
-/// statements). \p ID is the node's binding in the match result.
+/// Selects a node, including trailing semicolon, if any (for declarations and
+/// non-expression statements). \p ID is the node's binding in the match result.
 RangeSelector node(std::string ID);
 
 /// Selects a node, including trailing semicolon (always). Useful for selecting
Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -148,7 +148,7 @@
   if (Options.get("Skip", "false") == "true")
 return None;
   return tooling::makeRule(clang::ast_matchers::functionDecl(),
-   change(cat("void nothing()")), cat("no message"));
+   changeTo(cat("void nothing();")), cat("no message"));
 }
 
 class ConfigurableCheck : public TransformerClangTidyCheck {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91872: [libTooling] Update Transformer's `node` combinator to include the trailing semicolon for decls.

2020-11-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D91872#2408278 , @aaron.ballman 
wrote:

> Drive-by question from the peanut gallery, sorry if this is an ignorant one 
> -- not all declarations have a trailing semicolon; is that handled properly? 
> e.g., `int x;` has a trailing semicolon but `int x, y;` only has a trailing 
> semicolon for one of the two declarations. Relatedly, in `int f(int x);`, the 
> declaration of `f` has a trailing semicolon, but the declaration of `x` does 
> not.

No, it's a good question -- the comments and the patch description should have 
been clearer.  I've updated both. Also, I found a test that needed to be fixed 
(and also, hopefully, illustrates why the new behavior is preferred. The old 
behavior left the semicolon out of the replacement (which looks weird) because 
it was working around the fact that the source being removed didn't include the 
trailing semicolon, while the new version can just specify the replacement 
correctly).

Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91872/new/

https://reviews.llvm.org/D91872

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91872: [libTooling] Update Transformer's `node` combinator to include the trailing semicolon for decls.

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D91872#2408321 , @ymandel wrote:

> In D91872#2408278 , @aaron.ballman 
> wrote:
>
>> Drive-by question from the peanut gallery, sorry if this is an ignorant one 
>> -- not all declarations have a trailing semicolon; is that handled properly? 
>> e.g., `int x;` has a trailing semicolon but `int x, y;` only has a trailing 
>> semicolon for one of the two declarations. Relatedly, in `int f(int x);`, 
>> the declaration of `f` has a trailing semicolon, but the declaration of `x` 
>> does not.
>
> No, it's a good question -- the comments and the patch description should 
> have been clearer.  I've updated both. Also, I found a test that needed to be 
> fixed (and also, hopefully, illustrates why the new behavior is preferred. 
> The old behavior left the semicolon out of the replacement (which looks 
> weird) because it was working around the fact that the source being removed 
> didn't include the trailing semicolon, while the new version can just specify 
> the replacement correctly).
>
> Thanks!

Thanks, this is more clear now!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91872/new/

https://reviews.llvm.org/D91872

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91828: [Sema/Attribute] Ignore noderef attribute in unevaluated context

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Frontend/noderef.c:71
+  x = sizeof(s->a + (s->b)); // ok
+
   // Nested struct access

Can you add tests for the weird situations where the expression actually is 
evaluated? e.g.,
```
struct S {
  virtual ~S(); // Make S polymorphic
};

S NODEREF *s;
typeid(*s); // Actually evaluates *s at runtime

struct T {
  unsigned i;
};

T t1;
T NODEREF *t2 = &t1;

sizeof(int[++t2->i]); // Actually evaluates t2->i at runtime
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91828/new/

https://reviews.llvm.org/D91828

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91567: [llvm][inliner] Reuse the inliner pass to implement 'always inliner'

2020-11-20 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

From a ThinLTO perspective, no specific concerns as the 
buildModuleSimplificationPipeline is invoked in both the pre and post LTO link 
pipelines, so they both get an equivalent change. But there is an issue for 
regular LTO, noted below.




Comment at: llvm/test/Other/new-pm-lto-defaults.ll:70
 ; CHECK-O2-NEXT: Starting llvm::Module pass manager run.
-; CHECK-O2-NEXT: Running pass: AlwaysInlinerPass
 ; CHECK-O2-NEXT: Starting CGSCC pass manager run.

Note there is no corresponding add of an additional InlinerPass like in the 
other files. The reason is that PassBuilder::buildLTODefaultPipeline doesn't 
invoke buildModuleSimplificationPipeline, or even buildInlinerPipeline (it has 
a separate pipeline setup for compile time reasons due to the monolithic nature 
of the post-LTO link compilation), but rather directly adds 
ModuleInlinerWrapperPass. So you'll want to add the additional 
ModuleInlinerWrapperPass invocation there as well.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91567/new/

https://reviews.llvm.org/D91567

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91806: [SVE] Remove warning from debug info on scalable vector.

2020-11-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 306715.
fpetrogalli edited the summary of this revision.
fpetrogalli added a comment.

I have added assertions around before `TypeSize` comparisons where it made 
sense to do so, but not in the lambda used in the `sort` invocation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91806/new/

https://reviews.llvm.org/D91806

Files:
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/lib/Transforms/Utils/Local.cpp
  
llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll

Index: llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstCombine/debug-declare-no-warnings-on-scalable-vectors.ll
@@ -0,0 +1,42 @@
+; RUN: opt -mtriple aarch64-gnu-linux -mattr=+sve -instcombine -S < %s 2>%t | FileCheck %s
+; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
+
+; If this check fails please read
+; clang/test/CodeGen/aarch64-sve-intrinsics/README for instructions on
+; how to resolve it.
+
+; WARN-NOT: warning
+
+; CHECK-LABEL: @debug_local_scalable(
+define  @debug_local_scalable( %tostore) {
+  %vx = alloca , align 16
+  call void @llvm.dbg.declare(metadata * %vx, metadata !5, metadata !DIExpression()), !dbg !15
+  store  %tostore, * %vx, align 16
+  %ret = call  @f(* %vx)
+  ret  %ret
+}
+
+declare  @f(*)
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/tmp/test.c", directory: "/tmp/")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !DILocalVariable(name: "vx", scope: !6, file: !7, line: 26, type: !8)
+!6 = distinct !DISubprogram(name: "debug_local_scalable", scope: null, file: !1, line: 25, scopeLine: 25, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
+!7 = !DIFile(filename: "test.c", directory: "/tmp/")
+!8 = !DIDerivedType(tag: DW_TAG_typedef, name: "svfloat64_t", file: !9, line: 56, baseType: !10)
+!9 = !DIFile(filename: "arm_sve.h", directory: "/tmp/")
+!10 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVFloat64_t", file: !1, baseType: !11)
+!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, flags: DIFlagVector, elements: !13)
+!12 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
+!13 = !{!14}
+!14 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
+!15 = !DILocation(line: 26, column: 15, scope: !6)
Index: llvm/lib/Transforms/Utils/Local.cpp
===
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1368,16 +1368,22 @@
 /// least n bits.
 static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
   const DataLayout &DL = DII->getModule()->getDataLayout();
-  uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy);
-  if (auto FragmentSize = DII->getFragmentSizeInBits())
-return ValueSize >= *FragmentSize;
+  TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
+  if (Optional FragmentSize = DII->getFragmentSizeInBits()) {
+assert(ValueSize.isScalable() == FragmentSize->isScalable() &&
+   "Both sizes should agree on the scalable flag.");
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
+  }
   // We can't always calculate the size of the DI variable (e.g. if it is a
   // VLA). Try to use the size of the alloca that the dbg intrinsic describes
   // intead.
   if (DII->isAddressOfVariable())
 if (auto *AI = dyn_cast_or_null(DII->getVariableLocation()))
-  if (auto FragmentSize = AI->getAllocationSizeInBits(DL))
-return ValueSize >= *FragmentSize;
+  if (Optional FragmentSize = AI->getAllocationSizeInBits(DL)) {
+assert(ValueSize.isScalable() == FragmentSize->isScalable() &&
+   "Both sizes should agree on the scalable flag.");
+return TypeSize::isKnownGE(ValueSize, *FragmentSize);
+  }
   // Could not determine size of variable. Conservatively return false.
   return false;
 }
Index: llvm/lib/Transforms/Utils/Debugify.cpp
===
--- llvm/lib/Transforms/Utils/Debugify.cpp
+++ llvm/lib/Transforms/Utils/Debugify.cpp
@@ -44,8

[PATCH] D91806: [SVE] Remove warning from debug info on scalable vector.

2020-11-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli marked an inline comment as done.
fpetrogalli added inline comments.



Comment at: llvm/lib/Transforms/Coroutines/CoroFrame.cpp:589
   sort(FrameData.Allocas, [&](const auto &Iter1, const auto &Iter2) {
-return GetAllocaSize(Iter1) > GetAllocaSize(Iter2);
+return TypeSize::isKnownGT(GetAllocaSize(Iter1), GetAllocaSize(Iter2));
   });

We don't need to check whether the scalable flag matches here because we are 
sorting a container that (potentially) have both types of vectors.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91806/new/

https://reviews.llvm.org/D91806

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D90282: [clang-tidy] Add IgnoreShortNames config to identifier naming checks

2020-11-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:127-128
 getFileStyleFromOptions(const ClangTidyCheck::OptionsView &Options) {
   SmallVector, 0> Styles(
   SK_Count);
   SmallString<64> StyleString;

Making this change removes the need to NamingStyle to be copy 
constructable/assignable.



Comment at: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h:61
+  ? llvm::Regex()
+  : llvm::Regex("^" + IgnoredRegexpStr + "$");
+}

Potentially save an allocation.

Also is it wise to warn a user on an invalid regex, unfortunately clang-tidy 
doesnt support diags with no source location but could still output to 
llvm::errs.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90282/new/

https://reviews.llvm.org/D90282

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91373: [OpenMP5.0] Support more kinds of lvalues in map clauses

2020-11-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D91373#2408175 , @jacobdweightman 
wrote:

> Ping



1. Provide full diff, see https://www.llvm.org/docs/Phabricator.html for the 
guidance.
2. Need some more test with ast printing and codegen.
3. Would be good if you could run (at least locally) some tests to check that 
the changes really work.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91373/new/

https://reviews.llvm.org/D91373

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-20 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 306724.
zequanwu added a comment.
Herald added a subscriber: dexonsmith.

Add ThreadModel to LangOptions and remove it from CodegenOption.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91747/new/

https://reviews.llvm.org/D91747

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/CXX/cpp/cpp.predefined/p2.cpp
  clang/test/Preprocessor/init-aarch64.c

Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -233,6 +233,7 @@
 // AARCH64-NEXT: #define __SIZE_TYPE__ long unsigned int
 // AARCH64-NEXT: #define __SIZE_WIDTH__ 64
 // AARCH64_CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
+// AARCH64_CXX: #define __STDCPP_THREADS__ 1
 // AARCH64-NEXT: #define __STDC_HOSTED__ 1
 // AARCH64-NEXT: #define __STDC_UTF_16__ 1
 // AARCH64-NEXT: #define __STDC_UTF_32__ 1
Index: clang/test/CXX/cpp/cpp.predefined/p2.cpp
===
--- /dev/null
+++ clang/test/CXX/cpp/cpp.predefined/p2.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 %s -verify
+// expected-no-diagnostics
+
+#ifndef __STDCPP_THREADS__
+#error __STDCPP_THREADS__ is not defined
+#endif
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -403,6 +403,12 @@
 Builder.defineMacro("__STDCPP_DEFAULT_NEW_ALIGNMENT__",
 Twine(TI.getNewAlign() / TI.getCharWidth()) +
 TI.getTypeConstantSuffix(TI.getSizeType()));
+
+//   -- __STDCPP_­THREADS__
+//  Defined, and has the value integer literal 1, if and only if a
+//  program can have more than one thread of execution.
+if (LangOpts.getThreadModel() == LangOptions::ThreadModelKind::POSIX)
+  Builder.defineMacro("__STDCPP_THREADS__", "1");
   }
 
   // In C11 these are environment macros. In C++11 they are only defined
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1037,12 +1037,11 @@
   Opts.StrictVTablePointers = Args.hasArg(OPT_fstrict_vtable_pointers);
   Opts.ForceEmitVTables = Args.hasArg(OPT_fforce_emit_vtables);
   Opts.UnwindTables = Args.hasArg(OPT_munwind_tables);
-  Opts.ThreadModel =
+  std::string ThreadModel =
   std::string(Args.getLastArgValue(OPT_mthread_model, "posix"));
-  if (Opts.ThreadModel != "posix" && Opts.ThreadModel != "single")
+  if (ThreadModel != "posix" && ThreadModel != "single")
 Diags.Report(diag::err_drv_invalid_value)
-<< Args.getLastArg(OPT_mthread_model)->getAsString(Args)
-<< Opts.ThreadModel;
+<< Args.getLastArg(OPT_mthread_model)->getAsString(Args) << ThreadModel;
   Opts.TrapFuncName = std::string(Args.getLastArgValue(OPT_ftrap_function_EQ));
   Opts.UseInitArray = !Args.hasArg(OPT_fno_use_init_array);
 
Index: clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
===
--- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -49,7 +49,7 @@
   const PreprocessorOptions &PreprocessorOpts;
   CodeGenOptions CodeGenOpts;
   const TargetOptions TargetOpts;
-  const LangOptions LangOpts;
+  LangOptions LangOpts;
   std::unique_ptr VMContext;
   std::unique_ptr M;
   std::unique_ptr Builder;
@@ -147,7 +147,7 @@
 // The debug info output isn't affected by CodeModel and
 // ThreadModel, but the backend expects them to be nonempty.
 CodeGenOpts.CodeModel = "default";
-CodeGenOpts.ThreadModel = "single";
+LangOpts.setThreadModel(LangOptions::ThreadModelKind::Single);
 CodeGenOpts.DebugTypeExtRefs = true;
 // When building a module MainFileName is the name of the modulemap file.
 CodeGenOpts.MainFileName =
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -453,10 +453,14 @@
   const clang::TargetOptions &TargetOpts,
   const LangOptions &LangOpts,
   const HeaderSearchOptions &HSOpts) {
-  Options.ThreadModel =
-  llvm::StringSwitch(CodeGenOpts.ThreadModel)
-  .Case("posix", llvm::ThreadModel::POSIX)
-  .Case("single"

[clang] 88e6208 - [libTooling] Update Transformer's `node` combinator to include the trailing semicolon for decls.

2020-11-20 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-11-20T18:11:50Z
New Revision: 88e62085624e7ec55bd4a41c6d77acdcb7f1d113

URL: 
https://github.com/llvm/llvm-project/commit/88e62085624e7ec55bd4a41c6d77acdcb7f1d113
DIFF: 
https://github.com/llvm/llvm-project/commit/88e62085624e7ec55bd4a41c6d77acdcb7f1d113.diff

LOG: [libTooling] Update Transformer's `node` combinator to include the 
trailing semicolon for decls.

Currently, `node` only includes the semicolon for (some) statements. However,
declarations have the same issue of (potentially) trailing semicolons, so `node`
should behave the same for them.

Differential Revision: https://reviews.llvm.org/D91872

Added: 


Modified: 
clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
clang/include/clang/Tooling/Transformer/RangeSelector.h
clang/lib/Tooling/Transformer/RangeSelector.cpp
clang/unittests/Tooling/TransformerTest.cpp

Removed: 




diff  --git 
a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
index 76de7711cee9..536d6f8ef275 100644
--- a/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -148,7 +148,7 @@ Optional noSkip(const LangOptions &LangOpts,
   if (Options.get("Skip", "false") == "true")
 return None;
   return tooling::makeRule(clang::ast_matchers::functionDecl(),
-   change(cat("void nothing()")), cat("no message"));
+   changeTo(cat("void nothing();")), cat("no 
message"));
 }
 
 class ConfigurableCheck : public TransformerClangTidyCheck {

diff  --git a/clang/include/clang/Tooling/Transformer/RangeSelector.h 
b/clang/include/clang/Tooling/Transformer/RangeSelector.h
index e070c0e7e2e6..c6ca193123d1 100644
--- a/clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ b/clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -61,8 +61,8 @@ inline RangeSelector between(RangeSelector R1, RangeSelector 
R2) {
   return enclose(after(std::move(R1)), before(std::move(R2)));
 }
 
-/// Selects a node, including trailing semicolon (for non-expression
-/// statements). \p ID is the node's binding in the match result.
+/// Selects a node, including trailing semicolon, if any (for declarations and
+/// non-expression statements). \p ID is the node's binding in the match 
result.
 RangeSelector node(std::string ID);
 
 /// Selects a node, including trailing semicolon (always). Useful for selecting

diff  --git a/clang/lib/Tooling/Transformer/RangeSelector.cpp 
b/clang/lib/Tooling/Transformer/RangeSelector.cpp
index ce6f5fb9b444..0f3138db218a 100644
--- a/clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ b/clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -142,7 +142,8 @@ RangeSelector transformer::node(std::string ID) {
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
   return Node.takeError();
-return Node->get() != nullptr && Node->get() == nullptr
+return (Node->get() != nullptr ||
+(Node->get() != nullptr && Node->get() == nullptr))
? tooling::getExtendedRange(*Node, tok::TokenKind::semi,
*Result.Context)
: CharSourceRange::getTokenRange(Node->getSourceRange());

diff  --git a/clang/unittests/Tooling/TransformerTest.cpp 
b/clang/unittests/Tooling/TransformerTest.cpp
index 773420c015cd..e4fcc210782f 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -1353,7 +1353,7 @@ void instantiate()
 
   // Changes the 'int' in 'S', but not the 'T' in 'TemplStruct':
   testRule(makeRule(traverse(TK_IgnoreUnlessSpelledInSource, MatchedField),
-changeTo(cat("safe_int ", name("theField",
+changeTo(cat("safe_int ", name("theField"), ";"))),
NonTemplatesInput + TemplatesInput,
NonTemplatesExpected + TemplatesInput);
 
@@ -1378,7 +1378,7 @@ void instantiate()
 
   // Changes the 'int' in 'S', and (incorrectly) the 'T' in 'TemplStruct':
   testRule(makeRule(traverse(TK_AsIs, MatchedField),
-changeTo(cat("safe_int ", name("theField",
+changeTo(cat("safe_int ", name("theField"), ";"))),
 
NonTemplatesInput + TemplatesInput,
NonTemplatesExpected + IncorrectTemplatesExpected);
@@ -1589,7 +1589,7 @@ TEST_F(TransformerTest, MultipleFiles) {
Changes[0].getReplacements());
   ASSERT_TRUE(static_cast(UpdatedCode))
   << "Could not update code: " << llvm::toString(UpdatedCode.takeError());
-  EXPECT_EQ(format(*UpdatedCode), format(R"cc(;)cc"));
+  EXPECT_EQ(format(*UpdatedCode), "");
 
   ASSERT_EQ(Changes[1].getFilePath(), "input.cc");
   EXPECT_THAT(Ch

[PATCH] D91872: [libTooling] Update Transformer's `node` combinator to include the trailing semicolon for decls.

2020-11-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG88e62085624e: [libTooling] Update Transformer's `node` 
combinator to include the trailing… (authored by ymandel).

Changed prior to commit:
  https://reviews.llvm.org/D91872?vs=306707&id=306729#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91872/new/

https://reviews.llvm.org/D91872

Files:
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
  clang/include/clang/Tooling/Transformer/RangeSelector.h
  clang/lib/Tooling/Transformer/RangeSelector.cpp
  clang/unittests/Tooling/TransformerTest.cpp


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -1353,7 +1353,7 @@
 
   // Changes the 'int' in 'S', but not the 'T' in 'TemplStruct':
   testRule(makeRule(traverse(TK_IgnoreUnlessSpelledInSource, MatchedField),
-changeTo(cat("safe_int ", name("theField",
+changeTo(cat("safe_int ", name("theField"), ";"))),
NonTemplatesInput + TemplatesInput,
NonTemplatesExpected + TemplatesInput);
 
@@ -1378,7 +1378,7 @@
 
   // Changes the 'int' in 'S', and (incorrectly) the 'T' in 'TemplStruct':
   testRule(makeRule(traverse(TK_AsIs, MatchedField),
-changeTo(cat("safe_int ", name("theField",
+changeTo(cat("safe_int ", name("theField"), ";"))),
 
NonTemplatesInput + TemplatesInput,
NonTemplatesExpected + IncorrectTemplatesExpected);
@@ -1589,7 +1589,7 @@
Changes[0].getReplacements());
   ASSERT_TRUE(static_cast(UpdatedCode))
   << "Could not update code: " << llvm::toString(UpdatedCode.takeError());
-  EXPECT_EQ(format(*UpdatedCode), format(R"cc(;)cc"));
+  EXPECT_EQ(format(*UpdatedCode), "");
 
   ASSERT_EQ(Changes[1].getFilePath(), "input.cc");
   EXPECT_THAT(Changes[1].getInsertedHeaders(), IsEmpty());
@@ -1598,8 +1598,7 @@
   Source, Changes[1].getReplacements());
   ASSERT_TRUE(static_cast(UpdatedCode))
   << "Could not update code: " << llvm::toString(UpdatedCode.takeError());
-  EXPECT_EQ(format(*UpdatedCode), format(R"cc(#include "input.h"
-;)cc"));
+  EXPECT_EQ(format(*UpdatedCode), format("#include \"input.h\"\n"));
 }
 
 TEST_F(TransformerTest, AddIncludeMultipleFiles) {
Index: clang/lib/Tooling/Transformer/RangeSelector.cpp
===
--- clang/lib/Tooling/Transformer/RangeSelector.cpp
+++ clang/lib/Tooling/Transformer/RangeSelector.cpp
@@ -142,7 +142,8 @@
 Expected Node = getNode(Result.Nodes, ID);
 if (!Node)
   return Node.takeError();
-return Node->get() != nullptr && Node->get() == nullptr
+return (Node->get() != nullptr ||
+(Node->get() != nullptr && Node->get() == nullptr))
? tooling::getExtendedRange(*Node, tok::TokenKind::semi,
*Result.Context)
: CharSourceRange::getTokenRange(Node->getSourceRange());
Index: clang/include/clang/Tooling/Transformer/RangeSelector.h
===
--- clang/include/clang/Tooling/Transformer/RangeSelector.h
+++ clang/include/clang/Tooling/Transformer/RangeSelector.h
@@ -61,8 +61,8 @@
   return enclose(after(std::move(R1)), before(std::move(R2)));
 }
 
-/// Selects a node, including trailing semicolon (for non-expression
-/// statements). \p ID is the node's binding in the match result.
+/// Selects a node, including trailing semicolon, if any (for declarations and
+/// non-expression statements). \p ID is the node's binding in the match 
result.
 RangeSelector node(std::string ID);
 
 /// Selects a node, including trailing semicolon (always). Useful for selecting
Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -148,7 +148,7 @@
   if (Options.get("Skip", "false") == "true")
 return None;
   return tooling::makeRule(clang::ast_matchers::functionDecl(),
-   change(cat("void nothing()")), cat("no message"));
+   changeTo(cat("void nothing();")), cat("no 
message"));
 }
 
 class ConfigurableCheck : public TransformerClangTidyCheck {


Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -1353,7 +1353,7 @@
 

[PATCH] D91565: Guard init_priority attribute within libc++

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/SemaCXX/init-priority-attr.cpp:26
 Two foo __attribute__((init_priority(101))) ( 5, 6 );
+#if defined(__MVS__)
+ #if defined(SYSTEM)

Rather than using the preprocessor, you can assign a prefix to be checked to 
`-verify`. e.g., `-verify=unknown` would allow you to do `// unknown-warning 
{{unknown attribute 'init_priority' ignored}}` or `unknown-no-diagnostics` that 
is only checked when `-verify=unknown`.

I wonder if it would be cleaner to use that solution here instead of the 
preprocessor by adding a new RUN line that's specific to AIX, and setting some 
non-AIX triples for the other run lines.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91565/new/

https://reviews.llvm.org/D91565

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91327: [NewPM] Redesign of PreserveCFG Checker

2020-11-20 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added a comment.

Looks fine to me, but I'm not confident enough to give an approval.




Comment at: llvm/lib/Passes/StandardInstrumentations.cpp:733-735
+  static AnalysisKey Key;
+
+public:

This is already public


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91327/new/

https://reviews.llvm.org/D91327

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87974: [Builtin] Add __builtin_zero_non_value_bits.

2020-11-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

In D87974#2408119 , @jwakely wrote:

> As of a few hours ago, GCC has `__builtin_clear_padding`, see 
> https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbuiltin_005fclear_005fpadding
>  for the docs.

Great. Then I'll update this to be named `__builtin_clear_padding`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D87974/new/

https://reviews.llvm.org/D87974

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86502: [CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe instrumentation.

2020-11-20 Thread Wei Mi via Phabricator via cfe-commits
wmi added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:978-982
   Opts.DebugInfoForProfiling = Args.hasFlag(
   OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling, false);
+  Opts.PseudoProbeForProfiling =
+  Args.hasFlag(OPT_fpseudo_probe_for_profiling,
+   OPT_fno_pseudo_probe_for_profiling, false);

Should it emit an error if DebugInfoForProfiling and PseudoProbeForProfiling 
are enabled at the same time? I see that from the other patch related with 
pseudoprobe discriminator, these two flags are incompatible.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86502/new/

https://reviews.llvm.org/D86502

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86502: [CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe instrumentation.

2020-11-20 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:978-982
   Opts.DebugInfoForProfiling = Args.hasFlag(
   OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling, false);
+  Opts.PseudoProbeForProfiling =
+  Args.hasFlag(OPT_fpseudo_probe_for_profiling,
+   OPT_fno_pseudo_probe_for_profiling, false);

wmi wrote:
> Should it emit an error if DebugInfoForProfiling and PseudoProbeForProfiling 
> are enabled at the same time? I see that from the other patch related with 
> pseudoprobe discriminator, these two flags are incompatible.
Yes, we should. It's done in D91756 passbuilder.h : 
https://reviews.llvm.org/D91756#change-Bsibk2p32T1c for both `clang` and `opt`.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86502/new/

https://reviews.llvm.org/D86502

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8f51dc4 - [OPENMP]Honor constantness of captured variables.

2020-11-20 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-11-20T11:11:47-08:00
New Revision: 8f51dc49673c494cc1d118979b596288e938af13

URL: 
https://github.com/llvm/llvm-project/commit/8f51dc49673c494cc1d118979b596288e938af13
DIFF: 
https://github.com/llvm/llvm-project/commit/8f51dc49673c494cc1d118979b596288e938af13.diff

LOG: [OPENMP]Honor constantness of captured variables.

Fixes bug reported via Stackoverflow:
https://stackoverflow.com/questions/64179168/clang-overload-resolution-failure-with-templates-and-openmp-collapse

Need to honor constantness of private/target variables to  make the code
compilable.

Differential Revision: https://reviews.llvm.org/D91644

Added: 
clang/test/OpenMP/openmp_capture_const_var_ast_print.cpp

Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/OpenMP/distribute_firstprivate_messages.cpp
clang/test/OpenMP/teams_distribute_firstprivate_messages.cpp
clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp

clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
clang/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7a8124fadfd7..60a685bfdf15 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -17468,7 +17468,11 @@ bool Sema::tryCaptureVariable(
   if (IsTargetCap || IsOpenMPPrivateDecl == OMPC_private ||
   (IsGlobal && !IsGlobalCap)) {
 Nested = !IsTargetCap;
+bool HasConst = DeclRefType.isConstQualified();
 DeclRefType = DeclRefType.getUnqualifiedType();
+// Don't lose diagnostics about assignments to const.
+if (HasConst)
+  DeclRefType.addConst();
 CaptureType = Context.getLValueReferenceType(DeclRefType);
 break;
   }

diff  --git a/clang/test/OpenMP/distribute_firstprivate_messages.cpp 
b/clang/test/OpenMP/distribute_firstprivate_messages.cpp
index 346d1a834a86..25a5e9db0eb8 100644
--- a/clang/test/OpenMP/distribute_firstprivate_messages.cpp
+++ b/clang/test/OpenMP/distribute_firstprivate_messages.cpp
@@ -28,8 +28,8 @@ class S3 {
   S3 &operator=(const S3 &s3);
 
 public:
-  S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 
0 arguments, but 1 was provided}}
-  S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 
1st argument ('const S3') would lose const qualifier}}
+  S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: 
requires 0 arguments, but 1 was provided}}
+  S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not 
viable: 1st argument ('const S3') would lose const qualifier}}
 };
 const S3 c;
 const S3 ca[5];
@@ -95,7 +95,7 @@ int main(int argc, char **argv) {
   for (i = 0; i < argc; ++i) foo();
   #pragma omp target
   #pragma omp teams
-  #pragma omp distribute firstprivate (a, b, c, d, f) // expected-error 
{{firstprivate variable with incomplete type 'S1'}} expected-warning {{Type 
'const S2' is not trivially copyable and not guaranteed to be mapped 
correctly}} expected-warning {{Type 'const S3' is not trivially copyable and 
not guaranteed to be mapped correctly}} expected-error {{incomplete type 'S1' 
where a complete type is required}}
+  #pragma omp distribute firstprivate (a, b, c, d, f) // expected-error 
{{firstprivate variable with incomplete type 'S1'}} expected-warning {{Type 
'const S2' is not trivially copyable and not guaranteed to be mapped 
correctly}} expected-warning {{Type 'const S3' is not trivially copyable and 
not guaranteed to be mapped correctly}} expected-error {{incomplete type 'S1' 
where a complete type is required}} expected-error {{no matching constructor 
for initialization of 'S3'}}
   for (i = 0; i < argc; ++i) foo();
   #pragma omp target
   #pragma omp teams

diff  --git a/clang/test/OpenMP/openmp_capture_const_var_ast_print.cpp 
b/clang/test/OpenMP/openmp_capture_const_var_ast_print.cpp
new file mode 100644
index ..4d4b0b00cbaf
--- /dev/null
+++ b/clang/test/OpenMP/openmp_capture_const_var_ast_print.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify 
%s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only 
-verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+struct vector {
+  vector() = default;
+  int at(int) { return 0; }
+  int at(int) const { return 1; }
+};
+
+// CHECK: template  void test(const vector begin_vec) {
+// CHECK:   

[PATCH] D91644: [OPENMP]Honor constantness of captured variables.

2020-11-20 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f51dc49673c: [OPENMP]Honor constantness of captured 
variables. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91644/new/

https://reviews.llvm.org/D91644

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/OpenMP/distribute_firstprivate_messages.cpp
  clang/test/OpenMP/openmp_capture_const_var_ast_print.cpp
  clang/test/OpenMP/teams_distribute_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp

Index: clang/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
+++ clang/test/OpenMP/teams_distribute_simd_firstprivate_messages.cpp
@@ -39,8 +39,8 @@
   S3 &operator=(const S3 &s3);
   
 public:
-  S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
-  S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
+  S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
+  S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
 };
 const S3 c;
 const S3 ca[5];
@@ -110,7 +110,7 @@
   for (i = 0; i < argc; ++i) foo();
 
 #pragma omp target
-#pragma omp teams distribute simd firstprivate (k, a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{incomplete type 'S1' where a complete type is required}}
+#pragma omp teams distribute simd firstprivate (k, a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{incomplete type 'S1' where a complete type is required}} expected-error {{no matching constructor for initialization of 'S3'}}
   for (i = 0; i < argc; ++i) foo();
 
 #pragma omp target
Index: clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_messages.cpp
@@ -38,8 +38,8 @@
   S3 &operator=(const S3 &s3);
   
 public:
-  S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
-  S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
+  S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
+  S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
 };
 const S3 c;
 const S3 ca[5];
@@ -109,7 +109,7 @@
   for (i = 0; i < argc; ++i) foo();
 
 #pragma omp target
-#pragma omp teams distribute parallel for simd firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{incomplete type 'S1' where a complete type is required}}
+#pragma omp teams distribute parallel for simd firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} expected-error {{incomplete type 'S1' where a complete type is required}} expected-error {{no matching constructor for initialization of 'S3'}}
   for (i = 0; i < argc; ++i) foo();
 
 #pragma omp target
Index: clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
===
--- clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
+++ clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_messages.cpp
@@ -37,8 +37,8 @@
   S3 &operator=(const S3 &s3);
   
 public:
-  S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
-  S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
+  S3() : a(0) {} // expected-note 2 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
+  S3(S3 &s3) : a(s3.a) {} // expected-note 2 {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}}
 };
 const S3 c;
 const S3 ca[5];
@@ -108,7 +108,7 @@
   for (i = 0; i < argc; ++i) foo();
 
 #pragma omp target
-#pragma omp teams distribute parallel for firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with 

[PATCH] D91885: [clang-tidy] Add support for diagnostics with no location

2020-11-20 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: alexfh, aaron.ballman.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, nemanjai.
Herald added a project: clang.
njames93 requested review of this revision.

Add methods for emitting diagnostics with no location as well as a special 
diagnostic for configuration errors.
These show up in the errors as [clang-tidy-config].
The reason to use a custom name rather than the check name is to distinguish 
the error isn't the same category as the check that reported it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91885

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -10,7 +10,9 @@
 class TestCheck : public ClangTidyCheck {
 public:
   TestCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  : ClangTidyCheck(Name, Context) {
+diag("DiagWithNoLoc");
+  }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override {
 Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
   }
@@ -26,9 +28,10 @@
 TEST(ClangTidyDiagnosticConsumer, SortsErrors) {
   std::vector Errors;
   runCheckOnCode("int a;", &Errors);
-  EXPECT_EQ(2ul, Errors.size());
-  EXPECT_EQ("type specifier", Errors[0].Message.Message);
-  EXPECT_EQ("variable", Errors[1].Message.Message);
+  EXPECT_EQ(3ul, Errors.size());
+  EXPECT_EQ("DiagWithNoLoc", Errors[0].Message.Message);
+  EXPECT_EQ("type specifier", Errors[1].Message.Message);
+  EXPECT_EQ("variable", Errors[2].Message.Message);
 }
 
 } // namespace test
Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-case-violation.cpp
@@ -5,11 +5,11 @@
 // RUN:   {key: readability-identifier-naming.ClassCase, value: UUPER_CASE}, \
 // RUN:   {key: readability-identifier-naming.StructCase, value: CAMEL}, \
 // RUN:   {key: readability-identifier-naming.EnumCase, value: AnY_cASe}, \
-// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not warning
+// RUN:   ]}" 2>&1 | FileCheck %s --implicit-check-not="{{warning|error}}:"
 
-// CHECK-DAG: warning: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'?{{$}}
-// CHECK-DAG: warning: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'?{{$}}
+// CHECK-DAG: warning: invalid configuration value 'camelback' for option 'readability-identifier-naming.FunctionCase'; did you mean 'camelBack'? [clang-tidy-config]
+// CHECK-DAG: warning: invalid configuration value 'UUPER_CASE' for option 'readability-identifier-naming.ClassCase'; did you mean 'UPPER_CASE'? [clang-tidy-config]
 // Don't try to suggest an alternative for 'CAMEL'
-// CHECK-DAG: warning: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase'{{$}}
+// CHECK-DAG: warning: invalid configuration value 'CAMEL' for option 'readability-identifier-naming.StructCase' [clang-tidy-config]
 // This fails on the EditDistance, but as it matches ignoring case suggest the correct value
-// CHECK-DAG: warning: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'?{{$}}
+// CHECK-DAG: warning: invalid configuration value 'AnY_cASe' for option 'readability-identifier-naming.EnumCase'; did you mean 'aNy_CasE'? [clang-tidy-config]
Index: clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
==

[PATCH] D91565: Guard init_priority attribute within libc++

2020-11-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision as: libc++.
ldionne added a comment.

LGTM from libc++'s perspective. You should wait until the Clang part is LGTM'd 
before committing, of course.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91565/new/

https://reviews.llvm.org/D91565

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c964f30 - [OPENMP]Use the real pointer value as base, not indexed value.

2020-11-20 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-11-20T11:34:14-08:00
New Revision: c964f308141578f24932c68a03af5fae7f876011

URL: 
https://github.com/llvm/llvm-project/commit/c964f308141578f24932c68a03af5fae7f876011
DIFF: 
https://github.com/llvm/llvm-project/commit/c964f308141578f24932c68a03af5fae7f876011.diff

LOG: [OPENMP]Use the real pointer value as base, not indexed value.

After fix for PR48174 the base pointer for pointer-based
array-sections/array-subscripts will be emitted as `&ptr[idx]`, but
actually it should be just `ptr`, i.e. the address stored in the ponter
to point correctly to the beginning of the array. Currently it may lead
to a crash in the runtime.

Differential Revision: https://reviews.llvm.org/D91805

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 84733369a4a1..c15f6350b95e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7904,8 +7904,11 @@ class MappableExprsHandler {
 IsCaptureFirstInfo = false;
 FirstPointerInComplexData = false;
   } else if (FirstPointerInComplexData) {
-BP = CGF.EmitOMPSharedLValue(I->getAssociatedExpression())
- .getAddress(CGF);
+QualType Ty = Components.rbegin()
+  ->getAssociatedDeclaration()
+  ->getType()
+  .getNonReferenceType();
+BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
 FirstPointerInComplexData = false;
   }
 }

diff  --git 
a/clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp 
b/clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
index 14960191af03..77d416a685aa 100644
--- a/clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
+++ b/clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
@@ -38,10 +38,17 @@ MyObject *objects;
 // CHECK-DAG: [[MAPS1:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, 
i64 281474976710673]
 // CHECK: @main
 int main(void) {
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* 
%{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject***
+// CHECK: store %struct.MyObject** @objects, %struct.MyObject*** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, 
i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* [[SIZES0]], i32 0, i32 0), i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* [[MAPS0]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects [0:1])
+#pragma omp target enter data map(to : objects [1:1])
+// CHECK: [[OBJ:%.+]] = load %struct.MyObject*, %struct.MyObject** @objects,
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* 
%{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject**
+// CHECK: store %struct.MyObject* [[OBJ]], %struct.MyObject** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, 
i64 -1, i32 2, i8** %{{.+}}, i8** %{{.+}}, i64* %{{.+}}, i64* getelementptr 
inbounds ([2 x i64], [2 x i64]* [[MAPS1]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects[0].arr [0:1])
+#pragma omp target enter data map(to : objects[1].arr [0:1])
 
   return 0;
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91805: [OPENMP]Use the real pointer value as base, not indexed value.

2020-11-20 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc964f3081415: [OPENMP]Use the real pointer value as base, 
not indexed value. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91805/new/

https://reviews.llvm.org/D91805

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp


Index: clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
===
--- clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
+++ clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
@@ -38,10 +38,17 @@
 // CHECK-DAG: [[MAPS1:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, 
i64 281474976710673]
 // CHECK: @main
 int main(void) {
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* 
%{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject***
+// CHECK: store %struct.MyObject** @objects, %struct.MyObject*** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, 
i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* [[SIZES0]], i32 0, i32 0), i64* getelementptr inbounds ([1 x 
i64], [1 x i64]* [[MAPS0]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects [0:1])
+#pragma omp target enter data map(to : objects [1:1])
+// CHECK: [[OBJ:%.+]] = load %struct.MyObject*, %struct.MyObject** @objects,
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* 
%{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject**
+// CHECK: store %struct.MyObject* [[OBJ]], %struct.MyObject** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, 
i64 -1, i32 2, i8** %{{.+}}, i8** %{{.+}}, i64* %{{.+}}, i64* getelementptr 
inbounds ([2 x i64], [2 x i64]* [[MAPS1]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects[0].arr [0:1])
+#pragma omp target enter data map(to : objects[1].arr [0:1])
 
   return 0;
 }
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7904,8 +7904,11 @@
 IsCaptureFirstInfo = false;
 FirstPointerInComplexData = false;
   } else if (FirstPointerInComplexData) {
-BP = CGF.EmitOMPSharedLValue(I->getAssociatedExpression())
- .getAddress(CGF);
+QualType Ty = Components.rbegin()
+  ->getAssociatedDeclaration()
+  ->getType()
+  .getNonReferenceType();
+BP = CGF.EmitLoadOfPointer(BP, Ty->castAs());
 FirstPointerInComplexData = false;
   }
 }


Index: clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
===
--- clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
+++ clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
@@ -38,10 +38,17 @@
 // CHECK-DAG: [[MAPS1:@.+]] = private unnamed_addr constant [2 x i64] [i64 32, i64 281474976710673]
 // CHECK: @main
 int main(void) {
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [1 x i8*], [1 x i8*]* %{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject***
+// CHECK: store %struct.MyObject** @objects, %struct.MyObject*** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[SIZES0]], i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[MAPS0]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects [0:1])
+#pragma omp target enter data map(to : objects [1:1])
+// CHECK: [[OBJ:%.+]] = load %struct.MyObject*, %struct.MyObject** @objects,
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [2 x i8*], [2 x i8*]* %{{.+}}, i32 0, i32 0
+// CHECK: [[BPTRC0:%.+]] = bitcast i8** [[BPTR0]] to %struct.MyObject**
+// CHECK: store %struct.MyObject* [[OBJ]], %struct.MyObject** [[BPTRC0]],
 // CHECK: call void @__tgt_target_data_begin_mapper(%struct.ident_t* @{{.+}}, i64 -1, i32 2, i8** %{{.+}}, i8** %{{.+}}, i64* %{{.+}}, i64* getelementptr inbounds ([2 x i64], [2 x i64]* [[MAPS1]], i32 0, i32 0), i8** null, i8** null)
-#pragma omp target enter data map(to : objects[0].arr [0:1])
+#pragma omp target enter data map(to : objects[1].arr [0:1])
 
   return 0;
 }
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clan

[PATCH] D91565: Guard init_priority attribute within libc++

2020-11-20 Thread Zbigniew Sarbinowski via Phabricator via cfe-commits
zibi updated this revision to Diff 306753.
zibi added a comment.

Make test cleaner.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91565/new/

https://reviews.llvm.org/D91565

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/test/SemaCXX/init-priority-attr.cpp
  libcxx/include/__config
  libcxx/src/experimental/memory_resource.cpp
  libcxx/src/iostream.cpp

Index: libcxx/src/iostream.cpp
===
--- libcxx/src/iostream.cpp
+++ libcxx/src/iostream.cpp
@@ -77,7 +77,7 @@
 #endif
 ;
 
-_LIBCPP_HIDDEN ios_base::Init __start_std_streams __attribute__((init_priority(101)));
+_LIBCPP_HIDDEN ios_base::Init __start_std_streams _LIBCPP_INIT_PRIORITY_MAX;
 
 // On Windows the TLS storage for locales needs to be initialized before we create
 // the standard streams, otherwise it may not be alive during program termination
Index: libcxx/src/experimental/memory_resource.cpp
===
--- libcxx/src/experimental/memory_resource.cpp
+++ libcxx/src/experimental/memory_resource.cpp
@@ -76,16 +76,6 @@
   ~ResourceInitHelper() {}
 };
 
-// Detect if the init_priority attribute is supported.
-#if (defined(_LIBCPP_COMPILER_GCC) && defined(__APPLE__)) \
-  || defined(_LIBCPP_COMPILER_MSVC)
-// GCC on Apple doesn't support the init priority attribute,
-// and MSVC doesn't support any GCC attributes.
-# define _LIBCPP_INIT_PRIORITY_MAX
-#else
-# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
-#endif
-
 // When compiled in C++14 this initialization should be a constant expression.
 // Only in C++11 is "init_priority" needed to ensure initialization order.
 #if _LIBCPP_STD_VER > 11
Index: libcxx/include/__config
===
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -1435,6 +1435,12 @@
 #define _LIBCPP_HAS_NO_FGETPOS_FSETPOS
 #endif
 
+#if __has_attribute(init_priority)
+# define _LIBCPP_INIT_PRIORITY_MAX __attribute__((init_priority(101)))
+#else
+# define _LIBCPP_INIT_PRIORITY_MAX
+#endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP_CONFIG
Index: clang/test/SemaCXX/init-priority-attr.cpp
===
--- clang/test/SemaCXX/init-priority-attr.cpp
+++ clang/test/SemaCXX/init-priority-attr.cpp
@@ -1,5 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -DSYSTEM -verify %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-unknown -fsyntax-only -DSYSTEM -verify %s
+// RUN: %clang_cc1 -triple=s390x-none-zos -fsyntax-only -verify=unknown %s
+// RUN: %clang_cc1 -triple=s390x-none-zos -fsyntax-only -DSYSTEM -verify=unknown-system %s
 
 #if defined(SYSTEM)
 #5 "init-priority-attr.cpp" 3 // system header
@@ -23,25 +25,35 @@
 extern Two koo[];
 
 Two foo __attribute__((init_priority(101))) ( 5, 6 );
+ // unknown-system-no-diagnostics
+ // unknown-warning@-2 {{unknown attribute 'init_priority' ignored}}
 
 Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{'init_priority' attribute takes one argument}}
+// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}}
 
 Two coo[2]  __attribute__((init_priority(100)));
 #if !defined(SYSTEM)
-// expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
+  // expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
+  // unknown-warning@-3 {{unknown attribute 'init_priority' ignored}}
 #endif
 
 Two boo[2]  __attribute__((init_priority(65536)));
 #if !defined(SYSTEM)
-// expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
+ // expected-error@-2 {{'init_priority' attribute requires integer constant between 101 and 65535 inclusive}}
+ // unknown-warning@-3 {{unknown attribute 'init_priority' ignored}}
 #endif
 
 Two koo[4]  __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires an integer constant}}
+// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}}
 
 Two func()  __attribute__((init_priority(1001))); // expected-error {{'init_priority' attribute only applies to variables}}
+// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}}
+
 
 int i  __attribute__((init_priority(1001))); // expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
+// unknown-warning@-1 {{unknown attribute 'init_priority' ignored}}
 
 int main() {
-  Two foo __attribute__((init_priority(1001)));	// expected-error {{can only use 'init_priority' attribute on file-scope definitions of objects of class type}}
+  Two foo __attribute__((init_priority(1001))); // expected-error {{can onl

[PATCH] D91565: Guard init_priority attribute within libc++

2020-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM, thank you for the fixes!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91565/new/

https://reviews.llvm.org/D91565

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91565: Guard init_priority attribute within libc++

2020-11-20 Thread Zbigniew Sarbinowski via Phabricator via cfe-commits
zibi marked an inline comment as done.
zibi added inline comments.



Comment at: clang/test/SemaCXX/init-priority-attr.cpp:26
 Two foo __attribute__((init_priority(101))) ( 5, 6 );
+#if defined(__MVS__)
+ #if defined(SYSTEM)

aaron.ballman wrote:
> Rather than using the preprocessor, you can assign a prefix to be checked to 
> `-verify`. e.g., `-verify=unknown` would allow you to do `// unknown-warning 
> {{unknown attribute 'init_priority' ignored}}` or `unknown-no-diagnostics` 
> that is only checked when `-verify=unknown`.
> 
> I wonder if it would be cleaner to use that solution here instead of the 
> preprocessor by adding a new RUN line that's specific to AIX, and setting 
> some non-AIX triples for the other run lines.
That simplifies a lot in the expanse of duplicating the run.
Thank you Aaron.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91565/new/

https://reviews.llvm.org/D91565

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89046: [AST] Build recovery expression by default for all language.

2020-11-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/CodeGen/builtins-ppc-error.c:51
 void testCTF(int index) {
-  vec_ctf(vsi, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}}
-  vec_ctf(vui, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}}
+  vec_ctf(vsi, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}} expected-error 
{{argument to '__builtin_altivec_vcfux' must be a constant integer}}
+  vec_ctf(vui, index); //expected-error {{argument to 
'__builtin_altivec_vcfsx' must be a constant integer}} expected-error 
{{argument to '__builtin_altivec_vcfux' must be a constant integer}}

hokein wrote:
> sammccall wrote:
> > hmm, this doesn't exactly look right to me - we know the type of `vsi` so 
> > we should only be considering the signed case I thought.
> > 
> > However the existing diagnostic for `vui` indicates that it's considering 
> > the **signed** case, so I guess this is already broken/bad.
> yeah, we should know this is the signed case.
> 
> after the macro expansion, the code looks like 
> 
> ```
> _Generic((vsi), vector int
>: (vector float)__builtin_altivec_vcfsx((vector int)(vsi), 
> (index)), vector unsigned int
>: (vector float)__builtin_altivec_vcfux((vector unsigned 
> int)(vsi), (index))); 
> ```
> 
> it is a `GenericSelectionExpr` which contains a switch-like structure (see 
> the AST below), so when we traverse it, we will traverse both 
> `__builtin_altivec_vcfsx` and `__builtin_altivec_vcfux`.
> 
> ```
> `-GenericSelectionExpr 0x9527238  '__vector float' 
> contains-errors
> |-ImplicitCastExpr 0x9527220  '__vector int' 
> 
> | `-ParenExpr 0x9526980  '__vector int' lvalue
> |   `-DeclRefExpr 0x9526960  '__vector int' lvalue Var 0x9526568 
> 'vsi' '__vector int' non_odr_use_unevaluated
> |-VectorType 0x91923c0 '__vector int' altivec 4
> | `-BuiltinType 0x91296e0 'int'
> |-case  '__vector int' selected
> | |-VectorType 0x91923c0 '__vector int' altivec 4
> | | `-BuiltinType 0x91296e0 'int'
> | `-CStyleCastExpr 0x9526db8  '__vector float' 
> contains-errors 
> |   `-RecoveryExpr 0x9526d70  '' 
> contains-errors lvalue
> | |-DeclRefExpr 0x9526bc0  '' Function 
> 0x95269e8 '__builtin_altivec_vcfsx' '__attribute__((__vector_size__(4 * 
> sizeof(float float (__attribute__((__vector_size__(4 * sizeof(int 
> int, int)'
> | |-CStyleCastExpr 0x9526c68  '__vector int' 
> | | `-ImplicitCastExpr 0x9526c50  '__vector int' 
>  part_of_explicit_cast
> | |   `-ParenExpr 0x9526c30  '__vector int' lvalue
> | | `-DeclRefExpr 0x9526be0  '__vector int' lvalue Var 
> 0x9526568 'vsi' '__vector int'
> | `-ParenExpr 0x9526cb0  'const int' lvalue
> |   `-DeclRefExpr 0x9526c90  'const int' lvalue ParmVar 
> 0x95267c8 'index' 'const int'
> `-case  '__vector unsigned int'
>   |-VectorType 0x9192700 '__vector unsigned int' altivec 4
>   | `-BuiltinType 0x9129780 'unsigned int'
>   `-CStyleCastExpr 0x95271f8  '__vector float' 
> contains-errors 
> `-RecoveryExpr 0x95271b0  '' 
> contains-errors lvalue
>   |-DeclRefExpr 0x9527000  '' Function 
> 0x9526e28 '__builtin_altivec_vcfux' '__attribute__((__vector_size__(4 * 
> sizeof(float float (__attribute__((__vector_size__(4 * sizeof(unsigned 
> int unsigned int, int)'
>   |-CStyleCastExpr 0x95270a8  '__vector unsigned int' 
> 
>   | `-ImplicitCastExpr 0x9527090  '__vector int' 
>  part_of_explicit_cast
>   |   `-ParenExpr 0x9527070  '__vector int' lvalue
>   | `-DeclRefExpr 0x9527020  '__vector int' lvalue Var 
> 0x9526568 'vsi' '__vector int'
>   `-ParenExpr 0x95270f0  'const int' lvalue
> `-DeclRefExpr 0x95270d0  'const int' lvalue ParmVar 
> 0x95267c8 'index' 'const int'
> ```
> 
> 
> > However the existing diagnostic for vui indicates that it's considering the 
> > signed case, so I guess this is already broken/bad.
> 
> hmm, `vsi` and `vui` have the same type `vector signed int`, so I think there 
> is a typo for `vui`, it should be `vector unsigned int`?
> it is a GenericSelectionExpr which contains a switch-like structure (see the 
> AST below), so when we traverse it, we will traverse both 
> __builtin_altivec_vcfsx and __builtin_altivec_vcfux.

OK, that makes sense I guess.

> I think there is a typo for vui, it should be vector unsigned int?

Yep, that definitely looks to be the case.



Comment at: clang/test/Sema/__try.c:55
+// expected-error{{too few arguments to function call, expected 1, have 
0}} \
+// expected-error{{expected ';' after expression}}
   }

hokein wrote:
> sammccall wrote:
> > this seems bad, am I missing something?
> agree, `_

[PATCH] D86502: [CSSPGO] A Clang switch -fpseudo-probe-for-profiling for pseudo-probe instrumentation.

2020-11-20 Thread Wei Mi via Phabricator via cfe-commits
wmi accepted this revision.
wmi added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:978-982
   Opts.DebugInfoForProfiling = Args.hasFlag(
   OPT_fdebug_info_for_profiling, OPT_fno_debug_info_for_profiling, false);
+  Opts.PseudoProbeForProfiling =
+  Args.hasFlag(OPT_fpseudo_probe_for_profiling,
+   OPT_fno_pseudo_probe_for_profiling, false);

hoy wrote:
> wmi wrote:
> > Should it emit an error if DebugInfoForProfiling and 
> > PseudoProbeForProfiling are enabled at the same time? I see that from the 
> > other patch related with pseudoprobe discriminator, these two flags are 
> > incompatible.
> Yes, we should. It's done in D91756 passbuilder.h : 
> https://reviews.llvm.org/D91756#change-Bsibk2p32T1c for both `clang` and 
> `opt`.
> 
Ok, thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86502/new/

https://reviews.llvm.org/D86502

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] de5b0b7 - [clangd] semanticTokens: fields are 'property', not 'member'

2020-11-20 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-11-20T20:53:12+01:00
New Revision: de5b0b776fd7de72078256e003ede4fb5c37cdcb

URL: 
https://github.com/llvm/llvm-project/commit/de5b0b776fd7de72078256e003ede4fb5c37cdcb
DIFF: 
https://github.com/llvm/llvm-project/commit/de5b0b776fd7de72078256e003ede4fb5c37cdcb.diff

LOG: [clangd] semanticTokens: fields are 'property', not 'member'

This isn't obvious, but vscode maps member as 'entity.name.function.member',
so it's really for member functions.

Fixes https://github.com/clangd/vscode-clangd/issues/105

Added: 


Modified: 
clang-tools-extra/clangd/SemanticHighlighting.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index a9c885c7275e..1a78e7a8c0da 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -561,7 +561,8 @@ llvm::StringRef toSemanticTokenType(HighlightingKind Kind) {
 // FIXME: better function/member with static modifier?
 return "function";
   case HighlightingKind::Field:
-return "member";
+// Not "member": https://github.com/clangd/vscode-clangd/issues/105
+return "property";
   case HighlightingKind::Class:
 return "class";
   case HighlightingKind::Enum:



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >