[PATCH] D89765: [LibTooling][Clang-cast] A Clang LibTool to convert C-style casts to C++ style casts and more.

2020-10-20 Thread Ray Zhang via Phabricator via cfe-commits
oneraynyday added a comment.

Hi there,

Thank you for taking a look! Sorry about the mess with diff's - this is my 
first time working with Arcanist. I thought `arc diff --update ` in 
Arcanist meant a push to the branch. Moving forward, should I use `arc diff` to 
add extra changes onto the code review?

Regarding clang-tidy, I listed some of the reasons why I currently have it 
formatted as a standalone tool in the `NOTES` section above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89765

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


[PATCH] D88154: Initial support for vectorization using Libmvec (GLIBC vector math library).

2020-10-20 Thread Venkataramanan Kumar via Phabricator via cfe-commits
venkataramanan.kumar.llvm updated this revision to Diff 299278.
venkataramanan.kumar.llvm added a comment.
Herald added a subscriber: dexonsmith.

Added a test case for testing  vector library calls for VF=2 and VF=8.


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

https://reviews.llvm.org/D88154

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/fveclib.c
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/include/llvm/Analysis/VecFuncs.def
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/test/CodeGen/X86/cpus-other.null
  llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-VF2-VF8.ll
  llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-finite.ll
  llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
  llvm/test/Transforms/Util/add-TLI-mappings.ll

Index: llvm/test/Transforms/Util/add-TLI-mappings.ll
===
--- llvm/test/Transforms/Util/add-TLI-mappings.ll
+++ llvm/test/Transforms/Util/add-TLI-mappings.ll
@@ -3,6 +3,8 @@
 ; RUN: opt -vector-library=MASSV  -inject-tli-mappings-S < %s | FileCheck %s  --check-prefixes=COMMON,MASSV
 ; RUN: opt -vector-library=MASSV  -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,MASSV
 ; RUN: opt -vector-library=Accelerate -inject-tli-mappings-S < %s | FileCheck %s  --check-prefixes=COMMON,ACCELERATE
+; RUN: opt -vector-library=LIBMVEC-X86 -inject-tli-mappings-S < %s | FileCheck %s  --check-prefixes=COMMON,LIBMVEC-X86
+; RUN: opt -vector-library=LIBMVEC-X86 -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,LIBMVEC-X86
 ; RUN: opt -vector-library=Accelerate -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,ACCELERATE
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@@ -21,6 +23,9 @@
 ; MASSV-SAME: i8* bitcast (<4 x float> (<4 x float>)* @__log10f4_massv to i8*)
 ; ACCELERATE-SAME:  [1 x i8*] [
 ; ACCELERATE-SAME:i8* bitcast (<4 x float> (<4 x float>)* @vlog10f to i8*)
+; LIBMVEC-X86-SAME: [2 x i8*] [
+; LIBMVEC-X86-SAME:   i8* bitcast (<2 x double> (<2 x double>)* @_ZGVbN2v_sin to i8*),
+; LIBMVEC-X86-SAME:   i8* bitcast (<4 x double> (<4 x double>)* @_ZGVdN4v_sin to i8*)
 ; COMMON-SAME:  ], section "llvm.metadata"
 
 define double @sin_f64(double %in) {
@@ -28,6 +33,7 @@
 ; SVML: call double @sin(double %{{.*}}) #[[SIN:[0-9]+]]
 ; MASSV:call double @sin(double %{{.*}}) #[[SIN:[0-9]+]]
 ; ACCELERATE:   call double @sin(double %{{.*}})
+; LIBMVEC-X86:  call double @sin(double %{{.*}}) #[[SIN:[0-9]+]]
 ; No mapping of "sin" to a vector function for Accelerate.
 ; ACCELERATE-NOT: _ZGV_LLVM_{{.*}}_sin({{.*}})
   %call = tail call double @sin(double %in)
@@ -39,10 +45,12 @@
 define float @call_llvm.log10.f32(float %in) {
 ; COMMON-LABEL: @call_llvm.log10.f32(
 ; SVML: call float @llvm.log10.f32(float %{{.*}})
+; LIBMVEC-X86:  call float @llvm.log10.f32(float %{{.*}})
 ; MASSV:call float @llvm.log10.f32(float %{{.*}}) #[[LOG10:[0-9]+]]
 ; ACCELERATE:   call float @llvm.log10.f32(float %{{.*}}) #[[LOG10:[0-9]+]]
 ; No mapping of "llvm.log10.f32" to a vector function for SVML.
 ; SVML-NOT: _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
+; LIBMVEC-X86-NOT: _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
   %call = tail call float @llvm.log10.f32(float %in)
   ret float %call
 }
@@ -62,3 +70,7 @@
 
 ; ACCELERATE:  attributes #[[LOG10]] = { "vector-function-abi-variant"=
 ; ACCELERATE-SAME:   "_ZGV_LLVM_N4v_llvm.log10.f32(vlog10f)" }
+
+; LIBMVEC-X86:  attributes #[[SIN]] = { "vector-function-abi-variant"=
+; LIBMVEC-X86-SAME:   "_ZGV_LLVM_N2v_sin(_ZGVbN2v_sin),
+; LIBMVEC-X86-SAME:   _ZGV_LLVM_N4v_sin(_ZGVdN4v_sin)" }
Index: llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
===
--- /dev/null
+++ llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
@@ -0,0 +1,373 @@
+; RUN: opt -vector-library=LIBMVEC-X86  -inject-tli-mappings -loop-vectorize -S < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @sin_f64(double* nocapture %varray) {
+; CHECK-LABEL: @sin_f64(
+; CHECK-LABEL:vector.body
+; CHECK:[[TMP5:%.*]] = call <4 x double> @_ZGVdN4v_sin(<4 x double> [[TMP4:%.*]])
+;
+entry:
+  br label %for.body
+
+for.body:
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
+  %tmp = trunc i64 %iv to i32
+  %conv = sitofp i32 %tmp to double
+  %call = tail call double @sin(double %conv)
+  %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
+  store double %call, double* %arrayidx, align 4
+  %iv.next = add nu

[PATCH] D89709: [clang-format] Drop clangFrontend dependency for FormatTests

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

LGTM, I'm for anything that speeds up the build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89709

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


[PATCH] D89770: Don't use C++17 features

2020-10-20 Thread Ray Zhang via Phabricator via cfe-commits
oneraynyday created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
oneraynyday requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89770

Files:
  clang-tools-extra/clang-cast/Matcher.h


Index: clang-tools-extra/clang-cast/Matcher.h
===
--- clang-tools-extra/clang-cast/Matcher.h
+++ clang-tools-extra/clang-cast/Matcher.h
@@ -169,7 +169,9 @@
 // TODO: Is this okay to do?
 Matcher::~Matcher() {
   if (PublishSummary) {
-for (auto const &[CXXCastKind, Freq] : Statistics) {
+for (const auto &Pair : Statistics) {
+  const auto &CXXCastKind = Pair.first;
+  const auto &Freq = Pair.second;
   if (!Freq)
 continue;
   llvm::errs() << "The type " << cppCastToString(CXXCastKind)


Index: clang-tools-extra/clang-cast/Matcher.h
===
--- clang-tools-extra/clang-cast/Matcher.h
+++ clang-tools-extra/clang-cast/Matcher.h
@@ -169,7 +169,9 @@
 // TODO: Is this okay to do?
 Matcher::~Matcher() {
   if (PublishSummary) {
-for (auto const &[CXXCastKind, Freq] : Statistics) {
+for (const auto &Pair : Statistics) {
+  const auto &CXXCastKind = Pair.first;
+  const auto &Freq = Pair.second;
   if (!Freq)
 continue;
   llvm::errs() << "The type " << cppCastToString(CXXCastKind)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D88154: Initial support for vectorization using Libmvec (GLIBC vector math library).

2020-10-20 Thread Venkataramanan Kumar via Phabricator via cfe-commits
venkataramanan.kumar.llvm updated this revision to Diff 299280.
venkataramanan.kumar.llvm added a comment.

Remove an incorrect file that got attached with my earlier patch.


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

https://reviews.llvm.org/D88154

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/fveclib.c
  llvm/include/llvm/Analysis/TargetLibraryInfo.h
  llvm/include/llvm/Analysis/VecFuncs.def
  llvm/lib/Analysis/TargetLibraryInfo.cpp
  llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-VF2-VF8.ll
  llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls-finite.ll
  llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
  llvm/test/Transforms/Util/add-TLI-mappings.ll

Index: llvm/test/Transforms/Util/add-TLI-mappings.ll
===
--- llvm/test/Transforms/Util/add-TLI-mappings.ll
+++ llvm/test/Transforms/Util/add-TLI-mappings.ll
@@ -3,6 +3,8 @@
 ; RUN: opt -vector-library=MASSV  -inject-tli-mappings-S < %s | FileCheck %s  --check-prefixes=COMMON,MASSV
 ; RUN: opt -vector-library=MASSV  -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,MASSV
 ; RUN: opt -vector-library=Accelerate -inject-tli-mappings-S < %s | FileCheck %s  --check-prefixes=COMMON,ACCELERATE
+; RUN: opt -vector-library=LIBMVEC-X86 -inject-tli-mappings-S < %s | FileCheck %s  --check-prefixes=COMMON,LIBMVEC-X86
+; RUN: opt -vector-library=LIBMVEC-X86 -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,LIBMVEC-X86
 ; RUN: opt -vector-library=Accelerate -passes=inject-tli-mappings -S < %s | FileCheck %s  --check-prefixes=COMMON,ACCELERATE
 
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
@@ -21,6 +23,9 @@
 ; MASSV-SAME: i8* bitcast (<4 x float> (<4 x float>)* @__log10f4_massv to i8*)
 ; ACCELERATE-SAME:  [1 x i8*] [
 ; ACCELERATE-SAME:i8* bitcast (<4 x float> (<4 x float>)* @vlog10f to i8*)
+; LIBMVEC-X86-SAME: [2 x i8*] [
+; LIBMVEC-X86-SAME:   i8* bitcast (<2 x double> (<2 x double>)* @_ZGVbN2v_sin to i8*),
+; LIBMVEC-X86-SAME:   i8* bitcast (<4 x double> (<4 x double>)* @_ZGVdN4v_sin to i8*)
 ; COMMON-SAME:  ], section "llvm.metadata"
 
 define double @sin_f64(double %in) {
@@ -28,6 +33,7 @@
 ; SVML: call double @sin(double %{{.*}}) #[[SIN:[0-9]+]]
 ; MASSV:call double @sin(double %{{.*}}) #[[SIN:[0-9]+]]
 ; ACCELERATE:   call double @sin(double %{{.*}})
+; LIBMVEC-X86:  call double @sin(double %{{.*}}) #[[SIN:[0-9]+]]
 ; No mapping of "sin" to a vector function for Accelerate.
 ; ACCELERATE-NOT: _ZGV_LLVM_{{.*}}_sin({{.*}})
   %call = tail call double @sin(double %in)
@@ -39,10 +45,12 @@
 define float @call_llvm.log10.f32(float %in) {
 ; COMMON-LABEL: @call_llvm.log10.f32(
 ; SVML: call float @llvm.log10.f32(float %{{.*}})
+; LIBMVEC-X86:  call float @llvm.log10.f32(float %{{.*}})
 ; MASSV:call float @llvm.log10.f32(float %{{.*}}) #[[LOG10:[0-9]+]]
 ; ACCELERATE:   call float @llvm.log10.f32(float %{{.*}}) #[[LOG10:[0-9]+]]
 ; No mapping of "llvm.log10.f32" to a vector function for SVML.
 ; SVML-NOT: _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
+; LIBMVEC-X86-NOT: _ZGV_LLVM_{{.*}}_llvm.log10.f32({{.*}})
   %call = tail call float @llvm.log10.f32(float %in)
   ret float %call
 }
@@ -62,3 +70,7 @@
 
 ; ACCELERATE:  attributes #[[LOG10]] = { "vector-function-abi-variant"=
 ; ACCELERATE-SAME:   "_ZGV_LLVM_N4v_llvm.log10.f32(vlog10f)" }
+
+; LIBMVEC-X86:  attributes #[[SIN]] = { "vector-function-abi-variant"=
+; LIBMVEC-X86-SAME:   "_ZGV_LLVM_N2v_sin(_ZGVbN2v_sin),
+; LIBMVEC-X86-SAME:   _ZGV_LLVM_N4v_sin(_ZGVdN4v_sin)" }
Index: llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
===
--- /dev/null
+++ llvm/test/Transforms/LoopVectorize/X86/libm-vector-calls.ll
@@ -0,0 +1,373 @@
+; RUN: opt -vector-library=LIBMVEC-X86  -inject-tli-mappings -loop-vectorize -S < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @sin_f64(double* nocapture %varray) {
+; CHECK-LABEL: @sin_f64(
+; CHECK-LABEL:vector.body
+; CHECK:[[TMP5:%.*]] = call <4 x double> @_ZGVdN4v_sin(<4 x double> [[TMP4:%.*]])
+;
+entry:
+  br label %for.body
+
+for.body:
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
+  %tmp = trunc i64 %iv to i32
+  %conv = sitofp i32 %tmp to double
+  %call = tail call double @sin(double %conv)
+  %arrayidx = getelementptr inbounds double, double* %varray, i64 %iv
+  store double %call, double* %arrayidx, align 4
+  %iv.next = add nuw nsw i64 %iv, 1
+  %exitcond = icmp eq i64 %iv.next, 1000
+  br i1 %exitcond, label

[PATCH] D88553: [clangd] Stash a patch piece

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 299281.
kbobyrev added a comment.

Add support for compound statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88553

Files:
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -203,26 +203,87 @@
 TEST(FoldingRanges, All) {
   const char *Tests[] = {
   R"cpp(
-[[int global_variable]];
+void func() {[[
+  int Variable = 100;
 
-[[void func() {
-  int v = 100;
-}]]
+  if (Variable > 42) {[[
+Variable = 10;
+++Variable;
+  ]]}
+
+
+  if (Variable >= 9000) {[[
+Variable -= 500;
+  ]]} else {[[
+Variable = 42;
+  ]]}
+
+  if (42 > 5) {[[
+Variable += 42;
+  ]]} else if (Variable++) {[[
+++Variable;
+  ]]} else {[[
+Variable--;
+  ]]}
+
+  bool OK = true;
+
+  if (OK) {[[
+Variable++;
+  ]]} else
+--Variable;
+
+  switch (Variable) {[[
+  case 1:
+++Variable;
+break;
+  case 2:
+break;
+  default:
+break;
+  ]]}
+]]}
   )cpp",
   R"cpp(
-[[class Foo {
+void foo() {[[
+  // Do not generate FoldingRange for empty CompoundStmts.
+  for (;;) {}
+
+  // However, if there are newlines between {}, we will still generate
+  // one.
+  for (;;) {[[
+
+  ]]}
+
+  unsigned Variable = 42;
+
+  for (int i = 0; i < 42; ++i) {[[
+Variable += 10;
+  ]]}
+
+  while (Variable) {[[
+Variable--;
+  ]]}
+
+  do {[[
+
+  ]]} while (Variable);
+]]}
+  )cpp",
+  R"cpp(
+class Foo {
 public:
-  [[Foo() {
+  Foo() {[[
 int X = 1;
-  }]]
+  ]]}
 
 private:
-  [[int getBar() {
+  int getBar() {[[
 return 42;
-  }]]
+  ]]}
 
-  [[void getFooBar() { }]]
-}]];
+  void getFooBar() { }
+};
   )cpp",
   };
   for (const char *Test : Tests) {
Index: clang-tools-extra/clangd/SemanticSelection.cpp
===
--- clang-tools-extra/clangd/SemanticSelection.cpp
+++ clang-tools-extra/clangd/SemanticSelection.cpp
@@ -13,8 +13,15 @@
 #include "SourceCode.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -28,17 +35,39 @@
   }
 }
 
-// Recursively collects FoldingRange from a symbol and its children.
-void collectFoldingRanges(DocumentSymbol Symbol,
-  std::vector &Result) {
+FoldingRange constructFoldingRange(SourceRange SR, const SourceManager &SM) {
   FoldingRange Range;
-  Range.startLine = Symbol.range.start.line;
-  Range.startCharacter = Symbol.range.start.character;
-  Range.endLine = Symbol.range.end.line;
-  Range.endCharacter = Symbol.range.end.character;
-  Result.push_back(Range);
-  for (const auto &Child : Symbol.children)
-collectFoldingRanges(Child, Result);
+  Range.startCharacter = SM.getSpellingColumnNumber(SR.getBegin()) - 1;
+  Range.startLine = SM.getSpellingLineNumber(SR.getBegin()) - 1;
+  Range.endCharacter = SM.getSpellingColumnNumber(SR.getEnd()) - 1;
+  Range.endLine = SM.getSpellingLineNumber(SR.getEnd()) - 1;
+  return Range;
+}
+
+// Traverse the tree and collect folding ranges along the way.
+void collectRanges(const syntax::Node *Node, const SourceManager &SM,
+   std::vector &Ranges) {
+  if (Node->getKind() == syntax::NodeKind::CompoundStatement) {
+const auto *Tree = dyn_cast(Node);
+assert(Tree);
+const syntax::Token *FirstToken = Tree->findFirstLeaf()->getToken(),
+*LastToken = Tree->findLastLeaf()->getToken();
+assert(FirstToken->kind() == tok::TokenKind::l_brace);
+assert(LastToken->kind() == tok::TokenKind::r_brace);
+const SourceRange SR(FirstToken->endLocation(), LastToken->location());
+FoldingRange Range = constructFoldingRange(SR, SM);
+// Do not generate folding range 

[PATCH] D89770: Don't use C++17 features

2020-10-20 Thread Ray Zhang via Phabricator via cfe-commits
oneraynyday updated this revision to Diff 299282.
oneraynyday added a comment.

C++17 features cause buildkite to fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89770

Files:
  clang-tools-extra/clang-cast/Matcher.h


Index: clang-tools-extra/clang-cast/Matcher.h
===
--- clang-tools-extra/clang-cast/Matcher.h
+++ clang-tools-extra/clang-cast/Matcher.h
@@ -169,7 +169,9 @@
 // TODO: Is this okay to do?
 Matcher::~Matcher() {
   if (PublishSummary) {
-for (auto const &[CXXCastKind, Freq] : Statistics) {
+for (const auto &Pair : Statistics) {
+  const auto &CXXCastKind = Pair.first;
+  const auto &Freq = Pair.second;
   if (!Freq)
 continue;
   llvm::errs() << "The type " << cppCastToString(CXXCastKind)


Index: clang-tools-extra/clang-cast/Matcher.h
===
--- clang-tools-extra/clang-cast/Matcher.h
+++ clang-tools-extra/clang-cast/Matcher.h
@@ -169,7 +169,9 @@
 // TODO: Is this okay to do?
 Matcher::~Matcher() {
   if (PublishSummary) {
-for (auto const &[CXXCastKind, Freq] : Statistics) {
+for (const auto &Pair : Statistics) {
+  const auto &CXXCastKind = Pair.first;
+  const auto &Freq = Pair.second;
   if (!Freq)
 continue;
   llvm::errs() << "The type " << cppCastToString(CXXCastKind)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80488: Teach `-fsanitize=fuzzer` to respect `-static` and `-static-libstdc++` when adding C++ standard libraries.

2020-10-20 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

LGTM, but it could be better with a test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80488

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


[PATCH] D88553: [clangd] Stash a patch piece

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 299284.
kbobyrev added a comment.

Add one more test and remove unused include.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88553

Files:
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -203,26 +203,91 @@
 TEST(FoldingRanges, All) {
   const char *Tests[] = {
   R"cpp(
-[[int global_variable]];
+void func() {[[
+  int Variable = 100;
 
-[[void func() {
-  int v = 100;
-}]]
+  if (Variable > 42) {[[
+Variable = 10;
+++Variable;
+  ]]}
+
+
+  if (Variable >= 9000) {[[
+Variable -= 500;
+  ]]} else {[[
+Variable = 42;
+  ]]}
+
+  if (42 > 5) {[[
+Variable += 42;
+  ]]} else if (Variable++) {[[
+++Variable;
+  ]]} else {[[
+Variable--;
+  ]]}
+
+  bool OK = true;
+
+  if (OK) {[[
+Variable++;
+  ]]} else
+--Variable;
+
+  {[[
+bool CompoundStmt = true;
+  ]]}
+]]}
+  )cpp",
+  R"cpp(
+void foo() {[[
+  // Do not generate FoldingRange for empty CompoundStmts.
+  for (;;) {}
+
+  // However, if there are newlines between {}, we will still generate
+  // one.
+  for (;;) {[[
+
+  ]]}
+
+  unsigned Variable = 42;
+
+  for (int i = 0; i < 42; ++i) {[[
+Variable += 10;
+  ]]}
+
+  while (Variable) {[[
+Variable--;
+  ]]}
+
+  do {[[
+
+  ]]} while (Variable);
+
+  switch (Variable) {[[
+  case 1:
+++Variable;
+break;
+  case 2:
+break;
+  default:
+break;
+  ]]}
+]]}
   )cpp",
   R"cpp(
-[[class Foo {
+class Foo {
 public:
-  [[Foo() {
+  Foo() {[[
 int X = 1;
-  }]]
+  ]]}
 
 private:
-  [[int getBar() {
+  int getBar() {[[
 return 42;
-  }]]
+  ]]}
 
-  [[void getFooBar() { }]]
-}]];
+  void getFooBar() { }
+};
   )cpp",
   };
   for (const char *Test : Tests) {
Index: clang-tools-extra/clangd/SemanticSelection.cpp
===
--- clang-tools-extra/clangd/SemanticSelection.cpp
+++ clang-tools-extra/clangd/SemanticSelection.cpp
@@ -13,8 +13,14 @@
 #include "SourceCode.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tree.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -28,17 +34,39 @@
   }
 }
 
-// Recursively collects FoldingRange from a symbol and its children.
-void collectFoldingRanges(DocumentSymbol Symbol,
-  std::vector &Result) {
+FoldingRange constructFoldingRange(SourceRange SR, const SourceManager &SM) {
   FoldingRange Range;
-  Range.startLine = Symbol.range.start.line;
-  Range.startCharacter = Symbol.range.start.character;
-  Range.endLine = Symbol.range.end.line;
-  Range.endCharacter = Symbol.range.end.character;
-  Result.push_back(Range);
-  for (const auto &Child : Symbol.children)
-collectFoldingRanges(Child, Result);
+  Range.startCharacter = SM.getSpellingColumnNumber(SR.getBegin()) - 1;
+  Range.startLine = SM.getSpellingLineNumber(SR.getBegin()) - 1;
+  Range.endCharacter = SM.getSpellingColumnNumber(SR.getEnd()) - 1;
+  Range.endLine = SM.getSpellingLineNumber(SR.getEnd()) - 1;
+  return Range;
+}
+
+// Traverse the tree and collect folding ranges along the way.
+void collectRanges(const syntax::Node *Node, const SourceManager &SM,
+   std::vector &Ranges) {
+  if (Node->getKind() == syntax::NodeKind::CompoundStatement) {
+const auto *Tree = dyn_cast(Node);
+assert(Tree);
+const syntax::Token *FirstToken = Tree->findFirstLeaf()->getToken(),
+*LastToken = Tree->findLastLeaf()->getToken();
+assert(FirstToken->kind() == tok::TokenKind::l_brace);
+assert(LastToken->kind() == tok::TokenKind::r_brace);
+const SourceRange SR(FirstToken->endLocation(), LastToken->location());
+FoldingRange Range = constructFoldingRange(SR,

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

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

@sammccall I've reduced the patch to the bare minimum (compound statements) as 
I've had some issues with couple of other kinds of folding ranges and I'll be 
adding support for the node kinds one by one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88553

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


[PATCH] D89771: [clangd] NFC: Resolve Clang-Tidy warnings in Protocol.cpp

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89771

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


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -179,10 +179,12 @@
 if (*S == "off") {
   Out = TraceLevel::Off;
   return true;
-} else if (*S == "messages") {
+}
+if (*S == "messages") {
   Out = TraceLevel::Messages;
   return true;
-} else if (*S == "verbose") {
+}
+if (*S == "verbose") {
   Out = TraceLevel::Verbose;
   return true;
 }


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -179,10 +179,12 @@
 if (*S == "off") {
   Out = TraceLevel::Off;
   return true;
-} else if (*S == "messages") {
+}
+if (*S == "messages") {
   Out = TraceLevel::Messages;
   return true;
-} else if (*S == "verbose") {
+}
+if (*S == "verbose") {
   Out = TraceLevel::Verbose;
   return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89771: [clangd] NFC: Resolve Clang-Tidy warnings in Protocol.cpp

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 299288.
kbobyrev added a comment.

Add forgotten fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89771

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


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -179,10 +179,12 @@
 if (*S == "off") {
   Out = TraceLevel::Off;
   return true;
-} else if (*S == "messages") {
+}
+if (*S == "messages") {
   Out = TraceLevel::Messages;
   return true;
-} else if (*S == "verbose") {
+}
+if (*S == "verbose") {
   Out = TraceLevel::Verbose;
   return true;
 }
@@ -319,7 +321,8 @@
   if (auto *Item = Completion->getObject("completionItem")) {
 if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
   R.CompletionSnippets = *SnippetSupport;
-if (auto DocumentationFormat = Item->getArray("documentationFormat")) {
+if (const auto *DocumentationFormat =
+Item->getArray("documentationFormat")) {
   for (const auto &Format : *DocumentationFormat) {
 if (fromJSON(Format, R.CompletionDocumentationFormat, P))
   break;
@@ -645,7 +648,7 @@
   if (!O || !O.map("command", R.command))
 return false;
 
-  auto Args = Params.getAsObject()->getArray("arguments");
+  const auto *Args = Params.getAsObject()->getArray("arguments");
   if (R.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND) {
 return Args && Args->size() == 1 &&
fromJSON(Args->front(), R.workspaceEdit,


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -179,10 +179,12 @@
 if (*S == "off") {
   Out = TraceLevel::Off;
   return true;
-} else if (*S == "messages") {
+}
+if (*S == "messages") {
   Out = TraceLevel::Messages;
   return true;
-} else if (*S == "verbose") {
+}
+if (*S == "verbose") {
   Out = TraceLevel::Verbose;
   return true;
 }
@@ -319,7 +321,8 @@
   if (auto *Item = Completion->getObject("completionItem")) {
 if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
   R.CompletionSnippets = *SnippetSupport;
-if (auto DocumentationFormat = Item->getArray("documentationFormat")) {
+if (const auto *DocumentationFormat =
+Item->getArray("documentationFormat")) {
   for (const auto &Format : *DocumentationFormat) {
 if (fromJSON(Format, R.CompletionDocumentationFormat, P))
   break;
@@ -645,7 +648,7 @@
   if (!O || !O.map("command", R.command))
 return false;
 
-  auto Args = Params.getAsObject()->getArray("arguments");
+  const auto *Args = Params.getAsObject()->getArray("arguments");
   if (R.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND) {
 return Args && Args->size() == 1 &&
fromJSON(Args->front(), R.workspaceEdit,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78658: [clang][Frontend] Add missing error handling

2020-10-20 Thread LemonBoy via Phabricator via cfe-commits
LemonBoy added a comment.

> Looks good to me - thanks!

Great! Can you please commit this for me as I have no commit access?


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

https://reviews.llvm.org/D78658

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


[PATCH] D88640: [Format] Don't treat compound extension headers (foo.proto.h) as foo.cc main file.

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

In D88640#2339349 , @rupprecht wrote:

> It looks like this fix caused a different regression in not accepting 
> `name..h` as the main header for `name..cc`, e.g.:
>
>   $ cat /tmp/foo.bar.cc
>   #include "a.h"
>   #include "z.h"
>   #include "foo.bar.h"
>   
>   $ clang-format /tmp/foo.bar.cc  # Before
>   #include "foo.bar.h"
>   
>   #include "a.h"
>   #include "z.h"
>   
>   $ clang-format /tmp/foo.bar.cc  # After
>   #include "a.h"
>   #include "foo.bar.h"
>   #include "z.h"

oh, sorry for the regression. Will try to fix that, thanks for the example!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88640

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


[clang] f2cca0b - Silence unused variable warning in Release builds. NFCI.

2020-10-20 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2020-10-20T10:48:48+02:00
New Revision: f2cca0b291491f25dc6d2c073d71a2799625ad3b

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

LOG: Silence unused variable warning in Release builds. NFCI.

Added: 


Modified: 
clang/lib/AST/Decl.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 5084f867622f4..b3a67715d604b 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2451,8 +2451,7 @@ bool VarDecl::checkForConstantInitialization(
  "already evaluated var value before checking for constant init");
   assert(getASTContext().getLangOpts().CPlusPlus && "only meaningful in C++");
 
-  const auto *Init = cast(Eval->Value);
-  assert(!Init->isValueDependent());
+  assert(!cast(Eval->Value)->isValueDependent());
 
   // Evaluate the initializer to check whether it's a constant expression.
   Eval->HasConstantInitialization =



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


[PATCH] D89670: [clangd] Store the containing symbol for refs

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



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:349
+SymbolRef{SM.getFileLoc(Loc), Roles,
+  dyn_cast_or_null(ASTNode.Parent)});
   // Don't continue indexing if this is a mere reference.

What does `ASTNode.Parent` correspond to in here? I couldn't find any 
clarifications on libIndex side, are we sure that's always what we want? It 
would be nice to have some tests demonstrating what this corresponds to in a 
variety of cases.

Also why do we only store `NamedDecl`s as containers? It makes sense from 
CallHierarchy perspective as we are only interested in function-like 
containers, and they are nameddecls (?). But these might as well be 
`TranslationUnitDecl` (?) for top level declarations,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89670

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


[PATCH] D89708: Move clang/Tooling/Core/Lookup.h to clang/Tooling/Refactoring/Lookup.h

2020-10-20 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2214757e2ca: Move clang/Tooling/Core/Lookup.h to 
clang/Tooling/Refactoring/Lookup.h (authored by arichardson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89708

Files:
  clang/include/clang/Tooling/Core/Lookup.h
  clang/include/clang/Tooling/Refactoring/Lookup.h
  clang/lib/Format/FormatInternal.h
  clang/lib/Tooling/Core/CMakeLists.txt
  clang/lib/Tooling/Core/Lookup.cpp
  clang/lib/Tooling/Refactoring/CMakeLists.txt
  clang/lib/Tooling/Refactoring/Lookup.cpp
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  clang/unittests/Tooling/LookupTest.cpp

Index: clang/unittests/Tooling/LookupTest.cpp
===
--- clang/unittests/Tooling/LookupTest.cpp
+++ clang/unittests/Tooling/LookupTest.cpp
@@ -6,8 +6,8 @@
 //
 //===--===//
 
+#include "clang/Tooling/Refactoring/Lookup.h"
 #include "TestVisitor.h"
-#include "clang/Tooling/Core/Lookup.h"
 using namespace clang;
 
 namespace {
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -21,7 +21,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/Tooling/Core/Lookup.h"
+#include "clang/Tooling/Refactoring/Lookup.h"
 #include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
 #include "clang/Tooling/Refactoring/Rename/SymbolName.h"
 #include "clang/Tooling/Refactoring/Rename/USRFinder.h"
Index: clang/lib/Tooling/Refactoring/Lookup.cpp
===
--- clang/lib/Tooling/Refactoring/Lookup.cpp
+++ clang/lib/Tooling/Refactoring/Lookup.cpp
@@ -10,7 +10,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/Lookup.h"
+#include "clang/Tooling/Refactoring/Lookup.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
Index: clang/lib/Tooling/Refactoring/CMakeLists.txt
===
--- clang/lib/Tooling/Refactoring/CMakeLists.txt
+++ clang/lib/Tooling/Refactoring/CMakeLists.txt
@@ -6,6 +6,7 @@
   AtomicChange.cpp
   Extract/Extract.cpp
   Extract/SourceExtraction.cpp
+  Lookup.cpp
   RefactoringActions.cpp
   Rename/RenamingAction.cpp
   Rename/SymbolOccurrences.cpp
Index: clang/lib/Tooling/Core/CMakeLists.txt
===
--- clang/lib/Tooling/Core/CMakeLists.txt
+++ clang/lib/Tooling/Core/CMakeLists.txt
@@ -2,11 +2,9 @@
 
 add_clang_library(clangToolingCore
   Diagnostic.cpp
-  Lookup.cpp
   Replacement.cpp
 
   LINK_LIBS
-  clangAST
   clangBasic
   clangLex
   clangRewrite
Index: clang/lib/Format/FormatInternal.h
===
--- clang/lib/Format/FormatInternal.h
+++ clang/lib/Format/FormatInternal.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_LIB_FORMAT_FORMATINTERNAL_H
 
 #include "BreakableToken.h"
-#include "clang/Tooling/Core/Lookup.h"
 #include 
 
 namespace clang {
Index: clang/include/clang/Tooling/Refactoring/Lookup.h
===
--- clang/include/clang/Tooling/Refactoring/Lookup.h
+++ clang/include/clang/Tooling/Refactoring/Lookup.h
@@ -10,8 +10,8 @@
 //
 //===--===//
 
-#ifndef LLVM_CLANG_TOOLING_CORE_LOOKUP_H
-#define LLVM_CLANG_TOOLING_CORE_LOOKUP_H
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
+#define LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
 
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
@@ -47,4 +47,4 @@
 } // end namespace tooling
 } // end namespace clang
 
-#endif // LLVM_CLANG_TOOLING_CORE_LOOKUP_H
+#endif // LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a221475 - Move clang/Tooling/Core/Lookup.h to clang/Tooling/Refactoring/Lookup.h

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

Author: Alex Richardson
Date: 2020-10-20T10:13:28+01:00
New Revision: a2214757e2ca445112f19395493a78e820389655

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

LOG: Move clang/Tooling/Core/Lookup.h to clang/Tooling/Refactoring/Lookup.h

This allows removing the clangAST dependency from libclangToolingCore and
therefore allows clang-format to be built without depending on clangAST.
Before 1166 files had to be compiled for clang-format, now only 796.

Reviewed By: bkramer

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

Added: 
clang/include/clang/Tooling/Refactoring/Lookup.h
clang/lib/Tooling/Refactoring/Lookup.cpp

Modified: 
clang/lib/Format/FormatInternal.h
clang/lib/Tooling/Core/CMakeLists.txt
clang/lib/Tooling/Refactoring/CMakeLists.txt
clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
clang/unittests/Tooling/LookupTest.cpp

Removed: 
clang/include/clang/Tooling/Core/Lookup.h
clang/lib/Tooling/Core/Lookup.cpp



diff  --git a/clang/include/clang/Tooling/Core/Lookup.h 
b/clang/include/clang/Tooling/Refactoring/Lookup.h
similarity index 93%
rename from clang/include/clang/Tooling/Core/Lookup.h
rename to clang/include/clang/Tooling/Refactoring/Lookup.h
index 02b561c14f29..448bc422c4e7 100644
--- a/clang/include/clang/Tooling/Core/Lookup.h
+++ b/clang/include/clang/Tooling/Refactoring/Lookup.h
@@ -10,8 +10,8 @@
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_TOOLING_CORE_LOOKUP_H
-#define LLVM_CLANG_TOOLING_CORE_LOOKUP_H
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
+#define LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H
 
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
@@ -47,4 +47,4 @@ std::string replaceNestedName(const NestedNameSpecifier *Use,
 } // end namespace tooling
 } // end namespace clang
 
-#endif // LLVM_CLANG_TOOLING_CORE_LOOKUP_H
+#endif // LLVM_CLANG_TOOLING_REFACTOR_LOOKUP_H

diff  --git a/clang/lib/Format/FormatInternal.h 
b/clang/lib/Format/FormatInternal.h
index 3aa616da23d8..9043ce32e9e3 100644
--- a/clang/lib/Format/FormatInternal.h
+++ b/clang/lib/Format/FormatInternal.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_LIB_FORMAT_FORMATINTERNAL_H
 
 #include "BreakableToken.h"
-#include "clang/Tooling/Core/Lookup.h"
 #include 
 
 namespace clang {

diff  --git a/clang/lib/Tooling/Core/CMakeLists.txt 
b/clang/lib/Tooling/Core/CMakeLists.txt
index f7f423c52228..e523ca45301e 100644
--- a/clang/lib/Tooling/Core/CMakeLists.txt
+++ b/clang/lib/Tooling/Core/CMakeLists.txt
@@ -2,11 +2,9 @@ set(LLVM_LINK_COMPONENTS support)
 
 add_clang_library(clangToolingCore
   Diagnostic.cpp
-  Lookup.cpp
   Replacement.cpp
 
   LINK_LIBS
-  clangAST
   clangBasic
   clangLex
   clangRewrite

diff  --git a/clang/lib/Tooling/Refactoring/CMakeLists.txt 
b/clang/lib/Tooling/Refactoring/CMakeLists.txt
index 0565de224bbc..d3077be8810a 100644
--- a/clang/lib/Tooling/Refactoring/CMakeLists.txt
+++ b/clang/lib/Tooling/Refactoring/CMakeLists.txt
@@ -6,6 +6,7 @@ add_clang_library(clangToolingRefactoring
   AtomicChange.cpp
   Extract/Extract.cpp
   Extract/SourceExtraction.cpp
+  Lookup.cpp
   RefactoringActions.cpp
   Rename/RenamingAction.cpp
   Rename/SymbolOccurrences.cpp

diff  --git a/clang/lib/Tooling/Core/Lookup.cpp 
b/clang/lib/Tooling/Refactoring/Lookup.cpp
similarity index 99%
rename from clang/lib/Tooling/Core/Lookup.cpp
rename to clang/lib/Tooling/Refactoring/Lookup.cpp
index 712724a268fb..9468d4d032a7 100644
--- a/clang/lib/Tooling/Core/Lookup.cpp
+++ b/clang/lib/Tooling/Refactoring/Lookup.cpp
@@ -10,7 +10,7 @@
 //
 
//===--===//
 
-#include "clang/Tooling/Core/Lookup.h"
+#include "clang/Tooling/Refactoring/Lookup.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"

diff  --git a/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp 
b/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
index dfc319dd0639..6a08c7fd5247 100644
--- a/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -21,7 +21,7 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
-#include "clang/Tooling/Core/Lookup.h"
+#include "clang/Tooling/Refactoring/Lookup.h"
 #include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
 #include "clang/Tooling/Refactoring/Rename/SymbolName.h"
 #include "clang/Tooling/Refactoring/Rename/USRFinder.h"

diff  --git a/clang/unittests/Tooling/LookupTest.cpp 
b/clang/unittests/Tooling/LookupTest.cpp
index 372cbbf62b7a..05494cb42d90 100644
--- a/clang/unittests/Tooling/LookupTest.cpp
+++ b/clang/unittests/Tooling/LookupTest.cpp
@@ -6

[PATCH] D89709: [clang-format] Drop clangFrontend dependency for FormatTests

2020-10-20 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66a3b9073ac1: [clang-format] Drop clangFrontend dependency 
for FormatTests (authored by arichardson).

Changed prior to commit:
  https://reviews.llvm.org/D89709?vs=299078&id=299302#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89709

Files:
  clang/unittests/Format/CMakeLists.txt
  clang/unittests/Format/CleanupTest.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestComments.cpp
  clang/unittests/Format/FormatTestObjC.cpp
  clang/unittests/Format/FormatTestRawStrings.cpp
  clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
  clang/unittests/Tooling/RewriterTestContext.h

Index: clang/unittests/Tooling/RewriterTestContext.h
===
--- clang/unittests/Tooling/RewriterTestContext.h
+++ clang/unittests/Tooling/RewriterTestContext.h
@@ -18,7 +18,6 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -26,6 +25,22 @@
 
 namespace clang {
 
+/// \brief A very simple diagnostic consumer that prints to stderr and keeps
+/// track of the number of diagnostics.
+///
+/// This avoids a dependency on clangFrontend for FormatTests.
+struct RewriterDiagnosticConsumer : public DiagnosticConsumer {
+  RewriterDiagnosticConsumer() : NumDiagnosticsSeen(0) {}
+  void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
+const Diagnostic &Info) override {
+++NumDiagnosticsSeen;
+SmallString<100> OutStr;
+Info.FormatDiagnostic(OutStr);
+llvm::errs() << OutStr;
+  }
+  unsigned NumDiagnosticsSeen;
+};
+
 /// \brief A class that sets up a ready to use Rewriter.
 ///
 /// Useful in unit tests that need a Rewriter. Creates all dependencies
@@ -37,7 +52,6 @@
: DiagOpts(new DiagnosticOptions()),
  Diagnostics(IntrusiveRefCntPtr(new DiagnosticIDs),
  &*DiagOpts),
- DiagnosticPrinter(llvm::outs(), &*DiagOpts),
  InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
  OverlayFileSystem(
  new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem())),
@@ -113,7 +127,7 @@
 
   IntrusiveRefCntPtr DiagOpts;
   DiagnosticsEngine Diagnostics;
-  TextDiagnosticPrinter DiagnosticPrinter;
+  RewriterDiagnosticConsumer DiagnosticPrinter;
   IntrusiveRefCntPtr InMemoryFileSystem;
   IntrusiveRefCntPtr OverlayFileSystem;
   FileManager Files;
Index: clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
===
--- clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -8,7 +8,6 @@
 
 #include "clang/Format/Format.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 
Index: clang/unittests/Format/FormatTestRawStrings.cpp
===
--- clang/unittests/Format/FormatTestRawStrings.cpp
+++ clang/unittests/Format/FormatTestRawStrings.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
Index: clang/unittests/Format/FormatTestObjC.cpp
===
--- clang/unittests/Format/FormatTestObjC.cpp
+++ clang/unittests/Format/FormatTestObjC.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #inc

[clang] 66a3b90 - [clang-format] Drop clangFrontend dependency for FormatTests

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

Author: Alex Richardson
Date: 2020-10-20T10:13:28+01:00
New Revision: 66a3b9073ac116f0ee39baf625c733abe18140e5

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

LOG: [clang-format] Drop clangFrontend dependency for FormatTests

This allows building the clang-format unit tests in only 657 ninja steps
rather than 1257 which allows for much faster incremental builds after a
git pull.

Reviewed By: MyDeveloperDay
Differential Revision: https://reviews.llvm.org/D89709

Added: 


Modified: 
clang/unittests/Format/CMakeLists.txt
clang/unittests/Format/CleanupTest.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestComments.cpp
clang/unittests/Format/FormatTestObjC.cpp
clang/unittests/Format/FormatTestRawStrings.cpp
clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
clang/unittests/Tooling/RewriterTestContext.h

Removed: 




diff  --git a/clang/unittests/Format/CMakeLists.txt 
b/clang/unittests/Format/CMakeLists.txt
index d0cc2cae179f..472e6eec40af 100644
--- a/clang/unittests/Format/CMakeLists.txt
+++ b/clang/unittests/Format/CMakeLists.txt
@@ -27,7 +27,6 @@ clang_target_link_libraries(FormatTests
   PRIVATE
   clangBasic
   clangFormat
-  clangFrontend
   clangRewrite
   clangToolingCore
   )

diff  --git a/clang/unittests/Format/CleanupTest.cpp 
b/clang/unittests/Format/CleanupTest.cpp
index 9649b981d558..dc149b502bc5 100644
--- a/clang/unittests/Format/CleanupTest.cpp
+++ b/clang/unittests/Format/CleanupTest.cpp
@@ -9,7 +9,6 @@
 #include "clang/Format/Format.h"
 
 #include "../Tooling/ReplacementTest.h"
-#include "../Tooling/RewriterTestContext.h"
 #include "clang/Tooling/Core/Replacement.h"
 
 #include "gtest/gtest.h"

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 1bdd7062fbb8..be9c84332265 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"

diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index 34d6b62b26c8..95afb17114a2 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"

diff  --git a/clang/unittests/Format/FormatTestObjC.cpp 
b/clang/unittests/Format/FormatTestObjC.cpp
index 21b8d4701271..a34a0832286b 100644
--- a/clang/unittests/Format/FormatTestObjC.cpp
+++ b/clang/unittests/Format/FormatTestObjC.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"

diff  --git a/clang/unittests/Format/FormatTestRawStrings.cpp 
b/clang/unittests/Format/FormatTestRawStrings.cpp
index 31490355468e..6310fe510fd3 100644
--- a/clang/unittests/Format/FormatTestRawStrings.cpp
+++ b/clang/unittests/Format/FormatTestRawStrings.cpp
@@ -11,7 +11,6 @@
 #include "../Tooling/ReplacementTest.h"
 #include "FormatTestUtils.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "gtest/gtest.h"

diff  --git a/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp 
b/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
index 463afa67e8b0..3340e02f4a1c 100644
--- a/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
+++ b/clang/unittests/Format/NamespaceEndCommentsFixerTest.cpp
@@ -8,7 +8,6 @@
 
 #include "clang/Format/Format.h"
 
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "llvm/Support/Debug.h"
 #include "gtest/gtest.h"
 

diff  --git a/clang/unittests/Tooling/RewriterTestContext.h 
b/clang/unittests/Tooling/RewriterTestContext.h
index 99f7a11dca98..ae2d2baa0fdc 100644
--- a/clang/unittests/Tooling/RewriterTestContext.h
+++ b/clang/unittests/Tooling/RewriterTestContext.h
@@ -18,7 +18,6 @@
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/SourceManager.h"
-#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -26,6 +25,22 @@
 
 namespace clang {
 
+/// \brief A very simple diagnostic consumer that prints to stderr 

[PATCH] D89771: [clangd] NFC: Resolve Clang-Tidy warnings in Protocol.cpp

2020-10-20 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG691eb814c1ae: [clangd] NFC: Resolve Clang-Tidy warnings in 
Protocol.cpp (authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89771

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


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -179,10 +179,12 @@
 if (*S == "off") {
   Out = TraceLevel::Off;
   return true;
-} else if (*S == "messages") {
+}
+if (*S == "messages") {
   Out = TraceLevel::Messages;
   return true;
-} else if (*S == "verbose") {
+}
+if (*S == "verbose") {
   Out = TraceLevel::Verbose;
   return true;
 }
@@ -319,7 +321,8 @@
   if (auto *Item = Completion->getObject("completionItem")) {
 if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
   R.CompletionSnippets = *SnippetSupport;
-if (auto DocumentationFormat = Item->getArray("documentationFormat")) {
+if (const auto *DocumentationFormat =
+Item->getArray("documentationFormat")) {
   for (const auto &Format : *DocumentationFormat) {
 if (fromJSON(Format, R.CompletionDocumentationFormat, P))
   break;
@@ -645,7 +648,7 @@
   if (!O || !O.map("command", R.command))
 return false;
 
-  auto Args = Params.getAsObject()->getArray("arguments");
+  const auto *Args = Params.getAsObject()->getArray("arguments");
   if (R.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND) {
 return Args && Args->size() == 1 &&
fromJSON(Args->front(), R.workspaceEdit,


Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -179,10 +179,12 @@
 if (*S == "off") {
   Out = TraceLevel::Off;
   return true;
-} else if (*S == "messages") {
+}
+if (*S == "messages") {
   Out = TraceLevel::Messages;
   return true;
-} else if (*S == "verbose") {
+}
+if (*S == "verbose") {
   Out = TraceLevel::Verbose;
   return true;
 }
@@ -319,7 +321,8 @@
   if (auto *Item = Completion->getObject("completionItem")) {
 if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
   R.CompletionSnippets = *SnippetSupport;
-if (auto DocumentationFormat = Item->getArray("documentationFormat")) {
+if (const auto *DocumentationFormat =
+Item->getArray("documentationFormat")) {
   for (const auto &Format : *DocumentationFormat) {
 if (fromJSON(Format, R.CompletionDocumentationFormat, P))
   break;
@@ -645,7 +648,7 @@
   if (!O || !O.map("command", R.command))
 return false;
 
-  auto Args = Params.getAsObject()->getArray("arguments");
+  const auto *Args = Params.getAsObject()->getArray("arguments");
   if (R.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND) {
 return Args && Args->size() == 1 &&
fromJSON(Args->front(), R.workspaceEdit,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 691eb81 - [clangd] NFC: Resolve Clang-Tidy warnings in Protocol.cpp

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

Author: Kirill Bobyrev
Date: 2020-10-20T11:23:40+02:00
New Revision: 691eb814c1ae38d5015bf070dfed3fd54d542582

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

LOG: [clangd] NFC: Resolve Clang-Tidy warnings in Protocol.cpp

Reviewed By: kadircet

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 0b89c622e6f8..0103a06ff951 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -179,10 +179,12 @@ bool fromJSON(const llvm::json::Value &E, TraceLevel 
&Out, llvm::json::Path P) {
 if (*S == "off") {
   Out = TraceLevel::Off;
   return true;
-} else if (*S == "messages") {
+}
+if (*S == "messages") {
   Out = TraceLevel::Messages;
   return true;
-} else if (*S == "verbose") {
+}
+if (*S == "verbose") {
   Out = TraceLevel::Verbose;
   return true;
 }
@@ -319,7 +321,8 @@ bool fromJSON(const llvm::json::Value &Params, 
ClientCapabilities &R,
   if (auto *Item = Completion->getObject("completionItem")) {
 if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
   R.CompletionSnippets = *SnippetSupport;
-if (auto DocumentationFormat = Item->getArray("documentationFormat")) {
+if (const auto *DocumentationFormat =
+Item->getArray("documentationFormat")) {
   for (const auto &Format : *DocumentationFormat) {
 if (fromJSON(Format, R.CompletionDocumentationFormat, P))
   break;
@@ -645,7 +648,7 @@ bool fromJSON(const llvm::json::Value &Params, 
ExecuteCommandParams &R,
   if (!O || !O.map("command", R.command))
 return false;
 
-  auto Args = Params.getAsObject()->getArray("arguments");
+  const auto *Args = Params.getAsObject()->getArray("arguments");
   if (R.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND) {
 return Args && Args->size() == 1 &&
fromJSON(Args->front(), R.workspaceEdit,



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


[PATCH] D89783: [format] foo..h should be the main-header for foo..cc

2020-10-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: adamcz.
Herald added a project: clang.
hokein requested review of this revision.

This fixes a regression introduced in https://reviews.llvm.org/D88640.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89783

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -151,7 +151,7 @@
   EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), 
"a.cc").empty());
 }
 
-TEST_F(SortIncludesTest, NoMainFileHeader) {
+TEST_F(SortIncludesTest, MainFileHeader) {
   std::string Code = "#include \n"
  "\n"
  "#include \"a/extra_action.proto.h\"\n";
@@ -159,6 +159,13 @@
   EXPECT_TRUE(
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a/extra_action.cc")
   .empty());
+
+  EXPECT_EQ("#include \"foo.bar.h\"\n"
+"\n"
+"#include \"a.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"foo.bar.h\"\n",
+ "foo.bar.cc"));
 }
 
 TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -190,7 +190,6 @@
 IncludeCategoryManager::IncludeCategoryManager(const IncludeStyle &Style,
StringRef FileName)
 : Style(Style), FileName(FileName) {
-  FileStem = matchingStem(FileName);
   for (const auto &Category : Style.IncludeCategories)
 CategoryRegexs.emplace_back(Category.Regex, llvm::Regex::IgnoreCase);
   IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") ||
@@ -234,16 +233,30 @@
   if (!IncludeName.startswith("\""))
 return false;
 
+  IncludeName =
+  IncludeName.drop_front(1).drop_back(1); // remove the surrounding "" or 
<>
   // Not matchingStem: implementation files may have compound extensions but
   // headers may not.
-  StringRef HeaderStem =
-  llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(
-  1) /* remove the surrounding "" or <> */);
-  if (FileStem.startswith(HeaderStem) ||
-  FileStem.startswith_lower(HeaderStem)) {
+  StringRef HeaderStem = llvm::sys::path::stem(IncludeName);
+  StringRef FileStem = llvm::sys::path::stem(FileName); // foo.cu for foo.cu.cc
+  StringRef MatchingFileStem = matchingStem(FileName);  // foo for foo.cu.cc
+  // main-header examples:
+  //   1) foo.h => foo.cc
+  //   2) foo.h => foo..cc (e.g. foo.cu.cc)
+  //   3) foo..h => foo..cc
+  //
+  // non-main-header examples:
+  //  foo.proto.h => foo.cc
+  //  foo.h => bar.cc
+  StringRef Matching;
+  if (MatchingFileStem.startswith_lower(HeaderStem))
+Matching = MatchingFileStem; // example 1), 2)
+  else if (FileStem.equals_lower(HeaderStem))
+Matching = FileStem; // example 3)
+  if (!Matching.empty()) {
 llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,
  llvm::Regex::IgnoreCase);
-if (MainIncludeRegex.match(FileStem))
+if (MainIncludeRegex.match(Matching))
   return true;
   }
   return false;
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -40,8 +40,6 @@
   const IncludeStyle Style;
   bool IsMainFile;
   std::string FileName;
-  // This refers to a substring in FileName.
-  StringRef FileStem;
   SmallVector CategoryRegexs;
 };
 


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -151,7 +151,7 @@
   EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a.cc").empty());
 }
 
-TEST_F(SortIncludesTest, NoMainFileHeader) {
+TEST_F(SortIncludesTest, MainFileHeader) {
   std::string Code = "#include \n"
  "\n"
  "#include \"a/extra_action.proto.h\"\n";
@@ -159,6 +159,13 @@
   EXPECT_TRUE(
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a/extra_action.cc")
   .empty());
+
+  EXPECT_EQ("#include \"foo.bar.h\"\n"
+"\n"
+"#include \"a.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"foo.bar.h\"\n",
+ "foo.bar.cc"));
 }
 
 TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
Index: clang/lib/Tooling/Inclusions/H

[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

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

Looks like there are some failing tests in premerge bots, e.g. 
https://reviews.llvm.org/harbormaster/unit/view/185822/

Also run `clang/docs/tools/dump_ast_matchers.py` script to update the 
`LibASTMatchersReference.html` file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743

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


[PATCH] D89301: [X86] Add user-level interrupt instructions

2020-10-20 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing updated this revision to Diff 299317.
tianqing added a comment.
Herald added a subscriber: dexonsmith.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89301

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/BuiltinsX86_64.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/uintrintrin.h
  clang/lib/Headers/x86gprintrin.h
  clang/test/CodeGen/X86/x86-uintr-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/include/llvm/Support/X86TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Support/X86TargetParser.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/uintr-intrinsics.ll
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/x86-64.s

Index: llvm/test/MC/X86/x86-64.s
===
--- llvm/test/MC/X86/x86-64.s
+++ llvm/test/MC/X86/x86-64.s
@@ -2018,3 +2018,35 @@
 // CHECK: hreset
 // CHECK: encoding: [0xf3,0x0f,0x3a,0xf0,0xc0,0x01]
 hreset $1
+
+// CHECK: uiret
+// CHECK: encoding: [0xf3,0x0f,0x01,0xec]
+uiret
+
+// CHECK: clui
+// CHECK: encoding: [0xf3,0x0f,0x01,0xee]
+clui
+
+// CHECK: stui
+// CHECK: encoding: [0xf3,0x0f,0x01,0xef]
+stui
+
+// CHECK: testui
+// CHECK: encoding: [0xf3,0x0f,0x01,0xed]
+testui
+
+// CHECK: senduipi %rax
+// CHECK: encoding: [0xf3,0x0f,0xc7,0xf0]
+senduipi %rax
+
+// CHECK: senduipi %rdx
+// CHECK: encoding: [0xf3,0x0f,0xc7,0xf2]
+senduipi %rdx
+
+// CHECK: senduipi %r8
+// CHECK: encoding: [0xf3,0x41,0x0f,0xc7,0xf0]
+senduipi %r8
+
+// CHECK: senduipi %r13
+// CHECK: encoding: [0xf3,0x41,0x0f,0xc7,0xf5]
+senduipi %r13
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -715,3 +715,27 @@
 
 # CHECK: hreset $1
 0xf3 0x0f 0x3a 0xf0 0xc0 0x01
+
+# CHECK: uiret
+0xf3,0x0f,0x01,0xec
+
+# CHECK: clui
+0xf3,0x0f,0x01,0xee
+
+# CHECK: stui
+0xf3,0x0f,0x01,0xef
+
+# CHECK: testui
+0xf3,0x0f,0x01,0xed
+
+# CHECK: senduipi %rax
+0xf3,0x0f,0xc7,0xf0
+
+# CHECK: senduipi %rdx
+0xf3,0x0f,0xc7,0xf2
+
+# CHECK: senduipi %r8
+0xf3,0x41,0x0f,0xc7,0xf0
+
+# CHECK: senduipi %r13
+0xf3,0x41,0x0f,0xc7,0xf5
Index: llvm/test/CodeGen/X86/uintr-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/uintr-intrinsics.ll
@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+uintr | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+uintr | FileCheck %s --check-prefix=X32
+
+define i8 @test_uintr(i64 %arg) {
+; X64-LABEL: test_uintr:
+; X64:   # %bb.0: # %entry
+; X64-NEXT:clui
+; X64-NEXT:stui
+; X64-NEXT:senduipi %rdi
+; X64-NEXT:testui
+; X64-NEXT:setb %al
+; X64-NEXT:retq
+
+; X32-LABEL: test_uintr:
+; X32:   # %bb.0: # %entry
+; X32-NEXT:clui
+; X32-NEXT:stui
+; X32-NEXT:senduipi %rdi
+; X32-NEXT:testui
+; X32-NEXT:setb %al
+; X32-NEXT:retq
+entry:
+  call void @llvm.x86.clui()
+  call void @llvm.x86.stui()
+  call void @llvm.x86.senduipi(i64 %arg)
+  %0 = call i8 @llvm.x86.testui()
+  ret i8 %0
+}
+
+declare void @llvm.x86.clui()
+declare void @llvm.x86.stui()
+declare i8 @llvm.x86.testui()
+declare void @llvm.x86.senduipi(i64 %arg)
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -415,6 +415,9 @@
   bool HasAMXBF16 = false;
   bool HasAMXINT8 = false;
 
+  /// Processor supports User Level Interrupt instructions
+  bool HasUINTR = false;
+
   /// Processor has a single uop BEXTR implementation.
   bool HasFastBEXTR = false;
 
@@ -742,6 +745,7 @@
   bool hasHRESET() const { return HasHRESET; }
   bool hasSERIALIZE() const { return HasSERIALIZE; }
   bool hasTSXLDTRK() const { return HasTSXLDTRK; }
+  bool hasUINTR() const { return HasUINTR; }
   bool useRetpolineIndirectCalls() const { return UseRetpolineIndirectCalls; }
   bool useRetpolineIndirectBranches() const {
 return UseRetpolineIndirectBranches;
Index: llvm/lib/Target/X86/X86InstrInfo.td
===
--- llvm/lib/Target/X

[PATCH] D89785: [clangd] Add basic support for attributes (selection, hover)

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

These aren't terribly common, but we currently mishandle them badly.
Not only do we not recogize the attributes themselves, but we often end up
selecting some node other than the parent (because source ranges aren't accurate
in the presence of attributes).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89785

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -415,7 +415,19 @@
 template  class Container> class A {};
 A<[[V^ector]]> a;
   )cpp",
-   "TemplateArgumentLoc"}};
+   "TemplateArgumentLoc"},
+
+  // Attributes
+  {R"cpp(
+void f(int * __attribute__(([[no^nnull]])) );
+  )cpp",
+   "NonNullAttr"},
+
+  {R"cpp(
+// Digraph syntax for attributes to avoid accidental annotations.
+class <:[gsl::Owner([[in^t]])]:> X{};
+  )cpp",
+   "BuiltinTypeLoc"}};
 
   for (const Case &C : Cases) {
 trace::TestTracer Tracer;
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1991,6 +1991,16 @@
 HI.NamespaceScope = "ObjC::"; // FIXME: fix it
 HI.Definition = "char data";
   }},
+  {
+  R"cpp(
+   void foo(int * __attribute__(([[non^null]], noescape)) );
+  )cpp",
+  [](HoverInfo &HI) {
+HI.Name = "nonnull";
+HI.Kind = index::SymbolKind::Unknown; // FIXME: no suitable value
+HI.Definition = "__attribute__((nonnull()))";
+HI.Documentation = ""; // FIXME
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/unittests/ASTTests.cpp
===
--- clang-tools-extra/clangd/unittests/ASTTests.cpp
+++ clang-tools-extra/clangd/unittests/ASTTests.cpp
@@ -11,6 +11,7 @@
 #include "Annotations.h"
 #include "ParsedAST.h"
 #include "TestTU.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/Basic/SourceManager.h"
@@ -206,6 +207,31 @@
 }
   }
 }
+
+TEST(ClangdAST, HasAttributes) {
+  const char *Code = R"cpp(
+class X{};
+class [[nodiscard]] Y{};
+void f(int * a, int * __attribute__((nonnull)) b);
+void foo(bool c) {
+  if (c)
+[[unlikely]] return;
+}
+  )cpp";
+  ParsedAST AST = TestTU::withCode(Code).build();
+  ASSERT_FALSE(hasAttributes(DynTypedNode::create(findDecl(AST, "X";
+  ASSERT_TRUE(hasAttributes(DynTypedNode::create(findDecl(AST, "Y";
+  ASSERT_FALSE(hasAttributes(DynTypedNode::create(findDecl(AST, "f";
+  ASSERT_FALSE(
+  hasAttributes(DynTypedNode::create(findUnqualifiedDecl(AST, "a";
+  ASSERT_TRUE(
+  hasAttributes(DynTypedNode::create(findUnqualifiedDecl(AST, "b";
+
+  Stmt *FooBody = cast(findDecl(AST, "foo")).getBody();
+  IfStmt *FooIf = cast(cast(FooBody)->body_front());
+  ASSERT_FALSE(hasAttributes(DynTypedNode::create(*FooIf)));
+  ASSERT_TRUE(hasAttributes(DynTypedNode::create(*FooIf->getThen(;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -182,6 +182,12 @@
   ST.commonAncestor()) {
 if (NodeKind)
   *NodeKind = N->ASTNode.getNodeKind();
+// Attributes don't target decls, look at the
+// thing it's attached to.
+// We still report the original NodeKind!
+// This makes the `override` hack work.
+if (N->ASTNode.get() && N->Parent)
+  N = N->Parent;
 llvm::copy(targetDecl(N->ASTNode, Relations),
  

[PATCH] D89529: [clangd][remote] Add Windows paths support

2020-10-20 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd99b2a976a37: [clangd][remote] Add Windows paths support 
(authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89529

Files:
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
  clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Index: clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
===
--- clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
+++ clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp
@@ -239,8 +239,8 @@
 
   clangd::Symbol::IncludeHeaderWithReferences Header;
   // Add only valid headers.
-  Header.IncludeHeader = Strings.save(
-  URI::createFile("/usr/local/user/home/project/Header.h").toString());
+  Header.IncludeHeader =
+  Strings.save(URI::createFile(testPath("project/Header.h")).toString());
   Header.References = 21;
   Sym.IncludeHeaders.push_back(Header);
   Header.IncludeHeader = Strings.save("");
@@ -250,7 +250,7 @@
   Header.References = 200;
   Sym.IncludeHeaders.push_back(Header);
 
-  Marshaller ProtobufMarshaller(convert_to_slash("/"), convert_to_slash("/"));
+  Marshaller ProtobufMarshaller(testPath(""), testPath(""));
 
   auto Serialized = ProtobufMarshaller.toProtobuf(Sym);
   ASSERT_TRUE(bool(Serialized));
Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -50,20 +50,23 @@
 Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
llvm::StringRef LocalIndexRoot)
 : Strings(Arena) {
+  llvm::StringRef PosixSeparator =
+  llvm::sys::path::get_separator(llvm::sys::path::Style::posix);
   if (!RemoteIndexRoot.empty()) {
 assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
-assert(RemoteIndexRoot ==
-   llvm::sys::path::convert_to_slash(RemoteIndexRoot));
-this->RemoteIndexRoot = RemoteIndexRoot.str();
-if (!RemoteIndexRoot.endswith(llvm::sys::path::get_separator()))
-  *this->RemoteIndexRoot += llvm::sys::path::get_separator();
+this->RemoteIndexRoot = llvm::sys::path::convert_to_slash(
+RemoteIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->RemoteIndexRoot);
+if (!Path.endswith(PosixSeparator))
+  *this->RemoteIndexRoot += PosixSeparator;
   }
   if (!LocalIndexRoot.empty()) {
 assert(llvm::sys::path::is_absolute(LocalIndexRoot));
-assert(LocalIndexRoot == llvm::sys::path::convert_to_slash(LocalIndexRoot));
-this->LocalIndexRoot = LocalIndexRoot.str();
-if (!LocalIndexRoot.endswith(llvm::sys::path::get_separator()))
-  *this->LocalIndexRoot += llvm::sys::path::get_separator();
+this->LocalIndexRoot = llvm::sys::path::convert_to_slash(
+LocalIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->LocalIndexRoot);
+if (!Path.endswith(PosixSeparator))
+  *this->LocalIndexRoot += PosixSeparator;
   }
   assert(!RemoteIndexRoot.empty() || !LocalIndexRoot.empty());
 }
@@ -92,6 +95,9 @@
   for (const auto &Path : Message->proximity_paths()) {
 llvm::SmallString<256> LocalPath = llvm::StringRef(*RemoteIndexRoot);
 llvm::sys::path::append(LocalPath, Path);
+// FuzzyFindRequest requires proximity paths to have platform-native format
+// in order for SymbolIndex to process the query correctly.
+llvm::sys::path::native(LocalPath);
 Result.ProximityPaths.push_back(std::string(LocalPath));
   }
   for (const auto &Type : Message->preferred_types())
@@ -209,7 +215,7 @@
 llvm::SmallString<256> RelativePath = llvm::StringRef(Path);
 if (llvm::sys::path::replace_path_prefix(RelativePath, *LocalIndexRoot, ""))
   RPCRequest.add_proximity_paths(llvm::sys::path::convert_to_slash(
-  RelativePath, llvm::sys::path::Style::posix));
+  RelativePath, llvm::sys::path::Style::windows));
   }
   for (const auto &Type : From.PreferredTypes)
 RPCRequest.add_preferred_types(Type);
@@ -315,12 +321,17 @@
   if (ParsedURI->scheme() != "file")
 return error("Can not use URI schemes other than file, given: '{0}'.", URI);
   llvm::SmallString<256> Result = ParsedURI->body();
+  llvm::StringRef Path(Result);
+  // Check for Windows paths (URI=file:///X:/path => Body=/X:/path)
+  if (llvm::sys::path::is_absolute(Path.substr(1),
+   llvm::sys::path::Style::windows))
+Result = Path.drop_front();
   if (!llvm::sys::path::replace_path_prefix(Result, *RemoteIndexRoot, ""))
 return error("File path '{0}' doesn't start with '{1}'.", Result.str

[clang-tools-extra] d99b2a9 - [clangd][remote] Add Windows paths support

2020-10-20 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2020-10-20T13:04:20+03:00
New Revision: d99b2a976a37f5a63117086d464df40c124f5777

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

LOG: [clangd][remote] Add Windows paths support

Without this patch 6 marshalling tests fail on Windows.
This patch contains the following changes:
- Allow paths with Windows slashes (convert to the POSIX style instead of 
assertion)
- Add support for URI with Windows path.
- Change the value of the second parameter of several 
`llvm::sys::path::convert_to_slash()` calls: we should use `windows` instead of 
`posix` to ensure UNIX slashes in the path.
- Port `RemoteMarshallingTest::IncludeHeaderURI` test to Windows.

Reviewed By: kbobyrev

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

Added: 


Modified: 
clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
clang-tools-extra/clangd/unittests/remote/MarshallingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index d61848f295a3..6285022fc0a8 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -50,20 +50,23 @@ llvm::Expected> getIDs(IDRange 
IDs) {
 Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
llvm::StringRef LocalIndexRoot)
 : Strings(Arena) {
+  llvm::StringRef PosixSeparator =
+  llvm::sys::path::get_separator(llvm::sys::path::Style::posix);
   if (!RemoteIndexRoot.empty()) {
 assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
-assert(RemoteIndexRoot ==
-   llvm::sys::path::convert_to_slash(RemoteIndexRoot));
-this->RemoteIndexRoot = RemoteIndexRoot.str();
-if (!RemoteIndexRoot.endswith(llvm::sys::path::get_separator()))
-  *this->RemoteIndexRoot += llvm::sys::path::get_separator();
+this->RemoteIndexRoot = llvm::sys::path::convert_to_slash(
+RemoteIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->RemoteIndexRoot);
+if (!Path.endswith(PosixSeparator))
+  *this->RemoteIndexRoot += PosixSeparator;
   }
   if (!LocalIndexRoot.empty()) {
 assert(llvm::sys::path::is_absolute(LocalIndexRoot));
-assert(LocalIndexRoot == 
llvm::sys::path::convert_to_slash(LocalIndexRoot));
-this->LocalIndexRoot = LocalIndexRoot.str();
-if (!LocalIndexRoot.endswith(llvm::sys::path::get_separator()))
-  *this->LocalIndexRoot += llvm::sys::path::get_separator();
+this->LocalIndexRoot = llvm::sys::path::convert_to_slash(
+LocalIndexRoot, llvm::sys::path::Style::windows);
+llvm::StringRef Path(*this->LocalIndexRoot);
+if (!Path.endswith(PosixSeparator))
+  *this->LocalIndexRoot += PosixSeparator;
   }
   assert(!RemoteIndexRoot.empty() || !LocalIndexRoot.empty());
 }
@@ -92,6 +95,9 @@ Marshaller::fromProtobuf(const FuzzyFindRequest *Message) {
   for (const auto &Path : Message->proximity_paths()) {
 llvm::SmallString<256> LocalPath = llvm::StringRef(*RemoteIndexRoot);
 llvm::sys::path::append(LocalPath, Path);
+// FuzzyFindRequest requires proximity paths to have platform-native format
+// in order for SymbolIndex to process the query correctly.
+llvm::sys::path::native(LocalPath);
 Result.ProximityPaths.push_back(std::string(LocalPath));
   }
   for (const auto &Type : Message->preferred_types())
@@ -209,7 +215,7 @@ FuzzyFindRequest Marshaller::toProtobuf(const 
clangd::FuzzyFindRequest &From) {
 llvm::SmallString<256> RelativePath = llvm::StringRef(Path);
 if (llvm::sys::path::replace_path_prefix(RelativePath, *LocalIndexRoot, 
""))
   RPCRequest.add_proximity_paths(llvm::sys::path::convert_to_slash(
-  RelativePath, llvm::sys::path::Style::posix));
+  RelativePath, llvm::sys::path::Style::windows));
   }
   for (const auto &Type : From.PreferredTypes)
 RPCRequest.add_preferred_types(Type);
@@ -315,12 +321,17 @@ llvm::Expected 
Marshaller::uriToRelativePath(llvm::StringRef URI) {
   if (ParsedURI->scheme() != "file")
 return error("Can not use URI schemes other than file, given: '{0}'.", 
URI);
   llvm::SmallString<256> Result = ParsedURI->body();
+  llvm::StringRef Path(Result);
+  // Check for Windows paths (URI=file:///X:/path => Body=/X:/path)
+  if (llvm::sys::path::is_absolute(Path.substr(1),
+   llvm::sys::path::Style::windows))
+Result = Path.drop_front();
   if (!llvm::sys::path::replace_path_prefix(Result, *RemoteIndexRoot, ""))
 return error("File path '{0}' doesn't start with '{1}'.", Result.str(),
  *RemoteIndexRoot);
-  // Make sure the result has UNIX s

[PATCH] D86021: [IR] Make nosync, nofree and willreturn default for intrinsics.

2020-10-20 Thread Stefan Stipanovic via Phabricator via cfe-commits
sstefan1 closed this revision.
sstefan1 added a comment.

Commited in rGfbfb1c790982 
.

Forgot to add the revision link.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86021

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


[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

2020-10-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 299324.
sammccall added a comment.

Update docs, dynamic registry and tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/AST/ASTFwd.h
  clang/include/clang/AST/ASTTypeTraits.h
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h
  clang/lib/AST/ASTTypeTraits.cpp
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/AST/ASTTypeTraitsTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1875,6 +1875,17 @@
  nestedNameSpecifier()));
 }
 
+TEST_P(ASTMatchersTest, Attr) {
+  if (!GetParam().isCXX())
+return;
+  if (GetParam().isCXX17OrLater())
+EXPECT_TRUE(matches("struct [[nodiscard]] F{};", attr()));
+  EXPECT_TRUE(matches("int x(int * __attribute__((nonnull)) );", attr()));
+  // On windows, some nodes an implicit visibility attribute.
+  if (!GetParam().hasDelayedTemplateParsing() /* Windows */)
+EXPECT_TRUE(notMatches("struct F{}; int x(int *);", attr()));
+}
+
 TEST_P(ASTMatchersTest, NullStmt) {
   EXPECT_TRUE(matches("void f() {int i;;}", nullStmt()));
   EXPECT_TRUE(notMatches("void f() {int i;}", nullStmt()));
Index: clang/unittests/AST/ASTTypeTraitsTest.cpp
===
--- clang/unittests/AST/ASTTypeTraitsTest.cpp
+++ clang/unittests/AST/ASTTypeTraitsTest.cpp
@@ -120,6 +120,7 @@
   VERIFY_NAME(CallExpr);
   VERIFY_NAME(Type);
   VERIFY_NAME(ConstantArrayType);
+  VERIFY_NAME(NonNullAttr);
 #undef VERIFY_NAME
 }
 
@@ -148,6 +149,13 @@
  nestedNameSpecifierLoc()));
 }
 
+TEST(DynTypedNode, AttrSourceRange) {
+  RangeVerifier Verifier;
+  Verifier.expectRange(1, 31, 1, 31);
+  EXPECT_TRUE(Verifier.match("void x(char *y __attribute__((nonnull)) );",
+ ast_matchers::attr()));
+}
+
 TEST(DynTypedNode, DeclDump) {
   DumpVerifier Verifier;
   Verifier.expectSubstring("FunctionDecl");
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -141,6 +141,7 @@
   REGISTER_MATCHER(asmStmt);
   REGISTER_MATCHER(atomicExpr);
   REGISTER_MATCHER(atomicType);
+  REGISTER_MATCHER(attr);
   REGISTER_MATCHER(autoType);
   REGISTER_MATCHER(autoreleasePoolStmt)
   REGISTER_MATCHER(binaryConditionalOperator);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -973,6 +973,7 @@
 const internal::VariadicAllOfMatcher nestedNameSpecifier;
 const internal::VariadicAllOfMatcher
 nestedNameSpecifierLoc;
+const internal::VariadicAllOfMatcher attr;
 const internal::VariadicDynCastAllOfMatcher
 cudaKernelCallExpr;
 const AstTypeMatcher builtinType;
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -131,6 +131,8 @@
 else if (const TemplateArgumentLoc *TALoc =
  DynNode.get())
   traverse(*TALoc);
+else if (const Attr *A = DynNode.get())
+  traverse(*A);
 // FIXME: Add other base types after adding tests.
 
 // It's OK to always overwrite the bound nodes, as if there was
@@ -231,6 +233,10 @@
 ScopedIncrement ScopedDepth(&CurrentDepth);
 return traverse(TAL);
   }
+  bool TraverseAttr(Attr *A) {
+ScopedIncrement ScopedDepth(&CurrentDepth);
+return (A == nullptr || traverse(*A));
+  }
   bool TraverseLambdaExpr(LambdaExpr *Node) {
 if (Finder->getASTContext().getParentMapContext().getTraversalKind() !=
 TK_IgnoreUnlessSpelledInSource)
@@ -314,6 +320,9 @@
   bool baseTraverse(TemplateArgumentLoc TAL) {
 return VisitorBase::TraverseTemplateArgumentLoc(TAL);
   }
+  bool baseTraverse(const Attr &AttrNode) {
+return VisitorBase::TraverseAttr(const_cast(&AttrNode));
+  }
 
   // Sets 'Matched' to true if 'Matcher' matches 'Node' and:
   //   0 < CurrentDepth <= MaxDepth.
@@ -458,6 +467,7 @@
   bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS);
   bool TraverseConstructorInitializer(CXXCtorInitializer *CtorInit);
   bool TraverseTemplateArgumentLoc(TemplateArgumentLoc TAL);
+  bo

[PATCH] D89783: [format] foo..h should be the main-header for foo..cc

2020-10-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thank you!




Comment at: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp:243
+  StringRef MatchingFileStem = matchingStem(FileName);  // foo for foo.cu.cc
+  // main-header examples:
+  //   1) foo.h => foo.cc

nit: comment is internally inconsistent here, which makes it a bit hard to 
follow.
 - either use bullets for both lists, or for neither
 - either use placeholders like 'foo' or like '', but not both
 - list the most important/obvious examples at the top for both cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89783

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


[PATCH] D89783: [format] foo..h should be the main-header for foo..cc

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

address comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89783

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -151,7 +151,7 @@
   EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), 
"a.cc").empty());
 }
 
-TEST_F(SortIncludesTest, NoMainFileHeader) {
+TEST_F(SortIncludesTest, MainFileHeader) {
   std::string Code = "#include \n"
  "\n"
  "#include \"a/extra_action.proto.h\"\n";
@@ -159,6 +159,13 @@
   EXPECT_TRUE(
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a/extra_action.cc")
   .empty());
+
+  EXPECT_EQ("#include \"foo.bar.h\"\n"
+"\n"
+"#include \"a.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"foo.bar.h\"\n",
+ "foo.bar.cc"));
 }
 
 TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -190,7 +190,6 @@
 IncludeCategoryManager::IncludeCategoryManager(const IncludeStyle &Style,
StringRef FileName)
 : Style(Style), FileName(FileName) {
-  FileStem = matchingStem(FileName);
   for (const auto &Category : Style.IncludeCategories)
 CategoryRegexs.emplace_back(Category.Regex, llvm::Regex::IgnoreCase);
   IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") ||
@@ -234,16 +233,30 @@
   if (!IncludeName.startswith("\""))
 return false;
 
+  IncludeName =
+  IncludeName.drop_front(1).drop_back(1); // remove the surrounding "" or 
<>
   // Not matchingStem: implementation files may have compound extensions but
   // headers may not.
-  StringRef HeaderStem =
-  llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(
-  1) /* remove the surrounding "" or <> */);
-  if (FileStem.startswith(HeaderStem) ||
-  FileStem.startswith_lower(HeaderStem)) {
+  StringRef HeaderStem = llvm::sys::path::stem(IncludeName);
+  StringRef FileStem = llvm::sys::path::stem(FileName); // foo.cu for foo.cu.cc
+  StringRef MatchingFileStem = matchingStem(FileName);  // foo for foo.cu.cc
+  // main-header examples:
+  //  1) foo.h => foo.cc
+  //  2) foo.h => foo.cu.cc
+  //  3) foo.proto.h => foo.proto.cc
+  //
+  // non-main-header examples:
+  //  1) foo.h => bar.cc
+  //  2) foo.proto.h => foo.cc
+  StringRef Matching;
+  if (MatchingFileStem.startswith_lower(HeaderStem))
+Matching = MatchingFileStem; // example 1), 2)
+  else if (FileStem.equals_lower(HeaderStem))
+Matching = FileStem; // example 3)
+  if (!Matching.empty()) {
 llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,
  llvm::Regex::IgnoreCase);
-if (MainIncludeRegex.match(FileStem))
+if (MainIncludeRegex.match(Matching))
   return true;
   }
   return false;
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -40,8 +40,6 @@
   const IncludeStyle Style;
   bool IsMainFile;
   std::string FileName;
-  // This refers to a substring in FileName.
-  StringRef FileStem;
   SmallVector CategoryRegexs;
 };
 


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -151,7 +151,7 @@
   EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a.cc").empty());
 }
 
-TEST_F(SortIncludesTest, NoMainFileHeader) {
+TEST_F(SortIncludesTest, MainFileHeader) {
   std::string Code = "#include \n"
  "\n"
  "#include \"a/extra_action.proto.h\"\n";
@@ -159,6 +159,13 @@
   EXPECT_TRUE(
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a/extra_action.cc")
   .empty());
+
+  EXPECT_EQ("#include \"foo.bar.h\"\n"
+"\n"
+"#include \"a.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"foo.bar.h\"\n",
+ "foo.bar.cc"));
 }
 
 TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===

[PATCH] D89579: [clangd][ObjC] Support nullability annotations

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

Yep, let's revert to the previous state and land that, and I'll puzzle over the 
examples you give (because always returning false shouldn't affect behavior, 
just performance).

I have put together D89785  for more general 
attribute support, and it has a generalization of the fix here. (It returns 
`false` for any node with an attribute attached).
But it's worth landing this first as it has good tests for the objc cases, and 
that patch has its own prerequisites and risks of regressions.
(Not a timely coincidence, rather I got curious about the AST around Attrs 
after seeing this patch)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89579

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


[PATCH] D88645: [Annotation] Allows annotation to carry some additional constant arguments.

2020-10-20 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 299333.
Tyker marked 4 inline comments as done.
Tyker added a comment.
Herald added a subscriber: dexonsmith.

addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88645

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/ast-dump-attr.cpp
  clang/test/CodeGen/annotations-field.c
  clang/test/CodeGen/annotations-global.c
  clang/test/CodeGen/annotations-loc.c
  clang/test/CodeGen/annotations-var.c
  clang/test/CodeGenCXX/attr-annotate.cpp
  clang/test/CodeGenCXX/attr-annotate2.cpp
  clang/test/Misc/pragma-attribute-cxx.cpp
  clang/test/Misc/pragma-attribute-objc.m
  clang/test/Parser/access-spec-attrs.cpp
  clang/test/Parser/objc-implementation-attrs.m
  clang/test/Sema/annotate.c
  clang/test/Sema/pragma-attribute.c
  clang/test/SemaCXX/attr-annotate.cpp
  llvm/include/llvm/IR/Intrinsics.td
  llvm/test/Analysis/CostModel/X86/free-intrinsics.ll
  llvm/test/Analysis/CostModel/free-intrinsics-datalayout.ll
  llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
  llvm/test/CodeGen/Generic/ptr-annotate.ll
  llvm/test/Transforms/InstCombine/assume_inevitable.ll

Index: llvm/test/Transforms/InstCombine/assume_inevitable.ll
===
--- llvm/test/Transforms/InstCombine/assume_inevitable.ll
+++ llvm/test/Transforms/InstCombine/assume_inevitable.ll
@@ -15,7 +15,7 @@
 ; CHECK-NEXT:[[DUMMY_EQ:%.*]] = icmp ugt i32 [[LOADRES]], 42
 ; CHECK-NEXT:tail call void @llvm.assume(i1 [[DUMMY_EQ]])
 ; CHECK-NEXT:[[M_I8:%.*]] = bitcast i64* [[M]] to i8*
-; CHECK-NEXT:[[M_A:%.*]] = call i8* @llvm.ptr.annotation.p0i8(i8* nonnull [[M_I8]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i64 0, i64 0), i32 2)
+; CHECK-NEXT:[[M_A:%.*]] = call i8* @llvm.ptr.annotation.p0i8(i8* nonnull [[M_I8]], i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i64 0, i64 0), i32 2, i8* null)
 ; CHECK-NEXT:[[M_X:%.*]] = bitcast i8* [[M_A]] to i64*
 ; CHECK-NEXT:[[OBJSZ:%.*]] = call i64 @llvm.objectsize.i64.p0i8(i8* [[C:%.*]], i1 false, i1 false, i1 false)
 ; CHECK-NEXT:store i64 [[OBJSZ]], i64* [[M_X]], align 4
@@ -44,7 +44,7 @@
   call void @llvm.lifetime.end.p0i8(i64 1, i8* %dummy)
 
   %m_i8 = bitcast i64* %m to i8*
-  %m_a = call i8* @llvm.ptr.annotation.p0i8(i8* %m_i8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i32 0, i32 0), i32 2)
+  %m_a = call i8* @llvm.ptr.annotation.p0i8(i8* %m_i8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i32 0, i32 0), i32 2, i8* null)
   %m_x = bitcast i8* %m_a to i64*
   %objsz = call i64 @llvm.objectsize.i64.p0i8(i8* %c, i1 false)
   store i64 %objsz, i64* %m_x
@@ -64,7 +64,7 @@
 
 declare i64 @llvm.objectsize.i64.p0i8(i8*, i1)
 declare i32 @llvm.annotation.i32(i32, i8*, i8*, i32)
-declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32)
+declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*)
 
 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
Index: llvm/test/CodeGen/Generic/ptr-annotate.ll
===
--- llvm/test/CodeGen/Generic/ptr-annotate.ll
+++ llvm/test/CodeGen/Generic/ptr-annotate.ll
@@ -10,9 +10,9 @@
 define void @foo() {
 entry:
   %m = alloca i8, align 4
-  %0 = call i8* @llvm.ptr.annotation.p0i8(i8* %m, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i32 0, i32 0), i32 2)
+  %0 = call i8* @llvm.ptr.annotation.p0i8(i8* %m, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str1, i32 0, i32 0), i32 2, i8* null)
   store i8 1, i8* %0, align 4
   ret void
 }
 
-declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32) #1
+declare i8* @llvm.ptr.annotation.p0i8(i8*, i8*, i8*, i32, i8*) #1
Index: llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
===
--- llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
+++ llvm/test/Analysis/CostModel/free-intrinsics-no_info.ll
@@ -15,8 +15,8 @@
 ; CHECK-SIZE-NEXT:  Cost Model: Found an estimated

[PATCH] D88645: [Annotation] Allows annotation to carry some additional constant arguments.

2020-10-20 Thread Tyker via Phabricator via cfe-commits
Tyker added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:3706
+
+if (!Result || !Notes.empty()) {
+  Diag(E->getBeginLoc(), diag::err_attribute_argument_n_type)

aaron.ballman wrote:
> I'm surprised that the presence of notes alone would mean the attribute 
> argument has an error and should be skipped. Are there circumstances under 
> which `Result` is true but `Notes` is non-empty?
AFAIK
Result means the expression can be folded to a constant.
Note.empty() means the expression is a valid constant expression in the current 
language mode.

the difference is observable in code like:
```
constexpr int foldable_but_invalid() {
  int *A = new int(0);
  return *A;
}

[[clang::annotate("", foldable_but_invalid())]] void f1() {}
```
foldable_but_invalid retruns a constant but any constant evaluation of this 
function is invalid because it doesn't desallocate A.
with !Notes.empty() this fails, without it no errors occurs.

i think it is desirable that attributes don't diverge from the language mode.
I added a test for this.



Comment at: clang/test/SemaCXX/attr-annotate.cpp:96
+}
+
+void test() {}

aaron.ballman wrote:
> Some more tests for various constant expression situations that may be weird:
> ```
> int n = 10;
> int vla[n];
> 
> [[clang::annotate("vlas are awful", sizeof(vla[++n]))] int i = 0; // reject, 
> the sizeof is not unevaluated
> 
> [[clang::annotate("_Generic selection expression should be fine", _Generic(n, 
> int : 0, default : 1))]] int j = 0; // second arg should resolve to 0 fine
> 
> void designator();
> [[clang::annotate("function designators?", designator)]] int k = 0; // Should 
> work?
> ```
added CK_FunctionToPointerDecay cast when needed
the rest was working as is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88645

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


[clang] 84048e2 - [format] foo..h should be the main-header for foo..cc

2020-10-20 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-10-20T13:27:02+02:00
New Revision: 84048e234f8f0d81871caab842dbed84b84aa86f

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

LOG: [format] foo..h should be the main-header for foo..cc

This fixes a regression introduced in https://reviews.llvm.org/D88640.

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

Added: 


Modified: 
clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h 
b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
index 18374ad46a9c..02fb2875671a 100644
--- a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -40,8 +40,6 @@ class IncludeCategoryManager {
   const IncludeStyle Style;
   bool IsMainFile;
   std::string FileName;
-  // This refers to a substring in FileName.
-  StringRef FileStem;
   SmallVector CategoryRegexs;
 };
 

diff  --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp 
b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
index 07c1071419d5..5b29bbc4edb3 100644
--- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -190,7 +190,6 @@ StringRef matchingStem(llvm::StringRef Path) {
 IncludeCategoryManager::IncludeCategoryManager(const IncludeStyle &Style,
StringRef FileName)
 : Style(Style), FileName(FileName) {
-  FileStem = matchingStem(FileName);
   for (const auto &Category : Style.IncludeCategories)
 CategoryRegexs.emplace_back(Category.Regex, llvm::Regex::IgnoreCase);
   IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") ||
@@ -234,16 +233,30 @@ bool IncludeCategoryManager::isMainHeader(StringRef 
IncludeName) const {
   if (!IncludeName.startswith("\""))
 return false;
 
+  IncludeName =
+  IncludeName.drop_front(1).drop_back(1); // remove the surrounding "" or 
<>
   // Not matchingStem: implementation files may have compound extensions but
   // headers may not.
-  StringRef HeaderStem =
-  llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(
-  1) /* remove the surrounding "" or <> */);
-  if (FileStem.startswith(HeaderStem) ||
-  FileStem.startswith_lower(HeaderStem)) {
+  StringRef HeaderStem = llvm::sys::path::stem(IncludeName);
+  StringRef FileStem = llvm::sys::path::stem(FileName); // foo.cu for foo.cu.cc
+  StringRef MatchingFileStem = matchingStem(FileName);  // foo for foo.cu.cc
+  // main-header examples:
+  //  1) foo.h => foo.cc
+  //  2) foo.h => foo.cu.cc
+  //  3) foo.proto.h => foo.proto.cc
+  //
+  // non-main-header examples:
+  //  1) foo.h => bar.cc
+  //  2) foo.proto.h => foo.cc
+  StringRef Matching;
+  if (MatchingFileStem.startswith_lower(HeaderStem))
+Matching = MatchingFileStem; // example 1), 2)
+  else if (FileStem.equals_lower(HeaderStem))
+Matching = FileStem; // example 3)
+  if (!Matching.empty()) {
 llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,
  llvm::Regex::IgnoreCase);
-if (MainIncludeRegex.match(FileStem))
+if (MainIncludeRegex.match(Matching))
   return true;
   }
   return false;

diff  --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index c327be5e6b0b..279c4ee15a10 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -151,7 +151,7 @@ TEST_F(SortIncludesTest, NoReplacementsForValidIncludes) {
   EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), 
"a.cc").empty());
 }
 
-TEST_F(SortIncludesTest, NoMainFileHeader) {
+TEST_F(SortIncludesTest, MainFileHeader) {
   std::string Code = "#include \n"
  "\n"
  "#include \"a/extra_action.proto.h\"\n";
@@ -159,6 +159,13 @@ TEST_F(SortIncludesTest, NoMainFileHeader) {
   EXPECT_TRUE(
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a/extra_action.cc")
   .empty());
+
+  EXPECT_EQ("#include \"foo.bar.h\"\n"
+"\n"
+"#include \"a.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"foo.bar.h\"\n",
+ "foo.bar.cc"));
 }
 
 TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {



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


[PATCH] D89783: [format] foo..h should be the main-header for foo..cc

2020-10-20 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
hokein marked an inline comment as done.
Closed by commit rG84048e234f8f: [format] foo..h should be the 
main-header for foo..cc (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89783

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -151,7 +151,7 @@
   EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), 
"a.cc").empty());
 }
 
-TEST_F(SortIncludesTest, NoMainFileHeader) {
+TEST_F(SortIncludesTest, MainFileHeader) {
   std::string Code = "#include \n"
  "\n"
  "#include \"a/extra_action.proto.h\"\n";
@@ -159,6 +159,13 @@
   EXPECT_TRUE(
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a/extra_action.cc")
   .empty());
+
+  EXPECT_EQ("#include \"foo.bar.h\"\n"
+"\n"
+"#include \"a.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"foo.bar.h\"\n",
+ "foo.bar.cc"));
 }
 
 TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) {
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -190,7 +190,6 @@
 IncludeCategoryManager::IncludeCategoryManager(const IncludeStyle &Style,
StringRef FileName)
 : Style(Style), FileName(FileName) {
-  FileStem = matchingStem(FileName);
   for (const auto &Category : Style.IncludeCategories)
 CategoryRegexs.emplace_back(Category.Regex, llvm::Regex::IgnoreCase);
   IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") ||
@@ -234,16 +233,30 @@
   if (!IncludeName.startswith("\""))
 return false;
 
+  IncludeName =
+  IncludeName.drop_front(1).drop_back(1); // remove the surrounding "" or 
<>
   // Not matchingStem: implementation files may have compound extensions but
   // headers may not.
-  StringRef HeaderStem =
-  llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(
-  1) /* remove the surrounding "" or <> */);
-  if (FileStem.startswith(HeaderStem) ||
-  FileStem.startswith_lower(HeaderStem)) {
+  StringRef HeaderStem = llvm::sys::path::stem(IncludeName);
+  StringRef FileStem = llvm::sys::path::stem(FileName); // foo.cu for foo.cu.cc
+  StringRef MatchingFileStem = matchingStem(FileName);  // foo for foo.cu.cc
+  // main-header examples:
+  //  1) foo.h => foo.cc
+  //  2) foo.h => foo.cu.cc
+  //  3) foo.proto.h => foo.proto.cc
+  //
+  // non-main-header examples:
+  //  1) foo.h => bar.cc
+  //  2) foo.proto.h => foo.cc
+  StringRef Matching;
+  if (MatchingFileStem.startswith_lower(HeaderStem))
+Matching = MatchingFileStem; // example 1), 2)
+  else if (FileStem.equals_lower(HeaderStem))
+Matching = FileStem; // example 3)
+  if (!Matching.empty()) {
 llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,
  llvm::Regex::IgnoreCase);
-if (MainIncludeRegex.match(FileStem))
+if (MainIncludeRegex.match(Matching))
   return true;
   }
   return false;
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -40,8 +40,6 @@
   const IncludeStyle Style;
   bool IsMainFile;
   std::string FileName;
-  // This refers to a substring in FileName.
-  StringRef FileStem;
   SmallVector CategoryRegexs;
 };
 


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -151,7 +151,7 @@
   EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a.cc").empty());
 }
 
-TEST_F(SortIncludesTest, NoMainFileHeader) {
+TEST_F(SortIncludesTest, MainFileHeader) {
   std::string Code = "#include \n"
  "\n"
  "#include \"a/extra_action.proto.h\"\n";
@@ -159,6 +159,13 @@
   EXPECT_TRUE(
   sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a/extra_action.cc")
   .empty());
+
+  EXPECT_EQ("#include \"foo.bar.h\"\n"
+"\n"
+"#include \"a.h\"\n",
+sort("#include \"a.h\"\n"
+ "#include \"foo.bar.h\"\n

[PATCH] D89318: [ASTImporter] Fix crash caused by unset AttributeSpellingListIndex

2020-10-20 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Unfortunately, I could not reproduce the mentioned crash on our macOS machine. 
The mentioned test just passed with the output below. I gave up.

  myuser@msmarple ~/llvm3/build/release_assert $ 
/usr/local/Frameworks/Python.framework/Versions/3.8/bin/python3.8 
/Users/myuser/llvm3/git/llvm-project/lldb/test/API/dotest.py -S nm -u CXXFLAGS 
-u CFLAGS --codesign-identity - --env 
LLVM_LIBS_DIR=/Users/myuser/llvm3/build/release_assert/./lib --arch x86_64 
--build-dir /Users/myuser/llvm3/build/release_assert/lldb-test-build.noindex -s 
/Users/myuser/llvm3/build/release_assert/lldb-test-traces 
--lldb-module-cache-dir 
/Users/myuser/llvm3/build/release_assert/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/Users/myuser/llvm3/build/release_assert/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /Users/myuser/llvm3/build/release_assert/./bin/lldb --compiler 
/Users/myuser/llvm3/build/release_assert/./bin/clang --dsymutil 
/Users/myuser/llvm3/build/release_assert/./bin/dsymutil --filecheck 
/Users/myuser/llvm3/build/release_assert/./bin/FileCheck --yaml2obj 
/Users/myuser/llvm3/build/release_assert/./bin/yaml2obj --server 
/Users/myuser/llvm3/build/release_assert/./bin/debugserver --lldb-libs-dir 
/Users/myuser/llvm3/build/release_assert/./lib 
/Users/myuser/llvm3/git/llvm-project/lldb/test/API/commands/expression/import_builtin_fileid/
 -p TestImportBuiltinFileID.py -t
  lldb version 12.0.99 (https://github.com/llvm/llvm-project.git revision 
d454328ea88562a6ec6260529a040035ab9c4a06)
clang revision d454328ea88562a6ec6260529a040035ab9c4a06
llvm revision d454328ea88562a6ec6260529a040035ab9c4a06
  libstdcxx tests will not be run because: Don't know how to build with 
libstdcxx on macosx
  Skipping following debug info categories: ['dwo']
  
  Session logs for test failures/errors/unexpected successes will go into 
directory '/Users/myuser/llvm3/build/release_assert/lldb-test-traces'
  Change dir to: 
/Users/myuser/llvm3/git/llvm-project/lldb/test/API/commands/expression/import_builtin_fileid
  runCmd: settings clear -all
  output:
  
  runCmd: settings set symbols.enable-external-lookup false
  output:
  
  runCmd: settings set target.inherit-tcc true
  output:
  
  runCmd: settings set target.auto-apply-fixits false
  output:
  
  runCmd: settings set plugin.process.gdb-remote.packet-timeout 60
  output:
  
  runCmd: settings set symbols.clang-modules-cache-path 
"/Users/myuser/llvm3/build/release_assert/lldb-test-build.noindex/module-cache-lldb/lldb-api"
  output:
  
  runCmd: settings set use-color false
  output:
  
  runCmd: setting set target.prefer-dynamic-value no-dynamic-values
  output:
  
  runCmd: expr int (*DBG_CGImageGetRenderingIntent)(void *) = ((int (*)(void 
*))CGImageGetRenderingIntent); DBG_CGImageGetRenderingIntent((void 
*)0x00);
  output: (int) $0 = 0
  
  
  Ran command:
  "expr int (*DBG_CGImageGetRenderingIntent)(void *) = ((int (*)(void 
*))CGImageGetRenderingIntent); DBG_CGImageGetRenderingIntent((void 
*)0x00);"
  
  Got output:
  (int) $0 = 0
  
  Expecting sub string: "$0 = 0" (was found)
  
   >>: success
  
  PASS: LLDB (/Users/myuser/llvm3/build/release_assert/bin/clang-x86_64) :: 
test_import_builtin_fileid_gmodules 
(TestImportBuiltinFileID.TestImportBuiltinFileID)
  Restore dir to: /Users/myuser/llvm3/build/release_assert
  --
  Ran 1 test in 1.789s
  
  RESULT: PASSED (1 passes, 0 failures, 0 errors, 0 skipped, 0 expected 
failures, 0 unexpected successes)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89318

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


[PATCH] D89752: [CUDA] Improve clang's ability to detect recent CUDA versions.

2020-10-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89752

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


[PATCH] D88498: [FPEnv] Apply dynamic rounding to function body only

2020-10-20 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff abandoned this revision.
sepavloff added a comment.



In D88498#2339630 , @rsmith wrote:

> The tests in this patch exhibit the same behavior with and without the patch 
> applied; I think almost all the functionality changes from here are 
> superseded by the change to consider whether we're in a manifestly constant 
> evaluated context.

Thank you for review and explanations!
So I am abandoning the patch.

> So my inclination is to say that the status quo (prior to this patch) is 
> preferable behavior. The new tests look valuable.

I'll try to extract the tests to a new review item.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88498

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


[clang] c0cdd22 - Introduce CfgTraits abstraction

2020-10-20 Thread Nicolai Hähnle via cfe-commits

Author: Nicolai Hähnle
Date: 2020-10-20T13:50:52+02:00
New Revision: c0cdd22c72fab47a3c37b5a8401763995cadaa77

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

LOG: Introduce CfgTraits abstraction

The CfgTraits abstraction simplfies writing algorithms that are
generic over the type of CFG, and enables writing such algorithms
as regular non-template code that operates on opaque references
to CFG blocks and values.

Implementations of CfgTraits provide operations on the concrete
CFG types, e.g. `IrCfgTraits::BlockRef` is `BasicBlock *`.

CfgInterface is an abstract base class which provides operations
on opaque types CfgBlockRef and CfgValueRef. Those opaque types
encapsulate a `void *`, but the meaning depends on the concrete
CFG type. For example, MachineCfgTraits -- for use with MachineIR
in SSA form -- encodes a Register inside CfgValueRef. Converting
between concrete references and opaque/generic ones is done by
CfgTraits::{fromGeneric,toGeneric}. Convenience methods
CfgTraits::{un}wrap{Iterator,Range} are available as well.

Writing algorithms in terms of CfgInterface adds some overhead
(virtual method calls, plus in same cases it removes the
opportunity to inline iterators), but can be much more convenient
since generic algorithms can be written as non-templates.

This patch adds implementations of CfgTraits for all CFGs on
which dominator trees are calculated, so that the dominator
tree can be ported to this machinery. Only IrCfgTraits (LLVM IR)
and MachineCfgTraits (Machine IR in SSA form) are complete, the
other implementations are limited to the absolute minimum
required to make the upcoming dominator tree changes work.

v5:
- fix MachineCfgTraits::blockdef_iterator and allow it to iterate over
  the instructions in a bundle
- use MachineBasicBlock::printName

v6:
- implement predecessors/successors for all CfgTraits implementations
- fix error in unwrapRange
- rename toGeneric/fromGeneric into wrapRef/unwrapRef to have naming
  that is consistent with {wrap,unwrap}{Iterator,Range}
- use getVRegDef instead of getUniqueVRegDef

v7:
- std::forward fix in wrapping_iterator
- fix typos

v8:
- cleanup operators on CfgOpaqueType
- address other review comments

Change-Id: Ia75f4f268fded33fca11218a7d578c9aec1f3f4d

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

Added: 
llvm/include/llvm/CodeGen/MachineCfgTraits.h
llvm/include/llvm/Support/CfgTraits.h
llvm/lib/CodeGen/MachineCfgTraits.cpp
llvm/lib/IR/CFG.cpp
llvm/lib/Support/CfgTraits.cpp

Modified: 
clang/include/clang/Analysis/Analyses/Dominators.h
llvm/include/llvm/IR/CFG.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/IR/CMakeLists.txt
llvm/lib/Support/CMakeLists.txt
llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
mlir/include/mlir/IR/Dominance.h

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/Dominators.h 
b/clang/include/clang/Analysis/Analyses/Dominators.h
index 25a5ba9d83fe..e09ff04fa95a 100644
--- a/clang/include/clang/Analysis/Analyses/Dominators.h
+++ b/clang/include/clang/Analysis/Analyses/Dominators.h
@@ -18,11 +18,100 @@
 #include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/iterator.h"
-#include "llvm/Support/GenericIteratedDominanceFrontier.h"
+#include "llvm/Support/CfgTraits.h"
 #include "llvm/Support/GenericDomTree.h"
 #include "llvm/Support/GenericDomTreeConstruction.h"
+#include "llvm/Support/GenericIteratedDominanceFrontier.h"
 #include "llvm/Support/raw_ostream.h"
 
+namespace clang {
+
+/// Partial CFG traits for MLIR's CFG, without a value type.
+class CfgTraitsBase : public llvm::CfgTraitsBase {
+public:
+  using ParentType = CFG;
+  using BlockRef = CFGBlock *;
+  using ValueRef = void;
+
+  static llvm::CfgBlockRef wrapRef(BlockRef block) {
+return makeOpaque(block);
+  }
+  static BlockRef unwrapRef(llvm::CfgBlockRef block) {
+return static_cast(getOpaque(block));
+  }
+};
+
+class CfgTraits : public llvm::CfgTraits {
+public:
+  static ParentType *getBlockParent(CFGBlock *block) {
+return block->getParent();
+  }
+
+  // Clang's CFG contains null pointers for unreachable successors, e.g. when 
an
+  // if statement's condition is always false, it's 'then' branch is 
represented
+  // with a nullptr. Account for this in the predecessors / successors
+  // iteration.
+  template  struct skip_null_iterator;
+
+  template 
+  using skip_null_iterator_base =
+  llvm::iterator_adaptor_base,
+  BaseIteratorT,
+  std::bidirectional_iterator_tag>;
+
+  template 
+  struct skip_null_iterator : skip_null_iterator_base {
+using Base = skip_null_iterator_base;
+
+skip_null_iterator() = default;
+skip_null_iterato

[PATCH] D83088: Introduce CfgTraits abstraction

2020-10-20 Thread Nicolai Hähnle via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc0cdd22c72fa: Introduce CfgTraits abstraction (authored by 
nhaehnle).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/CodeGen/MachineCfgTraits.h
  llvm/include/llvm/IR/CFG.h
  llvm/include/llvm/Support/CfgTraits.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/MachineCfgTraits.cpp
  llvm/lib/IR/CFG.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/CfgTraits.cpp
  llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
  mlir/include/mlir/IR/Dominance.h

Index: mlir/include/mlir/IR/Dominance.h
===
--- mlir/include/mlir/IR/Dominance.h
+++ mlir/include/mlir/IR/Dominance.h
@@ -10,8 +10,46 @@
 #define MLIR_IR_DOMINANCE_H
 
 #include "mlir/IR/RegionGraphTraits.h"
+#include "llvm/Support/CfgTraits.h"
 #include "llvm/Support/GenericDomTree.h"
 
+namespace mlir {
+
+/// Partial CFG traits for MLIR's CFG, without a value type.
+class CfgTraitsBase : public llvm::CfgTraitsBase {
+public:
+  using ParentType = Region;
+  using BlockRef = Block *;
+  using ValueRef = void;
+
+  static llvm::CfgBlockRef wrapRef(BlockRef block) {
+return makeOpaque(block);
+  }
+  static BlockRef unwrapRef(llvm::CfgBlockRef block) {
+return static_cast(getOpaque(block));
+  }
+};
+
+class CfgTraits : public llvm::CfgTraits {
+public:
+  static Region *getBlockParent(Block *block) { return block->getParent(); }
+
+  static auto predecessors(Block *block) {
+return llvm::inverse_children(block);
+  }
+
+  static auto successors(Block *block) {
+return llvm::children(block);
+  }
+};
+
+} // namespace mlir
+
+template <>
+struct llvm::CfgTraitsFor {
+  using CfgTraits = mlir::CfgTraits;
+};
+
 extern template class llvm::DominatorTreeBase;
 extern template class llvm::DominatorTreeBase;
 
Index: llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
===
--- llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
+++ llvm/lib/Transforms/Vectorize/VPlanDominatorTree.h
@@ -18,9 +18,42 @@
 #include "VPlan.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/IR/Dominators.h"
+#include "llvm/Support/CfgTraits.h"
 
 namespace llvm {
 
+/// Partial CFG traits for VPlan's CFG, without a value type.
+class VPCfgTraitsBase : public CfgTraitsBase {
+public:
+  using ParentType = VPRegionBlock;
+  using BlockRef = VPBlockBase *;
+  using ValueRef = void;
+
+  static CfgBlockRef wrapRef(BlockRef block) {
+return makeOpaque(block);
+  }
+  static BlockRef unwrapRef(CfgBlockRef block) {
+return static_cast(getOpaque(block));
+  }
+};
+
+class VPCfgTraits : public CfgTraits {
+public:
+  static VPRegionBlock *getBlockParent(VPBlockBase *block) {
+return block->getParent();
+  }
+
+  static auto predecessors(VPBlockBase *block) {
+return llvm::inverse_children(block);
+  }
+
+  static auto successors(VPBlockBase *block) {
+return llvm::children(block);
+  }
+};
+
+template <> struct CfgTraitsFor { using CfgTraits = VPCfgTraits; };
+
 /// Template specialization of the standard LLVM dominator tree utility for
 /// VPBlockBases.
 using VPDominatorTree = DomTreeBase;
Index: llvm/lib/Support/CfgTraits.cpp
===
--- /dev/null
+++ llvm/lib/Support/CfgTraits.cpp
@@ -0,0 +1,14 @@
+//===- CfgTraits.cpp - Traits for generically working on CFGs ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/CfgTraits.h"
+
+using namespace llvm;
+
+void CfgInterface::anchor() {}
+void CfgPrinter::anchor() {}
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -97,6 +97,7 @@
   BranchProbability.cpp
   BuryPointer.cpp
   CachePruning.cpp
+  CfgTraits.cpp
   circular_raw_ostream.cpp
   Chrono.cpp
   COM.cpp
Index: llvm/lib/IR/CMakeLists.txt
===
--- llvm/lib/IR/CMakeLists.txt
+++ llvm/lib/IR/CMakeLists.txt
@@ -4,6 +4,7 @@
   Attributes.cpp
   AutoUpgrade.cpp
   BasicBlock.cpp
+  CFG.cpp
   Comdat.cpp
   ConstantFold.cpp
   ConstantRange.cpp
Index: llvm/lib/IR/CFG.cpp
===
--- /dev/null
+++ llvm/lib/IR/CFG.cpp
@@ -0,0 +1,56 @@
+//===- CFG.cpp -

[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas added inline comments.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:49-51
+  if (Node->getKind() == syntax::NodeKind::CompoundStatement) {
+const auto *Tree = dyn_cast(Node);
+assert(Tree);





Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:52-55
+const syntax::Token *FirstToken = Tree->findFirstLeaf()->getToken(),
+*LastToken = Tree->findLastLeaf()->getToken();
+assert(FirstToken->kind() == tok::TokenKind::l_brace);
+assert(LastToken->kind() == tok::TokenKind::r_brace);

Take a look at `clang/include/clang/Tooling/Syntax/Nodes.h`, syntax constructs 
usually have nice classes with accessors.

For instance `CompoundStatement` has the accessors `getLbrace` and `getRbrace` 
that seem to be exactly what you want.

However these might not give exactly the first leaf and last leaf in the case 
of syntactically incorrect code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88553

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


[PATCH] D89441: [xray] Honor xray-never function-instrument attribute

2020-10-20 Thread Dean Michael Berris via Phabricator via cfe-commits
dberris accepted this revision.
dberris added a comment.
This revision is now accepted and ready to land.

LGTM -- thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89441

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


[PATCH] D89752: [CUDA] Improve clang's ability to detect recent CUDA versions.

2020-10-20 Thread Evgeny Mankov via Phabricator via cfe-commits
emankov added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:158
 if (!VersionFile) {
-  // CUDA 7.0 doesn't have a version.txt, so guess that's our version if
-  // version.txt isn't present.
-  Version = CudaVersion::CUDA_70;
+  // CUDA 7.0 and CUDA 11.1+ do not have version.txt file.
+  // Use libdevice file to distinguish 7.0 from the new versions.

CUDA 11.0+, actually



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:161
+  if (FS.exists(LibDevicePath + "/libdevice.10.bc")) {
+Version = CudaVersion::LATEST;
+DetectedVersionIsNotSupported = Version > 
CudaVersion::LATEST_SUPPORTED;

Do we have any other mechanism besides version.txt for determining an exact 
CUDA version? Setting the latest version in case of absence of version.txt 
doesn't suit all the needs: sometimes the exact version is taken into account, 
for instance in [[ https://github.com/ROCm-Developer-Tools/HIPIFY#clang | 
hipify-clang ]].



Comment at: clang/test/Driver/cuda-version-check.cu:13
 // RUN:FileCheck %s --check-prefix=UNKNOWN_VERSION
+// CUDA-11.1 does not carry version.txt file. Make sure we still detect it as a
+// new version and handle it the same as we handle other new CUDA versions.

CUDA-11.0 Update 1 doesn't carry version.txt as well.



Comment at: clang/test/Driver/cuda-version-check.cu:72
 
-// UNKNOWN_VERSION: Unknown CUDA version 999.999. Assuming the latest 
supported version
+// UNKNOWN_VERSION: Unknown CUDA version{{.*}}. Assuming the latest supported 
version
 // UNKNOWN_VERSION_CXX-NOT: Unknown CUDA version

missing space before {{


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89752

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


[PATCH] D89719: [clang][Basic] Make SourceLocation usable as key in hash maps, NFCI

2020-10-20 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 299340.
miyuki edited the summary of this revision.
miyuki added a comment.

Added an example of usage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89719

Files:
  clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
  clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
  clang/include/clang/Basic/SourceLocation.h
  clang/lib/Basic/SourceLocation.cpp


Index: clang/lib/Basic/SourceLocation.cpp
===
--- clang/lib/Basic/SourceLocation.cpp
+++ clang/lib/Basic/SourceLocation.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -40,6 +41,10 @@
 // SourceLocation
 
//===--===//
 
+unsigned SourceLocation::getHashValue() const {
+  return llvm::DenseMapInfo::getHashValue(ID);
+}
+
 void SourceLocation::print(raw_ostream &OS, const SourceManager &SM)const{
   if (!isValid()) {
 OS << "";
Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -175,6 +175,7 @@
End.isFileID();
   }
 
+  unsigned getHashValue() const;
   void print(raw_ostream &OS, const SourceManager &SM) const;
   std::string printToString(const SourceManager &SM) const;
   void dump(const SourceManager &SM) const;
@@ -479,6 +480,27 @@
 }
   };
 
+  /// Define DenseMapInfo so that SourceLocation's can be used as keys in
+  /// DenseMap and DenseSet. This trait class is eqivalent to
+  /// DenseMapInfo which uses SourceLocation::ID is used as a key.
+  template <> struct DenseMapInfo {
+static clang::SourceLocation getEmptyKey() {
+  return clang::SourceLocation::getFromRawEncoding(~0U);
+}
+
+static clang::SourceLocation getTombstoneKey() {
+  return clang::SourceLocation::getFromRawEncoding(~0U - 1);
+}
+
+static unsigned getHashValue(clang::SourceLocation Loc) {
+  return Loc.getHashValue();
+}
+
+static bool isEqual(clang::SourceLocation LHS, clang::SourceLocation RHS) {
+  return LHS == RHS;
+}
+  };
+
   // Teach SmallPtrSet how to handle SourceLocation.
   template<>
   struct PointerLikeTypeTraits {
Index: clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
===
--- clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
+++ clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
@@ -33,7 +33,7 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
 private:
-  llvm::DenseSet MatchedTemplateLocations;
+  llvm::DenseSet MatchedTemplateLocations;
 };
 
 } // namespace google
Index: clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
+++ clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
@@ -298,8 +298,7 @@
 }
 
 if (IsInInstantiation) {
-  if (MatchedTemplateLocations.count(
-  ReplacementRange.getBegin().getRawEncoding()) == 0) {
+  if (MatchedTemplateLocations.count(ReplacementRange.getBegin()) == 0) {
 // For each location matched in a template instantiation, we check if
 // the location can also be found in `MatchedTemplateLocations`. If it
 // is not found, that means the expression did not create a match
@@ -313,8 +312,7 @@
 if (IsInTemplate) {
   // We gather source locations from template matches not in template
   // instantiations for future matches.
-  MatchedTemplateLocations.insert(
-  ReplacementRange.getBegin().getRawEncoding());
+  MatchedTemplateLocations.insert(ReplacementRange.getBegin());
 }
 
 if (!AddFix) {


Index: clang/lib/Basic/SourceLocation.cpp
===
--- clang/lib/Basic/SourceLocation.cpp
+++ clang/lib/Basic/SourceLocation.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -40,6 +41,10 @@
 // SourceLocation
 //===--===//
 
+unsigned SourceLocation::getHashValue() const {
+  return llvm::DenseMapInfo::getHashValue(ID);
+}
+
 void SourceLocation::print(raw_ostre

[PATCH] D32838: [libcxx] Make __shared_weak_count VTable consistent across all build configurations

2020-10-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 299342.
ldionne added a comment.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.

Rebase onto master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D32838

Files:
  libcxx/include/memory
  libcxx/src/memory.cpp


Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -124,16 +124,12 @@
 return nullptr;
 }
 
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
-
 const void*
 __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
 {
 return nullptr;
 }
 
-#endif  // _LIBCPP_NO_RTTI
-
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 
 _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3271,13 +3271,7 @@
 long use_count() const _NOEXCEPT {return __shared_count::use_count();}
 __shared_weak_count* lock() _NOEXCEPT;
 
-// Define the function out only if we build static libc++ without RTTI.
-// Otherwise we may break clients who need to compile their projects with
-// -fno-rtti and yet link against a libc++.dylib compiled
-// without -fno-rtti.
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-#endif
 private:
 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
 };


Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -124,16 +124,12 @@
 return nullptr;
 }
 
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
-
 const void*
 __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
 {
 return nullptr;
 }
 
-#endif  // _LIBCPP_NO_RTTI
-
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 
 _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3271,13 +3271,7 @@
 long use_count() const _NOEXCEPT {return __shared_count::use_count();}
 __shared_weak_count* lock() _NOEXCEPT;
 
-// Define the function out only if we build static libc++ without RTTI.
-// Otherwise we may break clients who need to compile their projects with
-// -fno-rtti and yet link against a libc++.dylib compiled
-// without -fno-rtti.
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-#endif
 private:
 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89528: [clang][test] Fix prefix operator++ signature in iterators

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

Ok, thanks for the context. LG!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89528

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


[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:37
 
-// Recursively collects FoldingRange from a symbol and its children.
-void collectFoldingRanges(DocumentSymbol Symbol,
-  std::vector &Result) {
+FoldingRange constructFoldingRange(SourceRange SR, const SourceManager &SM) {
   FoldingRange Range;

WDYT about "makeFoldingRange" or even "toFoldingRange" to emphasize it is a 
factory / conversion function (no actual computation)?



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:47
+// Traverse the tree and collect folding ranges along the way.
+void collectRanges(const syntax::Node *Node, const SourceManager &SM,
+   std::vector &Ranges) {

"collectFoldingRanges" was a better name I think.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:48
+void collectRanges(const syntax::Node *Node, const SourceManager &SM,
+   std::vector &Ranges) {
+  if (Node->getKind() == syntax::NodeKind::CompoundStatement) {

Why not return the vector?



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:246
+
+  // However, if there are newlines between {}, we will still generate
+  // one.

"Will" makes it sound like it is not intentional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88553

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


[PATCH] D32838: [libcxx] Make __shared_weak_count VTable consistent across all build configurations

2020-10-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 299344.
ldionne added a comment.
Herald added a subscriber: mgorny.
Herald added a project: libc++abi.
Herald added a reviewer: libc++abi.

Remove uses of _LIBCPP_BUILD_STATIC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D32838

Files:
  libcxx/include/memory
  libcxx/src/memory.cpp
  libcxxabi/CMakeLists.txt


Index: libcxxabi/CMakeLists.txt
===
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -338,10 +338,6 @@
 list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG)
   endif()
 endif()
-# Static library
-if (NOT LIBCXXABI_ENABLE_SHARED)
-  list(APPEND LIBCXXABI_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
-endif()
 
 # Threading
 if (NOT LIBCXXABI_ENABLE_THREADS)
Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -124,16 +124,12 @@
 return nullptr;
 }
 
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
-
 const void*
 __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
 {
 return nullptr;
 }
 
-#endif  // _LIBCPP_NO_RTTI
-
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 
 _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3271,13 +3271,7 @@
 long use_count() const _NOEXCEPT {return __shared_count::use_count();}
 __shared_weak_count* lock() _NOEXCEPT;
 
-// Define the function out only if we build static libc++ without RTTI.
-// Otherwise we may break clients who need to compile their projects with
-// -fno-rtti and yet link against a libc++.dylib compiled
-// without -fno-rtti.
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-#endif
 private:
 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
 };


Index: libcxxabi/CMakeLists.txt
===
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -338,10 +338,6 @@
 list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG)
   endif()
 endif()
-# Static library
-if (NOT LIBCXXABI_ENABLE_SHARED)
-  list(APPEND LIBCXXABI_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
-endif()
 
 # Threading
 if (NOT LIBCXXABI_ENABLE_THREADS)
Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -124,16 +124,12 @@
 return nullptr;
 }
 
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
-
 const void*
 __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
 {
 return nullptr;
 }
 
-#endif  // _LIBCPP_NO_RTTI
-
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 
 _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3271,13 +3271,7 @@
 long use_count() const _NOEXCEPT {return __shared_count::use_count();}
 __shared_weak_count* lock() _NOEXCEPT;
 
-// Define the function out only if we build static libc++ without RTTI.
-// Otherwise we may break clients who need to compile their projects with
-// -fno-rtti and yet link against a libc++.dylib compiled
-// without -fno-rtti.
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-#endif
 private:
 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32838: [libcxx] Make __shared_weak_count VTable consistent across all build configurations

2020-10-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

For libc++: We never manually define `_LIBCPP_BUILD_STATIC`, so libc++ always 
contains `__shared_weak_count::__get_deleter`.
For libc++abi: It could happen that `_LIBCPP_BUILD_STATIC` is defined through 
the CMake logic, however libc++abi always builds with RTTI enabled. So 
`!defined(_LIBCPP_NO_RTTI)` is always true anyway, and we always get the 
declaration of `__shared_weak_count::__get_deleter`.

I think this is a no-op change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D32838

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


[PATCH] D32838: [libcxx] Make __shared_weak_count VTable consistent across all build configurations

2020-10-20 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG229db3647491: [libc++] Make __shared_weak_count vtable 
consistent across all build… (authored by EricWF, committed by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D32838

Files:
  libcxx/include/memory
  libcxx/src/memory.cpp
  libcxxabi/CMakeLists.txt


Index: libcxxabi/CMakeLists.txt
===
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -338,10 +338,6 @@
 list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG)
   endif()
 endif()
-# Static library
-if (NOT LIBCXXABI_ENABLE_SHARED)
-  list(APPEND LIBCXXABI_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
-endif()
 
 # Threading
 if (NOT LIBCXXABI_ENABLE_THREADS)
Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -124,16 +124,12 @@
 return nullptr;
 }
 
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
-
 const void*
 __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
 {
 return nullptr;
 }
 
-#endif  // _LIBCPP_NO_RTTI
-
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 
 _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3271,13 +3271,7 @@
 long use_count() const _NOEXCEPT {return __shared_count::use_count();}
 __shared_weak_count* lock() _NOEXCEPT;
 
-// Define the function out only if we build static libc++ without RTTI.
-// Otherwise we may break clients who need to compile their projects with
-// -fno-rtti and yet link against a libc++.dylib compiled
-// without -fno-rtti.
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-#endif
 private:
 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
 };


Index: libcxxabi/CMakeLists.txt
===
--- libcxxabi/CMakeLists.txt
+++ libcxxabi/CMakeLists.txt
@@ -338,10 +338,6 @@
 list(APPEND LIBCXXABI_COMPILE_FLAGS -DNDEBUG)
   endif()
 endif()
-# Static library
-if (NOT LIBCXXABI_ENABLE_SHARED)
-  list(APPEND LIBCXXABI_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC)
-endif()
 
 # Threading
 if (NOT LIBCXXABI_ENABLE_THREADS)
Index: libcxx/src/memory.cpp
===
--- libcxx/src/memory.cpp
+++ libcxx/src/memory.cpp
@@ -124,16 +124,12 @@
 return nullptr;
 }
 
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
-
 const void*
 __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT
 {
 return nullptr;
 }
 
-#endif  // _LIBCPP_NO_RTTI
-
 #if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
 
 _LIBCPP_SAFE_STATIC static const std::size_t __sp_mut_count = 16;
Index: libcxx/include/memory
===
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -3271,13 +3271,7 @@
 long use_count() const _NOEXCEPT {return __shared_count::use_count();}
 __shared_weak_count* lock() _NOEXCEPT;
 
-// Define the function out only if we build static libc++ without RTTI.
-// Otherwise we may break clients who need to compile their projects with
-// -fno-rtti and yet link against a libc++.dylib compiled
-// without -fno-rtti.
-#if !defined(_LIBCPP_NO_RTTI) || !defined(_LIBCPP_BUILD_STATIC)
 virtual const void* __get_deleter(const type_info&) const _NOEXCEPT;
-#endif
 private:
 virtual void __on_zero_shared_weak() _NOEXCEPT = 0;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D85697: [clang-tidy] Add cppcoreguidelines-prefer-scoped-enums

2020-10-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D85697#2340317 , 
@janosbenjaminantal wrote:

> In D85697#2338249 , @njames93 wrote:
>
>> In D85697#2234468 , 
>> @janosbenjaminantal wrote:
>>
>>> It is not strongly connected to this review, but in the future I am 
>>> planning to extend the check with:
>>>
>>> - options to exclude enums, because changing them to scoped enumerations 
>>> might not be suitable for every cases
>>
>> Not strictly necessary, if people don't want the fix they could annotate the 
>> code with a `// NOLINT(*prefer-unscoped-enums)` comment.
>
> I think with the inline suppression the users should annotate every usage of 
> the enum while with the option it would be enough to list the enum's name to 
> ignore it from the whole check. However it is just an improvement, when I 
> reach that point I will do further digging about this topic, how the 
> suppression actually work etc.

Ah so an issue here is you emit a warning for the enum declaration as well as 
each usage and the NOLINT will only affect warnings emitted for the line its 
declared on.
Perhaps this needs a reshape.

Only emit a warning for the enum declaration and make sure the fix-its are 
attached to that warning, This is a safer way around this, and its also how 
RenamerClangTidy checks work. It means that if there is any conflict when 
trying to apply one of the fix-its none of them will be applied.
If you want to emit notes about usages that need updating you can, but don't 
attach fixes there, they wont be applied.

Due to how diagnostics works this will make it the code slightly more finicky, 
you can only have one DiagnosticBuilder active at once, and the notes need to 
be added after the warning has been emitted.

Maybe if it can be fixed, Emit a warning for the enum declaration, then add 
fix-its for the decl, any forward declares and any usages, then emit that 
diagnostic (Happens when the DiagnosticBuilder gets destroyed). After that you 
could emit notes for the forward declarations and usages(though I don't think 
we really needs notes for those)
If it can't be fixed its kind of similar, emit a warning for the declaration, 
then a note for each forward declaration and fault for why a fix can't be 
applied.
This has the added bonus that clang-tidy will output the diagnostics for an 
unscoped enum and all its uses next to each other.
If you want I've done the legwork to change the diagnostics behaviour to this 
and fix up the test cases if you want to have a look, should apply cleanly atop 
this version.
F13390481: ScopedEnums.patch 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85697

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


[PATCH] D88566: be more specific when testing for no fuse-ld warnings

2020-10-20 Thread Ties Stuij via Phabricator via cfe-commits
stuij added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88566

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


[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-20 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 299347.
eduucaldas marked 2 inline comments as not done.
eduucaldas added a comment.

Add tests, `ElementAndDelimiter` are input iterators


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  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
@@ -11,6 +11,7 @@
 #include "clang/Tooling/Syntax/BuildTree.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gtest/gtest.h"
 
 using namespace clang;
@@ -125,7 +126,7 @@
 }
 
 class ListTest : public SyntaxTreeTest {
-private:
+protected:
   std::string dumpQuotedTokensOrNull(const Node *N) {
 return N ? "'" +
StringRef(N->dumpTokens(Arena->getSourceManager()))
@@ -135,7 +136,15 @@
  : "null";
   }
 
-protected:
+  std::string
+  dumpElementAndDelimiter(const List::ElementAndDelimiter ED) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+OS << "(" << dumpQuotedTokensOrNull(ED.element) << ", "
+   << dumpQuotedTokensOrNull(ED.delimiter) << ")";
+return OS.str();
+  }
+
   std::string
   dumpElementsAndDelimiters(ArrayRef> EDs) {
 std::string Storage;
@@ -145,8 +154,7 @@
 
 llvm::interleaveComma(
 EDs, OS, [&OS, this](const List::ElementAndDelimiter &ED) {
-  OS << "(" << dumpQuotedTokensOrNull(ED.element) << ", "
- << dumpQuotedTokensOrNull(ED.delimiter) << ")";
+  OS << dumpElementAndDelimiter(ED);
 });
 
 OS << "]";
@@ -351,4 +359,40 @@
   EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', 'b', 'c']");
 }
 
+TEST_P(ListTest, List_Iterator_StableDereference) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  buildTree("", GetParam());
+
+  // "a:: b:: c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::coloncolon), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::coloncolon), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::NestedNameSpecifier));
+
+  auto It = List->getBeginNode();
+  const auto &First = *It;
+  auto ItAssign = It;
+
+  EXPECT_EQ(dumpElementAndDelimiter(First), "('a', '::')");
+  ++It;
+  EXPECT_EQ(dumpElementAndDelimiter(First), "('a', '::')");
+
+  EXPECT_EQ(*ItAssign, First);
+
+  auto It2 = std::next(List->getBeforeBegin(), 2);
+  EXPECT_EQ(It, It2);
+  EXPECT_EQ(*It, *It2);
+
+  ++It;
+  ++It;
+  EXPECT_EQ(It, List->getEndNode());
+}
 } // namespace
Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -311,91 +311,40 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
-
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
-}
-  }
+bool syntax::List::isElement(syntax::Node *N) {
+  return N && N->getRole() == NodeRole::ListElement;
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
-}
-break;
-  }
-  }
+bool syntax::List::isDelimiter(syntax::Node *N) {
+  return N && N->getRole() == NodeRole::ListDelimiter;
+}
 
-  return Children;
+syntax::List::ElementAndDelimiterIterator
+syntax::List::getBeforeBegin() {
+  return ElementAndDelimiterIterator::makeBeforeBegin(this);
 }
 
-// Almost the same implementation of `getElementsAsNodesAndDelimiters` but
-// 

[PATCH] D89372: [OpenCL] Remove unused extensions

2020-10-20 Thread Marco Antognini via Phabricator via cfe-commits
mantognini added a comment.
Herald added a subscriber: dexonsmith.

I don't want to stop the wider discussion, that being said I think I've 
addressed the comment regarding the content of this PR. Let me know if the 
latest version is fine or needs further addressing. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89372

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


[PATCH] D89761: Split out llvm/Support/FileSystem/UniqueID.h and clang/Basic/FileEntry.h, NFC

2020-10-20 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Basic/FileEntry.h:33
+
+using llvm::Optional;
+using llvm::StringRef;

JDevlieghere wrote:
> Won't this now make `llvm::Optional` visible as `clang::Optional` everywhere 
> this header is included? Isn't this considered bad practice in a header? 
I thought I found both of these usable in clang headers elsewhere. I’ll double 
check. 


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

https://reviews.llvm.org/D89761

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


[PATCH] D88553: [clangd] Start using SyntaxTrees for folding ranges feature

2020-10-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:39
   FoldingRange Range;
-  Range.startLine = Symbol.range.start.line;
-  Range.startCharacter = Symbol.range.start.character;
-  Range.endLine = Symbol.range.end.line;
-  Range.endCharacter = Symbol.range.end.character;
-  Result.push_back(Range);
-  for (const auto &Child : Symbol.children)
-collectFoldingRanges(Child, Result);
+  Range.startCharacter = SM.getSpellingColumnNumber(SR.getBegin()) - 1;
+  Range.startLine = SM.getSpellingLineNumber(SR.getBegin()) - 1;

Have you considered how you want macro-expanded code to work?

As written, this code can produce ranges inside macro definitions, invalid 
ranges (if { and } aren't from the same macro expansion) or even crash 
(FirstToken->endLocation() may be an invalid one-past-the-end location).

My suggestion would be to have this return optional and simply 
bail out if the location are not file locations for now. (Later we can deal 
with macro args in some cases)



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:52-55
+const syntax::Token *FirstToken = Tree->findFirstLeaf()->getToken(),
+*LastToken = Tree->findLastLeaf()->getToken();
+assert(FirstToken->kind() == tok::TokenKind::l_brace);
+assert(LastToken->kind() == tok::TokenKind::r_brace);

eduucaldas wrote:
> Take a look at `clang/include/clang/Tooling/Syntax/Nodes.h`, syntax 
> constructs usually have nice classes with accessors.
> 
> For instance `CompoundStatement` has the accessors `getLbrace` and 
> `getRbrace` that seem to be exactly what you want.
> 
> However these might not give exactly the first leaf and last leaf in the case 
> of syntactically incorrect code.
I think we should treat all bracket-like things generically. Today this is just 
CompoundStmt, but we want to handle init lists, function calls, parens around 
for-loop conditions, template parameter and arg lists etc in the same way.

This sort of use is why the `OpenParen`/`CloseParen` NodeRoles are generic - we 
can have one set of logic to handle all of these. (No opinion on whether that 
should live here or in the syntax trees library, but putting it here for now 
seems fine).

So in the end I think checking the class name and then grabbing the braces by 
role (not kind) is the right thing here.
We definitely want to avoid asserting that the code looks the way we expect 
though.



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:56
+assert(LastToken->kind() == tok::TokenKind::r_brace);
+const SourceRange SR(FirstToken->endLocation(), LastToken->location());
+FoldingRange Range = constructFoldingRange(SR, SM);

this is worthy of a comment (fold the entire range inside the brackets, 
including whitespace)



Comment at: clang-tools-extra/clangd/SemanticSelection.cpp:60
+// nodes and newlines.
+if (Tree->findFirstLeaf()->getNextSibling() != Tree->findLastLeaf() ||
+Range.startLine != Range.endLine)

until we support FoldingRangeClientCapabilities, should we just have the line 
check?



Comment at: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp:206
   R"cpp(
-[[int global_variable]];
+void func() {[[
+  int Variable = 100;

This is too many test cases for straightforward compoundstmt, I think. We have 
only once type of node handled for now, but we can't afford to write and 
maintain this many tests once we have lots.

I think a single if{}-elseif(nobraces)-else{} along with the existing function 
examples is probably enough. (Function examples show missing range for empty 
body, though it could use a comment)

We definitely need cases for macros:
 - entire {} within one macro arg
 - entire {} in the macro body
 - some combination (e.g. { in macro body, } outside the macro)
(we won't need these for every node type, assuming we have some consistent 
handling)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88553

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


[PATCH] D89719: [clang][Basic] Make SourceLocation usable as key in hash maps, NFCI

2020-10-20 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89719

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


[PATCH] D88106: [SyntaxTree] Provide iterator-like functions for Lists

2020-10-20 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 299348.
eduucaldas added a comment.

rename getBeforeBegin


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88106

Files:
  clang/include/clang/Tooling/Syntax/Tree.h
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  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
@@ -11,6 +11,7 @@
 #include "clang/Tooling/Syntax/BuildTree.h"
 #include "clang/Tooling/Syntax/Nodes.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gtest/gtest.h"
 
 using namespace clang;
@@ -125,7 +126,7 @@
 }
 
 class ListTest : public SyntaxTreeTest {
-private:
+protected:
   std::string dumpQuotedTokensOrNull(const Node *N) {
 return N ? "'" +
StringRef(N->dumpTokens(Arena->getSourceManager()))
@@ -135,7 +136,15 @@
  : "null";
   }
 
-protected:
+  std::string
+  dumpElementAndDelimiter(const List::ElementAndDelimiter ED) {
+std::string Storage;
+llvm::raw_string_ostream OS(Storage);
+OS << "(" << dumpQuotedTokensOrNull(ED.element) << ", "
+   << dumpQuotedTokensOrNull(ED.delimiter) << ")";
+return OS.str();
+  }
+
   std::string
   dumpElementsAndDelimiters(ArrayRef> EDs) {
 std::string Storage;
@@ -145,8 +154,7 @@
 
 llvm::interleaveComma(
 EDs, OS, [&OS, this](const List::ElementAndDelimiter &ED) {
-  OS << "(" << dumpQuotedTokensOrNull(ED.element) << ", "
- << dumpQuotedTokensOrNull(ED.delimiter) << ")";
+  OS << dumpElementAndDelimiter(ED);
 });
 
 OS << "]";
@@ -351,4 +359,40 @@
   EXPECT_EQ(dumpNodes(List->getElementsAsNodes()), "['a', 'b', 'c']");
 }
 
+TEST_P(ListTest, List_Iterator_StableDereference) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  buildTree("", GetParam());
+
+  // "a:: b:: c"
+  auto *List = dyn_cast(syntax::createTree(
+  *Arena,
+  {
+  {createLeaf(*Arena, tok::identifier, "a"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::coloncolon), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "b"), NodeRole::ListElement},
+  {createLeaf(*Arena, tok::coloncolon), NodeRole::ListDelimiter},
+  {createLeaf(*Arena, tok::identifier, "c"), NodeRole::ListElement},
+  },
+  NodeKind::NestedNameSpecifier));
+
+  auto It = List->getElementAndDelimiterBegin();
+  const auto &First = *It;
+  auto ItAssign = It;
+
+  EXPECT_EQ(dumpElementAndDelimiter(First), "('a', '::')");
+  ++It;
+  EXPECT_EQ(dumpElementAndDelimiter(First), "('a', '::')");
+
+  EXPECT_EQ(*ItAssign, First);
+
+  auto It2 = std::next(List->getElementAndDelimiterBeforeBegin(), 2);
+  EXPECT_EQ(It, It2);
+  EXPECT_EQ(*It, *It2);
+
+  ++It;
+  ++It;
+  EXPECT_EQ(It, List->getElementAndDelimiterEnd());
+}
 } // namespace
Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -311,91 +311,41 @@
   }
 }
 
-std::vector>
-syntax::List::getElementsAsNodesAndDelimiters() {
-  if (!getFirstChild())
-return {};
-
-  std::vector> Children;
-  syntax::Node *ElementWithoutDelimiter = nullptr;
-  for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
-switch (C->getRole()) {
-case syntax::NodeRole::ListElement: {
-  if (ElementWithoutDelimiter) {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-  }
-  ElementWithoutDelimiter = C;
-  break;
-}
-case syntax::NodeRole::ListDelimiter: {
-  Children.push_back({ElementWithoutDelimiter, cast(C)});
-  ElementWithoutDelimiter = nullptr;
-  break;
-}
-default:
-  llvm_unreachable(
-  "A list can have only elements and delimiters as children.");
-}
-  }
+bool syntax::List::isElement(syntax::Node *N) {
+  return N && N->getRole() == NodeRole::ListElement;
+}
 
-  switch (getTerminationKind()) {
-  case syntax::List::TerminationKind::Separated: {
-Children.push_back({ElementWithoutDelimiter, nullptr});
-break;
-  }
-  case syntax::List::TerminationKind::Terminated:
-  case syntax::List::TerminationKind::MaybeTerminated: {
-if (ElementWithoutDelimiter) {
-  Children.push_back({ElementWithoutDelimiter, nullptr});
-}
-break;
-  }
-  }
+bool syntax::List::isDelimiter(syntax::Node *N) {
+  return N && N->getRole() == NodeRole::ListDelimiter;
+}
 
-  return Children;
+syntax::List::ElementAndDelimiterIterator
+syntax::List::getElementAndDelimiterBeforeBegin() {
+  return ElementAndDelimiterIterator::makeBeforeBegin(this);
 }
 
-// Almost the same implementation of `getElementsAsNodesAndDelimiters` but
-// ignoring del

[clang-tools-extra] 6487ffa - Reland "[yaml2obj][ELF] - Simplify the code that performs sections validation."

2020-10-20 Thread Georgii Rymar via cfe-commits

Author: Georgii Rymar
Date: 2020-10-20T16:25:33+03:00
New Revision: 6487ffafd1dd5ab81c440dde46163218a85d90b5

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

LOG: Reland "[yaml2obj][ELF] - Simplify the code that performs sections 
validation."

This reverts commit 1b589f4d4db27e3fcd81fdc5abeb9407753ab790 and relands the 
D89463
with the fix: update `MappingTraits::validate()` in 
ClangTidyOptions.cpp to
match the new signature (change the return type to "std::string" from 
"StringRef").

Original commit message:

This:

Changes the return type of MappingTraits>::validate to std::string
instead of StringRef. It allows to create more complex error messages.

It introduces std::vector> getEntries():
a new virtual method of Section, which is the base class for all sections.
It returns names of special section specific keys (e.g. "Entries") and flags 
that says if them exist in a YAML.
The code in validate() uses this list of entries descriptions to generalize 
validation.
This approach was discussed in the D89039 thread.

Differential revision: https://reviews.llvm.org/D89463

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
llvm/include/llvm/ObjectYAML/DWARFYAML.h
llvm/include/llvm/ObjectYAML/ELFYAML.h
llvm/include/llvm/ObjectYAML/MachOYAML.h
llvm/include/llvm/ObjectYAML/MinidumpYAML.h
llvm/include/llvm/Support/YAMLTraits.h
llvm/lib/ObjectYAML/DWARFYAML.cpp
llvm/lib/ObjectYAML/ELFYAML.cpp
llvm/lib/ObjectYAML/MachOYAML.cpp
llvm/lib/ObjectYAML/MinidumpYAML.cpp
llvm/test/tools/yaml2obj/ELF/gnu-hash-section.yaml
llvm/unittests/Support/YAMLIOTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 6b28cb2bdd13..8ff22041d725 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -47,14 +47,14 @@ template <> struct MappingTraits {
 IO.mapRequired("name", File.Name);
 IO.mapOptional("lines", File.LineRanges);
   }
-  static StringRef validate(IO &io, FileFilter &File) {
+  static std::string validate(IO &io, FileFilter &File) {
 if (File.Name.empty())
   return "No file name specified";
 for (const FileFilter::LineRange &Range : File.LineRanges) {
   if (Range.first <= 0 || Range.second <= 0)
 return "Invalid line range";
 }
-return StringRef();
+return "";
   }
 };
 

diff  --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp 
b/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
index 7f53faaeaea3..3826e97d62b9 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
@@ -740,9 +740,7 @@ struct MappingTraits {
 io.mapOptional("exports",  file.exportInfo);
 io.mapOptional("dataInCode",   file.dataInCode);
   }
-  static StringRef validate(IO &io, NormalizedFile &file) {
-return StringRef();
-  }
+  static std::string validate(IO &io, NormalizedFile &file) { return {}; }
 };
 
 } // namespace llvm

diff  --git a/llvm/include/llvm/ObjectYAML/DWARFYAML.h 
b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
index edb5f00c5e80..856cea9a1535 100644
--- a/llvm/include/llvm/ObjectYAML/DWARFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DWARFYAML.h
@@ -359,8 +359,8 @@ struct MappingTraits> {
 template 
 struct MappingTraits> {
   static void mapping(IO &IO, DWARFYAML::ListEntries &ListEntries);
-  static StringRef validate(IO &IO,
-DWARFYAML::ListEntries &ListEntries);
+  static std::string validate(IO &IO,
+  DWARFYAML::ListEntries &ListEntries);
 };
 
 template <> struct MappingTraits {

diff  --git a/llvm/include/llvm/ObjectYAML/ELFYAML.h 
b/llvm/include/llvm/ObjectYAML/ELFYAML.h
index af6d934d611e..28cbf325ecb6 100644
--- a/llvm/include/llvm/ObjectYAML/ELFYAML.h
+++ b/llvm/include/llvm/ObjectYAML/ELFYAML.h
@@ -193,6 +193,13 @@ struct Section : public Chunk {
 
   static bool classof(const Chunk *S) { return S->Kind != ChunkKind::Fill; }
 
+  // Some derived sections might have their own special entries. This method
+  // returns a vector of  pairs. It is used for section
+  // validation.
+  virtual std::vector> getEntries() const {
+return {};
+  };
+
   // The following members are used to override section fields which is
   // useful for creating invalid objects.
 
@@ -235,6 +242,10 @@ struct StackSizesSection : Section {
 
   StackSizesSection() : Section(ChunkKind::StackSizes) {}
 
+  std::vector> getEntries() const override {
+return {{"Entries", Entries.hasValue()}};
+  };
+
   static bool classof(const Chunk 

[PATCH] D89790: [clangd] Add basic conflict detection for the rename.

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

With this patch, we reject the rename if the new name would conflict with
any other decls in the decl context of the renamed decl.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89790

Files:
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -630,6 +630,44 @@
  class Foo {};
)cpp",
"no symbol", !HeaderFile, nullptr},
+
+  {R"cpp(
+namespace {
+int Conflict;
+int Va^r;
+}
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(
+int Conflict;
+int Va^r;
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(
+class Foo {
+  int Conflict;
+  int Va^r;
+};
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(
+enum E {
+  Conflict,
+  Fo^o,
+};
+  )cpp",
+   "conflict", !HeaderFile, nullptr, "Conflict"},
+
+  {R"cpp(// FIXME: detecting local variables is not supported yet.
+void func() {
+  int Conflict;
+  int [[V^ar]];
+}
+  )cpp",
+   nullptr, !HeaderFile, nullptr, "Conflict"},
   };
 
   for (const auto& Case : Cases) {
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -254,6 +254,74 @@
   return Results;
 }
 
+// Lookup the declarations (if any) with the given Name in the given DC.
+NamedDecl *lookup(const ASTContext &Ctx, const DeclContext *DC,
+  llvm::StringRef Name) {
+  const auto &II = Ctx.Idents.get(Name);
+  DeclarationName LookupName(&II);
+  DeclContextLookupResult LookupResult;
+  switch (DC->getDeclKind()) {
+  case Decl::TranslationUnit:
+  case Decl::Namespace:
+  case Decl::Record:
+  case Decl::Enum:
+  case Decl::CXXRecord:
+LookupResult = DC->lookup(LookupName);
+break;
+  default:
+break;
+  }
+  if (!LookupResult.empty())
+return LookupResult.front();
+  return nullptr;
+}
+
+struct InvalidName {
+  enum Kind {
+Keywords,
+Conflict,
+  };
+  Kind K;
+  std::string Details;
+};
+
+llvm::Error makeError(InvalidName Reason) {
+  auto Message = [](InvalidName Reason) {
+switch (Reason.K) {
+case InvalidName::Keywords:
+  return llvm::formatv("the chosen name \"{0}\" is a keyword",
+   Reason.Details);
+case InvalidName::Conflict:
+  return llvm::formatv("conflict with the symbol in {0}", Reason.Details);
+}
+llvm_unreachable("unhandled InvalidName kind");
+  };
+  return error("invalid name: {0}", Message(Reason));
+}
+
+// Check if we can rename the given RenameDecl into NewName.
+// Return details if the rename would produce a conflict.
+llvm::Optional checkName(const NamedDecl &RenameDecl,
+  llvm::StringRef NewName) {
+  auto &ASTCtx = RenameDecl.getASTContext();
+  if (isKeyword(NewName, ASTCtx.getLangOpts()))
+return InvalidName{InvalidName::Keywords, NewName.str()};
+  // FIXME: detecting function conflicts is tricky, e.g. we can have a same name
+  // for two overload functions.
+  if (RenameDecl.getKind() == Decl::Function)
+return llvm::None;
+  // Perform a lookup in the decl context of the RenameDecl, to find out any
+  // conflicts if we perform the rename.
+  // (!) DeclContext::lookup doesn't perform lookup local decls in a
+  // function-kind DeclContext.
+  auto *Conflict = lookup(ASTCtx, RenameDecl.getDeclContext(), NewName);
+  if (!Conflict)
+return llvm::None;
+  return InvalidName{
+  InvalidName::Conflict,
+  Conflict->getLocation().printToString(ASTCtx.getSourceManager())};
+}
+
 // AST-based rename, it renames all occurrences in the main file.
 llvm::Expected
 renameWithinFile(ParsedAST &AST, const NamedDecl &RenameDecl,
@@ -476,11 +544,12 @@
 return makeError(ReasonToReject::NoSymbolFound);
   if (DeclsUnderCursor.size() > 1)
 return makeError(ReasonToReject::AmbiguousSymbol);
-  if (isKeyword(RInputs.NewName, AST.getLangOpts()))
-return makeError(ReasonToReject::RenameToKeywords);
-
   const auto &RenameDecl =
   llvm::cast(*(*DeclsUnderCursor.begin())->getCanonicalDecl());
+  auto Invalid = checkName(RenameDecl, RInputs.NewName);
+  if (Invalid)
+return makeError(*Invalid);
+
   auto Reject = renameable(R

[clang] 1ed506d - [clang] Fix warnings on the missing of explicitly copy constructor on the base class. NFC.

2020-10-20 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-10-20T10:06:24-04:00
New Revision: 1ed506deaddb41870d22f5b48d52ba710e8d6c00

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

LOG: [clang] Fix warnings on the missing of explicitly copy constructor on the 
base class. NFC.

Added: 


Modified: 
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Basic/PartialDiagnostic.h

Removed: 




diff  --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index f17b98f74038..3895e1f45894 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -1284,7 +1284,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
 public:
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
-  DiagnosticBuilder(const DiagnosticBuilder &D) {
+  DiagnosticBuilder(const DiagnosticBuilder &D) : StreamingDiagnostic(D) {
 DiagObj = D.DiagObj;
 DiagStorage = D.DiagStorage;
 IsActive = D.IsActive;

diff  --git a/clang/include/clang/Basic/PartialDiagnostic.h 
b/clang/include/clang/Basic/PartialDiagnostic.h
index 9e017902b120..9ddf64d2de2c 100644
--- a/clang/include/clang/Basic/PartialDiagnostic.h
+++ b/clang/include/clang/Basic/PartialDiagnostic.h
@@ -49,7 +49,8 @@ class PartialDiagnostic : public StreamingDiagnostic {
   PartialDiagnostic(unsigned DiagID, DiagStorageAllocator &Allocator_)
   : StreamingDiagnostic(Allocator_), DiagID(DiagID) {}
 
-  PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) {
+  PartialDiagnostic(const PartialDiagnostic &Other)
+  : StreamingDiagnostic(Other), DiagID(Other.DiagID) {
 Allocator = Other.Allocator;
 if (Other.DiagStorage) {
   DiagStorage = getStorage();



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


[PATCH] D89579: [clangd][ObjC] Support nullability annotations

2020-10-20 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D89579#2341513 , @sammccall wrote:

> Yep, let's revert to the previous state and land that, and I'll puzzle over 
> the examples you give (because always returning false shouldn't affect 
> behavior, just performance).
>
> I have put together D89785  for more general 
> attribute support, and it has a generalization of the fix here. (It returns 
> `false` for any node with an attribute attached).
> But it's worth landing this first as it has good tests for the objc cases, 
> and that patch has its own prerequisites and risks of regressions.
> (Not a timely coincidence, rather I got curious about the AST around Attrs 
> after seeing this patch)

SGTM,  the simplified cause is:

  R"cpp( [[int ^x = $C[[0]]^]]; )cpp"

which you can add to `TEST(SelectionTest, Selected)` in SelectionTests.cpp 
.

With a proper attribute fix I think to fix this selection issue above we'll 
need to change claimRange 
 
to take children into affect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89579

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


[PATCH] D89708: Move clang/Tooling/Core/Lookup.h to clang/Tooling/Refactoring/Lookup.h

2020-10-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Nice!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89708

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


[PATCH] D89612: NFC: Fix -Wsign-compare warnings on 32-bit builds

2020-10-20 Thread Denis Antrushin via Phabricator via cfe-commits
dantrushin accepted this revision.
dantrushin added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89612

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


[clang] e7a6915 - Revert "[clang] Fix warnings on the missing of explicitly copy constructor on the base class. NFC."

2020-10-20 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2020-10-20T10:25:20-04:00
New Revision: e7a69158635a30cb673e443a3b95ece359c72cc1

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

LOG: Revert "[clang] Fix warnings on the missing of explicitly copy constructor 
on the base class. NFC."

This reverts commit 1ed506deaddb41870d22f5b48d52ba710e8d6c00.

Added: 


Modified: 
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Basic/PartialDiagnostic.h

Removed: 




diff  --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index 3895e1f458948..f17b98f740385 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -1284,7 +1284,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
 public:
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
-  DiagnosticBuilder(const DiagnosticBuilder &D) : StreamingDiagnostic(D) {
+  DiagnosticBuilder(const DiagnosticBuilder &D) {
 DiagObj = D.DiagObj;
 DiagStorage = D.DiagStorage;
 IsActive = D.IsActive;

diff  --git a/clang/include/clang/Basic/PartialDiagnostic.h 
b/clang/include/clang/Basic/PartialDiagnostic.h
index 9ddf64d2de2c5..9e017902b1205 100644
--- a/clang/include/clang/Basic/PartialDiagnostic.h
+++ b/clang/include/clang/Basic/PartialDiagnostic.h
@@ -49,8 +49,7 @@ class PartialDiagnostic : public StreamingDiagnostic {
   PartialDiagnostic(unsigned DiagID, DiagStorageAllocator &Allocator_)
   : StreamingDiagnostic(Allocator_), DiagID(DiagID) {}
 
-  PartialDiagnostic(const PartialDiagnostic &Other)
-  : StreamingDiagnostic(Other), DiagID(Other.DiagID) {
+  PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) {
 Allocator = Other.Allocator;
 if (Other.DiagStorage) {
   DiagStorage = getStorage();



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


[PATCH] D82999: [CodeGen] Check the cleanup flag before destructing lifetime-extended temporaries created in conditional expressions

2020-10-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak abandoned this revision.
ahatanak added a comment.

This was fixed by https://reviews.llvm.org/D86854.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82999

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


[PATCH] D88239: [clang-format] Fix spaces around */& in multi-variable declarations

2020-10-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added subscribers: sammccall, djasper, klimek.
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:6636
-  verifyFormat("a *a = aaa, *b = 
bbb,\n"
-   "  *b = bbb, *d = ddd;",
Style);

arichardson wrote:
> arichardson wrote:
> > MyDeveloperDay wrote:
> > > huh! the original tests doesn't look like LEFT aligned but now we also 
> > > lose the alignment, should we care I wonder?
> > I looked at the git log and it seems like it was changed from left to right 
> > in 
> > https://github.com/llvm/llvm-project/commit/bea1ab46d9ffdfc50108580c712596a54323a94c
> Losing the alignment is annoying but I don't quite understand why it changed. 
> Hopefully there aren't too many multi line multi variable declarations.
Again how is this even left alignment anyway!



Comment at: clang/unittests/Format/FormatTest.cpp:6636
+  verifyFormat("a* a = aaa, * b = 
bb,\n"
+   "   * b = bbb, * d = ;",
Style);

MyDeveloperDay wrote:
> arichardson wrote:
> > arichardson wrote:
> > > MyDeveloperDay wrote:
> > > > huh! the original tests doesn't look like LEFT aligned but now we also 
> > > > lose the alignment, should we care I wonder?
> > > I looked at the git log and it seems like it was changed from left to 
> > > right in 
> > > https://github.com/llvm/llvm-project/commit/bea1ab46d9ffdfc50108580c712596a54323a94c
> > Losing the alignment is annoying but I don't quite understand why it 
> > changed. Hopefully there aren't too many multi line multi variable 
> > declarations.
> Again how is this even left alignment anyway!
I'm looking back an @djasper change, and it seems we are basically reverting 
the behavior it so I feel a little uncomfortable,  I'm not sure how to proceed, 

having said that I think that change was also wrong because its supposed to be 
left aligned and basically its not!

At this point I'd personally prefer to wait for a higher power, maybe if 
@sammccall  or @klimek are listening they could comment.

I'm going to pull the review into my local branch and see what impact it has on 
the code I look after. I also often run my code through those areas of clang 
that are fully clang-formatted to see what the impact will be.






Comment at: clang/unittests/Format/FormatTest.cpp:6639
   verifyFormat("vector a, b;", Style);
+  verifyFormat("for (int* p, * q; p != q; p = p->next) {\n}", Style);
+  verifyFormat("char* x, * const* y = NULL;", Style);
+  verifyFormat("char** x, ** y = NULL;", Style);
+  verifyFormat("int x, * xp = &x, & xr = x, *& xpr = xp, * const& xcpr = xp;",
+   Style);
+  Style.PointerAlignment = FormatStyle::PAS_Right;
   verifyFormat("for (int *p, *q; p != q; p = p->next) {\n}", Style);
 }

arichardson wrote:
> MyDeveloperDay wrote:
> > I don't get why `*q` would be `* q`
> Yeah I'm not sure what the best way to format multi-variable declarations 
> with left alignment. We usually have a space before the name so I thought I'd 
> do the same here (even though it looks a bit odd).
Actually this case is odd, because its supposed to be left aligned and we are 
getting right alignment anyway... ignore my comment on the right


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88239

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


[clang] b78045c - Add a C++ test case for https://reviews.llvm.org/D86854

2020-10-20 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2020-10-20T07:34:38-07:00
New Revision: b78045c2ce2dba9b43c0e48340c2a69e444386ec

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

LOG: Add a C++ test case for https://reviews.llvm.org/D86854

The test case was part of https://reviews.llvm.org/D82999, which was
abandoned after https://reviews.llvm.org/D86854 fixed the bug.

Added: 


Modified: 
clang/test/CodeGenCXX/exceptions.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/exceptions.cpp 
b/clang/test/CodeGenCXX/exceptions.cpp
index c2df30844bce9..7cbd21da63c45 100644
--- a/clang/test/CodeGenCXX/exceptions.cpp
+++ b/clang/test/CodeGenCXX/exceptions.cpp
@@ -1,6 +1,8 @@
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++98 -o - 
-fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK 
-check-prefix=CHECK98 %s
 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -std=c++11 -o - 
-fcxx-exceptions -fexceptions | FileCheck -check-prefix=CHECK 
-check-prefix=CHECK11 %s
 
+// CHECK: %[[STRUCT_TEST13_A:.*]] = type { i32, i32 }
+
 typedef __typeof(sizeof(0)) size_t;
 
 // Declare the reserved global placement new.
@@ -594,4 +596,41 @@ namespace test12 {
   // CHECK11:   call void @_ZN6test121AdlEPvS1_(i8* [[PTR]], i8* [[PTR]])
 }
 
+namespace test13 {
+
+struct A {
+  A();
+  ~A();
+  int a, b;
+};
+
+// CHECK: define void @_ZN6test134testEi(
+// CHECK: %[[REF_TMP:.*]] = alloca %[[STRUCT_TEST13_A]], align 4
+// CHECK: %[[CLEANUP_COND:.*]] = alloca i1, align 1
+// CHECK: %[[REF_TMP1:.*]] = alloca %[[STRUCT_TEST13_A]], align 4
+// CHECK: %[[CLEANUP_COND2:.*]] = alloca i1, align 1
+
+// CHECK: call void @_ZN6test131AC1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP]])
+// CHECK: store i1 true, i1* %[[CLEANUP_COND]], align 1
+// CHECK: br
+
+// CHECK: invoke void @_ZN6test131AC1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP1]])
+
+// CHECK: store i1 true, i1* %[[CLEANUP_COND2]], align 1
+// CHECK: br
+
+// Check the flag before destructing the temporary.
+
+// CHECK: landingpad { i8*, i32 }
+// CHECK: %[[CLEANUP_IS_ACTIVE:.*]] = load i1, i1* %[[CLEANUP_COND]], align 1
+// CHECK: br i1 %[[CLEANUP_IS_ACTIVE]],
+
+// CHECK: void @_ZN6test131AD1Ev(%[[STRUCT_TEST13_A]]* %[[REF_TMP]])
+
+void test(int c) {
+  const A &s = c ? static_cast(A()) : static_cast(A());
+}
+
+}
+
 // CHECK98: attributes [[NI_NR_NUW]] = { noinline noreturn nounwind }



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


[PATCH] D89579: [clangd][ObjC] Support nullability annotations

2020-10-20 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 299356.
dgoldman added a comment.

Revert to previous AttributedTypeLoc behavior


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89579

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/clangd/unittests/SelectionTests.cpp

Index: clang-tools-extra/clangd/unittests/SelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SelectionTests.cpp
@@ -356,6 +356,22 @@
 )cpp",
   "DeclRefExpr"},
 
+  // Objective-C nullability attributes.
+  {
+  R"cpp(
+@interface I{}
+@property(nullable) [[^I]] *x;
+@end
+  )cpp",
+  "ObjCInterfaceTypeLoc"},
+  {
+  R"cpp(
+@interface I{}
+- (void)doSomething:(nonnull [[i^d]])argument;
+@end
+  )cpp",
+  "TypedefTypeLoc"},
+
   // Objective-C OpaqueValueExpr/PseudoObjectExpr has weird ASTs.
   // Need to traverse the contents of the OpaqueValueExpr to the POE,
   // and ensure we traverse only the syntactic form of the PseudoObjectExpr.
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1991,6 +1991,34 @@
 HI.NamespaceScope = "ObjC::"; // FIXME: fix it
 HI.Definition = "char data";
   }},
+  {
+  R"cpp(
+  @interface MYObject
+  @end
+  @interface Interface
+  @property(retain) [[MYOb^ject]] *x;
+  @end
+  )cpp",
+  [](HoverInfo &HI) {
+HI.Name = "MYObject";
+HI.Kind = index::SymbolKind::Class;
+HI.NamespaceScope = "";
+HI.Definition = "@interface MYObject\n@end";
+  }},
+  {
+  R"cpp(
+  @interface MYObject
+  @end
+  @interface Interface
+  - (void)doWith:([[MYOb^ject]] *)object;
+  @end
+  )cpp",
+  [](HoverInfo &HI) {
+HI.Name = "MYObject";
+HI.Kind = index::SymbolKind::Class;
+HI.NamespaceScope = "";
+HI.Definition = "@interface MYObject\n@end";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -820,6 +820,24 @@
   EXPECT_DECLS("ObjCPropertyRefExpr",
"@property(atomic, retain, readwrite) I *x");
 
+  Code = R"cpp(
+@interface MYObject
+@end
+@interface Interface
+@property(retain) [[MYObject]] *x;
+@end
+  )cpp";
+  EXPECT_DECLS("ObjCInterfaceTypeLoc", "@interface MYObject");
+
+  Code = R"cpp(
+@interface MYObject2
+@end
+@interface Interface
+@property(retain, nonnull) [[MYObject2]] *x;
+@end
+  )cpp";
+  EXPECT_DECLS("ObjCInterfaceTypeLoc", "@interface MYObject2");
+
   Code = R"cpp(
 @protocol Foo
 @end
Index: clang-tools-extra/clangd/Selection.cpp
===
--- clang-tools-extra/clangd/Selection.cpp
+++ clang-tools-extra/clangd/Selection.cpp
@@ -605,6 +605,10 @@
   bool canSafelySkipNode(const DynTypedNode &N) {
 SourceRange S = N.getSourceRange();
 if (auto *TL = N.get()) {
+  // FIXME: TypeLoc::getBeginLoc()/getEndLoc() are pretty fragile
+  // heuristics. We should consider only pruning critical TypeLoc nodes, to
+  // be more robust.
+
   // DeclTypeTypeLoc::getSourceRange() is incomplete, which would lead to
   // failing
   // to descend into the child expression.
@@ -616,6 +620,10 @@
   // rid of this patch.
   if (auto DT = TL->getAs())
 S.setEnd(DT.getUnderlyingExpr()->getEndLoc());
+  // AttributedTypeLoc may point to the attribute's range, NOT the modified
+  // type's range.
+  if (auto AT = TL->getAs())
+S = AT.getModifiedLoc().getSourceRange();
 }
 if (!SelChecker.mayHit(S)) {
   dlog("{1}skip: {0}", printNodeToString(N, PrintPolicy), indent());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

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

This is *awesome*, thank you so much for working on it! One question I have is: 
as it stands, this is not a particularly useful matcher because it can only be 
used to say "yup, there's an attribute" -- are you planning to extend this 
functionality so that you can do something like `attr(hasName("foo"))`, or 
specify the syntax the attribute uses, `isImplicit()`, etc?




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6737
+///   struct [[nodiscard]] Foo{};
+///   void bar(int * __attribute__((nonnull)) );
+/// \endcode

Can you also add an example using `__declspec()`?

Should I expect this to work on attributes added in other, perhaps surprising 
ways, like through `#pragma` or keywords?
```
// Some pragmas add attributes under the hood
#pragma omp declare simd 
int min(int a, int b) { return a < b ? a : b; }

// Other pragmas only exist to add attributes
#pragma clang attribute push (__attribute__((annotate("custom"))), apply_to = 
function)
void function(); // The function now has the annotate("custom") attribute
#pragma clang attribute pop

// Still other attributes come through keywords
alignas(16) int i;
```
If this is expected to match, we should document it more clearly.



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:238
+ScopedIncrement ScopedDepth(&CurrentDepth);
+return (A == nullptr || traverse(*A));
+  }

Should we be properly handling `IgnoreUnlessSpelledInSource` for implicit 
attributes? e.g., `[[gnu::interrupt]] void func(int *i);` which gets two 
attributes (the `interrupt` attribute and an implicit `used` attribute).



Comment at: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp:1879
+TEST_P(ASTMatchersTest, Attr) {
+  if (!GetParam().isCXX())
+return;

Why?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743

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


[PATCH] D89793: [libc++] Explicitly request new/delete in libc++ for Win to ARM Linux builds

2020-10-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added a reviewer: broadwaylamb.
Herald added subscribers: cfe-commits, jkorous, kristof.beyls, mgorny.
Herald added a project: clang.
ldionne requested review of this revision.

Since 9b40ee8eb0c1 
, 
new/delete must be requested explicitly during the
CMake configuration if one wants these definitions to appear in libc++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89793

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -96,6 +96,7 @@
 set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
 set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
+set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONSON CACHE BOOL "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -96,6 +96,7 @@
 set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
 set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
+set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONSON CACHE BOOL "")
 
 set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89793: [libc++] Explicitly request new/delete in libc++ for Win to ARM Linux builds

2020-10-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a subscriber: rsmith.
ldionne added a comment.

This should fix the Win to ARM Linux bot failures seen by @rsmith in 
https://reviews.llvm.org/D68269.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89793

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


[PATCH] D89794: [SyntaxTree] Implement "by-pointer output parameter to return value" refactoring.

2020-10-20 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Example of such refactoring:

  Customer* C;
  getCustumer(C);

  Customer C = getCustumer();


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89794

Files:
  clang/include/clang/Tooling/Syntax/Mutations.h
  clang/lib/Tooling/Syntax/Mutations.cpp

Index: clang/lib/Tooling/Syntax/Mutations.cpp
===
--- clang/lib/Tooling/Syntax/Mutations.cpp
+++ clang/lib/Tooling/Syntax/Mutations.cpp
@@ -85,6 +85,92 @@
 P->assertInvariants();
 N->assertInvariants();
   }
+
+  static void
+  replaceChildRange(syntax::Tree *Parent, syntax::Node *BeforeBegin,
+syntax::Node *End,
+ArrayRef> NewRange) {
+if (NewRange.empty())
+  return Parent->replaceChildRangeLowLevel(BeforeBegin, End, nullptr);
+
+for (const auto &NodeAndRole : NewRange)
+  NodeAndRole.first->setRole(NodeAndRole.second);
+
+for (auto It = NewRange.begin(), EndIt = std::prev(NewRange.end());
+ It != EndIt; ++It) {
+  auto *Node = It->first;
+  auto *Next = std::next(It)->first;
+  Node->NextSibling = Next;
+}
+
+Parent->replaceChildRangeLowLevel(BeforeBegin, End, NewRange.front().first);
+  }
+
+  /// Removes all the `Node`s between the iterators `BeforeBegin` and `End`. For
+  /// separated lists, if we remove the last element we may need to remove the
+  /// delimiter before it, in order to keep it a separated list.
+  static void removeElementAndDelimiterRange(
+  List::ElementAndDelimiterIterator BeforeBegin,
+  List::ElementAndDelimiterIterator End) {
+auto *EndNode = [&End]() -> Node * {
+  if (End.isEnd())
+return nullptr;
+  if ((*End).element)
+return (*End).element;
+  return (*End).delimiter;
+}();
+auto *Parent = End.getParent();
+Node *BeforeBeginNode;
+if (End.isEnd() &&
+Parent->getTerminationKind() == List::TerminationKind::Separated) {
+  // In this case we also remove the delimiter before the last element of
+  // the list, if it exists.
+  if (BeforeBegin.isBeforeBegin())
+BeforeBeginNode = nullptr;
+  else if ((*BeforeBegin).element)
+BeforeBeginNode = (*BeforeBegin).element;
+  else if ((*BeforeBegin).delimiter)
+BeforeBeginNode = findPrevious((*BeforeBegin).delimiter);
+  else
+// `BeforeBegin` = (null, null) and thus we are in the last element of
+// the list. Nothing will be removed.
+return;
+} else
+  BeforeBeginNode = [&BeforeBegin]() -> Node * {
+if (BeforeBegin.isBeforeBegin())
+  return nullptr;
+if ((*BeforeBegin).delimiter)
+  return (*BeforeBegin).delimiter;
+if ((*BeforeBegin).element)
+  return (*BeforeBegin).element;
+llvm_unreachable("(null, null) can only appear in the end of a "
+ "separated range, and this is not possible here");
+  }();
+
+Parent->replaceChildRangeLowLevel(BeforeBeginNode, EndNode, nullptr);
+  }
+
+  static Node *extractLastElementAndDelimiter(List *Parent) {
+auto Prev = [](List::ElementAndDelimiterIterator EDI,
+   unsigned i = 1) {
+  auto Previous = EDI.getParent()->getElementAndDelimiterBeforeBegin();
+  auto It = Previous;
+  for (unsigned j = 0; j < i; ++j)
+++It;
+  for (; It != EDI; ++It)
+++Previous;
+
+  return Previous;
+};
+if (Parent->getElementAndDelimiterBegin() ==
+Parent->getElementAndDelimiterEnd())
+  return nullptr;
+auto BeforeLast = Prev(Parent->getElementAndDelimiterEnd(), 2);
+auto Last = std::next(BeforeLast);
+removeElementAndDelimiterRange(BeforeLast,
+   Parent->getElementAndDelimiterEnd());
+return (*Last).element;
+  }
 };
 
 void syntax::removeStatement(syntax::Arena &A, syntax::Statement *S) {
@@ -102,3 +188,39 @@
 
   MutationsImpl::replace(S, createEmptyStatement(A));
 }
+
+void syntax::replaceOutputParameterWithReturnValue(syntax::Arena &A,
+   syntax::CallExpression *CE) {
+  assert(CE);
+  assert(CE->canModify());
+  assert(CE->getParent());
+
+  // Extract Output Parameter
+  auto *OutParam =
+  MutationsImpl::extractLastElementAndDelimiter(CE->getArguments());
+
+  // Create pointer dereference with outParam
+  auto *DerefOutParam =
+  createTree(A,
+ {{createLeaf(A, tok::star), NodeRole::OperatorToken},
+  {OutParam, NodeRole::Operand}},
+ NodeKind::PrefixUnaryOperatorExpression);
+
+  // f(); -> *outParam = f();
+  // TODO: How to improve this: Add parent to AddAfter. Or `NodeIterator`, with
+  // a pointer to Parent when it's a sentinel.
+  auto *Parent = CE->getParent();
+  auto *BeforeB

[PATCH] D89793: [libc++] Explicitly request new/delete in libc++ for Win to ARM Linux builds

2020-10-20 Thread Sergej Jaskiewicz via Phabricator via cfe-commits
broadwaylamb accepted this revision.
broadwaylamb added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89793

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


[PATCH] D89793: [libc++] Explicitly request new/delete in libc++ for Win to ARM Linux builds

2020-10-20 Thread Louis Dionne via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeaa928b71a09: [libc++] Explicitly request new/delete in 
libc++ for Win to ARM Linux builds (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89793

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -96,6 +96,7 @@
 set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
 set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
+set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONSON CACHE BOOL "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")


Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- clang/cmake/caches/CrossWinToARMLinux.cmake
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -96,6 +96,7 @@
 set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
 set(LIBCXX_CXX_ABI_LIBRARY_PATH "${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
+set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONSON CACHE BOOL "")
 
 set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] eaa928b - [libc++] Explicitly request new/delete in libc++ for Win to ARM Linux builds

2020-10-20 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2020-10-20T10:51:05-04:00
New Revision: eaa928b71a090905cb178c22054cdf6aa8eb80cb

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

LOG: [libc++] Explicitly request new/delete in libc++ for Win to ARM Linux 
builds

Since 9b40ee8eb0c1, new/delete must be requested explicitly during the
CMake configuration if one wants these definitions to appear in libc++.

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

Added: 


Modified: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
index 9aa0efa8049f..83d581567020 100644
--- a/clang/cmake/caches/CrossWinToARMLinux.cmake
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -96,6 +96,7 @@ set(LIBCXX_ENABLE_SHAREDOFF CACHE BOOL "")
 set(LIBCXX_CXX_ABI  "libcxxabi" CACHE STRING "")
 set(LIBCXX_CXX_ABI_INCLUDE_PATHS
"${LLVM_PROJECT_DIR}/libcxxabi/include" CACHE PATH "")
 set(LIBCXX_CXX_ABI_LIBRARY_PATH 
"${CMAKE_BINARY_DIR}/lib/${LIBCXX_TARGET_TRIPLE}/c++" CACHE PATH "")
+set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONSON CACHE BOOL "")
 
 set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
 set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")



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


[PATCH] D89719: [clang][Basic] Make SourceLocation usable as key in hash maps, NFCI

2020-10-20 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

The build failure is unrelated (see D89463 )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89719

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


[PATCH] D88239: [clang-format] Fix spaces around */& in multi-variable declarations

2020-10-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think this patch needs rebasing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88239

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


[clang] 234c47a - [clang][Basic] Make SourceLocation usable as key in hash maps, NFCI

2020-10-20 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-10-20T15:52:59+01:00
New Revision: 234c47ae2a8e1877de8c661d5bb862ba952eabf9

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

LOG: [clang][Basic] Make SourceLocation usable as key in hash maps, NFCI

This change creates a `DenseMapInfo` trait specialization for the
SourceLocation class. The empty key, the tombstone key, and the hash
function are identical to `DenseMapInfo`, because we already
have hash maps that use raw the representation of `SourceLocation` as
a key.

The update of existing `DenseMap`s containing raw representation of
`SourceLocation`s will be done in a follow-up patch. As an example
the patch makes use of the new trait in one instance:
clang-tidy/google/UpgradeGoogletestCaseCheck.{h,cpp}

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
clang/include/clang/Basic/SourceLocation.h
clang/lib/Basic/SourceLocation.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp 
b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
index b2261ca7f507..d943b7a1a270 100644
--- a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
@@ -298,8 +298,7 @@ void UpgradeGoogletestCaseCheck::check(const 
MatchFinder::MatchResult &Result) {
 }
 
 if (IsInInstantiation) {
-  if (MatchedTemplateLocations.count(
-  ReplacementRange.getBegin().getRawEncoding()) == 0) {
+  if (MatchedTemplateLocations.count(ReplacementRange.getBegin()) == 0) {
 // For each location matched in a template instantiation, we check if
 // the location can also be found in `MatchedTemplateLocations`. If it
 // is not found, that means the expression did not create a match
@@ -313,8 +312,7 @@ void UpgradeGoogletestCaseCheck::check(const 
MatchFinder::MatchResult &Result) {
 if (IsInTemplate) {
   // We gather source locations from template matches not in template
   // instantiations for future matches.
-  MatchedTemplateLocations.insert(
-  ReplacementRange.getBegin().getRawEncoding());
+  MatchedTemplateLocations.insert(ReplacementRange.getBegin());
 }
 
 if (!AddFix) {

diff  --git a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h 
b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
index 367498b16a97..a05bedf60b23 100644
--- a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
+++ b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
@@ -33,7 +33,7 @@ class UpgradeGoogletestCaseCheck : public ClangTidyCheck {
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
 private:
-  llvm::DenseSet MatchedTemplateLocations;
+  llvm::DenseSet MatchedTemplateLocations;
 };
 
 } // namespace google

diff  --git a/clang/include/clang/Basic/SourceLocation.h 
b/clang/include/clang/Basic/SourceLocation.h
index 3735b904ef47..88ecb7c586d9 100644
--- a/clang/include/clang/Basic/SourceLocation.h
+++ b/clang/include/clang/Basic/SourceLocation.h
@@ -175,6 +175,7 @@ class SourceLocation {
End.isFileID();
   }
 
+  unsigned getHashValue() const;
   void print(raw_ostream &OS, const SourceManager &SM) const;
   std::string printToString(const SourceManager &SM) const;
   void dump(const SourceManager &SM) const;
@@ -479,6 +480,27 @@ namespace llvm {
 }
   };
 
+  /// Define DenseMapInfo so that SourceLocation's can be used as keys in
+  /// DenseMap and DenseSet. This trait class is eqivalent to
+  /// DenseMapInfo which uses SourceLocation::ID is used as a key.
+  template <> struct DenseMapInfo {
+static clang::SourceLocation getEmptyKey() {
+  return clang::SourceLocation::getFromRawEncoding(~0U);
+}
+
+static clang::SourceLocation getTombstoneKey() {
+  return clang::SourceLocation::getFromRawEncoding(~0U - 1);
+}
+
+static unsigned getHashValue(clang::SourceLocation Loc) {
+  return Loc.getHashValue();
+}
+
+static bool isEqual(clang::SourceLocation LHS, clang::SourceLocation RHS) {
+  return LHS == RHS;
+}
+  };
+
   // Teach SmallPtrSet how to handle SourceLocation.
   template<>
   struct PointerLikeTypeTraits {

diff  --git a/clang/lib/Basic/SourceLocation.cpp 
b/clang/lib/Basic/SourceLocation.cpp
index 8cb0899ea39d..2ff17973323e 100644
--- a/clang/lib/Basic/SourceLocation.cpp
+++ b/clang/lib/Basic/SourceLocation.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "cl

[PATCH] D89719: [clang][Basic] Make SourceLocation usable as key in hash maps, NFCI

2020-10-20 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG234c47ae2a8e: [clang][Basic] Make SourceLocation usable as 
key in hash maps, NFCI (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89719

Files:
  clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
  clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
  clang/include/clang/Basic/SourceLocation.h
  clang/lib/Basic/SourceLocation.cpp


Index: clang/lib/Basic/SourceLocation.cpp
===
--- clang/lib/Basic/SourceLocation.cpp
+++ clang/lib/Basic/SourceLocation.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -40,6 +41,10 @@
 // SourceLocation
 
//===--===//
 
+unsigned SourceLocation::getHashValue() const {
+  return llvm::DenseMapInfo::getHashValue(ID);
+}
+
 void SourceLocation::print(raw_ostream &OS, const SourceManager &SM)const{
   if (!isValid()) {
 OS << "";
Index: clang/include/clang/Basic/SourceLocation.h
===
--- clang/include/clang/Basic/SourceLocation.h
+++ clang/include/clang/Basic/SourceLocation.h
@@ -175,6 +175,7 @@
End.isFileID();
   }
 
+  unsigned getHashValue() const;
   void print(raw_ostream &OS, const SourceManager &SM) const;
   std::string printToString(const SourceManager &SM) const;
   void dump(const SourceManager &SM) const;
@@ -479,6 +480,27 @@
 }
   };
 
+  /// Define DenseMapInfo so that SourceLocation's can be used as keys in
+  /// DenseMap and DenseSet. This trait class is eqivalent to
+  /// DenseMapInfo which uses SourceLocation::ID is used as a key.
+  template <> struct DenseMapInfo {
+static clang::SourceLocation getEmptyKey() {
+  return clang::SourceLocation::getFromRawEncoding(~0U);
+}
+
+static clang::SourceLocation getTombstoneKey() {
+  return clang::SourceLocation::getFromRawEncoding(~0U - 1);
+}
+
+static unsigned getHashValue(clang::SourceLocation Loc) {
+  return Loc.getHashValue();
+}
+
+static bool isEqual(clang::SourceLocation LHS, clang::SourceLocation RHS) {
+  return LHS == RHS;
+}
+  };
+
   // Teach SmallPtrSet how to handle SourceLocation.
   template<>
   struct PointerLikeTypeTraits {
Index: clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
===
--- clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
+++ clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.h
@@ -33,7 +33,7 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 
 private:
-  llvm::DenseSet MatchedTemplateLocations;
+  llvm::DenseSet MatchedTemplateLocations;
 };
 
 } // namespace google
Index: clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
===
--- clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
+++ clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
@@ -298,8 +298,7 @@
 }
 
 if (IsInInstantiation) {
-  if (MatchedTemplateLocations.count(
-  ReplacementRange.getBegin().getRawEncoding()) == 0) {
+  if (MatchedTemplateLocations.count(ReplacementRange.getBegin()) == 0) {
 // For each location matched in a template instantiation, we check if
 // the location can also be found in `MatchedTemplateLocations`. If it
 // is not found, that means the expression did not create a match
@@ -313,8 +312,7 @@
 if (IsInTemplate) {
   // We gather source locations from template matches not in template
   // instantiations for future matches.
-  MatchedTemplateLocations.insert(
-  ReplacementRange.getBegin().getRawEncoding());
+  MatchedTemplateLocations.insert(ReplacementRange.getBegin());
 }
 
 if (!AddFix) {


Index: clang/lib/Basic/SourceLocation.cpp
===
--- clang/lib/Basic/SourceLocation.cpp
+++ clang/lib/Basic/SourceLocation.cpp
@@ -14,6 +14,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -40,6 +41,10 @@
 // SourceLocation
 //===--===//
 
+unsigned SourceLocation::g

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

2020-10-20 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob added a comment.

In D86671#2330689 , @njames93 wrote:

> Is this diff been created incorrectly again?
>
> Taking a step back, Is Hungarian notation really a case style, Seems to me 
> its mainly about the prefix and a user may want `DWORD dwUPPER_CASE`, Right 
> now there is no way of adopting that.
> Maybe extend the options for hungarian type decls to
>
>   Case
>   Prefix
>   Suffix
>   HungarianPrefix
>
> `HungarianPrefix` would likely be a bool and if enabled, it would be 
> prepended to `Prefix`
> I could see a situation like this
>
>   [Options]
>   // VariableCase: UPPER_CASE
>   // VariablePrefix: PRE_
>   // VariableSuffix: _POST
>   // VariableHungarianPrefix: true
>   
>   DWORD MyVariable; -> DWORD dwPRE_MY_VARIABLE_POST;
>
> This would give users full control of exactly how they want their 
> declarations with no hidden surprises.
>
> Granted this approach would require a little rework but it would satisfy more 
> users.

Hi @njames93,

It's a smart idea, the rework for it is worth. There is a special case if 
lowercase name with Hungarian prefix, it possibly makes variable ambiguous, 
like the `Case1`. How about separating them and `aNy_CasE` with an underscore, 
like `Case2` ?

  // Case1
  bool bRIGHT_LEVEL; // UPPER_CASE
  bool bRightLevel;  // CamelCase
  bool bRight_Level; // Camel_Snake_Case
  bool baNy_CasE;// aNy_CasE
  bool bright_level; // lower_case
  bool brightLevel;  // camelBack
  bool bright_Level; // camel_Snake_Back
  .^^ <-- right? bright?
  
  // Case2
  bool bRIGHT_LEVEL; // UPPER_CASE
  bool bRightLevel;  // CamelCase
  bool bRight_Level; // Camel_Snake_Case
  bool b_aNy_CasE;   // aNy_CasE
  bool b_right_level;// lower_case
  bool b_rightLevel; // camelBack
  bool b_right_Level;// camel_Snake_Back
  .^^^ <-- add an underscore


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[clang] c76cdea - Explicitly initialize StreamingDiagnostic in derived class copy ctors

2020-10-20 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-10-20T17:18:46+02:00
New Revision: c76cdeac93380b434349738d96f83d3ffda9869c

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

LOG: Explicitly initialize StreamingDiagnostic in derived class copy ctors

To pacify a GCC warning:

[1/1] Building CXX object 
tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/Dominators.cpp.o
In file included from 
/work/llvm.monorepo/clang/include/clang/AST/NestedNameSpecifier.h:18:0,
 from /work/llvm.monorepo/clang/include/clang/AST/Type.h:21,
 from 
/work/llvm.monorepo/clang/include/clang/AST/DeclarationName.h:16,
 from /work/llvm.monorepo/clang/include/clang/AST/DeclBase.h:18,
 from 
/work/llvm.monorepo/clang/include/clang/Analysis/AnalysisDeclContext.h:20,
 from 
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:16,
 from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9:
/work/llvm.monorepo/clang/include/clang/Basic/Diagnostic.h:
In copy constructor ‘clang::DiagnosticBuilder::DiagnosticBuilder(const 
clang::DiagnosticBuilder&)’:
/work/llvm.monorepo/clang/include/clang/Basic/Diagnostic.h:1287:3:
warning: base class ‘class clang::StreamingDiagnostic’ should be explicitly 
initialized in the copy constructor [-Wextra]
   DiagnosticBuilder(const DiagnosticBuilder &D) {
   ^
In file included from /work/llvm.monorepo/clang/include/clang/AST/Type.h:29:0,
 from 
/work/llvm.monorepo/clang/include/clang/AST/DeclarationName.h:16,
 from /work/llvm.monorepo/clang/include/clang/AST/DeclBase.h:18,
 from 
/work/llvm.monorepo/clang/include/clang/Analysis/AnalysisDeclContext.h:20,
 from 
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:16,
 from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9:
/work/llvm.monorepo/clang/include/clang/Basic/PartialDiagnostic.h:
In copy constructor ‘clang::PartialDiagnostic::PartialDiagnostic(const 
clang::PartialDiagnostic&)’:
/work/llvm.monorepo/clang/include/clang/Basic/PartialDiagnostic.h:52:3:
warning: base class ‘class clang::StreamingDiagnostic’ should be explicitly 
initialized in the copy constructor [-Wextra]
   PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) {
   ^

Added: 


Modified: 
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Basic/PartialDiagnostic.h

Removed: 




diff  --git a/clang/include/clang/Basic/Diagnostic.h 
b/clang/include/clang/Basic/Diagnostic.h
index f17b98f74038..3499c551cfdf 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -1284,7 +1284,7 @@ class DiagnosticBuilder : public StreamingDiagnostic {
 public:
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
-  DiagnosticBuilder(const DiagnosticBuilder &D) {
+  DiagnosticBuilder(const DiagnosticBuilder &D) : StreamingDiagnostic() {
 DiagObj = D.DiagObj;
 DiagStorage = D.DiagStorage;
 IsActive = D.IsActive;

diff  --git a/clang/include/clang/Basic/PartialDiagnostic.h 
b/clang/include/clang/Basic/PartialDiagnostic.h
index 9e017902b120..370bc6861dd6 100644
--- a/clang/include/clang/Basic/PartialDiagnostic.h
+++ b/clang/include/clang/Basic/PartialDiagnostic.h
@@ -49,7 +49,8 @@ class PartialDiagnostic : public StreamingDiagnostic {
   PartialDiagnostic(unsigned DiagID, DiagStorageAllocator &Allocator_)
   : StreamingDiagnostic(Allocator_), DiagID(DiagID) {}
 
-  PartialDiagnostic(const PartialDiagnostic &Other) : DiagID(Other.DiagID) {
+  PartialDiagnostic(const PartialDiagnostic &Other)
+  : StreamingDiagnostic(), DiagID(Other.DiagID) {
 Allocator = Other.Allocator;
 if (Other.DiagStorage) {
   DiagStorage = getStorage();



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


[clang] 03a5f7c - Try to make GCC5 happy about the CfgTraits thing

2020-10-20 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-10-20T17:18:42+02:00
New Revision: 03a5f7ce12e2111c8b7bc5a95cff4c51b516250f

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

LOG: Try to make GCC5 happy about the CfgTraits thing

It was failing with:

In file included from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9:0:
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h: At 
global scope:
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:111:26:
error: specialization of ‘template struct 
llvm::CfgTraitsFor’ in different namespace [-fpermissive]
 template <> struct llvm::CfgTraitsFor {
  ^
In file included from 
/work/llvm.monorepo/clang/include/clang/Analysis/Analyses/Dominators.h:21:0,
 from /work/llvm.monorepo/clang/lib/Analysis/Dominators.cpp:9:
/work/llvm.monorepo/llvm/include/llvm/Support/CfgTraits.h:294:44:
error:   from definition of ‘template struct 
llvm::CfgTraitsFor’ [-fpermissive]
 template  struct CfgTraitsFor;
^

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/Dominators.h

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/Dominators.h 
b/clang/include/clang/Analysis/Analyses/Dominators.h
index e09ff04fa95a..367f135a98ec 100644
--- a/clang/include/clang/Analysis/Analyses/Dominators.h
+++ b/clang/include/clang/Analysis/Analyses/Dominators.h
@@ -108,7 +108,9 @@ class CfgTraits : public llvm::CfgTraits {
 
 } // namespace clang
 
-template <> struct llvm::CfgTraitsFor {
+namespace llvm {
+
+template <> struct CfgTraitsFor {
   using CfgTraits = clang::CfgTraits;
 };
 
@@ -116,7 +118,6 @@ template <> struct llvm::CfgTraitsFor {
 // which accepts an LLVM Module, so remove this (and the method's argument that
 // needs it) when that is fixed.
 
-namespace llvm {
 
 class Module;
 



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


[PATCH] D89761: Split out llvm/Support/FileSystem/UniqueID.h and clang/Basic/FileEntry.h, NFC

2020-10-20 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/include/clang/Basic/FileEntry.h:33
+
+using llvm::Optional;
+using llvm::StringRef;

dexonsmith wrote:
> JDevlieghere wrote:
> > Won't this now make `llvm::Optional` visible as `clang::Optional` 
> > everywhere this header is included? Isn't this considered bad practice in a 
> > header? 
> I thought I found both of these usable in clang headers elsewhere. I’ll 
> double check. 
Ah, I was sort of right. The correct way to do this is:
```
#include 
```
which forward-declares a bunch of stuff and pulls it into `clang::`.

I'll update.


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

https://reviews.llvm.org/D89761

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


[clang-tools-extra] 7819411 - [clang] Use SourceLocation as key in hash maps, NFCI

2020-10-20 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-10-20T16:24:09+01:00
New Revision: 781941183700b52d11b27227e3341385447610fa

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

LOG: [clang] Use SourceLocation as key in hash maps, NFCI

The patch adjusts the existing `llvm::DenseMap` and
`llvm::DenseSet` objects that store source locations, so
that they use `SourceLocation` directly instead of `unsigned`.

This patch relies on the `DenseMapInfo` trait added in D89719.

It also replaces the construction of `SourceLocation` objects from
the constants -1 and -2 with calls to the trait's methods `getEmptyKey`
and `getTombstoneKey` where appropriate.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
clang-tools-extra/clangd/FindTarget.cpp
clang/include/clang/Edit/EditedSource.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Tooling/Syntax/Tokens.h
clang/lib/ARCMigrate/TransGCAttrs.cpp
clang/lib/ARCMigrate/TransProperties.cpp
clang/lib/ARCMigrate/Transforms.h
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/Edit/EditedSource.cpp
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/Tokens.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
index 83fca3d5799b0..f232a0a09fbb7 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
@@ -85,15 +85,13 @@ struct DenseMapInfo<
   clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
 
   static inline ClassDefId getEmptyKey() {
-return ClassDefId(
-clang::SourceLocation::getFromRawEncoding(static_cast(-1)),
-"EMPTY");
+return ClassDefId(DenseMapInfo::getEmptyKey(),
+  "EMPTY");
   }
 
   static inline ClassDefId getTombstoneKey() {
-return ClassDefId(
-clang::SourceLocation::getFromRawEncoding(static_cast(-2)),
-"TOMBSTONE");
+return ClassDefId(DenseMapInfo::getTombstoneKey(),
+  "TOMBSTONE");
   }
 
   static unsigned getHashValue(ClassDefId Val) {
@@ -101,7 +99,7 @@ struct DenseMapInfo<
 assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
 
 std::hash SecondHash;
-return Val.first.getRawEncoding() + SecondHash(Val.second);
+return Val.first.getHashValue() + SecondHash(Val.second);
   }
 
   static bool isEqual(const ClassDefId &LHS, const ClassDefId &RHS) {

diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index bb8caf1d84e2e..6a25813eb7480 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -28,15 +28,13 @@ struct 
DenseMapInfo {
   using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId;
 
   static inline NamingCheckId getEmptyKey() {
-return NamingCheckId(
-clang::SourceLocation::getFromRawEncoding(static_cast(-1)),
-"EMPTY");
+return NamingCheckId(DenseMapInfo::getEmptyKey(),
+ "EMPTY");
   }
 
   static inline NamingCheckId getTombstoneKey() {
-return NamingCheckId(
-clang::SourceLocation::getFromRawEncoding(static_cast(-2)),
-"TOMBSTONE");
+return 
NamingCheckId(DenseMapInfo::getTombstoneKey(),
+ "TOMBSTONE");
   }
 
   static unsigned getHashValue(NamingCheckId Val) {
@@ -44,7 +42,8 @@ struct 
DenseMapInfo {
 assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
 
 std::hash SecondHash;
-return Val.first.getRawEncoding() + SecondHash(Val.second);
+return DenseMapInfo::getHashValue(Val.first) +
+   SecondHash(Val.second);
   }
 
   static bool isEqual(const NamingCheckId &LHS, const NamingCheckId &RHS) {
@@ -173,8 +172,7 @@ void RenamerClangTidyCheck::addUsage(
   // is already in there
   RenamerClangTidyCheck::NamingCheckFailure &Failure =
   NamingCheckFailures[Decl];
-
-  if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second)
+  if (!Failure.RawUsageLocs.insert(FixLocation).second)
 return;
 
   if (!Failure.ShouldFix())
@@ -550,9 +548,8 @@ void RenamerClangTidyCheck::onEndOfTranslationUnit() {
   //
   // Other multi-token identifiers, such as operators are not checked 
at
 

[PATCH] D69840: [clang] Use SourceLocation as key in hash maps, NFCI

2020-10-20 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG781941183700: [clang] Use SourceLocation as key in hash 
maps, NFCI (authored by miyuki).

Changed prior to commit:
  https://reviews.llvm.org/D69840?vs=299126&id=299366#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69840

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang/include/clang/Edit/EditedSource.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/ARCMigrate/TransGCAttrs.cpp
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/lib/ARCMigrate/Transforms.h
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Edit/EditedSource.cpp
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Tokens.cpp

Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -575,11 +575,11 @@
 // A's startpoint.
 if (!Range.getBegin().isFileID()) {
   Range.setBegin(SM.getExpansionLoc(Range.getBegin()));
-  assert(Collector->Expansions.count(Range.getBegin().getRawEncoding()) &&
+  assert(Collector->Expansions.count(Range.getBegin()) &&
  "Overlapping macros should have same expansion location");
 }
 
-Collector->Expansions[Range.getBegin().getRawEncoding()] = Range.getEnd();
+Collector->Expansions[Range.getBegin()] = Range.getEnd();
 LastExpansionEnd = Range.getEnd();
   }
   // FIXME: handle directives like #pragma, #include, etc.
@@ -711,8 +711,8 @@
   // If we know mapping bounds at [NextSpelled, KnownEnd] (macro expansion)
   // then we want to partition our (empty) mapping.
   //   [Start, NextSpelled) [NextSpelled, KnownEnd] (KnownEnd, Target)
-  SourceLocation KnownEnd = CollectedExpansions.lookup(
-  SpelledTokens[NextSpelled].location().getRawEncoding());
+  SourceLocation KnownEnd =
+  CollectedExpansions.lookup(SpelledTokens[NextSpelled].location());
   if (KnownEnd.isValid()) {
 FlushMapping(); // Emits [Start, NextSpelled)
 while (NextSpelled < SpelledTokens.size() &&
@@ -749,7 +749,7 @@
   // We need no mapping for file tokens copied to the expanded stream.
 } else {
   // We found a new macro expansion. We should have its spelling bounds.
-  auto End = CollectedExpansions.lookup(Expansion.getRawEncoding());
+  auto End = CollectedExpansions.lookup(Expansion);
   assert(End.isValid() && "Macro expansion wasn't captured?");
 
   // Mapping starts here...
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -367,7 +367,7 @@
 public:
   TreeBuilder(syntax::Arena &Arena) : Arena(Arena), Pending(Arena) {
 for (const auto &T : Arena.getTokenBuffer().expandedTokens())
-  LocationToToken.insert({T.location().getRawEncoding(), &T});
+  LocationToToken.insert({T.location(), &T});
   }
 
   llvm::BumpPtrAllocator &allocator() { return Arena.getAllocator(); }
@@ -689,8 +689,7 @@
 
   syntax::Arena &Arena;
   /// To quickly find tokens by their start location.
-  llvm::DenseMap
-  LocationToToken;
+  llvm::DenseMap LocationToToken;
   Forest Pending;
   llvm::DenseSet DeclsWithoutSemicolons;
   ASTToSyntaxMapping Mapping;
@@ -1708,7 +1707,7 @@
 const syntax::Token *syntax::TreeBuilder::findToken(SourceLocation L) const {
   if (L.isInvalid())
 return nullptr;
-  auto It = LocationToToken.find(L.getRawEncoding());
+  auto It = LocationToToken.find(L);
   assert(It != LocationToToken.end());
   return It->second;
 }
Index: clang/lib/Edit/EditedSource.cpp
===
--- clang/lib/Edit/EditedSource.cpp
+++ clang/lib/Edit/EditedSource.cpp
@@ -59,7 +59,7 @@
 SourceLocation ExpLoc;
 MacroArgUse ArgUse;
 std::tie(ExpLoc, ArgUse) = ExpArg;
-auto &ArgUses = ExpansionToArgMap[ExpLoc.getRawEncoding()];
+auto &ArgUses = ExpansionToArgMap[ExpLoc];
 if (llvm::find(ArgUses, ArgUse) == ArgUses.end())
   ArgUses.push_back(ArgUse);
   }
@@ -82,7 +82,7 @@
 SourceLocation ExpLoc;
 MacroArgUse ArgUse;
 deconstructMacroArgLoc(OrigLoc, ExpLoc, ArgUse);
-auto I = ExpansionToArgMap.find(ExpLoc.getRawEncoding());
+auto I = ExpansionToArgMap.find(ExpLoc);
 if (I != ExpansionToArgMap.end() &&
 find_if(I->second, [&](const MacroArgUse &U) {
   return ArgUse.Identifier == U.Identifier &&
Index: clang/lib/CodeGen/CGOpenMPRuntime.h
===

[PATCH] D89761: Split out llvm/Support/FileSystem/UniqueID.h and clang/Basic/FileEntry.h, NFC

2020-10-20 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith updated this revision to Diff 299365.
dexonsmith added a comment.

Use `#include ` to pull `StringRef` and `Optional` into 
`clang::`.


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

https://reviews.llvm.org/D89761

Files:
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Basic/FileManager.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/FileEntry.cpp
  llvm/include/llvm/Support/FileSystem.h
  llvm/include/llvm/Support/FileSystem/UniqueID.h

Index: llvm/include/llvm/Support/FileSystem/UniqueID.h
===
--- /dev/null
+++ llvm/include/llvm/Support/FileSystem/UniqueID.h
@@ -0,0 +1,47 @@
+//===- llvm/Support/FileSystem/UniqueID.h - UniqueID for files --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file is cut out of llvm/Support/FileSystem.h to allow UniqueID to be
+// reused without bloating the includes.
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H
+#define LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H
+
+#include 
+
+namespace llvm {
+namespace sys {
+namespace fs {
+
+class UniqueID {
+  uint64_t Device;
+  uint64_t File;
+
+public:
+  UniqueID() = default;
+  UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {}
+
+  bool operator==(const UniqueID &Other) const {
+return Device == Other.Device && File == Other.File;
+  }
+  bool operator!=(const UniqueID &Other) const { return !(*this == Other); }
+  bool operator<(const UniqueID &Other) const {
+return std::tie(Device, File) < std::tie(Other.Device, Other.File);
+  }
+
+  uint64_t getDevice() const { return Device; }
+  uint64_t getFile() const { return File; }
+};
+
+} // end namespace fs
+} // end namespace sys
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_FILESYSTEM_UNIQUEID_H
Index: llvm/include/llvm/Support/FileSystem.h
===
--- llvm/include/llvm/Support/FileSystem.h
+++ llvm/include/llvm/Support/FileSystem.h
@@ -34,6 +34,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/FileSystem/UniqueID.h"
 #include "llvm/Support/MD5.h"
 #include 
 #include 
@@ -131,26 +132,6 @@
   static_cast(~static_cast(x)));
 }
 
-class UniqueID {
-  uint64_t Device;
-  uint64_t File;
-
-public:
-  UniqueID() = default;
-  UniqueID(uint64_t Device, uint64_t File) : Device(Device), File(File) {}
-
-  bool operator==(const UniqueID &Other) const {
-return Device == Other.Device && File == Other.File;
-  }
-  bool operator!=(const UniqueID &Other) const { return !(*this == Other); }
-  bool operator<(const UniqueID &Other) const {
-return std::tie(Device, File) < std::tie(Other.Device, Other.File);
-  }
-
-  uint64_t getDevice() const { return Device; }
-  uint64_t getFile() const { return File; }
-};
-
 /// Represents the result of a call to directory_iterator::status(). This is a
 /// subset of the information returned by a regular sys::fs::status() call, and
 /// represents the information provided by Windows FileFirstFile/FindNextFile.
Index: clang/lib/Basic/FileEntry.cpp
===
--- /dev/null
+++ clang/lib/Basic/FileEntry.cpp
@@ -0,0 +1,23 @@
+//===- FileEntry.cpp - File references --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+/// \file
+/// Defines implementation for clang::FileEntry and clang::FileEntryRef.
+//
+//===--===//
+
+#include "clang/Basic/FileEntry.h"
+#include "llvm/Support/VirtualFileSystem.h"
+
+using namespace clang;
+
+FileEntry::FileEntry() : UniqueID(0, 0), IsNamedPipe(false), IsValid(false) {}
+
+FileEntry::~FileEntry() = default;
+
+void FileEntry::closeFile() const { File.reset(); }
Index: clang/lib/Basic/CMakeLists.txt
===
--- clang/lib/Basic/CMakeLists.txt
+++ clang/lib/Basic/CMakeLists.txt
@@ -46,6 +46,7 @@
   DiagnosticIDs.cpp
   DiagnosticOptions.cpp
   ExpressionTraits.cpp
+  FileEntry.cpp
   FileManager.cpp
   FileSystemStatCache.cpp
   IdentifierTable.cpp
Index: clang/include/clang/Basic/FileManager.h
===
--- clang/include/clang/Basic/FileManager.h
+++ clang/

[PATCH] D89743: Support Attr in DynTypedNode and ASTMatchers.

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

In D89743#2341779 , @aaron.ballman 
wrote:

> This is *awesome*, thank you so much for working on it!

Thanks for the comments - haven't addressed them yet, but wanted to clarify 
scope first.

> One question I have is: as it stands, this is not a particularly useful 
> matcher because it can only be used to say "yup, there's an attribute"

Yes definitely, I should have mentioned this...

My main goal here was to support it in DynTypedNode, as we have APIs 
(clangd::SelectionTree) that can only handle nodes that fit there.
But the common test pattern in ASTTypeTraitsTest used matchers, and I figured a 
basic matcher wasn't hard to add.

> are you planning to extend this functionality so that you can do something 
> like `attr(hasName("foo"))`, or specify the syntax the attribute uses, 
> `isImplicit()`, etc?

I hadn't planned to - it definitely makes sense though I don't have any 
immediate use cases. I can do any of:

- leave as-is, waiting for someone to add matchers to make it useful
- scope down the patch to exclude the matcher (and write the ASTTypeTraitsTest 
another way)
- add some simple matcher like hasName (I guess in a followup patch) to make it 
minimally useful, with space for more

What do you think?




Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:6737
+///   struct [[nodiscard]] Foo{};
+///   void bar(int * __attribute__((nonnull)) );
+/// \endcode

aaron.ballman wrote:
> Can you also add an example using `__declspec()`?
> 
> Should I expect this to work on attributes added in other, perhaps surprising 
> ways, like through `#pragma` or keywords?
> ```
> // Some pragmas add attributes under the hood
> #pragma omp declare simd 
> int min(int a, int b) { return a < b ? a : b; }
> 
> // Other pragmas only exist to add attributes
> #pragma clang attribute push (__attribute__((annotate("custom"))), apply_to = 
> function)
> void function(); // The function now has the annotate("custom") attribute
> #pragma clang attribute pop
> 
> // Still other attributes come through keywords
> alignas(16) int i;
> ```
> If this is expected to match, we should document it more clearly.
I think the answer to all of these is yes, I'll update the docs.



Comment at: clang/lib/ASTMatchers/ASTMatchFinder.cpp:238
+ScopedIncrement ScopedDepth(&CurrentDepth);
+return (A == nullptr || traverse(*A));
+  }

aaron.ballman wrote:
> Should we be properly handling `IgnoreUnlessSpelledInSource` for implicit 
> attributes? e.g., `[[gnu::interrupt]] void func(int *i);` which gets two 
> attributes (the `interrupt` attribute and an implicit `used` attribute).
I think we should, I just wasn't thinking clearly about where that should go :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89743

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


[PATCH] D89684: [AIX] Add mvecnvol and mnovecnvol options to enable the AIX extended and default vector ABIs.

2020-10-20 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

I have two concerns over the choice of the option form/name.

Firstly, there's an `-mabi=` option that is used to select for ABI extensions. 
The choice of using an `-mabi=` suboption for selecting between the extended 
vector ABI and the default vector ABI should be considered.
Secondly, the `vecnvol` name does not allude to its relation with the 
vector-extended ABI.

`-mabi=aixvecextabi` was suggested when I discussed this with someone who is 
familiar with GCC. The choice of `extabi` at the end is to match the spelling 
of the `__EXTABI__` macro.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89684

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


[PATCH] D89799: [clang][driver] Rename DriverOption as NoXarchOption (NFC)

2020-10-20 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added subscribers: cfe-commits, dexonsmith, dang.
Herald added a project: clang.
awarzynski requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

As discussed in [1], ClangFlags::DriverOption is currently only used to
mark options that should not be forwarded to other tools via `-Xarch`
options. This patch renames this flag accordingly and updates the
corresponding driver diagnostic.

A comment in ToolChain::TranslateXarchArgs is also updated to reflect
the change. The original comment referred to isDriverOption(), which is
no longer available.

[1] http://lists.llvm.org/pipermail/cfe-dev/2020-October/066953.html


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89799

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChain.cpp

Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1192,14 +1192,13 @@
   //
   // We also want to disallow any options which would alter the
   // driver behavior; that isn't going to work in our model. We
-  // use isDriverOption() as an approximation, although things
-  // like -O4 are going to slip through.
+  // use options::NoXarchOption to control this.
   if (!XarchArg || Index > Prev + 1) {
 getDriver().Diag(diag::err_drv_invalid_Xarch_argument_with_args)
 << A->getAsString(Args);
 return;
-  } else if (XarchArg->getOption().hasFlag(options::DriverOption)) {
-getDriver().Diag(diag::err_drv_invalid_Xarch_argument_isdriver)
+  } else if (XarchArg->getOption().hasFlag(options::NoXarchOption)) {
+getDriver().Diag(diag::err_drv_invalid_Xarch_argument_unsupported)
 << A->getAsString(Args);
 return;
   }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -16,9 +16,9 @@
 /
 // Flags
 
-// DriverOption - The option is a "driver" option, and should not be forwarded
-// to other tools.
-def DriverOption : OptionFlag;
+// The option is a "driver"-only option, and should not be forwarded to other
+// tools via `-Xarch` options.
+def NoXarchOption : OptionFlag;
 
 // LinkerInput - The option is a linker input.
 def LinkerInput : OptionFlag;
@@ -290,19 +290,19 @@
   Group, HelpText<"DEBUG/DEVELOPMENT OPTIONS">;
 
 class InternalDriverOpt : Group,
-  Flags<[DriverOption, HelpHidden]>;
+  Flags<[NoXarchOption, HelpHidden]>;
 def driver_mode : Joined<["--"], "driver-mode=">, Group,
-  Flags<[CoreOption, DriverOption, HelpHidden]>,
+  Flags<[CoreOption, NoXarchOption, HelpHidden]>,
   HelpText<"Set the driver mode to either 'gcc', 'g++', 'cpp', or 'cl'">;
 def rsp_quoting : Joined<["--"], "rsp-quoting=">, Group,
-  Flags<[CoreOption, DriverOption, HelpHidden]>,
+  Flags<[CoreOption, NoXarchOption, HelpHidden]>,
   HelpText<"Set the rsp quoting to either 'posix', or 'windows'">;
 def ccc_gcc_name : Separate<["-"], "ccc-gcc-name">, InternalDriverOpt,
   HelpText<"Name for native GCC compiler">,
   MetaVarName<"">;
 
 class InternalDebugOpt : Group,
-  Flags<[DriverOption, HelpHidden, CoreOption]>;
+  Flags<[NoXarchOption, HelpHidden, CoreOption]>;
 def ccc_install_dir : Separate<["-"], "ccc-install-dir">, InternalDebugOpt,
   HelpText<"Simulate installation in the given directory">;
 def ccc_print_phases : Flag<["-"], "ccc-print-phases">, InternalDebugOpt,
@@ -326,7 +326,7 @@
 def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, InternalDebugOpt,
   HelpText<"Emit a compilation database fragment to the specified directory">;
 
-def _migrate : Flag<["--"], "migrate">, Flags<[DriverOption]>,
+def _migrate : Flag<["--"], "migrate">, Flags<[NoXarchOption]>,
   HelpText<"Run the migrator">;
 def ccc_objcmt_migrate : Separate<["-"], "ccc-objcmt-migrate">,
   InternalDriverOpt,
@@ -373,10 +373,10 @@
 
 // Standard Options
 
-def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[DriverOption, CoreOption]>,
+def _HASH_HASH_HASH : Flag<["-"], "###">, Flags<[NoXarchOption, CoreOption]>,
 HelpText<"Print (but do not run) the commands to run for this compilation">;
 def _DASH_DASH : Option<["--"], "", KIND_REMAINING_ARGS>,
-Flags<[DriverOption, CoreOption]>;
+Flags<[NoXarchOption, CoreOption]>;
 def A : JoinedOrSeparate<["-"], "A">, Flags<[RenderJoined]>, Group;
 def B : JoinedOrSeparate<["-"], "B">, MetaVarName<"">,
 HelpText<"Add  to search path for binaries and object files used implicitly">;
@@ -387,14 +387,14 @@
 def D : JoinedOrSeparate<["-"], "D">, Group,
 Flags<[CC1Option]>, MetaVarName<"=">,
 HelpText<"Define  to  (or 1 if  omitted)">;
-def E : Flag<["-"], "E">, Flags<[DriverOption,CC1Option]>, Group,
+def E : Flag<["-"], "E">

[PATCH] D89801: [SystemZ][ZOS] Set short-enums as the default for z/OS

2020-10-20 Thread Jonathan Crowther via Phabricator via cfe-commits
Jonathan.Crowther created this revision.
Jonathan.Crowther added reviewers: rsmith, abhina.sreeskantharajan, dlj.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Jonathan.Crowther requested review of this revision.

This patch sets short-enums to be the default for z/OS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89801

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/zos-driver-defaults.c


Index: clang/test/Driver/zos-driver-defaults.c
===
--- /dev/null
+++ clang/test/Driver/zos-driver-defaults.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck 
%s
+// REQUIRES: clang-driver
+
+//CHECK: -fshort-enums
+//CHECK: -fno-signed-char
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5560,9 +5560,9 @@
(RTTIMode == ToolChain::RM_Disabled)))
 CmdArgs.push_back("-fno-rtti");
 
-  // -fshort-enums=0 is default for all architectures except Hexagon.
+  // -fshort-enums=0 is default for all architectures except Hexagon and z/OS.
   if (Args.hasFlag(options::OPT_fshort_enums, options::OPT_fno_short_enums,
-   TC.getArch() == llvm::Triple::hexagon))
+   TC.getArch() == llvm::Triple::hexagon || Triple.isOSzOS()))
 CmdArgs.push_back("-fshort-enums");
 
   RenderCharacterOptions(Args, AuxTriple ? *AuxTriple : RawTriple, CmdArgs);


Index: clang/test/Driver/zos-driver-defaults.c
===
--- /dev/null
+++ clang/test/Driver/zos-driver-defaults.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### --target=s390x-none-zos -fsyntax-only %s 2>&1 | FileCheck %s
+// REQUIRES: clang-driver
+
+//CHECK: -fshort-enums
+//CHECK: -fno-signed-char
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5560,9 +5560,9 @@
(RTTIMode == ToolChain::RM_Disabled)))
 CmdArgs.push_back("-fno-rtti");
 
-  // -fshort-enums=0 is default for all architectures except Hexagon.
+  // -fshort-enums=0 is default for all architectures except Hexagon and z/OS.
   if (Args.hasFlag(options::OPT_fshort_enums, options::OPT_fno_short_enums,
-   TC.getArch() == llvm::Triple::hexagon))
+   TC.getArch() == llvm::Triple::hexagon || Triple.isOSzOS()))
 CmdArgs.push_back("-fshort-enums");
 
   RenderCharacterOptions(Args, AuxTriple ? *AuxTriple : RawTriple, CmdArgs);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89802: [OpenMP] Add Passing in Original Declaration Names To Mapper API

2020-10-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Initial version. This fails a few tests and needs additional test cases for the 
additional functionality as well as support inside the runtime library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89802

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


[PATCH] D89380: [clang-tidy] Fix for cppcoreguidelines-prefer-member-initializer to handle classes declared in macros

2020-10-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 299378.
baloghadamsoftware added a comment.

Tests added, code reformatted.


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

https://reviews.llvm.org/D89380

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -1,5 +1,11 @@
 // RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t -- -- -fcxx-exceptions
 
+// CHECK-MESSAGES: warning: '' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// FIXME: The source location of the assignment in MACRO6 (see towards the end
+//of this test file) is the macro itself and the spelling location is
+//:6:1 for some strange reason. This results this warning
+//to be placed at the very beginning of the message list.
+
 extern void __assert_fail (__const char *__assertion, __const char *__file,
 unsigned int __line, __const char *__function)
  __attribute__ ((__noreturn__));
@@ -488,3 +494,39 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
 // CHECK-FIXES: {{^\ *$}}
 }
+
+#define MACRO1 struct InMacro1 { int i; InMacro1() { i = 0; } };
+// CHECK-MESSAGES: :[[@LINE-1]]:54: warning: 'i' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: #define MACRO1 struct InMacro1 { int i; InMacro1() : i(0) { } };
+MACRO1
+
+#define MACRO2 struct InMacro2 { int i, j; InMacro2() : i(0) { j = 1; } };
+// CHECK-MESSAGES: :[[@LINE-1]]:64: warning: 'j' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: #define MACRO2 struct InMacro2 { int i, j; InMacro2() : i(0), j(1) { } };
+MACRO2
+
+#define MACRO3 struct InMacro3 { int i, j; InMacro3() : j(1) { i = 0; } };
+// CHECK-MESSAGES: :[[@LINE-1]]:64: warning: 'i' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: #define MACRO3 struct InMacro3 { int i, j; InMacro3() : i(0), j(1) { } };
+MACRO3
+
+#define MACRO4(field) struct InMacro4 { int field; InMacro4() { field = 0; } };
+// C_HECK-MESSAGES: :[[@LINE-1]]:65: warning: 'field' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// C_HECK-FIXES: #define MACRO4(field) struct InMacro4 { int field; InMacro4() : field(0) { } };
+MACRO4(q)
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'q' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// FIXME: The source location of the assignment is the macro itself and the
+//spelling location is the argument in the macro call, instead of the
+//place where it is used inside the macro.
+
+#define MACRO5(X) X
+MACRO5(struct InMacro5 { int field; InMacro5() { field = 0; } };)
+// CHECK-MESSAGES: :[[@LINE-1]]:50: warning: 'field' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: MACRO5(struct InMacro5 { int field; InMacro5() : field(0) { } };)
+
+#define MACRO6(field) struct InMacro6 { int qqq ## field; InMacro6() { \
+  qqq ## field = 0; } };
+// C_HECK-MESSAGES: :[[@LINE-1]]:3: warning: 'qqq ## field' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// C_HECK-FIXES: #define MACRO6(field) struct InMacro6 { int qqq ### field; InMacro6() : qqq ## field(0) { \
+// C_HECK-FIXES: } };
+MACRO6(q)
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -123,9 +123,8 @@
 
   for (const Stmt *S : Body->body()) {
 if (S->getBeginLoc().isMacroID()) {
-  StringRef MacroName =
-Lexer::getImmediateMacroName(S->getBeginLoc(), *Result.SourceManager,
- getLangOpts());
+  StringRef MacroName = Lexer::getImmediateMacroName(
+  S->getBeginLoc(), *Result.SourceManager, getLangOpts());
   if (MacroName.contains_lower("assert"))
 return;
 }
@@ -144,99 +143,125 @@

[PATCH] D89380: [clang-tidy] Fix for cppcoreguidelines-prefer-member-initializer to handle classes declared in macros

2020-10-20 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

In D89380#2330076 , @alexfh wrote:

> Thanks for the fix! However, I'm not sure it's possible to correctly rewrite 
> code in all cases where macros are involved. See a couple of motivating 
> examples in the comment.






Comment at: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp:492
+
+#define MACRO1 struct InMacro1 { int i; InMacro1() { i = 0; } };
+// CHECK-MESSAGES: :[[@LINE-1]]:54: warning: 'i' should be initialized in a 
member initializer of the constructor 
[cppcoreguidelines-prefer-member-initializer]

alexfh wrote:
> Could you add tests where the field name comes from a macro argument and from 
> token pasting? Something along the lines of:
> 
> ```
> #define MACRO4(field) struct InMacro1 { int field; InMacro1() { field = 0; } }
> 
> MACRO4(q);
> 
> #define MACRO5(X) X
> 
> MACRO5(struct InMacro1 { int field; InMacro1() { field = 0; } });
> 
> #define MACRO6(field) struct InMacro1 { int qqq ## field; InMacro1() { qqq ## 
> field = 0; } }
> 
> MACRO6(q);
> ```
It seems that handling of macro parameters in the `SourceManager` is totally 
off. The location in these cases are the macro call itself, but the spelling 
location is not the real location inside the macro, but in `MACRO4` it is the 
location of the argument still in the macro call. The case with `MACRO6` is 
even worse, because its spelling location is erroneous. So I could only added 
some fixmes. However, it does not crash, at least. That is the main intention 
of this particular patch.


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

https://reviews.llvm.org/D89380

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


[PATCH] D88154: Initial support for vectorization using Libmvec (GLIBC vector math library).

2020-10-20 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.

LGTM.
I'm not sure why we need 3 different test files to test the very similar 
patterns -  just programmer preference?
Wait a day or so to commit in case anyone else has comments.


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

https://reviews.llvm.org/D88154

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


[PATCH] D69903: [Basic] Introduce PODSourceLocation, NFCI

2020-10-20 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

In D69903#2340020 , @dexonsmith wrote:

> An alternative would be to update the unions to an `AlignedCharArrayUnion` 
> and use `SourceLocation` directly. WDYT?

So, say, in `DeclarationNameLoc`, I would add `AlignedCharArrayUnion` as 
follows:

  union {
llvm::AlignedCharArrayUnion UninitStorage;
struct NT NamedType;
struct CXXOpName CXXOperatorName;
struct CXXLitOpName CXXLiteralOperatorName;
  };

And change the constructor of `DeclarationNameLoc` to default-construct 
`UninitStorage`, i.e.:

  DeclarationNameLoc() : UninitStorage() {
memset(UninitStorage.buffer, 0, sizeof(UninitStorage.buffer));
  }

After that, I can use `SourceLocation` in `DeclarationNameLoc` directly.

Do I understand your idea correctly?


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

https://reviews.llvm.org/D69903

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


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

2020-10-20 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D86671#2341838 , @dougpuob wrote:

> Hi @njames93,
>
> It's a smart idea, the rework for it is worth. There is a special case if 
> lowercase name with Hungarian prefix, it possibly makes variable ambiguous, 
> like the `Case1`. How about separating them and `aNy_CasE` with an 
> underscore, like `Case2` ?
>
>   // Case1
>   bool bRIGHT_LEVEL; // UPPER_CASE
>   bool bRightLevel;  // CamelCase
>   bool bRight_Level; // Camel_Snake_Case
>   bool baNy_CasE;// aNy_CasE
>   bool bright_level; // lower_case
>   bool brightLevel;  // camelBack
>   bool bright_Level; // camel_Snake_Back
>   .^^ <-- right? bright?
>   
>   // Case2
>   bool bRIGHT_LEVEL; // UPPER_CASE
>   bool bRightLevel;  // CamelCase
>   bool bRight_Level; // Camel_Snake_Case
>   bool b_aNy_CasE;   // aNy_CasE
>   bool b_right_level;// lower_case
>   bool b_rightLevel; // camelBack
>   bool b_right_Level;// camel_Snake_Back
>   .^^^ <-- add an underscore

That still has hidden surprises. Maybe instead of a bool, an enum is used for 
controlling hungarian prefix (Off|On|...).
Can't think of a good name for the third option but it would do the inserting 
of '_' (bright_level ->b_right_level) or capitalising the first word of the 
identifier (brightLevel -> bRightLevel).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D89372: [OpenCL] Remove unused extensions

2020-10-20 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D89372#2341638 , @mantognini wrote:

> I don't want to stop the wider discussion, that being said I think I've 
> addressed the comment regarding the content of this PR. Let me know if the 
> latest version is fine or needs further addressing. Thanks.

Thank you for providing comprehensive information regarding the extensions 
being removed. Since there are no kernel language changes in those I still see 
no reason to keep them in clang!

However, regarding the discussion about the general extension mechanisms for 
the language changes, @jvesely would you be willing to describe your vision 
regarding extensions pragma on this issue 
https://github.com/KhronosGroup/OpenCL-Docs/issues/82? Or otherwise, would you 
be ok if I summarise it there? I think it would be useful to aggregate all the 
information before discussing future directions with Khronos.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89372

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


  1   2   3   >