[PATCH] D115982: [clang][AVR] Implement '__flashN' for variables on different flash banks

2021-12-22 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 395807.

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

https://reviews.llvm.org/D115982

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/avr-flash.c
  clang/test/Sema/avr-flash.c

Index: clang/test/Sema/avr-flash.c
===
--- /dev/null
+++ clang/test/Sema/avr-flash.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple avr -target-cpu atmega2560 -fsyntax-only -verify
+
+int foo(int n) {
+  static __flash3 const int b[] = {4, 6}; // OK
+  static __flash5 const int c[] = {8, 1}; // expected-error {{unknown type name '__flash5'}}
+  // TODO: It would be better to report "'__flash5' is not supported on atmega2560".
+  return b[n] + c[n];
+}
Index: clang/test/CodeGen/avr-flash.c
===
--- clang/test/CodeGen/avr-flash.c
+++ clang/test/CodeGen/avr-flash.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+// RUN: %clang_cc1 -triple avr -target-cpu atxmega256c3 -emit-llvm-only -verify %s
 
 int foo(void) {
-  static __flash int b[] = {4, 6}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash'}}
-  return b[0];
+  static __flash  int b[] = {4, 6}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+  static __flash3 int c[] = {8, 1}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+  return b[0] + c[1];
 }
Index: clang/test/CodeGen/address-space-avr.c
===
--- clang/test/CodeGen/address-space-avr.c
+++ clang/test/CodeGen/address-space-avr.c
@@ -1,8 +1,11 @@
-// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple avr -target-cpu atmega2560 -emit-llvm < %s | FileCheck %s
 
 // CHECK: @var0 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @f3var0 {{.*}} addrspace(4) constant [3 x i16]
 // CHECK: @bar.var2 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @bar.f3var2 {{.*}} addrspace(4) constant [3 x i16]
 // CHECK: @var1 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @f3var1 {{.*}} addrspace(4) constant [3 x i16]
 
 // CHECK: define{{.*}} void @bar() addrspace(1)
 // CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to void (i16) addrspace(1)*)
@@ -11,11 +14,16 @@
 __flash const int var0[] = {999, 888, 777};
 __flash static const int var1[] = {111, 222, 333};
 
+__flash3 const int f3var0[] = {12, 34, 56};
+__flash3 static const int f3var1[] = {52, 64, 96};
+
 int i;
 
 void foo();
 
 void bar() {
   static __flash const int var2[] = {555, 666, 777};
+  static __flash3 const int f3var2[] = {, , 7787};
   foo(var1[i]);
+  foo(f3var1[i]);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8282,14 +8282,15 @@
 
   LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
   const VarDecl *D) const override {
-// Check if a global/static variable is defined within address space 1
+// Check if global/static variable is defined in address space
+// 1~6 (__flash, __flash1, __flash2, __flash3, __flash4, __flash5)
 // but not constant.
 LangAS AS = D->getType().getAddressSpace();
-if (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 1 &&
-!D->getType().isConstQualified())
+if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
+toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
   CGM.getDiags().Report(D->getLocation(),
 diag::err_verify_nonconst_addrspace)
-  << "__flash";
+  << "__flash*";
 return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
   }
 
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -24,281 +24,282 @@
 struct LLVM_LIBRARY_VISIBILITY MCUInfo {
   const char *Name;
   const char *DefineName;
+  const int MaxFlashBank; // -1 means the device does not support LPM/ELPM.
 };
 
 // This list should be kept up-to-date with AVRDevices.td in LLVM.
 static MCUInfo AVRMcus[] = {
-{"at90s1200", "__AVR_AT90S1200__"},
-{"attiny11", "__AVR_ATtiny11__"},
-{"attiny12", "__AVR_ATtiny12__"},
-{"attiny15", "__AVR_ATtiny15__"},
-{"attiny28", "__AVR_ATtiny28__"},
-{"at90s2313", "__AVR_AT90S2313__"},
-{"at90s2323", "__AVR_AT90S2323__"},
-{"at90s2333", "__AVR_AT90S2333__"},
-{"at90s2343", "__AVR_AT90S2343__"},
-{"attiny22", "__AVR_ATtiny22__"},
-{"attiny26", "__AVR_ATtiny26__"},
-{"at86rf401", "__AVR_AT86RF401__"},
-{"at90s441

[PATCH] D115923: [RISCV][Don't Commit] Refactor the RISCV ISA extension info and target features to support multiple extension version

2021-12-22 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu abandoned this revision.
zixuan-wu added a comment.

Only need review D115921 . Just abandon it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115923

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


[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-22 Thread Balázs Benics via Phabricator via cfe-commits
steakhal reopened this revision.
steakhal added a comment.
This revision is now accepted and ready to land.

In D102669#3205889 , @OikawaKirie 
wrote:

> In D102669#3199270 , @steakhal 
> wrote:
>
>> We shouldn't skip mac targets. I CC ASTImporter folks, they probably have an 
>> M1 .
>
> I am not intended to ignore this problem triggered on M1 
> . However, I think it is not this patch that 
> leads to this problem, it just triggers it.
> I mean we can just disable the test case temporarily on M1 
> , and fix this problem as well as enable this 
> patch and the one of on-demand-parsing in another patch.
> I think they trigger the same problem for the same reason on M1 
> .
>
> Besides, it seems to be the problem of `ASTUnit::LoadFromCommandLine`, rather 
> than the ASTImporter.

Prior to this patch, it worked on M1 ; after 
landing it broke something, so we clearly shouldn't land this.
We should add a test-case demonstrating the problem with M1 
 with a given configuration.
Then we need to track down and fix the underlying issue causing it. That should 
be done probably in a separate patch and add it as a parent patch to this one.

If all of these are done, we can probably land both of them.




Comment at: clang/test/Analysis/ctu-lookup-name-with-space.cpp:13
+// RUN:   -verify %s
+
+void importee();

OikawaKirie wrote:
> arichardson wrote:
> > OikawaKirie wrote:
> > > Adding this line here.
> > Disabling the test on non- Linux is not a good idea IMO since it means we 
> > lose coverage on other platforms. My guess is that you just need to specify 
> > an explicit triple in the clang invocations.
> AFAIK, we cannot do that. If this test case is executed on different 
> platforms, we cannot determine the triple ahead of time and specify it in the 
> invocation list.
If we were to pin the triple, then each platform would emit the correct AST 
dumps according to that platform - ~~ cross-compilation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102669

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


[PATCH] D116110: Introduce the AttributeMask class

2021-12-22 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

Looking at some of the changes here, I landed a couple of cleanup commits:

- 
https://github.com/llvm/llvm-project/commit/3b0f5a4856fce76a6535feddd1692747b81b60cd
 (this should fix the build failure)
- 
https://github.com/llvm/llvm-project/commit/e8e8bfeeb7233bde17d0a811b87d392271b33f42
 (unnecessary AttrBuilder use for one attribute)
- 
https://github.com/llvm/llvm-project/commit/9f24f010abe6b9db3d3fd913805c9e0779d00334
 (make RS4GC attribute removal more idiomatic)

I think the latter change should allow you to drop the 
`AttrMask::hasAttributes()` method from the API.


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

https://reviews.llvm.org/D116110

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


[PATCH] D115982: [clang][AVR] Implement '__flashN' for variables on different flash banks

2021-12-22 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 395809.

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

https://reviews.llvm.org/D115982

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/avr-flash.c
  clang/test/Sema/avr-flash.c

Index: clang/test/Sema/avr-flash.c
===
--- /dev/null
+++ clang/test/Sema/avr-flash.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple avr -target-cpu atmega2560 -fsyntax-only -verify
+
+int foo(int n) {
+  static __flash3 const int b[] = {4, 6}; // OK
+  static __flash5 const int c[] = {8, 1}; // expected-error {{unknown type name '__flash5'}}
+  // TODO: It would be better to report "'__flash5' is not supported on atmega2560".
+  return b[n] + c[n];
+}
Index: clang/test/CodeGen/avr-flash.c
===
--- clang/test/CodeGen/avr-flash.c
+++ clang/test/CodeGen/avr-flash.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+// RUN: %clang_cc1 -triple avr -target-cpu atxmega256c3 -emit-llvm-only -verify %s
 
 int foo(void) {
-  static __flash int b[] = {4, 6}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash'}}
-  return b[0];
+  static __flash  int b[] = {4, 6}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+  static __flash3 int c[] = {8, 1}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+  return b[0] + c[1];
 }
Index: clang/test/CodeGen/address-space-avr.c
===
--- clang/test/CodeGen/address-space-avr.c
+++ clang/test/CodeGen/address-space-avr.c
@@ -1,8 +1,11 @@
-// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple avr -target-cpu atmega2560 -emit-llvm < %s | FileCheck %s
 
 // CHECK: @var0 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @f3var0 {{.*}} addrspace(4) constant [3 x i16]
 // CHECK: @bar.var2 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @bar.f3var2 {{.*}} addrspace(4) constant [3 x i16]
 // CHECK: @var1 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @f3var1 {{.*}} addrspace(4) constant [3 x i16]
 
 // CHECK: define{{.*}} void @bar() addrspace(1)
 // CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to void (i16) addrspace(1)*)
@@ -11,11 +14,16 @@
 __flash const int var0[] = {999, 888, 777};
 __flash static const int var1[] = {111, 222, 333};
 
+__flash3 const int f3var0[] = {12, 34, 56};
+__flash3 static const int f3var1[] = {52, 64, 96};
+
 int i;
 
 void foo();
 
 void bar() {
   static __flash const int var2[] = {555, 666, 777};
+  static __flash3 const int f3var2[] = {, , 7787};
   foo(var1[i]);
+  foo(f3var1[i]);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8282,14 +8282,15 @@
 
   LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
   const VarDecl *D) const override {
-// Check if a global/static variable is defined within address space 1
+// Check if global/static variable is defined in address space
+// 1~6 (__flash, __flash1, __flash2, __flash3, __flash4, __flash5)
 // but not constant.
 LangAS AS = D->getType().getAddressSpace();
-if (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 1 &&
-!D->getType().isConstQualified())
+if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
+toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
   CGM.getDiags().Report(D->getLocation(),
 diag::err_verify_nonconst_addrspace)
-  << "__flash";
+  << "__flash*";
 return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
   }
 
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -24,281 +24,282 @@
 struct LLVM_LIBRARY_VISIBILITY MCUInfo {
   const char *Name;
   const char *DefineName;
+  const int MaxFlashBank; // -1 means the device does not support LPM/ELPM.
 };
 
 // This list should be kept up-to-date with AVRDevices.td in LLVM.
 static MCUInfo AVRMcus[] = {
-{"at90s1200", "__AVR_AT90S1200__"},
-{"attiny11", "__AVR_ATtiny11__"},
-{"attiny12", "__AVR_ATtiny12__"},
-{"attiny15", "__AVR_ATtiny15__"},
-{"attiny28", "__AVR_ATtiny28__"},
-{"at90s2313", "__AVR_AT90S2313__"},
-{"at90s2323", "__AVR_AT90S2323__"},
-{"at90s2333", "__AVR_AT90S2333__"},
-{"at90s2343", "__AVR_AT90S2343__"},
-{"attiny22", "__AVR_ATtiny22__"},
-{"attiny26", "__AVR_ATtiny26__"},
-{"at86rf401", "__AVR_AT86RF401__"},
-{"at90s441

[clang] b55ea2f - [Clang] Add __builtin_reduce_xor

2021-12-22 Thread Florian Hahn via cfe-commits

Author: Jun Zhan
Date: 2021-12-22T10:00:27Z
New Revision: b55ea2fbc0a0564eece1e58fc5624057d5d05639

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

LOG: [Clang] Add __builtin_reduce_xor

This patch implements __builtin_reduce_xor as specified in D111529.

Reviewed By: fhahn, aaron.ballman

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

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-reduction-math.c
clang/test/Sema/builtins-reduction-math.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index f57635e010dce..45d4451637495 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -649,6 +649,7 @@ BUILTIN(__builtin_elementwise_min, "v.", "nct")
 BUILTIN(__builtin_elementwise_ceil, "v.", "nct")
 BUILTIN(__builtin_reduce_max, "v.", "nct")
 BUILTIN(__builtin_reduce_min, "v.", "nct")
+BUILTIN(__builtin_reduce_xor, "v.", "nct")
 
 BUILTIN(__builtin_matrix_transpose, "v.", "nFt")
 BUILTIN(__builtin_matrix_column_major_load, "v.", "nFt")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 875e639cb2beb..f50c5a0c711ad 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11378,7 +11378,8 @@ def err_builtin_invalid_arg_type: Error <
   "%select{vector, integer or floating point type|matrix|"
   "pointer to a valid matrix element type|"
   "signed integer or floating point type|vector type|"
-  "floating point type}1 (was %2)">;
+  "floating point type|"
+  "vector of integers}1 (was %2)">;
 
 def err_builtin_matrix_disabled: Error<
   "matrix types extension is disabled. Pass -fenable-matrix to enable it">;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 73c5ad1dd7acf..55171767da109 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -12784,7 +12784,7 @@ class Sema final {
 
   bool SemaBuiltinElementwiseMath(CallExpr *TheCall);
   bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall);
-  bool SemaBuiltinReduceMath(CallExpr *TheCall);
+  bool PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall);
 
   // Matrix builtin handling.
   ExprResult SemaBuiltinMatrixTranspose(CallExpr *TheCall,

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2cbc8f77bd391..7224b10f2e903 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -3211,6 +3211,13 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
 return RValue::get(Result);
   }
 
+  case Builtin::BI__builtin_reduce_xor: {
+Value *Op0 = EmitScalarExpr(E->getArg(0));
+Value *Result = Builder.CreateUnaryIntrinsic(
+llvm::Intrinsic::vector_reduce_xor, Op0, nullptr, "rdx.xor");
+return RValue::get(Result);
+  }
+
   case Builtin::BI__builtin_matrix_transpose: {
 const auto *MatrixTy = 
E->getArg(0)->getType()->getAs();
 Value *MatValue = EmitScalarExpr(E->getArg(0));

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index fb99591656d34..4e83fa1fffca4 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2216,10 +2216,38 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   return ExprError();
 break;
   case Builtin::BI__builtin_reduce_max:
-  case Builtin::BI__builtin_reduce_min:
-if (SemaBuiltinReduceMath(TheCall))
+  case Builtin::BI__builtin_reduce_min: {
+if (PrepareBuiltinReduceMathOneArgCall(TheCall))
   return ExprError();
+
+const Expr *Arg = TheCall->getArg(0);
+const auto *TyA = Arg->getType()->getAs();
+if (!TyA) {
+  Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+  << 1 << /* vector ty*/ 4 << Arg->getType();
+  return ExprError();
+}
+
+TheCall->setType(TyA->getElementType());
 break;
+  }
+
+  // __builtin_reduce_xor supports vector of integers only.
+  case Builtin::BI__builtin_reduce_xor: {
+if (PrepareBuiltinReduceMathOneArgCall(TheCall))
+  return ExprError();
+
+const Expr *Arg = TheCall->getArg(0);
+const auto *TyA = Arg->getType()->getAs();
+if (!TyA || !TyA->getElementType()->isIntegerType()) {
+  Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+  << 1  << /* vector of integers */ 6 << Arg->getType();
+  return ExprError();
+}
+TheCall->setType(TyA-

[PATCH] D115231: [Clang] Add __builtin_reduce_xor

2021-12-22 Thread Florian Hahn 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 rGb55ea2fbc0a0: [Clang] Add __builtin_reduce_xor (authored by 
junaire, committed by fhahn).

Changed prior to commit:
  https://reviews.llvm.org/D115231?vs=395791&id=395814#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115231

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-reduction-math.c
  clang/test/Sema/builtins-reduction-math.c

Index: clang/test/Sema/builtins-reduction-math.c
===
--- clang/test/Sema/builtins-reduction-math.c
+++ clang/test/Sema/builtins-reduction-math.c
@@ -35,3 +35,20 @@
   i = __builtin_reduce_min(i);
   // expected-error@-1 {{1st argument must be a vector type (was 'int')}}
 }
+
+void test_builtin_reduce_xor(int i, float4 v, int3 iv) {
+  struct Foo s = __builtin_reduce_xor(iv);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'int'}}
+
+  i = __builtin_reduce_xor();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_reduce_xor(iv, iv);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  i = __builtin_reduce_xor(i);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 'int')}}
+
+  i = __builtin_reduce_xor(v);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 'float4' (vector of 4 'float' values))}}
+}
Index: clang/test/CodeGen/builtins-reduction-math.c
===
--- clang/test/CodeGen/builtins-reduction-math.c
+++ clang/test/CodeGen/builtins-reduction-math.c
@@ -57,3 +57,14 @@
   const si8 cvi1 = vi1;
   unsigned long long r5 = __builtin_reduce_min(cvi1);
 }
+
+void test_builtin_reduce_xor(si8 vi1, u4 vu1) {
+
+  // CHECK:  [[VI1:%.+]] = load <8 x i16>, <8 x i16>* %vi1.addr, align 16
+  // CHECK-NEXT: call i16 @llvm.vector.reduce.xor.v8i16(<8 x i16> [[VI1]])
+  short r2 = __builtin_reduce_xor(vi1);
+
+  // CHECK:  [[VU1:%.+]] = load <4 x i32>, <4 x i32>* %vu1.addr, align 16
+  // CHECK-NEXT: call i32 @llvm.vector.reduce.xor.v4i32(<4 x i32> [[VU1]])
+  unsigned r3 = __builtin_reduce_xor(vu1);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2216,10 +2216,38 @@
   return ExprError();
 break;
   case Builtin::BI__builtin_reduce_max:
-  case Builtin::BI__builtin_reduce_min:
-if (SemaBuiltinReduceMath(TheCall))
+  case Builtin::BI__builtin_reduce_min: {
+if (PrepareBuiltinReduceMathOneArgCall(TheCall))
   return ExprError();
+
+const Expr *Arg = TheCall->getArg(0);
+const auto *TyA = Arg->getType()->getAs();
+if (!TyA) {
+  Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+  << 1 << /* vector ty*/ 4 << Arg->getType();
+  return ExprError();
+}
+
+TheCall->setType(TyA->getElementType());
 break;
+  }
+
+  // __builtin_reduce_xor supports vector of integers only.
+  case Builtin::BI__builtin_reduce_xor: {
+if (PrepareBuiltinReduceMathOneArgCall(TheCall))
+  return ExprError();
+
+const Expr *Arg = TheCall->getArg(0);
+const auto *TyA = Arg->getType()->getAs();
+if (!TyA || !TyA->getElementType()->isIntegerType()) {
+  Diag(Arg->getBeginLoc(), diag::err_builtin_invalid_arg_type)
+  << 1  << /* vector of integers */ 6 << Arg->getType();
+  return ExprError();
+}
+TheCall->setType(TyA->getElementType());
+break;
+  }
+
   case Builtin::BI__builtin_matrix_transpose:
 return SemaBuiltinMatrixTranspose(TheCall, TheCallResult);
 
@@ -16882,7 +16910,7 @@
   return false;
 }
 
-bool Sema::SemaBuiltinReduceMath(CallExpr *TheCall) {
+bool Sema::PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall) {
   if (checkArgCount(*this, TheCall, 1))
 return true;
 
@@ -16891,14 +16919,6 @@
 return true;
 
   TheCall->setArg(0, A.get());
-  const VectorType *TyA = A.get()->getType()->getAs();
-  if (!TyA) {
-SourceLocation ArgLoc = TheCall->getArg(0)->getBeginLoc();
-return Diag(ArgLoc, diag::err_builtin_invalid_arg_type)
-   << 1 << /* vector ty*/ 4 << A.get()->getType();
-  }
-
-  TheCall->setType(TyA->getElementType());
   return false;
 }
 
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -3211,6 +3211,13 @@
 return RValue::get(Result);
   }
 
+  case Builtin::BI__builtin_reduc

[PATCH] D116147: [clangd] Respect .clang-tidy ExtraArgs (-Wfoo only) when producing diagnostics

2021-12-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This mechanism is used almost exclusively to enable extra warnings in clang-tidy
using ExtraArgs=-Wfoo, Checks="clang-diagnostic-foo".
Its presence is a strong signal that these flags are useful.

We choose not to actually emit them as clang-tidy diagnostics, but under their
"main" name - this ensures we show the same diagnostic in a consistent way.

We don't add the ExtraArgs to the compile command in general, but rather just
handle the -W flags, which is the common case and avoids unexpected
side-effects.
And we only do this for the main file parse, when producing diagnostics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116147

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -517,6 +517,58 @@
   DiagSeverity(DiagnosticsEngine::Error);
 }
 
+TidyProvider addClangArgs(std::vector ExtraArgs) {
+  return [ExtraArgs = std::move(ExtraArgs)](tidy::ClangTidyOptions &Opts,
+llvm::StringRef) {
+if (!Opts.ExtraArgs)
+  Opts.ExtraArgs.emplace();
+for (llvm::StringRef Arg : ExtraArgs)
+  Opts.ExtraArgs->emplace_back(Arg);
+  };
+}
+
+TEST(DiagnosticTest, ClangTidyEnablesClangWarning) {
+  Annotations Main(R"cpp( // error-ok
+static void [[foo]]() {}
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  // This is always emitted as a clang warning, not a clang-tidy diagnostic.
+  auto UnusedFooWarning =
+  AllOf(Diag(Main.range(), "unused function 'foo'"),
+DiagName("-Wunused-function"), DiagSource(Diag::Clang),
+DiagSeverity(DiagnosticsEngine::Warning));
+
+  // Check the -Wunused warning isn't initially on.
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+
+  // We enable warnings based on clang-tidy extra args.
+  TU.ClangTidyProvider = addClangArgs({"-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), ElementsAre(UnusedFooWarning));
+
+  // But we don't respect other args.
+  TU.ClangTidyProvider = addClangArgs({"-Wunused", "-Dfoo=bar"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), ElementsAre(UnusedFooWarning))
+  << "Not unused function 'bar'!";
+
+  // -Werror doesn't apply to warnings enabled by clang-tidy extra args.
+  TU.ExtraArgs = {"-Werror"};
+  TU.ClangTidyProvider = addClangArgs({"-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ElementsAre(DiagSeverity(DiagnosticsEngine::Warning)));
+
+  // But clang-tidy extra args won't *downgrade* errors to warnings either.
+  TU.ExtraArgs = {"-Wunused", "-Werror"};
+  TU.ClangTidyProvider = addClangArgs({"-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ElementsAre(DiagSeverity(DiagnosticsEngine::Error)));
+
+  // FIXME: we're erroneously downgrading the whole group, this should be Error.
+  TU.ExtraArgs = {"-Wunused-function", "-Werror"};
+  TU.ClangTidyProvider = addClangArgs({"-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ElementsAre(DiagSeverity(DiagnosticsEngine::Warning)));
+}
+
 TEST(DiagnosticTest, LongFixMessages) {
   // We limit the size of printed code.
   Annotations Source(R"cpp(
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -311,7 +311,63 @@
 : "unknown error");
 return None;
   }
-  if (!PreserveDiags) {
+  tidy::ClangTidyOptions ClangTidyOpts;
+  if (PreserveDiags) {
+trace::Span Tracer("ClangTidyOpts");
+ClangTidyOpts = getTidyOptionsForFile(Inputs.ClangTidyProvider, Filename);
+dlog("ClangTidy configuration for file {0}: {1}", Filename,
+ tidy::configurationAsText(ClangTidyOpts));
+
+// If clang-tidy is configured to emit clang warnings, we should too.
+//
+// Such clang-tidy configuration consists of two parts:
+//   - ExtraArgs: ["-Wfoo"] causes clang to produce the warnings
+//   - Checks: "clang-diagnostic-foo" prevents clang-tidy filtering them out
+//
+// We treat these as clang warnings, so the Checks part is not relevant.
+// We must enable the warnings specified in ExtraArgs.
+//
+// We *don't* want to change the compile command directly. this can have
+// too many unexpected effects: breaking the command, interactions with
+// -- and -Werror, etc. Besides, we've already parsed the command.
+ 

[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-22 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

In D102669#3206089 , @steakhal wrote:

> Prior to this patch, it worked on M1 ; after 
> landing it broke something, so we clearly shouldn't land this.

I do not think it is this patch that breaks the functionality on M1 
, as it depends on the *on-demand-parsing* feature 
that is not tested on M1  currently.

> We should add a test-case demonstrating the problem with M1 
>  with a given configuration.

If I got it correct (it is on-demand-parsing that triggers the problem), this 
problem can be triggered by enabling the test case of D75665 
 on M1 .

> Then we need to track down and fix the underlying issue causing it. That 
> should be done probably in a separate patch and add it as a parent patch to 
> this one.
>
> If all of these are done, we can probably land both of them.

Maybe currently a simpler way is trying to use AST dump to load the external TU 
to be imported, rather than on-demand-parsing, which can make us fix this 
failure with the test case still enabled on M1 .

I will have a series of tests on my concerns later, and I will reply with my 
results if I can find something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102669

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


[PATCH] D116147: [clangd] Respect .clang-tidy ExtraArgs (-Wfoo only) when producing diagnostics

2021-12-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall planned changes to this revision.
sammccall added a comment.

Actually we should probably handle `-Wno-` too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116147

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


[PATCH] D116153: [ARM][AArch64] Add missing v8.x checks

2021-12-22 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson created this revision.
Herald added a subscriber: kristof.beyls.
tmatheson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116153

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Preprocessor/aarch64-target-features.c


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -294,7 +294,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" 
"+sha2" "-target-feature" "+aes"
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64_32 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64_32 %s
 // CHECK-ARCH-ARM64_32: "-target-cpu" "apple-s4" "-target-feature" "+v8.3a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" 
"-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" 
"-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" 
"-target-feature" "+sha2" "-target-feature" "+aes"
Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp
===
--- clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -390,6 +390,9 @@
   }
 
   if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.5a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.6a") != ItEnd ||
+  std::find(ItBegin, ItEnd, "+v8.7a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v9a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v9.1a") != ItEnd ||
   std::find(ItBegin, ItEnd, "+v9.2a") != ItEnd) {
Index: clang/lib/Basic/Targets/ARM.cpp
===
--- clang/lib/Basic/Targets/ARM.cpp
+++ clang/lib/Basic/Targets/ARM.cpp
@@ -930,6 +930,7 @@
   case llvm::ARM::ArchKind::ARMV8_4A:
   case llvm::ARM::ArchKind::ARMV8_5A:
   case llvm::ARM::ArchKind::ARMV8_6A:
+  case llvm::ARM::ArchKind::ARMV8_7A:
   case llvm::ARM::ArchKind::ARMV9A:
   case llvm::ARM::ArchKind::ARMV9_1A:
   case llvm::ARM::ArchKind::ARMV9_2A:


Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -294,7 +294,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" "-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sha2" "-target-feature" "+aes

[PATCH] D116154: [ARM] Adding macros for coprocessor intrinsics as per ACLE

2021-12-22 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson created this revision.
Herald added a subscriber: kristof.beyls.
tmatheson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Patch by Ranjeet Singh and Son Tuan Vu.

Change-Id: Ic18ffda35760587673b30c166ac145b0df038973


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116154

Files:
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm-acle-coproc.c
  clang/test/Preprocessor/aarch64-target-features.c

Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -43,6 +43,7 @@
 // CHECK-NOT: __ARM_PCS_VFP 1
 // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1
 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2
+// CHECK-NOT: __ARM_TARGET_COPROC 1
 // CHECK-NOT: __ARM_FEATURE_SVE
 // CHECK-NOT: __ARM_FEATURE_DOTPROD
 // CHECK-NOT: __ARM_FEATURE_PAC_DEFAULT
Index: clang/test/CodeGen/arm-acle-coproc.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-acle-coproc.c
@@ -0,0 +1,350 @@
+// RUN: %clang_cc1 -triple armv4 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V4 %s
+// RUN: %clang_cc1 -triple armv4t %s -E -dD -o - | FileCheck --check-prefix=CHECK-V4 %s
+// RUN: %clang_cc1 -triple armv5 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5 %s
+// RUN: %clang_cc1 -triple armv5te %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-TE %s
+// RUN: %clang_cc1 -triple armv5tej %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-TE %s
+// RUN: %clang_cc1 -triple armv6 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6 %s
+// RUN: %clang_cc1 -triple armv6m %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6M %s
+// RUN: %clang_cc1 -triple armv7a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple armv7r %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple armv7m %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple armv8a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8r %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.1a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.2a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.3a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.4a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.5a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.6a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple armv8.7a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv4 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V4-THUMB %s
+// RUN: %clang_cc1 -triple thumbv4t %s -E -dD -o - | FileCheck --check-prefix=CHECK-V4-THUMB %s
+// RUN: %clang_cc1 -triple thumbv5 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-THUMB %s
+// RUN: %clang_cc1 -triple thumbv5te %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-TE-THUMB %s
+// RUN: %clang_cc1 -triple thumbv5tej %s -E -dD -o - | FileCheck --check-prefix=CHECK-V5-TE-THUMB %s
+// RUN: %clang_cc1 -triple thumbv6 %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6-THUMB %s
+// RUN: %clang_cc1 -triple thumbv6k %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6-THUMB %s
+// RUN: %clang_cc1 -triple thumbv6kz %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6-THUMB %s
+// RUN: %clang_cc1 -triple thumbv6m %s -E -dD -o - | FileCheck --check-prefix=CHECK-V6M %s
+// RUN: %clang_cc1 -triple thumbv7a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple thumbv7r %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple thumbv7m %s -E -dD -o - | FileCheck --check-prefix=CHECK-V7 %s
+// RUN: %clang_cc1 -triple thumbv8a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.1a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.2a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.3a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.4a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.5a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.6a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8.7a %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8r %s -E -dD -o - | FileCheck --check-prefix=CHECK-V8 %s
+// RUN: %clang_cc1 -triple thumbv8m.base %s -E -dD -o - | FileCheck --check-prefix=C

[PATCH] D116128: [clang][driver] Warn when '-mno-outline-atomics' is used with a non-AArch64 triple

2021-12-22 Thread Marco Elver via Phabricator via cfe-commits
melver accepted this revision.
melver added inline comments.



Comment at: clang/test/Driver/x86-outline-atomics.c:1-7
+// RUN: %clang -target x86_64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s 
-check-prefix=CHECK-OUTLINE-ATOMICS
+// CHECK-OUTLINE-ATOMICS: warning: 'x86_64' does not support 
'-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target x86_64 -mno-outline-atomics -S %s -### 2>&1 | FileCheck 
%s -check-prefix=CHECK-NO-OUTLINE-ATOMICS
+// CHECK-NO-OUTLINE-ATOMICS: warning: 'x86_64' does not support 
'-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-NOT: "-target-feature" "-outline-atomics"

nathanchance wrote:
> nickdesaulniers wrote:
> > If `clang/test/Driver/aarch64-features.c` is only testing outline atomics, 
> > I wonder if this test should actually go in there? @t.p.northover , 
> > thoughts? Otherwise LGTM and thanks for the patch!
> I did consider that initially but:
> 
> 1. It does appear to test a few other AArch64 specific things.
> 2. It seemed weird to add an x86_64 test to an AArch64 file.
> 
> No strong opinions though, I'll go along with whatever works and makes the 
> majority happy.
There is a similar precedent in `clang/test/Driver/aarch64-outliner.c`, 
although maybe that should have been in aarch64-features.c

However, the fact it's called `x86-outline-atomics.c` makes me think that x86 
supports outline atomics.

Other similar tests appear in `clang/test/Driver/unsupported-*`.

My suggestion is to call it `unsupported-outline-atomics.c`.

Furthermore, this shouldn't just warn on x86, so one more arch (say riscv or 
ppc?) would be useful to check as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116128

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


[PATCH] D116155: [clang][AST][ASTImporter] Set record to complete during import of its members.

2021-12-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, martong, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

At import of a member it may require that the record is already set to complete.
(For example 'computeDependence' at create of some Expr nodes.)
The record at this time may not be completely imported, the result of layout
calculations can be incorrect, but at least no crash occurs this way.

A good solution would be if fields of every encountered record are imported
before other members of all records. This is much more difficult to implement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116155

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7475,6 +7475,57 @@
 ToDGOther);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportRecordWithLayoutRequestingExpr) {
+  TranslationUnitDecl *FromTU = getTuDecl(
+  R"(
+  struct A {
+int idx;
+static void foo(A x) {
+  (void)&"text"[x.idx];
+}
+  };
+  )",
+  Lang_CXX11);
+
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("A")));
+
+  // Test that during import of 'foo' the record layout can be obtained without
+  // crash.
+  auto *ToA = Import(FromA, Lang_CXX11);
+  EXPECT_TRUE(ToA);
+  EXPECT_TRUE(ToA->isCompleteDefinition());
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportRecordWithLayoutRequestingExprDifferentRecord) {
+  TranslationUnitDecl *FromTU = getTuDecl(
+  R"(
+  struct B;
+  struct A {
+int idx;
+B *b;
+  };
+  struct B {
+static void foo(A x) {
+  (void)&"text"[x.idx];
+}
+  };
+  )",
+  Lang_CXX11);
+
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("A")));
+
+  // Test that during import of 'foo' the record layout (of 'A') can be 
obtained
+  // without crash. It is not possible to have all of the fields of 'A' 
imported
+  // at that time (without big code changes).
+  auto *ToA = Import(FromA, Lang_CXX11);
+  EXPECT_TRUE(ToA);
+  EXPECT_TRUE(ToA->isCompleteDefinition());
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
  DefaultTestValuesForRunOptions);
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -2012,6 +2012,13 @@
   }
 
   To->startDefinition();
+  // Set the definition to complete even if it is really not complete during
+  // import. Some AST constructs (expressions) require the record layout
+  // to be calculated (see 'clang::computeDependence') at the time they are
+  // constructed. Import of such AST node is possible during import of the
+  // same record, there is no way to have a completely defined record (all
+  // fields imported) at that time without multiple AST import passes.
+  To->setCompleteDefinition(true);
   // Complete the definition even if error is returned.
   // The RecordDecl may be already part of the AST so it is better to
   // have it in complete state even if something is wrong with it.
@@ -2076,9 +2083,12 @@
   ToCXX->setBases(Bases.data(), Bases.size());
   }
 
-  if (shouldForceImportDeclContext(Kind))
+  if (shouldForceImportDeclContext(Kind)) {
+// Set to false here to force "completion" of the record.
+To->setCompleteDefinition(false);
 if (Error Err = ImportDeclContext(From, /*ForceImport=*/true))
   return Err;
+  }
 
   return Error::success();
 }


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7475,6 +7475,57 @@
 ToDGOther);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportRecordWithLayoutRequestingExpr) {
+  TranslationUnitDecl *FromTU = getTuDecl(
+  R"(
+  struct A {
+int idx;
+static void foo(A x) {
+  (void)&"text"[x.idx];
+}
+  };
+  )",
+  Lang_CXX11);
+
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, cxxRecordDecl(hasName("A")));
+
+  // Test that during import of 'foo' the record layout can be obtained without
+  // crash.
+  auto *ToA = Import(FromA, Lang_CXX11);
+  EXPECT_TRUE(ToA);
+  EXPECT_TRUE(ToA->isCompleteDefinition());
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase,
+   ImportRecordWithLayoutRequestingExprDifferentRecord) {
+  TranslationUnitDecl *FromTU = getTuDecl(
+  

[PATCH] D116159: [ARM][AArch64] clang support for Armv9.3-A

2021-12-22 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson created this revision.
Herald added a subscriber: kristof.beyls.
tmatheson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch introduces support for targetting the Armv9.3-A architecture,
which should map to the existing Armv8.8-A extensions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116159

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  clang/test/Preprocessor/arm-target-features.c

Index: clang/test/Preprocessor/arm-target-features.c
===
--- clang/test/Preprocessor/arm-target-features.c
+++ clang/test/Preprocessor/arm-target-features.c
@@ -879,6 +879,11 @@
 // CHECK-V92A: #define __ARM_ARCH_9_2A__ 1
 // CHECK-V92A: #define __ARM_ARCH_PROFILE 'A'
 
+// RUN: %clang -target armv9.3a-none-none-eabi -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V93A %s
+// CHECK-V93A: #define __ARM_ARCH 9
+// CHECK-V93A: #define __ARM_ARCH_9_3A__ 1
+// CHECK-V93A: #define __ARM_ARCH_PROFILE 'A'
+
 // RUN: %clang -target arm-none-none-eabi -march=armv7-m -mfpu=softvfp -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SOFTVFP %s
 // CHECK-SOFTVFP-NOT: #define __ARM_FP 0x
 
Index: clang/test/Driver/arm-cortex-cpus.c
===
--- clang/test/Driver/arm-cortex-cpus.c
+++ clang/test/Driver/arm-cortex-cpus.c
@@ -437,6 +437,23 @@
 // RUN: %clang -target arm -march=armebv9.2-a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V92A %s
 // CHECK-BE-V92A: "-cc1"{{.*}} "-triple" "armebv9.2{{.*}}" "-target-cpu" "generic"
 
+// RUN: %clang -target armv9.3a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V93A %s
+// RUN: %clang -target arm -march=armv9.3a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V93A %s
+// RUN: %clang -target arm -march=armv9.3-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V93A %s
+// RUN: %clang -target arm -march=armv9.3a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V93A %s
+// RUN: %clang -target armv9.3a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V93A %s
+// RUN: %clang -target arm -march=armv9.3a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V93A %s
+// RUN: %clang -target arm -mlittle-endian -march=armv9.3-a -mlittle-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-V93A %s
+// CHECK-V93A: "-cc1"{{.*}} "-triple" "armv9.3{{.*}}" "-target-cpu" "generic"
+
+// RUN: %clang -target armebv9.3a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V93A %s
+// RUN: %clang -target armv9.3a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V93A %s
+// RUN: %clang -target armeb -march=armebv9.3a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V93A %s
+// RUN: %clang -target armeb -march=armebv9.3-a -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V93A %s
+// RUN: %clang -target arm -march=armebv9.3a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V93A %s
+// RUN: %clang -target arm -march=armebv9.3-a -mbig-endian -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-BE-V93A %s
+// CHECK-BE-V93A: "-cc1"{{.*}} "-triple" "armebv9.3{{.*}}" "-target-cpu" "generic"
+
 // Once we have CPUs with optional v8.2-A FP16, we will need a way to turn it
 // on and off. Cortex-A53 is a placeholder for now.
 // RUN: %clang -target armv8a-linux-eabi -mcpu=cortex-a53+fp16 -### -c %s 2>&1 | FileCheck --check-prefix CHECK-CORTEX-A53-FP16 %s
Index: clang/test/Driver/aarch64-cpus.c
===
--- clang/test/Driver/aarch64-cpus.c
+++ clang/test/Driver/aarch64-cpus.c
@@ -876,6 +876,22 @@
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.2-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV92A-BE %s
 // GENERICV92A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" "generic" "-target-feature" "+neon" "-target-feature" "+v9.2a" "-target-feature" "+i8mm" "-target-feature" "+bf16" "-target-feature" "+sve" "-target-feature" "+sve2"
 
+// RUN: %clang -target aarch64 -march=armv9.3a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV93A %s
+// RUN: %clang -target aarch64 -march=armv9.3-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV93A %s
+// RUN: %clang -target aarch64 -mlittle-endian -march=armv9.3a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV93A %s
+// RUN: %clang -target aarch64 -mlittle-endian -march=armv9.3-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV93A %s
+// RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.3a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV93A %s
+// RUN: %clang -target aarch64_be -mlittle-endian -march=armv9.3-a -### -c %s 2>&1 | FileCheck -check-prefix=GENERICV93A %s
+// GENERICV9

[clang] 0af6281 - [CodeGen] Make lifetime marker test more robust (NFC)

2021-12-22 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-12-22T12:28:10+01:00
New Revision: 0af628152a0547ad02856a880830ec33aa79e21c

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

LOG: [CodeGen] Make lifetime marker test more robust (NFC)

Mark the first function optnone as well, to make sure that the
test is independent of optimization.

Added: 


Modified: 
clang/test/CodeGen/aggregate-assign-call.c

Removed: 




diff  --git a/clang/test/CodeGen/aggregate-assign-call.c 
b/clang/test/CodeGen/aggregate-assign-call.c
index 5aeaca19379a4..d25fc39cfe754 100644
--- a/clang/test/CodeGen/aggregate-assign-call.c
+++ b/clang/test/CodeGen/aggregate-assign-call.c
@@ -4,7 +4,8 @@
 // Ensure that we place appropriate lifetime markers around indirectly returned
 // temporaries, and that the lifetime.ends appear in a timely manner.
 //
-// -O1 is used so lifetime markers actually get emitted.
+// -O1 is used so lifetime markers actually get emitted and optnone is added
+// to avoid elimination of lifetime markers by optimizations.
 
 struct S {
   int ns[40];
@@ -13,25 +14,39 @@ struct S {
 struct S foo(void);
 
 // CHECK-LABEL: define dso_local void @bar
+__attribute__((optnone))
 struct S bar() {
   // O0-NOT: @llvm.lifetime.start
   // O0-NOT: @llvm.lifetime.end
 
   struct S r;
-  // O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* nonnull 
%[[TMP1:[^)]+]])
+  // O1: %[[TMP1_ALLOCA:[^ ]+]] = alloca %struct.S
+  // O1: %[[TMP2_ALLOCA:[^ ]+]] = alloca %struct.S
+  // O1: %[[TMP3_ALLOCA:[^ ]+]] = alloca %struct.S
+
+  // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
+  // O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
   // O1: call void @foo
   r = foo();
-  // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* nonnull %[[TMP1]])
+  // O1: memcpy
+  // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP1_ALLOCA]] to i8*
+  // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
 
-  // O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* nonnull 
%[[TMP2:[^)]+]])
+  // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8*
+  // O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
   // O1: call void @foo
   r = foo();
-  // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* nonnull %[[TMP2]])
+  // O1: memcpy
+  // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP2_ALLOCA]] to i8*
+  // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
 
-  // O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* nonnull 
%[[TMP3:[^)]+]])
+  // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP3_ALLOCA]] to i8*
+  // O1: call void @llvm.lifetime.start.p0i8({{[^,]*}}, i8* %[[P]])
   // O1: call void @foo
   r = foo();
-  // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* nonnull %[[TMP3]])
+  // O1: memcpy
+  // O1: %[[P:[^ ]+]] = bitcast %struct.S* %[[TMP3_ALLOCA]] to i8*
+  // O1: call void @llvm.lifetime.end.p0i8({{[^,]*}}, i8* %[[P]])
 
   return r;
 }
@@ -39,8 +54,6 @@ struct S bar() {
 struct S foo_int(int);
 
 // Be sure that we're placing the lifetime.end so that all paths go through it.
-// Since this function turns out to be large-ish, optnone to hopefully keep it
-// stable.
 // CHECK-LABEL: define dso_local void @baz
 __attribute__((optnone))
 struct S baz(int i, volatile int *j) {



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


[PATCH] D116160: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2021-12-22 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson created this revision.
Herald added a subscriber: kristof.beyls.
tmatheson requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This introduces the new `__ARM_FEATURE_MOPS` ACLE feature test macro,
which signals the availability of the new Armv8.8-A/Armv9.3-A
instructions for standardising memcpy, memset and memmove operations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116160

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/Support/AArch64TargetParser.h


Index: llvm/include/llvm/Support/AArch64TargetParser.h
===
--- llvm/include/llvm/Support/AArch64TargetParser.h
+++ llvm/include/llvm/Support/AArch64TargetParser.h
@@ -69,6 +69,7 @@
   AEK_SME = 1ULL << 37,
   AEK_SMEF64 =  1ULL << 38,
   AEK_SMEI64 =  1ULL << 39,
+  AEK_MOPS =1ULL << 40,
 };
 
 enum class ArchKind {
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -517,3 +517,13 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o 
- | FileCheck --check-prefix=CHECK-LSE %s
 // CHECK-LSE: __ARM_FEATURE_ATOMICS 1
+
+// == Check Armv8.8-A/Armv9.3-A memcpy and memset acceleration 
instructions (MOPS)
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+mops -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+nomops -x c -E 
-dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9-a+mops -x c -E -dM 
%s -o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a -x c -E -dM %s 
-o - | FileCheck --check-prefix=CHECK-MOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+nomops -x c -E 
-dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// CHECK-MOPS: __ARM_FEATURE_MOPS 1
+// CHECK-NOMOPS-NOT: __ARM_FEATURE_MOPS 1
Index: clang/lib/Basic/Targets/AArch64.h
===
--- clang/lib/Basic/Targets/AArch64.h
+++ clang/lib/Basic/Targets/AArch64.h
@@ -53,6 +53,7 @@
   bool HasMatmulFP32;
   bool HasLSE;
   bool HasFlagM;
+  bool HasMOPS;
 
   llvm::AArch64::ArchKind ArchKind;
 
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -435,6 +435,9 @@
   if (HasRandGen)
 Builder.defineMacro("__ARM_FEATURE_RNG", "1");
 
+  if (HasMOPS)
+Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
+
   switch (ArchKind) {
   default:
 break;
@@ -660,6 +663,17 @@
   HasFlagM = true;
   }
 
+  HasMOPS |= ArchKind == llvm::AArch64::ArchKind::ARMV8_8A ||
+ ArchKind == llvm::AArch64::ArchKind::ARMV9_3A;
+
+  // Check features that are manually disabled by command line options.
+  // This needs to be checked after architecture-related features are handled,
+  // making sure they are properly disabled when required.
+  for (const auto &Feature : Features) {
+if (Feature == "-mops")
+  HasMOPS = false;
+  }
+
   setDataLayout();
 
   return true;


Index: llvm/include/llvm/Support/AArch64TargetParser.h
===
--- llvm/include/llvm/Support/AArch64TargetParser.h
+++ llvm/include/llvm/Support/AArch64TargetParser.h
@@ -69,6 +69,7 @@
   AEK_SME = 1ULL << 37,
   AEK_SMEF64 =  1ULL << 38,
   AEK_SMEI64 =  1ULL << 39,
+  AEK_MOPS =1ULL << 40,
 };
 
 enum class ArchKind {
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -517,3 +517,13 @@
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // CHECK-LSE: __ARM_FEATURE_ATOMICS 1
+
+// == Check Armv8.8-A/Armv9.3-A memcpy and memset acceleration instructions (MOPS)
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS

[PATCH] D115867: [C++20] [Coroutines] Warning for always_inline coroutine

2021-12-22 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 395837.
ChuanqiXu added a comment.

Format codes


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

https://reviews.llvm.org/D115867

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaCoroutine.cpp
  clang/test/SemaCXX/coroutines.cpp


Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -1443,3 +1443,7 @@
   co_await missing_await_suspend{}; // expected-error {{no member named 
'await_suspend' in 'missing_await_suspend'}}
   co_await missing_await_resume{}; // expected-error {{no member named 
'await_resume' in 'missing_await_resume'}}
 }
+
+__attribute__((__always_inline__)) void warn_always_inline() { // 
expected-warning {{A coroutine marked always_inline might not be inlined 
properly}}
+  co_await suspend_always{};
+}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1062,6 +1062,12 @@
 return;
   }
 
+  // The coroutine marked always inline might not be inlined properly in 
current
+  // compiler support. Only the ramp function is guarantted to be inlined. It
+  // might be different to what users expects to. Emit a warning to tell it.
+  if (FD->hasAttr())
+Diag(FD->getLocation(), diag::warn_always_inline_coroutine);
+
   // Coroutines [stmt.return]p1:
   //   A return statement shall not appear in a coroutine.
   if (Fn->FirstReturnLoc.isValid()) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11107,6 +11107,10 @@
 def note_coroutine_function_declare_noexcept : Note<
   "must be declared with 'noexcept'"
 >;
+def warn_always_inline_coroutine : Warning<
+  "A coroutine marked always_inline might not be inlined properly."
+  >,
+  InGroup;
 } // end of coroutines issue category
 
 let CategoryName = "Documentation Issue" in {
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -58,7 +58,9 @@
   DiagGroup<"deprecated-experimental-coroutine">;
 def DeprecatedCoroutine :
   DiagGroup<"deprecated-coroutine", [DeprecatedExperimentalCoroutine]>;
-def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException, 
DeprecatedCoroutine]>;
+def AlwaysInlineCoroutine :
+  DiagGroup<"always-inline-coroutine">;
+def Coroutine : DiagGroup<"coroutine", [CoroutineMissingUnhandledException, 
DeprecatedCoroutine, AlwaysInlineCoroutine]>;
 def ObjCBoolConstantConversion : DiagGroup<"objc-bool-constant-conversion">;
 def ConstantConversion : DiagGroup<"constant-conversion",
[BitFieldConstantConversion,


Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -1443,3 +1443,7 @@
   co_await missing_await_suspend{}; // expected-error {{no member named 'await_suspend' in 'missing_await_suspend'}}
   co_await missing_await_resume{}; // expected-error {{no member named 'await_resume' in 'missing_await_resume'}}
 }
+
+__attribute__((__always_inline__)) void warn_always_inline() { // expected-warning {{A coroutine marked always_inline might not be inlined properly}}
+  co_await suspend_always{};
+}
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -1062,6 +1062,12 @@
 return;
   }
 
+  // The coroutine marked always inline might not be inlined properly in current
+  // compiler support. Only the ramp function is guarantted to be inlined. It
+  // might be different to what users expects to. Emit a warning to tell it.
+  if (FD->hasAttr())
+Diag(FD->getLocation(), diag::warn_always_inline_coroutine);
+
   // Coroutines [stmt.return]p1:
   //   A return statement shall not appear in a coroutine.
   if (Fn->FirstReturnLoc.isValid()) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11107,6 +11107,10 @@
 def note_coroutine_function_declare_noexcept : Note<
   "must be declared with 'noexcept'"
 >;
+def warn_always_inline_coroutine : Warning<
+  "A coroutine marked always_inline might not be inlined properly."
+  >,
+  InGroup;
 } // end of coroutines issue category
 
 let Ca

[PATCH] D116113: Add LLDB synthetic child and summary scripts for llvm::SmallVector, llvm::Optional, llvm::ErrorOr and llvm::Expected.

2021-12-22 Thread Pavel Labath via Phabricator via cfe-commits
labath added a comment.

Seems fairly straight-forward (and definitely useful). Just a couple of quick 
comments.




Comment at: clang/utils/ClangDataFormat.py:28-35
+debugger.HandleCommand("type summary add -F 
ClangDataFormat.Optional_summary -x 'llvm::Optional<.*>'")
+debugger.HandleCommand("type summary add -F 
ClangDataFormat.SmallVector_summary -x 'llvm::SmallVector<.*>'")
+debugger.HandleCommand("type summary add -F 
ClangDataFormat.Expected_summary -x 'llvm::Expected<.*>'")
+debugger.HandleCommand("type summary add -F 
ClangDataFormat.ErrorOr_summary -x 'llvm::ErrorOr<.*>'")
+debugger.HandleCommand("type synthetic add -l ClangDataFormat.Optional -x 
'llvm::Optional<.*>'")
+debugger.HandleCommand("type synthetic add -l ClangDataFormat.SmallVector 
-x 'llvm::SmallVector<.*>'")
+debugger.HandleCommand("type synthetic add -l ClangDataFormat.Expected -x 
'llvm::Expected<.*>'")

I believe it's necessary to anchor these regexes to avoid them matching things 
like `std::vector>`



Comment at: clang/utils/ClangDataFormat.py:371-373
+self.error_type = target.FindFirstType('std::__1::error_code')
+if not self.error_type.IsValid():
+self.error_type = 
target.FindFirstType('std::error_code').GetPointerType()

maybe access as 
`valobj.GetChildMemberWithName('ErrorStorage').GetType().GetTemplateArgumentType(0)`
 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116113

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


[PATCH] D116022: [clang][dataflow] Add support for terminating virtual destructors

2021-12-22 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 395841.
sgatev marked 2 inline comments as done.
sgatev added a comment.

Address reviewers' comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116022

Files:
  clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "TestingSupport.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
@@ -14,15 +15,24 @@
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 using namespace clang;
 using namespace dataflow;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
 
 template 
 class AnalysisCallback : public ast_matchers::MatchFinder::MatchCallback {
@@ -36,21 +46,12 @@
 Stmt *Body = Func->getBody();
 assert(Body != nullptr);
 
-// FIXME: Consider providing a utility that returns a `CFG::BuildOptions`
-// which is a good default for most clients or a utility that directly
-// builds the `CFG` using default `CFG::BuildOptions`.
-CFG::BuildOptions Options;
-Options.AddImplicitDtors = true;
-Options.AddTemporaryDtors = true;
-Options.setAllAlwaysAdd();
-
-std::unique_ptr Cfg =
-CFG::buildCFG(nullptr, Body, Result.Context, Options);
-assert(Cfg != nullptr);
+auto CFCtx = llvm::cantFail(
+ControlFlowContext::build(nullptr, Body, Result.Context));
 
 AnalysisT Analysis(*Result.Context);
 Environment Env;
-BlockStates = runDataflowAnalysis(*Cfg, Analysis, Env);
+BlockStates = runDataflowAnalysis(CFCtx, Analysis, Env);
   }
 
   std::vector<
@@ -141,8 +142,175 @@
 }
   )");
   EXPECT_EQ(BlockStates.size(), 4u);
-  EXPECT_FALSE(BlockStates[0].hasValue());
+  EXPECT_TRUE(BlockStates[0].hasValue());
   EXPECT_TRUE(BlockStates[1].hasValue());
   EXPECT_TRUE(BlockStates[2].hasValue());
   EXPECT_TRUE(BlockStates[3].hasValue());
 }
+
+struct FunctionCallLattice {
+  llvm::SmallSet CalledFunctions;
+
+  bool operator==(const FunctionCallLattice &Other) const {
+return CalledFunctions == Other.CalledFunctions;
+  }
+
+  LatticeJoinEffect join(const FunctionCallLattice &Other) {
+if (Other.CalledFunctions.empty())
+  return LatticeJoinEffect::Unchanged;
+const size_t size_before = CalledFunctions.size();
+CalledFunctions.insert(Other.CalledFunctions.begin(),
+   Other.CalledFunctions.end());
+return CalledFunctions.size() == size_before ? LatticeJoinEffect::Unchanged
+ : LatticeJoinEffect::Changed;
+  }
+};
+
+std::ostream &operator<<(std::ostream &OS, const FunctionCallLattice &L) {
+  std::string S;
+  llvm::raw_string_ostream ROS(S);
+  llvm::interleaveComma(L.CalledFunctions, ROS);
+  return OS << "{" << S << "}";
+}
+
+class FunctionCallAnalysis
+: public DataflowAnalysis {
+public:
+  explicit FunctionCallAnalysis(ASTContext &Context)
+  : DataflowAnalysis(Context) {}
+
+  static FunctionCallLattice initialElement() { return {}; }
+
+  FunctionCallLattice transfer(const Stmt *S, const FunctionCallLattice &E,
+   Environment &Env) {
+FunctionCallLattice R = E;
+if (auto *C = dyn_cast(S)) {
+  if (auto *F = dyn_cast(C->getCalleeDecl())) {
+R.CalledFunctions.insert(F->getNameInfo().getAsString());
+  }
+}
+return R;
+  }
+};
+
+class VirtualDestructorTest : public ::testing::Test {
+protected:
+  template 
+  void runDataflow(llvm::StringRef Code, Matcher Expectations) {
+tooling::FileContentMappings FilesContents;
+FilesContents.push_back(std::make_pair(
+"virtual_de

[PATCH] D116022: [clang][dataflow] Add support for terminating virtual destructors

2021-12-22 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev marked 3 inline comments as done.
sgatev added a comment.

I also agree that the current approach isn't robust. I think that a proper 
solution would involve patching the CFG because in some cases it seems to be 
incorrect. For example, the call to `qux` is incorrectly deemed to be 
unreachable in the CFG of the following code:

  int foo();
  
  class Fatal {
   public:
~Fatal() __attribute__((noreturn));
int bar();
int baz();
  };
  
  void qux();
  
  void target(bool b1, bool b2) {
int value = b1 ? foo() : (b2 ? Fatal().bar() : Fatal().baz());
qux();
  }

I'd be happy to look into a solution for this as a follow up. I guess it would 
have an impact on other users of the CFG too.




Comment at: clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h:50
+  std::unique_ptr Cfg;
+  llvm::DenseMap StmtToBlock;
+};

gribozavr2 wrote:
> xazax.hun wrote:
> > There is a special class for this at `clang/lib/Analysis/CFGStmtMap.cpp`. 
> > That also does some special handling of the terminators. I wonder if we 
> > need to do something similar here (or just use that class as is?).
> The only downside I see is that CFGStmtMap needs a ParentMap, which is not 
> cheap to make, but we don't need. Maybe we need to make it optional in 
> CFGStmtMap?
The main reason for me not to use `CFGStmtMap` right away is that based on some 
tests it seems to behave differently compared to what's implemented here. I 
plan to look into that in detail and see if there's an opportunity to replace 
the logic here. It shouldn't be too difficult to do that in a follow up as 
`getStmtToBlock` is used in a single place.



Comment at: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h:103
 std::vector>
-runTypeErasedDataflowAnalysis(const CFG &Cfg,
+runTypeErasedDataflowAnalysis(const ControlFlowContext &Ctx,
   TypeErasedDataflowAnalysis &Analysis,

gribozavr2 wrote:
> I'd suggest a more verbose name like `CFCtx`, since `Ctx` is most often used 
> in Clang for `ASTContext`. (Here and elsewhere in the patch.)
Replaced `Ctx` with `CFCtx` across the patch.



Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:51
+  if (Block.getTerminator().isTemporaryDtorsBranch()) {
+// The first successor of a block with a temporary destructor terminator is
+// the block that evaluates the destructor. If that block has a noreturn

xazax.hun wrote:
> This comment might be a bit hard to understand without a code example. 
> Admittedly, including an example here could get very chatty, but we could 
> refer to the name of the corresponding test.
> 
> I wonder whether naming the blocks like `The first successor of block 'A'` 
> would make this clearer.
I updated the comment and added more tests. Hopefully, that would be good 
enough for now and we can replace all of this with a more principled solution 
shortly.



Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:47
+auto Ctx = ControlFlowContext::build(nullptr, Body, Result.Context);
+assert(Ctx);
 

gribozavr2 wrote:
> Use `llvm::cantFail` to unwrap the `Expected`?
Much better. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116022

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


[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

2021-12-22 Thread Jun Zhang via Phabricator via cfe-commits
junaire created this revision.
junaire added reviewers: fhahn, arsenm.
junaire requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

This patch adds an overload for emitUnaryBuiltin, which is addressed in D115429 
.
After this change, we can avoid some duplicate codes when emitting IR for
__builtin_elementwise_*.

Signed-off-by: Jun Zhang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116161

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
 }
 
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+   unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
 const CallExpr *E,


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
 }
 
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+   unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
 const CallExpr *E,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115429: [Clang] Implement the rest of __builtin_elementwise_* functions.

2021-12-22 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

> Sounds good! Might be good to split the emitUnaryBuiltin changes off into a 
> separate change?

Thanks for your suggestion! I just sent another patch: D116161 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115429

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


[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

2021-12-22 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Can you also update the existing places that could use it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116161

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


[PATCH] D116022: [clang][dataflow] Add support for terminating noreturn destructors

2021-12-22 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev updated this revision to Diff 395845.
sgatev marked 3 inline comments as done.
sgatev added a comment.

Change commit message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116022

Files:
  clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
@@ -6,6 +6,7 @@
 //
 //===--===//
 
+#include "TestingSupport.h"
 #include "clang/AST/Decl.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
@@ -14,15 +15,24 @@
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "clang/Analysis/FlowSensitive/DataflowLattice.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 using namespace clang;
 using namespace dataflow;
+using ::testing::IsEmpty;
+using ::testing::Pair;
+using ::testing::UnorderedElementsAre;
 
 template 
 class AnalysisCallback : public ast_matchers::MatchFinder::MatchCallback {
@@ -36,21 +46,12 @@
 Stmt *Body = Func->getBody();
 assert(Body != nullptr);
 
-// FIXME: Consider providing a utility that returns a `CFG::BuildOptions`
-// which is a good default for most clients or a utility that directly
-// builds the `CFG` using default `CFG::BuildOptions`.
-CFG::BuildOptions Options;
-Options.AddImplicitDtors = true;
-Options.AddTemporaryDtors = true;
-Options.setAllAlwaysAdd();
-
-std::unique_ptr Cfg =
-CFG::buildCFG(nullptr, Body, Result.Context, Options);
-assert(Cfg != nullptr);
+auto CFCtx = llvm::cantFail(
+ControlFlowContext::build(nullptr, Body, Result.Context));
 
 AnalysisT Analysis(*Result.Context);
 Environment Env;
-BlockStates = runDataflowAnalysis(*Cfg, Analysis, Env);
+BlockStates = runDataflowAnalysis(CFCtx, Analysis, Env);
   }
 
   std::vector<
@@ -141,8 +142,175 @@
 }
   )");
   EXPECT_EQ(BlockStates.size(), 4u);
-  EXPECT_FALSE(BlockStates[0].hasValue());
+  EXPECT_TRUE(BlockStates[0].hasValue());
   EXPECT_TRUE(BlockStates[1].hasValue());
   EXPECT_TRUE(BlockStates[2].hasValue());
   EXPECT_TRUE(BlockStates[3].hasValue());
 }
+
+struct FunctionCallLattice {
+  llvm::SmallSet CalledFunctions;
+
+  bool operator==(const FunctionCallLattice &Other) const {
+return CalledFunctions == Other.CalledFunctions;
+  }
+
+  LatticeJoinEffect join(const FunctionCallLattice &Other) {
+if (Other.CalledFunctions.empty())
+  return LatticeJoinEffect::Unchanged;
+const size_t size_before = CalledFunctions.size();
+CalledFunctions.insert(Other.CalledFunctions.begin(),
+   Other.CalledFunctions.end());
+return CalledFunctions.size() == size_before ? LatticeJoinEffect::Unchanged
+ : LatticeJoinEffect::Changed;
+  }
+};
+
+std::ostream &operator<<(std::ostream &OS, const FunctionCallLattice &L) {
+  std::string S;
+  llvm::raw_string_ostream ROS(S);
+  llvm::interleaveComma(L.CalledFunctions, ROS);
+  return OS << "{" << S << "}";
+}
+
+class FunctionCallAnalysis
+: public DataflowAnalysis {
+public:
+  explicit FunctionCallAnalysis(ASTContext &Context)
+  : DataflowAnalysis(Context) {}
+
+  static FunctionCallLattice initialElement() { return {}; }
+
+  FunctionCallLattice transfer(const Stmt *S, const FunctionCallLattice &E,
+   Environment &Env) {
+FunctionCallLattice R = E;
+if (auto *C = dyn_cast(S)) {
+  if (auto *F = dyn_cast(C->getCalleeDecl())) {
+R.CalledFunctions.insert(F->getNameInfo().getAsString());
+  }
+}
+return R;
+  }
+};
+
+class VirtualDestructorTest : public ::testing::Test {
+protected:
+  template 
+  void runDataflow(llvm::StringRef Code, Matcher Expectations) {
+tooling::FileContentMappings FilesContents;
+FilesContents.push_back(std::make_pair(
+"virtual_destruct

[PATCH] D116160: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2021-12-22 Thread Kyrill Tkachov via Phabricator via cfe-commits
ktkachov added a comment.

I think the most important use of the __ARM_FEATURE_MOPS is to check whether 
it's safe to use the new intrinsics, so it should only be defined by the 
compiler once it supports the intrinsics proposed in 
https://github.com/ARM-software/acle/pull/38/files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116160

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


[PATCH] D116153: [ARM][AArch64] Add missing v8.x checks

2021-12-22 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added reviewers: dmgreen, SjoerdMeijer.
SjoerdMeijer added inline comments.



Comment at: clang/lib/Basic/Targets/ARM.cpp:937
   case llvm::ARM::ArchKind::ARMV9_2A:
 getTargetDefinesARMV83A(Opts, Builder);
 break;

Perhaps unrelated to this patch, but I am surprised to see that from v 8.3 and 
up we only include `getTargetDefinesARMV83A`, so no other target defines were 
introduced or are necessary? This is not rhetorical questionI haven't paid 
attention to this since v8.4.



Comment at: clang/test/Preprocessor/aarch64-target-features.c:296
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"

I don't pretend to understand the combo `x86_64-apple-macosx -arch arm64` 
here but is unrelated to this patch... 



Comment at: clang/test/Preprocessor/aarch64-target-features.c:298
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+v8.5a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fullfp16" "-target-feature" "+sm4" 
"-target-feature" "+sha3" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64_32 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64_32 %s

A test for v8.5 seems to be covered above somehow, but do we not need any tests 
for v8.6 and v 8.7?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116153

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


[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

2021-12-22 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 395852.
junaire added a comment.

Update the existing place that can use `emitUnaryBuiltin`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116161

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c

Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -156,3 +156,66 @@
   uv = __builtin_elementwise_ceil(uv);
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
+
+void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_floor(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_floor();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_floor(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_floor(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_floor(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_floor(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
+void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_roundeven(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_roundeven();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_roundeven(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_roundeven(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_roundeven(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_roundeven(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
+void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_trunc(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_trunc();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_trunc(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_trunc(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_trunc(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_trunc(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -205,3 +205,51 @@
   // CHECK-NEXT: call <4 x float> @llvm.ceil.v4f32(<4 x float> [[VF1]])
   vf2 = __builtin_elementwise_ceil(vf1);
 }
+
+void test_builtin_elementwise_floor(float f1, float f2, double d1, double d2,
+float4 vf1, float4 vf2) {
+  // CHECK-LABEL: define void @test_builtin_elementwise_floor(
+  // CHECK:  [[F1:%.+]] = load float, float* %f1.addr, align 4
+  // CHECK-NEXT:  call float @llvm.floor.f32(float [[F1]])
+  f2 = __builtin_elementwise_floor(f1);
+
+  // CHECK:  [[D1:%.+]] = load double, double* %d1.addr, align 8
+  // CHECK-NEXT: call double @llvm.floor.f64(double [[D1]])
+  d2 = __builtin_elementwise_floor(d1);
+
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call <4 x float> @llvm.floor.v4f32(<4 x float> [[VF1]])
+  vf2 = __builtin_elementwise_floor(vf1);
+}
+
+void test_builtin_elementwise_roundeven(float f1, float f2, double d1, double d2,
+fl

[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

2021-12-22 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 395853.
junaire added a comment.

Sorry, It seems that the base branch is wrong, reupdate it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116161

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
 }
 
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+   unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
 const CallExpr *E,
@@ -3128,8 +3134,8 @@
   Result = Builder.CreateBinaryIntrinsic(
   llvm::Intrinsic::abs, Op0, Builder.getFalse(), nullptr, "elt.abs");
 else
-  Result = Builder.CreateUnaryIntrinsic(llvm::Intrinsic::fabs, Op0, 
nullptr,
-"elt.abs");
+  Result = emitUnaryBuiltin(*this, E, llvm::Intrinsic::fabs, "elt.abs");
+
 return RValue::get(Result);
   }
 


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
 }
 
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+   unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
 const CallExpr *E,
@@ -3128,8 +3134,8 @@
   Result = Builder.CreateBinaryIntrinsic(
   llvm::Intrinsic::abs, Op0, Builder.getFalse(), nullptr, "elt.abs");
 else
-  Result = Builder.CreateUnaryIntrinsic(llvm::Intrinsic::fabs, Op0, nullptr,
-"elt.abs");
+  Result = emitUnaryBuiltin(*this, E, llvm::Intrinsic::fabs, "elt.abs");
+
 return RValue::get(Result);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

2021-12-22 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D116161#3206442 , @junaire wrote:

> Update the existing place that can use `emitUnaryBuiltin`.

I meant just update the existing uses *without* adding `floor`, `roundeven`, 
`trunc`, so this change should be NFC (non-functional change)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116161

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


[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

2021-12-22 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

In D116161#3206447 , @fhahn wrote:

> In D116161#3206442 , @junaire wrote:
>
>> Update the existing place that can use `emitUnaryBuiltin`.
>
> I meant just update the existing uses *without* adding `floor`, `roundeven`, 
> `trunc`, so this change should be NFC (non-functional change)

I'm sorry about it, I'm just too careless. :-(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116161

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


[PATCH] D116163: [clang-tidy] Add a SuppressedChecks option to ignore diagnostics from specific checks

2021-12-22 Thread Guillermo Rey via Phabricator via cfe-commits
reyg created this revision.
reyg added a reviewer: cfe-commits.
Herald added subscribers: carlosgalvezp, xazax.hun.
reyg requested review of this revision.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116163

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -76,12 +76,14 @@
 TEST(ParseConfiguration, ValidConfiguration) {
   llvm::ErrorOr Options =
   parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n"
+   "SuppressedChecks: \"noisy-*\"\n"
"HeaderFilterRegex: \".*\"\n"
"AnalyzeTemporaryDtors: true\n"
"User: some.user",
"Options"));
   EXPECT_TRUE(!!Options);
   EXPECT_EQ("-*,misc-*", *Options->Checks);
+  EXPECT_EQ("noisy-*", *Options->SuppressedChecks);
   EXPECT_EQ(".*", *Options->HeaderFilterRegex);
   EXPECT_EQ("some.user", *Options->User);
 }
@@ -90,6 +92,7 @@
   llvm::ErrorOr Options1 =
   parseConfiguration(llvm::MemoryBufferRef(R"(
   Checks: "check1,check2"
+  SuppressedChecks: "noisycheck1,noisycheck2"
   HeaderFilterRegex: "filter1"
   AnalyzeTemporaryDtors: true
   User: user1
@@ -102,6 +105,7 @@
   llvm::ErrorOr Options2 =
   parseConfiguration(llvm::MemoryBufferRef(R"(
   Checks: "check3,check4"
+  SuppressedChecks: "noisycheck3,noisycheck4"
   HeaderFilterRegex: "filter2"
   AnalyzeTemporaryDtors: false
   User: user2
@@ -113,6 +117,8 @@
   ASSERT_TRUE(!!Options2);
   ClangTidyOptions Options = Options1->merge(*Options2, 0);
   EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
+  EXPECT_EQ("noisycheck1,noisycheck2,noisycheck3,noisycheck4",
+*Options.SuppressedChecks);
   EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
   EXPECT_EQ("user2", *Options.User);
   ASSERT_TRUE(Options.ExtraArgs.hasValue());
Index: clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyDiagnosticConsumerTest.cpp
@@ -24,6 +24,19 @@
   }
 };
 
+// Test that has name == "test-check-noisy" and outputs exactly one diagnostic.
+class NoisyCheck : public ClangTidyCheck {
+public:
+  NoisyCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck("test-check-noisy", Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override {
+Finder->addMatcher(ast_matchers::varDecl().bind("var"), this);
+  }
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override {
+diag("Some diagnostic");
+  }
+};
+
 class HighlightTestCheck : public ClangTidyCheck {
 public:
   HighlightTestCheck(StringRef Name, ClangTidyContext *Context)
@@ -75,6 +88,27 @@
   EXPECT_EQ("variable", Errors[2].Message.Message);
 }
 
+TEST(ClangTidyDiagnosticConsumer, SkipsSuppressedChecks) {
+  std::vector Errors;
+  ClangTidyOptions CustomOptions;
+  CustomOptions.SuppressedChecks = "*noisy*";
+  runCheckOnCode("int a;", &Errors, "input.cc", None,
+CustomOptions);
+  // 4 comming from TestCheck, 0 from NoisyCheck (since it's suppressed).
+  EXPECT_EQ(3ul, Errors.size());
+}
+
+TEST(ClangTidyDiagnosticConsumer, ChecksIfNotSuppressed) {
+  std::vector Errors;
+  ClangTidyOptions CustomOptions;
+  CustomOptions.SuppressedChecks = "*different_glob*";
+  runCheckOnCode("int a;", &Errors, "input.cc", None,
+CustomOptions);
+
+  // 4 comming from TestCheck, 1 from NoisyCheck.
+  EXPECT_EQ(4ul, Errors.size());
+}
+
 TEST(ClangTidyDiagnosticConsumer, HandlesSourceRangeHighlight) {
   std::vector Errors;
   runCheckOnCode("int abc;", &Errors);
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -298,6 +298,7 @@
 
   ClangTidyOptions DefaultOptions;
   DefaultOptions.Checks = DefaultChecks;
+  DefaultOptions.

[PATCH] D116163: [clang-tidy] Add a SuppressedChecks option to ignore diagnostics from specific checks

2021-12-22 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Could you summarize what problem this is solving? There's multiple ways to 
"ignore diagnostics from specific checks", I think it would be confusing to add 
yet another one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116163

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


[PATCH] D116163: [clang-tidy] Add a SuppressedChecks option to ignore diagnostics from specific checks

2021-12-22 Thread Guillermo Rey via Phabricator via cfe-commits
reyg added a comment.

I actually couldn't find a way to black-list specific checks. Is there a way to 
do that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116163

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


[PATCH] D115456: Implement on-demand TLS initialization for Microsoft CXX ABI

2021-12-22 Thread Maurice Heumann via Phabricator via cfe-commits
momo5502 updated this revision to Diff 395856.
momo5502 edited the summary of this revision.
momo5502 added a comment.
Herald added a subscriber: dexonsmith.

A call to `isCompatibleWithMSVC` was added with the proper version that 
introduced the change (1925) and comments describing the intention of the 
change were added.

Additionally, a bug was fixed. Setting the guard variable to true before doing 
the initialization breaks the feature, as the guard needs to be false for 
`__dyn_tls_init` to work.
Not emitting the store to the guard should be fine, as it will be set by 
`__dyn_tls_init` anyways. The behaviour is now identical to the way Microsoft's 
compiler does it.


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

https://reviews.llvm.org/D115456

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/ms-thread_local.cpp

Index: clang/test/CodeGenCXX/ms-thread_local.cpp
===
--- clang/test/CodeGenCXX/ms-thread_local.cpp
+++ clang/test/CodeGenCXX/ms-thread_local.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 %s -std=c++1y -triple=i686-pc-win32 -emit-llvm -o - | FileCheck %s
-// RUN: %clang_cc1 %s  -std=c++1y -triple=i686-pc-win32 -ftls-model=local-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LD
+// RUN: %clang_cc1 %s -std=c++1y -triple=i686-pc-win32 -fms-compatibility-version=1925 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++1y -triple=i686-pc-win32 -fms-compatibility-version=1925 -ftls-model=local-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LD
 
 struct A {
   A();
@@ -17,10 +17,20 @@
 
 // CHECK-DAG: @"?b@@3UA@@A" = dso_local thread_local global %struct.A zeroinitializer, align 1
 // CHECK-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+// CHECK-DAG: @__tls_guard = external dso_local thread_local global i8
 // CHECK-LD-DAG: @"?b@@3UA@@A" = dso_local thread_local(localdynamic) global %struct.A zeroinitializer, align 1
 // CHECK-LD-DAG: @"__tls_init$initializer$" = internal constant void ()* @__tls_init, section ".CRT$XDU"
+// CHECK-LD-DAG: @__tls_guard = external dso_local thread_local global i8
 thread_local A b;
 
+// CHECK-LABEL: declare dso_local void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: declare dso_local void @__dyn_tls_on_demand_init()
+
+// CHECK-LABEL: define dso_local void @"?f@@YA?AUA@@XZ"(%struct.A* noalias sret(%struct.A) align 1 %agg.result)
+// CHECK: call void @__dyn_tls_on_demand_init()
+// CHECK-LD-LABEL: define dso_local void @"?f@@YA?AUA@@XZ"(%struct.A* noalias sret(%struct.A) align 1 %agg.result)
+// CHECK-LD: call void @__dyn_tls_on_demand_init()
+
 // CHECK-LABEL: define internal void @__tls_init()
 // CHECK: call void @"??__Eb@@YAXXZ"
 // CHECK-LD-LABEL: define internal void @__tls_init()
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -401,7 +401,7 @@
   ArrayRef CXXThreadLocalInitVars) override;
 
   bool usesThreadWrapperFunction(const VarDecl *VD) const override {
-return false;
+return true;
   }
   LValue EmitThreadLocalVarDeclLValue(CodeGenFunction &CGF, const VarDecl *VD,
   QualType LValType) override;
@@ -2397,11 +2397,99 @@
   }
 }
 
+static llvm::GlobalValue *getTlsGuardVar(CodeGenModule &CGM) {
+  // __tls_guard comes from the MSVC runtime and reflects
+  // whether TLS has been initialized for a particular thread.
+  // It is set from within __dyn_tls_init by the runtime.
+  // Every library and executable has its own variable.
+  llvm::Type *VTy = llvm::Type::getInt8Ty(CGM.getLLVMContext());
+  llvm::Constant *TlsGuardConstant =
+  CGM.CreateRuntimeVariable(VTy, "__tls_guard");
+  llvm::GlobalValue *TlsGuard = cast(TlsGuardConstant);
+
+  TlsGuard->setThreadLocal(true);
+
+  return TlsGuard;
+}
+
+static llvm::FunctionCallee getDynTlsOnDemandInitFn(CodeGenModule &CGM) {
+  // __dyn_tls_on_demand_init comes from the MSVC runtime and triggers
+  // dynamic TLS initialization by calling __dyn_tls_init internally.
+  llvm::FunctionType *FTy =
+  llvm::FunctionType::get(llvm::Type::getVoidTy(CGM.getLLVMContext()), {},
+  /*isVarArg=*/false);
+  return CGM.CreateRuntimeFunction(
+  FTy, "__dyn_tls_on_demand_init",
+  llvm::AttributeList::get(CGM.getLLVMContext(),
+   llvm::AttributeList::FunctionIndex,
+   llvm::Attribute::NoUnwind),
+  /*Local=*/true);
+}
+
+static void emitTlsGuardCheck(CodeGenFunction &CGF, llvm::GlobalValue *TlsGuard,
+  llvm::BasicBlock *DynInitBB,
+  llvm::BasicBlock *ContinueBB) {
+  llvm::LoadInst *TlsGuardValue =
+  CGF.Builder.CreateLoad(Address(TlsGuar

[PATCH] D116147: [clangd] Respect .clang-tidy ExtraArgs (-Wfoo only) when producing diagnostics

2021-12-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 395858.
sammccall added a comment.

Also handle -Wno- flags


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116147

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp

Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -517,6 +517,80 @@
   DiagSeverity(DiagnosticsEngine::Error);
 }
 
+TidyProvider addClangArgs(std::vector ExtraArgs) {
+  return [ExtraArgs = std::move(ExtraArgs)](tidy::ClangTidyOptions &Opts,
+llvm::StringRef) {
+if (!Opts.ExtraArgs)
+  Opts.ExtraArgs.emplace();
+for (llvm::StringRef Arg : ExtraArgs)
+  Opts.ExtraArgs->emplace_back(Arg);
+  };
+}
+
+TEST(DiagnosticTest, ClangTidyEnablesClangWarning) {
+  Annotations Main(R"cpp( // error-ok
+static void [[foo]]() {}
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  // This is always emitted as a clang warning, not a clang-tidy diagnostic.
+  auto UnusedFooWarning =
+  AllOf(Diag(Main.range(), "unused function 'foo'"),
+DiagName("-Wunused-function"), DiagSource(Diag::Clang),
+DiagSeverity(DiagnosticsEngine::Warning));
+
+  // Check the -Wunused warning isn't initially on.
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+
+  // We enable warnings based on clang-tidy extra args.
+  TU.ClangTidyProvider = addClangArgs({"-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), ElementsAre(UnusedFooWarning));
+
+  // But we don't respect other args.
+  TU.ClangTidyProvider = addClangArgs({"-Wunused", "-Dfoo=bar"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), ElementsAre(UnusedFooWarning))
+  << "Not unused function 'bar'!";
+
+  // -Werror doesn't apply to warnings enabled by clang-tidy extra args.
+  TU.ExtraArgs = {"-Werror"};
+  TU.ClangTidyProvider = addClangArgs({"-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ElementsAre(DiagSeverity(DiagnosticsEngine::Warning)));
+
+  // But clang-tidy extra args won't *downgrade* errors to warnings either.
+  TU.ExtraArgs = {"-Wunused", "-Werror"};
+  TU.ClangTidyProvider = addClangArgs({"-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ElementsAre(DiagSeverity(DiagnosticsEngine::Error)));
+
+  // FIXME: we're erroneously downgrading the whole group, this should be Error.
+  TU.ExtraArgs = {"-Wunused-function", "-Werror"};
+  TU.ClangTidyProvider = addClangArgs({"-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(),
+  ElementsAre(DiagSeverity(DiagnosticsEngine::Warning)));
+
+  // This looks silly, but it's the typical result if a warning is enabled by a
+  // high-level .clang-tidy file and disabled by a low-level one.
+  TU.ExtraArgs = {};
+  TU.ClangTidyProvider = addClangArgs({"-Wunused", "-Wno-unused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+
+  // Overriding only works in the proper order.
+  TU.ClangTidyProvider = addClangArgs({"-Wno-unused", "-Wunused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), SizeIs(1));
+
+  // More specific vs less-specific: match clang behavior
+  TU.ClangTidyProvider = addClangArgs({"-Wunused", "-Wno-unused-function"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+  TU.ClangTidyProvider = addClangArgs({"-Wunused-function", "-Wno-unused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+
+  // We do allow clang-tidy config to disable warnings from the compile command.
+  // It's unclear this is ideal, but it's hard to avoid.
+  TU.ExtraArgs = {"-Wunused"};
+  TU.ClangTidyProvider = addClangArgs({"-Wno-unused"});
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+}
+
 TEST(DiagnosticTest, LongFixMessages) {
   // We limit the size of printed code.
   Annotations Source(R"cpp(
Index: clang-tools-extra/clangd/ParsedAST.cpp
===
--- clang-tools-extra/clangd/ParsedAST.cpp
+++ clang-tools-extra/clangd/ParsedAST.cpp
@@ -246,6 +246,49 @@
   std::vector MainFileTokens;
 };
 
+// Find -W and -Wno- options in ExtraArgs and apply them to Diags.
+//
+// This is used to handle ExtraArgs in clang-tidy configuration.
+// We don't use clang's standard handling of this as we want slightly different
+// behavior (e.g. we want to exclude these from -Wno-error).
+void applyWarningOptions(llvm::ArrayRef ExtraArgs,
+ DiagnosticsEngine &Diags) {
+  for (llvm::StringRef Group : ExtraArgs) {
+// Only handle args that are of the form -W[no-].
+// Other flags are possible but rare and deliberately out of scope.
+llvm::SmallVector Members;
+if (!Group.consume_front("-W") || Group.

[PATCH] D116163: [clang-tidy] Add a SuppressedChecks option to ignore diagnostics from specific checks

2021-12-22 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

In D116163#3206473 , @reyg wrote:

> I actually couldn't find a way to black-list specific checks. Is there a way 
> to do that?

Just prepend a dash to the check name that you want to disable:

`checks=cppcoreguidelines-*,-cppcoreguidelines-pro-type-pointer-arithmetic`

This will enable all checks from `cppcoreguidelines` except 
`cppcoreguidelines-pro-type-pointer-arithmetic`.

Normally you do this with pretty formatting in the `.clang-tidy` file:

  Checks: > 
  cppcoreguidelines*,
  -cppcoreguidelines-pro-type-pointer-arithmetic,
  -cppcoreguidelines-avoid-c-arrays,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116163

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


[PATCH] D116163: [clang-tidy] Add a SuppressedChecks option to ignore diagnostics from specific checks

2021-12-22 Thread Guillermo Rey via Phabricator via cfe-commits
reyg abandoned this revision.
reyg added a comment.

Well now I feel stupid for not realizing that, thanks for pointing it out :)

At least I learned how to hack around in clang-tidy 😄


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116163

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


[clang] 5eb2718 - [clang][OpenMP][DebugInfo] Debug support for variables in shared clause of OpenMP task construct

2021-12-22 Thread Alok Kumar Sharma via cfe-commits

Author: Alok Kumar Sharma
Date: 2021-12-22T20:04:21+05:30
New Revision: 5eb271880c8fc59835797806ac44f736eaf3ddbd

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

LOG: [clang][OpenMP][DebugInfo] Debug support for variables in shared clause of 
OpenMP task construct

Currently variables appearing inside shared clause of OpenMP task construct
are not visible inside lldb debugger.

After the current patch, lldb is able to show the variable

```
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
frame #0: 0x00400934 a.out`.omp_task_entry. [inlined] 
.omp_outlined.(.global_tid.=0, .part_id.=0x0071f0d0, 
.privates.=0x0071f0e8, .copy_fn.=(a.out`.omp_task_privates_map. at 
testshared.cxx:8), .task_t.=0x0071f0c0, __context=0x0071f0f0) 
at testshared.cxx:10:34
   7  else {
   8#pragma omp task shared(svar) firstprivate(n)
   9{
-> 10 printf("Task svar = %d\n", svar);
   11 printf("Task n = %d\n", n);
   12 svar = fib(n - 1);
   13   }
(lldb) p svar
(int) $0 = 9
```

Reviewed By: djtodoro

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

Added: 
clang/test/OpenMP/debug_task_shared.c

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

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 2509de486671a..5677fce355d55 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -24,10 +24,13 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/PrettyStackTrace.h"
+#include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/Instructions.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/Support/AtomicOrdering.h"
 using namespace clang;
 using namespace CodeGen;
@@ -4431,6 +4434,53 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
 UntiedLocalVars;
 // Set proper addresses for generated private copies.
 OMPPrivateScope Scope(CGF);
+// Generate debug info for variables present in shared clause.
+if (auto *DI = CGF.getDebugInfo()) {
+  llvm::SmallDenseMap CaptureFields =
+  CGF.CapturedStmtInfo->getCaptureFields();
+  llvm::Value *ContextValue = CGF.CapturedStmtInfo->getContextValue();
+  if (CaptureFields.size() && ContextValue) {
+unsigned CharWidth = CGF.getContext().getCharWidth();
+// The shared variables are packed together as members of structure.
+// So the address of each shared variable can be computed by adding
+// offset of it (within record) to the base address of record. For each
+// shared variable, debug intrinsic llvm.dbg.declare is generated with
+// appropriate expressions (DIExpression).
+// Ex:
+//  %12 = load %struct.anon*, %struct.anon** %__context.addr.i
+//  call void @llvm.dbg.declare(metadata %struct.anon* %12,
+//metadata !svar1,
+//metadata !DIExpression(DW_OP_deref))
+//  call void @llvm.dbg.declare(metadata %struct.anon* %12,
+//metadata !svar2,
+//metadata !DIExpression(DW_OP_plus_uconst, 8, 
DW_OP_deref))
+for (auto It = CaptureFields.begin(); It != CaptureFields.end(); ++It) 
{
+  const VarDecl *SharedVar = It->first;
+  RecordDecl *CaptureRecord = It->second->getParent();
+  const ASTRecordLayout &Layout =
+  CGF.getContext().getASTRecordLayout(CaptureRecord);
+  unsigned Offset =
+  Layout.getFieldOffset(It->second->getFieldIndex()) / CharWidth;
+  (void)DI->EmitDeclareOfAutoVariable(SharedVar, ContextValue,
+  CGF.Builder, false);
+  llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back();
+  // Get the call dbg.declare instruction we just created and update
+  // its DIExpression to add offset to base address.
+  if (auto DDI = dyn_cast(&Last)) {
+SmallVector Ops;
+// Add offset to the base address if non zero.
+if (Offset) {
+  Ops.push_back(llvm::dwarf::DW_OP_plus_uconst);
+  Ops.push_back(Offset);
+}
+Ops.push_back(llvm::dwarf::DW_OP_deref);
+auto &Ctx = DDI->getContext();
+llvm::DIExpression *DIExpr = llvm::DIExpression::get(Ctx, Ops);
+Last.setOperand(2, llvm::MetadataAsValue::get(Ctx, DIExpr));
+  }
+}
+  }
+}
 llvm::SmallVector

[PATCH] D115510: [clang][OpenMP][DebugInfo] Debug support for variables in shared clause of OpenMP task construct

2021-12-22 Thread Alok Kumar Sharma via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5eb271880c8f: [clang][OpenMP][DebugInfo] Debug support for 
variables in shared clause of… (authored by alok).

Changed prior to commit:
  https://reviews.llvm.org/D115510?vs=393447&id=395860#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115510

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/debug_task_shared.c

Index: clang/test/OpenMP/debug_task_shared.c
===
--- /dev/null
+++ clang/test/OpenMP/debug_task_shared.c
@@ -0,0 +1,55 @@
+// This testcase checks emission of debug info for variables
+// inside shared clause of task construct.
+
+// REQUIRES: x86_64-linux
+
+// RUN: %clang_cc1 -debug-info-kind=constructor -DSHARED -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
+// RUN: %clang_cc1 -debug-info-kind=constructor -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
+// expected-no-diagnostics
+
+// CHECK-LABEL: define internal i32 @.omp_task_entry.
+
+// CHECK-DAG:  [[CONTEXT:%[0-9]+]] = load %struct.anon*, %struct.anon** %__context.addr.i, align 8
+// CHECK-DAG:  call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE2:![0-9]+]], metadata !DIExpression(DW_OP_deref))
+// CHECK-DAG:  call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE3:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref))
+// CHECK-DAG:  call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata [[SHARE1:![0-9]+]], metadata !DIExpression(DW_OP_plus_uconst, 16, DW_OP_deref))
+
+// CHECK-DAG: [[SHARE2]] = !DILocalVariable(name: "share2"
+// CHECK-DAG: [[SHARE3]] = !DILocalVariable(name: "share3"
+// CHECK-DAG: [[SHARE1]] = !DILocalVariable(name: "share1"
+
+// NEG-LABEL: define internal i32 @.omp_task_entry.
+// NEG:  [[CONTEXT:%[0-9]+]] = load %struct.anon*, %struct.anon** %__context.addr.i, align 8
+// NEG-NOT: call void @llvm.dbg.declare(metadata %struct.anon* [[CONTEXT]], metadata {{![0-9]+}}, metadata !DIExpression(DW_OP_deref))
+
+extern int printf(const char *, ...);
+
+int foo(int n) {
+  int share1 = 9, share2 = 11, share3 = 13, priv1, priv2, fpriv;
+  fpriv = n + 4;
+
+  if (n < 2)
+return n;
+  else {
+#if SHARED
+#pragma omp task shared(share1, share2) private(priv1, priv2) firstprivate(fpriv) shared(share3)
+#else
+#pragma omp task private(priv1, priv2) firstprivate(fpriv)
+#endif
+{
+  priv1 = n;
+  priv2 = n + 2;
+  share2 += share3;
+  printf("share1 = %d, share2 = %d, share3 = %d\n", share1, share2, share3);
+  share1 = priv1 + priv2 + fpriv + foo(n - 1) + share2 + share3;
+}
+#pragma omp taskwait
+return share1 + share2 + share3;
+  }
+}
+
+int main() {
+  int n = 10;
+  printf("foo(%d) = %d\n", n, foo(n));
+  return 0;
+}
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -459,6 +459,11 @@
 /// Get the name of the capture helper.
 virtual StringRef getHelperName() const { return "__captured_stmt"; }
 
+/// Get the CaptureFields
+llvm::SmallDenseMap getCaptureFields() {
+  return CaptureFields;
+}
+
   private:
 /// The kind of captured statement being generated.
 CapturedRegionKind Kind;
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -24,10 +24,13 @@
 #include "clang/AST/StmtVisitor.h"
 #include "clang/Basic/OpenMPKinds.h"
 #include "clang/Basic/PrettyStackTrace.h"
+#include "llvm/BinaryFormat/Dwarf.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/Constants.h"
+#include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/Instructions.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/Support/AtomicOrdering.h"
 using namespace clang;
 using namespace CodeGen;
@@ -4431,6 +4434,53 @@
 UntiedLocalVars;
 // Set proper addresses for generated private copies.
 OMPPrivateScope Scope(CGF);
+// Generate debug info for variables present in shared clause.
+if (auto *DI = CGF.getDebugInfo()) {
+  llvm::SmallDenseMap CaptureFields =
+  CGF.CapturedStmtInfo->getCaptureFields();
+  llvm::Value *ContextValue = CGF.CapturedStmtInfo->getContextValue();
+  if (CaptureFields.size() && ContextValue) {
+unsigned CharWidth = CGF.getContext().getCharWidth();
+// The shared variables are packed together as members of structure.
+// So the address of each shared variable can be comp

[PATCH] D115694: [ARM] Introduce an empty "armv8.8-a" architecture.

2021-12-22 Thread Momchil Velikov via Phabricator via cfe-commits
chill added inline comments.



Comment at: llvm/include/llvm/Support/ARMTargetParser.def:125
   ARM::AEK_DOTPROD| ARM::AEK_BF16 | ARM::AEK_I8MM))
+ARM_ARCH("armv8.8-a", ARMV8_8A, "8.8-A", "v8.8a",
+ ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,

... here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115694

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


[PATCH] D115510: [clang][OpenMP][DebugInfo] Debug support for variables in shared clause of OpenMP task construct

2021-12-22 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok marked an inline comment as done.
alok added a comment.

Thanks @djtodoro .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115510

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


[PATCH] D116160: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2021-12-22 Thread Momchil Velikov via Phabricator via cfe-commits
chill added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:666
 
+  HasMOPS |= ArchKind == llvm::AArch64::ArchKind::ARMV8_8A ||
+ ArchKind == llvm::AArch64::ArchKind::ARMV9_3A;

So, this is enabled by default (as in "is mandatory part") of 8.8-a and 9.3-a? 
Why don't we handle it like other extensions in `AArch64TargetParser.def`  like 
https://reviews.llvm.org/D115694#inline-1110596 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116160

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


[PATCH] D115604: [Support] Expand `<@>` as the base directory in response files.

2021-12-22 Thread Jack Andersen via Phabricator via cfe-commits
jackoalan added a comment.

bump, review requested


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115604

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


[PATCH] D116163: [clang-tidy] Add a SuppressedChecks option to ignore diagnostics from specific checks

2021-12-22 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

No worries, it's indeed good practice! Feel free to take a look at the docs, 
where this (and many more features) is described :) 
https://clang.llvm.org/extra/clang-tidy/

> will disable all default checks (-*) and enable all clang-analyzer-* checks 
> except for clang-analyzer-cplusplus* ones.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116163

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


[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

2021-12-22 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 395863.
junaire added a comment.

Update the existing place that can use emitUnaryBuiltin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116161

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
 }
 
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+   unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
 const CallExpr *E,
@@ -3130,6 +3136,7 @@
 else
   Result = Builder.CreateUnaryIntrinsic(llvm::Intrinsic::fabs, Op0, 
nullptr,
 "elt.abs");
+
 return RValue::get(Result);
   }
 
@@ -3185,11 +3192,11 @@
   }
   return llvm::Intrinsic::vector_reduce_fmax;
 };
-Value *Op0 = EmitScalarExpr(E->getArg(0));
-Value *Result = Builder.CreateUnaryIntrinsic(
-GetIntrinsicID(E->getArg(0)->getType(), Op0->getType()), Op0, nullptr,
-"rdx.min");
-return RValue::get(Result);
+return RValue::get(emitUnaryBuiltin(
+*this, E,
+GetIntrinsicID(E->getArg(0)->getType(),
+   EmitScalarExpr(E->getArg(0))->getType()),
+"rdx.min"));
   }
 
   case Builtin::BI__builtin_reduce_min: {


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
 }
 
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+   unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
 const CallExpr *E,
@@ -3130,6 +3136,7 @@
 else
   Result = Builder.CreateUnaryIntrinsic(llvm::Intrinsic::fabs, Op0, nullptr,
 "elt.abs");
+
 return RValue::get(Result);
   }
 
@@ -3185,11 +3192,11 @@
   }
   return llvm::Intrinsic::vector_reduce_fmax;
 };
-Value *Op0 = EmitScalarExpr(E->getArg(0));
-Value *Result = Builder.CreateUnaryIntrinsic(
-GetIntrinsicID(E->getArg(0)->getType(), Op0->getType()), Op0, nullptr,
-"rdx.min");
-return RValue::get(Result);
+return RValue::get(emitUnaryBuiltin(
+*this, E,
+GetIntrinsicID(E->getArg(0)->getType(),
+   EmitScalarExpr(E->getArg(0))->getType()),
+"rdx.min"));
   }
 
   case Builtin::BI__builtin_reduce_min: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116161: [Clang] Add an overload for emitUnaryBuiltin.

2021-12-22 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 395864.
junaire added a comment.

Update the existing place that can use emitUnaryBuiltin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116161

Files:
  clang/lib/CodeGen/CGBuiltin.cpp


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
 }
 
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+   unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
 const CallExpr *E,
@@ -3185,11 +3191,11 @@
   }
   return llvm::Intrinsic::vector_reduce_fmax;
 };
-Value *Op0 = EmitScalarExpr(E->getArg(0));
-Value *Result = Builder.CreateUnaryIntrinsic(
-GetIntrinsicID(E->getArg(0)->getType(), Op0->getType()), Op0, nullptr,
-"rdx.min");
-return RValue::get(Result);
+return RValue::get(emitUnaryBuiltin(
+*this, E,
+GetIntrinsicID(E->getArg(0)->getType(),
+   EmitScalarExpr(E->getArg(0))->getType()),
+"rdx.min"));
   }
 
   case Builtin::BI__builtin_reduce_min: {
@@ -3204,11 +3210,11 @@
   }
   return llvm::Intrinsic::vector_reduce_fmin;
 };
-Value *Op0 = EmitScalarExpr(E->getArg(0));
-Value *Result = Builder.CreateUnaryIntrinsic(
-GetIntrinsicID(E->getArg(0)->getType(), Op0->getType()), Op0, nullptr,
-"rdx.min");
-return RValue::get(Result);
+return RValue::get(emitUnaryBuiltin(
+*this, E,
+GetIntrinsicID(E->getArg(0)->getType(),
+   EmitScalarExpr(E->getArg(0))->getType()),
+"rdx.min"));
   }
 
   case Builtin::BI__builtin_reduce_xor: {


Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -541,6 +541,12 @@
   return CGF.Builder.CreateCall(F, Src0);
 }
 
+static Value *emitUnaryBuiltin(CodeGenFunction &CGF, const CallExpr *E,
+   unsigned IntrinsicID, llvm::StringRef Name) {
+  llvm::Value *Src0 = CGF.EmitScalarExpr(E->getArg(0));
+  return CGF.Builder.CreateUnaryIntrinsic(IntrinsicID, Src0, nullptr, Name);
+}
+
 // Emit an intrinsic that has 2 operands of the same type as its result.
 static Value *emitBinaryBuiltin(CodeGenFunction &CGF,
 const CallExpr *E,
@@ -3185,11 +3191,11 @@
   }
   return llvm::Intrinsic::vector_reduce_fmax;
 };
-Value *Op0 = EmitScalarExpr(E->getArg(0));
-Value *Result = Builder.CreateUnaryIntrinsic(
-GetIntrinsicID(E->getArg(0)->getType(), Op0->getType()), Op0, nullptr,
-"rdx.min");
-return RValue::get(Result);
+return RValue::get(emitUnaryBuiltin(
+*this, E,
+GetIntrinsicID(E->getArg(0)->getType(),
+   EmitScalarExpr(E->getArg(0))->getType()),
+"rdx.min"));
   }
 
   case Builtin::BI__builtin_reduce_min: {
@@ -3204,11 +3210,11 @@
   }
   return llvm::Intrinsic::vector_reduce_fmin;
 };
-Value *Op0 = EmitScalarExpr(E->getArg(0));
-Value *Result = Builder.CreateUnaryIntrinsic(
-GetIntrinsicID(E->getArg(0)->getType(), Op0->getType()), Op0, nullptr,
-"rdx.min");
-return RValue::get(Result);
+return RValue::get(emitUnaryBuiltin(
+*this, E,
+GetIntrinsicID(E->getArg(0)->getType(),
+   EmitScalarExpr(E->getArg(0))->getType()),
+"rdx.min"));
   }
 
   case Builtin::BI__builtin_reduce_xor: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-22 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

I have confirmed that this problem is not due to this patch.
Besides, on Mac, both m1 and intel, the on-demand-parsing as well as loading an 
AST file generated via driver argument `-emit-ast` will also trigger this 
problem.
However, when loading an AST file generated via cc1 argument `-emit-pch`, the 
problem is not triggered.

---

See the example below, which is executed on an intel Mac laptop with clang 
13.0.0.

/tmp/test/test.c:

  void f();
  void g() { f(); }

/tmp/test/importee.c:

  void f() { }

/tmp/test/odp/externalDefMap.txt:

  c:@F@f /tmp/test/importee.c

/tmp/test/odp/invocations.yaml:

  "/tmp/test/importee.c": ["gcc", "-c", "/tmp/test/importee.c"]

/tmp/test/ast/externalDefMap.txt:

  c:@F@f /tmp/test/ast/importee.c.ast

When executing the analyzer with CTU analysis via on-demand-parsing:

  /tmp/test$ clang -cc1 -analyze -analyzer-checker=core -analyzer-config 
experimental-enable-naive-ctu-analysis=true,ctu-dir=odp,ctu-invocation-list=invocations.yaml
 test.c

Or loading AST file generated via driver argument `-emit-ast`:

  /tmp/test$ clang -emit-ast importee.c -o ast/importee.c.ast
  /tmp/test$ clang -cc1 -analyze -analyzer-checker=core -analyzer-config 
experimental-enable-naive-ctu-analysis=true,ctu-dir=ast test.c

The same diagnostic message is generated, though the triples are different from 
the ones for m1.

  warning: imported AST from '/tmp/test/importee.c' had been generated for a 
different target, current: x86_64-apple-darwin21.2.0, imported: 
x86_64-apple-macosx12.0.0 [-Wctu]



---

However, the problem will not be triggered if triple is given:
(On demand parsing: setting the triple of the entry file to the one of imported 
ASTUnit)

  /tmp/test$ clang -cc1 -analyze -analyzer-checker=core -analyzer-config 
experimental-enable-naive-ctu-analysis=true,ctu-dir=odp,ctu-invocation-list=invocations.yaml
 test.c -triple x86_64-apple-macosx12.0.0

(AST)

  /tmp/test$ clang -target arm-apple-macosx -emit-ast importee.c -o 
ast/importee.c.ast
  /tmp/test$ clang -cc1 -analyze -analyzer-checker=core -analyzer-config 
experimental-enable-naive-ctu-analysis=true,ctu-dir=ast test.c -triple 
arm-apple-macosx

Or the AST file is generated via cc1 argument `-emit-pch`:

  /tmp/test$ clang -cc1 -emit-pch importee.c -o ast/importee.c.ast
  /tmp/test$ clang -cc1 -analyze -analyzer-checker=core -analyzer-config 
experimental-enable-naive-ctu-analysis=true,ctu-dir=ast test.c

I think we can bypass the problem temporarily by loading the AST file generated 
by cc1 argument `-emit-pch`, just as shown in the last code snippet above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102669

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


[clang-tools-extra] fd8fc5e - [clang-tidy] abseil-string-find-startswith: detect `s.rfind(z, 0) == 0`

2021-12-22 Thread Dmitri Gribenko via cfe-commits

Author: Ivan Gerasimov
Date: 2021-12-22T16:45:51+01:00
New Revision: fd8fc5e8d93849f4a2c8dea087690b1a0e6ea7df

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

LOG: [clang-tidy] abseil-string-find-startswith: detect `s.rfind(z, 0) == 0`

Suggest converting `std::string::rfind()` calls to `absl::StartsWith()`
where possible.

Added: 


Modified: 
clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-startswith.rst
clang-tools-extra/test/clang-tidy/checkers/abseil-string-find-startswith.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp 
b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
index 5741c0d505d51..e834c8a124590 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -40,7 +40,7 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder 
*Finder) {
 
   auto StringFind = cxxMemberCallExpr(
   // .find()-call on a string...
-  callee(cxxMethodDecl(hasName("find"))),
+  callee(cxxMethodDecl(hasName("find")).bind("findfun")),
   on(hasType(StringType)),
   // ... with some search expression ...
   hasArgument(0, expr().bind("needle")),
@@ -55,6 +55,25 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder 
*Finder) {
   ignoringParenImpCasts(StringFind.bind("findexpr"
   .bind("expr"),
   this);
+
+  auto StringRFind = cxxMemberCallExpr(
+  // .rfind()-call on a string...
+  callee(cxxMethodDecl(hasName("rfind")).bind("findfun")),
+  on(hasType(StringType)),
+  // ... with some search expression ...
+  hasArgument(0, expr().bind("needle")),
+  // ... and "0" as second argument.
+  hasArgument(1, ZeroLiteral));
+
+  Finder->addMatcher(
+  // Match [=!]= with either a zero or npos on one side and a string.rfind
+  // on the other.
+  binaryOperator(
+  hasAnyOperatorName("==", "!="),
+  hasOperands(ignoringParenImpCasts(ZeroLiteral),
+  ignoringParenImpCasts(StringRFind.bind("findexpr"
+  .bind("expr"),
+  this);
 }
 
 void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
@@ -69,6 +88,11 @@ void StringFindStartswithCheck::check(const 
MatchFinder::MatchResult &Result) {
   const Expr *Haystack = Result.Nodes.getNodeAs("findexpr")
  ->getImplicitObjectArgument();
   assert(Haystack != nullptr);
+  const CXXMethodDecl *FindFun =
+  Result.Nodes.getNodeAs("findfun");
+  assert(FindFun != nullptr);
+
+  bool Rev = FindFun->getName().contains("rfind");
 
   if (ComparisonExpr->getBeginLoc().isMacroID())
 return;
@@ -86,10 +110,11 @@ void StringFindStartswithCheck::check(const 
MatchFinder::MatchResult &Result) {
   bool Neg = ComparisonExpr->getOpcode() == BO_NE;
 
   // Create the warning message and a FixIt hint replacing the original expr.
-  auto Diagnostic = diag(ComparisonExpr->getBeginLoc(),
- "use %select{absl::StartsWith|!absl::StartsWith}0 "
- "instead of find() %select{==|!=}0 0")
-<< Neg;
+  auto Diagnostic =
+  diag(ComparisonExpr->getBeginLoc(),
+   "use %select{absl::StartsWith|!absl::StartsWith}0 "
+   "instead of %select{find()|rfind()}1 %select{==|!=}0 0")
+  << Neg << Rev;
 
   Diagnostic << FixItHint::CreateReplacement(
   ComparisonExpr->getSourceRange(),

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-startswith.rst 
b/clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-startswith.rst
index 43f35ac66c8ac..8224c37a087b8 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-startswith.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/abseil-string-find-startswith.rst
@@ -3,14 +3,15 @@
 abseil-string-find-startswith
 =
 
-Checks whether a ``std::string::find()`` result is compared with 0, and
-suggests replacing with ``absl::StartsWith()``. This is both a readability and
-performance issue.
+Checks whether a ``std::string::find()`` or ``std::string::rfind()`` result is
+compared with 0, and suggests replacing with ``absl::StartsWith()``. This is
+both a readability and performance issue.
 
 .. code-block:: c++
 
   string s = "...";
   if (s.find("Hello World") == 0) { /* do something */ }
+  if (s.rfind("Hello World", 0) == 0) { /* do something */ }
 
 becomes
 
@@ -19,6 +20,7 @@ becomes
 
   string s = "...";
   if (absl::StartsWith(s, "Hello World")) { /* do something */ }
+  if (absl::StartsWith(s, "Hello World")) { /*

[clang] da007a3 - [JSONNodeDumper] Regenerate test checks (NFC)

2021-12-22 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-12-22T16:56:52+01:00
New Revision: da007a33c95a37c1331a14bc4f377982598fe68a

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

LOG: [JSONNodeDumper] Regenerate test checks (NFC)

gen_ast_dump_json_test.py adds these lines of whitespace. Precommit
it to avoid spurious diffs in future changes.

Added: 


Modified: 
clang/test/AST/ast-dump-decl-json.c
clang/test/AST/ast-dump-decl-json.m
clang/test/AST/ast-dump-expr-json.c
clang/test/AST/ast-dump-expr-json.cpp
clang/test/AST/ast-dump-expr-json.m
clang/test/AST/ast-dump-file-line-json.c
clang/test/AST/ast-dump-funcs-json.cpp
clang/test/AST/ast-dump-stmt-json.c
clang/test/AST/ast-dump-stmt-json.cpp
clang/test/AST/ast-dump-stmt-json.m
clang/test/AST/ast-dump-template-decls-json.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-decl-json.c 
b/clang/test/AST/ast-dump-decl-json.c
index 9264590d67b89..7bc37a76b8003 100644
--- a/clang/test/AST/ast-dump-decl-json.c
+++ b/clang/test/AST/ast-dump-decl-json.c
@@ -91,6 +91,7 @@ void testParmVarDecl(int TestParmVarDecl);
 
 // NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "TypedefDecl",
 // CHECK-NEXT:  "loc": {
@@ -137,6 +138,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "VarDecl",
 // CHECK-NEXT:  "loc": {
@@ -165,6 +167,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  }
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "VarDecl",
 // CHECK-NEXT:  "loc": {
@@ -195,6 +198,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  }
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -250,6 +254,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -360,6 +365,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "LabelDecl",
 // CHECK-NEXT:  "loc": {
@@ -385,6 +391,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  "name": "TestLabelDecl"
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "TypedefDecl",
 // CHECK-NEXT:  "loc": {
@@ -421,6 +428,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "EnumDecl",
 // CHECK-NEXT:  "loc": {
@@ -474,6 +482,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -583,6 +592,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "EnumDecl",
 // CHECK-NEXT:  "loc": {
@@ -607,6 +617,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  "name": "TestEnumDeclForward"
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -662,6 +673,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -689,6 +701,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  "completeDefinition": true
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -771,6 +784,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -851,6 +865,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -876,6 +891,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  "tagUsed": "struct"
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "EnumConstantDecl",
 // CHECK-NEXT:  "loc": {
@@ -903,6 +919,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  }
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "EnumConstantDecl",
 // CHECK-NEXT:  "loc": {
@@ -976,6 +993,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CHECK:  "kind": "RecordDecl",
 // CHECK-NEXT:  "loc": {
@@ -1108,6 +1126,7 @@ void testParmVarDecl(int TestParmVarDecl);
 // CHECK-NEXT:  ]
 // CHECK-NEXT: }
 
+
 // CHECK-NOT: {{^}}Dumping
 // CH

[PATCH] D116167: [clangd] Adjust compile flags so they work when applied to other file(type)s.

2021-12-22 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

It's reasonable to want to use the command from one file to compile another.
In particular, the command from a translation unit to parse a related header:

  {"file": "foo.h", "command": "clang foo.cpp"}

This is largely what InterpolatingCompilationDatabase tries to do.
To do this correctly can require nontrivial changes to the argv, because the
file extension affects semantics.  e.g. here we must add "-x c++header".

When external tools compile commands for different files, we should apply the
same adjustments. This is better than telling people to "fix their tools":

- simple e.g. python scripts shouldn't have to interpret clang argv
- this is a good way to represent the intent "parse header X in the context of 
file Y", which can work even if X is not self-contained. clangd does not 
support this today, but some other tools do, and we may one day.

This issue is discussed in https://github.com/clangd/clangd/issues/519


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116167

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp


Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -53,6 +53,18 @@
"foo.cc"));
 }
 
+TEST(CommandMangler, FilenameMismatch) {
+  auto Mangler = CommandMangler::forTests();
+  Mangler.ClangPath = testPath("clang");
+  // Our compile flags refer to foo.cc...
+  std::vector Cmd = {"clang", "foo.cc"};
+  // but we're applying it to foo.h...
+  Mangler.adjust(Cmd, "foo.h");
+  // so transferCompileCommand should add -x c++-header to preserve semantics.
+  EXPECT_THAT(
+  Cmd, ElementsAre(testPath("clang"), "-x", "c++-header", "--", "foo.h"));
+}
+
 TEST(CommandMangler, ResourceDir) {
   auto Mangler = CommandMangler::forTests();
   Mangler.ResourceDir = testPath("fake/resources");
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -241,16 +241,38 @@
   if (ArchOptCount < 2)
 IndicesToDrop.clear();
 
+  // In some cases people may try to reuse the command from another file, e.g.
+  //   { File: "foo.h", CommandLine: "clang foo.cpp" }.
+  // We assume the intent is to parse foo.h the same way as foo.cpp, or as if
+  // it were being included from foo.cpp.
+  //
+  // We're going to rewrite the command to refer to foo.h, and this may change
+  // its semantics (e.g. by parsing the file as C). If we do this, we should
+  // use transferCompileCommand to adjust the argv.
+  // In practice only the extension of the file matters, so do this only when
+  // it differs.
+  llvm::StringRef FileExtension = llvm::sys::path::extension(File);
+  llvm::Optional TransferFrom;
+  auto SawInput = [&](llvm::StringRef Input) {
+if (llvm::sys::path::extension(Input) != FileExtension)
+  TransferFrom.emplace(Input);
+  };
+
   // Strip all the inputs and `--`. We'll put the input for the requested file
   // explicitly at the end of the flags. This ensures modifications done in the
   // following steps apply in more cases (like setting -x, which only affects
   // inputs that come after it).
-  for (auto *Input : ArgList.filtered(driver::options::OPT_INPUT))
+  for (auto *Input : ArgList.filtered(driver::options::OPT_INPUT)) {
+SawInput(Input->getValue(0));
 IndicesToDrop.push_back(Input->getIndex());
+  }
   // Anything after `--` is also treated as input, drop them as well.
   if (auto *DashDash =
   ArgList.getLastArgNoClaim(driver::options::OPT__DASH_DASH)) {
-Cmd.resize(DashDash->getIndex() + 1); // +1 to account for Cmd[0].
+auto DashDashIndex = DashDash->getIndex() + 1; // +1 accounts for Cmd[0]
+for (unsigned I = DashDashIndex; I < Cmd.size(); ++I)
+  SawInput(Cmd[I]);
+Cmd.resize(DashDashIndex);
   }
   llvm::sort(IndicesToDrop);
   llvm::for_each(llvm::reverse(IndicesToDrop),
@@ -262,6 +284,24 @@
   Cmd.push_back("--");
   Cmd.push_back(File.str());
 
+  if (TransferFrom) {
+tooling::CompileCommand TransferCmd;
+TransferCmd.Filename = std::move(*TransferFrom);
+TransferCmd.CommandLine = std::move(Cmd);
+TransferCmd = transferCompileCommand(std::move(TransferCmd), File);
+Cmd = std::move(TransferCmd.CommandLine);
+
+// Restore the canonical "driver --opts -- filename" form we expect.
+// FIXME: This is ugly and coupled. Make transferCompileCommand ensure it?
+

[PATCH] D116170: [clang-format] Add penalty for breaking after '('

2021-12-22 Thread G Pery via Phabricator via cfe-commits
GPery created this revision.
GPery requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116170

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18717,6 +18717,8 @@
   PenaltyBreakBeforeFirstCallParameter, 1234u);
   CHECK_PARSE("PenaltyBreakTemplateDeclaration: 1234",
   PenaltyBreakTemplateDeclaration, 1234u);
+  CHECK_PARSE("PenaltyBreakOpenParenthesis: 1234", PenaltyBreakOpenParenthesis,
+  1234u);
   CHECK_PARSE("PenaltyExcessCharacter: 1234", PenaltyExcessCharacter, 1234u);
   CHECK_PARSE("PenaltyReturnTypeOnItsOwnLine: 1234",
   PenaltyReturnTypeOnItsOwnLine, 1234u);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2907,6 +2907,8 @@
   }
   if (Left.ClosesTemplateDeclaration)
 return Style.PenaltyBreakTemplateDeclaration;
+  if (Left.is(tok::l_paren))
+return Style.PenaltyBreakOpenParenthesis;
   if (Left.is(TT_ConditionalExpr))
 return prec::Conditional;
   prec::Level Level = Left.getPrecedence();
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -759,6 +759,8 @@
 IO.mapOptional("PenaltyBreakString", Style.PenaltyBreakString);
 IO.mapOptional("PenaltyBreakTemplateDeclaration",
Style.PenaltyBreakTemplateDeclaration);
+IO.mapOptional("PenaltyBreakOpenParenthesis",
+   Style.PenaltyBreakOpenParenthesis);
 IO.mapOptional("PenaltyExcessCharacter", Style.PenaltyExcessCharacter);
 IO.mapOptional("PenaltyReturnTypeOnItsOwnLine",
Style.PenaltyReturnTypeOnItsOwnLine);
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2895,6 +2895,10 @@
   /// \version 7
   unsigned PenaltyBreakTemplateDeclaration;
 
+  /// The penalty for breaking after ``(``.
+  /// \version 14
+  unsigned PenaltyBreakOpenParenthesis;
+
   /// The penalty for each character outside of the column limit.
   /// \version 3.7
   unsigned PenaltyExcessCharacter;
@@ -3781,6 +3785,7 @@
R.PenaltyBreakBeforeFirstCallParameter &&
PenaltyBreakComment == R.PenaltyBreakComment &&
PenaltyBreakFirstLessLess == R.PenaltyBreakFirstLessLess &&
+   PenaltyBreakOpenParenthesis == R.PenaltyBreakOpenParenthesis &&
PenaltyBreakString == R.PenaltyBreakString &&
PenaltyExcessCharacter == R.PenaltyExcessCharacter &&
PenaltyReturnTypeOnItsOwnLine == R.PenaltyReturnTypeOnItsOwnLine &&
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3194,6 +3194,9 @@
 **PenaltyBreakTemplateDeclaration** (``Unsigned``) :versionbadge:`clang-format 
7`
   The penalty for breaking after template declaration.
 
+**PenaltyBreakOpenParenthesis** (``Unsigned``) :versionbadge:`clang-format 14`
+  The penalty for breaking after ``(``.
+
 **PenaltyExcessCharacter** (``Unsigned``) :versionbadge:`clang-format 3.7`
   The penalty for each character outside of the column limit.
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18717,6 +18717,8 @@
   PenaltyBreakBeforeFirstCallParameter, 1234u);
   CHECK_PARSE("PenaltyBreakTemplateDeclaration: 1234",
   PenaltyBreakTemplateDeclaration, 1234u);
+  CHECK_PARSE("PenaltyBreakOpenParenthesis: 1234", PenaltyBreakOpenParenthesis,
+  1234u);
   CHECK_PARSE("PenaltyExcessCharacter: 1234", PenaltyExcessCharacter, 1234u);
   CHECK_PARSE("PenaltyReturnTypeOnItsOwnLine: 1234",
   PenaltyReturnTypeOnItsOwnLine, 1234u);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2907,6 +2907,8 @@
   }
   if (Left.ClosesTemplateDeclaration)
 return Style.PenaltyBreakTemplateDeclaration;
+  if (Left.is(tok::l_paren))
+return Style.PenaltyBreakOpenParenthesis;
   if (Left.is(TT_ConditionalExpr))
   

[PATCH] D115573: [Clang][OpenMP] Return error ahead of time if there are multiple mutex clauses in atomic directive

2021-12-22 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 abandoned this revision.
tianshilei1992 added a comment.

Abandon the change because of the trade off between the amount of changes and 
benefit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115573

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


[clang] a364e8f - [NFC][Clang] Move function implementation of `OpenMPAtomicUpdateChecker` into anonymous namespace

2021-12-22 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2021-12-22T11:24:15-05:00
New Revision: a364e8f6adeb4b42296413b6112a8bdfbd2ea116

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

LOG: [NFC][Clang] Move function implementation of `OpenMPAtomicUpdateChecker` 
into anonymous namespace

Just to keep code consistent as `OpenMPAtomicUpdateChecker` is defined
in anonymous namespace.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 5ecfe7fca55cb..a5962ec3b1d95 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -10754,7 +10754,6 @@ class OpenMPAtomicUpdateChecker {
   bool checkBinaryOperation(BinaryOperator *AtomicBinOp, unsigned DiagId = 0,
 unsigned NoteId = 0);
 };
-} // namespace
 
 bool OpenMPAtomicUpdateChecker::checkBinaryOperation(
 BinaryOperator *AtomicBinOp, unsigned DiagId, unsigned NoteId) {
@@ -10915,6 +10914,7 @@ bool OpenMPAtomicUpdateChecker::checkStatement(Stmt *S, 
unsigned DiagId,
   }
   return ErrorFound != NoError;
 }
+} // namespace
 
 StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef Clauses,
 Stmt *AStmt,



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


[PATCH] D116068: [NFC][Clang] Move function implementation of `OpenMPAtomicUpdateChecker` into anonymous namespace

2021-12-22 Thread Shilei Tian 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 rGa364e8f6adeb: [NFC][Clang] Move function implementation of 
`OpenMPAtomicUpdateChecker` into… (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116068

Files:
  clang/lib/Sema/SemaOpenMP.cpp


Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -10754,7 +10754,6 @@
   bool checkBinaryOperation(BinaryOperator *AtomicBinOp, unsigned DiagId = 0,
 unsigned NoteId = 0);
 };
-} // namespace
 
 bool OpenMPAtomicUpdateChecker::checkBinaryOperation(
 BinaryOperator *AtomicBinOp, unsigned DiagId, unsigned NoteId) {
@@ -10915,6 +10914,7 @@
   }
   return ErrorFound != NoError;
 }
+} // namespace
 
 StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef Clauses,
 Stmt *AStmt,


Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -10754,7 +10754,6 @@
   bool checkBinaryOperation(BinaryOperator *AtomicBinOp, unsigned DiagId = 0,
 unsigned NoteId = 0);
 };
-} // namespace
 
 bool OpenMPAtomicUpdateChecker::checkBinaryOperation(
 BinaryOperator *AtomicBinOp, unsigned DiagId, unsigned NoteId) {
@@ -10915,6 +10914,7 @@
   }
   return ErrorFound != NoError;
 }
+} // namespace
 
 StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef Clauses,
 Stmt *AStmt,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116170: [clang-format] Add penalty for breaking after '('

2021-12-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

You need some unit tests to show it working.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116170

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


[clang] ea22fdd - [Clang][DebugInfo] Cease turning instruction-referencing off by default

2021-12-22 Thread Jeremy Morse via cfe-commits

Author: Jeremy Morse
Date: 2021-12-22T16:30:05Z
New Revision: ea22fdd120aeb1bbb9ea96670d70193dc02b2c5f

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

LOG: [Clang][DebugInfo] Cease turning instruction-referencing off by default

Over in D114631 I turned this debug-info feature on by default, for x86_64
only. I'd previously stripped out the clang cc1 option that controlled it
in 651122fc4ac, unfortunately that turned out to not be completely
effective, and the two things deleted in this patch continued to keep it
off-by-default.  Oooff.

As a follow-up, this patch removes the last few things to do with
ValueTrackingVariableLocations from clang, which was the original purpose
of D114631. In an ideal world, if this patch causes you trouble you'd
revert 3c045070882f instead, which was where this behaviour was supposed
to start being the default, although that might not be practical any more.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 94b3003a9c33c..723302f108e20 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -368,9 +368,6 @@ ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 3,
 /// emitted.
 VALUE_CODEGENOPT(DwarfVersion, 3, 0)
 
-/// Whether to use experimental new variable location tracking.
-CODEGENOPT(ValueTrackingVariableLocations, 1, 0)
-
 /// Whether we should emit CodeView debug information. It's possible to emit
 /// CodeView and DWARF into the same object.
 CODEGENOPT(EmitCodeView, 1, 0)

diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 5e16d3525b383..bacac0a20d4d5 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -603,8 +603,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
   Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
   Options.EnableAIXExtendedAltivecABI = 
CodeGenOpts.EnableAIXExtendedAltivecABI;
-  Options.ValueTrackingVariableLocations =
-  CodeGenOpts.ValueTrackingVariableLocations;
   Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;
   Options.LoopAlignment = CodeGenOpts.LoopAlignment;
 



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


Re: [clang] ea22fdd - [Clang][DebugInfo] Cease turning instruction-referencing off by default

2021-12-22 Thread David Blaikie via cfe-commits
Is there a way to turn this off now, if it's broken for some user/use case?
I guess using an -mllvm flag, instead of an -Xclang flag?

Generally I think for a significant change like this the process would be
to add it under a flag, off by default, encourage people to test it by
opting in via the flag, eventually change the default for the flag (letting
people know they can opt-out using the flag if they see problems & to
report them to you so they can be fixed & hopefully they can stop opting
out) & then remove the flag when it's stable. Reverting a patch to disable
a newly-on-by-default feature is a bit heavyweight and it can be nice to
have a flag to control it while it's getting more exposure/experience.

On Wed, Dec 22, 2021 at 11:31 AM Jeremy Morse via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Jeremy Morse
> Date: 2021-12-22T16:30:05Z
> New Revision: ea22fdd120aeb1bbb9ea96670d70193dc02b2c5f
>
> URL:
> https://github.com/llvm/llvm-project/commit/ea22fdd120aeb1bbb9ea96670d70193dc02b2c5f
> DIFF:
> https://github.com/llvm/llvm-project/commit/ea22fdd120aeb1bbb9ea96670d70193dc02b2c5f.diff
>
> LOG: [Clang][DebugInfo] Cease turning instruction-referencing off by
> default
>
> Over in D114631 I turned this debug-info feature on by default, for x86_64
> only. I'd previously stripped out the clang cc1 option that controlled it
> in 651122fc4ac, unfortunately that turned out to not be completely
> effective, and the two things deleted in this patch continued to keep it
> off-by-default.  Oooff.
>
> As a follow-up, this patch removes the last few things to do with
> ValueTrackingVariableLocations from clang, which was the original purpose
> of D114631. In an ideal world, if this patch causes you trouble you'd
> revert 3c045070882f instead, which was where this behaviour was supposed
> to start being the default, although that might not be practical any more.
>
> Added:
>
>
> Modified:
> clang/include/clang/Basic/CodeGenOptions.def
> clang/lib/CodeGen/BackendUtil.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/Basic/CodeGenOptions.def
> b/clang/include/clang/Basic/CodeGenOptions.def
> index 94b3003a9c33c..723302f108e20 100644
> --- a/clang/include/clang/Basic/CodeGenOptions.def
> +++ b/clang/include/clang/Basic/CodeGenOptions.def
> @@ -368,9 +368,6 @@ ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 3,
>  /// emitted.
>  VALUE_CODEGENOPT(DwarfVersion, 3, 0)
>
> -/// Whether to use experimental new variable location tracking.
> -CODEGENOPT(ValueTrackingVariableLocations, 1, 0)
> -
>  /// Whether we should emit CodeView debug information. It's possible to
> emit
>  /// CodeView and DWARF into the same object.
>  CODEGENOPT(EmitCodeView, 1, 0)
>
> diff  --git a/clang/lib/CodeGen/BackendUtil.cpp
> b/clang/lib/CodeGen/BackendUtil.cpp
> index 5e16d3525b383..bacac0a20d4d5 100644
> --- a/clang/lib/CodeGen/BackendUtil.cpp
> +++ b/clang/lib/CodeGen/BackendUtil.cpp
> @@ -603,8 +603,6 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
>Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
>Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
>Options.EnableAIXExtendedAltivecABI =
> CodeGenOpts.EnableAIXExtendedAltivecABI;
> -  Options.ValueTrackingVariableLocations =
> -  CodeGenOpts.ValueTrackingVariableLocations;
>Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;
>Options.LoopAlignment = CodeGenOpts.LoopAlignment;
>
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116022: [clang][dataflow] Add support for noreturn destructor calls

2021-12-22 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116022

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


[PATCH] D116128: [clang][driver] Warn when '-mno-outline-atomics' is used with a non-AArch64 triple

2021-12-22 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance updated this revision to Diff 395879.
nathanchance added a comment.
Herald added subscribers: luke957, s.egerton, simoncook.

- Move test from x86-outline-atomics.c to unsupported-outline-atomics.c (Marco).

- Add a test for riscv64 to ensure it works with multiple architectures (Marco).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116128

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/unsupported-outline-atomics.c


Index: clang/test/Driver/unsupported-outline-atomics.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-outline-atomics.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s 
-check-prefix=CHECK-OUTLINE-ATOMICS-X86
+// CHECK-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support 
'-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target x86_64 -mno-outline-atomics -S %s -### 2>&1 | FileCheck 
%s -check-prefix=CHECK-NO-OUTLINE-ATOMICS-X86
+// CHECK-NO-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support 
'-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "-outline-atomics"
+
+// RUN: %clang -target riscv64 -moutline-atomics -S %s -### 2>&1 | FileCheck 
%s -check-prefix=CHECK-OUTLINE-ATOMICS-RISCV
+// CHECK-OUTLINE-ATOMICS-RISCV: warning: 'riscv64' does not support 
'-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-RISCV-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target riscv64 -mno-outline-atomics -S %s -### 2>&1 | 
FileCheck %s -check-prefix=CHECK-NO-OUTLINE-ATOMICS-RISCV
+// CHECK-NO-OUTLINE-ATOMICS-RISCV: warning: 'riscv64' does not support 
'-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-RISCV-NOT: "-target-feature" "-outline-atomics"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7007,18 +7007,18 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_moutline_atomics,
options::OPT_mno_outline_atomics)) {
-if (A->getOption().matches(options::OPT_moutline_atomics)) {
-  // Option -moutline-atomics supported for AArch64 target only.
-  if (!Triple.isAArch64()) {
-D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
-<< Triple.getArchName();
-  } else {
+// Option -moutline-atomics supported for AArch64 target only.
+if (!Triple.isAArch64()) {
+  D.Diag(diag::warn_drv_moutline_atomics_unsupported_opt)
+  << Triple.getArchName() << A->getOption().getName();
+} else {
+  if (A->getOption().matches(options::OPT_moutline_atomics)) {
 CmdArgs.push_back("-target-feature");
 CmdArgs.push_back("+outline-atomics");
+  } else {
+CmdArgs.push_back("-target-feature");
+CmdArgs.push_back("-outline-atomics");
   }
-} else {
-  CmdArgs.push_back("-target-feature");
-  CmdArgs.push_back("-outline-atomics");
 }
   } else if (Triple.isAArch64() &&
  getToolChain().IsAArch64OutlineAtomicsDefault(Args)) {
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -559,7 +559,7 @@
   InGroup;
 
 def warn_drv_moutline_atomics_unsupported_opt : Warning<
-  "'%0' does not support '-moutline-atomics'; flag ignored">,
+  "'%0' does not support '-%1'; flag ignored">,
   InGroup;
 
 def warn_drv_darwin_sdk_invalid_settings : Warning<


Index: clang/test/Driver/unsupported-outline-atomics.c
===
--- /dev/null
+++ clang/test/Driver/unsupported-outline-atomics.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target x86_64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OUTLINE-ATOMICS-X86
+// CHECK-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support '-moutline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "+outline-atomics"
+
+// RUN: %clang -target x86_64 -mno-outline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-NO-OUTLINE-ATOMICS-X86
+// CHECK-NO-OUTLINE-ATOMICS-X86: warning: 'x86_64' does not support '-mno-outline-atomics'; flag ignored [-Woption-ignored]
+// CHECK-NO-OUTLINE-ATOMICS-X86-NOT: "-target-feature" "-outline-atomics"
+
+// RUN: %clang -target riscv64 -moutline-atomics -S %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-OUTLINE-ATOMICS-RISCV
+// CHECK-OUTLINE-ATOMICS-RIS

Re: [clang] ea22fdd - [Clang][DebugInfo] Cease turning instruction-referencing off by default

2021-12-22 Thread Jeremy Morse via cfe-commits
On Wed, Dec 22, 2021 at 4:34 PM David Blaikie via cfe-commits
 wrote:
> Is there a way to turn this off now, if it's broken for some user/use case? I 
> guess using an -mllvm flag, instead of an -Xclang flag?

Yup, that should be achieved by "-mllvm
-experimental-debug-variable-locations=false", there's a test for that
in llvm/test/DebugInfo/X86/instr-ref-flag.ll.

> Generally I think for a significant change like this the process would be to 
> add it under a flag, off by default, encourage people to test it by opting in 
> via the flag, eventually change the default for the flag (letting people know 
> they can opt-out using the flag if they see problems & to report them to you 
> so they can be fixed & hopefully they can stop opting out) & then remove the 
> flag when it's stable. Reverting a patch to disable a newly-on-by-default 
> feature is a bit heavyweight and it can be nice to have a flag to control it 
> while it's getting more exposure/experience.

Indeed, I'd hoped this was largely achieved with
https://lists.llvm.org/pipermail/llvm-dev/2021-July/151965.html , I
guess what's missing is better communicating in how to opt out now,
alas. It's unfortunate that people bisecting back are going to find
this commit; I couldn't think of another way of rectifying things
without pushing up several reverts and the re-applies at the same time
though.

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


[PATCH] D115604: [Support] Expand `<@>` as the base directory in response files.

2021-12-22 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: clang/docs/UsersManual.rst:920
 
+To generate paths relative to the configuration file, the `<@>` token may be
+used. This will expand to the absolute path of the directory containing the

Response and configuration files are different things, so the documentation 
must more specific what facility is extended.

According to this implementation the response file treatment is extended. 
During development of configuration files couple of attempts were taken to 
extend the functionality of response files (see for example 
https://reviews.llvm.org/D36045). They were rejected as breaking compatibility 
with gcc. It does not mean that such extending is not possible, but it should 
be discussed in wider community. There must be serious reason for such 
extension and significant use case.

As for using this feature for configuration files, it does not look as very 
helpful. Configuration files are searched for in several places and the first 
found file is used. In this case specification of various locations relative to 
the config-file does not look neither safe nor natural. Specific use case also 
would be helpful to ground the need for such extension.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115604

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


Re: [clang] ea22fdd - [Clang][DebugInfo] Cease turning instruction-referencing off by default

2021-12-22 Thread David Blaikie via cfe-commits
On Wed, Dec 22, 2021 at 11:47 AM Jeremy Morse 
wrote:

> On Wed, Dec 22, 2021 at 4:34 PM David Blaikie via cfe-commits
>  wrote:
> > Is there a way to turn this off now, if it's broken for some user/use
> case? I guess using an -mllvm flag, instead of an -Xclang flag?
>
> Yup, that should be achieved by "-mllvm
> -experimental-debug-variable-locations=false", there's a test for that
> in llvm/test/DebugInfo/X86/instr-ref-flag.ll.
>

Fair enough - probably would've been good to have that flag in this commit
message (hopefully some folks can find it here in the email thread) - and I
think I probably would've left the clang flag in (& changed its default) to
"ship" the feature (though, as you said on the other thread - LTO wouldn't
be affected by that flag flip, so would also have to make the change down
in LLVM too - sort of nice that they happened separately, really, to create
an incremental rollout)

Ah well - sounds alright, thanks for the details!


>
> > Generally I think for a significant change like this the process would
> be to add it under a flag, off by default, encourage people to test it by
> opting in via the flag, eventually change the default for the flag (letting
> people know they can opt-out using the flag if they see problems & to
> report them to you so they can be fixed & hopefully they can stop opting
> out) & then remove the flag when it's stable. Reverting a patch to disable
> a newly-on-by-default feature is a bit heavyweight and it can be nice to
> have a flag to control it while it's getting more exposure/experience.
>
> Indeed, I'd hoped this was largely achieved with
> https://lists.llvm.org/pipermail/llvm-dev/2021-July/151965.html , I
> guess what's missing is better communicating in how to opt out now,
> alas. It's unfortunate that people bisecting back are going to find
> this commit; I couldn't think of another way of rectifying things
> without pushing up several reverts and the re-applies at the same time
> though.
>
> --
> Thanks,
> Jeremy
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116022: [clang][dataflow] Add support for noreturn destructor calls

2021-12-22 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: 
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp:196
+
+class VirtualDestructorTest : public ::testing::Test {
+protected:

DYM "Noreturn" instead of "Virtual"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116022

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


[PATCH] D116174: [clang] support relative roots to vfs overlays

2021-12-22 Thread Richard Howell via Phabricator via cfe-commits
rmaz created this revision.
Herald added subscribers: dexonsmith, hiraditya.
rmaz requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This diff adds support for relative roots to VFS overlays.
The directory root will be made absolute from the current
working directory and will be used to determine the path
style to use.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116174

Files:
  clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
  clang/test/VFS/vfsoverlay-relative-root.c
  llvm/lib/Support/VirtualFileSystem.cpp


Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1649,10 +1649,17 @@
 sys::path::Style::windows_backslash)) {
 path_style = sys::path::Style::windows_backslash;
   } else {
-assert(NameValueNode && "Name presence should be checked earlier");
-error(NameValueNode,
-  "entry with relative path at the root level is not 
discoverable");
-return nullptr;
+// Relative VFS root entries are made absolute to the current working
+// directory, then we can determine the path style from that.
+auto EC = sys::fs::make_absolute(Name);
+if (EC) {
+  assert(NameValueNode && "Name presence should be checked earlier");
+  error(NameValueNode,
+"entry with relative path at the root level is not 
discoverable");
+  return nullptr;
+}
+path_style = sys::path::is_absolute(Name, sys::path::Style::posix) ?
+  sys::path::Style::posix : sys::path::Style::windows_backslash;
   }
 }
 
Index: clang/test/VFS/vfsoverlay-relative-root.c
===
--- /dev/null
+++ clang/test/VFS/vfsoverlay-relative-root.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -Werror -ivfsoverlay 
%S/Inputs/vfsoverlay-root-relative.yaml -I virtual -fsyntax-only %s
+
+#include "virtual_header.h"
+
Index: clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
===
--- /dev/null
+++ clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
@@ -0,0 +1,17 @@
+{
+  'version': 0,
+  'fallthrough': true,
+  'overlay-relative': true,
+  'roots': [
+{ 'name': 'virtual',
+  'type': 'directory',
+  'contents': [
+{
+  'external-contents': 'actual_header.h',
+  'type': 'file',
+  'name': 'virtual_header.h',
+}
+  ]
+}
+  ]
+}


Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1649,10 +1649,17 @@
 sys::path::Style::windows_backslash)) {
 path_style = sys::path::Style::windows_backslash;
   } else {
-assert(NameValueNode && "Name presence should be checked earlier");
-error(NameValueNode,
-  "entry with relative path at the root level is not discoverable");
-return nullptr;
+// Relative VFS root entries are made absolute to the current working
+// directory, then we can determine the path style from that.
+auto EC = sys::fs::make_absolute(Name);
+if (EC) {
+  assert(NameValueNode && "Name presence should be checked earlier");
+  error(NameValueNode,
+"entry with relative path at the root level is not discoverable");
+  return nullptr;
+}
+path_style = sys::path::is_absolute(Name, sys::path::Style::posix) ?
+  sys::path::Style::posix : sys::path::Style::windows_backslash;
   }
 }
 
Index: clang/test/VFS/vfsoverlay-relative-root.c
===
--- /dev/null
+++ clang/test/VFS/vfsoverlay-relative-root.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -Werror -ivfsoverlay %S/Inputs/vfsoverlay-root-relative.yaml -I virtual -fsyntax-only %s
+
+#include "virtual_header.h"
+
Index: clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
===
--- /dev/null
+++ clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
@@ -0,0 +1,17 @@
+{
+  'version': 0,
+  'fallthrough': true,
+  'overlay-relative': true,
+  'roots': [
+{ 'name': 'virtual',
+  'type': 'directory',
+  'contents': [
+{
+  'external-contents': 'actual_header.h',
+  'type': 'file',
+  'name': 'virtual_header.h',
+}
+  ]
+}
+  ]
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116174: [clang] support relative roots to vfs overlays

2021-12-22 Thread Richard Howell via Phabricator via cfe-commits
rmaz updated this revision to Diff 395893.
rmaz added a comment.

lint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116174

Files:
  clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
  clang/test/VFS/vfsoverlay-relative-root.c
  llvm/lib/Support/VirtualFileSystem.cpp


Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1649,10 +1649,17 @@
 sys::path::Style::windows_backslash)) {
 path_style = sys::path::Style::windows_backslash;
   } else {
-assert(NameValueNode && "Name presence should be checked earlier");
-error(NameValueNode,
-  "entry with relative path at the root level is not 
discoverable");
-return nullptr;
+// Relative VFS root entries are made absolute to the current working
+// directory, then we can determine the path style from that.
+auto EC = sys::fs::make_absolute(Name);
+if (EC) {
+  assert(NameValueNode && "Name presence should be checked earlier");
+  error(NameValueNode,
+"entry with relative path at the root level is not 
discoverable");
+  return nullptr;
+}
+path_style = sys::path::is_absolute(Name, sys::path::Style::posix) ?
+  sys::path::Style::posix : sys::path::Style::windows_backslash;
   }
 }
 
Index: clang/test/VFS/vfsoverlay-relative-root.c
===
--- /dev/null
+++ clang/test/VFS/vfsoverlay-relative-root.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -Werror -ivfsoverlay 
%S/Inputs/vfsoverlay-root-relative.yaml -I virtual -fsyntax-only %s
+
+#include "virtual_header.h"
+
Index: clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
===
--- /dev/null
+++ clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
@@ -0,0 +1,17 @@
+{
+  'version': 0,
+  'fallthrough': true,
+  'overlay-relative': true,
+  'roots': [
+{ 'name': 'virtual',
+  'type': 'directory',
+  'contents': [
+{
+  'external-contents': 'actual_header.h',
+  'type': 'file',
+  'name': 'virtual_header.h',
+}
+  ]
+}
+  ]
+}


Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1649,10 +1649,17 @@
 sys::path::Style::windows_backslash)) {
 path_style = sys::path::Style::windows_backslash;
   } else {
-assert(NameValueNode && "Name presence should be checked earlier");
-error(NameValueNode,
-  "entry with relative path at the root level is not discoverable");
-return nullptr;
+// Relative VFS root entries are made absolute to the current working
+// directory, then we can determine the path style from that.
+auto EC = sys::fs::make_absolute(Name);
+if (EC) {
+  assert(NameValueNode && "Name presence should be checked earlier");
+  error(NameValueNode,
+"entry with relative path at the root level is not discoverable");
+  return nullptr;
+}
+path_style = sys::path::is_absolute(Name, sys::path::Style::posix) ?
+  sys::path::Style::posix : sys::path::Style::windows_backslash;
   }
 }
 
Index: clang/test/VFS/vfsoverlay-relative-root.c
===
--- /dev/null
+++ clang/test/VFS/vfsoverlay-relative-root.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -Werror -ivfsoverlay %S/Inputs/vfsoverlay-root-relative.yaml -I virtual -fsyntax-only %s
+
+#include "virtual_header.h"
+
Index: clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
===
--- /dev/null
+++ clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
@@ -0,0 +1,17 @@
+{
+  'version': 0,
+  'fallthrough': true,
+  'overlay-relative': true,
+  'roots': [
+{ 'name': 'virtual',
+  'type': 'directory',
+  'contents': [
+{
+  'external-contents': 'actual_header.h',
+  'type': 'file',
+  'name': 'virtual_header.h',
+}
+  ]
+}
+  ]
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115604: [Support] Expand `<@>` as the base directory in response files.

2021-12-22 Thread Jack Andersen via Phabricator via cfe-commits
jackoalan added inline comments.



Comment at: clang/docs/UsersManual.rst:920
 
+To generate paths relative to the configuration file, the `<@>` token may be
+used. This will expand to the absolute path of the directory containing the

sepavloff wrote:
> Response and configuration files are different things, so the documentation 
> must more specific what facility is extended.
> 
> According to this implementation the response file treatment is extended. 
> During development of configuration files couple of attempts were taken to 
> extend the functionality of response files (see for example 
> https://reviews.llvm.org/D36045). They were rejected as breaking 
> compatibility with gcc. It does not mean that such extending is not possible, 
> but it should be discussed in wider community. There must be serious reason 
> for such extension and significant use case.
> 
> As for using this feature for configuration files, it does not look as very 
> helpful. Configuration files are searched for in several places and the first 
> found file is used. In this case specification of various locations relative 
> to the config-file does not look neither safe nor natural. Specific use case 
> also would be helpful to ground the need for such extension.
> Specific use case also would be helpful to ground the need for such extension.

An embedded architecture's community members may wish to deploy their own 
portable (non-installed) platform packages, while minimizing the user burden of 
configuring the build system of their choice to set up all the search paths. 
Ideally, just the `--config` option should be enough to handle everything 
necessary for full use of the package.

Consider an embedded architecture "foo". It deploys a common directory which 
contains a shared configuration file and headers:

```
-foo-common
  -config.cfg
  -include
-foo.h
-stdlib.h
-string.h
-...
```

foo-common/config.cfg:

```
--target=foo
-isystem <@>/include
```

foo is implemented by a family of boards. Each board SDK is contained in a 
directory located next to the common one. Each has their own device libraries 
and some require special feature and machine flags.

Here is the directory layout for a board named "bar":

```
-foo-bar
  -config.cfg
  -include
-bar.h
  -lib
-libbar.a
-libc.a
-libm.a
  -ldscripts
-link.ld
```

foo-bar/config.cfg:

```
@../foo-common/config.cfg
-mcpu=
-isystem <@>/include
-L <@>/lib
-T <@>/ldscripts/link.ld
```

Configuration files are very convenient for setting up compiler options in an 
accessible way (i.e. not having to depend on hard-coded logic in the driver or 
cmake/makefiles/etc to set up the environment). However, the inability to 
express config-relative paths is a major burden for setting up search paths in 
this use case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115604

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


[PATCH] D116174: [clang] support relative roots to vfs overlays

2021-12-22 Thread Richard Howell via Phabricator via cfe-commits
rmaz updated this revision to Diff 395896.
rmaz added a comment.

clang-format changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116174

Files:
  clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
  clang/test/VFS/vfsoverlay-relative-root.c
  llvm/lib/Support/VirtualFileSystem.cpp


Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1649,10 +1649,19 @@
 sys::path::Style::windows_backslash)) {
 path_style = sys::path::Style::windows_backslash;
   } else {
-assert(NameValueNode && "Name presence should be checked earlier");
-error(NameValueNode,
+// Relative VFS root entries are made absolute to the current working
+// directory, then we can determine the path style from that.
+auto EC = sys::fs::make_absolute(Name);
+if (EC) {
+  assert(NameValueNode && "Name presence should be checked earlier");
+  error(
+  NameValueNode,
   "entry with relative path at the root level is not 
discoverable");
-return nullptr;
+  return nullptr;
+}
+path_style = sys::path::is_absolute(Name, sys::path::Style::posix)
+ ? sys::path::Style::posix
+ : sys::path::Style::windows_backslash;
   }
 }
 
Index: clang/test/VFS/vfsoverlay-relative-root.c
===
--- /dev/null
+++ clang/test/VFS/vfsoverlay-relative-root.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -Werror -ivfsoverlay 
%S/Inputs/vfsoverlay-root-relative.yaml -I virtual -fsyntax-only %s
+
+#include "virtual_header.h"
Index: clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
===
--- /dev/null
+++ clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
@@ -0,0 +1,17 @@
+{
+  'version': 0,
+  'fallthrough': true,
+  'overlay-relative': true,
+  'roots': [
+{ 'name': 'virtual',
+  'type': 'directory',
+  'contents': [
+{
+  'external-contents': 'actual_header.h',
+  'type': 'file',
+  'name': 'virtual_header.h',
+}
+  ]
+}
+  ]
+}


Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -1649,10 +1649,19 @@
 sys::path::Style::windows_backslash)) {
 path_style = sys::path::Style::windows_backslash;
   } else {
-assert(NameValueNode && "Name presence should be checked earlier");
-error(NameValueNode,
+// Relative VFS root entries are made absolute to the current working
+// directory, then we can determine the path style from that.
+auto EC = sys::fs::make_absolute(Name);
+if (EC) {
+  assert(NameValueNode && "Name presence should be checked earlier");
+  error(
+  NameValueNode,
   "entry with relative path at the root level is not discoverable");
-return nullptr;
+  return nullptr;
+}
+path_style = sys::path::is_absolute(Name, sys::path::Style::posix)
+ ? sys::path::Style::posix
+ : sys::path::Style::windows_backslash;
   }
 }
 
Index: clang/test/VFS/vfsoverlay-relative-root.c
===
--- /dev/null
+++ clang/test/VFS/vfsoverlay-relative-root.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -Werror -ivfsoverlay %S/Inputs/vfsoverlay-root-relative.yaml -I virtual -fsyntax-only %s
+
+#include "virtual_header.h"
Index: clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
===
--- /dev/null
+++ clang/test/VFS/Inputs/vfsoverlay-root-relative.yaml
@@ -0,0 +1,17 @@
+{
+  'version': 0,
+  'fallthrough': true,
+  'overlay-relative': true,
+  'roots': [
+{ 'name': 'virtual',
+  'type': 'directory',
+  'contents': [
+{
+  'external-contents': 'actual_header.h',
+  'type': 'file',
+  'name': 'virtual_header.h',
+}
+  ]
+}
+  ]
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115867: [C++20] [Coroutines] Warning for always_inline coroutine

2021-12-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone requested changes to this revision.
Quuxplusone added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:0-3
+def warn_always_inline_coroutine : Warning<
+  "A coroutine marked always_inline might not be inlined properly."
+  >,
+  InGroup;

FWIW, this message isn't particularly helpful to the reader. My code "might" 
not be optimized "properly"? Does that mean it might be mis-optimized, 
improperly, and thus break in some way at runtime? Or is the compiler just 
saying that the attribute will be ignored? Or that it //might// be ignored, but 
it might not? How do I (the programmer) know whether the bad thing will happen?

I think as a programmer what I'd //like// to see here is just `"the '%0' 
attribute has no effect on coroutines"`. That's very clear, and easy to 
understand. Does that wording reflect what the compiler actually //does//, 
though?


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

https://reviews.llvm.org/D115867

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


[PATCH] D116085: [clang-tidy] Performance improvements for NOLINTBEGIN/END blocks

2021-12-22 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

some drive-by comments, i'll be AFK for a while though. so please don't block 
this on my approval if people disagree.




Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:197
+  SourceLocation Loc = FileStartLoc.getLocWithOffset(
+  static_cast(Error.Message.FileOffset));
   return diag(Error.DiagnosticName, Loc, Error.Message.Message,

this change looks unrelated to the current patch.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:455
 static bool
 lineIsMarkedWithNOLINT(const ClangTidyContext &Context,
SmallVectorImpl &SuppressionErrors,

as mentioned above, if we were to make this 
`NoLintPragmaHandler::isLineWithinNoLint` in which `NoLintPragmaHandler` owns 
the cache of `NoLintTokens` per `FileID`. We can just first populate the cache 
(or use the already cached tokens) and then iterate over them here to see if 
any of them suppresses diagnostic at hand.

I don't think it's worth optimizing the iteration over tokens, as we won't have 
more than a handful of nolint tokens in a single file. but if that assumption 
turned out to be wrong, i suppose we can also do a binary search over tokens 
rather than iterating over all of them in the future.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:546
+NoLintToken::Type NoLintToken::strToType(StringRef S) {
+  static const llvm::StringMap StrMapping = {
+  {"NOLINT", Type::NoLint},

nit: there's also `llvm::StringSwitch`



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:563
+return true;
+  GlobList Globs(Checks, /*KeepNegativeGlobs=*/false);
+  return Globs.contains(CheckName);

this creates new regexes at each call, what about building the glob once in 
constructor and storing that instead of `Checks` ?



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:580
+const SourceManager &SM) const {
+  if (!isValidPair(Begin, End, SM))
+return false;

performing this check once during construction sounds better than performing it 
for every diagnostics.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:602
EnableNolintBlocks)) {
-++Context.Stats.ErrorsIgnoredNOLINT;
+// Even though this diagnostic is suppressed, there may be other issues 
with
+// the file that need raising, such as unclosed NOLINT(BEGIN/END) blocks.

looks like an unrelated change, maybe move to a separate patch?



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:66
+struct NoLintToken {
+  enum class Type { Unknown, NoLint, NoLintNextLine, NoLintBegin, NoLintEnd };
+  Type NoLintType = Type::Unknown;

instead of having an unknown type here and making it a concern for all the 
places handling the token, can we just ignore such tokens during generation?

it'd probably imply having a constructor for the object which takes Location, 
Type and Checks as input.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:76
+  // NOTE: at first glance, *it may seem* that this bool is redundant when the
+  // `Checks.empty()` method already exists.
+  // However, `Checks.empty()` cannot differentiate "NOLINT" from "NOLINT()".

similar to above is `NOLINT()` useful at all? maybe we should just not generate 
such tokens?



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:94
+  NoLintToken Begin;
+  NoLintToken End;
+

why not just store a `SourceLocation` for the end and make sure we only 
construct valid ones?



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:236
+  const SmallVector &
+  getNoLintBlocks(FileID File, SmallVectorImpl &Errors,
+  bool AllowIO = true) const;

what about a narrower interface? e.g. moving `shouldSuppressDiagnostics` into 
`ClangTidyContext`. It already takes the `Context` as a mutable-ref.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:265
+
+  mutable llvm::DenseMap> NoLintCache;
 };

what about just having:
```
class NoLintPragmaHandler;
std::unique_ptr NoLintHandler;
```

And making all of this an implementation detail (including the 
NoLintToken/Block structs above)?

We can then have a `NoLintPragmaHandler::isLineWithinNoLint` which performs all 
the checks while filling the cache if need be?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116085

___
cfe-commits mailing list
cfe-

[PATCH] D43002: [CodeView] Emit S_OBJNAME record

2021-12-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Some test nits:) I don't know CodeView :(




Comment at: clang/test/CodeGenCXX/debug-info-objname.cpp:1
+// RUN: cp %s %T/debug-info-objname.cpp
+// RUN: cd %T

The whole file appears to be CRLF where almost all other tests use LF in 
llvm-project.



Comment at: clang/test/CodeGenCXX/debug-info-objname.cpp:2
+// RUN: cp %s %T/debug-info-objname.cpp
+// RUN: cd %T
+

%T is deprecated in lit 
(https://llvm.org/docs/CommandGuide/lit.html#substitutions): it is easy to 
cause multi-threading file reuse problems because lit runs tests parallelly.

I personally prefer `RUN: rm -rf %t && mkdir %t && cd %t` if you need to cd.

My personal comment style for non-RUN non-CHECK lines is `///` - it stands out 
in many editors and may help possible FileCheck/lit's future direction to catch 
stale CHECK prefixes.



Comment at: clang/test/CodeGenCXX/debug-info-objname.cpp:30
+// RUN: %clang_cl /c /Z7 -nostdinc -fdebug-compilation-dir=. 
/clang:-save-temps debug-info-objname.cpp
+// RUN: cat debug-info-objname.asm | FileCheck %s --check-prefix=ASM
+

Prefer `--input-file` or input redirection to `cat xxx | yyy`



Comment at: clang/test/CodeGenCXX/debug-info-objname.cpp:36
+
+// ABSOLUTE: S_OBJNAME [size = {{[0-9]+}}] sig=0, 
`{{.+}}debug-info-objname.obj`
+// RELATIVE: S_OBJNAME [size = {{[0-9]+}}] sig=0, `debug-info-objname.obj`

`{{[0-9]+}}` -> `[[#]]`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43002

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


[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-12-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

@ronlieb do you have any more information? The patch says remove /opt/rocm but 
the discussion seems to be going another way. What's the actual req here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-12-22 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb requested changes to this revision.
ronlieb added a comment.

This needs to be revisited.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-12-22 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

Our conclusion is that the /opt/rocm weak default needs to stay in place. Thus 
this patch should be abandoned in my opinion. MarkS and I are requesting the 
folks that requestedt his change  within AMD, revisit it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


[PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

2021-12-22 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Sounds good to me.

> CMAKE_INSTALL_PREFIX should be removed.

I think we have consensus on that ^, orthogonal to the /opt/rocm presence or 
absence. As long as there's some way to tell cmake to use a given HSA, and it 
seems there are several, deleting that string is an improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109885

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


[PATCH] D43002: [CodeView] Emit S_OBJNAME record

2021-12-22 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D43002#3205190 , @MaskRay wrote:

> Some test nits:) I don't know CodeView :(

Fixed, thanks @MaskRay !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43002

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


[PATCH] D115921: [RISCV] Refactor the RISCV ISA extension info and target features to support multiple extension version

2021-12-22 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu updated this revision to Diff 395803.
zixuan-wu edited the summary of this revision.
zixuan-wu added a comment.

Address comments.


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

https://reviews.llvm.org/D115921

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-arch.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVSubtarget.cpp
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/tools/llvm-objdump/ELF/RISCV/unknown-arch-attr.test

Index: llvm/test/tools/llvm-objdump/ELF/RISCV/unknown-arch-attr.test
===
--- llvm/test/tools/llvm-objdump/ELF/RISCV/unknown-arch-attr.test
+++ llvm/test/tools/llvm-objdump/ELF/RISCV/unknown-arch-attr.test
@@ -3,7 +3,7 @@
 ## The expected behavior is to ignore the unrecognized arch feature and
 ## continue to process the following arch features.
 ##
-## The object file has the "rv32i2p0_x1p0_m2p0" arch feature. "x1p0" is an
+## The object file has the "rv32i2p0_y1p0_m2p0" arch feature. "y1p0" is an
 ## unrecognized architecture extension. llvm-objdump will ignore it and decode
 ## "mul" instruction correctly according to "m2p0" in the arch feature.
 ##
@@ -34,5 +34,5 @@
 Content: 3385C502
   - Name:.riscv.attributes
 Type:SHT_RISCV_ATTRIBUTES
-## The content is the encoding of the arch feature "rv32i2p0_x1p0_m2p0"
-Content: 4123007269736376000119000572763332693270305F783170305F6D32703000
+## The content is the encoding of the arch feature "rv32i2p0_y1p0_m2p0"
+Content: 4123007269736376000119000572763332693270305F793170305F6D32703000
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -76,3 +76,6 @@
 
 .attribute arch, "rv32iv0p10zvlsseg0p10"
 # CHECK: attribute  5, "rv32i2p0_v0p10_zvlsseg0p10"
+
+.attribute arch, "rv32iv0p7zvlsseg0p7"
+# CHECK: attribute  5, "rv32i2p0_v0p7_zvlsseg0p7"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -17,6 +17,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbr %s -o - | FileCheck --check-prefix=RV32ZBR %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbs %s -o - | FileCheck --check-prefix=RV32ZBS %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbt %s -o - | FileCheck --check-prefix=RV32ZBT %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-v0p7 %s -o - | FileCheck --check-prefix=RV32V0P7 %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefix=RV64M %s
 ; RUN: llc -mtriple=riscv64 -mattr=+a %s -o - | FileCheck --check-prefix=RV64A %s
 ; RUN: llc -mtriple=riscv64 -mattr=+f %s -o - | FileCheck --check-prefix=RV64F %s
@@ -34,6 +35,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbr %s -o - | FileCheck --check-prefix=RV64ZBR %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbs %s -o - | FileCheck --check-prefix=RV64ZBS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbt %s -o - | FileCheck --check-prefix=RV64ZBT %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v0p7 %s -o - | FileCheck --check-prefix=RV64V0P7 %s
 
 ; RV32M: .attribute 5, "rv32i2p0_m2p0"
 ; RV32A: .attribute 5, "rv32i2p0_a2p0"
@@ -53,6 +55,7 @@
 ; RV32ZBR: .attribute 5, "rv32i2p0_zbr0p93"
 ; RV32ZBS: .attribute 5, "rv32i2p0_zbs1p0"
 ; RV32ZBT: .attribute 5, "rv32i2p0_zbt0p93"
+; RV32V0P7: .attribute 5, "rv32i2p0_v0p7_zvlsseg0p7"
 ; RV32COMBINED: .attribute 5, "rv32i2p0_f2p0_v0p10_zfh0p1_zfhmin0p1_zbb1p0_zvlsseg0p10"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
@@ -73,6 +76,7 @@
 ; RV64ZBS: .attribute 5, "rv64i2p0_zbs1p0"
 ; RV64ZBT: .attribute 5, "rv64i2p0_zbt0p93"
 ; RV64V: .attribute 5, "rv64i2p0_v0p10_zvlsseg0p10"
+; RV64V0P7: .attribute 5, "rv64i2p0_v0p7_zvlsseg0p7"
 ; RV64COMBINED: .attribute 5, "rv64i2p0_f2p0_v0p10_zfh0p1_zfhmin0p1_zbb1p0_zvlsseg0p10"
 
 
Index: llvm/lib/Target/RISCV/RISCVSubtarget.h
===
--- llvm/lib/Target/RISCV/RISCVSubtarget.h
+++ llvm/lib/Target/RISCV/RISCVSubtarget.h
@@ -24,6 +24,7 @@
 #include "llvm/CodeGen/SelectionDAGTargetInfo.h"
 #include "llvm/CodeGen/TargetSubtargetInfo.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Target/TargetMachine.h"
 
 #define GET_SUBTARGETINFO_HEADER
@@ -34,27 +35,28 @@
 
 class RISCVSubtarget : public RISCVGenSubtargetInfo {
   virtual void anchor();
-  bool HasStdExtM = false;
-  bool HasStdExtA = false;
-  bool HasS

[PATCH] D115921: [RISCV] Refactor the RISCV ISA extension info and target features to support multiple extension version

2021-12-22 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Do not bring back V draft 0.7. It is gone, it will never be supported again by 
LLVM under that name. The standard extension namespace is reserved for ratified 
extensions and development snapshots only, not old drafts vendors decided to 
ship. For those, non-standard extension names are needed.


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

https://reviews.llvm.org/D115921

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


[PATCH] D115790: [Coroutines] Set presplit attribute in Clang and mlir

2021-12-22 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 395835.
ChuanqiXu retitled this revision from "[Coroutines] Set presplit attribute in 
Clang" to "[Coroutines] Set presplit attribute in Clang and mlir".
ChuanqiXu edited the summary of this revision.
ChuanqiXu added a reviewer: mehdi_amini.
ChuanqiXu added a comment.
Herald added subscribers: sdasgup3, wenzhicui, wrengr, Chia-hungDuan, dcaballe, 
cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, 
Joonsoo, stephenneuendorffer, liufengdb, aartbik, lucyrfox, mgester, 
arpith-jacob, nicolasvasilache, antiagainst, shauheen, rriddle.
Herald added a reviewer: ftynse.
Herald added a project: MLIR.

Set presplit attribute in mlir too


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

https://reviews.llvm.org/D115790

Files:
  clang/lib/CodeGen/CGCoroutine.cpp
  clang/test/CodeGenCoroutines/coro-always-inline.cpp
  clang/test/CodeGenCoroutines/coro-attributes.cpp
  llvm/docs/Coroutines.rst
  llvm/lib/Transforms/Coroutines/CoroEarly.cpp
  llvm/lib/Transforms/Coroutines/CoroInternal.h
  llvm/test/Transforms/Coroutines/coro-debug-O2.ll
  llvm/test/Transforms/Coroutines/coro-debug-coro-frame.ll
  llvm/test/Transforms/Coroutines/coro-debug-dbg.values-not_used_in_frame.ll
  llvm/test/Transforms/Coroutines/coro-debug-dbg.values.ll
  llvm/test/Transforms/Coroutines/coro-debug-frame-variable.ll
  llvm/test/Transforms/Coroutines/coro-noalias-param.ll
  llvm/test/Transforms/Coroutines/coro-split-01.ll
  llvm/test/Transforms/Coroutines/coro-split-recursive.ll
  llvm/test/Transforms/Coroutines/ex0.ll
  llvm/test/Transforms/Coroutines/ex1.ll
  llvm/test/Transforms/Coroutines/ex2.ll
  llvm/test/Transforms/Coroutines/ex3.ll
  llvm/test/Transforms/Coroutines/ex4.ll
  llvm/test/Transforms/Coroutines/ex5.ll
  llvm/test/Transforms/Coroutines/phi-coro-end.ll
  llvm/test/Transforms/Coroutines/restart-trigger.ll
  mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp
  mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp
  mlir/test/mlir-opt/async.mlir

Index: mlir/test/mlir-opt/async.mlir
===
--- /dev/null
+++ mlir/test/mlir-opt/async.mlir
@@ -0,0 +1,80 @@
+// Check if mlir marks the corresponding function with required coroutine attribute.
+//
+// RUN:   mlir-opt %s -async-to-async-runtime  \
+// RUN:   -async-runtime-ref-counting  \
+// RUN:   -async-runtime-ref-counting-opt  \
+// RUN:   -convert-async-to-llvm   \
+// RUN:   -convert-linalg-to-loops \
+// RUN:   -convert-scf-to-std  \
+// RUN:   -convert-linalg-to-llvm  \
+// RUN:   -convert-memref-to-llvm  \
+// RUN:   -convert-arith-to-llvm   \
+// RUN:   -convert-std-to-llvm \
+// RUN:   -reconcile-unrealized-casts  \
+// RUN: | FileCheck %s
+
+// CHECK: llvm.func @async_execute_fn{{.*}}attributes{{.*}}"coroutine.presplit", "0"
+// CHECK: llvm.func @async_execute_fn_0{{.*}}attributes{{.*}}"coroutine.presplit", "0"
+// CHECK: llvm.func @async_execute_fn_1{{.*}}attributes{{.*}}"coroutine.presplit", "0"
+
+func @main() {
+  %i0 = arith.constant 0 : index
+  %i1 = arith.constant 1 : index
+  %i2 = arith.constant 2 : index
+  %i3 = arith.constant 3 : index
+
+  %c0 = arith.constant 0.0 : f32
+  %c1 = arith.constant 1.0 : f32
+  %c2 = arith.constant 2.0 : f32
+  %c3 = arith.constant 3.0 : f32
+  %c4 = arith.constant 4.0 : f32
+
+  %A = memref.alloc() : memref<4xf32>
+  linalg.fill(%c0, %A) : f32, memref<4xf32>
+
+  %U = memref.cast %A :  memref<4xf32> to memref<*xf32>
+  call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+  memref.store %c1, %A[%i0]: memref<4xf32>
+  call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+  call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+  %outer = async.execute {
+memref.store %c2, %A[%i1]: memref<4xf32>
+call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+// No op async region to create a token for testing async dependency.
+%noop = async.execute {
+  call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+  async.yield
+}
+
+%inner = async.execute [%noop] {
+  memref.store %c3, %A[%i2]: memref<4xf32>
+  call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+  call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+  async.yield
+}
+async.await %inner : !async.token
+
+memref.store %c4, %A[%i3]: memref<4xf32>
+call @mlirAsyncRuntimePrintCurrentThreadId(): () -> ()
+call @print_memref_f32(%U): (memref<*xf32>) -> ()
+
+  

[PATCH] D115790: [Coroutines] Set presplit attribute in Clang and mlir

2021-12-22 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@ezhulenev I finally made it! Thanks for your help! @mehdi_amini @ftynse hi, 
might you help to look if the change in mlir part is good?


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

https://reviews.llvm.org/D115790

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


[PATCH] D115921: [RISCV] Refactor the RISCV ISA extension info and target features to support multiple extension version

2021-12-22 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

I think this would benefit from increased test coverage, namely to show that 
the mattr command-line options are properly handled. Some possible ideas:

- Tests with the correct extension versions (maybe add a test file that 
exercises the version for all extensions).
- Tests that show an error message with unsupported versions.
- A test that shows that something like mattr=+m,+m2p1 is allowed (or not).

Nit: fix the lint / no new line warnings.


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

https://reviews.llvm.org/D115921

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


[PATCH] D114631: [DebugInfo][InstrRef] Turn instruction referencing on by default for x86

2021-12-22 Thread Jeremy Morse via Phabricator via cfe-commits
jmorse added a comment.

Hmmm. I thought this was quiet after landing -- and it turns out the reason why 
is there's still a sneek-circuit in clang that's turning instruction 
referencing off by default. Woe is me; should have done more end-to-end testing 
:|. On the upside, in the last few weeks LTO and non-clang frontends have had 
instruction referencing on, so it hasn't been completely worthless.

I'm going to drop in a patch removing the bit of clang that's turning this off 
again, on the "obvious fix" principle that that's what this patch was supposed 
to do. I'll also include in the commit message that ideally rG3c045070882f 
 should be 
reverted rather than the follow-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114631

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


[PATCH] D113049: [AIX] Disable tests that fail because of no 64-bit XCOFF object file support

2021-12-22 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan updated this revision to Diff 395904.
Jake-Egan added a comment.

Fixed typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113049

Files:
  clang/test/ASTMerge/codegen-body/test.c
  clang/test/ClangScanDeps/modules-full-by-mod-name.cpp
  clang/test/ClangScanDeps/resource_directory.c
  clang/test/lit.cfg.py
  llvm/test/LTO/X86/remangle_intrinsics.ll
  llvm/test/lit.cfg.py
  llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp

Index: llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
+++ llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp
@@ -1131,7 +1131,11 @@
   EXPECT_STREQ(String1, *Extracted3);
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestEmptyStringOffsets) {
+#else
 TEST(DWARFDebugInfo, TestEmptyStringOffsets) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1160,7 +1164,11 @@
   DwarfContext->getDWARFObj().getStrOffsetsSection().Data.empty());
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestRelations) {
+#else
 TEST(DWARFDebugInfo, TestRelations) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1347,7 +1355,11 @@
   EXPECT_FALSE(DefaultDie.getSibling().isValid());
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestChildIterators) {
+#else
 TEST(DWARFDebugInfo, TestChildIterators) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1456,7 +1468,11 @@
   EXPECT_EQ(CUDie.begin(), CUDie.end());
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestAttributeIterators) {
+#else
 TEST(DWARFDebugInfo, TestAttributeIterators) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1518,7 +1534,11 @@
   EXPECT_EQ(E, ++I);
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestFindRecurse) {
+#else
 TEST(DWARFDebugInfo, TestFindRecurse) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1732,7 +1752,11 @@
   // Test
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestFindAttrs) {
+#else
 TEST(DWARFDebugInfo, TestFindAttrs) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
@@ -1795,7 +1819,11 @@
   EXPECT_EQ(DieMangled, toString(NameOpt, ""));
 }
 
+#if defined(_AIX) && defined(__64BIT__)
+TEST(DWARFDebugInfo, DISABLED_TestImplicitConstAbbrevs) {
+#else
 TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
+#endif
   Triple Triple = getNormalizedDefaultTargetTriple();
   if (!isConfigurationSupported(Triple))
 GTEST_SKIP();
Index: llvm/test/lit.cfg.py
===
--- llvm/test/lit.cfg.py
+++ llvm/test/lit.cfg.py
@@ -405,3 +405,22 @@
 
 if "MemoryWithOrigins" in config.llvm_use_sanitizer:
 config.available_features.add('use_msan_with_origins')
+
+def exclude_unsupported_files_for_aix(dirname):
+   for filename in os.listdir(dirname):
+   source_path = os.path.join( dirname, filename)
+   if os.path.isdir(source_path):
+   continue
+   f = open(source_path, 'r')
+   try:
+  data = f.read()
+  # 64-bit object files are not supported on AIX, so exclude the tests.
+  if ('-emit-obj' in data or '-filetype=obj' in data) and '64' in config.target_triple:
+config.excludes += [ filename ]
+   finally:
+  f.close()
+
+if 'aix' in config.target_triple:
+for directory in ('/CodeGen/X86', '/DebugInfo', '/DebugInfo/X86', '/DebugInfo/Generic', '/LTO/X86', '/Linker'):
+exclude_unsupported_files_for_aix(config.test_source_root + directory)
+
Index: llvm/test/LTO/X86/remangle_intrinsics.ll
===
--- llvm/test/LTO/X86/remangle_intrinsics.ll
+++ llvm/test/LTO/X86/remangle_intrinsics.ll
@@ -1,3 +1,4 @@
+; UNSUPPORTED: powerpc64-ibm-aix
 ; RUN: llvm-as < %s > %t1
 ; RUN: llvm-as < %p/Inputs/remangle_intrinsics.ll > %t2
 ; RUN: llvm-lto %t1 %t2 | FileCheck %s
Index: clang/test/lit.cfg.py
===
--- clang/test/lit.cfg.py
+++ clang/test/lit.cfg.py
@@ -243,3 +243,24 @@
 # Add a vendor-specific feature.
 if config.clang_vendor_uti:
 config.available_features.add('clang-vendor=' + config.clang_vendor_uti)
+
+def exclude_unsupported_files_for_aix(dirname):
+for filename in os.listdir(dirname):
+

[PATCH] D116174: [clang] support relative roots to vfs overlays

2021-12-22 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

This LGTM but I'm interested to hear from folks with more knowledge about the 
VFS' desired behavior to comment on if this will have any unexpected side 
effects


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116174

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


[PATCH] D113049: [AIX] Disable tests that fail because of no 64-bit XCOFF object file support

2021-12-22 Thread Jake Egan via Phabricator via cfe-commits
Jake-Egan marked an inline comment as done.
Jake-Egan added inline comments.



Comment at: clang/test/ASTMerge/codegen-body/test.c:1
+// UNSUPPORTED: powerpc64-ibm-aix
 // RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/body1.c

shchenz wrote:
> Do we still need this? -emit-obj is already excluded?
Excluding this test causes regressions because LIT can't find any tests at 
`/codegen-body` directory:
```
Clang :: utils/update_cc_test_checks/global-hex-value-regex.test
Clang :: utils/update_cc_test_checks/global-value-regex.test
```
I figure it's easier to mark this test unsupported. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113049

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


[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-22 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov created this revision.
Herald added a subscriber: mgorny.
kstoimenov requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

This will allow linking in the callbacks directly instead of using PLT.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116182

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,12 @@
   asan_new_delete.cpp
   )
 
+if (NOT WIN32 AND NOT APPLE)
+  set(ASAN_DSO_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +140,12 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_dso
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_DSO_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -207,6 +218,13 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_dso
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_dso
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // ZXCV
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_dso");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116182: [ASan] Moved optimized callbacks into a separate library.

2021-12-22 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 395914.
kstoimenov added a comment.

Updated a comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116182

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/tests/CMakeLists.txt

Index: compiler-rt/lib/asan/tests/CMakeLists.txt
===
--- compiler-rt/lib/asan/tests/CMakeLists.txt
+++ compiler-rt/lib/asan/tests/CMakeLists.txt
@@ -261,6 +261,7 @@
   set(ASAN_TEST_RUNTIME_OBJECTS
 $
 $
+$
 $
 $
 $
@@ -286,6 +287,7 @@
 # Test w/o ASan instrumentation. Link it with ASan statically.
 add_executable(AsanNoinstTest # FIXME: .arch?
   $
+  $
   $
   $
   $
Index: compiler-rt/lib/asan/CMakeLists.txt
===
--- compiler-rt/lib/asan/CMakeLists.txt
+++ compiler-rt/lib/asan/CMakeLists.txt
@@ -34,7 +34,6 @@
 
 if (NOT WIN32 AND NOT APPLE)
   list(APPEND ASAN_SOURCES
-asan_rtl_x86_64.S
 asan_interceptors_vfork.S
 )
 endif()
@@ -43,6 +42,12 @@
   asan_new_delete.cpp
   )
 
+if (NOT WIN32 AND NOT APPLE)
+  set(ASAN_DSO_SOURCES
+asan_rtl_x86_64.S
+  )
+endif()
+
 set(ASAN_PREINIT_SOURCES
   asan_preinit.cpp
   )
@@ -135,6 +140,12 @@
 ADDITIONAL_HEADERS ${ASAN_HEADERS}
 CFLAGS ${ASAN_CFLAGS}
 DEFS ${ASAN_COMMON_DEFINITIONS})
+  add_compiler_rt_object_libraries(RTAsan_dso
+ARCHS ${ASAN_SUPPORTED_ARCH}
+SOURCES ${ASAN_DSO_SOURCES}
+ADDITIONAL_HEADERS ${ASAN_HEADERS}
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS})
   add_compiler_rt_object_libraries(RTAsan_preinit
 ARCHS ${ASAN_SUPPORTED_ARCH}
 SOURCES ${ASAN_PREINIT_SOURCES}
@@ -207,6 +218,13 @@
 DEFS ${ASAN_COMMON_DEFINITIONS}
 PARENT_TARGET asan)
 
+  add_compiler_rt_runtime(clang_rt.asan_dso
+STATIC
+ARCHS ${ASAN_SUPPORTED_ARCH}
+OBJECT_LIBS RTAsan_dso
+CFLAGS ${ASAN_CFLAGS}
+DEFS ${ASAN_COMMON_DEFINITIONS}
+PARENT_TARGET asan)
   add_compiler_rt_runtime(clang_rt.asan-preinit
 STATIC
 ARCHS ${ASAN_SUPPORTED_ARCH}
Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -22,7 +22,7 @@
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-NO-LINK-RUNTIME-LINUX %s
 //
-// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan
+// CHECK-ASAN-NO-LINK-RUNTIME-LINUX-NOT: libclang_rt.asan-x86_64
 
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -826,6 +826,11 @@
   if (SanArgs.needsStatsRt() && SanArgs.linkRuntimes())
 StaticRuntimes.push_back("stats_client");
 
+  // Always link the DSO part of the runtime regardless of DSO or executable.
+  if (SanArgs.needsAsanRt()) {
+HelperStaticRuntimes.push_back("asan_dso");
+  }
+
   // Collect static runtimes.
   if (Args.hasArg(options::OPT_shared)) {
 // Don't link static runtimes into DSOs.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116183: [clang-format] Fix wrong indentation after trailing requires clause.

2021-12-22 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/52834.

Before this patch, clang-format would wrongly parse top-level entities (e.g. 
namespaces) and format:

  template
  constexpr void foo requires(I == 42) {}
  namespace ns {
  void foo() {}
  }  // namespace ns

into:

  

template
constexpr void foo requires(I == 42) {}
namespace ns {

  void foo() {}

}  // namespace ns

  with configuration:

NamespaceIndentation: None

  `


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116183

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3556,6 +3556,11 @@
"struct b_struct {};\n"
"} // namespace B\n",
Style);
+  verifyFormat("template  constexpr void foo requires(I == 42) {}\n"
+   "namespace ns {\n"
+   "void foo() {}\n"
+   "} // namespace ns\n",
+   Style);
 }
 
 TEST_F(FormatTest, NamespaceMacros) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1439,7 +1439,7 @@
   return;
 case tok::kw_requires:
   parseRequires();
-  break;
+  return;
 case tok::kw_enum:
   // Ignore if this is part of "template is(tok::less)) {


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3556,6 +3556,11 @@
"struct b_struct {};\n"
"} // namespace B\n",
Style);
+  verifyFormat("template  constexpr void foo requires(I == 42) {}\n"
+   "namespace ns {\n"
+   "void foo() {}\n"
+   "} // namespace ns\n",
+   Style);
 }
 
 TEST_F(FormatTest, NamespaceMacros) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1439,7 +1439,7 @@
   return;
 case tok::kw_requires:
   parseRequires();
-  break;
+  return;
 case tok::kw_enum:
   // Ignore if this is part of "template is(tok::less)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116085: [clang-tidy] Performance improvements for NOLINTBEGIN/END blocks

2021-12-22 Thread Salman Javed via Phabricator via cfe-commits
salman-javed-nz added a comment.

Thanks for taking a look. I will update the diff to address your comments. Have 
a good new years break.




Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:197
+  SourceLocation Loc = FileStartLoc.getLocWithOffset(
+  static_cast(Error.Message.FileOffset));
   return diag(Error.DiagnosticName, Loc, Error.Message.Message,

kadircet wrote:
> this change looks unrelated to the current patch.
I suppose it is. It's fixing a lint issue in a function used by the NOLINTBEGIN 
functionality, but not needed to implement the caching functionality. I don't 
have strong feelings about whether this change is bundled in this patch or not.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:602
EnableNolintBlocks)) {
-++Context.Stats.ErrorsIgnoredNOLINT;
+// Even though this diagnostic is suppressed, there may be other issues 
with
+// the file that need raising, such as unclosed NOLINT(BEGIN/END) blocks.

kadircet wrote:
> looks like an unrelated change, maybe move to a separate patch?
This is needed for this patch. The diagnostic in question may be suppressed 
(`shouldSuppressDiagnostic() = true`) but the cache generation could return 
errors to do with badly formed NOLINTBEGIN blocks for other checks in the file. 



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:76
+  // NOTE: at first glance, *it may seem* that this bool is redundant when the
+  // `Checks.empty()` method already exists.
+  // However, `Checks.empty()` cannot differentiate "NOLINT" from "NOLINT()".

kadircet wrote:
> similar to above is `NOLINT()` useful at all? maybe we should just not 
> generate such tokens?
`NOLINT()` is a pretty silly statement, but it is specially mentioned in the 
clang-tidy documentation.
I didn't want the parser to just swallow `NOLINT()`s as if they were never 
there, because I still want to pick up errors like:
```
// NOLINTBEGIN()
// NOLINTEND(some-check)
   ^
   Error: NOLINTEND does not match previous NOLINTBEGIN
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116085

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


[clang-tools-extra] 86618e3 - Resolve lint warning about converting unsigned to signed (NFC)

2021-12-22 Thread Salman Javed via cfe-commits

Author: Salman Javed
Date: 2021-12-23T09:46:14+13:00
New Revision: 86618e37bded924d0a7a06ef0818bb9b2311532d

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

LOG: Resolve lint warning about converting unsigned to signed (NFC)

FileOffset is unsigned while getLocWithOffset() requires a signed value.

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index b09079b5e8ba4..6c5054fdca28e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -193,7 +193,8 @@ DiagnosticBuilder ClangTidyContext::diag(const 
ClangTidyError &Error) {
   SM.getFileManager().getFile(Error.Message.FilePath);
   FileID ID = SM.getOrCreateFileID(*File, SrcMgr::C_User);
   SourceLocation FileStartLoc = SM.getLocForStartOfFile(ID);
-  SourceLocation Loc = FileStartLoc.getLocWithOffset(Error.Message.FileOffset);
+  SourceLocation Loc = FileStartLoc.getLocWithOffset(
+  static_cast(Error.Message.FileOffset));
   return diag(Error.DiagnosticName, Loc, Error.Message.Message,
   static_cast(Error.DiagLevel));
 }



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


[PATCH] D116186: Comment parsing: Simplify Lexer::skipLineStartingDecorations (NFC)

2021-12-22 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: gribozavr2.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Inspection of the first character can just be handled by the loop as
well, it does exactly the same thing. Dereferencing the pointer a second
time shouldn't be an issue: the middle end can eliminate that second
read as it's separated from the first only by a pure function call.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116186

Files:
  clang/lib/AST/CommentLexer.cpp


Index: clang/lib/AST/CommentLexer.cpp
===
--- clang/lib/AST/CommentLexer.cpp
+++ clang/lib/AST/CommentLexer.cpp
@@ -94,31 +94,12 @@
   if (BufferPtr == CommentEnd)
 return;
 
-  switch (*BufferPtr) {
-  case ' ':
-  case '\t':
-  case '\f':
-  case '\v': {
-const char *NewBufferPtr = BufferPtr;
-NewBufferPtr++;
-if (NewBufferPtr == CommentEnd)
+  const char *NewBufferPtr = BufferPtr;
+  while (isHorizontalWhitespace(*NewBufferPtr))
+if (++NewBufferPtr == CommentEnd)
   return;
-
-char C = *NewBufferPtr;
-while (isHorizontalWhitespace(C)) {
-  NewBufferPtr++;
-  if (NewBufferPtr == CommentEnd)
-return;
-  C = *NewBufferPtr;
-}
-if (C == '*')
-  BufferPtr = NewBufferPtr + 1;
-break;
-  }
-  case '*':
-BufferPtr++;
-break;
-  }
+  if (*NewBufferPtr == '*')
+BufferPtr = NewBufferPtr + 1;
 }
 
 namespace {


Index: clang/lib/AST/CommentLexer.cpp
===
--- clang/lib/AST/CommentLexer.cpp
+++ clang/lib/AST/CommentLexer.cpp
@@ -94,31 +94,12 @@
   if (BufferPtr == CommentEnd)
 return;
 
-  switch (*BufferPtr) {
-  case ' ':
-  case '\t':
-  case '\f':
-  case '\v': {
-const char *NewBufferPtr = BufferPtr;
-NewBufferPtr++;
-if (NewBufferPtr == CommentEnd)
+  const char *NewBufferPtr = BufferPtr;
+  while (isHorizontalWhitespace(*NewBufferPtr))
+if (++NewBufferPtr == CommentEnd)
   return;
-
-char C = *NewBufferPtr;
-while (isHorizontalWhitespace(C)) {
-  NewBufferPtr++;
-  if (NewBufferPtr == CommentEnd)
-return;
-  C = *NewBufferPtr;
-}
-if (C == '*')
-  BufferPtr = NewBufferPtr + 1;
-break;
-  }
-  case '*':
-BufferPtr++;
-break;
-  }
+  if (*NewBufferPtr == '*')
+BufferPtr = NewBufferPtr + 1;
 }
 
 namespace {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] d840f3e - Resolve -Wdocumentation warning in ClangTidyDiagnosticConsumer (NFC)

2021-12-22 Thread Salman Javed via cfe-commits

Author: Salman Javed
Date: 2021-12-23T10:25:05+13:00
New Revision: d840f3edf0297699e750413e629543c2a9271b90

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

LOG: Resolve -Wdocumentation warning in ClangTidyDiagnosticConsumer (NFC)

Change to comments only; NFC.

```
ClangTidyDiagnosticConsumer.h:245:6: warning: '\param' command used in a
comment that is not attached to a function declaration [-Wdocumentation]
```

See this build for an example:
https://lab.llvm.org/buildbot/#/builders/109/builds/27293/steps/5/logs/warnings__702_

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
index 23800f5622f6..69f1ceddd9bd 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -241,14 +241,12 @@ getFixIt(const tooling::Diagnostic &Diagnostic, bool 
AnyFix);
 
 /// A diagnostic consumer that turns each \c Diagnostic into a
 /// \c SourceManager-independent \c ClangTidyError.
-///
-/// \param EnableNolintBlocks Enables diagnostic-disabling inside blocks of
-/// code, delimited by NOLINTBEGIN and NOLINTEND.
-//
 // FIXME: If we move away from unit-tests, this can be moved to a private
 // implementation file.
 class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
 public:
+  /// \param EnableNolintBlocks Enables diagnostic-disabling inside blocks of
+  /// code, delimited by NOLINTBEGIN and NOLINTEND.
   ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx,
   DiagnosticsEngine *ExternalDiagEngine = nullptr,
   bool RemoveIncompatibleErrors = true,



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


[PATCH] D116137: [clang-tidy] Remove dead plugin code

2021-12-22 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

If this code is truly dead, this looks fine to me.

But IIRC D97693  was about no longer linking 
clang-tidy into libclang, while clang-tidy/plugin/ClangTidyPlugin.cpp (if I 
read the comments therein right) is for using clang-tidy as a clang plugin. 
Those are two separate things I think (?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116137

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


[PATCH] D116183: [clang-format] Fix wrong indentation after trailing requires clause.

2021-12-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

I really need to get my requires patch done...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116183

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


[PATCH] D116170: [clang-format] Add penalty for breaking after '('

2021-12-22 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

And initialize the value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116170

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


[PATCH] D113530: [wip] [analyzer] support use-after-free checking with parameter annotation

2021-12-22 Thread Chris D'Angelo via Phabricator via cfe-commits
chrisdangelo updated this revision to Diff 395926.
chrisdangelo added a comment.

"I think it makes sense to simply copy that file and replace function 
attributes with parameter attributes and see if it still passes." - @NoQ (Tue, 
Dec 21, 12:28 PM)

Sounds good. This newest change adds malloc-annotations-param.c and 
malloc-annotations-param.cpp.

This change begins work to use ownership_takes and ownership_holds parameter 
attributes for the same tests still using function attributes in 
malloc-annotations.c and malloc-annotations.cpp respectively.

Note that this is just the beginning of the work to test parameter based 
ownership attributes. There are many misuse scenarios that are currently not 
supported in these changes, and not tested.

I've explained a bit more below, and plan to explain a bit more on the comment 
coinciding with the next Differential attachment.

"Do we also need to convert ownership_holds to parameter attribute? I think it 
doesn't make sense to deprecate until we convert all of them." - @NoQ (Tue, Dec 
21, 12:28 PM)

ownership_holds is expected to be functioning. However, there are several 
misuse scenarios that I've not yet accounted for.

Example 1: What happens if the developer uses the function attribute and 
parameter attribute on the same parameter with different ownership types?

Example 2: What happens if the developer uses multiple parameter attributes of 
varying owernship types on the same parameter?

Additionally, ownership_returns compile-time or analysis-time validation is not 
completely or correctly supported today. For example, nothing prevents the 
developer from attempting to apply ownership_returns to a parameter in a 
function.

-

These changes have been tested by successfully running `ninja 
check-clang-analysis`.


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

https://reviews.llvm.org/D113530

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/test/Analysis/malloc-annotations-param.c
  clang/test/Analysis/malloc-annotations-param.cpp
  clang/test/Analysis/malloc-annotations.c

Index: clang/test/Analysis/malloc-annotations.c
===
--- clang/test/Analysis/malloc-annotations.c
+++ clang/test/Analysis/malloc-annotations.c
@@ -271,5 +271,4 @@
   int *p = malloc(12);
   int *q = malloc(12);
   my_freeBoth(p, q);
-}
-
+}
\ No newline at end of file
Index: clang/test/Analysis/malloc-annotations-param.cpp
===
--- /dev/null
+++ clang/test/Analysis/malloc-annotations-param.cpp
@@ -0,0 +1,98 @@
+// RUN: %clang_analyze_cc1 -analyzer-store=region -verify \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.deadcode.UnreachableCode \
+// RUN:   -analyzer-checker=alpha.core.CastSize \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-config unix.DynamicMemoryModeling:Optimistic=true %s
+
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+
+struct MemoryAllocator {
+  void __attribute((ownership_returns(malloc))) * my_malloc(size_t);
+  void __attribute((ownership_takes(malloc, 2))) my_free(void *);
+  void __attribute((ownership_holds(malloc, 2))) my_hold(void *);
+};
+
+void *myglobalpointer;
+
+struct stuff {
+  void *somefield;
+};
+
+struct stuff myglobalstuff;
+
+void af1(MemoryAllocator &Alloc) {
+  void *p = Alloc.my_malloc(12);
+  return; // expected-warning{{Potential leak of memory pointed to by}}
+}
+
+void af1_b(MemoryAllocator &Alloc) {
+  void *p = Alloc.my_malloc(12);
+} // expected-warning{{Potential leak of memory pointed to by}}
+
+void af1_c(MemoryAllocator &Alloc) {
+  myglobalpointer = Alloc.my_malloc(12); // no-warning
+}
+
+// Test that we can pass out allocated memory via pointer-to-pointer.
+void af1_e(MemoryAllocator &Alloc, void **pp) {
+  *pp = Alloc.my_malloc(42); // no-warning
+}
+
+void af1_f(MemoryAllocator &Alloc, struct stuff *somestuff) {
+  somestuff->somefield = Alloc.my_malloc(12); // no-warning
+}
+
+// Allocating memory for a field via multiple indirections to our arguments is OK.
+void af1_g(MemoryAllocator &Alloc, struct stuff **pps) {
+  *pps = (struct stuff *)Alloc.my_malloc(sizeof(struct stuff)); // no-warning
+  (*pps)->somefield = Alloc.my_malloc(42);  // no-warning
+}
+
+void af2(MemoryAllocator &Alloc) {
+  void *p = Alloc.my_malloc(12);
+  Alloc.my_free(p);
+  free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2b(MemoryAllocator &Alloc) {
+  void *p = Alloc.my_malloc(12);
+  free(p);
+  Alloc.my_free(p); // expected-warning{{Attempt to free released memory}}
+}
+
+void af2c(MemoryAllocator &Alloc) {
+  void *p = Alloc.my_malloc(12);
+  free(p);
+  Alloc.my_hold(p); // expected-warning{{Attempt to free released memory}}
+}
+
+// No leak if malloc returns null.
+void af2e(MemoryAll

[PATCH] D115561: [Clang][OpenMP] Add the support for atomic compare in parser

2021-12-22 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 395929.
tianshilei1992 added a comment.

just emit the error but not return


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115561

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/atomic_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -180,6 +180,7 @@
 def OMPC_Write : Clause<"write"> { let clangClass = "OMPWriteClause"; }
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
+def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -536,6 +537,7 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause
   ];
   let allowedOnceClauses = [
 VersionedClause,
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -1482,6 +1482,7 @@
 CHECK_SIMPLE_CLAUSE(MemoryOrder, OMPC_memory_order)
 CHECK_SIMPLE_CLAUSE(Bind, OMPC_bind)
 CHECK_SIMPLE_CLAUSE(Align, OMPC_align)
+CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2275,6 +2275,8 @@
 
 void OMPClauseEnqueue::VisitOMPCaptureClause(const OMPCaptureClause *) {}
 
+void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/test/OpenMP/atomic_messages.cpp
===
--- clang/test/OpenMP/atomic_messages.cpp
+++ clang/test/OpenMP/atomic_messages.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -ferror-limit 150 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50,omp51 -fopenmp -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
 
 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -ferror-limit 150 %s -Wuninitialized
 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -ferror-limit 150 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50,omp51 -fopenmp-simd -fopenmp-version=51 -ferror-limit 150 %s -Wuninitialized
 
 int foo() {
 L1:
@@ -896,19 +898,19 @@
 template 
 T mixed() {
   T a, b = T();
-// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
 // expected-note@+1 2 {{'read' clause used here}}
 #pragma omp atomic read write
   a = b;
-// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
 // expected-note@+1 2 {{'write' clause used here}}
 #pragma omp atomic write read
   a = b;
-// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update' or 'capture' clause}}
+// expected-error@+2 2 {{directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause}}
 // expected-note@+1 2 {{'update' clause used here}}
 #pragma omp atomic update read
   a += b;
-// expected-error@+2 2 {{directive '#pragma omp atomi

[PATCH] D116188: [clang-format] Fix short enums getting wrapped even when denied

2021-12-22 Thread Gabriel Smith via Phabricator via cfe-commits
yodaldevoid created this revision.
yodaldevoid added reviewers: HazardyKnusperkeks, MyDeveloperDay, curdeius, 
owenpan.
yodaldevoid requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Single-variant enums were still getting placed on a single line even
when AllowShortEnumsOnASingleLine was false. This fixes that by checking
that setting when looking to merge lines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116188

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2511,6 +2511,10 @@
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -393,11 +393,16 @@
 
 // Try to merge a block with left brace wrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
+  const FormatToken *Tok = TheLine->First;
   bool ShouldMerge = false;
-  if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {
+  if (Tok && Tok->is(tok::kw_typedef))
+Tok = Tok->getNextNonComment();
+  if (Tok && Tok->isOneOf(tok::kw_class, tok::kw_struct)) {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (I[1]->First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
+  } else if (Tok && Tok->is(tok::kw_enum)) {
+ShouldMerge = Style.AllowShortEnumsOnASingleLine;
   } else {
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
   (I[1]->First->is(tok::r_brace) &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2511,6 +2511,10 @@
"  C\n"
"} ShortEnum1, ShortEnum2;",
Style);
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -393,11 +393,16 @@
 
 // Try to merge a block with left brace wrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
+  const FormatToken *Tok = TheLine->First;
   bool ShouldMerge = false;
-  if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {
+  if (Tok && Tok->is(tok::kw_typedef))
+Tok = Tok->getNextNonComment();
+  if (Tok && Tok->isOneOf(tok::kw_class, tok::kw_struct)) {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (I[1]->First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
+  } else if (Tok && Tok->is(tok::kw_enum)) {
+ShouldMerge = Style.AllowShortEnumsOnASingleLine;
   } else {
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
   (I[1]->First->is(tok::r_brace) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116189: [clang-format][NFC] Correct comment about checking merging of blocks

2021-12-22 Thread Gabriel Smith via Phabricator via cfe-commits
yodaldevoid created this revision.
yodaldevoid added reviewers: HazardyKnusperkeks, MyDeveloperDay, curdeius, 
owenpan.
yodaldevoid requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116189

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -391,7 +391,7 @@
   }
 }
 
-// Try to merge a block with left brace wrapped that wasn't yet covered
+// Try to merge a block with left brace unwrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
   bool ShouldMerge = false;
   if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -391,7 +391,7 @@
   }
 }
 
-// Try to merge a block with left brace wrapped that wasn't yet covered
+// Try to merge a block with left brace unwrapped that wasn't yet covered
 if (TheLine->Last->is(tok::l_brace)) {
   bool ShouldMerge = false;
   if (TheLine->First->isOneOf(tok::kw_class, tok::kw_struct)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116190: Comment parsing: Don't recognize commands in single-line double quotation

2021-12-22 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: gribozavr2.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is consistent with the behavior of Doxygen, and allows users to
write strings with C escapes or document input/output formats containing
special characters (@ or \) without escaping them, which might be
confusing. For example, if a function wants to document its expected
input format as "user@host" it doesn't have to write user\@host instead,
which would look right in the documentation but confusing in the code.
Now users can just use double quotes (which they might do anyway).

This fixes a lot of false positives of -Wdocumentation-unknown-command,
but it could also fix issues with -Wdocumentation if the text triggers
an actual command.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116190

Files:
  clang/include/clang/AST/CommentLexer.h
  clang/lib/AST/CommentLexer.cpp
  clang/test/Sema/warn-documentation-unknown-command.cpp
  clang/test/Sema/warn-documentation.cpp

Index: clang/test/Sema/warn-documentation.cpp
===
--- clang/test/Sema/warn-documentation.cpp
+++ clang/test/Sema/warn-documentation.cpp
@@ -125,6 +125,16 @@
 /// \brief \c Aaa
 int test_block_command6(int);
 
+// We don't recognize comments in double quotes.
+/// "\brief \returns Aaa"
+int test_block_command7(int);
+
+// But only if they're single-line. (Doxygen treats multi-line quotes inconsistently.)
+// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
+/// "\brief
+/// \returns Aaa"
+int test_block_command8(int);
+
 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}}
 /// \brief Aaa
 ///
Index: clang/test/Sema/warn-documentation-unknown-command.cpp
===
--- clang/test/Sema/warn-documentation-unknown-command.cpp
+++ clang/test/Sema/warn-documentation-unknown-command.cpp
@@ -9,6 +9,15 @@
 /// \retur aaa
 int test_unknown_comand_2();
 
+/// We don't recognize commands in double quotes: "\n\t @unknown2".
+int test_unknown_comand_3();
+
+// expected-warning@+2 {{unknown command tag name}}
+// expected-warning@+2 {{unknown command tag name}}
+/// But it has to be a single line: "\unknown3
+/// @unknown4" (Doxygen treats multi-line quotes inconsistently.)
+int test_unknown_comand_4();
+
 // RUN: c-index-test -test-load-source all -Wdocumentation-unknown-command %s > /dev/null 2> %t.err
 // RUN: FileCheck < %t.err -check-prefix=CHECK-RANGE %s
 // CHECK-RANGE: warn-documentation-unknown-command.cpp:5:9:{5:9-5:17}: warning: unknown command tag name
Index: clang/lib/AST/CommentLexer.cpp
===
--- clang/lib/AST/CommentLexer.cpp
+++ clang/lib/AST/CommentLexer.cpp
@@ -270,6 +270,29 @@
   BufferPtr = TokEnd;
 }
 
+const char *Lexer::skipTextToken() {
+  const char *TokenPtr = BufferPtr;
+  assert(TokenPtr < CommentEnd);
+  StringRef TokStartSymbols = ParseCommands ? "\n\r\\@\"&<" : "\n\r";
+
+again:
+  size_t End =
+  StringRef(TokenPtr, CommentEnd - TokenPtr).find_first_of(TokStartSymbols);
+  if (End == StringRef::npos)
+return CommentEnd;
+
+  // Doxygen doesn't recognize any commands in a one-line double quotation.
+  // If we don't find an ending quotation mark, we pretend it never began.
+  if (*(TokenPtr + End) == '\"') {
+TokenPtr += End + 1;
+End = StringRef(TokenPtr, CommentEnd - TokenPtr).find_first_of("\n\r\"");
+if (End != StringRef::npos && *(TokenPtr + End) == '\"')
+  TokenPtr += End + 1;
+goto again;
+  }
+  return TokenPtr + End;
+}
+
 void Lexer::lexCommentText(Token &T) {
   assert(CommentState == LCS_InsideBCPLComment ||
  CommentState == LCS_InsideCComment);
@@ -290,17 +313,8 @@
 skipLineStartingDecorations();
   return;
 
-  default: {
-  StringRef TokStartSymbols = ParseCommands ? "\n\r\\@&<" : "\n\r";
-  size_t End = StringRef(TokenPtr, CommentEnd - TokenPtr)
-   .find_first_of(TokStartSymbols);
-  if (End != StringRef::npos)
-TokenPtr += End;
-  else
-TokenPtr = CommentEnd;
-  formTextToken(T, TokenPtr);
-  return;
-  }
+  default:
+return formTextToken(T, skipTextToken());
 }
   };
 
Index: clang/include/clang/AST/CommentLexer.h
===
--- clang/include/clang/AST/CommentLexer.h
+++ clang/include/clang/AST/CommentLexer.h
@@ -320,6 +320,9 @@
   /// Eat string matching regexp \code \s*\* \endcode.
   void skipLineStartingDecorations();
 
+  /// Skip over pure text.
+  const char *skipTextToken();
+
   /// Lex comment text, including commands if ParseCommands is set to true.
   void lexCommentText(Token &T);
 
___

  1   2   >