[clang] 20a60f4 - [X86] Explicitly add popcnt feature to Intel CPUs with SSE4.2 in the frontend.

2020-06-29 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-06-28T11:06:40-07:00
New Revision: 20a60f46f505fc790e126b8b860c689870355f36

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

LOG: [X86] Explicitly add popcnt feature to Intel CPUs with SSE4.2 in the 
frontend.

Previously we inferred it if sse4.2 ended up being enabled after
all feature processing. But writing -march=nehalem -mno-sse4.2
should have popcnt enabled.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/test/Preprocessor/x86_target_features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 653db5e8b4ac..4b61f3c5536f 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -224,6 +224,7 @@ bool X86TargetInfo::initFeatureMap(
 LLVM_FALLTHROUGH;
   case CK_Nehalem:
 setFeatureEnabledImpl(Features, "sse4.2", true);
+setFeatureEnabledImpl(Features, "popcnt", true);
 LLVM_FALLTHROUGH;
   case CK_Penryn:
 setFeatureEnabledImpl(Features, "sse4.1", true);
@@ -281,6 +282,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "rdrnd", true);
 setFeatureEnabledImpl(Features, "pclmul", true);
 setFeatureEnabledImpl(Features, "sse4.2", true);
+setFeatureEnabledImpl(Features, "popcnt", true);
 setFeatureEnabledImpl(Features, "prfchw", true);
 LLVM_FALLTHROUGH;
   case CK_Bonnell:
@@ -307,6 +309,7 @@ bool X86TargetInfo::initFeatureMap(
 setFeatureEnabledImpl(Features, "rdseed", true);
 setFeatureEnabledImpl(Features, "adx", true);
 setFeatureEnabledImpl(Features, "lzcnt", true);
+setFeatureEnabledImpl(Features, "popcnt", true);
 setFeatureEnabledImpl(Features, "bmi", true);
 setFeatureEnabledImpl(Features, "bmi2", true);
 setFeatureEnabledImpl(Features, "fma", true);

diff  --git a/clang/test/Preprocessor/x86_target_features.c 
b/clang/test/Preprocessor/x86_target_features.c
index dc7c8109b4da..4a46a131afa7 100644
--- a/clang/test/Preprocessor/x86_target_features.c
+++ b/clang/test/Preprocessor/x86_target_features.c
@@ -269,6 +269,12 @@
 
 // NOSSE42POPCNT: #define __POPCNT__ 1
 
+// RUN: %clang -target i386-unknown-unknown -march=nehalem -mno-sse4.2 -x c -E 
-dM -o - %s | FileCheck -match-full-lines --check-prefix=CPUPOPCNT %s
+// RUN: %clang -target i386-unknown-unknown -march=silvermont -mno-sse4.2 -x c 
-E -dM -o - %s | FileCheck -match-full-lines --check-prefix=CPUPOPCNT %s
+// RUN: %clang -target i386-unknown-unknown -march=knl -mno-sse4.2 -x c -E -dM 
-o - %s | FileCheck -match-full-lines --check-prefix=CPUPOPCNT %s
+
+// CPUPOPCNT: #define __POPCNT__ 1
+
 // RUN: %clang -target i386-unknown-unknown -march=pentium -msse -x c -E -dM 
-o - %s | FileCheck -match-full-lines --check-prefix=SSEMMX %s
 
 // SSEMMX: #define __MMX__ 1



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


[PATCH] D82314: [Coroutines] Optimize the lifespan of temporary co_await object

2020-06-29 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 273946.
lxfind added a comment.

Rebase before landing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82314

Files:
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/coro-split-02.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime.ll

Index: llvm/test/Transforms/Coroutines/coro-split-sink-lifetime.ll
===
--- llvm/test/Transforms/Coroutines/coro-split-sink-lifetime.ll
+++ llvm/test/Transforms/Coroutines/coro-split-sink-lifetime.ll
@@ -1,6 +1,5 @@
-; Tests that coro-split can handle the case when a code after coro.suspend uses
-; a value produces between coro.save and coro.suspend (%Result.i19)
-; and checks whether stray coro.saves are properly removed
+; Tests that coro-split will optimize the lifetime.start maker of each local variable,
+; sink them to the places closest to the actual use.
 ; RUN: opt < %s -coro-split -S | FileCheck %s
 ; RUN: opt < %s -passes=coro-split -S | FileCheck %s
 
@@ -15,6 +14,9 @@
 entry:
   %ref.tmp7 = alloca %"struct.lean_future::Awaiter", align 8
   %testval = alloca i32
+  %cast = bitcast i32* %testval to i8*
+  ; lifetime of %testval starts here, but not used until await.ready.
+  call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
   %alloc = call i8* @malloc(i64 16) #3
   %vFrame = call noalias nonnull i8* @llvm.coro.begin(token %id, i8* %alloc)
@@ -29,8 +31,8 @@
 await.ready:
   %StrayCoroSave = call token @llvm.coro.save(i8* null)
   %val = load i32, i32* %Result.i19
-  %cast = bitcast i32* %testval to i8*
-  call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
+  %test = load i32, i32* %testval
+  call void @print(i32 %test)
   call void @llvm.lifetime.end.p0i8(i64 4, i8*  %cast)
   call void @print(i32 %val)
   br label %exit
@@ -40,14 +42,15 @@
 }
 
 ; CHECK-LABEL: @a.resume(
-; CHECK: %testval = alloca i32
-; CHECK: getelementptr inbounds %a.Frame
+; CHECK: %testval = alloca i32, align 4
+; CHECK-NEXT:getelementptr inbounds %a.Frame
 ; CHECK-NEXT:getelementptr inbounds %"struct.lean_future::Awaiter"
-; CHECK-NOT: call token @llvm.coro.save(i8* null)
+; CHECK-NEXT:%cast1 = bitcast i32* %testval to i8*
 ; CHECK-NEXT:%val = load i32, i32* %Result
-; CHECK-NEXT:%cast = bitcast i32* %testval to i8*
-; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
-; CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 4, i8* %cast)
+; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast1)
+; CHECK-NEXT:%test = load i32, i32* %testval
+; CHECK-NEXT:call void @print(i32 %test)
+; CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 4, i8* %cast1)
 ; CHECK-NEXT:call void @print(i32 %val)
 ; CHECK-NEXT:ret void
 
Index: llvm/test/Transforms/Coroutines/coro-split-02.ll
===
--- llvm/test/Transforms/Coroutines/coro-split-02.ll
+++ llvm/test/Transforms/Coroutines/coro-split-02.ll
@@ -31,6 +31,8 @@
   %val = load i32, i32* %Result.i19
   %cast = bitcast i32* %testval to i8*
   call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
+  %test = load i32, i32* %testval
+  call void @print(i32 %test)
   call void @llvm.lifetime.end.p0i8(i64 4, i8*  %cast)
   call void @print(i32 %val)
   br label %exit
@@ -47,6 +49,8 @@
 ; CHECK-NEXT:%val = load i32, i32* %Result
 ; CHECK-NEXT:%cast = bitcast i32* %testval to i8*
 ; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
+; CHECK-NEXT:%test = load i32, i32* %testval
+; CHECK-NEXT:call void @print(i32 %test)
 ; CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 4, i8* %cast)
 ; CHECK-NEXT:call void @print(i32 %val)
 ; CHECK-NEXT:ret void
Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -75,7 +75,7 @@
 
 namespace {
 
-/// A little helper class for building 
+/// A little helper class for building
 class CoroCloner {
 public:
   enum class Kind {
@@ -563,7 +563,7 @@
   // In the original function, the AllocaSpillBlock is a block immediately
   // following the allocation of the frame object which defines GEPs for
   // all the allocas that have been moved into the frame, and it ends by
-  // branching to the original beginning of the coroutine.  Make this 
+  // branching to the original beginning of the coroutine.  Make this
   // the entry block of the cloned function.
   auto *Entry = cast(VMap[Shape.AllocaSpillBlock]);
   auto *OldEntry = &NewF->getEntryBlock();
@@ -1239,6 +1239,103 @@
   S.resize(N);
 }
 
+/// For every local variable that has lifetime intrinsics markers, we sink
+

[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks chevk-clang-tools in mac: http://45.33.8.238/mac/16292/step_8.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82707: [clang][docs] Remove untracked files from formatted status

2020-06-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Thank you for this, I’m happy with this and can take a look at removing the 
os.walk I agree it might be better/quicker


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82707



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


[PATCH] D82707: [clang][docs] Remove untracked files from formatted status

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGabafb655c85d: [clang][docs] Remove untracked files from 
formatted status (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82707

Files:
  clang/docs/tools/generate_formatted_state.py


Index: clang/docs/tools/generate_formatted_state.py
===
--- clang/docs/tools/generate_formatted_state.py
+++ clang/docs/tools/generate_formatted_state.py
@@ -72,6 +72,8 @@
  - {style2}`{percent}%`
 """
 
+FNULL = open(os.devnull, 'w')
+
 with open(DOC_FILE, 'wb') as output:
 sha = get_git_revision_short_hash()
 today = datetime.now().strftime("%B %d, %Y %H:%M:%S")
@@ -85,14 +87,22 @@
 for subdir in subdirs:
 if any(sd == subdir for sd in skipped_dirs):
 subdirs.remove(subdir)
+else:
+act_sub_dir = os.path.join(root, subdir)
+# Check the git index to see if the directory contains tracked
+# files. Reditect the output to a null descriptor as we aren't
+# interested in it, just the return code.
+git_check = subprocess.Popen(
+["git", "ls-files", "--error-unmatch", act_sub_dir],
+stdout=FNULL,
+stderr=FNULL)
+if git_check.wait() != 0:
+print("Skipping directory: ", act_sub_dir)
+subdirs.remove(subdir)
 
 path = os.path.relpath(root, TOP_DIR)
 path = path.replace('\\', '/')
 
-head, _ = os.path.split(root)
-while head:
-head, _ = os.path.split(head)
-
 file_count = 0
 file_pass = 0
 file_fail = 0


Index: clang/docs/tools/generate_formatted_state.py
===
--- clang/docs/tools/generate_formatted_state.py
+++ clang/docs/tools/generate_formatted_state.py
@@ -72,6 +72,8 @@
  - {style2}`{percent}%`
 """
 
+FNULL = open(os.devnull, 'w')
+
 with open(DOC_FILE, 'wb') as output:
 sha = get_git_revision_short_hash()
 today = datetime.now().strftime("%B %d, %Y %H:%M:%S")
@@ -85,14 +87,22 @@
 for subdir in subdirs:
 if any(sd == subdir for sd in skipped_dirs):
 subdirs.remove(subdir)
+else:
+act_sub_dir = os.path.join(root, subdir)
+# Check the git index to see if the directory contains tracked
+# files. Reditect the output to a null descriptor as we aren't
+# interested in it, just the return code.
+git_check = subprocess.Popen(
+["git", "ls-files", "--error-unmatch", act_sub_dir],
+stdout=FNULL,
+stderr=FNULL)
+if git_check.wait() != 0:
+print("Skipping directory: ", act_sub_dir)
+subdirs.remove(subdir)
 
 path = os.path.relpath(root, TOP_DIR)
 path = path.replace('\\', '/')
 
-head, _ = os.path.split(root)
-while head:
-head, _ = os.path.split(head)
-
 file_count = 0
 file_pass = 0
 file_fail = 0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D82188#2118769 , @thakis wrote:

> This breaks chevk-clang-tools in mac: http://45.33.8.238/mac/16292/step_8.txt
>
> Please take a look and revert for now if it takes a while to fix.


Are you sure that this is the offending patch? I don't touch the diagnostics 
consumer in this patch and this is essentially NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82707: [clang][docs] Remove untracked files from formatted status

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D82707#2118772 , @MyDeveloperDay 
wrote:

> The net result is an actual reduction in the overall %
>
> F12256151: image.png 


Is that a bad thing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82707



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


[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

I have a few pending patches that enforce some long desired restrictions on 
which checkers can emit diagnostics, and I'd prefer not to mess with your 
checker after you land this :/




Comment at: clang/include/clang/StaticAnalyzer/Checkers/Checkers.td:577-583
+  CheckerOptions<[
+CmdLineOption,
+  ]>,

This goes against D81750 -- Sorry for not bringing this up earlier, but you 
can't emit diagnostics from a checker that is hidden :/

The proper solution would be to create a non-hidden checker, and emit a 
diagnostic under its name. You can take inspiration from `MallocChecker`, 
`NullabilityChecker`, and a variety of other sound in the stack of this patch: 
D77845


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

https://reviews.llvm.org/D81315



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


[PATCH] D82707: [clang][docs] Remove untracked files from formatted status

2020-06-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

The net result is an actual reduction in the overall %

F12256151: image.png 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82707



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


[PATCH] D82729: [clangd] Make sure headers are available in FS inside FindSymbolsTests

2020-06-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82729

Files:
  clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp

Index: clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
+++ clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
@@ -100,15 +100,16 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Globals) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
   int global_var;
 
   int global_func();
 
-  struct GlobalStruct {};)cpp");
+  struct GlobalStruct {};)cpp";
+
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
-  #include "foo.h"
-  )cpp");
+  #include "foo.h")cpp");
   EXPECT_THAT(getSymbols("global"),
   UnorderedElementsAre(
   AllOf(QName("GlobalStruct"), WithKind(SymbolKind::Struct)),
@@ -117,10 +118,11 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Unnamed) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
   struct {
 int InUnnamed;
-  } UnnamedStruct;)cpp");
+  } UnnamedStruct;)cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
@@ -141,14 +143,14 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Namespaces) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
   namespace ans1 {
 int ai1;
   namespace ans2 {
 int ai2;
   }
-  }
-  )cpp");
+  })cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
@@ -178,24 +180,20 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, MultiFile) {
-  addFile("foo.h", R"cpp(
-  int foo() {
-  }
-  )cpp");
-  addFile("foo2.h", R"cpp(
-  int foo2() {
-  }
-  )cpp");
+  FS.Files["foo.h"] = "int foo() {}";
+  FS.Files["foo2.h"] = "int foo2() {}";
+
+  addFile("foo.h", FS.Files["foo.h"]);
+  addFile("foo2.h", FS.Files["foo2.h"]);
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
-  #include "foo2.h"
-  )cpp");
+  #include "foo2.h")cpp");
   EXPECT_THAT(getSymbols("foo"),
   UnorderedElementsAre(QName("foo"), QName("foo2")));
 }
 
 TEST_F(WorkspaceSymbolsTest, GlobalNamespaceQueries) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
   int foo() {
   }
   class Foo {
@@ -204,8 +202,8 @@
   namespace ns {
   int foo2() {
   }
-  }
-  )cpp");
+  })cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
@@ -219,7 +217,7 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Enums) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
 enum {
   Red
 };
@@ -239,8 +237,8 @@
   enum class Color4 {
 White
   };
-}
-  )cpp");
+})cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
@@ -259,21 +257,21 @@
 }
 
 TEST_F(WorkspaceSymbolsTest, Ranking) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
   namespace ns{}
   void func();
-  )cpp");
+  )cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
-  #include "foo.h"
-  )cpp");
+  #include "foo.h")cpp");
   EXPECT_THAT(getSymbols("::"), ElementsAre(QName("func"), QName("ns")));
 }
 
 TEST_F(WorkspaceSymbolsTest, WithLimit) {
-  addFile("foo.h", R"cpp(
+  FS.Files["foo.h"] = R"cpp(
   int foo;
-  int foo2;
-  )cpp");
+  int foo2;)cpp";
+  addFile("foo.h", FS.Files["foo.h"]);
   addFile("foo.cpp", R"cpp(
   #include "foo.h"
   )cpp");
@@ -447,13 +445,13 @@
 }
 
 TEST_F(DocumentSymbolsTest, ExternSymbol) {
+  FS.Files["foo.h"] = R"cpp(
+  extern int var;)cpp";
+
+  addFile(testPath("foo.h"), FS.Files["foo.h"]);
   std::string FilePath = testPath("foo.cpp");
-  addFile(testPath("foo.h"), R"cpp(
-  extern int var;
-  )cpp");
   addFile(FilePath, R"cpp(
-  #include "foo.h"
-  )cpp");
+  #include "foo.h")cpp");
 
   EXPECT_THAT(getSymbols(FilePath), IsEmpty());
 }
@@ -488,19 +486,17 @@
 }
 
 TEST_F(DocumentSymbolsTest, InHeaderFile) {
-  addFile(testPath("bar.h"), R"cpp(
-  int foo() {
-  }
-  )cpp");
-  std::string FilePath = testPath("foo.h");
-  addFile(FilePath, R"cpp(
+  FS.Files["bar.h"] = R"cpp(
+  int foo() {})cpp";
+  FS.Files["foo.h"] = R"cpp(
   #include "bar.h"
-  int test() {
-  }
-  )cpp");
+  int test() {})cpp";
+
+  std::string FilePath = testPath("foo.h");
+  addFile(testPath("bar.h"), FS.Files["bar.h"]);
+  addFile(FilePath, FS.Files["foo.h"]);
   addFile(testPath("foo.cpp"), R"cpp(
-  #include "foo.h"
-  )cpp");
+  #include "foo.h")cpp");
   EXPECT

[PATCH] D82470: [OpenMP][IRBuilder] Support nested parallel regions

2020-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D82470#2116581 , @SouraVX wrote:

> Overall this seems great Thanks! I have one minor concern:
>  This patch seems to do 2 things: Support for nested parallel regions(which 
> was crashing earlier) and some infrastructure change(introducing 
> AllocBuilder..).
>  I'm not sure of this, but is it possible to separate these as 2( or more) 
> patches ? 1 for Nested parallel region support and other patch as a 
> infrastructure change ?


I'll try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470



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


[PATCH] D82089: [clang-tidy] modernize-loop-convert reverse iteration support

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 273913.
njames93 added a comment.

Rebased inline with new enum handling added in D82188 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82089

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp
@@ -0,0 +1,120 @@
+// RUN: %check_clang_tidy -std=c++20 -check-suffix=RANGES %s modernize-loop-convert %t
+
+// RUN: %check_clang_tidy -check-suffix=CUSTOM %s modernize-loop-convert %t -- \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:   {key: modernize-loop-convert.MakeReverseRangeFunction, value: 'llvm::reverse'}, \
+// RUN:   {key: modernize-loop-convert.MakeReverseRangeHeader, value: 'llvm/ADT/STLExtras.h'}]}"
+
+// Ensure the check doesn't transform reverse loops when not in c++20 mode or
+// when UseCxx20ReverseRanges has been disabled
+// RUN: clang-tidy %s -checks=-*,modernize-loop-convert -- -std=c++17 | count 0
+
+// RUN: clang-tidy %s -checks=-*,modernize-loop-convert -config="{CheckOptions: \
+// RUN: [{key: modernize-loop-convert.UseCxx20ReverseRanges, value: 'false'}] \
+// RUN: }" -- -std=c++20 | count 0
+
+// RUN: %check_clang_tidy -check-suffix=CUSTOM-NO-HEADER %s modernize-loop-convert %t -- \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:   {key: modernize-loop-convert.MakeReverseRangeFunction, value: 'globalReverse'}]}"
+
+// Ensure we get a warning if we only supply one of the required reverse range arguments.
+// RUN: %check_clang_tidy -check-suffix=BAD-CUSTOM %s modernize-loop-convert %t -- \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:   {key: modernize-loop-convert.MakeReverseRangeHeader, value: 'ranges/v3/views/reverse.hpp'}]}"
+
+// CHECK-MESSAGES-BAD-CUSTOM: warning: modernize-loop-convert: 'MakeReverseRangeHeader' is set but 'MakeReverseRangeFunction' is not, disabling reverse loop transformation
+
+// Make sure appropiate headers are included
+// CHECK-FIXES-RANGES: #include 
+// CHECK-FIXES-CUSTOM: #include "llvm/ADT/STLExtras.h"
+
+// Make sure no header is included in this example
+// CHECK-FIXES-CUSTOM-NO-HEADER-NOT: #include
+
+template 
+struct reversable {
+  using iterator = T *;
+  using const_iterator = const T *;
+
+  iterator begin();
+  iterator end();
+  iterator rbegin();
+  iterator rend();
+
+  const_iterator begin() const;
+  const_iterator end() const;
+  const_iterator rbegin() const;
+  const_iterator rend() const;
+
+  const_iterator cbegin() const;
+  const_iterator cend() const;
+  const_iterator crbegin() const;
+  const_iterator crend() const;
+};
+
+template 
+void observe(const T &);
+template 
+void mutate(T &);
+
+void constContainer(const reversable &Numbers) {
+  // CHECK-MESSAGES-RANGES: :[[@LINE+3]]:3: warning: use range-based for loop instead
+  // CHECK-MESSAGES-CUSTOM: :[[@LINE+2]]:3: warning: use range-based for loop instead
+  // CHECK-MESSAGES-CUSTOM-NO-HEADER: :[[@LINE+1]]:3: warning: use range-based for loop instead
+  for (auto I = Numbers.rbegin(), E = Numbers.rend(); I != E; ++I) {
+observe(*I);
+//  CHECK-FIXES-RANGES: for (int Number : std::ranges::reverse_view(Numbers)) {
+// CHECK-FIXES-RANGES-NEXT: observe(Number);
+//  CHECK-FIXES-CUSTOM: for (int Number : llvm::reverse(Numbers)) {
+// CHECK-FIXES-CUSTOM-NEXT: observe(Number);
+//  CHECK-FIXES-CUSTOM-NO-HEADER: for (int Number : globalReverse(Numbers)) {
+// CHECK-FIXES-CUSTOM-NO-HEADER-NEXT: observe(Number);
+  }
+  // CHECK-MESSAGES-RANGES: :[[@LINE+3]]:3: warning: use range-based for loop instead
+  // CHECK-MESSAGES-CUSTOM: :[[@LINE+2]]:3: warning: use range-based for loop instead
+  // CHECK-MESSAGES-CUSTOM-NO-HEADER: :[[@LINE+1]]:3: warning: use range-based for loop instead
+  for (auto I = Numbers.crbegin(), E = Numbers.crend(); I != E; ++I) {
+observe(*I);
+//  CHECK-FIXES-RANGES: for (int Number : std::ranges::reverse_view(Numbers)) {
+// CHECK-FIXES-RANGES-NEXT: observe(Number);
+//  CHECK-FIXES-CUSTOM: for (int Number : llvm::reverse(Numbers)) {
+// CHECK-FIXES-CUSTOM-NEXT: observe(Number);
+//  CHECK-FIXES-CUSTOM-NO-HEADER: for (int Number : globalReverse(Numbers)) {
+// CHECK-FIXES-CUSTOM-NO-HEADER-NEXT: observe(Number);
+  }
+
+  // Ensure these bad loops aren't transformed.
+  for (auto I = Numbers.rbegin(), E = Numbers.end(); I != E; ++I) {
+observe

[PATCH] D82314: [Coroutines] Optimize the lifespan of temporary co_await object

2020-06-29 Thread Xun Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc8755b6378c2: [Coroutines] Optimize the lifespan of 
temporary co_await object (authored by lxfind).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82314

Files:
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/coro-split-02.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime.ll

Index: llvm/test/Transforms/Coroutines/coro-split-sink-lifetime.ll
===
--- llvm/test/Transforms/Coroutines/coro-split-sink-lifetime.ll
+++ llvm/test/Transforms/Coroutines/coro-split-sink-lifetime.ll
@@ -1,6 +1,5 @@
-; Tests that coro-split can handle the case when a code after coro.suspend uses
-; a value produces between coro.save and coro.suspend (%Result.i19)
-; and checks whether stray coro.saves are properly removed
+; Tests that coro-split will optimize the lifetime.start maker of each local variable,
+; sink them to the places closest to the actual use.
 ; RUN: opt < %s -coro-split -S | FileCheck %s
 ; RUN: opt < %s -passes=coro-split -S | FileCheck %s
 
@@ -15,6 +14,9 @@
 entry:
   %ref.tmp7 = alloca %"struct.lean_future::Awaiter", align 8
   %testval = alloca i32
+  %cast = bitcast i32* %testval to i8*
+  ; lifetime of %testval starts here, but not used until await.ready.
+  call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
   %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
   %alloc = call i8* @malloc(i64 16) #3
   %vFrame = call noalias nonnull i8* @llvm.coro.begin(token %id, i8* %alloc)
@@ -29,8 +31,8 @@
 await.ready:
   %StrayCoroSave = call token @llvm.coro.save(i8* null)
   %val = load i32, i32* %Result.i19
-  %cast = bitcast i32* %testval to i8*
-  call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
+  %test = load i32, i32* %testval
+  call void @print(i32 %test)
   call void @llvm.lifetime.end.p0i8(i64 4, i8*  %cast)
   call void @print(i32 %val)
   br label %exit
@@ -40,14 +42,15 @@
 }
 
 ; CHECK-LABEL: @a.resume(
-; CHECK: %testval = alloca i32
-; CHECK: getelementptr inbounds %a.Frame
+; CHECK: %testval = alloca i32, align 4
+; CHECK-NEXT:getelementptr inbounds %a.Frame
 ; CHECK-NEXT:getelementptr inbounds %"struct.lean_future::Awaiter"
-; CHECK-NOT: call token @llvm.coro.save(i8* null)
+; CHECK-NEXT:%cast1 = bitcast i32* %testval to i8*
 ; CHECK-NEXT:%val = load i32, i32* %Result
-; CHECK-NEXT:%cast = bitcast i32* %testval to i8*
-; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
-; CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 4, i8* %cast)
+; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast1)
+; CHECK-NEXT:%test = load i32, i32* %testval
+; CHECK-NEXT:call void @print(i32 %test)
+; CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 4, i8* %cast1)
 ; CHECK-NEXT:call void @print(i32 %val)
 ; CHECK-NEXT:ret void
 
Index: llvm/test/Transforms/Coroutines/coro-split-02.ll
===
--- llvm/test/Transforms/Coroutines/coro-split-02.ll
+++ llvm/test/Transforms/Coroutines/coro-split-02.ll
@@ -31,6 +31,8 @@
   %val = load i32, i32* %Result.i19
   %cast = bitcast i32* %testval to i8*
   call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
+  %test = load i32, i32* %testval
+  call void @print(i32 %test)
   call void @llvm.lifetime.end.p0i8(i64 4, i8*  %cast)
   call void @print(i32 %val)
   br label %exit
@@ -47,6 +49,8 @@
 ; CHECK-NEXT:%val = load i32, i32* %Result
 ; CHECK-NEXT:%cast = bitcast i32* %testval to i8*
 ; CHECK-NEXT:call void @llvm.lifetime.start.p0i8(i64 4, i8* %cast)
+; CHECK-NEXT:%test = load i32, i32* %testval
+; CHECK-NEXT:call void @print(i32 %test)
 ; CHECK-NEXT:call void @llvm.lifetime.end.p0i8(i64 4, i8* %cast)
 ; CHECK-NEXT:call void @print(i32 %val)
 ; CHECK-NEXT:ret void
Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -75,7 +75,7 @@
 
 namespace {
 
-/// A little helper class for building 
+/// A little helper class for building
 class CoroCloner {
 public:
   enum class Kind {
@@ -563,7 +563,7 @@
   // In the original function, the AllocaSpillBlock is a block immediately
   // following the allocation of the frame object which defines GEPs for
   // all the allocas that have been moved into the frame, and it ends by
-  // branching to the original beginning of the coroutine.  Make this 
+  // branching to the original beginning of the coroutine.  Make this
   // the entry block of the cloned function.
   auto *Entry = cast(VMap[Shape.AllocaSpillBlock]);
   auto *OldEntry = &NewF->getEntryBlock();
@@ -1239,6 +1239,103 

[PATCH] D82722: [OpenMP][IRBuilder] Support nested parallel regions

2020-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: anchu-rajendran, kiranktp, fghanim.
Herald added a subscriber: rogfer01.
Herald added projects: clang, LLVM.
jdoerfert added a child revision: D82470: [OpenMP][IRBuilder] Support allocas 
in nested parallel regions.

During code generation we might change/add basic blocks so keeping a
list of them is fairly easy to break. Nested parallel regions were
enough. The new scheme does recompute the list of blocks to be outlined
once it is needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82722

Files:
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/irbuilder_nested_openmp_parallel_empty.c
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -128,13 +128,16 @@
 void OpenMPIRBuilder::initialize() { initializeTypes(M); }
 
 void OpenMPIRBuilder::finalize() {
+  SmallPtrSet ParallelRegionBlockSet;
+  SmallVector Blocks;
   for (OutlineInfo &OI : OutlineInfos) {
-assert(!OI.Blocks.empty() &&
-   "Outlined regions should have at least a single block!");
-BasicBlock *RegEntryBB = OI.Blocks.front();
-Function *OuterFn = RegEntryBB->getParent();
+ParallelRegionBlockSet.clear();
+Blocks.clear();
+OI.collectBlocks(ParallelRegionBlockSet, Blocks);
+
+Function *OuterFn = OI.EntryBB->getParent();
 CodeExtractorAnalysisCache CEAC(*OuterFn);
-CodeExtractor Extractor(OI.Blocks, /* DominatorTree */ nullptr,
+CodeExtractor Extractor(Blocks, /* DominatorTree */ nullptr,
 /* AggregateArgs */ false,
 /* BlockFrequencyInfo */ nullptr,
 /* BranchProbabilityInfo */ nullptr,
@@ -144,6 +147,8 @@
 /* Suffix */ ".omp_par");
 
 LLVM_DEBUG(dbgs() << "Before outlining: " << *OuterFn << "\n");
+LLVM_DEBUG(dbgs() << "Entry " << OI.EntryBB->getName()
+  << " Exit: " << OI.ExitBB->getName() << "\n");
 assert(Extractor.isEligible() &&
"Expected OpenMP outlining to be possible!");
 
@@ -163,12 +168,12 @@
 // made our own entry block after all.
 {
   BasicBlock &ArtificialEntry = OutlinedFn->getEntryBlock();
-  assert(ArtificialEntry.getUniqueSuccessor() == RegEntryBB);
-  assert(RegEntryBB->getUniquePredecessor() == &ArtificialEntry);
-  RegEntryBB->moveBefore(&ArtificialEntry);
+  assert(ArtificialEntry.getUniqueSuccessor() == OI.EntryBB);
+  assert(OI.EntryBB->getUniquePredecessor() == &ArtificialEntry);
+  OI.EntryBB->moveBefore(&ArtificialEntry);
   ArtificialEntry.eraseFromParent();
 }
-assert(&OutlinedFn->getEntryBlock() == RegEntryBB);
+assert(&OutlinedFn->getEntryBlock() == OI.EntryBB);
 assert(OutlinedFn && OutlinedFn->getNumUses() == 1);
 
 // Run a user callback, e.g. to add attributes.
@@ -618,20 +623,12 @@
   InsertPointTy PreFiniIP(PRegPreFiniBB, PRegPreFiniTI->getIterator());
   FiniCB(PreFiniIP);
 
-  SmallPtrSet ParallelRegionBlockSet;
-  SmallVector Worklist;
-  ParallelRegionBlockSet.insert(PRegEntryBB);
-  ParallelRegionBlockSet.insert(PRegExitBB);
+  OI.EntryBB = PRegEntryBB;
+  OI.ExitBB = PRegExitBB;
 
-  // Collect all blocks in-between PRegEntryBB and PRegExitBB.
-  Worklist.push_back(PRegEntryBB);
-  while (!Worklist.empty()) {
-BasicBlock *BB = Worklist.pop_back_val();
-OI.Blocks.push_back(BB);
-for (BasicBlock *SuccBB : successors(BB))
-  if (ParallelRegionBlockSet.insert(SuccBB).second)
-Worklist.push_back(SuccBB);
-  }
+  SmallPtrSet ParallelRegionBlockSet;
+  SmallVector Blocks;
+  OI.collectBlocks(ParallelRegionBlockSet, Blocks);
 
   // Ensure a single exit node for the outlined region by creating one.
   // We might have multiple incoming edges to the exit now due to finalizations,
@@ -639,10 +636,10 @@
   BasicBlock *PRegOutlinedExitBB = PRegExitBB;
   PRegExitBB = SplitBlock(PRegExitBB, &*PRegExitBB->getFirstInsertionPt());
   PRegOutlinedExitBB->setName("omp.par.outlined.exit");
-  OI.Blocks.push_back(PRegOutlinedExitBB);
+  Blocks.push_back(PRegOutlinedExitBB);
 
   CodeExtractorAnalysisCache CEAC(*OuterFn);
-  CodeExtractor Extractor(OI.Blocks, /* DominatorTree */ nullptr,
+  CodeExtractor Extractor(Blocks, /* DominatorTree */ nullptr,
   /* AggregateArgs */ false,
   /* BlockFrequencyInfo */ nullptr,
   /* BranchProbabilityInfo */ nullptr,
@@ -698,7 +695,7 @@
 
   LLVM_DEBUG(dbgs() << "After  privatization: " << *OuterFn << "\n");
   LLVM_DEBUG({
-for (auto *BB : OI.Blocks)
+for (auto *BB : Blocks)
   dbgs() << " PBR: " << BB->getName() << "\n";
   });
 
@@ -996,3 +993,20 @@
   std::string Name = g

[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb9306fd042ce: [clang-tidy] Reworked enum options 
handling(again) (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeSorter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -6,6 +6,20 @@
 
 namespace clang {
 namespace tidy {
+
+enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
+
+template <> struct OptionEnumMapping {
+  static llvm::ArrayRef> getEnumMapping() {
+static constexpr std::pair Mapping[] = {
+{Colours::Red, "Red"},   {Colours::Orange, "Orange"},
+{Colours::Yellow, "Yellow"}, {Colours::Green, "Green"},
+{Colours::Blue, "Blue"}, {Colours::Indigo, "Indigo"},
+{Colours::Violet, "Violet"}};
+return makeArrayRef(Mapping);
+  }
+};
+
 namespace test {
 
 TEST(ParseLineFilter, EmptyFilter) {
@@ -209,15 +223,6 @@
 }
 
 TEST(ValidConfiguration, ValidEnumOptions) {
-
-  enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
-  static constexpr std::pair Mapping[] = {
-  {"Red", Colours::Red},   {"Orange", Colours::Orange},
-  {"Yellow", Colours::Yellow}, {"Green", Colours::Green},
-  {"Blue", Colours::Blue}, {"Indigo", Colours::Indigo},
-  {"Violet", Colours::Violet}};
-  static const auto Map = makeArrayRef(Mapping);
-
   ClangTidyOptions Options;
   auto &CheckOptions = Options.CheckOptions;
 
@@ -237,29 +242,30 @@
 #define CHECK_ERROR_ENUM(Name, Expected)   \
   CHECK_ERROR(Name, UnparseableEnumOptionError, Expected)
 
-  CHECK_VAL(TestCheck.getLocal("Valid", Map), Colours::Red);
-  CHECK_VAL(TestCheck.getGlobal("GlobalValid", Map), Colours::Violet);
-  CHECK_VAL(TestCheck.getLocal("ValidWrongCase", Map, /*IgnoreCase*/ true),
-Colours::Red);
+  CHECK_VAL(TestCheck.getIntLocal("Valid"), Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValid"), Colours::Violet);
   CHECK_VAL(
-  TestCheck.getGlobal("GlobalValidWrongCase", Map, /*IgnoreCase*/ true),
-  Colours::Violet);
-  CHECK_ERROR_ENUM(TestCheck.getLocal("Invalid", Map),
+  TestCheck.getIntLocal("ValidWrongCase", /*IgnoreCase*/ true),
+  Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValidWrongCase",
+/*IgnoreCase*/ true),
+Colours::Violet);
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("Invalid"),
"invalid configuration value "
"'Scarlet' for option 'test.Invalid'");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("ValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("ValidWrongCase"),
"invalid configuration value 'rED' for option "
"'test.ValidWrongCase'; did you mean 'Red'?");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("NearMiss", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("NearMiss"),
"invalid configuration value 'Oragne' for option "
"'test.NearMiss'; did you mean 'Orange'?");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalInvalid", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalInvalid"),
"invalid configuration value "
"'Purple' for option 'GlobalInvalid'");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalValidWr

[PATCH] D82706: [ASTMatchers] Enhanced support for matchers taking Regex arguments

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 273960.
njames93 added a comment.

Moved the code to build and verify the regex out of the macro


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82706

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/include/clang/ASTMatchers/ASTMatchersMacros.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
  llvm/include/llvm/Support/Regex.h
  llvm/lib/Support/Regex.cpp

Index: llvm/lib/Support/Regex.cpp
===
--- llvm/lib/Support/Regex.cpp
+++ llvm/lib/Support/Regex.cpp
@@ -26,7 +26,7 @@
 
 Regex::Regex() : preg(nullptr), error(REG_BADPAT) {}
 
-Regex::Regex(StringRef regex, unsigned Flags) {
+Regex::Regex(StringRef regex, RegexFlags Flags) {
   unsigned flags = 0;
   preg = new llvm_regex();
   preg->re_endp = regex.end();
@@ -39,6 +39,9 @@
   error = llvm_regcomp(preg, regex.data(), flags|REG_PEND);
 }
 
+Regex::Regex(StringRef regex, unsigned Flags)
+: Regex(regex, static_cast(Flags)) {}
+
 Regex::Regex(Regex &®ex) {
   preg = regex.preg;
   error = regex.error;
Index: llvm/include/llvm/Support/Regex.h
===
--- llvm/include/llvm/Support/Regex.h
+++ llvm/include/llvm/Support/Regex.h
@@ -16,6 +16,7 @@
 #ifndef LLVM_SUPPORT_REGEX_H
 #define LLVM_SUPPORT_REGEX_H
 
+#include "llvm/ADT/BitmaskEnum.h"
 #include 
 
 struct llvm_regex;
@@ -26,20 +27,22 @@
 
   class Regex {
   public:
-enum {
-  NoFlags=0,
+enum RegexFlags : unsigned {
+  NoFlags = 0,
   /// Compile for matching that ignores upper/lower case distinctions.
-  IgnoreCase=1,
+  IgnoreCase = 1,
   /// Compile for newline-sensitive matching. With this flag '[^' bracket
   /// expressions and '.' never match newline. A ^ anchor matches the
   /// null string after any newline in the string in addition to its normal
   /// function, and the $ anchor matches the null string before any
   /// newline in the string in addition to its normal function.
-  Newline=2,
+  Newline = 2,
   /// By default, the POSIX extended regular expression (ERE) syntax is
   /// assumed. Pass this flag to turn on basic regular expressions (BRE)
   /// instead.
-  BasicRegex=4
+  BasicRegex = 4,
+
+  LLVM_MARK_AS_BITMASK_ENUM(BasicRegex)
 };
 
 Regex();
@@ -47,7 +50,8 @@
 ///
 /// \param Regex - referenced string is no longer needed after this
 /// constructor does finish.  Only its compiled form is kept stored.
-Regex(StringRef Regex, unsigned Flags = NoFlags);
+Regex(StringRef Regex, RegexFlags Flags = NoFlags);
+Regex(StringRef Regex, unsigned Flags);
 Regex(const Regex &) = delete;
 Regex &operator=(Regex regex) {
   std::swap(preg, regex.preg);
Index: clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -259,6 +259,15 @@
   EXPECT_TRUE(matches("unsigned X = sizeof(int);", MStmt));
   EXPECT_FALSE(matches("unsigned X = alignof(int);", MStmt));
 
+  Code =
+  R"query(namedDecl(matchesName("^::[ABC]*$", "IgnoreCase | BasicRegex")))query";
+  llvm::Optional MatchesName(
+  Parser::parseMatcherExpression(Code, nullptr, nullptr, &Error));
+  EXPECT_EQ("", Error.toStringFull());
+  M = MatchesName->unconditionalConvertTo();
+  EXPECT_TRUE(matches("unsigned AAACCBB;", M));
+  EXPECT_TRUE(matches("unsigned aaaccbb;", M));
+
   Code = "hasInitializer(\nbinaryOperator(hasLHS(\"A\")))";
   EXPECT_TRUE(!Parser::parseMatcherExpression(Code, &Error).hasValue());
   EXPECT_EQ("1:1: Error parsing argument 1 for matcher hasInitializer.\n"
@@ -348,6 +357,26 @@
 "1:14: Incorrect type for arg 1. (Expected = string) != (Actual = "
 "String)",
 ParseMatcherWithError(R"query(decl(hasAttr("unrelated")))query"));
+  EXPECT_EQ("1:1: Error parsing argument 1 for matcher namedDecl.\n"
+"1:11: Error building matcher matchesName.\n"
+"1:33: Incorrect type for arg 2. (Expected = string) != (Actual = "
+"String)",
+ParseMatcherWithError(
+R"query(namedDecl(matchesName("[ABC]*", "Ignorecase")))query"));
+  EXPECT_EQ(
+  "1:1: Error parsing argument 1 for matcher namedDecl.\n"
+  "1:11: Error building matcher matchesName.\n"
+  "1:33: Incorrect type for arg 2. 

[PATCH] D82470: [OpenMP][IRBuilder] Support allocas in nested parallel regions

2020-06-29 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 273961.
jdoerfert edited the summary of this revision.
jdoerfert added a comment.

restrict this to the alloca support


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -6,13 +6,14 @@
 //
 //===--===//
 
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/Function.h"
+#include "llvm/IR/InstIterator.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 #include "gtest/gtest.h"
@@ -402,6 +403,201 @@
   EXPECT_EQ(ForkCI->getArgOperand(3), F->arg_begin());
 }
 
+TEST_F(OpenMPIRBuilderTest, ParallelNested) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  unsigned NumInnerBodiesGenerated = 0;
+  unsigned NumOuterBodiesGenerated = 0;
+  unsigned NumFinalizationPoints = 0;
+
+  auto InnerBodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+BasicBlock &ContinuationIP) {
+++NumInnerBodiesGenerated;
+  };
+
+  auto PrivCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+Value &VPtr, Value *&ReplacementValue) -> InsertPointTy {
+// Trivial copy (=firstprivate).
+Builder.restoreIP(AllocaIP);
+Type *VTy = VPtr.getType()->getPointerElementType();
+Value *V = Builder.CreateLoad(VTy, &VPtr, VPtr.getName() + ".reload");
+ReplacementValue = Builder.CreateAlloca(VTy, 0, VPtr.getName() + ".copy");
+Builder.restoreIP(CodeGenIP);
+Builder.CreateStore(V, ReplacementValue);
+return CodeGenIP;
+  };
+
+  auto FiniCB = [&](InsertPointTy CodeGenIP) { ++NumFinalizationPoints; };
+
+  auto OuterBodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+BasicBlock &ContinuationIP) {
+++NumOuterBodiesGenerated;
+Builder.restoreIP(CodeGenIP);
+BasicBlock *CGBB = CodeGenIP.getBlock();
+BasicBlock *NewBB = SplitBlock(CGBB, &*CodeGenIP.getPoint());
+CGBB->getTerminator()->eraseFromParent();
+;
+
+IRBuilder<>::InsertPoint AfterIP = OMPBuilder.CreateParallel(
+InsertPointTy(CGBB, CGBB->end()), InnerBodyGenCB, PrivCB, FiniCB,
+nullptr, nullptr, OMP_PROC_BIND_default, false);
+
+Builder.restoreIP(AfterIP);
+Builder.CreateBr(NewBB);
+  };
+
+  IRBuilder<>::InsertPoint AfterIP =
+  OMPBuilder.CreateParallel(Loc, OuterBodyGenCB, PrivCB, FiniCB, nullptr,
+nullptr, OMP_PROC_BIND_default, false);
+
+  EXPECT_EQ(NumInnerBodiesGenerated, 1U);
+  EXPECT_EQ(NumOuterBodiesGenerated, 1U);
+  EXPECT_EQ(NumFinalizationPoints, 2U);
+
+  Builder.restoreIP(AfterIP);
+  Builder.CreateRetVoid();
+
+  OMPBuilder.finalize();
+
+  EXPECT_EQ(M->size(), 5U);
+  for (Function &OutlinedFn : *M) {
+if (F == &OutlinedFn || OutlinedFn.isDeclaration())
+  continue;
+EXPECT_FALSE(verifyModule(*M, &errs()));
+EXPECT_TRUE(OutlinedFn.hasFnAttribute(Attribute::NoUnwind));
+EXPECT_TRUE(OutlinedFn.hasFnAttribute(Attribute::NoRecurse));
+EXPECT_TRUE(OutlinedFn.hasParamAttribute(0, Attribute::NoAlias));
+EXPECT_TRUE(OutlinedFn.hasParamAttribute(1, Attribute::NoAlias));
+
+EXPECT_TRUE(OutlinedFn.hasInternalLinkage());
+EXPECT_EQ(OutlinedFn.arg_size(), 2U);
+
+EXPECT_EQ(OutlinedFn.getNumUses(), 1U);
+User *Usr = OutlinedFn.user_back();
+ASSERT_TRUE(isa(Usr));
+CallInst *ForkCI = dyn_cast(Usr->user_back());
+ASSERT_NE(ForkCI, nullptr);
+
+EXPECT_EQ(ForkCI->getCalledFunction()->getName(), "__kmpc_fork_call");
+EXPECT_EQ(ForkCI->getNumArgOperands(), 3U);
+EXPECT_TRUE(isa(ForkCI->getArgOperand(0)));
+EXPECT_EQ(ForkCI->getArgOperand(1),
+  ConstantInt::get(Type::getInt32Ty(Ctx), 0U));
+EXPECT_EQ(ForkCI->getArgOperand(2), Usr);
+  }
+}
+
+TEST_F(OpenMPIRBuilderTest, ParallelNested2Inner) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  unsigned NumInnerB

[PATCH] D82714: [clangd] Remove redundant `findRefs` calls. NFC.

2020-06-29 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 273928.
lh123 added a comment.

Rebase to head.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82714

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


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -993,7 +993,6 @@
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   auto Decls = targetDecl(N->ASTNode, Relations);
   if (!Decls.empty()) {
-auto Refs = findRefs({Decls.begin(), Decls.end()}, AST);
 // FIXME: we may get multiple DocumentHighlights with the same location
 // and different kinds, deduplicate them.
 for (const auto &Ref : findRefs({Decls.begin(), Decls.end()}, AST))


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -993,7 +993,6 @@
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   auto Decls = targetDecl(N->ASTNode, Relations);
   if (!Decls.empty()) {
-auto Refs = findRefs({Decls.begin(), Decls.end()}, AST);
 // FIXME: we may get multiple DocumentHighlights with the same location
 // and different kinds, deduplicate them.
 for (const auto &Ref : findRefs({Decls.begin(), Decls.end()}, AST))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82714: [clangd] Remove redundant `findRefs` calls. NFC.

2020-06-29 Thread liu hui via Phabricator via cfe-commits
lh123 created this revision.
lh123 added reviewers: sammccall, kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.
lh123 updated this revision to Diff 273928.
lh123 added a comment.

Rebase to head.


Remove redundant `findRefs` calls.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82714

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


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -993,7 +993,6 @@
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   auto Decls = targetDecl(N->ASTNode, Relations);
   if (!Decls.empty()) {
-auto Refs = findRefs({Decls.begin(), Decls.end()}, AST);
 // FIXME: we may get multiple DocumentHighlights with the same location
 // and different kinds, deduplicate them.
 for (const auto &Ref : findRefs({Decls.begin(), Decls.end()}, AST))


Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -993,7 +993,6 @@
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   auto Decls = targetDecl(N->ASTNode, Relations);
   if (!Decls.empty()) {
-auto Refs = findRefs({Decls.begin(), Decls.end()}, AST);
 // FIXME: we may get multiple DocumentHighlights with the same location
 // and different kinds, deduplicate them.
 for (const auto &Ref : findRefs({Decls.begin(), Decls.end()}, AST))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82711: [clang-tidy] Fix hicpp-named-paramater

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, jbcoe.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Currently this alias instantiates the readability-identifier-naming check, just 
swap it out to use the readability-named-paramater check.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82711

Files:
  clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp


Index: clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "../bugprone/UndelegatedConstructorCheck.h"
 #include "../bugprone/UseAfterMoveCheck.h"
 #include "../cppcoreguidelines/AvoidGotoCheck.h"
 #include "../cppcoreguidelines/NoMallocCheck.h"
@@ -20,7 +21,6 @@
 #include "../google/ExplicitConstructorCheck.h"
 #include "../misc/NewDeleteOverloadsCheck.h"
 #include "../misc/StaticAssertCheck.h"
-#include "../bugprone/UndelegatedConstructorCheck.h"
 #include "../modernize/AvoidCArraysCheck.h"
 #include "../modernize/DeprecatedHeadersCheck.h"
 #include "../modernize/UseAutoCheck.h"
@@ -34,7 +34,7 @@
 #include "../performance/NoexceptMoveConstructorCheck.h"
 #include "../readability/BracesAroundStatementsCheck.h"
 #include "../readability/FunctionSizeCheck.h"
-#include "../readability/IdentifierNamingCheck.h"
+#include "../readability/NamedParameterCheck.h"
 #include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "ExceptionBaseclassCheck.h"
 #include "MultiwayPathsCoveredCheck.h"
@@ -65,7 +65,7 @@
 "hicpp-explicit-conversions");
 CheckFactories.registerCheck(
 "hicpp-function-size");
-CheckFactories.registerCheck(
+CheckFactories.registerCheck(
 "hicpp-named-parameter");
 CheckFactories.registerCheck(
 "hicpp-invalid-access-moved");


Index: clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
+++ clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "../bugprone/UndelegatedConstructorCheck.h"
 #include "../bugprone/UseAfterMoveCheck.h"
 #include "../cppcoreguidelines/AvoidGotoCheck.h"
 #include "../cppcoreguidelines/NoMallocCheck.h"
@@ -20,7 +21,6 @@
 #include "../google/ExplicitConstructorCheck.h"
 #include "../misc/NewDeleteOverloadsCheck.h"
 #include "../misc/StaticAssertCheck.h"
-#include "../bugprone/UndelegatedConstructorCheck.h"
 #include "../modernize/AvoidCArraysCheck.h"
 #include "../modernize/DeprecatedHeadersCheck.h"
 #include "../modernize/UseAutoCheck.h"
@@ -34,7 +34,7 @@
 #include "../performance/NoexceptMoveConstructorCheck.h"
 #include "../readability/BracesAroundStatementsCheck.h"
 #include "../readability/FunctionSizeCheck.h"
-#include "../readability/IdentifierNamingCheck.h"
+#include "../readability/NamedParameterCheck.h"
 #include "../readability/UppercaseLiteralSuffixCheck.h"
 #include "ExceptionBaseclassCheck.h"
 #include "MultiwayPathsCoveredCheck.h"
@@ -65,7 +65,7 @@
 "hicpp-explicit-conversions");
 CheckFactories.registerCheck(
 "hicpp-function-size");
-CheckFactories.registerCheck(
+CheckFactories.registerCheck(
 "hicpp-named-parameter");
 CheckFactories.registerCheck(
 "hicpp-invalid-access-moved");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82314: [Coroutines] Optimize the lifespan of temporary co_await object

2020-06-29 Thread JunMa via Phabricator via cfe-commits
junparser accepted this revision.
junparser added a comment.
This revision is now accepted and ready to land.

LGTM, Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82314



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


[PATCH] D82650: [HIP] Set default FP_CONTRACT to ON

2020-06-29 Thread Daniil Fukalov via Phabricator via cfe-commits
dfukalov abandoned this revision.
dfukalov added a comment.

I was completely wrong


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82650



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


[PATCH] D82706: [ASTMatchers] Enhanced support for matchers taking Regex arguments

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 273957.
njames93 added a comment.

Include matcher name in error message when failing to build a regex


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82706

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/tools/dump_ast_matchers.py
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersMacros.h
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
  llvm/include/llvm/Support/Regex.h
  llvm/lib/Support/Regex.cpp

Index: llvm/lib/Support/Regex.cpp
===
--- llvm/lib/Support/Regex.cpp
+++ llvm/lib/Support/Regex.cpp
@@ -26,7 +26,7 @@
 
 Regex::Regex() : preg(nullptr), error(REG_BADPAT) {}
 
-Regex::Regex(StringRef regex, unsigned Flags) {
+Regex::Regex(StringRef regex, RegexFlags Flags) {
   unsigned flags = 0;
   preg = new llvm_regex();
   preg->re_endp = regex.end();
@@ -39,6 +39,9 @@
   error = llvm_regcomp(preg, regex.data(), flags|REG_PEND);
 }
 
+Regex::Regex(StringRef regex, unsigned Flags)
+: Regex(regex, static_cast(Flags)) {}
+
 Regex::Regex(Regex &®ex) {
   preg = regex.preg;
   error = regex.error;
Index: llvm/include/llvm/Support/Regex.h
===
--- llvm/include/llvm/Support/Regex.h
+++ llvm/include/llvm/Support/Regex.h
@@ -16,6 +16,7 @@
 #ifndef LLVM_SUPPORT_REGEX_H
 #define LLVM_SUPPORT_REGEX_H
 
+#include "llvm/ADT/BitmaskEnum.h"
 #include 
 
 struct llvm_regex;
@@ -26,20 +27,22 @@
 
   class Regex {
   public:
-enum {
-  NoFlags=0,
+enum RegexFlags : unsigned {
+  NoFlags = 0,
   /// Compile for matching that ignores upper/lower case distinctions.
-  IgnoreCase=1,
+  IgnoreCase = 1,
   /// Compile for newline-sensitive matching. With this flag '[^' bracket
   /// expressions and '.' never match newline. A ^ anchor matches the
   /// null string after any newline in the string in addition to its normal
   /// function, and the $ anchor matches the null string before any
   /// newline in the string in addition to its normal function.
-  Newline=2,
+  Newline = 2,
   /// By default, the POSIX extended regular expression (ERE) syntax is
   /// assumed. Pass this flag to turn on basic regular expressions (BRE)
   /// instead.
-  BasicRegex=4
+  BasicRegex = 4,
+
+  LLVM_MARK_AS_BITMASK_ENUM(BasicRegex)
 };
 
 Regex();
@@ -47,7 +50,8 @@
 ///
 /// \param Regex - referenced string is no longer needed after this
 /// constructor does finish.  Only its compiled form is kept stored.
-Regex(StringRef Regex, unsigned Flags = NoFlags);
+Regex(StringRef Regex, RegexFlags Flags = NoFlags);
+Regex(StringRef Regex, unsigned Flags);
 Regex(const Regex &) = delete;
 Regex &operator=(Regex regex) {
   std::swap(preg, regex.preg);
Index: clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -259,6 +259,15 @@
   EXPECT_TRUE(matches("unsigned X = sizeof(int);", MStmt));
   EXPECT_FALSE(matches("unsigned X = alignof(int);", MStmt));
 
+  Code =
+  R"query(namedDecl(matchesName("^::[ABC]*$", "IgnoreCase | BasicRegex")))query";
+  llvm::Optional MatchesName(
+  Parser::parseMatcherExpression(Code, nullptr, nullptr, &Error));
+  EXPECT_EQ("", Error.toStringFull());
+  M = MatchesName->unconditionalConvertTo();
+  EXPECT_TRUE(matches("unsigned AAACCBB;", M));
+  EXPECT_TRUE(matches("unsigned aaaccbb;", M));
+
   Code = "hasInitializer(\nbinaryOperator(hasLHS(\"A\")))";
   EXPECT_TRUE(!Parser::parseMatcherExpression(Code, &Error).hasValue());
   EXPECT_EQ("1:1: Error parsing argument 1 for matcher hasInitializer.\n"
@@ -348,6 +357,26 @@
 "1:14: Incorrect type for arg 1. (Expected = string) != (Actual = "
 "String)",
 ParseMatcherWithError(R"query(decl(hasAttr("unrelated")))query"));
+  EXPECT_EQ("1:1: Error parsing argument 1 for matcher namedDecl.\n"
+"1:11: Error building matcher matchesName.\n"
+"1:33: Incorrect type for arg 2. (Expected = string) != (Actual = "
+"String)",
+ParseMatcherWithError(
+R"query(namedDecl(matchesName("[ABC]*", "Ignorecase")))query"));
+  EXPECT_EQ(
+  "1:1: Error parsing argument 1 for matcher namedDecl.\n"
+  "1:11: Error building matcher matchesName.\n"
+  "1:33: Incorrect type for arg 2. (Expected = string) != (Actual = "
+  "String)",
+  ParseMatcherWithError(
+  R"qu

[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

It's the only change on the blame list, things pass consistently before the 
change, and fail consistently after it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82722: [OpenMP][IRBuilder] Support nested parallel regions

2020-06-29 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim added a comment.

Thanks for working on this. LGTM.
Did you make any changes other than splitting from D82470 
 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82722



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-06-29 Thread Logan Smith via Phabricator via cfe-commits
logan-5 created this revision.
logan-5 added a reviewer: rsmith.
logan-5 added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds `-Wsuggest-override`, which allows for more aggressive 
enforcement of modern C++ best practices, as well as better compatibility with 
gcc, which has had its own `-Wsuggest-override` since version 5.1.

Clang already has `-Winconsistent-missing-override`, which only warns in the 
case where there is at least one function already marked `override` in a class. 
This warning strengthens that warning by suggesting the `override` keyword 
regardless of whether it is already present anywhere.

The text between suggest-override and inconsistent-missing-override is now 
shared, using `TextSubstitution` for the entire diagnostic text. I'm not sure 
if there is a better way to accomplish this.

This patch as written behaves strangely with 
`-Wno-inconsistent-missing-override -Wsuggest-override`. In that case, a 
warning is //only// generated if there are no overrides already marked (because 
inconsistent-missing-override 'wins' when choosing which diagnostic to emit). 
However, this is a fairly nonsensical use case, so in my opinion it's fine.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

Index: clang/test/SemaCXX/warn-suggest-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-override
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-override
+
+class A {
+ public:
+  ~A() {}
+  void run() {}
+};
+
+class B : public A {
+ public:
+  ~B() {}
+  void run() {}
+};
+
+class C {
+ public:
+  virtual void run() {} // expected-note 2{{overridden virtual function is here}}
+  virtual ~C() {}  // expected-note 2{{overridden virtual function is here}}
+};
+
+class D : public C {
+ public:
+  void run() {}
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  ~D() {}
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 'override'}}
+};
+
+class E : public C {
+ public:
+  virtual void run() {}
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  virtual ~E() {}
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 'override'}}
+};
+
+class F : public C {
+ public:
+  void run() override {}
+  ~F() override {}
+};
+
+class G : public C {
+ public:
+  void run() final {}
+  ~G() final {}
+};
Index: clang/test/SemaCXX/warn-suggest-destructor-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-destructor-override
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
+class A {
+ public:
+  ~A() {}
+  void virtual run() {}
+};
+
+class B : public A {
+ public:
+  ~B() {}
+};
+
+class C {
+ public:
+  virtual void run() {}
+  virtual ~C() {}  // expected-note 2{{overridden virtual function is here}}
+};
+
+class D : public C {
+ public:
+  void run() {}
+  ~D() {}
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 'override'}}
+};
+
+class E : public C {
+ public:
+  void run() {}
+  virtual ~E() {}
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 'override'}}
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3045,7 +3045,7 @@
   << MD->getDeclName();
 }
 
-void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) {
+void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent) {
   if (D->isInvalidDecl() || D->hasAttr())
 return;
   CXXMethodDecl *MD = dyn_cast(D);
@@ -3061,12 +3061,19 @@
   return;
 
   if (MD->size_overridden_methods() > 0) {
-unsigned DiagID = isa(MD)
-  ? diag::warn_destructor_marked_not_override_overriding
-  : diag::warn_function_marked_not_override_overriding;
-Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+auto EmitDiag = [this, MD](unsigned DiagID) {
+  Diag(MD->getLocation(), DiagID) << MD->getDeclName();
+  const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
+  Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+};
+if (Inconsistent)
+  EmitDiag(isa(MD)
+  ? diag::warn_inconsistent_destructor_marked_not_override_overriding
+ 

[PATCH] D82470: [OpenMP][IRBuilder] Support allocas in nested parallel regions

2020-06-29 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX accepted this revision.
SouraVX added a comment.
This revision is now accepted and ready to land.

In D82470#2118814 , @jdoerfert wrote:

> In D82470#2116581 , @SouraVX wrote:
>
> > Overall this seems great Thanks! I have one minor concern:
> >  This patch seems to do 2 things: Support for nested parallel regions(which 
> > was crashing earlier) and some infrastructure change(introducing 
> > AllocBuilder..).
> >  I'm not sure of this, but is it possible to separate these as 2( or more) 
> > patches ? 1 for Nested parallel region support and other patch as a 
> > infrastructure change ?
>
>
> I'll try.


Thanks a lot for separating this :)  both LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470



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


[PATCH] D82548: [CodeComplete] Add code completion for `delete` and `default` specifier.

2020-06-29 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 273925.
lh123 edited the summary of this revision.
lh123 added a comment.

Rebase to head.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82548

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/delete-default-specifier.cpp

Index: clang/test/CodeCompletion/delete-default-specifier.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/delete-default-specifier.cpp
@@ -0,0 +1,24 @@
+struct A {
+  A() = default;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:2:9 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: COMPLETION: default
+  // CHECK-CC1-NEXT: COMPLETION: delete
+  A(const A &);
+};
+
+A::A(const A &) = default;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:9:19 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: COMPLETION: default
+// CHECK-CC2-NEXT: COMPLETION: delete
+
+struct B {
+  void test() = delete;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:15:17 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+  // CHECK-CC3: COMPLETION: default
+  // CHECK-CC3-NEXT: COMPLETION: delete
+};
+
+void test() = delete;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:21:15 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: COMPLETION: default
+// CHECK-CC4-NEXT: COMPLETION: delete
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -6261,6 +6261,25 @@
 Results.data(), Results.size());
 }
 
+void Sema::CodeCompleteFunctionDeleteAndDefaultSpecifier() {
+  if (!LangOpts.CPlusPlus11) {
+return;
+  }
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_Other);
+  Results.EnterNewScope();
+  // FIXME(liuhui): Ideally, we should only provide `default` completion for
+  // special functions.
+  Results.AddResult("default");
+  // FIXME(liuhui): Ideally, we should only provide `delete` completion for the
+  // first function declaration.
+  Results.AddResult("delete");
+  Results.ExitScope();
+  HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+Results.data(), Results.size());
+}
+
 /// Macro that optionally prepends an "@" to the string literal passed in via
 /// Keyword, depending on whether NeedAt is true or false.
 #define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -2713,6 +2713,11 @@
   DefinitionKind = FDK_Defaulted;
 else if (KW.is(tok::kw_delete))
   DefinitionKind = FDK_Deleted;
+else if (KW.is(tok::code_completion)) {
+  Actions.CodeCompleteFunctionDeleteAndDefaultSpecifier();
+  cutOffParsing();
+  return nullptr;
+}
   }
 }
 DeclaratorInfo.setFunctionDefinitionKind(DefinitionKind);
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -1898,46 +1898,52 @@
   }
 
   // Check to see if we have a function *definition* which must have a body.
-  if (D.isFunctionDeclarator() &&
-  // Look at the next token to make sure that this isn't a function
-  // declaration.  We have to check this because __attribute__ might be the
-  // start of a function definition in GCC-extended K&R C.
-  !isDeclarationAfterDeclarator()) {
-
-// Function definitions are only allowed at file scope and in C++ classes.
-// The C++ inline method definition case is handled elsewhere, so we only
-// need to handle the file scope definition case.
-if (Context == DeclaratorContext::FileContext) {
-  if (isStartOfFunctionDefinition(D)) {
-if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
-  Diag(Tok, diag::err_function_declared_typedef);
-
-  // Recover by treating the 'typedef' as spurious.
-  DS.ClearStorageClassSpecs();
-}
+  if (D.isFunctionDeclarator()) {
+if (Tok.is(tok::equal) && NextToken().is(tok::code_completion)) {
+  Actions.CodeCompleteFunctionDeleteAndDefaultSpecifier();
+  cutOffParsing();
+  return nullptr;
+}
+// Look at the nex

[PATCH] D79677: [Clang][OpenMP][OMPBuilder] (1/4) Privatize `parallel` for `OMPBuilder`

2020-06-29 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added a comment.

Is the ordering of code generation for clauses important?
copyin -> firstprivate -> barrier -> private




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1673
 //
 // TODO: This defaults to shared right now.
 auto PrivCB = [](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,

Should this change in this patch?



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1729-1736
+  if (!OMP_Entry->getTerminator()) {
+OMP_Entry->getInstList().push_back(EntryBI);
+  } else if (Builder.GetInsertBlock()->getTerminator()) {
+EntryBI->dropAllReferences();
+EntryBI->deleteValue();
+  } else {
+Builder.Insert(EntryBI);

Nit: What do these three cases correspond to? A comment might be useful.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:1743
+  Builder.SetInsertPoint(&ContinuationBB);
+  PrivateScope.ForceCleanup();
+  Builder.Insert(ContTI);

Not a comment about this patch: While the context makes it clear, the name does 
not suggest that this function is emitting something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79677



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


[PATCH] D82548: [CodeComplete] Add code completion for `delete` and `default` specifier.

2020-06-29 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 273942.
lh123 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82548

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/CodeCompletion/delete-default-specifier.cpp

Index: clang/test/CodeCompletion/delete-default-specifier.cpp
===
--- /dev/null
+++ clang/test/CodeCompletion/delete-default-specifier.cpp
@@ -0,0 +1,24 @@
+struct A {
+  A() = default;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:2:9 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
+  // CHECK-CC1: COMPLETION: default
+  // CHECK-CC1-NEXT: COMPLETION: delete
+  A(const A &);
+};
+
+A::A(const A &) = default;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:9:19 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
+// CHECK-CC2: COMPLETION: default
+// CHECK-CC2-NEXT: COMPLETION: delete
+
+struct B {
+  void test() = delete;
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:15:17 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC3 %s
+  // CHECK-CC3: COMPLETION: default
+  // CHECK-CC3-NEXT: COMPLETION: delete
+};
+
+void test() = delete;
+// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:21:15 -std=gnu++11 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: COMPLETION: default
+// CHECK-CC4-NEXT: COMPLETION: delete
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -6261,6 +6261,25 @@
 Results.data(), Results.size());
 }
 
+void Sema::CodeCompleteFunctionDeleteAndDefaultSpecifier() {
+  if (!LangOpts.CPlusPlus11) {
+return;
+  }
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_Other);
+  Results.EnterNewScope();
+  // FIXME(liuhui): Ideally, we should only provide `default` completion for
+  // special functions.
+  Results.AddResult("default");
+  // FIXME(liuhui): Ideally, we should only provide `delete` completion for the
+  // first function declaration.
+  Results.AddResult("delete");
+  Results.ExitScope();
+  HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+Results.data(), Results.size());
+}
+
 /// Macro that optionally prepends an "@" to the string literal passed in via
 /// Keyword, depending on whether NeedAt is true or false.
 #define OBJC_AT_KEYWORD_NAME(NeedAt, Keyword) ((NeedAt) ? "@" Keyword : Keyword)
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -2713,6 +2713,11 @@
   DefinitionKind = FDK_Defaulted;
 else if (KW.is(tok::kw_delete))
   DefinitionKind = FDK_Deleted;
+else if (KW.is(tok::code_completion)) {
+  Actions.CodeCompleteFunctionDeleteAndDefaultSpecifier();
+  cutOffParsing();
+  return nullptr;
+}
   }
 }
 DeclaratorInfo.setFunctionDefinitionKind(DefinitionKind);
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -1898,46 +1898,52 @@
   }
 
   // Check to see if we have a function *definition* which must have a body.
-  if (D.isFunctionDeclarator() &&
-  // Look at the next token to make sure that this isn't a function
-  // declaration.  We have to check this because __attribute__ might be the
-  // start of a function definition in GCC-extended K&R C.
-  !isDeclarationAfterDeclarator()) {
-
-// Function definitions are only allowed at file scope and in C++ classes.
-// The C++ inline method definition case is handled elsewhere, so we only
-// need to handle the file scope definition case.
-if (Context == DeclaratorContext::FileContext) {
-  if (isStartOfFunctionDefinition(D)) {
-if (DS.getStorageClassSpec() == DeclSpec::SCS_typedef) {
-  Diag(Tok, diag::err_function_declared_typedef);
-
-  // Recover by treating the 'typedef' as spurious.
-  DS.ClearStorageClassSpecs();
-}
+  if (D.isFunctionDeclarator()) {
+if (Tok.is(tok::equal) && NextToken().is(tok::code_completion)) {
+  Actions.CodeCompleteFunctionDeleteAndDefaultSpecifier();
+  cutOffParsing();
+  return nullptr;
+}
+// Look at the next token to make sure that this isn't a function
+   

[PATCH] D82720: [clang-tidy] performance-faster-string-find string-view

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, sbenza, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Extend the default string like classes to include `std::basic_string_view`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82720

Files:
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst
  clang-tools-extra/test/clang-tidy/checkers/performance-faster-string-find.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-faster-string-find.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-faster-string-find.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-faster-string-find.cpp
@@ -1,7 +1,8 @@
-// RUN: %check_clang_tidy %s performance-faster-string-find %t -- \
+// RUN: %check_clang_tidy %s performance-faster-string-find %t
+// RUN: %check_clang_tidy -check-suffix=CUSTOM %s performance-faster-string-find %t -- \
 // RUN:   -config="{CheckOptions: \
 // RUN: [{key: performance-faster-string-find.StringLikeClasses, \
-// RUN:   value: 'std::basic_string; ::llvm::StringRef;'}]}" --
+// RUN:   value: '::llvm::StringRef;'}]}"
 
 namespace std {
 template 
@@ -17,6 +18,20 @@
 
 typedef basic_string string;
 typedef basic_string wstring;
+
+template 
+struct basic_string_view {
+  int find(const Char *, int = 0) const;
+  int find(const Char *, int, int) const;
+  int rfind(const Char *) const;
+  int find_first_of(const Char *) const;
+  int find_first_not_of(const Char *) const;
+  int find_last_of(const Char *) const;
+  int find_last_not_of(const Char *) const;
+};
+
+typedef basic_string_view string_view;
+typedef basic_string_view wstring_view;
 }  // namespace std
 
 namespace llvm {
@@ -75,11 +90,25 @@
   // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'find' called with a string literal
   // CHECK-FIXES: Str.find(L'\x3A9');
 
+  // std::string_view and std::wstring_view should work.
+  std::string_view StrView;
+  StrView.find("n");
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: 'find' called with a string literal
+  // CHECK-FIXES: StrView.find('n');
+  std::wstring_view WStrView;
+
+  WStrView.find(L"n");
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'find' called with a string literal
+  // CHECK-FIXES: WStrView.find(L'n');
+  WStrView.find(L"\x3A9");
+  // CHECK-MESSAGES: [[@LINE-1]]:17: warning: 'find' called with a string literal
+  // CHECK-FIXES: WStrView.find(L'\x3A9');
+
   // Also with other types, but only if it was specified in the options.
   llvm::StringRef sr;
   sr.find("x");
-  // CHECK-MESSAGES: [[@LINE-1]]:11: warning: 'find' called with a string literal
-  // CHECK-FIXES: sr.find('x');
+  // CHECK-MESSAGES-CUSTOM: [[@LINE-1]]:11: warning: 'find' called with a string literal
+  // CHECK-FIXES-CUSTOM: sr.find('x');
   NotStringRef nsr;
   nsr.find("x");
 }
Index: clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst
+++ clang-tools-extra/docs/clang-tidy/checks/performance-faster-string-find.rst
@@ -23,6 +23,6 @@
 .. option:: StringLikeClasses
 
Semicolon-separated list of names of string-like classes. By default only
-   ``std::basic_string`` is considered. The list of methods to consired is
-   fixed.
+   ``::std::basic_string`` and ``::std::basic_string_view`` are considered. 
+   The list of methods to consired is fixed.
 
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -195,6 +195,11 @@
 Changes in existing checks
 ^^
 
+- Improved :doc:'performance-faster-string-find
+  ` check.
+
+  Now checks ``std::basic_string_view`` by default.
+
 - Improved :doc:'readability-identifier-naming
   ` check.
 
Index: clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -51,7 +51,8 @@
  ClangTidyContext *Context)
 : ClangTidyCheck(Name, Context),
   StringLikeClasses(utils::options::parseStringList(
-  Options.get("StringLikeClasses", "std::basic_string"))) {}
+  Options.get("StringLikeClasses",
+  "::std::basic_string;::std::basic_string_view"))) {}
 
 void FasterStringFindCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "StringLikeClasse

[clang-tools-extra] b9306fd - [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-28T10:18:33+01:00
New Revision: b9306fd042ce1c11d84f05d2124dfdc65b8331fe

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

LOG: [clang-tidy] Reworked enum options handling(again)

Following on from D77085, I was never happy with the passing a mapping to the 
option get/store functions. This patch addresses this by using explicit 
specializations to handle the serializing and deserializing of enum options.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.h
clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/clang-tidy/utils/IncludeSorter.h
clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 7ddf054a21a9..39c049948809 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -158,7 +158,7 @@ void 
ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
 }
 
 llvm::Expected ClangTidyCheck::OptionsView::getEnumInt(
-StringRef LocalName, ArrayRef> Mapping,
+StringRef LocalName, ArrayRef> Mapping,
 bool CheckGlobal, bool IgnoreCase) {
   auto Iter = CheckOptions.find((NamePrefix + LocalName).str());
   if (CheckGlobal && Iter == CheckOptions.end())
@@ -171,19 +171,19 @@ llvm::Expected 
ClangTidyCheck::OptionsView::getEnumInt(
   unsigned EditDistance = -1;
   for (const auto &NameAndEnum : Mapping) {
 if (IgnoreCase) {
-  if (Value.equals_lower(NameAndEnum.first))
-return NameAndEnum.second;
-} else if (Value.equals(NameAndEnum.first)) {
-  return NameAndEnum.second;
-} else if (Value.equals_lower(NameAndEnum.first)) {
-  Closest = NameAndEnum.first;
+  if (Value.equals_lower(NameAndEnum.second))
+return NameAndEnum.first;
+} else if (Value.equals(NameAndEnum.second)) {
+  return NameAndEnum.first;
+} else if (Value.equals_lower(NameAndEnum.second)) {
+  Closest = NameAndEnum.second;
   EditDistance = 0;
   continue;
 }
-unsigned Distance = Value.edit_distance(NameAndEnum.first);
+unsigned Distance = Value.edit_distance(NameAndEnum.second);
 if (Distance < EditDistance) {
   EditDistance = Distance;
-  Closest = NameAndEnum.first;
+  Closest = NameAndEnum.second;
 }
   }
   if (EditDistance < 3)

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 84438c21a30b..84ad16c9eea8 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -27,6 +27,13 @@ class CompilerInstance;
 
 namespace tidy {
 
+/// This class should be specialized by any enum type that needs to be 
converted
+/// to and from an \ref llvm::StringRef.
+template  struct OptionEnumMapping {
+  // Specializations of this struct must implement this function.
+  static ArrayRef> getEnumMapping() = delete;
+};
+
 template  class OptionError : public llvm::ErrorInfo {
   std::error_code convertToErrorCode() const override {
 return llvm::inconvertibleErrorCode();
@@ -313,36 +320,38 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 }
 
 /// Read a named option from the ``Context`` and parse it as an
-/// enum type ``T`` using the \p Mapping provided. If \p IgnoreCase is set,
-/// it will search the mapping ignoring the case.
+/// enum type ``T``.
 ///
 /// Reads the option with the check-local name \p LocalName from the
 ///

[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:148
+if (InnerPointVal && InnerPointVal->isZeroConstant()) {
+  reportBug(C, Call);
+}

This doesn't seem to be guarded by `ShouldCheckSmartPtrDereference`.

Consider adding a LIT test for the flag to make sure we're not leaking our 
project to the public until it's ready ^.^ Say, you could make two run-lines in 
your test like this:
```
// RUN: %clang_analyze_cc1 -verify=expected -analyzer-config 
cplusplus.SmartPtr:CheckSmartPtrDereference=true \
// RUN: ...
// RUN: %clang_analyze_cc1 -verify=unexpected \
// RUN: ...

// unexpected-no-diagnostics
```
(see https://clang.llvm.org/doxygen/classclang_1_1VerifyDiagnosticConsumer.html 
for more fancy tricks with `-verify`)


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

https://reviews.llvm.org/D81315



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


[PATCH] D82731: [X86] Move frontend CPU feature initialization to a look up table based implementation.

2020-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, LuoYuanke, LiuChen3, echristo, 
FreddyYe.
Herald added subscribers: jfb, hiraditya.
Herald added projects: clang, LLVM.
craig.topper added a reviewer: erichkeane.

This replaces the switch statement implementation in the clang's
X86.cpp with a lookup table X86TargetParser.cpp.

I've used constexpr and copy of the FeatureBitset from
SubtargetFeature.h to store the features in a lookup table.
After the lookup the bitset is translated into strings for use
by the rest of the frontend code.

I had to modify the implementation of the FeatureBitset to avoid
bugs in libgcc's constexpr handling. It seems to not like the
same array entry to be used on the left side and right hand side
of an assignment or &= or |=. I've also used uint32_t instead of
uint64_t and sized based on the X86::CPU_FEATURE_MAX.

I've initialized the features for different CPUs outside of the
table so that they can be inherited from to express inheritance in
an adhoc way. This was one of the big limitations of the switch
where had resorted to labels and gotos.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82731

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/Preprocessor/predefined-arch-macros.c
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/include/llvm/Support/X86TargetParser.h
  llvm/lib/Support/X86TargetParser.cpp

Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -19,134 +19,333 @@
 
 namespace {
 
+/// Container class for CPU features.
+/// This is a constexpr reimplementation of a subset of std::bitset. It would be
+/// nice to use std::bitset directly, but it doesn't support constant
+/// initialization.
+class FeatureBitset {
+  static constexpr unsigned NUM_FEATURE_WORDS = X86::CPU_FEATURE_MAX + 31 / 32;
+
+  // This cannot be a std::array, operator[] is not constexpr until C++17.
+  uint32_t Bits[NUM_FEATURE_WORDS] = {};
+
+public:
+  constexpr FeatureBitset() = default;
+  constexpr FeatureBitset(std::initializer_list Init) {
+for (auto I : Init)
+  set(I);
+  }
+
+  constexpr FeatureBitset &set(unsigned I) {
+uint32_t NewBits = Bits[I / 32] | (uint32_t(1) << (I % 32));
+Bits[I / 32] = NewBits;
+return *this;
+  }
+
+  constexpr bool operator[](unsigned I) const {
+uint32_t Mask = uint32_t(1) << (I % 32);
+return (Bits[I / 32] & Mask) != 0;
+  }
+
+  constexpr FeatureBitset operator&(const FeatureBitset &RHS) const {
+FeatureBitset Result;
+for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I)
+  Result.Bits[I] = Bits[I] & RHS.Bits[I];
+return Result;
+  }
+
+  constexpr FeatureBitset operator|(const FeatureBitset &RHS) const {
+FeatureBitset Result;
+for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I)
+  Result.Bits[I] = Bits[I] | RHS.Bits[I];
+return Result;
+  }
+
+  constexpr FeatureBitset operator~() const {
+FeatureBitset Result;
+for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I)
+  Result.Bits[I] = ~Bits[I];
+return Result;
+  }
+};
+
 struct ProcInfo {
   StringLiteral Name;
   X86::CPUKind Kind;
   unsigned KeyFeature;
-  bool Is64Bit;
+  FeatureBitset Features;
 };
 
 } // end anonymous namespace
 
-#define PROC_64_BIT true
-#define PROC_32_BIT false
+#define X86_FEATURE(ENUM, STRING)  \
+  static constexpr FeatureBitset Feature##ENUM = {X86::FEATURE_##ENUM};
+#include "llvm/Support/X86TargetParser.def"
+
+// Pentium with MMX.
+static constexpr FeatureBitset FeaturesPentiumMMX =
+FeatureX87 | FeatureCMPXCHG8B | FeatureMMX;
+
+// Pentium 2 and 3.
+static constexpr FeatureBitset FeaturesPentium2 =
+FeatureX87 | FeatureCMPXCHG8B | FeatureMMX | FeatureFXSR;
+static constexpr FeatureBitset FeaturesPentium3 =
+FeaturesPentium2 | FeatureSSE;
+
+// Pentium 4 CPUs
+static constexpr FeatureBitset FeaturesPentium4 =
+FeaturesPentium3 | FeatureSSE2;
+static constexpr FeatureBitset FeaturesPrescott =
+FeaturesPentium4 | FeatureSSE3;
+static constexpr FeatureBitset FeaturesNocona =
+FeaturesPrescott | FeatureEM64T | FeatureCMPXCHG16B;
+
+// Basic 64-bit capable CPU.
+static constexpr FeatureBitset FeaturesX86_64 =
+FeaturesPentium4 | FeatureEM64T;
+
+// Intel Core CPUs
+static constexpr FeatureBitset FeaturesCore2 =
+FeaturesNocona | FeatureSAHF | FeatureSSSE3;
+static constexpr FeatureBitset FeaturesPenryn = FeaturesCore2 | FeatureSSE4_1;
+static constexpr FeatureBitset FeaturesNehalem =
+FeaturesPenryn | FeaturePOPCNT | FeatureSSE4_2;
+static constexpr FeatureBitset FeaturesWestmere =
+FeaturesNehalem | FeaturePCLMUL;
+static constexpr FeatureBitset FeaturesSandyBridge =
+FeaturesWestmere | FeatureAVX | FeatureXSAVE | FeatureXSAVEOPT;
+static constexpr Fe

[PATCH] D82562: Implement AVX ABI Warning/error

2020-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticFrontendKinds.td:246
+  "enabled changes the ABI">,
+  InGroup>;
+def err_avx_calling_convention : Error;

Should this be -Wpsabi to match gcc? I think that's what gcc called it.



Comment at: clang/lib/CodeGen/CGCall.cpp:4248
   const Decl *TargetDecl = Callee.getAbstractInfo().getCalleeDecl().getDecl();
-  if (const FunctionDecl *FD = dyn_cast_or_null(TargetDecl))
+  if (const FunctionDecl *FD = dyn_cast_or_null(TargetDecl)) {
 // We can only guarantee that a function is called from the correct

Wow that was a big comment for no curly's.



Comment at: clang/lib/CodeGen/CGCall.cpp:4259
 
+// Some architectures (such as x86_64) have the ABI changed based on
+// attribute-target/features. Give them a chance to diagnose.

nit should probably be x86-64. I think we only use underscore when we're 
already using - for something else like in the triple.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2493
+ SourceLocation CallLoc,
+ llvm::StringMap &CallerMap,
+ llvm::StringMap &CalleeMap, QualType Ty,

Should these maps be const? Which means you have to use find to do the lookups.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2554
+  if (checkAVXParam(CGM.getDiags(), CGM.getContext(), CallLoc, CallerMap,
+CalleeMap, Ty, /*isArgument*/ true))
+return;

isArgument->IsArgument



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2567
+  CalleeMap, Callee->getReturnType(),
+  /*isArgument*/ false);
+  }

Same here


Repository:
  rC Clang

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

https://reviews.llvm.org/D82562



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


[clang-tools-extra] bfd99be - [clang-tidy] Update lang restrictions on perf module

2020-06-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-28T15:18:08+01:00
New Revision: bfd99be0fc58fe644aff76d180b333e6d840126a

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

LOG: [clang-tidy] Update lang restrictions on perf module

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.h
clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.h
clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h
clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.h

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
index bb0a02f06fc6..a6216b230911 100644
--- a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -59,9 +59,6 @@ void 
FasterStringFindCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void FasterStringFindCheck::registerMatchers(MatchFinder *Finder) {
-  if (!getLangOpts().CPlusPlus)
-return;
-
   const auto SingleChar =
   expr(ignoringParenCasts(stringLiteral(hasSize(1)).bind("literal")));
   const auto StringFindFunctions =

diff  --git a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.h 
b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.h
index 7d46d06c375c..71a45705f1e8 100644
--- a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.h
@@ -27,6 +27,9 @@ namespace performance {
 class FasterStringFindCheck : public ClangTidyCheck {
 public:
   FasterStringFindCheck(StringRef Name, ClangTidyContext *Context);
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override{
+return LangOpts.CPlusPlus;
+  }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;

diff  --git a/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.h 
b/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.h
index 3745c7bb4681..71f662ba5544 100644
--- a/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.h
@@ -22,6 +22,9 @@ namespace performance {
 class ForRangeCopyCheck : public ClangTidyCheck {
 public:
   ForRangeCopyCheck(StringRef Name, ClangTidyContext *Context);
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override{
+return LangOpts.CPlusPlus11;
+  }
   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;

diff  --git 
a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h 
b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h
index b372003a8002..4b271366f0f6 100644
--- a/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.h
@@ -22,6 +22,9 @@ class ImplicitConversionInLoopCheck : public ClangTidyCheck {
 public:
   ImplicitConversionInLoopCheck(StringRef Name, ClangTidyContext *Context)
   : ClangTidyCheck(Name, Context) {}
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const 
override{
+return LangOpts.CPlusPlus11;
+  }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 

diff  --git 
a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h 
b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
index e224dcc90685..533b30dc32b0 100644
--- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.h
@@ -26,6 +26,9 @@ namespace performance {
 class InefficientVectorOperationCheck : public ClangTidyCheck {
 public:
   InefficientVectorOperationCheck(StringRef Name, ClangTidyContext *Context);
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override{
+return LangOpts.CPlusPlus;
+  }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
   void storeOptions(ClangTidyOptions::OptionMap &

[clang] abafb65 - [clang][docs] Remove untracked files from formatted status

2020-06-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-28T09:49:39+01:00
New Revision: abafb655c85d92c02c19c8723ef9ecc5d48574bf

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

LOG: [clang][docs] Remove untracked files from formatted status

Currently on http://clang.llvm.org/docs/ClangFormattedStatus.html there are 
format stats on files no actually inside the tree but generated by build 
scripts. These are usually copied from somewhere else. Right now for example 
there are files from `llvm/utils/release/llvm-package...`. Adding these files 
bloats the list while not giving an accurate representation of how formatted 
the repo is.
This addresses this issue by checking the git index and ignoring any folder 
that doesn't contain tracked files.

I'm still unsure whether it would be better to just do away with the `os.walk` 
method and just check over every file returned from `git ls-index 
`.

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/docs/tools/generate_formatted_state.py

Removed: 




diff  --git a/clang/docs/tools/generate_formatted_state.py 
b/clang/docs/tools/generate_formatted_state.py
index 1b620a84ac0b..41d5cd9d4004 100755
--- a/clang/docs/tools/generate_formatted_state.py
+++ b/clang/docs/tools/generate_formatted_state.py
@@ -72,6 +72,8 @@ def get_style(count, passed):
  - {style2}`{percent}%`
 """
 
+FNULL = open(os.devnull, 'w')
+
 with open(DOC_FILE, 'wb') as output:
 sha = get_git_revision_short_hash()
 today = datetime.now().strftime("%B %d, %Y %H:%M:%S")
@@ -85,14 +87,22 @@ def get_style(count, passed):
 for subdir in subdirs:
 if any(sd == subdir for sd in skipped_dirs):
 subdirs.remove(subdir)
+else:
+act_sub_dir = os.path.join(root, subdir)
+# Check the git index to see if the directory contains tracked
+# files. Reditect the output to a null descriptor as we aren't
+# interested in it, just the return code.
+git_check = subprocess.Popen(
+["git", "ls-files", "--error-unmatch", act_sub_dir],
+stdout=FNULL,
+stderr=FNULL)
+if git_check.wait() != 0:
+print("Skipping directory: ", act_sub_dir)
+subdirs.remove(subdir)
 
 path = os.path.relpath(root, TOP_DIR)
 path = path.replace('\\', '/')
 
-head, _ = os.path.split(root)
-while head:
-head, _ = os.path.split(head)
-
 file_count = 0
 file_pass = 0
 file_fail = 0



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


[PATCH] D82733: [clang][docs] Add note about using `-flto` with `-g` on macOS

2020-06-29 Thread Philippe Blain via Phabricator via cfe-commits
phil-blain created this revision.
phil-blain added reviewers: echristo, dblaikie.
Herald added subscribers: dexonsmith, inglorion.
Herald added a reviewer: JDevlieghere.
Herald added a project: clang.

If `-Wl,object_path_lto,.o` is not passed at link time
when compiling and linking in separate steps with `-flto` and `-g`, the
temporary file used for Link Time Optimization is deleted by the linker,
so the executable is missing debug symbols and can't be easily debugged,
and `dsymutil` can't be run.

Document this behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82733

Files:
  clang/docs/CommandGuide/clang.rst


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -474,6 +474,14 @@
   optimization. With "thin", :doc:`ThinLTO <../ThinLTO>`
   compilation is invoked instead.
 
+  Note: on Darwin, when using :option:`-flto` along with :option:`-g` and
+  compiling and linking in separate steps, you also need to pass
+  `-Wl,object_path_lto,.o` at the linking step to instruct the
+  ld64 linker not to delete the temporary object file generated during Link
+  Time Optimization (this flag is automatically passed to the linker by Clang
+  if compilation and linking are done in a single step). This allows debugging
+  the executable as well as generating the `.dSYM` bundle using 
:manpage:`dsymutil(1)`.
+
 Driver Options
 ~~
 


Index: clang/docs/CommandGuide/clang.rst
===
--- clang/docs/CommandGuide/clang.rst
+++ clang/docs/CommandGuide/clang.rst
@@ -474,6 +474,14 @@
   optimization. With "thin", :doc:`ThinLTO <../ThinLTO>`
   compilation is invoked instead.
 
+  Note: on Darwin, when using :option:`-flto` along with :option:`-g` and
+  compiling and linking in separate steps, you also need to pass
+  `-Wl,object_path_lto,.o` at the linking step to instruct the
+  ld64 linker not to delete the temporary object file generated during Link
+  Time Optimization (this flag is automatically passed to the linker by Clang
+  if compilation and linking are done in a single step). This allows debugging
+  the executable as well as generating the `.dSYM` bundle using :manpage:`dsymutil(1)`.
+
 Driver Options
 ~~
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 80e15b4 - [Clang][OpenMP][OMPBuilder] Moving OMP allocation and cache creation code to OMPBuilderCBHelpers

2020-06-29 Thread Fady Ghanim via cfe-commits

Author: Fady Ghanim
Date: 2020-06-28T19:04:20-04:00
New Revision: 80e15b4574f4a11792472249f64bac790145cc56

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

LOG: [Clang][OpenMP][OMPBuilder] Moving OMP allocation and cache creation code 
to OMPBuilderCBHelpers

Summary:
Modified the OMPBuilderCBHelpers in the following ways:
- Moved location of class definition and deleted all constructors
- Moved OpenMP-specific address allocation of local variables
- Moved threadprivate variable creation for the current thread

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index f2549769080e..e4cb849e79d1 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -1400,10 +1400,15 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) {
 
   Address address = Address::invalid();
   Address AllocaAddr = Address::invalid();
-  Address OpenMPLocalAddr =
-  getLangOpts().OpenMP
-  ? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
-  : Address::invalid();
+  Address OpenMPLocalAddr = Address::invalid();
+  if (CGM.getOpenMPIRBuilder())
+OpenMPLocalAddr = OMPBuilderCBHelpers::getAddressOfLocalVariable(*this, 
&D);
+  else
+OpenMPLocalAddr =
+getLangOpts().OpenMP
+? CGM.getOpenMPRuntime().getAddressOfLocalVariable(*this, &D)
+: Address::invalid();
+
   bool NRVO = getLangOpts().ElideConstructors && D.isNRVOVariable();
 
   if (getLangOpts().OpenMP && OpenMPLocalAddr.isValid()) {

diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index bead7e8996c0..2547690ed3a3 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2398,7 +2398,13 @@ EmitBitCastOfLValueToProperType(CodeGenFunction &CGF,
 static LValue EmitThreadPrivateVarDeclLValue(
 CodeGenFunction &CGF, const VarDecl *VD, QualType T, Address Addr,
 llvm::Type *RealVarTy, SourceLocation Loc) {
-  Addr = CGF.CGM.getOpenMPRuntime().getAddrOfThreadPrivate(CGF, VD, Addr, Loc);
+  if (CGF.CGM.getOpenMPIRBuilder())
+Addr = CodeGenFunction::OMPBuilderCBHelpers::getAddrOfThreadPrivate(
+CGF, VD, Addr, Loc);
+  else
+Addr =
+CGF.CGM.getOpenMPRuntime().getAddrOfThreadPrivate(CGF, VD, Addr, Loc);
+
   Addr = CGF.Builder.CreateElementBitCast(Addr, RealVarTy);
   return CGF.MakeAddrLValue(Addr, T, AlignmentSource::Decl);
 }

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 7904d4a8c420..2639b9d9bf99 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -23,6 +23,7 @@
 #include "clang/AST/StmtOpenMP.h"
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/PrettyStackTrace.h"
+#include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Instructions.h"
@@ -1564,6 +1565,96 @@ static void emitEmptyBoundParameters(CodeGenFunction &,
  const OMPExecutableDirective &,
  llvm::SmallVectorImpl &) {}
 
+Address CodeGenFunction::OMPBuilderCBHelpers::getAddressOfLocalVariable(
+CodeGenFunction &CGF, const VarDecl *VD) {
+  CodeGenModule &CGM = CGF.CGM;
+  auto OMPBuilder = CGM.getOpenMPIRBuilder();
+  assert(OMPBuilder && "OMPIRBuilder does not exist!");
+
+  if (!VD)
+return Address::invalid();
+  const VarDecl *CVD = VD->getCanonicalDecl();
+  if (!CVD->hasAttr())
+return Address::invalid();
+  const auto *AA = CVD->getAttr();
+  // Use the default allocation.
+  if (AA->getAllocatorType() == OMPAllocateDeclAttr::OMPDefaultMemAlloc &&
+  !AA->getAllocator())
+return Address::invalid();
+  llvm::Value *Size;
+  CharUnits Align = CGM.getContext().getDeclAlign(CVD);
+  if (CVD->getType()->isVariablyModifiedType()) {
+Size = CGF.getTypeSize(CVD->getType());
+// Align the size: ((size + align - 1) / align) * align
+Size = CGF.Builder.CreateNUWAdd(
+Size, CGM.getSize(Align - CharUnits::fromQuantity(1)));
+Size = CGF.Builder.CreateUDiv(Size, CGM.getSize(Align));
+Size = CGF.Builder.CreateNUWMul(Size, CGM.getSize(Align));
+  } else {
+CharUnits Sz = CGM.getContext().getTypeSizeInChars(CVD->getType());
+Size = CGM.getSize(Sz.alignTo(Align));
+  }
+
+  assert(AA->getAllocator() &&
+ "Expected allocator expression for non-default allocator.");
+  llvm::Value *Allocator = 

[PATCH] D79676: [Clang][OpenMP][OMPBuilder] Moving OMP allocation and cache creation code to OMPBuilderCBHelpers

2020-06-29 Thread Fady Ghanim via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG80e15b4574f4: [Clang][OpenMP][OMPBuilder] Moving OMP 
allocation and cache creation code to… (authored by fghanim).

Changed prior to commit:
  https://reviews.llvm.org/D79676?vs=269584&id=273983#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79676

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h

Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -26,6 +26,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprOpenMP.h"
+#include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/ABI.h"
 #include "clang/Basic/CapturedStmt.h"
@@ -80,6 +81,7 @@
 class OMPUseDeviceAddrClause;
 class ReturnsNonNullAttr;
 class SVETypeFlags;
+class OMPExecutableDirective;
 
 namespace analyze_os_log {
 class OSLogBufferLayout;
@@ -259,114 +261,6 @@
 unsigned Index;
   };
 
-  // Helper class for the OpenMP IR Builder. Allows reusability of code used for
-  // region body, and finalization codegen callbacks. This will class will also
-  // contain privatization functions used by the privatization call backs
-  struct OMPBuilderCBHelpers {
-
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-/// Emit the Finalization for an OMP region
-/// \param CGF	The Codegen function this belongs to
-/// \param IP	Insertion point for generating the finalization code.
-static void FinalizeOMPRegion(CodeGenFunction &CGF, InsertPointTy IP) {
-  CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
-  assert(IP.getBlock()->end() != IP.getPoint() &&
- "OpenMP IR Builder should cause terminated block!");
-
-  llvm::BasicBlock *IPBB = IP.getBlock();
-  llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
-  assert(DestBB && "Finalization block should have one successor!");
-
-  // erase and replace with cleanup branch.
-  IPBB->getTerminator()->eraseFromParent();
-  CGF.Builder.SetInsertPoint(IPBB);
-  CodeGenFunction::JumpDest Dest = CGF.getJumpDestInCurrentScope(DestBB);
-  CGF.EmitBranchThroughCleanup(Dest);
-}
-
-/// Emit the body of an OMP region
-/// \param CGF	The Codegen function this belongs to
-/// \param RegionBodyStmt	The body statement for the OpenMP region being
-/// 			 generated
-/// \param CodeGenIP	Insertion point for generating the body code.
-/// \param FiniBB	The finalization basic block
-static void EmitOMPRegionBody(CodeGenFunction &CGF,
-  const Stmt *RegionBodyStmt,
-  InsertPointTy CodeGenIP,
-  llvm::BasicBlock &FiniBB) {
-  llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
-  if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator())
-CodeGenIPBBTI->eraseFromParent();
-
-  CGF.Builder.SetInsertPoint(CodeGenIPBB);
-
-  CGF.EmitStmt(RegionBodyStmt);
-
-  if (CGF.Builder.saveIP().isSet())
-CGF.Builder.CreateBr(&FiniBB);
-}
-
-/// RAII for preserving necessary info during Outlined region body codegen.
-class OutlinedRegionBodyRAII {
-
-  llvm::AssertingVH OldAllocaIP;
-  CodeGenFunction::JumpDest OldReturnBlock;
-  CodeGenFunction &CGF;
-
-public:
-  OutlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP,
- llvm::BasicBlock &RetBB)
-  : CGF(cgf) {
-assert(AllocaIP.isSet() &&
-   "Must specify Insertion point for allocas of outlined function");
-OldAllocaIP = CGF.AllocaInsertPt;
-CGF.AllocaInsertPt = &*AllocaIP.getPoint();
-
-OldReturnBlock = CGF.ReturnBlock;
-CGF.ReturnBlock = CGF.getJumpDestInCurrentScope(&RetBB);
-  }
-
-  ~OutlinedRegionBodyRAII() {
-CGF.AllocaInsertPt = OldAllocaIP;
-CGF.ReturnBlock = OldReturnBlock;
-  }
-};
-
-/// RAII for preserving necessary info during inlined region body codegen.
-class InlinedRegionBodyRAII {
-
-  llvm::AssertingVH OldAllocaIP;
-  CodeGenFunction &CGF;
-
-public:
-  InlinedRegionBodyRAII(CodeGenFunction &cgf, InsertPointTy &AllocaIP,
-llvm::BasicBlock &FiniBB)
-  : CGF(cgf) {
-// Alloca insertion block should be in the entry block of the containing
-// function so it expects an empty AllocaIP in which case will reuse the
-// old alloca insertion point, or a new AllocaIP in the same block as
-// the old one
-assert((!AllocaIP.isSet() ||
-CGF.AllocaInsertPt->getParent() 

[clang-tools-extra] 8f73c44 - Revert "[clang-tidy] Reworked enum options handling(again)"

2020-06-29 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-06-28T21:49:29-04:00
New Revision: 8f73c4432b5fa8510c99a5053c07dc70a610e1fb

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

LOG: Revert "[clang-tidy] Reworked enum options handling(again)"

This reverts commit b9306fd042ce1c11d84f05d2124dfdc65b8331fe
and follow-up 42a51587c79a673045aec3586f4070630e5e7af3.

It seems to build check-clang-tools on macOS, see comments on
https://reviews.llvm.org/D82188

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.h
clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/clang-tidy/utils/IncludeSorter.h
clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 39c049948809..7ddf054a21a9 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -158,7 +158,7 @@ void 
ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
 }
 
 llvm::Expected ClangTidyCheck::OptionsView::getEnumInt(
-StringRef LocalName, ArrayRef> Mapping,
+StringRef LocalName, ArrayRef> Mapping,
 bool CheckGlobal, bool IgnoreCase) {
   auto Iter = CheckOptions.find((NamePrefix + LocalName).str());
   if (CheckGlobal && Iter == CheckOptions.end())
@@ -171,19 +171,19 @@ llvm::Expected 
ClangTidyCheck::OptionsView::getEnumInt(
   unsigned EditDistance = -1;
   for (const auto &NameAndEnum : Mapping) {
 if (IgnoreCase) {
-  if (Value.equals_lower(NameAndEnum.second))
-return NameAndEnum.first;
-} else if (Value.equals(NameAndEnum.second)) {
-  return NameAndEnum.first;
-} else if (Value.equals_lower(NameAndEnum.second)) {
-  Closest = NameAndEnum.second;
+  if (Value.equals_lower(NameAndEnum.first))
+return NameAndEnum.second;
+} else if (Value.equals(NameAndEnum.first)) {
+  return NameAndEnum.second;
+} else if (Value.equals_lower(NameAndEnum.first)) {
+  Closest = NameAndEnum.first;
   EditDistance = 0;
   continue;
 }
-unsigned Distance = Value.edit_distance(NameAndEnum.second);
+unsigned Distance = Value.edit_distance(NameAndEnum.first);
 if (Distance < EditDistance) {
   EditDistance = Distance;
-  Closest = NameAndEnum.second;
+  Closest = NameAndEnum.first;
 }
   }
   if (EditDistance < 3)

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 84ad16c9eea8..84438c21a30b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -27,13 +27,6 @@ class CompilerInstance;
 
 namespace tidy {
 
-/// This class should be specialized by any enum type that needs to be 
converted
-/// to and from an \ref llvm::StringRef.
-template  struct OptionEnumMapping {
-  // Specializations of this struct must implement this function.
-  static ArrayRef> getEnumMapping() = delete;
-};
-
 template  class OptionError : public llvm::ErrorInfo {
   std::error_code convertToErrorCode() const override {
 return llvm::inconvertibleErrorCode();
@@ -320,38 +313,36 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 }
 
 /// Read a named option from the ``Context`` and parse it as an
-/// enum type ``T``.
+/// enum type ``T`` using the \p Mapping provided. If \p IgnoreCase is set,
+/// it will search the mapping ignoring the case.
 ///
 /// Reads the option with the check-local name \p LocalName from the
 /// ``CheckOptions``. If the corresponding key is not present, returns a
 /// ``MissingOption

[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I reverted this in 8f73c4432b5fa8510c99a5053c07dc70a610e1fb 
 and 
check-clang-tools stopped failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82728: [clang] Add -Wsuggest-override

2020-06-29 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 273986.
logan-5 added a comment.

Ran clang-format over the diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

Index: clang/test/SemaCXX/warn-suggest-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-override
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-override
+
+class A {
+ public:
+  ~A() {}
+  void run() {}
+};
+
+class B : public A {
+ public:
+  ~B() {}
+  void run() {}
+};
+
+class C {
+ public:
+  virtual void run() {} // expected-note 2{{overridden virtual function is here}}
+  virtual ~C() {}  // expected-note 2{{overridden virtual function is here}}
+};
+
+class D : public C {
+ public:
+  void run() {}
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  ~D() {}
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 'override'}}
+};
+
+class E : public C {
+ public:
+  virtual void run() {}
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  virtual ~E() {}
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 'override'}}
+};
+
+class F : public C {
+ public:
+  void run() override {}
+  ~F() override {}
+};
+
+class G : public C {
+ public:
+  void run() final {}
+  ~G() final {}
+};
Index: clang/test/SemaCXX/warn-suggest-destructor-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-destructor-override
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
+class A {
+ public:
+  ~A() {}
+  void virtual run() {}
+};
+
+class B : public A {
+ public:
+  ~B() {}
+};
+
+class C {
+ public:
+  virtual void run() {}
+  virtual ~C() {}  // expected-note 2{{overridden virtual function is here}}
+};
+
+class D : public C {
+ public:
+  void run() {}
+  ~D() {}
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 'override'}}
+};
+
+class E : public C {
+ public:
+  void run() {}
+  virtual ~E() {}
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 'override'}}
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3045,7 +3045,7 @@
   << MD->getDeclName();
 }
 
-void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) {
+void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent) {
   if (D->isInvalidDecl() || D->hasAttr())
 return;
   CXXMethodDecl *MD = dyn_cast(D);
@@ -3061,12 +3061,23 @@
   return;
 
   if (MD->size_overridden_methods() > 0) {
-unsigned DiagID = isa(MD)
-  ? diag::warn_destructor_marked_not_override_overriding
-  : diag::warn_function_marked_not_override_overriding;
-Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+auto EmitDiag = [this, MD](unsigned DiagID) {
+  Diag(MD->getLocation(), DiagID) << MD->getDeclName();
+  const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
+  Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+};
+if (Inconsistent)
+  EmitDiag(
+  isa(MD)
+  ? diag::
+warn_inconsistent_destructor_marked_not_override_overriding
+  : diag::
+warn_inconsistent_function_marked_not_override_overriding);
+else
+  EmitDiag(
+  isa(MD)
+  ? diag::warn_suggest_destructor_marked_not_override_overriding
+  : diag::warn_suggest_function_marked_not_override_overriding);
   }
 }
 
@@ -6749,13 +6760,10 @@
 }
   }
 
-  if (HasMethodWithOverrideControl &&
-  HasOverridingMethodWithoutOverrideControl) {
-// At least one method has the 'override' control declared.
-// Diagnose all other overridden methods which do not have 'override'
-// specified on them.
+  if (HasOverridingMethodWithoutOverrideControl) {
+bool InconsistentOverrideControl = HasMethodWithOverrideControl;
 for (auto *M : Record->methods())
-  DiagnoseAbsenceOfOverrideControl(M);
+  DiagnoseAbsenceOfOverrideControl(M, InconsistentOverrideControl);
   }
 
   // Check the defaulted secondary comparisons after any other member functions.
Index: clang/include/clang/Sema/Sem

[PATCH] D82728: [clang] Add -Wsuggest-override

2020-06-29 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 273991.
logan-5 added a comment.

Don't warn for destructors by default. This makes 
-Wsuggest-[destructor-]override more consistent with the behavior of 
-Winconsistent-missing-[destructor-]override, as well as gcc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82728

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/warn-suggest-destructor-override
  clang/test/SemaCXX/warn-suggest-override

Index: clang/test/SemaCXX/warn-suggest-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-override
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-override
+
+class A {
+ public:
+  ~A() {}
+  void run() {}
+};
+
+class B : public A {
+ public:
+  ~B() {}
+  void run() {}
+};
+
+class C {
+ public:
+  virtual void run() {} // expected-note 2{{overridden virtual function is here}}
+  virtual ~C() {}
+};
+
+class D : public C {
+ public:
+  void run() {}
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  ~D() {}
+};
+
+class E : public C {
+ public:
+  virtual void run() {}
+  // expected-warning@-1 {{'run()' overrides a member function but is not marked 'override'}}
+  virtual ~E() {}
+};
+
+class F : public C {
+ public:
+  void run() override {}
+  ~F() override {}
+};
+
+class G : public C {
+ public:
+  void run() final {}
+  ~G() final {}
+};
Index: clang/test/SemaCXX/warn-suggest-destructor-override
===
--- /dev/null
+++ clang/test/SemaCXX/warn-suggest-destructor-override
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify -Wsuggest-destructor-override
+
+class A {
+ public:
+  ~A() {}
+  void virtual run() {}
+};
+
+class B : public A {
+ public:
+  ~B() {}
+};
+
+class C {
+ public:
+  virtual void run() {}
+  virtual ~C() {}  // expected-note 2{{overridden virtual function is here}}
+};
+
+class D : public C {
+ public:
+  void run() {}
+  ~D() {}
+  // expected-warning@-1 {{'~D' overrides a destructor but is not marked 'override'}}
+};
+
+class E : public C {
+ public:
+  void run() {}
+  virtual ~E() {}
+  // expected-warning@-1 {{'~E' overrides a destructor but is not marked 'override'}}
+};
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -3045,7 +3045,7 @@
   << MD->getDeclName();
 }
 
-void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D) {
+void Sema::DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent) {
   if (D->isInvalidDecl() || D->hasAttr())
 return;
   CXXMethodDecl *MD = dyn_cast(D);
@@ -3061,12 +3061,23 @@
   return;
 
   if (MD->size_overridden_methods() > 0) {
-unsigned DiagID = isa(MD)
-  ? diag::warn_destructor_marked_not_override_overriding
-  : diag::warn_function_marked_not_override_overriding;
-Diag(MD->getLocation(), DiagID) << MD->getDeclName();
-const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
-Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+auto EmitDiag = [this, MD](unsigned DiagID) {
+  Diag(MD->getLocation(), DiagID) << MD->getDeclName();
+  const CXXMethodDecl *OMD = *MD->begin_overridden_methods();
+  Diag(OMD->getLocation(), diag::note_overridden_virtual_function);
+};
+if (Inconsistent)
+  EmitDiag(
+  isa(MD)
+  ? diag::
+warn_inconsistent_destructor_marked_not_override_overriding
+  : diag::
+warn_inconsistent_function_marked_not_override_overriding);
+else
+  EmitDiag(
+  isa(MD)
+  ? diag::warn_suggest_destructor_marked_not_override_overriding
+  : diag::warn_suggest_function_marked_not_override_overriding);
   }
 }
 
@@ -6749,13 +6760,10 @@
 }
   }
 
-  if (HasMethodWithOverrideControl &&
-  HasOverridingMethodWithoutOverrideControl) {
-// At least one method has the 'override' control declared.
-// Diagnose all other overridden methods which do not have 'override'
-// specified on them.
+  if (HasOverridingMethodWithoutOverrideControl) {
+bool InconsistentOverrideControl = HasMethodWithOverrideControl;
 for (auto *M : Record->methods())
-  DiagnoseAbsenceOfOverrideControl(M);
+  DiagnoseAbsenceOfOverrideControl(M, InconsistentOverrideControl);
   }
 
   // Check the defaulted secondary comparisons after any other member functions.
Index: clang/include/clang/Sema/Sema.h
===
--- clang/

[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double

2020-06-29 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/Layout/aix-double-struct-member.cpp:1
+// RUN: %clang_cc1 -emit-llvm-only -triple powerpc-ibm-aix-xcoff \
+// RUN: -fdump-record-layouts -fsyntax-only %s 2>/dev/null | \

I am concerned that none of the tests actually create an instance of the 
classes under test and check the alignment (or related adjustments) in the IR. 
That is, we set up the preferred alignment value but don't check that we use it 
where we should.

As it is, it seems array new/delete has problems:
```
#include 
extern "C" void *calloc(decltype(sizeof 0), decltype(sizeof 0));
extern "C" void free(void *);
extern "C" int printf(const char *, ...);

extern void *allocated_ptr;
extern decltype(sizeof 0) allocated_size;
struct B {
  double d;
  ~B() {}
  static void *operator new[](decltype(sizeof 0) sz);
  static void operator delete[](void *p, decltype(sizeof 0) sz);
};
B *allocBp();

#ifdef ALLOCBP
void *allocated_ptr;
decltype(sizeof 0) allocated_size;
void *B::operator new[](decltype(sizeof 0) sz) {
  void *alloc = calloc(1u, allocated_size = sz);
  printf("%p: %s\n", alloc, __PRETTY_FUNCTION__);
  printf("%zu\n", sz);
  return allocated_ptr = alloc;
}
void B::operator delete[](void *p, decltype(sizeof 0) sz) {
  printf("%p: %s\n", p, __PRETTY_FUNCTION__);
  printf("%zu\n", sz);
  assert(sz == allocated_size);
  assert(p == allocated_ptr);
  free(p);
}
B *allocBp() { return new B[2]; }
#endif

#ifdef MAIN
int main(void) { delete[] allocBp(); }
#endif
```

The `xlclang++` invocation from XL C/C++ generates padding before the 32-bit 
`new[]` cookie. I'm not seeing that padding with this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D82617: Disable GCC's -Woverloaded-virtual, which has false positives.

2020-06-29 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D82617#2119138 , @sammccall wrote:

> > Guess perhaps a different question: Why don't you want this for clangd? 
> > Does it make the codebase better by not adhering to this particular warning?
>
> Yes, exactly. (Sorry if this wasn't explicit).


Sorry - poor phrasing on my part. Seems we disagree on this - I think it's 
probably a good thing to adhere to, you don't. I'd like to better understand 
the difference of opinions.

My take on it is that having derived classes with hidden overloads seems to me 
like it could result in confusion when using those derived classes (or worse - 
if the overload set could result in successful compilation even when the 
desired overload isn't present - possibly bugs, rather than only confusing 
compilation errors). Seems good to me to keep the derived classes interfaces 
not containing such surprises.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82617



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


[PATCH] D82617: Disable GCC's -Woverloaded-virtual, which has false positives.

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

> Guess perhaps a different question: Why don't you want this for clangd? Does 
> it make the codebase better by not adhering to this particular warning?

Yes, exactly. (Sorry if this wasn't explicit).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82617



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


[PATCH] D82736: [clangd] Rename FS.view(None) to FS.viewWithDefaultCWD()

2020-06-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Quuxplusone added reviewers: sammccall, kadircet, dblaikie.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Fixes an instance of `-Woverloaded-virtual` on GCC.
Clarifies the purpose of this particular function.
Frees up a register that was being used for this pointless parameter of type 
`llvm::NoneType`.

Also eliminate `virtual` from `view(PathRef)` because it is not intended to be 
overridden.

(This is how I propose to address the underlying issue that led to D82617 
, instead of D82617 
. Of course the final call is 
Kadir's-or-Sam's-or-ultimately-certainly-not-mine.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82736

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/support/ThreadsafeFS.cpp
  clang-tools-extra/clangd/support/ThreadsafeFS.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -34,7 +34,7 @@
 class MockFS : public ThreadsafeFS {
 public:
   IntrusiveRefCntPtr
-  view(llvm::NoneType) const override {
+  viewWithDefaultCWD() const override {
 return buildTestFS(Files, Timestamps);
   }
 
Index: clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
===
--- clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
+++ clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp
@@ -30,11 +30,11 @@
   FS.Files[FooH];
   FS.Files[Invalid];
   Optional PathResult =
-  getCorrespondingHeaderOrSource(FooCpp, FS.view(llvm::None));
+  getCorrespondingHeaderOrSource(FooCpp, FS.viewWithDefaultCWD());
   EXPECT_TRUE(PathResult.hasValue());
   ASSERT_EQ(PathResult.getValue(), FooH);
 
-  PathResult = getCorrespondingHeaderOrSource(FooH, FS.view(llvm::None));
+  PathResult = getCorrespondingHeaderOrSource(FooH, FS.viewWithDefaultCWD());
   EXPECT_TRUE(PathResult.hasValue());
   ASSERT_EQ(PathResult.getValue(), FooCpp);
 
@@ -45,7 +45,7 @@
 
   FS.Files[FooC];
   FS.Files[FooHH];
-  PathResult = getCorrespondingHeaderOrSource(FooC, FS.view(llvm::None));
+  PathResult = getCorrespondingHeaderOrSource(FooC, FS.viewWithDefaultCWD());
   EXPECT_TRUE(PathResult.hasValue());
   ASSERT_EQ(PathResult.getValue(), FooHH);
 
@@ -54,7 +54,7 @@
   auto Foo2HH = testPath("foo2.HH");
   FS.Files[Foo2C];
   FS.Files[Foo2HH];
-  PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.view(llvm::None));
+  PathResult = getCorrespondingHeaderOrSource(Foo2C, FS.viewWithDefaultCWD());
   EXPECT_TRUE(PathResult.hasValue());
   ASSERT_EQ(PathResult.getValue(), Foo2HH);
 
@@ -64,13 +64,13 @@
 
   FS.Files[Foo3C];
   FS.Files[Foo3HXX];
-  PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.view(llvm::None));
+  PathResult = getCorrespondingHeaderOrSource(Foo3C, FS.viewWithDefaultCWD());
   EXPECT_TRUE(PathResult.hasValue());
   ASSERT_EQ(PathResult.getValue(), Foo3HXX);
 
   // Test if asking for a corresponding file that doesn't exist returns an empty
   // string.
-  PathResult = getCorrespondingHeaderOrSource(Invalid, FS.view(llvm::None));
+  PathResult = getCorrespondingHeaderOrSource(Invalid, FS.viewWithDefaultCWD());
   EXPECT_FALSE(PathResult.hasValue());
 }
 
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -274,7 +274,7 @@
   static Key Secret;
   struct ContextReadingFS : public ThreadsafeFS {
 IntrusiveRefCntPtr
-view(llvm::NoneType) const override {
+viewWithDefaultCWD() const override {
   Got = Context::current().getExisting(Secret);
   return buildTestFS({});
 }
@@ -930,7 +930,7 @@
 : CountStats(CountStats) {}
 
 IntrusiveRefCntPtr
-view(llvm::NoneType) const override {
+viewWithDefaultCWD() const override {
   class StatRecordingVFS : public llvm::vfs::ProxyFileSystem {
   public:
 StatRecordingVFS(IntrusiveRefCntPtr FS,
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -719,7 +719,7 @@
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
 /* D

[PATCH] D82736: [clangd] Rename FS.view(None) to FS.viewWithDefaultCWD()

2020-06-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

Thanks, renaming was also another option we had in mind, see 
https://reviews.llvm.org/D81920#2109901 and possibly the following comments. I 
thought it was discussed in the disable-the-warning thread, but to elaborate a 
little more:

Naming is hard in general, this case is no different.

The two overloads in the base class literally do the **same** thing, one of 
them doesn't **change** the CWD. Hence the `Default` doesn't reflect what it 
returns, it's likely to be in an arbitrary state. There are some parts of the 
code that always make use of absolute paths, and it is meaningless for them to 
have sense of "CWD". Since we can't always create a view with some **sane** 
CWD, we needed such an option.

It was originally meant to be a single function with signature 
`view(llvm::Optional)` but this result in wrapping the likely 
`std::string` parameter in an explicit `llvm::StringRef` constructor on almost 
all callsites, as an optional can't be constructed implicitly. Hence 
we rather chose to split the parameter type into two overloads.

So IMHO, having two functions with different names doesn't reflect the intent 
as clearly as code's current state (e.g. via overloads). This is definitely 
subjective though and depends on the taste of people that's reading/maintaining 
the code in question.

As for dropping the virtual in the latter function, it was done to support a 
pure virtual implementation of a ThreadsafeFS whom stored the CWD internally, 
not that we need it today or it is certain that we'll need one someday. So it 
can be changed when the need arises.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82736



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


[PATCH] D82436: [clangd] Implement textDocument/foldingRange

2020-06-29 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added a comment.

@sammccall ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82436



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


[clang-tools-extra] 117b923 - [clangd][Hover] Dont crash on null types

2020-06-29 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-06-29T09:10:03+02:00
New Revision: 117b9230a74cfbfe5e409adc2aa2d33c9c584a81

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

LOG: [clangd][Hover] Dont crash on null types

Reviewers: hokein, sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 3d5d002f8ded..bd5b7114cc35 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -124,8 +124,8 @@ std::string printType(QualType QT, const PrintingPolicy 
&Policy) {
   // TypePrinter doesn't resolve decltypes, so resolve them here.
   // FIXME: This doesn't handle composite types that contain a decltype in 
them.
   // We should rather have a printing policy for that.
-  while (const auto *DT = QT->getAs())
-QT = DT->getUnderlyingType();
+  while (!QT.isNull() && QT->isDecltypeType())
+QT = QT->getAs()->getUnderlyingType();
   return QT.getAsString(Policy);
 }
 
@@ -297,15 +297,7 @@ void fillFunctionTypeAndParams(HoverInfo &HI, const Decl 
*D,
   for (const ParmVarDecl *PVD : FD->parameters()) {
 HI.Parameters->emplace_back();
 auto &P = HI.Parameters->back();
-if (!PVD->getType().isNull()) {
-  P.Type = printType(PVD->getType(), Policy);
-} else {
-  std::string Param;
-  llvm::raw_string_ostream OS(Param);
-  PVD->dump(OS);
-  OS.flush();
-  elog("Got param with null type: {0}", Param);
-}
+P.Type = printType(PVD->getType(), Policy);
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
 if (const Expr *DefArg = getDefaultArg(PVD)) {

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index c6c0daa6380e..78964ee7ab91 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -708,6 +708,17 @@ class Foo {})cpp";
  HI.Definition = "X x";
  HI.Type = "struct X";
}},
+  {// Don't crash on null types.
+   R"cpp(auto [^[[x]]] = 1; /*error-ok*/)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "x";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "";
+ HI.Type = "NULL TYPE";
+ // Bindings are in theory public members of an anonymous struct.
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);



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


[PATCH] D82739: Improve heuristic resolution of dependent types in TargetFinder

2020-06-29 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
ilya-biryukov.
Herald added a project: clang.

Fixes https://github.com/clangd/clangd/issues/441


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82739

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -548,6 +548,23 @@
   EXPECT_DECLS("UnresolvedMemberExpr", "void func(int *)", "void func(char *)");
 }
 
+TEST_F(TargetDeclTest, DependentExprs) {
+  Flags = {"-fno-delayed-template-parsing"};
+
+  // Heuristic resolution of method of dependent field
+  Code = R"cpp(
+struct A { void foo() {} };
+template 
+struct B {
+  A a;
+  void bar() {
+this->a.[[foo]]();
+  }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+}
+
 TEST_F(TargetDeclTest, ObjC) {
   Flags = {"-xobjective-c"};
   Code = R"cpp(
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -58,50 +58,12 @@
   return S;
 }
 
-// Given a dependent type and a member name, heuristically resolve the
-// name to one or more declarations.
-// The current heuristic is simply to look up the name in the primary
-// template. This is a heuristic because the template could potentially
-// have specializations that declare different members.
-// Multiple declarations could be returned if the name is overloaded
-// (e.g. an overloaded method in the primary template).
-// This heuristic will give the desired answer in many cases, e.g.
-// for a call to vector::size().
-// The name to look up is provided in the form of a factory that takes
-// an ASTContext, because an ASTContext may be needed to obtain the
-// name (e.g. if it's an operator name), but the caller may not have
-// access to an ASTContext.
+// Forward declaration, needed as this function is mutually recursive
+// with getPointeeType() and resolveDependentExprToDecls().
 std::vector getMembersReferencedViaDependentName(
-const Type *T,
+const Expr *E, const Type *T,
 llvm::function_ref NameFactory,
-bool IsNonstaticMember) {
-  if (!T)
-return {};
-  if (auto *ET = T->getAs()) {
-auto Result =
-ET->getDecl()->lookup(NameFactory(ET->getDecl()->getASTContext()));
-return {Result.begin(), Result.end()};
-  }
-  if (auto *ICNT = T->getAs()) {
-T = ICNT->getInjectedSpecializationType().getTypePtrOrNull();
-  }
-  auto *TST = T->getAs();
-  if (!TST)
-return {};
-  const ClassTemplateDecl *TD = dyn_cast_or_null(
-  TST->getTemplateName().getAsTemplateDecl());
-  if (!TD)
-return {};
-  CXXRecordDecl *RD = TD->getTemplatedDecl();
-  if (!RD->hasDefinition())
-return {};
-  RD = RD->getDefinition();
-  DeclarationName Name = NameFactory(RD->getASTContext());
-  return RD->lookupDependentName(Name, [=](const NamedDecl *D) {
-return IsNonstaticMember ? D->isCXXInstanceMember()
- : !D->isCXXInstanceMember();
-  });
-}
+bool IsNonstaticMember);
 
 // Given the type T of a dependent expression that appears of the LHS of a "->",
 // heuristically find a corresponding pointee type in whose scope we could look
@@ -119,7 +81,7 @@
   // Look up operator-> in the primary template. If we find one, it's probably a
   // smart pointer type.
   auto ArrowOps = getMembersReferencedViaDependentName(
-  T,
+  nullptr, T,
   [](ASTContext &Ctx) {
 return Ctx.DeclarationNames.getCXXOperatorName(OO_Arrow);
   },
@@ -144,6 +106,119 @@
   return FirstArg.getAsType().getTypePtrOrNull();
 }
 
+// Try to heuristically resolve a dependent expression `E` to one
+// or more declarations that it likely references.
+std::vector resolveDependentExprToDecls(const Expr *E) {
+  switch (E->getStmtClass()) {
+  case Stmt::CXXDependentScopeMemberExprClass: {
+const auto *ME = llvm::cast(E);
+const Type *BaseType = ME->getBaseType().getTypePtrOrNull();
+if (ME->isArrow()) {
+  BaseType = getPointeeType(BaseType);
+}
+Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase();
+return getMembersReferencedViaDependentName(
+Base, BaseType, [ME](ASTContext &) { return ME->getMember(); },
+/*IsNonstaticMember=*/true);
+  }
+  case Stmt::DependentScopeDeclRefExprClass: {
+const auto *RE = llvm::cast(E);
+return getMembersReferencedViaDependentName(
+nullptr, RE->getQualifier()->getAsType(),
+[RE](ASTContext &) { return RE->getDeclName(); },
+/*IsNonstaticMember=*/false);
+  }
+  defau

[PATCH] D82738: [clang] Fix a null-NSS-access crash in DependentNameType.

2020-06-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.

The DependentNameType must have a non-null NSS. This property could be
violated during typo correction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82738

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Parser/cxx-template-decl.cpp


Index: clang/test/Parser/cxx-template-decl.cpp
===
--- clang/test/Parser/cxx-template-decl.cpp
+++ clang/test/Parser/cxx-template-decl.cpp
@@ -286,3 +286,16 @@
   template int b;
   template auto f() -> b<0>; // expected-error +{{}}
 }
+
+namespace NoCrashOnNullNNSTypoCorrection {
+
+int AddObservation(); // expected-note {{declared here}}
+
+template 
+class UsingImpl {};
+class AddObservation {
+  using Using =
+UsingImpl; // expected-error {{use of 
undeclared identifier 'AddObservationFn'; did you mean}}
+};
+
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -4866,6 +4866,11 @@
   if (Result.getAsSingle() ||
   Result.getResultKind() ==
   LookupResult::NotFoundInCurrentInstantiation) {
+if (SS.isEmpty())
+  // bail out if we don't have a NNS, this could be happened during
+  // typo correction in error recovery.
+  // A dependent name type should have a non-null NNS.
+  return true;
 // Suggest that the user add 'typename' before the NNS.
 SourceLocation Loc = AL.getSourceRange().getBegin();
 Diag(Loc, getLangOpts().MSVCCompat


Index: clang/test/Parser/cxx-template-decl.cpp
===
--- clang/test/Parser/cxx-template-decl.cpp
+++ clang/test/Parser/cxx-template-decl.cpp
@@ -286,3 +286,16 @@
   template int b;
   template auto f() -> b<0>; // expected-error +{{}}
 }
+
+namespace NoCrashOnNullNNSTypoCorrection {
+
+int AddObservation(); // expected-note {{declared here}}
+
+template 
+class UsingImpl {};
+class AddObservation {
+  using Using =
+UsingImpl; // expected-error {{use of undeclared identifier 'AddObservationFn'; did you mean}}
+};
+
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -4866,6 +4866,11 @@
   if (Result.getAsSingle() ||
   Result.getResultKind() ==
   LookupResult::NotFoundInCurrentInstantiation) {
+if (SS.isEmpty())
+  // bail out if we don't have a NNS, this could be happened during
+  // typo correction in error recovery.
+  // A dependent name type should have a non-null NNS.
+  return true;
 // Suggest that the user add 'typename' before the NNS.
 SourceLocation Loc = AL.getSourceRange().getBegin();
 Diag(Loc, getLangOpts().MSVCCompat
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82085: [TRE] allow TRE for non-capturing calls.

2020-06-29 Thread Alexey Lapshin via Phabricator via cfe-commits
avl added a comment.

ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D82701: [clangd][Hover] Dont crash on null types

2020-06-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks, I was going to prepare a patch this morning, then realized this one.




Comment at: clang-tools-extra/clangd/Hover.cpp:302
   P.Type = printType(PVD->getType(), Policy);
 } else {
   std::string Param;

nit: now we can remove this if-else branch.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:716
+  void foo() {
+M(auto [^[[x]]], bar()); /*error-ok*/
+  }

I think `auto [x, y] = 1` should be enough to reproduce the crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82701



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


[PATCH] D82701: [clangd][Hover] Dont crash on null types

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

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82701

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
@@ -708,6 +708,17 @@
  HI.Definition = "X x";
  HI.Type = "struct X";
}},
+  {// Don't crash on null types.
+   R"cpp(auto [^[[x]]] = 1; /*error-ok*/)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "x";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "";
+ HI.Type = "NULL TYPE";
+ // Bindings are in theory public members of an anonymous struct.
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -124,8 +124,8 @@
   // TypePrinter doesn't resolve decltypes, so resolve them here.
   // FIXME: This doesn't handle composite types that contain a decltype in 
them.
   // We should rather have a printing policy for that.
-  while (const auto *DT = QT->getAs())
-QT = DT->getUnderlyingType();
+  while (!QT.isNull() && QT->isDecltypeType())
+QT = QT->getAs()->getUnderlyingType();
   return QT.getAsString(Policy);
 }
 
@@ -297,15 +297,7 @@
   for (const ParmVarDecl *PVD : FD->parameters()) {
 HI.Parameters->emplace_back();
 auto &P = HI.Parameters->back();
-if (!PVD->getType().isNull()) {
-  P.Type = printType(PVD->getType(), Policy);
-} else {
-  std::string Param;
-  llvm::raw_string_ostream OS(Param);
-  PVD->dump(OS);
-  OS.flush();
-  elog("Got param with null type: {0}", Param);
-}
+P.Type = printType(PVD->getType(), Policy);
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
 if (const Expr *DefArg = getDefaultArg(PVD)) {


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -708,6 +708,17 @@
  HI.Definition = "X x";
  HI.Type = "struct X";
}},
+  {// Don't crash on null types.
+   R"cpp(auto [^[[x]]] = 1; /*error-ok*/)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "x";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "";
+ HI.Type = "NULL TYPE";
+ // Bindings are in theory public members of an anonymous struct.
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -124,8 +124,8 @@
   // TypePrinter doesn't resolve decltypes, so resolve them here.
   // FIXME: This doesn't handle composite types that contain a decltype in them.
   // We should rather have a printing policy for that.
-  while (const auto *DT = QT->getAs())
-QT = DT->getUnderlyingType();
+  while (!QT.isNull() && QT->isDecltypeType())
+QT = QT->getAs()->getUnderlyingType();
   return QT.getAsString(Policy);
 }
 
@@ -297,15 +297,7 @@
   for (const ParmVarDecl *PVD : FD->parameters()) {
 HI.Parameters->emplace_back();
 auto &P = HI.Parameters->back();
-if (!PVD->getType().isNull()) {
-  P.Type = printType(PVD->getType(), Policy);
-} else {
-  std::string Param;
-  llvm::raw_string_ostream OS(Param);
-  PVD->dump(OS);
-  OS.flush();
-  elog("Got param with null type: {0}", Param);
-}
+P.Type = printType(PVD->getType(), Policy);
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
 if (const Expr *DefArg = getDefaultArg(PVD)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82568: [clang][CrossTU] Invalidate parent map after get cross TU definition.

2020-06-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

I did not found problems related to traversal scope. At AST import `Decl`'s are 
added only, but the existing ones should remain valid. So the top-level decls 
in TraversalScope should remain valid after import.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82568



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


[PATCH] D81672: [Driver] When forcing a crash print the bug report message

2020-06-29 Thread James Henderson via Phabricator via cfe-commits
jhenderson accepted this revision.
jhenderson added a comment.

Latest version LGTM too.


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

https://reviews.llvm.org/D81672



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


[PATCH] D82701: [clangd][Hover] Dont crash on null types

2020-06-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG117b9230a74c: [clangd][Hover] Dont crash on null types 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82701

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
@@ -708,6 +708,17 @@
  HI.Definition = "X x";
  HI.Type = "struct X";
}},
+  {// Don't crash on null types.
+   R"cpp(auto [^[[x]]] = 1; /*error-ok*/)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "x";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "";
+ HI.Type = "NULL TYPE";
+ // Bindings are in theory public members of an anonymous struct.
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -124,8 +124,8 @@
   // TypePrinter doesn't resolve decltypes, so resolve them here.
   // FIXME: This doesn't handle composite types that contain a decltype in 
them.
   // We should rather have a printing policy for that.
-  while (const auto *DT = QT->getAs())
-QT = DT->getUnderlyingType();
+  while (!QT.isNull() && QT->isDecltypeType())
+QT = QT->getAs()->getUnderlyingType();
   return QT.getAsString(Policy);
 }
 
@@ -297,15 +297,7 @@
   for (const ParmVarDecl *PVD : FD->parameters()) {
 HI.Parameters->emplace_back();
 auto &P = HI.Parameters->back();
-if (!PVD->getType().isNull()) {
-  P.Type = printType(PVD->getType(), Policy);
-} else {
-  std::string Param;
-  llvm::raw_string_ostream OS(Param);
-  PVD->dump(OS);
-  OS.flush();
-  elog("Got param with null type: {0}", Param);
-}
+P.Type = printType(PVD->getType(), Policy);
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
 if (const Expr *DefArg = getDefaultArg(PVD)) {


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -708,6 +708,17 @@
  HI.Definition = "X x";
  HI.Type = "struct X";
}},
+  {// Don't crash on null types.
+   R"cpp(auto [^[[x]]] = 1; /*error-ok*/)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "x";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "";
+ HI.Type = "NULL TYPE";
+ // Bindings are in theory public members of an anonymous struct.
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -124,8 +124,8 @@
   // TypePrinter doesn't resolve decltypes, so resolve them here.
   // FIXME: This doesn't handle composite types that contain a decltype in them.
   // We should rather have a printing policy for that.
-  while (const auto *DT = QT->getAs())
-QT = DT->getUnderlyingType();
+  while (!QT.isNull() && QT->isDecltypeType())
+QT = QT->getAs()->getUnderlyingType();
   return QT.getAsString(Policy);
 }
 
@@ -297,15 +297,7 @@
   for (const ParmVarDecl *PVD : FD->parameters()) {
 HI.Parameters->emplace_back();
 auto &P = HI.Parameters->back();
-if (!PVD->getType().isNull()) {
-  P.Type = printType(PVD->getType(), Policy);
-} else {
-  std::string Param;
-  llvm::raw_string_ostream OS(Param);
-  PVD->dump(OS);
-  OS.flush();
-  elog("Got param with null type: {0}", Param);
-}
+P.Type = printType(PVD->getType(), Policy);
 if (!PVD->getName().empty())
   P.Name = PVD->getNameAsString();
 if (const Expr *DefArg = getDefaultArg(PVD)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82701: [clangd][Hover] Dont crash on null types

2020-06-29 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked 4 inline comments as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:302
   P.Type = printType(PVD->getType(), Policy);
 } else {
   std::string Param;

hokein wrote:
> nit: now we can remove this if-else branch.
well, I wasn't sure what we were logging for :/

but I think you are right, it seems hard to find in the best case.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:716
+  void foo() {
+M(auto [^[[x]]], bar()); /*error-ok*/
+  }

hokein wrote:
> I think `auto [x, y] = 1` should be enough to reproduce the crash.
i could swear this was not crashing the first time i checked :P


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82701



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


[PATCH] D82388: move "basic" builtins to TableGen

2020-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/include/llvm/TableGen/Record.h:1777
 /// string manipulation.
 struct LessRecordByID {
   bool operator()(const Record *LHS, const Record *RHS) const {

Here’s the sort predicate for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82388



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


[PATCH] D80791: [AArch64] Generate .note.gnu.property based on module flags.

2020-06-29 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

This patch solve this too: https://bugs.llvm.org/show_bug.cgi?id=46480


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80791



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


[PATCH] D82157: Fix crash on `user defined literals`

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:632
+// As a node is built by folding tokens we cannot generate one
+// for `_w`
+Builder.markChildToken(S->getBeginLoc(), syntax::NodeRole::LiteralToken);

This comment makes sense, but it is not clear how it is connected to the 
implementation. Could you clarify? Also, could you re-wrap the comment to 80 
columns? Where exactly in the AST do we have the source location that points to 
`_w`? What are we doing to avoid using that source location?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82157



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


[PATCH] D82612: [clangd] Config: compile Fragment -> CompiledFragment -> Config

2020-06-29 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/CMakeLists.txt:41
+  ConfigCompile.cpp
   ConfigYAML.cpp
   Diagnostics.cpp

we have a few config-related files now, I wonder would it make sense to create 
a config/ subdir?



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:47
+
+  std::string RegexError = "";
+  llvm::Optional compileRegex(const Located &Text) {

this is only used in method `compileRegex`, looks like can be moved to a local 
variable? is there life-time issue?



Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:96
+
+  constexpr static auto Error = llvm::SourceMgr::DK_Error;
+  void diag(llvm::SourceMgr::DiagKind Kind, llvm::StringRef Message,

this member seems unused.



Comment at: clang-tools-extra/clangd/ConfigProvider.h:32
+/// Describes the context used to evaluate configuration fragments.
+struct Params {
+  /// Absolute path to file we're targeting. Unix slashes.

nit: I find the name `Params` is too general, it implies less information. When 
I read the code using `Params`, I have to go-to-definition to see what it 
means. 

if we only have a single member in this struct, maybe just use it directly.



Comment at: clang-tools-extra/clangd/ConfigProvider.h:40
+///
+/// Fragments are compiled by Providers when first loaded, and cached for 
reuse.
+/// Like a compiled program, this is good for performance and also encourages

I might miss the context, where is the provider, not added yet? 



Comment at: clang-tools-extra/clangd/ConfigProvider.h:47
+  /// This always produces a usable compiled fragment (errors are recovered).
+  explicit CompiledFragment(Fragment, DiagnosticCallback);
+

Would it be more nature to have a function `compile`(or so) to do the actual 
compile (Fragment -> CompiledFragment) rather than doing it in a constructor?



Comment at: clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp:40
+TEST_F(ConfigCompileTests, Condition) {
+  // No condition.
+  Frag.CompileFlags.Add.emplace_back("X");

my first impression was that each `// XXX` is a separated test, but it turns 
out not, the tests here seem to be stateful -- `Frag` keeps being modified. I 
think it is intentional, but it is hard for readers to track given that the 
code is long.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82612



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


[PATCH] D82388: move "basic" builtins to TableGen

2020-06-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Every Record has an ID that is assigned in order. You can just sort the Records 
based on that in your emitter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82388



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D82188#2118885 , @thakis wrote:

> It's the only change on the blame list, things pass consistently before the 
> change, and fail consistently after it.


Do you happen to have a proper build log for the failing build. That bot 
doesn't show what happened when building, in fact it says there was no work to 
do when building which seems to confuse me. My best guess for the fail is 
infrastructure related.

Edit: http://45.33.8.238/mac/16282/log.txt this is the log I want. It shows the 
failure and that this is the cause, but I'm still struggling to see what the 
actual cause is?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82485: Add tests for sequences of callbacks that RecursiveASTVisitor produces

2020-06-29 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas accepted this revision.
eduucaldas added inline comments.



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:117
+  recordDefaultImplementation(
+  __func__, [&, this]() { RecordingVisitorBase::WalkUpFromStmt(S); });
+  return true;

gribozavr2 wrote:
> eduucaldas wrote:
> > Do we need this `this`?
> Yes, we're calling a method on `this` from the base class. 
> `RecordingVisitorBase::WalkUpFromStmt(S);` is implicitly calling a member 
> function, `this-> RecordingVisitorBase::WalkUpFromStmt(S);`.
True! The `&` default captures `this` already, but a better suggestion would be 
to use the capture: `[S, this]` or perhaps to just use `S` as an argument of 
the lambda. 
That is a nitpick though, feel free to push the patch :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82485



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


[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-06-29 Thread Milian Wolff via Phabricator via cfe-commits
milianw created this revision.
milianw added reviewers: bkramer, yvvan, nik.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

Fixes crash when visiting a partial AST after encountering
a parse error in the input code:

  #5  clang::Stmt::getStmtClass (this=) at 
llvm-project/clang/include/clang/AST/Stmt.h:1125
  #6  clang::cxcursor::MakeCXCursor (S=S@entry=0x0, Parent=0x0, 
TU=0x7f8c6c5186b0, RegionOfInterest=...) at 
llvm-project/clang/tools/libclang/CXCursor.cpp:132
  #7  0x7f8caddc96e5 in clang::cxcursor::CursorVisitor::EnqueueWorkList 
(this=this@entry=0x7f8c9bffc330, WL=..., S=S@entry=0x0) at 
llvm-project/clang/tools/libclang/CIndex.cpp:3028
  #8  0x7f8cadde4e2c in clang::cxcursor::CursorVisitor::Visit 
(this=this@entry=0x7f8c9bffc330, S=0x0) at 
llvm-project/clang/tools/libclang/CIndex.cpp:3256
  #9  0x7f8cadde4604 in clang::cxcursor::CursorVisitor::RunVisitorWorkList 
(this=this@entry=0x7f8c9bffc330, WL=...) at 
llvm-project/clang/tools/libclang/CIndex.cpp:3214
  #10 0x7f8cadde4e37 in clang::cxcursor::CursorVisitor::Visit 
(this=this@entry=0x7f8c9bffc330, S=0x7f8c6c17dc30) at 
llvm-project/clang/tools/libclang/CIndex.cpp:3257
  #11 0x7f8cadddeccb in clang::cxcursor::CursorVisitor::VisitChildren 
(this=this@entry=0x7f8c9bffc330, Cursor=...) at 
llvm-project/clang/tools/libclang/CIndex.cpp:515
  #12 0x7f8cadde688f in clang_visitChildren (parent=..., 
visitor=0x7f8caef6ddda <(anonymous namespace)::visitCursor(CXCursor, CXCursor, 
CXClientData)>, client_data=0x7f8c9bffe3b0) at 
llvm-project/clang/tools/libclang/CIndex.cpp:4450


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82740

Files:
  clang/tools/libclang/CIndex.cpp


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3243,6 +3243,8 @@
 }
 
 bool CursorVisitor::Visit(const Stmt *S) {
+  if (!S)
+return false;
   VisitorWorkList *WL = nullptr;
   if (!WorkListFreeList.empty()) {
 WL = WorkListFreeList.back();


Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3243,6 +3243,8 @@
 }
 
 bool CursorVisitor::Visit(const Stmt *S) {
+  if (!S)
+return false;
   VisitorWorkList *WL = nullptr;
   if (!WorkListFreeList.empty()) {
 WL = WorkListFreeList.back();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82740: [libclang]: check validity before visiting Stmt node

2020-06-29 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

I'm not sure how to write a unit test for this, but I ran into a reproducible 
crash with a complex C++ file which got fixed by this patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[clang-tools-extra] 37cc4fa - [clang-tidy] relanding b9306fd

2020-06-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-29T09:29:39+01:00
New Revision: 37cc4fa2eaa3d03ca8cd4947eb0d4c60e3c9b45c

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

LOG: [clang-tidy] relanding b9306fd

Added some sanity checks to figure out the cause of a (seemingly unrelated) 
test failure on mac.
These can be removed should no issues arise on that platform again.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.h
clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/clang-tidy/utils/IncludeSorter.h
clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 7ddf054a21a9..39c049948809 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -158,7 +158,7 @@ void 
ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
 }
 
 llvm::Expected ClangTidyCheck::OptionsView::getEnumInt(
-StringRef LocalName, ArrayRef> Mapping,
+StringRef LocalName, ArrayRef> Mapping,
 bool CheckGlobal, bool IgnoreCase) {
   auto Iter = CheckOptions.find((NamePrefix + LocalName).str());
   if (CheckGlobal && Iter == CheckOptions.end())
@@ -171,19 +171,19 @@ llvm::Expected 
ClangTidyCheck::OptionsView::getEnumInt(
   unsigned EditDistance = -1;
   for (const auto &NameAndEnum : Mapping) {
 if (IgnoreCase) {
-  if (Value.equals_lower(NameAndEnum.first))
-return NameAndEnum.second;
-} else if (Value.equals(NameAndEnum.first)) {
-  return NameAndEnum.second;
-} else if (Value.equals_lower(NameAndEnum.first)) {
-  Closest = NameAndEnum.first;
+  if (Value.equals_lower(NameAndEnum.second))
+return NameAndEnum.first;
+} else if (Value.equals(NameAndEnum.second)) {
+  return NameAndEnum.first;
+} else if (Value.equals_lower(NameAndEnum.second)) {
+  Closest = NameAndEnum.second;
   EditDistance = 0;
   continue;
 }
-unsigned Distance = Value.edit_distance(NameAndEnum.first);
+unsigned Distance = Value.edit_distance(NameAndEnum.second);
 if (Distance < EditDistance) {
   EditDistance = Distance;
-  Closest = NameAndEnum.first;
+  Closest = NameAndEnum.second;
 }
   }
   if (EditDistance < 3)

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 84438c21a30b..84ad16c9eea8 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -27,6 +27,13 @@ class CompilerInstance;
 
 namespace tidy {
 
+/// This class should be specialized by any enum type that needs to be 
converted
+/// to and from an \ref llvm::StringRef.
+template  struct OptionEnumMapping {
+  // Specializations of this struct must implement this function.
+  static ArrayRef> getEnumMapping() = delete;
+};
+
 template  class OptionError : public llvm::ErrorInfo {
   std::error_code convertToErrorCode() const override {
 return llvm::inconvertibleErrorCode();
@@ -313,36 +320,38 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 }
 
 /// Read a named option from the ``Context`` and parse it as an
-/// enum type ``T`` using the \p Mapping provided. If \p IgnoreCase is set,
-/// it will search the mapping ignoring the case.
+/// enum type ``T``.
 ///
 /// Reads the option with the check-local name \p LocalName from the
 /// ``CheckOptions``. If the corresponding key is not present, returns a
 /// ``Missing

[PATCH] D82736: [clangd] Rename FS.view(None) to FS.viewWithDefaultCWD()

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Yeah, IMO we spent a bunch of time on these names, I still like them, and I 
don't find the arguments since then convincing. New info is of course the 
warning, and the lack of consensus to change it at clang level.

As for this proposal specifically

- `viewWithDefaultCWD` suggests to me the default has some semantics which 
don't exist, if using this API "shape" I'd substitute `Arbitrary` here
- I think the argument for changing the *public* API is particularly weak (or 
missing?). It's more important than the private API, and no change is required 
to silence the warning. A new name is inevitably a mouthful, and it ties our 
hands for adding the `Optional` overload.
- I could certainly live with `private: virtual T viewImpl() = 0`. Sounds like 
some will find that nicer, it's not very intrusive, and we don't need to 
maintain a flag-divergence from clang

> [virtual]... not that we need it today or it is certain that we'll need one 
> someday

We have an out-of-tree implementation that should be using this, though may not 
have switched yet. But this also certainly will never really matter, so let's 
drop `virtual` for simplicity.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82736



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

I've relanded this with some sanity checks in 
37cc4fa2eaa3d03ca8cd4947eb0d4c60e3c9b45c 
. If it 
fails again without those asserts I'll go back to the drawing board


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82470: [OpenMP][IRBuilder] Support allocas in nested parallel regions

2020-06-29 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim requested changes to this revision.
fghanim added inline comments.
This revision now requires changes to proceed.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:282
+  IRBuilder<> AllocaBuilder;
+
   /// Map to remember source location strings

jdoerfert wrote:
> fghanim wrote:
> > jdoerfert wrote:
> > > fghanim wrote:
> > > > What's the benefit of this over just maintaining an alloca insertion 
> > > > point?
> > > > 
> > > > With this we will have 3 `IRBuilder`s to maintain and keep track of: 
> > > > the clang (or flang) `IRBuilder`, the OMP `IRBuilder` and the 
> > > > `allocaBuilder`
> > > No functional difference. Basically the same reason why clang has an 
> > > AllocIRBuilder (I think), we can use it independently of the other one. 
> > > The alternative is to save the builder IP, set it to the alloca IP, do 
> > > alloca stuff, reset the builder IP, when you use the AllocaIRBuilder 
> > > below. Again, no functional difference, just less setting/resetting of 
> > > IPs.
> > I understand where you are coming from, and I understand that functionally 
> > there is mostly no change - for now. But I prefer we do a small struct with 
> > some RAII, over adding an entire builder. I think it's a bit overkill and 
> > will be a source to lots of trouble.
> > 
> > Clang maintains an instruction `AllocaInsertPt`, not a specific builder. 
> > Speaking of which, This is completely from memory (i.e. check to make 
> > sure); I think we already save the previous `AllocaInsertionPt` in clang as 
> > part of the `bodyGenCB`. In which case, this is not needed; a nested 
> > `parallel` will always be generated by clang as part of the `bodyGenCB`, 
> > which in turn is going to save the Alloca insertion point for us. 
> > To enable the creation of the allocas for `TID` and `ZeroAddr` in the outer 
> > function, Why not pass current `AllocaInsertionPt` as an arg. to 
> > `createParallel`
> > I understand where you are coming from, and I understand that functionally 
> > there is mostly no change - for now. But I prefer we do a small struct with 
> > some RAII, over adding an entire builder. I think it's a bit overkill and 
> > will be a source to lots of trouble.
> 
> Could you explain what kind of overkill you see here? And maybe also the lots 
> of trouble you expect from a builder versus a insertion point? It is the same 
> information, just packed in a different struct, right?
> 
> 
> > Clang maintains an instruction AllocaInsertPt, not a specific builder. 
> 
> Right.
> 
> 
> > Speaking of which, This is completely from memory (i.e. check to make 
> > sure); I think we already save the previous AllocaInsertionPt in clang as 
> > part of the bodyGenCB. 
> 
> I think so.
> 
> 
> > In which case, this is not needed; 
> 
> Not strictly, no. 
> 
> > a nested parallel will always be generated by clang as part of the 
> > bodyGenCB,
> 
> Yes.
> 
> > which in turn is going to save the Alloca insertion point for us.
> 
> Yes.
> 
> > To enable the creation of the allocas for TID and ZeroAddr in the outer 
> > function, Why not pass current AllocaInsertionPt as an arg. to 
> > createParallel
> 
> So far, because this will not be the only one that needs to create allocas. 
> If you want to add the allocaIP to all runtime calls that create allocas, I'm 
> fine with that too.
> Could you explain what kind of overkill you see here?
Using an IRBuilder when an insertion point suffices

> And maybe also the lots of trouble you expect from a builder versus a 
> insertion point?
Currently, when using the OMPBuilder you need to juggle two IRBuilders, let's 
not make them 3 :)

> It is the same information, just packed in a different struct, right?
no it is not. `InsetrionPoint` vs  struct that contains `Insertionpoint` + 
other things. But that's beside the point

I mean, is the `AllocaBuilder` providing a new functionality other than a 
convenient way to keep track of the Alloca `InsertionPoint`?
Personally, I prefer some suitable structure to your needs and a stack (i.e. 
the way clang does it) . This should also resolve the todo below. 
Alternatively, pass an allocation point as an argument as suggested earlier. I 
am open to any third way if you have any.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82470



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


[clang-tools-extra] e34523c - Revert "[clang-tidy] relanding b9306fd"

2020-06-29 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-29T09:44:11+01:00
New Revision: e34523c87c3f1cfabcf741568dede026bbb12d3a

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

LOG: Revert "[clang-tidy] relanding b9306fd"

This reverts commit 37cc4fa2eaa3d03ca8cd4947eb0d4c60e3c9b45c. More 
investigation needed

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
clang-tools-extra/clang-tidy/ClangTidyCheck.h
clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
clang-tools-extra/clang-tidy/utils/IncludeSorter.h
clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 39c049948809..7ddf054a21a9 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -158,7 +158,7 @@ void 
ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
 }
 
 llvm::Expected ClangTidyCheck::OptionsView::getEnumInt(
-StringRef LocalName, ArrayRef> Mapping,
+StringRef LocalName, ArrayRef> Mapping,
 bool CheckGlobal, bool IgnoreCase) {
   auto Iter = CheckOptions.find((NamePrefix + LocalName).str());
   if (CheckGlobal && Iter == CheckOptions.end())
@@ -171,19 +171,19 @@ llvm::Expected 
ClangTidyCheck::OptionsView::getEnumInt(
   unsigned EditDistance = -1;
   for (const auto &NameAndEnum : Mapping) {
 if (IgnoreCase) {
-  if (Value.equals_lower(NameAndEnum.second))
-return NameAndEnum.first;
-} else if (Value.equals(NameAndEnum.second)) {
-  return NameAndEnum.first;
-} else if (Value.equals_lower(NameAndEnum.second)) {
-  Closest = NameAndEnum.second;
+  if (Value.equals_lower(NameAndEnum.first))
+return NameAndEnum.second;
+} else if (Value.equals(NameAndEnum.first)) {
+  return NameAndEnum.second;
+} else if (Value.equals_lower(NameAndEnum.first)) {
+  Closest = NameAndEnum.first;
   EditDistance = 0;
   continue;
 }
-unsigned Distance = Value.edit_distance(NameAndEnum.second);
+unsigned Distance = Value.edit_distance(NameAndEnum.first);
 if (Distance < EditDistance) {
   EditDistance = Distance;
-  Closest = NameAndEnum.second;
+  Closest = NameAndEnum.first;
 }
   }
   if (EditDistance < 3)

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
index 84ad16c9eea8..84438c21a30b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -27,13 +27,6 @@ class CompilerInstance;
 
 namespace tidy {
 
-/// This class should be specialized by any enum type that needs to be 
converted
-/// to and from an \ref llvm::StringRef.
-template  struct OptionEnumMapping {
-  // Specializations of this struct must implement this function.
-  static ArrayRef> getEnumMapping() = delete;
-};
-
 template  class OptionError : public llvm::ErrorInfo {
   std::error_code convertToErrorCode() const override {
 return llvm::inconvertibleErrorCode();
@@ -320,38 +313,36 @@ class ClangTidyCheck : public 
ast_matchers::MatchFinder::MatchCallback {
 }
 
 /// Read a named option from the ``Context`` and parse it as an
-/// enum type ``T``.
+/// enum type ``T`` using the \p Mapping provided. If \p IgnoreCase is set,
+/// it will search the mapping ignoring the case.
 ///
 /// Reads the option with the check-local name \p LocalName from the
 /// ``CheckOptions``. If the corresponding key is not present, returns a
 /// ``MissingOptionError``. If the key can't be parsed as a ``T`` returns a
 

[PATCH] D82485: Add tests for sequences of callbacks that RecursiveASTVisitor produces

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 marked an inline comment as done.
gribozavr2 added inline comments.



Comment at: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp:117
+  recordDefaultImplementation(
+  __func__, [&, this]() { RecordingVisitorBase::WalkUpFromStmt(S); });
+  return true;

eduucaldas wrote:
> gribozavr2 wrote:
> > eduucaldas wrote:
> > > Do we need this `this`?
> > Yes, we're calling a method on `this` from the base class. 
> > `RecordingVisitorBase::WalkUpFromStmt(S);` is implicitly calling a member 
> > function, `this-> RecordingVisitorBase::WalkUpFromStmt(S);`.
> True! The `&` default captures `this` already, but a better suggestion would 
> be to use the capture: `[S, this]` or perhaps to just use `S` as an argument 
> of the lambda. 
> That is a nitpick though, feel free to push the patch :)
> The & default captures this already

Oh indeed, thanks! I changed the capture list to `[&]` because I think it is 
not interesting what this closure captures exactly. It is not stored anywhere 
beyond the `recordCallback` call and invoked only once, so there are no 
lifetime concerns for variables captured by reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82485



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


[PATCH] D82485: Add tests for sequences of callbacks that RecursiveASTVisitor produces

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 274010.
gribozavr added a comment.

Simplified capture lists in lambdas


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82485

Files:
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -0,0 +1,877 @@
+//===--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestVisitor.h"
+
+using namespace clang;
+
+namespace {
+
+enum class ShouldTraversePostOrder : bool {
+  No = false,
+  Yes = true,
+};
+
+/// Base class for tests for RecursiveASTVisitor tests that validate the
+/// sequence of calls to user-defined callbacks like Traverse*(), WalkUp*(),
+/// Visit*().
+template 
+class RecordingVisitorBase : public TestVisitor {
+  ShouldTraversePostOrder ShouldTraversePostOrderValue;
+
+public:
+  RecordingVisitorBase(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+  : ShouldTraversePostOrderValue(ShouldTraversePostOrderValue) {}
+
+  bool shouldTraversePostOrder() const {
+return static_cast(ShouldTraversePostOrderValue);
+  }
+
+  // Callbacks received during traversal.
+  std::string CallbackLog;
+  unsigned CallbackLogIndent = 0;
+
+  std::string stmtToString(Stmt *S) {
+StringRef ClassName = S->getStmtClassName();
+if (IntegerLiteral *IL = dyn_cast(S)) {
+  return (ClassName + "(" + IL->getValue().toString(10, false) + ")").str();
+}
+if (BinaryOperator *BO = dyn_cast(S)) {
+  return (ClassName + "(" + BinaryOperator::getOpcodeStr(BO->getOpcode()) +
+  ")")
+  .str();
+}
+if (CallExpr *CE = dyn_cast(S)) {
+  if (FunctionDecl *Callee = CE->getDirectCallee()) {
+if (Callee->getIdentifier()) {
+  return (ClassName + "(" + Callee->getName() + ")").str();
+}
+  }
+}
+if (DeclRefExpr *DRE = dyn_cast(S)) {
+  if (NamedDecl *ND = DRE->getFoundDecl()) {
+if (ND->getIdentifier()) {
+  return (ClassName + "(" + ND->getName() + ")").str();
+}
+  }
+}
+return ClassName.str();
+  }
+
+  /// Record the fact that the user-defined callback member function
+  /// \p CallbackName was called with the argument \p S. Then, record the
+  /// effects of calling the default implementation \p CallDefaultFn.
+  template 
+  void recordCallback(StringRef CallbackName, Stmt *S,
+  CallDefault CallDefaultFn) {
+for (unsigned i = 0; i != CallbackLogIndent; ++i) {
+  CallbackLog += "  ";
+}
+CallbackLog += (CallbackName + " " + stmtToString(S) + "\n").str();
+++CallbackLogIndent;
+CallDefaultFn();
+--CallbackLogIndent;
+  }
+};
+
+template 
+::testing::AssertionResult visitorCallbackLogEqual(VisitorTy Visitor,
+   StringRef Code,
+   StringRef ExpectedLog) {
+  Visitor.runOver(Code);
+  // EXPECT_EQ shows the diff between the two strings if they are different.
+  EXPECT_EQ(ExpectedLog.trim().str(),
+StringRef(Visitor.CallbackLog).trim().str());
+  if (ExpectedLog.trim() != StringRef(Visitor.CallbackLog).trim()) {
+return ::testing::AssertionFailure();
+  }
+  return ::testing::AssertionSuccess();
+}
+
+} // namespace
+
+TEST(RecursiveASTVisitor, StmtCallbacks_TraverseLeaf) {
+  class RecordingVisitor : public RecordingVisitorBase {
+  public:
+RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
+
+bool TraverseIntegerLiteral(IntegerLiteral *IL) {
+  recordCallback(__func__, IL, [&]() {
+RecordingVisitorBase::TraverseIntegerLiteral(IL);
+  });
+  return true;
+}
+
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S,
+ [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
+  return true;
+}
+  };
+
+  StringRef Code = R"cpp(
+void add(int, int);
+void test() {
+  1;
+  2 + 3;
+  add(4, 5);
+}
+)cpp";
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::No), Code,
+  R"txt(
+WalkUpFromStmt CompoundStmt
+TraverseIntegerLiteral IntegerLiteral(1)
+  WalkUpFromStmt IntegerLiteral(1)
+WalkUpFromStmt BinaryOperator(+)
+TraverseIntegerLiteral IntegerLiteral(2)
+  WalkUpFromStmt IntegerLiteral(2)
+TraverseIntegerLiteral IntegerLitera

[PATCH] D82179: Move TestClangConfig into libClangTesting and use it in AST Matchers tests

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 274008.
gribozavr added a comment.

Addressed code review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82179

Files:
  clang/include/clang/Testing/TestClangConfig.h
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
+#include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
 #include "clang/Tooling/Syntax/Mutations.h"
@@ -47,83 +48,6 @@
 T->lastLeaf()->token() + 1);
 }
 
-struct TestClangConfig {
-  TestLanguage Language;
-  std::string Target;
-
-  bool isC99OrLater() const { return Language == Lang_C99; }
-
-  bool isC() const { return Language == Lang_C89 || Language == Lang_C99; }
-
-  bool isCXX() const {
-return Language == Lang_CXX03 || Language == Lang_CXX11 ||
-   Language == Lang_CXX14 || Language == Lang_CXX17 ||
-   Language == Lang_CXX20;
-  }
-
-  bool isCXX11OrLater() const {
-return Language == Lang_CXX11 || Language == Lang_CXX14 ||
-   Language == Lang_CXX17 || Language == Lang_CXX20;
-  }
-
-  bool isCXX14OrLater() const {
-return Language == Lang_CXX14 || Language == Lang_CXX17 ||
-   Language == Lang_CXX20;
-  }
-
-  bool isCXX17OrLater() const {
-return Language == Lang_CXX17 || Language == Lang_CXX20;
-  }
-
-  bool supportsCXXDynamicExceptionSpecification() const {
-return Language == Lang_CXX03 || Language == Lang_CXX11 ||
-   Language == Lang_CXX14;
-  }
-
-  bool hasDelayedTemplateParsing() const {
-return Target == "x86_64-pc-win32-msvc";
-  }
-
-  std::vector getCommandLineArgs() const {
-std::vector Result = getCommandLineArgsForTesting(Language);
-Result.push_back("-target");
-Result.push_back(Target);
-return Result;
-  }
-
-  std::string toString() const {
-std::string Result;
-llvm::raw_string_ostream OS(Result);
-OS << "{ Language=" << Language << ", Target=" << Target << " }";
-return OS.str();
-  }
-
-  friend std::ostream &operator<<(std::ostream &OS,
-  const TestClangConfig &ClangConfig) {
-return OS << ClangConfig.toString();
-  }
-
-  static std::vector &allConfigs() {
-static std::vector all_configs = []() {
-  std::vector all_configs;
-  for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
-Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
-TestClangConfig config;
-config.Language = lang;
-config.Target = "x86_64-pc-linux-gnu";
-all_configs.push_back(config);
-
-// Windows target is interesting to test because it enables
-// `-fdelayed-template-parsing`.
-config.Target = "x86_64-pc-win32-msvc";
-all_configs.push_back(config);
-  }
-  return all_configs;
-}();
-return all_configs;
-  }
-};
-
 class SyntaxTreeTest : public ::testing::Test,
public ::testing::WithParamInterface {
 protected:
@@ -3893,7 +3817,24 @@
   EXPECT_TRUE(S->isDetached());
 }
 
+static std::vector allTestClangConfigs() {
+  std::vector all_configs;
+  for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
+Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
+TestClangConfig config;
+config.Language = lang;
+config.Target = "x86_64-pc-linux-gnu";
+all_configs.push_back(config);
+
+// Windows target is interesting to test because it enables
+// `-fdelayed-template-parsing`.
+config.Target = "x86_64-pc-win32-msvc";
+all_configs.push_back(config);
+  }
+  return all_configs;
+}
+
 INSTANTIATE_TEST_CASE_P(SyntaxTreeTests, SyntaxTreeTest,
-testing::ValuesIn(TestClangConfig::allConfigs()), );
+testing::ValuesIn(allTestClangConfigs()), );
 
 } // namespace
Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -12,6 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Testing/CommandLineArgs.h"
+#include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
 
@@ -94,17 +95,29 @@
 return testing::AssertionFailure() << "Could not add dynamic matcher";

[PATCH] D82707: [clang][docs] Remove untracked files from formatted status

2020-06-29 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D82707#2118796 , @njames93 wrote:

> In D82707#2118772 , @MyDeveloperDay 
> wrote:
>
> > The net result is an actual reduction in the overall %
> >
> > F12256151: image.png 
>
>
> Is that a bad thing?


Not really, just a little disappointed ;-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82707



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: 
clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp:31
+  ~TestCheck() {
+assert(DidRegister && "Check never registered");
+assert(DidFire && "Check never fired");

This assert is failing on the mac builds - 
http://45.33.8.238/mac/16309/step_8.txt yet I can see no logical reason for it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82707: [clang][docs] Remove untracked files from formatted status

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D82707#2119303 , @MyDeveloperDay 
wrote:

> In D82707#2118796 , @njames93 wrote:
>
> > Is that a bad thing?
>
>
> Not really, just a little disappointed ;-(


I'm gonna hazard a guess the removal of these directories is the reason the % 
went down F12260876: image.png 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82707



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


[PATCH] D82179: Move TestClangConfig into libClangTesting and use it in AST Matchers tests

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 marked 5 inline comments as done.
gribozavr2 added a comment.

> However, is this worth an RFC to the list?

I don't think so. I'm consolidating existing testing infrastructure that was 
already providing this functionality, and using regular parameterized tests 
(`TEST_P`).




Comment at: clang/include/clang/Testing/TestClangConfig.h:18
+
+struct TestClangConfig {
+  TestLanguage Language;

ymandel wrote:
> Maybe add a brief comment explaining this struct?
Added.



Comment at: clang/include/clang/Testing/TestClangConfig.h:20
+  TestLanguage Language;
+  std::string Target;
+

ymandel wrote:
> Is this sufficiently obvious to the reader or is it worth commenting on the 
> meaning of "target"?
Added a comment.



Comment at: clang/include/clang/Testing/TestClangConfig.h:64
+std::string Result;
+llvm::raw_string_ostream OS(Result);
+OS << "{ Language=" << Language << ", Target=" << Target << " }";

ymandel wrote:
> Add include? ("llvm/Support/raw_ostream.h")
Added.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:818
+TEST_P(ASTMatchersTest, MaterializeTemporaryExpr_MatchesTemporaryCXX11CXX14) {
+  if (GetParam().Language != Lang_CXX11 || GetParam().Language != Lang_CXX14 ||
+  GetParam().Language != Lang_CXX17) {

ymandel wrote:
> Isn't this always true since any given value can't also be other values? 
> Should these be `&&`?
Thanks -- that was a bug, fixed!



Comment at: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1026
+TEST_P(ASTMatchersTest, Initializers_CXX) {
+  if (GetParam().Language != Lang_CXX03) {
+// FIXME: Make this test pass with other C++ standard versions.

ymandel wrote:
> Maybe add comment explaining this restriction? I take it this was some 
> feature support by gcc for C++03, which is also supported by clang for 
> compatibility (at that language version)?
I don't understand it enough to write a comment (I could try to, but I think it 
is not needed for this patch). This limitation was already present (without a 
comment) in the original code that I'm refactoring.

Clang accepts this code in C++03 mode, however I took a quick peek at the 
generated AST, and found that it is different from the AST in, for example, 
C++11. For example, the `CXXConstructExpr` required by the matcher only appears 
in C++03, not in C++11. I think the differences in the AST are the reason for 
the test not working.

It could be the case that the absence of `CXXConstructExpr` in non-C++03 is a 
bug in Clang, but I don't know this area well enough to say right away without 
an in-depth study.



Comment at: clang/unittests/Tooling/Syntax/TreeTest.cpp:3473
+Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
+TestClangConfig config;
+config.Language = lang;

ymandel wrote:
> nit: maybe just
> ```
> all_configs.push_back({lang, "x86_64-pc-linux-gnu"});
> 
> // Windows target is interesting to test because it enables
> // `-fdelayed-template-parsing`.
> all_configs.push_back({lang, "x86_64-pc-win32-msvc"});
> ```
> Or, if you'd like a bit nicer, add a constructor to the struct and use 
> `emplace_back`.
I didn't want to rely on brace initializers or constructors because they are 
less readable, and `TestClangConfig` has the potential to grow quite a few 
member variables in future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82179



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


[PATCH] D82741: [Analyzer][StreamChecker] Use BugType instead of BuiltinBug (NFC) .

2020-06-29 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
gamesh411, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a project: clang.
balazske retitled this revision from "[Analyzer][StreamChecker] Use BugType 
instead of BuiltinBug." to "[Analyzer][StreamChecker] Use BugType instead of 
BuiltinBug (NFC) .".
balazske added reviewers: baloghadamsoftware, gamesh411.
Herald added a subscriber: rnkovacs.

I do not like the BuiltinBug class.
And it takes no SuppressOnSink parameter that may be needed in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82741

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp

Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -195,29 +195,16 @@
 
 class StreamChecker : public Checker {
-  BuiltinBug BT_FileNull{this, "NULL stream pointer",
- "Stream pointer might be NULL."};
-  BuiltinBug BT_UseAfterClose{
-  this, "Closed stream",
-  "Stream might be already closed. Causes undefined behaviour."};
-  BuiltinBug BT_UseAfterOpenFailed{this, "Invalid stream",
-   "Stream might be invalid after "
-   "(re-)opening it has failed. "
-   "Can cause undefined behaviour."};
-  BuiltinBug BT_IndeterminatePosition{
-  this, "Invalid stream state",
-  "File position of the stream might be 'indeterminate' "
-  "after a failed operation. "
-  "Can cause undefined behavior."};
-  BuiltinBug BT_IllegalWhence{this, "Illegal whence argument",
-  "The whence argument to fseek() should be "
-  "SEEK_SET, SEEK_END, or SEEK_CUR."};
-  BuiltinBug BT_StreamEof{this, "Stream already in EOF",
-  "Read function called when stream is in EOF state. "
-  "Function has no effect."};
-  BuiltinBug BT_ResourceLeak{
-  this, "Resource leak",
-  "Opened stream never closed. Potential resource leak."};
+  BugType BT_FileNull{this, "NULL stream pointer", "Stream handling error"};
+  BugType BT_UseAfterClose{this, "Closed stream", "Stream handling error"};
+  BugType BT_UseAfterOpenFailed{this, "Invalid stream",
+"Stream handling error"};
+  BugType BT_IndeterminatePosition{this, "Invalid stream state",
+   "Stream handling error"};
+  BugType BT_IllegalWhence{this, "Illegal whence argument",
+   "Stream handling error"};
+  BugType BT_StreamEof{this, "Stream already in EOF", "Stream handling error"};
+  BugType BT_ResourceLeak{this, "Resource leak", "Stream handling error"};
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -834,7 +821,7 @@
   if (!StateNotNull && StateNull) {
 if (ExplodedNode *N = C.generateErrorNode(StateNull)) {
   C.emitReport(std::make_unique(
-  BT_FileNull, BT_FileNull.getDescription(), N));
+  BT_FileNull, "Stream pointer might be NULL.", N));
 }
 return nullptr;
   }
@@ -859,7 +846,8 @@
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
   C.emitReport(std::make_unique(
-  BT_UseAfterClose, BT_UseAfterClose.getDescription(), N));
+  BT_UseAfterClose,
+  "Stream might be already closed. Causes undefined behaviour.", N));
   return nullptr;
 }
 
@@ -874,7 +862,11 @@
 ExplodedNode *N = C.generateErrorNode();
 if (N) {
   C.emitReport(std::make_unique(
-  BT_UseAfterOpenFailed, BT_UseAfterOpenFailed.getDescription(), N));
+  BT_UseAfterOpenFailed,
+  "Stream might be invalid after "
+  "(re-)opening it has failed. "
+  "Can cause undefined behaviour.",
+  N));
   return nullptr;
 }
 return State;
@@ -885,6 +877,11 @@
 
 ProgramStateRef StreamChecker::ensureNoFilePositionIndeterminate(
 SVal StreamVal, CheckerContext &C, ProgramStateRef State) const {
+  static const char *BugMessage =
+  "File position of the stream might be 'indeterminate' "
+  "after a failed operation. "
+  "Can cause undefined behavior.";
+
   SymbolRef Sym = StreamVal.getAsSymbol();
   if (!Sym)
 return State;
@@ -905,8 +902,7 @@
 return nullptr;
 
   C.emitReport(std::make_unique(
-  BT_IndeterminatePosition, BT_IndeterminatePosition.getDescription(),
-  N));
+  BT_IndeterminatePosition, BugMessage, N));
   return State->set(
   Sym, StreamState::getOpened(SS->LastOperation, ErrorFEof, false));
 }
@@ -916,8 +912,7 @@
 ExplodedNode *N = C.generateErrorNode

[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

@thakis Do those bots use `gn`, could that be the cause of the failures? 
From what I can see `gn` isn't fully supported by llvm and could certainly be 
the cause of failing builds.
Do we have any build bots on mac that don't use `gn` but passed the test case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188



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


[PATCH] D82617: Disable GCC's -Woverloaded-virtual, which has false positives.

2020-06-29 Thread Sam McCall via Phabricator via cfe-commits
sammccall abandoned this revision.
sammccall added a comment.

Abandoning, we'll do this in clangd or find an acceptable way to silence it 
(see D82736 ).

In D82617#2119144 , @dblaikie wrote:

> In D82617#2119138 , @sammccall wrote:
>
> > > Guess perhaps a different question: Why don't you want this for clangd? 
> > > Does it make the codebase better by not adhering to this particular 
> > > warning?
> >
> > Yes, exactly. (Sorry if this wasn't explicit).
>
>
> Sorry - poor phrasing on my part. Seems we disagree on this - I think it's 
> probably a good thing to adhere to, you don't.


Yeah, I think we disagree, and that's OK! We need to stop emitting a warning, 
and apart from that, this doesn't seem like a terribly important question that 
needs an LLVM-wide policy.

On stylistic questions like this, I think code owners generally decide, right? 
So my intent was to drop this proposed change for clang (no consensus) and take 
these opinions under advisement for clangd.

I didn't re-engage here on the substance as I think all the arguments are 
played out and nobody's mind is being changed, and I figured it was time to 
move on.

> I'd like to better understand the difference of opinions.

Sure, and apologies I didn't read it that way. I can summarize the 
counterargument as:

1. I agree that this warning flags cases with confusing code, though in some 
cases (like ThreadsafeFS::view) I think the potential for confusion *due to the 
name-hiding + overloading pattern* is very low.
2. Marking one method of an overload set virtual and implementing others in 
terms of it is the most direct way to express what we're trying to do here. 
(e.g. in Java which has no equivalent name-hiding pattern, nobody really takes 
issue with this). Therefore if the name-hiding is harmless or close-to-it, it's 
the clearest expression of this pattern.
3. The question of whether people like the concrete names or the overload set 
chosen in ThreadsafeFS is irrelevant here.

I think there's a fair amount of disagreement about (1), nobody really 
presented a counterargument to (2), and for some reason we spent a lot of time 
on (3) which seems to be a total bikeshed on a tangentially related topic that 
had been settled in the usual way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82617



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


[PATCH] D82188: [clang-tidy] Reworked enum options handling(again)

2020-06-29 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 274012.
njames93 added a comment.

Figuring out mac crash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82188

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstructorInitCheck.cpp
  clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
  clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
  clang-tools-extra/clang-tidy/utils/IncludeSorter.h
  clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -6,6 +6,20 @@
 
 namespace clang {
 namespace tidy {
+
+enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
+
+template <> struct OptionEnumMapping {
+  static llvm::ArrayRef> getEnumMapping() {
+static constexpr std::pair Mapping[] = {
+{Colours::Red, "Red"},   {Colours::Orange, "Orange"},
+{Colours::Yellow, "Yellow"}, {Colours::Green, "Green"},
+{Colours::Blue, "Blue"}, {Colours::Indigo, "Indigo"},
+{Colours::Violet, "Violet"}};
+return makeArrayRef(Mapping);
+  }
+};
+
 namespace test {
 
 TEST(ParseLineFilter, EmptyFilter) {
@@ -209,15 +223,6 @@
 }
 
 TEST(ValidConfiguration, ValidEnumOptions) {
-
-  enum class Colours { Red, Orange, Yellow, Green, Blue, Indigo, Violet };
-  static constexpr std::pair Mapping[] = {
-  {"Red", Colours::Red},   {"Orange", Colours::Orange},
-  {"Yellow", Colours::Yellow}, {"Green", Colours::Green},
-  {"Blue", Colours::Blue}, {"Indigo", Colours::Indigo},
-  {"Violet", Colours::Violet}};
-  static const auto Map = makeArrayRef(Mapping);
-
   ClangTidyOptions Options;
   auto &CheckOptions = Options.CheckOptions;
 
@@ -237,29 +242,30 @@
 #define CHECK_ERROR_ENUM(Name, Expected)   \
   CHECK_ERROR(Name, UnparseableEnumOptionError, Expected)
 
-  CHECK_VAL(TestCheck.getLocal("Valid", Map), Colours::Red);
-  CHECK_VAL(TestCheck.getGlobal("GlobalValid", Map), Colours::Violet);
-  CHECK_VAL(TestCheck.getLocal("ValidWrongCase", Map, /*IgnoreCase*/ true),
-Colours::Red);
+  CHECK_VAL(TestCheck.getIntLocal("Valid"), Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValid"), Colours::Violet);
   CHECK_VAL(
-  TestCheck.getGlobal("GlobalValidWrongCase", Map, /*IgnoreCase*/ true),
-  Colours::Violet);
-  CHECK_ERROR_ENUM(TestCheck.getLocal("Invalid", Map),
+  TestCheck.getIntLocal("ValidWrongCase", /*IgnoreCase*/ true),
+  Colours::Red);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalValidWrongCase",
+/*IgnoreCase*/ true),
+Colours::Violet);
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("Invalid"),
"invalid configuration value "
"'Scarlet' for option 'test.Invalid'");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("ValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("ValidWrongCase"),
"invalid configuration value 'rED' for option "
"'test.ValidWrongCase'; did you mean 'Red'?");
-  CHECK_ERROR_ENUM(TestCheck.getLocal("NearMiss", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntLocal("NearMiss"),
"invalid configuration value 'Oragne' for option "
"'test.NearMiss'; did you mean 'Orange'?");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalInvalid", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalInvalid"),
"invalid configuration value "
"'Purple' for option 'GlobalInvalid'");
-  CHECK_ERROR_ENUM(TestCheck.getGlobal("GlobalValidWrongCase", Map),
+  CHECK_ERROR_ENUM(TestCheck.getIntGlobal("GlobalValidWrongCase"

[PATCH] D82486: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 274027.
gribozavr added a comment.

Rebased the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82486

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -149,22 +149,17 @@
   R"txt(
 TraverseIntegerLiteral IntegerLiteral(1)
   WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 TraverseIntegerLiteral IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
   WalkUpFromStmt IntegerLiteral(5)
-WalkUpFromStmt IntegerLiteral(5)
 WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -253,23 +248,14 @@
   WalkUpFromIntegerLiteral IntegerLiteral(1)
 WalkUpFromExpr IntegerLiteral(1)
   WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromIntegerLiteral IntegerLiteral(1)
-  WalkUpFromExpr IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
   WalkUpFromIntegerLiteral IntegerLiteral(2)
 WalkUpFromExpr IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromIntegerLiteral IntegerLiteral(2)
-  WalkUpFromExpr IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
   WalkUpFromIntegerLiteral IntegerLiteral(3)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromIntegerLiteral IntegerLiteral(3)
-  WalkUpFromExpr IntegerLiteral(3)
-WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromExpr BinaryOperator(+)
   WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
@@ -280,16 +266,10 @@
   WalkUpFromIntegerLiteral IntegerLiteral(4)
 WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromIntegerLiteral IntegerLiteral(4)
-  WalkUpFromExpr IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
   WalkUpFromIntegerLiteral IntegerLiteral(5)
 WalkUpFromExpr IntegerLiteral(5)
   WalkUpFromStmt IntegerLiteral(5)
-WalkUpFromIntegerLiteral IntegerLiteral(5)
-  WalkUpFromExpr IntegerLiteral(5)
-WalkUpFromStmt IntegerLiteral(5)
 WalkUpFromExpr CallExpr(add)
   WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
@@ -434,13 +414,14 @@
 WalkUpFromStmt IntegerLiteral(5)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromStmt for
+  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 WalkUpFromStmt IntegerLiteral(4)
@@ -530,9 +511,6 @@
   WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromBinaryOperator BinaryOperator(+)
-  WalkUpFromExpr BinaryOperator(+)
-WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
   WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromExpr ImplicitCastExpr
@@ -690,7 +668,6 @@
   WalkUpFromStmt IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(5)
   WalkUpFromStmt CallExpr(add)
-WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
@@ -784,9 +761,6 @@
   WalkUpFromCallExpr CallExpr(add)
 WalkUpFromExpr CallExpr(add)
   WalkUpFromStmt CallExpr(add)
-WalkUpFromCallExpr CallExpr(add)
-  WalkUpFromExpr CallExpr(add)
-WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -578,15 +578,19 @@
 // RAV traverses it as a statement, we produce invalid node kinds in that
 // case.
 // FIXME: should do this in RAV instead?
-if (S->getInit() && !TraverseStmt(S->getInit()))
-  return false;
-if (S->getLoopVariable() && !TraverseDecl(S->getLoopVariable()))
-  return false;
-if (S->getRangeInit() && !TraverseStmt(S->getRangeInit()))
-  return false;
-if (S->getBody() && !TraverseStmt(S->getBody()

[PATCH] D82391: [AArch64][SVE] Add bfloat16 support to svext intrinsic

2020-06-29 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.

LGTM


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

https://reviews.llvm.org/D82391



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


[PATCH] D82741: [Analyzer][StreamChecker] Use BugType instead of BuiltinBug (NFC) .

2020-06-29 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

I just checked `BuiltinBug` -- why do we even have this??? Anyways, LGTM. We 
should probably delete the whole thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82741



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


[PATCH] D82345: [sve][acle] Implement some of the C intrinsics for brain float.

2020-06-29 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added a comment.

@fpetrogalli thanks for updating, LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82345



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


[PATCH] D82486: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr updated this revision to Diff 274032.
gribozavr added a comment.

Added a FIXME about a regression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82486

Files:
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -149,22 +149,17 @@
   R"txt(
 TraverseIntegerLiteral IntegerLiteral(1)
   WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 TraverseIntegerLiteral IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
   WalkUpFromStmt IntegerLiteral(5)
-WalkUpFromStmt IntegerLiteral(5)
 WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -253,23 +248,14 @@
   WalkUpFromIntegerLiteral IntegerLiteral(1)
 WalkUpFromExpr IntegerLiteral(1)
   WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromIntegerLiteral IntegerLiteral(1)
-  WalkUpFromExpr IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
   WalkUpFromIntegerLiteral IntegerLiteral(2)
 WalkUpFromExpr IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromIntegerLiteral IntegerLiteral(2)
-  WalkUpFromExpr IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
   WalkUpFromIntegerLiteral IntegerLiteral(3)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromIntegerLiteral IntegerLiteral(3)
-  WalkUpFromExpr IntegerLiteral(3)
-WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromExpr BinaryOperator(+)
   WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
@@ -280,16 +266,10 @@
   WalkUpFromIntegerLiteral IntegerLiteral(4)
 WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromIntegerLiteral IntegerLiteral(4)
-  WalkUpFromExpr IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
   WalkUpFromIntegerLiteral IntegerLiteral(5)
 WalkUpFromExpr IntegerLiteral(5)
   WalkUpFromStmt IntegerLiteral(5)
-WalkUpFromIntegerLiteral IntegerLiteral(5)
-  WalkUpFromExpr IntegerLiteral(5)
-WalkUpFromStmt IntegerLiteral(5)
 WalkUpFromExpr CallExpr(add)
   WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
@@ -434,13 +414,14 @@
 WalkUpFromStmt IntegerLiteral(5)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromStmt for
+  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 WalkUpFromStmt IntegerLiteral(4)
@@ -521,6 +502,8 @@
   WalkUpFromStmt IntegerLiteral(5)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromStmt for
+  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -530,9 +513,6 @@
   WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromBinaryOperator BinaryOperator(+)
-  WalkUpFromExpr BinaryOperator(+)
-WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
   WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromExpr ImplicitCastExpr
@@ -690,7 +670,6 @@
   WalkUpFromStmt IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(5)
   WalkUpFromStmt CallExpr(add)
-WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
@@ -784,9 +763,6 @@
   WalkUpFromCallExpr CallExpr(add)
 WalkUpFromExpr CallExpr(add)
   WalkUpFromStmt CallExpr(add)
-WalkUpFromCallExpr CallExpr(add)
-  WalkUpFromExpr CallExpr(add)
-WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -578,15 +578,19 @@
 // RAV traverses it as a statement, we produce invalid node kinds in that
 // case.
 // FIXME: should do this in RAV instead?
-   

[PATCH] D82485: Add tests for sequences of callbacks that RecursiveASTVisitor produces

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8e5a56865f28: Add tests for sequences of callbacks that 
RecursiveASTVisitor produces (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82485

Files:
  clang/unittests/Tooling/CMakeLists.txt
  clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -0,0 +1,877 @@
+//===--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestVisitor.h"
+
+using namespace clang;
+
+namespace {
+
+enum class ShouldTraversePostOrder : bool {
+  No = false,
+  Yes = true,
+};
+
+/// Base class for tests for RecursiveASTVisitor tests that validate the
+/// sequence of calls to user-defined callbacks like Traverse*(), WalkUp*(),
+/// Visit*().
+template 
+class RecordingVisitorBase : public TestVisitor {
+  ShouldTraversePostOrder ShouldTraversePostOrderValue;
+
+public:
+  RecordingVisitorBase(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+  : ShouldTraversePostOrderValue(ShouldTraversePostOrderValue) {}
+
+  bool shouldTraversePostOrder() const {
+return static_cast(ShouldTraversePostOrderValue);
+  }
+
+  // Callbacks received during traversal.
+  std::string CallbackLog;
+  unsigned CallbackLogIndent = 0;
+
+  std::string stmtToString(Stmt *S) {
+StringRef ClassName = S->getStmtClassName();
+if (IntegerLiteral *IL = dyn_cast(S)) {
+  return (ClassName + "(" + IL->getValue().toString(10, false) + ")").str();
+}
+if (BinaryOperator *BO = dyn_cast(S)) {
+  return (ClassName + "(" + BinaryOperator::getOpcodeStr(BO->getOpcode()) +
+  ")")
+  .str();
+}
+if (CallExpr *CE = dyn_cast(S)) {
+  if (FunctionDecl *Callee = CE->getDirectCallee()) {
+if (Callee->getIdentifier()) {
+  return (ClassName + "(" + Callee->getName() + ")").str();
+}
+  }
+}
+if (DeclRefExpr *DRE = dyn_cast(S)) {
+  if (NamedDecl *ND = DRE->getFoundDecl()) {
+if (ND->getIdentifier()) {
+  return (ClassName + "(" + ND->getName() + ")").str();
+}
+  }
+}
+return ClassName.str();
+  }
+
+  /// Record the fact that the user-defined callback member function
+  /// \p CallbackName was called with the argument \p S. Then, record the
+  /// effects of calling the default implementation \p CallDefaultFn.
+  template 
+  void recordCallback(StringRef CallbackName, Stmt *S,
+  CallDefault CallDefaultFn) {
+for (unsigned i = 0; i != CallbackLogIndent; ++i) {
+  CallbackLog += "  ";
+}
+CallbackLog += (CallbackName + " " + stmtToString(S) + "\n").str();
+++CallbackLogIndent;
+CallDefaultFn();
+--CallbackLogIndent;
+  }
+};
+
+template 
+::testing::AssertionResult visitorCallbackLogEqual(VisitorTy Visitor,
+   StringRef Code,
+   StringRef ExpectedLog) {
+  Visitor.runOver(Code);
+  // EXPECT_EQ shows the diff between the two strings if they are different.
+  EXPECT_EQ(ExpectedLog.trim().str(),
+StringRef(Visitor.CallbackLog).trim().str());
+  if (ExpectedLog.trim() != StringRef(Visitor.CallbackLog).trim()) {
+return ::testing::AssertionFailure();
+  }
+  return ::testing::AssertionSuccess();
+}
+
+} // namespace
+
+TEST(RecursiveASTVisitor, StmtCallbacks_TraverseLeaf) {
+  class RecordingVisitor : public RecordingVisitorBase {
+  public:
+RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
+: RecordingVisitorBase(ShouldTraversePostOrderValue) {}
+
+bool TraverseIntegerLiteral(IntegerLiteral *IL) {
+  recordCallback(__func__, IL, [&]() {
+RecordingVisitorBase::TraverseIntegerLiteral(IL);
+  });
+  return true;
+}
+
+bool WalkUpFromStmt(Stmt *S) {
+  recordCallback(__func__, S,
+ [&]() { RecordingVisitorBase::WalkUpFromStmt(S); });
+  return true;
+}
+  };
+
+  StringRef Code = R"cpp(
+void add(int, int);
+void test() {
+  1;
+  2 + 3;
+  add(4, 5);
+}
+)cpp";
+
+  EXPECT_TRUE(visitorCallbackLogEqual(
+  RecordingVisitor(ShouldTraversePostOrder::No), Code,
+  R"txt(
+WalkUpFromStmt CompoundStmt
+TraverseIntegerLiteral IntegerLiteral(1)
+  WalkUpFromStmt IntegerLiteral(1)
+WalkUpFromStmt BinaryOperator(+)
+TraverseIntegerLiteral 

[PATCH] D82598: [analyzer][Liveness][NFC] Get rid of statement liveness, because such a thing doesn't exist

2020-06-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.

@szelethus
The patch looks good to me and I find it a welcome change that should make 
things easier to understand and maybe even a bit more efficient, I hope this 
won't break ObjC :) My discussion with Artem is orthogonal to this change.

In D82598#2117432 , @NoQ wrote:

> Well, formally it isn't.


Right. Sorry for being unclear there.

> I guess your point is that live expressions analysis could be replaced with 
> imperative cleanup requests from, say, `ExprEngine` to the `Environment`. 
> I.e., "We've just finished evaluating the if-statement, now we should 
> actively tell the Environment to remove the condition expression".

Yes. This is what I am proposing and this is what we did with the lifetime 
analysis. Unfortunately, I did not have time yet to identify all the cleanup 
points and I do agree that this is not a trivial task but I felt that this is 
much more lightweight in terms of memory and computation.

> I guess it could totally work that way, but it'd be pretty hard to not forget 
> such cleanups.

I agree.

> Given that we'd also barely ever notice that we forgot one of those, i'm very 
> much in favor of having liveness analysis instead, that would declaratively 
> describe which expressions are live when, so that to automatically guarantee 
> that we always only track what's necessary and never snowball our state with 
> dead expressions.

Fair point. I do not remember any problem with the current liveness analysis so 
I guess if something is not broken do not fix it. We also don't have any 
evidence of this being a bottleneck.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82598



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


[PATCH] D82756: Port some floating point options to new option marshalling infrastructure

2020-06-29 Thread Daniel Grumberg via Phabricator via cfe-commits
dang created this revision.
dang added a reviewer: Bigcheese.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1, dexonsmith.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.
dang added a parent revision: D82574: Merge TableGen files used for clang 
options.

This changes cc1 semantics for some options such as `-cl-fast-relaxed-math` 
that implied other options. Now the driver always emits all the implied 
options, and each option maps to one key path in `CompilerInvocation` so that 
the new option parsing system can be used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82756

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/complex-math.c
  clang/test/CodeGen/fast-math.c
  clang/test/CodeGen/finite-math.c
  clang/test/CodeGen/fp-floatcontrol-stack.cpp
  clang/test/CodeGen/fp-function-attrs.cpp
  clang/test/CodeGen/fp-options-to-fast-math-flags.c
  clang/test/CodeGen/fpconstrained.c
  clang/test/CodeGen/fpconstrained.cpp
  clang/test/CodeGen/libcalls.c
  clang/test/CodeGenOpenCL/no-signed-zeros.cl
  clang/test/CodeGenOpenCL/relaxed-fpmath.cl
  clang/test/Driver/opencl.cl
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -435,7 +435,8 @@
 OS << "OPTION(";
 WriteOptRecordFields(OS, R);
 OS << ")\n";
-if (!isa(R.getValueInit("MarshallingKind")))
+if (!isa(R.getValueInit("MarshallingKind")) &&
+!R.getValueAsString("KeyPath").empty())
   OptsWithMarshalling.push_back(MarshallingKindInfo::create(R));
   }
   OS << "#endif // OPTION\n";
Index: clang/test/Headers/nvptx_device_math_sin.cpp
===
--- clang/test/Headers/nvptx_device_math_sin.cpp
+++ clang/test/Headers/nvptx_device_math_sin.cpp
@@ -1,8 +1,15 @@
 // REQUIRES: nvptx-registered-target
 // RUN: %clang_cc1 -x c++ -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -x c++ -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix=SLOW
-// RUN: %clang_cc1 -x c++ -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -ffast-math -ffp-contract=fast
-// RUN: %clang_cc1 -x c++ -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -ffast-math -ffp-contract=fast | FileCheck %s --check-prefix=FAST
+// RUN: %clang_cc1 -x c++ -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown \
+// RUN:   -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -ffast-math -ffinite-math-only \
+// RUN:   -menable-no-infs -menable-no-nans -fno-signed-zeros -freciprocal-math -menable-unsafe-fp-math \
+// RUN:   -fapprox-func -mreassociate -ffp-contract=fast
+// RUN: %clang_cc1 -x c++ -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers \
+// RUN:   -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown \
+// RUN:   -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc \
+// RUN:   -o - -ffast-math -ffinite-math-only -menable-no-infs -menable-no-nans -fno-signed-zeros -freciprocal-math \
+// RUN:   -menable-unsafe-fp-math -fapprox-func -mreassociate -ffp-contract=fast | FileCheck %s --check-prefix=FAST
 // expected-no-diagnostics
 
 #include 
Index: clang/test/Headers/nvptx_device_math_sin.c
===
--- clang/test/Headers/nvptx_device_math_sin.c
+++ clang/test/Headers/nvptx_device_math_sin.c
@@ -1,8 +1,15 @@
 // REQUIRES: nvptx-registered-target
 // RUN: %clang_cc1 -x c -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
 // RUN: %clang_cc1 -x c -include __clang_openmp_device_functions.h -internal-isystem %S/../.

[PATCH] D81315: [analyzer] Warning for default constructed unique pointer dereferences

2020-06-29 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:139
+
+  const auto *MethodDecl = dyn_cast_or_null(OC->getDecl());
+

You should never get null here due to `isStdSmartPointerClass` guarding above. 
I think the null check could be transformed into an assert.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:141
+
+  if (!MethodDecl || !MethodDecl->isOverloadedOperator())
+return;

You have a `CXXMemberOperatorCall` which already represents an overloaded 
operator. This check is either redundant or could be an assert instead.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:144
+
+  OverloadedOperatorKind OOK = MethodDecl->getOverloadedOperator();
+  if (OOK == OO_Star || OOK == OO_Arrow) {

In case `CXXMemberOperatorCall ` class does not have a way to query the 
overloaded operator kind maybe it would be worth to add a helper method to that 
class. So you can do most of the checking using one interface only.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:198
+*InnerPointVal);
+C.addTransition(State);
+  }

It is possible that both `updateTrackedRegion` and this adds a transition. Both 
transition will have the same predecessor, i.e. you introduce a split in the 
exploded graph. Is this intended?


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

https://reviews.llvm.org/D81315



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


[PATCH] D82179: Move TestClangConfig into libClangTesting and use it in AST Matchers tests

2020-06-29 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG339ed1e042c0: Move TestClangConfig into libClangTesting and 
use it in AST Matchers tests (authored by gribozavr).

Changed prior to commit:
  https://reviews.llvm.org/D82179?vs=274008&id=274050#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82179

Files:
  clang/include/clang/Testing/TestClangConfig.h
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Testing/CommandLineArgs.h"
+#include "clang/Testing/TestClangConfig.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Syntax/BuildTree.h"
 #include "clang/Tooling/Syntax/Mutations.h"
@@ -47,83 +48,6 @@
 T->lastLeaf()->token() + 1);
 }
 
-struct TestClangConfig {
-  TestLanguage Language;
-  std::string Target;
-
-  bool isC99OrLater() const { return Language == Lang_C99; }
-
-  bool isC() const { return Language == Lang_C89 || Language == Lang_C99; }
-
-  bool isCXX() const {
-return Language == Lang_CXX03 || Language == Lang_CXX11 ||
-   Language == Lang_CXX14 || Language == Lang_CXX17 ||
-   Language == Lang_CXX20;
-  }
-
-  bool isCXX11OrLater() const {
-return Language == Lang_CXX11 || Language == Lang_CXX14 ||
-   Language == Lang_CXX17 || Language == Lang_CXX20;
-  }
-
-  bool isCXX14OrLater() const {
-return Language == Lang_CXX14 || Language == Lang_CXX17 ||
-   Language == Lang_CXX20;
-  }
-
-  bool isCXX17OrLater() const {
-return Language == Lang_CXX17 || Language == Lang_CXX20;
-  }
-
-  bool supportsCXXDynamicExceptionSpecification() const {
-return Language == Lang_CXX03 || Language == Lang_CXX11 ||
-   Language == Lang_CXX14;
-  }
-
-  bool hasDelayedTemplateParsing() const {
-return Target == "x86_64-pc-win32-msvc";
-  }
-
-  std::vector getCommandLineArgs() const {
-std::vector Result = getCommandLineArgsForTesting(Language);
-Result.push_back("-target");
-Result.push_back(Target);
-return Result;
-  }
-
-  std::string toString() const {
-std::string Result;
-llvm::raw_string_ostream OS(Result);
-OS << "{ Language=" << Language << ", Target=" << Target << " }";
-return OS.str();
-  }
-
-  friend std::ostream &operator<<(std::ostream &OS,
-  const TestClangConfig &ClangConfig) {
-return OS << ClangConfig.toString();
-  }
-
-  static std::vector &allConfigs() {
-static std::vector all_configs = []() {
-  std::vector all_configs;
-  for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
-Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
-TestClangConfig config;
-config.Language = lang;
-config.Target = "x86_64-pc-linux-gnu";
-all_configs.push_back(config);
-
-// Windows target is interesting to test because it enables
-// `-fdelayed-template-parsing`.
-config.Target = "x86_64-pc-win32-msvc";
-all_configs.push_back(config);
-  }
-  return all_configs;
-}();
-return all_configs;
-  }
-};
-
 class SyntaxTreeTest : public ::testing::Test,
public ::testing::WithParamInterface {
 protected:
@@ -3893,7 +3817,24 @@
   EXPECT_TRUE(S->isDetached());
 }
 
+static std::vector allTestClangConfigs() {
+  std::vector all_configs;
+  for (TestLanguage lang : {Lang_C89, Lang_C99, Lang_CXX03, Lang_CXX11,
+Lang_CXX14, Lang_CXX17, Lang_CXX20}) {
+TestClangConfig config;
+config.Language = lang;
+config.Target = "x86_64-pc-linux-gnu";
+all_configs.push_back(config);
+
+// Windows target is interesting to test because it enables
+// `-fdelayed-template-parsing`.
+config.Target = "x86_64-pc-win32-msvc";
+all_configs.push_back(config);
+  }
+  return all_configs;
+}
+
 INSTANTIATE_TEST_CASE_P(SyntaxTreeTests, SyntaxTreeTest,
-testing::ValuesIn(TestClangConfig::allConfigs()), );
+testing::ValuesIn(allTestClangConfigs()), );
 
 } // namespace
Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -12,6 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Testing/CommandLineArgs.h"
+#include "clang/Tes

[PATCH] D82391: [AArch64][SVE] Add bfloat16 support to svext intrinsic

2020-06-29 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd5fc592b7c26: [AArch64][SVE] Add bfloat16 support to svext 
intrinsic (authored by c-rhodes).

Changed prior to commit:
  https://reviews.llvm.org/D82391?vs=273685&id=274052#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82391

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll


Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -516,6 +516,16 @@
   ret  %out
 }
 
+define  @ext_bf16( %a,  %b) #0 {
+; CHECK-LABEL: ext_bf16:
+; CHECK: ext z0.b, z0.b, z1.b, #6
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.ext.nxv8bf16( %a,
+%b,
+   i32 3)
+  ret  %out
+}
+
 define  @ext_f16( %a,  %b) {
 ; CHECK-LABEL: ext_f16:
 ; CHECK: ext z0.b, z0.b, z1.b, #6
@@ -1885,6 +1895,7 @@
 declare  @llvm.aarch64.sve.ext.nxv8i16(, 
, i32)
 declare  @llvm.aarch64.sve.ext.nxv4i32(, 
, i32)
 declare  @llvm.aarch64.sve.ext.nxv2i64(, 
, i32)
+declare  @llvm.aarch64.sve.ext.nxv8bf16(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv8f16(, 
, i32)
 declare  @llvm.aarch64.sve.ext.nxv4f32(, , i32)
 declare  @llvm.aarch64.sve.ext.nxv2f64(, , i32)
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -1446,7 +1446,6 @@
 def : Pat<(nxv8i16 (bitconvert (nxv4i32 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv2i64 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv8f16 ZPR:$src))), (nxv8i16 ZPR:$src)>;
-def : Pat<(nxv8i16 (bitconvert (nxv8bf16 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv4f32 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv2f64 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
@@ -0,0 +1,26 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+
+// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README 
for instructions on how to resolve it.
+// ASM-NOT: warning
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbfloat16_t test_svext_bf16(svbfloat16_t op1, svbfloat16_t op2)
+{
+  // CHECK-LABEL: test_svext_bf16
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.ext.nxv8bf16( %op1,  %op2, i32 127)
+  // CHECK: ret  %[[INTRINSIC]]
+  // expected-warning@+1 {{implicit declaration of function 'svext_bf16'}}
+  return SVE_ACLE_FUNC(svext,_bf16,,)(op1, op2, 127);
+}
Index: clang/include/clang/Basic/arm_sve.td
===
--- clang/include/clang/Basic/arm_sve.td
+++ clang/include/clang/Basic/arm_sve.td
@@ -1208,6 +1208,7 @@
 def SVZIP2   : SInst<"svzip2[_{d}]",  "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_zip2">;
 
 let ArchGuard = "defined(__ARM_FEATURE_SVE_B

[PATCH] D82661: [clang-tidy][NFC] Remove unnecessary includes throughout clang-tidy header files

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

LGTM, though I think this should be landed in two commits (one for the headers, 
one for the tests).




Comment at: clang-tools-extra/test/clang-tidy/checkers/google-module.cpp:4
+// CHECK-DAG: {{- key: 
*google-readability-braces-around-statements.ShortStatementLines[[:space:]] 
value: *'1'}}
+// CHECK-DAG: {{- key: 
*google-readability-function-size.StatementThreshold[[:space:]] value: *'800'}}
+// CHECK-DAG: {{- key: 
*google-readability-namespace-comments.ShortNamespaceLines[[:space:]] value: 
*'10'}}

I feel like these testing changes, while NFC, should be landed in a separate 
patch as they don't have anything to do with the header file changes, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82661



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


[PATCH] D82665: [AArch64][SVE] Add bfloat16 to outstanding tuple vector intrinsics

2020-06-29 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added inline comments.



Comment at: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_create2-bfloat.c:9
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else

fpetrogalli wrote:
> Nit: these are all new files, so you can safely use clang-format on them, as 
> they will not modify the formatting of pre-existing tests. I know this is not 
> what we have done for most of the files in the ACLE tests, but it makes life 
> so much easier to just run a `git clang-format HEAD^` on a patch and kinda 
> forgetting about formatting! Since they are new files, they will not generate 
> conflicts with anything we might have downstream. FWIW, this is my personal 
> preference, so if you prefer to adhere with the manual formatting of other 
> files, I am happy with it.
I agree it's nice to be able to use clang-format and not think about it but in 
my opinion it's more important to be consistent in formatting across the ACLE 
tests. I'd prefer a follow-up patch once the ACLE is complete containing the 
diff produced from running clang-format on 
`clang/test/CodeGen/aarch64-sve-intrinsics` / 
`clang/test/CodeGen/aarch64-sve2-intrinsics`.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_get2-bfloat.c:20
+  // expected-warning@+1 {{implicit declaration of function 'svget2_bf16'}}
+  return SVE_ACLE_FUNC(svget2,_bf16,,)(tuple, 0);
+}

fpetrogalli wrote:
> Shouldn't we test also values other then zero? 0,1 for get2, 0,1,2 for 
> get3... 
> Shouldn't we test also values other then zero? 0,1 for get2, 0,1,2 for get3...

We have coverage for all valid indexes in the test suite for these intrinsics, 
I was about to say it's the same code path regardless of type, which it is on 
the LLVM side but the intrinsic defs in clang are split so I guess that isn't 
covered. I'll add extra tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82665



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


[clang] d5fc592 - [AArch64][SVE] Add bfloat16 support to svext intrinsic

2020-06-29 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2020-06-29T11:08:38Z
New Revision: d5fc592b7c26e96556d2667d2b65a8bd18094a75

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

LOG: [AArch64][SVE] Add bfloat16 support to svext intrinsic

Reviewers: sdesmalen, kmclaughlin, efriedma, david-arm, fpetrogalli

Reviewed By: sdesmalen, fpetrogalli

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

Added: 
clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c

Modified: 
clang/include/clang/Basic/arm_sve.td
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 3327b347..5a0989640eae 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1208,6 +1208,7 @@ def SVZIP1   : SInst<"svzip1[_{d}]",  "ddd",  
"csilUcUsUiUlhfd", MergeNo
 def SVZIP2   : SInst<"svzip2[_{d}]",  "ddd",  "csilUcUsUiUlhfd", 
MergeNone, "aarch64_sve_zip2">;
 
 let ArchGuard = "defined(__ARM_FEATURE_SVE_BF16)" in {
+def SVEXT_BF16: SInst<"svext[_{d}]","dddi", "b", MergeNone, 
"aarch64_sve_ext", [], [ImmCheck<2, ImmCheckExtract, 1>]>;
 def SVREV_BF16: SInst<"svrev[_{d}]","dd",   "b", MergeNone, 
"aarch64_sve_rev">;
 def SVSEL_BF16: SInst<"svsel[_{d}]","dPdd", "b", MergeNone, 
"aarch64_sve_sel">;
 def SVSPLICE_BF16 : SInst<"svsplice[_{d}]", "dPdd", "b", MergeNone, 
"aarch64_sve_splice">;

diff  --git a/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c 
b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
new file mode 100644
index ..52bca99b3f94
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ext-bfloat.c
@@ -0,0 +1,26 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns 
-S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-D__ARM_FEATURE_SVE_BF16 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall 
-o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_BF16_SCALAR_ARITHMETIC 
-triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 
-fallow-half-arguments-and-returns -fsyntax-only -verify 
-verify-ignore-unexpected=error -verify-ignore-unexpected=note %s
+
+// If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README 
for instructions on how to resolve it.
+// ASM-NOT: warning
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
+#endif
+
+svbfloat16_t test_svext_bf16(svbfloat16_t op1, svbfloat16_t op2)
+{
+  // CHECK-LABEL: test_svext_bf16
+  // CHECK: %[[INTRINSIC:.*]] = call  
@llvm.aarch64.sve.ext.nxv8bf16( %op1,  %op2, i32 127)
+  // CHECK: ret  %[[INTRINSIC]]
+  // expected-warning@+1 {{implicit declaration of function 'svext_bf16'}}
+  return SVE_ACLE_FUNC(svext,_bf16,,)(op1, op2, 127);
+}

diff  --git a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td 
b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
index 7b807fd1c08a..f2a8d732326e 100644
--- a/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -1446,7 +1446,6 @@ multiclass sve_prefetch;
 def : Pat<(nxv8i16 (bitconvert (nxv2i64 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv8f16 ZPR:$src))), (nxv8i16 ZPR:$src)>;
-def : Pat<(nxv8i16 (bitconvert (nxv8bf16 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv4f32 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 def : Pat<(nxv8i16 (bitconvert (nxv2f64 ZPR:$src))), (nxv8i16 ZPR:$src)>;
 

diff  --git a/llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll 
b/llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
index 718e01b6170a..e5866c1b68ff 100644
--- a/llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
+++ b/llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@

[PATCH] D82711: [clang-tidy] Fix hicpp-named-paramater

2020-06-29 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I do not understand the justification here -- `IdentifierNamingCheck` and 
`NamedParameterCheck` are two different checks. How do you know that this swap 
continues to honor the HIC++ coding standard?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82711



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


  1   2   3   >