[PATCH] D82365: [Power10] Implement Vector Insert Builtins in LLVM/Clang

2020-07-03 Thread Biplob Mishra via Phabricator via cfe-commits
biplmish marked an inline comment as done.
biplmish added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:12
+// RUN:   -target-cpu pwr10 -triple powerpc64le-unknown-unknown -emit-llvm %s \
+// RUN:   -o - | FileCheck %s -check-prefix=CHECK-LE
+

lei wrote:
> I just noticed this.  There is no need to add this RUN line since it's the 
> same as the one on line 2.  Please post a patch to remove this and update 
> tests to use the default `CHECK`.
Sure. However there are also tests in Line 125,133 etc which would need 
modification.

Can we also do "RUN:   -o - | FileCheck %s -check-prefixes=CHECK,CHECK-LE" in 
the test1 and remove the test3 so that the tests work in the current format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82365



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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-07-03 Thread Keith Smiley via Phabricator via cfe-commits
keith added a comment.

Open question: I don't know how all the toolchains fit together, but I noticed 
that only Clang.cpp handles -fmacro-prefix-map, but Clang.cpp, FreeBSD.cpp, and 
Gnu.cpp all handle -fdebug-prefix-map. I wasn't sure which pattern I should 
follow here, so right now this only adds the handling to Clang.cpp, please let 
me know if that's not appropriate in this case!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83154



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


[PATCH] D83154: clang: Add -fcoverage-prefix-map

2020-07-03 Thread Keith Smiley via Phabricator via cfe-commits
keith created this revision.
keith added reviewers: vsk, arphaman, rnk.
Herald added a subscriber: dexonsmith.
Herald added a project: clang.
keith added a comment.

Open question: I don't know how all the toolchains fit together, but I noticed 
that only Clang.cpp handles -fmacro-prefix-map, but Clang.cpp, FreeBSD.cpp, and 
Gnu.cpp all handle -fdebug-prefix-map. I wasn't sure which pattern I should 
follow here, so right now this only adds the handling to Clang.cpp, please let 
me know if that's not appropriate in this case!


This flag allows you to re-write absolute paths in coverage data analogous to 
-fdebug-prefix-map. This flag is also implied by -ffile-prefix-map.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83154

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CoverageMapping/coverage-prefix-map.c
  clang/test/Driver/debug-prefix-map.c

Index: clang/test/Driver/debug-prefix-map.c
===
--- clang/test/Driver/debug-prefix-map.c
+++ clang/test/Driver/debug-prefix-map.c
@@ -1,28 +1,39 @@
 // RUN: %clang -### -fdebug-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-INVALID
 // RUN: %clang -### -fmacro-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-INVALID
+// RUN: %clang -### -fcoverage-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-INVALID
 // RUN: %clang -### -ffile-prefix-map=old %s 2>&1 | FileCheck %s -check-prefix CHECK-FILE-INVALID
 
 // RUN: %clang -### -fdebug-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
 // RUN: %clang -### -fmacro-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
+// RUN: %clang -### -fcoverage-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-SIMPLE
 // RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-SIMPLE
 // RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-SIMPLE
+// RUN: %clang -### -ffile-prefix-map=old=new %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-SIMPLE
 
 // RUN: %clang -### -fdebug-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
 // RUN: %clang -### -fmacro-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
+// RUN: %clang -### -fcoverage-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-COMPLEX
 // RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-COMPLEX
 // RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-COMPLEX
+// RUN: %clang -### -ffile-prefix-map=old=n=ew %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-COMPLEX
 
 // RUN: %clang -### -fdebug-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
 // RUN: %clang -### -fmacro-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
+// RUN: %clang -### -fcoverage-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-EMPTY
 // RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-DEBUG-EMPTY
 // RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-MACRO-EMPTY
+// RUN: %clang -### -ffile-prefix-map=old= %s 2>&1 | FileCheck %s -check-prefix CHECK-COVERAGE-EMPTY
 
 // CHECK-DEBUG-INVALID: error: invalid argument 'old' to -fdebug-prefix-map
 // CHECK-MACRO-INVALID: error: invalid argument 'old' to -fmacro-prefix-map
+// CHECK-COVERAGE-INVALID: error: invalid argument 'old' to -fcoverage-prefix-map
 // CHECK-FILE-INVALID: error: invalid argument 'old' to -ffile-prefix-map
 // CHECK-DEBUG-SIMPLE: fdebug-prefix-map=old=new
 // CHECK-MACRO-SIMPLE: fmacro-prefix-map=old=new
+// CHECK-COVERAGE-SIMPLE: fcoverage-prefix-map=old=new
 // CHECK-DEBUG-COMPLEX: fdebug-prefix-map=old=n=ew
 // CHECK-MACRO-COMPLEX: fmacro-prefix-map=old=n=ew
+// CHECK-COVERAGE-COMPLEX: fcoverage-prefix-map=old=n=ew
 // CHECK-DEBUG-EMPTY: fdebug-prefix-map=old=
 // CHECK-MACRO-EMPTY: fmacro-prefix-map=old=
+// CHECK-COVERAGE-EMPTY: fcoverage-prefix-map=old=
Index: clang/test/CoverageMapping/coverage-prefix-map.c
===
--- /dev/null
+++ clang/test/CoverageMapping/coverage-prefix-map.c
@@ -0,0 +1,14 @@
+// %s expands to an absolute path, so to test relative paths we need to create a
+// clean directory, put the source there, and cd into it.
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/root/nested
+// RUN: echo "void f1() {}" > %t/root/nested/coverage-prefix-map.c
+// RUN: cd %t/root
+
+// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping -emit-llvm -mllvm -enable-name-compression=false -main-f

[PATCH] D81122: Reland: Use -fdebug-compilation-dir to form absolute paths in coverage mappings

2020-07-03 Thread Keith Smiley via Phabricator via cfe-commits
keith abandoned this revision.
keith added a comment.

https://reviews.llvm.org/D83154


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81122



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


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

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1908
   // The align if the field is not packed. This is to check if the attribute
   // was unnecessary (-Wpacked).
   CharUnits UnpackedFieldAlign = FieldAlign;

Testing using my build with this patch seems to indicate that tracking 
`FieldAlign` for `UnpackedFieldAlign` does not lead to the desired result.

The `QQ` and `ZZ` cases differ only on the `packed` attribute on `Q`. They are 
observed to have different sizes; however, we get a `-Wpacked` diagnostic 
claiming that the `packed` attribute was unnecessary (and could therefore be 
removed).

```
struct [[gnu::packed]] Q {
  double x [[gnu::aligned(4)]];
};
struct QQ : Q { char x; };

struct Z {
  double x [[gnu::aligned(4)]];
};
struct ZZ : Z { char x; };

extern char qx[sizeof(QQ)];
extern char qx[12];
extern char qz[sizeof(ZZ)];
extern char qz[16];
```

```
:1:24: warning: packed attribute is unnecessary for 'Q' [-Wpacked]
struct [[gnu::packed]] Q {
   ^
1 warning generated.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D83149: [gcov] Add __gcov_dump/__gcov_reset and delete __gcov_flush

2020-07-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: calixte, marco-c, serge-sans-paille, vsk.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, hiraditya.
Herald added projects: clang, Sanitizers, LLVM.

GCC r187297 (2012-05) introduced __gcov_dump and __gcov_reset.

  __gcov_flush = __gcov_dump + __gcov_reset

https://gcc.gnu.org/PR93623 (target GCC 11.0) removed the unuseful and 
undocumented __gcov_flush.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83149

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld.c
  compiler-rt/lib/profile/GCDAProfiling.c
  compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c
  compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main.c.gcov
  
compiler-rt/test/profile/Inputs/instrprof-dlopen-dlclose-main_three-libs.c.gcov
  compiler-rt/test/profile/Posix/gcov-shared-flush.c
  compiler-rt/test/profile/gcov-__gcov_flush-terminate.c
  compiler-rt/test/profile/gcov-dump-and-remove.c
  llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -130,7 +130,6 @@
   Function *
   insertCounterWriteout(ArrayRef>);
   Function *insertReset(ArrayRef>);
-  Function *insertFlush(Function *ResetF);
 
   bool AddFlushBeforeForkAndExec();
 
@@ -909,7 +908,6 @@
 
 Function *WriteoutF = insertCounterWriteout(CountersBySP);
 Function *ResetF = insertReset(CountersBySP);
-Function *FlushF = insertFlush(ResetF);
 
 // Create a small bit of code that registers the "__llvm_gcov_writeout" to
 // be executed at exit and the "__llvm_gcov_flush" function to be executed
@@ -927,14 +925,13 @@
 IRBuilder<> Builder(BB);
 
 FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
-Type *Params[] = {PointerType::get(FTy, 0), PointerType::get(FTy, 0),
-  PointerType::get(FTy, 0)};
-FTy = FunctionType::get(Builder.getVoidTy(), Params, false);
+auto *PFTy = PointerType::get(FTy, 0);
+FTy = FunctionType::get(Builder.getVoidTy(), {PFTy, PFTy}, false);
 
 // Initialize the environment and register the local writeout, flush and
 // reset functions.
 FunctionCallee GCOVInit = M->getOrInsertFunction("llvm_gcov_init", FTy);
-Builder.CreateCall(GCOVInit, {WriteoutF, FlushF, ResetF});
+Builder.CreateCall(GCOVInit, {WriteoutF, ResetF});
 Builder.CreateRetVoid();
 
 appendToGlobalCtors(*M, F, 0);
@@ -1266,36 +1263,3 @@
 
   return ResetF;
 }
-
-Function *GCOVProfiler::insertFlush(Function *ResetF) {
-  FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), false);
-  Function *FlushF = M->getFunction("__llvm_gcov_flush");
-  if (!FlushF)
-FlushF = Function::Create(FTy, GlobalValue::InternalLinkage,
-  "__llvm_gcov_flush", M);
-  FlushF->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
-  FlushF->addFnAttr(Attribute::NoInline);
-  if (Options.NoRedZone)
-FlushF->addFnAttr(Attribute::NoRedZone);
-
-  BasicBlock *Entry = BasicBlock::Create(*Ctx, "entry", FlushF);
-
-  // Write out the current counters.
-  Function *WriteoutF = M->getFunction("__llvm_gcov_writeout");
-  assert(WriteoutF && "Need to create the writeout function first!");
-
-  IRBuilder<> Builder(Entry);
-  Builder.CreateCall(WriteoutF, {});
-  Builder.CreateCall(ResetF, {});
-
-  Type *RetTy = FlushF->getReturnType();
-  if (RetTy->isVoidTy())
-Builder.CreateRetVoid();
-  else if (RetTy->isIntegerTy())
-// Used if __llvm_gcov_flush was implicitly declared.
-Builder.CreateRet(ConstantInt::get(RetTy, 0));
-  else
-report_fatal_error("invalid return type for __llvm_gcov_flush");
-
-  return FlushF;
-}
Index: compiler-rt/test/profile/gcov-dump-and-remove.c
===
--- compiler-rt/test/profile/gcov-dump-and-remove.c
+++ compiler-rt/test/profile/gcov-dump-and-remove.c
@@ -8,16 +8,19 @@
 // RUN: rm -f gcov-dump-and-remove.gcda && %run %t
 // RUN: llvm-cov gcov -t gcov-dump-and-remove.gcda | FileCheck %s
 
-extern void __gcov_flush(void);
+extern void __gcov_dump(void);
+extern void __gcov_reset(void);
 extern int remove(const char *);   // CHECK:  -: [[#@LINE]]:extern int remove
 int main(void) {   // CHECK-NEXT: #: [[#@LINE]]:
-  __gcov_flush();  // CHECK-NEXT: #: [[#@LINE]]:
+  __gcov_dump();   // CHECK-NEXT: #: [[#@LINE]]:
+  __gcov_reset();  // CHECK-NEXT: #: [[#@LINE]]:
   if (remove("gcov-dump-and-remove.gcda") != 0) // CHECK-NEXT: #: [[#@LINE]]:
 return 1;  // CHECK-NEXT: #: [[#@LINE]]: return 1;
// CHECK-NEXT: -: [[#@LINE]]:
-  __gcov_flush();  // CHECK-NEXT: 

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

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1235
 
+  // Do not use AIX special alignment if current base is not the first member 
or
+  // the struct is not a union.

hubert.reinterpretcast wrote:
> hubert.reinterpretcast wrote:
> > Suggestion:
> > ```
> >   // AIX `power` alignment does not apply the preferred alignment for 
> > non-union
> >   // classes if the source of the alignment (the current base in this 
> > context)
> >   // follows introduction of the first member with allocated space.
> > ```
> Adjustment to my suggestion:
> s/first member with allocated space/first subobject with exclusively 
> allocated space/;
Add:
[ ... ] or zero-extent array.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


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

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1877
+  CharUnits PreferredAlign = FieldAlign;
+  if (SupportsAIXPowerAlignment && FieldOffset == CharUnits::Zero() &&
+  (IsUnion || FoundNonOverlappingEmptyField)) {

This `if` condition does not currently capture that a zero-extent array in a 
base class renders the base class not empty.

```
struct Z { char zea[0]; };
struct A {
  Z z [[no_unique_address]];
  double d;
};
struct B : Z { double d; };
static_assert(__alignof__(A) == __alignof__(B));
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


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

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



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

Xiangling_L wrote:
> hubert.reinterpretcast wrote:
> > Xiangling_L wrote:
> > > hubert.reinterpretcast wrote:
> > > > I am concerned that none of the tests actually create an instance of 
> > > > the classes under test and check the alignment (or related adjustments) 
> > > > in the IR. That is, we set up the preferred alignment value but don't 
> > > > check that we use it where we should.
> > > > 
> > > > As it is, it seems array new/delete has problems:
> > > > ```
> > > > #include 
> > > > extern "C" void *calloc(decltype(sizeof 0), decltype(sizeof 0));
> > > > extern "C" void free(void *);
> > > > extern "C" int printf(const char *, ...);
> > > > 
> > > > extern void *allocated_ptr;
> > > > extern decltype(sizeof 0) allocated_size;
> > > > struct B {
> > > >   double d;
> > > >   ~B() {}
> > > >   static void *operator new[](decltype(sizeof 0) sz);
> > > >   static void operator delete[](void *p, decltype(sizeof 0) sz);
> > > > };
> > > > B *allocBp();
> > > > 
> > > > #ifdef ALLOCBP
> > > > void *allocated_ptr;
> > > > decltype(sizeof 0) allocated_size;
> > > > void *B::operator new[](decltype(sizeof 0) sz) {
> > > >   void *alloc = calloc(1u, allocated_size = sz);
> > > >   printf("%p: %s\n", alloc, __PRETTY_FUNCTION__);
> > > >   printf("%zu\n", sz);
> > > >   return allocated_ptr = alloc;
> > > > }
> > > > void B::operator delete[](void *p, decltype(sizeof 0) sz) {
> > > >   printf("%p: %s\n", p, __PRETTY_FUNCTION__);
> > > >   printf("%zu\n", sz);
> > > >   assert(sz == allocated_size);
> > > >   assert(p == allocated_ptr);
> > > >   free(p);
> > > > }
> > > > B *allocBp() { return new B[2]; }
> > > > #endif
> > > > 
> > > > #ifdef MAIN
> > > > int main(void) { delete[] allocBp(); }
> > > > #endif
> > > > ```
> > > > 
> > > > The `xlclang++` invocation from XL C/C++ generates padding before the 
> > > > 32-bit `new[]` cookie. I'm not seeing that padding with this patch.
> > > Thank. I will create more practical testcases as you mentioned in your 
> > > concern. And regarding to `padding before the 32-bit new[] cookie` issue, 
> > > I am wondering is that part of `power` alignment rule or what rules do we 
> > > follow to generate this kind of padding?
> > The padding has to do with the alignment. The allocation function returns 
> > 8-byte aligned memory. The 32-bit cookie takes 4 of the first 8 bytes. The 
> > type's preferred alignment is 8, so there are 4 bytes of padding.
> Regarding with checking the alignment where we use them, AFAIK the 
> problematic cases include not only the `cookie padding` issue you mentioned 
> here, but also the alignment of argument type, return type etc.
> 
> So I am wondering does it make sense to have them handled in a separate patch 
> since this is already a big one? We can use this patch to implement the 
> correct value of `__alignof` and `alignof` and use a second patch to handle 
> the places where `we use them where we should`?
> 
Yes, we can scope the patch that way somewhat; however, some cases of "[using 
the `__alignof__` value] where we should" that is missing is within the 
determination of the base and field offsets. We should keep those within the 
scope of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D68076: [AArch64] Enable unwind tables by default for Gnu targets

2020-07-03 Thread David Tellenbach via Phabricator via cfe-commits
tellenbach added a comment.

In D68076#2131108 , @hiraditya wrote:

> do we have a plan to follow up on this patch?


Hi! I'm currently not working on this (and LLVM in general) anymore. However, 
the issue seems to be still present and this patch would fix it. I have in mind 
that I've checked GCC recently and they seem to do something similar. I can 
check again but will probably take some time.

Thanks for bringing this up again!


Repository:
  rC Clang

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

https://reviews.llvm.org/D68076



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


[PATCH] D68076: [AArch64] Enable unwind tables by default for Gnu targets

2020-07-03 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya added a comment.
Herald added a subscriber: danielkiss.

do we have a plan to follow up on this patch?


Repository:
  rC Clang

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

https://reviews.llvm.org/D68076



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


[clang] e359ab1 - [PowerPC][NFC] Fix indentation

2020-07-03 Thread Lei Huang via cfe-commits

Author: Lei Huang
Date: 2020-07-03T16:47:24-05:00
New Revision: e359ab1eca5727ce4c688bb49323b8a09478d61c

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

LOG: [PowerPC][NFC] Fix indentation

Added: 


Modified: 
clang/lib/Headers/altivec.h
llvm/lib/Target/PowerPC/PPCInstrPrefix.td

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 38d5c00a7981..a63f2ee359fd 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16918,8 +16918,9 @@ vec_insertl(unsigned int __a, vector unsigned int __b, 
unsigned int __c) {
 #endif
 }
 
-static __inline__ vector unsigned long long __ATTRS_o_ai vec_insertl(
-unsigned long long __a, vector unsigned long long __b, unsigned int __c) {
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_insertl(unsigned long long __a, vector unsigned long long __b,
+unsigned int __c) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vinsdrx(__b, __c, __a);
 #else
@@ -16927,8 +16928,9 @@ static __inline__ vector unsigned long long 
__ATTRS_o_ai vec_insertl(
 #endif
 }
 
-static __inline__ vector unsigned char __ATTRS_o_ai vec_insertl(
-vector unsigned char __a, vector unsigned char __b, unsigned int __c) {
+static __inline__ vector unsigned char __ATTRS_o_ai
+vec_insertl(vector unsigned char __a, vector unsigned char __b,
+unsigned int __c) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vinsbvrx(__b, __c, __a);
 #else
@@ -16936,8 +16938,9 @@ static __inline__ vector unsigned char __ATTRS_o_ai 
vec_insertl(
 #endif
 }
 
-static __inline__ vector unsigned short __ATTRS_o_ai vec_insertl(
-vector unsigned short __a, vector unsigned short __b, unsigned int __c) {
+static __inline__ vector unsigned short __ATTRS_o_ai
+vec_insertl(vector unsigned short __a, vector unsigned short __b,
+unsigned int __c) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vinshvrx(__b, __c, __a);
 #else
@@ -16945,8 +16948,9 @@ static __inline__ vector unsigned short __ATTRS_o_ai 
vec_insertl(
 #endif
 }
 
-static __inline__ vector unsigned int __ATTRS_o_ai vec_insertl(
-vector unsigned int __a, vector unsigned int __b, unsigned int __c) {
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_insertl(vector unsigned int __a, vector unsigned int __b,
+unsigned int __c) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vinswvrx(__b, __c, __a);
 #else
@@ -16983,8 +16987,9 @@ vec_inserth(unsigned int __a, vector unsigned int __b, 
unsigned int __c) {
 #endif
 }
 
-static __inline__ vector unsigned long long __ATTRS_o_ai vec_inserth(
-unsigned long long __a, vector unsigned long long __b, unsigned int __c) {
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_inserth(unsigned long long __a, vector unsigned long long __b,
+unsigned int __c) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vinsdlx(__b, __c, __a);
 #else
@@ -16992,8 +16997,9 @@ static __inline__ vector unsigned long long 
__ATTRS_o_ai vec_inserth(
 #endif
 }
 
-static __inline__ vector unsigned char __ATTRS_o_ai vec_inserth(
-vector unsigned char __a, vector unsigned char __b, unsigned int __c) {
+static __inline__ vector unsigned char __ATTRS_o_ai
+vec_inserth(vector unsigned char __a, vector unsigned char __b,
+unsigned int __c) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vinsbvlx(__b, __c, __a);
 #else
@@ -17001,8 +17007,9 @@ static __inline__ vector unsigned char __ATTRS_o_ai 
vec_inserth(
 #endif
 }
 
-static __inline__ vector unsigned short __ATTRS_o_ai vec_inserth(
-vector unsigned short __a, vector unsigned short __b, unsigned int __c) {
+static __inline__ vector unsigned short __ATTRS_o_ai
+vec_inserth(vector unsigned short __a, vector unsigned short __b,
+unsigned int __c) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vinshvlx(__b, __c, __a);
 #else
@@ -17010,8 +17017,9 @@ static __inline__ vector unsigned short __ATTRS_o_ai 
vec_inserth(
 #endif
 }
 
-static __inline__ vector unsigned int __ATTRS_o_ai vec_inserth(
-vector unsigned int __a, vector unsigned int __b, unsigned int __c) {
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_inserth(vector unsigned int __a, vector unsigned int __b,
+unsigned int __c) {
 #ifdef __LITTLE_ENDIAN__
   return __builtin_altivec_vinswvlx(__b, __c, __a);
 #else
@@ -17028,8 +17036,9 @@ static __inline__ vector unsigned int __ATTRS_o_ai 
vec_inserth(
 
 /* vec_blendv */
 
-static __inline__ vector signed char __ATTRS_o_ai vec_blendv(
-vector signed char __a, vector signed char __b, vector unsigned char __c) {
+static __inline__ vector signed char __ATTRS_o_ai
+vec_blendv(vector signed char __a, vector signed ch

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

2020-07-03 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L marked 5 inline comments as done.
Xiangling_L added inline comments.



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

hubert.reinterpretcast wrote:
> Xiangling_L wrote:
> > hubert.reinterpretcast wrote:
> > > I am concerned that none of the tests actually create an instance of the 
> > > classes under test and check the alignment (or related adjustments) in 
> > > the IR. That is, we set up the preferred alignment value but don't check 
> > > that we use it where we should.
> > > 
> > > As it is, it seems array new/delete has problems:
> > > ```
> > > #include 
> > > extern "C" void *calloc(decltype(sizeof 0), decltype(sizeof 0));
> > > extern "C" void free(void *);
> > > extern "C" int printf(const char *, ...);
> > > 
> > > extern void *allocated_ptr;
> > > extern decltype(sizeof 0) allocated_size;
> > > struct B {
> > >   double d;
> > >   ~B() {}
> > >   static void *operator new[](decltype(sizeof 0) sz);
> > >   static void operator delete[](void *p, decltype(sizeof 0) sz);
> > > };
> > > B *allocBp();
> > > 
> > > #ifdef ALLOCBP
> > > void *allocated_ptr;
> > > decltype(sizeof 0) allocated_size;
> > > void *B::operator new[](decltype(sizeof 0) sz) {
> > >   void *alloc = calloc(1u, allocated_size = sz);
> > >   printf("%p: %s\n", alloc, __PRETTY_FUNCTION__);
> > >   printf("%zu\n", sz);
> > >   return allocated_ptr = alloc;
> > > }
> > > void B::operator delete[](void *p, decltype(sizeof 0) sz) {
> > >   printf("%p: %s\n", p, __PRETTY_FUNCTION__);
> > >   printf("%zu\n", sz);
> > >   assert(sz == allocated_size);
> > >   assert(p == allocated_ptr);
> > >   free(p);
> > > }
> > > B *allocBp() { return new B[2]; }
> > > #endif
> > > 
> > > #ifdef MAIN
> > > int main(void) { delete[] allocBp(); }
> > > #endif
> > > ```
> > > 
> > > The `xlclang++` invocation from XL C/C++ generates padding before the 
> > > 32-bit `new[]` cookie. I'm not seeing that padding with this patch.
> > Thank. I will create more practical testcases as you mentioned in your 
> > concern. And regarding to `padding before the 32-bit new[] cookie` issue, I 
> > am wondering is that part of `power` alignment rule or what rules do we 
> > follow to generate this kind of padding?
> The padding has to do with the alignment. The allocation function returns 
> 8-byte aligned memory. The 32-bit cookie takes 4 of the first 8 bytes. The 
> type's preferred alignment is 8, so there are 4 bytes of padding.
Regarding with checking the alignment where we use them, AFAIK the problematic 
cases include not only the `cookie padding` issue you mentioned here, but also 
the alignment of argument type, return type etc.

So I am wondering does it make sense to have them handled in a separate patch 
since this is already a big one? We can use this patch to implement the correct 
value of `__alignof` and `alignof` and use a second patch to handle the places 
where `we use them where we should`?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


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

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1884
+  if (const BuiltinType *BTy =
+  Context.getBaseElementType(CTy->getElementType())
+  ->getAs())

I don't think there's a reason to use `getBaseElementType` (which is used to 
handle arrays) on the element type of a `ComplexType`.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1885
+  Context.getBaseElementType(CTy->getElementType())
+  ->getAs())
+if (BTy->getKind() == BuiltinType::Double ||

I believe `castAs` should be expected to succeed here.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1888
+BTy->getKind() == BuiltinType::LongDouble) {
+  PreferredAlign = CharUnits::fromQuantity(8);
+}

I believe an assertion that `PreferredAlign` was 4 would be appropriate.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1893
+   ->getAs()) {
+  if (BTy->getKind() == BuiltinType::Double ||
+  BTy->getKind() == BuiltinType::LongDouble) {

Use a lambda instead of duplicating the code.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1898
+} else if (const RecordType *RT = D->getType()
+  ->getBaseElementTypeUnsafe()
+  ->getAs()) {

Is there a reason to use `getBaseElementTypeUnsafe` for this case and 
`Context.getBaseElementType` for the other ones? Also, it would make sense to 
factor out the array-type considerations once at the top of the if-else chain 
instead of doing so in each alternative.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1900
+  ->getAs()) {
+  if (const RecordDecl *RD = RT->getDecl()) {
+const ASTRecordLayout &FieldRecord = Context.getASTRecordLayout(RD);

I'd be a bit concerned if this failed. Can we assert that we get a non-null 
pointer back?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


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

2020-07-03 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.

This looks great to me as long as other reviewers are happy. @vrnithinkumar, I 
think you should ask for commit access and honorably push the patch to master 
yourself ^.^

I guess we'll talk about this more, but i think the really good next step would 
be to implenent the `checkRegionChanges` callback for the checker so that to 
destroy the tracked raw pointer data whenever something unknown happens to the 
smart pointer. We'll need this anyway, i.e. when a pointer is passed by a 
non-const reference into a function, we no longer know the raw pointer value. 
But as a side effect, it'll also destroy tracked data on any smart pointer 
method that's not modeled yet. That'll allow the modeling checker to behave 
correctly (i.e., not perfectly but avoid being confidently incorrect) even if 
not all methods are modeled. That, in turn, will allow us to remove the option 
and enable the checker by default even without fully implementing all methods.




Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp:32-33
+class SmartPtrChecker : public Checker {
+  BugType NullDereferenceBugType{this, "Null SmartPtr dereference",
+ "C++ Smart Pointer"};
+

Those strings are user-facing. We need to not forget to come up with a more 
humane explanation of the bug.


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

https://reviews.llvm.org/D81315



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


[PATCH] D82365: [Power10] Implement Vector Insert Builtins in LLVM/Clang

2020-07-03 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-p10vector.c:12
+// RUN:   -target-cpu pwr10 -triple powerpc64le-unknown-unknown -emit-llvm %s \
+// RUN:   -o - | FileCheck %s -check-prefix=CHECK-LE
+

I just noticed this.  There is no need to add this RUN line since it's the same 
as the one on line 2.  Please post a patch to remove this and update tests to 
use the default `CHECK`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82365



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


[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-07-03 Thread David Tenty via Phabricator via cfe-commits
daltenty accepted this revision.
daltenty added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/Driver/ToolChains/AIX.cpp:195
+  // Return if -nostdlibinc is specified as a driver option.
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;

hubert.reinterpretcast wrote:
> stevewan wrote:
> > Can we rewrite this block of code so that it's in consistent with the 
> > previous one?
> > ```
> >   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
> > // Add /usr/include.
> > SmallString<128> UP(Sysroot);
> > path::append(UP, "/usr/include");
> > addSystemInclude(DriverArgs, CC1Args, UP.str());
> >   }
> > ```
> I think the current expression with the early exit is friendlier for future 
> expansion. @daltenty, do you have an opinion on this?
I tend to agree, everything below this point should be standard system includes 
that all should get ignored with `nostdlibinc` so I think the early exit makes 
sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677



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


[PATCH] D83143: [clangd] Fix hover crash on invalid decls

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

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83143



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


[PATCH] D83143: [clangd] Fix hover crash on invalid decls

2020-07-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG50ba9f994c6f: [clangd] Fix hover crash on invalid decls 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83143

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -772,6 +772,22 @@
  HI.CallPassType->PassBy = PassMode::Value;
  HI.CallPassType->Converted = false;
}},
+  {// Dont crash on invalid decl
+   R"cpp(
+// error-ok
+struct Foo {
+  Bar [[x^x]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "xx";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int xx";
+ HI.LocalScope = "Foo::";
+ HI.Size = 4;
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -672,11 +672,10 @@
 if (Record)
   Record = Record->getDefinition();
 if (Record && !Record->isDependentType()) {
-  uint64_t OffsetBits = Ctx.getFieldOffset(FD);
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
 HI.Size = Size->getQuantity();
-HI.Offset = OffsetBits / 8;
-  }
+  if (!FD->isInvalidDecl())
+HI.Offset = Ctx.getFieldOffset(FD) / 8;
 }
 return;
   }


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -772,6 +772,22 @@
  HI.CallPassType->PassBy = PassMode::Value;
  HI.CallPassType->Converted = false;
}},
+  {// Dont crash on invalid decl
+   R"cpp(
+// error-ok
+struct Foo {
+  Bar [[x^x]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "xx";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int xx";
+ HI.LocalScope = "Foo::";
+ HI.Size = 4;
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -672,11 +672,10 @@
 if (Record)
   Record = Record->getDefinition();
 if (Record && !Record->isDependentType()) {
-  uint64_t OffsetBits = Ctx.getFieldOffset(FD);
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
 HI.Size = Size->getQuantity();
-HI.Offset = OffsetBits / 8;
-  }
+  if (!FD->isInvalidDecl())
+HI.Offset = Ctx.getFieldOffset(FD) / 8;
 }
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 50ba9f9 - [clangd] Fix hover crash on invalid decls

2020-07-03 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-07-03T22:51:04+02:00
New Revision: 50ba9f994c6f9c51692282494c3b40dbc69b4abd

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

LOG: [clangd] Fix hover crash on invalid decls

Summary: This also changes the way we display Size and Offset to be independent.

Reviewers: sammccall

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 616d4c91c0f7..f495052d2d30 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -672,11 +672,10 @@ void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
 if (Record)
   Record = Record->getDefinition();
 if (Record && !Record->isDependentType()) {
-  uint64_t OffsetBits = Ctx.getFieldOffset(FD);
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
 HI.Size = Size->getQuantity();
-HI.Offset = OffsetBits / 8;
-  }
+  if (!FD->isInvalidDecl())
+HI.Offset = Ctx.getFieldOffset(FD) / 8;
 }
 return;
   }

diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 4059f8307c4c..3be796a6fb89 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -772,6 +772,22 @@ class Foo {})cpp";
  HI.CallPassType->PassBy = PassMode::Value;
  HI.CallPassType->Converted = false;
}},
+  {// Dont crash on invalid decl
+   R"cpp(
+// error-ok
+struct Foo {
+  Bar [[x^x]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "xx";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int xx";
+ HI.LocalScope = "Foo::";
+ HI.Size = 4;
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);



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


[PATCH] D82365: [Power10] Implement Vector Insert Builtins in LLVM/Clang

2020-07-03 Thread Lei Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0939e04e4176: [PowerPC] Implement Vector Insert Builtins in 
LLVM/Clang (authored by biplmish, committed by lei).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82365

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll
@@ -81,3 +81,153 @@
   ret <2 x i64> %0
 }
 declare <2 x i64> @llvm.ppc.vsx.xxblendvd(<2 x i64>, <2 x i64>, <2 x i64>)
+
+define <16 x i8> @testVINSBLX(<16 x i8> %a, i64 %b, i64 %c) {
+; CHECK-LABEL: testVINSBLX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinsblx v2, r5, r6
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <16 x i8> @llvm.ppc.altivec.vinsblx(<16 x i8> %a, i64 %b, i64 %c)
+  ret <16 x i8> %0
+}
+declare <16 x i8> @llvm.ppc.altivec.vinsblx(<16 x i8>, i64, i64)
+
+define <16 x i8> @testVINSBRX(<16 x i8> %a, i64 %b, i64 %c) {
+; CHECK-LABEL: testVINSBRX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinsbrx v2, r5, r6
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <16 x i8> @llvm.ppc.altivec.vinsbrx(<16 x i8> %a, i64 %b, i64 %c)
+  ret <16 x i8> %0
+}
+declare <16 x i8> @llvm.ppc.altivec.vinsbrx(<16 x i8>, i64, i64)
+
+define <8 x i16> @testVINSHLX(<8 x i16> %a, i64 %b, i64 %c) {
+; CHECK-LABEL: testVINSHLX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinshlx v2, r5, r6
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <8 x i16> @llvm.ppc.altivec.vinshlx(<8 x i16> %a, i64 %b, i64 %c)
+  ret <8 x i16> %0
+}
+declare <8 x i16> @llvm.ppc.altivec.vinshlx(<8 x i16>, i64, i64)
+
+define <8 x i16> @testVINSHRX(<8 x i16> %a, i64 %b, i64 %c) {
+; CHECK-LABEL: testVINSHRX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinshrx v2, r5, r6
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <8 x i16> @llvm.ppc.altivec.vinshrx(<8 x i16> %a, i64 %b, i64 %c)
+  ret <8 x i16> %0
+}
+declare <8 x i16> @llvm.ppc.altivec.vinshrx(<8 x i16>, i64, i64)
+
+define <4 x i32> @testVINSWLX(<4 x i32> %a, i64 %b, i64 %c) {
+; CHECK-LABEL: testVINSWLX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinswlx v2, r5, r6
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <4 x i32> @llvm.ppc.altivec.vinswlx(<4 x i32> %a, i64 %b, i64 %c)
+  ret <4 x i32> %0
+}
+declare <4 x i32> @llvm.ppc.altivec.vinswlx(<4 x i32>, i64, i64)
+
+define <4 x i32> @testVINSWRX(<4 x i32> %a, i64 %b, i64 %c) {
+; CHECK-LABEL: testVINSWRX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinswrx v2, r5, r6
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <4 x i32> @llvm.ppc.altivec.vinswrx(<4 x i32> %a, i64 %b, i64 %c)
+  ret <4 x i32> %0
+}
+declare <4 x i32> @llvm.ppc.altivec.vinswrx(<4 x i32>, i64, i64)
+
+define <2 x i64> @testVINSDLX(<2 x i64> %a, i64 %b, i64 %c) {
+; CHECK-LABEL: testVINSDLX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinsdlx v2, r5, r6
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <2 x i64> @llvm.ppc.altivec.vinsdlx(<2 x i64> %a, i64 %b, i64 %c)
+  ret <2 x i64> %0
+}
+declare <2 x i64> @llvm.ppc.altivec.vinsdlx(<2 x i64>, i64, i64)
+
+define <2 x i64> @testVINSDRX(<2 x i64> %a, i64 %b, i64 %c) {
+; CHECK-LABEL: testVINSDRX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinsdrx v2, r5, r6
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <2 x i64> @llvm.ppc.altivec.vinsdrx(<2 x i64> %a, i64 %b, i64 %c)
+  ret <2 x i64> %0
+}
+declare <2 x i64> @llvm.ppc.altivec.vinsdrx(<2 x i64>, i64, i64)
+
+define <16 x i8> @testVINSBVLX(<16 x i8> %a, i64 %b, <16 x i8> %c) {
+; CHECK-LABEL: testVINSBVLX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinsbvlx v2, r5, v3
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <16 x i8> @llvm.ppc.altivec.vinsbvlx(<16 x i8> %a, i64 %b, <16 x i8> %c)
+  ret <16 x i8> %0
+}
+declare <16 x i8> @llvm.ppc.altivec.vinsbvlx(<16 x i8>, i64, <16 x i8>)
+
+define <16 x i8> @testVINSBVRX(<16 x i8> %a, i64 %b, <16 x i8> %c) {
+; CHECK-LABEL: testVINSBVRX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinsbvrx v2, r5, v3
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <16 x i8> @llvm.ppc.altivec.vinsbvrx(<16 x i8> %a, i64 %b, <16 x i8> %c)
+  ret <16 x i8> %0
+}
+declare <16 x i8> @llvm.ppc.altivec.vinsbvrx(<16 x i8>, i64, <16 x i8>)
+
+define <8 x i16> @testVINSHVLX(<8 x i16> %a, i64 %b, <8 x i16> %c) {
+; CHECK-LABEL: testVINSHVLX:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vinshvlx v2, r5, v3
+; CHECK-NEXT:blr
+entry:
+  %0 = tail call <8

[clang] 0939e04 - [PowerPC] Implement Vector Insert Builtins in LLVM/Clang

2020-07-03 Thread Lei Huang via cfe-commits

Author: Biplob Mishra
Date: 2020-07-03T15:30:41-05:00
New Revision: 0939e04e417634f6d38ec4f06835fb80756afdd3

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

LOG: [PowerPC] Implement Vector Insert Builtins in LLVM/Clang

Implements vec_insertl() and vec_inserth().

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/test/CodeGen/PowerPC/builtins-ppc-p10permute.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 856c862fb2a8..d0df5fcd1552 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -320,6 +320,22 @@ BUILTIN(__builtin_altivec_vctzdm, "V2ULLiV2ULLiV2ULLi", "")
 BUILTIN(__builtin_altivec_vsldbi, "V16UcV16UcV16UcIi", "")
 BUILTIN(__builtin_altivec_vsrdbi, "V16UcV16UcV16UcIi", "")
 
+// P10 Vector Insert built-ins.
+BUILTIN(__builtin_altivec_vinsblx, "V16UcV16UcULLiULLi", "")
+BUILTIN(__builtin_altivec_vinsbrx, "V16UcV16UcULLiULLi", "")
+BUILTIN(__builtin_altivec_vinshlx, "V8UsV8UsULLiULLi", "")
+BUILTIN(__builtin_altivec_vinshrx, "V8UsV8UsULLiULLi", "")
+BUILTIN(__builtin_altivec_vinswlx, "V4UiV4UiULLiULLi", "")
+BUILTIN(__builtin_altivec_vinswrx, "V4UiV4UiULLiULLi", "")
+BUILTIN(__builtin_altivec_vinsdlx, "V2ULLiV2ULLiULLiULLi", "")
+BUILTIN(__builtin_altivec_vinsdrx, "V2ULLiV2ULLiULLiULLi", "")
+BUILTIN(__builtin_altivec_vinsbvlx, "V16UcV16UcULLiV16Uc", "")
+BUILTIN(__builtin_altivec_vinsbvrx, "V16UcV16UcULLiV16Uc", "")
+BUILTIN(__builtin_altivec_vinshvlx, "V8UsV8UsULLiV8Us", "")
+BUILTIN(__builtin_altivec_vinshvrx, "V8UsV8UsULLiV8Us", "")
+BUILTIN(__builtin_altivec_vinswvlx, "V4UiV4UiULLiV4Ui", "")
+BUILTIN(__builtin_altivec_vinswvrx, "V4UiV4UiULLiV4Ui", "")
+
 // VSX built-ins.
 
 BUILTIN(__builtin_vsx_lxvd2x, "V2divC*", "")

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 39eebb7274c0..38d5c00a7981 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16889,6 +16889,136 @@ vec_cnttzm(vector unsigned long long __a, vector 
unsigned long long __b) {
 
 #define vec_srdb(__a, __b, __c) __builtin_altivec_vsrdbi(__a, __b, (__c & 0x7))
 
+/* vec_insertl */
+
+static __inline__ vector unsigned char __ATTRS_o_ai
+vec_insertl(unsigned char __a, vector unsigned char __b, unsigned int __c) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vinsbrx(__b, __c, __a);
+#else
+  return __builtin_altivec_vinsblx(__b, __c, __a);
+#endif
+}
+
+static __inline__ vector unsigned short __ATTRS_o_ai
+vec_insertl(unsigned short __a, vector unsigned short __b, unsigned int __c) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vinshrx(__b, __c, __a);
+#else
+  return __builtin_altivec_vinshlx(__b, __c, __a);
+#endif
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_insertl(unsigned int __a, vector unsigned int __b, unsigned int __c) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vinswrx(__b, __c, __a);
+#else
+  return __builtin_altivec_vinswlx(__b, __c, __a);
+#endif
+}
+
+static __inline__ vector unsigned long long __ATTRS_o_ai vec_insertl(
+unsigned long long __a, vector unsigned long long __b, unsigned int __c) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vinsdrx(__b, __c, __a);
+#else
+  return __builtin_altivec_vinsdlx(__b, __c, __a);
+#endif
+}
+
+static __inline__ vector unsigned char __ATTRS_o_ai vec_insertl(
+vector unsigned char __a, vector unsigned char __b, unsigned int __c) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vinsbvrx(__b, __c, __a);
+#else
+  return __builtin_altivec_vinsbvlx(__b, __c, __a);
+#endif
+}
+
+static __inline__ vector unsigned short __ATTRS_o_ai vec_insertl(
+vector unsigned short __a, vector unsigned short __b, unsigned int __c) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vinshvrx(__b, __c, __a);
+#else
+  return __builtin_altivec_vinshvlx(__b, __c, __a);
+#endif
+}
+
+static __inline__ vector unsigned int __ATTRS_o_ai vec_insertl(
+vector unsigned int __a, vector unsigned int __b, unsigned int __c) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vinswvrx(__b, __c, __a);
+#else
+  return __builtin_altivec_vinswvlx(__b, __c, __a);
+#endif
+}
+
+/* vec_inserth */
+
+static __inline__ vector unsigned char __ATTRS_o_ai
+vec_inserth(unsigned char __a, vector unsigned char __b, unsigned int __c) {
+#ifdef __LITTLE_ENDIAN__
+  return __builtin_altivec_vinsblx(__b, __c, __a);
+#else
+  return __builtin_altivec_vinsbrx(__b, __c, __a);
+#endif
+}
+
+static __

[PATCH] D83076: Revert AST Matchers default to AsIs mode

2020-07-03 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG551092bc3dfb: Revert AST Matchers default to AsIs mode 
(authored by stephenkelly).

Changed prior to commit:
  https://reviews.llvm.org/D83076?vs=275248&id=275458#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83076

Files:
  clang-tools-extra/clang-query/Query.cpp
  clang-tools-extra/clang-query/QuerySession.h
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ParentMapContext.h
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1207,7 +1207,12 @@
 }
 
 TEST_P(ASTMatchersTest, CastExpr_DoesNotMatchNonCasts) {
-  EXPECT_TRUE(notMatches("char c = '0';", castExpr()));
+  if (GetParam().Language == Lang_C89 || GetParam().Language == Lang_C99) {
+// This does have a cast in C
+EXPECT_TRUE(matches("char c = '0';", implicitCastExpr()));
+  } else {
+EXPECT_TRUE(notMatches("char c = '0';", castExpr()));
+  }
   EXPECT_TRUE(notMatches("int i = (0);", castExpr()));
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
Index: clang/include/clang/AST/ParentMapContext.h
===
--- clang/include/clang/AST/ParentMapContext.h
+++ clang/include/clang/AST/ParentMapContext.h
@@ -67,7 +67,7 @@
 private:
   ASTContext &ASTCtx;
   class ParentMap;
-  TraversalKind Traversal = TK_IgnoreUnlessSpelledInSource;
+  TraversalKind Traversal = TK_AsIs;
   std::unique_ptr Parents;
 };
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -258,44 +258,7 @@
 AST Matchers
 
 
-- Traversal in AST Matchers was simplified to use the
-  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
-  This means that many uses of the ``ignoringImplicit()`` and similar matchers
-  is no longer necessary.  Clients of AST Matchers which wish to match on
-  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
-  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
-  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
-  using ``set traversal AsIs`` in the ``clang-query`` environment.
-
-  As this change requires downstream tools which use AST Matchers to adapt
-  to the new default, a porting guide may be useful for downstream tools
-  needing to adapt.
-
-  Note that although there are many steps below, only the first is
-  non-optional. The steps are intentionally extemely granular to facilitate
-  understanding of the guide itself. It is reasonable to do some of the
-  steps at the same time if you understand the guide:
-
-  1. Use ``(your ASTContext instance).getParentMapContext().setTraversalKind(TK_AsIs)``
- to restore the previous behavior for your tool.  All further steps in
- this porting guide are optional.
-  2. Wrap your existing matcher expressions with ``traverse(TK_AsIs, ...)``
- before passing them to ``ASTMatchFinder::addMatcher``.
-  3. Remove ``(your ASTContext instance).getParentMapContext().setTraversalKind(TK_AsIs)``
- from your tool so that the default behavior of your tool matches the
- default behavior of upstream clang. This is made possible by wrapping
- your matchers in ``traverse(TK_AsIs, ...)`` from step (2).
-  4. Audit your matcher expressions and remove ``traverse(TK_AsIs, ...)``
- where not needed.
-  5. Audit your matcher expressions and remove calls to ``ignoring*()``
- matchers where not needed.
-  6. Audit your matcher expressions and consider whether the matcher is
- better using the ``TK_AsIs`` mode or if it can be better expressed in
- the default mode. For example, some matchers explicitly match
- ``has(implicitCastExpr(has(...)))``. Such matchers are sometimes
- written by author who were unaware of the existence of the
- ``ignoring*()`` matchers.
-
+- ...
 
 clang-format
 
Index: clang-tools-extra/clang-query/QuerySession.h
===
--- clang-tools-extra/clang-query/QuerySession.h
+++ clang-tools-extra/clang-query/QuerySession.h
@@ -26,7 +26,7 @@
   QuerySession(llvm::ArrayRef> ASTs)
   : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
 DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
-Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) {}
+Terminate(false), TK(ast_type_traits::TK_AsIs) {}
 
   llvm::ArrayRef> ASTs;
 
Index: clang-tools-extra/clang-query/Query.cpp

[clang-tools-extra] 551092b - Revert AST Matchers default to AsIs mode

2020-07-03 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2020-07-03T21:19:46+01:00
New Revision: 551092bc3dfb86f1e11a55f3bee0c8ee1be6fdd6

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

LOG: Revert AST Matchers default to AsIs mode

Reviewers: aaron.ballman, klimek

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/clang-query/QuerySession.h
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/ParentMapContext.h
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index 4fe7110daed3..ca2a285e9eb7 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -46,12 +46,12 @@ bool HelpQuery::run(llvm::raw_ostream &OS, QuerySession 
&QS) const {
 "  set traversal   "
 "Set traversal kind of clang-query session. Available kinds are:\n"
 "AsIs"
-"Print and match the AST as clang sees it.\n"
+"Print and match the AST as clang sees it.  This mode is the "
+"default.\n"
 "IgnoreImplicitCastsAndParentheses  "
 "Omit implicit casts and parens in matching and dumping.\n"
 "IgnoreUnlessSpelledInSource "
-"Omit AST nodes unless spelled in the source.  This mode is the "
-"default.\n"
+"Omit AST nodes unless spelled in the source.\n"
 "  set output   "
 "Set whether to output only  content.\n"
 "  enable output"

diff  --git a/clang-tools-extra/clang-query/QuerySession.h 
b/clang-tools-extra/clang-query/QuerySession.h
index 1660e4039f61..20c788b206a0 100644
--- a/clang-tools-extra/clang-query/QuerySession.h
+++ b/clang-tools-extra/clang-query/QuerySession.h
@@ -26,7 +26,7 @@ class QuerySession {
   QuerySession(llvm::ArrayRef> ASTs)
   : ASTs(ASTs), PrintOutput(false), DiagOutput(true),
 DetailedASTOutput(false), BindRoot(true), PrintMatcher(false),
-Terminate(false), TK(ast_type_traits::TK_IgnoreUnlessSpelledInSource) 
{}
+Terminate(false), TK(ast_type_traits::TK_AsIs) {}
 
   llvm::ArrayRef> ASTs;
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c24c289f94b4..4d271bfdcd31 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -258,44 +258,7 @@ release of Clang. Users of the build system should adjust 
accordingly.
 AST Matchers
 
 
-- Traversal in AST Matchers was simplified to use the
-  ``TK_IgnoreUnlessSpelledInSource`` mode by default, instead of ``TK_AsIs``.
-  This means that many uses of the ``ignoringImplicit()`` and similar matchers
-  is no longer necessary.  Clients of AST Matchers which wish to match on
-  implicit AST nodes can wrap their matcher in ``traverse(TK_AsIs, ...)`` or
-  use ``TraversalKindScope`` if appropriate.  The ``clang-query`` tool also
-  uses ``IgnoreUnlessSpelledInSource`` by default.  The mode can be changed
-  using ``set traversal AsIs`` in the ``clang-query`` environment.
-
-  As this change requires downstream tools which use AST Matchers to adapt
-  to the new default, a porting guide may be useful for downstream tools
-  needing to adapt.
-
-  Note that although there are many steps below, only the first is
-  non-optional. The steps are intentionally extemely granular to facilitate
-  understanding of the guide itself. It is reasonable to do some of the
-  steps at the same time if you understand the guide:
-
-  1. Use ``(your ASTContext 
instance).getParentMapContext().setTraversalKind(TK_AsIs)``
- to restore the previous behavior for your tool.  All further steps in
- this porting guide are optional.
-  2. Wrap your existing matcher expressions with ``traverse(TK_AsIs, ...)``
- before passing them to ``ASTMatchFinder::addMatcher``.
-  3. Remove ``(your ASTContext 
instance).getParentMapContext().setTraversalKind(TK_AsIs)``
- from your tool so that the default behavior of your tool matches the
- default behavior of upstream clang. This is made possible by wrapping
- your matchers in ``traverse(TK_AsIs, ...)`` from step (2).
-  4. Audit your matcher expressions and remove ``traverse(TK_AsIs, ...)``
- where not needed.
-  5. Audit your matcher expressions and remove calls to ``ignoring*()``
- matchers where not needed.
-  6. Audit your matcher expressions and consider whether the matcher is
- better using the ``TK_AsIs`` mode or if it can be better expressed in
- the default mode. For example, some matchers explicitly match
- ``has(implicitCastExpr(has(...))

[PATCH] D79279: Add overloaded versions of builtin mem* functions

2020-07-03 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:489
 BUILTIN(__builtin_memcpy_inline, "vv*vC*Iz", "nt")
+BUILTIN(__builtin_overloaded_memcpy, "v*v*vC*z", "nt")
 BUILTIN(__builtin_memmove, "v*v*vC*z", "nF")

jfb wrote:
> gchatelet wrote:
> > `overloaded` doesn't bring much semantic (says the one who added 
> > `__builtin_memcpy_inline`...). Can you come up with something that 
> > describes more precisely what the intends are?
> > 
> > Also `memset`, `memcmp`, `memcpy`, `memmove` will have their `inline` and 
> > `overloaded` versions. This is becoming a crowded space. It may be 
> > confusing in the long run. If we want to go in that direction maybe we 
> > should come up with a consistent pattern: `__builtin__`. 
> > WDYT?
> Flipping it around is fine with me, see update (done with `sed`).
> 
> What's your approach on choosing what gets an `inline` variant and what 
> doesn't? `memcmp` is easy to add, but I wonder how far it's useful to go... I 
> can just wait for requests as well (as I imagine you're doing?).
I don't see `memmove_inline` being useful but memset and memcmp would make 
sense to add as building blocks for C++ implementations (e.g. [[ 
https://github.com/llvm/llvm-project/blob/master/libc/src/string/memcpy.cpp | 
libc memcpy ]])

As for this new addition, how about `__builtin_memcpy_honor_qualifiers`?
I fear that `__builtin_memcpy_overloaded` is too ambiguous.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79279



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


[PATCH] D83144: Allow to specify macro names for android-comparison-in-temp-failure-retry.

2020-07-03 Thread Florian Mayer via Phabricator via cfe-commits
fmayer created this revision.
fmayer added a reviewer: george.burgess.iv.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Some projects do not use the TEMP_FAILURE_RETRY macro but define their own
one, as not to depend on glibc / Bionic details. By allowing the user to 
override the
list of macros, these projects can also benefit from this check.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83144

Files:
  clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
  clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.h
  
clang-tools-extra/docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst
  
clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry.c

Index: clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry.c
===
--- clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry.c
+++ clang-tools-extra/test/clang-tidy/checkers/android-comparison-in-temp-failure-retry.c
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s android-comparison-in-temp-failure-retry %t
+// RUN: %check_clang_tidy %s android-comparison-in-temp-failure-retry %t -- -config="{CheckOptions: [{key: android-comparison-in-temp-failure-retry.RetryMacros, value: 'TEMP_FAILURE_RETRY,MY_TEMP_FAILURE_RETRY'}]}"
 
 #define TEMP_FAILURE_RETRY(x)  \
   ({   \
@@ -9,6 +9,15 @@
 __z;   \
   })
 
+#define MY_TEMP_FAILURE_RETRY(x) \
+  ({ \
+typeof(x) __z;   \
+do   \
+  __z = (x); \
+while (__z == -1);   \
+__z; \
+  })
+
 int foo();
 int bar(int a);
 
@@ -25,6 +34,9 @@
   TEMP_FAILURE_RETRY((int)(foo() == 1));
   // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: top-level comparison in TEMP_FAILURE_RETRY
 
+  MY_TEMP_FAILURE_RETRY(foo() == 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: top-level comparison in MY_TEMP_FAILURE_RETRY
+
   TEMP_FAILURE_RETRY(bar(foo() == 1));
   TEMP_FAILURE_RETRY((bar(foo() == 1)));
   TEMP_FAILURE_RETRY((bar(foo() == 1)) == 1);
Index: clang-tools-extra/docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst
+++ clang-tools-extra/docs/clang-tidy/checks/android-comparison-in-temp-failure-retry.rst
@@ -34,3 +34,10 @@
   while (TEMP_FAILURE_RETRY(read(STDIN_FILENO, cs, sizeof(cs))) != 0) {
 // Do something with cs.
   }
+
+Options
+---
+
+.. option:: RetryMacros
+
+   A comma-separated list of the names of retry macros to be checked.
Index: clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.h
===
--- clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.h
+++ clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.h
@@ -10,6 +10,9 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ANDROID_COMPARISONINTEMPFAILURERETRYCHECK_H
 
 #include "../ClangTidyCheck.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include 
 
 namespace clang {
 namespace tidy {
@@ -22,10 +25,14 @@
 /// TEMP_FAILURE_RETRY is a macro provided by both glibc and Bionic.
 class ComparisonInTempFailureRetryCheck : public ClangTidyCheck {
 public:
-  ComparisonInTempFailureRetryCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  ComparisonInTempFailureRetryCheck(StringRef Name, ClangTidyContext *Context);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+  const std::string RawRetryList;
+  SmallVector RetryMacros;
 };
 
 } // namespace android
Index: clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
===
--- clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
+++ clang-tools-extra/clang-tidy/android/ComparisonInTempFailureRetryCheck.cpp
@@ -18,32 +18,17 @@
 namespace tidy {
 namespace android {
 
-namespace {
-AST_MATCHER(BinaryOperator, isRHSATempFailureRetryArg) {
-  if (!Node.getBeginLoc().isMacroID())
-return false;
-
-  const SourceManager &SM = Finder->getASTContext().getSourceManager();
-  if (!SM.isMacroArgExpansion(Node.getRHS()->IgnoreParenCasts()->getBeginLoc()))
-return false;
-
-  const LangOptions &Opts = Finder->getASTContext().getLangOpts();
-  Sour

[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:195
+  // Return if -nostdlibinc is specified as a driver option.
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;

stevewan wrote:
> Can we rewrite this block of code so that it's in consistent with the 
> previous one?
> ```
>   if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
> // Add /usr/include.
> SmallString<128> UP(Sysroot);
> path::append(UP, "/usr/include");
> addSystemInclude(DriverArgs, CC1Args, UP.str());
>   }
> ```
I think the current expression with the early exit is friendlier for future 
expansion. @daltenty, do you have an opinion on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677



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


[PATCH] D82964: [clangd] Config: loading and caching config from disk.

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

thanks LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82964



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


[PATCH] D83095: [clangd] Config: compute config in TUScheduler and BackgroundIndex

2020-07-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:748
 
+Context ClangdServer::createProcessingContext(PathRef File) const {
+  if (!ConfigProvider)

sammccall wrote:
> kadircet wrote:
> > why not make this a free function in `ConfigProvider.h` ?
> > 
> > that way we could just keep passing ConfigProvider around rather than a 
> > derived lambda.
> > It makes testing more cumbersome, but enables us to move the logic out of 
> > ClangdServer
> Oh, I thought hiding this logic in ClangdServer was a feature!
> 
> For instance, if we want to report configuration errors as LSP diagnostics or 
> as notifications, we need to have access to the ClangdServer to do that.
hmm, I thought we would rather make DiagnosticHandler an input parameter in 
such a scenario, (we even have the alias `config::DiagnosticCallback` 😅) with a 
nullptr just logging the errors and warnings (as in current implementation).

I don't see any other interaction but surfacing diagnostics, and I believe it 
would look nicer if we provided a callback for diags when creating context with 
configs. But this one also gets the job done, so up to you.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:761
+  auto DiagnosticHandler = [](const llvm::SMDiagnostic &Diag) {
+log("config {0} at {1}:{2}:{3}: {4}",
+Diag.getKind() == llvm::SourceMgr::DK_Error ? "error" : "warning",

kadircet wrote:
> why not elog
this is still logging though :D (not elog)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83095



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


[PATCH] D83095: [clangd] Config: compute config in TUScheduler and BackgroundIndex

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

thanks, lgtm!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83095



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


[PATCH] D83143: [clangd] Fix hover crash on invalid decls

2020-07-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 275448.
kadircet added a comment.

Inline OffsetBits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83143

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -772,6 +772,22 @@
  HI.CallPassType->PassBy = PassMode::Value;
  HI.CallPassType->Converted = false;
}},
+  {// Dont crash on invalid decl
+   R"cpp(
+// error-ok
+struct Foo {
+  Bar [[x^x]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "xx";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int xx";
+ HI.LocalScope = "Foo::";
+ HI.Size = 4;
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -672,11 +672,10 @@
 if (Record)
   Record = Record->getDefinition();
 if (Record && !Record->isDependentType()) {
-  uint64_t OffsetBits = Ctx.getFieldOffset(FD);
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
 HI.Size = Size->getQuantity();
-HI.Offset = OffsetBits / 8;
-  }
+  if (!FD->isInvalidDecl())
+HI.Offset = Ctx.getFieldOffset(FD) / 8;
 }
 return;
   }


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -772,6 +772,22 @@
  HI.CallPassType->PassBy = PassMode::Value;
  HI.CallPassType->Converted = false;
}},
+  {// Dont crash on invalid decl
+   R"cpp(
+// error-ok
+struct Foo {
+  Bar [[x^x]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "xx";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int xx";
+ HI.LocalScope = "Foo::";
+ HI.Size = 4;
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -672,11 +672,10 @@
 if (Record)
   Record = Record->getDefinition();
 if (Record && !Record->isDependentType()) {
-  uint64_t OffsetBits = Ctx.getFieldOffset(FD);
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
 HI.Size = Size->getQuantity();
-HI.Offset = OffsetBits / 8;
-  }
+  if (!FD->isInvalidDecl())
+HI.Offset = Ctx.getFieldOffset(FD) / 8;
 }
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D52676: [clang-format] tweaked another case of lambda formatting

2020-07-03 Thread Jeff Trull via Phabricator via cfe-commits
jaafar added inline comments.



Comment at: cfe/trunk/lib/Format/TokenAnnotator.cpp:3072
+  return false;
+if (!Next->isOneOf(TT_LambdaLSquare, tok::l_brace, tok::caret))
+  return true;

This is the clause that triggers the problem.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D52676



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


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

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1778
+if (FoundNonOverlappingEmptyField)
+  HandledFirstNonOverlappingEmptyField = true;
+

See my other comment for rationale on why 
`HandledFirstNonOverlappingEmptyField` should be set to `!IsUnion` instead of 
`true`.

A comment would be appropriate here:
```
if (FoundNonOverlappingEmptyField) {
  // For a union, the current field does not represent all "firsts".
  HandledFirstNonOverlappingEmptyField = !IsUnion;
}
```



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1879
+  (IsUnion || FoundNonOverlappingEmptyField)) {
+HandledFirstNonOverlappingEmptyField = true;
+

`IsOverlappingEmptyField` is still in play (as seen in further checks below). I 
do not believe it is appropriate to set `HandledFirstNonOverlappingEmptyField` 
to `true` in that case (possible because `IsUnion` overrides what is currently 
called `FoundNonOverlappingEmptyField`).

There are a few ways to address this. For example, 
`HandledFirstNonOverlappingEmptyField` could be set to `!IsUnion` instead for 
to `true`. This is semantically sound, because 
`HandledFirstNonOverlappingEmptyField` is meant to indicate that there would 
not be further "firsts" to consider (and that is not true for unions).

I believe the code should not require user to convince themselves that 
non-sequitur logic washes away, so I would like a fix for this although it 
introduces no functional change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D83143: [clangd] Fix hover crash on invalid decls

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

This also changes the way we display Size and Offset to be independent.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83143

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -772,6 +772,22 @@
  HI.CallPassType->PassBy = PassMode::Value;
  HI.CallPassType->Converted = false;
}},
+  {// Dont crash on invalid decl
+   R"cpp(
+// error-ok
+struct Foo {
+  Bar [[x^x]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "xx";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int xx";
+ HI.LocalScope = "Foo::";
+ HI.Size = 4;
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -672,9 +672,10 @@
 if (Record)
   Record = Record->getDefinition();
 if (Record && !Record->isDependentType()) {
-  uint64_t OffsetBits = Ctx.getFieldOffset(FD);
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
 HI.Size = Size->getQuantity();
+  if (!FD->isInvalidDecl()) {
+uint64_t OffsetBits = Ctx.getFieldOffset(FD);
 HI.Offset = OffsetBits / 8;
   }
 }


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -772,6 +772,22 @@
  HI.CallPassType->PassBy = PassMode::Value;
  HI.CallPassType->Converted = false;
}},
+  {// Dont crash on invalid decl
+   R"cpp(
+// error-ok
+struct Foo {
+  Bar [[x^x]];
+};)cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "xx";
+ HI.Kind = index::SymbolKind::Field;
+ HI.NamespaceScope = "";
+ HI.Definition = "int xx";
+ HI.LocalScope = "Foo::";
+ HI.Size = 4;
+ HI.Type = "int";
+ HI.AccessSpecifier = "public";
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -672,9 +672,10 @@
 if (Record)
   Record = Record->getDefinition();
 if (Record && !Record->isDependentType()) {
-  uint64_t OffsetBits = Ctx.getFieldOffset(FD);
-  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType()))
 HI.Size = Size->getQuantity();
+  if (!FD->isInvalidDecl()) {
+uint64_t OffsetBits = Ctx.getFieldOffset(FD);
 HI.Offset = OffsetBits / 8;
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81270: [XCOFF][AIX] Use 'L..' instead of '.L' for getPrivateGlobalPrefix in DataLayout

2020-07-03 Thread Jason Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG572dde55eebb: [XCOFF][AIX] Use 'L..' instead of 
'.L' for getPrivateGlobalPrefix in DataLayout (authored by jasonliu).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81270

Files:
  clang/lib/Basic/Targets/PPC.h
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/DataLayout.h
  llvm/lib/IR/DataLayout.cpp
  llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
  llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
  llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
  llvm/unittests/IR/ManglerTest.cpp

Index: llvm/unittests/IR/ManglerTest.cpp
===
--- llvm/unittests/IR/ManglerTest.cpp
+++ llvm/unittests/IR/ManglerTest.cpp
@@ -136,4 +136,24 @@
 "?vectorcall");
 }
 
+TEST(ManglerTest, XCOFF) {
+  LLVMContext Ctx;
+  DataLayout DL("m:a"); // XCOFF/AIX
+  Module Mod("test", Ctx);
+  Mod.setDataLayout(DL);
+  Mangler Mang;
+  EXPECT_EQ(mangleStr("foo", Mang, DL), "foo");
+  EXPECT_EQ(mangleStr("\01foo", Mang, DL), "foo");
+  EXPECT_EQ(mangleStr("?foo", Mang, DL), "?foo");
+  EXPECT_EQ(mangleFunc("foo", llvm::GlobalValue::ExternalLinkage,
+   llvm::CallingConv::C, Mod, Mang),
+"foo");
+  EXPECT_EQ(mangleFunc("?foo", llvm::GlobalValue::ExternalLinkage,
+   llvm::CallingConv::C, Mod, Mang),
+"?foo");
+  EXPECT_EQ(mangleFunc("foo", llvm::GlobalValue::PrivateLinkage,
+   llvm::CallingConv::C, Mod, Mang),
+"L..foo");
+}
+
 } // end anonymous namespace
Index: llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
===
--- llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
+++ llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
@@ -27,20 +27,20 @@
 
 ; CHECK:   .csect .rodata.str2.2[RO],2
 ; CHECK-NEXT:   .align  1
-; CHECK-NEXT: .Lmagic16:
+; CHECK-NEXT: L..magic16:
 ; CHECK-NEXT:   .vbyte	2, 264 # 0x108
 ; CHECK-NEXT:   .vbyte	2, 272 # 0x110
 ; CHECK-NEXT:   .vbyte	2, 213 # 0xd5
 ; CHECK-NEXT:   .vbyte	2, 0   # 0x0
 ; CHECK-NEXT:   .csect .rodata.str4.4[RO],2
 ; CHECK-NEXT:   .align  2
-; CHECK-NEXT: .Lmagic32:
+; CHECK-NEXT: L..magic32:
 ; CHECK-NEXT:   .vbyte	4, 464 # 0x1d0
 ; CHECK-NEXT:   .vbyte	4, 472 # 0x1d8
 ; CHECK-NEXT:   .vbyte	4, 413 # 0x19d
 ; CHECK-NEXT:   .vbyte	4, 0   # 0x0
 ; CHECK-NEXT:   .csect .rodata.str1.1[RO],2
-; CHECK-NEXT: .LstrA:
+; CHECK-NEXT: L..strA:
 ; CHECK-NEXT: .byte   104
 ; CHECK-NEXT: .byte   101
 ; CHECK-NEXT: .byte   108
@@ -55,7 +55,7 @@
 ; CHECK-NEXT: .byte   33
 ; CHECK-NEXT: .byte   10
 ; CHECK-NEXT: .byte   0
-; CHECK-NEXT: .L.str:
+; CHECK-NEXT: L...str:
 ; CHECK-NEXT: .byte   97
 ; CHECK-NEXT: .byte   98
 ; CHECK-NEXT: .byte   99
Index: llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
===
--- llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
+++ llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
@@ -25,7 +25,7 @@
 ;CHECK: .csect .rodata[RO],4
 
 ;CHECK-NEXT: .align  4
-;CHECK-NEXT: .L__const.main.cnst32:
+;CHECK-NEXT: L..__const.main.cnst32:
 ;CHECK32-NEXT: .vbyte	4, 1073741824
 ;CHECK32-NEXT: .vbyte	4, 50
 ;CHECK64-NEXT: .vbyte	8, 4611686018427387954
@@ -38,7 +38,7 @@
 ;CHECK-NEXT:   .space  4
 
 ;CHECK-NEXT:   .align  3
-;CHECK-NEXT: .L__const.main.cnst16:
+;CHECK-NEXT: L..__const.main.cnst16:
 ;CHECK32-NEXT: .vbyte	4, 1073741824
 ;CHECK32-NEXT: .vbyte	4, 22
 ;CHECK64-NEXT: .vbyte	8, 4611686018427387926
@@ -46,12 +46,12 @@
 ;CHECK-NEXT:   .space  4
 
 ;CHECK-NEXT: .align  3
-;CHECK-NEXT: .L__const.main.cnst8:
+;CHECK-NEXT: L..__const.main.cnst8:
 ;CHECK-NEXT: .vbyte	4, 1073741832  # 0x4008
 ;CHECK-NEXT: .vbyte	4, 0   # 0x0
 
 ;CHECK-NEXT: .align  3
-;CHECK-NEXT: .L__const.main.cnst4:
+;CHECK-NEXT: L..__const.main.cnst4:
 ;CHECK-NEXT: .vbyte	2, 16392   # 0x4008
 ;CHECK-NEXT: .byte   0   # 0x0
 ;CHECK-NEXT: .space  1
Index: llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
===
--- llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
+++ llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
@@ -98,11 +98,11 @@
 ; 32SMALL-ASM: 	blr
 ; 32SMALL-ASM: 	.csect .rodata[RO],2
 ; 32SMALL-ASM: 	.align  2
-; 32SMALL-ASM: .LJTI0_0:
-; 32SMALL-

[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-07-03 Thread Steven Wan via Phabricator via cfe-commits
stevewan accepted this revision.
stevewan added a comment.

LGTM with minor nit.

I took a look at the failed tests in premerge checks, they didn't seem to be 
related, but please double check before you commit.




Comment at: clang/lib/Driver/ToolChains/AIX.cpp:195
+  // Return if -nostdlibinc is specified as a driver option.
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;

Can we rewrite this block of code so that it's in consistent with the previous 
one?
```
  if (!DriverArgs.hasArg(options::OPT_nostdlibinc)) {
// Add /usr/include.
SmallString<128> UP(Sysroot);
path::append(UP, "/usr/include");
addSystemInclude(DriverArgs, CC1Args, UP.str());
  }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677



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


[PATCH] D82659: Fix missing build dependency on omp_gen.

2020-07-03 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D82659#2130022 , @simon_tatham 
wrote:

> @jdoerfert , @clementval : over in D83032  
> is a polished-up version of the script I used to check where the missing deps 
> needed to go. Might be useful for the next problem of this kind. But I'm not 
> sure who to get to review it; perhaps one of you might look at it?


No idea who can review this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82659



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


[clang] 572dde5 - [XCOFF][AIX] Use 'L..' instead of '.L' for getPrivateGlobalPrefix in DataLayout

2020-07-03 Thread via cfe-commits

Author: jasonliu
Date: 2020-07-03T18:25:14Z
New Revision: 572dde55eebbe54eb90398c16c71d4376ca754e3

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

LOG: [XCOFF][AIX] Use 'L..' instead of '.L' for getPrivateGlobalPrefix in 
DataLayout

Summary:
D80831 changed part of the prefix usage for AIX.
But there are other places getting prefix from DataLayout.
This patch intends to make prefix usage consistent on AIX.

Reviewed by: hubert.reinterpretcast, daltenty

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

Added: 


Modified: 
clang/lib/Basic/Targets/PPC.h
llvm/docs/LangRef.rst
llvm/include/llvm/IR/DataLayout.h
llvm/lib/IR/DataLayout.cpp
llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
llvm/test/CodeGen/PowerPC/aix-lower-jump-table.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll
llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll
llvm/unittests/IR/ManglerTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index 22a367a5ad42..46670eaf423b 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -349,7 +349,10 @@ class LLVM_LIBRARY_VISIBILITY PPC32TargetInfo : public 
PPCTargetInfo {
 public:
   PPC32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : PPCTargetInfo(Triple, Opts) {
-resetDataLayout("E-m:e-p:32:32-i64:64-n32");
+if (Triple.isOSAIX())
+  resetDataLayout("E-m:a-p:32:32-i64:64-n32");
+else
+  resetDataLayout("E-m:e-p:32:32-i64:64-n32");
 
 switch (getTriple().getOS()) {
 case llvm::Triple::Linux:
@@ -395,7 +398,11 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public 
PPCTargetInfo {
 IntMaxType = SignedLong;
 Int64Type = SignedLong;
 
-if ((Triple.getArch() == llvm::Triple::ppc64le)) {
+if (Triple.isOSAIX()) {
+  // TODO: Set appropriate ABI for AIX platform.
+  resetDataLayout("E-m:a-i64:64-n32:64");
+  SuitableAlign = 64;
+} else if ((Triple.getArch() == llvm::Triple::ppc64le)) {
   resetDataLayout("e-m:e-i64:64-n32:64");
   ABI = "elfv2";
 } else {
@@ -403,9 +410,6 @@ class LLVM_LIBRARY_VISIBILITY PPC64TargetInfo : public 
PPCTargetInfo {
   ABI = "elfv1";
 }
 
-if (Triple.getOS() == llvm::Triple::AIX)
-  SuitableAlign = 64;
-
 if (Triple.isOSFreeBSD() || Triple.getOS() == llvm::Triple::AIX ||
 Triple.isMusl()) {
   LongDoubleWidth = LongDoubleAlign = 64;

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index f8eaf881b90a..9e99f4daa90a 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -2366,6 +2366,7 @@ as follows:
   starting with ``?`` are not mangled in any way.
 * ``w``: Windows COFF mangling: Similar to ``x``, except that normal C
   symbols do not receive a ``_`` prefix.
+* ``a``: XCOFF mangling: Private symbols get a ``L..`` prefix.
 ``n::...``
 This specifies a set of native integer widths for the target CPU in
 bits. For example, it might contain ``n32`` for 32-bit PowerPC,

diff  --git a/llvm/include/llvm/IR/DataLayout.h 
b/llvm/include/llvm/IR/DataLayout.h
index 703670c9e1db..17297bb8b309 100644
--- a/llvm/include/llvm/IR/DataLayout.h
+++ b/llvm/include/llvm/IR/DataLayout.h
@@ -133,7 +133,8 @@ class DataLayout {
 MM_MachO,
 MM_WinCOFF,
 MM_WinCOFFX86,
-MM_Mips
+MM_Mips,
+MM_XCOFF
   };
   ManglingModeT ManglingMode;
 
@@ -309,6 +310,7 @@ class DataLayout {
 case MM_ELF:
 case MM_Mips:
 case MM_WinCOFF:
+case MM_XCOFF:
   return '\0';
 case MM_MachO:
 case MM_WinCOFFX86:
@@ -329,6 +331,8 @@ class DataLayout {
 case MM_MachO:
 case MM_WinCOFFX86:
   return "L";
+case MM_XCOFF:
+  return "L..";
 }
 llvm_unreachable("invalid mangling mode");
   }

diff  --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 25fed92a504f..c44737c5bfc2 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -153,6 +153,8 @@ const char *DataLayout::getManglingComponent(const Triple 
&T) {
 return "-m:o";
   if (T.isOSWindows() && T.isOSBinFormatCOFF())
 return T.getArch() == Triple::x86 ? "-m:x" : "-m:w";
+  if (T.isOSBinFormatXCOFF())
+return "-m:a";
   return "-m:e";
 }
 
@@ -444,6 +446,9 @@ void DataLayout::parseSpecifier(StringRef Desc) {
   case 'x':
 ManglingMode = MM_WinCOFFX86;
 break;
+  case 'a':
+ManglingMode = MM_XCOFF;
+break;
   }
   break;
 default:

diff  --git a/llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll 
b/llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll
index fb7f0ad257b9..1737097d368c 100644
--- a/llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-in

[PATCH] D82781: [OpenCL] Fix missing address space deduction in template variables

2020-07-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:3628
 
+  // FIXME: This may not be the best approach, as the correct type (including
+  // address space) is available in D, but the type in D may not be reliable

Is this still an issue with your new patch? I presume deducing the address 
space early would still be better in general but it seems not to play well with 
the way the template instantiation is implemented currently. Although it might 
generally be safer not to deduce anything for templates until the final 
instantiation is done.


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

https://reviews.llvm.org/D82781



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


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

2020-07-03 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp:41
+
+  bool checkDeferenceOps(const CallEvent &Call, CheckerContext &C) const;
+};

NoQ wrote:
> Looks like dead code.
Thanks!
removed.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp:72
+  NullDereferenceBugType, "Dereference of null smart pointer", ErrNode);
+  R->addRange(Call.getSourceRange());
+  C.emitReport(std::move(R));

NoQ wrote:
> This is probably unnecessary. The default `SourceRange` highlighted in 
> path-sensitive report is the error node's statement and it should be exactly 
> the same.
Removed.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:67-80
+bool isStdSmartPtrCall(const CallEvent &Call) {
+  const auto *MethodDecl = dyn_cast_or_null(Call.getDecl());
+  if (!MethodDecl || !MethodDecl->getParent())
+return false;
+
+  const auto *RecordDecl = MethodDecl->getParent();
+  if (!RecordDecl || !RecordDecl->getDeclContext()->isStdNamespace())

NoQ wrote:
> Ok, so the normal solution to this problem is to make this logic a part of 
> your `CallDescriptionMap`:
> 
> ```lang=c++
>   CallDescriptionMap SmartPtrMethodHandlers{
> 
> {{"std", "unique_ptr", "reset"}, &SmartPtrModeling::handleReset},
> {{"std", "unique_ptr", "release"}, &SmartPtrModeling::handleRelease},
> {{"std", "unique_ptr", "swap", 1}, &SmartPtrModeling::handleSwap},
> 
> {{"std", "shared_ptr", "reset"}, &SmartPtrModeling::handleReset},
> {{"std", "shared_ptr", "release"}, &SmartPtrModeling::handleRelease},
> {{"std", "shared_ptr", "swap", 1}, &SmartPtrModeling::handleSwap},
> 
> {{"std", "weak_ptr", "reset"}, &SmartPtrModeling::handleReset},
> {{"std", "weak_ptr", "release"}, &SmartPtrModeling::handleRelease},
> {{"std", "weak_ptr", "swap", 1}, &SmartPtrModeling::handleSwap},
>   };
> ```
> 
> It looks like you're not doing this because `CallDescriptionMap` doesn't 
> support operator calls yet. In fact, it looks like it doesn't support them 
> because i'm not doing my homework by reviewing D81059. I just tried to catch 
> up on it.
> 
> The other potential reason not to use `CallDescriptionMap` would be that 
> you'll have to duplicate the list of methods for every smart pointer class 
> you want to support. I don't think it's necessarily bad though, because 
> different classes may in fact require different handling.
> 
> The downside of your solution, though, is that you're manually implementing 
> the name matching logic that has been already implemented for you in 
> `CallDescriptionMap`. And the reason we made `CallDescriptionMap` was because 
> we really really wanted to re-use this logic because it's surprisingly 
> difficult to implement correctly. One potential problem i see with your 
> implementation is that you don't account for inline namespaces such as [[ 
> https://github.com/llvm/llvm-project/blob/master/clang/unittests/StaticAnalyzer/CallDescriptionTest.cpp#L127
>  | libcxx's `__1` ]]. `CallDescriptionMap` knows about these things but 
> they're almost impossible to discover independently when you're matching 
> names by hand.
> 
> Let's leave this code as-is for now but try to get rid of this function as 
> soon as possible (i.e., when D81059 lands).
Thanks for the details.
If I recall correctly, I also found that  `CallDescriptionMap` was not 
supporting constructors also. 
I am not sure why.
Is it because constructor name is a special name?



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:50
+  void handleSwap(const CallEvent &Call, CheckerContext &C) const;
+  bool checkDeferenceOps(const CallEvent &Call, CheckerContext &C) const;
+

NoQ wrote:
> Looks like dead code.
Thanks!
removed.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:81
 CheckerContext &C) const {
-  if (!isNullAfterMoveMethod(Call))
+  if (isNullAfterMoveMethod(Call)) {
+ProgramStateRef State = C.getState();

NoQ wrote:
> vrnithinkumar wrote:
> > xazax.hun wrote:
> > > Don't we want this to be also protected by the `isStdSmartPointerClass` 
> > > check?
> > added `isStdSmartPointerClass` check in the beginning.
> Uh-oh, i'm shocked this wasn't in place before. Maybe we should do some code 
> review or something. What idiot wrote this code anyway? Wait, it was me.
:)



Comment at: clang/test/Analysis/smart-ptr.cpp:5
 // RUN:   -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core\
+// RUN:   -analyzer-checker alpha.cplusplus.SmartPtr\

NoQ wrote:
> This second run-line no longer tests the option. The checker is disabled, of 
> course there won't be any diagnostics. I think we should remove the second 
> run-line now and i don't have much better tests in mind that 

[PATCH] D52676: [clang-format] tweaked another case of lambda formatting

2020-07-03 Thread Jeff Trull via Phabricator via cfe-commits
jaafar added a comment.

It's been pointed out to me that 28546 preceded this commit... so it may only 
//appear// related.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D52676



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


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

2020-07-03 Thread Nithin VR via Phabricator via cfe-commits
vrnithinkumar updated this revision to Diff 275434.
vrnithinkumar marked 11 inline comments as done.
vrnithinkumar added a comment.

addressing review comments


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

https://reviews.llvm.org/D81315

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/SmartPtr.h
  clang/lib/StaticAnalyzer/Checkers/SmartPtrChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/smart-ptr.cpp
  clang/test/Analysis/use-after-move.cpp

Index: clang/test/Analysis/use-after-move.cpp
===
--- clang/test/Analysis/use-after-move.cpp
+++ clang/test/Analysis/use-after-move.cpp
@@ -1,36 +1,36 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=KnownsOnly\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move -verify %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=KnownsOnly\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,non-aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=unexplored_first_queue\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=All\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,aggressive
 // RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.Move %s\
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=All\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,aggressive
 
 // RUN: not %clang_analyze_cc1 -verify %s \
@@ -49,7 +49,7 @@
 // RUN:  -std=c++11 -analyzer-output=text -analyzer-config eagerly-assume=false\
 // RUN:  -analyzer-config exploration_strategy=dfs -DDFS\
 // RUN:  -analyzer-config cplusplus.Move:WarnOn=All -DAGGRESSIVE_DFS\
-// RUN:  -analyzer-checker core,cplusplus.SmartPtr,debug.ExprInspection\
+// RUN:  -analyzer-checker core,cplusplus.SmartPtrModeling,debug.ExprInspection\
 // RUN:  -verify=expected,peaceful,aggressive %s 2>&1 | FileCheck %s
 
 #include "Inputs/system-header-simulator-cxx.h"
Index: clang/test/Analysis/smart-ptr.cpp
===
--- clang/test/Analysis/smart-ptr.cpp
+++ clang/test/Analysis/smart-ptr.cpp
@@ -1,16 +1,18 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection\
-// RUN:   -analyzer-checker cplusplus.Move,cplusplus.SmartPtr\
+// RUN:   -analyzer-checker cplusplus.Move,alpha.cplusplus.SmartPtr\
+// RUN:   -analyzer-config cplusplus.SmartPtrModeling:ModelSmartPtrDereference=true\
 // RUN:   -std=c++11 -verify %s
 
 #include "Inputs/system-header-simulator-cxx.h"
 
 void clang_analyzer_warnIfReached();
+void clang_analyzer_numTimesReached();
 
 void derefAfterMov

[PATCH] D80660: clang: Add support for relative linker paths with -fuse-ld

2020-07-03 Thread Keith Smiley via Phabricator via cfe-commits
keith abandoned this revision.
keith added a comment.

https://reviews.llvm.org/D83015


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80660



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


[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-07-03 Thread Shuhong Liu via Phabricator via cfe-commits
ShuhongL updated this revision to Diff 275432.
ShuhongL added a comment.

Add clang -xc tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/Driver/aix-toolchain-include.cpp

Index: clang/test/Driver/aix-toolchain-include.cpp
===
--- /dev/null
+++ clang/test/Driver/aix-toolchain-include.cpp
@@ -0,0 +1,136 @@
+// Tests that the AIX toolchain adds system includes to its search path.
+
+// Check powerpc-ibm-aix, 32-bit/64-bit.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// CHECK-INTERNAL-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-INTERNAL-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-INTERNAL-INCLUDE:	"-internal-isystem" "[[SYSROOT]]/usr/include"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nostdinc option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// CHECK-NOSTDINC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOSTDINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDINC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-NOSTDINC-INCLUDE-NOT:	"-internal-isystem"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nostdlibinc option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// RUN: %clang -### -xc -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// CHECK-NOSTDLIBINC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOSTDLIBINC-INCLUDE-NO

[PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-03 Thread Albion Fung via Phabricator via cfe-commits
Conanap marked 2 inline comments as done.
Conanap added a comment.

Addressed Lei's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502



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


[PATCH] D82502: [PowerPC][Power10] Implement Load VSX Vector and Sign Extend and Zero Extend

2020-07-03 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 275423.
Conanap marked 3 inline comments as done.
Conanap added a comment.

Moved some code to the top of the file as per Lei's request


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82502

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/p10-vsx-builtins.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- llvm/test/MC/PowerPC/p10.s
+++ llvm/test/MC/PowerPC/p10.s
@@ -33,3 +33,15 @@
 # CHECK-BE: vclrrb 1, 4, 3# encoding: [0x10,0x24,0x19,0xcd]
 # CHECK-LE: vclrrb 1, 4, 3# encoding: [0xcd,0x19,0x24,0x10]
 vclrrb 1, 4, 3
+# CHECK-BE: lxvrbx 32, 1, 2   # encoding: [0x7c,0x01,0x10,0x1b]
+# CHECK-LE: lxvrbx 32, 1, 2   # encoding: [0x1b,0x10,0x01,0x7c]
+lxvrbx 32, 1, 2
+# CHECK-BE: lxvrhx 33, 1, 2   # encoding: [0x7c,0x21,0x10,0x5b]
+# CHECK-LE: lxvrhx 33, 1, 2   # encoding: [0x5b,0x10,0x21,0x7c]
+lxvrhx 33, 1, 2
+# CHECK-BE: lxvrdx 34, 1, 2   # encoding: [0x7c,0x41,0x10,0xdb]
+# CHECK-LE: lxvrdx 34, 1, 2   # encoding: [0xdb,0x10,0x41,0x7c]
+lxvrdx 34, 1, 2
+# CHECK-BE: lxvrwx 35, 1, 2   # encoding: [0x7c,0x61,0x10,0x9b]
+# CHECK-LE: lxvrwx 35, 1, 2   # encoding: [0x9b,0x10,0x61,0x7c]
+lxvrwx 35, 1, 2
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- llvm/test/MC/Disassembler/PowerPC/p10insts.txt
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -30,3 +30,15 @@
 
 # CHECK: vclrrb 1, 4, 3
 0x10 0x24 0x19 0xcd
+
+# CHECK: lxvrbx 32, 1, 2
+0x7c 0x01 0x10 0x1b
+
+# CHECK: lxvrhx 33, 1, 2
+0x7c 0x21 0x10 0x5b
+
+# CHECK: lxvrdx 34, 1, 2
+0x7c 0x41 0x10 0xdb
+
+# CHECK: lxvrwx 35, 1, 2
+0x7c 0x61 0x10 0x9b
Index: llvm/test/CodeGen/PowerPC/p10-vsx-builtins.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-vsx-builtins.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; These test cases tests that zero extending loads utilize the Load VSX Vector Rightmost
+; (lxvr[b|h|w|d]x) instructions in Power10.
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+define dso_local <1 x i128> @vec_xl_zext(i64 %__offset, i8* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lxvrbx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i8, i8* %__pointer, i64 %__offset
+  %0 = load i8, i8* %add.ptr, align 1
+  %conv = zext i8 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_short(i64 %__offset, i16* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_short:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 1
+; CHECK-NEXT:lxvrhx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i16, i16* %__pointer, i64 %__offset
+  %0 = load i16, i16* %add.ptr, align 2
+  %conv = zext i16 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_word(i64 %__offset, i32* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_word:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 2
+; CHECK-NEXT:lxvrwx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i32, i32* %__pointer, i64 %__offset
+  %0 = load i32, i32* %add.ptr, align 4
+  %conv = zext i32 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
+define dso_local <1 x i128> @vec_xl_zext_dw(i64 %__offset, i64* nocapture readonly %__pointer) {
+; CHECK-LABEL: vec_xl_zext_dw:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:sldi r3, r3, 3
+; CHECK-NEXT:lxvrdx v2, r4, r3
+; CHECK-NEXT:blr
+entry:
+  %add.ptr = getelementptr inbounds i64, i64* %__pointer, i64 %__offset
+  %0 = load i64, i64* %add.ptr, align 8
+  %conv = zext i64 %0 to i128
+  %splat.splatinsert = insertelement <1 x i128> undef, i128 %conv, i32 0
+  ret <1 x i128> %splat.splatinsert
+}
+
Index: llvm/lib/Target/Po

[PATCH] D52676: [clang-format] tweaked another case of lambda formatting

2020-07-03 Thread Jeff Trull via Phabricator via cfe-commits
jaafar added a comment.

Hi everyone, I've been investigating a bug and bisected it to this commit.

The problem, in brief, is that lambdas passed as arguments can cause an extra 
line break before the first argument, but only if the lambda is neither the 
first nor the last argument. This implies, of course, that there are at least 
three arguments supplied... Perhaps the most minimal example is:

  void f()
{
func(0, [] {}, 0);
}

which gets formatted as:

  void
  f ()
  {
  func (
  0, [] {}, 0);
  }

(note the unnecessary newline after the left paren)

I found three existing reports of this problem: 28546 
,  45141 
, and 45424 
. I'm posting here in lieu of 
creating a fourth duplicate bug report, in the hopes that it will be more 
likely to find someone who can fix it. Thank you.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D52676



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


[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.

Aside from one comment; LGTM. Thanks.




Comment at: clang/test/Driver/aix-toolchain-include.cpp:4
+// Check powerpc-ibm-aix, 32-bit/64-bit.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:-target powerpc-ibm-aix \

I think there should be a `clang` (as opposed to `clang++`) test as well. 
Duplicate this invocation and use `clang` with `-xc`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677



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


[PATCH] D82620: [clang-format] Preserve whitespace in selected macros

2020-07-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/docs/ClangFormatStyleOptions.rst:2706
+
+  For example: STRINGIZE
+

JakeMerdichAMD wrote:
> curdeius wrote:
> > Shouldn't there be a configuration example like what's in `ForEachMacros` 
> > doc?
> > ```
> >   In the .clang-format configuration file, this can be configured like:
> > 
> >   .. code-block:: yaml
> > 
> > WhitespaceSensitiveMacros: ['STRINGIZE', 'PP_STRINGIZE']
> > 
> >   For example: BOOST_PP_STRINGIZE.
> > ```
> > 
> Done. I also added PP_STRINGIZE and BOOST_PP_STRINGIZE as defaults; seems 
> reasonable.
The change I think you made here gets lost when the ClangFormatOptions.rst file 
is regenerated

Could you update the `Format.h` and regenerate rather than making the code 
changes in the rst itself?

I ran into this issue when I tried to regenerate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82620



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


[PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library

2020-07-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware accepted this revision.
baloghadamsoftware added a comment.
This revision is now accepted and ready to land.

It looks OK.


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

https://reviews.llvm.org/D82585



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


[PATCH] D77150: [Analyzer] New Option for ContainerModeling: AggressiveEraseModeling

2020-07-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 275406.
baloghadamsoftware added a comment.

Rebased. Tests added. Fixed to work on `std::vector`-like and `std::deque`-like 
containers as well.


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

https://reviews.llvm.org/D77150

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/test/Analysis/analyzer-config.c
  clang/test/Analysis/iterator-range-aggressive-erase-modeling.cpp

Index: clang/test/Analysis/iterator-range-aggressive-erase-modeling.cpp
===
--- /dev/null
+++ clang/test/Analysis/iterator-range-aggressive-erase-modeling.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_analyze_cc1 -std=c++11 \
+// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange \
+// RUN: -analyzer-config aggressive-binary-operation-simplification=true \
+// RUN: -analyzer-config c++-container-inlining=false %s \
+// RUN: -analyzer-config alpha.cplusplus.ContainerModeling:AggressiveEraseModeling=true \
+// RUN: -verify
+
+// RUN: %clang_analyze_cc1 -std=c++11 \
+// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange \
+// RUN: -analyzer-config aggressive-binary-operation-simplification=true \
+// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s \
+// RUN: -analyzer-config alpha.cplusplus.ContainerModeling:AggressiveEraseModeling=true \
+// RUN: -verify
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+extern void __assert_fail (__const char *__assertion, __const char *__file,
+unsigned int __line, __const char *__function)
+ __attribute__ ((__noreturn__));
+#define assert(expr) \
+  ((expr)  ? (void)(0)  : __assert_fail (#expr, __FILE__, __LINE__, __func__))
+
+void bad_erase_loop(std::list L) {
+  for (auto i = L.cbegin(); i != L.end(); ++i) { // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+i = L.erase(i);
+  }
+}
+
+void bad_erase_loop(std::vector V) {
+  for (auto i = V.cbegin(); i != V.end(); ++i) { // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+i = V.erase(i);
+  }
+}
+void bad_erase_loop(std::deque D) {
+  for (auto i = D.cbegin(); i != D.end(); ++i) { // expected-warning{{Iterator incremented behind the past-the-end iterator}}
+i = D.erase(i);
+  }
+}
Index: clang/test/Analysis/analyzer-config.c
===
--- clang/test/Analysis/analyzer-config.c
+++ clang/test/Analysis/analyzer-config.c
@@ -7,6 +7,7 @@
 // CHECK-NEXT: alpha.clone.CloneChecker:IgnoredFilesPattern = ""
 // CHECK-NEXT: alpha.clone.CloneChecker:MinimumCloneComplexity = 50
 // CHECK-NEXT: alpha.clone.CloneChecker:ReportNormalClones = true
+// CHECK-NEXT: alpha.cplusplus.ContainerModeling:AggressiveEraseModeling = false
 // CHECK-NEXT: alpha.cplusplus.STLAlgorithmModeling:AggressiveStdFindModeling = false
 // CHECK-NEXT: alpha.osx.cocoa.DirectIvarAssignment:AnnotatedFunctions = false
 // CHECK-NEXT: alpha.security.MmapWriteExec:MmapProtExec = 0x04
Index: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
@@ -44,16 +44,16 @@
   void handlePopBack(CheckerContext &C, SVal Cont, const Expr *ContE) const;
   void handlePushFront(CheckerContext &C, SVal Cont, const Expr *ContE) const;
   void handlePopFront(CheckerContext &C, SVal Cont, const Expr *ContE) const;
-  void handleInsert(CheckerContext &C, SVal Cont, SVal Iter,
-SVal RetVal) const;
-  void handleInsertAfter(CheckerContext &C, SVal Cont, SVal Iter,
- SVal RetVal) const;
-  void handleErase(CheckerContext &C, SVal Cont, SVal Iter,
-SVal RetVal) const;
+  void handleInsert(CheckerContext &C, SVal Cont, SVal Iter, SVal RetVal,
+const Expr *CE) const;
+  void handleInsertAfter(CheckerContext &C, SVal Cont, SVal Iter, SVal RetVal,
+ const Expr *CE) const;
+  void handleErase(CheckerContext &C, SVal Cont, SVal Iter, SVal RetVal,
+   const Expr *CE) const;
   void handleErase(CheckerContext &C, SVal Cont, SVal Iter1, SVal Iter2,
 SVal RetVal) const;
-  void handleEraseAfter(CheckerContext &C, SVal Cont, SVal Iter,
-SVal RetVal) const;
+  void handleEraseAfter(CheckerContext &C, SVal Cont, SVal Iter, SVal RetVal,
+const Expr *CE) const;
   void handleEraseAfter(CheckerContext &C, SVal Cont, SVal Iter1,
 SVal Iter2, SVal RetVal) const;
   const NoteTag *getChangeTag(CheckerContext &C, StringRef Text,
@@ -65,14 +65,16 @@
 public:
   ContainerModeling() = default;
 
+  DefaultBool AggressiveEraseModeling;
+
   void checkPostCall(con

[PATCH] D77125: [Analyzer] Model return values of container insert and delete operations

2020-07-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 275405.
baloghadamsoftware added a comment.

Rebased.


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

https://reviews.llvm.org/D77125

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/test/Analysis/Inputs/system-header-simulator-cxx.h
  clang/test/Analysis/diagnostics/explicit-suppression.cpp
  clang/test/Analysis/iterator-modeling.cpp

Index: clang/test/Analysis/iterator-modeling.cpp
===
--- clang/test/Analysis/iterator-modeling.cpp
+++ clang/test/Analysis/iterator-modeling.cpp
@@ -873,9 +873,9 @@
   clang_analyzer_eval(clang_analyzer_iterator_validity(i0)); //expected-warning{{TRUE}}
   clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}}
 
-  clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning-re {{$L.begin(){{$
-  // clang_analyzer_express(clang_analyzer_iterator_position(i2)); FIXME: expect warning $L.begin() - 1
-  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re {{$L.end(){{$
+  clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.begin()}}
 }
 
 void list_insert_behind_begin(std::list &L, int n) {
@@ -890,10 +890,10 @@
   clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}}
   clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}}
 
-  clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning-re {{$L.begin(){{$ FIXME: Should be $L.begin() - 1
-  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re {{$L.begin() + 1{{$
-  // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.begin()
-  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$L.end(){{$
+  clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.begin() + 1}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i3)); // expected-warning{{$L.begin()}}
 }
 
 template  Iter return_any_iterator(const Iter &It);
@@ -911,10 +911,10 @@
   clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}}
   clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}}
 
-  clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning-re {{$L.begin(){{$
-  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re {{$i1{{$
-  // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $i - 1
-  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$L.end(){{$
+  clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$i1}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i3)); // expected-warning{{$i1}}
 }
 
 void list_insert_ahead_of_end(std::list &L, int n) {
@@ -929,10 +929,10 @@
   clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}}
   clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}}
 
-  clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning-re {{$L.begin(){{$
-  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning-re {{$L.end() - 1{{$
-  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning-re {{$L.end(){{$
-  // clang_analyzer_express(clang_analyzer_iterator_position(i3)); FIXME: expect warning $L.end() - 2
+  clang_analyzer_express(clang_analyzer_iterator_position(i0)); // expected-warning{{$L.begin()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i1)); // expected-warning{{$L.end() - 1}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i2)); // expected-warning{{$L.end()}}
+  clang_analyzer_express(clang_analyzer_iterator_position(i3)); // expected-warning{{$L.end() - 1}}
 }
 
 void list_insert_end(std::list &L, int n) {
@@ -947,10 +947,10 @@
   clang_analyzer_eval(clang_analyzer_iterator_validity(i1)); //expected-warning{{TRUE}}
   clang_analyzer_eval(clang_analyzer_iterator_validity(i2)); //expected-warning{{TRUE}}
 
-  clang_analyzer_express(clang_anal

[clang] ef875c2 - [clang][NFC] Removed unused parameters in InitializeSourceManager

2020-07-03 Thread Andrzej Warzynski via cfe-commits

Author: Andrzej Warzynski
Date: 2020-07-03T16:16:20+01:00
New Revision: ef875c228ae7484f7bc42511c9fb1e643fa7550d

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

LOG: [clang][NFC] Removed unused parameters in InitializeSourceManager

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInstance.h
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInstance.h 
b/clang/include/clang/Frontend/CompilerInstance.h
index ba9bd439c4a3..cb935becaef1 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -764,10 +764,7 @@ class CompilerInstance : public ModuleLoader {
   static bool InitializeSourceManager(const FrontendInputFile &Input,
   DiagnosticsEngine &Diags,
   FileManager &FileMgr,
-  SourceManager &SourceMgr,
-  HeaderSearch *HS,
-  DependencyOutputOptions &DepOpts,
-  const FrontendOptions &Opts);
+  SourceManager &SourceMgr);
 
   /// }
 

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 0140a756b7dd..9dc9c42297ed 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -815,17 +815,15 @@ std::unique_ptr 
CompilerInstance::createOutputFile(
 // Initialization Utilities
 
 bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input){
-  return InitializeSourceManager(
-  Input, getDiagnostics(), getFileManager(), getSourceManager(),
-  hasPreprocessor() ? &getPreprocessor().getHeaderSearchInfo() : nullptr,
-  getDependencyOutputOpts(), getFrontendOpts());
+  return InitializeSourceManager(Input, getDiagnostics(), getFileManager(),
+ getSourceManager());
 }
 
 // static
-bool CompilerInstance::InitializeSourceManager(
-const FrontendInputFile &Input, DiagnosticsEngine &Diags,
-FileManager &FileMgr, SourceManager &SourceMgr, HeaderSearch *HS,
-DependencyOutputOptions &DepOpts, const FrontendOptions &Opts) {
+bool CompilerInstance::InitializeSourceManager(const FrontendInputFile &Input,
+   DiagnosticsEngine &Diags,
+   FileManager &FileMgr,
+   SourceManager &SourceMgr) {
   SrcMgr::CharacteristicKind Kind =
   Input.getKind().getFormat() == InputKind::ModuleMap
   ? Input.isSystem() ? SrcMgr::C_System_ModuleMap



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


[PATCH] D81657: [AMDGPU] Added support of new inline assembler constraints

2020-07-03 Thread Dmitry Preobrazhensky via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53422e8b4f65: [AMDGPU] Added support of new inline assembler 
constraints (authored by dp).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D81657?vs=271332&id=275400#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81657

Files:
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
  clang/test/Sema/inline-asm-validate-amdgpu.cl

Index: clang/test/Sema/inline-asm-validate-amdgpu.cl
===
--- clang/test/Sema/inline-asm-validate-amdgpu.cl
+++ clang/test/Sema/inline-asm-validate-amdgpu.cl
@@ -18,9 +18,35 @@
   // vgpr constraints
   __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
 
-  // 'A' constraint
+  // 'I' constraint (an immediate integer in the range -16 to 64)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (imm) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (-16) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (64) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (-17) : ); // expected-error {{value '-17' out of range for constraint 'I'}}
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (65) : ); // expected-error {{value '65' out of range for constraint 'I'}}
+
+  // 'J' constraint (an immediate 16-bit signed integer)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (imm) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (-32768) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (32767) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (-32769) : ); // expected-error {{value '-32769' out of range for constraint 'J'}}
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (32768) : ); // expected-error {{value '32768' out of range for constraint 'J'}}
+
+  // 'A' constraint (an immediate constant that can be inlined)
   __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "A" (imm) : );
 
+  // 'B' constraint (an immediate 32-bit signed integer)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "B" (imm) : );
+
+  // 'C' constraint (an immediate 32-bit unsigned integer or 'A' constraint)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "C" (imm) : );
+
+  // 'DA' constraint (an immediate 64-bit constant that can be split into two 'A' constants)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "DA" (imm) : );
+
+  // 'DB' constraint (an immediate 64-bit constant that can be split into two 'B' constants)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "DB" (imm) : );
+
 }
 
 __kernel void
Index: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -33,3 +33,17 @@
  : "={a1}"(reg_a)
  : "{a1}"(reg_b));
 }
+
+kernel void test_constraint_DA() {
+  const long x = 0x20001;
+  int res;
+  // CHECK: call i32 asm sideeffect "v_mov_b32 $0, $1 & 0x", "=v,^DA"(i64 8589934593)
+  __asm volatile("v_mov_b32 %0, %1 & 0x" : "=v"(res) : "DA"(x));
+}
+
+kernel void test_constraint_DB() {
+  const long x = 0x20001;
+  int res;
+  // CHECK: call i32 asm sideeffect "v_mov_b32 $0, $1 & 0x", "=v,^DB"(i64 8589934593)
+  __asm volatile("v_mov_b32 %0, %1 & 0x" : "=v"(res) : "DB"(x));
+}
Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -130,8 +130,26 @@
 "exec_hi", "tma_lo", "tma_hi", "tba_lo", "tba_hi",
 });
 
+switch (*Name) {
+case 'I':
+  Info.setRequiresImmediate(-16, 64);
+  return true;
+case 'J':
+  Info.setRequiresImmediate(-32768, 32767);
+  return true;
+case 'A':
+case 'B':
+case 'C':
+  Info.setRequiresImmediate();
+  return true;
+default:
+  break;
+}
+
 StringRef S(Name);
-if (S == "A") {
+
+if (S == "DA" || S == "DB") {
+  Name++;
   Info.setRequiresImmediate();
   return true;
 }
@@ -203,6 +221,12 @@
   // the constraint.  In practice, it won't be changed unless the
   // constraint is longer than one character.
   std::string convertConstraint(const char *&Constraint) const override {
+
+StringRef S(Constraint);
+if (S == "DA" || S == "DB") {
+  return std::string("^") + std::string(Constraint++, 2);
+}
+
 const char *Begin = Constraint;
 TargetInfo::ConstraintInfo Info("", "");
 if (validateAsmConstraint(Constraint, Info))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82677: [Clang] Handle AIX Include management in the driver

2020-07-03 Thread Shuhong Liu via Phabricator via cfe-commits
ShuhongL updated this revision to Diff 275396.
ShuhongL added a comment.

- `nostdlibinc` should not suppress clang builtin headers
- Add tests for `nostdlibinc` and `nobuiltininc`
- fix lint


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82677

Files:
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/lib/Frontend/InitHeaderSearch.cpp
  clang/test/Driver/aix-toolchain-include.cpp

Index: clang/test/Driver/aix-toolchain-include.cpp
===
--- /dev/null
+++ clang/test/Driver/aix-toolchain-include.cpp
@@ -0,0 +1,82 @@
+// Tests that the AIX toolchain adds system includes to its search path.
+
+// Check powerpc-ibm-aix, 32-bit/64-bit.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:   | FileCheck -check-prefix=CHECK-INTERNAL-INCLUDE %s
+
+// CHECK-INTERNAL-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-INTERNAL-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-INTERNAL-INCLUDE:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-INTERNAL-INCLUDE:	"-internal-isystem" "[[SYSROOT]]/usr/include"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nostdinc option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDINC-INCLUDE %s
+
+// CHECK-NOSTDINC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOSTDINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDINC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-NOSTDINC-INCLUDE-NOT:	"-internal-isystem"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nostdlibinc option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nostdlibinc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOSTDLIBINC-INCLUDE %s
+
+// CHECK-NOSTDLIBINC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-NOSTDLIBINC-INCLUDE:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOSTDLIBINC-INCLUDE-NOT:	"-internal-isystem" "[[SYSROOT]]/usr/include"
+
+// Check powerpc-ibm-aix, 32-bit/64-bit. -nobuiltininc option.
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nobuiltininc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
+
+// RUN: %clangxx -### -no-canonical-prefixes %s 2>&1 \
+// RUN:		-target powerpc64-ibm-aix \
+// RUN:		-resource-dir=%S/Inputs/resource_dir \
+// RUN:		--sysroot=%S/Inputs/basic_aix_tree \
+// RUN:		-nobuiltininc \
+// RUN:   | FileCheck -check-prefix=CHECK-NOBUILTININC-INCLUDE %s
+
+// CHECK-NOBUILTININC-INCLUDE:	{{.*}}clang{{.*}}" "-cc1"
+// CHECK-NOBUILTININC-INCLUDE:	"-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-NOBUILTININC-INCLUDE:	"-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-NOBUILTININC-INCLUDE-NOT:	"-internal-isystem" "[[RESOURCE_DIR]]{{(/|)}}include"
+// CHECK-NOBUILTININC-INCLUDE:	"-internal-isystem" "[[SYSROOT]]/usr/include"
Index: clang/lib/Frontend/InitHeaderSearch.cpp
===
--- clang/lib/Frontend/InitHeaderSearch.cpp
+++ clang/lib/Frontend/InitHeaderSearch.cpp
@@ -381,6 +381,7 @@
   case llvm::Triple::Linux:
   case llvm::Triple::Hurd:
   case llvm::Triple::Solaris:
+  case llvm::Triple::AIX:
 llvm_unreachable("Include management is handled in the driver.");
 break;
   case llvm::Triple::Win32:
@@ -424,6 +425,7 @@
   case llvm::Tripl

[PATCH] D83088: Introduce CfgTraits abstraction

2020-07-03 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:133
+  ++m_def;
+  if (m_def == m_instr->defs().end()) {
+++m_instr;

!= return early?



Comment at: llvm/include/llvm/CodeGen/MachineCfgTraits.h:136-138
+  // Prefer to avoid support for bundled instructions as long as we
+  // don't really need it.
+  assert(!m_instr->isBundle());

I've been thinking about more aggressively using bundles around call sites to 
handle waterfall looping around divergent calls with SGPR arguments



Comment at: llvm/lib/CodeGen/MachineCfgTraits.cpp:27-29
+void MachineCfgTraits::Printer::printBlockName(raw_ostream &out,
+   MachineBasicBlock *block) const 
{
+  out << "bb." << block->getNumber();

I think this should be added to MachineBasicBlock. The same logic is already 
repeated in MIRPrinter (and the MBB dump function uses a different prefix)



Comment at: llvm/lib/CodeGen/MachineCfgTraits.cpp:32
+if (irBlock->hasName())
+  out << "." << irBlock->getName();
+  }

Single quotes around .



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83088



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


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

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1871
 
+  // AIX ABI has this special rule that in aggregates, the first member of
+  // floating point data type(or aggregate type contains floating point data

Suggestion:
```
  // The AIX `power` alignment rules apply the natural alignment of the
  // "first member" if it is of a floating-point data type (or is an aggregate
  // whose recursively "first" member or element is such a type). The alignment
  // associated with these types for subsequent members use an alignment value
  // where the floating-point data type is considered to have 4-byte alignment.
  //
  // For the purposes of the foregoing: vtable pointers, non-empty base classes,
  // and zero-width bit-fields count as prior members; members of empty class
  // types marked `no_unique_address` are not considered to be prior members.
```

This fixes a number of issues with the comment, including:

  - The meaning of "first member" is unclear and the intended meaning is 
unlikely to be understood from common meanings of the term.
  - The recursive application of the rule was not captured (the relationship is 
not merely "contains").
  - The statement about 4-byte alignment needed to take stricter alignment due 
to other factors into account.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D82948: [Driver][ARM] Disable unsupported features when nofp arch extension is used

2020-07-03 Thread Victor Campos via Phabricator via cfe-commits
vhscampos updated this revision to Diff 275392.
vhscampos added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

1. Merged the second patch into this (handle bf16).
2. Do the same treatment for -mcpu.
3. Instead of doing string search once again, return the desired information in 
the first time using a by-ref argument.
4. This new approach covers positional differences between +fp and +nofp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82948

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/CodeGen/arm-bf16-softfloat.c
  llvm/include/llvm/Support/ARMTargetParser.h
  llvm/lib/Support/ARMTargetParser.cpp

Index: llvm/lib/Support/ARMTargetParser.cpp
===
--- llvm/lib/Support/ARMTargetParser.cpp
+++ llvm/lib/Support/ARMTargetParser.cpp
@@ -490,9 +490,10 @@
   return ARM::FK_INVALID;
 }
 
-bool ARM::appendArchExtFeatures(
-  StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
-  std::vector &Features) {
+bool ARM::appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK,
+StringRef ArchExt,
+std::vector &Features,
+unsigned &ArgFPUID) {
 
   size_t StartingNumFeatures = Features.size();
   const bool Negated = stripNegationPrefix(ArchExt);
@@ -527,6 +528,7 @@
 } else {
   FPUKind = getDefaultFPU(CPU, AK);
 }
+ArgFPUID = FPUKind;
 return ARM::getFPUFeatures(FPUKind, Features);
   }
   return StartingNumFeatures != Features.size();
Index: llvm/include/llvm/Support/ARMTargetParser.h
===
--- llvm/include/llvm/Support/ARMTargetParser.h
+++ llvm/include/llvm/Support/ARMTargetParser.h
@@ -250,7 +250,8 @@
 StringRef getArchExtName(uint64_t ArchExtKind);
 StringRef getArchExtFeature(StringRef ArchExt);
 bool appendArchExtFeatures(StringRef CPU, ARM::ArchKind AK, StringRef ArchExt,
-   std::vector &Features);
+   std::vector &Features,
+   unsigned &ArgFPUKind);
 StringRef getHWDivName(uint64_t HWDivKind);
 
 // Information by Name
Index: clang/test/CodeGen/arm-bf16-softfloat.c
===
--- clang/test/CodeGen/arm-bf16-softfloat.c
+++ clang/test/CodeGen/arm-bf16-softfloat.c
@@ -1,4 +1,9 @@
-// RUN: not %clang -o %t.out -target arm-arm-eabi -march=armv8-a+bf16 -mfloat-abi=soft -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16 -mfloat-abi=soft -c %s -o %t 2>&1 | FileCheck %s
+// RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16 -mfpu=none -c %s -o %t 2>&1 | FileCheck %s
+// RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16+nofp -c %s -o %t 2>&1 | FileCheck %s
+// RUN: not %clang -target arm-arm-none-eabi -march=armv8-a+bf16+fp+nofp -c %s -o %t 2>&1 | FileCheck %s
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-a+bf16+fp -c %s -o %t
+// RUN: %clang -target arm-arm-none-eabi -march=armv8-a+bf16+nofp+fp -c %s -o %t
 
 // CHECK: error: __bf16 is not supported on this target
 extern __bf16 var;
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -73,14 +73,15 @@
 }
 
 // Decode ARM features from string like +[no]featureA+[no]featureB+...
-static bool DecodeARMFeatures(const Driver &D, StringRef text,
-  StringRef CPU, llvm::ARM::ArchKind ArchKind,
-  std::vector &Features) {
+static bool DecodeARMFeatures(const Driver &D, StringRef text, StringRef CPU,
+  llvm::ARM::ArchKind ArchKind,
+  std::vector &Features,
+  unsigned &ArgFPUID) {
   SmallVector Split;
   text.split(Split, StringRef("+"), -1, false);
 
   for (StringRef Feature : Split) {
-if (!appendArchExtFeatures(CPU, ArchKind, Feature, Features))
+if (!appendArchExtFeatures(CPU, ArchKind, Feature, Features, ArgFPUID))
   return false;
   }
   return true;
@@ -102,14 +103,14 @@
 static void checkARMArchName(const Driver &D, const Arg *A, const ArgList &Args,
  llvm::StringRef ArchName, llvm::StringRef CPUName,
  std::vector &Features,
- const llvm::Triple &Triple) {
+ const llvm::Triple &Triple, unsigned &ArgFPUID) {
   std::pair Split = ArchName.split("+");
 
   std::string MArch = arm::getARMArch(ArchName, Triple);
   llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(MArch);
   if (ArchKind == llvm::ARM::ArchKind::INVALID ||
-  (Split.second.size() && !DecodeARMFeatures(

[clang] 53422e8 - [AMDGPU] Added support of new inline assembler constraints

2020-07-03 Thread Dmitry Preobrazhensky via cfe-commits

Author: Dmitry Preobrazhensky
Date: 2020-07-03T18:01:12+03:00
New Revision: 53422e8b4f65a6736896311b10ad8a22fbc9e372

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

LOG: [AMDGPU] Added support of new inline assembler constraints

Added support for constraints 'I', 'J', 'L', 'B', 'C', 'Kf', 'DA', 'DB'.

See 
https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html#Machine-Constraints.

Reviewers: arsenm, rampitec

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

Added: 


Modified: 
clang/lib/Basic/Targets/AMDGPU.h
clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
clang/test/Sema/inline-asm-validate-amdgpu.cl

Removed: 




diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index 387b91abb537..d0394492cad6 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -130,8 +130,26 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
 "exec_hi", "tma_lo", "tma_hi", "tba_lo", "tba_hi",
 });
 
+switch (*Name) {
+case 'I':
+  Info.setRequiresImmediate(-16, 64);
+  return true;
+case 'J':
+  Info.setRequiresImmediate(-32768, 32767);
+  return true;
+case 'A':
+case 'B':
+case 'C':
+  Info.setRequiresImmediate();
+  return true;
+default:
+  break;
+}
+
 StringRef S(Name);
-if (S == "A") {
+
+if (S == "DA" || S == "DB") {
+  Name++;
   Info.setRequiresImmediate();
   return true;
 }
@@ -203,6 +221,12 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
   // the constraint.  In practice, it won't be changed unless the
   // constraint is longer than one character.
   std::string convertConstraint(const char *&Constraint) const override {
+
+StringRef S(Constraint);
+if (S == "DA" || S == "DB") {
+  return std::string("^") + std::string(Constraint++, 2);
+}
+
 const char *Begin = Constraint;
 TargetInfo::ConstraintInfo Info("", "");
 if (validateAsmConstraint(Constraint, Info))

diff  --git a/clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl 
b/clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
index 37090772f664..259c12384f2c 100644
--- a/clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -33,3 +33,17 @@ kernel void test_agpr() {
  : "={a1}"(reg_a)
  : "{a1}"(reg_b));
 }
+
+kernel void test_constraint_DA() {
+  const long x = 0x20001;
+  int res;
+  // CHECK: call i32 asm sideeffect "v_mov_b32 $0, $1 & 0x", 
"=v,^DA"(i64 8589934593)
+  __asm volatile("v_mov_b32 %0, %1 & 0x" : "=v"(res) : "DA"(x));
+}
+
+kernel void test_constraint_DB() {
+  const long x = 0x20001;
+  int res;
+  // CHECK: call i32 asm sideeffect "v_mov_b32 $0, $1 & 0x", 
"=v,^DB"(i64 8589934593)
+  __asm volatile("v_mov_b32 %0, %1 & 0x" : "=v"(res) : "DB"(x));
+}

diff  --git a/clang/test/Sema/inline-asm-validate-amdgpu.cl 
b/clang/test/Sema/inline-asm-validate-amdgpu.cl
index 3d6488227ef2..418952c0e727 100644
--- a/clang/test/Sema/inline-asm-validate-amdgpu.cl
+++ b/clang/test/Sema/inline-asm-validate-amdgpu.cl
@@ -18,9 +18,35 @@ kernel void test () {
   // vgpr constraints
   __asm__ ("v_mov_b32 %0, %1" : "=v" (vgpr) : "v" (imm) : );
 
-  // 'A' constraint
+  // 'I' constraint (an immediate integer in the range -16 to 64)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (imm) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (-16) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (64) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (-17) : ); // expected-error 
{{value '-17' out of range for constraint 'I'}}
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "I" (65) : ); // expected-error 
{{value '65' out of range for constraint 'I'}}
+
+  // 'J' constraint (an immediate 16-bit signed integer)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (imm) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (-32768) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (32767) : );
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (-32769) : ); // 
expected-error {{value '-32769' out of range for constraint 'J'}}
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "J" (32768) : ); // 
expected-error {{value '32768' out of range for constraint 'J'}}
+
+  // 'A' constraint (an immediate constant that can be inlined)
   __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "A" (imm) : );
 
+  // 'B' constraint (an immediate 32-bit signed integer)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "B" (imm) : );
+
+  // 'C' constraint (an immediate 32-bit unsigned integer or 'A' constraint)
+  __asm__ ("s_mov_b32 %0, %1" : "=s" (sgpr) : "C" (imm) : );
+
+  // 'DA' constrain

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

2020-07-03 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1235
 
+  // Do not use AIX special alignment if current base is not the first member 
or
+  // the struct is not a union.

hubert.reinterpretcast wrote:
> Suggestion:
> ```
>   // AIX `power` alignment does not apply the preferred alignment for 
> non-union
>   // classes if the source of the alignment (the current base in this context)
>   // follows introduction of the first member with allocated space.
> ```
Adjustment to my suggestion:
s/first member with allocated space/first subobject with exclusively allocated 
space/;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79719



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


[PATCH] D83095: [clangd] Config: compute config in TUScheduler and BackgroundIndex

2020-07-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 275387.
sammccall marked 6 inline comments as done.
sammccall added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83095

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -65,8 +65,20 @@
   return true;
 }
 
+// Dummy ContextProvider to verify the provider is invoked & contexts are used.
+static Key BoundPath;
+Context bindPath(PathRef F) {
+  return Context::current().derive(BoundPath, F.str());
+}
+llvm::StringRef boundPath() {
+  const std::string *V = Context::current().get(BoundPath);
+  return V ? *V : llvm::StringRef("");
+}
+
 TUScheduler::Options optsForTest() {
-  return TUScheduler::Options(ClangdServer::optsForTest());
+  TUScheduler::Options Opts(ClangdServer::optsForTest());
+  Opts.ContextProvider = bindPath;
+  return Opts;
 }
 
 class TUSchedulerTests : public ::testing::Test {
@@ -454,6 +466,7 @@
   [File, Nonce, Version(Inputs.Version), &Mut, &TotalUpdates,
&LatestDiagVersion](std::vector) {
 EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
+EXPECT_EQ(File, boundPath());
 
 std::lock_guard Lock(Mut);
 ++TotalUpdates;
@@ -474,6 +487,7 @@
   [File, Inputs, Nonce, &Mut,
&TotalASTReads](Expected AST) {
 EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
+EXPECT_EQ(File, boundPath());
 
 ASSERT_TRUE((bool)AST);
 EXPECT_EQ(AST->Inputs.Contents, Inputs.Contents);
@@ -493,6 +507,7 @@
   [File, Inputs, Nonce, &Mut,
&TotalPreambleReads](Expected Preamble) {
 EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
+EXPECT_EQ(File, boundPath());
 
 ASSERT_TRUE((bool)Preamble);
 EXPECT_EQ(Preamble->Contents, Inputs.Contents);
@@ -849,18 +864,22 @@
 }
 
 TEST_F(TUSchedulerTests, Run) {
-  TUScheduler S(CDB, optsForTest());
+  auto Opts = optsForTest();
+  Opts.ContextProvider = bindPath;
+  TUScheduler S(CDB, Opts);
   std::atomic Counter(0);
-  S.run("add 1", [&] { ++Counter; });
-  S.run("add 2", [&] { Counter += 2; });
+  S.run("add 1", /*Path=*/"", [&] { ++Counter; });
+  S.run("add 2", /*Path=*/"", [&] { Counter += 2; });
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_EQ(Counter.load(), 3);
 
   Notification TaskRun;
   Key TestKey;
   WithContextValue CtxWithKey(TestKey, 10);
-  S.run("props context", [&] {
+  const char *Path = "somepath";
+  S.run("props context", Path, [&] {
 EXPECT_EQ(Context::current().getExisting(TestKey), 10);
+EXPECT_EQ(Path, boundPath());
 TaskRun.notify();
   });
   TaskRun.wait();
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -10,6 +10,7 @@
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "CodeComplete.h"
+#include "ConfigFragment.h"
 #include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
 #include "SyncAPI.h"
@@ -19,6 +20,7 @@
 #include "support/Threading.h"
 #include "clang/Config/config.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
@@ -47,6 +49,7 @@
 using ::testing::Gt;
 using ::testing::IsEmpty;
 using ::testing::Pair;
+using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
 
 MATCHER_P2(DeclAt, File, Range, "") {
@@ -301,6 +304,48 @@
   EXPECT_EQ(Callbacks.Got, 42);
 }
 
+TEST(ClangdServerTest, RespectsConfig) {
+  // Go-to-definition will resolve as marked if FOO is defined.
+  Annotations Example(R"cpp(
+  #ifdef FOO
+  int [[x]];
+  #else
+  int x;
+  #endif
+  int y = ^x;
+  )cpp");
+  // Provide conditional config that defines FOO for foo.cc.
+  class ConfigProvider : public config::Provider {
+std::vector
+getFragments(const config::Params &,
+ config::DiagnosticCallback DC) const override {
+  config::Fragment F;
+  F.If.PathMatch.emplac

[PATCH] D83095: [clangd] Config: compute config in TUScheduler and BackgroundIndex

2020-07-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 275388.
sammccall added a comment.

fix -Wreorder


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83095

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -65,8 +65,20 @@
   return true;
 }
 
+// Dummy ContextProvider to verify the provider is invoked & contexts are used.
+static Key BoundPath;
+Context bindPath(PathRef F) {
+  return Context::current().derive(BoundPath, F.str());
+}
+llvm::StringRef boundPath() {
+  const std::string *V = Context::current().get(BoundPath);
+  return V ? *V : llvm::StringRef("");
+}
+
 TUScheduler::Options optsForTest() {
-  return TUScheduler::Options(ClangdServer::optsForTest());
+  TUScheduler::Options Opts(ClangdServer::optsForTest());
+  Opts.ContextProvider = bindPath;
+  return Opts;
 }
 
 class TUSchedulerTests : public ::testing::Test {
@@ -454,6 +466,7 @@
   [File, Nonce, Version(Inputs.Version), &Mut, &TotalUpdates,
&LatestDiagVersion](std::vector) {
 EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
+EXPECT_EQ(File, boundPath());
 
 std::lock_guard Lock(Mut);
 ++TotalUpdates;
@@ -474,6 +487,7 @@
   [File, Inputs, Nonce, &Mut,
&TotalASTReads](Expected AST) {
 EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
+EXPECT_EQ(File, boundPath());
 
 ASSERT_TRUE((bool)AST);
 EXPECT_EQ(AST->Inputs.Contents, Inputs.Contents);
@@ -493,6 +507,7 @@
   [File, Inputs, Nonce, &Mut,
&TotalPreambleReads](Expected Preamble) {
 EXPECT_THAT(Context::current().get(NonceKey), Pointee(Nonce));
+EXPECT_EQ(File, boundPath());
 
 ASSERT_TRUE((bool)Preamble);
 EXPECT_EQ(Preamble->Contents, Inputs.Contents);
@@ -849,18 +864,22 @@
 }
 
 TEST_F(TUSchedulerTests, Run) {
-  TUScheduler S(CDB, optsForTest());
+  auto Opts = optsForTest();
+  Opts.ContextProvider = bindPath;
+  TUScheduler S(CDB, Opts);
   std::atomic Counter(0);
-  S.run("add 1", [&] { ++Counter; });
-  S.run("add 2", [&] { Counter += 2; });
+  S.run("add 1", /*Path=*/"", [&] { ++Counter; });
+  S.run("add 2", /*Path=*/"", [&] { Counter += 2; });
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
   EXPECT_EQ(Counter.load(), 3);
 
   Notification TaskRun;
   Key TestKey;
   WithContextValue CtxWithKey(TestKey, 10);
-  S.run("props context", [&] {
+  const char *Path = "somepath";
+  S.run("props context", Path, [&] {
 EXPECT_EQ(Context::current().getExisting(TestKey), 10);
+EXPECT_EQ(Path, boundPath());
 TaskRun.notify();
   });
   TaskRun.wait();
Index: clang-tools-extra/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdTests.cpp
@@ -10,6 +10,7 @@
 #include "ClangdLSPServer.h"
 #include "ClangdServer.h"
 #include "CodeComplete.h"
+#include "ConfigFragment.h"
 #include "GlobalCompilationDatabase.h"
 #include "Matchers.h"
 #include "SyncAPI.h"
@@ -19,6 +20,7 @@
 #include "support/Threading.h"
 #include "clang/Config/config.h"
 #include "clang/Sema/CodeCompleteConsumer.h"
+#include "clang/Tooling/ArgumentsAdjusters.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
@@ -47,6 +49,7 @@
 using ::testing::Gt;
 using ::testing::IsEmpty;
 using ::testing::Pair;
+using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
 
 MATCHER_P2(DeclAt, File, Range, "") {
@@ -301,6 +304,48 @@
   EXPECT_EQ(Callbacks.Got, 42);
 }
 
+TEST(ClangdServerTest, RespectsConfig) {
+  // Go-to-definition will resolve as marked if FOO is defined.
+  Annotations Example(R"cpp(
+  #ifdef FOO
+  int [[x]];
+  #else
+  int x;
+  #endif
+  int y = ^x;
+  )cpp");
+  // Provide conditional config that defines FOO for foo.cc.
+  class ConfigProvider : public config::Provider {
+std::vector
+getFragments(const config::Params &,
+ config::DiagnosticCallback DC) const override {
+  config::Fragment F;
+  F.If.PathMatch.emplace_back(".*foo.cc");
+  F.CompileFlags.Add.e

[PATCH] D83095: [clangd] Config: compute config in TUScheduler and BackgroundIndex

2020-07-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:748
 
+Context ClangdServer::createProcessingContext(PathRef File) const {
+  if (!ConfigProvider)

kadircet wrote:
> why not make this a free function in `ConfigProvider.h` ?
> 
> that way we could just keep passing ConfigProvider around rather than a 
> derived lambda.
> It makes testing more cumbersome, but enables us to move the logic out of 
> ClangdServer
Oh, I thought hiding this logic in ClangdServer was a feature!

For instance, if we want to report configuration errors as LSP diagnostics or 
as notifications, we need to have access to the ClangdServer to do that.



Comment at: clang-tools-extra/clangd/index/Background.h:142
+  std::function OnProgress = nullptr,
+  std::function ContextProvider = nullptr);
   ~BackgroundIndex(); // Blocks while the current task finishes.

kadircet wrote:
> doesn't need to be in this patch, bu I think it is time we have an opts 
> struct in here.
Yeah, makes sense. (But indeed would rather not do it here...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83095



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


[PATCH] D82964: [clangd] Config: loading and caching config from disk.

2020-07-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/ConfigProvider.cpp:39
+auto Buf = FS.getBufferForFile(Path);
+// If stat() succeeds but we failed to read, retry once and cache failure.
+if (!Buf)

kadircet wrote:
> why do we want to cache failure case for missing files ?
> 
> If it is truly missing and we didn't race with another process (likely 
> git-checkout), the next stat will fail and we'll return a no-op fragment.
> If it was a race, we want to pick it up on the next run (and reading twice 
> might not have enough of a delay in between), so why not just cache with a 
> sentinel key in here too?
Yeah I was worried about a file we can stat but chronically can't read (e.g. 
because permissions are wrong). But this is probably not worth worrying about. 
Changed no not cache as you suggest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82964



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


[PATCH] D82781: [OpenCL] Fix missing address space deduction in template variables

2020-07-03 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 275381.
olestrohm added a comment.

I have added a check in `deduceOpenCLAddressSpace()` to check if the type is 
dependent, and not deduce the address space if it is. This is a big change in 
the behaviour of address space deduction, meaning that template variables only 
receive address spaces when they are being specialized. This is good, but 
caused a lot of changes in the current test file, which has been included in 
this patch.

There also had to be added a check for dependent types in 
CheckVariableDeclarationType when checking whether global variables have the 
correct address space. With this new change dependent types don't necessarily 
have address spaces yet, and thus then lets it pass until the variable 
declaration of the specialized template variable is checked later.


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

https://reviews.llvm.org/D82781

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaOpenCLCXX/address-space-deduction.cl

Index: clang/test/SemaOpenCLCXX/address-space-deduction.cl
===
--- clang/test/SemaOpenCLCXX/address-space-deduction.cl
+++ clang/test/SemaOpenCLCXX/address-space-deduction.cl
@@ -5,6 +5,11 @@
 //CHECK: |-VarDecl {{.*}} foo 'const __global int'
 constexpr int foo = 0;
 
+//CHECK: |-VarDecl {{.*}} foo1 'T' cinit
+//CHECK: `-VarTemplateSpecializationDecl {{.*}} used foo1 '__global long':'__global long' cinit
+template 
+T foo1 = 0;
+
 class c {
 public:
   //CHECK: `-VarDecl {{.*}} foo2 'const __global int'
@@ -30,7 +35,7 @@
 
 template 
 struct x1 {
-//CHECK: -CXXMethodDecl {{.*}} operator= 'x1 &(const x1 &__private){{( __attribute__.*)?}} __generic'
+//CHECK: -CXXMethodDecl {{.*}} operator= 'x1 &(const x1 &){{( __attribute__.*)?}} __generic'
 //CHECK: -CXXMethodDecl {{.*}} operator= '__generic x1 &(const __generic x1 &__private){{( __attribute__.*)?}} __generic'
   x1& operator=(const x1& xx) {
 y = xx.y;
@@ -41,7 +46,7 @@
 
 template 
 struct x2 {
-//CHECK: -CXXMethodDecl {{.*}} foo 'void (x1 *__private){{( __attribute__.*)?}} __generic'
+//CHECK: -CXXMethodDecl {{.*}} foo 'void (x1 *){{( __attribute__.*)?}} __generic'
 //CHECK: -CXXMethodDecl {{.*}} foo 'void (__generic x1 *__private){{( __attribute__.*)?}} __generic'
   void foo(x1* xx) {
 m[0] = *xx;
@@ -57,10 +62,10 @@
 template 
 class x3 : public T {
 public:
-  //CHECK: -CXXConstructorDecl {{.*}} x3 'void (const x3 &__private){{( __attribute__.*)?}} __generic'
+  //CHECK: -CXXConstructorDecl {{.*}} x3 'void (const x3 &){{( __attribute__.*)?}} __generic'
   x3(const x3 &t);
 };
-//CHECK: -CXXConstructorDecl {{.*}} x3 'void (const x3 &__private){{( __attribute__.*)?}} __generic'
+//CHECK: -CXXConstructorDecl {{.*}} x3 'void (const x3 &){{( __attribute__.*)?}} __generic'
 template 
 x3::x3(const x3 &t) {}
 
@@ -68,7 +73,8 @@
 T xxx(T *in1, T in2) {
   // This pointer can't be deduced to generic because addr space
   // will be taken from the template argument.
-  //CHECK: `-VarDecl {{.*}} '__private T *__private' cinit
+  //CHECK: `-VarDecl {{.*}} 'T *' cinit
+  //CHECK: `-VarDecl {{.*}} i '__private int *__private' cinit
   T *i = in1;
   T ii;
   __private T *ptr = ⅈ
@@ -111,4 +117,5 @@
   t3(&x);
   t4(&p);
   t5(&p);
+  long f1 = foo1;
 }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3625,6 +3625,13 @@
   if (InsertPos)
 VarTemplate->AddSpecialization(Var, InsertPos);
 
+  // FIXME: This may not be the best approach, as the correct type (including
+  // address space) is available in D, but the type in D may not be reliable
+  // in every situation.
+  // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
+  if (SemaRef.getLangOpts().OpenCL)
+SemaRef.deduceOpenCLAddressSpace(Var);
+
   // Substitute the nested name specifier, if any.
   if (SubstQualifier(D, Var))
 return nullptr;
@@ -4803,6 +4810,13 @@
   // Instantiate the initializer.
   InstantiateVariableInitializer(VarSpec, PatternDecl, TemplateArgs);
 
+  // FIXME: This may not be the best approach, as the correct type (including
+  // address space) is available in PatternDecl, but this type may not be
+  // reliable in every situation.
+  // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
+  if (getLangOpts().OpenCL)
+deduceOpenCLAddressSpace(VarSpec);
+
   return VarSpec;
 }
 
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6287,6 +6287,8 @@
 void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
   if (Decl->getType().hasAddressSpace())
 return;
+  if (Decl->getType()->isDependentType())
+return;
   i

[PATCH] D82964: [clangd] Config: loading and caching config from disk.

2020-07-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 275384.
sammccall marked 2 inline comments as done.
sammccall added a comment.

Don't cache failed opens.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82964

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ConfigProvider.cpp
  clang-tools-extra/clangd/ConfigProvider.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -69,7 +69,8 @@
 const char *testRoot();
 
 // Returns a suitable absolute path for this OS.
-std::string testPath(PathRef File);
+std::string testPath(PathRef File,
+ llvm::sys::path::Style = llvm::sys::path::Style::native);
 
 // unittest: is a scheme that refers to files relative to testRoot()
 // This anchor is used to force the linker to link in the generated object file
Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -79,13 +79,13 @@
 #endif
 }
 
-std::string testPath(PathRef File) {
+std::string testPath(PathRef File, llvm::sys::path::Style Style) {
   assert(llvm::sys::path::is_relative(File) && "FileName should be relative");
 
   llvm::SmallString<32> NativeFile = File;
-  llvm::sys::path::native(NativeFile);
+  llvm::sys::path::native(NativeFile, Style);
   llvm::SmallString<32> Path;
-  llvm::sys::path::append(Path, testRoot(), NativeFile);
+  llvm::sys::path::append(Path, Style, testRoot(), NativeFile);
   return std::string(Path.str());
 }
 
Index: clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/ConfigProviderTests.cpp
@@ -0,0 +1,156 @@
+//===-- ConfigProviderTests.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Config.h"
+#include "ConfigProvider.h"
+#include "ConfigTesting.h"
+#include "TestFS.h"
+#include "llvm/Support/SourceMgr.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace config {
+namespace {
+using ::testing::ElementsAre;
+using ::testing::IsEmpty;
+
+// Provider that appends an arg to compile flags.
+// The arg is prefix, where N is the times getFragments() was called.
+// It also yields a diagnostic each time it's called.
+class FakeProvider : public Provider {
+  std::string Prefix;
+  mutable std::atomic Index = {0};
+
+  std::vector
+  getFragments(const Params &, DiagnosticCallback DC) const override {
+DC(llvm::SMDiagnostic("", llvm::SourceMgr::DK_Error, Prefix));
+CompiledFragment F =
+[Arg(Prefix + std::to_string(++Index))](const Params &P, Config &C) {
+  C.CompileFlags.Edits.push_back(
+  [Arg](std::vector &Argv) { Argv.push_back(Arg); });
+  return true;
+};
+return {F};
+  }
+
+public:
+  FakeProvider(llvm::StringRef Prefix) : Prefix(Prefix) {}
+};
+
+std::vector getAddedArgs(Config &C) {
+  std::vector Argv;
+  for (auto &Edit : C.CompileFlags.Edits)
+Edit(Argv);
+  return Argv;
+}
+
+// The provider from combine() should invoke its providers in order, and not
+// cache their results.
+TEST(ProviderTest, Combine) {
+  CapturedDiags Diags;
+  std::vector> Providers;
+  Providers.push_back(std::make_unique("foo"));
+  Providers.push_back(std::make_unique("bar"));
+  auto Combined = Provider::combine(std::move(Providers));
+  Config Cfg = Combined->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(DiagMessage("foo"), DiagMessage("bar")));
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo1", "bar1"));
+  Diags.Diagnostics.clear();
+
+  Cfg = Combined->getConfig(Params(), Diags.callback());
+  EXPECT_THAT(Diags.Diagnostics,
+  ElementsAre(DiagMessage("foo"), DiagMessage("bar")));
+  EXPECT_THAT(getAddedArgs(Cfg), ElementsAre("foo2", "bar2"));
+}
+
+const char *AddFooWithErr = R"yaml(
+CompileFlags:
+  Add: foo
+  Unknown: 42
+)yaml";
+
+const char *AddBarBaz = R"yaml(
+CompileFlags:
+  Add: bar
+---
+CompileFlags:
+  Add: baz
+)yaml";
+
+TEST(ProviderTest, FromYAMLFile) {
+  MockFS FS;
+  FS.Files["foo.yaml"] = AddFooWithErr

[PATCH] D83076: Revert AST Matchers default to AsIs mode

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

LG, but should this also update the release notes to remove the mention about 
the new default?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83076



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


[clang] 54eb425 - [clang][NFC] Also test for serialization in test/AST/ast-dump-comment.cpp

2020-07-03 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-03T13:59:23+01:00
New Revision: 54eb42537e8c566fa15046bc0302bf5390d26f08

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

LOG: [clang][NFC] Also test for serialization in test/AST/ast-dump-comment.cpp

Added: 


Modified: 
clang/test/AST/ast-dump-comment.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-comment.cpp 
b/clang/test/AST/ast-dump-comment.cpp
index da73483f041a..8df0416cd092 100644
--- a/clang/test/AST/ast-dump-comment.cpp
+++ b/clang/test/AST/ast-dump-comment.cpp
@@ -1,4 +1,12 @@
-// RUN: %clang_cc1 -Wdocumentation -ast-dump -ast-dump-filter Test %s | 
FileCheck -strict-whitespace %s
+// Without serialization:
+// RUN: %clang_cc1 -Wdocumentation -ast-dump -ast-dump-filter Test %s \
+// RUN: | FileCheck -strict-whitespace %s
+//
+// With serialization:
+// RUN: %clang_cc1 -Wdocumentation -emit-pch -o %t %s
+// RUN: %clang_cc1 -x c++ -Wdocumentation -include-pch %t -ast-dump-all 
-ast-dump-filter Test /dev/null \
+// RUN: | sed -e "s/ //" -e "s/ imported//" \
+// RUN: | FileCheck --strict-whitespace %s
 
 /// Aaa
 int TestLocation;



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


[clang-tools-extra] 473fbc9 - [clang][NFC] Store a pointer to the ASTContext in ASTDumper and TextNodeDumper

2020-07-03 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-03T13:59:22+01:00
New Revision: 473fbc90d1fbf17e16594dfb17248c4f50b4d399

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

LOG: [clang][NFC] Store a pointer to the ASTContext in ASTDumper and 
TextNodeDumper

In general there is no way to get to the ASTContext from most AST nodes
(Decls are one of the exception). This will be a problem when implementing
the rest of APValue::dump since we need the ASTContext to dump some kinds of
APValues.

The ASTContext* in ASTDumper and TextNodeDumper is not always non-null.
This is because we still want to be able to use the various dump() functions
in a debugger.

No functional changes intended.

Reverted in fcf4d5e4499a391dff42ea1a096f146db44147b6 since a few dump()
functions in lldb where missed.

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
clang/include/clang/AST/APValue.h
clang/include/clang/AST/ASTDumper.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/Comment.h
clang/include/clang/AST/Stmt.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/AST/Type.h
clang/lib/AST/APValue.cpp
clang/lib/AST/ASTDumper.cpp
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/lib/CodeGen/CGExprComplex.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Frontend/ASTConsumers.cpp
clang/unittests/AST/CommentParser.cpp
clang/unittests/AST/MatchVerifier.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index 2fc7af6a56e1..4fe7110daed3 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -157,8 +157,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession 
&QS) const {
   OS << "Binding for \"" << BI->first << "\":\n";
   const ASTContext &Ctx = AST->getASTContext();
   const SourceManager &SM = Ctx.getSourceManager();
-  ASTDumper Dumper(OS, &Ctx.getCommentCommandTraits(), &SM,
-SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy());
+  ASTDumper Dumper(OS, Ctx, SM.getDiagnostics().getShowColors());
   Dumper.SetTraversalKind(QS.TK);
   Dumper.Visit(BI->second);
   OS << "\n";

diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
index 616e100adf08..b2b883d64567 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DumpAST.cpp
@@ -62,7 +62,7 @@ REGISTER_TWEAK(DumpAST)
 llvm::Expected DumpAST::apply(const Selection &Inputs) {
   std::string Str;
   llvm::raw_string_ostream OS(Str);
-  Node->dump(OS, Inputs.AST->getSourceManager());
+  Node->dump(OS, Inputs.AST->getASTContext());
   return Effect::showMessage(std::move(OS.str()));
 }
 

diff  --git a/clang/include/clang/AST/APValue.h 
b/clang/include/clang/AST/APValue.h
index 63359294ef63..c69974c63c71 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -372,7 +372,7 @@ class APValue {
   bool isAddrLabelDiff() const { return Kind == AddrLabelDiff; }
 
   void dump() const;
-  void dump(raw_ostream &OS) const;
+  void dump(raw_ostream &OS, const ASTContext *Context) const;
 
   void printPretty(raw_ostream &OS, const ASTContext &Ctx, QualType Ty) const;
   std::string getAsString(const ASTContext &Ctx, QualType Ty) const;

diff  --git a/clang/include/clang/AST/ASTDumper.h 
b/clang/include/clang/AST/ASTDumper.h
index f46ffb960db6..a154bc2db3a7 100644
--- a/clang/include/clang/AST/ASTDumper.h
+++ b/clang/include/clang/AST/ASTDumper.h
@@ -24,18 +24,11 @@ class ASTDumper : public ASTNodeTraverser {
   const bool ShowColors;
 
 public:
-  ASTDumper(raw_ostream &OS, const comments::CommandTraits *Traits,
-const SourceManager *SM)
-  : ASTDumper(OS, Traits, SM, SM && SM->getDiagnostics().getShowColors()) 
{}
-
-  ASTDumper(raw_ostream &OS, const comments::CommandTraits *Traits,
-const SourceManager *SM, bool ShowColors)
-  : ASTDumper(OS, Traits, SM, ShowColors, LangOptions()) {}
-  ASTDumper(raw_ostream &OS, const comments::CommandTraits *Traits,
-const SourceManager *SM, bool ShowColors,
-const PrintingPolicy &PrintPolicy)
-  : NodeDumper(OS, ShowColors, SM, PrintPolicy, Traits), OS(OS),
-ShowColors(ShowColors) {}
+  ASTDumper(raw_ostream &OS, const ASTContext &Context, bool ShowColors)
+  : NodeDumper(OS, Context, ShowColors), OS(OS), ShowColors(ShowColors) {}
+
+ 

[clang] c10295e - [clang][NFC] Add a missing /dev/null in test/AST/ast-dump-lambda.cpp

2020-07-03 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-07-03T13:59:23+01:00
New Revision: c10295e1bdbf892946bf1db6c3c8feb1219c4070

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

LOG: [clang][NFC] Add a missing /dev/null in test/AST/ast-dump-lambda.cpp

Added: 


Modified: 
clang/test/AST/ast-dump-lambda.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-lambda.cpp 
b/clang/test/AST/ast-dump-lambda.cpp
index a3ca4a8fc534..37fb62ef9930 100644
--- a/clang/test/AST/ast-dump-lambda.cpp
+++ b/clang/test/AST/ast-dump-lambda.cpp
@@ -7,7 +7,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
 // RUN:-emit-pch -o %t %s
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wno-unused-value 
-std=gnu++17 \
-// RUN:-x c++ -include-pch %t -ast-dump-all -ast-dump-filter test \
+// RUN:-x c++ -include-pch %t -ast-dump-all -ast-dump-filter test 
/dev/null \
 // RUN: | FileCheck -strict-whitespace --match-full-lines %s
 
 



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


[PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library

2020-07-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h:216
+  /// This output is not intended to be machine-parseable.
+  void printCheckerWithDescList(const AnalyzerOptions &AnOpts, raw_ostream 
&Out,
+size_t MaxNameChars = 30) const;

baloghadamsoftware wrote:
> Why not store `AnOpts` in `CheckerRegistryData`? It would save the need to 
> pass it to every function separately.
This is definitely a point where I chose a well defined interface over 
convenience. These print functions only have a single user, `CompilerInstance`, 
which must juggle all sorts of analyzer managers anyways, so it wouldn't have 
made the code any more readable in my opinion.

The idea was to constrain all data this class has to be strictly about what was 
processed by `CheckerRegistry`. While mildly inconvenient, the only way to 
retrieve this object would be from `CheckerManager`, that also has a getter to 
`AnalyzerOptions`, so in case someone were to use this for debug purposes or 
something, they certainly can.


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

https://reviews.llvm.org/D82585



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


[PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library

2020-07-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 275378.
Szelethus marked 6 inline comments as done.
Szelethus added a comment.

Small fixes according to reviewer comments.


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

https://reviews.llvm.org/D82585

Files:
  clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
  clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h
  clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  clang/lib/StaticAnalyzer/Core/CMakeLists.txt
  clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp
  clang/lib/StaticAnalyzer/Core/Environment.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalyzerHelpFlags.cpp
  clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  clang/lib/StaticAnalyzer/Frontend/CreateCheckerManager.cpp
  clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp

Index: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
===
--- clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
+++ clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp
@@ -11,6 +11,7 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerRegistryData.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Frontend/AnalysisConsumer.h"
@@ -100,7 +101,7 @@
 llvm::raw_svector_ostream OS(Buf);
 C.getAnalysisManager()
 .getCheckerManager()
-->getCheckerRegistry()
+->getCheckerRegistryData()
 .printEnabledCheckerList(OS);
 // Strip a newline off.
 auto R =
Index: clang/lib/StaticAnalyzer/Frontend/CreateCheckerManager.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/CreateCheckerManager.cpp
+++ clang/lib/StaticAnalyzer/Frontend/CreateCheckerManager.cpp
@@ -23,11 +23,11 @@
 ArrayRef> checkerRegistrationFns)
 : Context(&Context), LangOpts(Context.getLangOpts()), AOptions(AOptions),
   PP(&PP), Diags(Context.getDiagnostics()),
-  Registry(
-  std::make_unique(plugins, Context.getDiagnostics(),
-AOptions, checkerRegistrationFns)) {
-  Registry->initializeRegistry(*this);
-  Registry->initializeManager(*this);
+  RegistryData(std::make_unique()) {
+  CheckerRegistry Registry(*RegistryData, plugins, Context.getDiagnostics(),
+   AOptions, checkerRegistrationFns);
+  Registry.initializeRegistry(*this);
+  Registry.initializeManager(*this);
   finishedCheckerRegistration();
 }
 
@@ -36,8 +36,9 @@
DiagnosticsEngine &Diags,
ArrayRef plugins)
 : LangOpts(LangOpts), AOptions(AOptions), Diags(Diags),
-  Registry(std::make_unique(plugins, Diags, AOptions)) {
-  Registry->initializeRegistry(*this);
+  RegistryData(std::make_unique()) {
+  CheckerRegistry Registry(*RegistryData, plugins, Diags, AOptions, {});
+  Registry.initializeRegistry(*this);
 }
 
 CheckerManager::~CheckerManager() {
Index: clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -25,14 +25,13 @@
 
 using namespace clang;
 using namespace ento;
+using namespace checker_registry;
 using llvm::sys::DynamicLibrary;
 
 //===--===//
 // Utilities.
 //===--===//
 
-using RegisterCheckersFn = void (*)(CheckerRegistry &);
-
 static bool isCompatibleAPIVersion(const char *VersionString) {
   // If the version string is null, its not an analyzer plugin.
   if (!VersionString)
@@ -43,140 +42,17 @@
   return strcmp(VersionString, CLANG_ANALYZER_API_VERSION_STRING) == 0;
 }
 
-namespace {
-template  struct FullNameLT {
-  bool operator()(const T &Lhs, const T &Rhs) {
-return Lhs.FullName < Rhs.FullName;
-  }
-};
-
-using PackageNameLT = FullNameLT;
-using CheckerNameLT = FullNameLT;
-} // end of anonymous namespace
-
-template 
-static std::conditional_t::value,
-  typename CheckerOrPackageInfoList::const_iterator,
-  typename CheckerOrPackageInfoList::iterator>
-binaryFind(CheckerOrPackageInfoList &Collection, StringRef FullName) {
-
-  using CheckerOrPackage = typename CheckerOrPackageInfoList::value_type;
-  using CheckerOrPackageFullNameLT = FullNameLT;
-
-  assert(llvm::is_sorted(Collection, CheckerOrPackageFullNameLT{}) &&
- "In order to efficiently gather checkers/packages, this function "
- "expect

[PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library

2020-07-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang/include/clang/StaticAnalyzer/Core/CheckerRegistryData.h:216
+  /// This output is not intended to be machine-parseable.
+  void printCheckerWithDescList(const AnalyzerOptions &AnOpts, raw_ostream 
&Out,
+size_t MaxNameChars = 30) const;

Why not store `AnOpts` in `CheckerRegistryData`? It would save the need to pass 
it to every function separately.



Comment at: clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp:166
+void CheckerRegistryData::printEnabledCheckerList(const AnalyzerOptions 
&AnOpts,
+  raw_ostream &Out) const {
+  for (const auto *i : EnabledCheckers)

Why do we need the new `AnOpts` parameter here? It does not seem to be used at 
all.


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

https://reviews.llvm.org/D82585



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


[PATCH] D82887: [ARM] Add Cortex-A77 Support for Clang and LLVM

2020-07-03 Thread Luke Geeson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bf99f1e6f0f: [ARM] Add Cortex-A77 Support for Clang and 
LLVM (authored by LukeGeeson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82887

Files:
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm-cortex-cpus.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/ARMTargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMSubtarget.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/test/CodeGen/AArch64/remat.ll
  llvm/test/MC/AArch64/armv8.2a-dotprod.s
  llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
  llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
  llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -256,6 +256,12 @@
  ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
  ARM::AEK_RAS | ARM::AEK_DOTPROD,
  "8.2-A"));
+  EXPECT_TRUE(testARMCPU("cortex-a77", "armv8.2-a", "crypto-neon-fp-armv8",
+ ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
+ ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
+ ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_FP16 |
+ ARM::AEK_RAS | ARM::AEK_DOTPROD,
+ "8.2-A"));
   EXPECT_TRUE(testARMCPU("neoverse-n1", "armv8.2-a", "crypto-neon-fp-armv8",
 ARM::AEK_CRC | ARM::AEK_SEC | ARM::AEK_MP |
 ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
@@ -304,7 +310,7 @@
  "7-S"));
 }
 
-static constexpr unsigned NumARMCPUArchs = 86;
+static constexpr unsigned NumARMCPUArchs = 87;
 
 TEST(TargetParserTest, testARMCPUArchList) {
   SmallVector List;
@@ -853,6 +859,12 @@
   AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
   AArch64::AEK_RCPC| AArch64::AEK_SSBS, "8.2-A"));
   EXPECT_TRUE(testAArch64CPU(
+  "cortex-a77", "armv8.2-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_RDM | AArch64::AEK_SIMD | AArch64::AEK_RAS |
+  AArch64::AEK_LSE | AArch64::AEK_FP16 | AArch64::AEK_DOTPROD |
+  AArch64::AEK_RCPC | AArch64::AEK_SSBS, "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
   EXPECT_TRUE(testAArch64CPU(
@@ -990,7 +1002,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 39;
+static constexpr unsigned NumAArch64CPUArchs = 40;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
===
--- llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
+++ llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
@@ -4,6 +4,7 @@
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a65 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a65ae --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a75 --disassemble < %s | FileCheck %s
+# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=cortex-a77 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-e1 --disassemble < %s | FileCheck %s
 # RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n1 --disassemble < %s | FileCheck %s
 
Index: llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
===
--- llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
+++ llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
@@ -2,6 +2,7 @@
 // RUN: llvm-mc -triple thumb -mcpu=cortex-a55 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=cortex-a75 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=cortex-a76 -show-encoding < %s | FileCheck %s  --check-prefix=CHECK
+// RUN: llvm-mc -triple thumb -mcpu=cortex-a77 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 // RUN: llvm-mc -triple thumb -mcpu=neoverse-n1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK
 
 // RUN: not llvm-mc -triple thumb -mattr=-dotprod -show-encoding < %s 2> %t
Index: llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
===
--- llvm/test/MC/AR

[PATCH] D82663: [CodeGen] Have CodeGen for fixed-point unsigned with padding emit signed operations.

2020-07-03 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

Well, it's not so much as adding the bit, but adding the information that the 
bit exists. That means either new intrinsics for all of the operations, or 
adding flags to the existing ones. That's a fair bit of added complexity. Also, 
 +  would do virtually the exact same thing as 
the new unsigned-with-padding operations, so the utility of adding all of it is 
a bit questionable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82663



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


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

2020-07-03 Thread Milian Wolff via Phabricator via cfe-commits
milianw added a comment.

@jkorous ping? can you chime in on either of the two patches? I'm fine with 
either, and D82629  comes with a test too. So 
maybe let's just go with that one? If so, could you integrate that one please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82740



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


[clang] 8bf99f1 - [ARM] Add Cortex-A77 Support for Clang and LLVM

2020-07-03 Thread Luke Geeson via cfe-commits

Author: Luke Geeson
Date: 2020-07-03T13:00:54+01:00
New Revision: 8bf99f1e6f0f9b426d6060361ea6d9d47c1868d1

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

LOG: [ARM] Add Cortex-A77 Support for Clang and LLVM

This patch upstreams support for the Arm-v8 Cortex-A77
processor for AArch64 and ARM.

In detail:
- Adding cortex-a77 as a cpu option for aarch64 and arm targets in clang
- Cortex-A77 CPU name and ProcessorModel in llvm

details of the CPU can be found here:
https://www.arm.com/products/silicon-ip-cpu/cortex-a/cortex-a77

and a similar submission to GCC can be found here:
https://github.com/gcc-mirror/gcc/commit/e0664b7a63ed8305e9f8539309df7fb3eb13babe

The following people contributed to this patch:
- Luke Geeson
- Mikhail Maltsev

Reviewers: t.p.northover, dmgreen, ostannard, SjoerdMeijer

Reviewed By: dmgreen

Subscribers: dmgreen, kristof.beyls, hiraditya, danielkiss, cfe-commits,
llvm-commits, miyuki

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/test/Driver/aarch64-cpus.c
clang/test/Driver/arm-cortex-cpus.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/include/llvm/Support/ARMTargetParser.def
llvm/lib/Support/Host.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/lib/Target/ARM/ARM.td
llvm/lib/Target/ARM/ARMSubtarget.cpp
llvm/lib/Target/ARM/ARMSubtarget.h
llvm/test/CodeGen/AArch64/cpus.ll
llvm/test/CodeGen/AArch64/remat.ll
llvm/test/MC/AArch64/armv8.2a-dotprod.s
llvm/test/MC/ARM/armv8.2a-dotprod-a32.s
llvm/test/MC/ARM/armv8.2a-dotprod-t32.s
llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/test/Driver/aarch64-cpus.c 
b/clang/test/Driver/aarch64-cpus.c
index f774e5c4d8db..53b546265f6a 100644
--- a/clang/test/Driver/aarch64-cpus.c
+++ b/clang/test/Driver/aarch64-cpus.c
@@ -171,6 +171,9 @@
 // ARM64-CORTEX-A76: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"cortex-a76"
 // ARM64-CORTEX-A76-TUNE: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" 
"generic"
 
+// RUN: %clang -target aarch64 -mcpu=cortex-a77  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A77 %s
+// CORTEX-A77: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a77"
+
 // RUN: %clang -target aarch64_be -mcpu=exynos-m3 -### -c %s 2>&1 | FileCheck 
-check-prefix=M3 %s
 // RUN: %clang -target aarch64 -mbig-endian -mcpu=exynos-m3 -### -c %s 2>&1 | 
FileCheck -check-prefix=M3 %s
 // RUN: %clang -target aarch64_be -mbig-endian -mcpu=exynos-m3 -### -c %s 2>&1 
| FileCheck -check-prefix=M3 %s

diff  --git a/clang/test/Driver/arm-cortex-cpus.c 
b/clang/test/Driver/arm-cortex-cpus.c
index c1ce9c08ca87..d99526abe446 100644
--- a/clang/test/Driver/arm-cortex-cpus.c
+++ b/clang/test/Driver/arm-cortex-cpus.c
@@ -686,10 +686,12 @@
 // RUN: %clang -target arm -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a76 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a76ae -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a77 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a55 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a75 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a76 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a76ae -mlittle-endian -### -c %s 2>&1 
| FileCheck -check-prefix=CHECK-CPUV82A %s
+// RUN: %clang -target arm -mcpu=cortex-a77 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV82A %s
 //
 // RUN: %clang -target arm -mcpu=exynos-m4 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-CPUV82A %s
 // RUN: %clang -target arm -mcpu=exynos-m4 -mlittle-endian -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-CPUV82A %s
@@ -718,10 +720,12 @@
 // RUN: %clang -target armeb -mcpu=cortex-a75 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV82A %s
 // RUN: %clang -target armeb -mcpu=cortex-a76 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV82A %s
 // RUN: %clang -target armeb -mcpu=cortex-a76ae -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV82A %s
+// RUN: %clang -target armeb -mcpu=cortex-a77 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BE-CPUV82A %s
 // RUN: %clang -target arm -mcpu=cortex-a55 -mbig-endian -### -c %s 2>&1 | 
FileCheck -c

[clang] 19eaff6 - Revert RecursiveASTVisitor fixes.

2020-07-03 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-03T13:48:24+02:00
New Revision: 19eaff650c9c091e844f0a342540f1d10573772c

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

LOG: Revert RecursiveASTVisitor fixes.

This reverts commit 8bf4c40af813e73de77739b33b8808f6bd13497b.
This reverts commit 7b0be962d681c408c8ecf7180c6ad8f9fbcdaf2d.
This reverts commit 94454442c3c15a67ae70ef3a73616632968973fc.

Some compilers on some buildbots didn't accept the specialization of
is_same_method_impl in a non-namespace scope.

Added: 


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

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index ba36d5b23fc6..b16c1ae1e483 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -331,32 +331,6 @@ template  class RecursiveASTVisitor {
   struct has_same_member_pointer_type
   : std::true_type {};
 
-  template  struct is_same_method_impl {
-template 
-static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
- SecondMethodPtrTy SecondMethodPtr) {
-  return false;
-}
-  };
-
-  template <> struct is_same_method_impl {
-template 
-static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
- SecondMethodPtrTy SecondMethodPtr) {
-  return FirstMethodPtr == SecondMethodPtr;
-}
-  };
-
-  /// Returns true if and only if \p FirstMethodPtr and \p SecondMethodPtr
-  /// are pointers to the same non-static member function.
-  template 
-  bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
-SecondMethodPtrTy SecondMethodPtr) {
-return is_same_method_impl<
-has_same_member_pointer_type::
-value>::isSameMethod(FirstMethodPtr, SecondMethodPtr);
-  }
-
   // Traverse the given statement. If the most-derived traverse function takes 
a
   // data recursion queue, pass it on; otherwise, discard it. Note that the
   // first branch of this conditional must compile whether or not the derived
@@ -412,8 +386,6 @@ template  class RecursiveASTVisitor {
 if (!getDerived().shouldTraversePostOrder())   
\
   TRY_TO(WalkUpFromUnary##NAME(S));
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
\
-if (!Queue && getDerived().shouldTraversePostOrder())  
\
-  TRY_TO(WalkUpFromUnary##NAME(S));
\
 return true;   
\
   }
\
   bool WalkUpFromUnary##NAME(UnaryOperator *S) {   
\
@@ -435,8 +407,6 @@ template  class RecursiveASTVisitor {
   TRY_TO(WalkUpFromBin##NAME(S));  
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
\
-if (!Queue && getDerived().shouldTraversePostOrder())  
\
-  TRY_TO(WalkUpFromBin##NAME(S));  
\
 return true;   
\
   }
\
   bool WalkUpFromBin##NAME(BINOP_TYPE *S) {
\
@@ -593,6 +563,7 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   BINOP_LIST()
 #undef OPERATOR
+#undef BINOP_LIST
 
 #define OPERATOR(NAME) 
\
   case BO_##NAME##Assign:  
\
@@ -600,6 +571,7 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   CAO_LIST()
 #undef OPERATOR
+#undef CAO_LIST
 }
   } else if (UnaryOperator *UnOp = dyn_cast(S)) {
 switch (UnOp->getOpcode()) {
@@ -609,6 +581,7 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   UNARYOP_LIST()
 #undef OPERATOR
+#undef UNARYOP_LIST
 }
   }
 
@@ -630,84 +603,23 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt 
*S,
 
 template 
 bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) {
-  // In pre-order traversal mode, each Traverse##STMT method is responsible for
-  // calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT and
-  // does not call the default implementation, the WalkUpFrom callback is not
-  // called. Post-order traversal mode should provide the same behavior
-  // 

[PATCH] D83095: [clangd] Config: compute config in TUScheduler and BackgroundIndex

2020-07-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

LG, mostly nits apart from a question about moving the context generation logic 
into a different place.




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:748
 
+Context ClangdServer::createProcessingContext(PathRef File) const {
+  if (!ConfigProvider)

why not make this a free function in `ConfigProvider.h` ?

that way we could just keep passing ConfigProvider around rather than a derived 
lambda.
It makes testing more cumbersome, but enables us to move the logic out of 
ClangdServer



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:756
+llvm::SmallString<256> PosixPath = File;
+llvm::sys::path::native(PosixPath);
+Params.Path = PosixPath.str();

also provide posix style instead of defaulted native



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:761
+  auto DiagnosticHandler = [](const llvm::SMDiagnostic &Diag) {
+log("config {0} at {1}:{2}:{3}: {4}",
+Diag.getKind() == llvm::SourceMgr::DK_Error ? "error" : "warning",

why not elog



Comment at: clang-tools-extra/clangd/ClangdServer.h:340
+  Context createProcessingContext(PathRef) const;
+  config::Provider *ConfigProvider;
+

nit: `= nullptr;`



Comment at: clang-tools-extra/clangd/index/Background.h:142
+  std::function OnProgress = nullptr,
+  std::function ContextProvider = nullptr);
   ~BackgroundIndex(); // Blocks while the current task finishes.

doesn't need to be in this patch, bu I think it is time we have an opts struct 
in here.



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:879
   WithContextValue CtxWithKey(TestKey, 10);
-  S.run("props context", [&] {
+  S.run("props context", "somepath", [&] {
 EXPECT_EQ(Context::current().getExisting(TestKey), 10);

nit: maybe extract "somepath" to a constant


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83095



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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-07-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 275356.
MyDeveloperDay marked 4 inline comments as done.
MyDeveloperDay added a comment.

Addressed review comments
Added one or two more tests

NOTE: renamed the option from `AlwaysBreakBeforeConceptDeclarations`  -> 
`BreakBeforeConceptDeclarations`


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

https://reviews.llvm.org/D79773

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13648,6 +13648,7 @@
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
+  CHECK_PARSE_BOOL(BreakBeforeConceptDeclarations);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(CompactNamespaces);
@@ -13659,6 +13660,7 @@
   CHECK_PARSE_BOOL(IndentCaseLabels);
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
+  CHECK_PARSE_BOOL(IndentRequires);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
@@ -16728,6 +16730,277 @@
"}",
Style);
 }
+
+TEST_F(FormatTest, ConceptsAndRequires) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+
+  verifyFormat("template \n"
+   "concept Hashable = requires(T a) {\n"
+   "  { std::hash{}(a) } -> std::convertible_to;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+
+  verifyFormat("template \n"
+   "requires Iterator\n"
+   "void sort(It begin, It end) {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "concept Large = sizeof(T) > 10;",
+   Style);
+
+  verifyFormat("template \n"
+   "concept FooableWith = requires(T t, U u) {\n"
+   "  typename T::foo_type;\n"
+   "  { t.foo(u) } -> typename T::foo_type;\n"
+   "  t++;\n"
+   "};\n"
+   "void doFoo(FooableWith auto t) {\n"
+   "  t.foo(3);\n"
+   "}",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = sizeof(T) == 1;",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = is_specialization_of_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Node = std::is_object_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Tree = true;",
+   Style);
+
+  verifyFormat("template  int g(T i) requires Concept1 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 || "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 && "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "requires Foo() && Ba

[PATCH] D82585: [analyzer][NFC] Move the data structures from CheckerRegistry to the Core library

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

Basically this looks good in the current way too, but I can only assume that 
the code was copied correctly. A rule could be that the `CheckerRegistryData` 
is manipulated only by `CheckerRegistry` but get or print functions can be in 
`CheckerRegistryData`.




Comment at: clang/unittests/StaticAnalyzer/CallEventTest.cpp:13
 #include "clang/Frontend/CompilerInstance.h"
+#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"

This line seems to be not needed here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82585



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


[PATCH] D82875: Added tests for RecursiveASTVisitor for AST nodes that are special cased

2020-07-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79889691430d: Added tests for RecursiveASTVisitor for AST 
nodes that are special cased (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82875

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

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -41,6 +41,11 @@
 if (IntegerLiteral *IL = dyn_cast(S)) {
   return (ClassName + "(" + IL->getValue().toString(10, false) + ")").str();
 }
+if (UnaryOperator *UO = dyn_cast(S)) {
+  return (ClassName + "(" + UnaryOperator::getOpcodeStr(UO->getOpcode()) +
+  ")")
+  .str();
+}
 if (BinaryOperator *BO = dyn_cast(S)) {
   return (ClassName + "(" + BinaryOperator::getOpcodeStr(BO->getOpcode()) +
   ")")
@@ -390,15 +395,15 @@
 )txt"));
 }
 
-TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinaryOperator) {
+TEST(RecursiveASTVisitor, StmtCallbacks_TraverseUnaryOperator) {
   class RecordingVisitor : public RecordingVisitorBase {
   public:
 RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
 : RecordingVisitorBase(ShouldTraversePostOrderValue) {}
 
-bool TraverseBinaryOperator(BinaryOperator *BO) {
-  recordCallback(__func__, BO, [&]() {
-RecordingVisitorBase::TraverseBinaryOperator(BO);
+bool TraverseUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::TraverseUnaryOperator(UO);
   });
   return true;
 }
@@ -411,27 +416,24 @@
   };
 
   StringRef Code = R"cpp(
-void add(int, int);
 void test() {
   1;
-  2 + 3;
-  add(4, 5);
+  -2;
+  3;
 }
 )cpp";
 
+  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
+  // individual operators as subclasses, for which it calls their Traverse
+  // methods.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::No), Code,
   R"txt(
 WalkUpFromStmt CompoundStmt
 WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt BinaryOperator(+)
+WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt CallExpr(add)
-WalkUpFromStmt ImplicitCastExpr
-WalkUpFromStmt DeclRefExpr(add)
-WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(5)
 )txt"));
 
   EXPECT_TRUE(visitorCallbackLogEqual(
@@ -439,27 +441,22 @@
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt BinaryOperator(+)
-WalkUpFromStmt DeclRefExpr(add)
-WalkUpFromStmt ImplicitCastExpr
-WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(5)
-WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
 
 TEST(RecursiveASTVisitor,
- StmtCallbacks_TraverseBinaryOperator_WalkUpFromBinaryOperator) {
+ StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) {
   class RecordingVisitor : public RecordingVisitorBase {
   public:
 RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
 : RecordingVisitorBase(ShouldTraversePostOrderValue) {}
 
-bool TraverseBinaryOperator(BinaryOperator *BO) {
-  recordCallback(__func__, BO, [&]() {
-RecordingVisitorBase::TraverseBinaryOperator(BO);
+bool TraverseUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::TraverseUnaryOperator(UO);
   });
   return true;
 }
@@ -476,49 +473,38 @@
   return true;
 }
 
-bool WalkUpFromBinaryOperator(BinaryOperator *BO) {
-  recordCallback(__func__, BO, [&]() {
-RecordingVisitorBase::WalkUpFromBinaryOperator(BO);
+bool WalkUpFromUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::WalkUpFromUnaryOperator(UO);
   });
   return true;
 }
   };
 
   StringRef Code = R"cpp(
-void add(int, int);
 void test() {
   1;
-  2 + 3;
-  add(4, 5);
+  -2;
+  3;
 }
 )cpp";
 
-  // FIXME: It is arguably a bug in RecursiveASTVisitor that
-  // WalkUpFromBinaryOperator is called, but TraverseBinaryOperator is not
-  // called.
+  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
+  // individual operators as subclasses, for which it calls their Traverse
+  // methods.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::No), Code,
   R"txt(
 WalkUpFromStmt CompoundStmt
 WalkUpFromExpr IntegerLiteral(1)
   WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromBinaryOperator BinaryOperator(+)
-  Wa

[PATCH] D82889: Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

2020-07-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8bf4c40af813: Make RecursiveASTVisitor call WalkUpFrom for 
operators when the data recursion… (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82889

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

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -606,14 +606,13 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -675,7 +674,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromUnaryMinus.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -684,6 +682,9 @@
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromUnaryMinus UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -996,8 +997,6 @@
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1005,6 +1004,7 @@
 TraverseBinAdd BinaryOperator(+)
   WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1067,7 +1067,6 @@
   WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAdd.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1078,6 +1077,9 @@
 WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromExpr IntegerLiteral(3)
 WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromBinAdd BinaryOperator(+)
+WalkUpFromExpr BinaryOperator(+)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
@@ -1396,8 +1398,6 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // CompoundAssignOperator(+=).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1405,6 +1405,7 @@
 TraverseBinAddAssign CompoundAssignOperator(+=)
   WalkUpFromStmt DeclRefExpr(a)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt CompoundAssignOperator(+=)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1470,7 +1471,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAddAssign.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1481,6 +1481,9 @@
 WalkUpFromStmt DeclRefExpr(a)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromBinAddAssign CompoundAssignOperator(+=)
+WalkUpFromExpr CompoundAssignOperator(+=)
+  WalkUpFromStmt CompoundAssignOperator(+=)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
Index: clang/include/clang/AST/RecursiveASTVisitor.h
===
--- clang/include/clang/AST/RecursiveASTVisitor.h
+++ clang/include/clang/AST/RecursiveASTVisitor.h
@@ -412,6 +412,8 @@
 if (!getDerived().shouldTraversePostOrder())   \
   TRY_TO(WalkUpFromUnary##NAME(S));\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  \
+if (!Queue && getDerived().shouldTraversePostOrder())  \
+  TRY_TO(WalkUpFromUnary##NAME(S));\
 return true;   \
   }\
   bool WalkUp

[PATCH] D82787: Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in post-order traversal mode

2020-07-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b0be962d681: Make RecursiveASTVisitor call WalkUpFrom for 
unary and binary operators in post… (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82787

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

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -416,13 +416,12 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -488,8 +487,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromUnaryOperator
-  // for UnaryyOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -497,6 +494,9 @@
   WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromExpr IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromUnaryOperator UnaryOperator(-)
+  WalkUpFromExpr UnaryOperator(-)
+WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -606,13 +606,14 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromStmt for
+  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -683,8 +684,6 @@
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromExpr UnaryOperator(-)
-  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -739,7 +738,6 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromUnaryMinus.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -747,8 +745,9 @@
   WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromExpr IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromExpr UnaryOperator(-)
-  WalkUpFromStmt UnaryOperator(-)
+WalkUpFromUnaryMinus UnaryOperator(-)
+  WalkUpFromExpr UnaryOperator(-)
+WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -797,14 +796,13 @@
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(3)
+WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -872,7 +870,6 @@
   WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinaryOperator.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -882,6 +879,9 @@
   WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
+WalkUpFromBinaryOperator BinaryOperator(+)
+  WalkUpFromExpr BinaryOperator(+)
+WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
@@ -996,6 +996,8 @@
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromStmt for
+  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1003,7 +1005,6 @@
 TraverseBinAdd BinaryOperator(+)
   WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1077,8 +1078,6 @@
 WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromExpr IntegerLiteral

[PATCH] D83115: [Analyzer] Report every bug if only uniqueing location differs.

2020-07-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 2 inline comments as done.
balazske added inline comments.



Comment at: clang/lib/Analysis/PathDiagnostic.cpp:333
+  if (XL.isValid() && YL.isInvalid())
+return false;
   std::pair XOffs = XL.getDecomposedLoc();

baloghadamsoftware wrote:
> Why this asymmetry?
The function returns something like "`XL` is less than `YL`". The invalid 
source locations should come always as first (or last?) in the ordering.



Comment at: clang/lib/Analysis/PathDiagnostic.cpp:389
+  return *Result;
   }
   PathDiagnostic::meta_iterator XI = X.meta_begin(), XE = X.meta_end();

baloghadamsoftware wrote:
> Asymmetry again. What if YUL is valid?
Here we have already a precondition that `XUL == YUL` (from line 358).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83115



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


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

2020-07-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94454442c3c1: RecursiveASTVisitor: don't call WalkUp 
unnecessarily in post-order traversal (authored by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82486

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

Index: clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
===
--- clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -154,22 +154,17 @@
   R"txt(
 TraverseIntegerLiteral IntegerLiteral(1)
   WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt DeclRefExpr(add)
 WalkUpFromStmt ImplicitCastExpr
 TraverseIntegerLiteral IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
   WalkUpFromStmt IntegerLiteral(5)
-WalkUpFromStmt IntegerLiteral(5)
 WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -258,23 +253,14 @@
   WalkUpFromIntegerLiteral IntegerLiteral(1)
 WalkUpFromExpr IntegerLiteral(1)
   WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromIntegerLiteral IntegerLiteral(1)
-  WalkUpFromExpr IntegerLiteral(1)
-WalkUpFromStmt IntegerLiteral(1)
 TraverseIntegerLiteral IntegerLiteral(2)
   WalkUpFromIntegerLiteral IntegerLiteral(2)
 WalkUpFromExpr IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromIntegerLiteral IntegerLiteral(2)
-  WalkUpFromExpr IntegerLiteral(2)
-WalkUpFromStmt IntegerLiteral(2)
 TraverseIntegerLiteral IntegerLiteral(3)
   WalkUpFromIntegerLiteral IntegerLiteral(3)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromIntegerLiteral IntegerLiteral(3)
-  WalkUpFromExpr IntegerLiteral(3)
-WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromExpr BinaryOperator(+)
   WalkUpFromStmt BinaryOperator(+)
 WalkUpFromExpr DeclRefExpr(add)
@@ -285,16 +271,10 @@
   WalkUpFromIntegerLiteral IntegerLiteral(4)
 WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromIntegerLiteral IntegerLiteral(4)
-  WalkUpFromExpr IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(4)
 TraverseIntegerLiteral IntegerLiteral(5)
   WalkUpFromIntegerLiteral IntegerLiteral(5)
 WalkUpFromExpr IntegerLiteral(5)
   WalkUpFromStmt IntegerLiteral(5)
-WalkUpFromIntegerLiteral IntegerLiteral(5)
-  WalkUpFromExpr IntegerLiteral(5)
-WalkUpFromStmt IntegerLiteral(5)
 WalkUpFromExpr CallExpr(add)
   WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
@@ -436,12 +416,13 @@
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromStmt for
+  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -507,6 +488,8 @@
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromUnaryOperator
+  // for UnaryyOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -514,9 +497,6 @@
   WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromExpr IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(2)
-WalkUpFromUnaryOperator UnaryOperator(-)
-  WalkUpFromExpr UnaryOperator(-)
-WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -817,13 +797,14 @@
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromStmt for
+  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -891,6 +872,7 @@
   WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
+  // FIXME: The following log should include a call to WalkUpFromBinaryOperator.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -900,9 +882,6 @@
   WalkUpFrom

[PATCH] D82781: [OpenCL] Fix missing address space deduction in template variables

2020-07-03 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 275351.
olestrohm added a comment.

Disregard the last comment, rolling back that diff for now.


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

https://reviews.llvm.org/D82781

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaOpenCLCXX/address-space-deduction.cl


Index: clang/test/SemaOpenCLCXX/address-space-deduction.cl
===
--- clang/test/SemaOpenCLCXX/address-space-deduction.cl
+++ clang/test/SemaOpenCLCXX/address-space-deduction.cl
@@ -5,6 +5,10 @@
 //CHECK: |-VarDecl {{.*}} foo 'const __global int'
 constexpr int foo = 0;
 
+//CHECK: `-VarTemplateSpecializationDecl {{.*}} used foo1 '__global 
long':'__global long' cinit
+template 
+T foo1 = 0;
+
 class c {
 public:
   //CHECK: `-VarDecl {{.*}} foo2 'const __global int'
@@ -111,4 +115,5 @@
   t3(&x);
   t4(&p);
   t5(&p);
+  long f1 = foo1;
 }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3625,6 +3625,13 @@
   if (InsertPos)
 VarTemplate->AddSpecialization(Var, InsertPos);
 
+  // FIXME: This may not be the best approach, as the correct type (including
+  // address space) is available in D, but the type in D may not be reliable
+  // in every situation.
+  // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
+  if (SemaRef.getLangOpts().OpenCL)
+ SemaRef.deduceOpenCLAddressSpace(Var);
+
   // Substitute the nested name specifier, if any.
   if (SubstQualifier(D, Var))
 return nullptr;
@@ -4803,6 +4810,13 @@
   // Instantiate the initializer.
   InstantiateVariableInitializer(VarSpec, PatternDecl, TemplateArgs);
 
+  // FIXME: This may not be the best approach, as the correct type (including
+  // address space) is available in PatternDecl, but this type may not be
+  // reliable in every situation.
+  // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
+  if (getLangOpts().OpenCL)
+ deduceOpenCLAddressSpace(VarSpec);
+
   return VarSpec;
 }
 


Index: clang/test/SemaOpenCLCXX/address-space-deduction.cl
===
--- clang/test/SemaOpenCLCXX/address-space-deduction.cl
+++ clang/test/SemaOpenCLCXX/address-space-deduction.cl
@@ -5,6 +5,10 @@
 //CHECK: |-VarDecl {{.*}} foo 'const __global int'
 constexpr int foo = 0;
 
+//CHECK: `-VarTemplateSpecializationDecl {{.*}} used foo1 '__global long':'__global long' cinit
+template 
+T foo1 = 0;
+
 class c {
 public:
   //CHECK: `-VarDecl {{.*}} foo2 'const __global int'
@@ -111,4 +115,5 @@
   t3(&x);
   t4(&p);
   t5(&p);
+  long f1 = foo1;
 }
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3625,6 +3625,13 @@
   if (InsertPos)
 VarTemplate->AddSpecialization(Var, InsertPos);
 
+  // FIXME: This may not be the best approach, as the correct type (including
+  // address space) is available in D, but the type in D may not be reliable
+  // in every situation.
+  // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
+  if (SemaRef.getLangOpts().OpenCL)
+ SemaRef.deduceOpenCLAddressSpace(Var);
+
   // Substitute the nested name specifier, if any.
   if (SubstQualifier(D, Var))
 return nullptr;
@@ -4803,6 +4810,13 @@
   // Instantiate the initializer.
   InstantiateVariableInitializer(VarSpec, PatternDecl, TemplateArgs);
 
+  // FIXME: This may not be the best approach, as the correct type (including
+  // address space) is available in PatternDecl, but this type may not be
+  // reliable in every situation.
+  // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
+  if (getLangOpts().OpenCL)
+ deduceOpenCLAddressSpace(VarSpec);
+
   return VarSpec;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9445444 - RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order traversal

2020-07-03 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-03T13:03:19+02:00
New Revision: 94454442c3c15a67ae70ef3a73616632968973fc

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

LOG: RecursiveASTVisitor: don't call WalkUp unnecessarily in post-order 
traversal

Summary:
How does RecursiveASTVisitor call the WalkUp callback for expressions?

* In pre-order traversal mode, RecursiveASTVisitor calls the WalkUp
  callback from the default implementation of Traverse callbacks.

* In post-order traversal mode when we don't have a DataRecursionQueue,
  RecursiveASTVisitor also calls the WalkUp callback from the default
  implementation of Traverse callbacks.

* However, in post-order traversal mode when we have a DataRecursionQueue,
  RecursiveASTVisitor calls the WalkUp callback from PostVisitStmt.

As a result, when the user overrides the Traverse callback, in pre-order
traversal mode they never get the corresponding WalkUp callback. However
in the post-order traversal mode the WalkUp callback is invoked or not
depending on whether the data recursion optimization could be applied.

I had to adjust the implementation of TraverseCXXForRangeStmt in the
syntax tree builder to call the WalkUp method directly, as it was
relying on this behavior. There is an existing test for this
functionality and it prompted me to make this extra fix.

In addition, I had to fix the default implementation implementation of
RecursiveASTVisitor::TraverseSynOrSemInitListExpr to call WalkUpFrom in
the same manner as the implementation generated by the DEF_TRAVERSE_STMT
macro. Without this fix, the InitListExprIsPostOrderNoQueueVisitedTwice
test was failing because WalkUpFromInitListExpr was never called.

Reviewers: eduucaldas, ymandel

Reviewed By: eduucaldas, ymandel

Subscribers: gribozavr2, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index b16c1ae1e483..821a6c549b71 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -331,6 +331,32 @@ template  class RecursiveASTVisitor {
   struct has_same_member_pointer_type
   : std::true_type {};
 
+  template  struct is_same_method_impl {
+template 
+static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+ SecondMethodPtrTy SecondMethodPtr) {
+  return false;
+}
+  };
+
+  template <> struct is_same_method_impl {
+template 
+static bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+ SecondMethodPtrTy SecondMethodPtr) {
+  return FirstMethodPtr == SecondMethodPtr;
+}
+  };
+
+  /// Returns true if and only if \p FirstMethodPtr and \p SecondMethodPtr
+  /// are pointers to the same non-static member function.
+  template 
+  bool isSameMethod(FirstMethodPtrTy FirstMethodPtr,
+SecondMethodPtrTy SecondMethodPtr) {
+return is_same_method_impl<
+has_same_member_pointer_type::
+value>::isSameMethod(FirstMethodPtr, SecondMethodPtr);
+  }
+
   // Traverse the given statement. If the most-derived traverse function takes 
a
   // data recursion queue, pass it on; otherwise, discard it. Note that the
   // first branch of this conditional must compile whether or not the derived
@@ -609,17 +635,38 @@ bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) 
{
 #define ABSTRACT_STMT(STMT)
 #define STMT(CLASS, PARENT)
\
   case Stmt::CLASS##Class: 
\
-TRY_TO(WalkUpFrom##CLASS(static_cast(S))); break;
+/* In pre-order traversal mode, each Traverse##STMT method is responsible  
\
+ * for calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT 
\
+ * and does not call the default implementation, the WalkUpFrom callback   
\
+ * is not called. Post-order traversal mode should provide the same
\
+ * behavior regarding method overrides.
\
+ * 
\
+ * In post-order traversal mode the Traverse##STMT method, when it 
\
+ * receives a DataRecursionQueue, can't call WalkUpFrom after traversing   
\
+ * children because it only enqueues the children and does not traverse
\
+ * them. TraverseStmt traverses the enqueued children, and we call 
\
+ * WalkUpFrom here.   

[clang] 8bf4c40 - Make RecursiveASTVisitor call WalkUpFrom for operators when the data recursion queue is absent

2020-07-03 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-03T13:03:19+02:00
New Revision: 8bf4c40af813e73de77739b33b8808f6bd13497b

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

LOG: Make RecursiveASTVisitor call WalkUpFrom for operators when the data 
recursion queue is absent

Reviewers: eduucaldas, ymandel, rsmith

Reviewed By: eduucaldas

Subscribers: gribozavr2, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 3d7cb73a471c..ba36d5b23fc6 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -412,6 +412,8 @@ template  class RecursiveASTVisitor {
 if (!getDerived().shouldTraversePostOrder())   
\
   TRY_TO(WalkUpFromUnary##NAME(S));
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getSubExpr());  
\
+if (!Queue && getDerived().shouldTraversePostOrder())  
\
+  TRY_TO(WalkUpFromUnary##NAME(S));
\
 return true;   
\
   }
\
   bool WalkUpFromUnary##NAME(UnaryOperator *S) {   
\
@@ -433,6 +435,8 @@ template  class RecursiveASTVisitor {
   TRY_TO(WalkUpFromBin##NAME(S));  
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getLHS());  
\
 TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(S->getRHS());  
\
+if (!Queue && getDerived().shouldTraversePostOrder())  
\
+  TRY_TO(WalkUpFromBin##NAME(S));  
\
 return true;   
\
   }
\
   bool WalkUpFromBin##NAME(BINOP_TYPE *S) {
\

diff  --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
index 0a4e9aa1e9e8..70c7eb37ad4c 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -606,14 +606,13 @@ TraverseUnaryMinus UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // UnaryOperator(-).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -675,7 +674,6 @@ WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromUnaryMinus.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -684,6 +682,9 @@ WalkUpFromExpr IntegerLiteral(1)
 TraverseUnaryMinus UnaryOperator(-)
   WalkUpFromExpr IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(2)
+  WalkUpFromUnaryMinus UnaryOperator(-)
+WalkUpFromExpr UnaryOperator(-)
+  WalkUpFromStmt UnaryOperator(-)
 WalkUpFromExpr IntegerLiteral(3)
   WalkUpFromStmt IntegerLiteral(3)
 WalkUpFromStmt CompoundStmt
@@ -996,8 +997,6 @@ TraverseBinAdd BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromStmt for
-  // BinaryOperator(+).
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1005,6 +1004,7 @@ WalkUpFromStmt IntegerLiteral(1)
 TraverseBinAdd BinaryOperator(+)
   WalkUpFromStmt IntegerLiteral(2)
   WalkUpFromStmt IntegerLiteral(3)
+  WalkUpFromStmt BinaryOperator(+)
 WalkUpFromStmt IntegerLiteral(4)
 WalkUpFromStmt CompoundStmt
 )txt"));
@@ -1067,7 +1067,6 @@ WalkUpFromExpr IntegerLiteral(4)
   WalkUpFromStmt IntegerLiteral(4)
 )txt"));
 
-  // FIXME: The following log should include a call to WalkUpFromBinAdd.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::Yes), Code,
   R"txt(
@@ -1078,6 +1077,9 @@ TraverseBinAdd BinaryOperator(+)
 WalkUpFromStmt Inte

[clang] 7988969 - Added tests for RecursiveASTVisitor for AST nodes that are special cased

2020-07-03 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-03T13:03:18+02:00
New Revision: 79889691430d8e76e908706170102a8b46432a07

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

LOG: Added tests for RecursiveASTVisitor for AST nodes that are special cased

Summary:
RecursiveASTVisitor has special code for handling operator AST nodes,
specifically, unary, binary, and compound assignment operators. In this
change I'm adding tests for operator AST nodes that follow the existing
pattern of tests for the CallExpr node (an AST node that triggers the
common code path).

Reviewers: ymandel, eduucaldas

Reviewed By: ymandel, eduucaldas

Subscribers: gribozavr2, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp 
b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
index 0eb9a43ecb14..66aa1d763833 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp
@@ -41,6 +41,11 @@ class RecordingVisitorBase : public TestVisitor {
 if (IntegerLiteral *IL = dyn_cast(S)) {
   return (ClassName + "(" + IL->getValue().toString(10, false) + 
")").str();
 }
+if (UnaryOperator *UO = dyn_cast(S)) {
+  return (ClassName + "(" + UnaryOperator::getOpcodeStr(UO->getOpcode()) +
+  ")")
+  .str();
+}
 if (BinaryOperator *BO = dyn_cast(S)) {
   return (ClassName + "(" + BinaryOperator::getOpcodeStr(BO->getOpcode()) +
   ")")
@@ -390,15 +395,15 @@ WalkUpFromStmt CompoundStmt
 )txt"));
 }
 
-TEST(RecursiveASTVisitor, StmtCallbacks_TraverseBinaryOperator) {
+TEST(RecursiveASTVisitor, StmtCallbacks_TraverseUnaryOperator) {
   class RecordingVisitor : public RecordingVisitorBase {
   public:
 RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
 : RecordingVisitorBase(ShouldTraversePostOrderValue) {}
 
-bool TraverseBinaryOperator(BinaryOperator *BO) {
-  recordCallback(__func__, BO, [&]() {
-RecordingVisitorBase::TraverseBinaryOperator(BO);
+bool TraverseUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::TraverseUnaryOperator(UO);
   });
   return true;
 }
@@ -411,27 +416,24 @@ TEST(RecursiveASTVisitor, 
StmtCallbacks_TraverseBinaryOperator) {
   };
 
   StringRef Code = R"cpp(
-void add(int, int);
 void test() {
   1;
-  2 + 3;
-  add(4, 5);
+  -2;
+  3;
 }
 )cpp";
 
+  // TraverseUnaryOperator is not called because RecursiveASTVisitor treats
+  // individual operators as subclasses, for which it calls their Traverse
+  // methods.
   EXPECT_TRUE(visitorCallbackLogEqual(
   RecordingVisitor(ShouldTraversePostOrder::No), Code,
   R"txt(
 WalkUpFromStmt CompoundStmt
 WalkUpFromStmt IntegerLiteral(1)
-WalkUpFromStmt BinaryOperator(+)
+WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(2)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt CallExpr(add)
-WalkUpFromStmt ImplicitCastExpr
-WalkUpFromStmt DeclRefExpr(add)
-WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(5)
 )txt"));
 
   EXPECT_TRUE(visitorCallbackLogEqual(
@@ -439,27 +441,22 @@ WalkUpFromStmt IntegerLiteral(5)
   R"txt(
 WalkUpFromStmt IntegerLiteral(1)
 WalkUpFromStmt IntegerLiteral(2)
+WalkUpFromStmt UnaryOperator(-)
 WalkUpFromStmt IntegerLiteral(3)
-WalkUpFromStmt BinaryOperator(+)
-WalkUpFromStmt DeclRefExpr(add)
-WalkUpFromStmt ImplicitCastExpr
-WalkUpFromStmt IntegerLiteral(4)
-WalkUpFromStmt IntegerLiteral(5)
-WalkUpFromStmt CallExpr(add)
 WalkUpFromStmt CompoundStmt
 )txt"));
 }
 
 TEST(RecursiveASTVisitor,
- StmtCallbacks_TraverseBinaryOperator_WalkUpFromBinaryOperator) {
+ StmtCallbacks_TraverseUnaryOperator_WalkUpFromUnaryOperator) {
   class RecordingVisitor : public RecordingVisitorBase {
   public:
 RecordingVisitor(ShouldTraversePostOrder ShouldTraversePostOrderValue)
 : RecordingVisitorBase(ShouldTraversePostOrderValue) {}
 
-bool TraverseBinaryOperator(BinaryOperator *BO) {
-  recordCallback(__func__, BO, [&]() {
-RecordingVisitorBase::TraverseBinaryOperator(BO);
+bool TraverseUnaryOperator(UnaryOperator *UO) {
+  recordCallback(__func__, UO, [&]() {
+RecordingVisitorBase::TraverseUnaryOperator(UO);
   });
   return true;
 }
@@ -476,49 +473,38 @@ TEST(RecursiveASTVisitor,
   return true;
 }
 
-bool WalkUpFromBinaryOperator(BinaryOperator *BO) {
-  recordCallback(__func__, BO, [&]() {
-RecordingVisitorBase::WalkUpFromBinaryOperator(BO);
+bool W

[clang] 7b0be96 - Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in post-order traversal mode

2020-07-03 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2020-07-03T13:03:19+02:00
New Revision: 7b0be962d681c408c8ecf7180c6ad8f9fbcdaf2d

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

LOG: Make RecursiveASTVisitor call WalkUpFrom for unary and binary operators in 
post-order traversal mode

Reviewers: ymandel, eduucaldas, rsmith

Reviewed By: eduucaldas, rsmith

Subscribers: gribozavr2, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/RecursiveASTVisitor.h
clang/unittests/Tooling/RecursiveASTVisitorTests/Callbacks.cpp

Removed: 




diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 821a6c549b71..3d7cb73a471c 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -589,7 +589,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   BINOP_LIST()
 #undef OPERATOR
-#undef BINOP_LIST
 
 #define OPERATOR(NAME) 
\
   case BO_##NAME##Assign:  
\
@@ -597,7 +596,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   CAO_LIST()
 #undef OPERATOR
-#undef CAO_LIST
 }
   } else if (UnaryOperator *UnOp = dyn_cast(S)) {
 switch (UnOp->getOpcode()) {
@@ -607,7 +605,6 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt *S,
 
   UNARYOP_LIST()
 #undef OPERATOR
-#undef UNARYOP_LIST
 }
   }
 
@@ -629,27 +626,68 @@ bool RecursiveASTVisitor::dataTraverseNode(Stmt 
*S,
 
 template 
 bool RecursiveASTVisitor::PostVisitStmt(Stmt *S) {
+  // In pre-order traversal mode, each Traverse##STMT method is responsible for
+  // calling WalkUpFrom. Therefore, if the user overrides Traverse##STMT and
+  // does not call the default implementation, the WalkUpFrom callback is not
+  // called. Post-order traversal mode should provide the same behavior
+  // regarding method overrides.
+  //
+  // In post-order traversal mode the Traverse##STMT method, when it receives a
+  // DataRecursionQueue, can't call WalkUpFrom after traversing children 
because
+  // it only enqueues the children and does not traverse them. TraverseStmt
+  // traverses the enqueued children, and we call WalkUpFrom here.
+  //
+  // However, to make pre-order and post-order modes identical with regards to
+  // whether they call WalkUpFrom at all, we call WalkUpFrom if and only if the
+  // user did not override the Traverse##STMT method. We implement the override
+  // check with isSameMethod calls below.
+
+  if (BinaryOperator *BinOp = dyn_cast(S)) {
+switch (BinOp->getOpcode()) {
+#define OPERATOR(NAME) 
\
+  case BO_##NAME:  
\
+if (isSameMethod(&RecursiveASTVisitor::TraverseBin##NAME,  
\
+ &Derived::TraverseBin##NAME)) {   
\
+  TRY_TO(WalkUpFromBin##NAME(static_cast(S)));   
\
+}  
\
+return true;
+
+  BINOP_LIST()
+#undef OPERATOR
+
+#define OPERATOR(NAME) 
\
+  case BO_##NAME##Assign:  
\
+if (isSameMethod(&RecursiveASTVisitor::TraverseBin##NAME##Assign,  
\
+ &Derived::TraverseBin##NAME##Assign)) {   
\
+  TRY_TO(WalkUpFromBin##NAME##Assign(  
\
+  static_cast(S)));  
\
+}  
\
+return true;
+
+  CAO_LIST()
+#undef OPERATOR
+}
+  } else if (UnaryOperator *UnOp = dyn_cast(S)) {
+switch (UnOp->getOpcode()) {
+#define OPERATOR(NAME) 
\
+  case UO_##NAME:  
\
+if (isSameMethod(&RecursiveASTVisitor::TraverseUnary##NAME,
\
+ &Derived::TraverseUnary##NAME)) { 
\
+  TRY_TO(WalkUpFromUnary##NAME(static_cast(S)));  
\
+}  
\
+return true;
+
+  UNARYOP_LIST()
+#undef OPERATOR
+}
+  }
+
   switch (S->getStmtClass()) {
   case Stmt::NoStmtClass:
 break;
 #define ABSTRACT_STMT(STMT)
 #define STMT(CLASS, PARENT)
\
   case Stmt::CLASS##Class: 
\
-/* In pre-

[PATCH] D75740: [ASTImporter] Corrected import of repeated friend declarations.

2020-07-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 275343.
balazske added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75740

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

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -759,6 +759,27 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceRecordTest, SameFriendMultipleTimes) {
+  auto t = makeNamedDecls("struct foo { friend class X; };",
+  "struct foo { friend class X; friend class X; };",
+  Lang_CXX11);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceRecordTest, SameFriendsDifferentOrder) {
+  auto t = makeNamedDecls("struct foo { friend class X; friend class Y; };",
+  "struct foo { friend class Y; friend class X; };",
+  Lang_CXX11);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceRecordTest, SameFriendsSameOrder) {
+  auto t = makeNamedDecls("struct foo { friend class X; friend class Y; };",
+  "struct foo { friend class X; friend class Y; };",
+  Lang_CXX11);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
 struct StructuralEquivalenceLambdaTest : StructuralEquivalenceTest {};
 
 TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithDifferentMethods) {
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -3974,6 +3974,56 @@
   EXPECT_EQ(ImportedFwd, ImportedDef->getPreviousDecl());
 }
 
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendType) {
+  const char *Code =
+  R"(
+  class Container {
+friend class X;
+friend class X;
+  };
+  )";
+  Decl *ToTu = getToTuDecl(Code, Lang_CXX03);
+  Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc");
+
+  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+  auto *FromFriend1 =
+  FirstDeclMatcher().match(FromTu, friendDecl());
+  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
+
+  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03);
+  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03);
+
+  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
+  EXPECT_EQ(ToFriend1, ToImportedFriend1);
+  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+}
+
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendDecl) {
+  const char *Code =
+  R"(
+  class Container {
+friend void f();
+friend void f();
+  };
+  )";
+  Decl *ToTu = getToTuDecl(Code, Lang_CXX03);
+  Decl *FromTu = getTuDecl(Code, Lang_CXX03, "from.cc");
+
+  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+  auto *FromFriend1 =
+  FirstDeclMatcher().match(FromTu, friendDecl());
+  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
+
+  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX03);
+  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX03);
+
+  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
+  EXPECT_EQ(ToFriend1, ToImportedFriend1);
+  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, FriendFunInClassTemplate) {
   auto *Code = R"(
   template 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3646,6 +3646,54 @@
   return ToIndirectField;
 }
 
+/// Used as return type of getFriendCountAndPosition.
+struct FriendCountAndPosition {
+  /// Number of similar looking friends.
+  unsigned int TotalCount;
+  /// Index of the specific FriendDecl.
+  unsigned int IndexOfDecl;
+};
+
+template 
+FriendCountAndPosition getFriendCountAndPosition(
+const FriendDecl *FD,
+std::function GetCanTypeOrDecl) {
+  unsigned int FriendCount = 0;
+  llvm::Optional FriendPosition;
+  const auto *RD = cast(FD->getLexicalDeclContext());
+
+  T TypeOrDecl = GetCanTypeOrDecl(FD);
+
+  for (const FriendDecl *FoundFriend : RD->friends()) {
+if (FoundFriend == FD) {
+  FriendPosition = FriendCount;
+  ++FriendCount;
+} else if (!FoundFriend->getFriendDecl() == !FD->getFriendDecl() &&
+   GetCanTypeOrDecl(FoundFriend) == TypeOrDecl) {
+  ++FriendCount;
+}
+  }
+
+  assert(FriendPosition && "Friend decl not found in own parent.");
+
+  return {Friend

[PATCH] D83121: [AMDGPU] Change Clang AMDGCN atomic inc/dec builtins to take unsigned values

2020-07-03 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Thanks for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83121



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


[PATCH] D82781: [OpenCL] Fix missing address space deduction in template variables

2020-07-03 Thread Ole Strohm via Phabricator via cfe-commits
olestrohm updated this revision to Diff 275345.
olestrohm added a comment.

Added a guard in deduceOpenCLAddressSpace to stop it from deducing address 
space for dependent types, as requested.


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

https://reviews.llvm.org/D82781

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp


Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3630,7 +3630,7 @@
   // in every situation.
   // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
   if (SemaRef.getLangOpts().OpenCL)
- SemaRef.deduceOpenCLAddressSpace(Var);
+SemaRef.deduceOpenCLAddressSpace(Var);
 
   // Substitute the nested name specifier, if any.
   if (SubstQualifier(D, Var))
@@ -4815,7 +4815,7 @@
   // reliable in every situation.
   // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
   if (getLangOpts().OpenCL)
- deduceOpenCLAddressSpace(VarSpec);
+deduceOpenCLAddressSpace(VarSpec);
 
   return VarSpec;
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6287,6 +6287,8 @@
 void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
   if (Decl->getType().hasAddressSpace())
 return;
+  if (Decl->getType().isDependentType())
+return;
   if (VarDecl *Var = dyn_cast(Decl)) {
 QualType Type = Var->getType();
 if (Type->isSamplerT() || Type->isVoidType())


Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3630,7 +3630,7 @@
   // in every situation.
   // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
   if (SemaRef.getLangOpts().OpenCL)
- SemaRef.deduceOpenCLAddressSpace(Var);
+SemaRef.deduceOpenCLAddressSpace(Var);
 
   // Substitute the nested name specifier, if any.
   if (SubstQualifier(D, Var))
@@ -4815,7 +4815,7 @@
   // reliable in every situation.
   // This approach was copied from TemplateDeclInstantiator::VisitVarDecl
   if (getLangOpts().OpenCL)
- deduceOpenCLAddressSpace(VarSpec);
+deduceOpenCLAddressSpace(VarSpec);
 
   return VarSpec;
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6287,6 +6287,8 @@
 void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
   if (Decl->getType().hasAddressSpace())
 return;
+  if (Decl->getType().isDependentType())
+return;
   if (VarDecl *Var = dyn_cast(Decl)) {
 QualType Type = Var->getType();
 if (Type->isSamplerT() || Type->isVoidType())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D83121: [AMDGPU] Change Clang AMDGCN atomic inc/dec builtins to take unsigned values

2020-07-03 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam created this revision.
saiislam added reviewers: arsenm, sameerds, JonChesterfield.
Herald added subscribers: cfe-commits, kerbowa, jfb, t-tye, tpr, dstuttard, 
yaxunl, nhaehnle, wdng, jvesely, kzhuravl.
Herald added a project: clang.
saiislam added a parent revision: D80804: [AMDGPU] Introduce Clang builtins to 
be mapped to AMDGCN atomic inc/dec intrinsics.

builtin_amdgcn_atomic_inc32(uint *Ptr, uint Val, unsigned MemoryOrdering, const 
char *SyncScope)
builtin_amdgcn_atomic_inc64(uint64_t *Ptr, uint64_t Val, unsigned 
MemoryOrdering, const char *SyncScope)
builtin_amdgcn_atomic_dec32(uint *Ptr, uint Val, unsigned MemoryOrdering, const 
char *SyncScope)
builtin_amdgcn_atomic_dec64(uint64_t *Ptr, uint64_t Val, unsigned 
MemoryOrdering, const char *SyncScope)

As AMDGCN IR instrinsic for atomic inc/dec does unsigned comparison,
these clang builtins should also take unsigned types instead of signed
int types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83121

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/test/CodeGenCXX/builtin-amdgcn-atomic-inc-dec.cpp
  clang/test/Sema/builtin-amdgcn-atomic-inc-dec-failure.cpp
  clang/test/SemaOpenCL/builtins-amdgcn-error.cl

Index: clang/test/SemaOpenCL/builtins-amdgcn-error.cl
===
--- clang/test/SemaOpenCL/builtins-amdgcn-error.cl
+++ clang/test/SemaOpenCL/builtins-amdgcn-error.cl
@@ -146,7 +146,7 @@
 }
 
 void test_atomic_inc32() {
-  int val = 17;
+  uint val = 17;
   val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
   val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
   val = __builtin_amdgcn_atomic_inc32(4);// expected-error {{too few arguments to function call, expected 4}}
@@ -155,10 +155,12 @@
   val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE, 5);   // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
   const char ptr[] = "workgroup";
   val = __builtin_amdgcn_atomic_inc32(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}}
+  int signedVal = 15;
+  signedVal = __builtin_amdgcn_atomic_inc32(&signedVal, signedVal, __ATOMIC_ACQUIRE, ""); // expected-warning {{passing '__private int *' to parameter of type 'volatile __private unsigned int *' converts between pointers to integer types with different sign}}
 }
 
 void test_atomic_inc64() {
-  __INT64_TYPE__ val = 17;
+  __UINT64_TYPE__ val = 17;
   val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
   val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
   val = __builtin_amdgcn_atomic_inc64(4);// expected-error {{too few arguments to function call, expected 4}}
@@ -167,10 +169,12 @@
   val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE, 5);   // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
   const char ptr[] = "workgroup";
   val = __builtin_amdgcn_atomic_inc64(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}}
+  __INT64_TYPE__ signedVal = 15;
+  signedVal = __builtin_amdgcn_atomic_inc64(&signedVal, signedVal, __ATOMIC_ACQUIRE, ""); // expected-warning {{passing '__private long *' to parameter of type 'volatile __private unsigned long *' converts between pointers to integer types with different sign}}
 }
 
 void test_atomic_dec32() {
-  int val = 17;
+  uint val = 17;
   val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_SEQ_CST + 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
   val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE - 1, "workgroup"); // expected-warning {{memory order argument to atomic operation is invalid}}
   val = __builtin_amdgcn_atomic_dec32(4);// expected-error {{too few arguments to function call, expected 4}}
@@ -179,10 +183,12 @@
   val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE, 5);   // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *'}}
   const char ptr[] = "workgroup";
   val = __builtin_amdgcn_atomic_dec32(&val, val, __ATOMIC_ACQUIRE, ptr); // expected-error {{expression is not a string literal}}
+  int signedVal = 15;
+  signedVal = __builtin_amdgcn_atomic_dec32(&signedVal, signedVal, __ATOMIC_ACQU

[PATCH] D81169: [clangd] Improve hover on arguments to function call

2020-07-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c46fefdba3b: [clangd] Improve hover on arguments to 
function call (authored by adamcz, committed by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81169

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -26,6 +26,8 @@
 namespace clangd {
 namespace {
 
+using PassMode = HoverInfo::PassType::PassMode;
+
 TEST(Hover, Structured) {
   struct {
 const char *const Code;
@@ -719,6 +721,57 @@
  // Bindings are in theory public members of an anonymous struct.
  HI.AccessSpecifier = "public";
}},
+  {// Extra info for function call.
+   R"cpp(
+  void fun(int arg_a, int &arg_b) {};
+  void code() {
+int a = 1, b = 2;
+fun(a, [[^b]]);
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "b";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "int b = 2";
+ HI.LocalScope = "code::";
+ HI.Value = "2";
+ HI.Type = "int";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_b";
+ HI.CalleeArgInfo->Type = "int &";
+ HI.CallPassType.emplace();
+ HI.CallPassType->PassBy = PassMode::Ref;
+ HI.CallPassType->Converted = false;
+   }},
+  {// Extra info for method call.
+   R"cpp(
+  class C {
+   public:
+void fun(int arg_a = 3, int arg_b = 4) {}
+  };
+  void code() {
+int a = 1, b = 2;
+C c;
+c.fun([[^a]], b);
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "a";
+ HI.Kind = index::SymbolKind::Variable;
+ HI.NamespaceScope = "";
+ HI.Definition = "int a = 1";
+ HI.LocalScope = "code::";
+ HI.Value = "1";
+ HI.Type = "int";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_a";
+ HI.CalleeArgInfo->Type = "int";
+ HI.CalleeArgInfo->Default = "3";
+ HI.CallPassType.emplace();
+ HI.CallPassType->PassBy = PassMode::Value;
+ HI.CallPassType->Converted = false;
+   }},
   };
   for (const auto &Case : Cases) {
 SCOPED_TRACE(Case.Code);
@@ -752,6 +805,85 @@
 EXPECT_EQ(H->Size, Expected.Size);
 EXPECT_EQ(H->Offset, Expected.Offset);
 EXPECT_EQ(H->AccessSpecifier, Expected.AccessSpecifier);
+EXPECT_EQ(H->CalleeArgInfo, Expected.CalleeArgInfo);
+EXPECT_EQ(H->CallPassType, Expected.CallPassType);
+  }
+}
+
+TEST(Hover, CallPassType) {
+  const llvm::StringRef CodePrefix = R"cpp(
+class Base {};
+class Derived : public Base {};
+class CustomClass {
+ public:
+  CustomClass() {}
+  CustomClass(const Base &x) {}
+  CustomClass(int &x) {}
+  CustomClass(float x) {}
+};
+
+void int_by_ref(int &x) {}
+void int_by_const_ref(const int &x) {}
+void int_by_value(int x) {}
+void base_by_ref(Base &x) {}
+void base_by_const_ref(const Base &x) {}
+void base_by_value(Base x) {}
+void float_by_value(float x) {}
+void custom_by_value(CustomClass x) {}
+
+void fun() {
+  int int_x;
+  int &int_ref = int_x;
+  const int &int_const_ref = int_x;
+  Base base;
+  const Base &base_const_ref = base;
+  Derived derived;
+  float float_x;
+)cpp";
+  const llvm::StringRef CodeSuffix = "}";
+
+  struct {
+const char *const Code;
+HoverInfo::PassType::PassMode PassBy;
+bool Converted;
+  } Tests[] = {
+  // Integer tests
+  {"int_by_value([[^int_x]]);", PassMode::Value, false},
+  {"int_by_ref([[^int_x]]);", PassMode::Ref, false},
+  {"int_by_const_ref([[^int_x]]);", PassMode::ConstRef, false},
+  {"int_by_value([[^int_ref]]);", PassMode::Value, false},
+  {"int_by_const_ref([[^int_ref]]);", PassMode::ConstRef, false},
+  {"int_by_const_ref([[^int_ref]]);", PassMode::ConstRef, false},
+  {"int_by_const_ref([[^int_const_ref]]);", PassMode::ConstRef, false},
+  // Custom class tests
+  {"base_by_ref([[^base]]);", PassMode::Ref, false},
+  {"base_by_const_ref([[^base]]);", PassMode::ConstRef, false},
+  {"base_by_const_ref([[^base_const_ref]]);", PassMode::ConstRef, false},
+  {"base_by_value([[^base]]);", PassMode::Value, false},
+  {"base_by_value([[^base_const_ref]]);", PassMode::Value, false},
+  {"base_by_ref([[^derived]]);", PassMode::Ref, false},
+  {"base_by_const_ref([[^derived]]);", PassMode::ConstRef, false},
+  {"base_by_value([[^derived]]);", PassMode::Value, false},
+  // Co

[PATCH] D80804: [AMDGPU] Introduce Clang builtins to be mapped to AMDGCN atomic inc/dec intrinsics

2020-07-03 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam added a comment.

In D80804#2123183 , @JonChesterfield 
wrote:

> This patch declares the clang builtin as acting on signed values, but the IR 
> intrinsic maps to an instruction which does an unsigned comparison. We don't 
> have ISA support for a signed comparison equivalent. Addition is the same 
> operation on signed or unsigned integers, but signed integer comparison is 
> not equivalent to unsigned integer comparison.
>
>   // 32bit
>tmp = MEM[ADDR];
>MEM[ADDR] = (tmp >= DATA) ? 0 : tmp + 1; // unsigned
>   compare
>RETURN_DATA = tmp.
>
>
> The builtins should be changed to take unsigned values, optionally making 
> that clear from the naming scheme, perhaps  `__amdgcn_builtin_atomic_dec_u32`.
>
> Apologies for not reviewing this the first time around.


I have created D83121  for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80804



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


[PATCH] D82964: [clangd] Config: loading and caching config from disk.

2020-07-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ConfigProvider.cpp:39
+auto Buf = FS.getBufferForFile(Path);
+// If stat() succeeds but we failed to read, retry once and cache failure.
+if (!Buf)

why do we want to cache failure case for missing files ?

If it is truly missing and we didn't race with another process (likely 
git-checkout), the next stat will fail and we'll return a no-op fragment.
If it was a race, we want to pick it up on the next run (and reading twice 
might not have enough of a delay in between), so why not just cache with a 
sentinel key in here too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82964



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


[PATCH] D83115: [Analyzer] Report every bug if only uniqueing location differs.

2020-07-03 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: clang/lib/Analysis/PathDiagnostic.cpp:333
+  if (XL.isValid() && YL.isInvalid())
+return false;
   std::pair XOffs = XL.getDecomposedLoc();

Why this asymmetry?



Comment at: clang/lib/Analysis/PathDiagnostic.cpp:389
+  return *Result;
   }
   PathDiagnostic::meta_iterator XI = X.meta_begin(), XE = X.meta_end();

Asymmetry again. What if YUL is valid?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83115



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


[clang-tools-extra] 5c46fef - [clangd] Improve hover on arguments to function call

2020-07-03 Thread Kadir Cetinkaya via cfe-commits

Author: Adam Czachorowski
Date: 2020-07-03T11:51:15+02:00
New Revision: 5c46fefdba3b18329dc331e69d1d1d6550c4075f

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

LOG: [clangd] Improve hover on arguments to function call

Summary:
In cases like:
  foo(a, ^b);
We now additionally show the name and type of the parameter to foo that
corresponds that "b" is passed as.

The name should help with understanding what it's used for and type can
be useful to find out if call to foo() can mutate variable "b" or not
(i.e. if it is pass by value, reference, const reference, etc).

Patch By: adamcz@ !

Reviewers: kadircet

Reviewed By: kadircet

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

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index bd5b7114cc35..616d4c91c0f7 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -289,23 +289,27 @@ const Expr *getDefaultArg(const ParmVarDecl *PVD) {
 : PVD->getDefaultArg();
 }
 
+HoverInfo::Param toHoverInfoParam(const ParmVarDecl *PVD,
+  const PrintingPolicy &Policy) {
+  HoverInfo::Param Out;
+  Out.Type = printType(PVD->getType(), Policy);
+  if (!PVD->getName().empty())
+Out.Name = PVD->getNameAsString();
+  if (const Expr *DefArg = getDefaultArg(PVD)) {
+Out.Default.emplace();
+llvm::raw_string_ostream OS(*Out.Default);
+DefArg->printPretty(OS, nullptr, Policy);
+  }
+  return Out;
+}
+
 // Populates Type, ReturnType, and Parameters for function-like decls.
 void fillFunctionTypeAndParams(HoverInfo &HI, const Decl *D,
const FunctionDecl *FD,
const PrintingPolicy &Policy) {
   HI.Parameters.emplace();
-  for (const ParmVarDecl *PVD : FD->parameters()) {
-HI.Parameters->emplace_back();
-auto &P = HI.Parameters->back();
-P.Type = printType(PVD->getType(), Policy);
-if (!PVD->getName().empty())
-  P.Name = PVD->getNameAsString();
-if (const Expr *DefArg = getDefaultArg(PVD)) {
-  P.Default.emplace();
-  llvm::raw_string_ostream Out(*P.Default);
-  DefArg->printPretty(Out, nullptr, Policy);
-}
-  }
+  for (const ParmVarDecl *PVD : FD->parameters())
+HI.Parameters->emplace_back(toHoverInfoParam(PVD, Policy));
 
   // We don't want any type info, if name already contains it. This is true for
   // constructors/destructors and conversion operators.
@@ -678,6 +682,92 @@ void addLayoutInfo(const NamedDecl &ND, HoverInfo &HI) {
   }
 }
 
+// If N is passed as argument to a function, fill HI.CalleeArgInfo with
+// information about that argument.
+void maybeAddCalleeArgInfo(const SelectionTree::Node *N, HoverInfo &HI,
+   const PrintingPolicy &Policy) {
+  const auto &OuterNode = N->outerImplicit();
+  if (!OuterNode.Parent)
+return;
+  const auto *CE = OuterNode.Parent->ASTNode.get();
+  if (!CE)
+return;
+  const FunctionDecl *FD = CE->getDirectCallee();
+  // For non-function-call-like operatators (e.g. operator+, operator<<) it's
+  // not immediattely obvious what the "passed as" would refer to and, given
+  // fixed function signature, the value would be very low anyway, so we choose
+  // to not support that.
+  // Both variadic functions and operator() (especially relevant for lambdas)
+  // should be supported in the future.
+  if (!FD || FD->isOverloadedOperator() || FD->isVariadic())
+return;
+
+  // Find argument index for N.
+  for (unsigned I = 0; I < CE->getNumArgs() && I < FD->getNumParams(); ++I) {
+if (CE->getArg(I) != OuterNode.ASTNode.get())
+  continue;
+
+// Extract matching argument from function declaration.
+if (const ParmVarDecl *PVD = FD->getParamDecl(I))
+  HI.CalleeArgInfo.emplace(toHoverInfoParam(PVD, Policy));
+break;
+  }
+  if (!HI.CalleeArgInfo)
+return;
+
+  // If we found a matching argument, also figure out if it's a
+  // [const-]reference. For this we need to walk up the AST from the arg itself
+  // to CallExpr and check all implicit casts, constructor calls, etc.
+  HoverInfo::PassType PassType;
+  if (const auto *E = N->ASTNode.get()) {
+if (E->getType().isConstQualified())
+  PassType.PassBy = HoverInfo::PassType::ConstRef;
+  }
+
+  for (auto *CastNode = N->Parent;
+   CastNode != OuterNode.Parent && !PassType.Converted;
+   CastNode = CastNode->Parent) {
+if (const auto *ImplicitCast = 

  1   2   >