[PATCH] D92009: [clangd] Sort results of incomingCalls request by container name

2020-11-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp:79
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel2, UnorderedElementsAre(
-  AllOf(From(WithName("caller2")),
-FromRanges(Source.range("Caller1A"),
-   Source.range("Caller1B"))),
-  AllOf(From(WithName("caller3")),
-
FromRanges(Source.range("Caller1C");
+  EXPECT_THAT(IncomingLevel2,
+  ElementsAre(AllOf(From(WithName("caller2")),

let's also change these from EXPECT_ to ASSERT_. As we are dereferencing 
elements in the following calls. Same in other places too.



Comment at: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp:92
   auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get());
   EXPECT_THAT(IncomingLevel4, ElementsAre());
 }

s/ElementsAre()/IsEmpty()/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92009

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


[PATCH] D92009: [clangd] Sort results of incomingCalls request by container name

2020-11-24 Thread Nathan Ridge 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 rG5b6f47595bab: [clangd] Sort results of incomingCalls request 
by container name (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92009

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp

Index: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -31,6 +31,7 @@
 using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAre;
 
@@ -69,27 +70,27 @@
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+  ASSERT_THAT(Items, ElementsAre(WithName("callee")));
   auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
-  EXPECT_THAT(IncomingLevel1,
+  ASSERT_THAT(IncomingLevel1,
   ElementsAre(AllOf(From(WithName("caller1")),
 FromRanges(Source.range("Callee");
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel2, UnorderedElementsAre(
-  AllOf(From(WithName("caller2")),
-FromRanges(Source.range("Caller1A"),
-   Source.range("Caller1B"))),
-  AllOf(From(WithName("caller3")),
-FromRanges(Source.range("Caller1C");
+  ASSERT_THAT(IncomingLevel2,
+  ElementsAre(AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1A"),
+   Source.range("Caller1B"))),
+  AllOf(From(WithName("caller3")),
+FromRanges(Source.range("Caller1C");
 
   auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel3,
+  ASSERT_THAT(IncomingLevel3,
   ElementsAre(AllOf(From(WithName("caller3")),
 FromRanges(Source.range("Caller2");
 
   auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel4, ElementsAre());
+  EXPECT_THAT(IncomingLevel4, IsEmpty());
 }
 
 TEST(CallHierarchy, MainFileOnlyRef) {
@@ -113,16 +114,16 @@
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+  ASSERT_THAT(Items, ElementsAre(WithName("callee")));
   auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
-  EXPECT_THAT(IncomingLevel1,
+  ASSERT_THAT(IncomingLevel1,
   ElementsAre(AllOf(From(WithName("caller1")),
 FromRanges(Source.range("Callee");
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
   EXPECT_THAT(IncomingLevel2,
-  UnorderedElementsAre(AllOf(From(WithName("caller2")),
- FromRanges(Source.range("Caller1");
+  ElementsAre(AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1");
 }
 
 TEST(CallHierarchy, IncomingQualified) {
@@ -146,13 +147,13 @@
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("Waldo::find")));
+  ASSERT_THAT(Items, ElementsAre(WithName("Waldo::find")));
   auto Incoming = incomingCalls(Items[0], Index.get());
   EXPECT_THAT(Incoming,
-  UnorderedElementsAre(AllOf(From(WithName("caller1")),
- FromRanges(Source.range("Caller1"))),
-   AllOf(From(WithName("caller2")),
- FromRanges(Source.range("Caller2");
+  ElementsAre(AllOf(From(WithName("caller1")),
+FromRanges(Source.range("Caller1"))),
+  AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller2");
 }
 
 TEST(CallHierarchy, IncomingMultiFile) {
@@ -212,27 +213,27 @@
   auto CheckCallHierarchy = [&](ParsedAST , Position Pos, PathRef TUPath) {
 std::vector Items =
 prepareCallHierarchy(AST, Pos, TUPath);
-EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+ASSERT_THAT(Items, ElementsAre(WithName("callee")));
 auto IncomingLevel1 = 

[clang-tools-extra] 5b6f475 - [clangd] Sort results of incomingCalls request by container name

2020-11-24 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2020-11-24T03:29:02-05:00
New Revision: 5b6f47595bab686c6c3351fc1bd1f564add80dbf

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

LOG: [clangd] Sort results of incomingCalls request by container name

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index e319636f9076..31e963cb853f 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -1716,6 +1716,11 @@ incomingCalls(const CallHierarchyItem , const 
SymbolIndex *Index) {
   Results.push_back(
   CallHierarchyIncomingCall{std::move(*CHI), std::move(It->second)});
   });
+  // Sort results by name of container.
+  llvm::sort(Results, [](const CallHierarchyIncomingCall ,
+ const CallHierarchyIncomingCall ) {
+return A.from.name < B.from.name;
+  });
   return Results;
 }
 

diff  --git a/clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp 
b/clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
index ce192466b442..8b5069d8dae8 100644
--- a/clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -31,6 +31,7 @@ namespace {
 using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAre;
 
@@ -69,27 +70,27 @@ TEST(CallHierarchy, IncomingOneFile) {
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+  ASSERT_THAT(Items, ElementsAre(WithName("callee")));
   auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
-  EXPECT_THAT(IncomingLevel1,
+  ASSERT_THAT(IncomingLevel1,
   ElementsAre(AllOf(From(WithName("caller1")),
 FromRanges(Source.range("Callee");
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel2, UnorderedElementsAre(
-  AllOf(From(WithName("caller2")),
-FromRanges(Source.range("Caller1A"),
-   Source.range("Caller1B"))),
-  AllOf(From(WithName("caller3")),
-
FromRanges(Source.range("Caller1C");
+  ASSERT_THAT(IncomingLevel2,
+  ElementsAre(AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1A"),
+   Source.range("Caller1B"))),
+  AllOf(From(WithName("caller3")),
+FromRanges(Source.range("Caller1C");
 
   auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel3,
+  ASSERT_THAT(IncomingLevel3,
   ElementsAre(AllOf(From(WithName("caller3")),
 FromRanges(Source.range("Caller2");
 
   auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel4, ElementsAre());
+  EXPECT_THAT(IncomingLevel4, IsEmpty());
 }
 
 TEST(CallHierarchy, MainFileOnlyRef) {
@@ -113,16 +114,16 @@ TEST(CallHierarchy, MainFileOnlyRef) {
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+  ASSERT_THAT(Items, ElementsAre(WithName("callee")));
   auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
-  EXPECT_THAT(IncomingLevel1,
+  ASSERT_THAT(IncomingLevel1,
   ElementsAre(AllOf(From(WithName("caller1")),
 FromRanges(Source.range("Callee");
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
   EXPECT_THAT(IncomingLevel2,
-  UnorderedElementsAre(AllOf(From(WithName("caller2")),
- 
FromRanges(Source.range("Caller1");
+  ElementsAre(AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1");
 }
 
 TEST(CallHierarchy, IncomingQualified) {
@@ -146,13 +147,13 @@ TEST(CallHierarchy, IncomingQualified) {
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("Waldo::find")));
+  ASSERT_THAT(Items, ElementsAre(WithName("Waldo::find")));
   auto Incoming = incomingCalls(Items[0], 

[PATCH] D91428: Add support for multiple program address spaces

2020-11-24 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

Thanks, @arichardson and @jrtc27 for your comments. 
I am definitely surprised to find that if you explicitly mark the call with the 
address space, this patch is not required. At first look, this RFC is not 
required any more but I need sometime to investigate further. If no changes are 
necessary, this is indeed good news.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

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


[PATCH] D91927: [X86] Add x86_amx type for intel AMX.

2020-11-24 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 307298.
LuoYuanke retitled this revision from "[X86] Add x86_amx type for intel AMX. " 
to "[X86] Add x86_amx type for intel AMX.".
LuoYuanke added a comment.

Address Craig's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91927

Files:
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/CodeGen/ValueTypes.td
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/Intrinsics.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/AMX/amx-across-func.ll
  llvm/test/CodeGen/X86/AMX/amx-config.ll
  llvm/test/CodeGen/X86/AMX/amx-spill.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/utils/TableGen/CodeGenTarget.cpp
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -248,7 +248,8 @@
   IIT_V128 = 47,
   IIT_BF16 = 48,
   IIT_STRUCT9 = 49,
-  IIT_V256 = 50
+  IIT_V256 = 50,
+  IIT_AMX  = 51,
 };
 
 static void EncodeFixedValueType(MVT::SimpleValueType VT,
@@ -276,6 +277,7 @@
   case MVT::token: return Sig.push_back(IIT_TOKEN);
   case MVT::Metadata: return Sig.push_back(IIT_METADATA);
   case MVT::x86mmx: return Sig.push_back(IIT_MMX);
+  case MVT::x86amx: return Sig.push_back(IIT_AMX);
   // MVT::OtherVT is used to mean the empty struct type here.
   case MVT::Other: return Sig.push_back(IIT_EMPTYSTRUCT);
   // MVT::isVoid is used to represent varargs here.
Index: llvm/utils/TableGen/CodeGenTarget.cpp
===
--- llvm/utils/TableGen/CodeGenTarget.cpp
+++ llvm/utils/TableGen/CodeGenTarget.cpp
@@ -76,6 +76,7 @@
   case MVT::f128: return "MVT::f128";
   case MVT::ppcf128:  return "MVT::ppcf128";
   case MVT::x86mmx:   return "MVT::x86mmx";
+  case MVT::x86amx:   return "MVT::x86amx";
   case MVT::Glue: return "MVT::Glue";
   case MVT::isVoid:   return "MVT::isVoid";
   case MVT::v1i1: return "MVT::v1i1";
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-type.ll
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -8,18 +8,70 @@
 @buf = dso_local global [1024 x i8] zeroinitializer, align 16
 @buf2 = dso_local global [1024 x i8] zeroinitializer, align 16
 
+; test bitcast x86_amx to <256 x i32>
+define dso_local void @test_user_empty(x86_amx %in) #2 {
+; CHECK-LABEL: @test_user_empty(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:ret void
+;
+entry:
+  %t = bitcast x86_amx %in to <256 x i32>
+  ret void
+}
+
+; test bitcast <256 x i32> to x86_amx
+define dso_local void @test_user_empty2(<256 x i32> %in) #2 {
+; CHECK-LABEL: @test_user_empty2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:ret void
+;
+entry:
+  %t = bitcast <256 x i32> %in to x86_amx
+  ret void
+}
+
+define dso_local void @test_src_add(<256 x i32> %x, <256 x i32> %y, i16 %r, i16 %c, i8* %buf, i64 %s) #2 {
+; CHECK-LABEL: @test_src_add(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = alloca <256 x i32>, align 1024
+; CHECK-NEXT:[[ADD:%.*]] = add <256 x i32> [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast <256 x i32>* [[TMP0]] to i8*
+; CHECK-NEXT:store <256 x i32> [[ADD]], <256 x i32>* [[TMP0]], align 1024
+; CHECK-NEXT:[[TMP2:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[R:%.*]], i16 [[C:%.*]], i8* [[TMP1]], i64 64)
+; CHECK-NEXT:call void @llvm.x86.tilestored64.internal(i16 [[R]], i16 [[C]], i8* [[BUF:%.*]], i64 [[S:%.*]], x86_amx [[TMP2]]) [[ATTR3:#.*]]
+; CHECK-NEXT:ret void
+;
+entry:
+  %add = add <256 x i32> %y, %x
+  %t = bitcast <256 x i32> %add to x86_amx
+  call void @llvm.x86.tilestored64.internal(i16 %r, i16 %c, i8* %buf, i64 %s, x86_amx %t) #3
+  ret void
+}
+
+define dso_local void @test_src_add2(<256 x i32> %x, i16 %r, i16 %c, i8* %buf, i64 %s) #2 {
+; CHECK-LABEL: @test_src_add2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = alloca <256 x i32>, align 1024
+; CHECK-NEXT:[[T1:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[R:%.*]], i16 

[PATCH] D83698: Port Target option flags to new option parsing system

2020-11-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 commandeered this revision.
jansvoboda11 added a reviewer: dang.
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/D83698/new/

https://reviews.llvm.org/D83698

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


[PATCH] D92009: [clangd] Sort results of incomingCalls request by container name

2020-11-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, mgrang.
Herald added a project: clang.
nridge requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92009

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp


Index: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -76,12 +76,12 @@
 FromRanges(Source.range("Callee");
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel2, UnorderedElementsAre(
-  AllOf(From(WithName("caller2")),
-FromRanges(Source.range("Caller1A"),
-   Source.range("Caller1B"))),
-  AllOf(From(WithName("caller3")),
-
FromRanges(Source.range("Caller1C");
+  EXPECT_THAT(IncomingLevel2,
+  ElementsAre(AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1A"),
+   Source.range("Caller1B"))),
+  AllOf(From(WithName("caller3")),
+FromRanges(Source.range("Caller1C");
 
   auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
   EXPECT_THAT(IncomingLevel3,
@@ -121,8 +121,8 @@
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
   EXPECT_THAT(IncomingLevel2,
-  UnorderedElementsAre(AllOf(From(WithName("caller2")),
- 
FromRanges(Source.range("Caller1");
+  ElementsAre(AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1");
 }
 
 TEST(CallHierarchy, IncomingQualified) {
@@ -149,10 +149,10 @@
   EXPECT_THAT(Items, ElementsAre(WithName("Waldo::find")));
   auto Incoming = incomingCalls(Items[0], Index.get());
   EXPECT_THAT(Incoming,
-  UnorderedElementsAre(AllOf(From(WithName("caller1")),
- FromRanges(Source.range("Caller1"))),
-   AllOf(From(WithName("caller2")),
- 
FromRanges(Source.range("Caller2");
+  ElementsAre(AllOf(From(WithName("caller1")),
+FromRanges(Source.range("Caller1"))),
+  AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller2");
 }
 
 TEST(CallHierarchy, IncomingMultiFile) {
@@ -219,9 +219,9 @@
   FromRanges(Caller1C.range();
 
 auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
-EXPECT_THAT(IncomingLevel2,
-UnorderedElementsAre(
-AllOf(From(WithName("caller2")),
+EXPECT_THAT(
+IncomingLevel2,
+ElementsAre(AllOf(From(WithName("caller2")),
   FromRanges(Caller2C.range("A"), 
Caller2C.range("B"))),
 AllOf(From(WithName("caller3")),
   FromRanges(Caller3C.range("Caller1");
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1716,6 +1716,11 @@
   Results.push_back(
   CallHierarchyIncomingCall{std::move(*CHI), std::move(It->second)});
   });
+  // Sort results by name of container.
+  llvm::sort(Results, [](const CallHierarchyIncomingCall ,
+ const CallHierarchyIncomingCall ) {
+return A.from.name < B.from.name;
+  });
   return Results;
 }
 


Index: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -76,12 +76,12 @@
 FromRanges(Source.range("Callee");
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel2, UnorderedElementsAre(
-  AllOf(From(WithName("caller2")),
-FromRanges(Source.range("Caller1A"),
-   Source.range("Caller1B"))),
-  AllOf(From(WithName("caller3")),
-

[PATCH] D92012: [clangd][query-driver] Extract target

2020-11-24 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
Herald added subscribers: cfe-commits, usaxena95, mstorsjo, kadircet, arphaman.
Herald added a project: clang.
ArcsinX requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

In some cases system includes extractions is not enough, we also need target 
specific defines.
The problems appears when clang default target is not the same as toolchain's 
one (GCC cross-compiler, MinGW on Windows).
After this patch `query-driver` also extracts target and adds 
`-target=` compile option.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92012

Files:
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test

Index: clang-tools-extra/clangd/test/system-include-extractor.test
===
--- clang-tools-extra/clangd/test/system-include-extractor.test
+++ clang-tools-extra/clangd/test/system-include-extractor.test
@@ -12,6 +12,7 @@
 # RUN: echo '[ -z "${args##*"-isysroot=/isysroot"*}" ] || exit' >> %t.dir/my_driver.sh
 # RUN: echo 'echo " $* " | grep " --sysroot /my/sysroot/path " || exit' >> %t.dir/my_driver.sh
 # RUN: echo 'echo line to ignore >&2' >> %t.dir/my_driver.sh
+# RUN: echo 'printf "Target: arm-linux-gnueabihf\r\n" >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'printf "#include <...> search starts here:\r\n" >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir/ >&2' >> %t.dir/my_driver.sh
 # RUN: echo 'echo %t.dir/my/dir2/ >&2' >> %t.dir/my_driver.sh
@@ -45,7 +46,7 @@
   "uri": "file://INPUT_DIR/the-file.cpp",
   "languageId":"cpp",
   "version":1,
-  "text":"#include \n#include "
+  "text":"#include \n#include \n#if !defined(__ARM_ARCH) || !defined(__gnu_linux__)\n#error \"Invalid target\"\n#endif"
 }
   }
 }
Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -56,18 +56,34 @@
 namespace clangd {
 namespace {
 
-std::vector parseDriverOutput(llvm::StringRef Output) {
+std::pair, std::string>
+parseDriverOutput(llvm::StringRef Output) {
   std::vector SystemIncludes;
+  std::string Target;
   const char SIS[] = "#include <...> search starts here:";
   const char SIE[] = "End of search list.";
+  const char TS[] = "Target: ";
   llvm::SmallVector Lines;
   Output.split(Lines, '\n', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 
   auto StartIt = llvm::find_if(
-  Lines, [SIS](llvm::StringRef Line) { return Line.trim() == SIS; });
+  Lines, [TS](llvm::StringRef Line) { return Line.trim().startswith(TS); });
+
+  if (StartIt != Lines.end()) {
+llvm::StringRef TargetLine = StartIt->trim();
+TargetLine.consume_front(TS);
+Target = TargetLine.str();
+++StartIt;
+  } else {
+// Start from the beginning if target was not found.
+StartIt = Lines.begin();
+  }
+  StartIt =
+  llvm::find_if(llvm::make_range(StartIt, Lines.end()),
+[SIS](llvm::StringRef Line) { return Line.trim() == SIS; });
   if (StartIt == Lines.end()) {
 elog("System include extraction: start marker not found: {0}", Output);
-return {};
+return {SystemIncludes, Target};
   }
   ++StartIt;
   const auto EndIt =
@@ -75,21 +91,21 @@
 [SIE](llvm::StringRef Line) { return Line.trim() == SIE; });
   if (EndIt == Lines.end()) {
 elog("System include extraction: end marker missing: {0}", Output);
-return {};
+return {SystemIncludes, Target};
   }
 
   for (llvm::StringRef Line : llvm::make_range(StartIt, EndIt)) {
 SystemIncludes.push_back(Line.trim().str());
 vlog("System include extraction: adding {0}", Line);
   }
-  return SystemIncludes;
+  return {SystemIncludes, Target};
 }
 
-std::vector
-extractSystemIncludes(PathRef Driver, llvm::StringRef Lang,
-  llvm::ArrayRef CommandLine,
-  const llvm::Regex ) {
-  trace::Span Tracer("Extract system includes");
+std::pair, std::string>
+extractSystemIncludesAndTarget(PathRef Driver, llvm::StringRef Lang,
+   llvm::ArrayRef CommandLine,
+   const llvm::Regex ) {
+  trace::Span Tracer("Extract system includes and target");
   SPAN_ATTACH(Tracer, "driver", Driver);
   SPAN_ATTACH(Tracer, "lang", Lang);
 
@@ -168,11 +184,15 @@
 return {};
   }
 
-  auto Includes = parseDriverOutput(BufOrError->get()->getBuffer());
-  log("System include extractor: successfully executed {0}, got includes: "
+  auto IncludesAndTarget = parseDriverOutput(BufOrError->get()->getBuffer());
+  log("System includes extractor: successfully executed {0}, got includes: "
   "\"{1}\"",
-  Driver, llvm::join(Includes, ", "));
-  return Includes;
+  Driver, llvm::join(IncludesAndTarget.first, ", "));
+  if (!IncludesAndTarget.second.empty())

[PATCH] D91760: [Driver] Default Generic_GCC aarch64 to use -fasynchronous-unwind-tables

2020-11-24 Thread Peter Smith via Phabricator via cfe-commits
psmith added a comment.

Radio silence so far; I think no news is good news applies in this case. I'm 
happy to say no objections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91760

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


[PATCH] D83698: [clang][cli] Port Target option flags to new option parsing system

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

Undo moving of options (NFC) & rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83698

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
@@ -3721,9 +3721,6 @@
   Opts.LinkerVersion =
   std::string(Args.getLastArgValue(OPT_target_linker_version));
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
-  Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
-  Opts.NVPTXUseShortPointers = Args.hasFlag(
-  options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr, false);
   Opts.AllowAMDGPUUnsafeFPAtomics =
   Args.hasFlag(options::OPT_munsafe_fp_atomics,
options::OPT_mno_unsafe_fp_atomics, false);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -692,7 +692,7 @@
   "Generate relocatable device code, also known as separate compilation mode", 
"", "">;
 def : Flag<["-"], "fcuda-rdc">, Alias;
 def : Flag<["-"], "fno-cuda-rdc">, Alias;
-defm cuda_short_ptr : OptInFFlag<"cuda-short-ptr",
+defm cuda_short_ptr : BooleanMarshalledFFlag<"cuda-short-ptr", 
"TargetOpts->NVPTXUseShortPointers", "false",
   "Use 32-bit pointers for accessing const/local/shared address spaces">;
 def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group,
   HelpText<"ROCm installation path, used for finding and automatically linking 
required bitcode libraries.">;
@@ -1049,7 +1049,7 @@
 def fsignaling_math : Flag<["-"], "fsignaling-math">, Group;
 def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group;
 defm jump_tables : OptOutFFlag<"jump-tables", "Use", "Do not use", " jump 
tables for lowering switches">;
-defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", 
"Disable", " support for int128_t type">;
+defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", 
"Disable", " support for int128_t type", [], "TargetOpts->ForceEnableInt128">;
 defm keep_static_consts : OptInFFlag<"keep-static-consts", "Keep", "Don't 
keep", " static const variables if unused", [NoXarchOption]>;
 defm fixed_point : OptInFFlag<"fixed-point", "Enable", "Disable", " fixed 
point types">;
 defm cxx_static_destructors : OptOutFFlag<"c++-static-destructors", "",


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3721,9 +3721,6 @@
   Opts.LinkerVersion =
   std::string(Args.getLastArgValue(OPT_target_linker_version));
   Opts.OpenCLExtensionsAsWritten = Args.getAllArgValues(OPT_cl_ext_EQ);
-  Opts.ForceEnableInt128 = Args.hasArg(OPT_fforce_enable_int128);
-  Opts.NVPTXUseShortPointers = Args.hasFlag(
-  options::OPT_fcuda_short_ptr, options::OPT_fno_cuda_short_ptr, false);
   Opts.AllowAMDGPUUnsafeFPAtomics =
   Args.hasFlag(options::OPT_munsafe_fp_atomics,
options::OPT_mno_unsafe_fp_atomics, false);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -692,7 +692,7 @@
   "Generate relocatable device code, also known as separate compilation mode", "", "">;
 def : Flag<["-"], "fcuda-rdc">, Alias;
 def : Flag<["-"], "fno-cuda-rdc">, Alias;
-defm cuda_short_ptr : OptInFFlag<"cuda-short-ptr",
+defm cuda_short_ptr : BooleanMarshalledFFlag<"cuda-short-ptr", "TargetOpts->NVPTXUseShortPointers", "false",
   "Use 32-bit pointers for accessing const/local/shared address spaces">;
 def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group,
   HelpText<"ROCm installation path, used for finding and automatically linking required bitcode libraries.">;
@@ -1049,7 +1049,7 @@
 def fsignaling_math : Flag<["-"], "fsignaling-math">, Group;
 def fno_signaling_math : Flag<["-"], "fno-signaling-math">, Group;
 defm jump_tables : OptOutFFlag<"jump-tables", "Use", "Do not use", " jump tables for lowering switches">;
-defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", "Disable", " support for int128_t type">;
+defm force_enable_int128 : OptInFFlag<"force-enable-int128", "Enable", "Disable", " support for int128_t type", [], "TargetOpts->ForceEnableInt128">;
 defm keep_static_consts : OptInFFlag<"keep-static-consts", "Keep", "Don't keep", " static const variables if unused", [NoXarchOption]>;
 defm fixed_point : OptInFFlag<"fixed-point", "Enable", "Disable", " fixed 

[PATCH] D92000: [clangd] Collect main file refs by default

2020-11-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

NVM, found the summary 
https://github.com/clangd/clangd/issues/162#issuecomment-653981038


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92000

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


[PATCH] D92000: [clangd] Collect main file refs by default

2020-11-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

i remember discussing this in the past, and having "negative" feelings about 
it. I couldn't find the discussion on the issues page tho, could you toss me 
the link if you can find it? (it might've been an offline discussion as well, 
sorry if that's the case for not dumping a summary).

But if there were no discussions before, it would be nice to see some numbers, 
for increase in memory and disk usage for LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92000

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


[PATCH] D92010: [clang-offload-bundler] use std::forward_list for storing temp file names [NFC]

2020-11-24 Thread Sergey Dmitriev via Phabricator via cfe-commits
sdmitriev created this revision.
sdmitriev added a reviewer: ABataev.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
sdmitriev requested review of this revision.

Use a different container that preserves existing elements on modification
for storing temporary file names. Current container can make StringRefs
returned earlier invalid on reallocation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92010

Files:
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -394,7 +395,7 @@
 if (std::error_code EC =
 sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
   return createFileError(File, EC);
-Files.push_back(File);
+Files.push_front(File);
 
 if (Contents) {
   std::error_code EC;
@@ -403,11 +404,11 @@
 return createFileError(File, EC);
   OS.write(Contents->data(), Contents->size());
 }
-return Files.back();
+return Files.front();
   }
 
 private:
-  SmallVector, 4u> Files;
+  std::forward_list> Files;
 };
 
 } // end anonymous namespace


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -394,7 +395,7 @@
 if (std::error_code EC =
 sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
   return createFileError(File, EC);
-Files.push_back(File);
+Files.push_front(File);
 
 if (Contents) {
   std::error_code EC;
@@ -403,11 +404,11 @@
 return createFileError(File, EC);
   OS.write(Contents->data(), Contents->size());
 }
-return Files.back();
+return Files.front();
   }
 
 private:
-  SmallVector, 4u> Files;
+  std::forward_list> Files;
 };
 
 } // end anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92012: [clangd][query-driver] Extract target

2020-11-24 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added reviewers: sammccall, kadircet.
ArcsinX added a comment.

I'm not sure if this solution is elegant enough. I will be happy to hear 
advices.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92012

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


[PATCH] D91122: [clangd] Call hierarchy (XRefs layer, incoming calls)

2020-11-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp:86
+
+  auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel3,

nridge wrote:
> kadircet wrote:
> > the order of elements in `IncomingLevel2` is not sorted, so on some 
> > buildbots you are receiving "caller3" as the first element of the result, 
> > and "caller2" in others.
> > 
> > sorry for missing it the first time, it might make sense to sort containers 
> > by name before returning from `incomingCalls`
> Thanks for catching that! Patch at https://reviews.llvm.org/D92000
Sorry, wrong link, correct link is: https://reviews.llvm.org/D92009


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91122

___
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-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 307281.
kadircet added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

- Link protobuf and grpc++ publicly to generated targets


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91859

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -112,7 +112,7 @@
 
   add_clang_library(${LibraryName} ${GeneratedProtoSource}
 PARTIAL_SOURCES_INTENDED
-LINK_LIBS grpc++ protobuf)
+LINK_LIBS PUBLIC grpc++ protobuf)
 
   # Ensure dependency headers are generated before dependent protos are built.
   # DEPENDS arg is a list of "Foo.proto". While they're logically relative to
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -146,7 +146,8 @@
 if (CLANGD_ENABLE_REMOTE)
   target_link_libraries(ClangdTests
 PRIVATE
-clangdRemoteMarshalling)
+clangdRemoteMarshalling
+RemoteIndexProto)
 endif()
 
 if (CLANGD_BUILD_XPC)
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,6 +17,4 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
-
-  grpc++
   )
Index: clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
@@ -4,7 +4,6 @@
   LINK_LIBS
   RemoteIndexProto
 
-  protobuf
   clangDaemon
   clangdSupport
 
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,12 @@
   generate_protos(RemoteIndexServiceProto "Service.proto"
 DEPENDS "Index.proto"
 GRPC)
+  # FIXME: Move this into generate_protos. Currently we only mention proto
+  # filename as a dependency, but linking requires target name.
+  target_link_libraries(RemoteIndexServiceProto
+PRIVATE
+RemoteIndexProto
+)
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 
@@ -18,8 +24,8 @@
 RemoteIndexProto
 RemoteIndexServiceProto
 clangdRemoteMarshalling
-protobuf
-grpc++
+clangBasic
+clangDaemon
 clangdSupport
 
 DEPENDS
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -168,17 +168,18 @@
   add_subdirectory(xpc)
 endif ()
 
+if (CLANGD_ENABLE_REMOTE)
+  include(FindGRPC)
+endif()
+
 if(CLANG_INCLUDE_TESTS)
-add_subdirectory(test)
-add_subdirectory(unittests)
+  add_subdirectory(test)
+  add_subdirectory(unittests)
 endif()
 
 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
 
-if (CLANGD_ENABLE_REMOTE)
-  include(FindGRPC)
-endif()
 add_subdirectory(index/remote)
 add_subdirectory(index/dex/dexp)
___
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-24 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 307306.
fpetrogalli added a comment.

Rebase on top of D92020 . NFC.


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/IntrinsicInst.h
  llvm/lib/IR/IntrinsicInst.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  = 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 +44,9 @@
 
 raw_ostream () { return Quiet ? nulls() : errs(); }
 
-uint64_t getAllocSizeInBits(Module , Type *Ty) {
-  return Ty->isSized() ? M.getDataLayout().getTypeAllocSizeInBits(Ty) : 0;
+TypeSize getAllocSizeInBits(Module , Type *Ty) {
+  

[PATCH] D92009: [clangd] Sort results of incomingCalls request by container name

2020-11-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 307262.
nridge added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92009

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp

Index: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -31,6 +31,7 @@
 using ::testing::AllOf;
 using ::testing::ElementsAre;
 using ::testing::Field;
+using ::testing::IsEmpty;
 using ::testing::Matcher;
 using ::testing::UnorderedElementsAre;
 
@@ -69,27 +70,27 @@
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+  ASSERT_THAT(Items, ElementsAre(WithName("callee")));
   auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
-  EXPECT_THAT(IncomingLevel1,
+  ASSERT_THAT(IncomingLevel1,
   ElementsAre(AllOf(From(WithName("caller1")),
 FromRanges(Source.range("Callee");
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel2, UnorderedElementsAre(
-  AllOf(From(WithName("caller2")),
-FromRanges(Source.range("Caller1A"),
-   Source.range("Caller1B"))),
-  AllOf(From(WithName("caller3")),
-FromRanges(Source.range("Caller1C");
+  ASSERT_THAT(IncomingLevel2,
+  ElementsAre(AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1A"),
+   Source.range("Caller1B"))),
+  AllOf(From(WithName("caller3")),
+FromRanges(Source.range("Caller1C");
 
   auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel3,
+  ASSERT_THAT(IncomingLevel3,
   ElementsAre(AllOf(From(WithName("caller3")),
 FromRanges(Source.range("Caller2");
 
   auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get());
-  EXPECT_THAT(IncomingLevel4, ElementsAre());
+  EXPECT_THAT(IncomingLevel4, IsEmpty());
 }
 
 TEST(CallHierarchy, MainFileOnlyRef) {
@@ -113,16 +114,16 @@
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+  ASSERT_THAT(Items, ElementsAre(WithName("callee")));
   auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
-  EXPECT_THAT(IncomingLevel1,
+  ASSERT_THAT(IncomingLevel1,
   ElementsAre(AllOf(From(WithName("caller1")),
 FromRanges(Source.range("Callee");
 
   auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
   EXPECT_THAT(IncomingLevel2,
-  UnorderedElementsAre(AllOf(From(WithName("caller2")),
- FromRanges(Source.range("Caller1");
+  ElementsAre(AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1");
 }
 
 TEST(CallHierarchy, IncomingQualified) {
@@ -146,13 +147,13 @@
 
   std::vector Items =
   prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
-  EXPECT_THAT(Items, ElementsAre(WithName("Waldo::find")));
+  ASSERT_THAT(Items, ElementsAre(WithName("Waldo::find")));
   auto Incoming = incomingCalls(Items[0], Index.get());
   EXPECT_THAT(Incoming,
-  UnorderedElementsAre(AllOf(From(WithName("caller1")),
- FromRanges(Source.range("Caller1"))),
-   AllOf(From(WithName("caller2")),
- FromRanges(Source.range("Caller2");
+  ElementsAre(AllOf(From(WithName("caller1")),
+FromRanges(Source.range("Caller1"))),
+  AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller2");
 }
 
 TEST(CallHierarchy, IncomingMultiFile) {
@@ -212,27 +213,27 @@
   auto CheckCallHierarchy = [&](ParsedAST , Position Pos, PathRef TUPath) {
 std::vector Items =
 prepareCallHierarchy(AST, Pos, TUPath);
-EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+ASSERT_THAT(Items, ElementsAre(WithName("callee")));
 auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
-EXPECT_THAT(IncomingLevel1,
+ASSERT_THAT(IncomingLevel1,
 ElementsAre(AllOf(From(WithName("caller1")),
   

[PATCH] D91952: [clangd] Add support for within-file rename of complicated fields

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

I assume this fixes https://github.com/clangd/clangd/issues/582?

can you check the static members in template classes etc? I think the AST is 
different.




Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:131
+// Clang AST does not store relevant information about the field that is
+// instantiated.
+const auto *TemplateSpec =

yeah, this is a bit unfortunate, I don't have a better solution (extending the 
AST is one option, but it may be not easy). I think we can live with the 
heuristic.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:137
+const CXXRecordDecl *FieldParent =
+TemplateSpec->getTemplateInstantiationPattern();
+// Field is not instantiation.

nit: I think we can simplify the code a bit more:

```
const auto* Template = Field->getParent()->getTemplateInstantiationPattern();
if (!Template)
  return...;

```



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:142
+for (const FieldDecl *Candidate : FieldParent->fields()) {
+  if (Field->getFieldIndex() == Candidate->getFieldIndex()) {
+assert(Field->getLocation() == Candidate->getLocation() &&

I think we could also check the equality of their names.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:143
+  if (Field->getFieldIndex() == Candidate->getFieldIndex()) {
+assert(Field->getLocation() == Candidate->getLocation() &&
+   "Field should be generated from Candidate so it has the same "

this assertion seems too strong to me -- this is a heuristics, it may have 
false positives. I think we can remove it. 



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:149
+}
+llvm_unreachable("FieldParent should have field with same index as 
Field.");
+  }

use `elog`?



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:545
+  R"cpp(
+class Foo {
+public:

I think this is a normal rename-field case, it should already work prior to the 
patch.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:575
+  T Variable[42];
+  U Another;
+

`Another` seems to be not needed. I'd suggest removing it to make the testcase 
as tense as possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91952

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


[PATCH] D91927: [X86] Add x86_amx type for intel AMX.

2020-11-24 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke updated this revision to Diff 307300.
LuoYuanke added a comment.

Address Craig's comments.
Change dyn_cast to cast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91927

Files:
  clang/test/CodeGen/X86/amx_api.c
  llvm/include/llvm-c/Core.h
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/CodeGen/ValueTypes.td
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/Intrinsics.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/AMX/amx-across-func.ll
  llvm/test/CodeGen/X86/AMX/amx-config.ll
  llvm/test/CodeGen/X86/AMX/amx-spill.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/utils/TableGen/CodeGenTarget.cpp
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -248,7 +248,8 @@
   IIT_V128 = 47,
   IIT_BF16 = 48,
   IIT_STRUCT9 = 49,
-  IIT_V256 = 50
+  IIT_V256 = 50,
+  IIT_AMX  = 51,
 };
 
 static void EncodeFixedValueType(MVT::SimpleValueType VT,
@@ -276,6 +277,7 @@
   case MVT::token: return Sig.push_back(IIT_TOKEN);
   case MVT::Metadata: return Sig.push_back(IIT_METADATA);
   case MVT::x86mmx: return Sig.push_back(IIT_MMX);
+  case MVT::x86amx: return Sig.push_back(IIT_AMX);
   // MVT::OtherVT is used to mean the empty struct type here.
   case MVT::Other: return Sig.push_back(IIT_EMPTYSTRUCT);
   // MVT::isVoid is used to represent varargs here.
Index: llvm/utils/TableGen/CodeGenTarget.cpp
===
--- llvm/utils/TableGen/CodeGenTarget.cpp
+++ llvm/utils/TableGen/CodeGenTarget.cpp
@@ -76,6 +76,7 @@
   case MVT::f128: return "MVT::f128";
   case MVT::ppcf128:  return "MVT::ppcf128";
   case MVT::x86mmx:   return "MVT::x86mmx";
+  case MVT::x86amx:   return "MVT::x86amx";
   case MVT::Glue: return "MVT::Glue";
   case MVT::isVoid:   return "MVT::isVoid";
   case MVT::v1i1: return "MVT::v1i1";
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-type.ll
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -8,18 +8,70 @@
 @buf = dso_local global [1024 x i8] zeroinitializer, align 16
 @buf2 = dso_local global [1024 x i8] zeroinitializer, align 16
 
+; test bitcast x86_amx to <256 x i32>
+define dso_local void @test_user_empty(x86_amx %in) #2 {
+; CHECK-LABEL: @test_user_empty(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:ret void
+;
+entry:
+  %t = bitcast x86_amx %in to <256 x i32>
+  ret void
+}
+
+; test bitcast <256 x i32> to x86_amx
+define dso_local void @test_user_empty2(<256 x i32> %in) #2 {
+; CHECK-LABEL: @test_user_empty2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:ret void
+;
+entry:
+  %t = bitcast <256 x i32> %in to x86_amx
+  ret void
+}
+
+define dso_local void @test_src_add(<256 x i32> %x, <256 x i32> %y, i16 %r, i16 %c, i8* %buf, i64 %s) #2 {
+; CHECK-LABEL: @test_src_add(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = alloca <256 x i32>, align 1024
+; CHECK-NEXT:[[ADD:%.*]] = add <256 x i32> [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast <256 x i32>* [[TMP0]] to i8*
+; CHECK-NEXT:store <256 x i32> [[ADD]], <256 x i32>* [[TMP0]], align 1024
+; CHECK-NEXT:[[TMP2:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[R:%.*]], i16 [[C:%.*]], i8* [[TMP1]], i64 64)
+; CHECK-NEXT:call void @llvm.x86.tilestored64.internal(i16 [[R]], i16 [[C]], i8* [[BUF:%.*]], i64 [[S:%.*]], x86_amx [[TMP2]]) [[ATTR3:#.*]]
+; CHECK-NEXT:ret void
+;
+entry:
+  %add = add <256 x i32> %y, %x
+  %t = bitcast <256 x i32> %add to x86_amx
+  call void @llvm.x86.tilestored64.internal(i16 %r, i16 %c, i8* %buf, i64 %s, x86_amx %t) #3
+  ret void
+}
+
+define dso_local void @test_src_add2(<256 x i32> %x, i16 %r, i16 %c, i8* %buf, i64 %s) #2 {
+; CHECK-LABEL: @test_src_add2(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = alloca <256 x i32>, align 1024
+; CHECK-NEXT:[[T1:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 [[R:%.*]], i16 [[C:%.*]], i8* [[BUF:%.*]], i64 [[S:%.*]]) [[ATTR3]]
+; CHECK-NEXT:[[TMP1:%.*]] = bitcast <256 x i32>* 

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

2020-11-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf726101b6240: [clangd] Fix shared-lib builds (authored by 
kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91859

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -112,7 +112,7 @@
 
   add_clang_library(${LibraryName} ${GeneratedProtoSource}
 PARTIAL_SOURCES_INTENDED
-LINK_LIBS grpc++ protobuf)
+LINK_LIBS PUBLIC grpc++ protobuf)
 
   # Ensure dependency headers are generated before dependent protos are built.
   # DEPENDS arg is a list of "Foo.proto". While they're logically relative to
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -146,7 +146,8 @@
 if (CLANGD_ENABLE_REMOTE)
   target_link_libraries(ClangdTests
 PRIVATE
-clangdRemoteMarshalling)
+clangdRemoteMarshalling
+RemoteIndexProto)
 endif()
 
 if (CLANGD_BUILD_XPC)
Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,6 +17,4 @@
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
-
-  grpc++
   )
Index: clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
===
--- clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
@@ -4,7 +4,6 @@
   LINK_LIBS
   RemoteIndexProto
 
-  protobuf
   clangDaemon
   clangdSupport
 
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,12 @@
   generate_protos(RemoteIndexServiceProto "Service.proto"
 DEPENDS "Index.proto"
 GRPC)
+  # FIXME: Move this into generate_protos. Currently we only mention proto
+  # filename as a dependency, but linking requires target name.
+  target_link_libraries(RemoteIndexServiceProto
+PRIVATE
+RemoteIndexProto
+)
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 
@@ -18,8 +24,8 @@
 RemoteIndexProto
 RemoteIndexServiceProto
 clangdRemoteMarshalling
-protobuf
-grpc++
+clangBasic
+clangDaemon
 clangdSupport
 
 DEPENDS
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-extra/clangd/CMakeLists.txt
+++ clang-tools-extra/clangd/CMakeLists.txt
@@ -168,17 +168,18 @@
   add_subdirectory(xpc)
 endif ()
 
+if (CLANGD_ENABLE_REMOTE)
+  include(FindGRPC)
+endif()
+
 if(CLANG_INCLUDE_TESTS)
-add_subdirectory(test)
-add_subdirectory(unittests)
+  add_subdirectory(test)
+  add_subdirectory(unittests)
 endif()
 
 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is stable.
 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support for Clangd" OFF)
 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual installation.")
 
-if (CLANGD_ENABLE_REMOTE)
-  include(FindGRPC)
-endif()
 add_subdirectory(index/remote)
 add_subdirectory(index/dex/dexp)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] f726101 - [clangd] Fix shared-lib builds

2020-11-24 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-11-24T13:05:20+01:00
New Revision: f726101b6240a6740b3c0926af759da5e7336f8a

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

LOG: [clangd] Fix shared-lib builds

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

Added: 


Modified: 
clang-tools-extra/clangd/CMakeLists.txt
clang-tools-extra/clangd/index/remote/CMakeLists.txt
clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
clang-tools-extra/clangd/unittests/CMakeLists.txt
llvm/cmake/modules/FindGRPC.cmake

Removed: 




diff  --git a/clang-tools-extra/clangd/CMakeLists.txt 
b/clang-tools-extra/clangd/CMakeLists.txt
index b8300ddaf548..2ce5d31e623e 100644
--- a/clang-tools-extra/clangd/CMakeLists.txt
+++ b/clang-tools-extra/clangd/CMakeLists.txt
@@ -168,17 +168,18 @@ if ( CLANGD_BUILD_XPC )
   add_subdirectory(xpc)
 endif ()
 
+if (CLANGD_ENABLE_REMOTE)
+  include(FindGRPC)
+endif()
+
 if(CLANG_INCLUDE_TESTS)
-add_subdirectory(test)
-add_subdirectory(unittests)
+  add_subdirectory(test)
+  add_subdirectory(unittests)
 endif()
 
 # FIXME(kirillbobyrev): Document this in the LLVM docs once remote index is 
stable.
 option(CLANGD_ENABLE_REMOTE "Use gRPC library to enable remote index support 
for Clangd" OFF)
 set(GRPC_INSTALL_PATH "" CACHE PATH "Path to gRPC library manual 
installation.")
 
-if (CLANGD_ENABLE_REMOTE)
-  include(FindGRPC)
-endif()
 add_subdirectory(index/remote)
 add_subdirectory(index/dex/dexp)

diff  --git a/clang-tools-extra/clangd/index/remote/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
index 8625fa8f351e..eaa000b745e5 100644
--- a/clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -3,6 +3,12 @@ if (CLANGD_ENABLE_REMOTE)
   generate_protos(RemoteIndexServiceProto "Service.proto"
 DEPENDS "Index.proto"
 GRPC)
+  # FIXME: Move this into generate_protos. Currently we only mention proto
+  # filename as a dependency, but linking requires target name.
+  target_link_libraries(RemoteIndexServiceProto
+PRIVATE
+RemoteIndexProto
+)
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 
@@ -18,8 +24,8 @@ if (CLANGD_ENABLE_REMOTE)
 RemoteIndexProto
 RemoteIndexServiceProto
 clangdRemoteMarshalling
-protobuf
-grpc++
+clangBasic
+clangDaemon
 clangdSupport
 
 DEPENDS

diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
index 7b78ba3bb690..a5f6ebd179ec 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/marshalling/CMakeLists.txt
@@ -4,7 +4,6 @@ add_clang_library(clangdRemoteMarshalling
   LINK_LIBS
   RemoteIndexProto
 
-  protobuf
   clangDaemon
   clangdSupport
 

diff  --git a/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt 
b/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
index 595c406eff0f..e6959db6bbd8 100644
--- a/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
+++ b/clang-tools-extra/clangd/index/remote/server/CMakeLists.txt
@@ -17,6 +17,4 @@ target_link_libraries(clangd-index-server
   RemoteIndexProto
   RemoteIndexServiceProto
   clangdRemoteMarshalling
-
-  grpc++
   )

diff  --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index e7baf880e504..72ce97ed31b6 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -146,7 +146,8 @@ target_link_libraries(ClangdTests
 if (CLANGD_ENABLE_REMOTE)
   target_link_libraries(ClangdTests
 PRIVATE
-clangdRemoteMarshalling)
+clangdRemoteMarshalling
+RemoteIndexProto)
 endif()
 
 if (CLANGD_BUILD_XPC)

diff  --git a/llvm/cmake/modules/FindGRPC.cmake 
b/llvm/cmake/modules/FindGRPC.cmake
index f2c9bee38c93..7031c5f0016a 100644
--- a/llvm/cmake/modules/FindGRPC.cmake
+++ b/llvm/cmake/modules/FindGRPC.cmake
@@ -112,7 +112,7 @@ function(generate_protos LibraryName ProtoFile)
 
   add_clang_library(${LibraryName} ${GeneratedProtoSource}
 PARTIAL_SOURCES_INTENDED
-LINK_LIBS grpc++ protobuf)
+LINK_LIBS PUBLIC grpc++ protobuf)
 
   # Ensure dependency headers are generated before dependent protos are built.
   # DEPENDS arg is a list of "Foo.proto". While they're logically relative to



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


[PATCH] D91122: [clangd] Call hierarchy (XRefs layer, incoming calls)

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



Comment at: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp:86
+
+  auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel3,

the order of elements in `IncomingLevel2` is not sorted, so on some buildbots 
you are receiving "caller3" as the first element of the result, and "caller2" 
in others.

sorry for missing it the first time, it might make sense to sort containers by 
name before returning from `incomingCalls`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91122

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


[PATCH] D91122: [clangd] Call hierarchy (XRefs layer, incoming calls)

2020-11-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp:86
+
+  auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel3,

kadircet wrote:
> the order of elements in `IncomingLevel2` is not sorted, so on some buildbots 
> you are receiving "caller3" as the first element of the result, and "caller2" 
> in others.
> 
> sorry for missing it the first time, it might make sense to sort containers 
> by name before returning from `incomingCalls`
Thanks for catching that! Patch at https://reviews.llvm.org/D92000


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91122

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


[PATCH] D92000: [clangd] Collect main file refs by default

2020-11-24 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Note, the call hierarchy feature is pretty significantly impaired without this. 
See the example of `Selection::createEach()` discussed in this comment 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92000

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


[PATCH] D91676: Avoid redundant work when computing vtable vcall visibility

2020-11-24 Thread Wei Mi via Phabricator via cfe-commits
wmi accepted this revision.
wmi added inline comments.



Comment at: clang/lib/CodeGen/CGVTables.cpp:1301-1302
+  // has no effect on the min visibility computed below by the recursive 
caller.
+  if (!Visited.insert(RD).second)
+return llvm::GlobalObject::VCallVisibilityTranslationUnit;
+

tejohnson wrote:
> wmi wrote:
> > tejohnson wrote:
> > > wmi wrote:
> > > > If a CXXRecordDecl is visited twice, the visibility returned in the 
> > > > second visit could be larger than necessary. Will it change the final 
> > > > result? If it will, can we cache the visibility result got in the first 
> > > > visit instead of returning the max value? 
> > > The recursive callsites compute the std::min of the current TypeVis and 
> > > the one returned by the recursive call. So returning the max guarantees 
> > > that there is no effect on the current TypeVis. Let me know if the 
> > > comment can be clarified (that's what I meant by "so that it has no 
> > > effect on the min visibility computed below ...". Note that the initial 
> > > non-recursive invocation always has an empty Visited set.
> > I see. That makes sense! I didn't understand the location meant by 
> > "computed below by the recursive caller." Your explanation "initial 
> > non-recursive invocation always has an empty Visited set" helps a lot. It 
> > means the immediate result of GetVCallVisibilityLevel may change, but the 
> > result for the initial invocation of the recursive call won't be changed. 
> I've tried to clarify the comment accordingly
Thanks for making the comment more clear. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

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


[PATCH] D92051: [clangd] PopulateSwitch: disable on dependent enums.

2020-11-24 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
adamcz requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

If the enum is a dependent type, we would crash somewhere in
getIntWidth(). -Wswitch diagnostic doesn't work on dependent enums
either.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92051

Files:
  clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -3025,6 +3025,12 @@
   R""(enum Enum {A,B,b=B}; ^switch (A) {case A:case B:break;})"",
   "unavailable",
   },
+  {
+  // Enum is dependent type
+  File,
+  R""(template void f() {enum Enum {A}; ^switch (A) {}})"",
+  "unavailable",
+  },
   };
 
   for (const auto  : Cases) {
Index: clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
@@ -126,7 +126,7 @@
 return false;
 
   EnumD = EnumT->getDecl();
-  if (!EnumD)
+  if (!EnumD || EnumD->isDependentType())
 return false;
 
   // We trigger if there are any values in the enum that aren't covered by the


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -3025,6 +3025,12 @@
   R""(enum Enum {A,B,b=B}; ^switch (A) {case A:case B:break;})"",
   "unavailable",
   },
+  {
+  // Enum is dependent type
+  File,
+  R""(template void f() {enum Enum {A}; ^switch (A) {}})"",
+  "unavailable",
+  },
   };
 
   for (const auto  : Cases) {
Index: clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/PopulateSwitch.cpp
@@ -126,7 +126,7 @@
 return false;
 
   EnumD = EnumT->getDecl();
-  if (!EnumD)
+  if (!EnumD || EnumD->isDependentType())
 return false;
 
   // We trigger if there are any values in the enum that aren't covered by the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92053: [clangd] Addusing tweak: find insertion point after definition

2020-11-24 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 307429.
adamcz added a comment.

typo in description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92053

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2825,7 +2825,66 @@
 namespace {using two::cc;
 
 cc C;
-})cpp"}};
+})cpp"},
+// Type defined in main file, make sure using is after that.
+{R"cpp(
+namespace xx {
+  struct yy {};
+}
+
+x^x::yy X;
+)cpp",
+ R"cpp(
+namespace xx {
+  struct yy {};
+}
+
+using xx::yy;
+
+yy X;
+)cpp"},
+// Type defined in main file via "using", insert after that.
+{R"cpp(
+#include "test.hpp"
+
+namespace xx {
+  using yy = one::two::cc;
+}
+
+x^x::yy X;
+)cpp",
+ R"cpp(
+#include "test.hpp"
+
+namespace xx {
+  using yy = one::two::cc;
+}
+
+using xx::yy;
+
+yy X;
+)cpp"},
+// Using must come after function definition.
+{R"cpp(
+namespace xx {
+  void yy();
+}
+
+void fun() {
+  x^x::yy();
+}
+)cpp",
+ R"cpp(
+namespace xx {
+  void yy();
+}
+
+using xx::yy;
+
+void fun() {
+  yy();
+}
+)cpp"}};
   llvm::StringMap EditedFiles;
   for (const auto  : Cases) {
 for (const auto  : expandCases(Case.TestSource)) {
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -48,6 +48,10 @@
   NestedNameSpecifierLoc QualifierToRemove;
   // The name following QualifierToRemove.
   llvm::StringRef Name;
+  // If valid, the insertion point for "using" statement must come after this.
+  // This is relevant when the type is defined in the main file, to make sure
+  // the type/function is already defined at the point where "using" is added.
+  SourceLocation MustInsertAfterLoc;
 };
 REGISTER_TWEAK(AddUsing)
 
@@ -120,7 +124,8 @@
 llvm::Expected
 findInsertionPoint(const Tweak::Selection ,
const NestedNameSpecifierLoc ,
-   const llvm::StringRef Name) {
+   const llvm::StringRef Name,
+   const SourceLocation MustInsertAfterLoc) {
   auto  = Inputs.AST->getSourceManager();
 
   // Search for all using decls that affect this point in file. We need this for
@@ -149,6 +154,10 @@
 U->getName() == Name) {
   return InsertionPointData();
 }
+
+if (MustInsertAfterLoc.isValid() &&
+SM.isBeforeInTranslationUnit(U->getUsingLoc(), MustInsertAfterLoc))
+  continue;
 // Insertion point will be before last UsingDecl that affects cursor
 // position. For most cases this should stick with the local convention of
 // add using inside or outside namespace.
@@ -175,7 +184,10 @@
 if (Tok == Toks.end() || Tok->endLocation().isInvalid()) {
   return error("Namespace with no {");
 }
-if (!Tok->endLocation().isMacroID()) {
+if (!Tok->endLocation().isMacroID() &&
+(MustInsertAfterLoc.isInvalid() ||
+ SM.isBeforeInTranslationUnit(MustInsertAfterLoc,
+  Tok->endLocation( {
   InsertionPointData Out;
   Out.Loc = Tok->endLocation();
   Out.Suffix = "\n";
@@ -183,15 +195,18 @@
 }
   }
   // No using, no namespace, no idea where to insert. Try above the first
-  // top level decl.
+  // top level decl after MustInsertAfterLoc.
   auto TLDs = Inputs.AST->getLocalTopLevelDecls();
-  if (TLDs.empty()) {
-return error("Cannot find place to insert \"using\"");
+  for (const auto  : TLDs) {
+if (MustInsertAfterLoc.isValid() &&
+SM.isBeforeInTranslationUnit(TLD->getBeginLoc(), MustInsertAfterLoc))
+  continue;
+InsertionPointData Out;
+Out.Loc = SM.getExpansionLoc(TLD->getBeginLoc());
+Out.Suffix = "\n\n";
+return Out;
   }
-  InsertionPointData Out;
-  Out.Loc = SM.getExpansionLoc(TLDs[0]->getBeginLoc());
-  Out.Suffix = "\n\n";
-  return Out;
+  return error("Cannot find place to insert \"using\"");
 }
 
 bool isNamespaceForbidden(const Tweak::Selection ,
@@ -254,6 +269,7 @@
 if (auto *II = D->getDecl()->getIdentifier()) {
   QualifierToRemove = D->getQualifierLoc();
   Name = II->getName();
+  MustInsertAfterLoc = D->getDecl()->getBeginLoc();
 }
   } else if (auto *T = Node->ASTNode.get()) {
 if (auto E = T->getAs()) {
@@ -271,6 +287,15 @@
   QualifierToRemove, Inputs.AST->getASTContext().getPrintingPolicy());
   if (!Name.consume_front(QualifierToRemoveStr))
 return false; // What's spelled doesn't match the qualifier.
+
+  

[PATCH] D92012: [clangd][query-driver] Extract target

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



Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:212
+  if (!Target.empty()) {
+Cmd.CommandLine.push_back("-target");
+Cmd.CommandLine.push_back(Target);

sammccall wrote:
> `clang -target foo test.cc` seems to be a hard error in the driver if the 
> target is unknown.
> (vs likely *some* functionality if we just didn't set the driver)
> 
> so this could regress some scenarios. Can we mitigate that?
> (It's possible that we're running the driver in a mode where we proceed 
> anyway, but I can't remember :-()
what if target already exists in `Cmd`?

also it would be nice to use `--target=X` format to be consistent with target 
inference from invocation name as in 
https://github.com/llvm/llvm-project/blob/master/clang/lib/Tooling/Tooling.cpp#L278.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92012

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


[PATCH] D89869: [OpenCL] Define OpenCL feature macros for all versions

2020-11-24 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov updated this revision to Diff 307436.
azabaznov marked 24 inline comments as done.
azabaznov added a comment.

Addressed almost all technical and cosmetic concerns concerns. Except putting 
reference of `OpenCLOptions` in `Sema` due to const of `TargetInfo`. I think 
I'll think about that later. Also:

1. Added new target hook to define extensions/features macros in one step 
(target settings + option)
2. Define generic address space macro if pipes or device enqueue is supported.
3. Did some minor refactoring of `OpenCLOptions.h` and `OpenCLExtensions.def`.




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

https://reviews.llvm.org/D89869

Files:
  clang/include/clang/Basic/OpenCLExtensions.def
  clang/include/clang/Basic/OpenCLOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/SemaOpenCL/opencl-feature-extension-simult.cl
  clang/test/SemaOpenCL/opencl-feature-generic-as-req.cl
  clang/test/SemaOpenCL/opencl-features.cl

Index: clang/test/SemaOpenCL/opencl-features.cl
===
--- /dev/null
+++ clang/test/SemaOpenCL/opencl-features.cl
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CL20
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0  -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple spir-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL2.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+// RUN: %clang_cc1 -triple spir-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CLC++ \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL20
+
+// x86_64 and spir support all features by default
+
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+// RUN: %clang_cc1 -triple r600-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+// RUN: %clang_cc1 -triple nvptx-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finclude-default-header %s -E -dM -o - -x cl -cl-std=CL3.0 -cl-ext=-all \
+// RUN:   | FileCheck -match-full-lines %s  --check-prefix=CL30
+// RUN: %clang_cc1 -triple spir-unknown-unknown 

[PATCH] D91927: [X86] Add x86_amx type for intel AMX.

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



Comment at: llvm/lib/Target/X86/X86LowerAMXType.cpp:72
   LLVMContext  = Builder.getContext();
-  Type *Ty = LD->getType();
-  EVT VT = EVT::getEVT(Ty);
-  EVT HalfVT = VT.getHalfNumVectorElementsVT(Ctx);
-  Type *HalfTy = HalfVT.getTypeForEVT(Ctx);
-
-  Value *Ptr = LD->getPointerOperand();
-  PointerType *HalfPtrTy = HalfTy->getPointerTo(LD->getPointerAddressSpace());
-  Value *HalfPtr = Builder.CreateBitCast(Ptr, HalfPtrTy);
-  // The HW require the alignment for AMX tile is 64, but front-end generate
-  // code for the vector alignment which is the vector size.
-  uint64_t HalfTySize = HalfTy->getPrimitiveSizeInBits().getFixedSize() / 8;
-  Align Alignment = std::min(LD->getAlign(), Align(HalfTySize));
-  auto *Lo =
-  Builder.CreateAlignedLoad(HalfTy, HalfPtr, Alignment, LD->isVolatile());
-
-  HalfPtr = Builder.CreateGEP(HalfTy, HalfPtr, Builder.getInt32(1));
-  auto *Hi =
-  Builder.CreateAlignedLoad(HalfTy, HalfPtr, Alignment, LD->isVolatile());
-
-  LoadMap[Inst] = std::make_pair(Lo, Hi);
-}
-
-bool X86LowerAMXType::visitLD() {
-  if (LDSet.empty())
-return false;
-  for (auto  : LDSet) {
-int Count = 0;
-Value *NewInst = nullptr;
-// The user should be all AMX intrinsics or all LLVM instruction.
-// Don't support it is used by both AMX intrinsics and LLVM instructions.
-for (auto I = Inst->use_begin(), E = Inst->use_end(); I != E;) {
-  Use  = *I++;
-  const IntrinsicInst *II = dyn_cast(U.getUser());
-  if (!II) {
-Count++;
-continue;
-  }
-  if (NewInst)
-continue;
-  Value *Row, *Col;
-  switch (II->getIntrinsicID()) {
-  default:
-report_fatal_error("Non-AMX intrinsic use tile type.");
-break;
-  case Intrinsic::x86_tdpbssd_internal: {
-unsigned OpNo = U.getOperandNo();
-switch (OpNo) {
-case 3:
-  Row = II->getArgOperand(0);
-  Col = II->getArgOperand(1);
-  break;
-case 4:
-  Row = II->getArgOperand(0);
-  Col = II->getArgOperand(2);
-  break;
-case 5:
-  Row = II->getArgOperand(2);
-  Col = II->getArgOperand(1);
-  break;
-}
-break;
-  }
-  case Intrinsic::x86_tilestored64_internal: {
-Row = II->getArgOperand(0);
-Col = II->getArgOperand(1);
-break;
-  }
-  }
-  assert(Count == 0 && "Can NOT mix amx intrinsic and LLVM instruction");
-  // FIXME: The shape def should be ahead of load.
-  IRBuilder<> Builder(Inst);
-  LLVMContext  = Builder.getContext();
-  // Use the maximun column as stride.
-  Value *Stride = Builder.getInt64(64);
-  Value *I8Ptr =
-  Builder.CreateBitCast(Inst->getOperand(0), Type::getInt8PtrTy(Ctx));
-  std::array Args = {Row, Col, I8Ptr, Stride};
-
-  NewInst = Builder.CreateIntrinsic(Intrinsic::x86_tileloadd64_internal,
-None, Args);
-
-  Inst->replaceAllUsesWith(NewInst);
-}
-if (!NewInst)
-  splitLD(Inst);
+  AllocaInst *AllocaAddr = CreateAllocaInst(Builder, Bitcast->getParent());
+  Value *I8Ptr =

Shouldn't this be in the function's entry block?



Comment at: llvm/lib/Target/X86/X86LowerAMXType.cpp:89
+// TODO we can pick an constant operand for the shape.
+auto *Row = AMXIntrinsic->getOperand(0);
+auto *Col = AMXIntrinsic->getOperand(1);

Just use Value. auto doesn't add any value other than shortening by 1 character.



Comment at: llvm/lib/Target/X86/X86LowerAMXType.cpp:178
+LLVMContext  = Builder.getContext();
+// Use the maximun column as stride. It must be the same with load
+// stride.

maximun->maximum



Comment at: llvm/lib/Target/X86/X86LowerAMXType.cpp:182
+Value *I8Ptr =
+Builder.CreateBitCast(ST->getOperand(1), Type::getInt8PtrTy(Ctx));
+std::array Args = {Row, Col, I8Ptr, Stride, Src};

Use Builder.getInt8PtrTy then you don't need Ctx


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91927

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


[PATCH] D92054: [Driver] Default Generic_GCC ppc/ppc64/ppc64le to -fasynchronous-unwind-tables

2020-11-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: PowerPC, Bdragon28, nemanjai.
Herald added subscribers: cfe-commits, steven.zhang, kbarton, krytarowski, 
arichardson, emaste.
Herald added a project: clang.
MaskRay requested review of this revision.

GCC made the switch in 2018-04-10 ("rs6000: Enable -fasynchronous-unwind-tables 
by default").
In Clang, FreeBSD/NetBSD powerpc have already defaulted to 
-fasynchronous-unwind-tables.

This patch defaults Generic_GCC powerpc (which affects Linux) to use 
-fasynchronous-unwind-tables.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92054

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/ppc-features.cpp


Index: clang/test/Driver/ppc-features.cpp
===
--- clang/test/Driver/ppc-features.cpp
+++ clang/test/Driver/ppc-features.cpp
@@ -1,6 +1,7 @@
 /// Check default CC1 and linker options for ppc32.
 // RUN: %clang -### -target powerpc-unknown-linux-gnu %s 2>&1 | FileCheck 
--check-prefix=PPC32 %s
-// PPC32: "-mfloat-abi" "hard"
+// PPC32:  "-munwind-tables"
+// PPC32-SAME: "-mfloat-abi" "hard"
 
 // PPC32: "-m" "elf32ppclinux"
 
@@ -40,7 +41,8 @@
 /// Check default CC1 and linker options for ppc64.
 // RUN: %clang -### -target powerpc64le-unknown-linux-gnu %s 2>&1 | FileCheck 
--check-prefix=PPC64 %s
 // RUN: %clang -### -target powerpc64-unknown-linux-gnu %s 2>&1 | FileCheck 
-check-prefix=PPC64BE %s
-// PPC64: "-mfloat-abi" "hard"
+// PPC64:  "-munwind-tables"
+// PPC64-SAME: "-mfloat-abi" "hard"
 
 // PPC64: "-m" "elf64lppc"
 // PPC64BE: "-m" "elf64ppc"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2674,6 +2674,9 @@
 bool Generic_GCC::IsUnwindTablesDefault(const ArgList ) const {
   switch (getArch()) {
   case llvm::Triple::aarch64:
+  case llvm::Triple::ppc:
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
   case llvm::Triple::x86_64:
 return true;
   default:


Index: clang/test/Driver/ppc-features.cpp
===
--- clang/test/Driver/ppc-features.cpp
+++ clang/test/Driver/ppc-features.cpp
@@ -1,6 +1,7 @@
 /// Check default CC1 and linker options for ppc32.
 // RUN: %clang -### -target powerpc-unknown-linux-gnu %s 2>&1 | FileCheck --check-prefix=PPC32 %s
-// PPC32: "-mfloat-abi" "hard"
+// PPC32:  "-munwind-tables"
+// PPC32-SAME: "-mfloat-abi" "hard"
 
 // PPC32: "-m" "elf32ppclinux"
 
@@ -40,7 +41,8 @@
 /// Check default CC1 and linker options for ppc64.
 // RUN: %clang -### -target powerpc64le-unknown-linux-gnu %s 2>&1 | FileCheck --check-prefix=PPC64 %s
 // RUN: %clang -### -target powerpc64-unknown-linux-gnu %s 2>&1 | FileCheck -check-prefix=PPC64BE %s
-// PPC64: "-mfloat-abi" "hard"
+// PPC64:  "-munwind-tables"
+// PPC64-SAME: "-mfloat-abi" "hard"
 
 // PPC64: "-m" "elf64lppc"
 // PPC64BE: "-m" "elf64ppc"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2674,6 +2674,9 @@
 bool Generic_GCC::IsUnwindTablesDefault(const ArgList ) const {
   switch (getArch()) {
   case llvm::Triple::aarch64:
+  case llvm::Triple::ppc:
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
   case llvm::Triple::x86_64:
 return true;
   default:
___
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-24 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA marked 7 inline comments as done.
ZarkoCA added inline comments.



Comment at: clang/test/CodeGen/altivec.c:7
+ 
+// RUN: %clang -S -emit-llvm -maltivec -mabi=vec-extabi -target 
powerpc-unknown-aix %s -o - | FileCheck %s
+// RUN: not %clang -S -emit-llvm -mabi=vec-default -target powerpc-unknown-aix 
%s 2>&1  | FileCheck  %s --check-prefix=AIX-ATVER

Xiangling_L wrote:
> When user specify `-maltivec / -target-feature +altivec`  without using any 
> abi option,  the compiler will assume default altivec abi. In this situation, 
> since default abi hasn’t been implemented, we should emit an error. So can we 
> also add testcases for :
> 
> ```
> // RUN: not %clang -S -emit-llvm -maltivec -target powerpc-unknown-aix %s 
> 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
> and
> // RUN: not %clang_cc1 -target-feature +altivec -triple powerpc-unknown-aix 
> -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=AIX-ERROR
> ```
That's a good catch, the error was able to be generated previously but 
reworking the logic in Clang.cpp with the previous diff caused it to not be 
emitted.  I went back to the older logic which emits the error in cases like 
where `maltivec` is specified without `mabi=vec-extabi`.

As for the cc1 error, currently the not vector types error catch that before we 
emit the Altivec ABI error since at this time there isn't a good way to check 
for `target-feature +altivec` in cc1. 



Comment at: llvm/test/CodeGen/PowerPC/aix-vec-abi.ll:1
+; 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

Xiangling_L wrote:
> May I ask why we use `pwr8` for this test?
Sorry for missing this earlier, I wanted to specify a CPU that has Altivec 
instructions enabled so that hasAltivec true without the user specifying it. 


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


[clang-tools-extra] 1e82121 - [clangd] Add more trace spans for rename, NFC.

2020-11-24 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-11-24T19:57:05+01:00
New Revision: 1e821217cb3619449d536978bae7c9f05bdf0fa5

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

LOG: [clangd] Add more trace spans for rename, NFC.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index d10a7a4574ba..e7924b4add09 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -300,6 +300,7 @@ std::vector 
findOccurrencesWithinFile(ParsedAST ,
 const NamedDecl *lookupSiblingWithName(const ASTContext ,
const NamedDecl ,
llvm::StringRef Name) {
+  trace::Span Tracer("LookupSiblingWithName");
   const auto  = Ctx.Idents.get(Name);
   DeclarationName LookupName();
   DeclContextLookupResult LookupResult;
@@ -359,6 +360,7 @@ llvm::Error makeError(InvalidName Reason) {
 // Return details if the rename would produce a conflict.
 llvm::Optional checkName(const NamedDecl ,
   llvm::StringRef NewName) {
+  trace::Span Tracer("CheckName");
   auto  = RenameDecl.getASTContext();
   if (isKeyword(NewName, ASTCtx.getLangOpts()))
 return InvalidName{InvalidName::Keywords, NewName.str()};



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


[PATCH] D91029: [clangd] Implement clang-tidy options from config

2020-11-24 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 307416.
njames93 marked 5 inline comments as done.
njames93 added a comment.

Address (most of the) comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91029

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/TidyProvider.cpp
  clang-tools-extra/clangd/TidyProvider.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h

Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -17,6 +17,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTTU_H
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTTU_H
 
+#include "../TidyProvider.h"
 #include "Compiler.h"
 #include "ParsedAST.h"
 #include "TestFS.h"
@@ -58,8 +59,7 @@
   // Extra arguments for the compiler invocation.
   std::vector ExtraArgs;
 
-  llvm::Optional ClangTidyChecks;
-  llvm::Optional ClangTidyWarningsAsErrors;
+  TidyProvider ClangTidyProvider = {};
   // Index to use when building AST.
   const SymbolIndex *ExternalIndex = nullptr;
 
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -59,8 +59,8 @@
 FS.OverlayRealFileSystemForModules = true;
   Inputs.TFS = 
   Inputs.Opts = ParseOptions();
-  Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
-  Inputs.Opts.ClangTidyOpts.WarningsAsErrors = ClangTidyWarningsAsErrors;
+  if (ClangTidyProvider)
+Inputs.ClangTidyProvider = ClangTidyProvider;
   Inputs.Index = ExternalIndex;
   if (Inputs.Index)
 Inputs.Opts.SuggestMissingIncludes = true;
Index: clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ParsedASTTests.cpp
@@ -24,6 +24,7 @@
 #include "SourceCode.h"
 #include "TestFS.h"
 #include "TestTU.h"
+#include "TidyProvider.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
@@ -250,7 +251,7 @@
   TestTU TU;
   // this check runs the preprocessor, we need to make sure it does not break
   // our recording logic.
-  TU.ClangTidyChecks = "modernize-use-trailing-return-type";
+  TU.ClangTidyProvider = addTidyChecks("modernize-use-trailing-return-type");
   TU.Code = "inline int foo() {}";
 
   auto AST = TU.build();
@@ -406,7 +407,7 @@
   "replay-preamble-module", "");
   TestTU TU;
   // This check records inclusion directives replayed by clangd.
-  TU.ClangTidyChecks = "replay-preamble-check";
+  TU.ClangTidyProvider = addTidyChecks("replay-preamble-check");
   llvm::Annotations Test(R"cpp(
 $hash^#$include[[import]] $filebegin^"$filerange[[bar.h]]"
 $hash^#$include[[include_next]] $filebegin^"$filerange[[baz.h]]"
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -14,6 +14,7 @@
 #include "TestFS.h"
 #include "TestIndex.h"
 #include "TestTU.h"
+#include "TidyProvider.h"
 #include "index/MemIndex.h"
 #include "support/Path.h"
 #include "clang/Basic/Diagnostic.h"
@@ -129,7 +130,7 @@
 }
   )cpp");
   auto TU = TestTU::withCode(Test.code());
-  TU.ClangTidyChecks = "-*,google-explicit-constructor";
+  TU.ClangTidyProvider = addTidyChecks("google-explicit-constructor");
   EXPECT_THAT(
   TU.build().getDiagnostics(),
   ElementsAre(
@@ -201,8 +202,8 @@
   auto TU = TestTU::withCode(Test.code());
   // Enable alias clang-tidy checks, these check emits the same diagnostics
   // (except the check name).
-  TU.ClangTidyChecks = "-*, readability-uppercase-literal-suffix, "
-   "hicpp-uppercase-literal-suffix";
+  TU.ClangTidyProvider = addTidyChecks("readability-uppercase-literal-suffix,"
+   "hicpp-uppercase-literal-suffix");
   // Verify that we filter out the duplicated diagnostic message.
   EXPECT_THAT(
   TU.build().getDiagnostics(),
@@ -245,9 +246,10 @@
   )cpp");
   auto TU = TestTU::withCode(Test.code());
   TU.HeaderFilename = 

[PATCH] D91029: [clangd] Implement clang-tidy options from config

2020-11-24 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 12 inline comments as done and an inline comment as not done.
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:241
+/// Empty clang tidy provider, using this as a provider will disable 
clang-tidy.
+static void emptyTidyProvider(tidy::ClangTidyOptions &, llvm::StringRef,
+  unsigned &, PathRef) {}

sammccall wrote:
> or just use fixedTidyProvider("-*")
Issue with that approach is fixedTidyProvider has state so that would need a 
stable storage when passing to `asClangTidyOptionsProvider`.



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:74
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");

sammccall wrote:
> I'm not sure if this applies anymore - it's going to be the bottom of the 
> stack, and nullopt is the default
This is just incase `ClangTidyOptions::getDefaults()` ever changes.



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:75
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");
+#ifdef _WIN32

sammccall wrote:
> sammccall wrote:
> > nit: hoist the getenv out of the lambda?
> seems like we can just assign to Opts.User directly?
We can't as `EmptyDefaults` also contains the Options clang tidy modules may 
want to set.



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:167
+
+if (FS->makeAbsolute(AbsolutePath))
+  return;

sammccall wrote:
> (as noted elsewhere, the path is always absolute in clangd and we should make 
> this an interface requiremnet)
See previous comment about clang-tidy checks not adhering to this requirement.



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:170
+
+llvm::sys::path::remove_dots(AbsolutePath, true);
+llvm::StringRef Directory = llvm::sys::path::parent_path(AbsolutePath);

sammccall wrote:
> I don't think we need to try to stat the directory here.
> 
> FileOptionsProvider does, but looking at the history, this seems related to 
> some combination of:
>  - arg validation (the parameter there is a directory name, rather than a 
> filename)
>  - trying to return an appropriate error_code (original return type was 
> ErrorOr)
>  - iterating over multiple possible config files
>  - maybe caching
Ditto



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:194
+for (auto  : llvm::reverse(OptionStack))
+  Opts.mergeWith(Option, ++Order);
+  };

sammccall wrote:
> This order business is a real tangle, and looks like legacy to me (qualified 
> vs unqualified names).
> 
> I don't really think we want to use/expose it beyond the requirement that we 
> don't change the meaning of existing sets of `.clang-tidy` config files.
> And I don't think we want to bother teaching clangd's config system about it.
> 
> So I'd suggest a hack/simplification:
>  - we remove the `order` parameter from TidyProvider
>  - here in provideClangTidyFiles, we just use a local Order which counts up 
> from 1. This preserves the relative precedence of .clang-tidy files
>  - in provideClangdConfig, we always set the order to max_uint (always wins)
>  - if we ever add checkoptions to any other providers, we set the order to 0 
> (always loses)
>  - combine() doesn't touch order
> 
> This *does* duplicate the fact that .clangd config is stacked on top of 
> .clang-tidy in ClangdMain, but in a way that only matters with disputes 
> between qualified/unqualified names.
That approach is a simplification but it only makes sense in how we are using 
the providers in clangd. Downstream someone may want to add another provider 
that may get ran after `.clangd` providers. Forcing `.clangd` to have the 
highest priority will result in unexpected behaviour in that instance.
I'm happy to go with your approach if you don't see it as a blocking issue.



Comment at: clang-tools-extra/clangd/TidyProvider.h:25
+   /*Priority=*/unsigned &,
+   /*CWD*/ PathRef);
+} // namespace detail

sammccall wrote:
> we should always be passing an absolute path, so CWD shouldn't be needed.
> 
> I'm a bit surprised that ParsedAST::build doesn't assert that (though it 
> calls PreamblePatch::create, which does). Feel free to add it!
While clangd may always use absolute paths, clang-tidy may not. Checks are able 
to query the context and get options for other files.
When I put asserts on the Filename being absolute, things started failing.



Comment at: clang-tools-extra/clangd/tool/ClangdMain.cpp:850
+Providers.push_back(provideEnvironment());
+

[clang] 8f8bbf9 - [test] Clean up ppc-features.cpp and improve tests

2020-11-24 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-11-24T11:59:15-08:00
New Revision: 8f8bbf98dae1c513b70614a9640b861e6e240b5f

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

LOG: [test] Clean up ppc-features.cpp and improve tests

And add ppc-cpus.cpp for -mcpu= specific tests.

Added: 
clang/test/Driver/ppc-cpus.c

Modified: 
clang/test/Driver/ppc-features.cpp

Removed: 




diff  --git a/clang/test/Driver/ppc-cpus.c b/clang/test/Driver/ppc-cpus.c
new file mode 100644
index ..9f23d86e41ef
--- /dev/null
+++ b/clang/test/Driver/ppc-cpus.c
@@ -0,0 +1,21 @@
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=ppc64 2>&1 | FileCheck 
--check-prefix=MCPU_PPC64 %s
+// MCPU_PPC64: "-target-cpu" "ppc64"
+
+/// We cannot check much for -mcpu=native, but it should be replaced by a CPU 
name.
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=native 2>&1 | FileCheck 
--check-prefix=MCPU_NATIVE %s
+// MCPU_NATIVE-NOT: "-target-cpu" "native"
+
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=7400 2>&1 | FileCheck 
--check-prefix=MCPU_7400 %s
+// MCPU_7400: "-target-cpu" "7400"
+
+/// The following -mcpu= have their own -target-cpu values.
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=G4 2>&1 | FileCheck %s 
--check-prefix=NO_PPC64
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=7450 2>&1 | FileCheck %s 
--check-prefix=NO_PPC64
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=G4+ 2>&1 | FileCheck %s 
--check-prefix=NO_PPC64
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=970 2>&1 | FileCheck %s 
--check-prefix=NO_PPC64
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=G5 2>&1 | FileCheck %s 
--check-prefix=NO_PPC64
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=pwr6 2>&1 | FileCheck %s 
--check-prefix=NO_PPC64
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=pwr7 2>&1 | FileCheck %s 
--check-prefix=NO_PPC64
+// RUN: %clang -### -c -target powerpc64 %s -mcpu=pwr8 2>&1 | FileCheck %s 
--check-prefix=NO_PPC64
+
+// NO_PPC64-NOT: "-target-cpu" "ppc64"

diff  --git a/clang/test/Driver/ppc-features.cpp 
b/clang/test/Driver/ppc-features.cpp
index a1affba61ee4..de176c9d5942 100644
--- a/clang/test/Driver/ppc-features.cpp
+++ b/clang/test/Driver/ppc-features.cpp
@@ -1,3 +1,9 @@
+/// Check default CC1 and linker options for ppc32.
+// RUN: %clang -### -target powerpc-unknown-linux-gnu %s 2>&1 | FileCheck 
--check-prefix=PPC32 %s
+// PPC32: "-mfloat-abi" "hard"
+
+// PPC32: "-m" "elf32ppclinux"
+
 // check -msoft-float option for ppc32
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -msoft-float -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-SOFTFLOAT %s
 // CHECK-SOFTFLOAT: "-target-feature" "-hard-float"
@@ -30,6 +36,15 @@
 // RUN: %clang -target powerpc-unknown-linux-gnu %s -mfloat-abi=x -### -o %t.o 
2>&1 | FileCheck --check-prefix=CHECK-ERRMSG %s
 // CHECK-ERRMSG: error: invalid float ABI '-mfloat-abi=x'
 
+
+/// Check default CC1 and linker options for ppc64.
+// RUN: %clang -### -target powerpc64le-unknown-linux-gnu %s 2>&1 | FileCheck 
--check-prefix=PPC64 %s
+// RUN: %clang -### -target powerpc64-unknown-linux-gnu %s 2>&1 | FileCheck 
-check-prefix=PPC64BE %s
+// PPC64: "-mfloat-abi" "hard"
+
+// PPC64: "-m" "elf64lppc"
+// PPC64BE: "-m" "elf64ppc"
+
 // check -msoft-float option for ppc64
 // RUN: %clang -target powerpc64-unknown-linux-gnu %s -msoft-float -### -o 
%t.o 2>&1 | FileCheck --check-prefix=CHECK-SOFTFLOAT64 %s
 // CHECK-SOFTFLOAT64: "-target-feature" "-hard-float"
@@ -48,53 +63,11 @@
 
 // Check that -mno-altivec correctly disables the altivec target feature on 
powerpc.
 
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -### -o 
%t.o 2>&1 | FileCheck --check-prefix=CHECK-1 %s
-// CHECK-1: "-target-feature" "-altivec"
-
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -### -o 
%t.o 2>&1 | FileCheck --check-prefix=CHECK-2 %s
-// CHECK-2: "-target-feature" "-altivec"
-
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -maltivec -mno-altivec 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-3 %s
-// CHECK-3: "-target-feature" "-altivec"
-
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -maltivec -mno-altivec 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-4 %s
-// CHECK-4: "-target-feature" "-altivec"
-
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -maltivec 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-5 %s
-// CHECK-5-NOT: "-target-feature" "-altivec"
-
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -maltivec 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-6 %s
-// CHECK-6-NOT: "-target-feature" "-altivec"
-
-// RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-altivec -mcpu=7400 
-### -o %t.o 2>&1 | FileCheck --check-prefix=CHECK-7 %s
-// 

[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2020-11-24 Thread Dave Airlie via Phabricator via cfe-commits
airlied added a comment.

In D92004#2413560 , @Anastasia wrote:

> Btw how about making some checks simpler. We could always define feature 
> macros `__opencl_c_atomic_scope_device`, `__opencl_c_generic_address_space` 
> for  OpenCL 2.0 or C++ for OpenCL . Then everywhere we would only need to 
> check feature macros instead of language versions and feature macros together.
>
>   #if !(defined()) && (defined(__OPENCL_CPP_VERSION__) || 
> (__OPENCL_C_VERSION__ == CL_VERSION_2_0))
>   #define __opencl_c_atomic_scope_device  1
>   #define __opencl_c_generic_address_space   1
>   ...
>   #endif

I like this idea but my only worry was about leaking those definitions to the 
user source when the system hasn't defined them.

i.e. a CL2.0 user now sees __opencl_c_generic_address_space, writes code to use 
that macro, but it fails on other OpenCL C implementations.

But if we are going to have feature code that works like that then I'm fine 
with going ahead and changing things to look like this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[PATCH] D91980: [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-11-24 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:10333
+  /// Check if there is an active global `omp begin assumes` directive.
+  bool isInOpenMPAssumeScope() { return !OMPAssumeScoped.empty(); }
+

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > jdoerfert wrote:
> > > > ABataev wrote:
> > > > > ABataev wrote:
> > > > > > `const` member functions.
> > > > > It may have side-effects with template instantiations. What if we 
> > > > > have something like this:
> > > > > ```
> > > > > #pragma omp begin assumes ...
> > > > > template 
> > > > > struct S {
> > > > > ...
> > > > > }
> > > > > #pragma omp end assumes
> > > > > 
> > > > > void bar() {
> > > > > #pragma omp assumes ...
> > > > >   {
> > > > > S s;
> > > > > s.foo();
> > > > >   }
> > > > > }
> > > > > ```
> > > > > ?
> > > > > 
> > > > > `struct S` will be instantiated in the second assume region 
> > > > > context though I doubt this is the user intention.
> > > > I'm not sure what problem you expect here. Could you elaborate what you 
> > > > think should happen or should not?
> > > May it lead to the wrong compiler assumptions and result in the incorrect 
> > > codegen?
> > I'm still not following your example. What wrong assumptions and/or 
> > incorrect code generation do you expect? Could you provide an example with 
> > actual assumptions and then describe what the problem is please.
> Say, you have something like this:
> ```
> template 
> struct S {
>   int a;
>   void foo() {
> #pragma omp parallel
> ...
>   }
> };
> 
> void bar() {
> #pragma omp assumems no_openmp
>   S s; // S is instantiated here and function S::foo() gets 
> no_openmp attribute.
>   s.a = 0; // S::foo is instantiated here but not used and the attribute 
> no_openmp should not be propagated for this function.
> #pragma omp end assumes
> 
>   S b; // S already instantiated and S::foo is instantiated 
> with attribute no_openmp
>   b.foo(); // calls function S::foo with no_openmp attribute.
> }
> ```
> What do you think?
Thanks for the extra information. I'll add a test based on this for sure, no 
matter what we come up with for now.

```
#pragma omp begin assumes no_openmp
  S s; // S is instantiated here and function S::foo() gets 
no_openmp attribute.
  s.a = 0;
#pragma omp end assumes
```

Hm, I guess the question is: 
Is `S::foo()` a function defined in between the `begin`/`end` or not. If 
we say it is, the behavior right now seems consistent but the standard might 
need some clarifications. If we say it is not, we should not annotate it. 
Though, if it is not, where is it defined? I could avoid annotating template 
instantiations I guess. I might start with that. Update is coming.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

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


[PATCH] D91980: [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-11-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:10333
+  /// Check if there is an active global `omp begin assumes` directive.
+  bool isInOpenMPAssumeScope() { return !OMPAssumeScoped.empty(); }
+

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > ABataev wrote:
> > > > > `const` member functions.
> > > > It may have side-effects with template instantiations. What if we have 
> > > > something like this:
> > > > ```
> > > > #pragma omp begin assumes ...
> > > > template 
> > > > struct S {
> > > > ...
> > > > }
> > > > #pragma omp end assumes
> > > > 
> > > > void bar() {
> > > > #pragma omp assumes ...
> > > >   {
> > > > S s;
> > > > s.foo();
> > > >   }
> > > > }
> > > > ```
> > > > ?
> > > > 
> > > > `struct S` will be instantiated in the second assume region 
> > > > context though I doubt this is the user intention.
> > > I'm not sure what problem you expect here. Could you elaborate what you 
> > > think should happen or should not?
> > May it lead to the wrong compiler assumptions and result in the incorrect 
> > codegen?
> I'm still not following your example. What wrong assumptions and/or incorrect 
> code generation do you expect? Could you provide an example with actual 
> assumptions and then describe what the problem is please.
Say, you have something like this:
```
template 
struct S {
  int a;
  void foo() {
#pragma omp parallel
...
  }
};

void bar() {
#pragma omp assumems no_openmp
  S s; // S is instantiated here and function S::foo() gets 
no_openmp attribute.
  s.a = 0; // S::foo is instantiated here but not used and the attribute 
no_openmp should not be propagated for this function.
#pragma omp end assumes

  S b; // S already instantiated and S::foo is instantiated with 
attribute no_openmp
  b.foo(); // calls function S::foo with no_openmp attribute.
}
```
What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

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


[clang] 0768b05 - Avoid redundant work when computing vtable vcall visibility

2020-11-24 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-11-24T12:06:24-08:00
New Revision: 0768b0576a938b6a4832884384fcb02cd2f74e09

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

LOG: Avoid redundant work when computing vtable vcall visibility

Add a Visited set to avoid repeatedly processing the same base classes
in complex class hierarchies. This cut down the compile time of one
source file from >12min to ~1min.

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

Added: 


Modified: 
clang/lib/CodeGen/CGVTables.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/MicrosoftCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 65b3b0c5f53d..75afc860cc47 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -1294,8 +1294,16 @@ bool CodeGenModule::HasHiddenLTOVisibility(const 
CXXRecordDecl *RD) {
   return !HasLTOVisibilityPublicStd(RD);
 }
 
-llvm::GlobalObject::VCallVisibility
-CodeGenModule::GetVCallVisibilityLevel(const CXXRecordDecl *RD) {
+llvm::GlobalObject::VCallVisibility CodeGenModule::GetVCallVisibilityLevel(
+const CXXRecordDecl *RD, llvm::DenseSet ) {
+  // If we have already visited this RD (which means this is a recursive call
+  // since the initial call should have an empty Visited set), return the max
+  // visibility. The recursive calls below compute the min between the result
+  // of the recursive call and the current TypeVis, so returning the max here
+  // ensures that it will have no effect on the current TypeVis.
+  if (!Visited.insert(RD).second)
+return llvm::GlobalObject::VCallVisibilityTranslationUnit;
+
   LinkageInfo LV = RD->getLinkageAndVisibility();
   llvm::GlobalObject::VCallVisibility TypeVis;
   if (!isExternallyVisible(LV.getLinkage()))
@@ -1307,13 +1315,15 @@ CodeGenModule::GetVCallVisibilityLevel(const 
CXXRecordDecl *RD) {
 
   for (auto B : RD->bases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
-  TypeVis = std::min(TypeVis,
-
GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl()));
+  TypeVis = std::min(
+  TypeVis,
+  GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl(), Visited));
 
   for (auto B : RD->vbases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
-  TypeVis = std::min(TypeVis,
-
GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl()));
+  TypeVis = std::min(
+  TypeVis,
+  GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl(), Visited));
 
   return TypeVis;
 }
@@ -1382,7 +1392,9 @@ void CodeGenModule::EmitVTableTypeMetadata(const 
CXXRecordDecl *RD,
 
   if (getCodeGenOpts().VirtualFunctionElimination ||
   getCodeGenOpts().WholeProgramVTables) {
-llvm::GlobalObject::VCallVisibility TypeVis = GetVCallVisibilityLevel(RD);
+llvm::DenseSet Visited;
+llvm::GlobalObject::VCallVisibility TypeVis =
+GetVCallVisibilityLevel(RD, Visited);
 if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
   VTable->setVCallVisibilityMetadata(TypeVis);
   }

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 7d812b6658dc..c59570598b0d 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1333,8 +1333,11 @@ class CodeGenModule : public CodeGenTypeCache {
   /// a virtual function call could be made which ends up being dispatched to a
   /// member function of this class. This scope can be wider than the 
visibility
   /// of the class itself when the class has a more-visible dynamic base class.
+  /// The client should pass in an empty Visited set, which is used to prevent
+  /// redundant recursive processing.
   llvm::GlobalObject::VCallVisibility
-  GetVCallVisibilityLevel(const CXXRecordDecl *RD);
+  GetVCallVisibilityLevel(const CXXRecordDecl *RD,
+  llvm::DenseSet );
 
   /// Emit type metadata for the given vtable using the given layout.
   void EmitVTableTypeMetadata(const CXXRecordDecl *RD,

diff  --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp 
b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
index 8046b7afce57..c16c72dc93d5 100644
--- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1649,8 +1649,9 @@ void MicrosoftCXXABI::emitVTableTypeMetadata(const 
VPtrInfo ,
   // TODO: Should VirtualFunctionElimination also be supported here?
   // See similar handling in CodeGenModule::EmitVTableTypeMetadata.
   if (CGM.getCodeGenOpts().WholeProgramVTables) {
+llvm::DenseSet Visited;
 llvm::GlobalObject::VCallVisibility TypeVis =
-CGM.GetVCallVisibilityLevel(RD);
+CGM.GetVCallVisibilityLevel(RD, Visited);
 if (TypeVis != 

[PATCH] D91676: Avoid redundant work when computing vtable vcall visibility

2020-11-24 Thread Teresa Johnson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0768b0576a93: Avoid redundant work when computing vtable 
vcall visibility (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/MicrosoftCXXABI.cpp


Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1649,8 +1649,9 @@
   // TODO: Should VirtualFunctionElimination also be supported here?
   // See similar handling in CodeGenModule::EmitVTableTypeMetadata.
   if (CGM.getCodeGenOpts().WholeProgramVTables) {
+llvm::DenseSet Visited;
 llvm::GlobalObject::VCallVisibility TypeVis =
-CGM.GetVCallVisibilityLevel(RD);
+CGM.GetVCallVisibilityLevel(RD, Visited);
 if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
   VTable->setVCallVisibilityMetadata(TypeVis);
   }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1333,8 +1333,11 @@
   /// a virtual function call could be made which ends up being dispatched to a
   /// member function of this class. This scope can be wider than the 
visibility
   /// of the class itself when the class has a more-visible dynamic base class.
+  /// The client should pass in an empty Visited set, which is used to prevent
+  /// redundant recursive processing.
   llvm::GlobalObject::VCallVisibility
-  GetVCallVisibilityLevel(const CXXRecordDecl *RD);
+  GetVCallVisibilityLevel(const CXXRecordDecl *RD,
+  llvm::DenseSet );
 
   /// Emit type metadata for the given vtable using the given layout.
   void EmitVTableTypeMetadata(const CXXRecordDecl *RD,
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -1294,8 +1294,16 @@
   return !HasLTOVisibilityPublicStd(RD);
 }
 
-llvm::GlobalObject::VCallVisibility
-CodeGenModule::GetVCallVisibilityLevel(const CXXRecordDecl *RD) {
+llvm::GlobalObject::VCallVisibility CodeGenModule::GetVCallVisibilityLevel(
+const CXXRecordDecl *RD, llvm::DenseSet ) {
+  // If we have already visited this RD (which means this is a recursive call
+  // since the initial call should have an empty Visited set), return the max
+  // visibility. The recursive calls below compute the min between the result
+  // of the recursive call and the current TypeVis, so returning the max here
+  // ensures that it will have no effect on the current TypeVis.
+  if (!Visited.insert(RD).second)
+return llvm::GlobalObject::VCallVisibilityTranslationUnit;
+
   LinkageInfo LV = RD->getLinkageAndVisibility();
   llvm::GlobalObject::VCallVisibility TypeVis;
   if (!isExternallyVisible(LV.getLinkage()))
@@ -1307,13 +1315,15 @@
 
   for (auto B : RD->bases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
-  TypeVis = std::min(TypeVis,
-
GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl()));
+  TypeVis = std::min(
+  TypeVis,
+  GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl(), Visited));
 
   for (auto B : RD->vbases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
-  TypeVis = std::min(TypeVis,
-
GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl()));
+  TypeVis = std::min(
+  TypeVis,
+  GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl(), Visited));
 
   return TypeVis;
 }
@@ -1382,7 +1392,9 @@
 
   if (getCodeGenOpts().VirtualFunctionElimination ||
   getCodeGenOpts().WholeProgramVTables) {
-llvm::GlobalObject::VCallVisibility TypeVis = GetVCallVisibilityLevel(RD);
+llvm::DenseSet Visited;
+llvm::GlobalObject::VCallVisibility TypeVis =
+GetVCallVisibilityLevel(RD, Visited);
 if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
   VTable->setVCallVisibilityMetadata(TypeVis);
   }


Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1649,8 +1649,9 @@
   // TODO: Should VirtualFunctionElimination also be supported here?
   // See similar handling in CodeGenModule::EmitVTableTypeMetadata.
   if (CGM.getCodeGenOpts().WholeProgramVTables) {
+llvm::DenseSet Visited;
 llvm::GlobalObject::VCallVisibility TypeVis =
-CGM.GetVCallVisibilityLevel(RD);
+CGM.GetVCallVisibilityLevel(RD, Visited);
 if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
   

[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-11-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 307408.
vsavchenko added a comment.

Fix tests and a typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

Files:
  clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaObjC/attr-called-once.m
  clang/test/SemaObjC/warn-called-once.m

Index: clang/test/SemaObjC/warn-called-once.m
===
--- /dev/null
+++ clang/test/SemaObjC/warn-called-once.m
@@ -0,0 +1,887 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -fobjc-exceptions -Wcompletion-handler %s
+
+#define NULL (void *)0
+#define CALLED_ONCE __attribute__((called_once))
+#define NORETURN __attribute__((noreturn))
+
+@protocol NSObject
+@end
+@interface NSObject 
+- (id)copy;
+- (id)class;
+- autorelease;
+@end
+
+typedef unsigned int NSUInteger;
+typedef struct {
+} NSFastEnumerationState;
+
+@interface NSArray <__covariant NSFastEnumeration>
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@interface NSMutableArray : NSArray 
+- addObject:anObject;
+@end
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...);
+
+void escape(void (^callback)(void));
+void escape_void(void *);
+void indirect_call(void (^callback)(void) CALLED_ONCE);
+void indirect_conv(void (^completionHandler)(void));
+void filler(void);
+void exit(int) NORETURN;
+
+void double_call_one_block(void (^callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_parens(void (^callback)(void) CALLED_ONCE) {
+  (callback)(); // expected-note{{previous call is here}}
+  (callback)(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_ptr(void (*callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_ptr_deref(void (*callback)(void) CALLED_ONCE) {
+  (*callback)(); // expected-note{{previous call is here}}
+  (*callback)(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void multiple_call_one_block(void (^callback)(void) CALLED_ONCE) {
+  // We don't really need to repeat the same warning for the same parameter.
+  callback(); // no-warning
+  callback(); // no-warning
+  callback(); // no-warning
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_branching_1(int cond, void (^callback)(void) CALLED_ONCE) {
+  if (cond) {
+callback(); // expected-note{{previous call is here}}
+  } else {
+cond += 42;
+  }
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_branching_2(int cond, void (^callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+
+  if (cond) {
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  } else {
+cond += 42;
+  }
+}
+
+void double_call_branching_3(int cond, void (^callback)(void) CALLED_ONCE) {
+  if (cond) {
+callback();
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void double_call_branching_4(int cond1, int cond2, void (^callback)(void) CALLED_ONCE) {
+  if (cond1) {
+cond2 = !cond2;
+  } else {
+callback(); // expected-note{{previous call is here}}
+  }
+
+  if (cond2) {
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  }
+}
+
+void double_call_loop(int counter, void (^callback)(void) CALLED_ONCE) {
+  while (counter > 0) {
+counter--;
+// Both note and warning are on the same line, which is a common situation
+// in loops.
+callback(); // expected-note{{previous call is here}}
+// expected-warning@-1{{'callback' parameter marked 'called_once' is called twice}}
+  }
+}
+
+void never_called_trivial(void (^callback)(void) CALLED_ONCE) {
+  // expected-warning@-1{{'callback' parameter marked 'called_once' is never called}}
+}
+
+int never_called_branching(int x, void (^callback)(void) CALLED_ONCE) {
+  // expected-warning@-1{{'callback' parameter marked 'called_once' is never called}}
+  x -= 42;
+
+  if (x == 10) {
+return 0;
+  }
+
+  return x + 15;
+}
+
+void 

[PATCH] D92048: [SystemZ][NFC]Move all SystemZ tests to init-s390x.c

2020-11-24 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: fanbo-meng, Kai, uweigand, 
Jonathan.Crowther, muiez.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.
abhina.sreeskantharajan requested review of this revision.

This patch moves all s390x tests in init.c and init-zos.c to init-s390x.c.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92048

Files:
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-zos.c
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -855,189 +855,6 @@
 // AMDGPU:#define cl_khr_local_int32_base_atomics 1
 // AMDGPU:#define cl_khr_local_int32_extended_atomics 1
 
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X %s
-// RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=s390x-none-none -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix S390X -check-prefix S390X-CXX %s
-//
-// S390X:#define __BIGGEST_ALIGNMENT__ 8
-// S390X:#define __CHAR16_TYPE__ unsigned short
-// S390X:#define __CHAR32_TYPE__ unsigned int
-// S390X:#define __CHAR_BIT__ 8
-// S390X:#define __CHAR_UNSIGNED__ 1
-// S390X:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324
-// S390X:#define __DBL_DIG__ 15
-// S390X:#define __DBL_EPSILON__ 2.2204460492503131e-16
-// S390X:#define __DBL_HAS_DENORM__ 1
-// S390X:#define __DBL_HAS_INFINITY__ 1
-// S390X:#define __DBL_HAS_QUIET_NAN__ 1
-// S390X:#define __DBL_MANT_DIG__ 53
-// S390X:#define __DBL_MAX_10_EXP__ 308
-// S390X:#define __DBL_MAX_EXP__ 1024
-// S390X:#define __DBL_MAX__ 1.7976931348623157e+308
-// S390X:#define __DBL_MIN_10_EXP__ (-307)
-// S390X:#define __DBL_MIN_EXP__ (-1021)
-// S390X:#define __DBL_MIN__ 2.2250738585072014e-308
-// S390X:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__
-// S390X:#define __FLT_DENORM_MIN__ 1.40129846e-45F
-// S390X:#define __FLT_DIG__ 6
-// S390X:#define __FLT_EPSILON__ 1.19209290e-7F
-// S390X:#define __FLT_EVAL_METHOD__ 0
-// S390X:#define __FLT_HAS_DENORM__ 1
-// S390X:#define __FLT_HAS_INFINITY__ 1
-// S390X:#define __FLT_HAS_QUIET_NAN__ 1
-// S390X:#define __FLT_MANT_DIG__ 24
-// S390X:#define __FLT_MAX_10_EXP__ 38
-// S390X:#define __FLT_MAX_EXP__ 128
-// S390X:#define __FLT_MAX__ 3.40282347e+38F
-// S390X:#define __FLT_MIN_10_EXP__ (-37)
-// S390X:#define __FLT_MIN_EXP__ (-125)
-// S390X:#define __FLT_MIN__ 1.17549435e-38F
-// S390X:#define __FLT_RADIX__ 2
-// S390X:#define __INT16_C_SUFFIX__
-// S390X:#define __INT16_FMTd__ "hd"
-// S390X:#define __INT16_FMTi__ "hi"
-// S390X:#define __INT16_MAX__ 32767
-// S390X:#define __INT16_TYPE__ short
-// S390X:#define __INT32_C_SUFFIX__
-// S390X:#define __INT32_FMTd__ "d"
-// S390X:#define __INT32_FMTi__ "i"
-// S390X:#define __INT32_MAX__ 2147483647
-// S390X:#define __INT32_TYPE__ int
-// S390X:#define __INT64_C_SUFFIX__ L
-// S390X:#define __INT64_FMTd__ "ld"
-// S390X:#define __INT64_FMTi__ "li"
-// S390X:#define __INT64_MAX__ 9223372036854775807L
-// S390X:#define __INT64_TYPE__ long int
-// S390X:#define __INT8_C_SUFFIX__
-// S390X:#define __INT8_FMTd__ "hhd"
-// S390X:#define __INT8_FMTi__ "hhi"
-// S390X:#define __INT8_MAX__ 127
-// S390X:#define __INT8_TYPE__ signed char
-// S390X:#define __INTMAX_C_SUFFIX__ L
-// S390X:#define __INTMAX_FMTd__ "ld"
-// S390X:#define __INTMAX_FMTi__ "li"
-// S390X:#define __INTMAX_MAX__ 9223372036854775807L
-// S390X:#define __INTMAX_TYPE__ long int
-// S390X:#define __INTMAX_WIDTH__ 64
-// S390X:#define __INTPTR_FMTd__ "ld"
-// S390X:#define __INTPTR_FMTi__ "li"
-// S390X:#define __INTPTR_MAX__ 9223372036854775807L
-// S390X:#define __INTPTR_TYPE__ long int
-// S390X:#define __INTPTR_WIDTH__ 64
-// S390X:#define __INT_FAST16_FMTd__ "hd"
-// S390X:#define __INT_FAST16_FMTi__ "hi"
-// S390X:#define __INT_FAST16_MAX__ 32767
-// S390X:#define __INT_FAST16_TYPE__ short
-// S390X:#define __INT_FAST32_FMTd__ "d"
-// S390X:#define __INT_FAST32_FMTi__ "i"
-// S390X:#define __INT_FAST32_MAX__ 2147483647
-// S390X:#define __INT_FAST32_TYPE__ int
-// S390X:#define __INT_FAST64_FMTd__ "ld"
-// S390X:#define __INT_FAST64_FMTi__ "li"
-// S390X:#define __INT_FAST64_MAX__ 9223372036854775807L
-// S390X:#define __INT_FAST64_TYPE__ long int
-// S390X:#define __INT_FAST8_FMTd__ "hhd"
-// S390X:#define __INT_FAST8_FMTi__ "hhi"
-// S390X:#define __INT_FAST8_MAX__ 127
-// S390X:#define __INT_FAST8_TYPE__ signed char
-// S390X:#define __INT_LEAST16_FMTd__ "hd"
-// S390X:#define __INT_LEAST16_FMTi__ "hi"
-// S390X:#define __INT_LEAST16_MAX__ 32767
-// S390X:#define __INT_LEAST16_TYPE__ short
-// S390X:#define __INT_LEAST32_FMTd__ "d"
-// S390X:#define __INT_LEAST32_FMTi__ "i"
-// S390X:#define __INT_LEAST32_MAX__ 2147483647
-// S390X:#define __INT_LEAST32_TYPE__ int
-// S390X:#define 

[PATCH] D92053: [clangd] Addusing tweak: find insertion point after definition

2020-11-24 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
adamcz requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

When type/function is defined in the middle of the file, previuosly we
would sometimes insert a "using" line before that definition, leading to
a compilation error. With this fix, we pick a point after such
definition in translation unit.

This is not perfect solution. For example, it still doesn't handle
"using namespace" directives. It is, however, a significant improvement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92053

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2825,7 +2825,66 @@
 namespace {using two::cc;
 
 cc C;
-})cpp"}};
+})cpp"},
+// Type defined in main file, make sure using is after that.
+{R"cpp(
+namespace xx {
+  struct yy {};
+}
+
+x^x::yy X;
+)cpp",
+ R"cpp(
+namespace xx {
+  struct yy {};
+}
+
+using xx::yy;
+
+yy X;
+)cpp"},
+// Type defined in main file via "using", insert after that.
+{R"cpp(
+#include "test.hpp"
+
+namespace xx {
+  using yy = one::two::cc;
+}
+
+x^x::yy X;
+)cpp",
+ R"cpp(
+#include "test.hpp"
+
+namespace xx {
+  using yy = one::two::cc;
+}
+
+using xx::yy;
+
+yy X;
+)cpp"},
+// Using must come after function definition.
+{R"cpp(
+namespace xx {
+  void yy();
+}
+
+void fun() {
+  x^x::yy();
+}
+)cpp",
+ R"cpp(
+namespace xx {
+  void yy();
+}
+
+using xx::yy;
+
+void fun() {
+  yy();
+}
+)cpp"}};
   llvm::StringMap EditedFiles;
   for (const auto  : Cases) {
 for (const auto  : expandCases(Case.TestSource)) {
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -48,6 +48,10 @@
   NestedNameSpecifierLoc QualifierToRemove;
   // The name following QualifierToRemove.
   llvm::StringRef Name;
+  // If valid, the insertion point for "using" statement must come after this.
+  // This is relevant when the type is defined in the main file, to make sure
+  // the type/function is already defined at the point where "using" is added.
+  SourceLocation MustInsertAfterLoc;
 };
 REGISTER_TWEAK(AddUsing)
 
@@ -120,7 +124,8 @@
 llvm::Expected
 findInsertionPoint(const Tweak::Selection ,
const NestedNameSpecifierLoc ,
-   const llvm::StringRef Name) {
+   const llvm::StringRef Name,
+   const SourceLocation MustInsertAfterLoc) {
   auto  = Inputs.AST->getSourceManager();
 
   // Search for all using decls that affect this point in file. We need this for
@@ -149,6 +154,10 @@
 U->getName() == Name) {
   return InsertionPointData();
 }
+
+if (MustInsertAfterLoc.isValid() &&
+SM.isBeforeInTranslationUnit(U->getUsingLoc(), MustInsertAfterLoc))
+  continue;
 // Insertion point will be before last UsingDecl that affects cursor
 // position. For most cases this should stick with the local convention of
 // add using inside or outside namespace.
@@ -175,7 +184,10 @@
 if (Tok == Toks.end() || Tok->endLocation().isInvalid()) {
   return error("Namespace with no {");
 }
-if (!Tok->endLocation().isMacroID()) {
+if (!Tok->endLocation().isMacroID() &&
+(MustInsertAfterLoc.isInvalid() ||
+ SM.isBeforeInTranslationUnit(MustInsertAfterLoc,
+  Tok->endLocation( {
   InsertionPointData Out;
   Out.Loc = Tok->endLocation();
   Out.Suffix = "\n";
@@ -183,15 +195,18 @@
 }
   }
   // No using, no namespace, no idea where to insert. Try above the first
-  // top level decl.
+  // top level decl after MustInsertAfterLoc.
   auto TLDs = Inputs.AST->getLocalTopLevelDecls();
-  if (TLDs.empty()) {
-return error("Cannot find place to insert \"using\"");
+  for (const auto  : TLDs) {
+if (MustInsertAfterLoc.isValid() &&
+SM.isBeforeInTranslationUnit(TLD->getBeginLoc(), MustInsertAfterLoc))
+  continue;
+InsertionPointData Out;
+Out.Loc = SM.getExpansionLoc(TLD->getBeginLoc());
+Out.Suffix = "\n\n";
+return Out;
   }
-  InsertionPointData Out;
-  Out.Loc = SM.getExpansionLoc(TLDs[0]->getBeginLoc());
-  Out.Suffix = "\n\n";
-  return Out;
+  return error("Cannot find place to insert \"using\"");
 }
 
 bool isNamespaceForbidden(const Tweak::Selection ,
@@ -254,6 +269,7 @@
 if (auto *II = D->getDecl()->getIdentifier()) {
   

[PATCH] D91980: [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-11-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:10333
+  /// Check if there is an active global `omp begin assumes` directive.
+  bool isInOpenMPAssumeScope() { return !OMPAssumeScoped.empty(); }
+

jdoerfert wrote:
> ABataev wrote:
> > jdoerfert wrote:
> > > ABataev wrote:
> > > > jdoerfert wrote:
> > > > > ABataev wrote:
> > > > > > ABataev wrote:
> > > > > > > `const` member functions.
> > > > > > It may have side-effects with template instantiations. What if we 
> > > > > > have something like this:
> > > > > > ```
> > > > > > #pragma omp begin assumes ...
> > > > > > template 
> > > > > > struct S {
> > > > > > ...
> > > > > > }
> > > > > > #pragma omp end assumes
> > > > > > 
> > > > > > void bar() {
> > > > > > #pragma omp assumes ...
> > > > > >   {
> > > > > > S s;
> > > > > > s.foo();
> > > > > >   }
> > > > > > }
> > > > > > ```
> > > > > > ?
> > > > > > 
> > > > > > `struct S` will be instantiated in the second assume region 
> > > > > > context though I doubt this is the user intention.
> > > > > I'm not sure what problem you expect here. Could you elaborate what 
> > > > > you think should happen or should not?
> > > > May it lead to the wrong compiler assumptions and result in the 
> > > > incorrect codegen?
> > > I'm still not following your example. What wrong assumptions and/or 
> > > incorrect code generation do you expect? Could you provide an example 
> > > with actual assumptions and then describe what the problem is please.
> > Say, you have something like this:
> > ```
> > template 
> > struct S {
> >   int a;
> >   void foo() {
> > #pragma omp parallel
> > ...
> >   }
> > };
> > 
> > void bar() {
> > #pragma omp assumems no_openmp
> >   S s; // S is instantiated here and function S::foo() gets 
> > no_openmp attribute.
> >   s.a = 0; // S::foo is instantiated here but not used and the 
> > attribute no_openmp should not be propagated for this function.
> > #pragma omp end assumes
> > 
> >   S b; // S already instantiated and S::foo is instantiated 
> > with attribute no_openmp
> >   b.foo(); // calls function S::foo with no_openmp attribute.
> > }
> > ```
> > What do you think?
> Thanks for the extra information. I'll add a test based on this for sure, no 
> matter what we come up with for now.
> 
> ```
> #pragma omp begin assumes no_openmp
>   S s; // S is instantiated here and function S::foo() gets 
> no_openmp attribute.
>   s.a = 0;
> #pragma omp end assumes
> ```
> 
> Hm, I guess the question is: 
> Is `S::foo()` a function defined in between the `begin`/`end` or not. If 
> we say it is, the behavior right now seems consistent but the standard might 
> need some clarifications. If we say it is not, we should not annotate it. 
> Though, if it is not, where is it defined? I could avoid annotating template 
> instantiations I guess. I might start with that. Update is coming.
> 
> 
Yep, this is what I'm asking about. I would check С++ standard, I believe we 
shall follow С++ rules here about the instantiation context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

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


[PATCH] D50979: Eliminate instances of `EmitScalarExpr(E->getArg(n))` in EmitX86BuiltinExpr().

2020-11-24 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.
Herald added a subscriber: pengfei.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:10471
   case X86::BI_InterlockedIncrement64:
 return EmitMSVCBuiltinExpr(MSVCIntrin::_InterlockedIncrement, E);
   case X86::BI_InterlockedCompareExchange128: {

I noticed that EmitMSVCBuiltinExpr evaluates args again, so each one of these 
intrinsic implementations has this same bug. :(

I'll put together a fix.

It's a bit not straightforward because AArch64 doesn't pre-evaluate all the 
builtin arguments like x86, so we need an adapter from one style to the other.


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

https://reviews.llvm.org/D50979

___
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-24 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4624
+
+  if (Triple.isOSAIX()) {
+if (Args.hasArg(options::OPT_maltivec) &&

line 4624 to line 4635 can be simplified to :

```
  if (Triple.isOSAIX() && Args.hasArg(options::OPT_maltivec) {
if (Args.hasArg(options::OPT_mabi_EQ_vec_extabi)) {
  CmdArgs.push_back("-mabi=vec-extabi");
} else {
  D.Diag(diag::err_aix_default_altivec_abi);
}
  }
```

or even simplify line 4617 -4636 to the following if it works:

```
  if (Arg *A = Args.getLastArg(options::OPT_mabi_EQ_vec_extabi,
   options::OPT_mabi_EQ_vec_default)) {
if (!Triple.isOSAIX())
  D.Diag(diag::err_drv_unsupported_opt_for_target)
  << A->getSpelling() << RawTriple.str();

if (!Args.hasArg(options::OPT_maltivec))
  D.Diag(diag::err_aix_altivec);

if (Args.hasArg(options::OPT_mabi_EQ_vec_default))
  D.Diag(diag::err_aix_default_altivec_abi);

CmdArgs.push_back("-mabi=vec-extabi");
  } else if (Triple.isOSAIX() && Args.hasArg(options::OPT_maltivec) {
  D.Diag(diag::err_aix_default_altivec_abi);
  }
```



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1445
+  Args.getLastArg(OPT_mabi_EQ_vec_default, OPT_mabi_EQ_vec_extabi)) {
+if (!T.isOSAIX() || !T.isOSBinFormatXCOFF())
+  Diags.Report(diag::err_drv_unsupported_opt_for_target)

Hi Zarko, is the above comment missed being addressed?


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] D92053: [clangd] Addusing tweak: find insertion point after definition

2020-11-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, LGTM




Comment at: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp:158
+
+if (MustInsertAfterLoc.isValid() &&
+SM.isBeforeInTranslationUnit(U->getUsingLoc(), MustInsertAfterLoc))

why not check for this below? as usings are sorted, we expect `LastUsingLoc` to 
be after this point. so maybe change the `if` below to:

`if(LastUsingLoc.isValid() && (!MustInsertAfterLoc.isValid() || 
SM.isBeforeInTranslationUnit(MustInsertAfterLoc, LastUsingLoc)))`



Comment at: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp:201
+  for (const auto  : TLDs) {
+if (MustInsertAfterLoc.isValid() &&
+SM.isBeforeInTranslationUnit(TLD->getBeginLoc(), MustInsertAfterLoc))

nit: maybe factor this into a lambda `bool IsUsingValidAt(SourceLocation)` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92053

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


[PATCH] D92053: [clangd] Addusing tweak: find insertion point after definition

2020-11-24 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp:201
+  for (const auto  : TLDs) {
+if (MustInsertAfterLoc.isValid() &&
+SM.isBeforeInTranslationUnit(TLD->getBeginLoc(), MustInsertAfterLoc))

kadircet wrote:
> nit: maybe factor this into a lambda `bool IsUsingValidAt(SourceLocation)` ?
Good idea. Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92053

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


[clang] 3823665 - [docs] Try to make this bullet list in ThinLTO.rst actually be a bullet list

2020-11-24 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-11-24T14:08:42+01:00
New Revision: 38236656ab4a4bea5e582f709929003abfa1ddcd

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

LOG: [docs] Try to make this bullet list in ThinLTO.rst actually be a bullet 
list

Added: 


Modified: 
clang/docs/ThinLTO.rst

Removed: 




diff  --git a/clang/docs/ThinLTO.rst b/clang/docs/ThinLTO.rst
index 0da822f498b9..fa6d28e13ba7 100644
--- a/clang/docs/ThinLTO.rst
+++ b/clang/docs/ThinLTO.rst
@@ -124,9 +124,13 @@ be reduced to ``N`` via:
   ``/opt:lldltojobs=N``
 
 Other possible values for ``N`` are:
-- 0: Use one thread per physical core (default)
-- 1: Use a single thread only (disable multi-threading)
-- all: Use one thread per logical core (uses all hyper-threads)
+
+- 0:
+  Use one thread per physical core (default)
+- 1:
+  Use a single thread only (disable multi-threading)
+- all:
+  Use one thread per logical core (uses all hyper-threads)
 
 Incremental
 ---



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


[PATCH] D91088: [CUDA][HIP] Fix capturing reference to host variable

2020-11-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 2 inline comments as done.
yaxunl added a comment.

ping




Comment at: clang/lib/Sema/SemaExpr.cpp:357
 
+  if (LangOpts.CUDAIsDevice) {
+auto *FD = dyn_cast_or_null(CurContext);

tra wrote:
> This could use a comment about why we only check `D->H` references.
> `H->D` references will still work (sort of) because on the host side we have 
> matching `shadow` variables.
> 
> 
the comment has been added in the separated patch for diagnostics.


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

https://reviews.llvm.org/D91088

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


[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2020-11-24 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added a comment.

Hi! Great to see the interest in OpenCL C 3.0!

I'm being working already at a proper feature macros definition to unify both 
clang and header OpenCL C 3.0 related changes, here is the change: 
https://reviews.llvm.org/D89869. So as this patch will be merged then the check 
for supported feature can be done uniformly in all OpenCL versions:

Use:

  #ifdef __opencl_c_pipes

instead of

  #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= 
CL_VERSION_2_0 && __OPENCL_C_VERSION__ < CL_VERSION_3_0) || 
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && defined(__opencl_c_pipes))

The main concepts are described in RFC thread here: 
https://lists.llvm.org/pipermail/cfe-dev/2020-September/066883.html. Will be 
glad to discuss any technical details and concerns. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[PATCH] D88712: [CGBuiltin] Respect asm labels and redefine_extname for builtins with specialized emitting

2020-11-24 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D88712#2412874 , 
@venkataramanan.kumar.llvm wrote:

> In D88712#2412366 , @MaskRay wrote:
>
>> In D88712#2411841 , 
>> @venkataramanan.kumar.llvm wrote:
>>
>>> 
>>
>> For your example:
>>
>>   extern double log (double) asm ("" "log_finite") __attribute__ ((nothrow));
>>   
>>   double mylog (double d) { return log(d); }
>>
>> The intention is to emit `log_finite`, no matter the `-ffast-math`. Both GCC 
>> and Clang (after this patch) emit `jmp log_finite`.
>>
>> The previous behavior (according to your comment, with an older glibc) was 
>> undesired. So I think the right suggestion is to upgrade glibc.
>
> Then there optimizations like vectorization, inst combine which works on the 
> LLVM intrinsics.  But they will be not happening now  with  log_finite calls.

I'm not sure about the expected semantics/lowering for the finite calls, but 
can you add something under LibCallSimplifier::optimizeFloatingPointLibCall() 
that would turn it into the LLVM log intrinsic with appropriate FMF? Codegen 
would need to be responsible for converting it back to finite call(s) if those 
are available?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88712

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


[PATCH] D91310: [AMDGPU] Add -mcode-object-version=n

2020-11-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D91310

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


[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2020-11-24 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D92004#2413603 , @Anastasia wrote:

> @svenvh I imagine the testing functionality between the two headers will be 
> identical?

Mostly, assuming you intend to test in the conventional way of feeding a .cl 
file to Clang.  Although currently `-fdeclare-opencl-builtins` only provides a 
subset of the builtins in `opencl-c.h`.

In the past I did have a look at the possibility of automated equivalence 
checking of declarations provided by both `-fdeclare-opencl-builtins` and 
`opencl-c.h`.  It shouldn't be impossible, but it's not trivial (one reason 
being that gentype-expansion is currently done in Sema).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[clang-tools-extra] 9e83d0b - [clangd] Mention when CXXThis is implicit in exposed AST.

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

Author: Sam McCall
Date: 2020-11-24T16:57:56+01:00
New Revision: 9e83d0bcdfe86fd13f2817c9f40c5ca0b08f1443

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

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

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

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 9ea17e876de7..12698b42ef3e 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -234,6 +234,14 @@ class DumpVisitor : public 
RecursiveASTVisitor {
   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";
+  return "";
+}
 if (isa(S) || isa(S) ||
 isa(S) || isa(S) ||
 isa(S) || isa(S))

diff  --git a/clang-tools-extra/clangd/unittests/DumpASTTests.cpp 
b/clang-tools-extra/clangd/unittests/DumpASTTests.cpp
index 4b524820cb4c..23c673284f66 100644
--- a/clang-tools-extra/clangd/unittests/DumpASTTests.cpp
+++ b/clang-tools-extra/clangd/unittests/DumpASTTests.cpp
@@ -76,29 +76,32 @@ declaration: Namespace - root
   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 @@ declaration: Var - root
   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  : 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());



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


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

2020-11-24 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
sammccall marked an inline comment as done.
Closed by commit rG9e83d0bcdfe8: [clangd] Mention when CXXThis is implicit in 
exposed AST. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D91868?vs=306681=307363#toc

Repository:
  rG LLVM Github Monorepo

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

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  : 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
@@ -234,6 +234,14 @@
   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";
+  return "";
+}
 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] D92037: clang: Pass -platform-version to new MachO LLD

2020-11-24 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Driver/ToolChain.h:334
   /// LLD's supported flags, error output, etc.
-  std::string GetLinkerPath(bool *LinkerIsLLD = nullptr) const;
+  /// If LinkerIsLLDDarwinNew is non-nullptr, it's set if it's the in-progress
+  /// new version in lld/MachO.

ultra nit: the "in-progress" part doesn't really add much to the comment and 
might be obsolete soon, so i would probably have left that out. Also, strictly 
speaking, it's not immediately clear what the second "it" refers to here.


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

https://reviews.llvm.org/D92037

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


[PATCH] D92010: [clang-offload-bundler] use std::forward_list for storing temp file names [NFC]

2020-11-24 Thread Sergey Dmitriev 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 rG1b0ca81a6c35: [clang-offload-bundler] use std::forward_list 
for storing temp file names [NFC] (authored by sdmitriev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92010

Files:
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -394,7 +395,7 @@
 if (std::error_code EC =
 sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
   return createFileError(File, EC);
-Files.push_back(File);
+Files.push_front(File);
 
 if (Contents) {
   std::error_code EC;
@@ -403,11 +404,11 @@
 return createFileError(File, EC);
   OS.write(Contents->data(), Contents->size());
 }
-return Files.back();
+return Files.front();
   }
 
 private:
-  SmallVector, 4u> Files;
+  std::forward_list> Files;
 };
 
 } // end anonymous namespace


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -394,7 +395,7 @@
 if (std::error_code EC =
 sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
   return createFileError(File, EC);
-Files.push_back(File);
+Files.push_front(File);
 
 if (Contents) {
   std::error_code EC;
@@ -403,11 +404,11 @@
 return createFileError(File, EC);
   OS.write(Contents->data(), Contents->size());
 }
-return Files.back();
+return Files.front();
   }
 
 private:
-  SmallVector, 4u> Files;
+  std::forward_list> Files;
 };
 
 } // end anonymous namespace
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1b0ca81 - [clang-offload-bundler] use std::forward_list for storing temp file names [NFC]

2020-11-24 Thread Sergey Dmitriev via cfe-commits

Author: Sergey Dmitriev
Date: 2020-11-24T08:07:31-08:00
New Revision: 1b0ca81a6c358d2d52d4f84b7f42e620ead1ed26

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

LOG: [clang-offload-bundler] use std::forward_list for storing temp file names 
[NFC]

Use a different container that preserves existing elements on modification
for storing temporary file names. Current container can make StringRefs
returned earlier invalid on reallocation.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Removed: 




diff  --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index 44c46a89a859..a1b2fecb4a80 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -394,7 +395,7 @@ class TempFileHandlerRAII {
 if (std::error_code EC =
 sys::fs::createTemporaryFile("clang-offload-bundler", "tmp", File))
   return createFileError(File, EC);
-Files.push_back(File);
+Files.push_front(File);
 
 if (Contents) {
   std::error_code EC;
@@ -403,11 +404,11 @@ class TempFileHandlerRAII {
 return createFileError(File, EC);
   OS.write(Contents->data(), Contents->size());
 }
-return Files.back();
+return Files.front();
   }
 
 private:
-  SmallVector, 4u> Files;
+  std::forward_list> Files;
 };
 
 } // end anonymous namespace



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


[PATCH] D91676: Avoid redundant work when computing vtable vcall visibility

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

Adding another reviewer - @wmi can you take a look? This is a straightforward 
compile time fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

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


[PATCH] D91966: [clangd] AddUsing: Used spelled text instead of type name.

2020-11-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp:268
+   SpelledTokens->back());
+  llvm::StringRef NameRef = SpelledRange.text(SM);
+

adamcz wrote:
> kadircet wrote:
> > what about saving the full range here, and using it's `start` and `length - 
> > name.size()` as removal range in `apply`?
> > 
> > similarly we can also use the `range.text` as text to insert. that way we 
> > can inline `getNNSLAsString` as it won't be needed elsewhere anymore.
> We only have a range in this branch of the code. The other one (for 
> DeclRefExpr) is not using TokenBuffers, so no range right now.
> 
> We may change it in the future. Or would you prefer this changed now?
> We only have a range in this branch of the code. The other one (for 
> DeclRefExpr) is not using TokenBuffers, so no range right now.

Ah right, I've forgot that one. My main concern was the extra `getSpellingLoc` 
in `apply`.

> We may change it in the future. Or would you prefer this changed now?

No hurries.



Comment at: clang-tools-extra/clangd/unittests/TweakTests.cpp:2814
+  uu u;
 })cpp"}};
   llvm::StringMap EditedFiles;

adamcz wrote:
> kadircet wrote:
> > Tests don't seem to be covering something like:
> > ```
> > namespace foo { namespace bar { struct X {}; } }
> > using namespace foo;
> > bar::X^ x;
> > ```
> So this has the unfortunate side-effect of triggering a variation of 
> https://github.com/clangd/clangd/issues/585
> 
> That's something I'm fixing in a later change (although this case is still 
> not handled). For now, I'm putting an extra namespace scope to make this test 
> correct, while still testing your example.
sorry for being confusing, I was actually suggesting putting:
```
namespace foo { namespace bar { struct X {}; } }
using namespace foo;
```
into the header (to prevent that bug from triggering), and only having the 
usage in the CC file. but this works too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91966

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


[PATCH] D91760: [Driver] Default Generic_GCC aarch64 to use -fasynchronous-unwind-tables

2020-11-24 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D91760#2413294 , @psmith wrote:

> Radio silence so far; I think no news is good news applies in this case. I'm 
> happy to say no objections.

Thanks. I'll commit then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91760

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


[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-11-24 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

Probably irrelevant comment from the C++ world: If I needed this concept in 
C++, I'd probably piggyback on the existing semantic analysis of `std::move`: 
I'd design a `class OnceCallable` with an `operator() &&` that both called and 
nulled-out its object parameter, and then call it like 
`std::move(myCallback)()`. Then if I ever tried to call it a second time, the 
static analyzer would (hopefully) complain that I was accessing a moved-from 
`myCallback`. But you want this for existing APIs that take the built-in block 
type, so never mind. :)

Probably irrelevant scope creep: Is it worth trying to support the possibility 
that someone might want to pass both a `successHandler` and a `failureHandler`, 
with the invariant that we'd make //exactly one call to one of them// (but 
never call both)? Is that just not a thing that ever happens in NSWhatever?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

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


[PATCH] D88172: [clangd] Extract common file-caching logic from ConfigProvider.

2020-11-24 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D88172#2414249 , @sammccall wrote:

> @kbobyrev ping... I think we do actually want to land this, for use with 
> `.clang-tidy` files after D91029 

Yes, I was looking at copying the config cache for use with `.clang-tidy`




Comment at: clang-tools-extra/clangd/support/FileCache.h:43
+  // Path must be absolute.
+  FileCache(llvm::StringRef Path);
+

nit: Is it more descriptive to have this spelled as `PathRef`, same for 
`path()` below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88172

___
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-24 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 307405.
ZarkoCA added a comment.

Went back to old option selection logic as updated version did not emit an 
error when selecting 'maltivec` but not `mabi=vec-extabi`.

Fixed formatting.


Repository:
  rG LLVM Github Monorepo

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/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 

[PATCH] D92037: clang: Pass -platform-version to new MachO LLD

2020-11-24 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
thakis requested review of this revision.

New MachO LLD doesn't implement the old -macos_version_min (etc)
flags, but it understands the modern platform_version flag.
So make the clang driver pass that when using new MachO LLD.

Also, while here, don't pass -lto_library to LLD, since it
links in LTO libraries statically (which it can because it's
versioned alongside clang).


https://reviews.llvm.org/D92037

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c

Index: clang/test/Driver/darwin-ld-platform-version-watchos.c
===
--- clang/test/Driver/darwin-ld-platform-version-watchos.c
+++ clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -1,12 +1,24 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN: %clang -target arm64_32-apple-watchos5.2 \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN: %clang -target arm64_32-apple-watchos5.2 \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinnew \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
+// RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
-// RUN: %clang -target x86_64-apple-watchos6-simulator -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: %clang -target arm64_32-apple-watchos5.2 \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
+// RUN: %clang -target x86_64-apple-watchos6-simulator \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
 // LINKER-OLD: "-watchos_version_min" "5.2.0"
Index: clang/test/Driver/darwin-ld-platform-version-tvos.c
===
--- clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,12 +1,24 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN: %clang -target arm64-apple-tvos12.3 \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN: %clang -target arm64-apple-tvos12.3 \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinnew \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
+// RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
-// RUN: %clang -target x86_64-apple-tvos13-simulator -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: %clang -target arm64-apple-tvos12.3 \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
+// RUN: %clang -target x86_64-apple-tvos13-simulator \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
 // LINKER-OLD: "-tvos_version_min" "12.3.0"
Index: clang/test/Driver/darwin-ld-platform-version-macos.c
===
--- clang/test/Driver/darwin-ld-platform-version-macos.c
+++ clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,20 +1,42 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN: %clang -target 

[PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine

2020-11-24 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3938
+  if ((FLAGS)::CC1Option) {
\
+const auto  = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\

jansvoboda11 wrote:
> dexonsmith wrote:
> > dexonsmith wrote:
> > > jansvoboda11 wrote:
> > > > Bigcheese wrote:
> > > > > Will this ever have an issue with lifetime? I can see various values 
> > > > > for `EXTRACTOR` causing issues here. https://abseil.io/tips/107
> > > > > 
> > > > > 
> > > > > It would be good to at least document somewhere the restrictions on 
> > > > > `EXTRACTOR`.
> > > > Mentioned the reference lifetime extension in a comment near extractor 
> > > > definitions.
> > > It might be safer to refactor as:
> > > ```
> > > // Capture the extracted value as a lambda argument to avoid potential
> > > // lifetime extension issues.
> > > [&](const auto ) {
> > >   if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))
> > > DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);
> > > }(EXTRACTOR(this->KEYPATH));
> > > ```
> > > 
> > Might be even better to avoid the generic lambda:
> > ```
> > // Capture the extracted value as a lambda argument to avoid potential
> > // lifetime extension issues.
> > using ExtractedType =
> > std::remove_const_t > decltype(EXTRACTOR(this->KEYPATH))>>
> > [&](const ExtractedType ) {
> >   if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))
> > DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);
> > }(EXTRACTOR(this->KEYPATH));
> > ```
> > (since generic vs. non-generic could affect compile-time of 
> > CompilerInvocation.cpp given how many instances there will be).
> Thanks for the suggestions @dexonsmith. I'm having trouble writing a test 
> case where the lambda workaround produces a different result than `const auto 
> &` variable.
> @Bigcheese, could you show a concrete example of an extractor that causes 
> issues so I can test it out?
I think I was confused about when this can happen. The `const auto &` will 
never cause a conversion that would prevent lifetime extension. The only place 
this would break is if the copy constructor of the type is rather broken, which 
isn't a reasonable case to support.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83211

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


[PATCH] D91029: [clangd] Implement clang-tidy options from config

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

OK this looks really great, thanks so much for persisting with this.

Comments are mostly simple nits/simplifications, with the exception of `Order` 
which is a... slightly trickier simplification, but seems worth doing.

Tomorrow I'll adapt our internal clang-tidy config bits to work with this 
interface...




Comment at: clang-tools-extra/clangd/ParsedAST.cpp:241
+/// Empty clang tidy provider, using this as a provider will disable 
clang-tidy.
+static void emptyTidyProvider(tidy::ClangTidyOptions &, llvm::StringRef,
+  unsigned &, PathRef) {}

or just use fixedTidyProvider("-*")



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:74
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");

I'm not sure if this applies anymore - it's going to be the bottom of the 
stack, and nullopt is the default



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:75
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");
+#ifdef _WIN32

nit: hoist the getenv out of the lambda?



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:75
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+EmptyDefaults.User = llvm::sys::Process::GetEnv("USER");
+#ifdef _WIN32

sammccall wrote:
> nit: hoist the getenv out of the lambda?
seems like we can just assign to Opts.User directly?



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:99
+  "misc-definitions-in-headers");
+  Opts.Checks.emplace(DefaultChecks);
+}

nit: = seems clearer than emplace



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:110
+  tidy::ClangTidyOptions , llvm::StringRef, unsigned &, PathRef) {
+mergeCheckList(Opts.Checks, Checks);
+mergeCheckList(Opts.WarningsAsErrors, WarningsAsErrors);

I think should just be assignment rather than merge (same with 
WarningsAsErrors).
The name suggests that it always returns the same set of checks.

(Failing that, maybe call it `addTidyChecks`)



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:167
+
+if (FS->makeAbsolute(AbsolutePath))
+  return;

(as noted elsewhere, the path is always absolute in clangd and we should make 
this an interface requiremnet)



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:170
+
+llvm::sys::path::remove_dots(AbsolutePath, true);
+llvm::StringRef Directory = llvm::sys::path::parent_path(AbsolutePath);

I don't think we need to try to stat the directory here.

FileOptionsProvider does, but looking at the history, this seems related to 
some combination of:
 - arg validation (the parameter there is a directory name, rather than a 
filename)
 - trying to return an appropriate error_code (original return type was 
ErrorOr)
 - iterating over multiple possible config files
 - maybe caching



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:181
+}
+
+for (llvm::StringRef CurrentDirectory = Directory;

can you add a FIXME to add caching here?

I hadn't realized FileOptionsProvider *was* actually doing caching.

(I don't think this is a big problem in the short term, and I don't think we 
should solve it inline in this patch, rather I should land D88172 and use that, 
which doesn't have the annoying "cache forever" behavior)



Comment at: clang-tools-extra/clangd/TidyProvider.cpp:194
+for (auto  : llvm::reverse(OptionStack))
+  Opts.mergeWith(Option, ++Order);
+  };

This order business is a real tangle, and looks like legacy to me (qualified vs 
unqualified names).

I don't really think we want to use/expose it beyond the requirement that we 
don't change the meaning of existing sets of `.clang-tidy` config files.
And I don't think we want to bother teaching clangd's config system about it.

So I'd suggest a hack/simplification:
 - we remove the `order` parameter from TidyProvider
 - here in provideClangTidyFiles, we just use a local Order which counts up 
from 1. This preserves the relative precedence of .clang-tidy files
 - in provideClangdConfig, we always set the order to max_uint (always wins)
 - if we ever add checkoptions to any other providers, we set the order to 0 
(always loses)
 - combine() doesn't touch order

This *does* duplicate the fact that .clangd config is stacked on top of 
.clang-tidy in ClangdMain, but in a way that only matters with disputes between 
qualified/unqualified names.



Comment at: 

[clang] 9a8386d - clang: Pass -platform-version to new MachO LLD

2020-11-24 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-11-24T11:16:03-05:00
New Revision: 9a8386dba889b038c23bfc89dd0ff3cf55bbf86a

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

LOG: clang: Pass -platform-version to new MachO LLD

New MachO LLD doesn't implement the old -macos_version_min (etc)
flags, but it understands the modern platform_version flag.
So make the clang driver pass that when using new MachO LLD.

Also, while here, don't pass -lto_library to LLD, since it
links in LTO libraries statically (which it can because it's
versioned alongside clang).

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/test/Driver/darwin-ld-platform-version-ios.c
clang/test/Driver/darwin-ld-platform-version-macos.c
clang/test/Driver/darwin-ld-platform-version-tvos.c
clang/test/Driver/darwin-ld-platform-version-watchos.c

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 58df4d04aea6..7aa8ba7b1da9 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -331,7 +331,10 @@ class ToolChain {
   /// is LLD. If it's set, it can be assumed that the linker is LLD built
   /// at the same revision as clang, and clang can make assumptions about
   /// LLD's supported flags, error output, etc.
-  std::string GetLinkerPath(bool *LinkerIsLLD = nullptr) const;
+  /// If LinkerIsLLDDarwinNew is non-nullptr, it's set if the linker is
+  /// the new version in lld/MachO.
+  std::string GetLinkerPath(bool *LinkerIsLLD = nullptr,
+bool *LinkerIsLLDDarwinNew = nullptr) const;
 
   /// Returns the linker path for emitting a static library.
   std::string GetStaticLibToolPath() const;

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index ae1838aeb9db..0330afdcec48 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -548,9 +548,12 @@ std::string ToolChain::GetProgramPath(const char *Name) 
const {
   return D.GetProgramPath(Name, *this);
 }
 
-std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
+std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD,
+ bool *LinkerIsLLDDarwinNew) const {
   if (LinkerIsLLD)
 *LinkerIsLLD = false;
+  if (LinkerIsLLDDarwinNew)
+*LinkerIsLLDDarwinNew = false;
 
   // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= 
is
   // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
@@ -603,9 +606,11 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) 
const {
 
 std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
 if (llvm::sys::fs::can_execute(LinkerPath)) {
+  // FIXME: Remove lld.darwinnew here once it's the only MachO lld.
   if (LinkerIsLLD)
-// FIXME: Remove lld.darwinnew here once it's the only MachO lld.
 *LinkerIsLLD = UseLinker == "lld" || UseLinker == "lld.darwinnew";
+  if (LinkerIsLLDDarwinNew)
+*LinkerIsLLDDarwinNew = UseLinker == "lld.darwinnew";
   return LinkerPath;
 }
   }

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index ddfab0e6ab7c..db3d57a48098 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -204,7 +204,8 @@ static bool shouldLinkerNotDedup(bool IsLinkerOnlyAction, 
const ArgList ) {
 void darwin::Linker::AddLinkArgs(Compilation , const ArgList ,
  ArgStringList ,
  const InputInfoList ,
- unsigned Version[5], bool LinkerIsLLD) const {
+ unsigned Version[5], bool LinkerIsLLD,
+ bool LinkerIsLLDDarwinNew) const {
   const Driver  = getToolChain().getDriver();
   const toolchains::MachO  = getMachOToolChain();
 
@@ -252,7 +253,9 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
   // Since this is passed unconditionally, ld64 will never look for 
libLTO.dylib
   // next to it. That's ok since ld64 using a libLTO.dylib not matching the
   // clang version won't work anyways.
-  if (Version[0] >= 133) {
+  // lld is built at the same revision as clang and statically links in
+  // LLVM libraries, so it doesn't need libLTO.dylib.
+  if (Version[0] >= 133 && !LinkerIsLLD) {
 // Search for libLTO in /../lib/libLTO.dylib
 StringRef P = llvm::sys::path::parent_path(D.Dir);
 SmallString<128> LibLTOPath(P);
@@ -335,7 +338,7 @@ void 

[PATCH] D92037: clang: Pass -platform-version to new MachO LLD

2020-11-24 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a8386dba889: clang: Pass -platform-version to new MachO LLD 
(authored by thakis).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D92037?vs=307365=307369#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92037

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c

Index: clang/test/Driver/darwin-ld-platform-version-watchos.c
===
--- clang/test/Driver/darwin-ld-platform-version-watchos.c
+++ clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -1,12 +1,24 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN: %clang -target arm64_32-apple-watchos5.2 \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN: %clang -target arm64_32-apple-watchos5.2 \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinnew \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
+// RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
-// RUN: %clang -target x86_64-apple-watchos6-simulator -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: %clang -target arm64_32-apple-watchos5.2 \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
+// RUN: %clang -target x86_64-apple-watchos6-simulator \
+// RUN:   -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
 // LINKER-OLD: "-watchos_version_min" "5.2.0"
Index: clang/test/Driver/darwin-ld-platform-version-tvos.c
===
--- clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,12 +1,24 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN: %clang -target arm64-apple-tvos12.3 \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN: %clang -target arm64-apple-tvos12.3 \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-OLD %s
-// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinnew \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
+// RUN:   -### %t.o -B%S/Inputs/lld 2>&1 \
 // RUN:   | FileCheck --check-prefix=LINKER-NEW %s
-// RUN: %clang -target x86_64-apple-tvos13-simulator -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: %clang -target arm64-apple-tvos12.3 \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
+// RUN: %clang -target x86_64-apple-tvos13-simulator \
+// RUN:   -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
+// RUN:   -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
 // LINKER-OLD: "-tvos_version_min" "12.3.0"
Index: clang/test/Driver/darwin-ld-platform-version-macos.c
===
--- clang/test/Driver/darwin-ld-platform-version-macos.c
+++ clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,20 +1,42 @@
 // RUN: touch %t.o
 
-// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN: %clang -target x86_64-apple-macos10.13 \
+// RUN:   -isysroot 

[PATCH] D91980: [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-11-24 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:10333
+  /// Check if there is an active global `omp begin assumes` directive.
+  bool isInOpenMPAssumeScope() { return !OMPAssumeScoped.empty(); }
+

ABataev wrote:
> jdoerfert wrote:
> > ABataev wrote:
> > > ABataev wrote:
> > > > `const` member functions.
> > > It may have side-effects with template instantiations. What if we have 
> > > something like this:
> > > ```
> > > #pragma omp begin assumes ...
> > > template 
> > > struct S {
> > > ...
> > > }
> > > #pragma omp end assumes
> > > 
> > > void bar() {
> > > #pragma omp assumes ...
> > >   {
> > > S s;
> > > s.foo();
> > >   }
> > > }
> > > ```
> > > ?
> > > 
> > > `struct S` will be instantiated in the second assume region context 
> > > though I doubt this is the user intention.
> > I'm not sure what problem you expect here. Could you elaborate what you 
> > think should happen or should not?
> May it lead to the wrong compiler assumptions and result in the incorrect 
> codegen?
I'm still not following your example. What wrong assumptions and/or incorrect 
code generation do you expect? Could you provide an example with actual 
assumptions and then describe what the problem is please.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

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


[clang] 44174b3 - [NFC][tests] Replace non-portable grep with FileCheck

2020-11-24 Thread Hubert Tong via cfe-commits

Author: Hubert Tong
Date: 2020-11-24T12:15:07-05:00
New Revision: 44174b3d518ed70482ff5df2879523a4e26f92cc

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

LOG: [NFC][tests] Replace non-portable grep with FileCheck

After commit 2482648a795afbe12774168bbbf70dc14c031267, a GNU grep option
is just passed unconditionally to `grep` in general. This patch fixes
the test for platforms where `grep` is not GNU grep.

Added: 


Modified: 
clang/test/CodeGen/thinlto_embed_bitcode.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto_embed_bitcode.ll 
b/clang/test/CodeGen/thinlto_embed_bitcode.ll
index 971d4005435d..590cadbfd418 100644
--- a/clang/test/CodeGen/thinlto_embed_bitcode.ll
+++ b/clang/test/CodeGen/thinlto_embed_bitcode.ll
@@ -18,7 +18,7 @@
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t.o -x ir %t1.bc -c 
-fthinlto-index=%t.o.thinlto.bc -mllvm -lto-embed-bitcode=post-merge-pre-opt
 ; RUN: llvm-readelf -S %t.o | FileCheck %s 
--check-prefixes=CHECK-ELF,CHECK-ELF-CMD
 ; RUN: llvm-objcopy --dump-section=.llvmcmd=%t-embedded.cmd %t.o /dev/null
-; RUN: grep --text x86_64-unknown-linux-gnu %t-embedded.cmd | count 1
+; RUN: FileCheck %s --check-prefixes=CHECK-EMBEDDED-CMD <%t-embedded.cmd
 ; RUN: llvm-objcopy --dump-section=.llvmbc=%t-embedded.bc %t.o /dev/null
 ; RUN: llvm-dis %t-embedded.bc -o - | FileCheck %s 
--check-prefixes=CHECK,CHECK-NOOPT
 ; We should only need the index and the post-thinlto merged module to generate 
@@ -43,3 +43,6 @@
 ; CHECK-NOOPT-NEXT: call void @bar()
 ; CHECK-NOOPT: define available_externally void @bar()
 ; CHECK-NOOPT-NEXT: ret void
+
+; CHECK-EMBEDDED-CMD: x86_64-unknown-linux-gnu{{.*$}}
+; CHECK-EMBEDDED-CMD-NOT: x86_64-unknown-linux-gnu



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


[PATCH] D88172: [clangd] Extract common file-caching logic from ConfigProvider.

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

@kbobyrev ping... I think we do actually want to land this, for use with 
`.clang-tidy` files after D91029 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88172

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


[clang] 6e4c1cf - [ThinLTO/WPD] Enable -wholeprogramdevirt-skip in ThinLTO backends

2020-11-24 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-11-24T09:35:07-08:00
New Revision: 6e4c1cf2938842ceefc2712f0007843369dd16ca

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

LOG: [ThinLTO/WPD] Enable -wholeprogramdevirt-skip in ThinLTO backends

Previously this option could be used to skip devirtualizations of the
given functions in regular LTO and in the ThinLTO indexing step. This
change allows them to be skipped in the backend as well, which is useful
when debugging WPD in a distributed ThinLTO backend.

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

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll 
b/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
index 5c753ba6f93c..0a330a53e948 100644
--- a/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
+++ b/clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
@@ -40,8 +40,16 @@
 ; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: 
allOnes, sizeM1BitWidth: 7), wpdResolutions: ((offset: 0, wpdRes: (kind: 
branchFunnel)), (offset: 8, wpdRes: (kind: singleImpl, singleImplName: 
"_ZN1A1nEi") ; guid = 7004155349499253778
 
 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
-; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 \
-; RUN:   -emit-llvm -o - -x ir %t.o | FileCheck %s --check-prefixes=CHECK-IR
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 
-Rpass=wholeprogramdevirt \
+; RUN:   -emit-llvm -o - -x ir %t.o 2>&1 | FileCheck %s 
--check-prefixes=CHECK-IR --check-prefixes=REMARKS
+
+; Check that the devirtualization is suppressed via -wholeprogramdevirt-skip
+; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu -mllvm 
-wholeprogramdevirt-skip=_ZN1A1nEi \
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 
-Rpass=wholeprogramdevirt \
+; RUN:   -emit-llvm -o - -x ir %t.o 2>&1 | FileCheck %s 
--check-prefixes=SKIP-IR --check-prefixes=SKIP-REMARKS
+
+; REMARKS: single-impl: devirtualized a call to _ZN1A1nEi
+; SKIP-REMARKS-NOT: single-impl
 
 ; Check that backend does not fail generating native code.
 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
@@ -78,6 +86,7 @@ cont:
 
   ; Check that the call was devirtualized.
   ; CHECK-IR: %call = tail call i32 @_ZN1A1nEi
+  ; SKIP-IR-NOT: %call = tail call i32 @_ZN1A1nEi
   %call = tail call i32 %4(%struct.A* nonnull %obj, i32 %a)
   %vtable16 = load i8*, i8** %0
   %5 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable16, i32 0, 
metadata !"_ZTS1A")

diff  --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp 
b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index e97f1acbb396..5350d85e11f3 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1030,6 +1030,10 @@ bool DevirtIndex::tryFindVirtualCallTargets(
 
 void DevirtModule::applySingleImplDevirt(VTableSlotInfo ,
  Constant *TheFn, bool ) {
+  // Don't devirtualize function if we're told to skip it
+  // in -wholeprogramdevirt-skip.
+  if (FunctionsToSkip.match(TheFn->stripPointerCasts()->getName()))
+return;
   auto Apply = [&](CallSiteInfo ) {
 for (auto & : CSInfo.CallSites) {
   if (RemarksEnabled)



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


[PATCH] D91812: [ThinLTO/WPD] Enable -wholeprogramdevirt-skip in ThinLTO backends

2020-11-24 Thread Teresa Johnson 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 rG6e4c1cf29388: [ThinLTO/WPD] Enable -wholeprogramdevirt-skip 
in ThinLTO backends (authored by tejohnson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91812

Files:
  clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp


Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1030,6 +1030,10 @@
 
 void DevirtModule::applySingleImplDevirt(VTableSlotInfo ,
  Constant *TheFn, bool ) {
+  // Don't devirtualize function if we're told to skip it
+  // in -wholeprogramdevirt-skip.
+  if (FunctionsToSkip.match(TheFn->stripPointerCasts()->getName()))
+return;
   auto Apply = [&](CallSiteInfo ) {
 for (auto & : CSInfo.CallSites) {
   if (RemarksEnabled)
Index: clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
===
--- clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
+++ clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
@@ -40,8 +40,16 @@
 ; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: 
allOnes, sizeM1BitWidth: 7), wpdResolutions: ((offset: 0, wpdRes: (kind: 
branchFunnel)), (offset: 8, wpdRes: (kind: singleImpl, singleImplName: 
"_ZN1A1nEi") ; guid = 7004155349499253778
 
 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
-; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 \
-; RUN:   -emit-llvm -o - -x ir %t.o | FileCheck %s --check-prefixes=CHECK-IR
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 
-Rpass=wholeprogramdevirt \
+; RUN:   -emit-llvm -o - -x ir %t.o 2>&1 | FileCheck %s 
--check-prefixes=CHECK-IR --check-prefixes=REMARKS
+
+; Check that the devirtualization is suppressed via -wholeprogramdevirt-skip
+; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu -mllvm 
-wholeprogramdevirt-skip=_ZN1A1nEi \
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 
-Rpass=wholeprogramdevirt \
+; RUN:   -emit-llvm -o - -x ir %t.o 2>&1 | FileCheck %s 
--check-prefixes=SKIP-IR --check-prefixes=SKIP-REMARKS
+
+; REMARKS: single-impl: devirtualized a call to _ZN1A1nEi
+; SKIP-REMARKS-NOT: single-impl
 
 ; Check that backend does not fail generating native code.
 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
@@ -78,6 +86,7 @@
 
   ; Check that the call was devirtualized.
   ; CHECK-IR: %call = tail call i32 @_ZN1A1nEi
+  ; SKIP-IR-NOT: %call = tail call i32 @_ZN1A1nEi
   %call = tail call i32 %4(%struct.A* nonnull %obj, i32 %a)
   %vtable16 = load i8*, i8** %0
   %5 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable16, i32 0, 
metadata !"_ZTS1A")


Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1030,6 +1030,10 @@
 
 void DevirtModule::applySingleImplDevirt(VTableSlotInfo ,
  Constant *TheFn, bool ) {
+  // Don't devirtualize function if we're told to skip it
+  // in -wholeprogramdevirt-skip.
+  if (FunctionsToSkip.match(TheFn->stripPointerCasts()->getName()))
+return;
   auto Apply = [&](CallSiteInfo ) {
 for (auto & : CSInfo.CallSites) {
   if (RemarksEnabled)
Index: clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
===
--- clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
+++ clang/test/CodeGen/thinlto-distributed-cfi-devirt.ll
@@ -40,8 +40,16 @@
 ; CHECK-DIS: ^2 = typeid: (name: "_ZTS1A", summary: (typeTestRes: (kind: allOnes, sizeM1BitWidth: 7), wpdResolutions: ((offset: 0, wpdRes: (kind: branchFunnel)), (offset: 8, wpdRes: (kind: singleImpl, singleImplName: "_ZN1A1nEi") ; guid = 7004155349499253778
 
 ; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
-; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 \
-; RUN:   -emit-llvm -o - -x ir %t.o | FileCheck %s --check-prefixes=CHECK-IR
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 -Rpass=wholeprogramdevirt \
+; RUN:   -emit-llvm -o - -x ir %t.o 2>&1 | FileCheck %s --check-prefixes=CHECK-IR --check-prefixes=REMARKS
+
+; Check that the devirtualization is suppressed via -wholeprogramdevirt-skip
+; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu -mllvm -wholeprogramdevirt-skip=_ZN1A1nEi \
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc -O2 -Rpass=wholeprogramdevirt \
+; RUN:   -emit-llvm -o - -x ir %t.o 2>&1 | FileCheck %s --check-prefixes=SKIP-IR --check-prefixes=SKIP-REMARKS
+
+; REMARKS: single-impl: devirtualized a call to 

[PATCH] D91676: Avoid redundant work when computing vtable vcall visibility

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



Comment at: clang/lib/CodeGen/CGVTables.cpp:1301-1302
+  // has no effect on the min visibility computed below by the recursive 
caller.
+  if (!Visited.insert(RD).second)
+return llvm::GlobalObject::VCallVisibilityTranslationUnit;
+

If a CXXRecordDecl is visited twice, the visibility returned in the second 
visit could be larger than necessary. Will it change the final result? If it 
will, can we cache the visibility result got in the first visit instead of 
returning the max value? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

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


[clang-tools-extra] f6e5929 - [clangd] AddUsing: Used spelled text instead of type name.

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

Author: Adam Czachorowski
Date: 2020-11-24T18:59:09+01:00
New Revision: f6e59294b63e1fd0b25720f24111cd17865004be

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

LOG: [clangd] AddUsing: Used spelled text instead of type name.

This improves the behavior related to type aliases, as well as cases of
typo correction.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
index cf8347f312a3..b53df446c732 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -43,9 +43,10 @@ class AddUsing : public Tweak {
   }
 
 private:
-  // The qualifier to remove. Set by prepare().
+  // All of the following are set by prepare().
+  // The qualifier to remove.
   NestedNameSpecifierLoc QualifierToRemove;
-  // The name following QualifierToRemove. Set by prepare().
+  // The name following QualifierToRemove.
   llvm::StringRef Name;
 };
 REGISTER_TWEAK(AddUsing)
@@ -206,8 +207,17 @@ bool isNamespaceForbidden(const Tweak::Selection ,
   return false;
 }
 
+std::string getNNSLAsString(NestedNameSpecifierLoc ,
+const PrintingPolicy ) {
+  std::string Out;
+  llvm::raw_string_ostream OutStream(Out);
+  NNSL.getNestedNameSpecifier()->print(OutStream, Policy);
+  return OutStream.str();
+}
+
 bool AddUsing::prepare(const Selection ) {
   auto  = Inputs.AST->getSourceManager();
+  const auto  = Inputs.AST->getTokens();
 
   // Do not suggest "using" in header files. That way madness lies.
   if (isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
@@ -247,11 +257,20 @@ bool AddUsing::prepare(const Selection ) {
 }
   } else if (auto *T = Node->ASTNode.get()) {
 if (auto E = T->getAs()) {
-  if (auto *BaseTypeIdentifier =
-  E.getType().getUnqualifiedType().getBaseTypeIdentifier()) {
-Name = BaseTypeIdentifier->getName();
-QualifierToRemove = E.getQualifierLoc();
-  }
+  QualifierToRemove = E.getQualifierLoc();
+
+  auto SpelledTokens =
+  TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));
+  if (!SpelledTokens)
+return false;
+  auto SpelledRange = syntax::Token::range(SM, SpelledTokens->front(),
+   SpelledTokens->back());
+  Name = SpelledRange.text(SM);
+
+  std::string QualifierToRemoveStr = getNNSLAsString(
+  QualifierToRemove, Inputs.AST->getASTContext().getPrintingPolicy());
+  if (!Name.consume_front(QualifierToRemoveStr))
+return false; // What's spelled doesn't match the qualifier.
 }
   }
 
@@ -283,20 +302,13 @@ bool AddUsing::prepare(const Selection ) {
 
 Expected AddUsing::apply(const Selection ) {
   auto  = Inputs.AST->getSourceManager();
-  auto  = Inputs.AST->getTokens();
 
-  // Determine the length of the qualifier under the cursor, then remove it.
-  auto SpelledTokens = TB.spelledForExpanded(
-  TB.expandedTokens(QualifierToRemove.getSourceRange()));
-  if (!SpelledTokens) {
-return error("Could not determine length of the qualifier");
-  }
-  unsigned Length =
-  syntax::Token::range(SM, SpelledTokens->front(), SpelledTokens->back())
-  .length();
+  std::string QualifierToRemoveStr = getNNSLAsString(
+  QualifierToRemove, Inputs.AST->getASTContext().getPrintingPolicy());
   tooling::Replacements R;
   if (auto Err = R.add(tooling::Replacement(
-  SM, SpelledTokens->front().location(), Length, ""))) {
+  SM, SM.getSpellingLoc(QualifierToRemove.getBeginLoc()),
+  QualifierToRemoveStr.length(), ""))) {
 return std::move(Err);
   }
 
@@ -313,9 +325,8 @@ Expected AddUsing::apply(const Selection 
) {
 if (InsertionPoint->AlwaysFullyQualify &&
 !isFullyQualified(QualifierToRemove.getNestedNameSpecifier()))
   UsingTextStream << "::";
-QualifierToRemove.getNestedNameSpecifier()->print(
-UsingTextStream, Inputs.AST->getASTContext().getPrintingPolicy());
-UsingTextStream << Name << ";" << InsertionPoint->Suffix;
+UsingTextStream << QualifierToRemoveStr << Name << ";"
+<< InsertionPoint->Suffix;
 
 assert(SM.getFileID(InsertionPoint->Loc) == SM.getMainFileID());
 if (auto Err = R.add(tooling::Replacement(SM, InsertionPoint->Loc, 0,

diff  --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp 
b/clang-tools-extra/clangd/unittests/TweakTests.cpp
index 98d797aacd8f..edfaee779e38 100644
--- 

[PATCH] D91966: [clangd] AddUsing: Used spelled text instead of type name.

2020-11-24 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6e59294b63e: [clangd] AddUsing: Used spelled text instead 
of type name. (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91966

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2520,6 +2520,9 @@
   EXPECT_UNAVAILABLE(Header + "void fun() { ::ban::fo^o(); }");
   EXPECT_AVAILABLE(Header + "void fun() { banana::fo^o(); }");
 
+  // Do not offer code action on typo-corrections.
+  EXPECT_UNAVAILABLE(Header + "/*error-ok*/c^c C;");
+
   // Check that we do not trigger in header files.
   FileName = "test.h";
   ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.
@@ -2793,6 +2796,35 @@
 
 void fun() {
   ff();
+})cpp"},
+// using alias; insert using for the spelled name.
+{R"cpp(
+#include "test.hpp"
+
+void fun() {
+  one::u^u u;
+})cpp",
+ R"cpp(
+#include "test.hpp"
+
+using one::uu;
+
+void fun() {
+  uu u;
+})cpp"},
+// using namespace.
+{R"cpp(
+#include "test.hpp"
+using namespace one;
+namespace {
+two::c^c C;
+})cpp",
+ R"cpp(
+#include "test.hpp"
+using namespace one;
+namespace {using two::cc;
+
+cc C;
 })cpp"}};
   llvm::StringMap EditedFiles;
   for (const auto  : Cases) {
@@ -2809,6 +2841,7 @@
   static void mm() {}
 };
 }
+using uu = two::cc;
 })cpp";
   EXPECT_EQ(apply(SubCase, ), Case.ExpectedSource);
 }
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -43,9 +43,10 @@
   }
 
 private:
-  // The qualifier to remove. Set by prepare().
+  // All of the following are set by prepare().
+  // The qualifier to remove.
   NestedNameSpecifierLoc QualifierToRemove;
-  // The name following QualifierToRemove. Set by prepare().
+  // The name following QualifierToRemove.
   llvm::StringRef Name;
 };
 REGISTER_TWEAK(AddUsing)
@@ -206,8 +207,17 @@
   return false;
 }
 
+std::string getNNSLAsString(NestedNameSpecifierLoc ,
+const PrintingPolicy ) {
+  std::string Out;
+  llvm::raw_string_ostream OutStream(Out);
+  NNSL.getNestedNameSpecifier()->print(OutStream, Policy);
+  return OutStream.str();
+}
+
 bool AddUsing::prepare(const Selection ) {
   auto  = Inputs.AST->getSourceManager();
+  const auto  = Inputs.AST->getTokens();
 
   // Do not suggest "using" in header files. That way madness lies.
   if (isHeaderFile(SM.getFileEntryForID(SM.getMainFileID())->getName(),
@@ -247,11 +257,20 @@
 }
   } else if (auto *T = Node->ASTNode.get()) {
 if (auto E = T->getAs()) {
-  if (auto *BaseTypeIdentifier =
-  E.getType().getUnqualifiedType().getBaseTypeIdentifier()) {
-Name = BaseTypeIdentifier->getName();
-QualifierToRemove = E.getQualifierLoc();
-  }
+  QualifierToRemove = E.getQualifierLoc();
+
+  auto SpelledTokens =
+  TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));
+  if (!SpelledTokens)
+return false;
+  auto SpelledRange = syntax::Token::range(SM, SpelledTokens->front(),
+   SpelledTokens->back());
+  Name = SpelledRange.text(SM);
+
+  std::string QualifierToRemoveStr = getNNSLAsString(
+  QualifierToRemove, Inputs.AST->getASTContext().getPrintingPolicy());
+  if (!Name.consume_front(QualifierToRemoveStr))
+return false; // What's spelled doesn't match the qualifier.
 }
   }
 
@@ -283,20 +302,13 @@
 
 Expected AddUsing::apply(const Selection ) {
   auto  = Inputs.AST->getSourceManager();
-  auto  = Inputs.AST->getTokens();
 
-  // Determine the length of the qualifier under the cursor, then remove it.
-  auto SpelledTokens = TB.spelledForExpanded(
-  TB.expandedTokens(QualifierToRemove.getSourceRange()));
-  if (!SpelledTokens) {
-return error("Could not determine length of the qualifier");
-  }
-  unsigned Length =
-  syntax::Token::range(SM, SpelledTokens->front(), SpelledTokens->back())
-  .length();
+  std::string QualifierToRemoveStr = getNNSLAsString(
+  QualifierToRemove, Inputs.AST->getASTContext().getPrintingPolicy());
   tooling::Replacements R;
   if (auto Err = R.add(tooling::Replacement(
-  SM, SpelledTokens->front().location(), Length, ""))) {
+  SM, SM.getSpellingLoc(QualifierToRemove.getBeginLoc()),
+  QualifierToRemoveStr.length(), ""))) {
 return 

[PATCH] D43159: [libc++] Replace several uses of 0 by nullptr

2020-11-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 307402.
ldionne added a comment.
Herald added a project: libc++abi.
Herald added a reviewer: libc++abi.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43159

Files:
  libcxx/include/__locale
  libcxx/include/__sso_allocator
  libcxx/include/__string
  libcxx/include/__threading_support
  libcxx/include/algorithm
  libcxx/include/bitset
  libcxx/include/chrono
  libcxx/include/fstream
  libcxx/include/functional
  libcxx/include/ios
  libcxx/include/istream
  libcxx/include/iterator
  libcxx/include/locale
  libcxx/include/memory
  libcxx/include/regex
  libcxx/include/sstream
  libcxx/include/streambuf
  libcxx/include/string
  libcxx/include/strstream
  libcxx/include/system_error
  libcxx/include/valarray
  libcxx/src/new.cpp
  libcxxabi/src/stdlib_new_delete.cpp

Index: libcxxabi/src/stdlib_new_delete.cpp
===
--- libcxxabi/src/stdlib_new_delete.cpp
+++ libcxxabi/src/stdlib_new_delete.cpp
@@ -27,7 +27,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -48,7 +48,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
 try
 {
@@ -74,7 +74,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
 try
 {
@@ -170,7 +170,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
 try
 {
@@ -196,7 +196,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
 try
 {
Index: libcxx/src/new.cpp
===
--- libcxx/src/new.cpp
+++ libcxx/src/new.cpp
@@ -64,7 +64,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -85,7 +85,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -111,7 +111,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -207,7 +207,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -233,7 +233,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
Index: libcxx/include/valarray
===
--- libcxx/include/valarray
+++ libcxx/include/valarray
@@ -802,7 +802,7 @@
 public:
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
-valarray() : __begin_(0), __end_(0) {}
+valarray() : __begin_(nullptr), __end_(nullptr) {}
 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
 explicit valarray(size_t __n);
 _LIBCPP_INLINE_VISIBILITY
@@ -2750,8 +2750,8 @@
 template 
 inline
 valarray<_Tp>::valarray(size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2776,16 +2776,16 @@
 template 
 inline
 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 resize(__n, __x);
 }
 
 template 
 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2809,8 +2809,8 @@
 
 template 
 valarray<_Tp>::valarray(const valarray& __v)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__v.size())
 {
@@ -2845,8 +2845,8 @@
 
 template 
 valarray<_Tp>::valarray(initializer_list __il)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __il.size();
 if (__n)
@@ -2874,8 +2874,8 @@
 
 template 
 valarray<_Tp>::valarray(const slice_array& __sa)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = 

[PATCH] D91944: OpenMP 5.0 metadirective

2020-11-24 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

This looks close to an OpenMP 5.0 implementation. I left comments inlined.

We need tests that show how non-selected alternatives *do not* impact the 
program. As an example, a template instantiation inside of a non-selected 
alternative is not actually performed.

We also need test with ill-formed metadirectives.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10493
+  "misplaced default clause! Only one default clause is allowed in "
+  "metadirective in the end">;
 } // end of OpenMP category

no `!`. The default clause doesn't need to be in the end either.



Comment at: clang/include/clang/Serialization/ASTBitCodes.h:1952
-  STMT_MS_DEPENDENT_EXISTS,   // MSDependentExistsStmt
-  EXPR_LAMBDA,// LambdaExpr
   STMT_COROUTINE_BODY,

Unrelated.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:10211
+return;
+  }
+

Can you explain this, this seems odd to me.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2186
+// parse and get condition expression to pass to the When clause
+parseOMPContextSelectors(Loc, TI);
+

Usually you would check the return value in case we later actually propagate 
errors while parsing the context selector.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2193
+  Diag(Tok, diag::warn_pragma_expected_colon) << "when clause";
+  return Directive;
+}

If we give up it should be an error, I think. If we issue a warning we just 
pretend the colon was there afterwards.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2204
+ConsumeAnyToken();
+  }
+  // Parse ')'

We have balanced trackers for this that also deal with the fact that there 
might be a `)` missing. This code will probably crash.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2216
+TPA.Revert();
+TargetOMPContext OMPCtx(ASTContext, nullptr, nullptr);
+int BestIdx = getBestWhenMatchForContext(VMIs, OMPCtx);

Add a TODO that `nullptr` should be replaced as per the use in 
`Sema::ActOnOpenMPCall`.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2237
+continue;
+  }
+

Use a BalancedDelimiterTracker.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2254
+// Parse ':'
+ConsumeAnyToken();
+  }

If you warn and continue above you need to check for `:` here again.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2260
+DirKind = parseOpenMPDirectiveKind(*this);
+ConsumeToken();
+if (DirKind != OMPD_unknown) {

What is this token? We have skipped this part before so we need to validate it 
is what we expect it to be.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2264
+  Actions.StartOpenMPDSABlock(DirKind, DirName, Actions.getCurScope(),
+  Loc);
+  int paren = 0;

Should we not go back to the original code handling "directives" instead? This 
looks like it is copied here.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2317
+  ConsumeAnnotationToken();
+}
+  } else {

Same as below, change the order. Also, the "skipping" part is always the same, 
put it in a helper function or lambda.



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2324
+ConsumeAnnotationToken();
+  }
+  break;

Move the smaller case first and use an early exit. That will reduce the 
indention of the larger case by 1.



Comment at: clang/test/OpenMP/metadirective_construct.cpp:12
+when(construct = {"target"} \
+ : distribute parallel for) default()
+  for (int i = 0; i < N; i++)

Since when does the `construct` trait work? I'm confused.



Comment at: clang/test/OpenMP/metadirective_empty.cpp:1
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda 
-emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics

no -fopenmp-targets please.



Comment at: clang/test/OpenMP/metadirective_implementation.cpp:1
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda 
-emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics

Can we run this for all configurations of the metadirective so we can actually 
see it will pick the right one, not the first?



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPContext.h:197
+// int getBestWhenMatchForContext(const SmallVectorImpl 
,
+//   const OMPContext );
 /// Return the index (into \p VMIs) of the variant with the highest score


[PATCH] D91676: Avoid redundant work when computing vtable vcall visibility

2020-11-24 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/lib/CodeGen/CGVTables.cpp:1301-1302
+  // has no effect on the min visibility computed below by the recursive 
caller.
+  if (!Visited.insert(RD).second)
+return llvm::GlobalObject::VCallVisibilityTranslationUnit;
+

wmi wrote:
> tejohnson wrote:
> > wmi wrote:
> > > If a CXXRecordDecl is visited twice, the visibility returned in the 
> > > second visit could be larger than necessary. Will it change the final 
> > > result? If it will, can we cache the visibility result got in the first 
> > > visit instead of returning the max value? 
> > The recursive callsites compute the std::min of the current TypeVis and the 
> > one returned by the recursive call. So returning the max guarantees that 
> > there is no effect on the current TypeVis. Let me know if the comment can 
> > be clarified (that's what I meant by "so that it has no effect on the min 
> > visibility computed below ...". Note that the initial non-recursive 
> > invocation always has an empty Visited set.
> I see. That makes sense! I didn't understand the location meant by "computed 
> below by the recursive caller." Your explanation "initial non-recursive 
> invocation always has an empty Visited set" helps a lot. It means the 
> immediate result of GetVCallVisibilityLevel may change, but the result for 
> the initial invocation of the recursive call won't be changed. 
I've tried to clarify the comment accordingly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

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


[PATCH] D92012: [clangd][query-driver] Extract target

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

Thanks, this seems really useful!




Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:59
 
-std::vector parseDriverOutput(llvm::StringRef Output) {
+std::pair, std::string>
+parseDriverOutput(llvm::StringRef Output) {

define a little struct holding these two, for clarity?



Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:78
+  } else {
+// Start from the beginning if target was not found.
+StartIt = Lines.begin();

This part seems pretty confusing :-)
You could just search for Target: independently of the current scanning - I'm 
not terribly worried about it appearing in the middle of the include list!

If we want to be strict though, it might be time to rewrite to be more stateful 
e.g. a loop consuming chunks from an ArrayRef, or a state machine, 
or something.




Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:87
+return {SystemIncludes, Target};
   }
   ++StartIt;

this changes the error behavior: intentional?



Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:212
+  if (!Target.empty()) {
+Cmd.CommandLine.push_back("-target");
+Cmd.CommandLine.push_back(Target);

`clang -target foo test.cc` seems to be a hard error in the driver if the 
target is unknown.
(vs likely *some* functionality if we just didn't set the driver)

so this could regress some scenarios. Can we mitigate that?
(It's possible that we're running the driver in a mode where we proceed anyway, 
but I can't remember :-()



Comment at: clang-tools-extra/clangd/QueryDriverDatabase.cpp:307
+addSystemIncludes(*Cmd, SystemIncludesAndTarget.first);
+return setTarget(*Cmd, SystemIncludesAndTarget.second);
   }

nit: while here, add std::move?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92012

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


[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-11-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D92039#2414314 , @Quuxplusone wrote:

> Probably irrelevant comment from the C++ world: If I needed this concept in 
> C++, I'd probably piggyback on the existing semantic analysis of `std::move`: 
> I'd design a `class OnceCallable` with an `operator() &&` that both called 
> and nulled-out its object parameter, and then call it like 
> `std::move(myCallback)()`. Then if I ever tried to call it a second time, the 
> static analyzer would (hopefully) complain that I was accessing a moved-from 
> `myCallback`. But you want this for existing APIs that take the built-in 
> block type, so never mind. :)

That's neat!  But yeah, it's designed for existing Obj-C APIs.  However, I do 
want to add this attribute for C++, but it's way more things to support 
(lambda, call operators, pointers to member functions and so on).

> Probably irrelevant scope creep: Is it worth trying to support the 
> possibility that someone might want to pass both a `successHandler` and a 
> `failureHandler`, with the invariant that we'd make //exactly one call to one 
> of them// (but never call both)? Is that just not a thing that ever happens 
> in NSWhatever?

This is a somewhat usual thing, actually.  However, the naming convention is 
pretty strong, so parameter in `addSuccessHandler` and `addFailureHandler` 
won't be named `completionHandler`.  In this case, the analysis won't consider 
those as **calls**, but rather as **escapes** and won't report when it sees two 
of those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

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


[PATCH] D92037: clang: Pass -platform-version to new MachO LLD

2020-11-24 Thread Nico Weber via Phabricator via cfe-commits
thakis marked an inline comment as done.
thakis added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92037

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


[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-11-24 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: aaron.ballman, dexonsmith, rsmith, Bigcheese, 
rjmccall, NoQ, doug.gregor, ravikandhadai, dcoughlin.
Herald added subscribers: cfe-commits, Charusso, mgorny.
Herald added a project: clang.
vsavchenko requested review of this revision.

This commit introduces a new attribute `called_once`.
It can be applied to function-like parameters to signify that
this parameter should be called exactly once.  This concept
is particularly widespread in asynchronous programs.

Additionally, this commit introduce a new group of dataflow
analysis-based warnings to check this property.  It identifies
and reports the following situations:

- parameter is called twice
- parameter is never called
- parameter is not called on one of the paths

Current implementation can also automatically infer `called_once`
attribute for completion handler paramaters that should follow the
same principle by convention.  This behavior is OFF by default and
can be turned on by using `-Wcompletion-handler`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92039

Files:
  clang/include/clang/Analysis/Analyses/CalledOnceCheck.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/CalledOnceCheck.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaObjC/attr-called-once.m
  clang/test/SemaObjC/warn-called-once.m

Index: clang/test/SemaObjC/warn-called-once.m
===
--- /dev/null
+++ clang/test/SemaObjC/warn-called-once.m
@@ -0,0 +1,887 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fblocks -fobjc-exceptions -Wcompletion-handler %s
+
+#define NULL (void *)0
+#define CALLED_ONCE __attribute__((called_once))
+#define NORETURN __attribute__((noreturn))
+
+@protocol NSObject
+@end
+@interface NSObject 
+- (id)copy;
+- (id)class;
+- autorelease;
+@end
+
+typedef unsigned int NSUInteger;
+typedef struct {
+} NSFastEnumerationState;
+
+@interface NSArray <__covariant NSFastEnumeration>
+- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
+@end
+@interface NSMutableArray : NSArray 
+- addObject:anObject;
+@end
+@class NSString, Protocol;
+extern void NSLog(NSString *format, ...);
+
+void escape(void (^callback)(void));
+void escape_void(void *);
+void indirect_call(void (^callback)(void) CALLED_ONCE);
+void indirect_conv(void (^completionHandler)(void));
+void filler(void);
+void exit(int) NORETURN;
+
+void double_call_one_block(void (^callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_parens(void (^callback)(void) CALLED_ONCE) {
+  (callback)(); // expected-note{{previous call is here}}
+  (callback)(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_ptr(void (*callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_one_block_ptr_deref(void (*callback)(void) CALLED_ONCE) {
+  (*callback)(); // expected-note{{previous call is here}}
+  (*callback)(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void multiple_call_one_block(void (^callback)(void) CALLED_ONCE) {
+  // We don't really need to repeat the same warning for the same parameter.
+  callback(); // no-warning
+  callback(); // no-warning
+  callback(); // no-warning
+  callback(); // expected-note{{previous call is here}}
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_branching_1(int cond, void (^callback)(void) CALLED_ONCE) {
+  if (cond) {
+callback(); // expected-note{{previous call is here}}
+  } else {
+cond += 42;
+  }
+  callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+}
+
+void double_call_branching_2(int cond, void (^callback)(void) CALLED_ONCE) {
+  callback(); // expected-note{{previous call is here}}
+
+  if (cond) {
+callback(); // expected-warning{{'callback' parameter marked 'called_once' is called twice}}
+  } else {
+cond += 42;
+  }
+}
+
+void double_call_branching_3(int cond, void (^callback)(void) CALLED_ONCE) {
+  if (cond) {
+callback();
+  } else {
+callback();
+  }
+  // no-warning
+}
+
+void double_call_branching_4(int cond1, int cond2, void (^callback)(void) CALLED_ONCE) {
+  if (cond1) {
+cond2 = !cond2;
+  } else {
+callback(); // expected-note{{previous call is here}}
+  }
+
+  if (cond2) {
+

[PATCH] D88712: [CGBuiltin] Respect asm labels and redefine_extname for builtins with specialized emitting

2020-11-24 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In D88712#2413877 , 
@venkataramanan.kumar.llvm wrote:

> In D88712#2413688 , @spatel wrote:
>
>> In D88712#2412874 , 
>> @venkataramanan.kumar.llvm wrote:
>>
>>> In D88712#2412366 , @MaskRay wrote:
>>>
 In D88712#2411841 , 
 @venkataramanan.kumar.llvm wrote:

> 

 For your example:

   extern double log (double) asm ("" "log_finite") __attribute__ 
 ((nothrow));
   
   double mylog (double d) { return log(d); }

 The intention is to emit `log_finite`, no matter the `-ffast-math`. Both 
 GCC and Clang (after this patch) emit `jmp log_finite`.

 The previous behavior (according to your comment, with an older glibc) was 
 undesired. So I think the right suggestion is to upgrade glibc.
>>>
>>> Then there optimizations like vectorization, inst combine which works on 
>>> the LLVM intrinsics.  But they will be not happening now  with  log_finite 
>>> calls.
>>
>> I'm not sure about the expected semantics/lowering for the finite calls, but 
>> can you add something under 
>> LibCallSimplifier::optimizeFloatingPointLibCall() that would turn it into 
>> the LLVM log intrinsic with appropriate FMF? Codegen would need to be 
>> responsible for converting it back to finite call(s) if those are available?
>
> Hi Sanjay I thought codegen no longer lowers them back to finite calls 
> https://reviews.llvm.org/rGcd0926d087a85c5ee1222ca80980b4440214a822

There was a comment in D74712  that we might 
be moving too fast. If you would like to revert/adjust that patch, raise a bug 
or post a patch to discuss? If the goal is to be able to vectorize the finite 
calls, then we will need some way to represent those. Alternatively, we could 
change something in the cost models to enable more unrolling, etc?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88712

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


[PATCH] D83698: [clang][cli] Port Target option flags to new option parsing system

2020-11-24 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese 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/D83698/new/

https://reviews.llvm.org/D83698

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


[PATCH] D92041: Add hover info for `this` expr

2020-11-24 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Thanks, this sounds like a sensible idea. I got a few suggestions for the 
implementation though.




Comment at: clang-tools-extra/clangd/Hover.cpp:610
+/// Generate a \p Hover object given the \p this pointer.
+HoverInfo getHoverContents(const CXXThisExpr *CTE, const SymbolIndex *Index) {
+  const NamedDecl *D = CTE->getType()->getPointeeType()->getAsCXXRecordDecl();

what about using the existing `getHoverContents(QualType ..)` overload instead ?



Comment at: clang-tools-extra/clangd/Hover.cpp:644
 // FIXME: Support hover for literals (esp user-defined)
 llvm::Optional getHoverContents(const Expr *E, ParsedAST ) {
   // There's not much value in hovering over "42" and getting a hover card

can you handle `CXXThisExpr` inside this function, instead of an extra branch 
in the `getHover`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92041

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


[PATCH] D91676: Avoid redundant work when computing vtable vcall visibility

2020-11-24 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/CodeGen/CGVTables.cpp:1301-1302
+  // has no effect on the min visibility computed below by the recursive 
caller.
+  if (!Visited.insert(RD).second)
+return llvm::GlobalObject::VCallVisibilityTranslationUnit;
+

tejohnson wrote:
> wmi wrote:
> > If a CXXRecordDecl is visited twice, the visibility returned in the second 
> > visit could be larger than necessary. Will it change the final result? If 
> > it will, can we cache the visibility result got in the first visit instead 
> > of returning the max value? 
> The recursive callsites compute the std::min of the current TypeVis and the 
> one returned by the recursive call. So returning the max guarantees that 
> there is no effect on the current TypeVis. Let me know if the comment can be 
> clarified (that's what I meant by "so that it has no effect on the min 
> visibility computed below ...". Note that the initial non-recursive 
> invocation always has an empty Visited set.
I see. That makes sense! I didn't understand the location meant by "computed 
below by the recursive caller." Your explanation "initial non-recursive 
invocation always has an empty Visited set" helps a lot. It means the immediate 
result of GetVCallVisibilityLevel may change, but the result for the initial 
invocation of the recursive call won't be changed. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

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


[PATCH] D92039: [-Wcalled-once-parameter] Introduce 'called_once' attribute

2020-11-24 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: clang/lib/Analysis/CalledOnceCheck.cpp:1223
+// We consider '(void)parameter' as a manual no-op escape.
+// It should be used to explicitly tell the analysis that this paramater
+// is intentionally not called on this path.

s/paramater/parameter/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92039

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


[PATCH] D91676: Avoid redundant work when computing vtable vcall visibility

2020-11-24 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 307404.
tejohnson added a comment.

Improve comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

Files:
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/MicrosoftCXXABI.cpp


Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1649,8 +1649,9 @@
   // TODO: Should VirtualFunctionElimination also be supported here?
   // See similar handling in CodeGenModule::EmitVTableTypeMetadata.
   if (CGM.getCodeGenOpts().WholeProgramVTables) {
+llvm::DenseSet Visited;
 llvm::GlobalObject::VCallVisibility TypeVis =
-CGM.GetVCallVisibilityLevel(RD);
+CGM.GetVCallVisibilityLevel(RD, Visited);
 if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
   VTable->setVCallVisibilityMetadata(TypeVis);
   }
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1333,8 +1333,11 @@
   /// a virtual function call could be made which ends up being dispatched to a
   /// member function of this class. This scope can be wider than the 
visibility
   /// of the class itself when the class has a more-visible dynamic base class.
+  /// The client should pass in an empty Visited set, which is used to prevent
+  /// redundant recursive processing.
   llvm::GlobalObject::VCallVisibility
-  GetVCallVisibilityLevel(const CXXRecordDecl *RD);
+  GetVCallVisibilityLevel(const CXXRecordDecl *RD,
+  llvm::DenseSet );
 
   /// Emit type metadata for the given vtable using the given layout.
   void EmitVTableTypeMetadata(const CXXRecordDecl *RD,
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -1294,8 +1294,16 @@
   return !HasLTOVisibilityPublicStd(RD);
 }
 
-llvm::GlobalObject::VCallVisibility
-CodeGenModule::GetVCallVisibilityLevel(const CXXRecordDecl *RD) {
+llvm::GlobalObject::VCallVisibility CodeGenModule::GetVCallVisibilityLevel(
+const CXXRecordDecl *RD, llvm::DenseSet ) {
+  // If we have already visited this RD (which means this is a recursive call
+  // since the initial call should have an empty Visited set), return the max
+  // visibility. The recursive calls below compute the min between the result
+  // of the recursive call and the current TypeVis, so returning the max here
+  // ensures that it will have no effect on the current TypeVis.
+  if (!Visited.insert(RD).second)
+return llvm::GlobalObject::VCallVisibilityTranslationUnit;
+
   LinkageInfo LV = RD->getLinkageAndVisibility();
   llvm::GlobalObject::VCallVisibility TypeVis;
   if (!isExternallyVisible(LV.getLinkage()))
@@ -1307,13 +1315,15 @@
 
   for (auto B : RD->bases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
-  TypeVis = std::min(TypeVis,
-
GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl()));
+  TypeVis = std::min(
+  TypeVis,
+  GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl(), Visited));
 
   for (auto B : RD->vbases())
 if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())
-  TypeVis = std::min(TypeVis,
-
GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl()));
+  TypeVis = std::min(
+  TypeVis,
+  GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl(), Visited));
 
   return TypeVis;
 }
@@ -1382,7 +1392,9 @@
 
   if (getCodeGenOpts().VirtualFunctionElimination ||
   getCodeGenOpts().WholeProgramVTables) {
-llvm::GlobalObject::VCallVisibility TypeVis = GetVCallVisibilityLevel(RD);
+llvm::DenseSet Visited;
+llvm::GlobalObject::VCallVisibility TypeVis =
+GetVCallVisibilityLevel(RD, Visited);
 if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
   VTable->setVCallVisibilityMetadata(TypeVis);
   }


Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1649,8 +1649,9 @@
   // TODO: Should VirtualFunctionElimination also be supported here?
   // See similar handling in CodeGenModule::EmitVTableTypeMetadata.
   if (CGM.getCodeGenOpts().WholeProgramVTables) {
+llvm::DenseSet Visited;
 llvm::GlobalObject::VCallVisibility TypeVis =
-CGM.GetVCallVisibilityLevel(RD);
+CGM.GetVCallVisibilityLevel(RD, Visited);
 if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)
   VTable->setVCallVisibilityMetadata(TypeVis);
   }
Index: clang/lib/CodeGen/CodeGenModule.h

[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-11-24 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob marked 5 inline comments as done.
dougpuob added a comment.

Hi @aaron.ballman and @Eugene.Zelenko, thank you for your suggestions. I will 
improve them and upload my diff later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D92041: Add hover info for `this` expr

2020-11-24 Thread xndcn via Phabricator via cfe-commits
xndcn created this revision.
xndcn added reviewers: sammccall, kadircet.
xndcn added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
xndcn requested review of this revision.

How about add hover information for `this` expr?
It seems useful to show related information about the class for `this` expr 
sometimes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92041

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2019,6 +2019,23 @@
 HI.NamespaceScope = "";
 HI.Definition = "@interface MYObject\n@end";
   }},
+  {
+  R"cpp(// this expr
+   namespace ns {
+ class Foo {
+   Foo* bar() {
+ return [[t^his]];
+   }
+ };
+   };
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "this";
+HI.Type = "ns::Foo *";
+HI.Kind = index::SymbolKind::Unknown;
+HI.NamespaceScope = "ns::";
+HI.Definition = "class Foo {}";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -606,6 +606,17 @@
   return HI;
 }
 
+/// Generate a \p Hover object given the \p this pointer.
+HoverInfo getHoverContents(const CXXThisExpr *CTE, const SymbolIndex *Index) {
+  const NamedDecl *D = CTE->getType()->getPointeeType()->getAsCXXRecordDecl();
+  HoverInfo HI = getHoverContents(D, Index);
+  HI.Name = "this";
+  // TODO: determine the symbol kind.
+  HI.Kind = index::SymbolKind::Unknown;
+  HI.Type = printType(CTE->getType(), D->getASTContext().getPrintingPolicy());
+  return HI;
+}
+
 bool isLiteral(const Expr *E) {
   // Unfortunately there's no common base Literal classes inherits from
   // (apart from Expr), therefore these exclusions.
@@ -860,6 +871,8 @@
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext());
 maybeAddCalleeArgInfo(N, *HI, AST.getASTContext().getPrintingPolicy());
+  } else if (const CXXThisExpr *CTE = N->ASTNode.get()) {
+HI = getHoverContents(CTE, Index);
   } else if (const Expr *E = N->ASTNode.get()) {
 HI = getHoverContents(E, AST);
   }


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2019,6 +2019,23 @@
 HI.NamespaceScope = "";
 HI.Definition = "@interface MYObject\n@end";
   }},
+  {
+  R"cpp(// this expr
+   namespace ns {
+ class Foo {
+   Foo* bar() {
+ return [[t^his]];
+   }
+ };
+   };
+  )cpp",
+  [](HoverInfo ) {
+HI.Name = "this";
+HI.Type = "ns::Foo *";
+HI.Kind = index::SymbolKind::Unknown;
+HI.NamespaceScope = "ns::";
+HI.Definition = "class Foo {}";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -606,6 +606,17 @@
   return HI;
 }
 
+/// Generate a \p Hover object given the \p this pointer.
+HoverInfo getHoverContents(const CXXThisExpr *CTE, const SymbolIndex *Index) {
+  const NamedDecl *D = CTE->getType()->getPointeeType()->getAsCXXRecordDecl();
+  HoverInfo HI = getHoverContents(D, Index);
+  HI.Name = "this";
+  // TODO: determine the symbol kind.
+  HI.Kind = index::SymbolKind::Unknown;
+  HI.Type = printType(CTE->getType(), D->getASTContext().getPrintingPolicy());
+  return HI;
+}
+
 bool isLiteral(const Expr *E) {
   // Unfortunately there's no common base Literal classes inherits from
   // (apart from Expr), therefore these exclusions.
@@ -860,6 +871,8 @@
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext());
 maybeAddCalleeArgInfo(N, *HI, AST.getASTContext().getPrintingPolicy());
+  } else if (const CXXThisExpr *CTE = N->ASTNode.get()) {
+HI = getHoverContents(CTE, Index);
   } else if (const Expr *E = N->ASTNode.get()) {
 HI = getHoverContents(E, AST);
   }
___
cfe-commits mailing list

[PATCH] D83211: Factor out call to EXTRACTOR in generateCC1CommandLine

2020-11-24 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3938
+  if ((FLAGS)::CC1Option) {
\
+const auto  = EXTRACTOR(this->KEYPATH);  
\
+if (ALWAYS_EMIT || Extracted != DEFAULT_VALUE) 
\

Bigcheese wrote:
> jansvoboda11 wrote:
> > dexonsmith wrote:
> > > dexonsmith wrote:
> > > > jansvoboda11 wrote:
> > > > > Bigcheese wrote:
> > > > > > Will this ever have an issue with lifetime? I can see various 
> > > > > > values for `EXTRACTOR` causing issues here. 
> > > > > > https://abseil.io/tips/107
> > > > > > 
> > > > > > 
> > > > > > It would be good to at least document somewhere the restrictions on 
> > > > > > `EXTRACTOR`.
> > > > > Mentioned the reference lifetime extension in a comment near 
> > > > > extractor definitions.
> > > > It might be safer to refactor as:
> > > > ```
> > > > // Capture the extracted value as a lambda argument to avoid potential
> > > > // lifetime extension issues.
> > > > [&](const auto ) {
> > > >   if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))
> > > > DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);
> > > > }(EXTRACTOR(this->KEYPATH));
> > > > ```
> > > > 
> > > Might be even better to avoid the generic lambda:
> > > ```
> > > // Capture the extracted value as a lambda argument to avoid potential
> > > // lifetime extension issues.
> > > using ExtractedType =
> > > std::remove_const_t > > decltype(EXTRACTOR(this->KEYPATH))>>
> > > [&](const ExtractedType ) {
> > >   if (ALWAYS_EMIT || Extracted != (DEFAULT_VALUE))
> > > DENORMALIZER(Args, SPELLING, SA, TABLE_INDEX, Extracted);
> > > }(EXTRACTOR(this->KEYPATH));
> > > ```
> > > (since generic vs. non-generic could affect compile-time of 
> > > CompilerInvocation.cpp given how many instances there will be).
> > Thanks for the suggestions @dexonsmith. I'm having trouble writing a test 
> > case where the lambda workaround produces a different result than `const 
> > auto &` variable.
> > @Bigcheese, could you show a concrete example of an extractor that causes 
> > issues so I can test it out?
> I think I was confused about when this can happen. The `const auto &` will 
> never cause a conversion that would prevent lifetime extension. The only 
> place this would break is if the copy constructor of the type is rather 
> broken, which isn't a reasonable case to support.
Now I remember what the issue was, it's if the `EXTRACTOR` itself creates an 
owning temporary and converts back to a reference type: 
https://godbolt.org/z/xsvh4f

This is kind of weird to do, the `EXTRACTOR` would need to take an owning type 
with an implicit conversion from the type of `KEYPATH`, and then return a 
reference type. I'm not sure how realistic that situation is, but it seems fine 
to defend against with Duncan's suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83211

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


[PATCH] D91676: Avoid redundant work when computing vtable vcall visibility

2020-11-24 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/lib/CodeGen/CGVTables.cpp:1301-1302
+  // has no effect on the min visibility computed below by the recursive 
caller.
+  if (!Visited.insert(RD).second)
+return llvm::GlobalObject::VCallVisibilityTranslationUnit;
+

wmi wrote:
> If a CXXRecordDecl is visited twice, the visibility returned in the second 
> visit could be larger than necessary. Will it change the final result? If it 
> will, can we cache the visibility result got in the first visit instead of 
> returning the max value? 
The recursive callsites compute the std::min of the current TypeVis and the one 
returned by the recursive call. So returning the max guarantees that there is 
no effect on the current TypeVis. Let me know if the comment can be clarified 
(that's what I meant by "so that it has no effect on the min visibility 
computed below ...". Note that the initial non-recursive invocation always has 
an empty Visited set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

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


[clang] f96fef8 - [Driver] Default Generic_GCC aarch64 to -fasynchronous-unwind-tables

2020-11-24 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-11-24T09:51:32-08:00
New Revision: f96fef89b5eca29f2dc41e97829c20bf742cdcd9

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

LOG: [Driver] Default Generic_GCC aarch64 to -fasynchronous-unwind-tables

In GCC, `aarch64-*-linux` and `aarch64-*-freebsd` made the switch in 2018
(https://gcc.gnu.org/pipermail/gcc-patches/2018-March/495549.html).
In Clang, FreeBSD/Fuchsia/NetBSD/MinGW aarch64 default to 
-fasynchronous-unwind-tables.

This patch defaults Generic_GCC aarch64 (which affects Linux) to use 
-fasynchronous-unwind-tables.

Reviewed By: nickdesaulniers

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/aarch64-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7d75e90c6092..08158ba4bae8 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2672,7 +2672,13 @@ void Generic_GCC::printVerboseInfo(raw_ostream ) 
const {
 }
 
 bool Generic_GCC::IsUnwindTablesDefault(const ArgList ) const {
-  return getArch() == llvm::Triple::x86_64;
+  switch (getArch()) {
+  case llvm::Triple::aarch64:
+  case llvm::Triple::x86_64:
+return true;
+  default:
+return false;
+  }
 }
 
 bool Generic_GCC::isPICDefault() const {

diff  --git a/clang/test/Driver/aarch64-features.c 
b/clang/test/Driver/aarch64-features.c
index 7c3f8754049a..8d8cc3c68afe 100644
--- a/clang/test/Driver/aarch64-features.c
+++ b/clang/test/Driver/aarch64-features.c
@@ -1,6 +1,8 @@
 // RUN: %clang -target aarch64-none-linux-gnu -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 // RUN: %clang -target arm64-none-linux-gnu -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 
+// CHECK: "-munwind-tables"
+
 // The AArch64 PCS states that chars should be unsigned.
 // CHECK: fno-signed-char
 



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


[PATCH] D91760: [Driver] Default Generic_GCC aarch64 to use -fasynchronous-unwind-tables

2020-11-24 Thread Fangrui Song 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 rGf96fef89b5ec: [Driver] Default Generic_GCC aarch64 to 
-fasynchronous-unwind-tables (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91760

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/aarch64-features.c


Index: clang/test/Driver/aarch64-features.c
===
--- clang/test/Driver/aarch64-features.c
+++ clang/test/Driver/aarch64-features.c
@@ -1,6 +1,8 @@
 // RUN: %clang -target aarch64-none-linux-gnu -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 // RUN: %clang -target arm64-none-linux-gnu -### %s -fsyntax-only 2>&1 | 
FileCheck %s
 
+// CHECK: "-munwind-tables"
+
 // The AArch64 PCS states that chars should be unsigned.
 // CHECK: fno-signed-char
 
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2672,7 +2672,13 @@
 }
 
 bool Generic_GCC::IsUnwindTablesDefault(const ArgList ) const {
-  return getArch() == llvm::Triple::x86_64;
+  switch (getArch()) {
+  case llvm::Triple::aarch64:
+  case llvm::Triple::x86_64:
+return true;
+  default:
+return false;
+  }
 }
 
 bool Generic_GCC::isPICDefault() const {


Index: clang/test/Driver/aarch64-features.c
===
--- clang/test/Driver/aarch64-features.c
+++ clang/test/Driver/aarch64-features.c
@@ -1,6 +1,8 @@
 // RUN: %clang -target aarch64-none-linux-gnu -### %s -fsyntax-only 2>&1 | FileCheck %s
 // RUN: %clang -target arm64-none-linux-gnu -### %s -fsyntax-only 2>&1 | FileCheck %s
 
+// CHECK: "-munwind-tables"
+
 // The AArch64 PCS states that chars should be unsigned.
 // CHECK: fno-signed-char
 
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2672,7 +2672,13 @@
 }
 
 bool Generic_GCC::IsUnwindTablesDefault(const ArgList ) const {
-  return getArch() == llvm::Triple::x86_64;
+  switch (getArch()) {
+  case llvm::Triple::aarch64:
+  case llvm::Triple::x86_64:
+return true;
+  default:
+return false;
+  }
 }
 
 bool Generic_GCC::isPICDefault() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43159: Modernize: Use nullptr more.

2020-11-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 307398.
ldionne added a comment.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Rebase onto master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43159

Files:
  libcxx/include/__locale
  libcxx/include/__sso_allocator
  libcxx/include/__string
  libcxx/include/__threading_support
  libcxx/include/algorithm
  libcxx/include/bitset
  libcxx/include/chrono
  libcxx/include/fstream
  libcxx/include/functional
  libcxx/include/ios
  libcxx/include/istream
  libcxx/include/iterator
  libcxx/include/locale
  libcxx/include/memory
  libcxx/include/regex
  libcxx/include/sstream
  libcxx/include/streambuf
  libcxx/include/string
  libcxx/include/strstream
  libcxx/include/system_error
  libcxx/include/valarray
  libcxx/src/new.cpp

Index: libcxx/src/new.cpp
===
--- libcxx/src/new.cpp
+++ libcxx/src/new.cpp
@@ -64,7 +64,7 @@
 if (size == 0)
 size = 1;
 void* p;
-while ((p = ::malloc(size)) == 0)
+while ((p = ::malloc(size)) == nullptr)
 {
 // If malloc fails and there is a new_handler,
 // call it to try free up memory.
@@ -85,7 +85,7 @@
 void*
 operator new(size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -111,7 +111,7 @@
 void*
 operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -207,7 +207,7 @@
 void*
 operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
@@ -233,7 +233,7 @@
 void*
 operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) _NOEXCEPT
 {
-void* p = 0;
+void* p = nullptr;
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
Index: libcxx/include/valarray
===
--- libcxx/include/valarray
+++ libcxx/include/valarray
@@ -802,7 +802,7 @@
 public:
 // construct/destroy:
 _LIBCPP_INLINE_VISIBILITY
-valarray() : __begin_(0), __end_(0) {}
+valarray() : __begin_(nullptr), __end_(nullptr) {}
 inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
 explicit valarray(size_t __n);
 _LIBCPP_INLINE_VISIBILITY
@@ -2750,8 +2750,8 @@
 template 
 inline
 valarray<_Tp>::valarray(size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2776,16 +2776,16 @@
 template 
 inline
 valarray<_Tp>::valarray(const value_type& __x, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 resize(__n, __x);
 }
 
 template 
 valarray<_Tp>::valarray(const value_type* __p, size_t __n)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__n)
 {
@@ -2809,8 +2809,8 @@
 
 template 
 valarray<_Tp>::valarray(const valarray& __v)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 if (__v.size())
 {
@@ -2845,8 +2845,8 @@
 
 template 
 valarray<_Tp>::valarray(initializer_list __il)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __il.size();
 if (__n)
@@ -2874,8 +2874,8 @@
 
 template 
 valarray<_Tp>::valarray(const slice_array& __sa)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __sa.__size_;
 if (__n)
@@ -2901,8 +2901,8 @@
 
 template 
 valarray<_Tp>::valarray(const gslice_array& __ga)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ga.__1d_.size();
 if (__n)
@@ -2930,8 +2930,8 @@
 
 template 
 valarray<_Tp>::valarray(const mask_array& __ma)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ma.__1d_.size();
 if (__n)
@@ -2959,8 +2959,8 @@
 
 template 
 valarray<_Tp>::valarray(const indirect_array& __ia)
-: __begin_(0),
-  __end_(0)
+: __begin_(nullptr),
+  __end_(nullptr)
 {
 const size_t __n = __ia.__1d_.size();
 if (__n)
Index: libcxx/include/system_error
===
--- libcxx/include/system_error
+++ libcxx/include/system_error
@@ -253,7 +253,7 @@
 template 
 _LIBCPP_INLINE_VISIBILITY
 error_condition(_Ep __e,
-  typename enable_if::value>::type* = 0
+  typename enable_if::value>::type* = nullptr
  ) _NOEXCEPT
 {*this = make_error_condition(__e);}
 
@@ -325,7 +325,7 @@
 template 
 

  1   2   >