Re: r355698 - Re-fix _lrotl/_lrotr to always take Long, no matter the platform.

2020-02-26 Thread James Y Knight via cfe-commits
I'm not clear as to what you're saying is broken.

On MS platforms, long is 32-bit, so either way this function takes a 32bit
value, right? And, Microsoft's docs say this function takes a long.


On Wed, Feb 26, 2020, 5:09 PM Michael Spencer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> I believe this commit is wrong. These intrinsics were originally
> implemented to support Windows code which expects _lrot{l,r}'s first
> argument to be 32 bits, it's a breaking change to change these definitions.
> I'm fine with adding the Intel version of these intrinsics, but you can't
> just break the Microsoft version of them.
>
> - Michael Spencer
>
> On Fri, Mar 8, 2019 at 7:09 AM Erich Keane via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: erichkeane
>> Date: Fri Mar  8 07:10:07 2019
>> New Revision: 355698
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=355698=rev
>> Log:
>> Re-fix _lrotl/_lrotr to always take Long, no matter the platform.
>>
>> r355322 fixed this, however is being reverted due to concerns with
>> enabling it in other modes.
>>
>> Change-Id: I6a939b7469b8fa196d5871a627eb2330dbd30f29
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/Builtins.def
>> cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
>>
>> Modified: cfe/trunk/include/clang/Basic/Builtins.def
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=355698=355697=355698=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
>> +++ cfe/trunk/include/clang/Basic/Builtins.def Fri Mar  8 07:10:07 2019
>> @@ -831,12 +831,12 @@ LANGBUILTIN(_ReturnAddress, "v*", "n", A
>>  LANGBUILTIN(_rotl8,  "UcUcUc","n", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(_rotl16, "UsUsUc","n", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(_rotl,   "UiUii", "n", ALL_MS_LANGUAGES)
>> -LANGBUILTIN(_lrotl,  "UNiUNii",   "n", ALL_MS_LANGUAGES)
>> +LANGBUILTIN(_lrotl,  "ULiULii",   "n", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(_rotl64, "UWiUWii",   "n", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(_rotr8,  "UcUcUc","n", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(_rotr16, "UsUsUc","n", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(_rotr,   "UiUii", "n", ALL_MS_LANGUAGES)
>> -LANGBUILTIN(_lrotr,  "UNiUNii",   "n", ALL_MS_LANGUAGES)
>> +LANGBUILTIN(_lrotr,  "ULiULii",   "n", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(_rotr64, "UWiUWii",   "n", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(__va_start,   "vc**.", "nt", ALL_MS_LANGUAGES)
>>  LANGBUILTIN(__fastfail, "vUi","nr", ALL_MS_LANGUAGES)
>>
>> Modified: cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c?rev=355698=355697=355698=diff
>>
>> ==
>> --- cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c (original)
>> +++ cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c Fri Mar  8 07:10:07
>> 2019
>> @@ -12,17 +12,10 @@
>>  // RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
>>  // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility
>> -fms-compatibility-version=17.00 \
>>  // RUN: -triple x86_64--linux -emit-llvm %s -o - \
>> -// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
>> +// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
>>  // RUN: %clang_cc1 -ffreestanding -fms-extensions \
>>  // RUN: -triple x86_64--darwin -emit-llvm %s -o - \
>> -// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
>> -
>> -// LP64 targets use 'long' as 'int' for MS intrinsics (-fms-extensions)
>> -#ifdef __LP64__
>> -#define LONG int
>> -#else
>> -#define LONG long
>> -#endif
>> +// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
>>
>>  // rotate left
>>
>> @@ -47,12 +40,15 @@ unsigned int test_rotl(unsigned int valu
>>  // CHECK:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32
>> [[X]], i32 [[Y:%.*]])
>>  // CHECK:   ret i32 [[R]]
>>
>> -unsigned LONG test_lrotl(unsigned LONG value, int shift) {
>> +unsigned long test_lrotl(unsigned long value, int shift) {
>>return _lrotl(value, shift);
>>  }
>>  // CHECK-32BIT-LONG: i32 @test_lrotl
>>  // CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32
>> [[X:%.*]], i32 [[X]], i32 [[Y:%.*]])
>>  // CHECK-32BIT-LONG:   ret i32 [[R]]
>> +// CHECK-64BIT-LONG: i64 @test_lrotl
>> +// CHECK-64BIT-LONG:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64
>> [[X:%.*]], i64 [[X]], i64 [[Y:%.*]])
>> +// CHECK-64BIT-LONG:   ret i64 [[R]]
>>
>>  unsigned __int64 test_rotl64(unsigned __int64 value, int shift) {
>>return _rotl64(value, shift);
>> @@ -84,12 +80,15 @@ unsigned int test_rotr(unsigned int valu
>>  // CHECK:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32
>> [[X]], i32 [[Y:%.*]])
>>  // CHECK:   ret i32 [[R]]
>>
>> -unsigned LONG test_lrotr(unsigned LONG value, int shift) 

[PATCH] D66564: [clang-tidy] new altera struct pack align check

2020-02-26 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 246871.
ffrankies marked 5 inline comments as done.
ffrankies added a comment.

Addressed comments by @aaron.ballman

- Removed commented-out code and irrelevant FIXMEs
- Added Fix-Its to insert/amend the aligned and packed struct attributes as 
needed.


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

https://reviews.llvm.org/D66564

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/ClangTidyForceLinker.h
  clang-tidy/altera/AlteraTidyModule.cpp
  clang-tidy/altera/CMakeLists.txt
  clang-tidy/altera/StructPackAlignCheck.cpp
  clang-tidy/altera/StructPackAlignCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/altera-struct-pack-align.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/checkers/altera-struct-pack-align.cpp

Index: test/clang-tidy/checkers/altera-struct-pack-align.cpp
===
--- /dev/null
+++ test/clang-tidy/checkers/altera-struct-pack-align.cpp
@@ -0,0 +1,87 @@
+// RUN: %check_clang_tidy %s altera-struct-pack-align %t -- -header-filter=.* "--" --include opencl-c.h -cl-std=CL1.2 -c
+
+// Struct needs both alignment and packing
+struct error {
+  char a;
+  double b;
+  char c;
+};
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'error' is inefficient due to padding; only needs 10 bytes but is using 24 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((packed))" to reduce the amount of padding applied to struct 'error'
+// CHECK-MESSAGES: :[[@LINE-7]]:8: warning: accessing fields in struct 'error' is inefficient due to poor alignment; currently aligned to 8 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-8]]:8: note: use "__attribute__((aligned(16)))" to align struct 'error' to 16 bytes
+// CHECK-FIXES: __attribute__((packed))
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+// Struct is explicitly packed, but needs alignment
+struct error_packed {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'error_packed' is inefficient due to poor alignment; currently aligned to 1 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((aligned(16)))" to align struct 'error_packed' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)))
+
+// Struct is properly packed, but needs alignment
+struct align_only {
+  char a;
+  char b;
+  char c;
+  char d;
+  int e;
+  double f;
+};
+// CHECK-MESSAGES: :[[@LINE-8]]:8: warning: accessing fields in struct 'align_only' is inefficient due to poor alignment; currently aligned to 8 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-9]]:8: note: use "__attribute__((aligned(16)))" to align struct 'align_only' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+// Struct is perfectly packed but wrongly aligned
+struct bad_align {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed)) __attribute__((aligned(8)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'bad_align' is inefficient due to poor alignment; currently aligned to 8 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((aligned(16)))" to align struct 'bad_align' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+struct bad_align2 {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed)) __attribute__((aligned(32)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'bad_align2' is inefficient due to poor alignment; currently aligned to 32 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((aligned(16)))" to align struct 'bad_align2' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+struct bad_align3 {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed)) __attribute__((aligned(4)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'bad_align3' is inefficient due to poor alignment; currently aligned to 4 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((aligned(16)))" to align struct 'bad_align3' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+// Struct is both perfectly packed and aligned
+struct success {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed)) __attribute__((aligned(16)));
+//Should take 10 bytes and be aligned to 16 bytes
+
+// Struct is properly packed, and explicitly aligned
+struct success2 {
+  int a;
+  int b;
+  int c;
+} __attribute__((aligned(16)));
+
+// If struct is properly aligned, packing not needed

[PATCH] D75223: [clang-offload-wrapper] Lower priority of __tgt_register_lib in favor of __tgt_register_requires

2020-02-26 Thread George Rokos via Phabricator via cfe-commits
grokos updated this revision to Diff 246870.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75223

Files:
  clang/test/Driver/clang-offload-wrapper.c
  clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp


Index: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
===
--- clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
+++ clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -262,7 +262,12 @@
 Builder.CreateRetVoid();
 
 // Add this function to constructors.
-appendToGlobalCtors(M, Func, 0);
+// Set priority to 1 so that __tgt_register_lib is executed AFTER
+// __tgt_register_requires (we want to know what requirements have been
+// asked for before we load a libomptarget plugin so that by the time the
+// plugin is loaded it can report how many devices there are which can
+// satisfy these requirements).
+appendToGlobalCtors(M, Func, /*Priority*/ 1);
   }
 
   void createUnregisterFunction(GlobalVariable *BinDesc) {
@@ -283,7 +288,8 @@
 Builder.CreateRetVoid();
 
 // Add this function to global destructors.
-appendToGlobalDtors(M, Func, 0);
+// Match priority of __tgt_register_lib
+appendToGlobalDtors(M, Func, 1);
   }
 
 public:
Index: clang/test/Driver/clang-offload-wrapper.c
===
--- clang/test/Driver/clang-offload-wrapper.c
+++ clang/test/Driver/clang-offload-wrapper.c
@@ -39,8 +39,8 @@
 
 // CHECK-IR: [[DESC:@.+]] = internal constant [[DESCTY]] { i32 1, [[IMAGETY]]* 
getelementptr inbounds ([1 x [[IMAGETY]]], [1 x [[IMAGETY]]]* [[IMAGES]], i64 
0, i64 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }
 
-// CHECK-IR: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* 
}] [{ i32, void ()*, i8* } { i32 0, void ()* [[REGFN:@.+]], i8* null }]
-// CHECK-IR: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* 
}] [{ i32, void ()*, i8* } { i32 0, void ()* [[UNREGFN:@.+]], i8* null }]
+// CHECK-IR: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* 
}] [{ i32, void ()*, i8* } { i32 1, void ()* [[REGFN:@.+]], i8* null }]
+// CHECK-IR: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* 
}] [{ i32, void ()*, i8* } { i32 1, void ()* [[UNREGFN:@.+]], i8* null }]
 
 // CHECK-IR: define internal void [[REGFN]]()
 // CHECK-IR:   call void @__tgt_register_lib([[DESCTY]]* [[DESC]])


Index: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
===
--- clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
+++ clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -262,7 +262,12 @@
 Builder.CreateRetVoid();
 
 // Add this function to constructors.
-appendToGlobalCtors(M, Func, 0);
+// Set priority to 1 so that __tgt_register_lib is executed AFTER
+// __tgt_register_requires (we want to know what requirements have been
+// asked for before we load a libomptarget plugin so that by the time the
+// plugin is loaded it can report how many devices there are which can
+// satisfy these requirements).
+appendToGlobalCtors(M, Func, /*Priority*/ 1);
   }
 
   void createUnregisterFunction(GlobalVariable *BinDesc) {
@@ -283,7 +288,8 @@
 Builder.CreateRetVoid();
 
 // Add this function to global destructors.
-appendToGlobalDtors(M, Func, 0);
+// Match priority of __tgt_register_lib
+appendToGlobalDtors(M, Func, 1);
   }
 
 public:
Index: clang/test/Driver/clang-offload-wrapper.c
===
--- clang/test/Driver/clang-offload-wrapper.c
+++ clang/test/Driver/clang-offload-wrapper.c
@@ -39,8 +39,8 @@
 
 // CHECK-IR: [[DESC:@.+]] = internal constant [[DESCTY]] { i32 1, [[IMAGETY]]* getelementptr inbounds ([1 x [[IMAGETY]]], [1 x [[IMAGETY]]]* [[IMAGES]], i64 0, i64 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }
 
-// CHECK-IR: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* [[REGFN:@.+]], i8* null }]
-// CHECK-IR: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 0, void ()* [[UNREGFN:@.+]], i8* null }]
+// CHECK-IR: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* [[REGFN:@.+]], i8* null }]
+// CHECK-IR: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 1, void ()* [[UNREGFN:@.+]], i8* null }]
 
 // CHECK-IR: define internal void [[REGFN]]()
 // CHECK-IR:   call void @__tgt_register_lib([[DESCTY]]* [[DESC]])
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70700: [WebAssembly] Mangle the argc/argv `main` as `__main_argc_argv`

2020-02-26 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

Would you mind re-basing?  I'd like to download and try this but it seems to 
have conflicts right now.  (i'll do my best to resolve them you might do 
better).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70700



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


[PATCH] D72100: Allow matching "any file" in `VerifyDiagnosticConsumer`.

2020-02-26 Thread Alexandre Rames via Phabricator via cfe-commits
arames marked 2 inline comments as done.
arames added a comment.

In D72100#1855483 , @jkorous wrote:

> We should either simplify the implementation to reflect that we don't support 
> e. g. `*:42` (seems preferable to me) or have the codepaths that are 
> currently not accessible through `-fverify` tested by other means.


That makes sense. I have updated the naming and added a comment to reflect 
that. PTAL.
As a note and future reference, the issue was not on the side of the 
verification; I tested combinations of `MatchAnyFile` and `MatchAnyLine`, but 
the fact that we cannot always create a source location with the appropriate 
line number when we do not know what file we are dealing with.




Comment at: clang/lib/Frontend/VerifyDiagnosticConsumer.cpp:300
+ SourceLocation ExpectedLoc, bool MatchAnyFile = false,
+ bool MatchAnyLine = false) {
   // Construct new directive.

jkorous wrote:
> Should we make it clear from the interface that `MatchAnyFile` => 
> `MatchAnyLine`?
The naming should now make it clear. Additionally, I have added a comment for 
the implication in `Directive`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72100



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


[PATCH] D75223: [clang-offload-wrapper] Lower priority of __tgt_register_lib in favor of __tgt_register_requires

2020-02-26 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
vzakhari added inline comments.



Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:291
 // Add this function to global destructors.
 appendToGlobalDtors(M, Func, 0);
   }

I think __tgt_unregister_lib should have a matching priority.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75223



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


[PATCH] D75223: [clang-offload-wrapper] Lower priority of __tgt_register_lib in favor of __tgt_register_requires

2020-02-26 Thread George Rokos via Phabricator via cfe-commits
grokos created this revision.
grokos added reviewers: ABataev, vzakhari.
grokos added projects: OpenMP, clang.
Herald added a reviewer: jdoerfert.

Currently, the offload-wrapper tool inserts `__tgt_register_lib` to the list of 
global ctors of a target module with `Priority=0`. This means that it's got the 
same priority as `__tgt_register_requires` and the order in which these two 
functions are called in not guaranteed. Ideally, we'd like to call 
`__tgt_register_requires` BEFORE loading a libomptarget plugin (which is one of 
the actions happening inside `__tgt_register_lib`). The reason is that we want 
to know which requirements the user has asked for so that upon loading the 
plugin libomptarget can report how many devices there are that can satisfy the 
requirements.

E.g. with the current implementation we can run into the following problem:

1. The user requests `unified_shared_memory` but the available devices on the 
system do not support this feature.
2. Initially, the offload policy is set to `tgt_default`.
3. `__tgt_register_lib` is called and the plugin for the specific target device 
reports there are N>0 available devices.
4. Consequently, the offload policy is set to `tgt_mandatory`.
5. `__tgt_register_requires` is called and we find out that the 
`unified_shared_memory` requirement cannot be satisfied.
6. Offload fails and because the offload policy had been set to mandatory 
libomptarget terminates the application.

With the proposed change things will proceed as follows:

1. The user requests `unified_shared_memory` but the available devices on the 
system do not support this feature.
2. Initially, the offload policy is set to `tgt_default`.
3. `__tgt_register_requires` is called and registers the 
`unified_shared_memory` requirement with libomptarget.
4. `__tgt_register_lib` is called and the plugin for the specific target device 
reports that the `unified_shared_memory` requirement cannot be satisfied, so 
there are N=0 available devices.
5. Consequently, the offload policy is set to `tgt_disabled`.
6. Execution falls back on the host instead of terminating the application.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75223

Files:
  clang/test/Driver/clang-offload-wrapper.c
  clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp


Index: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
===
--- clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
+++ clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -262,7 +262,12 @@
 Builder.CreateRetVoid();
 
 // Add this function to constructors.
-appendToGlobalCtors(M, Func, 0);
+// Set priority to 1 so that __tgt_register_lib is executed AFTER
+// __tgt_register_requires (we want to know what requirements have been
+// asked for before we load a libomptarget plugin so that by the time the
+// plugin is loaded it can report how many devices there are which can
+// satisfy these requirements).
+appendToGlobalCtors(M, Func, /*Priority*/ 1);
   }
 
   void createUnregisterFunction(GlobalVariable *BinDesc) {
Index: clang/test/Driver/clang-offload-wrapper.c
===
--- clang/test/Driver/clang-offload-wrapper.c
+++ clang/test/Driver/clang-offload-wrapper.c
@@ -39,7 +39,7 @@
 
 // CHECK-IR: [[DESC:@.+]] = internal constant [[DESCTY]] { i32 1, [[IMAGETY]]* 
getelementptr inbounds ([1 x [[IMAGETY]]], [1 x [[IMAGETY]]]* [[IMAGES]], i64 
0, i64 0), [[ENTTY]]* [[ENTBEGIN]], [[ENTTY]]* [[ENTEND]] }
 
-// CHECK-IR: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* 
}] [{ i32, void ()*, i8* } { i32 0, void ()* [[REGFN:@.+]], i8* null }]
+// CHECK-IR: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* 
}] [{ i32, void ()*, i8* } { i32 1, void ()* [[REGFN:@.+]], i8* null }]
 // CHECK-IR: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* 
}] [{ i32, void ()*, i8* } { i32 0, void ()* [[UNREGFN:@.+]], i8* null }]
 
 // CHECK-IR: define internal void [[REGFN]]()


Index: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
===
--- clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
+++ clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
@@ -262,7 +262,12 @@
 Builder.CreateRetVoid();
 
 // Add this function to constructors.
-appendToGlobalCtors(M, Func, 0);
+// Set priority to 1 so that __tgt_register_lib is executed AFTER
+// __tgt_register_requires (we want to know what requirements have been
+// asked for before we load a libomptarget plugin so that by the time the
+// plugin is loaded it can report how many devices there are which can
+// satisfy these requirements).
+appendToGlobalCtors(M, Func, /*Priority*/ 1);
   }
 
   void createUnregisterFunction(GlobalVariable *BinDesc) {
Index: 

[PATCH] D75215: [DebugInfo] Fix for adding "returns cxx udt" option to functions in CodeView.

2020-02-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked an inline comment as done.
akhuang added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:992
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,
   llvm::DINode::FlagFwdDecl, Identifier);
   if (CGM.getCodeGenOpts().DebugFwdTemplateParams)

rnk wrote:
> One alternative would be to add `llvm::DINode::FlagNonTrivial` here if the 
> type is complete and not trivial.
> 
> There is the case where the the compiler has to emit a method type when the 
> class has been forward declared, and that could still lead to duplicate 
> records. For example:
> ```
> class Returned;
> class Foo {
>   Foo();
>   Returned bar();
> };
> Foo::Foo() {}
> ```
> In this example, clang will have to describe the method type of Foo::bar, but 
> it will not have access to Returned. I think in practice this won't come up, 
> because Foo::bar will be defined in the same file as the constructor.
I suppose this would be a lot simpler. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75215



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


[PATCH] D67112: [Sema] Add implicit cast for conversion of function references

2020-02-26 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert reclaimed this revision.
aaronpuchert removed a reviewer: riccibruno.
aaronpuchert added a comment.

The diff between both changes might still be interesting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67112



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


[PATCH] D67112: [Sema] Add implicit cast for conversion of function references

2020-02-26 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert updated this revision to Diff 246862.
aaronpuchert added a comment.

Rebase on top of D66437 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67112

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Sema/Initialization.h
  clang/lib/Sema/SemaInit.cpp
  clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp

Index: clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++17 -ast-dump %s | FileCheck %s
+
+void f() noexcept;
+// CHECK: VarDecl {{.*}} fp 'void (&)()' cinit
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void ()':'void ()' lvalue 
+// CHECK-NEXT: DeclRefExpr {{.*}} 'void () noexcept' lvalue Function {{.*}} 'f' 'void () noexcept'
+void ()() = f;
+
+struct X {
+  typedef void ()() noexcept;
+  operator fp();
+} x;
+
+// CHECK: VarDecl {{.*}} xp 'void (&)()' cinit
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void ()':'void ()' lvalue 
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void () noexcept':'void () noexcept' lvalue 
+void ()() = x;
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -3417,6 +3417,7 @@
   case SK_QualificationConversionRValue:
   case SK_QualificationConversionXValue:
   case SK_QualificationConversionLValue:
+  case SK_FunctionReferenceConversion:
   case SK_AtomicConversion:
   case SK_ListInitialization:
   case SK_UnwrapInitList:
@@ -3594,6 +3595,13 @@
   Steps.push_back(S);
 }
 
+void InitializationSequence::AddFunctionReferenceConversionStep(QualType Ty) {
+  Step S;
+  S.Kind = SK_FunctionReferenceConversion;
+  S.Type = Ty;
+  Steps.push_back(S);
+}
+
 void InitializationSequence::AddAtomicConversionStep(QualType Ty) {
   Step S;
   S.Kind = SK_AtomicConversion;
@@ -4627,7 +4635,7 @@
   else if (RefConv & Sema::ReferenceConversions::ObjC)
 Sequence.AddObjCObjectConversionStep(cv1T1);
   else if (RefConv & Sema::ReferenceConversions::Function)
-Sequence.AddQualificationConversionStep(cv1T1, VK);
+Sequence.AddFunctionReferenceConversionStep(cv1T1);
   else if (RefConv & Sema::ReferenceConversions::Qualification) {
 if (!S.Context.hasSameType(cv1T4, cv1T1))
   Sequence.AddQualificationConversionStep(cv1T1, VK);
@@ -4725,12 +4733,12 @@
   Sequence.AddDerivedToBaseCastStep(cv1T1, VK_LValue);
 else
   Sequence.AddObjCObjectConversionStep(cv1T1);
-  } else if (RefConv & (Sema::ReferenceConversions::Qualification |
-Sema::ReferenceConversions::Function)) {
+  } else if (RefConv & Sema::ReferenceConversions::Qualification) {
 // Perform a (possibly multi-level) qualification conversion.
-// FIXME: Should we use a different step kind for function conversions?
 Sequence.AddQualificationConversionStep(cv1T1,
 Initializer->getValueKind());
+  } else if (RefConv & Sema::ReferenceConversions::Function) {
+Sequence.AddFunctionReferenceConversionStep(cv1T1);
   }
 
   // We only create a temporary here when binding a reference to a
@@ -7897,6 +7905,7 @@
   case SK_QualificationConversionLValue:
   case SK_QualificationConversionXValue:
   case SK_QualificationConversionRValue:
+  case SK_FunctionReferenceConversion:
   case SK_AtomicConversion:
   case SK_ConversionSequence:
   case SK_ConversionSequenceNoNarrowing:
@@ -8162,6 +8171,13 @@
   break;
 }
 
+case SK_FunctionReferenceConversion:
+  assert(CurInit.get()->isLValue() &&
+ "function reference should be lvalue");
+  CurInit =
+  S.ImpCastExprToType(CurInit.get(), Step->Type, CK_NoOp, VK_LValue);
+  break;
+
 case SK_AtomicConversion: {
   assert(CurInit.get()->isRValue() && "cannot convert glvalue to atomic");
   CurInit = S.ImpCastExprToType(CurInit.get(), Step->Type,
@@ -9398,6 +9414,10 @@
   OS << "qualification conversion (lvalue)";
   break;
 
+case SK_FunctionReferenceConversion:
+  OS << "function reference conversion";
+  break;
+
 case SK_AtomicConversion:
   OS << "non-atomic-to-atomic conversion";
   break;
Index: clang/include/clang/Sema/Initialization.h
===
--- clang/include/clang/Sema/Initialization.h
+++ clang/include/clang/Sema/Initialization.h
@@ -818,6 +818,9 @@
 /// Perform a qualification conversion, producing an lvalue.
 SK_QualificationConversionLValue,
 
+/// Perform a function reference conversion, see [dcl.init.ref]p4.
+SK_FunctionReferenceConversion,
+
 /// Perform a conversion adding _Atomic to a type.
 

[PATCH] D75220: [clang-tidy] RenamerClangTidy now correctly renames decls

2020-02-26 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, JonasToth, hokein, alexfh.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
njames93 updated this revision to Diff 246853.
njames93 added a comment.

- Remove unnecessary include


Fixes readability-identifier-naming doesn't rename using namespace correctly. 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75220

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


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -527,3 +527,8 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+using namespace FOO_NS;
+// CHECK-FIXES: {{^}}using namespace foo_ns;
+
+using namespace FOO_NS::InlineNamespace;
+// CHECK-FIXES: {{^}}using namespace foo_ns::inline_namespace;
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
@@ -272,6 +272,13 @@
   }
 
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
+
+// fix using namespace decls
+if (const auto *UsingNS = dyn_cast(Decl)) {
+  addUsage(NamingCheckFailures, UsingNS->getNominatedNamespaceAsWritten(),
+   UsingNS->getIdentLocation());
+}
+
 if (!Decl->getIdentifier() || Decl->getName().empty() || 
Decl->isImplicit())
   return;
 


Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -527,3 +527,8 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+using namespace FOO_NS;
+// CHECK-FIXES: {{^}}using namespace foo_ns;
+
+using namespace FOO_NS::InlineNamespace;
+// CHECK-FIXES: {{^}}using namespace foo_ns::inline_namespace;
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
@@ -272,6 +272,13 @@
   }
 
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
+
+// fix using namespace decls
+if (const auto *UsingNS = dyn_cast(Decl)) {
+  addUsage(NamingCheckFailures, UsingNS->getNominatedNamespaceAsWritten(),
+   UsingNS->getIdentLocation());
+}
+
 if (!Decl->getIdentifier() || Decl->getName().empty() || Decl->isImplicit())
   return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75220: [clang-tidy] RenamerClangTidy now correctly renames decls

2020-02-26 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 246853.
njames93 added a comment.

- Remove unnecessary include


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75220

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


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -527,3 +527,8 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+using namespace FOO_NS;
+// CHECK-FIXES: {{^}}using namespace foo_ns;
+
+using namespace FOO_NS::InlineNamespace;
+// CHECK-FIXES: {{^}}using namespace foo_ns::inline_namespace;
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
@@ -272,6 +272,13 @@
   }
 
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
+
+// fix using namespace decls
+if (const auto *UsingNS = dyn_cast(Decl)) {
+  addUsage(NamingCheckFailures, UsingNS->getNominatedNamespaceAsWritten(),
+   UsingNS->getIdentLocation());
+}
+
 if (!Decl->getIdentifier() || Decl->getName().empty() || 
Decl->isImplicit())
   return;
 


Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming.cpp
@@ -527,3 +527,8 @@
 // CHECK-FIXES: {{^}}int * const lc_PointerB = nullptr;{{$}}
 }
 
+using namespace FOO_NS;
+// CHECK-FIXES: {{^}}using namespace foo_ns;
+
+using namespace FOO_NS::InlineNamespace;
+// CHECK-FIXES: {{^}}using namespace foo_ns::inline_namespace;
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
@@ -272,6 +272,13 @@
   }
 
   if (const auto *Decl = Result.Nodes.getNodeAs("decl")) {
+
+// fix using namespace decls
+if (const auto *UsingNS = dyn_cast(Decl)) {
+  addUsage(NamingCheckFailures, UsingNS->getNominatedNamespaceAsWritten(),
+   UsingNS->getIdentLocation());
+}
+
 if (!Decl->getIdentifier() || Decl->getName().empty() || Decl->isImplicit())
   return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69591: Devirtualize a call on alloca without waiting for post inline cleanup and next DevirtSCCRepeatedPass iteration.

2020-02-26 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
yamauchi closed this revision.
yamauchi added a comment.

Committed as https://reviews.llvm.org/rG59fb9cde7a4a


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69591



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


[PATCH] D71314: Warn of uninitialized variables on asm goto's indirect branch

2020-02-26 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 246849.
void added a comment.

Rebasing.


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

https://reviews.llvm.org/D71314

Files:
  clang/lib/Analysis/UninitializedValues.cpp
  clang/test/Analysis/uninit-asm-goto.cpp

Index: clang/test/Analysis/uninit-asm-goto.cpp
===
--- clang/test/Analysis/uninit-asm-goto.cpp
+++ clang/test/Analysis/uninit-asm-goto.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++11 -Wuninitialized -verify %s
-// expected-no-diagnostics
 
+// test1: Expect no diagnostics
 int test1(int x) {
 int y;
 asm goto("nop" : "=r"(y) : "r"(x) : : err);
@@ -8,3 +8,52 @@
   err:
 return -1;
 }
+
+int test2(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  if (x < 42)
+asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect_1, indirect_2);
+  else
+asm volatile goto("testl %0, %1; testl %2, %3; jne %l5" : "+S"(x), "+D"(y) : "r"(x), "r"(y) :: indirect_1, indirect_2);
+  return x + y;
+indirect_1:
+  return -42;
+indirect_2:
+  return y; // expected-note {{uninitialized use occurs here}}
+}
+
+int test3(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  asm goto("xorl %1, %0; jmp %l2" : "="(y) : "r"(x) : : fail);
+normal:
+  y += x;
+  return y;
+  if (x) {
+fail:
+return y; // expected-note {{uninitialized use occurs here}}
+  }
+  return 0;
+}
+
+int test4(int x) {
+  int y; // expected-warning {{variable 'y' is used uninitialized whenever its declaration is reached}} \
+ // expected-note {{initialize the variable}}
+  goto forward;
+backward:
+  return y; // expected-note {{uninitialized use occurs here}}
+forward:
+  asm goto("# %0 %1 %2" : "=r"(y) : "r"(x) : : backward);
+  return y;
+}
+
+// test5: Expect no diagnostics
+int test5(int x) {
+  int y;
+  asm volatile goto("testl %0, %0; testl %1, %2; jne %l3" : "+S"(x), "+D"(y) : "r"(x) :: indirect, fallthrough);
+fallthrough:
+  return y;
+indirect:
+  return -2;
+}
Index: clang/lib/Analysis/UninitializedValues.cpp
===
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -576,6 +576,28 @@
   continue;
 }
 
+if (AtPredExit == MayUninitialized) {
+  // If the predecessor's terminator is an "asm goto" that initializes
+  // the variable, then it won't be counted as "initialized" on the
+  // non-fallthrough paths.
+  CFGTerminator term = Pred->getTerminator();
+  if (const auto *as = dyn_cast_or_null(term.getStmt())) {
+const CFGBlock *fallthrough = *Pred->succ_begin();
+if (as->isAsmGoto() &&
+llvm::any_of(as->outputs(), [&](const Expr *output) {
+return vd == findVar(output).getDecl() &&
+llvm::any_of(as->labels(),
+ [&](const AddrLabelExpr *label) {
+  return label->getLabel()->getStmt() == B->Label &&
+  B != fallthrough;
+});
+})) {
+  Use.setUninitAfterDecl();
+  continue;
+}
+  }
+}
+
 unsigned  = SuccsVisited[Pred->getBlockID()];
 if (!SV) {
   // When visiting the first successor of a block, mark all NULL
@@ -768,7 +790,11 @@
 
   for (const Expr *o : as->outputs())
 if (const VarDecl *VD = findVar(o).getDecl())
-  vals[VD] = Initialized;
+  if (vals[VD] != Initialized)
+// If the variable isn't initialized by the time we get here, then we
+// mark it as potentially uninitialized for those cases where it's used
+// on an indirect path, where it's not guaranteed to be defined.
+vals[VD] = MayUninitialized;
 }
 
 void TransferFunctions::VisitObjCMessageExpr(ObjCMessageExpr *ME) {
@@ -809,7 +835,7 @@
   tf.Visit(const_cast(cs->getStmt()));
   }
   CFGTerminator terminator = block->getTerminator();
-  if (GCCAsmStmt *as = dyn_cast_or_null(terminator.getStmt()))
+  if (auto *as = dyn_cast_or_null(terminator.getStmt()))
 if (as->isAsmGoto())
   tf.Visit(as);
   return vals.updateValueVectorWithScratch(block);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75215: [DebugInfo] Fix for adding "returns cxx udt" option to functions in CodeView.

2020-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:992
   getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,
   llvm::DINode::FlagFwdDecl, Identifier);
   if (CGM.getCodeGenOpts().DebugFwdTemplateParams)

One alternative would be to add `llvm::DINode::FlagNonTrivial` here if the type 
is complete and not trivial.

There is the case where the the compiler has to emit a method type when the 
class has been forward declared, and that could still lead to duplicate 
records. For example:
```
class Returned;
class Foo {
  Foo();
  Returned bar();
};
Foo::Foo() {}
```
In this example, clang will have to describe the method type of Foo::bar, but 
it will not have access to Returned. I think in practice this won't come up, 
because Foo::bar will be defined in the same file as the constructor.



Comment at: llvm/include/llvm/IR/DebugInfoFlags.def:61
 HANDLE_DI_FLAG((1 << 29), AllCallsDescribed)
+HANDLE_DI_FLAG((1 << 30), CxxReturnUdt)
 

@dblaikie @aprantl, does this seem like a reasonable flag to add, or should we 
mark record forward decls as trivial/nontrivial instead?



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:407
 static bool isNonTrivial(const DICompositeType *DCTy) {
   return ((DCTy->getFlags() & DINode::FlagNonTrivial) == 
DINode::FlagNonTrivial);
 }

Should we assert here that the composite type is not a forward decl, assuming 
we stick with the CxxReturn flag?



Comment at: llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp:420
   // DISubroutineType is unnamed. Use DISubprogram's i.e. SPName in comparison.
   if (ClassTy && isNonTrivial(ClassTy) && SPName == ClassTy->getName()) {
 FO |= FunctionOptions::Constructor;

We also use isNonTrivial here, but I think if we are emitting a method type, it 
means the class must not be a forward declaration?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75215



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


[PATCH] D65543: [Windows] Autolink with basenames and add libdir to libpath

2020-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I ran into this issue again, and would like to move forward with this. I'll 
rebase it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65543



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


[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-26 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

@rjmccall @rsmith @tra, could you review on this revision?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227



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


[PATCH] D75215: [DebugInfo] Fix for adding "returns cxx udt" option to functions in CodeView.

2020-02-26 Thread Amy Huang via Phabricator via cfe-commits
akhuang created this revision.
akhuang added reviewers: rnk, asmith.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This change checks for the return type in the frontend and adds a flag
to the DISubroutineType to indicate that the option should be added in
CodeViewDebug.

Previously function types sometimes appeared twice in the PDB: once with
"returns cxx udt" and once without.
See https://bugs.llvm.org/show_bug.cgi?id=44785.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75215

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-return-udt.cpp
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/test/DebugInfo/COFF/function-options.ll

Index: llvm/test/DebugInfo/COFF/function-options.ll
===
--- llvm/test/DebugInfo/COFF/function-options.ll
+++ llvm/test/DebugInfo/COFF/function-options.ll
@@ -17,24 +17,12 @@
 ; };
 ; DEFINE_FUNCTION(BClass); // Expect: FO = CxxReturnUdt
 ;
-; class C1Class {
-; public:
-;   C1Class() = default; // Note: Clang generates one defaulted ctor (FO = None) while MSVC doesn't.
+; class CClass {
+;   AClass Member_AClass(AClass &); // Expect: FO = CxxReturnUdt
+;   BClass Member_BClass(BClass &); // Expect: FO = CxxReturnUdt
 ; };
-; DEFINE_FUNCTION(C1Class); // Expect: FO = None
+; DEFINE_FUNCTION(CClass);
 ;
-; class C2Class { // Note: MSVC-specific dtor, i.e. __vecDelDtor won't be verified in this case.
-; public:
-;   ~C2Class() {} // Expect ~C2Class: FO = None
-; };
-; DEFINE_FUNCTION(C2Class); // Expect: FO = CxxReturnUdt
-;
-; class DClass : public BClass {}; // Note: MSVC yields one compiler-generated ctor for DClass while clang doesn't.
-; DEFINE_FUNCTION(DClass); // Expect: FO = CxxReturnUdt
-;
-; class FClass { static int x; };
-; DEFINE_FUNCTION(FClass); // Expect FO = None
-; 
 ; struct AStruct {};
 ; DEFINE_FUNCTION(AStruct); // Expect FO = None
 ;
@@ -54,7 +42,7 @@
 ; CHECK: CodeViewTypes [
 ; CHECK:   Section: .debug$T ({{.*}})
 ; CHECK:   Magic: 0x4
-; CHECK:   Procedure ([[SP1:.*]]) {
+; CHECK:   Procedure ([[SP_A:.*]]) {
 ; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
 ; CHECK: ReturnType: AClass ({{.*}})
 ; CHECK: CallingConvention: NearC (0x0)
@@ -66,10 +54,10 @@
 ; CHECK:   FuncId ({{.*}}) {
 ; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
 ; CHECK: ParentScope: 0x0
-; CHECK: FunctionType: AClass (AClass&) ([[SP1]])
+; CHECK: FunctionType: AClass (AClass&) ([[SP_A]])
 ; CHECK: Name: Func_AClass
 ; CHECK:   }
-; CHECK:   Procedure ([[SP2:.*]]) {
+; CHECK:   Procedure ([[SP_B:.*]]) {
 ; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
 ; CHECK: ReturnType: BClass ({{.*}})
 ; CHECK: CallingConvention: NearC (0x0)
@@ -104,132 +92,66 @@
 ; CHECK:   FuncId ({{.*}}) {
 ; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
 ; CHECK: ParentScope: 0x0
-; CHECK: FunctionType: BClass (BClass&) ([[SP2]])
+; CHECK: FunctionType: BClass (BClass&) ([[SP_B]])
 ; CHECK: Name: Func_BClass
 ; CHECK:   }
-; CHECK:   Procedure ([[SP3:.*]]) {
+; CHECK:   Procedure ([[SP_C:.*]]) {
 ; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
-; CHECK: ReturnType: C1Class ({{.*}})
+; CHECK: ReturnType: CClass ({{.*}})
 ; CHECK: CallingConvention: NearC (0x0)
 ; CHECK: FunctionOptions [ (0x0)
 ; CHECK: ]
 ; CHECK: NumParameters: 1
-; CHECK: ArgListType: (C1Class&) ({{.*}})
-; CHECK:   }
-; CHECK:   MemberFunction ([[MF2:.*]]) {
-; CHECK: TypeLeafKind: LF_MFUNCTION (0x1009)
-; CHECK: ReturnType: void (0x3)
-; CHECK: ClassType: C1Class ({{.*}})
-; CHECK: ThisType: C1Class* const ({{.*}})
-; CHECK: CallingConvention: NearC (0x0)
-; CHECK: FunctionOptions [ (0x0)
-; CHECK: ]
-; CHECK: NumParameters: 0
-; CHECK: ArgListType: () ({{.*}})
-; CHECK: ThisAdjustment: 0
-; CHECK:   }
-; CHECK:   FieldList ({{.*}}) {
-; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
-; CHECK: OneMethod {
-; CHECK:   TypeLeafKind: LF_ONEMETHOD (0x1511)
-; CHECK:   AccessSpecifier: Public (0x3)
-; CHECK:   Type: void C1Class::() ([[MF2]])
-; CHECK:   Name: C1Class
-; CHECK: }
-; CHECK:   }
-; CHECK:   FuncId ({{.*}}) {
-; CHECK: TypeLeafKind: LF_FUNC_ID (0x1601)
-; CHECK: ParentScope: 0x0
-; CHECK: FunctionType: C1Class (C1Class&) ([[SP3]])
-; CHECK: Name: Func_C1Class
-; CHECK:   }
-; CHECK:   Procedure ([[SP4:.*]]) {
-; CHECK: TypeLeafKind: LF_PROCEDURE (0x1008)
-; CHECK: ReturnType: C2Class ({{.*}})
+; CHECK: ArgListType: (CClass&) (0x1016)
+; CHECK:  }
+; CHECK:   MemberFunction ([[MF_A:.*]]) {
+; CHECK: TypeLeafKind: LF_MFUNCTION ({{.*}})
+; CHECK: ReturnType: AClass ({{.*}})
+; CHECK: ClassType: CClass ({{.*}})
+; CHECK: ThisType: CClass* const ({{.*}})
 ; CHECK: CallingConvention: NearC (0x0)
 ; CHECK: FunctionOptions [ (0x1)
 ; 

[PATCH] D75056: [Driver] Default to -fno-common for all targets

2020-02-26 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:87
 
+- -fno-common has been enabled as the default for all targets.
 

jyknight wrote:
> Might be nice to expand upon this somewhat, to give users a clue what it 
> means to them.
> 
> E.g. 
> 
> Therefore, C code which uses multiple definitions of a global variable will 
> trigger a multiple-definition linker errors. Generally this occurs when a 
> variable in a header file neglects to use the "extern" keyword on the 
> declaration. The previous behavior can be restored by specifying -fcommon.
Suggestion:
Therefore, C code that uses tentative definitions as definitions of a variable 
in multiple translation units will trigger multiple-definition linker errors. 
Generally, this occurs when the use of the `extern` keyword is neglected in the 
declaration of a variable in a header file. In some cases, no specific 
translation unit provides a definition of the variable. The previous behavior 
can be restored by specifying `-fcommon`.


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

https://reviews.llvm.org/D75056



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


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-02-26 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

libc++ has no idea what a correct max_align_t is. The internal definition works 
due to historic requirements that all three fundamental types are supported for 
new/delete, but we don't have any such guarantees for every other context. A 
correctly implemented stddef.h does not provide max_align_t in C++03 mode, 
since that would pollute the global namespace. This means that libc++ currently 
has two failure modes: on NetBSD, it outright tries to use a non-existing 
symbol. On other platforms it silently defines max_align_t in a way that can be 
subtle wrong.

I should add that e.g. libstdc++ doesn't provide it either, so at least 
somewhat portable C++03 code can not depend on the presence anyway.


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

https://reviews.llvm.org/D73245



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


[clang] 98ed0c5 - PR44978: Accept as an extension some cases where destructor name lookup

2020-02-26 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-02-26T14:55:31-08:00
New Revision: 98ed0c5475df57ca5cd4df0997d8bba323c843aa

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

LOG: PR44978: Accept as an extension some cases where destructor name lookup
is ambiguous, but only one of the possible lookup results could possibly
be right.

Clang recently started diagnosing ambiguity in more cases, and this
broke the build of Firefox. GCC, ICC, MSVC, and previous versions of
Clang all accept some forms of ambiguity here (albeit different ones in
each case); this patch mostly accepts anything any of those compilers
accept.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/destructor.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 5cfb12967f14..e22fc9d2232c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1941,6 +1941,9 @@ def ext_dtor_name_missing_template_arguments : Extension<
 def ext_qualified_dtor_named_in_lexical_scope : ExtWarn<
   "qualified destructor name only found in lexical scope; omit the qualifier "
   "to find this type name by unqualified lookup">, InGroup;
+def ext_dtor_name_ambiguous : Extension<
+  "ISO C++ considers this destructor name lookup to be ambiguous">,
+  InGroup;
 
 def err_destroy_attr_on_non_static_var : Error<
   "%select{no_destroy|always_destroy}0 attribute can only be applied to a"

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 44fd6997ef3e..c8c6d7c95a7f 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -181,13 +181,23 @@ ParsedType Sema::getDestructorName(SourceLocation 
TildeLoc,
   ObjectTypePtr ? GetTypeFromParser(ObjectTypePtr) : QualType();
 
   auto CheckLookupResult = [&](LookupResult ) -> ParsedType {
-// FIXME: Should we be suppressing ambiguities here?
-if (Found.isAmbiguous()) {
-  Failed = true;
-  return nullptr;
-}
+auto IsAcceptableResult = [&](NamedDecl *D) -> bool {
+  auto *Type = dyn_cast(D->getUnderlyingDecl());
+  if (!Type)
+return false;
+
+  if (SearchType.isNull() || SearchType->isDependentType())
+return true;
+
+  QualType T = Context.getTypeDeclType(Type);
+  return Context.hasSameUnqualifiedType(T, SearchType);
+};
 
+unsigned NumAcceptableResults = 0;
 for (NamedDecl *D : Found) {
+  if (IsAcceptableResult(D))
+++NumAcceptableResults;
+
   // Don't list a class twice in the lookup failure diagnostic if it's
   // found by both its injected-class-name and by the name in the enclosing
   // scope.
@@ -199,10 +209,34 @@ ParsedType Sema::getDestructorName(SourceLocation 
TildeLoc,
 FoundDecls.push_back(D);
 }
 
+// As an extension, attempt to "fix" an ambiguity by erasing all non-type
+// results, and all non-matching results if we have a search type. It's not
+// clear what the right behavior is if destructor lookup hits an ambiguity,
+// but other compilers do generally accept at least some kinds of
+// ambiguity.
+if (Found.isAmbiguous() && NumAcceptableResults == 1) {
+  Diag(NameLoc, diag::ext_dtor_name_ambiguous);
+  LookupResult::Filter F = Found.makeFilter();
+  while (F.hasNext()) {
+NamedDecl *D = F.next();
+if (auto *TD = dyn_cast(D->getUnderlyingDecl()))
+  Diag(D->getLocation(), diag::note_destructor_type_here)
+  << Context.getTypeDeclType(TD);
+else
+  Diag(D->getLocation(), diag::note_destructor_nontype_here);
+
+if (!IsAcceptableResult(D))
+  F.erase();
+  }
+  F.done();
+}
+
+if (Found.isAmbiguous())
+  Failed = true;
+
 if (TypeDecl *Type = Found.getAsSingle()) {
-  QualType T = Context.getTypeDeclType(Type);
-  if (SearchType.isNull() || SearchType->isDependentType() ||
-  Context.hasSameUnqualifiedType(T, SearchType)) {
+  if (IsAcceptableResult(Type)) {
+QualType T = Context.getTypeDeclType(Type);
 MarkAnyDeclReferenced(Type->getLocation(), Type, /*OdrUse=*/false);
 return CreateParsedType(T,
 Context.getTrivialTypeSourceInfo(T, NameLoc));

diff  --git a/clang/test/SemaCXX/destructor.cpp 
b/clang/test/SemaCXX/destructor.cpp
index 7fe1cac3c7e7..bc0048621f76 100644
--- a/clang/test/SemaCXX/destructor.cpp
+++ b/clang/test/SemaCXX/destructor.cpp
@@ -510,4 +510,44 @@ namespace DtorTypedef {
   N::C::~C() {}
 #pragma clang diagnostic pop
 }
+
+// Ignore ambiguity errors in destructor name lookup. This 

[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-26 Thread dmajor via Phabricator via cfe-commits
dmajor added a comment.

Thanks! I'm still working on getting commit access, would one of you be able to 
submit for me?


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

https://reviews.llvm.org/D74784



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


[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-02-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D73242#1894146 , @tejohnson wrote:

> Sent fix for review in D75201 .
>
> If the new problem showed up later and not when this one first went in, then 
> it seems likely it is different than this issue.  I'll see if I can reproduce 
> and take a look.


I am not seeing this, although my client is from Friday. So it is likely 
something committed subsequently that caused it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D75202: [ASTMatchers] HasNameMatcher handles `extern "C"`

2020-02-26 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG16cabf278fc8: [ASTMatchers] HasNameMatcher handles `extern 
C` (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75202

Files:
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1643,6 +1643,21 @@
   EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m";
 }
 
+TEST(Matcher, HasNameQualifiedSupportsLinkage) {
+  // https://bugs.llvm.org/show_bug.cgi?id=42193
+  std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+
+  code = R"cpp(namespace foo { extern "C" { void test(); } })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+}
+
 TEST(Matcher, HasAnyName) {
   const std::string Code = "namespace a { namespace b { class C; } }";
 
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -513,7 +513,13 @@
   if (Ctx->isFunctionOrMethod())
 return Patterns.foundMatch(/*AllowFullyQualified=*/false);
 
-  for (; Ctx && isa(Ctx); Ctx = Ctx->getParent()) {
+  for (; Ctx; Ctx = Ctx->getParent()) {
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))
+  continue;
+if (!isa(Ctx))
+  break;
 if (Patterns.foundMatch(/*AllowFullyQualified=*/false))
   return true;
 


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1643,6 +1643,21 @@
   EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m";
 }
 
+TEST(Matcher, HasNameQualifiedSupportsLinkage) {
+  // https://bugs.llvm.org/show_bug.cgi?id=42193
+  std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+
+  code = R"cpp(namespace foo { extern "C" { void test(); } })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+}
+
 TEST(Matcher, HasAnyName) {
   const std::string Code = "namespace a { namespace b { class C; } }";
 
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -513,7 +513,13 @@
   if (Ctx->isFunctionOrMethod())
 return Patterns.foundMatch(/*AllowFullyQualified=*/false);
 
-  for (; Ctx && isa(Ctx); Ctx = Ctx->getParent()) {
+  for (; Ctx; Ctx = Ctx->getParent()) {
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))
+  continue;
+if (!isa(Ctx))
+  break;
 if (Patterns.foundMatch(/*AllowFullyQualified=*/false))
   return true;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75202: [ASTMatchers] HasNameMatcher handles `extern "C"`

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



Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:518
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))

aaron.ballman wrote:
> I would imagine we'd want to skip an `ExternCContextDecl` for similar 
> reasons, though I am struggling to find a test case that actually generates 
> that context.
I couldn't figure a way to generate one of those either. However if a context 
type that isnt found matched the assertions should go off and we can look into 
the issue again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75202



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


[PATCH] D73245: Depend stddef.h to provide max_align_t for C++11 and provide better fallback in

2020-02-26 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a subscriber: ldionne.
EricWF added a comment.

@ldionne Since this has the possibility of breaking existing users of 
`std::max_align_t`, can you test this against your c++03 codebases?

@joerg I still don't understand why you need this change. Why can't we provide 
the name in C++03 mode?

I'll repeat: libc++ does not provide a C++03 mode. Only a C++11 mode that 
tolerates C++03 compilers.

C++03 conformance is not a valid reason for this change.




Comment at: 
libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp:144
   void* p = nullptr;
+#if TEST_STD_VER >= 11
   size_t over_align_val = TEST_ALIGNOF(std::max_align_t) * 2;

Tests under `test/libcxx` can use the `__libcpp_max_align_t` name directly, 
instead of being disabled.


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

https://reviews.llvm.org/D73245



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


[PATCH] D75202: [ASTMatchers] HasNameMatcher handles `extern "C"`

2020-02-26 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 246829.
njames93 marked an inline comment as done.
njames93 added a comment.

- Add extra test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75202

Files:
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1643,6 +1643,21 @@
   EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m";
 }
 
+TEST(Matcher, HasNameQualifiedSupportsLinkage) {
+  // https://bugs.llvm.org/show_bug.cgi?id=42193
+  std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+
+  code = R"cpp(namespace foo { extern "C" { void test(); } })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+}
+
 TEST(Matcher, HasAnyName) {
   const std::string Code = "namespace a { namespace b { class C; } }";
 
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -513,7 +513,13 @@
   if (Ctx->isFunctionOrMethod())
 return Patterns.foundMatch(/*AllowFullyQualified=*/false);
 
-  for (; Ctx && isa(Ctx); Ctx = Ctx->getParent()) {
+  for (; Ctx; Ctx = Ctx->getParent()) {
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))
+  continue;
+if (!isa(Ctx))
+  break;
 if (Patterns.foundMatch(/*AllowFullyQualified=*/false))
   return true;
 


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1643,6 +1643,21 @@
   EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m";
 }
 
+TEST(Matcher, HasNameQualifiedSupportsLinkage) {
+  // https://bugs.llvm.org/show_bug.cgi?id=42193
+  std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+
+  code = R"cpp(namespace foo { extern "C" { void test(); } })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+}
+
 TEST(Matcher, HasAnyName) {
   const std::string Code = "namespace a { namespace b { class C; } }";
 
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -513,7 +513,13 @@
   if (Ctx->isFunctionOrMethod())
 return Patterns.foundMatch(/*AllowFullyQualified=*/false);
 
-  for (; Ctx && isa(Ctx); Ctx = Ctx->getParent()) {
+  for (; Ctx; Ctx = Ctx->getParent()) {
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))
+  continue;
+if (!isa(Ctx))
+  break;
 if (Patterns.foundMatch(/*AllowFullyQualified=*/false))
   return true;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r355698 - Re-fix _lrotl/_lrotr to always take Long, no matter the platform.

2020-02-26 Thread Michael Spencer via cfe-commits
I believe this commit is wrong. These intrinsics were originally
implemented to support Windows code which expects _lrot{l,r}'s first
argument to be 32 bits, it's a breaking change to change these definitions.
I'm fine with adding the Intel version of these intrinsics, but you can't
just break the Microsoft version of them.

- Michael Spencer

On Fri, Mar 8, 2019 at 7:09 AM Erich Keane via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: erichkeane
> Date: Fri Mar  8 07:10:07 2019
> New Revision: 355698
>
> URL: http://llvm.org/viewvc/llvm-project?rev=355698=rev
> Log:
> Re-fix _lrotl/_lrotr to always take Long, no matter the platform.
>
> r355322 fixed this, however is being reverted due to concerns with
> enabling it in other modes.
>
> Change-Id: I6a939b7469b8fa196d5871a627eb2330dbd30f29
>
> Modified:
> cfe/trunk/include/clang/Basic/Builtins.def
> cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
>
> Modified: cfe/trunk/include/clang/Basic/Builtins.def
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=355698=355697=355698=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
> +++ cfe/trunk/include/clang/Basic/Builtins.def Fri Mar  8 07:10:07 2019
> @@ -831,12 +831,12 @@ LANGBUILTIN(_ReturnAddress, "v*", "n", A
>  LANGBUILTIN(_rotl8,  "UcUcUc","n", ALL_MS_LANGUAGES)
>  LANGBUILTIN(_rotl16, "UsUsUc","n", ALL_MS_LANGUAGES)
>  LANGBUILTIN(_rotl,   "UiUii", "n", ALL_MS_LANGUAGES)
> -LANGBUILTIN(_lrotl,  "UNiUNii",   "n", ALL_MS_LANGUAGES)
> +LANGBUILTIN(_lrotl,  "ULiULii",   "n", ALL_MS_LANGUAGES)
>  LANGBUILTIN(_rotl64, "UWiUWii",   "n", ALL_MS_LANGUAGES)
>  LANGBUILTIN(_rotr8,  "UcUcUc","n", ALL_MS_LANGUAGES)
>  LANGBUILTIN(_rotr16, "UsUsUc","n", ALL_MS_LANGUAGES)
>  LANGBUILTIN(_rotr,   "UiUii", "n", ALL_MS_LANGUAGES)
> -LANGBUILTIN(_lrotr,  "UNiUNii",   "n", ALL_MS_LANGUAGES)
> +LANGBUILTIN(_lrotr,  "ULiULii",   "n", ALL_MS_LANGUAGES)
>  LANGBUILTIN(_rotr64, "UWiUWii",   "n", ALL_MS_LANGUAGES)
>  LANGBUILTIN(__va_start,   "vc**.", "nt", ALL_MS_LANGUAGES)
>  LANGBUILTIN(__fastfail, "vUi","nr", ALL_MS_LANGUAGES)
>
> Modified: cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c?rev=355698=355697=355698=diff
>
> ==
> --- cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c (original)
> +++ cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c Fri Mar  8 07:10:07
> 2019
> @@ -12,17 +12,10 @@
>  // RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
>  // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility
> -fms-compatibility-version=17.00 \
>  // RUN: -triple x86_64--linux -emit-llvm %s -o - \
> -// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
> +// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
>  // RUN: %clang_cc1 -ffreestanding -fms-extensions \
>  // RUN: -triple x86_64--darwin -emit-llvm %s -o - \
> -// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
> -
> -// LP64 targets use 'long' as 'int' for MS intrinsics (-fms-extensions)
> -#ifdef __LP64__
> -#define LONG int
> -#else
> -#define LONG long
> -#endif
> +// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
>
>  // rotate left
>
> @@ -47,12 +40,15 @@ unsigned int test_rotl(unsigned int valu
>  // CHECK:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]], i32 [[X]],
> i32 [[Y:%.*]])
>  // CHECK:   ret i32 [[R]]
>
> -unsigned LONG test_lrotl(unsigned LONG value, int shift) {
> +unsigned long test_lrotl(unsigned long value, int shift) {
>return _lrotl(value, shift);
>  }
>  // CHECK-32BIT-LONG: i32 @test_lrotl
>  // CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshl.i32(i32 [[X:%.*]],
> i32 [[X]], i32 [[Y:%.*]])
>  // CHECK-32BIT-LONG:   ret i32 [[R]]
> +// CHECK-64BIT-LONG: i64 @test_lrotl
> +// CHECK-64BIT-LONG:   [[R:%.*]] = call i64 @llvm.fshl.i64(i64 [[X:%.*]],
> i64 [[X]], i64 [[Y:%.*]])
> +// CHECK-64BIT-LONG:   ret i64 [[R]]
>
>  unsigned __int64 test_rotl64(unsigned __int64 value, int shift) {
>return _rotl64(value, shift);
> @@ -84,12 +80,15 @@ unsigned int test_rotr(unsigned int valu
>  // CHECK:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]], i32 [[X]],
> i32 [[Y:%.*]])
>  // CHECK:   ret i32 [[R]]
>
> -unsigned LONG test_lrotr(unsigned LONG value, int shift) {
> +unsigned long test_lrotr(unsigned long value, int shift) {
>return _lrotr(value, shift);
>  }
>  // CHECK-32BIT-LONG: i32 @test_lrotr
>  // CHECK-32BIT-LONG:   [[R:%.*]] = call i32 @llvm.fshr.i32(i32 [[X:%.*]],
> i32 [[X]], i32 [[Y:%.*]])
>  // CHECK-32BIT-LONG:   ret i32 [[R]]
> +// CHECK-64BIT-LONG: i64 @test_lrotr
> +// CHECK-64BIT-LONG:   [[R:%.*]] = call i64 @llvm.fshr.i64(i64 [[X:%.*]],
> 

[clang] 16cabf2 - [ASTMatchers] HasNameMatcher handles `extern "C"`

2020-02-26 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-02-26T22:07:47Z
New Revision: 16cabf278fc8c14d415e677ce0bc40d46a6de30d

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

LOG: [ASTMatchers] HasNameMatcher handles `extern "C"`

Summary: Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=42193 | hasName AST 
matcher is confused by extern "C" in namespace. ]]

Reviewers: klimek, aaron.ballman, gribozavr2

Reviewed By: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 59c77a167b1f..777400f84974 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -513,7 +513,13 @@ bool HasNameMatcher::matchesNodeFullFast(const NamedDecl 
) const {
   if (Ctx->isFunctionOrMethod())
 return Patterns.foundMatch(/*AllowFullyQualified=*/false);
 
-  for (; Ctx && isa(Ctx); Ctx = Ctx->getParent()) {
+  for (; Ctx; Ctx = Ctx->getParent()) {
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))
+  continue;
+if (!isa(Ctx))
+  break;
 if (Patterns.foundMatch(/*AllowFullyQualified=*/false))
   return true;
 

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 4b9fce9e3107..65fb11caa489 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1643,6 +1643,21 @@ TEST(Matcher, HasNameSupportsFunctionScope) {
   EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m";
 }
 
+TEST(Matcher, HasNameQualifiedSupportsLinkage) {
+  // https://bugs.llvm.org/show_bug.cgi?id=42193
+  std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+
+  code = R"cpp(namespace foo { extern "C" { void test(); } })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+}
+
 TEST(Matcher, HasAnyName) {
   const std::string Code = "namespace a { namespace b { class C; } }";
 



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


[PATCH] D75210: [Attr] Allow ParsedAttr to be constructor for any Attribute

2020-02-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added a comment.

In D75210#1894370 , @erichkeane wrote:

> I don't see anything glaring here, but I would love some better explanation 
> as to the goal here.  I don't see this used anywhere, the commit message is a 
> bit underwhelming in its reasoning, and there is no test/etc showing why I 
> would want this.


Agreed. The followup "user" patch is going to be put on phab very soon. I did 
rush this one out because I saw D31337  land 
today. Wanted to make sure people see what I hope to achieve here.

The reason for this is `omp begin/end declare variant` which I implement via 
`attribute push/pop`. The idea of both are basically the same, attach some 
information (=Attribute) on all function (definitions) in the scope. I have a 
new function definition matcher and the rest of the logic basically done, some 
overloading work is still missing.




Comment at: clang/include/clang/Sema/ParsedAttr.h:115
 /// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
 /// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
 ///

erichkeane wrote:
> Can you update this comment?
Will do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75210



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


[PATCH] D71227: [cuda][hip] Fix function overload resolution in the global initiailizer.

2020-02-26 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 246826.
hliao added a comment.

Rebase to the latest trunk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71227

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/SemaCUDA.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/SemaCUDA/function-overload.cu
  clang/test/SemaCUDA/global-initializers-host.cu
  clang/test/SemaCUDA/hip-pinned-shadow.cu

Index: clang/test/SemaCUDA/hip-pinned-shadow.cu
===
--- clang/test/SemaCUDA/hip-pinned-shadow.cu
+++ clang/test/SemaCUDA/hip-pinned-shadow.cu
@@ -13,13 +13,19 @@
 
 template 
 struct texture : public textureReference {
+// expected-note@-1{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-2{{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-3{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
+// expected-note@-4{{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
 texture() { a = 1; }
+// expected-note@-1{{candidate constructor not viable: call to __host__ function from __device__ function}}
+// expected-note@-2{{candidate constructor not viable: call to __host__ function from __device__ function}}
 };
 
 __hip_pinned_shadow__ texture tex;
 __device__ __hip_pinned_shadow__ texture tex2; // expected-error{{'hip_pinned_shadow' and 'device' attributes are not compatible}}
-// expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-// expected-note@-2{{conflicting attribute is here}}
+// expected-note@-1{{conflicting attribute is here}}
+// expected-error@-2{{no matching constructor for initialization of 'texture'}}
 __constant__ __hip_pinned_shadow__ texture tex3; // expected-error{{'hip_pinned_shadow' and 'constant' attributes are not compatible}}
-  // expected-error@-1{{dynamic initialization is not supported for __device__, __constant__, and __shared__ variables}}
-  // expected-note@-2{{conflicting attribute is here}}
+  // expected-note@-1{{conflicting attribute is here}}
+  // expected-error@-2{{no matching constructor for initialization of 'texture'}}
Index: clang/test/SemaCUDA/global-initializers-host.cu
===
--- clang/test/SemaCUDA/global-initializers-host.cu
+++ clang/test/SemaCUDA/global-initializers-host.cu
@@ -6,12 +6,14 @@
 // module initializer.
 
 struct S {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 0 were provided}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 0 were provided}}
   __device__ S() {}
-  // expected-note@-1 {{'S' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 
 S s;
-// expected-error@-1 {{reference to __device__ function 'S' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'S'}}
 
 struct T {
   __host__ __device__ T() {}
@@ -19,14 +21,17 @@
 T t;  // No error, this is OK.
 
 struct U {
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const U' for 1st argument}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'U' for 1st argument}}
   __host__ U() {}
+  // expected-note@-1 {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
   __device__ U(int) {}
-  // expected-note@-1 {{'U' declared here}}
+  // expected-note@-1 {{candidate constructor not viable: call to __device__ function from __host__ function}}
 };
 U u(42);
-// expected-error@-1 {{reference to __device__ function 'U' in global initializer}}
+// expected-error@-1 {{no matching constructor for initialization of 'U'}}
 
 __device__ int device_fn() { return 42; }
-// expected-note@-1 {{'device_fn' declared here}}
+// expected-note@-1 {{candidate function not viable: call to __device__ 

[clang] 7848a3c - Update the ARC docs for non-trivial ownership in structs.

2020-02-26 Thread John McCall via cfe-commits

Author: John McCall
Date: 2020-02-26T16:42:08-05:00
New Revision: 7848a3c8ab54570f5875e63606ff75b5736750b4

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

LOG: Update the ARC docs for non-trivial ownership in structs.

Added: 


Modified: 
clang/docs/AutomaticReferenceCounting.rst

Removed: 




diff  --git a/clang/docs/AutomaticReferenceCounting.rst 
b/clang/docs/AutomaticReferenceCounting.rst
index 9d61f58ed4d1..7b86d169ac49 100644
--- a/clang/docs/AutomaticReferenceCounting.rst
+++ b/clang/docs/AutomaticReferenceCounting.rst
@@ -1100,32 +1100,126 @@ A pass-by-writeback is evaluated as follows:
 Ownership-qualified fields of structs and unions
 
 
-A program is ill-formed if it declares a member of a C struct or union to have
-a nontrivially ownership-qualified type.
+A member of a struct or union may be declared to have ownership-qualified
+type, except that it may not be declared to be ``__autoreleasing``.
 
 .. admonition:: Rationale
 
-  The resulting type would be non-POD in the C++ sense, but C does not give us
-  very good language tools for managing the lifetime of aggregates, so it is
-  more convenient to simply forbid them.  It is still possible to manage this
-  with a ``void*`` or an ``__unsafe_unretained`` object.
-
-This restriction does not apply in Objective-C++.  However, nontrivally
-ownership-qualified types are considered non-POD: in C++11 terms, they are not
-trivially default constructible, copy constructible, move constructible, copy
-assignable, move assignable, or destructible.  It is a violation of C++'s One
-Definition Rule to use a class outside of ARC that, under ARC, would have a
-nontrivially ownership-qualified member.
+  Permitting ``__strong`` and ``__weak`` references in aggregate types
+  allows programmers to take advantage of the normal language tools of
+  C and C++ while still automatically managing memory.  While it is
+  usually simpler and more idiomatic to use Objective-C objects for
+  secondary data structures, doing so can introduce extra allocation
+  and message-send overhead, which can cause to unacceptable
+  performance.  Using structs can resolve this tension.
+
+  ``__autoreleasing`` is forbidden because it is treacherous to rely
+  on autoreleases as an ownership tool outside of a function-local
+  contexts.
+
+  Earlier releases of Clang permitted ``__strong`` and ``__weak`` only
+  references in Objective-C++ classes, not in Objective-C.  This
+  restriction was an undesirable short-term constraint arising from the
+  complexity of adding support for non-trivial struct types to C.
+
+In Objective-C++, for the purposes of determining triviality of special
+members, nontrivially ownership-qualified types are treated as if they
+were class types with:
+- non-trivial default, copy, and move constructors,
+- non-trivial copy and move assignment operators, and
+- non-trivial destructors.
+
+In Objective-C, language rules have been added to cover non-trivial
+members of struct and union types.  These rules generally match the
+Objective-C++ behavior and can be summarized as follows:
+
+- Initializing, copying, or destroying a struct with non-trivial
+  members recursively initializes, copies or destroys those members
+  as appropriate for their type.
+
+- Copying or destroying a union with non-trivial members is ill-formed.
+  (This also applies to structs containing such unions.)  It is
+  nonetheless possible to create objects of these types by
+  zero-initializing suitable memory before accessing it through the
+  union type, and they may be destroyed by ensuring that any active
+  members are reset to ``nil`` before the memory is re-used.  These
+  techniques mirror the precautions necessary when working with
+  dynamically-allocated arrays of nontrivially ownership-qualified type.
+
+Structs and unions with non-trivial members are compatible in
+
diff erent language modes under the following conditions:
+
+- The types must be compatible ignoring ownership qualifiers according
+  to the baseline non-ARC rules.  This condition implies a pairwise
+  correspondance between fields.
+
+  Note that an Objective-C++ class with base classes, a user-provided
+  copy or move constructor, or a user-provided destructor is never
+  compatible with an Objective-C type.
+
+- If two fields correspond as above, and at least one of the fields is
+  ownership-qualified, then:
+
+- the fields must be identically qualified, or else
+
+- one type must be unqualified (and thus declared in a non-ARC mode),
+  and the other type must be qualified with ``__unsafe_unretained``
+  or ``__strong``.
+
+  Note that ``__weak`` fields must always be declared ``__weak``  because
+  of the 

[PATCH] D75202: [ASTMatchers] HasNameMatcher handles `extern "C"`

2020-02-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:518
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))

I would imagine we'd want to skip an `ExternCContextDecl` for similar reasons, 
though I am struggling to find a test case that actually generates that context.



Comment at: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp:1648
+  // https://bugs.llvm.org/show_bug.cgi?id=42193
+  std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";

As another test:
```
namespace foo {
extern "C" {
void test();
}
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75202



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


[PATCH] D44609: [clang-format] New option BeforeLambdaBody to manage lambda line break inside function parameter call (in Allman style)

2020-02-26 Thread Francois JEAN via Phabricator via cfe-commits
Wawha added a comment.

In D44609#1893390 , 
@christophe-calmejane wrote:

> Nice to finally see this patch integrated!
>
> But, it looks like you didn't include all the test case I posted 1.5y ago in 
> this post, that are still problematic and not formatting correctly with your 
> patch:
>  For example, this simple case do not format correctly:
>
>   paramBeforeAndAfterLambda(8,[](int x){call();},5);
>
>
> The output is:
>
>   paramBeforeAndAfterLambda(
>   8,
>   [](int x)
>   {
>   call();
>   },
>   5);
>  
>
>
> although I would expect to see
>
>   paramBeforeAndAfterLambda(8,
>   [](int x)
>   {
>   call();
>   },
>   5);
>  
>
>
> See my proposed fix in the discussion, but note that I don't think it's clean 
> enough to be accepted :)


Thank for the feedback.

Looking back at your comment and patch, I integrate most of your proposal in 
order to fix the problem with "noexcept" .
I even have a comment of MyDevelopperDay because I reuse the keyword "auto" for 
nextTok variable like it was in your proposal :)

For the bug your are reporting with the line wrap for first parameter, looking 
at the tests I wrote, I see two tests which have should cover that case:

  verifyFormat("FctWithMultipleParams_SLS_Empty(A, B,\n"
  " []()\n"
  " {\n"
  " return 17;\n"
  " });", LLVMWithBeforeLambdaBody);
  
  verifyFormat("TwoNestedLambdas_SLS_Empty(A,\n"
   " []()\n"
   " {\n"
   " return Call([]() {});\n"
   " });", LLVMWithBeforeLambdaBody);

So perhaps there is a mistake, depending of the options or if there is an extra 
parameter after the lambda.
I do not have a PC in the next 10 Days to check that but I Will try have a look 
later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D44609



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


[PATCH] D75210: [Attr] Allow ParsedAttr to be constructor for any Attribute

2020-02-26 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I don't see anything glaring here, but I would love some better explanation as 
to the goal here.  I don't see this used anywhere, the commit message is a bit 
underwhelming in its reasoning, and there is no test/etc showing why I would 
want this.




Comment at: clang/include/clang/Sema/ParsedAttr.h:115
 /// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
 /// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
 ///

Can you update this comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75210



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


[PATCH] D75210: [Attr] Allow ParsedAttr to be constructor for any Attribute

2020-02-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added reviewers: erichkeane, aaron.ballman, rjmccall, john.brawn.
Herald added a subscriber: bollu.
Herald added a project: clang.

ParsedAttr is used for `clang attribute push/pop` a utility that is
reusable in other contexts as well. This allows us to create "fake"
parsed attributes from other attributes, e.g., implicit ones.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75210

Files:
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Sema/ParsedAttr.cpp

Index: clang/lib/Sema/ParsedAttr.cpp
===
--- clang/lib/Sema/ParsedAttr.cpp
+++ clang/lib/Sema/ParsedAttr.cpp
@@ -42,10 +42,10 @@
   else if (HasParsedType)
 return totalSizeToAlloc(0, 0, 0, 1, 0);
+detail::PropertyData, Attr *>(0, 0, 0, 1, 0, 0);
   return totalSizeToAlloc(NumArgs, 0, 0, 0, 0);
+  detail::PropertyData, Attr *>(NumArgs, 0, 0, 0, 0, 0);
 }
 
 AttributeFactory::AttributeFactory() {
Index: clang/include/clang/Sema/ParsedAttr.h
===
--- clang/include/clang/Sema/ParsedAttr.h
+++ clang/include/clang/Sema/ParsedAttr.h
@@ -116,9 +116,10 @@
 ///
 class ParsedAttr final
 : public AttributeCommonInfo,
-  private llvm::TrailingObjects<
-  ParsedAttr, ArgsUnion, detail::AvailabilityData,
-  detail::TypeTagForDatatypeData, ParsedType, detail::PropertyData> {
+  private llvm::TrailingObjects {
   friend TrailingObjects;
 
   size_t numTrailingObjects(OverloadToken) const { return NumArgs; }
@@ -135,6 +136,7 @@
   size_t numTrailingObjects(OverloadToken) const {
 return IsProperty;
   }
+  size_t numTrailingObjects(OverloadToken) const { return HasAttrPtr; }
 
 private:
   IdentifierInfo *MacroII = nullptr;
@@ -143,7 +145,7 @@
 
   /// The number of expression arguments this attribute has.
   /// The expressions themselves are stored after the object.
-  unsigned NumArgs : 16;
+  unsigned NumArgs : 15;
 
   /// True if already diagnosed as invalid.
   mutable unsigned Invalid : 1;
@@ -166,6 +168,9 @@
   /// True if this has a ParsedType
   unsigned HasParsedType : 1;
 
+  /// True if this has an attribute pointer.
+  unsigned HasAttrPtr : 1;
+
   /// True if the processing cache is valid.
   mutable unsigned HasProcessingCache : 1;
 
@@ -207,7 +212,8 @@
 EllipsisLoc(ellipsisLoc), NumArgs(numArgs), Invalid(false),
 UsedAsTypeAttr(false), IsAvailability(false),
 IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
-HasProcessingCache(false), IsPragmaClangAttribute(false) {
+HasAttrPtr(false), HasProcessingCache(false),
+IsPragmaClangAttribute(false) {
 if (numArgs)
   memcpy(getArgsBuffer(), args, numArgs * sizeof(ArgsUnion));
   }
@@ -224,8 +230,9 @@
 syntaxUsed),
 NumArgs(1), Invalid(false), UsedAsTypeAttr(false), IsAvailability(true),
 IsTypeTagForDatatype(false), IsProperty(false), HasParsedType(false),
-HasProcessingCache(false), IsPragmaClangAttribute(false),
-UnavailableLoc(unavailable), MessageExpr(messageExpr) {
+HasAttrPtr(false), HasProcessingCache(false),
+IsPragmaClangAttribute(false), UnavailableLoc(unavailable),
+MessageExpr(messageExpr) {
 ArgsUnion PVal(Parm);
 memcpy(getArgsBuffer(), , sizeof(ArgsUnion));
 new (getAvailabilityData()) detail::AvailabilityData(
@@ -241,7 +248,7 @@
 syntaxUsed),
 NumArgs(3), Invalid(false), UsedAsTypeAttr(false),
 IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
-HasParsedType(false), HasProcessingCache(false),
+HasParsedType(false), HasAttrPtr(false), HasProcessingCache(false),
 IsPragmaClangAttribute(false) {
 ArgsUnion *Args = getArgsBuffer();
 Args[0] = Parm1;
@@ -258,7 +265,7 @@
 syntaxUsed),
 NumArgs(1), Invalid(false), UsedAsTypeAttr(false),
 IsAvailability(false), IsTypeTagForDatatype(true), IsProperty(false),
-HasParsedType(false), HasProcessingCache(false),
+HasParsedType(false), HasAttrPtr(false), HasProcessingCache(false),
 IsPragmaClangAttribute(false) {
 ArgsUnion PVal(ArgKind);
 memcpy(getArgsBuffer(), , sizeof(ArgsUnion));
@@ -276,7 +283,7 @@
 syntaxUsed),
 NumArgs(0), Invalid(false), UsedAsTypeAttr(false),
 IsAvailability(false), IsTypeTagForDatatype(false), IsProperty(false),
-HasParsedType(true), HasProcessingCache(false),
+HasParsedType(true), HasAttrPtr(false), HasProcessingCache(false),
 IsPragmaClangAttribute(false) {
 new (()) ParsedType(typeArg);
   }
@@ -290,11 +297,25 @@
 syntaxUsed),
 NumArgs(0), Invalid(false), UsedAsTypeAttr(false),
 

[PATCH] D75056: [Driver] Default to -fno-common for all targets

2020-02-26 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Are there any tests remaining that check that with -fcommon, IR generation 
creates "common" variables, now that all these tests have been modified? If 
there are not, one should be added.




Comment at: clang/docs/ClangCommandLineReference.rst:1311
+Place definitions of variables with no storage class and no initializer
+(tentative definitions) in a common block, or generate individual
+zero-initialized definitions (default -fno-common).

Use "instead of generating" instead of "or generate".

Mention "This option has no effect in C++ mode."



Comment at: clang/docs/ReleaseNotes.rst:87
 
+- -fno-common has been enabled as the default for all targets.
 

Might be nice to expand upon this somewhat, to give users a clue what it means 
to them.

E.g. 

Therefore, C code which uses multiple definitions of a global variable will 
trigger a multiple-definition linker errors. Generally this occurs when a 
variable in a header file neglects to use the "extern" keyword on the 
declaration. The previous behavior can be restored by specifying -fcommon.


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

https://reviews.llvm.org/D75056



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


[PATCH] D74941: [OpenMP] `omp begin/end declare variant` - part 1, parsing

2020-02-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman 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/D74941/new/

https://reviews.llvm.org/D74941



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


[PATCH] D75077: [OpenMP5.0] Allow pointer arithmetic in motion/map clause

2020-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/test/OpenMP/target_update_codegen.cpp:371-372
+  // CK6-DAG: store i32* [[ADD_PTR:%.+]], i32** [[PC0]]
+  // CK6-DAG: [[ADD_PTR]] = getelementptr inbounds i32, i32* [[ONE:%.+]], 
i{{32|64}} [[IDX_EXT:%.+]]
+  // CK6-DAG: [[TWO:%.+]] = load i32, i32* [[L_ADDR:%.+]]
+  // CK6-DAG: store i32 [[L:%.+]], i32* [[L_ADDR]]

I suppose you missed some checks here, where `IDX_EXT` and `TWO` are used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75077



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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

Also, we cannot remove traversing of RecordDecl and CapturedDecl encountered in 
function body since we have OpenMP test like this:

  int main() {
  #pragma omp target
{
  t1(0);
}
return 0;
  }

This results in a kernel function embedded in a captured record decl in AST. We 
have to drill into the record decl to get the kernel and the function called by 
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Submitted fixes in d2cbaf1755ffa90300365c0d71400a5ee4ada3bd 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


[PATCH] D75056: [Driver] Default to -fno-common for all targets

2020-02-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

LGTM. Hope @tstellar and @jyknight can confirm.


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

https://reviews.llvm.org/D75056



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


[PATCH] D75209: [OPENMP][NVPTX]Fix PR45003: add support for complex functions.

2020-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: tra, hfinkel.
Herald added a subscriber: guansong.
Herald added a project: clang.

Inherited support for complex math functions from CUDA implementation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75209

Files:
  clang/lib/Headers/__clang_cuda_complex_builtins.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp

Index: clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
===
--- clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
+++ clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
@@ -24,3 +24,15 @@
 double l5 = abs((int)a1);
   }
 }
+
+// CHECK-YES-DAG: call { double, double } @__muldc3(
+// CHECK-YES-DAG: call { double, double } @__divdc3(
+void test_cmplx(double _Complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
+// CHECK-YES-DAG: define {{.*}}hidden { double, double } @__muldc3(
+// CHECK-YES-DAG: define {{.*}}hidden { double, double } @__divdc3(
+
Index: clang/test/Headers/nvptx_device_cmath_functions.cpp
===
--- clang/test/Headers/nvptx_device_cmath_functions.cpp
+++ clang/test/Headers/nvptx_device_cmath_functions.cpp
@@ -24,3 +24,15 @@
 double l5 = abs((int)a1);
   }
 }
+
+// CHECK-YES-DAG: call { float, float } @__mulsc3(
+// CHECK-YES-DAG: call { float, float } @__divsc3(
+void test_cmplx(float _Complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
+// CHECK-YES-DAG: define {{.*}}hidden { float, float } @__mulsc3(
+// CHECK-YES-DAG: define {{.*}}hidden { float, float } @__divsc3(
+
Index: clang/test/Headers/nvptx_device_cmath_functions.c
===
--- clang/test/Headers/nvptx_device_cmath_functions.c
+++ clang/test/Headers/nvptx_device_cmath_functions.c
@@ -8,6 +8,11 @@
 
 #include 
 
+// CHECK-YES-DAG: define {{.*}}hidden { double, double } @__muldc3(
+// CHECK-YES-DAG: define {{.*}}hidden { float, float } @__mulsc3(
+// CHECK-YES-DAG: define {{.*}}hidden { double, double } @__divdc3(
+// CHECK-YES-DAG: define {{.*}}hidden { float, float } @__divsc3(
+
 void test_sqrt(double a1) {
   #pragma omp target
   {
@@ -23,3 +28,11 @@
 double l5 = abs((int)a1);
   }
 }
+
+// CHECK-YES-NOT: @{{__mulsc3|__divsc3}}(
+void test_cmplx(float _Complex a) {
+#pragma omp target
+  {
+(void)(a * (a / a));
+  }
+}
Index: clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
===
--- clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
+++ clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
@@ -26,6 +26,8 @@
 #include <__clang_cuda_libdevice_declares.h>
 /// Provide definitions for these functions.
 #include <__clang_cuda_device_functions.h>
+/// Provide definitions for complex math functions.
+#include <__clang_cuda_complex_builtins.h>
 
 #undef __CUDA__
 
Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -15,8 +15,61 @@
 // operations.  (These implementations come from libc++, and have been modified
 // to work with CUDA.)
 
-extern "C" inline __device__ double _Complex __muldc3(double __a, double __b,
-  double __c, double __d) {
+#ifdef _OPENMP
+#ifdef __cplusplus
+#define __DEVICE__ extern "C" inline
+#else
+#define __DEVICE__ __attribute__((always_inline))
+#endif // __cplusplus
+#else
+#define __DEVICE__ extern "C" inline __device__
+#endif // _OPENMP
+
+#ifdef _OPENMP
+#define MAX(x, y) fmax((x), (y))
+#define MAXF(x, y) fmaxf((x), (y))
+#define IS_NAN(x) __isnan(x)
+#define IS_NANF(x) __isnanf(x)
+#define IS_INF(x) __isinf(x)
+#define IS_INFF(x) __isinff(x)
+#define IS_FINITE(x) __finite(x)
+#define IS_FINITEF(x) __finitef(x)
+#define COPYSIGN(x, y) copysign((x), (y))
+#define COPYSIGNF(x, y) copysignf((x), (y))
+#define LOGB(x) logb(x)
+#define LOGBF(x) logbf(x)
+#define ABS(x) fabs(x)
+#define ABSF(x) fabsf(x)
+#define SCALBN(x, y) scalbn((x), (y))
+#define SCALBNF(x, y) scalbnf((x), (y))
+#else
+// Can't use std::max, because that's defined in , and we don't
+// want to pull that in for every compile.  The CUDA headers define
+// ::max(float, float) and ::max(double, double), which is sufficient for us.
+#define MAX(x, y) max((x), (y))
+#define MAXF(x, y) max((x), (y))
+#define IS_NAN(x) std::isnan(x)
+#define IS_NANF(x) std::isnan(x)
+#define IS_INF(x) std::isinf(x)
+#define IS_INFF(x) std::isinf(x)
+#define IS_FINITE(x) std::isfinite(x)
+#define 

[clang] d2cbaf1 - Fix for the test failues introduced in https://reviews.llvm.org/D74704.

2020-02-26 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-02-26T12:23:15-08:00
New Revision: d2cbaf1755ffa90300365c0d71400a5ee4ada3bd

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

LOG: Fix for the test failues introduced in https://reviews.llvm.org/D74704.

Added: 


Modified: 
clang/test/Driver/riscv32-toolchain-extra.c
clang/test/Driver/riscv64-toolchain-extra.c

Removed: 




diff  --git a/clang/test/Driver/riscv32-toolchain-extra.c 
b/clang/test/Driver/riscv32-toolchain-extra.c
index ff9842b37c02..3182e0cfc1ae 100644
--- a/clang/test/Driver/riscv32-toolchain-extra.c
+++ b/clang/test/Driver/riscv32-toolchain-extra.c
@@ -11,6 +11,7 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
+// REQUIRES: platform-linker
 // RUN: mkdir -p %T/testroot-riscv32-baremetal-nogcc/bin
 // RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/clang ] || rm 
%T/testroot-riscv32-baremetal-nogcc/bin/clang
 // RUN: [ ! -s %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld 
] || rm %T/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld

diff  --git a/clang/test/Driver/riscv64-toolchain-extra.c 
b/clang/test/Driver/riscv64-toolchain-extra.c
index 6b474e88f473..081fc67e01cf 100644
--- a/clang/test/Driver/riscv64-toolchain-extra.c
+++ b/clang/test/Driver/riscv64-toolchain-extra.c
@@ -11,6 +11,7 @@
 // The test below checks that the driver correctly finds the linker and
 // runtime if and only if they exist.
 //
+// REQUIRES: platform-linker
 // RUN: mkdir -p %T/testroot-riscv64-baremetal-nogcc/bin
 // RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/clang ] || rm 
%T/testroot-riscv64-baremetal-nogcc/bin/clang
 // RUN: [ ! -s %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld 
] || rm %T/testroot-riscv64-baremetal-nogcc/bin/riscv64-unknown-elf-ld



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


[PATCH] D75198: [ms] Rename ParsingInlineAsm functions/variables to reflect MS-specificity.

2020-02-26 Thread Eric Astor via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG85b641c27aec: [ms] Rename ParsingInlineAsm 
functions/variables to reflect MS-specificity. (authored by epastor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75198

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  llvm/include/llvm/MC/MCParser/MCAsmParser.h
  llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -611,9 +611,9 @@
 }
 bool onIdentifierExpr(const MCExpr *SymRef, StringRef SymRefName,
   const InlineAsmIdentifierInfo ,
-  bool ParsingInlineAsm, StringRef ) {
+  bool ParsingMSInlineAsm, StringRef ) {
   // InlineAsm: Treat an enum value as an integer
-  if (ParsingInlineAsm)
+  if (ParsingMSInlineAsm)
 if (IDInfo.isKind(InlineAsmIdentifierInfo::IK_EnumVal))
   return onInteger(IDInfo.Enum.EnumVal, ErrMsg);
   // Treat a symbolic constant like an integer
@@ -634,7 +634,7 @@
 MemExpr = true;
 State = IES_INTEGER;
 IC.pushOperand(IC_IMM);
-if (ParsingInlineAsm)
+if (ParsingMSInlineAsm)
   Info = IDInfo;
 break;
   }
@@ -815,7 +815,7 @@
   }
 }
 bool onOffset(const MCExpr *Val, SMLoc OffsetLoc, StringRef ID,
-  const InlineAsmIdentifierInfo , bool ParsingInlineAsm,
+  const InlineAsmIdentifierInfo , bool ParsingMSInlineAsm,
   StringRef ) {
   PrevState = State;
   switch (State) {
@@ -833,7 +833,7 @@
 // As we cannot yet resolve the actual value (offset), we retain
 // the requested semantics by pushing a '0' to the operands stack
 IC.pushOperand(IC_IMM);
-if (ParsingInlineAsm) {
+if (ParsingMSInlineAsm) {
   Info = IDInfo;
 }
 break;
@@ -899,10 +899,10 @@
 
   bool ParseIntelMemoryOperandSize(unsigned );
   std::unique_ptr
-  CreateMemForInlineAsm(unsigned SegReg, const MCExpr *Disp, unsigned BaseReg,
-unsigned IndexReg, unsigned Scale, SMLoc Start,
-SMLoc End, unsigned Size, StringRef Identifier,
-const InlineAsmIdentifierInfo );
+  CreateMemForMSInlineAsm(unsigned SegReg, const MCExpr *Disp, unsigned BaseReg,
+  unsigned IndexReg, unsigned Scale, SMLoc Start,
+  SMLoc End, unsigned Size, StringRef Identifier,
+  const InlineAsmIdentifierInfo );
 
   bool parseDirectiveEven(SMLoc L);
   bool ParseDirectiveCode(StringRef IDVal, SMLoc L);
@@ -1177,7 +1177,7 @@
 
   // The "flags" and "mxcsr" registers cannot be referenced directly.
   // Treat it as an identifier instead.
-  if (isParsingInlineAsm() && isParsingIntelSyntax() &&
+  if (isParsingMSInlineAsm() && isParsingIntelSyntax() &&
   (RegNo == X86::EFLAGS || RegNo == X86::MXCSR))
 RegNo = 0;
 
@@ -1458,7 +1458,7 @@
   return ParseATTOperand();
 }
 
-std::unique_ptr X86AsmParser::CreateMemForInlineAsm(
+std::unique_ptr X86AsmParser::CreateMemForMSInlineAsm(
 unsigned SegReg, const MCExpr *Disp, unsigned BaseReg, unsigned IndexReg,
 unsigned Scale, SMLoc Start, SMLoc End, unsigned Size, StringRef Identifier,
 const InlineAsmIdentifierInfo ) {
@@ -1536,7 +1536,7 @@
   return true;
 StringRef ErrMsg;
 ParseError =
-SM.onOffset(Val, OffsetLoc, ID, Info, isParsingInlineAsm(), ErrMsg);
+SM.onOffset(Val, OffsetLoc, ID, Info, isParsingMSInlineAsm(), ErrMsg);
 if (ParseError)
   return Error(SMLoc::getFromPointer(Name.data()), ErrMsg);
   } else {
@@ -1595,7 +1595,7 @@
   // Symbol reference, when parsing assembly content
   InlineAsmIdentifierInfo Info;
   const MCExpr *Val;
-  if (!isParsingInlineAsm()) {
+  if (!isParsingMSInlineAsm()) {
 if (getParser().parsePrimaryExpr(Val, End)) {
   return Error(Tok.getLoc(), "Unexpected identifier!");
 } else if (SM.onIdentifierExpr(Val, Identifier, Info, false, ErrMsg)) {
@@ -1646,8 +1646,8 @@
 return Error(Loc, "invalid reference to undefined symbol");
   StringRef Identifier = Sym->getName();
   InlineAsmIdentifierInfo Info;
-  if (SM.onIdentifierExpr(Val, Identifier, Info,
-  isParsingInlineAsm(), ErrMsg))
+  if (SM.onIdentifierExpr(Val, Identifier, Info, isParsingMSInlineAsm(),
+  ErrMsg))
 return Error(Loc, ErrMsg);
   End = consumeToken();
   

[clang] 85b641c - [ms] Rename ParsingInlineAsm functions/variables to reflect MS-specificity.

2020-02-26 Thread Eric Astor via cfe-commits

Author: Eric Astor
Date: 2020-02-26T15:19:40-05:00
New Revision: 85b641c27aecee637d3f7ab25915f47438f55848

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

LOG: [ms] Rename ParsingInlineAsm functions/variables to reflect MS-specificity.

Summary: ParsingInlineAsm was a misleading name. These values are only set for 
MS-style inline assembly.

Reviewed By: rnk

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/Parse/ParseStmtAsm.cpp
llvm/include/llvm/MC/MCParser/MCAsmParser.h
llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/MasmParser.cpp
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseStmtAsm.cpp 
b/clang/lib/Parse/ParseStmtAsm.cpp
index b596aded867d..bf02dd6c02d4 100644
--- a/clang/lib/Parse/ParseStmtAsm.cpp
+++ b/clang/lib/Parse/ParseStmtAsm.cpp
@@ -631,8 +631,8 @@ StmtResult 
Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
   // Change to the Intel dialect.
   Parser->setAssemblerDialect(1);
   Parser->setTargetParser(*TargetParser.get());
-  Parser->setParsingInlineAsm(true);
-  TargetParser->setParsingInlineAsm(true);
+  Parser->setParsingMSInlineAsm(true);
+  TargetParser->setParsingMSInlineAsm(true);
 
   ClangAsmParserCallback Callback(*this, AsmLoc, AsmString, AsmToks,
   TokOffsets);

diff  --git a/llvm/include/llvm/MC/MCParser/MCAsmParser.h 
b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
index 9d9091306c13..7d57dd605fcb 100644
--- a/llvm/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/llvm/include/llvm/MC/MCParser/MCAsmParser.h
@@ -165,8 +165,8 @@ class MCAsmParser {
   /// Run the parser on the input source buffer.
   virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false) = 0;
 
-  virtual void setParsingInlineAsm(bool V) = 0;
-  virtual bool isParsingInlineAsm() = 0;
+  virtual void setParsingMSInlineAsm(bool V) = 0;
+  virtual bool isParsingMSInlineAsm() = 0;
 
   /// Parse MS-style inline assembly.
   virtual bool parseMSInlineAsm(

diff  --git a/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h 
b/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
index 9ce1890916e9..ad086eaa539c 100644
--- a/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
+++ b/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
@@ -329,8 +329,8 @@ class MCTargetAsmParser : public MCAsmParserExtension {
   /// AvailableFeatures - The current set of available features.
   FeatureBitset AvailableFeatures;
 
-  /// ParsingInlineAsm - Are we parsing ms-style inline assembly?
-  bool ParsingInlineAsm = false;
+  /// ParsingMSInlineAsm - Are we parsing ms-style inline assembly?
+  bool ParsingMSInlineAsm = false;
 
   /// SemaCallback - The Sema callback implementation.  Must be set when 
parsing
   /// ms-style inline assembly.
@@ -359,8 +359,8 @@ class MCTargetAsmParser : public MCAsmParserExtension {
 AvailableFeatures = Value;
   }
 
-  bool isParsingInlineAsm () { return ParsingInlineAsm; }
-  void setParsingInlineAsm (bool Value) { ParsingInlineAsm = Value; }
+  bool isParsingMSInlineAsm () { return ParsingMSInlineAsm; }
+  void setParsingMSInlineAsm (bool Value) { ParsingMSInlineAsm = Value; }
 
   MCTargetOptions getTargetOptions() const { return MCOptions; }
 

diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp 
b/llvm/lib/MC/MCParser/AsmParser.cpp
index 05c479abb69b..57e152156475 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -174,7 +174,7 @@ class AsmParser : public MCAsmParser {
   bool IsDarwin = false;
 
   /// Are we parsing ms-style inline assembly?
-  bool ParsingInlineAsm = false;
+  bool ParsingMSInlineAsm = false;
 
   /// Did we already inform the user about inconsistent MD5 usage?
   bool ReportedInconsistentMD5 = false;
@@ -226,13 +226,13 @@ class AsmParser : public MCAsmParser {
 
   const AsmToken () override;
 
-  void setParsingInlineAsm(bool V) override {
-ParsingInlineAsm = V;
+  void setParsingMSInlineAsm(bool V) override {
+ParsingMSInlineAsm = V;
 // When parsing MS inline asm, we must lex 0b1101 and 0ABCH as binary and
 // hex integer literals.
 Lexer.setLexMasmIntegers(V);
   }
-  bool isParsingInlineAsm() override { return ParsingInlineAsm; }
+  bool isParsingMSInlineAsm() override { return ParsingMSInlineAsm; }
 
   bool parseMSInlineAsm(void *AsmLoc, std::string ,
 unsigned , unsigned ,
@@ -994,7 +994,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool 
NoFinalize) {
 }
 
 bool AsmParser::checkForValidSection() {
-  if (!ParsingInlineAsm && !getStreamer().getCurrentSectionOnly()) {
+  if (!ParsingMSInlineAsm && 

[PATCH] D75056: [Driver] Default to -fno-common for all targets

2020-02-26 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 246808.
SjoerdMeijer retitled this revision from "[Driver] Default to -fno-common" to 
"[Driver] Default to -fno-common for all targets".
SjoerdMeijer edited the summary of this revision.
SjoerdMeijer added a comment.

Removed the CHECK-NOTs from some tests as suggested.

And as also suggested, made the title more descriptive.

Thanks for all suggestions!


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

https://reviews.llvm.org/D75056

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
  clang/test/CodeGen/2009-10-20-GlobalDebug.c
  clang/test/CodeGen/aarch64-sve.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/alignment.c
  clang/test/CodeGen/asm-label.c
  clang/test/CodeGen/attr-weak-import.c
  clang/test/CodeGen/attr-weakref2.c
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/blocks-windows.c
  clang/test/CodeGen/bool-convert.c
  clang/test/CodeGen/c11atomics.c
  clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
  clang/test/CodeGen/cfstring-windows.c
  clang/test/CodeGen/default-address-space.c
  clang/test/CodeGen/dllexport-1.c
  clang/test/CodeGen/dllexport.c
  clang/test/CodeGen/dllimport.c
  clang/test/CodeGen/microsoft-no-common-align.c
  clang/test/CodeGen/no-common.c
  clang/test/CodeGen/pr25786.c
  clang/test/CodeGen/pragma-pack-1.c
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/private-extern-redef.c
  clang/test/CodeGen/tentative-decls.c
  clang/test/CodeGen/tls-model.c
  clang/test/CodeGen/visibility.c
  clang/test/CodeGen/vlt_to_pointer.c
  clang/test/CodeGen/volatile-1.c
  clang/test/CodeGen/weak-global.c
  clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
  clang/test/CodeGenCXX/clang-sections-tentative.c
  clang/test/CodeGenObjC/constant-string-class.m
  clang/test/CodeGenObjC/tentative-cfconstantstring.m
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
  clang/test/Driver/apple-kext-mkernel.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/no-common.c
  clang/test/Driver/xcore-opts.c
  clang/test/Frontend/ast-codegen.c
  clang/test/Headers/xmmintrin.c
  clang/test/PCH/chain-external-defs.c
  clang/test/PCH/external-defs.c
  clang/test/PCH/tentative-defs.c
  clang/test/Parser/pragma-visibility2.c

Index: clang/test/Parser/pragma-visibility2.c
===
--- clang/test/Parser/pragma-visibility2.c
+++ clang/test/Parser/pragma-visibility2.c
@@ -6,14 +6,14 @@
 #pragma GCC visibility push(hidden)
 
 int v1;
-// CHECK: @v1 = common hidden global i32 0, align 4
+// CHECK: @v1 = hidden global i32 0, align 4
 
 #pragma GCC visibility pop
 
 int v2;
-// CHECK: @v2 = common global i32 0, align 4
+// CHECK: @v2 = global i32 0, align 4
 
 _Pragma("GCC visibility push(hidden)");
 
 int v3;
-// CHECK: @v3 = common hidden global i32 0, align 4
+// CHECK: @v3 = hidden global i32 0, align 4
Index: clang/test/PCH/tentative-defs.c
===
--- clang/test/PCH/tentative-defs.c
+++ clang/test/PCH/tentative-defs.c
@@ -1,6 +1,6 @@
 // Test with pch.
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/tentative-defs.h
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -verify -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -emit-pch -o %t.pch %S/tentative-defs.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -include-pch %t.pch -verify -emit-llvm -o %t %s
 // REQUIRES: x86-registered-target
 
 // RUN: grep "@variable = common global i32 0" %t | count 1
Index: clang/test/PCH/external-defs.c
===
--- clang/test/PCH/external-defs.c
+++ clang/test/PCH/external-defs.c
@@ -3,16 +3,16 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/external-defs.h
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s
 
-// RUN: grep "@x = common global i32 0" %t | count 1
+// RUN: grep "@x = global i32 0" %t | count 1
 // RUN: not grep "@z" %t
 
 // RUN: grep "@x2 = global i32 19" %t | count 1
 int x2 = 19;
 
-// RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1
-// RUN: grep "@incomplete_array2 = common global .*17 x i32" %t | count 1
+// RUN: grep "@incomplete_array = global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array2 = global .*17 x i32" %t | count 1
 int incomplete_array2[17];
-// RUN: grep "@incomplete_array3 = common global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array3 = global .*1 x i32" %t | count 1
 int incomplete_array3[];
 
 struct S 

Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Serge Guelton via cfe-commits
On Wed, Feb 26, 2020 at 08:08:49PM +, Leonard Chan via Phabricator wrote:
> leonardchan added a comment.
> 
> Unsure if my reply was sent over email so copying it here.
> 
> Yup, adding `// REQUIRES: platform-linker` to both `*-extra.c` files seems to 
> fix it. Thanks. Will you be sending out the fix?

Feel free to commit these changes/push them on phabricator if they work for 
you, unless you explicitly
want me to do it?

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


[PATCH] D74418: [clang] fix error detection in consteval calls

2020-02-26 Thread Tyker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGca50f09db9f8: [clang] fix error detection in consteval calls 
(authored by Tyker).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D74418?vs=243892=246810#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74418

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -309,6 +309,14 @@
 
 namespace alloc {
 
+consteval int f() {
+  int *A = new int(0);
+// expected-note@-1+ {{allocation performed here was not deallocated}}
+  return *A;
+}
+
+int i1 = f(); // expected-error {{is not a constant expression}}
+
 struct A {
   int* p = new int(42);
   // expected-note@-1+ {{heap allocation performed here}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15368,8 +15368,9 @@
   Expr::EvalResult Eval;
   Eval.Diag = 
   ConstantExpr *CE = Candidate.getPointer();
-  if (!CE->EvaluateAsConstantExpr(Eval, Expr::EvaluateForCodeGen,
-  SemaRef.getASTContext(), true)) {
+  bool Result = CE->EvaluateAsConstantExpr(Eval, Expr::EvaluateForCodeGen,
+   SemaRef.getASTContext(), true);
+  if (!Result || !Notes.empty()) {
 Expr *InnerExpr = CE->getSubExpr()->IgnoreImplicit();
 FunctionDecl *FD = nullptr;
 if (auto *Call = dyn_cast(InnerExpr))


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -309,6 +309,14 @@
 
 namespace alloc {
 
+consteval int f() {
+  int *A = new int(0);
+// expected-note@-1+ {{allocation performed here was not deallocated}}
+  return *A;
+}
+
+int i1 = f(); // expected-error {{is not a constant expression}}
+
 struct A {
   int* p = new int(42);
   // expected-note@-1+ {{heap allocation performed here}}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15368,8 +15368,9 @@
   Expr::EvalResult Eval;
   Eval.Diag = 
   ConstantExpr *CE = Candidate.getPointer();
-  if (!CE->EvaluateAsConstantExpr(Eval, Expr::EvaluateForCodeGen,
-  SemaRef.getASTContext(), true)) {
+  bool Result = CE->EvaluateAsConstantExpr(Eval, Expr::EvaluateForCodeGen,
+   SemaRef.getASTContext(), true);
+  if (!Result || !Notes.empty()) {
 Expr *InnerExpr = CE->getSubExpr()->IgnoreImplicit();
 FunctionDecl *FD = nullptr;
 if (auto *Call = dyn_cast(InnerExpr))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ca50f09 - [clang] fix error detection in consteval calls

2020-02-26 Thread via cfe-commits

Author: Tyker
Date: 2020-02-26T21:09:31+01:00
New Revision: ca50f09db9f86eb5ac7aa0cb53c52637f2b7effa

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

LOG: [clang] fix error detection in consteval calls

Summary:
code like:
```
consteval int f() {
  int *A = new int(0);
  return *A;
}

int i1 = f();
```
currently doesn't generate any error.

Reviewers: rsmith

Reviewed By: rsmith

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

Added: 


Modified: 
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/cxx2a-consteval.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d07c32487c13..f50a77a40510 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -15368,8 +15368,9 @@ static void EvaluateAndDiagnoseImmediateInvocation(
   Expr::EvalResult Eval;
   Eval.Diag = 
   ConstantExpr *CE = Candidate.getPointer();
-  if (!CE->EvaluateAsConstantExpr(Eval, Expr::EvaluateForCodeGen,
-  SemaRef.getASTContext(), true)) {
+  bool Result = CE->EvaluateAsConstantExpr(Eval, Expr::EvaluateForCodeGen,
+   SemaRef.getASTContext(), true);
+  if (!Result || !Notes.empty()) {
 Expr *InnerExpr = CE->getSubExpr()->IgnoreImplicit();
 FunctionDecl *FD = nullptr;
 if (auto *Call = dyn_cast(InnerExpr))

diff  --git a/clang/test/SemaCXX/cxx2a-consteval.cpp 
b/clang/test/SemaCXX/cxx2a-consteval.cpp
index db6bca03fcc3..6d51b895cbd2 100644
--- a/clang/test/SemaCXX/cxx2a-consteval.cpp
+++ b/clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -309,6 +309,14 @@ void test() {
 
 namespace alloc {
 
+consteval int f() {
+  int *A = new int(0);
+// expected-note@-1+ {{allocation performed here was not deallocated}}
+  return *A;
+}
+
+int i1 = f(); // expected-error {{is not a constant expression}}
+
 struct A {
   int* p = new int(42);
   // expected-note@-1+ {{heap allocation performed here}}



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


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Unsure if my reply was sent over email so copying it here.

Yup, adding `// REQUIRES: platform-linker` to both `*-extra.c` files seems to 
fix it. Thanks. Will you be sending out the fix?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74704



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


Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Leonard Chan via cfe-commits
Yup, I added it to both *-extra.c files and it seemed to fix the tests.

On Wed, Feb 26, 2020 at 11:37 AM Serge Guelton  wrote:

> Does adding
>
> // REQUIRES: platform-linker
>
> to Driver/riscv32-toolchain-extra.c fixes your issue?
>
>
> On Wed, Feb 26, 2020 at 06:25:39PM +, Leonard Chan via Phabricator
> wrote:
> > leonardchan added a comment.
> >
> > Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 <
> https://reviews.llvm.org/rGe058667a2e017d3225a9bb067dbac7f2159576f7>
> might've broken our toolchain again:
> >
> >   FAIL: Clang :: Driver/riscv32-toolchain-extra.c (5723 of 17018)
> >    TEST 'Clang :: Driver/riscv32-toolchain-extra.c'
> FAILED 
> >   Script:
> >   --
> >   : 'RUN: at line 14';   mkdir -p
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin
> >   : 'RUN: at line 15';   [ ! -s
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
> ] || rm
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
> >   : 'RUN: at line 16';   [ ! -s
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
> ] || rm
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
> >   : 'RUN: at line 17';   [ ! -s
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
> ] || rm
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
> >   : 'RUN: at line 18';   ln -s
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/clang
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
> >   : 'RUN: at line 19';   ln -s
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
> >   : 'RUN: at line 20';   ln -s
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
> >   : 'RUN: at line 21';
>  
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
> -### -no-canonical-prefixes
>  
> --gcc-toolchain=/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/invalid
>-target riscv32-unknown-elf --rtlib=platform 2>&1 |
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/FileCheck
> -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
> >   --
> >   Exit Code: 1
> >
> >   Command Output (stderr):
> >   --
> >
>  
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c:27:34:
> error: C-RV32-BAREMETAL-ILP32-NOGCC: expected string not found in input
> >   // C-RV32-BAREMETAL-ILP32-NOGCC:
> "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
> >^
> >   :5:1070: note: scanning from here
> >
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang"
> "-cc1" "-triple" "riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all"
> "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier"
> "-discard-value-names" "-main-file-name" "riscv32-toolchain-extra.c"
> "-mrelocation-model" "static" "-mthread-model" "posix"
> "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-masm-verbose"
> "-mconstructor-aliases" "-nostdsysteminc" "-target-feature" "+m"
> "-target-feature" "+a" "-target-feature" "+c" "-target-feature" "+relax"
> "-target-feature" "-save-restore" "-target-abi" "ilp32"
> "-dwarf-column-info" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb"
> "-resource-dir"
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/lib/clang/11.0.0"
> "-internal-isystem"
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
> "-fdebug-compilation-dir"
> 

Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Leonard Chan via cfe-commits
Will you be sending out the patch for this?

On Wed, Feb 26, 2020 at 12:05 PM Leonard Chan 
wrote:

> Yup, I added it to both *-extra.c files and it seemed to fix the tests.
>
> On Wed, Feb 26, 2020 at 11:37 AM Serge Guelton 
> wrote:
>
>> Does adding
>>
>> // REQUIRES: platform-linker
>>
>> to Driver/riscv32-toolchain-extra.c fixes your issue?
>>
>>
>> On Wed, Feb 26, 2020 at 06:25:39PM +, Leonard Chan via Phabricator
>> wrote:
>> > leonardchan added a comment.
>> >
>> > Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 <
>> https://reviews.llvm.org/rGe058667a2e017d3225a9bb067dbac7f2159576f7>
>> might've broken our toolchain again:
>> >
>> >   FAIL: Clang :: Driver/riscv32-toolchain-extra.c (5723 of 17018)
>> >    TEST 'Clang :: Driver/riscv32-toolchain-extra.c'
>> FAILED 
>> >   Script:
>> >   --
>> >   : 'RUN: at line 14';   mkdir -p
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin
>> >   : 'RUN: at line 15';   [ ! -s
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>> ] || rm
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>> >   : 'RUN: at line 16';   [ ! -s
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>> ] || rm
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>> >   : 'RUN: at line 17';   [ ! -s
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>> ] || rm
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>> >   : 'RUN: at line 18';   ln -s
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/clang
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>> >   : 'RUN: at line 19';   ln -s
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>> >   : 'RUN: at line 20';   ln -s
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>> >   : 'RUN: at line 21';
>>  
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
>> -### -no-canonical-prefixes
>>  
>> --gcc-toolchain=/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/invalid
>>-target riscv32-unknown-elf --rtlib=platform 2>&1 |
>> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/FileCheck
>> -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
>> >   --
>> >   Exit Code: 1
>> >
>> >   Command Output (stderr):
>> >   --
>> >
>>  
>> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c:27:34:
>> error: C-RV32-BAREMETAL-ILP32-NOGCC: expected string not found in input
>> >   // C-RV32-BAREMETAL-ILP32-NOGCC:
>> "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
>> >^
>> >   :5:1070: note: scanning from here
>> >
>> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang"
>> "-cc1" "-triple" "riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all"
>> "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier"
>> "-discard-value-names" "-main-file-name" "riscv32-toolchain-extra.c"
>> "-mrelocation-model" "static" "-mthread-model" "posix"
>> "-mframe-pointer=all" "-fmath-errno" "-fno-rounding-math" "-masm-verbose"
>> "-mconstructor-aliases" "-nostdsysteminc" "-target-feature" "+m"
>> "-target-feature" "+a" "-target-feature" "+c" "-target-feature" "+relax"
>> "-target-feature" "-save-restore" "-target-abi" "ilp32"
>> "-dwarf-column-info" "-fno-split-dwarf-inlining" "-debugger-tuning=gdb"
>> "-resource-dir"
>> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/lib/clang/11.0.0"
>> "-internal-isystem"
>> 

[PATCH] D75077: [OpenMP5.0] Allow pointer arithmetic in motion/map clause

2020-02-26 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked 2 inline comments as done.
cchen added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9965
   "memory order clause '%0' is specified here">;
+def err_omp_non_lvalue_in_map_or_motion_clauses: Error<
+  "expected lvalue with no function call in '#pragma omp target update' and 
'#pragma omp target map'"

ABataev wrote:
> ABataev wrote:
> > I would say that this lvalue must be addressable, no? Also, some function 
> > calls can be handled, probably, those returning rvalues, for example, or 
> > constexprs.
> Fix this message, please, it is not quite correct.
Will fix this, thanks.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7616-7633
+  const auto *UO = dyn_cast(I->getAssociatedExpression());
+  const auto *BO = dyn_cast(I->getAssociatedExpression());
   bool IsPointer =
   (OASE && OMPArraySectionExpr::getBaseOriginalType(OASE)
.getCanonicalType()
->isAnyPointerType()) ||
   I->getAssociatedExpression()->getType()->isAnyPointerType();

ABataev wrote:
> Do you have the tests for these changes?
I think target_update_codegen.cpp has already tested those.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75077



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


Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Serge Guelton via cfe-commits
Does adding

// REQUIRES: platform-linker

to Driver/riscv32-toolchain-extra.c fixes your issue?


On Wed, Feb 26, 2020 at 06:25:39PM +, Leonard Chan via Phabricator wrote:
> leonardchan added a comment.
> 
> Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 
>  
> might've broken our toolchain again:
> 
>   FAIL: Clang :: Driver/riscv32-toolchain-extra.c (5723 of 17018)
>    TEST 'Clang :: Driver/riscv32-toolchain-extra.c' 
> FAILED 
>   Script:
>   --
>   : 'RUN: at line 14';   mkdir -p 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin
>   : 'RUN: at line 15';   [ ! -s 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>  ] || rm 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>   : 'RUN: at line 16';   [ ! -s 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>  ] || rm 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>   : 'RUN: at line 17';   [ ! -s 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>  ] || rm 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>   : 'RUN: at line 18';   ln -s 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/clang 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>   : 'RUN: at line 19';   ln -s 
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
>  
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
>   : 'RUN: at line 20';   ln -s 
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf
>  
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
>   : 'RUN: at line 21';   
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
>  /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c 
> -### -no-canonical-prefixes 
> --gcc-toolchain=/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/invalid
>  -target riscv32-unknown-elf --rtlib=platform 2>&1 | 
> /b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/FileCheck 
> -check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC 
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
>   --
>   Exit Code: 1
>   
>   Command Output (stderr):
>   --
>   
> /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c:27:34:
>  error: C-RV32-BAREMETAL-ILP32-NOGCC: expected string not found in input
>   // C-RV32-BAREMETAL-ILP32-NOGCC: 
> "{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
>^
>   :5:1070: note: scanning from here
>
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang"
>  "-cc1" "-triple" "riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all" 
> "--mrelax-relocations" "-disable-free" "-disable-llvm-verifier" 
> "-discard-value-names" "-main-file-name" "riscv32-toolchain-extra.c" 
> "-mrelocation-model" "static" "-mthread-model" "posix" "-mframe-pointer=all" 
> "-fmath-errno" "-fno-rounding-math" "-masm-verbose" "-mconstructor-aliases" 
> "-nostdsysteminc" "-target-feature" "+m" "-target-feature" "+a" 
> "-target-feature" "+c" "-target-feature" "+relax" "-target-feature" 
> "-save-restore" "-target-abi" "ilp32" "-dwarf-column-info" 
> "-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" 
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/lib/clang/11.0.0"
>  "-internal-isystem" 
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
>  "-fdebug-compilation-dir" 
> "/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver"
>  "-ferror-limit" "19" "-fmessage-length" "0" "-fno-signed-char" 
> "-fgnuc-version=4.2.1" 

Re: [PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Serge Guelton via cfe-commits
On Wed, Feb 26, 2020 at 06:25:39PM +, Leonard Chan via Phabricator wrote:
> leonardchan added a comment.
> 
> Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 
>  
> might've broken our toolchain again:

s***t. Can you share you cmake configure flags?
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D70172#1894036 , @yaxunl wrote:

> I tried recording functions to be emitted during normal parsing and using it 
> as starting point for the final traversal. It is quite promising. I only get 
> one lit test failure for OpenMP:
>
>   int foobar2();
>  
>   #pragma omp declare target
>   int (*B)() = 
>   #pragma omp end declare target
>  
>   int foobar2() { throw 1; } // expected-error {{cannot use 'throw' with 
> exceptions disabled}}
>  
>
>
> In this case, the emission state of foobar2 cannot be determined by itself. 
> It can only be determined to be emitted through variable B. Therefore, I also 
> need to record variables that are potentially emitted.


Okay.  Sounds like you have some common cause with 
https://reviews.llvm.org/D71227, then.  Pinging @hliao.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

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

LGTM to me too.  With @steven_wu and me on board, I don't think you need to 
wait for @arphaman.  Thanks for the fix!


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

https://reviews.llvm.org/D74784



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


[PATCH] D75202: [ASTMatchers] HasNameMatcher handles `extern "C"`

2020-02-26 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: klimek, aaron.ballman, gribozavr2.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes hasName AST matcher is confused by extern "C" in namespace. 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75202

Files:
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1643,6 +1643,15 @@
   EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m";
 }
 
+TEST(Matcher, HasNameQualifiedSupportsLinkage) {
+  // https://bugs.llvm.org/show_bug.cgi?id=42193
+  std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+}
+
 TEST(Matcher, HasAnyName) {
   const std::string Code = "namespace a { namespace b { class C; } }";
 
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -513,7 +513,13 @@
   if (Ctx->isFunctionOrMethod())
 return Patterns.foundMatch(/*AllowFullyQualified=*/false);
 
-  for (; Ctx && isa(Ctx); Ctx = Ctx->getParent()) {
+  for (; Ctx; Ctx = Ctx->getParent()) {
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))
+  continue;
+if (!isa(Ctx))
+  break;
 if (Patterns.foundMatch(/*AllowFullyQualified=*/false))
   return true;
 


Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1643,6 +1643,15 @@
   EXPECT_TRUE(matches(code, fieldDecl(hasName("::a::F(int)::S::m";
 }
 
+TEST(Matcher, HasNameQualifiedSupportsLinkage) {
+  // https://bugs.llvm.org/show_bug.cgi?id=42193
+  std::string code = R"cpp(namespace foo { extern "C" void test(); })cpp";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("foo::test";
+  EXPECT_TRUE(matches(code, functionDecl(hasName("::foo::test";
+  EXPECT_TRUE(notMatches(code, functionDecl(hasName("::test";
+}
+
 TEST(Matcher, HasAnyName) {
   const std::string Code = "namespace a { namespace b { class C; } }";
 
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -513,7 +513,13 @@
   if (Ctx->isFunctionOrMethod())
 return Patterns.foundMatch(/*AllowFullyQualified=*/false);
 
-  for (; Ctx && isa(Ctx); Ctx = Ctx->getParent()) {
+  for (; Ctx; Ctx = Ctx->getParent()) {
+// Linkage Spec can just be ignored
+// FIXME: Any other DeclContext kinds that can be safely disregarded
+if (isa(Ctx))
+  continue;
+if (!isa(Ctx))
+  break;
 if (Patterns.foundMatch(/*AllowFullyQualified=*/false))
   return true;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-02-26 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

Sent fix for review in D75201 .

If the new problem showed up later and not when this one first went in, then it 
seems likely it is different than this issue.  I'll see if I can reproduce and 
take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D75176: [clangd] Get rid of getBeginningOfIdentifier helper

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

Did you want to delete the lexer check in getDeducedType or is that another 
patch?




Comment at: clang-tools-extra/clangd/Hover.cpp:533
+  }
+  auto TokensAroundCursor =
+  syntax::spelledTokensTouching(*CurLoc, AST.getTokens());

again, I'd stick with "touching" to match syntax::tokens



Comment at: clang-tools-extra/clangd/Hover.cpp:542
+  // identifier-or-keyword token is equivalent.
+  SourceLocation SLocID;
+  SourceLocation SLocAutoKW;

nit: we don't tend to use SLoc to refer to SourceLocations outside 
SourceManager, or ID to refer to identifiers.
IdentLoc, AutoLoc?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75176



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


[PATCH] D75198: [ms] Rename ParsingInlineAsm functions/variables to reflect MS-specificity.

2020-02-26 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk 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/D75198/new/

https://reviews.llvm.org/D75198



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


[PATCH] D75198: [ms] Rename ParsingInlineAsm functions/variables to reflect MS-specificity.

2020-02-26 Thread Eric Astor via Phabricator via cfe-commits
epastor created this revision.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
epastor added a child revision: D73227: [ms] [llvm-ml] Use default RIP-relative 
addressing for x64 MASM..

ParsingInlineAsm was a misleading name. These values are only set for MS-style 
inline assembly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75198

Files:
  clang/lib/Parse/ParseStmtAsm.cpp
  llvm/include/llvm/MC/MCParser/MCAsmParser.h
  llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
  llvm/lib/MC/MCParser/AsmParser.cpp
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp

Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -611,9 +611,9 @@
 }
 bool onIdentifierExpr(const MCExpr *SymRef, StringRef SymRefName,
   const InlineAsmIdentifierInfo ,
-  bool ParsingInlineAsm, StringRef ) {
+  bool ParsingMSInlineAsm, StringRef ) {
   // InlineAsm: Treat an enum value as an integer
-  if (ParsingInlineAsm)
+  if (ParsingMSInlineAsm)
 if (IDInfo.isKind(InlineAsmIdentifierInfo::IK_EnumVal))
   return onInteger(IDInfo.Enum.EnumVal, ErrMsg);
   // Treat a symbolic constant like an integer
@@ -634,7 +634,7 @@
 MemExpr = true;
 State = IES_INTEGER;
 IC.pushOperand(IC_IMM);
-if (ParsingInlineAsm)
+if (ParsingMSInlineAsm)
   Info = IDInfo;
 break;
   }
@@ -815,7 +815,7 @@
   }
 }
 bool onOffset(const MCExpr *Val, SMLoc OffsetLoc, StringRef ID,
-  const InlineAsmIdentifierInfo , bool ParsingInlineAsm,
+  const InlineAsmIdentifierInfo , bool ParsingMSInlineAsm,
   StringRef ) {
   PrevState = State;
   switch (State) {
@@ -833,7 +833,7 @@
 // As we cannot yet resolve the actual value (offset), we retain
 // the requested semantics by pushing a '0' to the operands stack
 IC.pushOperand(IC_IMM);
-if (ParsingInlineAsm) {
+if (ParsingMSInlineAsm) {
   Info = IDInfo;
 }
 break;
@@ -899,10 +899,10 @@
 
   bool ParseIntelMemoryOperandSize(unsigned );
   std::unique_ptr
-  CreateMemForInlineAsm(unsigned SegReg, const MCExpr *Disp, unsigned BaseReg,
-unsigned IndexReg, unsigned Scale, SMLoc Start,
-SMLoc End, unsigned Size, StringRef Identifier,
-const InlineAsmIdentifierInfo );
+  CreateMemForMSInlineAsm(unsigned SegReg, const MCExpr *Disp, unsigned BaseReg,
+  unsigned IndexReg, unsigned Scale, SMLoc Start,
+  SMLoc End, unsigned Size, StringRef Identifier,
+  const InlineAsmIdentifierInfo );
 
   bool parseDirectiveEven(SMLoc L);
   bool ParseDirectiveCode(StringRef IDVal, SMLoc L);
@@ -1177,7 +1177,7 @@
 
   // The "flags" and "mxcsr" registers cannot be referenced directly.
   // Treat it as an identifier instead.
-  if (isParsingInlineAsm() && isParsingIntelSyntax() &&
+  if (isParsingMSInlineAsm() && isParsingIntelSyntax() &&
   (RegNo == X86::EFLAGS || RegNo == X86::MXCSR))
 RegNo = 0;
 
@@ -1458,7 +1458,7 @@
   return ParseATTOperand();
 }
 
-std::unique_ptr X86AsmParser::CreateMemForInlineAsm(
+std::unique_ptr X86AsmParser::CreateMemForMSInlineAsm(
 unsigned SegReg, const MCExpr *Disp, unsigned BaseReg, unsigned IndexReg,
 unsigned Scale, SMLoc Start, SMLoc End, unsigned Size, StringRef Identifier,
 const InlineAsmIdentifierInfo ) {
@@ -1536,7 +1536,7 @@
   return true;
 StringRef ErrMsg;
 ParseError =
-SM.onOffset(Val, OffsetLoc, ID, Info, isParsingInlineAsm(), ErrMsg);
+SM.onOffset(Val, OffsetLoc, ID, Info, isParsingMSInlineAsm(), ErrMsg);
 if (ParseError)
   return Error(SMLoc::getFromPointer(Name.data()), ErrMsg);
   } else {
@@ -1595,7 +1595,7 @@
   // Symbol reference, when parsing assembly content
   InlineAsmIdentifierInfo Info;
   const MCExpr *Val;
-  if (!isParsingInlineAsm()) {
+  if (!isParsingMSInlineAsm()) {
 if (getParser().parsePrimaryExpr(Val, End)) {
   return Error(Tok.getLoc(), "Unexpected identifier!");
 } else if (SM.onIdentifierExpr(Val, Identifier, Info, false, ErrMsg)) {
@@ -1646,8 +1646,8 @@
 return Error(Loc, "invalid reference to undefined symbol");
   StringRef Identifier = Sym->getName();
   InlineAsmIdentifierInfo Info;
-  if (SM.onIdentifierExpr(Val, Identifier, Info,
-  isParsingInlineAsm(), ErrMsg))
+  if (SM.onIdentifierExpr(Val, Identifier, Info, isParsingMSInlineAsm(),
+  ErrMsg))
 

Re: r329762 - Introduce a new builtin, __builtin_dump_struct, that is useful for dumping structure contents at runtime in circumstances where debuggers may not be easily available (such as in kernel w

2020-02-26 Thread Aaron Ballman via cfe-commits
On Tue, Feb 25, 2020 at 4:36 PM Richard Smith  wrote:
>
> It looks like we forgot to document this builtin. Can some documentation be 
> added?

If Paul doesn't get to it first, I can try to stub some out.

~Aaron

>
> On Tue, 10 Apr 2018 at 15:01, Aaron Ballman via cfe-commits 
>  wrote:
>>
>> Author: aaronballman
>> Date: Tue Apr 10 14:58:13 2018
>> New Revision: 329762
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=329762=rev
>> Log:
>> Introduce a new builtin, __builtin_dump_struct, that is useful for dumping 
>> structure contents at runtime in circumstances where debuggers may not be 
>> easily available (such as in kernel work).
>>
>> Patch by Paul Semel.
>>
>> Added:
>> cfe/trunk/test/CodeGen/dump-struct-builtin.c
>> cfe/trunk/test/Sema/builtin-dump-struct.c
>> Modified:
>> cfe/trunk/include/clang/Basic/Builtins.def
>> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> cfe/trunk/lib/Sema/SemaChecking.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/Builtins.def
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=329762=329761=329762=diff
>> ==
>> --- cfe/trunk/include/clang/Basic/Builtins.def (original)
>> +++ cfe/trunk/include/clang/Basic/Builtins.def Tue Apr 10 14:58:13 2018
>> @@ -1374,6 +1374,7 @@ BUILTIN(__builtin_addressof, "v*v&", "nc
>>  BUILTIN(__builtin_operator_new, "v*z", "tc")
>>  BUILTIN(__builtin_operator_delete, "vv*", "tn")
>>  BUILTIN(__builtin_char_memchr, "c*cC*iz", "n")
>> +BUILTIN(__builtin_dump_struct, "ivC*v*", "tn")
>>
>>  // Safestack builtins
>>  BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")
>>
>> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=329762=329761=329762=diff
>> ==
>> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Apr 10 14:58:13 2018
>> @@ -14,6 +14,7 @@
>>  #include "CGCXXABI.h"
>>  #include "CGObjCRuntime.h"
>>  #include "CGOpenCLRuntime.h"
>> +#include "CGRecordLayout.h"
>>  #include "CodeGenFunction.h"
>>  #include "CodeGenModule.h"
>>  #include "ConstantEmitter.h"
>> @@ -930,6 +931,93 @@ EmitCheckedMixedSignMultiply(CodeGenFunc
>>return RValue::get(Overflow);
>>  }
>>
>> +static llvm::Value *dumpRecord(CodeGenFunction , QualType RType,
>> +   Value *, CharUnits Align, Value 
>> *Func,
>> +   int Lvl) {
>> +  const auto *RT = RType->getAs();
>> +  ASTContext  = CGF.getContext();
>> +  RecordDecl *RD = RT->getDecl()->getDefinition();
>> +  ASTContext  = RD->getASTContext();
>> +  const ASTRecordLayout  = Ctx.getASTRecordLayout(RD);
>> +  std::string Pad = std::string(Lvl * 4, ' ');
>> +
>> +  Value *GString =
>> +  CGF.Builder.CreateGlobalStringPtr(RType.getAsString() + " {\n");
>> +  Value *Res = CGF.Builder.CreateCall(Func, {GString});
>> +
>> +  static llvm::DenseMap Types;
>> +  if (Types.empty()) {
>> +Types[Context.CharTy] = "%c";
>> +Types[Context.BoolTy] = "%d";
>> +Types[Context.IntTy] = "%d";
>> +Types[Context.UnsignedIntTy] = "%u";
>> +Types[Context.LongTy] = "%ld";
>> +Types[Context.UnsignedLongTy] = "%lu";
>> +Types[Context.LongLongTy] = "%lld";
>> +Types[Context.UnsignedLongLongTy] = "%llu";
>> +Types[Context.ShortTy] = "%hd";
>> +Types[Context.UnsignedShortTy] = "%hu";
>> +Types[Context.VoidPtrTy] = "%p";
>> +Types[Context.FloatTy] = "%f";
>> +Types[Context.DoubleTy] = "%f";
>> +Types[Context.LongDoubleTy] = "%Lf";
>> +Types[Context.getPointerType(Context.CharTy)] = "%s";
>> +  }
>> +
>> +  for (const auto *FD : RD->fields()) {
>> +uint64_t Off = RL.getFieldOffset(FD->getFieldIndex());
>> +Off = Ctx.toCharUnitsFromBits(Off).getQuantity();
>> +
>> +Value *FieldPtr = RecordPtr;
>> +if (RD->isUnion())
>> +  FieldPtr = CGF.Builder.CreatePointerCast(
>> +  FieldPtr, CGF.ConvertType(Context.getPointerType(FD->getType(;
>> +else
>> +  FieldPtr = CGF.Builder.CreateStructGEP(CGF.ConvertType(RType), 
>> FieldPtr,
>> + FD->getFieldIndex());
>> +
>> +GString = CGF.Builder.CreateGlobalStringPtr(
>> +llvm::Twine(Pad)
>> +.concat(FD->getType().getAsString())
>> +.concat(llvm::Twine(' '))
>> +.concat(FD->getNameAsString())
>> +.concat(" : ")
>> +.str());
>> +Value *TmpRes = CGF.Builder.CreateCall(Func, {GString});
>> +Res = CGF.Builder.CreateAdd(Res, TmpRes);
>> +
>> +QualType CanonicalType =
>> +FD->getType().getUnqualifiedType().getCanonicalType();
>> +
>> +// We check whether we are in a recursive type
>> +if (CanonicalType->isRecordType()) {
>> +  Value *TmpRes =
>> +  dumpRecord(CGF, 

Re: [clang] 83f4372 - [CodeGen] fix clang test that runs the optimizer pipeline; NFC

2020-02-26 Thread Sanjay Patel via cfe-commits
To be clear - the test is checking IR instructions, but it's checking -O1
IR for various targets.
So there must be different expectations per target...
But I just tried a test of turning everything down to -O0, and it all
passed except for the "fast-math" run for AArch64.
I can tweak that to not be so specific if that sounds like a reasonable
solution.

On Wed, Feb 26, 2020 at 1:05 PM Eric Christopher  wrote:

> I mean anything that's testing assembly output out of clang is less than
> ideal. There are some circumstances, but this doesn't seem like one of
> them.
>
> On Wed, Feb 26, 2020, 9:10 AM Sanjay Patel  wrote:
>
>> The test file dates back to:
>> https://reviews.llvm.org/D5698
>> ...and I'm not familiar with _Complex enough to say how to fix this
>> properly (seems like the check lines are already limited such that -O0
>> rather than -O1 would work?).
>>
>> But this file keeps wiggling unexpectedly, it's going to move again with
>> https://reviews.llvm.org/D75130
>>
>> On Tue, Feb 25, 2020 at 1:15 PM Eric Christopher 
>> wrote:
>>
>>> Is there any way to pull this test out of clang and as an opt test?
>>> What's it trying to test?
>>>
>>> -eric
>>>
>>> On Tue, Feb 25, 2020 at 6:15 AM Sanjay Patel via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>

 Author: Sanjay Patel
 Date: 2020-02-25T09:13:49-05:00
 New Revision: 83f4372f3a708ceaa800feff8b1bd92ae2c3be5f

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

 LOG: [CodeGen] fix clang test that runs the optimizer pipeline; NFC

 There's already a FIXME note on this file; it can break when the
 underlying LLVM behavior changes independently of anything in clang.

 Added:


 Modified:
 clang/test/CodeGen/complex-math.c

 Removed:




 
 diff  --git a/clang/test/CodeGen/complex-math.c
 b/clang/test/CodeGen/complex-math.c
 index e42418ad72c2..54dee473a364 100644
 --- a/clang/test/CodeGen/complex-math.c
 +++ b/clang/test/CodeGen/complex-math.c
 @@ -93,14 +93,15 @@ float _Complex mul_float_rc(float a, float _Complex
 b) {
// X86: ret
return a * b;
  }
 +
  float _Complex mul_float_cc(float _Complex a, float _Complex b) {
// X86-LABEL: @mul_float_cc(
// X86: %[[AC:[^ ]+]] = fmul
// X86: %[[BD:[^ ]+]] = fmul
// X86: %[[AD:[^ ]+]] = fmul
// X86: %[[BC:[^ ]+]] = fmul
 -  // X86: %[[RR:[^ ]+]] = fsub float %[[AC]], %[[BD]]
 -  // X86: %[[RI:[^ ]+]] = fadd float
 +  // X86: %[[RR:[^ ]+]] = fsub
 +  // X86: %[[RI:[^ ]+]] = fadd
// X86-DAG: %[[AD]]
// X86-DAG: ,
// X86-DAG: %[[BC]]



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

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


[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2020-02-26 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I tried recording functions to be emitted during normal parsing and using it as 
starting point for the final traversal. It is quite promising. I only get one 
lit test failure for OpenMP:

  int foobar2();
  
  #pragma omp declare target
  int (*B)() = 
  #pragma omp end declare target
  
  int foobar2() { throw 1; } // expected-error {{cannot use 'throw' with 
exceptions disabled}}

In this case, the emission state of foobar2 cannot be determined by itself. It 
can only be determined to be emitted through variable B. Therefore, I also need 
to record variables that are potentially emitted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70172



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


[PATCH] D74704: Support -fuse-ld=lld for riscv

2020-02-26 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi again, I think e058667a2e017d3225a9bb067dbac7f2159576f7 
 might've 
broken our toolchain again:

  FAIL: Clang :: Driver/riscv32-toolchain-extra.c (5723 of 17018)
   TEST 'Clang :: Driver/riscv32-toolchain-extra.c' FAILED 

  Script:
  --
  : 'RUN: at line 14';   mkdir -p 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin
  : 'RUN: at line 15';   [ ! -s 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
 ] || rm 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
  : 'RUN: at line 16';   [ ! -s 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
 ] || rm 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
  : 'RUN: at line 17';   [ ! -s 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
 ] || rm 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
  : 'RUN: at line 18';   ln -s 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/clang 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
  : 'RUN: at line 19';   ln -s 
/b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/bin/riscv32-unknown-elf-ld
 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld
  : 'RUN: at line 20';   ln -s 
/b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/Inputs/basic_riscv32_nogcc_tree/riscv32-unknown-elf
 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/riscv32-unknown-elf
  : 'RUN: at line 21';   
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang
 /b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c 
-### -no-canonical-prefixes 
--gcc-toolchain=/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/invalid
 -target riscv32-unknown-elf --rtlib=platform 2>&1 | 
/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/bin/FileCheck 
-check-prefix=C-RV32-BAREMETAL-ILP32-NOGCC 
/b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c:27:34:
 error: C-RV32-BAREMETAL-ILP32-NOGCC: expected string not found in input
  // C-RV32-BAREMETAL-ILP32-NOGCC: 
"{{.*}}Output/testroot-riscv32-baremetal-nogcc/bin/riscv32-unknown-elf-ld"
   ^
  :5:1070: note: scanning from here
   
"/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/clang"
 "-cc1" "-triple" "riscv32-unknown-unknown-elf" "-emit-obj" "-mrelax-all" 
"--mrelax-relocations" "-disable-free" "-disable-llvm-verifier" 
"-discard-value-names" "-main-file-name" "riscv32-toolchain-extra.c" 
"-mrelocation-model" "static" "-mthread-model" "posix" "-mframe-pointer=all" 
"-fmath-errno" "-fno-rounding-math" "-masm-verbose" "-mconstructor-aliases" 
"-nostdsysteminc" "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+c" "-target-feature" "+relax" "-target-feature" 
"-save-restore" "-target-abi" "ilp32" "-dwarf-column-info" 
"-fno-split-dwarf-inlining" "-debugger-tuning=gdb" "-resource-dir" 
"/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/lib/clang/11.0.0"
 "-internal-isystem" 
"/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver/Output/testroot-riscv32-baremetal-nogcc/bin/../riscv32-unknown-elf/include"
 "-fdebug-compilation-dir" 
"/b/fuchsia-x86_64-linux/llvm.obj/tools/clang/stage2-bins/tools/clang/test/Driver"
 "-ferror-limit" "19" "-fmessage-length" "0" "-fno-signed-char" 
"-fgnuc-version=4.2.1" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" 
"-faddrsig" "-o" "/tmp/riscv32-toolchain-extra-b2b7d0.o" "-x" "c" 
"/b/fuchsia-x86_64-linux/llvm.src/clang/test/Driver/riscv32-toolchain-extra.c"


[PATCH] D75056: [Driver] Default to -fno-common

2020-02-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/clang_f_opts.c:15
 // CHECK-OPTIONS2: -fshort-enums
-// CHECK-OPTIONS2: -fno-common
+// CHECK-OPTIONS2-NOT: -fcommon
 // CHECK-OPTIONS2: -fno-show-source-location

I think such NOT patterns should just be deleted.

(Note that `NOT` patterns tend to be insufficient due to order reasons)

`-fcommon` is a minority now. We only need to test it for an OS/Arch that 
really needs it (currently no).


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

https://reviews.llvm.org/D75056



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


[PATCH] D75077: [OpenMP5.0] Allow pointer arithmetic in motion/map clause

2020-02-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9965
   "memory order clause '%0' is specified here">;
+def err_omp_non_lvalue_in_map_or_motion_clauses: Error<
+  "expected lvalue with no function call in '#pragma omp target update' and 
'#pragma omp target map'"

ABataev wrote:
> I would say that this lvalue must be addressable, no? Also, some function 
> calls can be handled, probably, those returning rvalues, for example, or 
> constexprs.
Fix this message, please, it is not quite correct.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7616-7633
+  const auto *UO = dyn_cast(I->getAssociatedExpression());
+  const auto *BO = dyn_cast(I->getAssociatedExpression());
   bool IsPointer =
   (OASE && OMPArraySectionExpr::getBaseOriginalType(OASE)
.getCanonicalType()
->isAnyPointerType()) ||
   I->getAssociatedExpression()->getType()->isAnyPointerType();

Do you have the tests for these changes?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7751
+ "Unexpected FunctionDecl");
   const auto *FD = dyn_cast(EncounteredME->getMemberDecl());
   unsigned FieldIndex = FD->getFieldIndex();

Change this line to just `cast`. In this case the assert is not 
required.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15695-15696
+}
+Expr *SubE = UO->getSubExpr()->IgnoreParenImpCasts();
+return RelevantExpr || Visit(SubE);
+  }

I think, here we should have `return RelevantExpr || Visit(UO->getSubExpr())` 
without dropping parens and implicit casts. Again, we may drop some important 
implicit casts



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15703-15706
+// Pointer arithmetic is the only thing we expect to happen
+// here so we only need to visit the subtree that has the
+// same type as root (so that we know the other subtree
+// is just an offset)

Add a check here that the type of the expression must be a pointer type.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15715-15717
+} else {
+  return Visit(RE);
+}

Just `return Visit(RE);` without `else`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15718
+}
+return false;
+  }

Unreachable code



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15683
   }
+  bool VisitUnaryOperator(UnaryOperator *UO) {
+if (SemaRef.getLangOpts().OpenMP < 50) {

cchen wrote:
> ABataev wrote:
> > cchen wrote:
> > > ABataev wrote:
> > > > I think you need to extend this to support paren expressions, at least.
> > > I have `UO->getSubExpr()->IgnoreParenImpCasts()` here, or I might not 
> > > understand what you mean by "support paren expression".
> > `(*(..))` is not supported, I think. Or, maybe, `*((a)+b)`
> Both cases are handled correctly. For `(*((b)+a))`, the binop in 
> `VisitBinaryOperator()`does not include the outer paren and for `*((a)+b)`, 
> the parens can be handled by `Expr *SubE = 
> UO->getSubExpr()->IgnoreParenImpCasts();`.
I think we need to change the way we check the expression in call for 
`MapBaseChecker::Visit` in `checkMapClauseExpressionBase` or extend the check 
in the `checkMapClauseExpressionBase`. `E->IgnoreParenImpCasts()` may drop 
implicit lvalue-to-rvalue cast and we may allow mapping of rvalues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75077



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


[PATCH] D75125: [Docs][OpenCL] Release 10.0 notes for OpenCL

2020-02-26 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D75125



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


[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-26 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Thanks. LGTM. I will let @arphaman to approve this.


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

https://reviews.llvm.org/D74784



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


Re: [clang] 83f4372 - [CodeGen] fix clang test that runs the optimizer pipeline; NFC

2020-02-26 Thread Eric Christopher via cfe-commits
I mean anything that's testing assembly output out of clang is less than
ideal. There are some circumstances, but this doesn't seem like one of
them.

On Wed, Feb 26, 2020, 9:10 AM Sanjay Patel  wrote:

> The test file dates back to:
> https://reviews.llvm.org/D5698
> ...and I'm not familiar with _Complex enough to say how to fix this
> properly (seems like the check lines are already limited such that -O0
> rather than -O1 would work?).
>
> But this file keeps wiggling unexpectedly, it's going to move again with
> https://reviews.llvm.org/D75130
>
> On Tue, Feb 25, 2020 at 1:15 PM Eric Christopher 
> wrote:
>
>> Is there any way to pull this test out of clang and as an opt test?
>> What's it trying to test?
>>
>> -eric
>>
>> On Tue, Feb 25, 2020 at 6:15 AM Sanjay Patel via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>>
>>> Author: Sanjay Patel
>>> Date: 2020-02-25T09:13:49-05:00
>>> New Revision: 83f4372f3a708ceaa800feff8b1bd92ae2c3be5f
>>>
>>> URL:
>>> https://github.com/llvm/llvm-project/commit/83f4372f3a708ceaa800feff8b1bd92ae2c3be5f
>>> DIFF:
>>> https://github.com/llvm/llvm-project/commit/83f4372f3a708ceaa800feff8b1bd92ae2c3be5f.diff
>>>
>>> LOG: [CodeGen] fix clang test that runs the optimizer pipeline; NFC
>>>
>>> There's already a FIXME note on this file; it can break when the
>>> underlying LLVM behavior changes independently of anything in clang.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>> clang/test/CodeGen/complex-math.c
>>>
>>> Removed:
>>>
>>>
>>>
>>>
>>> 
>>> diff  --git a/clang/test/CodeGen/complex-math.c
>>> b/clang/test/CodeGen/complex-math.c
>>> index e42418ad72c2..54dee473a364 100644
>>> --- a/clang/test/CodeGen/complex-math.c
>>> +++ b/clang/test/CodeGen/complex-math.c
>>> @@ -93,14 +93,15 @@ float _Complex mul_float_rc(float a, float _Complex
>>> b) {
>>>// X86: ret
>>>return a * b;
>>>  }
>>> +
>>>  float _Complex mul_float_cc(float _Complex a, float _Complex b) {
>>>// X86-LABEL: @mul_float_cc(
>>>// X86: %[[AC:[^ ]+]] = fmul
>>>// X86: %[[BD:[^ ]+]] = fmul
>>>// X86: %[[AD:[^ ]+]] = fmul
>>>// X86: %[[BC:[^ ]+]] = fmul
>>> -  // X86: %[[RR:[^ ]+]] = fsub float %[[AC]], %[[BD]]
>>> -  // X86: %[[RI:[^ ]+]] = fadd float
>>> +  // X86: %[[RR:[^ ]+]] = fsub
>>> +  // X86: %[[RI:[^ ]+]] = fadd
>>>// X86-DAG: %[[AD]]
>>>// X86-DAG: ,
>>>// X86-DAG: %[[BC]]
>>>
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75056: [Driver] Default to -fno-common

2020-02-26 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

I have no objections; however, it may help for the title of the patch to 
clearly indicate "for all targets".


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

https://reviews.llvm.org/D75056



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


[PATCH] D74784: [driver][darwin] Don't use -platform_version flag by default

2020-02-26 Thread dmajor via Phabricator via cfe-commits
dmajor updated this revision to Diff 246771.
dmajor edited the summary of this revision.
dmajor added a comment.

Updated the tests: three cases for {default, old, new} linkers in the 
platform-version tests; left alone the tests not specifically targeting this 
path.


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

https://reviews.llvm.org/D74784

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-ld-platform-version-ios.c
  clang/test/Driver/darwin-ld-platform-version-macos.c
  clang/test/Driver/darwin-ld-platform-version-tvos.c
  clang/test/Driver/darwin-ld-platform-version-watchos.c


Index: clang/test/Driver/darwin-ld-platform-version-watchos.c
===
--- clang/test/Driver/darwin-ld-platform-version-watchos.c
+++ clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -1,9 +1,14 @@
 // RUN: touch %t.o
 
+// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot 
%S/Inputs/WatchOS6.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot 
%S/Inputs/WatchOS6.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot 
%S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 // RUN: %clang -target x86_64-apple-watchos6-simulator -isysroot 
%S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
-// CHECK: "-platform_version" "watchos" "5.2.0" "6.0.0"
+// LINKER-OLD: "-watchos_version_min" "5.2.0"
+// LINKER-NEW: "-platform_version" "watchos" "5.2.0" "6.0.0"
 // SIMUL: "-platform_version" "watchos-simulator" "6.0.0" "6.0.0"
Index: clang/test/Driver/darwin-ld-platform-version-tvos.c
===
--- clang/test/Driver/darwin-ld-platform-version-tvos.c
+++ clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -1,9 +1,14 @@
 // RUN: touch %t.o
 
+// RUN: %clang -target arm64-apple-tvos12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target arm64-apple-tvos12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-tvos12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 // RUN: %clang -target x86_64-apple-tvos13-simulator -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
 // RUN:   | FileCheck --check-prefix=SIMUL %s
 
-// CHECK: "-platform_version" "tvos" "12.3.0" "13.0"
+// LINKER-OLD: "-tvos_version_min" "12.3.0"
+// LINKER-NEW: "-platform_version" "tvos" "12.3.0" "13.0"
 // SIMUL: "-platform_version" "tvos-simulator" "13.0.0" "13.0"
Index: clang/test/Driver/darwin-ld-platform-version-macos.c
===
--- clang/test/Driver/darwin-ld-platform-version-macos.c
+++ clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -1,11 +1,14 @@
 // RUN: touch %t.o
 
 // RUN: %clang -target x86_64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=0 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target x86_64-apple-macos10.13 -isysroot 
%S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: env SDKROOT=%S/Inputs/MacOSX10.14.sdk %clang -target 
x86_64-apple-macos10.13.0.1 -mlinker-version=520 -### %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   | FileCheck --check-prefix=LINKER-NEW %s
 
-// CHECK: "-platform_version" "macos" "10.13.0" "10.14"
+// LINKER-OLD: "-macosx_version_min" "10.13.0"
+// LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"
 
 // RUN: %clang -target x86_64-apple-macos10.13  -mlinker-version=520 -### %t.o 
2>&1 \
 // RUN:   | FileCheck --check-prefix=NOSDK %s
Index: clang/test/Driver/darwin-ld-platform-version-ios.c
===
--- clang/test/Driver/darwin-ld-platform-version-ios.c
+++ clang/test/Driver/darwin-ld-platform-version-ios.c
@@ -1,9 +1,14 @@
 // RUN: touch %t.o
 
+// RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
+// RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
+// RUN:   | FileCheck --check-prefix=LINKER-OLD %s
 // RUN: %clang -target arm64-apple-ios12.3 -isysroot 
%S/Inputs/iPhoneOS13.0.sdk 

[PATCH] D75125: [Docs][OpenCL] Release 10.0 notes for OpenCL

2020-02-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 246774.
Anastasia added a comment.

Addressed comments from Hans and Sven.


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

https://reviews.llvm.org/D75125

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -284,10 +284,33 @@
 // Fix: add an explicit cast to 'id'.
 NSDictionary* d = @{(id)cls : @"Hello"};
 
-OpenCL C Language Changes in Clang
---
+OpenCL Kernel Language Changes in Clang
+---
+
+Generic changes:
+
+- Made ``__private`` to be appear explicitly in diagnostics, AST, etc.
+- Fixed diagnostics of ``enqueue_kernel``.
+
+OpenCL builtin functions:
+
+- The majority of the OpenCL builtin functions are now available through
+  the experimental `TableGen` driven ``-fdeclare-opencl-builtins`` option.
+- Align the ``enqueue_marker`` declaration in standard ``opencl-c.h`` to the 
OpenCL
+  spec.
+- Avoid a void pointer cast in the ``CLK_NULL_EVENT`` definition.
+- Aligned OpenCL with c11 atomic fetch max/min.
+
+Changes in C++ for OpenCL:
+
+- Fixed language mode predefined macros for C++ mode.
+- Allow OpenCL C style compound vector initialization.
+- Improved destructor support.
+- Implemented address space deduction for pointers/references
+  to arrays and auto variables.
+- Added address spaces support for lambdas and ``constexpr``.
+- Fixed misc address spaces usages in classes.
 
-...
 
 ABI Changes in Clang
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -284,10 +284,33 @@
 // Fix: add an explicit cast to 'id'.
 NSDictionary* d = @{(id)cls : @"Hello"};
 
-OpenCL C Language Changes in Clang
---
+OpenCL Kernel Language Changes in Clang
+---
+
+Generic changes:
+
+- Made ``__private`` to be appear explicitly in diagnostics, AST, etc.
+- Fixed diagnostics of ``enqueue_kernel``.
+
+OpenCL builtin functions:
+
+- The majority of the OpenCL builtin functions are now available through
+  the experimental `TableGen` driven ``-fdeclare-opencl-builtins`` option.
+- Align the ``enqueue_marker`` declaration in standard ``opencl-c.h`` to the OpenCL
+  spec.
+- Avoid a void pointer cast in the ``CLK_NULL_EVENT`` definition.
+- Aligned OpenCL with c11 atomic fetch max/min.
+
+Changes in C++ for OpenCL:
+
+- Fixed language mode predefined macros for C++ mode.
+- Allow OpenCL C style compound vector initialization.
+- Improved destructor support.
+- Implemented address space deduction for pointers/references
+  to arrays and auto variables.
+- Added address spaces support for lambdas and ``constexpr``.
+- Fixed misc address spaces usages in classes.
 
-...
 
 ABI Changes in Clang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 59fb9cd - Devirtualize a call on alloca without waiting for post inline cleanup and next

2020-02-26 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-02-26T09:51:24-08:00
New Revision: 59fb9cde7a4a96fe8485a80d9010e4420ffdca82

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

LOG: Devirtualize a call on alloca without waiting for post inline cleanup and 
next
DevirtSCCRepeatedPass iteration.  Needs ReviewPublic

This aims to fix a missed inlining case.

If there's a virtual call in the callee on an alloca (stack allocated object) in
the caller, and the callee is inlined into the caller, the post-inline cleanup
would devirtualize the virtual call, but if the next iteration of
DevirtSCCRepeatedPass doesn't happen (under the new pass manager), which is
based on a heuristic to determine whether to reiterate, we may miss inlining the
devirtualized call.

This enables inlining in 
clang/test/CodeGenCXX/member-function-pointer-calls.cpp.

Added: 
llvm/test/Transforms/Inline/devirtualize-4.ll

Modified: 
clang/test/CodeGenCXX/member-function-pointer-calls.cpp
llvm/lib/Transforms/IPO/Inliner.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp 
b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
index 0e98b12e6e9d..232b1f06df89 100644
--- a/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
+++ b/clang/test/CodeGenCXX/member-function-pointer-calls.cpp
@@ -11,12 +11,8 @@ int f(A* a, int (A::*fp)()) {
 }
 
 // CHECK-LABEL: define i32 @_Z2g1v()
-// CHECK-LEGACY: ret i32 1
-// CHECK-NEWPM: [[A:%.*]] = alloca %struct.A, align 8
-// CHECK-NEWPM: [[TMP:%.*]] = getelementptr inbounds %struct.A, %struct.A* %a, 
i64 0, i32 0
-// CHECK-NEWPM: store i32 (...)** bitcast (i8** getelementptr inbounds ({ [4 x 
i8*] }, { [4 x i8*] }* @_ZTV1A, i64 0, inrange i32 0, i64 2) to i32 (...)**), 
i32 (...)*** [[TMP]], align 8
-// CHECK-NEWPM: [[RET:%.*]] = call i32 @_ZN1A3vf1Ev(%struct.A* nonnull %a) #2
-// CHECK-NEWPM: ret i32 [[RET]]
+// CHECK-NOT: }
+// CHECK: ret i32 1
 // MINGW64-LABEL: define dso_local i32 @_Z2g1v()
 // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})
 int g1() {
@@ -25,6 +21,7 @@ int g1() {
 }
 
 // CHECK-LABEL: define i32 @_Z2g2v()
+// CHECK-NOT: }
 // CHECK: ret i32 2
 // MINGW64-LABEL: define dso_local i32 @_Z2g2v()
 // MINGW64: call i32 @_Z1fP1AMS_FivE(%struct.A* %{{.*}}, { i64, i64 }* %{{.*}})

diff  --git a/llvm/lib/Transforms/IPO/Inliner.cpp 
b/llvm/lib/Transforms/IPO/Inliner.cpp
index 4f9f4bd1cd04..55753d979b2c 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -35,6 +35,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Transforms/Utils/Local.h"
+#include "llvm/Transforms/Utils/CallPromotionUtils.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CallSite.h"
@@ -1100,10 +1101,20 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC 
,
   if (!IFI.InlinedCallSites.empty()) {
 int NewHistoryID = InlineHistory.size();
 InlineHistory.push_back({, InlineHistoryID});
-for (CallSite  : reverse(IFI.InlinedCallSites))
-  if (Function *NewCallee = CS.getCalledFunction())
+for (CallSite  : reverse(IFI.InlinedCallSites)) {
+  Function *NewCallee = CS.getCalledFunction();
+  if (!NewCallee) {
+// Try to promote an indirect (virtual) call without waiting for 
the
+// post-inline cleanup and the next DevirtSCCRepeatedPass iteration
+// because the next iteration may not happen and we may miss
+// inlining it.
+if (tryPromoteCall(CS))
+  NewCallee = CS.getCalledFunction();
+  }
+  if (NewCallee)
 if (!NewCallee->isDeclaration())
   Calls.push_back({CS, NewHistoryID});
+}
   }
 
   if (InlinerFunctionImportStats != InlinerFunctionImportStatsOpts::No)

diff  --git a/llvm/test/Transforms/Inline/devirtualize-4.ll 
b/llvm/test/Transforms/Inline/devirtualize-4.ll
new file mode 100644
index ..2205dae7aa23
--- /dev/null
+++ b/llvm/test/Transforms/Inline/devirtualize-4.ll
@@ -0,0 +1,214 @@
+; RUN: opt < %s -passes='cgscc(devirt<4>(inline)),function(sroa,early-cse)' -S 
| FileCheck %s
+; RUN: opt < %s -passes='default' -S | FileCheck %s
+
+; Check that DoNotOptimize is inlined into Test.
+; CHECK: @_Z4Testv()
+; CHECK-NOT: ret void
+; CHECK: call void asm
+; CHECK: ret void
+
+;template 
+;void DoNotOptimize(const T& var) {
+;  asm volatile("" : "+m"(const_cast(var)));
+;}
+;
+;class Interface {
+; public:
+;  virtual void Run() = 0;
+;};
+;
+;class Impl : public Interface {
+; public:
+;  Impl() : f(3) {}
+;  void Run() { DoNotOptimize(this); }
+;
+; private:
+;  int f;
+;};
+;
+;static void 

[PATCH] D75056: [Driver] Default to -fno-common

2020-02-26 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 246768.
SjoerdMeijer added a comment.
Herald added subscribers: kerbowa, nhaehnle, jvesely.

Thanks for catching that. Now it shows more changes in tests, so updated a 
bunch of tests.


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

https://reviews.llvm.org/D75056

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
  clang/test/CodeGen/2009-10-20-GlobalDebug.c
  clang/test/CodeGen/aarch64-sve.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/alignment.c
  clang/test/CodeGen/asm-label.c
  clang/test/CodeGen/attr-weak-import.c
  clang/test/CodeGen/attr-weakref2.c
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/blocks-windows.c
  clang/test/CodeGen/bool-convert.c
  clang/test/CodeGen/c11atomics.c
  clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
  clang/test/CodeGen/cfstring-windows.c
  clang/test/CodeGen/default-address-space.c
  clang/test/CodeGen/dllexport-1.c
  clang/test/CodeGen/dllexport.c
  clang/test/CodeGen/dllimport.c
  clang/test/CodeGen/microsoft-no-common-align.c
  clang/test/CodeGen/no-common.c
  clang/test/CodeGen/pr25786.c
  clang/test/CodeGen/pragma-pack-1.c
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/private-extern-redef.c
  clang/test/CodeGen/tentative-decls.c
  clang/test/CodeGen/tls-model.c
  clang/test/CodeGen/visibility.c
  clang/test/CodeGen/vlt_to_pointer.c
  clang/test/CodeGen/volatile-1.c
  clang/test/CodeGen/weak-global.c
  clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
  clang/test/CodeGenCXX/clang-sections-tentative.c
  clang/test/CodeGenObjC/constant-string-class.m
  clang/test/CodeGenObjC/tentative-cfconstantstring.m
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
  clang/test/Driver/apple-kext-mkernel.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/no-common.c
  clang/test/Driver/xcore-opts.c
  clang/test/Frontend/ast-codegen.c
  clang/test/Headers/xmmintrin.c
  clang/test/PCH/chain-external-defs.c
  clang/test/PCH/external-defs.c
  clang/test/PCH/tentative-defs.c
  clang/test/Parser/pragma-visibility2.c

Index: clang/test/Parser/pragma-visibility2.c
===
--- clang/test/Parser/pragma-visibility2.c
+++ clang/test/Parser/pragma-visibility2.c
@@ -6,14 +6,14 @@
 #pragma GCC visibility push(hidden)
 
 int v1;
-// CHECK: @v1 = common hidden global i32 0, align 4
+// CHECK: @v1 = hidden global i32 0, align 4
 
 #pragma GCC visibility pop
 
 int v2;
-// CHECK: @v2 = common global i32 0, align 4
+// CHECK: @v2 = global i32 0, align 4
 
 _Pragma("GCC visibility push(hidden)");
 
 int v3;
-// CHECK: @v3 = common hidden global i32 0, align 4
+// CHECK: @v3 = hidden global i32 0, align 4
Index: clang/test/PCH/tentative-defs.c
===
--- clang/test/PCH/tentative-defs.c
+++ clang/test/PCH/tentative-defs.c
@@ -1,6 +1,6 @@
 // Test with pch.
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/tentative-defs.h
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -verify -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -emit-pch -o %t.pch %S/tentative-defs.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -include-pch %t.pch -verify -emit-llvm -o %t %s
 // REQUIRES: x86-registered-target
 
 // RUN: grep "@variable = common global i32 0" %t | count 1
Index: clang/test/PCH/external-defs.c
===
--- clang/test/PCH/external-defs.c
+++ clang/test/PCH/external-defs.c
@@ -3,16 +3,16 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/external-defs.h
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s
 
-// RUN: grep "@x = common global i32 0" %t | count 1
+// RUN: grep "@x = global i32 0" %t | count 1
 // RUN: not grep "@z" %t
 
 // RUN: grep "@x2 = global i32 19" %t | count 1
 int x2 = 19;
 
-// RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1
-// RUN: grep "@incomplete_array2 = common global .*17 x i32" %t | count 1
+// RUN: grep "@incomplete_array = global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array2 = global .*17 x i32" %t | count 1
 int incomplete_array2[17];
-// RUN: grep "@incomplete_array3 = common global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array3 = global .*1 x i32" %t | count 1
 int incomplete_array3[];
 
 struct S {
Index: clang/test/PCH/chain-external-defs.c
===
--- clang/test/PCH/chain-external-defs.c
+++ 

[PATCH] D75056: [Driver] Default to -fno-common

2020-02-26 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer updated this revision to Diff 246770.
SjoerdMeijer added a comment.

minor test update


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

https://reviews.llvm.org/D75056

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/2008-07-21-mixed-var-fn-decl.c
  clang/test/CodeGen/2009-10-20-GlobalDebug.c
  clang/test/CodeGen/aarch64-sve.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align-systemz.c
  clang/test/CodeGen/alignment.c
  clang/test/CodeGen/asm-label.c
  clang/test/CodeGen/attr-weak-import.c
  clang/test/CodeGen/attr-weakref2.c
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/blocks-windows.c
  clang/test/CodeGen/bool-convert.c
  clang/test/CodeGen/c11atomics.c
  clang/test/CodeGen/cfstring-elf-cfbuild-x86_64.c
  clang/test/CodeGen/cfstring-windows.c
  clang/test/CodeGen/default-address-space.c
  clang/test/CodeGen/dllexport-1.c
  clang/test/CodeGen/dllexport.c
  clang/test/CodeGen/dllimport.c
  clang/test/CodeGen/microsoft-no-common-align.c
  clang/test/CodeGen/no-common.c
  clang/test/CodeGen/pr25786.c
  clang/test/CodeGen/pragma-pack-1.c
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/private-extern-redef.c
  clang/test/CodeGen/tentative-decls.c
  clang/test/CodeGen/tls-model.c
  clang/test/CodeGen/visibility.c
  clang/test/CodeGen/vlt_to_pointer.c
  clang/test/CodeGen/volatile-1.c
  clang/test/CodeGen/weak-global.c
  clang/test/CodeGen/windows-on-arm-dllimport-dllexport.c
  clang/test/CodeGenCXX/clang-sections-tentative.c
  clang/test/CodeGenObjC/constant-string-class.m
  clang/test/CodeGenObjC/tentative-cfconstantstring.m
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgpu-nullptr.cl
  clang/test/Driver/apple-kext-mkernel.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/no-common.c
  clang/test/Driver/xcore-opts.c
  clang/test/Frontend/ast-codegen.c
  clang/test/Headers/xmmintrin.c
  clang/test/PCH/chain-external-defs.c
  clang/test/PCH/external-defs.c
  clang/test/PCH/tentative-defs.c
  clang/test/Parser/pragma-visibility2.c

Index: clang/test/Parser/pragma-visibility2.c
===
--- clang/test/Parser/pragma-visibility2.c
+++ clang/test/Parser/pragma-visibility2.c
@@ -6,14 +6,14 @@
 #pragma GCC visibility push(hidden)
 
 int v1;
-// CHECK: @v1 = common hidden global i32 0, align 4
+// CHECK: @v1 = hidden global i32 0, align 4
 
 #pragma GCC visibility pop
 
 int v2;
-// CHECK: @v2 = common global i32 0, align 4
+// CHECK: @v2 = global i32 0, align 4
 
 _Pragma("GCC visibility push(hidden)");
 
 int v3;
-// CHECK: @v3 = common hidden global i32 0, align 4
+// CHECK: @v3 = hidden global i32 0, align 4
Index: clang/test/PCH/tentative-defs.c
===
--- clang/test/PCH/tentative-defs.c
+++ clang/test/PCH/tentative-defs.c
@@ -1,6 +1,6 @@
 // Test with pch.
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/tentative-defs.h
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -verify -emit-llvm -o %t %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -emit-pch -o %t.pch %S/tentative-defs.h
+// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fcommon -include-pch %t.pch -verify -emit-llvm -o %t %s
 // REQUIRES: x86-registered-target
 
 // RUN: grep "@variable = common global i32 0" %t | count 1
Index: clang/test/PCH/external-defs.c
===
--- clang/test/PCH/external-defs.c
+++ clang/test/PCH/external-defs.c
@@ -3,16 +3,16 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-pch -o %t.pch %S/external-defs.h
 // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s
 
-// RUN: grep "@x = common global i32 0" %t | count 1
+// RUN: grep "@x = global i32 0" %t | count 1
 // RUN: not grep "@z" %t
 
 // RUN: grep "@x2 = global i32 19" %t | count 1
 int x2 = 19;
 
-// RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1
-// RUN: grep "@incomplete_array2 = common global .*17 x i32" %t | count 1
+// RUN: grep "@incomplete_array = global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array2 = global .*17 x i32" %t | count 1
 int incomplete_array2[17];
-// RUN: grep "@incomplete_array3 = common global .*1 x i32" %t | count 1
+// RUN: grep "@incomplete_array3 = global .*1 x i32" %t | count 1
 int incomplete_array3[];
 
 struct S {
Index: clang/test/PCH/chain-external-defs.c
===
--- clang/test/PCH/chain-external-defs.c
+++ clang/test/PCH/chain-external-defs.c
@@ -16,11 +16,11 @@
 
 // Z-NOT: @z
 
-// XA: @x = common global i32 0
-// XA-NOT: @x = common global 

[PATCH] D31338: Move ParsedAttrInfos into a registry and point to one in ParsedAttr

2020-02-26 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 246763.
john.brawn added a comment.
Herald added a subscriber: krytarowski.

This has been rewritten so that the registry is only used for attributes added 
by plugins, and everything else continues as before. This also removes the 
strange dependency I'd previously introduced, where Attributes.cpp (in 
libclangBasic.so) declared and used the registry but ParsedAttr.cpp (in 
libclangSema.so) populated it - now the registry is declared and used solely 
within ParsedAttr.cpp.


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

https://reviews.llvm.org/D31338

Files:
  clang/include/clang/Basic/AttributeCommonInfo.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Basic/Attributes.cpp
  clang/lib/Sema/ParsedAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3625,9 +3625,11 @@
 
 // We need to generate struct instances based off ParsedAttrInfo from
 // ParsedAttr.cpp.
+const std::string  = I->first;
 const Record  = *I->second;
 OS << "struct ParsedAttrInfo" << I->first << " : public ParsedAttrInfo {\n";
 OS << "  ParsedAttrInfo" << I->first << "() {\n";
+OS << "AttrKind = ParsedAttr::AT_" << AttrName << ";\n";
 emitArgInfo(Attr, OS);
 OS << "HasCustomParsing = ";
 OS << Attr.getValueAsBit("HasCustomParsing") << ";\n";
@@ -3642,6 +3644,20 @@
 OS << IsKnownToGCC(Attr) << ";\n";
 OS << "IsSupportedByPragmaAttribute = ";
 OS << PragmaAttributeSupport.isAttributedSupported(*I->second) << ";\n";
+for (const auto  : GetFlattenedSpellings(Attr)) {
+  const std::string  = S.name();
+  std::string Spelling;
+  if (S.variety() == "CXX11" || S.variety() == "C2x") {
+Spelling += S.nameSpace();
+Spelling += "::";
+  }
+  if (S.variety() == "GNU")
+Spelling += NormalizeGNUAttrSpelling(RawSpelling);
+  else
+Spelling += RawSpelling;
+  OS << "Spellings.push_back({AttributeCommonInfo::AS_" << S.variety();
+  OS << ",\"" << Spelling << "\"});\n";
+}
 OS << "  }\n";
 GenerateAppertainsTo(Attr, OS);
 GenerateLangOptRequirements(Attr, OS);
Index: clang/lib/Sema/ParsedAttr.cpp
===
--- clang/lib/Sema/ParsedAttr.cpp
+++ clang/lib/Sema/ParsedAttr.cpp
@@ -25,6 +25,8 @@
 
 using namespace clang;
 
+LLVM_INSTANTIATE_REGISTRY(ParsedAttrInfoRegistry)
+
 IdentifierLoc *IdentifierLoc::create(ASTContext , SourceLocation Loc,
  IdentifierInfo *Ident) {
   IdentifierLoc *Result = new (Ctx) IdentifierLoc;
@@ -100,66 +102,58 @@
   pool.Attrs.clear();
 }
 
-struct ParsedAttrInfo {
-  unsigned NumArgs : 4;
-  unsigned OptArgs : 4;
-  unsigned HasCustomParsing : 1;
-  unsigned IsTargetSpecific : 1;
-  unsigned IsType : 1;
-  unsigned IsStmt : 1;
-  unsigned IsKnownToGCC : 1;
-  unsigned IsSupportedByPragmaAttribute : 1;
-
-  virtual ~ParsedAttrInfo() = default;
-
-  virtual bool diagAppertainsToDecl(Sema , const ParsedAttr ,
-const Decl *) const {
-return true;
-  }
-  virtual bool diagLangOpts(Sema , const ParsedAttr ) const {
-return true;
-  }
-  virtual bool existsInTarget(const TargetInfo ) const {
-return true;
-  }
-  virtual unsigned
-  spellingIndexToSemanticSpelling(const ParsedAttr ) const {
-return UINT_MAX;
-  }
-  virtual void getPragmaAttributeMatchRules(
-llvm::SmallVectorImpl> ,
-const LangOptions ) const {
-  }
-};
-
 namespace {
 
 #include "clang/Sema/AttrParsedAttrImpl.inc"
 
 } // namespace
 
-static const ParsedAttrInfo (const ParsedAttr ) {
-  // If we have a ParsedAttrInfo for this ParsedAttr then return that,
-  // otherwise return a default ParsedAttrInfo.
-  if (A.getKind() < llvm::array_lengthof(AttrInfoMap))
-return *AttrInfoMap[A.getKind()];
-
+const ParsedAttrInfo ::get(const AttributeCommonInfo ) {
+  // If we have a ParsedAttrInfo for this ParsedAttr then return that.
+  if (A.getParsedKind() < llvm::array_lengthof(AttrInfoMap))
+return *AttrInfoMap[A.getParsedKind()];
+
+  // If this is an ignored attribute then return an appropriate ParsedAttrInfo.
+  static ParsedAttrInfo IgnoredParsedAttrInfo(
+  AttributeCommonInfo::IgnoredAttribute);
+  if (A.getParsedKind() == AttributeCommonInfo::IgnoredAttribute)
+return IgnoredParsedAttrInfo;
+
+  // Otherwise this may be an attribute defined by a plugin. First instantiate
+  // all plugin attributes if we haven't already done so.
+  static std::list> PluginAttrInstances;
+  if (PluginAttrInstances.empty())
+for (auto It : ParsedAttrInfoRegistry::entries())
+  PluginAttrInstances.emplace_back(It.instantiate());
+
+  // Search for a ParsedAttrInfo whose name and syntax 

[PATCH] D31337: Use virtual functions in ParsedAttrInfo instead of function pointers

2020-02-26 Thread John Brawn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG590dc8d02cd7: Use virtual functions in ParsedAttrInfo 
instead of function pointers (authored by john.brawn).

Changed prior to commit:
  https://reviews.llvm.org/D31337?vs=242363=246765#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D31337

Files:
  clang/lib/Sema/ParsedAttr.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1814,7 +1814,7 @@
 
   void emitMatchRuleList(raw_ostream );
 
-  std::string generateStrictConformsTo(const Record , raw_ostream );
+  void generateStrictConformsTo(const Record , raw_ostream );
 
   void generateParsingHelpers(raw_ostream );
 };
@@ -1975,21 +1975,17 @@
   return Test;
 }
 
-std::string
+void
 PragmaClangAttributeSupport::generateStrictConformsTo(const Record ,
   raw_ostream ) {
-  if (!isAttributedSupported(Attr))
-return "nullptr";
+  if (!isAttributedSupported(Attr) || Attr.isValueUnset("Subjects"))
+return;
   // Generate a function that constructs a set of matching rules that describe
   // to which declarations the attribute should apply to.
-  std::string FnName = "matchRulesFor" + Attr.getName().str();
-  OS << "static void " << FnName << "(llvm::SmallVectorImpl> , const LangOptions ) {\n";
-  if (Attr.isValueUnset("Subjects")) {
-OS << "}\n\n";
-return FnName;
-  }
+ << ", bool>> , const LangOptions ) const {\n";
   const Record *SubjectObj = Attr.getValueAsDef("Subjects");
   std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
   for (const auto *Subject : Subjects) {
@@ -2006,7 +2002,6 @@
 }
   }
   OS << "}\n\n";
-  return FnName;
 }
 
 void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream ) {
@@ -3300,14 +3295,8 @@
 
   // If there is a variadic argument, we will set the optional argument count
   // to its largest value. Since it's currently a 4-bit number, we set it to 15.
-  OS << ArgCount << ", " << (HasVariadic ? 15 : OptCount);
-}
-
-static void GenerateDefaultAppertainsTo(raw_ostream ) {
-  OS << "static bool defaultAppertainsTo(Sema &, const ParsedAttr &,";
-  OS << "const Decl *) {\n";
-  OS << "  return true;\n";
-  OS << "}\n\n";
+  OS << "NumArgs = " << ArgCount << ";\n";
+  OS << "OptArgs = " << (HasVariadic ? 15 : OptCount) << ";\n";
 }
 
 static std::string GetDiagnosticSpelling(const Record ) {
@@ -3388,16 +3377,14 @@
   return "is" + Subject.getName().str();
 }
 
-static std::string GenerateCustomAppertainsTo(const Record ,
-  raw_ostream ) {
+static void GenerateCustomAppertainsTo(const Record , raw_ostream ) {
   std::string FnName = functionNameForCustomAppertainsTo(Subject);
 
-  // If this code has already been generated, simply return the previous
-  // instance of it.
+  // If this code has already been generated, we don't need to do anything.
   static std::set CustomSubjectSet;
   auto I = CustomSubjectSet.find(FnName);
   if (I != CustomSubjectSet.end())
-return *I;
+return;
 
   // This only works with non-root Decls.
   Record *Base = Subject.getValueAsDef(BaseFieldName);
@@ -3406,7 +3393,7 @@
   if (Base->isSubClassOf("SubsetSubject")) {
 PrintFatalError(Subject.getLoc(),
 "SubsetSubjects within SubsetSubjects is not supported");
-return "";
+return;
   }
 
   OS << "static bool " << FnName << "(const Decl *D) {\n";
@@ -3418,14 +3405,13 @@
   OS << "}\n\n";
 
   CustomSubjectSet.insert(FnName);
-  return FnName;
 }
 
-static std::string GenerateAppertainsTo(const Record , raw_ostream ) {
+static void GenerateAppertainsTo(const Record , raw_ostream ) {
   // If the attribute does not contain a Subjects definition, then use the
   // default appertainsTo logic.
   if (Attr.isValueUnset("Subjects"))
-return "defaultAppertainsTo";
+return;
 
   const Record *SubjectObj = Attr.getValueAsDef("Subjects");
   std::vector Subjects = SubjectObj->getValueAsListOfDefs("Subjects");
@@ -3433,52 +3419,46 @@
   // If the list of subjects is empty, it is assumed that the attribute
   // appertains to everything.
   if (Subjects.empty())
-return "defaultAppertainsTo";
+return;
 
   bool Warn = SubjectObj->getValueAsDef("Diag")->getValueAsBit("Warn");
 
   // Otherwise, generate an appertainsTo check specific to this attribute which
-  // checks all of the given subjects against the Decl passed in. Return the
-  // name of that check to the caller.
+  // checks all of the given subjects against the Decl passed in.
   //
   // If D is null, that means the attribute was not applied to a declaration
   // at all (for instance because it was applied 

[PATCH] D75193: [clangd] Get rid of lexer usage in AST.cpp

2020-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.
kadircet added a parent revision: D75176: [clangd] Get rid of 
getBeginningOfIdentifier helper.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75193

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


Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -109,7 +109,6 @@
 QualType declaredType(const TypeDecl *D);
 
 /// Retrieves the deduced type at a given location (auto, decltype).
-/// Retuns None unless Loc starts an auto/decltype token.
 /// It will return the underlying type.
 llvm::Optional getDeducedType(ASTContext &, SourceLocation Loc);
 
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -25,7 +25,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Index/USRGeneration.h"
-#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -417,16 +416,8 @@
 
 llvm::Optional getDeducedType(ASTContext ,
 SourceLocation Loc) {
-  Token Tok;
-  // Only try to find a deduced type if the token is auto or decltype.
-  if (!Loc.isValid() ||
-  Lexer::getRawToken(Loc, Tok, ASTCtx.getSourceManager(),
- ASTCtx.getLangOpts(), false) ||
-  !Tok.is(tok::raw_identifier) ||
-  !(Tok.getRawIdentifier() == "auto" ||
-Tok.getRawIdentifier() == "decltype")) {
+  if (!Loc.isValid())
 return {};
-  }
   DeducedTypeVisitor V(Loc);
   V.TraverseAST(ASTCtx);
   if (V.DeducedType.isNull())


Index: clang-tools-extra/clangd/AST.h
===
--- clang-tools-extra/clangd/AST.h
+++ clang-tools-extra/clangd/AST.h
@@ -109,7 +109,6 @@
 QualType declaredType(const TypeDecl *D);
 
 /// Retrieves the deduced type at a given location (auto, decltype).
-/// Retuns None unless Loc starts an auto/decltype token.
 /// It will return the underlying type.
 llvm::Optional getDeducedType(ASTContext &, SourceLocation Loc);
 
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -25,7 +25,6 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Index/USRGeneration.h"
-#include "clang/Lex/Lexer.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -417,16 +416,8 @@
 
 llvm::Optional getDeducedType(ASTContext ,
 SourceLocation Loc) {
-  Token Tok;
-  // Only try to find a deduced type if the token is auto or decltype.
-  if (!Loc.isValid() ||
-  Lexer::getRawToken(Loc, Tok, ASTCtx.getSourceManager(),
- ASTCtx.getLangOpts(), false) ||
-  !Tok.is(tok::raw_identifier) ||
-  !(Tok.getRawIdentifier() == "auto" ||
-Tok.getRawIdentifier() == "decltype")) {
+  if (!Loc.isValid())
 return {};
-  }
   DeducedTypeVisitor V(Loc);
   V.TraverseAST(ASTCtx);
   if (V.DeducedType.isNull())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 590dc8d - Use virtual functions in ParsedAttrInfo instead of function pointers

2020-02-26 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2020-02-26T17:24:30Z
New Revision: 590dc8d02cd781b110a87b82476c3557cb5957c3

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

LOG: Use virtual functions in ParsedAttrInfo instead of function pointers

This doesn't do anything on its own, but it's the first step towards
allowing plugins to define attributes. It does simplify the
ParsedAttrInfo generation in ClangAttrEmitter a little though.

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

Added: 


Modified: 
clang/lib/Sema/ParsedAttr.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp
index 5d0a734f237a..c814639f00ea 100644
--- a/clang/lib/Sema/ParsedAttr.cpp
+++ b/clang/lib/Sema/ParsedAttr.cpp
@@ -110,13 +110,26 @@ struct ParsedAttrInfo {
   unsigned IsKnownToGCC : 1;
   unsigned IsSupportedByPragmaAttribute : 1;
 
-  bool (*DiagAppertainsToDecl)(Sema , const ParsedAttr , const Decl *);
-  bool (*DiagLangOpts)(Sema , const ParsedAttr );
-  bool (*ExistsInTarget)(const TargetInfo );
-  unsigned (*SpellingIndexToSemanticSpelling)(const ParsedAttr );
-  void (*GetPragmaAttributeMatchRules)(
-  llvm::SmallVectorImpl> ,
-  const LangOptions );
+  virtual ~ParsedAttrInfo() = default;
+
+  virtual bool diagAppertainsToDecl(Sema , const ParsedAttr ,
+const Decl *) const {
+return true;
+  }
+  virtual bool diagLangOpts(Sema , const ParsedAttr ) const {
+return true;
+  }
+  virtual bool existsInTarget(const TargetInfo ) const {
+return true;
+  }
+  virtual unsigned
+  spellingIndexToSemanticSpelling(const ParsedAttr ) const {
+return UINT_MAX;
+  }
+  virtual void getPragmaAttributeMatchRules(
+llvm::SmallVectorImpl> ,
+const LangOptions ) const {
+  }
 };
 
 namespace {
@@ -126,7 +139,13 @@ namespace {
 } // namespace
 
 static const ParsedAttrInfo (const ParsedAttr ) {
-  return AttrInfoMap[A.getKind()];
+  // If we have a ParsedAttrInfo for this ParsedAttr then return that,
+  // otherwise return a default ParsedAttrInfo.
+  if (A.getKind() < llvm::array_lengthof(AttrInfoMap))
+return *AttrInfoMap[A.getKind()];
+
+  static ParsedAttrInfo DefaultParsedAttrInfo;
+  return DefaultParsedAttrInfo;
 }
 
 unsigned ParsedAttr::getMinArgs() const { return getInfo(*this).NumArgs; }
@@ -140,7 +159,7 @@ bool ParsedAttr::hasCustomParsing() const {
 }
 
 bool ParsedAttr::diagnoseAppertainsTo(Sema , const Decl *D) const {
-  return getInfo(*this).DiagAppertainsToDecl(S, *this, D);
+  return getInfo(*this).diagAppertainsToDecl(S, *this, D);
 }
 
 bool ParsedAttr::appliesToDecl(const Decl *D,
@@ -152,11 +171,11 @@ void ParsedAttr::getMatchRules(
 const LangOptions ,
 SmallVectorImpl> )
 const {
-  return getInfo(*this).GetPragmaAttributeMatchRules(MatchRules, LangOpts);
+  return getInfo(*this).getPragmaAttributeMatchRules(MatchRules, LangOpts);
 }
 
 bool ParsedAttr::diagnoseLangOpts(Sema ) const {
-  return getInfo(*this).DiagLangOpts(S, *this);
+  return getInfo(*this).diagLangOpts(S, *this);
 }
 
 bool ParsedAttr::isTargetSpecificAttr() const {
@@ -168,7 +187,7 @@ bool ParsedAttr::isTypeAttr() const { return 
getInfo(*this).IsType; }
 bool ParsedAttr::isStmtAttr() const { return getInfo(*this).IsStmt; }
 
 bool ParsedAttr::existsInTarget(const TargetInfo ) const {
-  return getInfo(*this).ExistsInTarget(Target);
+  return getInfo(*this).existsInTarget(Target);
 }
 
 bool ParsedAttr::isKnownToGCC() const { return getInfo(*this).IsKnownToGCC; }
@@ -178,7 +197,7 @@ bool ParsedAttr::isSupportedByPragmaAttribute() const {
 }
 
 unsigned ParsedAttr::getSemanticSpelling() const {
-  return getInfo(*this).SpellingIndexToSemanticSpelling(*this);
+  return getInfo(*this).spellingIndexToSemanticSpelling(*this);
 }
 
 bool ParsedAttr::hasVariadicArg() const {

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index 116c382c1e8f..251cbecd1c45 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1814,7 +1814,7 @@ struct PragmaClangAttributeSupport {
 
   void emitMatchRuleList(raw_ostream );
 
-  std::string generateStrictConformsTo(const Record , raw_ostream );
+  void generateStrictConformsTo(const Record , raw_ostream );
 
   void generateParsingHelpers(raw_ostream );
 };
@@ -1975,21 +1975,17 @@ static std::string 
GenerateTestExpression(ArrayRef LangOpts) {
   return Test;
 }
 
-std::string
+void
 PragmaClangAttributeSupport::generateStrictConformsTo(const Record ,
   raw_ostream ) {
-  if (!isAttributedSupported(Attr))
-return "nullptr";
+  if (!isAttributedSupported(Attr) || 

[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-02-26 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 246758.
DmitryPolukhin added a comment.

Rebase on top of master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,9 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s 
-check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s 
-check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' 
-header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s 
-check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
 // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
Index: 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
@@ -0,0 +1,3 @@
+InheritParentConfig: true
+Checks: 'from-child3'
+HeaderFilterRegex: 'child3'
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -106,6 +106,10 @@
 
   /// Add extra compilation arguments to the start of the list.
   llvm::Optional ExtraArgsBefore;
+
+  /// Config flag for FileOptionsProvider to also include config from parent
+  /// dir.
+  llvm::Optional InheritParentConfig;
 };
 
 /// Abstract interface for retrieving various ClangTidy options.
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -92,6 +92,7 @@
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
 IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
+IO.mapOptional("InheritParentConfig", Options.InheritParentConfig);
   }
 };
 
@@ -237,6 +238,7 @@
   DefaultOptionsProvider::getRawOptions(AbsoluteFilePath.str());
   OptionsSource CommandLineOptions(OverrideOptions,
OptionsSourceTypeCheckCommandLineOption);
+  size_t FirstFileConfig = RawOptions.size();
   // Look for a suitable configuration file in all parent directories of the
   // file. Start with the immediate parent directory and move up.
   StringRef Path = llvm::sys::path::parent_path(AbsoluteFilePath.str());
@@ -262,9 +264,14 @@
   CachedOptions[Path] = *Result;
 
   RawOptions.push_back(*Result);
-  break;
+  if (!Result->first.InheritParentConfig ||
+  !*Result->first.InheritParentConfig)
+break;
 }
   }
+  // Reverse order of file configs because closer configs should have higher
+  // priority.
+  std::reverse(RawOptions.begin() + FirstFileConfig, RawOptions.end());
   RawOptions.push_back(CommandLineOptions);
   return RawOptions;
 }


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,9 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' -header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
 // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy

[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

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

Im sorry, i though we talked about internal code and we're stuck with the 
checker interface -- this should definitely be solved by changing the parameter 
of the `shouldRegister` function to `CheckerManager`. If you want to emit 
errors for incorrect file, there is an example in `UninitializedObjectChecker` 
and maybe in `GenericTaintChecker`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75171



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


Re: [clang] 83f4372 - [CodeGen] fix clang test that runs the optimizer pipeline; NFC

2020-02-26 Thread Sanjay Patel via cfe-commits
The test file dates back to:
https://reviews.llvm.org/D5698
...and I'm not familiar with _Complex enough to say how to fix this
properly (seems like the check lines are already limited such that -O0
rather than -O1 would work?).

But this file keeps wiggling unexpectedly, it's going to move again with
https://reviews.llvm.org/D75130

On Tue, Feb 25, 2020 at 1:15 PM Eric Christopher  wrote:

> Is there any way to pull this test out of clang and as an opt test? What's
> it trying to test?
>
> -eric
>
> On Tue, Feb 25, 2020 at 6:15 AM Sanjay Patel via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> Author: Sanjay Patel
>> Date: 2020-02-25T09:13:49-05:00
>> New Revision: 83f4372f3a708ceaa800feff8b1bd92ae2c3be5f
>>
>> URL:
>> https://github.com/llvm/llvm-project/commit/83f4372f3a708ceaa800feff8b1bd92ae2c3be5f
>> DIFF:
>> https://github.com/llvm/llvm-project/commit/83f4372f3a708ceaa800feff8b1bd92ae2c3be5f.diff
>>
>> LOG: [CodeGen] fix clang test that runs the optimizer pipeline; NFC
>>
>> There's already a FIXME note on this file; it can break when the
>> underlying LLVM behavior changes independently of anything in clang.
>>
>> Added:
>>
>>
>> Modified:
>> clang/test/CodeGen/complex-math.c
>>
>> Removed:
>>
>>
>>
>>
>> 
>> diff  --git a/clang/test/CodeGen/complex-math.c
>> b/clang/test/CodeGen/complex-math.c
>> index e42418ad72c2..54dee473a364 100644
>> --- a/clang/test/CodeGen/complex-math.c
>> +++ b/clang/test/CodeGen/complex-math.c
>> @@ -93,14 +93,15 @@ float _Complex mul_float_rc(float a, float _Complex
>> b) {
>>// X86: ret
>>return a * b;
>>  }
>> +
>>  float _Complex mul_float_cc(float _Complex a, float _Complex b) {
>>// X86-LABEL: @mul_float_cc(
>>// X86: %[[AC:[^ ]+]] = fmul
>>// X86: %[[BD:[^ ]+]] = fmul
>>// X86: %[[AD:[^ ]+]] = fmul
>>// X86: %[[BC:[^ ]+]] = fmul
>> -  // X86: %[[RR:[^ ]+]] = fsub float %[[AC]], %[[BD]]
>> -  // X86: %[[RI:[^ ]+]] = fadd float
>> +  // X86: %[[RR:[^ ]+]] = fsub
>> +  // X86: %[[RI:[^ ]+]] = fadd
>>// X86-DAG: %[[AD]]
>>// X86-DAG: ,
>>// X86-DAG: %[[BC]]
>>
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75166: [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations

2020-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2011d14296ee: [clangd] Clean-up XRefs.cpp from Lexer usages 
and unnecessary SourceLoc… (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75166

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -97,6 +97,15 @@
   R"cpp(// Function parameter in decl
 void foo(int [[^bar]]);
   )cpp",
+  R"cpp(// Not touching any identifiers.
+struct Foo {
+  [[~]]Foo() {};
+};
+void foo() {
+  Foo f;
+  f.[[^~]]Foo();
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
@@ -960,6 +969,15 @@
class [[Foo]] {};
void func([[Fo^o]]);
   )cpp",
+  R"cpp(// Not touching any identifiers.
+struct Foo {
+  [[~]]Foo() {};
+};
+void foo() {
+  Foo f;
+  f.[[^~]]Foo();
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -43,6 +43,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -214,24 +215,34 @@
 }
   }
 
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+  if (!CurLoc) {
+elog("locateSymbolAt failed to convert position to source location: {0}",
+ CurLoc.takeError());
+return {};
+  }
+
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
-  getBeginningOfIdentifier(Pos, AST.getSourceManager(), AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
-if (auto Loc = makeLocation(AST.getASTContext(),
-M->Info->getDefinitionLoc(), *MainFilePath)) {
-  LocatedSymbol Macro;
-  Macro.Name = std::string(M->Name);
-  Macro.PreferredDeclaration = *Loc;
-  Macro.Definition = Loc;
-  Result.push_back(std::move(Macro));
-
-  // Don't look at the AST or index if we have a macro result.
-  // (We'd just return declarations referenced from the macro's
-  // expansion.)
-  return Result;
+  const auto *TouchedIdentifier =
+  syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
+  if (TouchedIdentifier) {
+if (auto M = locateMacroAt(TouchedIdentifier->location(),
+   AST.getPreprocessor())) {
+  if (auto Loc = makeLocation(AST.getASTContext(),
+  M->Info->getDefinitionLoc(), *MainFilePath)) {
+LocatedSymbol Macro;
+Macro.Name = std::string(M->Name);
+Macro.PreferredDeclaration = *Loc;
+Macro.Definition = Loc;
+Result.push_back(std::move(Macro));
+
+// Don't look at the AST or index if we have a macro result.
+// (We'd just return declarations referenced from the macro's
+// expansion.)
+return Result;
+  }
 }
   }
 
@@ -244,15 +255,6 @@
   // Keep track of SymbolID -> index mapping, to fill in index data later.
   llvm::DenseMap ResultIndex;
 
-  SourceLocation SourceLoc;
-  if (auto L = sourceLocationInMainFile(SM, Pos)) {
-SourceLoc = *L;
-  } else {
-elog("locateSymbolAt failed to convert position to source location: {0}",
- L.takeError());
-return Result;
-  }
-
   auto AddResultDecl = [&](const NamedDecl *D) {
 const NamedDecl *Def = getDefinition(D);
 const NamedDecl *Preferred = Def ? Def : D;
@@ -277,16 +279,15 @@
   // Emit all symbol locations (declaration or definition) from AST.
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
-  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+  for (const NamedDecl *D : getDeclAtPosition(AST, *CurLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const InheritableAttr* Attr = D->getAttr();
+  const InheritableAttr *Attr = D->getAttr();
   if (!Attr)
 Attr = D->getAttr();
-  const syntax::Token *Tok =
-  spelledIdentifierTouching(SourceLoc, AST.getTokens());
-  if (Attr 

[clang-tools-extra] 2011d14 - [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations

2020-02-26 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-02-26T17:51:27+01:00
New Revision: 2011d14296eeaae911e898d11154ee5d1a5db1d6

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

LOG: [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc 
transformations

Summary:
Get rid of calls to lexer and unnecessary source location
transformations.

Reviewers: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/XRefs.cpp 
b/clang-tools-extra/clangd/XRefs.cpp
index 3e0c9f79fc57..f7702c98b38f 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -43,6 +43,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -214,24 +215,34 @@ std::vector locateSymbolAt(ParsedAST , 
Position Pos,
 }
   }
 
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+  if (!CurLoc) {
+elog("locateSymbolAt failed to convert position to source location: {0}",
+ CurLoc.takeError());
+return {};
+  }
+
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
-  getBeginningOfIdentifier(Pos, AST.getSourceManager(), 
AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
-if (auto Loc = makeLocation(AST.getASTContext(),
-M->Info->getDefinitionLoc(), *MainFilePath)) {
-  LocatedSymbol Macro;
-  Macro.Name = std::string(M->Name);
-  Macro.PreferredDeclaration = *Loc;
-  Macro.Definition = Loc;
-  Result.push_back(std::move(Macro));
-
-  // Don't look at the AST or index if we have a macro result.
-  // (We'd just return declarations referenced from the macro's
-  // expansion.)
-  return Result;
+  const auto *TouchedIdentifier =
+  syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
+  if (TouchedIdentifier) {
+if (auto M = locateMacroAt(TouchedIdentifier->location(),
+   AST.getPreprocessor())) {
+  if (auto Loc = makeLocation(AST.getASTContext(),
+  M->Info->getDefinitionLoc(), *MainFilePath)) 
{
+LocatedSymbol Macro;
+Macro.Name = std::string(M->Name);
+Macro.PreferredDeclaration = *Loc;
+Macro.Definition = Loc;
+Result.push_back(std::move(Macro));
+
+// Don't look at the AST or index if we have a macro result.
+// (We'd just return declarations referenced from the macro's
+// expansion.)
+return Result;
+  }
 }
   }
 
@@ -244,15 +255,6 @@ std::vector locateSymbolAt(ParsedAST , 
Position Pos,
   // Keep track of SymbolID -> index mapping, to fill in index data later.
   llvm::DenseMap ResultIndex;
 
-  SourceLocation SourceLoc;
-  if (auto L = sourceLocationInMainFile(SM, Pos)) {
-SourceLoc = *L;
-  } else {
-elog("locateSymbolAt failed to convert position to source location: {0}",
- L.takeError());
-return Result;
-  }
-
   auto AddResultDecl = [&](const NamedDecl *D) {
 const NamedDecl *Def = getDefinition(D);
 const NamedDecl *Preferred = Def ? Def : D;
@@ -277,16 +279,15 @@ std::vector locateSymbolAt(ParsedAST , 
Position Pos,
   // Emit all symbol locations (declaration or definition) from AST.
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
-  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+  for (const NamedDecl *D : getDeclAtPosition(AST, *CurLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const InheritableAttr* Attr = D->getAttr();
+  const InheritableAttr *Attr = D->getAttr();
   if (!Attr)
 Attr = D->getAttr();
-  const syntax::Token *Tok =
-  spelledIdentifierTouching(SourceLoc, AST.getTokens());
-  if (Attr && Tok &&
-  SM.getSpellingLoc(Attr->getLocation()) == Tok->location()) {
+  if (Attr && TouchedIdentifier &&
+  SM.getSpellingLoc(Attr->getLocation()) ==
+  TouchedIdentifier->location()) {
 // We may be overridding multiple methods - offer them all.
 for (const NamedDecl *ND : 

[PATCH] D75166: [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations

2020-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 246750.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Add tests for non-identifier cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75166

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

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -97,6 +97,15 @@
   R"cpp(// Function parameter in decl
 void foo(int [[^bar]]);
   )cpp",
+  R"cpp(// Not touching any identifiers.
+struct Foo {
+  [[~]]Foo() {};
+};
+void foo() {
+  Foo f;
+  f.[[^~]]Foo();
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
@@ -960,6 +969,15 @@
class [[Foo]] {};
void func([[Fo^o]]);
   )cpp",
+  R"cpp(// Not touching any identifiers.
+struct Foo {
+  [[~]]Foo() {};
+};
+void foo() {
+  Foo f;
+  f.[[^~]]Foo();
+}
+  )cpp",
   };
   for (const char *Test : Tests) {
 Annotations T(Test);
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -43,6 +43,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -214,24 +215,34 @@
 }
   }
 
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+  if (!CurLoc) {
+elog("locateSymbolAt failed to convert position to source location: {0}",
+ CurLoc.takeError());
+return {};
+  }
+
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
-  getBeginningOfIdentifier(Pos, AST.getSourceManager(), AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
-if (auto Loc = makeLocation(AST.getASTContext(),
-M->Info->getDefinitionLoc(), *MainFilePath)) {
-  LocatedSymbol Macro;
-  Macro.Name = std::string(M->Name);
-  Macro.PreferredDeclaration = *Loc;
-  Macro.Definition = Loc;
-  Result.push_back(std::move(Macro));
-
-  // Don't look at the AST or index if we have a macro result.
-  // (We'd just return declarations referenced from the macro's
-  // expansion.)
-  return Result;
+  const auto *TouchedIdentifier =
+  syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
+  if (TouchedIdentifier) {
+if (auto M = locateMacroAt(TouchedIdentifier->location(),
+   AST.getPreprocessor())) {
+  if (auto Loc = makeLocation(AST.getASTContext(),
+  M->Info->getDefinitionLoc(), *MainFilePath)) {
+LocatedSymbol Macro;
+Macro.Name = std::string(M->Name);
+Macro.PreferredDeclaration = *Loc;
+Macro.Definition = Loc;
+Result.push_back(std::move(Macro));
+
+// Don't look at the AST or index if we have a macro result.
+// (We'd just return declarations referenced from the macro's
+// expansion.)
+return Result;
+  }
 }
   }
 
@@ -244,15 +255,6 @@
   // Keep track of SymbolID -> index mapping, to fill in index data later.
   llvm::DenseMap ResultIndex;
 
-  SourceLocation SourceLoc;
-  if (auto L = sourceLocationInMainFile(SM, Pos)) {
-SourceLoc = *L;
-  } else {
-elog("locateSymbolAt failed to convert position to source location: {0}",
- L.takeError());
-return Result;
-  }
-
   auto AddResultDecl = [&](const NamedDecl *D) {
 const NamedDecl *Def = getDefinition(D);
 const NamedDecl *Preferred = Def ? Def : D;
@@ -277,16 +279,15 @@
   // Emit all symbol locations (declaration or definition) from AST.
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
-  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+  for (const NamedDecl *D : getDeclAtPosition(AST, *CurLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const InheritableAttr* Attr = D->getAttr();
+  const InheritableAttr *Attr = D->getAttr();
   if (!Attr)
 Attr = D->getAttr();
-  const syntax::Token *Tok =
-  spelledIdentifierTouching(SourceLoc, AST.getTokens());
-  if (Attr && Tok &&
-  

[PATCH] D73242: [WPD/LowerTypeTests] Delay lowering/removal of type tests until after ICP

2020-02-26 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D73242#1893506 , @tejohnson wrote:

> In D73242#1888295 , @tejohnson wrote:
>
> > FYI I have reproduced the failure, and am starting to debug.
>
>
> I see what is going on and have a simple fix, just need to create a test 
> case. Expect to send a patch to fix this today, hopefully this morning.


Thanks! Let me know, I'll test right away.

I'm seeing another (new?) bug with latest trunk, I'm not sure if it's related 
or not. The repro is the same, just sync the latest, and do the two-stage 
build, then `ninja check-lld`, all the LTO tests fail with this stack:

   #0 0x7ff63bd7e891 `anonymous namespace'::RealFile::`scalar deleting 
dtor'(unsigned int) 
(d:\llvm-project\buildninjarelmimalloc\bin\ld.lld.exe+0x1e891)
   #1 0x7ff63c47d4ac llvm::FPPassManager::~FPPassManager 
D:\llvm-project\llvm\include\llvm\IR\LegacyPassManagers.h:461:0
   #2 0x7ff63c47c98c `anonymous namespace'::MPPassManager::~MPPassManager 
D:\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:407:0
   #3 0x7ff63c475fac llvm::PMTopLevelManager::~PMTopLevelManager(void) 
D:\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:855:0
   #4 0x7ff63c47c3bc llvm::legacy::FunctionPassManagerImpl::`scalar 
deleting dtor'(unsigned int) 
D:\llvm-project\llvm\lib\IR\LegacyPassManager.cpp:324:0
   #5 0x7ff63c39aa41 `anonymous namespace'::codegen 
D:\llvm-project\llvm\lib\LTO\LTOBackend.cpp:373:0
   #6 0x7ff63c39732c llvm::lto::backend(struct llvm::lto::Config const &, 
class std::function<(unsigned int)>, unsigned int, class std::unique_ptr>, class 
llvm::ModuleSummaryIndex &) D:\llvm-project\llvm\lib\LTO\LTOBackend.cpp:466:0
   #7 0x7ff63be8a49a llvm::lto::LTO::run(class std::function<(unsigned 
int)>, class std::function<(unsigned int, class llvm::StringRef)>) 
D:\llvm-project\llvm\lib\LTO\LTO.cpp:942:0
   #8 0x7ff63c153eb5 lld::elf::BitcodeCompiler::compile(void) 
D:\llvm-project\lld\ELF\LTO.cpp:261:0
   #9 0x7ff63bdc0b01 lld::elf::LinkerDriver::main 
D:\llvm-project\lld\ELF\Driver.cpp:522:0
  #10 0x7ff63bdba6dc lld::elf::link(class llvm::ArrayRef, 
bool, class llvm::raw_ostream &, class llvm::raw_ostream &) 
D:\llvm-project\lld\ELF\Driver.cpp:117:0
  #11 0x7ff63bd61807 main D:\llvm-project\lld\tools\lld\lld.cpp:166:0
  #12 0x7ff63e9cf914 __scrt_common_main_seh 
d:\agent\_work\5\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
  #13 0x7ffa95737bd4 (C:\WINDOWS\System32\KERNEL32.DLL+0x17bd4)
  #14 0x7ffa972eced1 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x6ced1)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73242



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


[PATCH] D75077: [OpenMP5.0] Allow pointer arithmetic in motion/map clause

2020-02-26 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:15683
   }
+  bool VisitUnaryOperator(UnaryOperator *UO) {
+if (SemaRef.getLangOpts().OpenMP < 50) {

ABataev wrote:
> cchen wrote:
> > ABataev wrote:
> > > I think you need to extend this to support paren expressions, at least.
> > I have `UO->getSubExpr()->IgnoreParenImpCasts()` here, or I might not 
> > understand what you mean by "support paren expression".
> `(*(..))` is not supported, I think. Or, maybe, `*((a)+b)`
Both cases are handled correctly. For `(*((b)+a))`, the binop in 
`VisitBinaryOperator()`does not include the outer paren and for `*((a)+b)`, the 
parens can be handled by `Expr *SubE = 
UO->getSubExpr()->IgnoreParenImpCasts();`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75077



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


[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-02-26 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added reviewers: alexfh, gribozavr2.
DmitryPolukhin added projects: clang, clang-tools-extra.
Herald added subscribers: aheejin, xazax.hun.

Without this patch clang-tidy stops finding file configs on the nearest
.clang-tidy file. In some cases it is not very convenient because it
results in common parts duplication into every child .clang-tidy file.
This diff adds optional config inheritance from the parent directories
config files.

Test Plan:

Added test case in existing config test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75184

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,9 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s 
-check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s 
-check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' 
-header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s 
-check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
 // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
Index: 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
@@ -0,0 +1,3 @@
+InheritParentConfig: true
+Checks: 'from-child3'
+HeaderFilterRegex: 'child3'
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.h
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -106,6 +106,10 @@
 
   /// Add extra compilation arguments to the start of the list.
   llvm::Optional ExtraArgsBefore;
+
+  /// Config flag for FileOptionsProvider to also include config from parent
+  /// dir.
+  llvm::Optional InheritParentConfig;
 };
 
 /// Abstract interface for retrieving various ClangTidy options.
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -92,6 +92,7 @@
 IO.mapOptional("CheckOptions", NOpts->Options);
 IO.mapOptional("ExtraArgs", Options.ExtraArgs);
 IO.mapOptional("ExtraArgsBefore", Options.ExtraArgsBefore);
+IO.mapOptional("InheritParentConfig", Options.InheritParentConfig);
   }
 };
 
@@ -237,6 +238,7 @@
   DefaultOptionsProvider::getRawOptions(AbsoluteFilePath.str());
   OptionsSource CommandLineOptions(OverrideOptions,
OptionsSourceTypeCheckCommandLineOption);
+  size_t FirstFileConfig = RawOptions.size();
   // Look for a suitable configuration file in all parent directories of the
   // file. Start with the immediate parent directory and move up.
   StringRef Path = llvm::sys::path::parent_path(AbsoluteFilePath.str());
@@ -262,9 +264,14 @@
   CachedOptions[Path] = *Result;
 
   RawOptions.push_back(*Result);
-  break;
+  if (!Result->first.InheritParentConfig ||
+  !*Result->first.InheritParentConfig)
+break;
 }
   }
+  // Reverse order of file configs because closer configs should have higher
+  // priority.
+  std::reverse(RawOptions.begin() + FirstFileConfig, RawOptions.end());
   RawOptions.push_back(CommandLineOptions);
   return RawOptions;
 }


Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,9 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config 

[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

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

Ping !


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-02-26 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added a comment.

ping.


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

https://reviews.llvm.org/D74166



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


[PATCH] D75166: [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations

2020-02-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/XRefs.cpp:432
   auto References = findRefs(
-  getDeclAtPosition(AST,
-
SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, SM, AST.getLangOpts())),
-Relations),
-  AST);
+  getDeclAtPosition(AST, IdentifierAtCursor->location(), Relations), AST);
 

kadircet wrote:
> sammccall wrote:
> > apparently we don't have tests for non-identifier cases, but they did work. 
> > let's keep them working for now :) CurLoc here
> also get rid of the bail-out when no tokens were touched. (which means we can 
> now possibly trigger on `^~Foo()`.)
can I bother you to add a test for this (or some non-identifier case, assuming 
any works)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75166



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


[PATCH] D75022: clang-format: Extend AllowShortLoopsOnASingleLine to do ... while loops.

2020-02-26 Thread Daan De Meyer via Phabricator via cfe-commits
DaanDeMeyer added a comment.

Is there CI infra that runs for each revision? I verified all the format unit 
tests still pass but I haven't run the entire test suite on my machine.


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

https://reviews.llvm.org/D75022



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


[PATCH] D75166: [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations

2020-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 246734.
kadircet marked 4 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75166

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

Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -43,6 +43,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -214,24 +215,34 @@
 }
   }
 
+  auto CurLoc = sourceLocationInMainFile(SM, Pos);
+  if (!CurLoc) {
+elog("locateSymbolAt failed to convert position to source location: {0}",
+ CurLoc.takeError());
+return {};
+  }
+
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
-  SourceLocation IdentStartLoc = SM.getMacroArgExpandedLocation(
-  getBeginningOfIdentifier(Pos, AST.getSourceManager(), AST.getLangOpts()));
   std::vector Result;
-  if (auto M = locateMacroAt(IdentStartLoc, AST.getPreprocessor())) {
-if (auto Loc = makeLocation(AST.getASTContext(),
-M->Info->getDefinitionLoc(), *MainFilePath)) {
-  LocatedSymbol Macro;
-  Macro.Name = std::string(M->Name);
-  Macro.PreferredDeclaration = *Loc;
-  Macro.Definition = Loc;
-  Result.push_back(std::move(Macro));
-
-  // Don't look at the AST or index if we have a macro result.
-  // (We'd just return declarations referenced from the macro's
-  // expansion.)
-  return Result;
+  const auto *TouchedIdentifier =
+  syntax::spelledIdentifierTouching(*CurLoc, AST.getTokens());
+  if (TouchedIdentifier) {
+if (auto M = locateMacroAt(TouchedIdentifier->location(),
+   AST.getPreprocessor())) {
+  if (auto Loc = makeLocation(AST.getASTContext(),
+  M->Info->getDefinitionLoc(), *MainFilePath)) {
+LocatedSymbol Macro;
+Macro.Name = std::string(M->Name);
+Macro.PreferredDeclaration = *Loc;
+Macro.Definition = Loc;
+Result.push_back(std::move(Macro));
+
+// Don't look at the AST or index if we have a macro result.
+// (We'd just return declarations referenced from the macro's
+// expansion.)
+return Result;
+  }
 }
   }
 
@@ -244,15 +255,6 @@
   // Keep track of SymbolID -> index mapping, to fill in index data later.
   llvm::DenseMap ResultIndex;
 
-  SourceLocation SourceLoc;
-  if (auto L = sourceLocationInMainFile(SM, Pos)) {
-SourceLoc = *L;
-  } else {
-elog("locateSymbolAt failed to convert position to source location: {0}",
- L.takeError());
-return Result;
-  }
-
   auto AddResultDecl = [&](const NamedDecl *D) {
 const NamedDecl *Def = getDefinition(D);
 const NamedDecl *Preferred = Def ? Def : D;
@@ -277,16 +279,15 @@
   // Emit all symbol locations (declaration or definition) from AST.
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
-  for (const NamedDecl *D : getDeclAtPosition(AST, SourceLoc, Relations)) {
+  for (const NamedDecl *D : getDeclAtPosition(AST, *CurLoc, Relations)) {
 // Special case: void foo() ^override: jump to the overridden method.
 if (const auto *CMD = llvm::dyn_cast(D)) {
-  const InheritableAttr* Attr = D->getAttr();
+  const InheritableAttr *Attr = D->getAttr();
   if (!Attr)
 Attr = D->getAttr();
-  const syntax::Token *Tok =
-  spelledIdentifierTouching(SourceLoc, AST.getTokens());
-  if (Attr && Tok &&
-  SM.getSpellingLoc(Attr->getLocation()) == Tok->location()) {
+  if (Attr && TouchedIdentifier &&
+  SM.getSpellingLoc(Attr->getLocation()) ==
+  TouchedIdentifier->location()) {
 // We may be overridding multiple methods - offer them all.
 for (const NamedDecl *ND : CMD->overridden_methods())
   AddResultDecl(ND);
@@ -296,8 +297,9 @@
 
 // Special case: the point of declaration of a template specialization,
 // it's more useful to navigate to the template declaration.
-if (SM.getMacroArgExpandedLocation(D->getLocation()) == IdentStartLoc) {
-  if (auto *CTSD = dyn_cast(D)) {
+if (auto *CTSD = dyn_cast(D)) {
+  if (TouchedIdentifier &&
+  D->getLocation() == TouchedIdentifier->location()) {
 AddResultDecl(CTSD->getSpecializedTemplate());
 continue;
   }
@@ -416,12 +418,12 @@
   // FIXME: show references to macro within file?
   DeclRelationSet Relations =
   DeclRelation::TemplatePattern | DeclRelation::Alias;
-  auto References = findRefs(
-   

[PATCH] D75166: [clangd] Clean-up XRefs.cpp from Lexer usages and unnecessary SourceLoc transformations

2020-02-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:432
   auto References = findRefs(
-  getDeclAtPosition(AST,
-
SM.getMacroArgExpandedLocation(getBeginningOfIdentifier(
-Pos, SM, AST.getLangOpts())),
-Relations),
-  AST);
+  getDeclAtPosition(AST, IdentifierAtCursor->location(), Relations), AST);
 

sammccall wrote:
> apparently we don't have tests for non-identifier cases, but they did work. 
> let's keep them working for now :) CurLoc here
also get rid of the bail-out when no tokens were touched. (which means we can 
now possibly trigger on `^~Foo()`.)



Comment at: clang-tools-extra/clangd/XRefs.cpp:503
+auto Decls =
+getDeclAtPosition(AST, IdentifierAtCursor->location(), Relations);
 

sammccall wrote:
> again, CurLoc?
ah thanks for catching this one especially, it also means we don't need to bail 
out when there are no identifiers touching cursor(it is only necessary for 
macros).
Updated it to do that, PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75166



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


[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

2020-02-26 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Also, //errors// should conceptually break the operation at hand, so this thing 
should be a warning instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75171



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


[PATCH] D74692: [clang-tidy][bugprone-use-after-move] Warn on std::move for consts

2020-02-26 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis marked an inline comment as done.
zinovy.nis added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-use-after-move.cpp:329
   // CHECK-NOTES: [[@LINE-3]]:7: note: move occurred here
+  // CHECK-NOTES: [[@LINE-6]]:7: note: std::move of the const expression 
{{.*}}
 };

Quuxplusone wrote:
> It continues to seem silly to me that you give an extra note here saying that 
> line 325 doesn't do anything, when of course line 336 doesn't do anything 
> either (and you don't give any extra note there).
> 
> This clang-tidy warning isn't supposed to be about what //physically 
> happens// in the machine code during any particular compilation run; it's 
> supposed to be about helping the user avoid //semantic// bugs by cleaning up 
> their codebase's //logical// behavior. The rule is "don't use things after 
> moving from them," period.
> 
> Analogously, if there were a clang-tidy warning to say "always indent four 
> spaces after an `if`," and you proposed to add a note to some cases that said 
> "...but here a three-space indent is OK, because C++ is 
> whitespace-insensitive" — I'd also find //that// note to be mildly 
> objectionable. We want to train people to do the right thing, not to do the 
> right thing "except in this case because hey, it doesn't matter to the 
> machine."
Thanks for the feedback. I got your point. But my note (may be expressed with 
wrong words) is about that there're 2 ways to fix the issue: either get rid of 
'std::move' or somehow remove 'const'. That was the main purpose of my commit.


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

https://reviews.llvm.org/D74692



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


[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

2020-02-26 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

Do you have access to the `Driver` somehow? Instead of a `cerr` (-ish) output, 
something that is formatted like a "true" error diagnostic (or warning), such 
as `"no such file or directory"` would be much better, I fear this `[ERROR]` 
will simply be flooded away with the usual diagnostic output on screen, 
especially if multiple files are concerned.

Are you trying to land this before `10.0` goes out? In this case, it could be 
okay, but for the long term, this seems a very crude solution.




Comment at: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp:1037-1038
+llvm::errs() << "[ERROR] Checker " << mgr.getCurrentCheckerName().getName()
+ << " cannot be enabled without analyzer option aggressive-"
+"binary-operation-simplification.\n";
+return false;

In Clang diagnostics, "identifiers" are put between apostrophes:

'aggressive-binary-operation-simplification'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75171



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


  1   2   >