[PATCH] D97625: fix check-clang-tools tests that fail due to Windows CRLF line endings

2022-02-04 Thread Conrad Poelman via Phabricator via cfe-commits
poelmanc added a comment.

Sorry I somehow missed the acceptance back on 10 Jan. I lack commit access, it 
would be great if you could push for me, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97625

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


[PATCH] D117888: [clang][driver][wasm] Support -stdlib=libstdc++ for WebAssembly

2022-02-04 Thread cqwrteur via Phabricator via cfe-commits
expnkx reopened this revision.
expnkx added a comment.
This revision is now accepted and ready to land.

This patch is simply wrong.

cqwrteur@Home-Server:~/fast_io_cleanup/fast_io/examples/0001.helloworld$ 
clang++ -o helloworld helloworld.cc -Ofast -std=c++2b -s -flto -fuse-ld=lld 
--target=wasm32-wasi --sysroot=$HOME/toolchains/sysroot/wasm32-wasi 
-fno-exceptions -fno-rtti -fno-unwind-tables -fno-asynchronous-unwind-tables 
-I../../include -stdlib=libstdc++
In file included from helloworld.cc:1:
In file included from ../../include/fast_io.h:9:
In file included from ../../include/fast_io_hosted.h:17:
In file included from ../../include/fast_io_freestanding.h:12:
In file included from ../../include/fast_io_core.h:11:
In file included from ../../include/fast_io_concept.h:20:
In file included from 
/home/cqwrteur/toolchains/sysroot/wasm32-wasi/include/c++/12.0.1/concepts:44:
/home/cqwrteur/toolchains/sysroot/wasm32-wasi/include/c++/12.0.1/type_traits:38:10:
 fatal error: 'bits/c++config.h' file not found
#include 

  ^~

1 error generated.

It cannot find bits/c++config.h

wasm32-wasi\include\c++\12.0.1\wasm32-wasi\bits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117888

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


[PATCH] D113620: Skip exception cleanups when the innermost scope is EHTerminateScope.

2022-02-04 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Should be fixed by rGcaa1ebde70673ddb7124a0599ba846362a1f8b1e 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113620

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


[clang] caa1ebd - Don't assume that a new cleanup was added to InnermostEHScope.

2022-02-04 Thread James Y Knight via cfe-commits

Author: James Y Knight
Date: 2022-02-04T23:39:42-05:00
New Revision: caa1ebde70673ddb7124a0599ba846362a1f8b1e

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

LOG: Don't assume that a new cleanup was added to InnermostEHScope.

After fa87fa97fb79, this was no longer guaranteed to be the cleanup
just added by this code, if IsEHCleanup got disabled. Instead, use
stable_begin(), which _is_ guaranteed to be the cleanup just added.

This caused a crash when a object that is callee destroyed (e.g. with the MS 
ABI) was passed in a call from a noexcept function.

Added a test to verify.

Fixes: fa87fa97fb79

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a37ff8844e885..67a3f73525e35 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4331,7 +4331,7 @@ void CodeGenFunction::EmitCallArg(CallArgList , 
const Expr *E,
   type);
   // This unreachable is a temporary marker which will be removed later.
   llvm::Instruction *IsActive = Builder.CreateUnreachable();
-  args.addArgCleanupDeactivation(EHStack.getInnermostEHScope(), IsActive);
+  args.addArgCleanupDeactivation(EHStack.stable_begin(), IsActive);
 }
 return;
   }

diff  --git a/clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp 
b/clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
index 92fa17b145001..e6d602464d9b3 100644
--- a/clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
+++ b/clang/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp
@@ -32,6 +32,28 @@ void HasEHCleanup() {
 // WIN32-NOT: @"??1A@@QAE@XZ"
 // WIN32: }
 
+
+// This test verifies the fix for a crash that occurred after
+// fa87fa97fb79.
+void HasEHCleanupNoexcept() noexcept {
+  TakesTwo(getA(), getA());
+}
+
+// With exceptions, we need to clean up at least one of these temporaries.
+// WIN32-LABEL: define dso_local void @"?HasEHCleanupNoexcept@@YAXXZ"() {{.*}} 
{
+// WIN32:   %[[base:.*]] = call i8* @llvm.stacksave()
+// WIN32:   invoke void @"?getA@@YA?AUA@@XZ"(%struct.A* sret(%struct.A) align 
4 %{{.*}})
+// WIN32:   invoke void @"?getA@@YA?AUA@@XZ"(%struct.A* sret(%struct.A) align 
4 %{{.*}})
+// WIN32:   invoke noundef i32 @"?TakesTwo@@YAHUA@@0@Z"
+// WIN32:   call void @llvm.stackrestore
+// WIN32:   ret void
+//
+//Since all the calls terminate, there should be no dtors on the unwind
+// WIN32:   cleanuppad
+// WIN32-NOT: @"??1A@@QAE@XZ"
+// WIN32: }
+
+
 void TakeRef(const A );
 int HasDeactivatedCleanups() {
   return TakesTwo((TakeRef(A()), A()), (TakeRef(A()), A()));



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


[PATCH] D119051: Fix pod-packed functionality to use the C++11 definition of pod-ness

2022-02-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D119051#3298491 , @dblaikie wrote:

> Test case showing GCC's behavior here: https://godbolt.org/z/4W7j8Yd54

Oh, and demonstrating this applies (as best as I can figure) even when 
compiling in C++03 mode: https://godbolt.org/z/9eqbThrKs (but perhaps there are 
otther differences between 03 and 11 POD I could test?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

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


[PATCH] D119051: Fix pod-packed functionality to use the C++11 definition of pod-ness

2022-02-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Test case showing GCC's behavior here: https://godbolt.org/z/4W7j8Yd54


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

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


[PATCH] D117616: GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs

2022-02-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Hmm, I guess it might be the C++11 definition, as suggested - since a base 
class (even a public one) seems to classify the type as "non pod" as far as GCC 
is concerned (

In D117616#3298001 , @dblaikie wrote:

> In D117616#3295859 , @Bhramar.vatsa 
> wrote:
>
>> @dblaikie 
>> The condition `FieldClass->isPOD()` returns false for the following case 
>> (when considering field 'struct foo t' of 'struct foo1') :
>>
>>   class foo {
>>  foo() = default;
>>  int _a;
>>   };
>>   
>>   struct foo1 {
>>   struct foo t;
>>   } t1;
>>
>> The same code though doesn't give any warning for gcc: 
>> https://godbolt.org/z/f4chraerY
>>
>> This is because the way it works for CXXRecordDecl : 
>> https://github.com/llvm/llvm-project/blob/1e3a02162db20264e9615b1346420c8d199cb347/clang/lib/AST/DeclCXX.cpp#L928
>>
>> So, there seems to be a difference the way GCC is handling this case, in 
>> comparison to how now clang handles it.
>>
>> For the same case, `D->getType().isCXX11PODType()` (or `isPODType()`) 
>> indicates it to be a POD type. So, we think that this should be further 
>> changed such that it doesn't break the code that works with GCC.
>
> Sorry, was a bit confused by the discussion of warnings and such - but, yes, 
> this does seem to be a remaining divergence in the layout between Clang 
> (after this patch was committed) and GCC: https://godbolt.org/z/GEM5q4fd3
>
> @rsmith do you have a semi-exhaustive list of the variations in POD-ness I 
> should probably test to better understand which definition GCC is using here? 
> Reading the cppreference on POD, aggregate, standard layout, and trivial 
> there are a lot of dimensions and I was wondering if you had a quick-ish 
> summary so I hopefully don't miss cases & figure out exactly how this is 
> meant to be sliced?
>
> I'll work on some godbolt probes/test cases for now to see what I can come up 
> with.

Posted https://reviews.llvm.org/D119051 at least with the existing test case - 
thanks for that!

Open to more robust test case suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117616

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


[PATCH] D119051: Fix pod-packed functionality to use the C++11 definition of pod-ness

2022-02-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie created this revision.
dblaikie added reviewers: rsmith, Bhramar.vatsa, rjmccall, rnk.
dblaikie requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119051

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/SemaCXX/class-layout.cpp


Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -641,3 +641,14 @@
 _Static_assert(_Alignof(t1) == 1, "");
 _Static_assert(_Alignof(t2) == 1, "");
 } // namespace non_pod_packed
+
+namespace cxx11_pod {
+struct t1 {
+  t1() = default;
+  int a;
+};
+struct t2 {
+  t1 v1;
+} __attribute__((packed));
+_Static_assert(_Alignof(t2) == 1, "");
+}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1888,11 +1888,12 @@
   LastBitfieldStorageUnitSize = 0;
 
   llvm::Triple Target = Context.getTargetInfo().getTriple();
-  bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
- Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver13 ||
- Target.isPS4() || Target.isOSDarwin())) ||
- D->hasAttr();
+  bool FieldPacked =
+  (Packed && (!FieldClass || D->getType().isCXX11PODType(Context) ||
+  Context.getLangOpts().getClangABICompat() <=
+  LangOptions::ClangABI::Ver13 ||
+  Target.isPS4() || Target.isOSDarwin())) ||
+  D->hasAttr();
 
   AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;


Index: clang/test/SemaCXX/class-layout.cpp
===
--- clang/test/SemaCXX/class-layout.cpp
+++ clang/test/SemaCXX/class-layout.cpp
@@ -641,3 +641,14 @@
 _Static_assert(_Alignof(t1) == 1, "");
 _Static_assert(_Alignof(t2) == 1, "");
 } // namespace non_pod_packed
+
+namespace cxx11_pod {
+struct t1 {
+  t1() = default;
+  int a;
+};
+struct t2 {
+  t1 v1;
+} __attribute__((packed));
+_Static_assert(_Alignof(t2) == 1, "");
+}
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1888,11 +1888,12 @@
   LastBitfieldStorageUnitSize = 0;
 
   llvm::Triple Target = Context.getTargetInfo().getTriple();
-  bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() ||
- Context.getLangOpts().getClangABICompat() <=
- LangOptions::ClangABI::Ver13 ||
- Target.isPS4() || Target.isOSDarwin())) ||
- D->hasAttr();
+  bool FieldPacked =
+  (Packed && (!FieldClass || D->getType().isCXX11PODType(Context) ||
+  Context.getLangOpts().getClangABICompat() <=
+  LangOptions::ClangABI::Ver13 ||
+  Target.isPS4() || Target.isOSDarwin())) ||
+  D->hasAttr();
 
   AlignRequirementKind AlignRequirement = AlignRequirementKind::None;
   CharUnits FieldSize;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113620: Skip exception cleanups when the innermost scope is EHTerminateScope.

2022-02-04 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Found the problem, tweaking a test-case; will commit shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113620

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


[PATCH] D116753: [Driver] Default to -fno-math-errno for musl too

2022-02-04 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG38449c98f3d3: [Driver] Default to -fno-math-errno for musl 
(authored by alxu, committed by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116753

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/fast-math.c


Index: clang/test/Driver/fast-math.c
===
--- clang/test/Driver/fast-math.c
+++ clang/test/Driver/fast-math.c
@@ -119,6 +119,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-musl -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target amdgcn-amd-amdhsa -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target amdgcn-amd-amdpal -c %s 2>&1 \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -687,7 +687,7 @@
 }
 
 bool Linux::IsMathErrnoDefault() const {
-  if (getTriple().isAndroid())
+  if (getTriple().isAndroid() || getTriple().isMusl())
 return false;
   return Generic_ELF::IsMathErrnoDefault();
 }


Index: clang/test/Driver/fast-math.c
===
--- clang/test/Driver/fast-math.c
+++ clang/test/Driver/fast-math.c
@@ -119,6 +119,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-musl -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target amdgcn-amd-amdhsa -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target amdgcn-amd-amdpal -c %s 2>&1 \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -687,7 +687,7 @@
 }
 
 bool Linux::IsMathErrnoDefault() const {
-  if (getTriple().isAndroid())
+  if (getTriple().isAndroid() || getTriple().isMusl())
 return false;
   return Generic_ELF::IsMathErrnoDefault();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 38449c9 - [Driver] Default to -fno-math-errno for musl

2022-02-04 Thread Fangrui Song via cfe-commits

Author: Alex Xu (Hello71)
Date: 2022-02-04T19:20:30-08:00
New Revision: 38449c98f3d33dffdaf7e1feeb9dfdcf63b5126b

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

LOG: [Driver] Default to -fno-math-errno for musl

musl does not set errno in math functions: 
https://wiki.musl-libc.org/mathematical-library.html, 
https://git.musl-libc.org/cgit/musl/tree/include/math.h?id=cfdfd5ea3ce14c6abf7fb22a531f3d99518b5a1b#n26.

Reviewed By: srhines, MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/fast-math.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index af74b108e04e..f85c04df4f6c 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -687,7 +687,7 @@ bool Linux::IsAArch64OutlineAtomicsDefault(const ArgList 
) const {
 }
 
 bool Linux::IsMathErrnoDefault() const {
-  if (getTriple().isAndroid())
+  if (getTriple().isAndroid() || getTriple().isMusl())
 return false;
   return Generic_ELF::IsMathErrnoDefault();
 }

diff  --git a/clang/test/Driver/fast-math.c b/clang/test/Driver/fast-math.c
index a66e9d0eca17..36ea8ecb5298 100644
--- a/clang/test/Driver/fast-math.c
+++ b/clang/test/Driver/fast-math.c
@@ -119,6 +119,8 @@
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target x86_64-linux-android -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
+// RUN: %clang -### -target x86_64-linux-musl -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target amdgcn-amd-amdhsa -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s
 // RUN: %clang -### -target amdgcn-amd-amdpal -c %s 2>&1 \



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


[PATCH] D118965: [OpenMP] Add search path for llvm-strip

2022-02-04 Thread Kelvin Li via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ea4aed50a9f: [OpenMP] Add search path for llvm-strip 
(authored by kkwli0).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118965

Files:
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -310,7 +310,13 @@
 
   // We will use llvm-strip to remove the now unneeded section containing the
   // offloading code.
-  ErrorOr StripPath = sys::findProgramByName("llvm-strip");
+  void *P = (void *)(intptr_t)
+  StringRef COWDir = "";
+  auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
+  if (!COWPath.empty())
+COWDir = sys::path::parent_path(COWPath);
+  ErrorOr StripPath =
+  sys::findProgramByName("llvm-strip", {COWDir});
   if (!StripPath)
 return createStringError(StripPath.getError(),
  "Unable to find 'llvm-strip' in path");


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -310,7 +310,13 @@
 
   // We will use llvm-strip to remove the now unneeded section containing the
   // offloading code.
-  ErrorOr StripPath = sys::findProgramByName("llvm-strip");
+  void *P = (void *)(intptr_t)
+  StringRef COWDir = "";
+  auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
+  if (!COWPath.empty())
+COWDir = sys::path::parent_path(COWPath);
+  ErrorOr StripPath =
+  sys::findProgramByName("llvm-strip", {COWDir});
   if (!StripPath)
 return createStringError(StripPath.getError(),
  "Unable to find 'llvm-strip' in path");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8ea4aed - [OpenMP] Add search path for llvm-strip

2022-02-04 Thread Kelvin Li via cfe-commits

Author: Kelvin Li
Date: 2022-02-04T22:15:14-05:00
New Revision: 8ea4aed50a9f84d9617219ccc936c005c5f31c24

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

LOG: [OpenMP] Add search path for llvm-strip

Add the build directory to the search path for llvm-strip instead
of solely relying on the PATH environment variable setting.

Reviewed By: jhuber6

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

Added: 


Modified: 
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index de0af187731d3..2f5ddb77b7b3f 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -310,7 +310,13 @@ extractFromBinary(const ObjectFile ,
 
   // We will use llvm-strip to remove the now unneeded section containing the
   // offloading code.
-  ErrorOr StripPath = sys::findProgramByName("llvm-strip");
+  void *P = (void *)(intptr_t)
+  StringRef COWDir = "";
+  auto COWPath = sys::fs::getMainExecutable("llvm-strip", P);
+  if (!COWPath.empty())
+COWDir = sys::path::parent_path(COWPath);
+  ErrorOr StripPath =
+  sys::findProgramByName("llvm-strip", {COWDir});
   if (!StripPath)
 return createStringError(StripPath.getError(),
  "Unable to find 'llvm-strip' in path");



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


[PATCH] D116753: [Driver] Default to -fno-math-errno for musl too

2022-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I am testing check-clang-driver and will cherry pick this into release/14.x.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116753

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


[PATCH] D116753: [Driver] Default to -fno-math-errno for musl too

2022-02-04 Thread Alex Xu (Hello71) via Phabricator via cfe-commits
alxu added a comment.

In D116753#3298299 , @pirama wrote:

> @alxu Just realized you don't have commit access.  Do you want one of us to 
> merge this?

Yes, I forgot about this patch. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116753

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


[clang] 280716e - [OpenMP] Change amdgcn to amdgpu in device library handling

2022-02-04 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-04T20:51:05-05:00
New Revision: 280716e75f76820f1c8b7c13812c96237dc4bcc5

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

LOG: [OpenMP] Change amdgcn to amdgpu in device library handling

Summary:
The name of the AMDGPU device library was changes. Previously it was
called 'libomptarget-amdgcn'. This patch changes fixes the tests to use
the new name of the library and adds a new flag with the same name.

Added: 
clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc
clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx906.bc

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c

Removed: 
clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc
clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx906.bc



diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 1dc52b8474d63..a01ba7bda9e3b 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1232,9 +1232,9 @@ Set directory to include search path with prefix
 
 Add directory to SYSTEM include search path, absolute paths are relative to 
-isysroot
 
-.. option:: --libomptarget-amdgcn-bc-path=
+.. option:: --libomptarget-amdgpu-bc-path=
 
-Path to libomptarget-amdgcn bitcode library
+Path to libomptarget-amdgpu bitcode library
 
 .. option:: --libomptarget-nvptx-bc-path=
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c57d9cde094de..25612d2bc24e9 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1033,8 +1033,10 @@ def fuse_cuid_EQ : Joined<["-"], "fuse-cuid=">,
"file path and command line options) | 'random' (ID's generated as "
"random numbers) | 'none' (disabled). Default is 'hash'. This 
option "
"will be overridden by option '-cuid=[ID]' if it is specified." >;
-def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], 
"libomptarget-amdgcn-bc-path=">, Group,
+def libomptarget_amdgpu_bc_path_EQ : Joined<["--"], 
"libomptarget-amdgpu-bc-path=">, Group,
   HelpText<"Path to libomptarget-amdgcn bitcode library">;
+def libomptarget_amdgcn_bc_path_EQ : Joined<["--"], 
"libomptarget-amdgcn-bc-path=">, Group,
+  HelpText<"Path to libomptarget-amdgcn bitcode library">, 
Alias;
 def libomptarget_nvptx_bc_path_EQ : Joined<["--"], 
"libomptarget-nvptx-bc-path=">, Group,
   HelpText<"Path to libomptarget-nvptx bitcode library">;
 def dD : Flag<["-"], "dD">, Group, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index a6a4997f71297..8addee22a2bd3 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2013,7 +2013,7 @@ void tools::addOpenMPDeviceRTL(const Driver ,
   }
 
   OptSpecifier LibomptargetBCPathOpt =
-  Triple.isAMDGCN() ? options::OPT_libomptarget_amdgcn_bc_path_EQ
+  Triple.isAMDGCN() ? options::OPT_libomptarget_amdgpu_bc_path_EQ
 : options::OPT_libomptarget_nvptx_bc_path_EQ;
 
   StringRef ArchPrefix = Triple.isAMDGCN() ? "amdgcn" : "nvptx";

diff  --git 
a/clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc 
b/clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc
similarity index 100%
rename from clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx803.bc
rename to clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc

diff  --git 
a/clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx906.bc 
b/clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx906.bc
similarity index 100%
rename from clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgcn-gfx906.bc
rename to clang/test/Driver/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx906.bc

diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain.c 
b/clang/test/Driver/amdgpu-openmp-toolchain.c
index 78fee12a5a98c..0d50411f24881 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -1,12 +1,12 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: amdgpu-registered-target
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx906 --libomptarget-amdgcn-bc-path=%S/Inputs/hip_dev_lib %s 2>&1 \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp 
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa 
-march=gfx906 

[PATCH] D110663: [Driver] Support Debian multiarch style lib/clang/14.0.0/x86_64-linux-gnu runtime path and include/x86_64-linux-gnu/c++/v1 libc++ path

2022-02-04 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping @phosek


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110663

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


[PATCH] D119026: [HIP] Emit amdgpu_code_object_version module flag

2022-02-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:575
+// times 100.
+if (getTarget().getTargetOpts().CodeObjectVersion != "none") {
+  unsigned CodeObjVer;

yaxunl wrote:
> tra wrote:
> > When will it ever be set to `none`? Does the new option parser enforce the 
> > default & version values specified in the tablegen?
> > If so, then it should never be `none`.
> > If the `Values` specified for the option are not enforced, then the 
> > condition will be true if user specifies any invalid value other than 
> > `none`.
> > 
> Normal HIP programs should only use `-mcode-object-version={2|3|4|5}`. clang 
> driver enforces that.
> 
> ROCm device library need to be compiled with `-Xclang 
> -mcode-object-version=none` so that the module flag is not emitted. Since 
> this use case is not for common users,  `-mcode-object-version=none` can only 
> be used with -cc1.
I'm surprised that cc1 does not check option validity. It does check them at 
the driver level: https://godbolt.org/z/9T6n47es9

Assuming that's intentional, and there are no checks in cc1, then we should 
probably remove the now-useless `Values` from the option tablegen and add a 
test to verify what happens with invalid values.




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

https://reviews.llvm.org/D119026

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


[PATCH] D59254: [RFC] Implementation of Clang randstruct

2022-02-04 Thread Connor Kuehl via Phabricator via cfe-commits
connorkuehl added a comment.

In D59254#3298184 , @void wrote:

> In D59254#1792134 , @connorkuehl 
> wrote:
>
>> In D59254#1792068 , @xbolva00 wrote:
>>
>>> Re-ping
>>
>> Still under development here: 
>> https://github.com/connorkuehl/llvm-project/tree/randstruct
>
> Hi @connorkuehl,
>
> I was asked by @kees to take a look at implementing this, with the view to 
> support it in the Linux kernel. There doesn't seem to have been a lot of work 
> on this recently. Is it effectively in limbo at the moment?

@void Cool! Yeah, I haven't done anything with this. The git tree in the quoted 
comment (https://github.com/connorkuehl/llvm-project/tree/randstruct) does have 
a lot more progress compared to this Phabricator submission in terms of some 
bug fixes and unit test coverage, though there's still room for improvement in 
terms of performance (and possibly correctness, iirc compiling Linux segfaulted 
Clang with those patches). Furthermore, the patchset is quite old, so I would 
be entirely shocked if it applied without much fuss on a recent LLVM tree. As 
you can see, the latest commit was in late 2019.

Best of luck! I hope at least some of it is helpful to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59254

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


[PATCH] D119045: Fix address space for function types with AS qualifier

2022-02-04 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews created this revision.
eandrews added reviewers: rjmccall, dylanmckay, bader.
eandrews requested review of this revision.

This patch fixes a bug introduced in commit 4eaf5846d0e7 
 - 
https://reviews.llvm.org/D111566

Commit 4eaf5846d0e7 
 sets 
address space of function type as program address space unconditionally. This 
breaks types which have address space qualifiers. E.g. __ptr32.

This patch fixes the bug by using address space qualifiers if present.


https://reviews.llvm.org/D119045

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGen/address-space-ptr32.c


Index: clang/test/CodeGen/address-space-ptr32.c
===
--- /dev/null
+++ clang/test/CodeGen/address-space-ptr32.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm < %s 
| FileCheck %s
+
+int foo() {
+  int (*__ptr32 a)(int);
+  return sizeof(a);
+}
+
+// CHECK: define dso_local i32 @foo
+// CHECK: %a = alloca i32 (i32) addrspace(270)*, align 4
+// CHECK: ret i32 4
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11959,8 +11959,11 @@
 }
 
 unsigned ASTContext::getTargetAddressSpace(QualType T) const {
-  return T->isFunctionType() ? getTargetInfo().getProgramAddressSpace()
- : getTargetAddressSpace(T.getQualifiers());
+  // For function type, return program address space, unless
+  // type has address space qualifier
+  return T->isFunctionType() && !T.hasAddressSpace()
+ ? getTargetInfo().getProgramAddressSpace()
+ : getTargetAddressSpace(T.getQualifiers());
 }
 
 unsigned ASTContext::getTargetAddressSpace(Qualifiers Q) const {


Index: clang/test/CodeGen/address-space-ptr32.c
===
--- /dev/null
+++ clang/test/CodeGen/address-space-ptr32.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm < %s | FileCheck %s
+
+int foo() {
+  int (*__ptr32 a)(int);
+  return sizeof(a);
+}
+
+// CHECK: define dso_local i32 @foo
+// CHECK: %a = alloca i32 (i32) addrspace(270)*, align 4
+// CHECK: ret i32 4
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11959,8 +11959,11 @@
 }
 
 unsigned ASTContext::getTargetAddressSpace(QualType T) const {
-  return T->isFunctionType() ? getTargetInfo().getProgramAddressSpace()
- : getTargetAddressSpace(T.getQualifiers());
+  // For function type, return program address space, unless
+  // type has address space qualifier
+  return T->isFunctionType() && !T.hasAddressSpace()
+ ? getTargetInfo().getProgramAddressSpace()
+ : getTargetAddressSpace(T.getQualifiers());
 }
 
 unsigned ASTContext::getTargetAddressSpace(Qualifiers Q) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116753: [Driver] Default to -fno-math-errno for musl too

2022-02-04 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama added a comment.

@alxu Just realized you don't have commit access.  Do you want one of us to 
merge this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116753

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


[PATCH] D118876: [HIPSPV] Fix literals are mapped to Generic address space

2022-02-04 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

@yaxunl This looks good to me, you can go ahead and cherry-pick it directly to 
release/14.x.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118876

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


[PATCH] D118876: [HIPSPV] Fix literals are mapped to Generic address space

2022-02-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a subscriber: tstellar.
yaxunl added a comment.

In D118876#3295958 , @linjamaki wrote:

> Thanks for the review, @yaxunl. Could you push this to the LLVM? And to the 
> LLVM 14 release branch too, if possible?

Sure. @tstellar What is the current procedure for cherry-picking a fix to a 
release branch? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118876

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


[PATCH] D119026: [HIP] Emit amdgpu_code_object_version module flag

2022-02-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:575
+// times 100.
+if (getTarget().getTargetOpts().CodeObjectVersion != "none") {
+  unsigned CodeObjVer;

tra wrote:
> When will it ever be set to `none`? Does the new option parser enforce the 
> default & version values specified in the tablegen?
> If so, then it should never be `none`.
> If the `Values` specified for the option are not enforced, then the condition 
> will be true if user specifies any invalid value other than `none`.
> 
Normal HIP programs should only use `-mcode-object-version={2|3|4|5}`. clang 
driver enforces that.

ROCm device library need to be compiled with `-Xclang 
-mcode-object-version=none` so that the module flag is not emitted. Since this 
use case is not for common users,  `-mcode-object-version=none` can only be 
used with -cc1.


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

https://reviews.llvm.org/D119026

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


[PATCH] D118471: [clang][Lexer] Make raw and normal lexer behave the same for line comments

2022-02-04 Thread Paul Robinson via Phabricator via cfe-commits
probinson added inline comments.



Comment at: clang/unittests/Lex/LexerTest.cpp:654
+  while (!L.LexFromRawLexer(T)) {
+ASSERT_TRUE(!ToksView.empty());
+EXPECT_EQ(T.getKind(), ToksView.front().getKind());

@kadircet  @sammccall  It turns out this while loop is zero-trip; the test 
assertions in the body are never executed.  Replace it with `assert(false);` 
and the test doesn't crash.

That means `ToksView` is empty from the start.  This is probably not what you 
wanted?

In other words, the test does not exercise the patch.  This is pretty serious.  
It needs to be fixed or reverted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118471

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


[clang-tools-extra] fb7ddd0 - Revert "[clangd] Properly compute framework-style include spelling"

2022-02-04 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-02-04T18:02:32-05:00
New Revision: fb7ddd0628f4894f9d14a2d1f84830607c5f946e

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

LOG: Revert "[clangd] Properly compute framework-style include spelling"

This reverts commit 4dfd11324eb05d167392958c0f0f273cae6386c6
due to the failures on Linux CI:
https://lab.llvm.org/buildbot/#/builders/188/builds/9296

Added: 


Modified: 
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 7ae77d35ad7a1..3257041ffa0e3 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -183,13 +183,6 @@ const Decl *getRefContainer(const Decl *Enclosing,
 // including filename normalization, URI conversion etc.
 // Expensive checks are cached internally.
 class SymbolCollector::HeaderFileURICache {
-  struct FrameworkUmbrellaSpelling {
-// Spelling for the public umbrella header, e.g. 
-llvm::Optional PublicHeader;
-// Spelling for the private umbrella header, e.g.
-// 
-llvm::Optional PrivateHeader;
-  };
   // Weird double-indirect access to PP, which might not be ready yet when
   // HeaderFiles is created but will be by the time it's used.
   // (IndexDataConsumer::setPreprocessor can happen before or after initialize)
@@ -200,9 +193,6 @@ class SymbolCollector::HeaderFileURICache {
   llvm::DenseMap CacheFEToURI;
   llvm::StringMap CachePathToURI;
   llvm::DenseMap CacheFIDToInclude;
-  llvm::StringMap CachePathToFrameworkSpelling;
-  llvm::StringMap
-  CacheFrameworkToUmbrellaHeaderSpelling;
 
 public:
   HeaderFileURICache(Preprocessor *, const SourceManager ,
@@ -259,125 +249,6 @@ class SymbolCollector::HeaderFileURICache {
 return R.first->second;
   }
 
-  struct FrameworkHeaderPath {
-// Path to the framework directory containing the Headers/PrivateHeaders
-// directories  e.g. /Frameworks/Foundation.framework/
-llvm::StringRef HeadersParentDir;
-// Subpath relative to the Headers or PrivateHeaders dir, e.g. NSObject.h
-// Note: This is NOT relative to the `HeadersParentDir`.
-llvm::StringRef HeaderSubpath;
-// Whether this header is under the PrivateHeaders dir
-bool IsPrivateHeader;
-  };
-
-  llvm::Optional
-  splitFrameworkHeaderPath(llvm::StringRef Path) {
-using namespace llvm::sys;
-path::reverse_iterator I = path::rbegin(Path);
-path::reverse_iterator Prev = I;
-path::reverse_iterator E = path::rend(Path);
-while (I != E) {
-  if (*I == "Headers") {
-FrameworkHeaderPath HeaderPath;
-HeaderPath.HeadersParentDir = Path.substr(0, I - E);
-HeaderPath.HeaderSubpath = Path.substr(Prev - E);
-return HeaderPath;
-  }
-  if (*I == "PrivateHeaders") {
-FrameworkHeaderPath HeaderPath;
-HeaderPath.HeadersParentDir = Path.substr(0, I - E);
-HeaderPath.HeaderSubpath = Path.substr(Prev - E);
-HeaderPath.IsPrivateHeader = true;
-return HeaderPath;
-  }
-  Prev = I;
-  ++I;
-}
-// Unexpected, must not be a framework header.
-return llvm::None;
-  }
-
-  // Frameworks typically have an umbrella header of the same name, e.g.
-  //  instead of  or
-  //  instead of
-  //  which should be used instead of directly
-  // importing the header.
-  llvm::Optional getFrameworkUmbrellaSpelling(
-  llvm::StringRef Framework, SrcMgr::CharacteristicKind HeadersDirKind,
-  HeaderSearch , FrameworkHeaderPath ) {
-auto Res = CacheFrameworkToUmbrellaHeaderSpelling.try_emplace(Framework);
-auto *CachedSpelling = >second;
-if (!Res.second) {
-  return HeaderPath.IsPrivateHeader ? CachedSpelling->PrivateHeader
-: CachedSpelling->PublicHeader;
-}
-bool IsSystem = isSystem(HeadersDirKind);
-SmallString<256> UmbrellaPath(HeaderPath.HeadersParentDir);
-llvm::sys::path::append(UmbrellaPath, "Headers", Framework + ".h");
-
-llvm::vfs::Status Status;
-auto StatErr = HS.getFileMgr().getNoncachedStatValue(UmbrellaPath, Status);
-if (!StatErr) {
-  if (IsSystem)
-CachedSpelling->PublicHeader = llvm::formatv("<{0}/{0}.h>", Framework);
-  else
-CachedSpelling->PublicHeader =
-llvm::formatv("\"{0}/{0}.h\"", Framework);
-}
-
-UmbrellaPath = HeaderPath.HeadersParentDir;
-llvm::sys::path::append(UmbrellaPath, "PrivateHeaders",
-Framework + "_Private.h");
-
-StatErr = HS.getFileMgr().getNoncachedStatValue(UmbrellaPath, Status);
-if 

[PATCH] D59254: [RFC] Implementation of Clang randstruct

2022-02-04 Thread Bill Wendling via Phabricator via cfe-commits
void added subscribers: kees, void.
void added a comment.
Herald added a subscriber: dang.

In D59254#1792134 , @connorkuehl wrote:

> In D59254#1792068 , @xbolva00 wrote:
>
>> Re-ping
>
> Still under development here: 
> https://github.com/connorkuehl/llvm-project/tree/randstruct

Hi @connorkuehl,

I was asked by @kees to take a look at implementing this, with the view to 
support it in the Linux kernel. There doesn't seem to have been a lot of work 
on this recently. Is it effectively in limbo at the moment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59254

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


[clang-tools-extra] 6abb70c - Attempt forward fix after 4dfd113

2022-02-04 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-02-04T17:47:38-05:00
New Revision: 6abb70c2d00812350153f4299a2491fdc3810ac3

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

LOG: Attempt forward fix after 4dfd113

If this doesn't work will just revert the change,
can't seem to repro on macOS.

Added: 


Modified: 
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp 
b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index 1b934bd2342eb..7c1e1a96db003 100644
--- a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -675,14 +675,11 @@ TEST_F(SymbolCollectorTest, ObjCFrameworkIncludeHeader) {
   testPath("Frameworks/Foundation.framework/Headers/NSObject.h"), 0,
   llvm::MemoryBuffer::getMemBuffer(FrameworkHeader));
   std::string PrivateFrameworkHeader = R"(
-#import 
+#import 
 
 @interface PrivateClass : NSObject
 @end
   )";
-  InMemoryFileSystem->addFile(
-  testPath("Frameworks/Foundation.framework/Headers/NSObject.h"), 0,
-  llvm::MemoryBuffer::getMemBuffer(FrameworkHeader));
   InMemoryFileSystem->addFile(
   testPath(
   "Frameworks/Foundation.framework/PrivateHeaders/NSObject+Private.h"),



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


[PATCH] D119040: Fix LookupTest where it was missing an assertion

2022-02-04 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

By "the EXPECT_EQ was never executed" I mean, replacing it with 
`assert(false);` does not crash the test.  The string `"a::b::Foo"` was never 
seen by the Visitor.

Maybe this indicates some much more subtle, deeper problem; I don't know.  This 
change does cause the EXPECT_EQ to be executed, though.


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

https://reviews.llvm.org/D119040

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


[PATCH] D119040: Fix LookupTest where it was missing an assertion

2022-02-04 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added a reviewer: ioeric.
probinson requested review of this revision.

The preceding EXPECT_EQ was never executed; modifying the test input
made that happen.

Found by the Rotten Green Tests project.


https://reviews.llvm.org/D119040

Files:
  clang/unittests/Tooling/LookupTest.cpp


Index: clang/unittests/Tooling/LookupTest.cpp
===
--- clang/unittests/Tooling/LookupTest.cpp
+++ clang/unittests/Tooling/LookupTest.cpp
@@ -210,7 +210,7 @@
 }
   };
   Visitor.runOver("namespace a { namespace b { class Foo {}; } }\n"
-  "namespace c { using a::b::Foo; Foo f();; }\n");
+  "namespace c { a::b::Foo f();; }\n");
 
   // Rename TypeLoc `x::y::Old` to new name `x::Foo` at [0] and check that the
   // type is replaced with "Foo" instead of "x::Foo". Although there is a 
symbol


Index: clang/unittests/Tooling/LookupTest.cpp
===
--- clang/unittests/Tooling/LookupTest.cpp
+++ clang/unittests/Tooling/LookupTest.cpp
@@ -210,7 +210,7 @@
 }
   };
   Visitor.runOver("namespace a { namespace b { class Foo {}; } }\n"
-  "namespace c { using a::b::Foo; Foo f();; }\n");
+  "namespace c { a::b::Foo f();; }\n");
 
   // Rename TypeLoc `x::y::Old` to new name `x::Foo` at [0] and check that the
   // type is replaced with "Foo" instead of "x::Foo". Although there is a symbol
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118985: [flang][driver] Add support for `-emit-mlir`

2022-02-04 Thread Eric Schweitz via Phabricator via cfe-commits
schweitz accepted this revision.
schweitz added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: flang/include/flang/Frontend/FrontendActions.h:150
+//===--===//
+class CodeGenAction : public FrontendAction {
+

This appears in a header file. Should there be doxygen comments?



Comment at: flang/include/flang/Frontend/FrontendActions.h:160
+  std::unique_ptr mlirModule_;
+  std::unique_ptr mlirCtx_;
+  /// }

The LLVM coding conventions do not require trailing undescores.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118985

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-04 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Woow, that's a mountain of work!
All my comments are non-blocking.




Comment at: clang/docs/ClangFormatStyleOptions.rst:1992
+**BreakBeforeConceptDeclarations** (``BreakBeforeConceptDeclarationsStyle``) 
:versionbadge:`clang-format 13`
+  The style wether before ``concept`` declarations should be broken.
 





Comment at: clang/docs/ClangFormatStyleOptions.rst:1997
+  * ``BBCDS_Never`` (in configuration: ``Never``)
+Never break, put them in the template declaration line.
+





Comment at: clang/docs/ClangFormatStyleOptions.rst:2004-2005
+  * ``BBCDS_Allowed`` (in configuration: ``Allowed``)
+It can be broken, but doesn't have to. The actual behavior depends on
+the content and line breaking rules and penalities.
+





Comment at: clang/docs/ClangFormatStyleOptions.rst:2008
+  * ``BBCDS_Always`` (in configuration: ``Always``)
+Always break, put them in the line after the template declaration.
+





Comment at: clang/docs/ClangFormatStyleOptions.rst:2708-2709
+**IndentRequiresClause** (``Boolean``) :versionbadge:`clang-format 13`
+  Indent the requires clause in a template. This only applies
+  ``RequiresClausePosition`` is ``OwnLine``, or ``ToFollowing``.
 





Comment at: clang/docs/ClangFormatStyleOptions.rst:3498
+  * ``RCPS_OwnLine`` (in configuration: ``OwnLine``)
+The clause always gets its own line.
+





Comment at: clang/docs/ClangFormatStyleOptions.rst:3515
+
+  * ``RCPS_ToPreceding`` (in configuration: ``ToPreceding``)
+The clause tries to stick to the template declaration in case of class

Maybe `WithPreceding` makes a little more sense without context?



Comment at: clang/docs/ClangFormatStyleOptions.rst:3516-3518
+The clause tries to stick to the template declaration in case of class
+templates or between template and function declarations. In case of
+after the function declaration it tries to stick to this.

Just a suggestion, I'm not a writer. I'd just like to see something clear and 
comprehensible.



Comment at: clang/docs/ClangFormatStyleOptions.rst:3532
+
+  * ``RCPS_ToFollowing`` (in configuration: ``ToFollowing``)
+The clause tries to stick to the class respectively function





Comment at: clang/docs/ClangFormatStyleOptions.rst:3533-3534
+  * ``RCPS_ToFollowing`` (in configuration: ``ToFollowing``)
+The clause tries to stick to the class respectively function
+declaration.
+





Comment at: clang/docs/ClangFormatStyleOptions.rst:3549-3550
+  * ``RCPS_SingleLine`` (in configuration: ``SingleLine``)
+The clause tries to get everything in the same line, if it doesn't fit
+normal line breaking rules decide to which part it sticks.
+

I'm really not fond of writing that "clauses try to do something" :).



Comment at: clang/docs/ClangFormatStyleOptions.rst:3554-3558
+  template requires C struct Foo {...
+
+  template requires C void bar(T t) {...
+
+  template void bar(T t) requires C {...

It would be cool to have an example with long template, long parameter list and 
a long requires clause too.



Comment at: clang/docs/ReleaseNotes.rst:157
 
+- **Important Change** Renamed ``IndentRequires`` to ``IndentRequiresClause``
+  and changed the default for all styles from ``false`` to ``true``.





Comment at: clang/lib/Format/ContinuationIndenter.cpp:484
 // different LineFormatter would be used otherwise.
-if (Previous.ClosesTemplateDeclaration)
+// *: Except when antoher option does interfere with that, like concepts.
+if (Previous.ClosesTemplateDeclaration) {





Comment at: clang/lib/Format/ContinuationIndenter.cpp:1499-1500
+  if (State.NextToken->ClosesRequiresClause && Style.IndentRequiresClause) {
+// Remove the indentation of the requires clauses (which is not in Indent,
+// but in LastSpace).
+State.Stack.back().LastSpace -= Style.IndentWidth;

And why it is not in `Indent`?



Comment at: clang/lib/Format/TokenAnnotator.cpp:3900-3908
+  if (Right.is(TT_RequiresClause)) {
+switch (Style.RequiresClausePosition) {
+case FormatStyle::RCPS_OwnLine:
+case FormatStyle::RCPS_ToFollowing:
+  return true;
+default:
+  break;

The body of seems to be the exact same code as below in lines 3920-3926.
Maybe you can refactor to something like this?
Name of the lambda in my suggestion is maybe incorrect though.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3919-3927
+  if (Left.ClosesRequiresClause) {
+switch 

[PATCH] D118070: Make lld-link work in a non-MSVC shell

2022-02-04 Thread Peter Kasting via Phabricator via cfe-commits
pkasting updated this revision to Diff 406101.
Herald added a reviewer: MaskRay.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118070

Files:
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/lib/Driver/ToolChains/MSVC.h
  clang/lib/Driver/ToolChains/MSVCSetupApi.h
  lld/COFF/Driver.cpp
  lld/COFF/Driver.h
  lld/COFF/Options.td
  lld/COFF/SymbolTable.cpp
  lld/docs/ReleaseNotes.rst
  lld/test/COFF/winsysroot.test
  llvm/include/llvm/Support/MSVCPaths.h
  llvm/include/llvm/Support/MSVCSetupApi.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/MSVCPaths.cpp
  llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/clang/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/clang/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/clang/BUILD.bazel
@@ -1309,9 +1309,6 @@
 "lib/Driver/ToolChains/Arch/*.cpp",
 "lib/Driver/ToolChains/Arch/*.h",
 ],
-exclude = [
-"lib/Driver/ToolChains/MSVCSetupApi.h",
-],
 ),
 hdrs = glob([
 "include/clang/Driver/*.h",
Index: llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
@@ -98,6 +98,7 @@
 "MD5.cpp",
 "MSP430AttributeParser.cpp",
 "MSP430Attributes.cpp",
+"MSVCPaths.cpp",
 "ManagedStatic.cpp",
 "MathExtras.cpp",
 "MemAlloc.cpp",
Index: llvm/lib/Support/MSVCPaths.cpp
===
--- /dev/null
+++ llvm/lib/Support/MSVCPaths.cpp
@@ -0,0 +1,707 @@
+//===-- MSVCPaths.cpp - MSVC path-parsing helpers -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/MSVCPaths.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Process.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/VersionTuple.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
+
+#ifdef _WIN32
+  #define WIN32_LEAN_AND_MEAN
+  #define NOGDI
+  #ifndef NOMINMAX
+#define NOMINMAX
+  #endif
+  #include 
+#endif
+
+#ifdef _MSC_VER
+// Don't support SetupApi on MinGW.
+#define USE_MSVC_SETUP_API
+
+// Make sure this comes before MSVCSetupApi.h
+#include 
+
+#include "llvm/Support/COM.h"
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
+#endif
+#include "llvm/Support/MSVCSetupApi.h"
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+_COM_SMARTPTR_TYPEDEF(ISetupConfiguration, __uuidof(ISetupConfiguration));
+_COM_SMARTPTR_TYPEDEF(ISetupConfiguration2, __uuidof(ISetupConfiguration2));
+_COM_SMARTPTR_TYPEDEF(ISetupHelper, __uuidof(ISetupHelper));
+_COM_SMARTPTR_TYPEDEF(IEnumSetupInstances, __uuidof(IEnumSetupInstances));
+_COM_SMARTPTR_TYPEDEF(ISetupInstance, __uuidof(ISetupInstance));
+_COM_SMARTPTR_TYPEDEF(ISetupInstance2, __uuidof(ISetupInstance2));
+#endif
+
+static std::string
+getHighestNumericTupleInDirectory(llvm::vfs::FileSystem ,
+  llvm::StringRef Directory) {
+  std::string Highest;
+  llvm::VersionTuple HighestTuple;
+
+  std::error_code EC;
+  for (llvm::vfs::directory_iterator DirIt = VFS.dir_begin(Directory, EC),
+ DirEnd;
+   !EC && DirIt != DirEnd; DirIt.increment(EC)) {
+auto Status = VFS.status(DirIt->path());
+if (!Status || !Status->isDirectory())
+  continue;
+llvm::StringRef CandidateName = llvm::sys::path::filename(DirIt->path());
+llvm::VersionTuple Tuple;
+if (Tuple.tryParse(CandidateName)) // tryParse() returns true on error.
+  continue;
+if (Tuple > HighestTuple) {
+  HighestTuple = Tuple;
+  Highest = CandidateName.str();
+}
+  }
+
+  return Highest;
+}
+
+static bool getWindows10SDKVersionFromPath(llvm::vfs::FileSystem ,
+   const std::string ,
+   std::string ) {
+  llvm::SmallString<128> IncludePath(SDKPath);
+  llvm::sys::path::append(IncludePath, "Include");
+  

[PATCH] D118070: Make lld-link work in a non-MSVC shell

2022-02-04 Thread Peter Kasting via Phabricator via cfe-commits
pkasting added a comment.

In D118070#3297956 , @thakis wrote:

> I think the setup matches what we have in clang, right?

Yes, I think so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118070

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


[PATCH] D118070: Make lld-link work in a non-MSVC shell

2022-02-04 Thread Peter Kasting via Phabricator via cfe-commits
pkasting marked an inline comment as done.
pkasting added a comment.

In D118070#3289222 , @ychen wrote:

> Thanks for doing this! Update the release note?

Done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118070

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


[PATCH] D103395: PR45879: Keep evaluated expression in LValue object

2022-02-04 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

@rsmith Thanks a bunch!

And thanks @sepavloff for trying out this approach too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103395

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


[PATCH] D105297: [OPENMP]Fix PR50347: Mapping of global scope deep object fails.

2022-02-04 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 406099.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105297

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_map_codegen_hold.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_34.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp

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


[clang] 5966c2e - [OpenMP] Fix mismatched device runtime name

2022-02-04 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-04T16:54:31-05:00
New Revision: 5966c2ec026c7953a86dd849b13a98589ed10e9c

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

LOG: [OpenMP] Fix mismatched device runtime name

Summary:
The new runtime was deleted. AMD's old runtime used the triple name
`amdgcn` while the new runtime used `amdgpu`. This was not updated when
the old runtime was removed causing the library to not be found on
AMDGPU.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
clang/lib/Driver/ToolChains/Cuda.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp 
b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index b68b026cd988..3088ba593c24 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -289,8 +289,7 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
   if (getDriver().isUsingLTO(/* IsOffload */ true))
 return;
 
-  std::string BitcodeSuffix;
-  BitcodeSuffix = "amdgcn-" + GPUArch;
+  std::string BitcodeSuffix = "amdgpu-" + GPUArch;
 
   addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
  getTriple());

diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 14e7d26ba1c0..7dd54f87b5f4 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -748,8 +748,7 @@ void CudaToolChain::addClangTargetOptions(
 if (getDriver().isUsingLTO(/* IsOffload */ true))
   return;
 
-std::string BitcodeSuffix;
-BitcodeSuffix = "nvptx-" + GpuArch.str();
+std::string BitcodeSuffix = "nvptx-" + GpuArch.str();
 
 addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
getTriple());



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


[PATCH] D117056: [clangd] Properly compute framework-style include spelling

2022-02-04 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4dfd11324eb0: [clangd] Properly compute framework-style 
include spelling (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117056

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -663,6 +663,83 @@
   qName("Cat::meow"), qName("Cat::pur")));
 }
 
+TEST_F(SymbolCollectorTest, ObjCFrameworkIncludeHeader) {
+  CollectorOpts.CollectIncludePath = true;
+  auto FrameworksPath = testPath("Frameworks/");
+  std::string FrameworkHeader = R"(
+__attribute((objc_root_class))
+@interface NSObject
+@end
+  )";
+  InMemoryFileSystem->addFile(
+  testPath("Frameworks/Foundation.framework/Headers/NSObject.h"), 0,
+  llvm::MemoryBuffer::getMemBuffer(FrameworkHeader));
+  std::string PrivateFrameworkHeader = R"(
+#import 
+
+@interface PrivateClass : NSObject
+@end
+  )";
+  InMemoryFileSystem->addFile(
+  testPath("Frameworks/Foundation.framework/Headers/NSObject.h"), 0,
+  llvm::MemoryBuffer::getMemBuffer(FrameworkHeader));
+  InMemoryFileSystem->addFile(
+  testPath(
+  "Frameworks/Foundation.framework/PrivateHeaders/NSObject+Private.h"),
+  0, llvm::MemoryBuffer::getMemBuffer(PrivateFrameworkHeader));
+
+  std::string Header = R"(
+#import 
+#import 
+
+@interface Container : NSObject
+@end
+  )";
+  std::string Main = "";
+  TestFileName = testPath("test.m");
+  runSymbolCollector(Header, Main, {"-F", FrameworksPath, "-xobjective-c++"});
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  AllOf(qName("NSObject"), includeHeader("\"Foundation/NSObject.h\"")),
+  AllOf(qName("PrivateClass"),
+includeHeader("\"Foundation/NSObject+Private.h\"")),
+  AllOf(qName("Container";
+
+  // After adding the umbrella headers, we should use that spelling instead.
+  std::string UmbrellaHeader = R"(
+#import 
+  )";
+  InMemoryFileSystem->addFile(
+  testPath("Frameworks/Foundation.framework/Headers/Foundation.h"), 0,
+  llvm::MemoryBuffer::getMemBuffer(UmbrellaHeader));
+  std::string PrivateUmbrellaHeader = R"(
+#import 
+  )";
+  InMemoryFileSystem->addFile(
+  testPath("Frameworks/Foundation.framework/PrivateHeaders/"
+   "Foundation_Private.h"),
+  0, llvm::MemoryBuffer::getMemBuffer(PrivateUmbrellaHeader));
+  runSymbolCollector(Header, Main, {"-F", FrameworksPath, "-xobjective-c++"});
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  AllOf(qName("NSObject"),
+includeHeader("\"Foundation/Foundation.h\"")),
+  AllOf(qName("PrivateClass"),
+includeHeader("\"Foundation/Foundation_Private.h\"")),
+  AllOf(qName("Container";
+
+  runSymbolCollector(Header, Main,
+ {"-iframework", FrameworksPath, "-xobjective-c++"});
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  AllOf(qName("NSObject"), includeHeader("")),
+  AllOf(qName("PrivateClass"),
+includeHeader("")),
+  AllOf(qName("Container";
+}
+
 TEST_F(SymbolCollectorTest, Locations) {
   Annotations Header(R"cpp(
 // Declared in header, defined in main.
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -183,6 +183,13 @@
 // including filename normalization, URI conversion etc.
 // Expensive checks are cached internally.
 class SymbolCollector::HeaderFileURICache {
+  struct FrameworkUmbrellaSpelling {
+// Spelling for the public umbrella header, e.g. 
+llvm::Optional PublicHeader;
+// Spelling for the private umbrella header, e.g.
+// 
+llvm::Optional PrivateHeader;
+  };
   // Weird double-indirect access to PP, which might not be ready yet when
   // HeaderFiles is created but will be by the time it's used.
   // (IndexDataConsumer::setPreprocessor can happen before or after initialize)
@@ -193,6 +200,9 @@
   llvm::DenseMap CacheFEToURI;
   llvm::StringMap CachePathToURI;
   llvm::DenseMap CacheFIDToInclude;
+  llvm::StringMap CachePathToFrameworkSpelling;
+  llvm::StringMap
+  CacheFrameworkToUmbrellaHeaderSpelling;
 
 public:
   HeaderFileURICache(Preprocessor *, const SourceManager ,
@@ -249,6 +259,125 @@
 return R.first->second;
   }
 
+  struct FrameworkHeaderPath 

[clang-tools-extra] 4dfd113 - [clangd] Properly compute framework-style include spelling

2022-02-04 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-02-04T16:40:56-05:00
New Revision: 4dfd11324eb05d167392958c0f0f273cae6386c6

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

LOG: [clangd] Properly compute framework-style include spelling

With this change, clangd now computes framework-style includes
for framework headers at indexing time.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/SymbolCollector.cpp
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 3257041ffa0e3..7ae77d35ad7a1 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -183,6 +183,13 @@ const Decl *getRefContainer(const Decl *Enclosing,
 // including filename normalization, URI conversion etc.
 // Expensive checks are cached internally.
 class SymbolCollector::HeaderFileURICache {
+  struct FrameworkUmbrellaSpelling {
+// Spelling for the public umbrella header, e.g. 
+llvm::Optional PublicHeader;
+// Spelling for the private umbrella header, e.g.
+// 
+llvm::Optional PrivateHeader;
+  };
   // Weird double-indirect access to PP, which might not be ready yet when
   // HeaderFiles is created but will be by the time it's used.
   // (IndexDataConsumer::setPreprocessor can happen before or after initialize)
@@ -193,6 +200,9 @@ class SymbolCollector::HeaderFileURICache {
   llvm::DenseMap CacheFEToURI;
   llvm::StringMap CachePathToURI;
   llvm::DenseMap CacheFIDToInclude;
+  llvm::StringMap CachePathToFrameworkSpelling;
+  llvm::StringMap
+  CacheFrameworkToUmbrellaHeaderSpelling;
 
 public:
   HeaderFileURICache(Preprocessor *, const SourceManager ,
@@ -249,6 +259,125 @@ class SymbolCollector::HeaderFileURICache {
 return R.first->second;
   }
 
+  struct FrameworkHeaderPath {
+// Path to the framework directory containing the Headers/PrivateHeaders
+// directories  e.g. /Frameworks/Foundation.framework/
+llvm::StringRef HeadersParentDir;
+// Subpath relative to the Headers or PrivateHeaders dir, e.g. NSObject.h
+// Note: This is NOT relative to the `HeadersParentDir`.
+llvm::StringRef HeaderSubpath;
+// Whether this header is under the PrivateHeaders dir
+bool IsPrivateHeader;
+  };
+
+  llvm::Optional
+  splitFrameworkHeaderPath(llvm::StringRef Path) {
+using namespace llvm::sys;
+path::reverse_iterator I = path::rbegin(Path);
+path::reverse_iterator Prev = I;
+path::reverse_iterator E = path::rend(Path);
+while (I != E) {
+  if (*I == "Headers") {
+FrameworkHeaderPath HeaderPath;
+HeaderPath.HeadersParentDir = Path.substr(0, I - E);
+HeaderPath.HeaderSubpath = Path.substr(Prev - E);
+return HeaderPath;
+  }
+  if (*I == "PrivateHeaders") {
+FrameworkHeaderPath HeaderPath;
+HeaderPath.HeadersParentDir = Path.substr(0, I - E);
+HeaderPath.HeaderSubpath = Path.substr(Prev - E);
+HeaderPath.IsPrivateHeader = true;
+return HeaderPath;
+  }
+  Prev = I;
+  ++I;
+}
+// Unexpected, must not be a framework header.
+return llvm::None;
+  }
+
+  // Frameworks typically have an umbrella header of the same name, e.g.
+  //  instead of  or
+  //  instead of
+  //  which should be used instead of directly
+  // importing the header.
+  llvm::Optional getFrameworkUmbrellaSpelling(
+  llvm::StringRef Framework, SrcMgr::CharacteristicKind HeadersDirKind,
+  HeaderSearch , FrameworkHeaderPath ) {
+auto Res = CacheFrameworkToUmbrellaHeaderSpelling.try_emplace(Framework);
+auto *CachedSpelling = >second;
+if (!Res.second) {
+  return HeaderPath.IsPrivateHeader ? CachedSpelling->PrivateHeader
+: CachedSpelling->PublicHeader;
+}
+bool IsSystem = isSystem(HeadersDirKind);
+SmallString<256> UmbrellaPath(HeaderPath.HeadersParentDir);
+llvm::sys::path::append(UmbrellaPath, "Headers", Framework + ".h");
+
+llvm::vfs::Status Status;
+auto StatErr = HS.getFileMgr().getNoncachedStatValue(UmbrellaPath, Status);
+if (!StatErr) {
+  if (IsSystem)
+CachedSpelling->PublicHeader = llvm::formatv("<{0}/{0}.h>", Framework);
+  else
+CachedSpelling->PublicHeader =
+llvm::formatv("\"{0}/{0}.h\"", Framework);
+}
+
+UmbrellaPath = HeaderPath.HeadersParentDir;
+llvm::sys::path::append(UmbrellaPath, "PrivateHeaders",
+Framework + "_Private.h");
+
+StatErr = HS.getFileMgr().getNoncachedStatValue(UmbrellaPath, Status);
+if 

[PATCH] D114439: [Annotation] Allow parameter pack expansions and initializer lists in annotate attribute

2022-02-04 Thread Steffen Larsen via Phabricator via cfe-commits
steffenlarsen updated this revision to Diff 406094.
steffenlarsen added a comment.

Added missing `isVariadicExprArgument` function.


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

https://reviews.llvm.org/D114439

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/ParsedAttr.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/Sema/annotate.c
  clang/test/SemaCXX/attr-annotate.cpp
  clang/test/SemaTemplate/attributes.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -202,9 +202,9 @@
 bool Fake;
 
   public:
-Argument(const Record , StringRef Attr)
-: lowerName(std::string(Arg.getValueAsString("Name"))),
-  upperName(lowerName), attrName(Attr), isOpt(false), Fake(false) {
+Argument(StringRef Arg, StringRef Attr)
+: lowerName(std::string(Arg)), upperName(lowerName), attrName(Attr),
+  isOpt(false), Fake(false) {
   if (!lowerName.empty()) {
 lowerName[0] = std::tolower(lowerName[0]);
 upperName[0] = std::toupper(upperName[0]);
@@ -215,6 +215,8 @@
   if (lowerName == "interface")
 lowerName = "interface_";
 }
+Argument(const Record , StringRef Attr)
+: Argument(Arg.getValueAsString("Name"), Attr) {}
 virtual ~Argument() = default;
 
 StringRef getLowerName() const { return lowerName; }
@@ -666,6 +668,11 @@
   ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + "Size"),
   RangeName(std::string(getLowerName())) {}
 
+VariadicArgument(StringRef Arg, StringRef Attr, std::string T)
+: Argument(Arg, Attr), Type(std::move(T)),
+  ArgName(getLowerName().str() + "_"), ArgSizeName(ArgName + "Size"),
+  RangeName(std::string(getLowerName())) {}
+
 const std::string () const { return Type; }
 const std::string () const { return ArgName; }
 const std::string () const { return ArgSizeName; }
@@ -688,6 +695,18 @@
  << "); }\n";
 }
 
+void writeSetter(raw_ostream ) const {
+  OS << "  void set" << getUpperName() << "(ASTContext , ";
+  writeCtorParameters(OS);
+  OS << ") {\n";
+  OS << "" << ArgSizeName << " = " << getUpperName() << "Size;\n";
+  OS << "" << ArgName << " = new (Ctx, 16) " << getType() << "["
+ << ArgSizeName << "];\n";
+  OS << "  ";
+  writeCtorBody(OS);
+  OS << "  }\n";
+}
+
 void writeCloneArgs(raw_ostream ) const override {
   OS << ArgName << ", " << ArgSizeName;
 }
@@ -1169,6 +1188,9 @@
   : VariadicArgument(Arg, Attr, "Expr *")
 {}
 
+VariadicExprArgument(StringRef ArgName, StringRef Attr)
+: VariadicArgument(ArgName, Attr, "Expr *") {}
+
 void writeASTVisitorTraversal(raw_ostream ) const override {
   OS << "  {\n";
   OS << "" << getType() << " *I = A->" << getLowerName()
@@ -2138,6 +2160,11 @@
   }
 }
 
+static bool isTypeArgument(const Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ Arg->getSuperClasses().back().first->getName() == "TypeArgument";
+}
+
 /// Emits the first-argument-is-type property for attributes.
 static void emitClangAttrTypeArgList(RecordKeeper , raw_ostream ) {
   OS << "#if defined(CLANG_ATTR_TYPE_ARG_LIST)\n";
@@ -2149,7 +2176,7 @@
 if (Args.empty())
   continue;
 
-if (Args[0]->getSuperClasses().back().first->getName() != "TypeArgument")
+if (!isTypeArgument(Args[0]))
   continue;
 
 // All these spellings take a single type argument.
@@ -2179,7 +2206,7 @@
   OS << "#endif // CLANG_ATTR_ARG_CONTEXT_LIST\n\n";
 }
 
-static bool isIdentifierArgument(Record *Arg) {
+static bool isIdentifierArgument(const Record *Arg) {
   return !Arg->getSuperClasses().empty() &&
 llvm::StringSwitch(Arg->getSuperClasses().back().first->getName())
 .Case("IdentifierArgument", true)
@@ -2188,7 +2215,7 @@
 .Default(false);
 }
 
-static bool isVariadicIdentifierArgument(Record *Arg) {
+static bool isVariadicIdentifierArgument(const Record *Arg) {
   return !Arg->getSuperClasses().empty() &&
  llvm::StringSwitch(
  Arg->getSuperClasses().back().first->getName())
@@ -2197,6 +2224,14 @@
  .Default(false);
 }
 
+static bool isVariadicExprArgument(const Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ llvm::StringSwitch(
+ Arg->getSuperClasses().back().first->getName())
+ 

[PATCH] D117616: GCC ABI Compatibility: Preserve alignment of non-pod members in packed structs

2022-02-04 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D117616#3295859 , @Bhramar.vatsa 
wrote:

> @dblaikie 
> The condition `FieldClass->isPOD()` returns false for the following case 
> (when considering field 'struct foo t' of 'struct foo1') :
>
>   class foo {
>  foo() = default;
>  int _a;
>   };
>   
>   struct foo1 {
>   struct foo t;
>   } t1;
>
> The same code though doesn't give any warning for gcc: 
> https://godbolt.org/z/f4chraerY
>
> This is because the way it works for CXXRecordDecl : 
> https://github.com/llvm/llvm-project/blob/1e3a02162db20264e9615b1346420c8d199cb347/clang/lib/AST/DeclCXX.cpp#L928
>
> So, there seems to be a difference the way GCC is handling this case, in 
> comparison to how now clang handles it.
>
> For the same case, `D->getType().isCXX11PODType()` (or `isPODType()`) 
> indicates it to be a POD type. So, we think that this should be further 
> changed such that it doesn't break the code that works with GCC.

Sorry, was a bit confused by the discussion of warnings and such - but, yes, 
this does seem to be a remaining divergence in the layout between Clang (after 
this patch was committed) and GCC: https://godbolt.org/z/GEM5q4fd3

@rsmith do you have a semi-exhaustive list of the variations in POD-ness I 
should probably test to better understand which definition GCC is using here? 
Reading the cppreference on POD, aggregate, standard layout, and trivial there 
are a lot of dimensions and I was wondering if you had a quick-ish summary so I 
hopefully don't miss cases & figure out exactly how this is meant to be sliced?

I'll work on some godbolt probes/test cases for now to see what I can come up 
with.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117616

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


[PATCH] D118070: Make lld-link work in a non-MSVC shell

2022-02-04 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

> @pkasting Note, this patch makes the outcome non-deterministic when the 
> auto-detection kicks in. We are stamping the command-line the .PDB file, see  
> https://github.com/llvm/llvm-project/blob/main/lld/COFF/PDB.cpp#L1402 - and 
> some live-code-patching tools rely on that to reproduce the link. It'd be 
> nice if the detected paths are queued to `config->argv`, to ensure that we 
> can emit a self-standing LLD cmd-line, a bit like what `clang -cc1` does.

You mean "non-deterministic" in "cmd.exe / local-computer dependent", yes? If 
so: There are enough flags that you can pass in to make the output 
deterministic if this is something you care about. (We care about determinism a 
lot over in chromium land!) I think the setup matches what we have in clang, 
right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118070

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


[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct member is passed to a function

2022-02-04 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:12693-12695
   void CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
- StringRef ParamName, QualType ArgTy, QualType 
ParamTy);
+ StringRef ParamName, QualType ArgTy, QualType ParamTy,
+ const Expr *Arg = nullptr);

ZarkoCA wrote:
> ZarkoCA wrote:
> > aaron.ballman wrote:
> > > I'm not keen on passing both `Arg` and `ArgTy` such that they can get out 
> > > of sync. Do all of the places calling `CheckArgAlignment()` have access 
> > > to the `Expr` so that we can require it be passed (and drop the `ArgTy` 
> > > parameter)?
> > Thanks, that is something I overlooked. 
> > 
> > It seems like I can do this everywhere except the call from 
> > `Sema::CheckConstructorCall`. Trying to figure out whether it's something 
> > I'm missing. 
> Thanks for the through review, I think I addressed everything but this 
> comment. I agree with your concern about having `Arg` and `ArgTy` getting out 
> of sync. I need to spend more time on that particular call from 
> `Sema::CheckConstructorCall` and see what can be done. 
@aaron.ballman I moved the check to its own function and only pass `Expr *Arg` 
to it. I think this should avoid them getting out of sync. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118350

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


[clang] be3d811 - Rename this file to fix the typo in its name; NFC

2022-02-04 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-02-04T15:59:59-05:00
New Revision: be3d811e2c21c864694ce73cb5c2878c3ea0bd68

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

LOG: Rename this file to fix the typo in its name; NFC

Added: 
clang/test/Sema/suppress-deprecated.c

Modified: 


Removed: 
clang/test/Sema/surpress-deprecated.c



diff  --git a/clang/test/Sema/surpress-deprecated.c 
b/clang/test/Sema/suppress-deprecated.c
similarity index 100%
rename from clang/test/Sema/surpress-deprecated.c
rename to clang/test/Sema/suppress-deprecated.c



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


[PATCH] D118350: [Clang][Sema][AIX][PowerPC] Emit byval alignment warning only when struct member is passed to a function

2022-02-04 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA updated this revision to Diff 406086.
ZarkoCA added a comment.

- Moved AIX check to its own function to hopefully avoid Arg and ArgTy getting 
out of sync
- Rebased and removed LIT test cases workaround


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118350

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Analysis/padding_c.c
  clang/test/Analysis/padding_cpp.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/Sema/aix-attr-align.c
  clang/test/SemaTemplate/instantiate-attr.cpp

Index: clang/test/SemaTemplate/instantiate-attr.cpp
===
--- clang/test/SemaTemplate/instantiate-attr.cpp
+++ clang/test/SemaTemplate/instantiate-attr.cpp
@@ -1,7 +1,4 @@
-// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
-// refined.
-
-// RUN: %clang_cc1 -fsyntax-only -verify -Wno-aix-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 // expected-no-diagnostics
 template 
 struct A {
Index: clang/test/Sema/aix-attr-align.c
===
--- clang/test/Sema/aix-attr-align.c
+++ clang/test/Sema/aix-attr-align.c
@@ -6,17 +6,43 @@
 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux -verify=off -fsyntax-only %s
 
 struct S {
-  int a[8] __attribute__((aligned(8))); // no-warning
+  int a[8] __attribute__((aligned(8)));  // no-warning
+  int b[8] __attribute__((aligned(16))); // no-warning
+  int c[2] __attribute__((aligned(32))); // no-warning
 };
 
 struct T {
-  int a[4] __attribute__((aligned(16))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  int a[4] __attribute__((aligned(16))); // no-warning
 };
 
 struct U {
-  int a[2] __attribute__((aligned(32))); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  int a[2] __attribute__((aligned(32))); // no-warning
 };
 
 int a[8] __attribute__((aligned(8)));  // no-warning
 int b[4] __attribute__((aligned(16))); // no-warning
 int c[2] __attribute__((aligned(32))); // no-warning
+
+void baz(int *);
+static void static_baz(int *b) {
+  b = b + 1;
+}
+
+void foo(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8,
+ struct S s) {
+  baz(s.a); // no-warning
+  baz(s.b); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+  baz(s.c); // expected-warning {{requesting an alignment of 16 bytes or greater for struct members is not binary compatible with IBM XL C/C++ for AIX 16.1.0 and older}}
+
+  baz(a); // no-warning
+  baz(b); // no-warning
+  baz(c); // no-warning
+
+  static_baz(s.a); // no-warning
+  static_baz(s.b); // no-warning
+  static_baz(s.c); // no-warning
+
+  static_baz(a); // no-warning
+  static_baz(b); // no-warning
+  static_baz(c); // no-warning
+}
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1,10 +1,8 @@
-// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
-// refined.
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -Wno-aix-compat
+// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking
 
 namespace std {
   struct type_info {};
Index: clang/test/Analysis/padding_cpp.cpp
===
--- clang/test/Analysis/padding_cpp.cpp
+++ clang/test/Analysis/padding_cpp.cpp
@@ -1,6 +1,4 @@
-// FIXME -Wno-aix-compat added temporarily while the diagnostic is being
-// refined.
-// RUN: %clang_analyze_cc1 

[PATCH] D117056: [clangd] Properly compute framework-style include spelling

2022-02-04 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 406081.
dgoldman added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117056

Files:
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp

Index: clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
===
--- clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
+++ clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
@@ -663,6 +663,83 @@
   qName("Cat::meow"), qName("Cat::pur")));
 }
 
+TEST_F(SymbolCollectorTest, ObjCFrameworkIncludeHeader) {
+  CollectorOpts.CollectIncludePath = true;
+  auto FrameworksPath = testPath("Frameworks/");
+  std::string FrameworkHeader = R"(
+__attribute((objc_root_class))
+@interface NSObject
+@end
+  )";
+  InMemoryFileSystem->addFile(
+  testPath("Frameworks/Foundation.framework/Headers/NSObject.h"), 0,
+  llvm::MemoryBuffer::getMemBuffer(FrameworkHeader));
+  std::string PrivateFrameworkHeader = R"(
+#import 
+
+@interface PrivateClass : NSObject
+@end
+  )";
+  InMemoryFileSystem->addFile(
+  testPath("Frameworks/Foundation.framework/Headers/NSObject.h"), 0,
+  llvm::MemoryBuffer::getMemBuffer(FrameworkHeader));
+  InMemoryFileSystem->addFile(
+  testPath(
+  "Frameworks/Foundation.framework/PrivateHeaders/NSObject+Private.h"),
+  0, llvm::MemoryBuffer::getMemBuffer(PrivateFrameworkHeader));
+
+  std::string Header = R"(
+#import 
+#import 
+
+@interface Container : NSObject
+@end
+  )";
+  std::string Main = "";
+  TestFileName = testPath("test.m");
+  runSymbolCollector(Header, Main, {"-F", FrameworksPath, "-xobjective-c++"});
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  AllOf(qName("NSObject"), includeHeader("\"Foundation/NSObject.h\"")),
+  AllOf(qName("PrivateClass"),
+includeHeader("\"Foundation/NSObject+Private.h\"")),
+  AllOf(qName("Container";
+
+  // After adding the umbrella headers, we should use that spelling instead.
+  std::string UmbrellaHeader = R"(
+#import 
+  )";
+  InMemoryFileSystem->addFile(
+  testPath("Frameworks/Foundation.framework/Headers/Foundation.h"), 0,
+  llvm::MemoryBuffer::getMemBuffer(UmbrellaHeader));
+  std::string PrivateUmbrellaHeader = R"(
+#import 
+  )";
+  InMemoryFileSystem->addFile(
+  testPath("Frameworks/Foundation.framework/PrivateHeaders/"
+   "Foundation_Private.h"),
+  0, llvm::MemoryBuffer::getMemBuffer(PrivateUmbrellaHeader));
+  runSymbolCollector(Header, Main, {"-F", FrameworksPath, "-xobjective-c++"});
+  EXPECT_THAT(Symbols,
+  UnorderedElementsAre(
+  AllOf(qName("NSObject"),
+includeHeader("\"Foundation/Foundation.h\"")),
+  AllOf(qName("PrivateClass"),
+includeHeader("\"Foundation/Foundation_Private.h\"")),
+  AllOf(qName("Container";
+
+  runSymbolCollector(Header, Main,
+ {"-iframework", FrameworksPath, "-xobjective-c++"});
+  EXPECT_THAT(
+  Symbols,
+  UnorderedElementsAre(
+  AllOf(qName("NSObject"), includeHeader("")),
+  AllOf(qName("PrivateClass"),
+includeHeader("")),
+  AllOf(qName("Container";
+}
+
 TEST_F(SymbolCollectorTest, Locations) {
   Annotations Header(R"cpp(
 // Declared in header, defined in main.
Index: clang-tools-extra/clangd/index/SymbolCollector.cpp
===
--- clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -183,6 +183,13 @@
 // including filename normalization, URI conversion etc.
 // Expensive checks are cached internally.
 class SymbolCollector::HeaderFileURICache {
+  struct FrameworkUmbrellaSpelling {
+// Spelling for the public umbrella header, e.g. 
+llvm::Optional PublicHeader;
+// Spelling for the private umbrella header, e.g.
+// 
+llvm::Optional PrivateHeader;
+  };
   // Weird double-indirect access to PP, which might not be ready yet when
   // HeaderFiles is created but will be by the time it's used.
   // (IndexDataConsumer::setPreprocessor can happen before or after initialize)
@@ -193,6 +200,9 @@
   llvm::DenseMap CacheFEToURI;
   llvm::StringMap CachePathToURI;
   llvm::DenseMap CacheFIDToInclude;
+  llvm::StringMap CachePathToFrameworkSpelling;
+  llvm::StringMap
+  CacheFrameworkToUmbrellaHeaderSpelling;
 
 public:
   HeaderFileURICache(Preprocessor *, const SourceManager ,
@@ -249,6 +259,125 @@
 return R.first->second;
   }
 
+  struct FrameworkHeaderPath {
+// Path to the framework directory containing the Headers/PrivateHeaders
+// directories  e.g. 

[PATCH] D118744: [clang] Don't cache function type after clearing clang->llvm type cache

2022-02-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 406077.
aeubanks added a comment.

fix more issues, ready to review
I've split the OpenCL change out into D119011 
, will rebase once that's submitted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118744

Files:
  clang/lib/CodeGen/CGBuilder.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGOpenCLRuntime.cpp
  clang/lib/CodeGen/CGOpenCLRuntime.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGenCXX/type-cache-2.cpp
  clang/test/CodeGenCXX/type-cache-3.cpp
  clang/test/CodeGenCXX/type-cache.cpp

Index: clang/test/CodeGenCXX/type-cache.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/type-cache.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// REQUIRES: asserts, x86-registered-target
+
+// CHECK: call {}* @"?f@@YA?AUz@@XZ"()
+
+struct z {
+  z (*p)();
+};
+
+z f();
+
+void g() {
+  f();
+}
Index: clang/test/CodeGenCXX/type-cache-3.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/type-cache-3.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// REQUIRES: asserts, x86-registered-target
+
+// CHECK-LABEL: define {{.*}}@"?f@@YAXXZ"(
+// CHECK: call void @"?dc@z@@SAXU1@@Z"
+
+// CHECK-LABEL: define {{.*}}@"?dc@z@@SAXU1@@Z"(
+// CHECK: store void ({}*)* %{{.*}}, void ({}*)** %{{.*}}
+struct z {
+  static void dc(z) {}
+  void (*p)(z);
+};
+
+void f() {
+  z::dc({});
+}
Index: clang/test/CodeGenCXX/type-cache-2.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/type-cache-2.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -mllvm -verify-type-cache -emit-llvm %s -o - -triple i386-pc-windows-msvc19.16.0 | FileCheck %s
+// REQUIRES: asserts, x86-registered-target
+
+// CHECK: call void @"?dc@z@@SAXU1@@Z"
+struct z {
+  static void dc(z);
+  void (*p)(z);
+};
+
+void f() {
+  z::dc({});
+}
Index: clang/lib/CodeGen/CodeGenTypes.cpp
===
--- clang/lib/CodeGen/CodeGenTypes.cpp
+++ clang/lib/CodeGen/CodeGenTypes.cpp
@@ -25,9 +25,20 @@
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Module.h"
+
 using namespace clang;
 using namespace CodeGen;
 
+#ifndef NDEBUG
+#include "llvm/Support/CommandLine.h"
+// TODO: turn on by default when defined(EXPENSIVE_CHECKS) once check-clang is
+// -verify-type-cache clean.
+static llvm::cl::opt VerifyTypeCache(
+"verify-type-cache",
+llvm::cl::desc("Verify that the type cache matches the computed type"),
+llvm::cl::init(false), llvm::cl::Hidden);
+#endif
+
 CodeGenTypes::CodeGenTypes(CodeGenModule )
   : CGM(cgm), Context(cgm.getContext()), TheModule(cgm.getModule()),
 Target(cgm.getTarget()), TheCXXABI(cgm.getCXXABI()),
@@ -382,9 +393,6 @@
 
   RecordsBeingLaidOut.erase(Ty);
 
-  if (SkippedLayout)
-TypeCache.clear();
-
   if (RecordsBeingLaidOut.empty())
 while (!DeferredRecords.empty())
   ConvertRecordDeclType(DeferredRecords.pop_back_val());
@@ -415,11 +423,29 @@
   if (const RecordType *RT = dyn_cast(Ty))
 return ConvertRecordDeclType(RT->getDecl());
 
-  // See if type is already cached.
-  llvm::DenseMap::iterator TCI = TypeCache.find(Ty);
-  // If type is found in map then use it. Otherwise, convert type T.
-  if (TCI != TypeCache.end())
-return TCI->second;
+  // The LLVM type we return for a given Clang type may not always be the same,
+  // most notably when dealing with recursive structs. We mark these potential
+  // cases with ShouldUseCache below. Builtin types cannot be recursive.
+  // TODO: when clang uses LLVM opaque pointers we won't be able to represent
+  // recursive types with LLVM types, making this logic much simpler.
+  llvm::Type *CachedType = nullptr;
+  bool ShouldUseCache =
+  Ty->isBuiltinType() ||
+  (noRecordsBeingLaidOut() && FunctionsBeingProcessed.empty());
+  if (ShouldUseCache) {
+llvm::DenseMap::iterator TCI =
+TypeCache.find(Ty);
+if (TCI != TypeCache.end())
+  CachedType = TCI->second;
+if (CachedType) {
+#ifndef NDEBUG
+  if (!VerifyTypeCache)
+return CachedType;
+#else
+  return CachedType;
+#endif
+}
+  }
 
   // If we don't have it in the cache, convert it now.
   llvm::Type *ResultType = nullptr;
@@ -797,7 +823,15 @@
 
   assert(ResultType && "Didn't convert a type?");
 
-  TypeCache[Ty] = ResultType;
+#ifndef NDEBUG
+  if (CachedType) {
+assert(CachedType == ResultType &&
+   "Cached type doesn't match computed type");
+  }
+#endif
+
+  if (ShouldUseCache)
+TypeCache[Ty] = ResultType;
   return ResultType;
 }
 
Index: 

[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D116637#3297833 , @jdoerfert wrote:

> In D116637#3297790 , 
> @tianshilei1992 wrote:
>
>> In D116637#3297785 , @kda wrote:
>>
>>> This still seems to be breaking sanitizers fast: 
>>> https://lab.llvm.org/buildbot/#/builders/5/builds/18563
>>>
>>> To reproduce these results:
>>> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild
>>
>> I pushed a fix about half an hour ago. It should fix the issue. Thanks.
>
> I doubt it is fixed. Also, please reference the phab review in a fix to make 
> it easier to find it.

It will. The BuildBot link here is still the one for this patch. It is fixed in 
`b8ec430de71766d9a35a6b737c8a789c0c7cf812`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[clang] 0d54457 - [IntrospectionTest] Replace "return" with "GTEST_SKIP"

2022-02-04 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2022-02-04T12:35:44-08:00
New Revision: 0d54457f8aed169dff8a668059979a2646afc3fc

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

LOG: [IntrospectionTest] Replace "return" with "GTEST_SKIP"

If a test simply returns, it gets mis-reported as a pass; being
reported as SKIPPED is correct.

Found by the Rotten Green Tests project.

Added: 


Modified: 
clang/unittests/Introspection/IntrospectionTest.cpp

Removed: 




diff  --git a/clang/unittests/Introspection/IntrospectionTest.cpp 
b/clang/unittests/Introspection/IntrospectionTest.cpp
index d4f626bfeb740..69e461609e7dd 100644
--- a/clang/unittests/Introspection/IntrospectionTest.cpp
+++ b/clang/unittests/Introspection/IntrospectionTest.cpp
@@ -134,7 +134,7 @@ TEST(Introspection, SourceLocations_Formatter) {
 
 TEST(Introspection, SourceLocations_Stmt) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST = buildASTFromCode("void foo() {} void bar() { foo(); }", "foo.cpp",
   std::make_shared());
   auto  = AST->getASTContext();
@@ -169,7 +169,7 @@ TEST(Introspection, SourceLocations_Stmt) {
 
 TEST(Introspection, SourceLocations_Decl) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 namespace ns1 {
@@ -354,7 +354,7 @@ STRING_LOCATION_STDPAIR(MethodDecl, 
getTypeSourceInfo()->getTypeLoc().getSourceR
 
 TEST(Introspection, SourceLocations_NNS) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 namespace ns
@@ -414,7 +414,7 @@ void ns::A::foo() {}
 
 TEST(Introspection, SourceLocations_TA_Type) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 template
@@ -472,7 +472,7 @@ STRING_LOCATION_PAIR(
 
 TEST(Introspection, SourceLocations_TA_Decl) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 template
@@ -509,7 +509,7 @@ void test() {
 
 TEST(Introspection, SourceLocations_TA_Nullptr) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 template
@@ -546,7 +546,7 @@ void test() {
 
 TEST(Introspection, SourceLocations_TA_Integral) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 template
@@ -582,7 +582,7 @@ void test() {
 
 TEST(Introspection, SourceLocations_TA_Template) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 template class A;
@@ -621,7 +621,7 @@ void bar()
 
 TEST(Introspection, SourceLocations_TA_TemplateExpansion) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST = buildASTFromCodeWithArgs(
   R"cpp(
 template class ...> class B { };
@@ -660,7 +660,7 @@ template class ...> class B { };
 
 TEST(Introspection, SourceLocations_TA_Expression) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 template class testExpr;
@@ -693,7 +693,7 @@ template class testExpr { };
 
 TEST(Introspection, SourceLocations_TA_Pack) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST = buildASTFromCodeWithArgs(
   R"cpp(
 template class A {};
@@ -748,7 +748,7 @@ STRING_LOCATION_PAIR(
 
 TEST(Introspection, SourceLocations_CXXCtorInitializer_base) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 struct A {
@@ -808,7 +808,7 @@ STRING_LOCATION_PAIR(CtorInit, 
getTypeSourceInfo()->getTypeLoc().getEndLoc())
 
 TEST(Introspection, SourceLocations_CXXCtorInitializer_member) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 struct A {
@@ -849,7 +849,7 @@ struct A {
 
 TEST(Introspection, SourceLocations_CXXCtorInitializer_ctor) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST =
   buildASTFromCode(R"cpp(
 struct C {
@@ -906,7 +906,7 @@ STRING_LOCATION_PAIR(CtorInit,
 
 TEST(Introspection, SourceLocations_CXXCtorInitializer_pack) {
   if (!NodeIntrospection::hasIntrospectionSupport())
-return;
+GTEST_SKIP();
   auto AST = buildASTFromCodeWithArgs(
   R"cpp(
 template
@@ -979,7 +979,7 @@ STRING_LOCATION_STDPAIR(CtorInit, 

[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-04 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D116637#3297790 , @tianshilei1992 
wrote:

> In D116637#3297785 , @kda wrote:
>
>> This still seems to be breaking sanitizers fast: 
>> https://lab.llvm.org/buildbot/#/builders/5/builds/18563
>>
>> To reproduce these results:
>> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild
>
> I pushed a fix about half an hour ago. It should fix the issue. Thanks.

I doubt it is fixed. Also, please reference the phab review in a fix to make it 
easier to find it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D116637#3297785 , @kda wrote:

> This still seems to be breaking sanitizers fast: 
> https://lab.llvm.org/buildbot/#/builders/5/builds/18563
>
> To reproduce these results:
> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild

I pushed a fix about half an hour ago. It should fix the issue. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-04 Thread Kevin Athey via Phabricator via cfe-commits
kda added a comment.

This still seems to be breaking sanitizers fast: 
https://lab.llvm.org/buildbot/#/builders/5/builds/18563

To reproduce these results:
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[clang] eeb29c8 - [OpenMP] Add -Bsymbolic to arguments for GNU linker

2022-02-04 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-02-04T15:13:32-05:00
New Revision: eeb29c8477d96ad821b3283dad8ed060a3426118

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

LOG: [OpenMP] Add -Bsymbolic to arguments for GNU linker

This patch adds the '-Bsymbolic' flag when we perform linking for the
offloading device. We already pass '-fvisibility=protected' but this is
not properly handled when using the bfd linker as is described in
https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic.
Previously this caused linker errors when creating the shared library.

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 12eaf1fb8b514..d0808d061c827 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -572,6 +572,14 @@ void tools::gnutools::Linker::ConstructJob(Compilation , 
const JobAction ,
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally. The
+  // symbols are already protected which makes this redundant. This is only
+  // necessary to work around a problem in bfd.
+  // TODO: Remove this once 'lld' becomes the only linker for offloading.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 



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


[PATCH] D119018: [OpenMP] Add -Bsymbolic to arguments for GNU linker

2022-02-04 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeeb29c8477d9: [OpenMP] Add -Bsymbolic to arguments for GNU 
linker (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119018

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -572,6 +572,14 @@
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally. The
+  // symbols are already protected which makes this redundant. This is only
+  // necessary to work around a problem in bfd.
+  // TODO: Remove this once 'lld' becomes the only linker for offloading.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -572,6 +572,14 @@
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally. The
+  // symbols are already protected which makes this redundant. This is only
+  // necessary to work around a problem in bfd.
+  // TODO: Remove this once 'lld' becomes the only linker for offloading.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119026: [HIP] Emit amdgpu_code_object_version module flag

2022-02-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:575
+// times 100.
+if (getTarget().getTargetOpts().CodeObjectVersion != "none") {
+  unsigned CodeObjVer;

When will it ever be set to `none`? Does the new option parser enforce the 
default & version values specified in the tablegen?
If so, then it should never be `none`.
If the `Values` specified for the option are not enforced, then the condition 
will be true if user specifies any invalid value other than `none`.



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

https://reviews.llvm.org/D119026

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


[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D118969#3297699 , 
@HazardyKnusperkeks wrote:

> Ah because of a race condition, I couldn't accept anymore. :)

Sorry! I should have waited a little longer. :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118969

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


[clang] b8ec430 - [Clang][Sema][OpenMP] Fix uninitialized variable Op

2022-02-04 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2022-02-04T15:00:43-05:00
New Revision: b8ec430de71766d9a35a6b737c8a789c0c7cf812

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

LOG: [Clang][Sema][OpenMP] Fix uninitialized variable Op

This can fix the case atomic_messages

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 4143e070a8738..7486e1389172c 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -11063,8 +11063,18 @@ bool 
OpenMPAtomicCompareChecker::checkCondUpdateStmt(IfStmt *S,
 ErrorInfo.ErrorRange = ErrorInfo.NoteRange = 
S->getCond()->getSourceRange();
 return false;
   }
-  if (Cond->getOpcode() != BO_EQ && Cond->getOpcode() != BO_LT &&
-  Cond->getOpcode() != BO_GT) {
+
+  switch (Cond->getOpcode()) {
+  case BO_EQ:
+Op = OMPAtomicCompareOp::EQ;
+break;
+  case BO_LT:
+Op = OMPAtomicCompareOp::MIN;
+break;
+  case BO_GT:
+Op = OMPAtomicCompareOp::MAX;
+break;
+  default:
 ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
 ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
 ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();
@@ -11148,8 +11158,17 @@ bool 
OpenMPAtomicCompareChecker::checkCondExprStmt(Stmt *S,
 return false;
   }
 
-  if (Cond->getOpcode() != BO_EQ && Cond->getOpcode() != BO_LT &&
-  Cond->getOpcode() != BO_GT) {
+  switch (Cond->getOpcode()) {
+  case BO_EQ:
+Op = OMPAtomicCompareOp::EQ;
+break;
+  case BO_LT:
+Op = OMPAtomicCompareOp::MIN;
+break;
+  case BO_GT:
+Op = OMPAtomicCompareOp::MAX;
+break;
+  default:
 ErrorInfo.Error = ErrorTy::InvalidBinaryOp;
 ErrorInfo.ErrorLoc = ErrorInfo.NoteLoc = Cond->getExprLoc();
 ErrorInfo.ErrorRange = ErrorInfo.NoteRange = Cond->getSourceRange();



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


[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Ah because of a race condition, I couldn't accept anymore. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118969

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


[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

LGTM, since when can't I post an empty comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118969

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-04 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks marked 3 inline comments as done.
HazardyKnusperkeks added a comment.

Format notes updated on local commit.




Comment at: clang/docs/ClangFormatStyleOptions.rst:3399
 
+**RequiresClausePositionForClasses** (``RequiresClausePositionStyle``) 
:versionbadge:`clang-format 14`
+  The position of the ``requires`` clause for class templates.

Mordante wrote:
> I assume that should `clang-format 15` now. Same for other new options.
Yeah, you hit the small margin between my reply and my upload of the current 
diff. ;)



Comment at: clang/lib/Format/Format.cpp:1212
   LLVMStyle.ReferenceAlignment = FormatStyle::RAS_Pointer;
+  // This is open for discussions! When will LLVM adapt C++20?
+  LLVMStyle.RequiresClausePositionForClasses = FormatStyle::RCPS_OwnLine;

Mordante wrote:
> Note the libc++ already uses C++20 code. We don't use clang-format 
> officially, but I use it for new code. (Mainly the `std::format` related 
> code.)
And is there a consensus about formatting requires clauses?


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

https://reviews.llvm.org/D113319

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


[PATCH] D118969: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG35f7dd601d33: [clang-format][NFC] Fix a bug in setting type 
FunctionLBrace (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118969

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


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -91,6 +91,12 @@
   EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_RecordLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsLBracesInMacroDefinition) {
+  auto Tokens = annotate("#define BEGIN NS {");
+  EXPECT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_Unknown);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1577,7 +1577,8 @@
 } else if (Style.BraceWrapping.AfterFunction) {
   addUnwrappedLine();
 }
-FormatTok->setType(TT_FunctionLBrace);
+if (!Line->InPPDirective)
+  FormatTok->setType(TT_FunctionLBrace);
 parseBlock();
 addUnwrappedLine();
 return;


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -91,6 +91,12 @@
   EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_RecordLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsLBracesInMacroDefinition) {
+  auto Tokens = annotate("#define BEGIN NS {");
+  EXPECT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_Unknown);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1577,7 +1577,8 @@
 } else if (Style.BraceWrapping.AfterFunction) {
   addUnwrappedLine();
 }
-FormatTok->setType(TT_FunctionLBrace);
+if (!Line->InPPDirective)
+  FormatTok->setType(TT_FunctionLBrace);
 parseBlock();
 addUnwrappedLine();
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 35f7dd6 - [clang-format][NFC] Fix a bug in setting type FunctionLBrace

2022-02-04 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2022-02-04T11:36:30-08:00
New Revision: 35f7dd601d33219fafa2c0d308e187df3e36847a

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

LOG: [clang-format][NFC] Fix a bug in setting type FunctionLBrace

The l_brace token in a macro definition should not be set to
TT_FunctionLBrace.

This patch could have fixed #42087.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index eb927b5c49217..97a2cf367e808 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1577,7 +1577,8 @@ void 
UnwrappedLineParser::parseStructuralElement(IfStmtKind *IfKind,
 } else if (Style.BraceWrapping.AfterFunction) {
   addUnwrappedLine();
 }
-FormatTok->setType(TT_FunctionLBrace);
+if (!Line->InPPDirective)
+  FormatTok->setType(TT_FunctionLBrace);
 parseBlock();
 addUnwrappedLine();
 return;

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 1684e815b0617..88deee974bbf5 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -91,6 +91,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsEnums) {
   EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_RecordLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsLBracesInMacroDefinition) {
+  auto Tokens = annotate("#define BEGIN NS {");
+  EXPECT_EQ(Tokens.size(), 6u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_Unknown);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang



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


[PATCH] D119026: [HIP] Emit amdgpu_code_object_version module flag

2022-02-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, b-sumner.
Herald added subscribers: dang, kerbowa, t-tye, tpr, dstuttard, jvesely, 
kzhuravl.
yaxunl requested review of this revision.
Herald added a subscriber: wdng.

code object version determines ABI, therefore should not be mixed.

This patch emits amdgpu_code_object_version module flag in LLVM IR
based on code object version (default 4).

The amdgpu_code_object_version value is code object version times 100.

LLVM IR with different amdgpu_code_object_version module flag cannot
be linked.

The -cc1 option -mcode-object-version=none is for ROCm device library use
only, which supports multiple ABI.


https://reviews.llvm.org/D119026

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
  clang/test/CodeGenCUDA/amdgpu-asan.cu
  clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
  clang/test/Driver/hip-code-object-version.hip

Index: clang/test/Driver/hip-code-object-version.hip
===
--- clang/test/Driver/hip-code-object-version.hip
+++ clang/test/Driver/hip-code-object-version.hip
@@ -34,6 +34,7 @@
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V3 %s
 
 // V3-WARN: warning: argument '-mcode-object-v3' is deprecated, use '-mcode-object-version=3' instead [-Wdeprecated]
+// V3: "-mcode-object-version=3"
 // V3: "-mllvm" "--amdhsa-code-object-version=3"
 // V3: "-targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa--gfx906"
 
@@ -44,6 +45,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V4 %s
 
+// V4: "-mcode-object-version=4"
 // V4: "-mllvm" "--amdhsa-code-object-version=4"
 // V4: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
 
@@ -54,6 +56,7 @@
 // RUN:   --offload-arch=gfx906 -nogpulib \
 // RUN:   %s 2>&1 | FileCheck -check-prefix=V5 %s
 
+// V5: "-mcode-object-version=5"
 // V5: "-mllvm" "--amdhsa-code-object-version=5"
 // V5: "-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx906"
 
Index: clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-code-object-version.cu
@@ -0,0 +1,25 @@
+// Create module flag for code object version.
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -o - %s | FileCheck %s -check-prefix=V4
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=2 -o - %s | FileCheck -check-prefix=V2 %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=3 -o - %s | FileCheck -check-prefix=V3 %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=4 -o - %s | FileCheck -check-prefix=V4 %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=5 -o - %s | FileCheck -check-prefix=V5 %s
+
+// RUN: %clang_cc1 -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm \
+// RUN:   -mcode-object-version=none -o - %s | FileCheck %s -check-prefix=NONE
+
+// V2: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 200}
+// V3: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 300}
+// V4: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 400}
+// V5: !{{.*}} = !{i32 1, !"amdgpu_code_object_version", i32 500}
+// NONE-NOT: !{{.*}} = !{i32 1, !"amdgpu_code_object_version",
Index: clang/test/CodeGenCUDA/amdgpu-asan.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan.cu
+++ clang/test/CodeGenCUDA/amdgpu-asan.cu
@@ -27,8 +27,7 @@
 // ASAN-DAG: @llvm.compiler.used = {{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr
 // ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}})
 
-// MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
-// MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
+// MFCHECK: !{{.*}} = !{i32 4, !"amdgpu_hostcall", i32 1}
 
 // CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions
 // CHECK-NOT: @__asan_report_load1
Index: clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
===
--- clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
+++ clang/test/CodeGenCUDA/amdgpu-asan-printf.cu
@@ -2,8 +2,7 @@
 // RUN:   -fcuda-is-device -target-cpu gfx906 -fsanitize=address \
 // RUN:   -O3 -x hip | FileCheck -check-prefixes=MFCHECK %s
 
-// MFCHECK: !llvm.module.flags = !{![[FLAG1:[0-9]+]], ![[FLAG2:[0-9]+]]}
-// MFCHECK: ![[FLAG1]] = !{i32 4, !"amdgpu_hostcall", i32 1}
+// MFCHECK: !{{.*}} = !{i32 4, !"amdgpu_hostcall", i32 1}
 
 // Test to check hostcall module flag metadata is generated correctly
 

[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-04 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 406048.
HazardyKnusperkeks marked an inline comment as done.
HazardyKnusperkeks edited the summary of this revision.
HazardyKnusperkeks added a comment.

This took a lot of work and debugging.
I tried to minimize the refactoring on related code (I've prepared quite a few 
other commits and stashes...).

I'm confident that we can now format every sane use of requires clauses, 
expressions, and concept declarations. And even some I wouldn't call sane.

Decided to drop https://llvm.org/PR32166 since in this approach the book 
keeping to bring the indention back on track after the clause would be too much 
burden on everyone not using it.


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

https://reviews.llvm.org/D113319

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

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -14,6 +14,14 @@
 
 namespace clang {
 namespace format {
+
+// Not really the equality, but everything we need.
+static bool operator==(const FormatToken ,
+   const FormatToken ) noexcept {
+  return LHS.Tok.getKind() == RHS.Tok.getKind() &&
+ LHS.getType() == RHS.getType();
+}
+
 namespace {
 
 class TokenAnnotatorTest : public ::testing::Test {
@@ -91,6 +99,261 @@
   EXPECT_TOKEN(Tokens[2], tok::l_brace, TT_RecordLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) {
+  auto Tokens = annotate("template \n"
+ "concept C = (Foo && Bar) && (Bar && Baz);");
+
+  ASSERT_EQ(Tokens.size(), 21u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[13], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[16], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("template \n"
+"concept C = requires(T t) {\n"
+"  { t.foo() };\n"
+"} && Bar && Baz;");
+  ASSERT_EQ(Tokens.size(), 35u) << Tokens;
+  EXPECT_TOKEN(Tokens[23], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[28], tok::ampamp, TT_BinaryOperator);
+
+  Tokens = annotate("template\n"
+"requires C1 && (C21 || C22 && C2e) && C3\n"
+"struct Foo;");
+  ASSERT_EQ(Tokens.size(), 36u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::identifier, TT_Unknown);
+  EXPECT_EQ(Tokens[6]->FakeLParens.size(), 1u);
+  EXPECT_TOKEN(Tokens[10], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[16], tok::pipepipe, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[21], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[27], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[31], tok::greater, TT_TemplateCloser);
+  EXPECT_EQ(Tokens[31]->FakeRParens, 1u);
+  EXPECT_TRUE(Tokens[31]->ClosesRequiresClause);
+
+  Tokens =
+  annotate("template\n"
+   "requires (C1 && (C21 || C22 && C2e) && C3)\n"
+   "struct Foo;");
+  ASSERT_EQ(Tokens.size(), 38u) << Tokens;
+  EXPECT_TOKEN(Tokens[7], tok::identifier, TT_Unknown);
+  EXPECT_EQ(Tokens[7]->FakeLParens.size(), 1u);
+  EXPECT_TOKEN(Tokens[11], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[17], tok::pipepipe, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[22], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[28], tok::ampamp, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[32], tok::greater, TT_TemplateCloser);
+  EXPECT_EQ(Tokens[32]->FakeRParens, 1u);
+  EXPECT_TOKEN(Tokens[33], tok::r_paren, TT_Unknown);
+  EXPECT_TRUE(Tokens[33]->ClosesRequiresClause);
+}
+
+TEST_F(TokenAnnotatorTest, RequiresDoesNotChangeParsingOfTheRest) {
+  auto NumberOfAdditionalRequiresClauseTokens = 5u;
+  auto NumberOfTokensBeforeRequires = 5u;
+
+  auto BaseTokens = annotate("template\n"
+ "T Pi = 3.14;");
+  auto ConstrainedTokens = annotate("template\n"
+"  requires Foo\n"
+"T Pi = 3.14;");
+
+  auto NumberOfBaseTokens = 11u;
+
+  ASSERT_EQ(BaseTokens.size(), NumberOfBaseTokens) << BaseTokens;
+  ASSERT_EQ(ConstrainedTokens.size(),
+NumberOfBaseTokens + NumberOfAdditionalRequiresClauseTokens)
+  << ConstrainedTokens;
+
+  for (auto I = 0u; I < NumberOfBaseTokens; ++I)
+if (I < NumberOfTokensBeforeRequires)
+  EXPECT_EQ(*BaseTokens[I], *ConstrainedTokens[I]) << I;
+else
+  EXPECT_EQ(*BaseTokens[I],
+

[clang] 56d46b3 - [clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".

2022-02-04 Thread Dmitri Gribenko via cfe-commits

Author: Devin Jeanpierre
Date: 2022-02-04T20:17:34+01:00
New Revision: 56d46b36fc231a0beb518602503035bba92043e0

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

LOG: [clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially 
relocatable"".

This reverts commit 852afed5e0200b70047c28ccf4424a17089d17b0.

Changes since D114732:

On PS4, we reverse the expectation that classes whose constructor is deleted 
are not trivially relocatable. Because, at the moment, only classes which are 
passed in registers are trivially relocatable, and PS4 allows passing in 
registers if the copy constructor is deleted, the original assertions were 
broken on PS4.

(This is kinda similar to DR1734.)

Reviewed By: gribozavr2

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/include/clang/AST/Type.h
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/TokenKinds.def
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/test/SemaCXX/attr-trivial-abi.cpp
clang/test/SemaCXX/type-traits.cpp
clang/test/SemaObjCXX/arc-type-traits.mm
clang/test/SemaObjCXX/objc-weak-type-traits.mm

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index f848fb01d8c5e..e74539d650ce0 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1365,6 +1365,11 @@ The following type trait primitives are supported by 
Clang. Those traits marked
 * ``__is_trivially_constructible`` (C++, GNU, Microsoft)
 * ``__is_trivially_copyable`` (C++, GNU, Microsoft)
 * ``__is_trivially_destructible`` (C++, MSVC 2013)
+* ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
+  of the given type, and then destroying the source object, is known to be
+  functionally equivalent to copying the underlying bytes and then dropping the
+  source object on the floor. This is true of trivial types and types which
+  were made trivially relocatable via the ``clang::trivial_abi`` attribute.
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero):
   Returns false for enumeration types. Note, before Clang 13, returned true for

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index a69c0ae67d0a0..3c71cbbb9c8f3 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -829,6 +829,8 @@ class QualType {
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext ) const;
 
+  /// Return true if this is a trivially relocatable type.
+  bool isTriviallyRelocatableType(const ASTContext ) const;
 
   /// Returns true if it is a class and it might be dynamic.
   bool mayBeDynamicClass() const;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index efd2af1ab1df3..e12a0b259cc2e 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -3295,6 +3295,9 @@ If a type is trivial for the purposes of calls, has a 
non-trivial destructor,
 and is passed as an argument by value, the convention is that the callee will
 destroy the object before returning.
 
+If a type is trivial for the purpose of calls, it is assumed to be trivially
+relocatable for the purpose of ``__is_trivially_relocatable``.
+
 Attribute ``trivial_abi`` has no effect in the following cases:
 
 - The class directly declares a virtual base or virtual methods.

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index e55244e1c3ac9..b9d5cd76d51d6 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -510,6 +510,7 @@ TYPE_TRAIT_1(__has_unique_object_representations,
 KEYWORD(__underlying_type   , KEYCXX)
 
 // Clang-only C++ Type Traits
+TYPE_TRAIT_1(__is_trivially_relocatable, IsTriviallyRelocatable, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 
 // Embarcadero Expression Traits

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 774b3e94159db..1c7499c3c237e 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2495,6 +2495,25 @@ bool QualType::isTriviallyCopyableType(const ASTContext 
) const {
   return false;
 }
 
+bool QualType::isTriviallyRelocatableType(const ASTContext ) const {
+  QualType BaseElementType = Context.getBaseElementType(*this);
+
+  if (BaseElementType->isIncompleteType()) {
+return false;
+  } else if (const auto *RD = BaseElementType->getAsRecordDecl()) {
+return RD->canPassInRegisters();
+  } else {
+switch 

[PATCH] D119017: [clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".

2022-02-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG56d46b36fc23: [clang] roll-forward [clang] Mark 
`trivial_abi` types as trivially… (authored by devin.jeanpierre, 
committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119017

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaCXX/type-traits.cpp
  clang/test/SemaObjCXX/arc-type-traits.mm
  clang/test/SemaObjCXX/objc-weak-type-traits.mm

Index: clang/test/SemaObjCXX/objc-weak-type-traits.mm
===
--- clang/test/SemaObjCXX/objc-weak-type-traits.mm
+++ clang/test/SemaObjCXX/objc-weak-type-traits.mm
@@ -8,7 +8,7 @@
 #define TRAIT_IS_FALSE(Trait, Type) static_assert(!Trait(Type), "")
 #define TRAIT_IS_TRUE_2(Trait, Type1, Type2) static_assert(Trait(Type1, Type2), "")
 #define TRAIT_IS_FALSE_2(Trait, Type1, Type2) static_assert(!Trait(Type1, Type2), "")
-  
+
 struct HasStrong { id obj; };
 struct HasWeak { __weak id obj; };
 struct HasUnsafeUnretained { __unsafe_unretained id obj; };
@@ -208,3 +208,12 @@
 TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak&&);
 TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained);
 TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained&&);
+
+// __is_trivially_relocatable
+TRAIT_IS_TRUE(__is_trivially_relocatable, __strong id);
+TRAIT_IS_FALSE(__is_trivially_relocatable, __weak id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __autoreleasing id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __unsafe_unretained id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, HasStrong);
+TRAIT_IS_FALSE(__is_trivially_relocatable, HasWeak);
+TRAIT_IS_TRUE(__is_trivially_relocatable, HasUnsafeUnretained);
Index: clang/test/SemaObjCXX/arc-type-traits.mm
===
--- clang/test/SemaObjCXX/arc-type-traits.mm
+++ clang/test/SemaObjCXX/arc-type-traits.mm
@@ -12,7 +12,7 @@
 #define TRAIT_IS_FALSE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? -1 : 1]
 #define TRAIT_IS_TRUE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? 1 : -1]
 #define TRAIT_IS_FALSE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? -1 : 1]
-  
+
 struct HasStrong { id obj; };
 struct HasWeak { __weak id obj; };
 struct HasUnsafeUnretained { __unsafe_unretained id obj; };
@@ -213,3 +213,11 @@
 TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained);
 TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained&&);
 
+// __is_trivially_relocatable
+TRAIT_IS_TRUE(__is_trivially_relocatable, __strong id);
+TRAIT_IS_FALSE(__is_trivially_relocatable, __weak id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __autoreleasing id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __unsafe_unretained id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, HasStrong);
+TRAIT_IS_FALSE(__is_trivially_relocatable, HasWeak);
+TRAIT_IS_TRUE(__is_trivially_relocatable, HasUnsafeUnretained);
Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2854,3 +2854,64 @@
 #undef T16384
 #undef T32768
 } // namespace type_trait_expr_numargs_overflow
+
+namespace is_trivially_relocatable {
+
+static_assert(!__is_trivially_relocatable(void), "");
+static_assert(__is_trivially_relocatable(int), "");
+static_assert(__is_trivially_relocatable(int[]), "");
+
+enum Enum {};
+static_assert(__is_trivially_relocatable(Enum), "");
+static_assert(__is_trivially_relocatable(Enum[]), "");
+
+union Union {int x;};
+static_assert(__is_trivially_relocatable(Union), "");
+static_assert(__is_trivially_relocatable(Union[]), "");
+
+struct Trivial {};
+static_assert(__is_trivially_relocatable(Trivial), "");
+static_assert(__is_trivially_relocatable(Trivial[]), "");
+
+struct Incomplete; // expected-note {{forward declaration of 'is_trivially_relocatable::Incomplete'}}
+bool unused = __is_trivially_relocatable(Incomplete); // expected-error {{incomplete type}}
+
+struct NontrivialDtor {
+  ~NontrivialDtor() {}
+};
+static_assert(!__is_trivially_relocatable(NontrivialDtor), "");
+static_assert(!__is_trivially_relocatable(NontrivialDtor[]), "");
+
+struct NontrivialCopyCtor {
+  NontrivialCopyCtor(const NontrivialCopyCtor&) {}
+};
+static_assert(!__is_trivially_relocatable(NontrivialCopyCtor), "");
+static_assert(!__is_trivially_relocatable(NontrivialCopyCtor[]), "");
+
+struct NontrivialMoveCtor 

[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-04 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Thanks for working on this! I love to see better `requires` support in 
clang-format. I didn't do a real review, just some drive-by comments.




Comment at: clang/docs/ClangFormatStyleOptions.rst:3399
 
+**RequiresClausePositionForClasses** (``RequiresClausePositionStyle``) 
:versionbadge:`clang-format 14`
+  The position of the ``requires`` clause for class templates.

I assume that should `clang-format 15` now. Same for other new options.



Comment at: clang/lib/Format/Format.cpp:1212
   LLVMStyle.ReferenceAlignment = FormatStyle::RAS_Pointer;
+  // This is open for discussions! When will LLVM adapt C++20?
+  LLVMStyle.RequiresClausePositionForClasses = FormatStyle::RCPS_OwnLine;

Note the libc++ already uses C++20 code. We don't use clang-format officially, 
but I use it for new code. (Mainly the `std::format` related code.)


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

https://reviews.llvm.org/D113319

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


[PATCH] D113319: [clang-format] Improve require and concept handling

2022-02-04 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks marked 15 inline comments as done.
HazardyKnusperkeks added inline comments.



Comment at: clang/include/clang/Format/Format.h:3130-3136
+  /// \brief The position of the ``requires`` clause for class templates.
+  /// \version 14
+  RequiresClausePositionStyle RequiresClausePositionForClasses;
+
+  /// \brief The position of the ``requires`` clause for function templates.
+  /// \version 14
+  RequiresClausePositionStyle RequiresClausePositionForFunctions;

Quuxplusone wrote:
> HazardyKnusperkeks wrote:
> > Quuxplusone wrote:
> > > What about for variable templates? What about for alias templates? What 
> > > about for deduction guides?
> > > It makes sense to me to have //one// option for this. It doesn't make 
> > > sense to have 2, 3, or 4. Having 5 feels insane. So, I think you should 
> > > just have one option that applies consistently to all `requires`-clauses 
> > > everywhere in the code.
> > That makes sense, in my defense I thought about it and came to the 
> > conclusion there would be no need for requires on variable templates, and 
> > the others I did not think of.
> > 
> > Why I have chosen to options is maybe someone wants
> > ```template 
> > requires ...
> > class ...```
> > 
> > But also
> > ```template 
> > void foo(T) requires ... {
> > ```
> > 
> > What's your opinion on that?
> Well, I see that there is a machine-readable distinction between "`requires` 
> after `template`" versus "`requires` after function parameter list," i.e. 
> between
> ```
> template requires X
> void f(T);
> 
> template
> void f(T) requires X;
> ```
> The latter position is not (currently) valid for non-functions (e.g. 
> `template int v requires X;` is a syntax error).
> However, as usual, I don't think that the user should //want// to format 
> these differently.
> If you're using clang-format to format your code, then you should definitely 
> want function-parameter-list-requires-clauses on their own line for sure, to 
> avoid confusing strings of tokens such as
> ```
> void f() const noexcept requires foobar;  // bad
> 
> void f() const noexcept  // better
>   requires foobar;
> ```
> If you do that, then (in my proposed world) you would also automatically get
> ```
> template
>   requires foobar  // automatically
> void f();
> 
> template requires foobar  // can't get this
> void f();
> 
> template  // could also get this, via manual intervention
> void f();
> ```
> And personally I see nothing wrong with that state of affairs.
I still can imagine someone maybe wants it different, but for now I go with 
your suggestion, only one option for all clauses.


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

https://reviews.llvm.org/D113319

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


[PATCH] D118996: [clang-tidy] Support C++14 in bugprone-signal-handler.

2022-02-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:41
 
+bool isInNoNamespace(const FunctionDecl *FD) {
+  const DeclContext *DC = FD->getDeclContext();

`isInGlobalNamespace` might be a better name?



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:126-129
+  if (LangOpts.CPlusPlus17)
 return false;
 
   return true;

`return LangOpts.CPlusPlus17 == 0;`



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:142-149
   Finder->addMatcher(
   callExpr(callee(SignalFunction), hasArgument(1, HandlerExpr))
   .bind("register_call"),
   this);
+  Finder->addMatcher(
+  callExpr(callee(SignalFunction), hasArgument(1, HandlerLambda))
+  .bind("register_call"),

Is there any utility/performance to be gained by combining these into a single 
matcher?
e.g.
```
callExpr(callee(SignalFunction), anyOf(hasArgument(1, HandlerExpr), 
hasArgument(1, HandlerLambda)))
```
(not sure if that is syntactically valid, but you get my point)



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:207-215
+})) {
+// Found problems in this function, skip functions called from it.
+Itr.skipChildren();
+  } else {
+++Itr;
+  }
+} else {

Style guide says no braces on single statement blocks



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:247
 
+  if (!getLangOpts().CPlusPlus17 && getLangOpts().CPlusPlus)
+return checkFunctionCPP14(FD, CallOrRef, ChainReporter);

How can the first expression here ever be false when
we rejected C++17 in the `isLanguageVersionSupported`
override?



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:275
+const auto *FoundS = Match.getNodeAs("stmt");
+StringRef Name = FoundS->getStmtClassName();
+if (Name.startswith("CXX")) {

Hrm, I was curious what `getStmtClassName()` does, but there doesn't seem to be 
any doxygen on it or the underlying data structure it accesses.  Drilling into 
it with the IDE seems to say that it's a bunch of enums and corresponding names 
for each statement kind?



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:323-325
+if (SkipPathEnd) {
+  SkipPathEnd = false;
+} else {

drop braces on 'then' block per style guide



Comment at: clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp:334-338
+  if (!SkipPathEnd) {
+diag(HandlerRef->getBeginLoc(),
+ "function %0 registered here as signal handler", DiagnosticIDs::Note)
+<< cast(Caller->getDecl());
+  }

drop braces per style guide


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118996

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


[PATCH] D117830: [HeaderSearch] Track framework name in LookupFile

2022-02-04 Thread David Goldman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
dgoldman marked an inline comment as done.
Closed by commit rG9385ece95a4a: [HeaderSearch] Track framework name in 
LookupFile (authored by dgoldman).

Changed prior to commit:
  https://reviews.llvm.org/D117830?vs=403340=406035#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117830

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/unittests/Lex/HeaderSearchTest.cpp


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -186,6 +186,29 @@
 "Sub/Sub.h");
 }
 
+TEST_F(HeaderSearchTest, HeaderFrameworkLookup) {
+  std::string HeaderPath = "/tmp/Frameworks/Foo.framework/Headers/Foo.h";
+  addSystemFrameworkSearchDir("/tmp/Frameworks");
+  VFS->addFile(
+  HeaderPath, 0, llvm::MemoryBuffer::getMemBufferCopy("", HeaderPath),
+  /*User=*/None, /*Group=*/None, llvm::sys::fs::file_type::regular_file);
+
+  bool IsFrameworkFound = false;
+  auto FoundFile = Search.LookupFile(
+  "Foo/Foo.h", SourceLocation(), /*isAngled=*/true, /*FromDir=*/nullptr,
+  /*CurDir=*/nullptr, /*Includers=*/{}, /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr, /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*IsMapped=*/nullptr, );
+
+  EXPECT_TRUE(FoundFile.hasValue());
+  EXPECT_TRUE(IsFrameworkFound);
+  auto  = FoundFile.getValue();
+  auto FI = Search.getExistingFileInfo(FE);
+  EXPECT_TRUE(FI);
+  EXPECT_TRUE(FI->IsValid);
+  EXPECT_EQ(FI->Framework.str(), "Foo");
+}
+
 // Helper struct with null terminator character to make MemoryBuffer happy.
 template 
 struct NullTerminatedFile : public FileTy {
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1037,8 +1037,9 @@
   }
 }
 
-// If this file is found in a header map and uses the framework style of
-// includes, then this header is part of a framework we're building.
+// Set the `Framework` info if this file is in a header map with framework
+// style include spelling or found in a framework dir. The header map case
+// is possible when building frameworks which use header maps.
 if (CurDir->isHeaderMap() && isAngled) {
   size_t SlashPos = Filename.find('/');
   if (SlashPos != StringRef::npos)
@@ -1046,6 +1047,11 @@
 getUniqueFrameworkName(StringRef(Filename.begin(), SlashPos));
   if (CurDir->isIndexHeaderMap())
 HFI.IndexHeaderMapHeader = 1;
+} else if (CurDir->isFramework()) {
+  size_t SlashPos = Filename.find('/');
+  if (SlashPos != StringRef::npos)
+HFI.Framework =
+getUniqueFrameworkName(StringRef(Filename.begin(), SlashPos));
 }
 
 if (checkMSVCHeaderSearch(Diags, MSFE ? >getFileEntry() : nullptr,


Index: clang/unittests/Lex/HeaderSearchTest.cpp
===
--- clang/unittests/Lex/HeaderSearchTest.cpp
+++ clang/unittests/Lex/HeaderSearchTest.cpp
@@ -186,6 +186,29 @@
 "Sub/Sub.h");
 }
 
+TEST_F(HeaderSearchTest, HeaderFrameworkLookup) {
+  std::string HeaderPath = "/tmp/Frameworks/Foo.framework/Headers/Foo.h";
+  addSystemFrameworkSearchDir("/tmp/Frameworks");
+  VFS->addFile(
+  HeaderPath, 0, llvm::MemoryBuffer::getMemBufferCopy("", HeaderPath),
+  /*User=*/None, /*Group=*/None, llvm::sys::fs::file_type::regular_file);
+
+  bool IsFrameworkFound = false;
+  auto FoundFile = Search.LookupFile(
+  "Foo/Foo.h", SourceLocation(), /*isAngled=*/true, /*FromDir=*/nullptr,
+  /*CurDir=*/nullptr, /*Includers=*/{}, /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr, /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*IsMapped=*/nullptr, );
+
+  EXPECT_TRUE(FoundFile.hasValue());
+  EXPECT_TRUE(IsFrameworkFound);
+  auto  = FoundFile.getValue();
+  auto FI = Search.getExistingFileInfo(FE);
+  EXPECT_TRUE(FI);
+  EXPECT_TRUE(FI->IsValid);
+  EXPECT_EQ(FI->Framework.str(), "Foo");
+}
+
 // Helper struct with null terminator character to make MemoryBuffer happy.
 template 
 struct NullTerminatedFile : public FileTy {
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1037,8 +1037,9 @@
   }
 }
 
-// If this file is found in a header map and uses the framework style of
-// includes, then this header is part of a framework we're building.
+// Set the `Framework` info if this file is in a header map with framework
+// style include spelling or found in a framework dir. The header map case
+// is possible when building frameworks which 

[clang] 9385ece - [HeaderSearch] Track framework name in LookupFile

2022-02-04 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-02-04T13:32:39-05:00
New Revision: 9385ece95a4a342ca4f4c46ea747f79d4ede9783

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

LOG: [HeaderSearch] Track framework name in LookupFile

Previously, the Framework name was only set if the file
came from a header mapped framework; now we'll always
set the framework name if the file is in a framework.

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

Added: 


Modified: 
clang/lib/Lex/HeaderSearch.cpp
clang/unittests/Lex/HeaderSearchTest.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 39c125c395ef8..19e284f04b38c 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1037,8 +1037,9 @@ Optional HeaderSearch::LookupFile(
   }
 }
 
-// If this file is found in a header map and uses the framework style of
-// includes, then this header is part of a framework we're building.
+// Set the `Framework` info if this file is in a header map with framework
+// style include spelling or found in a framework dir. The header map case
+// is possible when building frameworks which use header maps.
 if (CurDir->isHeaderMap() && isAngled) {
   size_t SlashPos = Filename.find('/');
   if (SlashPos != StringRef::npos)
@@ -1046,6 +1047,11 @@ Optional HeaderSearch::LookupFile(
 getUniqueFrameworkName(StringRef(Filename.begin(), SlashPos));
   if (CurDir->isIndexHeaderMap())
 HFI.IndexHeaderMapHeader = 1;
+} else if (CurDir->isFramework()) {
+  size_t SlashPos = Filename.find('/');
+  if (SlashPos != StringRef::npos)
+HFI.Framework =
+getUniqueFrameworkName(StringRef(Filename.begin(), SlashPos));
 }
 
 if (checkMSVCHeaderSearch(Diags, MSFE ? >getFileEntry() : nullptr,

diff  --git a/clang/unittests/Lex/HeaderSearchTest.cpp 
b/clang/unittests/Lex/HeaderSearchTest.cpp
index 10ecbbd26659e..fbb5cb30754a7 100644
--- a/clang/unittests/Lex/HeaderSearchTest.cpp
+++ b/clang/unittests/Lex/HeaderSearchTest.cpp
@@ -186,6 +186,29 @@ TEST_F(HeaderSearchTest, NestedFramework) {
 "Sub/Sub.h");
 }
 
+TEST_F(HeaderSearchTest, HeaderFrameworkLookup) {
+  std::string HeaderPath = "/tmp/Frameworks/Foo.framework/Headers/Foo.h";
+  addSystemFrameworkSearchDir("/tmp/Frameworks");
+  VFS->addFile(
+  HeaderPath, 0, llvm::MemoryBuffer::getMemBufferCopy("", HeaderPath),
+  /*User=*/None, /*Group=*/None, llvm::sys::fs::file_type::regular_file);
+
+  bool IsFrameworkFound = false;
+  auto FoundFile = Search.LookupFile(
+  "Foo/Foo.h", SourceLocation(), /*isAngled=*/true, /*FromDir=*/nullptr,
+  /*CurDir=*/nullptr, /*Includers=*/{}, /*SearchPath=*/nullptr,
+  /*RelativePath=*/nullptr, /*RequestingModule=*/nullptr,
+  /*SuggestedModule=*/nullptr, /*IsMapped=*/nullptr, );
+
+  EXPECT_TRUE(FoundFile.hasValue());
+  EXPECT_TRUE(IsFrameworkFound);
+  auto  = FoundFile.getValue();
+  auto FI = Search.getExistingFileInfo(FE);
+  EXPECT_TRUE(FI);
+  EXPECT_TRUE(FI->IsValid);
+  EXPECT_EQ(FI->Framework.str(), "Foo");
+}
+
 // Helper struct with null terminator character to make MemoryBuffer happy.
 template 
 struct NullTerminatedFile : public FileTy {



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


[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

In D116637#3297387 , @cmtice wrote:

> This commit is causing some of our builds to fail with these errors:
>
> clang/lib/Sema/SemaOpenMP.cpp:11372:9: error: unused variable 'D' 
> [-Werror,-Wunused-variable]
>
>   Expr *D = nullptr;
> ^
>
> clang/lib/Sema/SemaOpenMP.cpp:11373:9: error: unused variable 'CE' 
> [-Werror,-Wunused-variable]
>
>   Expr *CE = nullptr;
> ^
>
> 2 errors generated.
>
> Would you please fix this?

Yeah, I noticed that. It's been fixed now. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[clang] 012c811 - [Clang][Sema][OpenMP] Remove unused variables. NFC.

2022-02-04 Thread Benjamin Kramer via cfe-commits

Author: Benjamin Kramer
Date: 2022-02-04T19:27:59+01:00
New Revision: 012c811fed44da85f9870df9accf4477e626a012

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

LOG: [Clang][Sema][OpenMP] Remove unused variables. NFC.

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 1fafd58ba3ed..4143e070a873 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -11369,8 +11369,6 @@ StmtResult 
Sema::ActOnOpenMPAtomicDirective(ArrayRef Clauses,
   Expr *V = nullptr;
   Expr *E = nullptr;
   Expr *UE = nullptr;
-  Expr *D = nullptr;
-  Expr *CE = nullptr;
   bool IsXLHSInRHSPart = false;
   bool IsPostfixUpdate = false;
   // OpenMP [2.12.6, atomic Construct]



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


[PATCH] D118900: [ASTMatchers] Expand isInline matcher to VarDecl

2022-02-04 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added inline comments.



Comment at: clang/docs/LibASTMatchersReference.html:5736
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisInline
+Matches function and 
namespace declarations that are marked with
+the inline keyword.

Izaron wrote:
> > Matches function and namespace declarations
> Could it be something like
> > Matches variable, function and namespace declarations
> ?
> 
> Also, maybe it worth to mention the checker in release notes? In 
> `clang/docs/ReleaseNotes.rst`
(The matcher, not checker, of course)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118900

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


[PATCH] D118900: [ASTMatchers] Expand isInline matcher to VarDecl

2022-02-04 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added inline comments.



Comment at: clang/docs/LibASTMatchersReference.html:5736
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1VarDecl.html;>VarDeclisInline
+Matches function and 
namespace declarations that are marked with
+the inline keyword.

> Matches function and namespace declarations
Could it be something like
> Matches variable, function and namespace declarations
?

Also, maybe it worth to mention the checker in release notes? In 
`clang/docs/ReleaseNotes.rst`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118900

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


[PATCH] D118977: [NVPTX] Add more FMA intriniscs/builtins

2022-02-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> They all require PTX 7.0, SM_80.

According to 
https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#half-precision-floating-point-instructions-fma
 only `fma.relu` and `bf16*` variants require ptx70/sm80:

  PTX ISA Notes
  Introduced in PTX ISA version 4.2.
  
  fma.relu.{f16, f16x2} and fma{.relu}.{bf16, bf16x2} introduced in PTX ISA 
version 7.0.
  
  Target ISA Notes
  Requires sm_53 or higher.
  
  fma.relu.{f16, f16x2} and fma{.relu}.{bf16, bf16x2} require sm_80 or higher.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118977

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


[PATCH] D118900: [ASTMatchers] Expand isInline matcher to VarDecl

2022-02-04 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

Thanks for the matcher! I'm planning to reuse it in my checker (D118743 
). Looking forward to seeing this commit 
merged.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118900

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


[PATCH] D118922: [ASTMatchers] The `isInline` matcher now accepts inline variables

2022-02-04 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron abandoned this revision.
Izaron added a comment.

In D118922#3296542 , @njames93 wrote:

> I had the same idea in D118900 

Wow! That's a curious coincidence. I'm closing my PR =) Let it be your version 
as the earlier one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118922

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


[PATCH] D119018: [OpenMP] Add -Bsymbolic to arguments for GNU linker

2022-02-04 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield accepted this revision.
JonChesterfield added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119018

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


[PATCH] D119018: [OpenMP] Add -Bsymbolic to arguments for GNU linker

2022-02-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 406027.
jhuber6 added a comment.

More informative error message.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119018

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -577,6 +577,14 @@
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally. The
+  // symbols are already protected which makes this redundant. This is only
+  // necessary to work around a problem in bfd.
+  // TODO: Remove this once 'lld' becomes the only linker for offloading.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -577,6 +577,14 @@
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally. The
+  // symbols are already protected which makes this redundant. This is only
+  // necessary to work around a problem in bfd.
+  // TODO: Remove this once 'lld' becomes the only linker for offloading.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118927: [clang-tidy] Fix invalid fix-it for cppcoreguidelines-prefer-member-initializer

2022-02-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood accepted this revision.
LegalizeAdulthood 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/D118927/new/

https://reviews.llvm.org/D118927

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


[PATCH] D119018: [OpenMP] Add -Bsymbolic to arguments for GNU linker

2022-02-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D119018#3297391 , @JonChesterfield 
wrote:

> Can we drop an xfail in an existing test as part of this patch?

We can drop an XFAIL for AMDGPU, but that's not related to the problem this 
fixes, we don't have any XFAIL lines for x86 tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119018

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


[PATCH] D118927: [clang-tidy] Fix invalid fix-it for cppcoreguidelines-prefer-member-initializer

2022-02-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp:251
+  if (InsertPos.isValid())
+InvalidFix |= InsertPos.isMacroID();
+  else

I'm not a fan of using bit-wise operators on booleans, but I see that
the code for this check was already doing that.
(See https://github.com/llvm/llvm-project/issues/40307)



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp:293
 << Field;
 if (!InvalidFix) {
+  StringRef NewInit = Lexer::getSourceText(

I'm not a fan of double negatives either `:)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118927

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


[PATCH] D119018: [OpenMP] Add -Bsymbolic to arguments for GNU linker

2022-02-04 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Can we drop an xfail in an existing test as part of this patch?




Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:581
+
+  // If we are linking for the device all symbols should be bound locally.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))

Perhaps a comment to the effect that the symbols are protected which makes 
Bsymbolic redundant, except in that it works around an issue in bfd?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119018

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


[PATCH] D116637: [Clang][Sema][OpenMP] Sema support for `atomic compare`

2022-02-04 Thread Caroline Tice via Phabricator via cfe-commits
cmtice added a comment.

This commit is causing some of our builds to fail with these errors:

clang/lib/Sema/SemaOpenMP.cpp:11372:9: error: unused variable 'D' 
[-Werror,-Wunused-variable]

  Expr *D = nullptr;
^

clang/lib/Sema/SemaOpenMP.cpp:11373:9: error: unused variable 'CE' 
[-Werror,-Wunused-variable]

  Expr *CE = nullptr;
^

2 errors generated.

Would you please fix this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116637

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


[PATCH] D119011: [clang] Cache OpenCL types

2022-02-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D119011#3297305 , @Anastasia wrote:

> Just to understand the intent - is this a performance optimization or 
> functionality fix?

This is a functionality fix.

> Also is there any way to test this?

I came across this while working on another patch. This should be NFC with ToT 
clang, but was required my other patch. Since this part was easily split apart 
I wanted to do that.
Separately I think this makes sense in general.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119011

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


[PATCH] D119011: [clang] Cache OpenCL types

2022-02-04 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 406024.
aeubanks added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119011

Files:
  clang/lib/CodeGen/CGOpenCLRuntime.cpp
  clang/lib/CodeGen/CGOpenCLRuntime.h


Index: clang/lib/CodeGen/CGOpenCLRuntime.h
===
--- clang/lib/CodeGen/CGOpenCLRuntime.h
+++ clang/lib/CodeGen/CGOpenCLRuntime.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
 
@@ -38,6 +39,7 @@
   llvm::Type *PipeROTy;
   llvm::Type *PipeWOTy;
   llvm::PointerType *SamplerTy;
+  llvm::StringMap CachedTys;
 
   /// Structure for enqueued block information.
   struct EnqueuedBlockInfo {
@@ -50,6 +52,7 @@
 
   virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name,
   llvm::Type *);
+  llvm::PointerType *getPointerType(const Type *T, StringRef Name);
 
 public:
   CGOpenCLRuntime(CodeGenModule ) : CGM(CGM),
Index: clang/lib/CodeGen/CGOpenCLRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenCLRuntime.cpp
+++ clang/lib/CodeGen/CGOpenCLRuntime.cpp
@@ -34,41 +34,46 @@
   assert(T->isOpenCLSpecificType() &&
  "Not an OpenCL specific type!");
 
-  llvm::LLVMContext& Ctx = CGM.getLLVMContext();
-  uint32_t AddrSpc = CGM.getContext().getTargetAddressSpace(
-  CGM.getContext().getOpenCLTypeAddrSpace(T));
   switch (cast(T)->getKind()) {
   default:
 llvm_unreachable("Unexpected opencl builtin type!");
 return nullptr;
-#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
-  case BuiltinType::Id: \
-return llvm::PointerType::get( \
-llvm::StructType::create(Ctx, "opencl." #ImgType "_" #Suffix "_t"), \
-AddrSpc);
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix)   
\
+  case BuiltinType::Id:
\
+return getPointerType(T, "opencl." #ImgType "_" #Suffix "_t");
 #include "clang/Basic/OpenCLImageTypes.def"
   case BuiltinType::OCLSampler:
 return getSamplerType(T);
   case BuiltinType::OCLEvent:
-return llvm::PointerType::get(
-llvm::StructType::create(Ctx, "opencl.event_t"), AddrSpc);
+return getPointerType(T, "opencl.event_t");
   case BuiltinType::OCLClkEvent:
-return llvm::PointerType::get(
-llvm::StructType::create(Ctx, "opencl.clk_event_t"), AddrSpc);
+return getPointerType(T, "opencl.clk_event_t");
   case BuiltinType::OCLQueue:
-return llvm::PointerType::get(
-llvm::StructType::create(Ctx, "opencl.queue_t"), AddrSpc);
+return getPointerType(T, "opencl.queue_t");
   case BuiltinType::OCLReserveID:
-return llvm::PointerType::get(
-llvm::StructType::create(Ctx, "opencl.reserve_id_t"), AddrSpc);
-#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
-  case BuiltinType::Id: \
-return llvm::PointerType::get( \
-llvm::StructType::create(Ctx, "opencl." #ExtType), AddrSpc);
+return getPointerType(T, "opencl.reserve_id_t");
+#define EXT_OPAQUE_TYPE(ExtType, Id, Ext)  
\
+  case BuiltinType::Id:
\
+return getPointerType(T, "opencl." #ExtType);
 #include "clang/Basic/OpenCLExtensionTypes.def"
   }
 }
 
+llvm::PointerType *CGOpenCLRuntime::getPointerType(const Type *T,
+   StringRef Name) {
+  auto I = CachedTys.find(Name);
+  if (I != CachedTys.end())
+return I->second;
+
+  llvm::LLVMContext  = CGM.getLLVMContext();
+  uint32_t AddrSpc = CGM.getContext().getTargetAddressSpace(
+  CGM.getContext().getOpenCLTypeAddrSpace(T));
+  auto *PTy =
+  llvm::PointerType::get(llvm::StructType::create(Ctx, Name), AddrSpc);
+  CachedTys[Name] = PTy;
+  return PTy;
+}
+
 llvm::Type *CGOpenCLRuntime::getPipeType(const PipeType *T) {
   if (T->isReadOnly())
 return getPipeType(T, "opencl.pipe_ro_t", PipeROTy);


Index: clang/lib/CodeGen/CGOpenCLRuntime.h
===
--- clang/lib/CodeGen/CGOpenCLRuntime.h
+++ clang/lib/CodeGen/CGOpenCLRuntime.h
@@ -18,6 +18,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/Type.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/StringMap.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Value.h"
 
@@ -38,6 +39,7 @@
   llvm::Type *PipeROTy;
   llvm::Type *PipeWOTy;
   llvm::PointerType *SamplerTy;
+  llvm::StringMap CachedTys;
 
   /// Structure for enqueued block information.
   struct EnqueuedBlockInfo {
@@ -50,6 +52,7 @@
 
   virtual llvm::Type *getPipeType(const PipeType *T, StringRef Name,
   llvm::Type *);
+  llvm::PointerType 

[PATCH] D119017: [clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".

2022-02-04 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

Approving the delta for the PS4 fix (relying or @rsmith 's approval for the 
actual patch -- https://reviews.llvm.org/D114732).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119017

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


[PATCH] D119018: [OpenMP] Add -Bsymbolic to arguments for GNU linker

2022-02-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 406022.
jhuber6 added a comment.

Clang format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119018

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -577,6 +577,11 @@
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -577,6 +577,11 @@
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119018: [OpenMP] Add -Bsymbolic to arguments for GNU linker

2022-02-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, jdoerfert, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch adds the '-Bsymbolic' flag when we perform linking for the
offloading device. We already pass '-fvisibility=protected' but this is
not properly handled when using the bfd linker as is described in
https://maskray.me/blog/2021-05-16-elf-interposition-and-bsymbolic.
Previously this caused linker errors when creating the shared library.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119018

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -577,6 +577,11 @@
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+  
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -577,6 +577,11 @@
 }
 CmdArgs.push_back("-lm");
   }
+
+  // If we are linking for the device all symbols should be bound locally.
+  if (JA.isDeviceOffloading(Action::OFK_OpenMP))
+CmdArgs.push_back("-Bsymbolic");
+  
   // Silence warnings when linking C code with a C++ '-stdlib' argument.
   Args.ClaimAllArgs(options::OPT_stdlib_EQ);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118104: Make run-clang-tidy.py print the configured checks correctly

2022-02-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

In D118104#3295876 , @JesApp wrote:

> In D118104#3294883 , 
> @LegalizeAdulthood wrote:
>
>> What is the feasibility of Python unit tests Instead of a heavy-weight `lit` 
>> oriented test?
>
> I don't know the code-base well enough to answer that. Is python used for 
> testing purposes anywhere else?

I'm not sure; this is a little bit unusual because there is not much production
python code in llvm/clang.  I'm actually bumping into some grief in 
`check_clang_tidy.py`
that might go easier if I were to unit test some of the python itself.

> Anyway, I'm new here, so I don't want to tell you guys how to run things,
> but: In the projects I usually work on, a fix would get merged quickly and 
> things
> like "let's write a test suite for this script" would go in the backlog. 
> What's your
> opinion on that?

In this case, I think it's fine.  Generally speaking though, the coding 
guidelines for llvm/clang
require that tests be added alongside the new features or bug fixes.  This is 
certainly the case
when we add new checks, for instance.

See https://llvm.org/docs/DeveloperPolicy.html#test-cases


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

https://reviews.llvm.org/D118104

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


[PATCH] D119017: [clang] roll-forward "[clang] Mark `trivial_abi` types as "trivially relocatable"".

2022-02-04 Thread Devin Jeanpierre via Phabricator via cfe-commits
devin.jeanpierre created this revision.
devin.jeanpierre added a reviewer: gribozavr2.
Herald added a reviewer: aaron.ballman.
Herald added a subscriber: dexonsmith.
devin.jeanpierre requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit 852afed5e0200b70047c28ccf4424a17089d17b0 
.

Changes since D114732 :

On PS4, we reverse the expectation that classes whose constructor is deleted 
are not trivially relocatable. Because, at the moment, only classes which are 
passed in registers are trivially relocatable, and PS4 allows passing in 
registers if the copy constructor is deleted, the original assertions were 
broken on PS4.

(This is kinda similar to DR1734.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119017

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp
  clang/test/SemaCXX/type-traits.cpp
  clang/test/SemaObjCXX/arc-type-traits.mm
  clang/test/SemaObjCXX/objc-weak-type-traits.mm

Index: clang/test/SemaObjCXX/objc-weak-type-traits.mm
===
--- clang/test/SemaObjCXX/objc-weak-type-traits.mm
+++ clang/test/SemaObjCXX/objc-weak-type-traits.mm
@@ -8,7 +8,7 @@
 #define TRAIT_IS_FALSE(Trait, Type) static_assert(!Trait(Type), "")
 #define TRAIT_IS_TRUE_2(Trait, Type1, Type2) static_assert(Trait(Type1, Type2), "")
 #define TRAIT_IS_FALSE_2(Trait, Type1, Type2) static_assert(!Trait(Type1, Type2), "")
-  
+
 struct HasStrong { id obj; };
 struct HasWeak { __weak id obj; };
 struct HasUnsafeUnretained { __unsafe_unretained id obj; };
@@ -208,3 +208,12 @@
 TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak&&);
 TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained);
 TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained&&);
+
+// __is_trivially_relocatable
+TRAIT_IS_TRUE(__is_trivially_relocatable, __strong id);
+TRAIT_IS_FALSE(__is_trivially_relocatable, __weak id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __autoreleasing id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __unsafe_unretained id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, HasStrong);
+TRAIT_IS_FALSE(__is_trivially_relocatable, HasWeak);
+TRAIT_IS_TRUE(__is_trivially_relocatable, HasUnsafeUnretained);
Index: clang/test/SemaObjCXX/arc-type-traits.mm
===
--- clang/test/SemaObjCXX/arc-type-traits.mm
+++ clang/test/SemaObjCXX/arc-type-traits.mm
@@ -12,7 +12,7 @@
 #define TRAIT_IS_FALSE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? -1 : 1]
 #define TRAIT_IS_TRUE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? 1 : -1]
 #define TRAIT_IS_FALSE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? -1 : 1]
-  
+
 struct HasStrong { id obj; };
 struct HasWeak { __weak id obj; };
 struct HasUnsafeUnretained { __unsafe_unretained id obj; };
@@ -213,3 +213,11 @@
 TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained);
 TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained&&);
 
+// __is_trivially_relocatable
+TRAIT_IS_TRUE(__is_trivially_relocatable, __strong id);
+TRAIT_IS_FALSE(__is_trivially_relocatable, __weak id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __autoreleasing id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, __unsafe_unretained id);
+TRAIT_IS_TRUE(__is_trivially_relocatable, HasStrong);
+TRAIT_IS_FALSE(__is_trivially_relocatable, HasWeak);
+TRAIT_IS_TRUE(__is_trivially_relocatable, HasUnsafeUnretained);
Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -2854,3 +2854,64 @@
 #undef T16384
 #undef T32768
 } // namespace type_trait_expr_numargs_overflow
+
+namespace is_trivially_relocatable {
+
+static_assert(!__is_trivially_relocatable(void), "");
+static_assert(__is_trivially_relocatable(int), "");
+static_assert(__is_trivially_relocatable(int[]), "");
+
+enum Enum {};
+static_assert(__is_trivially_relocatable(Enum), "");
+static_assert(__is_trivially_relocatable(Enum[]), "");
+
+union Union {int x;};
+static_assert(__is_trivially_relocatable(Union), "");
+static_assert(__is_trivially_relocatable(Union[]), "");
+
+struct Trivial {};
+static_assert(__is_trivially_relocatable(Trivial), "");
+static_assert(__is_trivially_relocatable(Trivial[]), "");
+
+struct Incomplete; // expected-note {{forward declaration of 'is_trivially_relocatable::Incomplete'}}
+bool unused = 

[PATCH] D118999: [OpenCL] Adjust diagnostic for subgroup support.

2022-02-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D118999#3296899 , @azabaznov wrote:

> It seems hard to find a direct mention in the spec, but in the API spec:
>
> //CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS: Is CL_TRUE if this device 
> supports independent forward progress of sub-groups, CL_FALSE otherwise. This 
> query must return CL_TRUE for devices that support the cl_khr_subgroups 
> extension, and must return CL_FALSE for devices that do not support 
> subgroups.//

Ok, I would agree that the wording doesn't seem identical since the extension 
explicitly details forward progress behavior but the feature doesn't:
https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#cl_khr_subgroups

But I think it would make sense to add wording of it in the feature spec too 
otherwise it appears unspecified?

Anyway, at present, since they are not identical having separate handling of 
these teo seems reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118999

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


[PATCH] D118104: Make run-clang-tidy.py print the configured checks correctly

2022-02-04 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

In D118104#3296467 , @salman-javed-nz 
wrote:

> Anyway, I don't want what was a drive-by comment by me baloon into a lot of 
> extra work for the author, so I will not push for it, unless others really 
> want it.

I think it's reasonable to accept this change and have the tests added as a 
follow-up change.


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

https://reviews.llvm.org/D118104

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


[PATCH] D119011: [clang] Cache OpenCL types

2022-02-04 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Just to understand the intent - is this a performance optimization or 
functionality fix?

Also is there any way to test this?




Comment at: clang/lib/CodeGen/CGOpenCLRuntime.h:42
   llvm::PointerType *SamplerTy;
+  llvm::StringMap Tys;
 

Maybe it can be named CachedTys?



Comment at: clang/lib/CodeGen/CGOpenCLRuntime.h:55
   llvm::Type *);
+  llvm::PointerType *getType(const Type *T, StringRef Name);
 

getType -> getPointerType ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119011

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


[PATCH] D113620: Skip exception cleanups when the innermost scope is EHTerminateScope.

2022-02-04 Thread Haowei Wu via Phabricator via cfe-commits
haowei added a comment.

Hi,  we are seeing clang Windows build breakages after this change was relanded 
error message:

  Assertion failed: isa(Val) && "cast() argument of incompatible type!", 
file C:\b\s\w\ir\x\w\llvm-llvm-project\llvm\include\llvm/Support/Casting.h, 
line 262
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: 
C:\\b\\s\\w\\ir\\x\\w\\staging\\llvm_build\\.\\bin\\clang-cl.exe /nologo -TP 
-DNDEBUG -DUNICODE -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH 
-D_ALLOW_MSC_VER_MISMATCH -D_CRTBLD -D_CRT_NONSTDC_NO_DEPRECATE 
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS 
-D_CRT_STDIO_ISO_WIDE_SPECIFIERS -D_LIBCPP_BUILDING_LIBRARY 
-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-IC:\\b\\s\\w\\ir\\x\\w\\llvm-llvm-project\\libcxx\\src /DWIN32 /D_WINDOWS 
/Zc:inline /Zc:__cplusplus /Zc:strictStrings /Oi /Zc:rvalueCast /bigobj /W4 
-wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 
-wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 
-wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 
-wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw 
-no-canonical-prefixes --target=x86_64-pc-windows-msvc /MD /Zi /O2 /Ob1 
--target=x86_64-pc-windows-msvc -UNDEBUG -W4 -Wextra -W -Wwrite-strings 
-Wno-unused-parameter -Wno-long-long -Werror=return-type -Wextra-semi -Wundef 
-Wformat-nonliteral -Wno-user-defined-literals -Wno-covered-switch-default 
-Wno-suggest-override -Wno-c++98-compat -Wno-c++98-compat-pedantic 
-Wno-c++11-compat -Wno-undef -Wno-reserved-id-macro -Wno-gnu-include-next 
-Wno-gcc-compat -Wno-zero-as-null-pointer-constant 
-Wno-deprecated-dynamic-exception-spec -Wno-sign-conversion -Wno-old-style-cast 
-Wno-deprecated -Wno-shift-sign-overflow -Wno-double-promotion -Wno-error -EHsc 
/IC:/b/s/w/ir/x/w/staging/llvm_build/include/c++/v1 
/IC:/b/s/w/ir/x/w/staging/llvm_build/include/x86_64-pc-windows-msvc/c++/v1 
-std:c++latest /showIncludes 
/Folibcxx\\src\\CMakeFiles\\cxx_static.dir\\future.cpp.obj 
/Fdlibcxx\\src\\CMakeFiles\\cxx_static.dir\\cxx_static.pdb -c 
C:\\b\\s\\w\\ir\\x\\w\\llvm-llvm-project\\libcxx\\src\\future.cpp
  1. parser at end of file
  2.C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\src\future.cpp:16:1 
: 
LLVM IR generation of declaration 'std'
  3.C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\src\future.cpp:204:16: 
Generating code for declaration 'std::promise::~promise'
  4.C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\src\future.cpp:205:1: LLVM IR 
generation of compound statement ('{}')
  5.C:\b\s\w\ir\x\w\llvm-llvm-project\libcxx\src\future.cpp:207:5: LLVM IR 
generation of compound statement ('{}')

We confirmed it by local bisecting. Full build log: 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8823297314867545825/+/u/clang/build/stdout
Could you take a look? If it takes time to fix, could you revert the change 
please. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113620

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


[PATCH] D118632: [WIP][Clang]OpenMP] Add the codegen support for `atomic compare`

2022-02-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 406012.
tianshilei1992 marked an inline comment as done.
tianshilei1992 added a comment.

remove leftovers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118632

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp

Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -11767,14 +11767,18 @@
   << ErrorInfo.Error << ErrorInfo.NoteRange;
   return StmtError();
 }
-// TODO: We don't set X, D, E, etc. here because in code gen we will emit
-// error directly.
+X = Checker.getX();
+E = Checker.getE();
+D = Checker.getD();
+CE = Checker.getCond();
+// We reuse this bool variable to tell if it is in the form 'x ordop expr'.
+IsXLHSInRHSPart = Checker.isXBinopExpr();
   }
 
   setFunctionHasBranchProtectedScope();
 
   return OMPAtomicDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
-X, V, E, UE, IsXLHSInRHSPart,
+X, V, E, UE, D, CE, IsXLHSInRHSPart,
 IsPostfixUpdate);
 }
 
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6011,11 +6011,50 @@
   }
 }
 
+static void emitOMPAtomicCompareExpr(CodeGenFunction ,
+ llvm::AtomicOrdering AO, const Expr *X,
+ const Expr *E, const Expr *D,
+ const Expr *CE, bool IsXBinopExpr,
+ SourceLocation Loc) {
+
+  llvm::OpenMPIRBuilder  =
+  CGF.CGM.getOpenMPRuntime().getOMPBuilder();
+
+  OMPAtomicCompareOp Op;
+  assert(isa(CE) && "CE is not a BinaryOperator");
+  switch (cast(CE)->getOpcode()) {
+  case BO_EQ:
+Op = OMPAtomicCompareOp::EQ;
+break;
+  case BO_LT:
+Op = OMPAtomicCompareOp::MIN;
+break;
+  case BO_GT:
+Op = OMPAtomicCompareOp::MAX;
+break;
+  default:
+llvm_unreachable("unsupported atomic compare binary operator");
+  }
+
+  LValue XLVal = CGF.EmitLValue(X);
+  llvm::Value *XPtr = XLVal.getPointer(CGF);
+  llvm::Value *EVal = CGF.EmitScalarExpr(E);
+  llvm::Value *DVal = D ? CGF.EmitScalarExpr(D) : nullptr;
+
+  llvm::OpenMPIRBuilder::AtomicOpValue XOpVal{
+  XPtr, XPtr->getType()->getPointerElementType(),
+  X->getType().isVolatileQualified(),
+  X->getType()->hasSignedIntegerRepresentation()};
+
+  CGF.Builder.restoreIP(OMPBuilder.createAtomicCompare(
+  CGF.Builder, XOpVal, EVal, DVal, AO, Op, IsXBinopExpr));
+}
+
 static void emitOMPAtomicExpr(CodeGenFunction , OpenMPClauseKind Kind,
   llvm::AtomicOrdering AO, bool IsPostfixUpdate,
   const Expr *X, const Expr *V, const Expr *E,
-  const Expr *UE, bool IsXLHSInRHSPart,
-  SourceLocation Loc) {
+  const Expr *UE, const Expr *D, const Expr *CE,
+  bool IsXLHSInRHSPart, SourceLocation Loc) {
   switch (Kind) {
   case OMPC_read:
 emitOMPAtomicReadExpr(CGF, AO, X, V, Loc);
@@ -6031,11 +6070,8 @@
 emitOMPAtomicCaptureExpr(CGF, AO, IsPostfixUpdate, V, X, E, UE,
  IsXLHSInRHSPart, Loc);
 break;
-  case OMPC_compare: {
-// Emit an error here.
-unsigned DiagID = CGF.CGM.getDiags().getCustomDiagID(
-DiagnosticsEngine::Error, "'atomic compare' is not supported for now");
-CGF.CGM.getDiags().Report(DiagID);
+  case OMPC_compare:
+emitOMPAtomicCompareExpr(CGF, AO, X, E, D, CE, IsXLHSInRHSPart, Loc);
 break;
   }
   case OMPC_if:
@@ -6182,8 +6218,8 @@
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(S.getAssociatedStmt());
   emitOMPAtomicExpr(*this, Kind, AO, S.isPostfixUpdate(), S.getX(), S.getV(),
-S.getExpr(), S.getUpdateExpr(), S.isXLHSInRHSPart(),
-S.getBeginLoc());
+S.getExpr(), S.getUpdateExpr(), S.getD(), S.getCondExpr(),
+S.isXLHSInRHSPart(), S.getBeginLoc());
 }
 
 static void emitCommonOMPTargetDirective(CodeGenFunction ,
Index: clang/lib/AST/StmtOpenMP.cpp
===
--- clang/lib/AST/StmtOpenMP.cpp
+++ clang/lib/AST/StmtOpenMP.cpp
@@ -863,16 +863,20 @@
!IsStandalone);
 }
 
-OMPAtomicDirective *OMPAtomicDirective::Create(
-const ASTContext , SourceLocation StartLoc, SourceLocation EndLoc,
-ArrayRef Clauses, Stmt *AssociatedStmt, Expr *X, 

[PATCH] D114732: [clang] Mark `trivial_abi` types as "trivially relocatable".

2022-02-04 Thread Devin Jeanpierre via Phabricator via cfe-commits
devin.jeanpierre added a comment.

The core difference of behavior is this, in the logic for setting 
`canPassInRegisters`:

  // Clang <= 4 used the pre-C++11 rule, which ignores move operations.
  // The PS4 platform ABI follows the behavior of Clang 3.2.
  if (CCK == TargetInfo::CCK_ClangABI4OrPS4)
return !D->hasNonTrivialDestructorForCall() &&
   !D->hasNonTrivialCopyConstructorForCall();

This is noticeably different from the non-PS4 behavior: not only does it ignore 
the move constructor, but it also does not require that a copy constructor or 
destructor even exist. And so all of the broken tests are structs where the 
copy constructor is deleted and the destructor is either trivial or deleted. On 
non-`CCK_ClangABI4OrPS4`, it is not passable in registers, but on 
`CCK_ClangABI4OrPS4` it is.

Related, but separate: DR1734, which is the same thing, but for 
`std::is_trivially_copyable`.

I believe the fix here, like for Windows, is to special-case this platform in 
the test. (Or delete these tests.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114732

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


[PATCH] D118632: [WIP][Clang]OpenMP] Add the codegen support for `atomic compare`

2022-02-04 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 406008.
tianshilei1992 added a comment.

rebase and make preparation for codegen in clang


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118632

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/atomic_ast_print.cpp

Index: clang/test/OpenMP/atomic_ast_print.cpp
===
--- clang/test/OpenMP/atomic_ast_print.cpp
+++ clang/test/OpenMP/atomic_ast_print.cpp
@@ -572,6 +572,7 @@
   int c = 0;
   int b = 0;
   int a = 0;
+  int c = 0;
 // CHECK: int a = 0;
 #pragma omp atomic
   a++;
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -11767,14 +11767,18 @@
   << ErrorInfo.Error << ErrorInfo.NoteRange;
   return StmtError();
 }
-// TODO: We don't set X, D, E, etc. here because in code gen we will emit
-// error directly.
+X = Checker.getX();
+E = Checker.getE();
+D = Checker.getD();
+CE = Checker.getCond();
+// We reuse this bool variable to tell if it is in the form 'x ordop expr'.
+IsXLHSInRHSPart = Checker.isXBinopExpr();
   }
 
   setFunctionHasBranchProtectedScope();
 
   return OMPAtomicDirective::Create(Context, StartLoc, EndLoc, Clauses, AStmt,
-X, V, E, UE, IsXLHSInRHSPart,
+X, V, E, UE, D, CE, IsXLHSInRHSPart,
 IsPostfixUpdate);
 }
 
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6011,11 +6011,52 @@
   }
 }
 
+static void emitOMPAtomicCompareExpr(CodeGenFunction ,
+ llvm::AtomicOrdering AO, const Expr *X,
+ const Expr *E, const Expr *D,
+ const Expr *CE, bool IsXBinopExpr,
+ SourceLocation Loc) {
+
+  llvm::OpenMPIRBuilder  =
+  CGF.CGM.getOpenMPRuntime().getOMPBuilder();
+  // llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
+  // CGF.AllocaInsertPt->getParent(), CGF.AllocaInsertPt->getIterator());
+
+  OMPAtomicCompareOp Op;
+  assert(isa(CE) && "CE is not a BinaryOperator");
+  switch (cast(CE)->getOpcode()) {
+  case BO_EQ:
+Op = OMPAtomicCompareOp::EQ;
+break;
+  case BO_LT:
+Op = OMPAtomicCompareOp::MIN;
+break;
+  case BO_GT:
+Op = OMPAtomicCompareOp::MAX;
+break;
+  default:
+llvm_unreachable("unsupported atomic compare binary operator");
+  }
+
+  LValue XLVal = CGF.EmitLValue(X);
+  llvm::Value *XPtr = XLVal.getPointer(CGF);
+  llvm::Value *EVal = CGF.EmitScalarExpr(E);
+  llvm::Value *DVal = D ? CGF.EmitScalarExpr(D) : nullptr;
+
+  llvm::OpenMPIRBuilder::AtomicOpValue XOpVal{
+  XPtr, XPtr->getType()->getPointerElementType(),
+  X->getType().isVolatileQualified(),
+  X->getType()->hasSignedIntegerRepresentation()};
+
+  CGF.Builder.restoreIP(OMPBuilder.createAtomicCompare(
+  CGF.Builder, XOpVal, EVal, DVal, AO, Op, IsXBinopExpr));
+}
+
 static void emitOMPAtomicExpr(CodeGenFunction , OpenMPClauseKind Kind,
   llvm::AtomicOrdering AO, bool IsPostfixUpdate,
   const Expr *X, const Expr *V, const Expr *E,
-  const Expr *UE, bool IsXLHSInRHSPart,
-  SourceLocation Loc) {
+  const Expr *UE, const Expr *D, const Expr *CE,
+  bool IsXLHSInRHSPart, SourceLocation Loc) {
   switch (Kind) {
   case OMPC_read:
 emitOMPAtomicReadExpr(CGF, AO, X, V, Loc);
@@ -6031,11 +6072,8 @@
 emitOMPAtomicCaptureExpr(CGF, AO, IsPostfixUpdate, V, X, E, UE,
  IsXLHSInRHSPart, Loc);
 break;
-  case OMPC_compare: {
-// Emit an error here.
-unsigned DiagID = CGF.CGM.getDiags().getCustomDiagID(
-DiagnosticsEngine::Error, "'atomic compare' is not supported for now");
-CGF.CGM.getDiags().Report(DiagID);
+  case OMPC_compare:
+emitOMPAtomicCompareExpr(CGF, AO, X, E, D, CE, IsXLHSInRHSPart, Loc);
 break;
   }
   case OMPC_if:
@@ -6182,8 +6220,8 @@
   LexicalScope Scope(*this, S.getSourceRange());
   EmitStopPoint(S.getAssociatedStmt());
   emitOMPAtomicExpr(*this, Kind, AO, S.isPostfixUpdate(), S.getX(), S.getV(),
-S.getExpr(), S.getUpdateExpr(), S.isXLHSInRHSPart(),
-S.getBeginLoc());
+S.getExpr(), S.getUpdateExpr(), S.getD(), S.getCondExpr(),
+S.isXLHSInRHSPart(), S.getBeginLoc());
 }
 
 static void 

  1   2   3   >