[PATCH] D91898: [attributes] Add a facility for defining and enforcing a Trusted Computing Base.

2020-11-23 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> if the TCB-based functions are a small subset of the code then this attribute 
> is better

Yes, that's exactly the case. We want most functions to be untrusted by default 
but also have no restrictions imposed or warnings emitted for them when they do 
their usual function things.


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

https://reviews.llvm.org/D91898

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


[PATCH] D92006: Refactoring the attrubute plugin example to fit the new API

2020-11-23 Thread Yafei Liu via Phabricator via cfe-commits
psionic12 created this revision.
psionic12 added reviewers: john.brawn, aaron.ballman, Tyker.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
psionic12 requested review of this revision.

Make the example compiled and the test case passed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92006

Files:
  clang/examples/Attribute/Attribute.cpp
  clang/test/Frontend/plugin-attribute.cpp

Index: clang/test/Frontend/plugin-attribute.cpp
===
--- clang/test/Frontend/plugin-attribute.cpp
+++ clang/test/Frontend/plugin-attribute.cpp
@@ -1,25 +1,23 @@
-// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -S %s -o - 2>&1 | FileCheck %s --check-prefix=ATTRIBUTE
-// RUN: not %clang -fplugin=%llvmshlibdir/Attribute%pluginext -emit-llvm -DBAD_ATTRIBUTE -S %s -o - 2>&1 | FileCheck %s --check-prefix=BADATTRIBUTE
+// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -DGOOD_ATTR -fsyntax-only -Xclang -verify=goodattr %s
+// RUN: %clang -fplugin=%llvmshlibdir/Attribute%pluginext -DBAD_ATTR -fsyntax-only -Xclang -verify=badattr %s
 // REQUIRES: plugins, examples
-
+#ifdef GOOD_ATTR
+// goodattr-no-diagnostics
 void fn1a() __attribute__((example)) { }
 [[example]] void fn1b() { }
 [[plugin::example]] void fn1c() { }
 void fn2() __attribute__((example("somestring"))) { }
-// ATTRIBUTE: warning: 'example' attribute only applies to functions
-int var1 __attribute__((example("otherstring"))) = 1;
-
-// ATTRIBUTE: [[STR1_VAR:@.+]] = private unnamed_addr constant [10 x i8] c"example()\00"
-// ATTRIBUTE: [[STR2_VAR:@.+]] = private unnamed_addr constant [20 x i8] c"example(somestring)\00"
-// ATTRIBUTE: @llvm.global.annotations = {{.*}}@{{.*}}fn1a{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1b{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn1c{{.*}}[[STR1_VAR]]{{.*}}@{{.*}}fn2{{.*}}[[STR2_VAR]]
+#endif
 
-#ifdef BAD_ATTRIBUTE
+#ifdef BAD_ATTR
+// badattr-warning@14 {{'example' attribute only applies to functions}}
+int var1 __attribute__((example("otherstring"))) = 1;
 class Example {
-  // BADATTRIBUTE: error: 'example' attribute only allowed at file scope
+  // badattr-error@17 {{'example' attribute only allowed at file scope}}
   void __attribute__((example)) fn3();
 };
-// BADATTRIBUTE: error: 'example' attribute requires a string
+// badattr-error@20 {{'example's first argument should be a string literal}}
 void fn4() __attribute__((example(123))) { }
-// BADATTRIBUTE: error: 'example' attribute takes no more than 1 argument
-void fn5() __attribute__((example("a","b"))) { }
+// badattr-error@22 {{'example' attribute only allowed at most three arguments}}
+void fn5() __attribute__((example("a","b", 3, 4.0))) { }
 #endif
Index: clang/examples/Attribute/Attribute.cpp
===
--- clang/examples/Attribute/Attribute.cpp
+++ clang/examples/Attribute/Attribute.cpp
@@ -23,9 +23,8 @@
 
 struct ExampleAttrInfo : public ParsedAttrInfo {
   ExampleAttrInfo() {
-// Can take an optional string argument (the check that the argument
-// actually is a string happens in handleDeclAttribute).
-OptArgs = 1;
+// Can take variadic arguments.
+OptArgs = 15;
 // GNU-style __attribute__(("example")) and C++-style [[example]] and
 // [[plugin::example]] supported.
 static constexpr Spelling S[] = {{ParsedAttr::AS_GNU, "example"},
@@ -39,7 +38,7 @@
 // This attribute appertains to functions only.
 if (!isa(D)) {
   S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
-<< Attr << "functions";
+  << Attr << "functions";
   return false;
 }
 return true;
@@ -55,23 +54,31 @@
   S.Diag(Attr.getLoc(), ID);
   return AttributeNotApplied;
 }
-// Check if we have an optional string argument.
-StringRef Str = "";
+// Make sure there are at most three arguments exists
+if (Attr.getNumArgs() > 3) {
+  unsigned ID = S.getDiagnostics().getCustomDiagID(
+  DiagnosticsEngine::Error,
+  "'example' attribute only allowed at most three arguments");
+  S.Diag(Attr.getLoc(), ID);
+  return AttributeNotApplied;
+}
+// If has arguments, the first argument should be a string literal
+Expr *Arg0 = nullptr;
 if (Attr.getNumArgs() > 0) {
-  Expr *ArgExpr = Attr.getArgAsExpr(0);
+  Arg0 = Attr.getArgAsExpr(0);
   StringLiteral *Literal =
-  dyn_cast(ArgExpr->IgnoreParenCasts());
-  if (Literal) {
-Str = Literal->getString();
-  } else {
-S.Diag(ArgExpr->getExprLoc(), diag::err_attribute_argument_type)
-<< Attr.getAttrName() << AANT_ArgumentString;
+  dyn_cast(Arg0->IgnoreParenCasts());
+  if (!Literal) {
+unsigned ID = S.getDiagnostics().getCustomDiagID(
+DiagnosticsEngine::Error,
+"'example's first argument should be a string literal");
+S.Diag(Attr.getLoc(), ID);
   

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

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

this file has never been clang-format clean, happy to make changes if reviewer 
decides they are needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


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

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

It looks like `CallHierarchy.IncomingOneFile` in failing on a few of the 
buildbots (e.g. clang-ppc64be-linux 
 and clang-s390x-linux 
), while passing on most of 
them. I cannot reproduce the failure locally.

Any suggestions for what might be the cause, or how to investigate?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91122

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


[PATCH] D91930: [clangd] Implement textDocument/codeLens

2020-11-23 Thread WangWei via Phabricator via cfe-commits
lightmelodies added a comment.

In D91930#2411338 , @kadircet wrote:

> Thanks a lot for working on improving clangd!
>
> Can you also give a high-level overview of what kind of functionality you are 
> providing here? Looks like there's a lot going on here, and it would be nice 
> to know what you are attempting to do, rather than inferring that from the 
> code. It would also help future travellers, as they can just read the 
> description rather than going through the whole patch.

Thanks for your response. I have updated the summary and add some detailed 
explanation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91930

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


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

2020-11-23 Thread Eugene Leviant via Phabricator via cfe-commits
evgeny777 accepted this revision.
evgeny777 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/D91812/new/

https://reviews.llvm.org/D91812

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


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

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

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

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

I lean toward not adding an option since newer glibc does not have the problem 
(and the new Clang behavior is consistent with GCC).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88712

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


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

2020-11-23 Thread Venkataramanan Kumar via Phabricator via cfe-commits
venkataramanan.kumar.llvm added a comment.

In D88712#2412366 , @MaskRay wrote:

> In D88712#2411841 , 
> @venkataramanan.kumar.llvm wrote:
>
>> 
>
> For your example:
>
>   extern double log (double) asm ("" "log_finite") __attribute__ ((nothrow));
>   
>   double mylog (double d) { return log(d); }
>
> The intention is to emit `log_finite`, no matter the `-ffast-math`. Both GCC 
> and Clang (after this patch) emit `jmp log_finite`.
>
> The previous behavior (according to your comment, with an older glibc) was 
> undesired. So I think the right suggestion is to upgrade glibc.

Then there optimizations like vectorization, inst combine which works on the 
LLVM intrinsics.  But they will be not happening now  with  log_finite calls.  
is it possible to add an option to disable this feature, in case anyone who 
wants to avail these optimization?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88712

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


[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

2020-11-23 Thread Orivej Desh via Phabricator via cfe-commits
orivej added a comment.

Sorry, I don't understand the issue and can't write a better description.
Since this test triggers an assert in getCommonPtr that it "Cannot retrieve a 
NULL type pointer" of Ty->getPointeeType(), the fix just checks that the 
pointee is not null before using isVolatileQualified.


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

https://reviews.llvm.org/D92001

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


[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

2020-11-23 Thread Orivej Desh via Phabricator via cfe-commits
orivej updated this revision to Diff 307239.

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

https://reviews.llvm.org/D92001

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-assume-aligned-crash.c


Index: clang/test/CodeGen/ubsan-assume-aligned-crash.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-assume-aligned-crash.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsanitize=alignment -emit-llvm %s -o /dev/null
+
+/* Testcase for PR45813 - clang crashes checking isVolatileQualified of isNull 
pointee. */
+
+__attribute__((aligned(8))) int data[2];
+
+int* test() {
+return __builtin_assume_aligned(data, 8);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2521,7 +2521,7 @@
 
   // Don't check pointers to volatile data. The behavior here is 
implementation-
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && 
Ty->getPointeeType().isVolatileQualified())
 return;
 
   // We need to temorairly remove the assumption so we can insert the


Index: clang/test/CodeGen/ubsan-assume-aligned-crash.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-assume-aligned-crash.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsanitize=alignment -emit-llvm %s -o /dev/null
+
+/* Testcase for PR45813 - clang crashes checking isVolatileQualified of isNull pointee. */
+
+__attribute__((aligned(8))) int data[2];
+
+int* test() {
+return __builtin_assume_aligned(data, 8);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2521,7 +2521,7 @@
 
   // Don't check pointers to volatile data. The behavior here is implementation-
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && Ty->getPointeeType().isVolatileQualified())
 return;
 
   // We need to temorairly remove the assumption so we can insert the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92001: [ubsan] Fix crash on __builtin_assume_aligned

2020-11-23 Thread Orivej Desh via Phabricator via cfe-commits
orivej created this revision.
orivej added reviewers: lebedev.ri, Tyker, rsmith.
orivej added projects: clang, Sanitizers.
Herald added a subscriber: cfe-commits.
orivej requested review of this revision.

Fixes PR45813


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92001

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-assume-aligned-crash.c


Index: clang/test/CodeGen/ubsan-assume-aligned-crash.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-assume-aligned-crash.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsanitize=alignment -emit-llvm %s -o /dev/null
+
+/* Testcase for PR - clang crashes checking isVolatileQualified of isNull 
pointee. */
+
+__attribute__((aligned(8))) int data[2];
+
+int* test() {
+return __builtin_assume_aligned(data, 8);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2521,7 +2521,7 @@
 
   // Don't check pointers to volatile data. The behavior here is 
implementation-
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && 
Ty->getPointeeType().isVolatileQualified())
 return;
 
   // We need to temorairly remove the assumption so we can insert the


Index: clang/test/CodeGen/ubsan-assume-aligned-crash.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-assume-aligned-crash.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsanitize=alignment -emit-llvm %s -o /dev/null
+
+/* Testcase for PR - clang crashes checking isVolatileQualified of isNull pointee. */
+
+__attribute__((aligned(8))) int data[2];
+
+int* test() {
+return __builtin_assume_aligned(data, 8);
+}
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2521,7 +2521,7 @@
 
   // Don't check pointers to volatile data. The behavior here is implementation-
   // defined.
-  if (Ty->getPointeeType().isVolatileQualified())
+  if (!Ty->getPointeeType().isNull() && Ty->getPointeeType().isVolatileQualified())
 return;
 
   // We need to temorairly remove the assumption so we can insert the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73156: [clang] Build clang-shlib on mingw

2020-11-23 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This actually is done (almost) like this in current git master, see D87547 
 and D89225 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73156

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


[PATCH] D91651: [clang] Add a warning (à la gcc) for too small enum bitfields

2020-11-23 Thread Faisal Vali via Phabricator via cfe-commits
faisalv requested review of this revision.
faisalv marked 4 inline comments as done.
faisalv added a comment.

*ping*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91651

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


[PATCH] D91605: [sanitizers] Implement GetTls on Solaris

2020-11-23 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/tools/driver/CMakeLists.txt:123
+
+check_linker_flag("-Wl,-z,relax=transtls" LINKER_SUPPORTS_Z_RELAX_TRANSTLS)

ro wrote:
> MaskRay wrote:
> > ro wrote:
> > > MaskRay wrote:
> > > > ro wrote:
> > > > > MaskRay wrote:
> > > > > > GNU ld reports a warning instead of an error when an unknown `-z` 
> > > > > > is seen. The warning remains a warning even with `--fatal-warnings`.
> > > > > > GNU ld reports a warning instead of an error when an unknown `-z` 
> > > > > > is seen. The warning remains a warning even with `--fatal-warnings`.
> > > > > 
> > > > > Thanks for reminding me about that misfeature of GNU `ld`.  I guess 
> > > > > `check_linker_flags` needs to be updated to handle that.
> > > > > In the case at hand, it won't matter either way: the flag is only 
> > > > > passed to `ld`, which on Solaris is guaranteed to be the native 
> > > > > linker.  Once (if at all) I get around to completing D85309, I can 
> > > > > deal with that.  For now, other targets won't see linker warnings 
> > > > > about this flag, other than when the flag is used at build time.
> > > > OK. Then I guess you can condition this when the OS is Solaris?
> > > > OK. Then I guess you can condition this when the OS is Solaris?
> > > 
> > > I fear not: `LINKER_SUPPORTS_Z_RELAX_TRANSTLS` is tested inside an `if` 
> > > in `Solaris.cpp`: this code is also compiled on non-Solaris hosts.  Why 
> > > are you worried about the definition being always present?
> > It is not suitable if LINKER_SUPPORTS_Z_RELAX_TRANSTLS returns a wrong 
> > result for GNU ld, even if it is not used for non-Solaris. We should make 
> > the value correct in other configurations.
> > It is not suitable if LINKER_SUPPORTS_Z_RELAX_TRANSTLS returns a wrong 
> > result for GNU ld, even if it is not used for non-Solaris. We should make 
> > the value correct in other configurations.
> 
> Tell the binutils maintainers that ;-)  While I'm still unconcerned about 
> this particular case (it's only used on a Solaris host where `clang` 
> hardcodes the use of `/usr/bin/ld`), I continue to be annoyed by GNU `ld`'s 
> nonsensical (or even outright dangerous) behaviour of accepting every `-z` 
> option.
> 
> It took me some wrestling with `cmake` , but now `check_linker_flag` 
> correctly rejects `-z ` flags where GNU `ld` produces the warning.
> 
> Some caveats about the implementation:
> - `check_cxx_compiler_flag` doesn't support the `FAIL_REGEX` arg, so I had to 
> switch to `check_cxx_source_compiles` instead.
> - While it would be more appropriate to add the linker flag under test to 
> `CMAKE_REQUIRED_LINK_OPTIONS`, that is only present since `cmake` 3.14 while 
> LLVM still only requires 3.13.
> warning: -z.* ignored

Doesn't this stop working if binutils starts to use `error: -z.* ignored`? 
Isn't there a way to call `check_linker_flag` only when the target is Solaris? 
Does `LLVM_LINKER_IS_SOLARISLD` work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91605

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-23 Thread Fangrui Song via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc2fb114475d1: [Driver] Enable getOSLibDir() lib32 workaround 
for SPARC on Linux (authored by glaubitz, committed by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D90524?vs=303846=307233#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/Inputs/debian_8_sparc64_tree/lib/sparc64-linux-gnu/.keep
  clang/test/Driver/Inputs/debian_8_sparc64_tree/lib64/.keep
  clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/include/c++/4.9/.keep
  
clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/include/sparc64-linux-gnu/c++/4.9/.keep
  
clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/4.9/crtbegin.o
  
clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/4.9/crtend.o
  
clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crt1.o
  
clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crti.o
  
clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crtn.o
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/lib/sparc-linux-gnu/.keep
  clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/lib64/.keep
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/include/c++/4.9/backward/.keep
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/include/sparc-linux-gnu/c++/4.9/64/.keep
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/64/crtbegin.o
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/64/crtend.o
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/crtbegin.o
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/crtend.o
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crt1.o
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crti.o
  
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crtn.o
  clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crt1.o
  clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crti.o
  clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crtn.o
  clang/test/Driver/Inputs/debian_multiarch_tree/lib/sparc-linux-gnu/.keep
  clang/test/Driver/Inputs/debian_multiarch_tree/lib/sparc64-linux-gnu/.keep
  
clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/sparc-linux-gnu/.keep
  
clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/sparc64-linux-gnu/.keep
  
clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/sparc-linux-gnu/.keep
  
clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/sparc64-linux-gnu/.keep
  
clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/sparc-linux-gnu/4.5/crtbegin.o
  
clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/sparc64-linux-gnu/4.5/crtbegin.o
  clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/sparc-linux-gnu/.keep
  clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/sparc64-linux-gnu/.keep
  clang/test/Driver/linux-header-search.cpp
  clang/test/Driver/linux-ld.c

Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1282,67 +1282,32 @@
 // CHECK-DEBIAN-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.."
 // CHECK-DEBIAN-MIPS64EL-N32: "-L[[SYSROOT]]/lib"
 // CHECK-DEBIAN-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib"
-//
-// Check linker paths on Debian 8 / Sparc
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
 // RUN: --target=sparc-linux-gnu -rtlib=platform \
 // RUN: --gcc-toolchain="" \
-// RUN: --sysroot=%S/Inputs/debian_8_sparc_multilib_tree \
-// RUN:   | FileCheck --check-prefix=CHECK-DEBIAN-SPARC32 %s
-// CHECK-DEBIAN-SPARC32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-DEBIAN-SPARC32: "[[SYSROOT]]/usr/lib/gcc/sparc-linux-gnu/4.9/../../../sparc-linux-gnu{{/|}}crt1.o"
-// CHECK-DEBIAN-SPARC32: "[[SYSROOT]]/usr/lib/gcc/sparc-linux-gnu/4.9/../../../sparc-linux-gnu{{/|}}crti.o"
-// CHECK-DEBIAN-SPARC32: "[[SYSROOT]]/usr/lib/gcc/sparc-linux-gnu/4.9{{/|}}crtbegin.o"
-// CHECK-DEBIAN-SPARC32: "-L[[SYSROOT]]/usr/lib/gcc/sparc-linux-gnu/4.9"
-// CHECK-DEBIAN-SPARC32: "-L[[SYSROOT]]/usr/lib/gcc/sparc-linux-gnu/4.9/../../../sparc-linux-gnu"
-// CHECK-DEBIAN-SPARC32: "-L[[SYSROOT]]/usr/lib/gcc/sparc-linux-gnu/4.9/../../../../lib"
-// CHECK-DEBIAN-SPARC32: "-L[[SYSROOT]]/lib/sparc-linux-gnu"
-// CHECK-DEBIAN-SPARC32: "-L[[SYSROOT]]/usr/lib/sparc-linux-gnu"
-// CHECK-DEBIAN-SPARC32: "-L[[SYSROOT]]/lib"

[clang] c2fb114 - [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

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

Author: John Paul Adrian Glaubitz
Date: 2020-11-23T19:25:36-08:00
New Revision: c2fb114475d15a1d39545f700b8c6d6e18367ca9

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

LOG: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

This fixes the Builtins-sparc-linux testsuite failures on Linux
SPARC which occur because clang cannot find the 32-bit runtime
libraries when -m32 is passed on the command line. The same
workaround is already being used on X86 and PPC.

Also, switch the CHECK-DEBIAN-SPARC tests to use debian_multiarch_tree
as both sparc and sparc64 are using the MultiArch mechanism on modern Debian
systems the same way as x86_64, powerpc64el and others. Thus, switch the
CHECK-DEBIAN-SPARC32 and CHECK-DEBIAN-SPARC64 tests to use the files from
the debian_multiarch_tree directory for the header and linker path tests.

Finally, rename CHECK-DEBIAN-SPARC32 to CHECK-DEBIAN-SPARC to match the naming
scheme of the Debian MultiArch checks for the other Debian architectures.

Reviewed By: MaskRay, phosek

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

Added: 
clang/test/Driver/Inputs/debian_multiarch_tree/lib/sparc-linux-gnu/.keep
clang/test/Driver/Inputs/debian_multiarch_tree/lib/sparc64-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/sparc-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/sparc64-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/sparc-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/include/sparc64-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/sparc-linux-gnu/4.5/crtbegin.o

clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/sparc64-linux-gnu/4.5/crtbegin.o
clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/sparc-linux-gnu/.keep

clang/test/Driver/Inputs/debian_multiarch_tree/usr/lib/sparc64-linux-gnu/.keep

Modified: 
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-header-search.cpp
clang/test/Driver/linux-ld.c

Removed: 
clang/test/Driver/Inputs/debian_8_sparc64_tree/lib/sparc64-linux-gnu/.keep
clang/test/Driver/Inputs/debian_8_sparc64_tree/lib64/.keep
clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/include/c++/4.9/.keep

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/include/sparc64-linux-gnu/c++/4.9/.keep

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/4.9/crtbegin.o

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/gcc/sparc64-linux-gnu/4.9/crtend.o

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crt1.o

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crti.o

clang/test/Driver/Inputs/debian_8_sparc64_tree/usr/lib/sparc64-linux-gnu/crtn.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/lib/sparc-linux-gnu/.keep
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/lib64/.keep

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/include/c++/4.9/backward/.keep

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/include/sparc-linux-gnu/c++/4.9/64/.keep

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/64/crtbegin.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/64/crtend.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/crtbegin.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/gcc/sparc-linux-gnu/4.9/crtend.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crt1.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crti.o

clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib/sparc-linux-gnu/crtn.o
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crt1.o
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crti.o
clang/test/Driver/Inputs/debian_8_sparc_multilib_tree/usr/lib64/crtn.o



diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 180350476c38..c2e21159b316 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -185,17 +185,18 @@ static StringRef getOSLibDir(const llvm::Triple , 
const ArgList ) {
 return Triple.isArch32Bit() ? "lib" : "lib64";
   }
 
-  // It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and
-  // using that variant while targeting other architectures causes problems
-  // because the libraries are laid out in shared system roots that can't cope
-  // with a 'lib32' 

[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-23 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: clang/test/Driver/linux-header-search.cpp:266
+// CHECK-DEBIAN-SPARC: "{{[^"]*}}clang{{[^"]*}}" "-cc1"
+// CHECK-DEBIAN-SPARC: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
+// CHECK-DEBIAN-SPARC: "-isysroot" "[[SYSROOT:[^"]+]]"

I'll add some -SAME directives because that helps FileCheck to provide a 
friendly error message when things go off.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[libunwind] bb13411 - [libunwind] Multiple preprocessor fixes on PowerPC*

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

Author: Brandon Bergren
Date: 2020-11-23T19:07:21-08:00
New Revision: bb1341161478dc589893cda9f808e5f5b859b5ae

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

LOG: [libunwind] Multiple preprocessor fixes on PowerPC*

* Remove misnamed `PPC64_HAS_VMX` in preference of directly checking 
`defined(__VSX__)`.

libunwind was using "VMX" to mean "VSX". "VMX" is just another name for 
Altivec, while "VSX" is the vector-scalar extensions first used in POWER7. 
Exposing a "PPC64_HAS_VMX" define was misleading and incorrect.

* Add `defined(__ALTIVEC__)` guards around vector register operations to fix 
non-altivec CPUS such as the e5500.

When compiling for certain Book-E processors such as the e5500, we want to skip 
vector save/restore, as the Altivec registers are illegal on non-Altivec 
implementations.

* Add `!defined(__NO_FPRS__)` guards around traditional floating-point 
save/restore.

When compiling for powerpcspe, we cannot access floating point registers, as 
there aren't any. (The SPE on e500v2 is a 64-bit extension of the GPRs, and it 
doesn't have the normal floating-point registers at all.)
This fixes building for powerpcspe, although no actual handling for SPE 
save/restore is written yet.

Reviewed By: MaskRay, #libunwind, compnerd

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

Added: 


Modified: 
libunwind/src/Registers.hpp
libunwind/src/UnwindRegistersRestore.S
libunwind/src/UnwindRegistersSave.S
libunwind/src/assembly.h
libunwind/src/config.h

Removed: 




diff  --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index 4d963b4156d1..e0cb84f00e7f 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -1514,12 +1514,12 @@ inline void Registers_ppc64::setFloatRegister(int 
regNum, double value) {
 }
 
 inline bool Registers_ppc64::validVectorRegister(int regNum) const {
-#ifdef PPC64_HAS_VMX
+#if defined(__VSX__)
   if (regNum >= UNW_PPC64_VS0 && regNum <= UNW_PPC64_VS31)
 return true;
   if (regNum >= UNW_PPC64_VS32 && regNum <= UNW_PPC64_VS63)
 return true;
-#else
+#elif defined(__ALTIVEC__)
   if (regNum >= UNW_PPC64_V0 && regNum <= UNW_PPC64_V31)
 return true;
 #endif

diff  --git a/libunwind/src/UnwindRegistersRestore.S 
b/libunwind/src/UnwindRegistersRestore.S
index d817e6dae948..289afe98b0b2 100644
--- a/libunwind/src/UnwindRegistersRestore.S
+++ b/libunwind/src/UnwindRegistersRestore.S
@@ -170,7 +170,7 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind15Registers_ppc646jumptoEv)
   PPC64_LR(30)
   PPC64_LR(31)
 
-#ifdef PPC64_HAS_VMX
+#if defined(__VSX__)
 
   // restore VS registers
   // (note that this also restores floating point registers and V registers,
@@ -312,6 +312,7 @@ PPC64_CLVS_BOTTOM(n)
   PPC64_LF(30)
   PPC64_LF(31)
 
+#if defined(__ALTIVEC__)
   // restore vector registers if any are in use
   ld%r5, PPC64_OFFS_VRSAVE(%r3)   // test VRsave
   cmpwi %r5, 0
@@ -373,6 +374,7 @@ PPC64_CLV_UNALIGNED_BOTTOM(n)
   PPC64_CLV_UNALIGNEDh(31)
 
 #endif
+#endif
 
 Lnovec:
   ld%r0, PPC64_OFFS_CR(%r3)
@@ -431,6 +433,7 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
   lwz %r30,128(%r3)
   lwz %r31,132(%r3)
 
+#ifndef __NO_FPRS__
   // restore float registers
   lfd %f0, 160(%r3)
   lfd %f1, 168(%r3)
@@ -464,7 +467,9 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
   lfd %f29,392(%r3)
   lfd %f30,400(%r3)
   lfd %f31,408(%r3)
+#endif
 
+#if defined(__ALTIVEC__)
   // restore vector registers if any are in use
   lwz %r5, 156(%r3)   // test VRsave
   cmpwi   %r5, 0
@@ -537,6 +542,7 @@ 
DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
   LOAD_VECTOR_UNALIGNEDh(29)
   LOAD_VECTOR_UNALIGNEDh(30)
   LOAD_VECTOR_UNALIGNEDh(31)
+#endif
 
 Lnovec:
   lwz %r0, 136(%r3)   // __cr

diff  --git a/libunwind/src/UnwindRegistersSave.S 
b/libunwind/src/UnwindRegistersSave.S
index 51bb9b0688fd..94fc8365455d 100644
--- a/libunwind/src/UnwindRegistersSave.S
+++ b/libunwind/src/UnwindRegistersSave.S
@@ -384,7 +384,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   mfvrsave%r0
   std   %r0,  PPC64_OFFS_VRSAVE(%r3)
 
-#ifdef PPC64_HAS_VMX
+#if defined(__VSX__)
   // save VS registers
   // (note that this also saves floating point registers and V registers,
   // because part of VS is mapped to these registers)
@@ -501,6 +501,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   PPC64_STF(30)
   PPC64_STF(31)
 
+#if defined(__ALTIVEC__)
   // save vector registers
 
   // Use 16-bytes below the stack pointer as an
@@ -548,6 +549,7 @@ DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
   PPC64_STV_UNALIGNED(30)
   PPC64_STV_UNALIGNED(31)
 
+#endif
 #endif
 
   li%r3,  0   // return UNW_ESUCCESS
@@ -608,6 

[PATCH] D91895: [Clang] improve -Wimplicit-fallthrough GCC compat

2020-11-23 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I'd suggest instead of removing these warnings, we split the warning flag in 
two:

1. A warning flag that warns that there is implicit fallthrough that's not 
equivalent to `break;` (which sounds like it's what the kernel folks want in 
the 99% case) -- that is, warn if the language rule "if execution from one case 
label reaches a case label attached to a different statement, an implicit 
`break` is evaluated" could give different program behavior.
2. A warning flag that warns that there is implicit fallthrough at all (a 
superset of (1), and the same as our current warning flag) -- that is, warn if 
control flow from one case label is able to fall through a case label attached 
to a different statement.

The linux kernel folks aren't the only users of this facility, and some other 
users will want an explicit `break;` even before a set of `case` labels that 
themselves label a `break;`, and will want that enforced by warning. I'd also 
suggest that we retain our existing warning flag for (2) and add a new warning 
flag for the subset behavior of (1).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91895

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


[PATCH] D91895: [Clang] improve -Wimplicit-fallthrough GCC compat

2020-11-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

I'm happy to modify the patch based on feedback from LKML, though

  switch (x) {
case 0:
  ++x;
default:
  break;
  }

is the important case that's 99% of the differences between GCC and Clang, 
which should not get removed from this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91895

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


[PATCH] D86097: [OpenMP][AMDGCN] Generate global variables and attributes for AMDGCN

2020-11-23 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:1344
 
+FieldDecl *clang::CodeGen::CodeGenUtil::CodeGenUtil::addFieldToRecordDecl(
+ASTContext , DeclContext *DC, QualType FieldTy) {

This appears to be the same as the free function we had before, except now all 
the call sites are prefixed CodegenUtil. Is there a functional change I'm 
missing?

The rest of this patch would be easier to read with this part split off.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:77
+
+void CGOpenMPRuntimeAMDGCN::emitNonSPMDKernelWrapper(
+const OMPExecutableDirective , StringRef ParentName,

This is a very verbose way to say that amdgcn calls emitmetatdata at the end of 
emitkernel and nvptx doesn't. Suggest unconditionally calling emitmetatdata, 
and having emitmetatdata be a no-op for nvptx.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:89
+//
+void CGOpenMPRuntimeAMDGCN::setPropertyWorkGroupSize(CodeGenModule ,
+ StringRef Name,

I think there's a credible chance this is useful to nvptx, so doesn't have to 
be amdgcn specific



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:108
+  bool FlatAttrEmitted = false;
+  unsigned DefaultWorkGroupSz =
+  CGM.getTarget().getGridValue(llvm::omp::GVIDX::GV_Default_WG_Size);

I think this is about computing a maximum workgroup size which the runtime uses 
to limit the number of threads it launches. If so, this is probably useful for 
nvptx and amdgcn. I'm having trouble working out what the conditions are 
though. Maybe it's based on an openmp clause?



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:150
+  // emit amdgpu-flat-work-group-size if not emitted already.
+  if (!FlatAttrEmitted) {
+std::string FlatAttrVal = llvm::utostr(DefaultWorkGroupSz);

I think I remember seeing a diff that makes this attribute unconditionally 
emitted by some other part of the toolchain. If so, it may no longer be required



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp:169
+  // Create all device images
+  llvm::Constant *AttrData[] = {
+  llvm::ConstantInt::get(CGM.Int16Ty, 2), // Version

HostServices is unused. Mode is redundant with exec_mode. wg_size is redundant 
with the other wg_size symbol added above. This kern_desc object should be 
deleted, not upstreamed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86097

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


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

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

This is needed for call hierarchy to be able to find callers of
main-file-only functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92000

Files:
  clang-tools-extra/clangd/index/Background.h
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/tool/ClangdMain.cpp
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -694,6 +694,7 @@
   class d {};
   )");
   CollectorOpts.RefFilter = RefKind::All;
+  CollectorOpts.CollectMainFileRefs = false;
   CollectorOpts.CollectMacro = true;
   runSymbolCollector(Header.code(),
  (Main.code() + SymbolsOnlyInMainCode.code()).str());
@@ -753,7 +754,6 @@
 }
   )cpp");
   CollectorOpts.RefFilter = RefKind::All;
-  CollectorOpts.CollectMainFileRefs = true;
   runSymbolCollector("", Code.code());
   auto FindRefWithRange = [&](Range R) -> Optional {
 for (auto  : Refs) {
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -201,7 +201,7 @@
   EXPECT_THAT(runFuzzyFind(Idx, ""),
   UnorderedElementsAre(AllOf(Named("common"), NumReferences(1U)),
AllOf(Named("A_CC"), NumReferences(0U)),
-   AllOf(Named("g"), NumReferences(0U)),
+   AllOf(Named("g"), NumReferences(1U)),
AllOf(Named("f_b"), Declared(),
  Not(Defined()), NumReferences(0U;
 
@@ -214,7 +214,7 @@
   EXPECT_THAT(runFuzzyFind(Idx, ""),
   UnorderedElementsAre(AllOf(Named("common"), NumReferences(5U)),
AllOf(Named("A_CC"), NumReferences(0U)),
-   AllOf(Named("g"), NumReferences(0U)),
+   AllOf(Named("g"), NumReferences(1U)),
AllOf(Named("f_b"), Declared(), Defined(),
  NumReferences(1U;
 
@@ -238,14 +238,16 @@
   FS.Files[testPath("root/A.cc")] =
   "#include \"A.h\"\nstatic void main_sym() { (void)header_sym; }";
 
-  // Check the behaviour with CollectMainFileRefs = false (the default).
+  // Check the behaviour with CollectMainFileRefs = false.
   {
 llvm::StringMap Storage;
 size_t CacheHits = 0;
 MemoryShardStorage MSS(Storage, CacheHits);
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex Idx(FS, CDB, [&](llvm::StringRef) { return  },
-/*Opts=*/{});
+BackgroundIndex::Options Opts;
+Opts.CollectMainFileRefs = false;
+BackgroundIndex Idx(
+FS, CDB, [&](llvm::StringRef) { return  }, Opts);
 
 tooling::CompileCommand Cmd;
 Cmd.Filename = testPath("root/A.cc");
@@ -260,16 +262,14 @@
  AllOf(Named("main_sym"), NumReferences(0U;
   }
 
-  // Check the behaviour with CollectMainFileRefs = true.
+  // Check the behaviour with CollectMainFileRefs = true (the default).
   {
 llvm::StringMap Storage;
 size_t CacheHits = 0;
 MemoryShardStorage MSS(Storage, CacheHits);
 OverlayCDB CDB(/*Base=*/nullptr);
-BackgroundIndex::Options Opts;
-Opts.CollectMainFileRefs = true;
-BackgroundIndex Idx(
-FS, CDB, [&](llvm::StringRef) { return  }, Opts);
+BackgroundIndex Idx(FS, CDB, [&](llvm::StringRef) { return  },
+/*Opts=*/{});
 
 tooling::CompileCommand Cmd;
 Cmd.Filename = testPath("root/A.cc");
Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -489,7 +489,7 @@
 "collect-main-file-refs",
 cat(Misc),
 desc("Store references to main-file-only symbols in the index"),
-init(false),
+init(true),
 };
 
 #if CLANGD_ENABLE_REMOTE
Index: clang-tools-extra/clangd/index/SymbolCollector.h
===
--- clang-tools-extra/clangd/index/SymbolCollector.h
+++ clang-tools-extra/clangd/index/SymbolCollector.h
@@ -79,7 +79,7 @@
 /// and symbols 

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

2020-11-23 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 307229.
njames93 added a comment.

Added PathRef to TidyProvider, this handles finding clang-tidy files when the 
compile command directory isn't the project root.
Use elog for reporting errors instead of `llvm::errs` - It was an artefact from 
the code in ClangTidyOptions.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91029

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

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

[PATCH] D91941: [clangd] Use WorkScheduler.run() in ClangdServer::resolveTypeHierarchy()

2020-11-23 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdced150375d0: [clangd] Use WorkScheduler.run() in 
ClangdServer::resolveTypeHierarchy() (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91941

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


Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -674,8 +674,11 @@
 void ClangdServer::resolveTypeHierarchy(
 TypeHierarchyItem Item, int Resolve, TypeHierarchyDirection Direction,
 Callback> CB) {
-  clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
-  CB(Item);
+  WorkScheduler.run(
+  "Resolve Type Hierarchy", "", [=, CB = std::move(CB)]() mutable {
+clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
+CB(Item);
+  });
 }
 
 void ClangdServer::prepareCallHierarchy(


Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -674,8 +674,11 @@
 void ClangdServer::resolveTypeHierarchy(
 TypeHierarchyItem Item, int Resolve, TypeHierarchyDirection Direction,
 Callback> CB) {
-  clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
-  CB(Item);
+  WorkScheduler.run(
+  "Resolve Type Hierarchy", "", [=, CB = std::move(CB)]() mutable {
+clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
+CB(Item);
+  });
 }
 
 void ClangdServer::prepareCallHierarchy(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91124: [clangd] Call hierarchy (ClangdLSPServer layer)

2020-11-23 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a4f99c494d0: [clangd] Call hierarchy (ClangdLSPServer 
layer) (authored by nridge).

Changed prior to commit:
  https://reviews.llvm.org/D91124?vs=306954=307226#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91124

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/test/call-hierarchy.test
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -37,6 +37,8 @@
   LSPTest() : LogSession(*this) {
 ClangdServer::Options  = Opts;
 Base = ClangdServer::optsForTest();
+// This is needed to we can test index-based operations like call hierarchy.
+Base.BuildDynamicSymbolIndex = true;
   }
 
   LSPClient () {
@@ -165,6 +167,33 @@
   stop();
   EXPECT_THAT(Tracer.takeMetric("lsp_latency", MethodName), testing::SizeIs(1));
 }
+
+TEST_F(LSPTest, IncomingCalls) {
+  Annotations Code(R"cpp(
+void calle^e(int);
+void caller1() {
+  [[callee]](42);
+}
+  )cpp");
+  auto  = start();
+  Client.didOpen("foo.cpp", Code.code());
+  auto Items = Client
+   .call("textDocument/prepareCallHierarchy",
+ llvm::json::Object{
+ {"textDocument", Client.documentID("foo.cpp")},
+ {"position", Code.point()}})
+   .takeValue();
+  auto FirstItem = (*Items.getAsArray())[0];
+  auto Calls = Client
+   .call("callHierarchy/incomingCalls",
+ llvm::json::Object{{"item", FirstItem}})
+   .takeValue();
+  auto FirstCall = *(*Calls.getAsArray())[0].getAsObject();
+  EXPECT_EQ(FirstCall["fromRanges"], llvm::json::Value{Code.range()});
+  auto From = *FirstCall["from"].getAsObject();
+  EXPECT_EQ(From["name"], "caller1");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -6,6 +6,7 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"capabilities": {
 # CHECK-NEXT:  "astProvider": true,
+# CHECK-NEXT:  "callHierarchyProvider": true,
 # CHECK-NEXT:  "codeActionProvider": true,
 # CHECK-NEXT:  "completionProvider": {
 # CHECK-NEXT:"allCommitCharacters": [
Index: clang-tools-extra/clangd/test/call-hierarchy.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/call-hierarchy.test
@@ -0,0 +1,39 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"void callee(int);\nvoid caller1() {\n  callee(42);\n}\nvoid caller2() {\n  caller1();\n  caller1();\n}\nvoid caller3() {\n  caller1();\n  caller2();\n}\n","uri":"test:///main.cpp","version":1}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/prepareCallHierarchy","params":{"position":{"character":8,"line":0},"textDocument":{"uri":"test:///main.cpp"}}}
+#  CHECK:  "id": 1,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": [
+# CHECK-NEXT:{
+# CHECK-NEXT:  "data": "{{.*}}",
+# CHECK-NEXT:  "kind": 12,
+# CHECK-NEXT:  "name": "callee",
+# CHECK-NEXT:  "range": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 16,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 0,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:}
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "selectionRange": {
+# CHECK-NEXT:"end": {
+# CHECK-NEXT:  "character": 11,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:},
+# CHECK-NEXT:"start": {
+# CHECK-NEXT:  "character": 5,
+# CHECK-NEXT:  "line": 0
+# CHECK-NEXT:}
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "uri": "file://{{.*}}/clangd-test/main.cpp"
+# CHECK-NEXT:}
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
Index: clang-tools-extra/clangd/ClangdLSPServer.h
===
--- 

[PATCH] D91123: [clangd] Call hierarchy (ClangdServer layer)

2020-11-23 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4cb976e014db: [clangd] Call hierarchy (ClangdServer layer) 
(authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91123

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -242,6 +242,14 @@
 TypeHierarchyDirection Direction,
 Callback> CB);
 
+  /// Get information about call hierarchy for a given position.
+  void prepareCallHierarchy(PathRef File, Position Pos,
+Callback> CB);
+
+  /// Resolve incoming calls for a given call hierarchy item.
+  void incomingCalls(const CallHierarchyItem ,
+ Callback>);
+
   /// Retrieve the top symbols from the workspace matching a query.
   void workspaceSymbols(StringRef Query, int Limit,
 Callback> CB);
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -678,6 +678,26 @@
   CB(Item);
 }
 
+void ClangdServer::prepareCallHierarchy(
+PathRef File, Position Pos, Callback> CB) {
+  auto Action = [File = File.str(), Pos,
+ CB = std::move(CB)](Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::prepareCallHierarchy(InpAST->AST, Pos, File));
+  };
+  WorkScheduler.runWithAST("Call Hierarchy", File, std::move(Action));
+}
+
+void ClangdServer::incomingCalls(
+const CallHierarchyItem ,
+Callback> CB) {
+  WorkScheduler.run("Incoming Calls", "",
+[CB = std::move(CB), Item, this]() mutable {
+  CB(clangd::incomingCalls(Item, Index));
+});
+}
+
 void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams ) {
   // FIXME: Do nothing for now. This will be used for indexing and potentially
   // invalidating other caches.


Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -242,6 +242,14 @@
 TypeHierarchyDirection Direction,
 Callback> CB);
 
+  /// Get information about call hierarchy for a given position.
+  void prepareCallHierarchy(PathRef File, Position Pos,
+Callback> CB);
+
+  /// Resolve incoming calls for a given call hierarchy item.
+  void incomingCalls(const CallHierarchyItem ,
+ Callback>);
+
   /// Retrieve the top symbols from the workspace matching a query.
   void workspaceSymbols(StringRef Query, int Limit,
 Callback> CB);
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -678,6 +678,26 @@
   CB(Item);
 }
 
+void ClangdServer::prepareCallHierarchy(
+PathRef File, Position Pos, Callback> CB) {
+  auto Action = [File = File.str(), Pos,
+ CB = std::move(CB)](Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::prepareCallHierarchy(InpAST->AST, Pos, File));
+  };
+  WorkScheduler.runWithAST("Call Hierarchy", File, std::move(Action));
+}
+
+void ClangdServer::incomingCalls(
+const CallHierarchyItem ,
+Callback> CB) {
+  WorkScheduler.run("Incoming Calls", "",
+[CB = std::move(CB), Item, this]() mutable {
+  CB(clangd::incomingCalls(Item, Index));
+});
+}
+
 void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams ) {
   // FIXME: Do nothing for now. This will be used for indexing and potentially
   // invalidating other caches.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2020-11-23 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3e6e6a2db674: [clangd] Call hierarchy (XRefs layer, incoming 
calls) (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91122

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -156,7 +156,8 @@
 
 std::unique_ptr TestTU::index() const {
   auto AST = build();
-  auto Idx = std::make_unique(/*UseDex=*/true);
+  auto Idx = std::make_unique(/*UseDex=*/true,
+ /*CollectMainFileRefs=*/true);
   Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
   AST.getASTContext(), AST.getPreprocessorPtr(),
   AST.getCanonicalIncludes());
Index: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -0,0 +1,256 @@
+//===-- CallHierarchyTests.cpp  ---*- C++ -*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "Annotations.h"
+#include "Compiler.h"
+#include "Matchers.h"
+#include "ParsedAST.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "TestTU.h"
+#include "TestWorkspace.h"
+#include "XRefs.h"
+#include "index/FileIndex.h"
+#include "index/SymbolCollector.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Index/IndexingAction.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using ::testing::AllOf;
+using ::testing::ElementsAre;
+using ::testing::Field;
+using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
+
+// Helpers for matching call hierarchy data structures.
+MATCHER_P(WithName, N, "") { return arg.name == N; }
+MATCHER_P(WithSelectionRange, R, "") { return arg.selectionRange == R; }
+
+template 
+::testing::Matcher From(ItemMatcher M) {
+  return Field(::from, M);
+}
+template 
+::testing::Matcher FromRanges(RangeMatchers... M) {
+  return Field(::fromRanges,
+   UnorderedElementsAre(M...));
+}
+
+TEST(CallHierarchy, IncomingOneFile) {
+  Annotations Source(R"cpp(
+void call^ee(int);
+void caller1() {
+  $Callee[[callee]](42);
+}
+void caller2() {
+  $Caller1A[[caller1]]();
+  $Caller1B[[caller1]]();
+}
+void caller3() {
+  $Caller1C[[caller1]]();
+  $Caller2[[caller2]]();
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+
+  std::vector Items =
+  prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
+  EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+  auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
+  EXPECT_THAT(IncomingLevel1,
+  ElementsAre(AllOf(From(WithName("caller1")),
+FromRanges(Source.range("Callee");
+
+  auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel2, UnorderedElementsAre(
+  AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1A"),
+   Source.range("Caller1B"))),
+  AllOf(From(WithName("caller3")),
+FromRanges(Source.range("Caller1C");
+
+  auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel3,
+  ElementsAre(AllOf(From(WithName("caller3")),
+FromRanges(Source.range("Caller2");
+
+  auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel4, ElementsAre());
+}
+
+TEST(CallHierarchy, MainFileOnlyRef) {
+  // In addition to testing that we store refs to main-file only symbols,
+  // this tests that anonymous namespaces do not interfere with the
+  // symbol re-identification process in callHierarchyItemToSymbo().
+  Annotations 

[clang-tools-extra] dced150 - [clangd] Use WorkScheduler.run() in ClangdServer::resolveTypeHierarchy()

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

Author: Nathan Ridge
Date: 2020-11-23T20:44:14-05:00
New Revision: dced150375d09df6266448342fbb066d638b59ef

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

LOG: [clangd] Use WorkScheduler.run() in ClangdServer::resolveTypeHierarchy()

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 523931d9cc7b..502078c776db 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -674,8 +674,11 @@ void ClangdServer::typeHierarchy(PathRef File, Position 
Pos, int Resolve,
 void ClangdServer::resolveTypeHierarchy(
 TypeHierarchyItem Item, int Resolve, TypeHierarchyDirection Direction,
 Callback> CB) {
-  clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
-  CB(Item);
+  WorkScheduler.run(
+  "Resolve Type Hierarchy", "", [=, CB = std::move(CB)]() mutable {
+clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
+CB(Item);
+  });
 }
 
 void ClangdServer::prepareCallHierarchy(



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


[clang-tools-extra] 0a4f99c - [clangd] Call hierarchy (ClangdLSPServer layer)

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

Author: Nathan Ridge
Date: 2020-11-23T20:44:07-05:00
New Revision: 0a4f99c494d007a21652b1b3939bde4753042c33

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

LOG: [clangd] Call hierarchy (ClangdLSPServer layer)

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

Added: 
clang-tools-extra/clangd/test/call-hierarchy.test

Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 335a6fc9ad94..66dee68ec474 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -625,6 +625,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
,
  }},
 {"typeHierarchyProvider", true},
 {"memoryUsageProvider", true}, // clangd extension.
+{"callHierarchyProvider", true},
 ;
   if (Opts.Encoding)
 Result["offsetEncoding"] = *Opts.Encoding;
@@ -1224,6 +1225,26 @@ void ClangdLSPServer::onResolveTypeHierarchy(
std::move(Reply));
 }
 
+void ClangdLSPServer::onPrepareCallHierarchy(
+const CallHierarchyPrepareParams ,
+Callback> Reply) {
+  Server->prepareCallHierarchy(Params.textDocument.uri.file(), Params.position,
+   std::move(Reply));
+}
+
+void ClangdLSPServer::onCallHierarchyIncomingCalls(
+const CallHierarchyIncomingCallsParams ,
+Callback> Reply) {
+  Server->incomingCalls(Params.item, std::move(Reply));
+}
+
+void ClangdLSPServer::onCallHierarchyOutgoingCalls(
+const CallHierarchyOutgoingCallsParams ,
+Callback> Reply) {
+  // FIXME: To be implemented.
+  Reply(std::vector{});
+}
+
 void ClangdLSPServer::applyConfiguration(
 const ConfigurationSettings ) {
   // Per-file update to the compilation database.
@@ -1468,6 +1489,9 @@ ClangdLSPServer::ClangdLSPServer(class Transport ,
   MsgHandler->bind("textDocument/symbolInfo", ::onSymbolInfo);
   MsgHandler->bind("textDocument/typeHierarchy", 
::onTypeHierarchy);
   MsgHandler->bind("typeHierarchy/resolve", 
::onResolveTypeHierarchy);
+  MsgHandler->bind("textDocument/prepareCallHierarchy", 
::onPrepareCallHierarchy);
+  MsgHandler->bind("callHierarchy/incomingCalls", 
::onCallHierarchyIncomingCalls);
+  MsgHandler->bind("callHierarchy/outgoingCalls", 
::onCallHierarchyOutgoingCalls);
   MsgHandler->bind("textDocument/selectionRange", 
::onSelectionRange);
   MsgHandler->bind("textDocument/documentLink", 
::onDocumentLink);
   MsgHandler->bind("textDocument/semanticTokens/full", 
::onSemanticTokens);

diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.h 
b/clang-tools-extra/clangd/ClangdLSPServer.h
index 4d568bc13d8b..e65fc0e8a006 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.h
+++ b/clang-tools-extra/clangd/ClangdLSPServer.h
@@ -135,6 +135,14 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
Callback>);
   void onResolveTypeHierarchy(const ResolveTypeHierarchyItemParams &,
   Callback>);
+  void onPrepareCallHierarchy(const CallHierarchyPrepareParams &,
+  Callback>);
+  void onCallHierarchyIncomingCalls(
+  const CallHierarchyIncomingCallsParams &,
+  Callback>);
+  void onCallHierarchyOutgoingCalls(
+  const CallHierarchyOutgoingCallsParams &,
+  Callback>);
   void onChangeConfiguration(const DidChangeConfigurationParams &);
   void onSymbolInfo(const TextDocumentPositionParams &,
 Callback>);

diff  --git a/clang-tools-extra/clangd/test/call-hierarchy.test 
b/clang-tools-extra/clangd/test/call-hierarchy.test
new file mode 100644
index ..6548ea0068a8
--- /dev/null
+++ b/clang-tools-extra/clangd/test/call-hierarchy.test
@@ -0,0 +1,39 @@
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"void
 callee(int);\nvoid caller1() {\n  callee(42);\n}\nvoid caller2() {\n  
caller1();\n  caller1();\n}\nvoid caller3() {\n  caller1();\n  
caller2();\n}\n","uri":"test:///main.cpp","version":1}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/prepareCallHierarchy","params":{"position":{"character":8,"line":0},"textDocument":{"uri":"test:///main.cpp"}}}
+#  CHECK:  "id": 1,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": [
+# CHECK-NEXT:{

[clang-tools-extra] 4cb976e - [clangd] Call hierarchy (ClangdServer layer)

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

Author: Nathan Ridge
Date: 2020-11-23T20:43:41-05:00
New Revision: 4cb976e014db80efd20dfca45ba218c3a69aac42

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

LOG: [clangd] Call hierarchy (ClangdServer layer)

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.cpp
clang-tools-extra/clangd/ClangdServer.h

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 889d2cbcf280..523931d9cc7b 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -678,6 +678,26 @@ void ClangdServer::resolveTypeHierarchy(
   CB(Item);
 }
 
+void ClangdServer::prepareCallHierarchy(
+PathRef File, Position Pos, Callback> CB) {
+  auto Action = [File = File.str(), Pos,
+ CB = std::move(CB)](Expected InpAST) mutable {
+if (!InpAST)
+  return CB(InpAST.takeError());
+CB(clangd::prepareCallHierarchy(InpAST->AST, Pos, File));
+  };
+  WorkScheduler.runWithAST("Call Hierarchy", File, std::move(Action));
+}
+
+void ClangdServer::incomingCalls(
+const CallHierarchyItem ,
+Callback> CB) {
+  WorkScheduler.run("Incoming Calls", "",
+[CB = std::move(CB), Item, this]() mutable {
+  CB(clangd::incomingCalls(Item, Index));
+});
+}
+
 void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams ) {
   // FIXME: Do nothing for now. This will be used for indexing and potentially
   // invalidating other caches.

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 1ccb4c5899f8..18c35e701e5b 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -242,6 +242,14 @@ class ClangdServer {
 TypeHierarchyDirection Direction,
 Callback> CB);
 
+  /// Get information about call hierarchy for a given position.
+  void prepareCallHierarchy(PathRef File, Position Pos,
+Callback> CB);
+
+  /// Resolve incoming calls for a given call hierarchy item.
+  void incomingCalls(const CallHierarchyItem ,
+ Callback>);
+
   /// Retrieve the top symbols from the workspace matching a query.
   void workspaceSymbols(StringRef Query, int Limit,
 Callback> CB);



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


[clang-tools-extra] 3e6e6a2 - [clangd] Call hierarchy (XRefs layer, incoming calls)

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

Author: Nathan Ridge
Date: 2020-11-23T20:43:38-05:00
New Revision: 3e6e6a2db674cd85b33c06b75685c6bce5acb154

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

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

Support for outgoing calls is left for a future change.

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

Added: 
clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp

Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/XRefs.h
clang-tools-extra/clangd/unittests/CMakeLists.txt
clang-tools-extra/clangd/unittests/TestTU.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 0cd8695da92d..e319636f9076 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -47,6 +47,7 @@
 #include "clang/Index/USRGeneration.h"
 #include "clang/Tooling/Syntax/Tokens.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
@@ -1339,9 +1340,9 @@ llvm::raw_ostream <<(llvm::raw_ostream , 
const LocatedSymbol ) {
   return OS;
 }
 
-// FIXME(nridge): Reduce duplication between this function and declToSym().
-static llvm::Optional
-declToTypeHierarchyItem(ASTContext , const NamedDecl ) {
+template 
+static llvm::Optional declToHierarchyItem(const NamedDecl ) {
+  ASTContext  = ND.getASTContext();
   auto  = Ctx.getSourceManager();
   SourceLocation NameLoc = nameLocation(ND, Ctx.getSourceManager());
   SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
@@ -1365,54 +1366,84 @@ declToTypeHierarchyItem(ASTContext , const 
NamedDecl ) {
   // correctly.
   SymbolKind SK = indexSymbolKindToSymbolKind(SymInfo.Kind);
 
-  TypeHierarchyItem THI;
-  THI.name = printName(Ctx, ND);
-  THI.kind = SK;
-  THI.deprecated = ND.isDeprecated();
-  THI.range = Range{sourceLocToPosition(SM, DeclRange->getBegin()),
-sourceLocToPosition(SM, DeclRange->getEnd())};
-  THI.selectionRange = Range{NameBegin, NameEnd};
-  if (!THI.range.contains(THI.selectionRange)) {
+  HierarchyItem HI;
+  HI.name = printName(Ctx, ND);
+  HI.kind = SK;
+  HI.range = Range{sourceLocToPosition(SM, DeclRange->getBegin()),
+   sourceLocToPosition(SM, DeclRange->getEnd())};
+  HI.selectionRange = Range{NameBegin, NameEnd};
+  if (!HI.range.contains(HI.selectionRange)) {
 // 'selectionRange' must be contained in 'range', so in cases where clang
 // reports unrelated ranges we need to reconcile somehow.
-THI.range = THI.selectionRange;
+HI.range = HI.selectionRange;
   }
 
-  THI.uri = URIForFile::canonicalize(*FilePath, *TUPath);
+  HI.uri = URIForFile::canonicalize(*FilePath, *TUPath);
 
   // Compute the SymbolID and store it in the 'data' field.
   // This allows typeHierarchy/resolve to be used to
   // resolve children of items returned in a previous request
   // for parents.
   if (auto ID = getSymbolID())
-THI.data = ID.str();
+HI.data = ID.str();
+
+  return HI;
+}
 
-  return THI;
+static llvm::Optional
+declToTypeHierarchyItem(const NamedDecl ) {
+  auto Result = declToHierarchyItem(ND);
+  if (Result)
+Result->deprecated = ND.isDeprecated();
+  return Result;
 }
 
-static Optional
-symbolToTypeHierarchyItem(const Symbol , const SymbolIndex *Index,
-  PathRef TUPath) {
+static llvm::Optional
+declToCallHierarchyItem(const NamedDecl ) {
+  auto Result = declToHierarchyItem(ND);
+  if (Result && ND.isDeprecated())
+Result->tags.push_back(SymbolTag::Deprecated);
+  return Result;
+}
+
+template 
+static llvm::Optional symbolToHierarchyItem(const Symbol ,
+   PathRef TUPath) {
   auto Loc = symbolToLocation(S, TUPath);
   if (!Loc) {
-log("Type hierarchy: {0}", Loc.takeError());
+elog("Failed to convert symbol to hierarchy item: {0}", Loc.takeError());
 return llvm::None;
   }
-  TypeHierarchyItem THI;
-  THI.name = std::string(S.Name);
-  THI.kind = indexSymbolKindToSymbolKind(S.SymInfo.Kind);
-  THI.deprecated = (S.Flags & Symbol::Deprecated);
-  THI.selectionRange = Loc->range;
+  HierarchyItem HI;
+  HI.name = std::string(S.Name);
+  HI.kind = indexSymbolKindToSymbolKind(S.SymInfo.Kind);
+  HI.selectionRange = Loc->range;
   // FIXME: Populate 'range' correctly
   // (https://github.com/clangd/clangd/issues/59).
-  THI.range = THI.selectionRange;
-  THI.uri = Loc->uri;
+  HI.range = HI.selectionRange;
+  HI.uri = Loc->uri;
   // Store the SymbolID in the 'data' field. The client will
-  // send this back in typeHierarchy/resolve, allowing us to
-  // continue resolving additional levels of the type 

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

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

Thank you for the reviews!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91122

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


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

2020-11-23 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 307223.
nridge marked 2 inline comments as done.
nridge added a comment.

Address final review comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91122

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -156,7 +156,8 @@
 
 std::unique_ptr TestTU::index() const {
   auto AST = build();
-  auto Idx = std::make_unique(/*UseDex=*/true);
+  auto Idx = std::make_unique(/*UseDex=*/true,
+ /*CollectMainFileRefs=*/true);
   Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
   AST.getASTContext(), AST.getPreprocessorPtr(),
   AST.getCanonicalIncludes());
Index: clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/CallHierarchyTests.cpp
@@ -0,0 +1,256 @@
+//===-- CallHierarchyTests.cpp  ---*- C++ -*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "Annotations.h"
+#include "Compiler.h"
+#include "Matchers.h"
+#include "ParsedAST.h"
+#include "SyncAPI.h"
+#include "TestFS.h"
+#include "TestTU.h"
+#include "TestWorkspace.h"
+#include "XRefs.h"
+#include "index/FileIndex.h"
+#include "index/SymbolCollector.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/Index/IndexingAction.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/ScopedPrinter.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+using ::testing::AllOf;
+using ::testing::ElementsAre;
+using ::testing::Field;
+using ::testing::Matcher;
+using ::testing::UnorderedElementsAre;
+
+// Helpers for matching call hierarchy data structures.
+MATCHER_P(WithName, N, "") { return arg.name == N; }
+MATCHER_P(WithSelectionRange, R, "") { return arg.selectionRange == R; }
+
+template 
+::testing::Matcher From(ItemMatcher M) {
+  return Field(::from, M);
+}
+template 
+::testing::Matcher FromRanges(RangeMatchers... M) {
+  return Field(::fromRanges,
+   UnorderedElementsAre(M...));
+}
+
+TEST(CallHierarchy, IncomingOneFile) {
+  Annotations Source(R"cpp(
+void call^ee(int);
+void caller1() {
+  $Callee[[callee]](42);
+}
+void caller2() {
+  $Caller1A[[caller1]]();
+  $Caller1B[[caller1]]();
+}
+void caller3() {
+  $Caller1C[[caller1]]();
+  $Caller2[[caller2]]();
+}
+  )cpp");
+  TestTU TU = TestTU::withCode(Source.code());
+  auto AST = TU.build();
+  auto Index = TU.index();
+
+  std::vector Items =
+  prepareCallHierarchy(AST, Source.point(), testPath(TU.Filename));
+  EXPECT_THAT(Items, ElementsAre(WithName("callee")));
+  auto IncomingLevel1 = incomingCalls(Items[0], Index.get());
+  EXPECT_THAT(IncomingLevel1,
+  ElementsAre(AllOf(From(WithName("caller1")),
+FromRanges(Source.range("Callee");
+
+  auto IncomingLevel2 = incomingCalls(IncomingLevel1[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel2, UnorderedElementsAre(
+  AllOf(From(WithName("caller2")),
+FromRanges(Source.range("Caller1A"),
+   Source.range("Caller1B"))),
+  AllOf(From(WithName("caller3")),
+FromRanges(Source.range("Caller1C");
+
+  auto IncomingLevel3 = incomingCalls(IncomingLevel2[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel3,
+  ElementsAre(AllOf(From(WithName("caller3")),
+FromRanges(Source.range("Caller2");
+
+  auto IncomingLevel4 = incomingCalls(IncomingLevel3[0].from, Index.get());
+  EXPECT_THAT(IncomingLevel4, ElementsAre());
+}
+
+TEST(CallHierarchy, MainFileOnlyRef) {
+  // In addition to testing that we store refs to main-file only symbols,
+  // this tests that anonymous namespaces do not interfere with the
+  // symbol re-identification process in callHierarchyItemToSymbo().
+  Annotations Source(R"cpp(
+void call^ee(int);
+namespace {
+  void caller1() {
+

[PATCH] D88630: [clang/CMake] Respect LLVM_TOOLS_INSTALL_DIR

2020-11-23 Thread Valentin Churavy via Phabricator via cfe-commits
vchuravy added a comment.

> Well, I've tested it and it doesn't seem to break anything for us (Gentoo) 
> but I don't really understand why you'd have a different install dir for LLVM 
> and Clang.

We (Julia) ship LLVM as a dependency and put all the LLVM binaries into a 
separate `tools` folder so that folks can just add `/bin` to their path and 
don't pick up our custom LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88630

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


[PATCH] D91895: [Clang] improve -Wimplicit-fallthrough GCC compat

2020-11-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:1102
+  return llvm::any_of(B->succs(),
+  [this](const CFGBlock::AdjacentBlock ) {
+if (const CFGBlock *S = Succ.getReachableBlock()) {

is there maybe a nicer way to do this using `std::bind` or `std::mem_fn`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91895

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


[PATCH] D91895: [Clang] improve -Wimplicit-fallthrough GCC compat

2020-11-23 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

I think that not warning upon falling through to `goto` or `return` is a 
mistake. We have a confirmed case of a bug where `clang` would catch this bug 
whereas `gcc` would not: 
https://lore.kernel.org/lkml/20201121124019.21116-1-ogab...@kernel.org/. I 
suspect that warnings from falling through to `break` and `;` make up the vast 
majority of the noise in the Linux kernel and I highly doubt that those are 
bugs. The other two generally have code flow implications that should be 
annotated. I will modify this patch tonight and see how many warnings we get 
from `goto` and `return` statements against mainline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91895

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


[PATCH] D91895: [Clang] avoid -Wimplicit-fallthrough for fallthrough to break

2020-11-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 307218.
nickdesaulniers added a comment.

- git-clang-format HEAD~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91895

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp

Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -33,7 +33,7 @@
   }
 case 6:  // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
   n += 300;
-case 66:  // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}}
+case 66:
 case 67:
 case 68:
   break;
@@ -151,23 +151,23 @@
 #define MY_CASE2(X, Y, U, V) case X: Y; case U: V
 
 int fallthrough_macro1(int n) {
-  MY_SWITCH(n, 13, n *= 2, 14, break)  // expected-warning{{unannotated fall-through between switch labels}}
+  MY_SWITCH(n, 13, n *= 2, 14, break)
 
   switch (n + 1) {
 MY_CASE(33, n += 2);
-MY_CASE(44, break);  // expected-warning{{unannotated fall-through between switch labels}}
-MY_CASE(55, n += 3);
+MY_CASE(44, n += 3); // expected-warning{{unannotated fall-through between switch labels}}
+MY_CASE(55, break);
   }
 
   switch (n + 3) {
 MY_CASE(333, return 333);
-MY_CASE2(444, n += 44, , break);  // expected-warning{{unannotated fall-through between switch labels}}
+MY_CASE2(444, n += 44, , break);
 MY_CASE(555, n += 33);
   }
 
-  MY_SWITCH2(n + 4, MY_CASE(17, n *= 3), MY_CASE(19, break))  // expected-warning{{unannotated fall-through between switch labels}}
+  MY_SWITCH2(n + 4, MY_CASE(17, n *= 3), MY_CASE(19, break))
 
-  MY_SWITCH2(n + 5, MY_CASE(21, break), MY_CASE2(23, n *= 7, 25, break))  // expected-warning{{unannotated fall-through between switch labels}}
+  MY_SWITCH2(n + 5, MY_CASE(21, break), MY_CASE2(23, n *= 7, 25, break))
 
   return n;
 }
@@ -237,9 +237,15 @@
   [[clang::fallthrough]]; // no diagnostics
 case 1:
   x++;
+case 2: // no diagnostics
+  break;
+case 3:
+  x++;
 default: // \
 expected-warning{{unannotated fall-through between switch labels}} \
+expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
 expected-note{{insert 'break;' to avoid fall-through}}
+  x++;
   break;
   }
 }
@@ -257,9 +263,15 @@
   [[clang::fallthrough]]; // no diagnostics
 case 1:
   x++;
+case 2: // no diagnostics
+  break;
+case 3:
+  x++;
 default: // \
 expected-warning{{unannotated fall-through between switch labels}} \
+expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
 expected-note{{insert 'break;' to avoid fall-through}}
+  x++;
   break;
 }
   };
@@ -279,6 +291,106 @@
   }
 }
 
+void bar(void);
+
+// Should not warn.
+void test0(int x) {
+  switch (x) {
+  case 0:
+bar();
+  default:
+break;
+  }
+}
+
+// should not warn.
+void test1(int x) {
+  switch (x) {
+  case 0:
+bar();
+  default:
+return;
+  }
+}
+
+// should not warn.
+void test2(int x) {
+  switch (x) {
+  case 0:
+bar();
+  default:
+goto y;
+  }
+y:;
+}
+
+void test3(int x) {
+  switch (x) {
+  case 0:
+bar();
+  default: // \
+  // expected-warning{{unannotated fall-through between switch labels}} \
+  // expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
+  // expected-note{{insert 'break;' to avoid fall-through}}
+bar();
+break;
+  }
+}
+
+// Should not warn.
+int y;
+void test4(int x) {
+  switch (x) {
+  case 0:
+if (y)
+  bar();
+  default:
+break;
+  }
+}
+
+// Should not warn.
+void test5(int x) {
+  switch (x) {
+  case 0:
+++x;
+  case 1:
+  case 2:
+  case 3:
+break;
+  }
+}
+
+// Should not warn.
+// TODO: GCC does not warn
+void test6(int x) {
+  switch (x) {
+  case 0:
+bar();
+  default: // \
+  // expected-warning{{unannotated fall-through between switch labels}} \
+  // expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
+  // expected-note{{insert 'break;' to avoid fall-through}}
+   ;
+  }
+  bar();
+  bar();
+}
+
+// Should warn.
+void test7(int x) {
+  switch (x) {
+  case 3:
+++x;
+  case 4: // \
+  // expected-warning{{unannotated fall-through between switch labels}} \
+  // expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
+  // expected-note{{insert 

[PATCH] D91895: [Clang] avoid -Wimplicit-fallthrough for fallthrough to break

2020-11-23 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 307217.
nickdesaulniers added a comment.

- rewrite to handle a few more cases from the Linux kernel


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91895

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough-blocks.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp

Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -33,7 +33,7 @@
   }
 case 6:  // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
   n += 300;
-case 66:  // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}}
+case 66:
 case 67:
 case 68:
   break;
@@ -151,23 +151,23 @@
 #define MY_CASE2(X, Y, U, V) case X: Y; case U: V
 
 int fallthrough_macro1(int n) {
-  MY_SWITCH(n, 13, n *= 2, 14, break)  // expected-warning{{unannotated fall-through between switch labels}}
+  MY_SWITCH(n, 13, n *= 2, 14, break)
 
   switch (n + 1) {
 MY_CASE(33, n += 2);
-MY_CASE(44, break);  // expected-warning{{unannotated fall-through between switch labels}}
-MY_CASE(55, n += 3);
+MY_CASE(44, n += 3);  // expected-warning{{unannotated fall-through between switch labels}}
+MY_CASE(55, break);
   }
 
   switch (n + 3) {
 MY_CASE(333, return 333);
-MY_CASE2(444, n += 44, , break);  // expected-warning{{unannotated fall-through between switch labels}}
+MY_CASE2(444, n += 44, , break);
 MY_CASE(555, n += 33);
   }
 
-  MY_SWITCH2(n + 4, MY_CASE(17, n *= 3), MY_CASE(19, break))  // expected-warning{{unannotated fall-through between switch labels}}
+  MY_SWITCH2(n + 4, MY_CASE(17, n *= 3), MY_CASE(19, break))
 
-  MY_SWITCH2(n + 5, MY_CASE(21, break), MY_CASE2(23, n *= 7, 25, break))  // expected-warning{{unannotated fall-through between switch labels}}
+  MY_SWITCH2(n + 5, MY_CASE(21, break), MY_CASE2(23, n *= 7, 25, break))
 
   return n;
 }
@@ -237,9 +237,15 @@
   [[clang::fallthrough]]; // no diagnostics
 case 1:
   x++;
+case 2: // no diagnostics
+  break;
+case 3:
+  x++;
 default: // \
 expected-warning{{unannotated fall-through between switch labels}} \
+expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
 expected-note{{insert 'break;' to avoid fall-through}}
+  x++;
   break;
   }
 }
@@ -257,9 +263,15 @@
   [[clang::fallthrough]]; // no diagnostics
 case 1:
   x++;
+case 2: // no diagnostics
+  break;
+case 3:
+  x++;
 default: // \
 expected-warning{{unannotated fall-through between switch labels}} \
+expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
 expected-note{{insert 'break;' to avoid fall-through}}
+  x++;
   break;
 }
   };
@@ -279,6 +291,105 @@
   }
 }
 
+void bar(void);
+
+// Should not warn.
+void test0 (int x) {
+  switch (x) {
+case 0:
+  bar();
+default:
+  break;
+  }
+}
+
+// should not warn.
+void test1 (int x) {
+  switch (x) {
+case 0:
+  bar();
+default:
+  return;
+  }
+}
+
+// should not warn.
+void test2 (int x) {
+  switch (x) {
+case 0:
+  bar();
+default:
+  goto y;
+  }
+y:;
+}
+
+void test3 (int x) {
+  switch (x) {
+case 0:
+  bar();
+default: // \
+  // expected-warning{{unannotated fall-through between switch labels}} \
+  // expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
+  // expected-note{{insert 'break;' to avoid fall-through}}
+  bar();
+  break;
+  }
+}
+
+// Should not warn.
+int y;
+void test4 (int x) {
+  switch (x) {
+case 0:
+  if (y)
+bar();
+default:
+  break;
+  }
+}
+
+// Should not warn.
+void test5 (int x) {
+  switch (x) {
+case 0:
+  ++x;
+case 1:
+case 2:
+case 3:
+  break;
+  }
+}
+
+// Should not warn.
+// TODO: GCC does not warn
+void test6 (int x) {
+  switch (x) {
+case 0:
+  bar();
+default: // \
+  // expected-warning{{unannotated fall-through between switch labels}} \
+  // expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} \
+  // expected-note{{insert 'break;' to avoid fall-through}}
+  ;
+  }
+  bar();
+  bar();
+}
+
+// Should warn.
+void test7 (int x) {
+  switch (x) {
+case 3:
+  ++x;
+case 4: // \
+  // expected-warning{{unannotated fall-through between switch labels}} \
+  // 

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

2020-11-23 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D91927#2412604 , @LuoYuanke wrote:

> In D91927#2412557 , @craig.topper 
> wrote:
>
>> I only took a quick pass through this so far.  What happens if a bitcast 
>> between x86amx and v256i32(or any other 1024-bit vector type) exists in the 
>> IR but isn't next to a load/store?
>
> @craig.topper , thank you for reviewing my patch.
> I think if user just use our external API, such IR won't be generated. 
> However if there is such IR, we can transform bitcast to , so 
> that the type can be translated through memory. One of  is AMX 
> intrinsics store/load, so it won't be optimized. Is it reasonable?

Its fine if its not optimized, just make sure it doesn't crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91927

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


[PATCH] D91779: [Clang][-fvisibility-from-dllstorageclass] Set DSO Locality from final visibility

2020-11-23 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe42021d5cc25: [Clang][-fvisibility-from-dllstorageclass] Set 
DSO Locality from final… (authored by Ben Dunbobbin 
ben.dunbob...@sony.com).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91779

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/visibility-dllstorageclass.cpp

Index: clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
===
--- clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
+++ clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
@@ -5,12 +5,14 @@
 
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
 // RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -x c++ %s -S -emit-llvm -o - | \
-// RUN:   FileCheck %s --check-prefixes=DEFAULT
+// RUN:   FileCheck %s --check-prefixes=DEFAULTS
 
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
 // RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -fvisibility-dllexport=hidden \
 // RUN: -fvisibility-nodllstorageclass=protected \
@@ -19,45 +21,78 @@
 // RUN: -x c++  %s -S -emit-llvm -o - | \
 // RUN:   FileCheck %s --check-prefixes=EXPLICIT
 
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
+// RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
+// RUN: -fvisibility-from-dllstorageclass \
+// RUN: -fvisibility-dllexport=default \
+// RUN: -fvisibility-nodllstorageclass=default \
+// RUN: -fvisibility-externs-dllimport=default \
+// RUN: -fvisibility-externs-nodllstorageclass=default \
+// RUN: -x c++  %s -S -emit-llvm -o - | \
+// RUN:   FileCheck %s --check-prefixes=ALL_DEFAULT
+
 // Local
 static void l() {}
 void use_locals(){l();}
-// DEFAULT-DAG: define internal void @_ZL1lv()
+// DEFAULTS-DAG: define internal void @_ZL1lv()
 // EXPLICIT-DAG: define internal void @_ZL1lv()
+// ALL_DEFAULT-DAG: define internal void @_ZL1lv()
 
 // Function
 void f() {}
 void __declspec(dllexport) exported_f() {}
-// DEFAULT-DAG: define hidden void @_Z1fv()
-// DEFAULT-DAG: define dso_local void @_Z10exported_fv()
+// DEFAULTS-DAG: define hidden void @_Z1fv()
+// DEFAULTS-DAG: define void @_Z10exported_fv()
 // EXPLICIT-DAG: define protected void @_Z1fv()
 // EXPLICIT-DAG: define hidden void @_Z10exported_fv()
+// ALL_DEFAULT-DAG: define void @_Z1fv()
+// ALL_DEFAULT-DAG: define void @_Z10exported_fv()
 
 // Variable
 int d = 123;
 __declspec(dllexport) int exported_d = 123;
-// DEFAULT-DAG: @d = hidden global
-// DEFAULT-DAG: @exported_d = dso_local global
+// DEFAULTS-DAG: @d = hidden global
+// DEFAULTS-DAG: @exported_d = global
 // EXPLICIT-DAG: @d = protected global
 // EXPLICIT-DAG: @exported_d = hidden global
+// ALL_DEFAULT-DAG: @d = global
+// ALL_DEFAULT-DAG: @exported_d = global
 
 // Alias
 extern "C" void aliased() {}
 void a() __attribute__((alias("aliased")));
 void __declspec(dllexport) a_exported() __attribute__((alias("aliased")));
-// DEFAULT-DAG: @_Z1av = hidden alias
-// DEFAULT-DAG: @_Z10a_exportedv = dso_local alias
+// DEFAULTS-DAG: @_Z1av = hidden alias
+// DEFAULTS-DAG: @_Z10a_exportedv = alias
 // EXPLICIT-DAG: @_Z1av = protected alias
 // EXPLICIT-DAG: @_Z10a_exportedv = hidden alias
+// ALL_DEFAULT-DAG: @_Z1av = alias
+// ALL_DEFAULT-DAG: @_Z10a_exportedv = alias
 
 // Declaration
 extern void e();
 extern void __declspec(dllimport) imported_e();
-void use_declarations(){e(); imported_e();}
-// DEFAULT-DAG: declare hidden void @_Z1ev()
-// DEFAULT-DAG: declare void @_Z10imported_ev()
+// DEFAULTS-DAG: declare hidden void @_Z1ev()
+// DEFAULTS-DAG: declare void @_Z10imported_ev()
 // EXPLICIT-DAG: declare protected void @_Z1ev()
 // EXPLICIT-DAG: declare hidden void @_Z10imported_ev()
+// ALL_DEFAULT-DAG: declare void @_Z1ev()
+// ALL_DEFAULT-DAG: declare void @_Z10imported_ev()
+
+// Weak Declaration
+__attribute__((weak))
+extern void w();
+__attribute__((weak))
+extern void __declspec(dllimport) imported_w();
+// DEFAULTS-DAG: declare extern_weak hidden void @_Z1wv()
+// DEFAULTS-DAG: declare extern_weak void @_Z10imported_wv()
+// EXPLICIT-DAG: declare extern_weak protected void @_Z1wv()
+// EXPLICIT-DAG: declare extern_weak hidden void @_Z10imported_wv()
+// ALL_DEFAULT-DAG: declare extern_weak void @_Z1wv()
+// ALL_DEFAULT-DAG: declare extern_weak void @_Z10imported_wv()
+
+void use_declarations(){e(); imported_e(); w(); imported_w();}
 
 // Show that -fvisibility-from-dllstorageclass overrides the effect of visibility annotations.
 
@@ -65,12 +100,12 @@
   virtual void foo();
 };
 void 

[clang] e42021d - [Clang][-fvisibility-from-dllstorageclass] Set DSO Locality from final visibility

2020-11-23 Thread Ben Dunbobbin via cfe-commits

Author: Ben Dunbobbin
Date: 2020-11-24T00:32:14Z
New Revision: e42021d5cc25a8dc7e3efac1e7007cc0c1a7b2bd

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

LOG: [Clang][-fvisibility-from-dllstorageclass] Set DSO Locality from final 
visibility

Ensure that the DSO Locality of the globals in the IR is derived from
their final visibility when using -fvisibility-from-dllstorageclass.

To accomplish this we reset the DSO locality of globals (before
setting their visibility from their dllstorageclass) at the end of
IRGen in Clang. This removes any effects that visibility options or
annotations may have had on the DSO locality.

The resulting DSO locality of the globals will be pessimistic
w.r.t. to the normal compiler IRGen.

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCXX/visibility-dllstorageclass.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index f56b7374082f..6d0228e9e2e9 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -420,6 +420,13 @@ static void setVisibilityFromDLLStorageClass(const 
clang::LangOptions ,
 if (GV.hasAppendingLinkage() || GV.hasLocalLinkage())
   continue;
 
+// Reset DSO locality before setting the visibility. This removes
+// any effects that visibility options and annotations may have
+// had on the DSO locality. Setting the visibility will implicitly set
+// appropriate globals to DSO Local; however, this will be pessimistic
+// w.r.t. to the normal compiler IRGen.
+GV.setDSOLocal(false);
+
 if (GV.isDeclarationForLinker()) {
   GV.setVisibility(GV.getDLLStorageClass() ==
llvm::GlobalValue::DLLImportStorageClass

diff  --git a/clang/test/CodeGenCXX/visibility-dllstorageclass.cpp 
b/clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
index 9003909f3ee0..c4dddcec2eb0 100644
--- a/clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
+++ b/clang/test/CodeGenCXX/visibility-dllstorageclass.cpp
@@ -5,12 +5,14 @@
 
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
 // RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -x c++ %s -S -emit-llvm -o - | \
-// RUN:   FileCheck %s --check-prefixes=DEFAULT
+// RUN:   FileCheck %s --check-prefixes=DEFAULTS
 
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
 // RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
 // RUN: -fvisibility-from-dllstorageclass \
 // RUN: -fvisibility-dllexport=hidden \
 // RUN: -fvisibility-nodllstorageclass=protected \
@@ -19,45 +21,78 @@
 // RUN: -x c++  %s -S -emit-llvm -o - | \
 // RUN:   FileCheck %s --check-prefixes=EXPLICIT
 
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-itanium -fdeclspec \
+// RUN: -fvisibility hidden \
+// RUN: -fapply-global-visibility-to-externs \
+// RUN: -fvisibility-from-dllstorageclass \
+// RUN: -fvisibility-dllexport=default \
+// RUN: -fvisibility-nodllstorageclass=default \
+// RUN: -fvisibility-externs-dllimport=default \
+// RUN: -fvisibility-externs-nodllstorageclass=default \
+// RUN: -x c++  %s -S -emit-llvm -o - | \
+// RUN:   FileCheck %s --check-prefixes=ALL_DEFAULT
+
 // Local
 static void l() {}
 void use_locals(){l();}
-// DEFAULT-DAG: define internal void @_ZL1lv()
+// DEFAULTS-DAG: define internal void @_ZL1lv()
 // EXPLICIT-DAG: define internal void @_ZL1lv()
+// ALL_DEFAULT-DAG: define internal void @_ZL1lv()
 
 // Function
 void f() {}
 void __declspec(dllexport) exported_f() {}
-// DEFAULT-DAG: define hidden void @_Z1fv()
-// DEFAULT-DAG: define dso_local void @_Z10exported_fv()
+// DEFAULTS-DAG: define hidden void @_Z1fv()
+// DEFAULTS-DAG: define void @_Z10exported_fv()
 // EXPLICIT-DAG: define protected void @_Z1fv()
 // EXPLICIT-DAG: define hidden void @_Z10exported_fv()
+// ALL_DEFAULT-DAG: define void @_Z1fv()
+// ALL_DEFAULT-DAG: define void @_Z10exported_fv()
 
 // Variable
 int d = 123;
 __declspec(dllexport) int exported_d = 123;
-// DEFAULT-DAG: @d = hidden global
-// DEFAULT-DAG: @exported_d = dso_local global
+// DEFAULTS-DAG: @d = hidden global
+// DEFAULTS-DAG: @exported_d = global
 // EXPLICIT-DAG: @d = protected global
 // EXPLICIT-DAG: @exported_d = hidden global
+// ALL_DEFAULT-DAG: @d = global
+// ALL_DEFAULT-DAG: @exported_d = global
 
 // Alias
 extern "C" void aliased() {}
 void a() __attribute__((alias("aliased")));
 void __declspec(dllexport) a_exported() __attribute__((alias("aliased")));
-// DEFAULT-DAG: @_Z1av = hidden alias
-// 

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

2020-11-23 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added a comment.

In D91927#2412557 , @craig.topper 
wrote:

> I only took a quick pass through this so far.  What happens if a bitcast 
> between x86amx and v256i32(or any other 1024-bit vector type) exists in the 
> IR but isn't next to a load/store?

@craig.topper , thank you for reviewing my patch.
I think if user just use our external API, such IR won't be generated. However 
if there is such IR, we can transform bitcast to , so that the 
type can be translated through memory. One of  is AMX intrinsics 
store/load, so it won't be optimized. Is it reasonable?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91927

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


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

2020-11-23 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 307213.
njames93 added a comment.

Fix assertion in provideDefaultChecks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91029

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

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

[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-23 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

Thanks so much! Would you mind pushing that change for me? I don't have commit 
access at the moment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


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

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

@psmith Do they have concerns? :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91760

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-23 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


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

2020-11-23 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I only took a quick pass through this so far.  What happens if a bitcast 
between x86amx and v256i32(or any other 1024-bit vector type) exists in the IR 
but isn't next to a load/store?




Comment at: llvm/lib/Target/X86/X86ISelLowering.cpp:5334
   // to x86 amx tile on amx intrinsics.
-  if (MemVT == MVT::v256i32)
-return false;
+  // if (MemVT == MVT::v256i32)
+  //   return false;

Should this just be deleted?



Comment at: llvm/lib/Target/X86/X86LowerAMXType.cpp:63
+LoadInst *LD = dyn_cast(Src);
+assert(LD && "Expected bitcast to x86amx from load");
+assert(LD->hasOneUser() &&

Don't use an assert to check the result of a dyn_cast. If it shouldn't fail 
just use cast which will assert internally.



Comment at: llvm/lib/Target/X86/X86LowerAMXType.cpp:71
+auto *AMXIntrinsic =
+dyn_cast(Inst.use_begin()->getUser());
+auto *Row = AMXIntrinsic->getOperand(0);

Unchecked dyn_cast



Comment at: llvm/lib/Target/X86/X86LowerAMXType.cpp:94
+for (auto UI = Inst.use_begin(), UE = Inst.use_end(); UI != UE;) {
+  StoreInst *ST = dyn_cast((UI++)->getUser());
+  assert(ST && "Expected bitcast to x86amx for store");

Use cast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91927

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

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

In D71726#2351069 , @rjmccall wrote:

>> Yes, there are no generically available libcalls for atomic float math -- 
>> but that's okay -- let LLVM handle transform into a cmpxchg loop when 
>> required.
>
> I suspect Yaxun's target cannot provide libcalls at all, which is why he 
> wants to diagnose up-front.  But I agree that we should be thinking about 
> this uniformly, and that his target should be diagnosing *all* unsupported 
> atomics.

amdgpu target currently does not support atomic libcalls. I added a target hook 
for atomic operation support and diagnostics for generic atomic operations by 
John's comments.

Clang has existing diagnostics for unsupported atomic load/store for some 
platforms, and functions about atomic support scattered in target info, AST 
context, and codegen. This change refactors these codes and unify them as a 
target hook.


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

https://reviews.llvm.org/D71726

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


[PATCH] D91908: [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check

2020-11-23 Thread Shane via Phabricator via cfe-commits
smhc added a comment.

Yes all looks good, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91908

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2020-11-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 307206.
yaxunl edited the summary of this revision.
yaxunl added a comment.

revised by John's comments. Added target hook and diagnostics for generic 
atomic operations.


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

https://reviews.llvm.org/D71726

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/ARM.h
  clang/lib/Basic/Targets/Hexagon.h
  clang/lib/Basic/Targets/Mips.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/fp-atomic-ops.c
  clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
  clang/test/CodeGenOpenCL/atomic-ops.cl
  clang/test/Sema/atomic-ops.c
  clang/test/Sema/atomic-requires-library-error.c
  clang/test/SemaCUDA/amdgpu-atomic-ops.cu
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=spir64
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify=expected,spir \
+// RUN:   -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \
+// RUN:   -triple=amdgcn-amd-amdhsa
 
 // Basic parsing/Sema tests for __opencl_atomic_*
 
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 typedef __INTPTR_TYPE__ intptr_t;
 typedef int int8 __attribute__((ext_vector_type(8)));
@@ -36,7 +39,7 @@
 
 atomic_int gn;
 void f(atomic_int *i, const atomic_int *ci,
-   atomic_intptr_t *p, atomic_float *d,
+   atomic_intptr_t *p, atomic_float *f, atomic_double *d, atomic_half *h, // expected-error {{unknown type name 'atomic_half'}}
int *I, const int *CI,
intptr_t *P, float *D, struct S *s1, struct S *s2,
global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
@@ -57,37 +60,38 @@
 
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(f, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(i_c, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
 
   __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+  (int)__opencl_atomic_store(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
 
   int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_group);
   int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
 
   __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_add(f, 1.0f, memory_order_seq_cst, memory_scope_work_group); // spir-error {{atomic add/sub of '__generic atomic_float' (aka '__generic _Atomic(float)') type requires runtime support that is not available for this target}}
+  __opencl_atomic_fetch_add(d, 1.0, memory_order_seq_cst, memory_scope_work_group); // spir-error {{atomic add/sub of '__generic atomic_double' (aka '__generic _Atomic(double)') type requires runtime support that is not available for this target}}
   __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  

[PATCH] D91531: [RFC][OpenCL] Provide mechanisms for defining extension macros

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

> So if I understand it well you are suggesting to perform a check for every 
> parsed macro definition that would identify whether the macro has a name 
> matching what is provided in -cl-ext=? Then if the name matches it would 
> check whether the macro should be defined or not?

No, sorry for confusing. There is no need to check every parsed macro. For 
example an internal pragma can be used for these purposes (`#pragma OPENCL 
EXTENSION all : undef` in example below). So imagine if we can differentiate 
header-only extensions and features and all of them are defined in header. 
After the list of definitions the special pragma is used and is a processed in 
a way that it inserts undef for each macro definition which relates to 
header-only extension/feature and was turned off with the option 
(`-cl-ext=-cl_khr_depth_images`):

  #define cl_khr_depth_images 1
  #define cl_khr_fp64 1
  #define cl_khr_mipmap_image  1
  ...
  #pragma OPENCL EXTENSION all : undef

However, this might be hard to maintain and I'm not sure yet that this is even 
legally to do in current `Preprocessor` design, but this is at least more 
scalable than adding `#if defined(__undef_` for each extension in the end of 
the header.  Nevertheless, that's what I meant about preserving the current 
interface.

Also, I didn't quite get how the proposing hook will allow users to declare own 
extensions outside the codebase. Are you expecting them to use existing 
`-cl-ext` or `-Dcl_khr_depth_images`? In the later case they won't able to use 
`#pragma OPENCL EXTESNION cl_khr_depth_images : enable` (while the 
specification does not describe for which extensions pragma is exactly needed 
or not, but still)


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

https://reviews.llvm.org/D91531

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-23 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

I changed it to 4.5 to be consisted with the other Multi-Arch tests for x86, 
MIPS and PowerPC. That's all.

Debian Multi-Arch on sparc/sparc64 behaves the exact same way as it does on 
mips*, powerpc* and x86, so I think it makes sense to use the exact same path 
patterns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D90524: [Driver] Enable getOSLibDir() lib32 workaround for SPARC on Linux

2020-11-23 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/test/Driver/linux-ld.c:1292
+// CHECK-DEBIAN-SPARC: 
"{{.*}}/usr/lib/gcc/sparc-linux-gnu/4.5{{/|}}crtbegin.o"
+// CHECK-DEBIAN-SPARC: "-L[[SYSROOT]]/usr/lib/gcc/sparc-linux-gnu/4.5"
+// CHECK-DEBIAN-SPARC: 
"-L[[SYSROOT]]/usr/lib/gcc/sparc-linux-gnu/4.5/../../../sparc-linux-gnu"

What's the reason for changing the version from 4.9 to 4.5? Not that it really 
matters, but I'm curious.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90524

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


[PATCH] D91998: [OpenMP50][DOCS] Mark target data non-contiguous as done, NFC.

2020-11-23 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen created this revision.
Herald added subscribers: cfe-commits, guansong, yaxunl.
Herald added a project: clang.
cchen requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91998

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -217,7 +217,7 @@
 
+--+--+--+---+
 | device extension | teams construct on the host device
   | :part:`worked on`| Clang part is done, r371553.
  |
 
+--+--+--+---+
-| device extension | support non-contiguous array sections for 
target update  | :part:`worked on`| 
  |
+| device extension | support non-contiguous array sections for 
target update  | :good:`done` | 
  |
 
+--+--+--+---+
 | device extension | pointer attachment
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -217,7 +217,7 @@
 +--+--+--+---+
 | device extension | teams construct on the host device   | :part:`worked on`| Clang part is done, r371553.  |
 +--+--+--+---+
-| device extension | support non-contiguous array sections for target update  | :part:`worked on`|   |
+| device extension | support non-contiguous array sections for target update  | :good:`done` |   |
 +--+--+--+---+
 | device extension | pointer attachment   | :none:`unclaimed`|   |
 +--+--+--+---+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D89684: [AIX] Add mabi=vec-extabi options to enable the AIX extended and default vector ABIs.

2020-11-23 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 307192.
ZarkoCA marked 3 inline comments as done.
ZarkoCA added a comment.

Addressed some of the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89684

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/altivec.c
  clang/test/Driver/aix-vec-extabi.c
  clang/test/Preprocessor/aix-vec_extabi.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/aix-vec-abi.ll

Index: llvm/test/CodeGen/PowerPC/aix-vec-abi.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-vec-abi.ll
@@ -0,0 +1,12 @@
+; RUN: not --crash llc < %s -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr8 2>&1 | FileCheck %s --check-prefix=DFLTERROR
+; RUN: not --crash llc < %s -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr8 2>&1 | FileCheck %s --check-prefix=DFLTERROR
+
+; RUN: not --crash llc < %s -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr8 -vec-extabi 2>&1 | FileCheck %s --check-prefix=VEXTERROR
+; RUN: not --crash llc < %s -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr8 -vec-extabi 2>&1 | FileCheck %s --check-prefix=VEXTERROR
+
+define void @vec_callee(<4 x i32> %vec1) {
+ret void 
+}
+
+; DFLTERROR:  LLVM ERROR: the default Altivec AIX ABI is not yet supported
+; VEXTERROR:  LLVM ERROR: the extended Altivec AIX ABI is not yet supported
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -6968,6 +6968,16 @@
   const Align PtrAlign = IsPPC64 ? Align(8) : Align(4);
   const MVT RegVT = IsPPC64 ? MVT::i64 : MVT::i32;
 
+  if (ValVT.isVector() && !State.getMachineFunction()
+   .getTarget()
+   .Options.EnableAIXExtendedAltivecABI)
+report_fatal_error("the default Altivec AIX ABI is not yet supported");
+
+  if (ValVT.isVector() && State.getMachineFunction()
+  .getTarget()
+  .Options.EnableAIXExtendedAltivecABI)
+report_fatal_error("the extended Altivec AIX ABI is not yet supported");
+
   assert((!ValVT.isInteger() ||
   (ValVT.getFixedSizeInBits() <= RegVT.getFixedSizeInBits())) &&
  "Integer argument exceeds register size: should have been legalized");
Index: llvm/lib/CodeGen/CommandFlags.cpp
===
--- llvm/lib/CodeGen/CommandFlags.cpp
+++ llvm/lib/CodeGen/CommandFlags.cpp
@@ -58,6 +58,7 @@
 CGOPT(bool, EnableNoNaNsFPMath)
 CGOPT(bool, EnableNoSignedZerosFPMath)
 CGOPT(bool, EnableNoTrappingFPMath)
+CGOPT(bool, EnableAIXExtendedAltivecABI)
 CGOPT(DenormalMode::DenormalModeKind, DenormalFPMath)
 CGOPT(DenormalMode::DenormalModeKind, DenormalFP32Math)
 CGOPT(bool, EnableHonorSignDependentRoundingFPMath)
@@ -282,6 +283,11 @@
   cl::init(false));
   CGBINDOPT(DontPlaceZerosInBSS);
 
+  static cl::opt EnableAIXExtendedAltivecABI(
+  "vec-extabi", cl::desc("Enable the AIX Extended Altivec ABI."),
+  cl::init(false));
+  CGBINDOPT(EnableAIXExtendedAltivecABI);
+
   static cl::opt EnableGuaranteedTailCallOpt(
   "tailcallopt",
   cl::desc(
@@ -516,6 +522,7 @@
   getEnableHonorSignDependentRoundingFPMath();
   if (getFloatABIForCalls() != FloatABI::Default)
 Options.FloatABIType = getFloatABIForCalls();
+  Options.EnableAIXExtendedAltivecABI = getEnableAIXExtendedAltivecABI();
   Options.NoZerosInBSS = getDontPlaceZerosInBSS();
   Options.GuaranteedTailCallOpt = getEnableGuaranteedTailCallOpt();
   Options.StackAlignmentOverride = getOverrideStackAlignment();
Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -124,6 +124,7 @@
 TargetOptions()
 : UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false),
   NoTrappingFPMath(true), NoSignedZerosFPMath(false),
+  EnableAIXExtendedAltivecABI(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
   EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
@@ -175,6 +176,12 @@
 /// argument or result as insignificant.
 unsigned 

[PATCH] D91997: APINotes: add bitcode format schema definitions

2020-11-23 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: martong, gribozavr2, MForster.
compnerd added a project: clang.
Herald added a subscriber: rnkovacs.
compnerd requested review of this revision.

This adds the bitcode format schema required for serialization of the
YAML data to a binary format.  APINotes are pre-compiled and re-used in
the binary format from the frontend.  These definitions provide the data
layout representation enabling writing (and eventually) reading of the
data in bitcode format.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91997

Files:
  clang/lib/APINotes/APINotesFormat.h

Index: clang/lib/APINotes/APINotesFormat.h
===
--- /dev/null
+++ clang/lib/APINotes/APINotesFormat.h
@@ -0,0 +1,255 @@
+//===-- APINotesWriter.h - API Notes Writer -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_APINOTES_APINOTESFORMAT_H
+#define LLVM_CLANG_LIB_APINOTES_APINOTESFORMAT_H
+
+#include "llvm/ADT/PointerEmbeddedInt.h"
+#include "llvm/Bitcode/BitcodeConvenience.h"
+
+namespace clang {
+namespace api_notes {
+/// Magic number for API notes files.
+const unsigned char API_NOTES_SIGNATURE[] = {0xE2, 0x9C, 0xA8, 0x01};
+
+/// API notes file major version number.
+const uint16_t VERSION_MAJOR = 0;
+
+/// API notes file minor version number.
+///
+/// When the format changes IN ANY WAY, this number should be incremented.
+const uint16_t VERSION_MINOR = 24; // EnumExtensibility + FlagEnum
+
+using IdentifierID = llvm::PointerEmbeddedInt;
+using IdentifierIDField = llvm::BCVBR<16>;
+
+using SelectorID = llvm::PointerEmbeddedInt;
+using SelectorIDField = llvm::BCVBR<16>;
+
+/// The various types of blocks that can occur within a API notes file.
+///
+/// These IDs must \em not be renumbered or reordered without incrementing
+/// VERSION_MAJOR.
+enum BlockID {
+  /// The control block, which contains all of the information that needs to
+  /// be validated prior to committing to loading the API notes file.
+  ///
+  /// \sa control_block
+  CONTROL_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID,
+
+  /// The identifier data block, which maps identifier strings to IDs.
+  IDENTIFIER_BLOCK_ID,
+
+  /// The Objective-C context data block, which contains information about
+  /// Objective-C classes and protocols.
+  OBJC_CONTEXT_BLOCK_ID,
+
+  /// The Objective-C property data block, which maps Objective-C
+  /// (class name, property name) pairs to information about the
+  /// property.
+  OBJC_PROPERTY_BLOCK_ID,
+
+  /// The Objective-C property data block, which maps Objective-C
+  /// (class name, selector, is_instance_method) tuples to information
+  /// about the method.
+  OBJC_METHOD_BLOCK_ID,
+
+  /// The Objective-C selector data block, which maps Objective-C
+  /// selector names (# of pieces, identifier IDs) to the selector ID
+  /// used in other tables.
+  OBJC_SELECTOR_BLOCK_ID,
+
+  /// The global variables data block, which maps global variable names to
+  /// information about the global variable.
+  GLOBAL_VARIABLE_BLOCK_ID,
+
+  /// The (global) functions data block, which maps global function names to
+  /// information about the global function.
+  GLOBAL_FUNCTION_BLOCK_ID,
+
+  /// The tag data block, which maps tag names to information about
+  /// the tags.
+  TAG_BLOCK_ID,
+
+  /// The typedef data block, which maps typedef names to information about
+  /// the typedefs.
+  TYPEDEF_BLOCK_ID,
+
+  /// The enum constant data block, which maps enumerator names to
+  /// information about the enumerators.
+  ENUM_CONSTANT_BLOCK_ID,
+};
+
+namespace control_block {
+// These IDs must \em not be renumbered or reordered without incrementing
+// VERSION_MAJOR.
+enum {
+  METADATA = 1,
+  MODULE_NAME = 2,
+  MODULE_OPTIONS = 3,
+  SOURCE_FILE = 4,
+};
+
+using MetadataLayout =
+llvm::BCRecordLayout, // Module format major version
+ llvm::BCFixed<16>  // Module format minor version
+ >;
+
+using ModuleNameLayout = llvm::BCRecordLayout;
+
+using ModuleOptionsLayout =
+llvm::BCRecordLayout // SwiftInferImportAsMember
+ >;
+
+using SourceFileLayout = llvm::BCRecordLayout, // file size
+  llvm::BCVBR<16>  // creation time
+  >;
+} // namespace control_block
+
+namespace identifier_block {
+enum {
+  IDENTIFIER_DATA = 1,
+};
+
+using IdentifierDataLayout = llvm::BCRecordLayout<
+IDENTIFIER_DATA, // record ID
+llvm::BCVBR<16>, // table offset within the blob (see below)
+llvm::BCBlob // map from identifier strings to decl kinds 

[PATCH] D91979: [Clang][Attr] Introduce the `assume` function attribute

2020-11-23 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 307194.
jdoerfert added a comment.

Generalize check lines [NFC]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91979

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/assume_attr.c
  clang/test/CodeGenCXX/assume_attr.cpp

Index: clang/test/CodeGenCXX/assume_attr.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/assume_attr.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu %s -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+/// foo: declarations only
+
+__attribute__((assume("foo:before1"))) void foo();
+
+__attribute__((assume("foo:before2")))
+__attribute__((assume("foo:before3"))) void
+foo();
+
+/// baz: static function declarations and a definition
+
+__attribute__((assume("baz:before1"))) static void baz();
+
+__attribute__((assume("baz:before2")))
+__attribute__((assume("baz:before3"))) static void
+baz();
+
+// Definition
+__attribute__((assume("baz:def1,baz:def2"))) static void baz() { foo(); }
+
+__attribute__((assume("baz:after"))) static void baz();
+
+/// bar: external function declarations and a definition
+
+__attribute__((assume("bar:before1"))) void bar();
+
+__attribute__((assume("bar:before2")))
+__attribute__((assume("bar:before3"))) void
+bar();
+
+// Definition
+__attribute__((assume("bar:def1,bar:def2"))) void bar() { baz(); }
+
+__attribute__((assume("bar:after"))) void bar();
+
+/// back to foo
+
+__attribute__((assume("foo:after"))) void foo();
+
+/// class tests
+class C {
+  __attribute__((assume("C:private_method"))) void private_method();
+  __attribute__((assume("C:private_static"))) static void private_static();
+
+public:
+  __attribute__((assume("C:public_method1"))) void public_method();
+  __attribute__((assume("C:public_static1"))) static void public_static();
+};
+
+__attribute__((assume("C:public_method2"))) void C::public_method() {
+  private_method();
+}
+
+__attribute__((assume("C:public_static2"))) void C::public_static() {
+  private_static();
+}
+
+/// template tests
+template 
+__attribute__((assume("template_func"))) void template_func() {}
+
+template <>
+__attribute__((assume("template_func"))) void template_func() {}
+
+template <>
+void template_func() {}
+
+template 
+struct S {
+  __attribute__((assume("S::method"))) void method();
+};
+
+template <>
+__attribute__((assume("S::method"))) void S::method() {}
+
+template <>
+void S::method() {}
+
+// CHECK: define{{.*}} void @_Z3barv() #0
+// CHECK: define{{.*}} void @_ZL3bazv() #1
+// CHECK: define{{.*}} void @_ZN1C13public_methodEv({{.*}}) #2
+// CHECK: declare{{.*}} void @_ZN1C14private_methodEv({{.*}}) #3
+// CHECK: define{{.*}} void @_ZN1C13public_staticEv() #4
+// CHECK: declare{{.*}} void @_ZN1C14private_staticEv() #5
+// CHECK: define{{.*}} void @_Z13template_funcIfEvv() #6
+// CHECK: define{{.*}} void @_Z13template_funcIiEvv() #7
+// CHECK: define{{.*}} void @_ZN1SIfE6methodEv({{.*}}) #8
+// CHECK: define{{.*}} void @_ZN1SIiE6methodEv({{.*}}) #9
+// CHECK: declare{{.*}} void @_Z3foov() #10
+// CHECK: attributes #0
+// CHECK-SAME:  "llvm.assume"="bar:before1,bar:before2,bar:before3,bar:def1,bar:def2"
+// CHECK: attributes #1
+// CHECK-SAME:  "llvm.assume"="baz:before1,baz:before2,baz:before3,baz:def1,baz:def2,baz:after"
+// CHECK: attributes #2
+// CHECK-SAME:  "llvm.assume"="C:public_method1,C:public_method2"
+// CHECK: attributes #3
+// CHECK-SAME:  "llvm.assume"="C:private_method"
+// CHECK: attributes #4
+// CHECK-SAME:  "llvm.assume"="C:public_static1,C:public_static2"
+// CHECK: attributes #5
+// CHECK-SAME:  "llvm.assume"="C:private_static"
+// CHECK: attributes #6
+// CHECK-SAME:  "llvm.assume"="template_func,template_func"
+// CHECK: attributes #7
+// CHECK-SAME:  "llvm.assume"="template_func"
+// CHECK: attributes #8
+// CHECK-SAME:  "llvm.assume"="S::method,S::method"
+// CHECK: attributes #9
+// CHECK-SAME:  "llvm.assume"="S::method"
+// CHECK: attributes #10
+// CHECK-SAME:  "llvm.assume"="foo:before1,foo:before2,foo:before3"
+
+#endif
Index: clang/test/CodeGen/assume_attr.c
===
--- /dev/null
+++ clang/test/CodeGen/assume_attr.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu %s -o - | FileCheck %s
+// RUN: %clang_cc1 -x c -emit-pch -o %t %s
+// RUN: %clang_cc1 

[PATCH] D91104: APINotes: add property models for YAML attributes

2020-11-23 Thread Saleem Abdulrasool via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf6b02ecd027a: APINotes: add property models for YAML 
attributes (authored by compnerd).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91104

Files:
  clang/include/clang/APINotes/Types.h
  clang/lib/APINotes/APINotesTypes.cpp
  clang/lib/APINotes/CMakeLists.txt

Index: clang/lib/APINotes/CMakeLists.txt
===
--- clang/lib/APINotes/CMakeLists.txt
+++ clang/lib/APINotes/CMakeLists.txt
@@ -1,6 +1,7 @@
 set(LLVM_LINK_COMPONENTS
   Support)
 add_clang_library(clangAPINotes
+  APINotesTypes.cpp
   APINotesYAMLCompiler.cpp
   LINK_LIBS
 clangBasic)
Index: clang/lib/APINotes/APINotesTypes.cpp
===
--- /dev/null
+++ clang/lib/APINotes/APINotesTypes.cpp
@@ -0,0 +1,107 @@
+//===-- APINotesTypes.cpp - API Notes Data Types *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/APINotes/Types.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace api_notes {
+void CommonEntityInfo::dump(llvm::raw_ostream ) {
+  if (Unavailable)
+OS << "[Unavailable] (" << UnavailableMsg << ")" << ' ';
+  if (UnavailableInSwift)
+OS << "[UnavailableInSwift] ";
+  if (SwiftPrivateSpecified)
+OS << (SwiftPrivate ? "[SwiftPrivate] " : "");
+  if (!SwiftName.empty())
+OS << "Swift Name: " << SwiftName << ' ';
+  OS << '\n';
+}
+
+void CommonTypeInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  if (SwiftBridge)
+OS << "Swift Briged Type: " << *SwiftBridge << ' ';
+  if (NSErrorDomain)
+OS << "NSError Domain: " << *NSErrorDomain << ' ';
+  OS << '\n';
+}
+
+void ObjCContextInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  if (HasDefaultNullability)
+OS << "DefaultNullability: " << DefaultNullability << ' ';
+  if (HasDesignatedInits)
+OS << "[HasDesignatedInits] ";
+  if (SwiftImportAsNonGenericSpecified)
+OS << (SwiftImportAsNonGeneric ? "[SwiftImportAsNonGeneric] " : "");
+  if (SwiftObjCMembersSpecified)
+OS << (SwiftObjCMembers ? "[SwiftObjCMembers] " : "");
+  OS << '\n';
+}
+
+void VariableInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  if (NullabilityAudited)
+OS << "Audited Nullability: " << Nullable << ' ';
+  if (!Type.empty())
+OS << "C Type: " << Type << ' ';
+  OS << '\n';
+}
+
+void ObjCPropertyInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  if (SwiftImportAsAccessorsSpecified)
+OS << (SwiftImportAsAccessors ? "[SwiftImportAsAccessors] " : "");
+  OS << '\n';
+}
+
+void ParamInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  if (NoEscapeSpecified)
+OS << (NoEscape ? "[NoEscape] " : "");
+  OS << "RawRetainCountConvention: " << RawRetainCountConvention << ' ';
+  OS << '\n';
+}
+
+void FunctionInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  OS << (NullabilityAudited ? "[NullabilityAudited] " : "")
+ << "RawRetainCountConvention: " << RawRetainCountConvention << ' ';
+  if (!ResultType.empty())
+OS << "Result Type: " << ResultType << ' ';
+  if (!Params.empty())
+OS << '\n';
+  for (auto  : Params)
+PI.dump(OS);
+}
+
+void ObjCMethodInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  OS << (DesignatedInit ? "[DesignatedInit] " : "")
+ << (RequiredInit ? "[RequiredInit] " : "") << '\n';
+}
+
+void TagInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  if (HasFlagEnum)
+OS << (IsFlagEnum ? "[FlagEnum] " : "");
+  if (EnumExtensibility)
+OS << "Enum Extensibility: " << static_cast(*EnumExtensibility)
+   << ' ';
+  OS << '\n';
+}
+
+void TypedefInfo::dump(llvm::raw_ostream ) {
+  static_cast(*this).dump(OS);
+  if (SwiftWrapper)
+OS << "Swift Type: " << static_cast(*SwiftWrapper) << ' ';
+  OS << '\n';
+}
+} // namespace api_notes
+} // namespace clang
Index: clang/include/clang/APINotes/Types.h
===
--- clang/include/clang/APINotes/Types.h
+++ clang/include/clang/APINotes/Types.h
@@ -9,6 +9,12 @@
 #ifndef LLVM_CLANG_APINOTES_TYPES_H
 #define LLVM_CLANG_APINOTES_TYPES_H
 
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
 namespace clang {
 namespace api_notes {
 enum class RetainCountConventionKind {
@@ -34,6 +40,694 @@
   Struct,
   Enum,
 };
+
+/// Describes API notes data for any entity.
+///
+/// 

[clang] f6b02ec - APINotes: add property models for YAML attributes

2020-11-23 Thread Saleem Abdulrasool via cfe-commits

Author: Saleem Abdulrasool
Date: 2020-11-23T21:29:17Z
New Revision: f6b02ecd027a825f1f4a1804c464f9f96d9372c9

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

LOG: APINotes: add property models for YAML attributes

This adds internal representation of the attributes in a more usable
form.  This is meant to allow programmatic access to the attributes that
are specified in the YAML data.

This is based upon the work contributed by Apple at
https://github.com/llvm/llvm-project-staging/tree/staging/swift/apinotes.

Differential Revision: https://reviews.llvm.org/D91104
Reviewed By: Gabor Marton

Added: 
clang/lib/APINotes/APINotesTypes.cpp

Modified: 
clang/include/clang/APINotes/Types.h
clang/lib/APINotes/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/APINotes/Types.h 
b/clang/include/clang/APINotes/Types.h
index be2a99ad6fd0..3095bfbf1718 100644
--- a/clang/include/clang/APINotes/Types.h
+++ b/clang/include/clang/APINotes/Types.h
@@ -9,6 +9,12 @@
 #ifndef LLVM_CLANG_APINOTES_TYPES_H
 #define LLVM_CLANG_APINOTES_TYPES_H
 
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+#include 
+
 namespace clang {
 namespace api_notes {
 enum class RetainCountConventionKind {
@@ -34,6 +40,694 @@ enum class SwiftNewTypeKind {
   Struct,
   Enum,
 };
+
+/// Describes API notes data for any entity.
+///
+/// This is used as the base of all API notes.
+class CommonEntityInfo {
+public:
+  /// Message to use when this entity is unavailable.
+  std::string UnavailableMsg;
+
+  /// Whether this entity is marked unavailable.
+  unsigned Unavailable : 1;
+
+  /// Whether this entity is marked unavailable in Swift.
+  unsigned UnavailableInSwift : 1;
+
+private:
+  /// Whether SwiftPrivate was specified.
+  unsigned SwiftPrivateSpecified : 1;
+
+  /// Whether this entity is considered "private" to a Swift overlay.
+  unsigned SwiftPrivate : 1;
+
+public:
+  /// Swift name of this entity.
+  std::string SwiftName;
+
+  CommonEntityInfo()
+  : Unavailable(0), UnavailableInSwift(0), SwiftPrivateSpecified(0),
+SwiftPrivate(0) {}
+
+  llvm::Optional isSwiftPrivate() const {
+return SwiftPrivateSpecified ? llvm::Optional(SwiftPrivate)
+ : llvm::None;
+  }
+
+  void setSwiftPrivate(llvm::Optional Private) {
+SwiftPrivateSpecified = Private.hasValue();
+SwiftPrivate = Private.hasValue() ? *Private : 0;
+  }
+
+  friend bool operator==(const CommonEntityInfo &, const CommonEntityInfo &);
+
+  CommonEntityInfo |=(const CommonEntityInfo ) {
+// Merge unavailability.
+if (RHS.Unavailable) {
+  Unavailable = true;
+  if (UnavailableMsg.empty())
+UnavailableMsg = RHS.UnavailableMsg;
+}
+
+if (RHS.UnavailableInSwift) {
+  UnavailableInSwift = true;
+  if (UnavailableMsg.empty())
+UnavailableMsg = RHS.UnavailableMsg;
+}
+
+if (!SwiftPrivateSpecified)
+  setSwiftPrivate(RHS.isSwiftPrivate());
+
+if (SwiftName.empty())
+  SwiftName = RHS.SwiftName;
+
+return *this;
+  }
+
+  LLVM_DUMP_METHOD void dump(llvm::raw_ostream );
+};
+
+inline bool operator==(const CommonEntityInfo ,
+   const CommonEntityInfo ) {
+  return LHS.UnavailableMsg == RHS.UnavailableMsg &&
+ LHS.Unavailable == RHS.Unavailable &&
+ LHS.UnavailableInSwift == RHS.UnavailableInSwift &&
+ LHS.SwiftPrivateSpecified == RHS.SwiftPrivateSpecified &&
+ LHS.SwiftPrivate == RHS.SwiftPrivate && LHS.SwiftName == 
RHS.SwiftName;
+}
+
+inline bool operator!=(const CommonEntityInfo ,
+   const CommonEntityInfo ) {
+  return !(LHS == RHS);
+}
+
+/// Describes API notes for types.
+class CommonTypeInfo : public CommonEntityInfo {
+  /// The Swift type to which a given type is bridged.
+  ///
+  /// Reflects the swift_bridge attribute.
+  llvm::Optional SwiftBridge;
+
+  /// The NS error domain for this type.
+  llvm::Optional NSErrorDomain;
+
+public:
+  CommonTypeInfo() : CommonEntityInfo() {}
+
+  const llvm::Optional () const {
+return SwiftBridge;
+  }
+
+  void setSwiftBridge(const llvm::Optional ) {
+SwiftBridge = SwiftType;
+  }
+
+  void setSwiftBridge(const llvm::Optional ) {
+SwiftBridge = SwiftType
+  ? llvm::Optional(std::string(*SwiftType))
+  : llvm::None;
+  }
+
+  const llvm::Optional () const {
+return NSErrorDomain;
+  }
+
+  void setNSErrorDomain(const llvm::Optional ) {
+NSErrorDomain = Domain;
+  }
+
+  void setNSErrorDomain(const llvm::Optional ) {
+NSErrorDomain =
+Domain ? llvm::Optional(std::string(*Domain)) : 
llvm::None;
+  }
+
+  friend bool operator==(const CommonTypeInfo &, const 

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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

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


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

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



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

ABataev wrote:
> ABataev wrote:
> > `const` member functions.
> It may have side-effects with template instantiations. What if we have 
> something like this:
> ```
> #pragma omp begin assumes ...
> template 
> struct S {
> ...
> }
> #pragma omp end assumes
> 
> void bar() {
> #pragma omp assumes ...
>   {
> S s;
> s.foo();
>   }
> }
> ```
> ?
> 
> `struct S` will be instantiated in the second assume region context 
> though I doubt this is the user intention.
I'm not sure what problem you expect here. Could you elaborate what you think 
should happen or should not?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

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


[PATCH] D91996: [clang-format] Remove double trim

2020-11-23 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, krasimir, klimek.
HazardyKnusperkeks added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
HazardyKnusperkeks requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91996

Files:
  clang/lib/Format/BreakableToken.cpp


Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -776,7 +776,7 @@
   // We need to trim the blanks in case this is not the first line in a
   // multiline comment. Then the indent is included in Lines[i].
   StringRef IndentPrefix =
-  getLineCommentIndentPrefix(Lines[i].ltrim(Blanks), Style);
+  getLineCommentIndentPrefix(Lines[i], Style);
   assert((TokenText.startswith("//") || TokenText.startswith("#")) &&
  "unsupported line comment prefix, '//' and '#' are supported");
   OriginalPrefix[i] = Prefix[i] = IndentPrefix;


Index: clang/lib/Format/BreakableToken.cpp
===
--- clang/lib/Format/BreakableToken.cpp
+++ clang/lib/Format/BreakableToken.cpp
@@ -776,7 +776,7 @@
   // We need to trim the blanks in case this is not the first line in a
   // multiline comment. Then the indent is included in Lines[i].
   StringRef IndentPrefix =
-  getLineCommentIndentPrefix(Lines[i].ltrim(Blanks), Style);
+  getLineCommentIndentPrefix(Lines[i], Style);
   assert((TokenText.startswith("//") || TokenText.startswith("#")) &&
  "unsupported line comment prefix, '//' and '#' are supported");
   OriginalPrefix[i] = Prefix[i] = IndentPrefix;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

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

> 

For your example:

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

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

The previous behavior (according to your comment, with an older glibc) was 
undesired. So I think the right suggestion is to upgrade glibc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88712

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-23 Thread Alan Phipps via Phabricator via cfe-commits
alanphipps added a comment.

Looks like _LIBCPP_HAS_NO_THREADS is being set for libcxxabi, and the build now 
fails with this change:

llvm-project/libcxxabi/../libcxx/include/__config:1172:2: error: 
_LIBCPP_HAS_NO_THREADS cannot be set when __STDCPP_THREADS__ is set


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[PATCH] D91908: [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check

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

In D91908#2410240 , @smhc wrote:

> Thank you - I don't have commit access so am unable to merge it myself. The 
> clang-tidy tests are passing fine.

Just checking, Has this landed correctly, showing you are the author? I'm 
assuming https://github.com/smhc is correct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91908

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


[PATCH] D90282: [clang-tidy] Support IgnoredRegexp configuration to selectively suppress identifier naming checks

2020-11-23 Thread Shane via Phabricator via cfe-commits
smhc added a comment.

Yes I thought the same wrt the doco. There is also a hungarian notation config 
option in the works which does the same thing.

I nearly reworked it but figured it would be best done under a separate patch

It does have the potential to be less searchable through google for specific 
options. Automatic generation could be used instead if that is a problem.


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

https://reviews.llvm.org/D90282

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


[PATCH] D90282: [clang-tidy] Support IgnoredRegexp configuration to selectively suppress identifier naming checks

2020-11-23 Thread Shane via Phabricator via cfe-commits
smhc updated this revision to Diff 307177.
smhc marked an inline comment as done.
smhc added a comment.

Removed unnecessary diff


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

https://reviews.llvm.org/D90282

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp
@@ -0,0 +1,47 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.ParameterIgnoredRegexp, value: "^[a-z]{1,2}$"}, \
+// RUN: {key: readability-identifier-naming.ClassCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.ClassIgnoredRegexp, value: "^fo$|^fooo$"}, \
+// RUN: {key: readability-identifier-naming.StructCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.StructIgnoredRegexp, value: "sooo|so|soo|$invalidregex["} \
+// RUN:  ]}'
+
+int testFunc(int a, char **b);
+int testFunc(int ab, char **ba);
+int testFunc(int abc, char **cba);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'abc'
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'cba'
+// CHECK-FIXES: {{^}}int testFunc(int Abc, char **Cba);{{$}}
+int testFunc(int dE, char **eD);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'dE'
+// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: invalid case style for parameter 'eD'
+// CHECK-FIXES: {{^}}int testFunc(int DE, char **ED);{{$}}
+int testFunc(int Abc, char **Cba);
+
+class fo {
+};
+
+class fofo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'fofo'
+  // CHECK-FIXES: {{^}}class Fofo {{{$}}
+};
+
+class foo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'foo'
+  // CHECK-FIXES: {{^}}class Foo {{{$}}
+};
+
+class fooo {
+};
+
+class afooo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'afooo'
+  // CHECK-FIXES: {{^}}class Afooo {{{$}}
+};
+
+struct soo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'soo'
+  // CHECK-FIXES: {{^}}struct Soo {{{$}}
+};
Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -35,60 +35,60 @@
 
 The following options are describe below:
 
- - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`
+ - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`
  - :option:`AggressiveDependentMemberLookup`
- - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`
- - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`
- - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`
- - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix`
- - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`ConstantSuffix`
- - :option:`ConstantMemberCase`, :option:`ConstantMemberPrefix`, :option:`ConstantMemberSuffix`
- - :option:`ConstantParameterCase`, :option:`ConstantParameterPrefix`, :option:`ConstantParameterSuffix`
- - :option:`ConstantPointerParameterCase`, :option:`ConstantPointerParameterPrefix`, :option:`ConstantPointerParameterSuffix`
- - :option:`ConstexprFunctionCase`, :option:`ConstexprFunctionPrefix`, :option:`ConstexprFunctionSuffix`
- - :option:`ConstexprMethodCase`, :option:`ConstexprMethodPrefix`, :option:`ConstexprMethodSuffix`
- - :option:`ConstexprVariableCase`, :option:`ConstexprVariablePrefix`, :option:`ConstexprVariableSuffix`
- - :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix`
- - :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix`
- - :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix`
+ - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`, :option:`ClassIgnoredRegexp`
+ - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`, :option:`ClassConstantIgnoredRegexp`
+ - 

[PATCH] D91908: [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check

2020-11-23 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG269ef315d1be: [clang-tidy] Use compiled regex for 
AllowedRegexp in macro usage check (authored by smhc, committed by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91908

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp


Index: clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
@@ -32,8 +32,8 @@
 class MacroUsageCallbacks : public PPCallbacks {
 public:
   MacroUsageCallbacks(MacroUsageCheck *Check, const SourceManager ,
-  StringRef RegExp, bool CapsOnly, bool IgnoreCommandLine)
-  : Check(Check), SM(SM), RegExp(RegExp), CheckCapsOnly(CapsOnly),
+  StringRef RegExpStr, bool CapsOnly, bool 
IgnoreCommandLine)
+  : Check(Check), SM(SM), RegExp(RegExpStr), CheckCapsOnly(CapsOnly),
 IgnoreCommandLineMacros(IgnoreCommandLine) {}
   void MacroDefined(const Token ,
 const MacroDirective *MD) override {
@@ -47,7 +47,7 @@
   return;
 
 StringRef MacroName = MacroNameTok.getIdentifierInfo()->getName();
-if (!CheckCapsOnly && !llvm::Regex(RegExp).match(MacroName))
+if (!CheckCapsOnly && !RegExp.match(MacroName))
   Check->warnMacro(MD, MacroName);
 
 if (CheckCapsOnly && !isCapsOnly(MacroName))
@@ -57,7 +57,7 @@
 private:
   MacroUsageCheck *Check;
   const SourceManager 
-  StringRef RegExp;
+  const llvm::Regex RegExp;
   bool CheckCapsOnly;
   bool IgnoreCommandLineMacros;
 };


Index: clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
@@ -32,8 +32,8 @@
 class MacroUsageCallbacks : public PPCallbacks {
 public:
   MacroUsageCallbacks(MacroUsageCheck *Check, const SourceManager ,
-  StringRef RegExp, bool CapsOnly, bool IgnoreCommandLine)
-  : Check(Check), SM(SM), RegExp(RegExp), CheckCapsOnly(CapsOnly),
+  StringRef RegExpStr, bool CapsOnly, bool IgnoreCommandLine)
+  : Check(Check), SM(SM), RegExp(RegExpStr), CheckCapsOnly(CapsOnly),
 IgnoreCommandLineMacros(IgnoreCommandLine) {}
   void MacroDefined(const Token ,
 const MacroDirective *MD) override {
@@ -47,7 +47,7 @@
   return;
 
 StringRef MacroName = MacroNameTok.getIdentifierInfo()->getName();
-if (!CheckCapsOnly && !llvm::Regex(RegExp).match(MacroName))
+if (!CheckCapsOnly && !RegExp.match(MacroName))
   Check->warnMacro(MD, MacroName);
 
 if (CheckCapsOnly && !isCapsOnly(MacroName))
@@ -57,7 +57,7 @@
 private:
   MacroUsageCheck *Check;
   const SourceManager 
-  StringRef RegExp;
+  const llvm::Regex RegExp;
   bool CheckCapsOnly;
   bool IgnoreCommandLineMacros;
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 269ef31 - [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check

2020-11-23 Thread Nathan James via cfe-commits

Author: smhc
Date: 2020-11-23T20:46:43Z
New Revision: 269ef315d1beaff534a038b60389226b0f0f5d4f

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

LOG: [clang-tidy] Use compiled regex for AllowedRegexp in macro usage check

Current check compiles the regex on every attempt at matching. The check also 
populates and enables a regex value by default so the default behaviour results 
in regex re-compilation for every macro - if the check is enabled. If people 
used this check there's a reasonable chance they would have relatively complex 
regexes in use.

This is a quick and simple fix to store and use the compiled regex.

Reviewed By: njames93

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
index febc295d78e6..eb21bb44f63d 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp
@@ -32,8 +32,8 @@ bool isCapsOnly(StringRef Name) {
 class MacroUsageCallbacks : public PPCallbacks {
 public:
   MacroUsageCallbacks(MacroUsageCheck *Check, const SourceManager ,
-  StringRef RegExp, bool CapsOnly, bool IgnoreCommandLine)
-  : Check(Check), SM(SM), RegExp(RegExp), CheckCapsOnly(CapsOnly),
+  StringRef RegExpStr, bool CapsOnly, bool 
IgnoreCommandLine)
+  : Check(Check), SM(SM), RegExp(RegExpStr), CheckCapsOnly(CapsOnly),
 IgnoreCommandLineMacros(IgnoreCommandLine) {}
   void MacroDefined(const Token ,
 const MacroDirective *MD) override {
@@ -47,7 +47,7 @@ class MacroUsageCallbacks : public PPCallbacks {
   return;
 
 StringRef MacroName = MacroNameTok.getIdentifierInfo()->getName();
-if (!CheckCapsOnly && !llvm::Regex(RegExp).match(MacroName))
+if (!CheckCapsOnly && !RegExp.match(MacroName))
   Check->warnMacro(MD, MacroName);
 
 if (CheckCapsOnly && !isCapsOnly(MacroName))
@@ -57,7 +57,7 @@ class MacroUsageCallbacks : public PPCallbacks {
 private:
   MacroUsageCheck *Check;
   const SourceManager 
-  StringRef RegExp;
+  const llvm::Regex RegExp;
   bool CheckCapsOnly;
   bool IgnoreCommandLineMacros;
 };



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


[PATCH] D90282: [clang-tidy] Support IgnoredRegexp configuration to selectively suppress identifier naming checks

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

Just one last small nit.

// You can ignore this, nothing to do with this patch.
All these changes in the documentation tell me we should probably restructure 
the documentation for this check.
Right now we have NxM lines of documentation for each combination of style 
kind(N) and style option(M). 
This could probably be changed so we could describe each style option at the 
top of the documentation (`Case`, ` Prefix`,  ...)
Then we could describe each StyleKind afterwards.

  .. option:: ClassCase, option::ClassPrefix...
  
  Transforms class names
  .. code-block:: c++
  
  class  {
  };
  
  .. option:: FunctionCase, option::FunctionPrefix...
  
  Transforms class names
  .. code-block:: c++
  
  void (int Param0);




Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:149
+StyleString.append("IgnoredRegexp");
+std::string IgnoredRegexpStr = Options.get((StyleString).str(), "");
+StyleString.resize(StyleSize);

Dont need to use `str()` here


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

https://reviews.llvm.org/D90282

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-23 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D91747#2412212 , @rnk wrote:

> Does rG64802d48d51d651bd2e4567b2f228f8795569542 
>  fix it?

Yup, looks like it does. Thanks for the quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-23 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Does rG64802d48d51d651bd2e4567b2f228f8795569542 fix it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[clang] 64802d4 - Make check-clang depend on the LLVM split-file utility

2020-11-23 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2020-11-23T12:21:44-08:00
New Revision: 64802d48d51d651bd2e4567b2f228f8795569542

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

LOG: Make check-clang depend on the LLVM split-file utility

Fixes a recently added test that has this dependency. IMO this utility
is generally useful, so we should go ahead and take the new dependency.

Added: 


Modified: 
clang/test/CMakeLists.txt
llvm/utils/gn/secondary/clang/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 4e9a1840fec3..2aff029cfbf1 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -124,6 +124,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-readobj
 llvm-symbolizer
 opt
+split-file
 yaml2obj
 )
 

diff  --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn 
b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index 8f436ac10586..70f28c8b5812 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -164,6 +164,7 @@ group("test") {
 "//llvm/tools/llvm-readobj:symlinks",
 "//llvm/tools/llvm-symbolizer:symlinks",
 "//llvm/tools/opt",
+"//llvm/tools/split-file",
 "//llvm/utils/FileCheck",
 "//llvm/utils/count",
 "//llvm/utils/llvm-lit",



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


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

2020-11-23 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Currently `P0-P1` is valid and results in the program address space being 1, 
but this patch changes the semantics of that. How sure are you that nothing 
will break? I do not like the idea of reusing existing valid syntax to mean 
something else; if you want to introduce some notion of secondary program 
address spaces then the syntax should be different.

However, I don't understand why this is needed; can you not just change your 
`call void %ref()` to `call addrspace(1) void %ref()`? That gets parsed and 
type-checked


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-23 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I'll push a fix to add it to the cmake deps list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[PATCH] D90282: [clang-tidy] Support IgnoredRegexp configuration to selectively suppress identifier naming checks

2020-11-23 Thread Shane via Phabricator via cfe-commits
smhc added a comment.

Thanks for the reviews everyone, I have updated the title and summary.
Unfortunately I don't have push access to llvm - could someone help to push 
this please?


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

https://reviews.llvm.org/D90282

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


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

2020-11-23 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

The change to rename getProgramAddressSpace getDefaultProgramAddressSpace seems 
fine to me since it matches the GlobalsAddressSpace.

By the way, your test already seems to work (if you add an explicit `call 
addrspace(1) void %ref()` for llc: https://godbolt.org/z/bqYMdE


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

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


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

2020-11-23 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson requested changes to this revision.
arichardson added a comment.

I don't see why you would need multiple program address spaces to support calls 
to other address spaces. You can already do the following:

  define i32 @foo(i32) addrspace(1) {
  %ret = add i32 %0, 1
  ret i32 %ret
  }
  
  define i32 @bar() addrspace(0) {
  %call = call addrspace(1) i32 @foo(i32 1)
  ret i32 %call
  }

Isn't that sufficient for your WebAssembly changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91428

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


[PATCH] D90282: [clang-tidy] Support IgnoredRegexp configuration to selectively suppress identifier naming checks

2020-11-23 Thread Shane via Phabricator via cfe-commits
smhc updated this revision to Diff 307157.
smhc marked an inline comment as done.
smhc added a comment.

Fixed uk/us spelling difference as suggested


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

https://reviews.llvm.org/D90282

Files:
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-ignored-regexp.cpp
@@ -0,0 +1,47 @@
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config='{CheckOptions: [ \
+// RUN: {key: readability-identifier-naming.ParameterCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.ParameterIgnoredRegexp, value: "^[a-z]{1,2}$"}, \
+// RUN: {key: readability-identifier-naming.ClassCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.ClassIgnoredRegexp, value: "^fo$|^fooo$"}, \
+// RUN: {key: readability-identifier-naming.StructCase, value: CamelCase}, \
+// RUN: {key: readability-identifier-naming.StructIgnoredRegexp, value: "sooo|so|soo|$invalidregex["} \
+// RUN:  ]}'
+
+int testFunc(int a, char **b);
+int testFunc(int ab, char **ba);
+int testFunc(int abc, char **cba);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'abc'
+// CHECK-MESSAGES: :[[@LINE-2]]:30: warning: invalid case style for parameter 'cba'
+// CHECK-FIXES: {{^}}int testFunc(int Abc, char **Cba);{{$}}
+int testFunc(int dE, char **eD);
+// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: invalid case style for parameter 'dE'
+// CHECK-MESSAGES: :[[@LINE-2]]:29: warning: invalid case style for parameter 'eD'
+// CHECK-FIXES: {{^}}int testFunc(int DE, char **ED);{{$}}
+int testFunc(int Abc, char **Cba);
+
+class fo {
+};
+
+class fofo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'fofo'
+  // CHECK-FIXES: {{^}}class Fofo {{{$}}
+};
+
+class foo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'foo'
+  // CHECK-FIXES: {{^}}class Foo {{{$}}
+};
+
+class fooo {
+};
+
+class afooo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for class 'afooo'
+  // CHECK-FIXES: {{^}}class Afooo {{{$}}
+};
+
+struct soo {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for struct 'soo'
+  // CHECK-FIXES: {{^}}struct Soo {{{$}}
+};
Index: clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
@@ -35,60 +35,60 @@
 
 The following options are describe below:
 
- - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`
+ - :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`
  - :option:`AggressiveDependentMemberLookup`
- - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`
- - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`
- - :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`
- - :option:`ClassMethodCase`, :option:`ClassMethodPrefix`, :option:`ClassMethodSuffix`
- - :option:`ConstantCase`, :option:`ConstantPrefix`, :option:`ConstantSuffix`
- - :option:`ConstantMemberCase`, :option:`ConstantMemberPrefix`, :option:`ConstantMemberSuffix`
- - :option:`ConstantParameterCase`, :option:`ConstantParameterPrefix`, :option:`ConstantParameterSuffix`
- - :option:`ConstantPointerParameterCase`, :option:`ConstantPointerParameterPrefix`, :option:`ConstantPointerParameterSuffix`
- - :option:`ConstexprFunctionCase`, :option:`ConstexprFunctionPrefix`, :option:`ConstexprFunctionSuffix`
- - :option:`ConstexprMethodCase`, :option:`ConstexprMethodPrefix`, :option:`ConstexprMethodSuffix`
- - :option:`ConstexprVariableCase`, :option:`ConstexprVariablePrefix`, :option:`ConstexprVariableSuffix`
- - :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix`
- - :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix`
- - :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix`
+ - :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`, :option:`ClassIgnoredRegexp`
+ - :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`, 

[PATCH] D91915: [clang-tidy] Fix RenamerClangTidy checks trying to emit a fix that isnt a valid identifier

2020-11-23 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f3edc323a88: [clang-tidy] Fix RenamerClangTidy checks 
trying to emit a fix that isnt a valid… (authored by njames93).

Changed prior to commit:
  https://reviews.llvm.org/D91915?vs=306854=307156#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91915

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
@@ -25,3 +25,13 @@
 
   return 0;
 }
+
+int func3(int _0Bad) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for 
parameter '_0Bad'; cannot be fixed automatically [readability-identifier-naming]
+  // CHECK-FIXES: {{^}}int func3(int _0Bad) {{{$}}
+  if (_0Bad == 1) {
+// CHECK-FIXES: {{^}}  if (_0Bad == 1) {{{$}}
+return 2;
+  }
+  return 0;
+}
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -59,6 +59,9 @@
 /// automatically.
 ConflictsWithMacroDefinition,
 
+/// The fixup results in an identifier that is not a valid c/c++ 
identifier.
+FixInvalidIdentifier,
+
 /// Values pass this threshold will be ignored completely
 /// i.e no message, no fixup.
 IgnoreFailureThreshold,
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -10,6 +10,7 @@
 #include "ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -463,6 +464,8 @@
 Failure.FixStatus = ShouldFixStatus::ConflictsWithKeyword;
   else if (Ident->hasMacroDefinition())
 Failure.FixStatus = ShouldFixStatus::ConflictsWithMacroDefinition;
+} else if (!isValidIdentifier(Info.Fixup)) {
+  Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
 }
 
 Failure.Info = std::move(Info);
@@ -503,7 +506,8 @@
 static std::string
 getDiagnosticSuffix(const RenamerClangTidyCheck::ShouldFixStatus FixStatus,
 const std::string ) {
-  if (Fixup.empty())
+  if (Fixup.empty() ||
+  FixStatus == 
RenamerClangTidyCheck::ShouldFixStatus::FixInvalidIdentifier)
 return "; cannot be fixed automatically";
   if (FixStatus == RenamerClangTidyCheck::ShouldFixStatus::ShouldFix)
 return {};
@@ -517,7 +521,6 @@
   RenamerClangTidyCheck::ShouldFixStatus::ConflictsWithMacroDefinition)
 return "; cannot be fixed because '" + Fixup +
"' would conflict with a macro definition";
-
   llvm_unreachable("invalid ShouldFixStatus");
 }
 


Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
@@ -25,3 +25,13 @@
 
   return 0;
 }
+
+int func3(int _0Bad) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for parameter '_0Bad'; cannot be fixed automatically [readability-identifier-naming]
+  // CHECK-FIXES: {{^}}int func3(int _0Bad) {{{$}}
+  if (_0Bad == 1) {
+// CHECK-FIXES: {{^}}  if (_0Bad == 1) {{{$}}
+return 2;
+  }
+  return 0;
+}
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -59,6 +59,9 @@
 /// automatically.
 ConflictsWithMacroDefinition,
 
+/// The fixup results in an identifier that is not a valid c/c++ identifier.
+FixInvalidIdentifier,
+
 /// Values pass this threshold will be ignored completely
 /// i.e no message, no fixup.
 IgnoreFailureThreshold,
Index: 

[clang-tools-extra] 9f3edc3 - [clang-tidy] Fix RenamerClangTidy checks trying to emit a fix that isnt a valid identifier

2020-11-23 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-11-23T20:04:51Z
New Revision: 9f3edc323a88c1a179a0a5a9dc9a87a2964c0d48

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

LOG: [clang-tidy] Fix RenamerClangTidy checks trying to emit a fix that isnt a 
valid identifier

Addresses https://bugs.llvm.org/show_bug.cgi?id=48230.
Handle the case when the Fixup suggested isn't a valid c/c++ identifer.

Reviewed By: aaron.ballman, gribozavr2

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index 6a25813eb748..2bb97eca14ab 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -10,6 +10,7 @@
 #include "ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
@@ -463,6 +464,8 @@ void RenamerClangTidyCheck::check(const 
MatchFinder::MatchResult ) {
 Failure.FixStatus = ShouldFixStatus::ConflictsWithKeyword;
   else if (Ident->hasMacroDefinition())
 Failure.FixStatus = ShouldFixStatus::ConflictsWithMacroDefinition;
+} else if (!isValidIdentifier(Info.Fixup)) {
+  Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
 }
 
 Failure.Info = std::move(Info);
@@ -503,7 +506,8 @@ void RenamerClangTidyCheck::expandMacro(const Token 
,
 static std::string
 getDiagnosticSuffix(const RenamerClangTidyCheck::ShouldFixStatus FixStatus,
 const std::string ) {
-  if (Fixup.empty())
+  if (Fixup.empty() ||
+  FixStatus == 
RenamerClangTidyCheck::ShouldFixStatus::FixInvalidIdentifier)
 return "; cannot be fixed automatically";
   if (FixStatus == RenamerClangTidyCheck::ShouldFixStatus::ShouldFix)
 return {};
@@ -517,7 +521,6 @@ getDiagnosticSuffix(const 
RenamerClangTidyCheck::ShouldFixStatus FixStatus,
   RenamerClangTidyCheck::ShouldFixStatus::ConflictsWithMacroDefinition)
 return "; cannot be fixed because '" + Fixup +
"' would conflict with a macro definition";
-
   llvm_unreachable("invalid ShouldFixStatus");
 }
 

diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
index aabb80133939..fd5b32075cbe 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -59,6 +59,9 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
 /// automatically.
 ConflictsWithMacroDefinition,
 
+/// The fixup results in an identifier that is not a valid c/c++ 
identifier.
+FixInvalidIdentifier,
+
 /// Values pass this threshold will be ignored completely
 /// i.e no message, no fixup.
 IgnoreFailureThreshold,

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
index 12ddcf55c119..bee93c99976b 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-bugfix-name-conflicts.cpp
@@ -25,3 +25,13 @@ int func2(int Foo) {
 
   return 0;
 }
+
+int func3(int _0Bad) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: invalid case style for 
parameter '_0Bad'; cannot be fixed automatically [readability-identifier-naming]
+  // CHECK-FIXES: {{^}}int func3(int _0Bad) {{{$}}
+  if (_0Bad == 1) {
+// CHECK-FIXES: {{^}}  if (_0Bad == 1) {{{$}}
+return 2;
+  }
+  return 0;
+}



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


[PATCH] D91747: [Clang] Add __STDCPP_THREADS__ to standard predefine macros

2020-11-23 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi, it seems that `p2.cpp` is failing on our production builder 
(https://luci-milo.appspot.com/p/fuchsia/builders/prod/clang-linux-x64/b8862835022166171808):

  FAIL: Clang :: CXX/cpp/cpp.predefined/p2.cpp (1210 of 26900)
   TEST 'Clang :: CXX/cpp/cpp.predefined/p2.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   split-file 
/b/s/w/ir/x/w/llvm-project/clang/test/CXX/cpp/cpp.predefined/p2.cpp 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir
  : 'RUN: at line 2';   
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/lib/clang/12.0.0/include
 -nostdsysteminc -verify 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir/defined.cpp
  : 'RUN: at line 3';   
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/lib/clang/12.0.0/include
 -nostdsysteminc -verify -mthread-model posix 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir/defined.cpp
  : 'RUN: at line 4';   
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/lib/clang/12.0.0/include
 -nostdsysteminc -verify -mthread-model single 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir/not-defined.cpp
  : 'RUN: at line 5';   
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/bin/clang -cc1 
-internal-isystem 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/lib/clang/12.0.0/include
 -nostdsysteminc -verify -x c 
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.tmp.dir/not-defined.cpp
  --
  Exit Code: 127
  
  Command Output (stderr):
  --
  
/b/s/w/ir/x/w/staging/llvm_build/tools/clang/stage2-bins/tools/clang/test/CXX/cpp/cpp.predefined/Output/p2.cpp.script:
 line 1: split-file: command not found
  
  --
  
  
  Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
  
  Failed Tests (1):
Clang :: CXX/cpp/cpp.predefined/p2.cpp

This can be reproduced if you run clang tests before building llvm tools 
(running `check-clang` without running `check-llvm`). Should `split-file` be 
used here in the first place since it's an llvm tool? If so, should there be a 
way to force `check-clang` to build `split-file` before running tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91747

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


[PATCH] D91844: [llvm][clang] Add checks for the smart pointers with the possibility to be null

2020-11-23 Thread Alexey Lapshin via Phabricator via cfe-commits
avl added a comment.

The change for DWARFLinker is fine. I also think it is better to split the 
patch up into separate patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91844

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


[PATCH] D91507: [clang-format] Add option for case sensitive regexes for sorted includes

2020-11-23 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 307142.
HazardyKnusperkeks edited the summary of this revision.
HazardyKnusperkeks added a comment.

I've rebased it to master, ran the documentation script and have build the 
targets
clang-format clang-tidy pp-trace clang-include-fixer clangd clang-doc 
clang-move modularize clang-rename FormatTests successfully.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91507

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Tooling/Inclusions/IncludeStyle.h
  clang/lib/Format/Format.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/lib/Tooling/Inclusions/IncludeStyle.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/SortIncludesTest.cpp

Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -72,19 +72,19 @@
 TEST_F(SortIncludesTest, SortedIncludesUsingSortPriorityAttribute) {
   FmtStyle.IncludeStyle.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
   FmtStyle.IncludeStyle.IncludeCategories = {
-  {"^", 1, 0},
-  {"^", 1, 1},
-  {"^", 8, 10},
-  {"^\".*\\.h\"", 10, 12}};
+  {"^", 1, 0, false},
+  {"^", 1, 1, false},
+  {"^", 8, 10, false},
+  {"^\".*\\.h\"", 10, 12, false}};
   EXPECT_EQ("#include \n"
 "#include \n"
 "#include \n"
@@ -587,8 +587,59 @@
  "a_TEST.cc"));
 }
 
+TEST_F(SortIncludesTest, SupportOptionalCaseSensitiveMachting) {
+  Style.IncludeBlocks = clang::tooling::IncludeStyle::IBS_Regroup;
+  Style.IncludeCategories = {{"^\"", 1, 0, false},
+ {"^<.*\\.h>$", 2, 0, false},
+ {"^", 3, 0, false},
+ {"^", 4, 0, false},
+ {"^<", 5, 0, false}};
+
+  StringRef UnsortedCode = "#include \n"
+   "#include \"qt.h\"\n"
+   "#include \n"
+   "#include \n"
+   "#include \n"
+   "#include \"qa.h\"\n"
+   "#include \n"
+   "#include \n"
+   "#include \n";
+
+  EXPECT_EQ("#include \"qa.h\"\n"
+"#include \"qt.h\"\n"
+"\n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n",
+sort(UnsortedCode));
+
+  Style.IncludeCategories[2].RegexIsCaseSensitive = true;
+  Style.IncludeCategories[3].RegexIsCaseSensitive = true;
+  EXPECT_EQ("#include \"qa.h\"\n"
+"#include \"qt.h\"\n"
+"\n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n"
+"\n"
+"#include \n"
+"\n"
+"#include \n"
+"#include \n",
+sort(UnsortedCode));
+}
+
 TEST_F(SortIncludesTest, NegativePriorities) {
-  Style.IncludeCategories = {{".*important_os_header.*", -1, 0}, {".*", 1, 0}};
+  Style.IncludeCategories = {{".*important_os_header.*", -1, 0, false},
+ {".*", 1, 0, false}};
   EXPECT_EQ("#include \"important_os_header.h\"\n"
 "#include \"c_main.h\"\n"
 "#include \"a_other.h\"\n",
@@ -608,7 +659,8 @@
 }
 
 TEST_F(SortIncludesTest, PriorityGroupsAreSeparatedWhenRegroupping) {
-  Style.IncludeCategories = {{".*important_os_header.*", -1, 0}, {".*", 1, 0}};
+  Style.IncludeCategories = {{".*important_os_header.*", -1, 0, false},
+ {".*", 1, 0, false}};
   Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup;
 
   EXPECT_EQ("#include \"important_os_header.h\"\n"
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14524,12 +14524,13 @@
 
   Style.IncludeStyle.IncludeCategories.clear();
   std::vector ExpectedCategories = {
-  {"abc/.*", 2, 0}, {".*", 1, 0}};
+  {"abc/.*", 2, 0, false}, {".*", 1, 0, true}};
   CHECK_PARSE("IncludeCategories:\n"
   "  - Regex: abc/.*\n"
   "Priority: 2\n"
   "  - Regex: .*\n"
-  "Priority: 1",
+  "Priority: 1\n"
+  "CaseSensitive: true\n",
   IncludeStyle.IncludeCategories, ExpectedCategories);
   CHECK_PARSE("IncludeIsMainRegex: 'abc$'", IncludeStyle.IncludeIsMainRegex,
   "abc$");
Index: clang/lib/Tooling/Inclusions/IncludeStyle.cpp

[PATCH] D87974: [Builtin] Add __builtin_zero_non_value_bits.

2020-11-23 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

> Filed https://gcc.gnu.org/PR97943 for that. Avoiding the crash is trivial, 
> deciding what we want to do exactly for flexible array members (which are 
> beyond the C++ standard) is harder.

Yes, and we should try to do the same thing in this case. Currently, this 
implementation clears any padding bits that might come before the flexible 
array member but doesn't attempt to clear any of the array's padding bits 
(which I'm pretty sure wouldn't be feasible). So, what we're really deciding is 
whether or not to error for these types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87974

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


[clang] b3f1b19 - [AArch64] Update clang CodeGen tests I missed in 4252f7773a5b98b825d17e5f77c7d349cb2fb7c7.

2020-11-23 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-11-23T11:10:27-08:00
New Revision: b3f1b19c9cecd2ac8f8153aa25f8025dbd5702b8

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

LOG: [AArch64] Update clang CodeGen tests I missed in 
4252f7773a5b98b825d17e5f77c7d349cb2fb7c7.

These tests invoke opt and llc even though they are in the frontend.

We now do a better job of generating commuted patterns for fma so
these tests now form fmls instead of fmla+fneg.

Added: 


Modified: 
clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c

Removed: 




diff  --git a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c 
b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
index 7ebb7eb65057..3f88b6ed1db5 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -69,10 +69,9 @@ float16x8_t test_vfmaq_f16(float16x8_t a, float16x8_t b, 
float16x8_t c) {
 
 // COMMON-LABEL: test_vfms_f16
 // COMMONIR:   [[SUB:%.*]] = fneg <4 x half> %b
-// CHECK-ASM:  fneg v{{[0-9]+}}.4h, v{{[0-9]+}}.4h
 // UNCONSTRAINED:  [[ADD:%.*]] = call <4 x half> @llvm.fma.v4f16(<4 x half> 
[[SUB]], <4 x half> %c, <4 x half> %a)
 // CONSTRAINED:[[ADD:%.*]] = call <4 x half> 
@llvm.experimental.constrained.fma.v4f16(<4 x half> [[SUB]], <4 x half> %c, <4 
x half> %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-// CHECK-ASM:  fmla v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h
+// CHECK-ASM:  fmls v{{[0-9]+}}.4h, v{{[0-9]+}}.4h, v{{[0-9]+}}.4h
 // COMMONIR:   ret <4 x half> [[ADD]]
 float16x4_t test_vfms_f16(float16x4_t a, float16x4_t b, float16x4_t c) {
   return vfms_f16(a, b, c);
@@ -80,10 +79,9 @@ float16x4_t test_vfms_f16(float16x4_t a, float16x4_t b, 
float16x4_t c) {
 
 // COMMON-LABEL: test_vfmsq_f16
 // COMMONIR:   [[SUB:%.*]] = fneg <8 x half> %b
-// CHECK-ASM:  fneg v{{[0-9]+}}.8h, v{{[0-9]+}}.8h
 // UNCONSTRAINED:  [[ADD:%.*]] = call <8 x half> @llvm.fma.v8f16(<8 x half> 
[[SUB]], <8 x half> %c, <8 x half> %a)
 // CONSTRAINED:[[ADD:%.*]] = call <8 x half> 
@llvm.experimental.constrained.fma.v8f16(<8 x half> [[SUB]], <8 x half> %c, <8 
x half> %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-// CHECK-ASM:  fmla v{{[0-9]+}}.8h, v{{[0-9]+}}.8h, v{{[0-9]+}}.8h
+// CHECK-ASM:  fmls v{{[0-9]+}}.8h, v{{[0-9]+}}.8h, v{{[0-9]+}}.8h
 // COMMONIR:   ret <8 x half> [[ADD]]
 float16x8_t test_vfmsq_f16(float16x8_t a, float16x8_t b, float16x8_t c) {
   return vfmsq_f16(a, b, c);



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


[PATCH] D90928: [OpenCL] Check for extension string extension lookup

2020-11-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:47
   bool isSupported(llvm::StringRef Ext, const LangOptions ) const {
+auto E = OptMap.find(Ext);
+if (E == OptMap.end()) {

erik2020 wrote:
> Anastasia wrote:
> > Btw how about we use `isKnown` instead because it does exactly that? Also, 
> > I think we should update the comment to explain this change in the API 
> > behavior and add a comment for `isKnown`. 
> My thinking was that this way, there's only one look-up in `OptMap`, but when 
> using `isKnown()` there are two. I don't know how good a compiler would be at 
> inlining `isKnown()` and de-duplicating the look-ups.
> 
> But maybe the overhead doesn't really matter in this case and calling 
> `isKnown()` is clearer?
I would say it is likely to be inlined in the optimized builds, removing 
duplicate calls to find would be trickier but since it's part of the standard 
libraries I think it is very likely going to happen.

Ok, if you are concerned about the performance we can leave it as is and only 
update the comments. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90928

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


[PATCH] D91531: [RFC][OpenCL] Provide mechanisms for defining extension macros

2020-11-23 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D91531#2411725 , @azabaznov wrote:

>> Perhaps if you give me an example it would help to understand
>
> I was meant that this can potentially be used to undefine macros inside clang 
> directly. In this case there will no need to add a lot of conditional 
> preprocessor directives in the header, also the existing interface 
> (`-cl-ext=-cl_khr_depth_images`) will be preserved. So for example in the 
> header there was specified an extension definition. Can undef directive be 
> allocated and bound to a specific source location right after extension 
> definition if `-cl-ext=-cl_khr_depth_images` was specifed:
>
>   #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ == 
> CL_VERSION_2_0) || \
>   (__OPENCL_C_VERSION__ >= CL_VERSION_1_2  && defined(__SPIR__) )
>   #define cl_khr_depth_images 1
>   #endif
>   
>   // Bind undef directive here
>
> I understand that this sounds tricky, but preserving interface sound 
> reasonable for me.

Yes, preserving the interface is not unreasonable indeed. So if I understand it 
well you are suggesting to perform a check for every parsed macro definition 
that would identify whether the macro has a name matching what is provided in 
`-cl-ext=`? Then if the name matches it would check whether the macro should be 
defined or not? I feel this might be a bit too costly to justify the gain. That 
means that not every user would agree on such a mechanism to be enabled by 
default i.e. it means we would need to provide an alternative interface anyway.


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

https://reviews.llvm.org/D91531

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


[clang] 47eb5ce - [mac/arm] fix clang/test/Driver/darwin-ld-dedup.c

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

Author: Nico Weber
Date: 2020-11-23T13:32:29-05:00
New Revision: 47eb5ce19ab10bcfe00af04e6a6e39613e2cb3c9

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

LOG: [mac/arm] fix clang/test/Driver/darwin-ld-dedup.c

The test needs an object file, which it currenty gets with
`-target x86_64-apple-darwin10`.  Rather than adding `REQUIRES: X86`, create
the object file via yaml2obj. This way, the test runs and passes even if the
host arch isn't x86 and only the host arch is built.

Part of PR46644.

Added: 
clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml

Modified: 
clang/test/CMakeLists.txt
clang/test/Driver/darwin-ld-dedup.c
clang/test/lit.cfg.py
llvm/utils/gn/secondary/clang/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 1eb434e192db..4e9a1840fec3 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -124,6 +124,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-readobj
 llvm-symbolizer
 opt
+yaml2obj
 )
 
   if(TARGET llvm-lto)

diff  --git a/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml 
b/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml
new file mode 100644
index ..c4561050b8b6
--- /dev/null
+++ b/clang/test/Driver/Inputs/empty-x86_64-apple-darwin.yaml
@@ -0,0 +1,44 @@
+# Created by `clang -target x86_64-apple-darwin10 -c -x c /dev/null -o - | 
obj2yaml`.
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x107
+  cpusubtype:  0x3
+  filetype:0x1
+  ncmds:   2
+  sizeofcmds:  176
+  flags:   0x2000
+  reserved:0x0
+LoadCommands:
+  - cmd: LC_SEGMENT_64
+cmdsize: 152
+segname: ''
+vmaddr:  0
+vmsize:  0
+fileoff: 208
+filesize:0
+maxprot: 7
+initprot:7
+nsects:  1
+flags:   0
+Sections:
+  - sectname:__text
+segname: __TEXT
+addr:0x0
+size:0
+offset:  0xD0
+align:   0
+reloff:  0x0
+nreloc:  0
+flags:   0x8000
+reserved1:   0x0
+reserved2:   0x0
+reserved3:   0x0
+content: ''
+  - cmd: LC_BUILD_VERSION
+cmdsize: 24
+platform:1
+minos:   720896
+sdk: 720896
+ntools:  0
+...

diff  --git a/clang/test/Driver/darwin-ld-dedup.c 
b/clang/test/Driver/darwin-ld-dedup.c
index a06ca7bebe57..1d866f40291a 100644
--- a/clang/test/Driver/darwin-ld-dedup.c
+++ b/clang/test/Driver/darwin-ld-dedup.c
@@ -29,7 +29,7 @@
 // Do *not* add -no_deduplicate when no -O option is specified and this is 
just a link
 // (since we can't imply -O0)
 // RUN: rm -f %t.o %t.bin
-// RUN: %clang -target x86_64-apple-darwin10 -c -o %t.o %s
+// RUN: yaml2obj %S/Inputs/empty-x86_64-apple-darwin.yaml -o %t.o
 // RUN: %clang -target x86_64-apple-darwin10 %t.o -### -mlinker-version=262 \
 // RUN:   -o %t.bin 2>&1 | FileCheck -check-prefix=LINK_DEDUP %s
 // RUN: %clang -target x86_64-apple-darwin10 %t.o -### -mlinker-version=262 \

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 1a6e73ed9783..863ab444fb02 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -64,7 +64,7 @@
 
 tools = [
 'apinotes-test', 'c-index-test', 'clang-
diff ', 'clang-format',
-'clang-tblgen', 'opt', 'llvm-ifs',
+'clang-tblgen', 'opt', 'llvm-ifs', 'yaml2obj',
 ToolSubst('%clang_extdef_map', command=FindTool(
 'clang-extdef-mapping'), unresolved='ignore'),
 ]

diff  --git a/llvm/utils/gn/secondary/clang/test/BUILD.gn 
b/llvm/utils/gn/secondary/clang/test/BUILD.gn
index 9219d2d7bfad..8f436ac10586 100644
--- a/llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -168,6 +168,7 @@ group("test") {
 "//llvm/utils/count",
 "//llvm/utils/llvm-lit",
 "//llvm/utils/not",
+"//llvm/tools/yaml2obj",
   ]
   if (clang_enable_arcmt) {
 deps += [



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


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

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



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

ABataev wrote:
> `const` member functions.
It may have side-effects with template instantiations. What if we have 
something like this:
```
#pragma omp begin assumes ...
template 
struct S {
...
}
#pragma omp end assumes

void bar() {
#pragma omp assumes ...
  {
S s;
s.foo();
  }
}
```
?

`struct S` will be instantiated in the second assume region context though 
I doubt this is the user intention.



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

`const` member functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

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


[PATCH] D91975: clang-tidy: detect narrowing conversions involving typedefs

2020-11-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added subscribers: gchatelet, courbet, lebedev.ri.
lebedev.ri edited reviewers, added: aaron.ballman, njames93; removed: 
gchatelet, courbet.
lebedev.ri added a comment.
This revision now requires review to proceed.

Whoa, that's a fun bug :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91975

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


[PATCH] D91979: [Clang][Attr] Introduce the `assume` function attribute

2020-11-23 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Swift uses a similar mechanism:
https://github.com/apple/swift/blob/887464b7b67d5202bfa7adc4e3f045ff1027a5a7/stdlib/public/core/Array.swift#L829


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91979

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


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

2020-11-23 Thread Venkataramanan Kumar via Phabricator via cfe-commits
venkataramanan.kumar.llvm added a comment.

Hi,

I am on Ubuntu 18 machine and it has finite math header .
This header is included by the glibc 2.27.  This header has this following 
definition.
extern double log (double) __asm__ ("" "__log_finite") __attribute__ 
((__nothrow__ ));

Consider the following test case

#include 
double mylog (double d) {

  return log(d);

}

Before this patch clang generates  -O2 -ffast-math
--Snip--
; Function Attrs: nounwind readnone uwtable
define dso_local double @mlog(double %d) local_unnamed_addr #0 {
entry:

  %0 = tail call fast double @llvm.log.f64(double %d)
  ret double %0

}
---Snip--

After this patch  on machines with lesser glibc versions,  for -O2 -ffast-math, 
clang generates

--Snip--
; Function Attrs: nounwind readnone uwtable
define dso_local double @mlog(double %d) local_unnamed_addr #0 {
entry:

  %call = tail call fast double @__log_finite(double %d) #2
  ret double %call

}
--Snip--

Note on latest Ubuntu 20.04.1 LTS with Glibc 2.31  header 
is not present
It is removed by glibc.  so there I see the @llvm.log.f64 intrinsic calls.

So on machines with lesser glibc versions where the header file is present this 
will be a problem.
Note the LLVM "opt" does optimizations like vectorization only on the 
intrinsic, but ignores the calls to  @__log_finite.

Example https://llvm.godbolt.org/z/765We8

I am not sure if this known issue.

It is causing some performance issues with some benchmarks  on my ubuntu 18 
machine.

Shall I file a PR for this ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88712

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


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

2020-11-23 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, aaron.ballman, jhuber6, grokos, 
ggeorgakoudis, ABataev.
Herald added subscribers: llvm-commits, guansong, bollu, yaxunl.
Herald added projects: clang, LLVM.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.

The `assumes` directive is an OpenMP 5.1 feature that allows the user to
provide assumptions to the optimizer. Assumptions can refer to
directives (`absent` and `contains` clauses), expressions (`holds`
clause), or generic properties (`no_openmp_routines`, `ext_ABCD`, ...).

The `assumes` spelling is used for assumptions in the global scope while
`assume` is used for executable contexts with an associated structured
block.

This patch only implements the global spellings. While clauses with
arguments are "accepted" by the parser, they will simply be ignored for
now. The implementation lowers the assumptions directly to the
`AssumptionAttr`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91980

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/assumes_codegen.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/assumes_messages.c
  clang/test/OpenMP/assumes_print.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -1560,6 +1560,9 @@
 VersionedClause
   ];
 }
+def OMP_Assumes : Directive<"assumes"> {}
+def OMP_BeginAssumes : Directive<"begin assumes"> {}
+def OMP_EndAssumes : Directive<"end assumes"> {}
 def OMP_BeginDeclareVariant : Directive<"begin declare variant"> {}
 def OMP_EndDeclareVariant : Directive<"end declare variant"> {}
 def OMP_ParallelWorkshare : Directive<"parallel workshare"> {
Index: clang/test/OpenMP/assumes_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/assumes_print.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+void foo() {
+}
+
+#pragma omp assumes no_openmp_routines
+
+#pragma omp assumes no_openmp
+
+#pragma omp begin assumes ext_range_bar_only
+
+#pragma omp begin assumes ext_range_bar_only_2
+
+void bar() {
+}
+
+#pragma omp end assumes
+#pragma omp end assumes
+
+#pragma omp begin assumes ext_not_seen
+#pragma omp end assumes
+
+#pragma omp begin assumes ext_1234
+void baz() {
+}
+#pragma omp end assumes
+
+
+// CHECK: void foo() __attribute__((assume("no_openmp_routines"))) __attribute__((assume("no_openmp")))
+// CHECK: void bar() __attribute__((assume("range_bar_only"))) __attribute__((assume("range_bar_only_2"))) __attribute__((assume("no_openmp_routines"))) __attribute__((assume("no_openmp")))
+// CHECK: void baz() __attribute__((assume("1234"))) __attribute__((assume("no_openmp_routines"))) __attribute__((assume("no_openmp")))
+
+#endif
Index: clang/test/OpenMP/assumes_messages.c
===
--- /dev/null
+++ clang/test/OpenMP/assumes_messages.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp -x c -std=c99 -fms-extensions -Wno-pragma-pack %s
+
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -verify -fopenmp-simd -x c -std=c99 -fms-extensions -Wno-pragma-pack %s
+
+#pragma omp assumes // expected-error {{'assumes' directive requires at least one clause}}
+#pragma omp begin // expected-error {{expected an OpenMP directive}}
+#pragma omp begin assumes // expected-error {{'begin assumes' directive requires at least one clause}}
+#pragma omp end assumes
+
+#pragma omp assumes foobar // expected-warning {{valid assumes clauses start with 'ext_', 'absent', 'contains', 'holds', 'no_openmp', 'no_openmp_routines', 'no_parallelism'; token will be ignored}}
+#pragma omp begin assumes foobar // expected-warning {{valid begin assumes clauses start with 'ext_', 'absent', 'contains', 'holds', 'no_openmp', 'no_openmp_routines', 'no_parallelism'; token will be ignored}}
+#pragma omp end assumes
+
+#pragma omp begin assumes foobar(foo 2 no_openmp // expected-error {{expected ')'}} expected-warning {{valid begin assumes clauses start with 'ext_', 'absent', 'contains', 'holds', 

[PATCH] D91979: [Clang][Attr] Introduce the `assume` function attribute

2020-11-23 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: JonChesterfield, aaron.ballman, jhuber6.
Herald added a subscriber: bollu.
Herald added a project: clang.
jdoerfert requested review of this revision.
Herald added a subscriber: sstefan1.

The `assume` attribute is a way to provide additional, arbitrary
information to the optimizer. For now, assumptions are restricted to
strings which will be accumulated for a function and emitted as comma
separated string function attribute. The key of the LLVM-IR function
attribute is `llvm.assume`. Similar to `llvm.assume` and
`__builtin_assume`, the `assume` attribute provides a user defined
assumption to the compiler.

A follow up patch will introduce an LLVM-core API to query the
assumptions attached to a function. We also expect to add more options,
e.g., expression arguments, to the `assume` attribute later on.

The `omp [begin] asssumes` pragma will leverage this attribute and
expose the functionality in the absence of OpenMP.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91979

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/assume_attr.c
  clang/test/CodeGenCXX/assume_attr.cpp

Index: clang/test/CodeGenCXX/assume_attr.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/assume_attr.cpp
@@ -0,0 +1,120 @@
+// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu %s -o - | FileCheck %s
+// RUN: %clang_cc1 -x c++ -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+/// foo: declarations only
+
+__attribute__((assume("foo:before1"))) void foo();
+
+__attribute__((assume("foo:before2")))
+__attribute__((assume("foo:before3"))) void
+foo();
+
+/// baz: static function declarations and a definition
+
+__attribute__((assume("baz:before1"))) static void baz();
+
+__attribute__((assume("baz:before2")))
+__attribute__((assume("baz:before3"))) static void
+baz();
+
+// Definition
+__attribute__((assume("baz:def1,baz:def2"))) static void baz() { foo(); }
+
+__attribute__((assume("baz:after"))) static void baz();
+
+/// bar: external function declarations and a definition
+
+__attribute__((assume("bar:before1"))) void bar();
+
+__attribute__((assume("bar:before2")))
+__attribute__((assume("bar:before3"))) void
+bar();
+
+// Definition
+__attribute__((assume("bar:def1,bar:def2"))) void bar() { baz(); }
+
+__attribute__((assume("bar:after"))) void bar();
+
+/// back to foo
+
+__attribute__((assume("foo:after"))) void foo();
+
+/// class tests
+class C {
+  __attribute__((assume("C:private_method"))) void private_method();
+  __attribute__((assume("C:private_static"))) static void private_static();
+
+public:
+  __attribute__((assume("C:public_method1"))) void public_method();
+  __attribute__((assume("C:public_static1"))) static void public_static();
+};
+
+__attribute__((assume("C:public_method2"))) void C::public_method() {
+  private_method();
+}
+
+__attribute__((assume("C:public_static2"))) void C::public_static() {
+  private_static();
+}
+
+/// template tests
+template 
+__attribute__((assume("template_func"))) void template_func() {}
+
+template <>
+__attribute__((assume("template_func"))) void template_func() {}
+
+template <>
+void template_func() {}
+
+template 
+struct S {
+  __attribute__((assume("S::method"))) void method();
+};
+
+template <>
+__attribute__((assume("S::method"))) void S::method() {}
+
+template <>
+void S::method() {}
+
+// CHECK: define void @_Z3barv() #0
+// CHECK: define internal void @_ZL3bazv() #1
+// CHECK: define void @_ZN1C13public_methodEv(%class.C* %this) #2
+// CHECK: declare void @_ZN1C14private_methodEv(%class.C*) #3
+// CHECK: define void @_ZN1C13public_staticEv() #4
+// CHECK: declare void @_ZN1C14private_staticEv() #5
+// CHECK: define void @_Z13template_funcIfEvv() #6
+// CHECK: define void @_Z13template_funcIiEvv() #7
+// CHECK: define void @_ZN1SIfE6methodEv(%struct.S* %this) #8
+// CHECK: define void @_ZN1SIiE6methodEv(%struct.S.0* %this) #9
+// CHECK: declare void @_Z3foov() #10
+// CHECK: attributes #0
+// CHECK-SAME:  "llvm.assume"="bar:before1,bar:before2,bar:before3,bar:def1,bar:def2"
+// CHECK: attributes #1
+// CHECK-SAME:  "llvm.assume"="baz:before1,baz:before2,baz:before3,baz:def1,baz:def2,baz:after"
+// CHECK: attributes #2
+// CHECK-SAME:  "llvm.assume"="C:public_method1,C:public_method2"
+// CHECK: attributes #3
+// CHECK-SAME:  "llvm.assume"="C:private_method"
+// CHECK: attributes #4
+// CHECK-SAME:  "llvm.assume"="C:public_static1,C:public_static2"
+// CHECK: attributes #5
+// CHECK-SAME:  

[clang] e0e334a - [mac/arm] make clang/test/Driver/clang_f_opts.c pass consistently

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

Author: Nico Weber
Date: 2020-11-23T12:56:52-05:00
New Revision: e0e334a9c1ace7dd9339ca6cb5866ff7b7885e11

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

LOG: [mac/arm] make clang/test/Driver/clang_f_opts.c pass consistently

Part of PR46644, see comment 7/8.

Added: 


Modified: 
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index 27380413b7fe..123ad7e2aa99 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -541,6 +541,12 @@
 // CHECK-NO-RECORD-GCC-SWITCHES-NOT: "-record-command-line"
 // CHECK-RECORD-GCC-SWITCHES-ERROR: error: unsupported option 
'-frecord-command-line' for target
 // Test when clang is in a path containing a space.
+// The initial `rm` is a workaround for https://openradar.appspot.com/FB8914243
+// (Scenario: Run tests once, `clang` gets copied and run at new location and 
signature
+// is cached at the new clang's inode, then clang is changed, tests run again, 
old signature
+// is still cached with old clang's inode, so it won't execute this time. 
Removing the dir
+// first guarantees a new inode without old cache entries.)
+// RUN: rm -rf "%t.r/with spaces"
 // RUN: mkdir -p "%t.r/with spaces"
 // RUN: cp %clang "%t.r/with spaces/clang"
 // RUN: "%t.r/with spaces/clang" -### -S -target x86_64-unknown-linux 
-frecord-gcc-switches %s 2>&1 | FileCheck 
-check-prefix=CHECK-RECORD-GCC-SWITCHES-ESCAPED %s



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


[PATCH] D86097: [OpenMP][AMDGCN] Generate global variables and attributes for AMDGCN

2020-11-23 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 307108.
saiislam added a comment.

1. Simplifies overall patch after D90248 .
2. Removes MaxParallelLevel and thus target specific PrePostActionTy.
3. Removes ExternallyInitialized qualifier from shared variables for AMDGCN.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86097

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeAMDGCN.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h

Index: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
===
--- clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -27,6 +27,7 @@
 public:
   explicit CGOpenMPRuntimeNVPTX(CodeGenModule );
 
+private:
   /// Get the GPU warp size.
   llvm::Value *getGPUWarpSize(CodeGenFunction ) override;
 
@@ -35,6 +36,20 @@
 
   /// Get the maximum number of threads in a block of the GPU.
   llvm::Value *getGPUNumThreads(CodeGenFunction ) override;
+
+  /// Target independent wrapper over target specific emitSPMDKernel()
+  void emitSPMDKernelWrapper(const OMPExecutableDirective ,
+ StringRef ParentName, llvm::Function *,
+ llvm::Constant *, bool IsOffloadEntry,
+ const RegionCodeGenTy ) override;
+
+  /// Target independent wrapper over target specific emitNonSPMDKernel()
+  void emitNonSPMDKernelWrapper(const OMPExecutableDirective ,
+StringRef ParentName,
+llvm::Function *,
+llvm::Constant *,
+bool IsOffloadEntry,
+const RegionCodeGenTy ) override;
 };
 
 } // CodeGen namespace.
Index: clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -30,6 +30,7 @@
 : CGOpenMPRuntimeGPU(CGM) {
   if (!CGM.getLangOpts().OpenMPIsDevice)
 llvm_unreachable("OpenMP NVPTX can only handle device code.");
+  KernelStaticGlobalizedLinkage = llvm::GlobalValue::InternalLinkage;
 }
 
 llvm::Value *CGOpenMPRuntimeNVPTX::getGPUWarpSize(CodeGenFunction ) {
@@ -54,3 +55,19 @@
   (), llvm::Intrinsic::nvvm_read_ptx_sreg_ntid_x);
   return Bld.CreateCall(F, llvm::None, "nvptx_num_threads");
 }
+
+void CGOpenMPRuntimeNVPTX::emitSPMDKernelWrapper(
+const OMPExecutableDirective , StringRef ParentName,
+llvm::Function *, llvm::Constant *,
+bool IsOffloadEntry, const RegionCodeGenTy ) {
+  emitSPMDKernel(D, ParentName, OutlinedFn, OutlinedFnID, IsOffloadEntry,
+ CodeGen);
+}
+
+void CGOpenMPRuntimeNVPTX::emitNonSPMDKernelWrapper(
+const OMPExecutableDirective , StringRef ParentName,
+llvm::Function *, llvm::Constant *,
+bool IsOffloadEntry, const RegionCodeGenTy ) {
+  emitNonSPMDKernel(D, ParentName, OutlinedFn, OutlinedFnID, IsOffloadEntry,
+CodeGen);
+}
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
@@ -33,6 +33,11 @@
 /// Unknown execution mode (orphaned directive).
 EM_Unknown,
   };
+
+protected:
+  /// Linkage type of KernelStaticGlobalized variable
+  llvm::GlobalValue::LinkageTypes KernelStaticGlobalizedLinkage;
+
 private:
   /// Parallel outlined function work for workers to execute.
   llvm::SmallVector Work;
@@ -99,6 +104,7 @@
   uint64_t Size, int32_t Flags,
   llvm::GlobalValue::LinkageTypes Linkage) override;
 
+protected:
   /// Emit outlined function specialized for the Fork-Join
   /// programming model for applicable target directives on the NVPTX device.
   /// \param D Directive to emit.
@@ -129,6 +135,7 @@
   llvm::Constant *, bool IsOffloadEntry,
   const RegionCodeGenTy );
 
+private:
   /// Emit outlined function for 'target' directive on the NVPTX
   /// device.
   /// \param D Directive to emit.
@@ -211,6 +218,22 @@
   /// Get the maximum number of threads in a block of the GPU.
   virtual llvm::Value *getGPUNumThreads(CodeGenFunction ) = 0;
 
+  /// Target independent wrapper over target specific emitSPMDKernel()
+  virtual void emitSPMDKernelWrapper(const OMPExecutableDirective ,
+ StringRef ParentName,
+ llvm::Function *,
+ llvm::Constant *,
+   

[PATCH] D90928: [OpenCL] Check for extension string extension lookup

2020-11-23 Thread Erik Tomusk via Phabricator via cfe-commits
erik2020 added inline comments.



Comment at: clang/include/clang/Basic/OpenCLOptions.h:47
   bool isSupported(llvm::StringRef Ext, const LangOptions ) const {
+auto E = OptMap.find(Ext);
+if (E == OptMap.end()) {

Anastasia wrote:
> Btw how about we use `isKnown` instead because it does exactly that? Also, I 
> think we should update the comment to explain this change in the API behavior 
> and add a comment for `isKnown`. 
My thinking was that this way, there's only one look-up in `OptMap`, but when 
using `isKnown()` there are two. I don't know how good a compiler would be at 
inlining `isKnown()` and de-duplicating the look-ups.

But maybe the overhead doesn't really matter in this case and calling 
`isKnown()` is clearer?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90928

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


[PATCH] D91975: clang-tidy: detect narrowing conversions involving typedefs

2020-11-23 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet accepted this revision.
gchatelet added a comment.
This revision is now accepted and ready to land.

Thx for the patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91975

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


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

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

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91676

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


  1   2   3   >