[lldb] [clang] [libc] [flang] [lld] [clang-tools-extra] [llvm] [libcxx] [compiler-rt] [lld-macho] Find objects in library search path (PR #78628)

2024-01-20 Thread Shoaib Meenai via cfe-commits


@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: mkdir -p %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s 
-o %t/hello.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
+# RUN: %lld -L %t %t/main.o %t/hello.o -o %t/a.out

smeenai wrote:

Should one of these be linked with `-l` instead of by path?

https://github.com/llvm/llvm-project/pull/78628
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [lld] [libcxxabi] [clang] [libcxx] [mlir] [openmp] [compiler-rt] [runtimes] Use LLVM libunwind from libc++abi by default (PR #77687)

2024-01-11 Thread Shoaib Meenai via cfe-commits


@@ -22,6 +22,9 @@ set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
 set(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY ON CACHE BOOL "")
 set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 
+# Android uses its own unwinder library
+set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")

smeenai wrote:

Hmm. The Android runtime unwinder is also LLVM libunwind; is there any harm in 
building and using our own instead of the NDK's? CC @rprichard 

https://github.com/llvm/llvm-project/pull/77687
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add getClangVendor() and use it in CodeGenModule.cpp (PR #75935)

2023-12-20 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai approved this pull request.

LGTM, thanks!

https://github.com/llvm/llvm-project/pull/75935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][CodeGen] Always use CLANG_VENDOR as a quoted string (PR #75935)

2023-12-19 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai requested changes to this pull request.

IIRC, applying definitions like this only to a small set of files was an 
intentional decision, to minimize rebuilding when their values changed. It 
matters much more for the commit hash than the vendor, but passing defines like 
this to every single compilation in Clang is ugly IMO. Can we instead add a 
function to Version.cpp to access the vendor (so that the correct type gets 
encoded in the function signature) and use that from CodeGenModule.cpp instead 
of referencing `CLANG_VENDOR` directly?

https://github.com/llvm/llvm-project/pull/75935
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] [clang] [llvm] [compiler-rt] [libc] [compiler-rt]Add lld into dependency for apple builds now that lld Mach-O backend is available (PR #75884)

2023-12-18 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai approved this pull request.

LGTM, thanks!

https://github.com/llvm/llvm-project/pull/75884
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 863b938 - [clang] Remove stale release note

2023-12-11 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-12-11T15:37:49-08:00
New Revision: 863b9388687d01c67de1248e48cee0df698515c0

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

LOG: [clang] Remove stale release note

This fix was merged into 17.0.3 (commit 69c8c96691c7), so the release
note for Clang 18 should be removed.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 783dc7333af7e2..d6719680d2ac70 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -401,9 +401,6 @@ Improvements to Clang's diagnostics
   (`#54678: `_).
 - Clang now prints its 'note' diagnostic in cyan instead of black, to be more 
compatible
   with terminals with dark background colors. This is also more consistent 
with GCC.
-- The fix-it emitted by ``-Wformat`` for scoped enumerations now take the
-  enumeration's underlying type into account instead of suggesting a type just
-  based on the format string specifier being used.
 - Clang now displays an improved diagnostic and a note when a defaulted special
   member is marked ``constexpr`` in a class with a virtual base class
   (`#64843: `_).



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


[clang] [clang] Only build static analyzer sources if requested (PR #71653)

2023-11-13 Thread Shoaib Meenai via cfe-commits


@@ -23,7 +23,9 @@ add_subdirectory(Tooling)
 add_subdirectory(DirectoryWatcher)
 add_subdirectory(Index)
 add_subdirectory(IndexSerialization)
-add_subdirectory(StaticAnalyzer)
+if(CLANG_ENABLE_STATIC_ANALYZER)

smeenai wrote:

I agree with Chris in general. This case is a bit different because the static 
analyzer sources would be included in Clang otherwise instead of being a 
standalone target you could just not build (roughly analogous to 
`LLVM_TARGETS_TO_BUILD`), but what are the concrete savings (build time, binary 
size, etc.) from the option, to weigh against the added build complexity?

I see some unguarded uses of the static analyzer libraries, e.g. 
`clang/tools/clang-check/CMakeLists.txt` unconditionally references 
`clangStaticAnalyzerFrontend`, so those would need to be adjusted as well if we 
went this route. It seems like that can get easily broken in the future as well 
though.

https://github.com/llvm/llvm-project/pull/71653
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] cd7ba9f - [Clang] Generate test checks (NFC)

2023-11-11 Thread Shoaib Meenai via cfe-commits
This is breaking tests when building without assertions enabled, e.g. 
https://lab.llvm.org/buildbot/#/builders/67/builds/13266/steps/7/logs/stdio, I 
think because the initial entry: label isn’t generated in such builds. Could 
you please take a look?

From: cfe-commits  on behalf of Nikita 
Popov via cfe-commits 
Date: Friday, November 10, 2023 at 7:28 AM
To: cfe-commits@lists.llvm.org 
Subject: [clang] cd7ba9f - [Clang] Generate test checks (NFC)
!---|
  This Message Is From an External Sender

|---!


Author: Nikita Popov
Date: 2023-11-10T16:27:37+01:00
New Revision: cd7ba9f3d090afb5d3b15b0dcf379d15d1e11e33

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

LOG: [Clang] Generate test checks (NFC)

Added:


Modified:
clang/test/Analysis/builtin_signbit.cpp

Removed:




diff  --git a/clang/test/Analysis/builtin_signbit.cpp 
b/clang/test/Analysis/builtin_signbit.cpp
index 251391952f9c586..a0bf7a45be1302b 100644
--- a/clang/test/Analysis/builtin_signbit.cpp
+++ b/clang/test/Analysis/builtin_signbit.cpp
@@ -1,46 +1,113 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
 // RUN: %clang -target powerpc-linux-gnu -emit-llvm -S -mabi=ibmlongdouble \
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-BE32
 // RUN: %clang -target powerpc64-linux-gnu -emit-llvm -S -mabi=ibmlongdouble \
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-BE64
 // RUN: %clang -target powerpc64le-linux-gnu -emit-llvm -S -mabi=ibmlongdouble 
\
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-LE

 bool b;
 double d = -1.0;
 long double ld = -1.0L;
+// CHECK-BE32-LABEL: define dso_local void @_Z12test_signbitv(
+// CHECK-BE32-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-BE32-NEXT:  entry:
+// CHECK-BE32-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1
+// CHECK-BE32-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE32-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128
+// CHECK-BE32-NEXT:[[TMP2:%.*]] = lshr i128 [[TMP1]], 64
+// CHECK-BE32-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64
+// CHECK-BE32-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP4]] to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL1]], ptr @b, align 1
+// CHECK-BE32-NEXT:store i8 0, ptr @b, align 1
+// CHECK-BE32-NEXT:[[TMP5:%.*]] = load double, ptr @d, align 8
+// CHECK-BE32-NEXT:[[CONV:%.*]] = fptrunc double [[TMP5]] to float
+// CHECK-BE32-NEXT:[[TMP6:%.*]] = bitcast float [[CONV]] to i32
+// CHECK-BE32-NEXT:[[TMP7:%.*]] = icmp slt i32 [[TMP6]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TMP7]] to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL2]], ptr @b, align 1
+// CHECK-BE32-NEXT:[[FROMBOOL3:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL3]], ptr @b, align 1
+// CHECK-BE32-NEXT:[[TMP8:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE32-NEXT:[[TMP9:%.*]] = bitcast ppc_fp128 [[TMP8]] to i128
+// CHECK-BE32-NEXT:[[TMP10:%.*]] = lshr i128 [[TMP9]], 64
+// CHECK-BE32-NEXT:[[TMP11:%.*]] = trunc i128 [[TMP10]] to i64
+// CHECK-BE32-NEXT:[[TMP12:%.*]] = icmp slt i64 [[TMP11]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL4:%.*]] = zext i1 [[TMP12]] to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL4]], ptr @b, align 1
+// CHECK-BE32-NEXT:ret void
+//
+// CHECK-BE64-LABEL: define dso_local void @_Z12test_signbitv(
+// CHECK-BE64-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-BE64-NEXT:  entry:
+// CHECK-BE64-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
+// CHECK-BE64-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1
+// CHECK-BE64-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE64-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128
+// CHECK-BE64-NEXT:[[TMP2:%.*]] = lshr i128 [[TMP1]], 64
+// CHECK-BE64-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64
+// CHECK-BE64-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0
+// 

[clang] 3bb7ecc - Revert "[Clang] Generate test checks (NFC)"

2023-11-10 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-11-10T17:08:35-08:00
New Revision: 3bb7ecc5a515d2ddd2708257096e14e3fe3b839d

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

LOG: Revert "[Clang] Generate test checks (NFC)"

This reverts commit cd7ba9f3d090afb5d3b15b0dcf379d15d1e11e33.

This is causing test failures on builds without assertions:

/data/users/smeenai/llvm-project/clang/test/Analysis/builtin_signbit.cpp:14:21: 
error: CHECK-BE32-NEXT: expected string not found in input
// CHECK-BE32-NEXT: entry:
^

Bots are also failing, e.g. 
https://lab.llvm.org/buildbot/#/builders/67/builds/13266/steps/7/logs/stdio

Added: 


Modified: 
clang/test/Analysis/builtin_signbit.cpp

Removed: 




diff  --git a/clang/test/Analysis/builtin_signbit.cpp 
b/clang/test/Analysis/builtin_signbit.cpp
index a0bf7a45be1302b..251391952f9c586 100644
--- a/clang/test/Analysis/builtin_signbit.cpp
+++ b/clang/test/Analysis/builtin_signbit.cpp
@@ -1,113 +1,46 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
 // RUN: %clang -target powerpc-linux-gnu -emit-llvm -S -mabi=ibmlongdouble \
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-BE32
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang -target powerpc64-linux-gnu -emit-llvm -S -mabi=ibmlongdouble \
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-BE64
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 // RUN: %clang -target powerpc64le-linux-gnu -emit-llvm -S -mabi=ibmlongdouble 
\
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-LE
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE
 
 bool b;
 double d = -1.0;
 long double ld = -1.0L;
-// CHECK-BE32-LABEL: define dso_local void @_Z12test_signbitv(
-// CHECK-BE32-SAME: ) #[[ATTR0:[0-9]+]] {
-// CHECK-BE32-NEXT:  entry:
-// CHECK-BE32-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
-// CHECK-BE32-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16
-// CHECK-BE32-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128
-// CHECK-BE32-NEXT:[[TMP2:%.*]] = lshr i128 [[TMP1]], 64
-// CHECK-BE32-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64
-// CHECK-BE32-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP4]] to i8
-// CHECK-BE32-NEXT:store i8 [[FROMBOOL1]], ptr @b, align 1
-// CHECK-BE32-NEXT:store i8 0, ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP5:%.*]] = load double, ptr @d, align 8
-// CHECK-BE32-NEXT:[[CONV:%.*]] = fptrunc double [[TMP5]] to float
-// CHECK-BE32-NEXT:[[TMP6:%.*]] = bitcast float [[CONV]] to i32
-// CHECK-BE32-NEXT:[[TMP7:%.*]] = icmp slt i32 [[TMP6]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TMP7]] to i8
-// CHECK-BE32-NEXT:store i8 [[FROMBOOL2]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[FROMBOOL3:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
-// CHECK-BE32-NEXT:store i8 [[FROMBOOL3]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP8:%.*]] = load ppc_fp128, ptr @ld, align 16
-// CHECK-BE32-NEXT:[[TMP9:%.*]] = bitcast ppc_fp128 [[TMP8]] to i128
-// CHECK-BE32-NEXT:[[TMP10:%.*]] = lshr i128 [[TMP9]], 64
-// CHECK-BE32-NEXT:[[TMP11:%.*]] = trunc i128 [[TMP10]] to i64
-// CHECK-BE32-NEXT:[[TMP12:%.*]] = icmp slt i64 [[TMP11]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL4:%.*]] = zext i1 [[TMP12]] to i8
-// CHECK-BE32-NEXT:store i8 [[FROMBOOL4]], ptr @b, align 1
-// CHECK-BE32-NEXT:ret void
-//
-// CHECK-BE64-LABEL: define dso_local void @_Z12test_signbitv(
-// CHECK-BE64-SAME: ) #[[ATTR0:[0-9]+]] {
-// CHECK-BE64-NEXT:  entry:
-// CHECK-BE64-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
-// CHECK-BE64-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1
-// CHECK-BE64-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16
-// CHECK-BE64-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128
-// CHECK-BE64-NEXT:[[TMP2:%.*]] = lshr i128 [[TMP1]], 64
-// CHECK-BE64-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64
-// CHECK-BE64-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0
-// CHECK-BE64-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP4]] to i8
-// CHECK-BE64-NEXT:store i8 [[FROMBOOL1]], ptr @b, align 1
-// CHECK-BE64-NEXT:store i8 0, ptr @b, align 1
-// CHECK-BE64-NEXT:  

[clang] 8ee07a4 - Revert "[IR] Mark lshr and ashr constant expressions as undesirable"

2023-11-10 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-11-10T17:08:35-08:00
New Revision: 8ee07a4be7f7d8654ecf25e7ce0a680975649544

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

LOG: Revert "[IR] Mark lshr and ashr constant expressions as undesirable"

This reverts commit 82f68a992b9f89036042d57a5f6345cb2925b2c1.

cd7ba9f3d090afb5d3b15b0dcf379d15d1e11e33 needs to be reverted to fix
test failures on builds without assertions, and this one needs to be
reverted first for that.

Added: 


Modified: 
clang/test/Analysis/builtin_signbit.cpp
llvm/lib/IR/Constants.cpp
llvm/test/CodeGen/AArch64/stack-tagging-initializer-merge.ll

Removed: 




diff  --git a/clang/test/Analysis/builtin_signbit.cpp 
b/clang/test/Analysis/builtin_signbit.cpp
index e02802c5a514b0b..a0bf7a45be1302b 100644
--- a/clang/test/Analysis/builtin_signbit.cpp
+++ b/clang/test/Analysis/builtin_signbit.cpp
@@ -12,72 +12,60 @@ long double ld = -1.0L;
 // CHECK-BE32-LABEL: define dso_local void @_Z12test_signbitv(
 // CHECK-BE32-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-BE32-NEXT:  entry:
-// CHECK-BE32-NEXT:[[TMP0:%.*]] = lshr i128 bitcast (ppc_fp128 
0xM3FF0 to i128), 64
-// CHECK-BE32-NEXT:[[TMP1:%.*]] = trunc i128 [[TMP0]] to i64
-// CHECK-BE32-NEXT:[[TMP2:%.*]] = icmp slt i64 [[TMP1]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL:%.*]] = zext i1 [[TMP2]] to i8
+// CHECK-BE32-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP3:%.*]] = load ppc_fp128, ptr @ld, align 16
-// CHECK-BE32-NEXT:[[TMP4:%.*]] = bitcast ppc_fp128 [[TMP3]] to i128
-// CHECK-BE32-NEXT:[[TMP5:%.*]] = lshr i128 [[TMP4]], 64
-// CHECK-BE32-NEXT:[[TMP6:%.*]] = trunc i128 [[TMP5]] to i64
-// CHECK-BE32-NEXT:[[TMP7:%.*]] = icmp slt i64 [[TMP6]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP7]] to i8
+// CHECK-BE32-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE32-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128
+// CHECK-BE32-NEXT:[[TMP2:%.*]] = lshr i128 [[TMP1]], 64
+// CHECK-BE32-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64
+// CHECK-BE32-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP4]] to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL1]], ptr @b, align 1
 // CHECK-BE32-NEXT:store i8 0, ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP8:%.*]] = load double, ptr @d, align 8
-// CHECK-BE32-NEXT:[[CONV:%.*]] = fptrunc double [[TMP8]] to float
-// CHECK-BE32-NEXT:[[TMP9:%.*]] = bitcast float [[CONV]] to i32
-// CHECK-BE32-NEXT:[[TMP10:%.*]] = icmp slt i32 [[TMP9]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TMP10]] to i8
+// CHECK-BE32-NEXT:[[TMP5:%.*]] = load double, ptr @d, align 8
+// CHECK-BE32-NEXT:[[CONV:%.*]] = fptrunc double [[TMP5]] to float
+// CHECK-BE32-NEXT:[[TMP6:%.*]] = bitcast float [[CONV]] to i32
+// CHECK-BE32-NEXT:[[TMP7:%.*]] = icmp slt i32 [[TMP6]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TMP7]] to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL2]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP11:%.*]] = lshr i128 bitcast (ppc_fp128 
0xM3FF0 to i128), 64
-// CHECK-BE32-NEXT:[[TMP12:%.*]] = trunc i128 [[TMP11]] to i64
-// CHECK-BE32-NEXT:[[TMP13:%.*]] = icmp slt i64 [[TMP12]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL3:%.*]] = zext i1 [[TMP13]] to i8
+// CHECK-BE32-NEXT:[[FROMBOOL3:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL3]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP14:%.*]] = load ppc_fp128, ptr @ld, align 16
-// CHECK-BE32-NEXT:[[TMP15:%.*]] = bitcast ppc_fp128 [[TMP14]] to i128
-// CHECK-BE32-NEXT:[[TMP16:%.*]] = lshr i128 [[TMP15]], 64
-// CHECK-BE32-NEXT:[[TMP17:%.*]] = trunc i128 [[TMP16]] to i64
-// CHECK-BE32-NEXT:[[TMP18:%.*]] = icmp slt i64 [[TMP17]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL4:%.*]] = zext i1 [[TMP18]] to i8
+// CHECK-BE32-NEXT:[[TMP8:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE32-NEXT:[[TMP9:%.*]] = bitcast ppc_fp128 [[TMP8]] to i128
+// CHECK-BE32-NEXT:[[TMP10:%.*]] = lshr i128 [[TMP9]], 64
+// CHECK-BE32-NEXT:[[TMP11:%.*]] = trunc i128 [[TMP10]] to i64
+// CHECK-BE32-NEXT:[[TMP12:%.*]] = icmp slt i64 [[TMP11]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL4:%.*]] = zext i1 [[TMP12]] to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL4]], ptr @b, align 1
 // 

[clang] bdd396f - [Analysis] Make test require asserts

2023-11-10 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-11-10T17:29:32-08:00
New Revision: bdd396f353582b50d0a9af5e5e809aeacc2848bf

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

LOG: [Analysis] Make test require asserts

This is a hacky fix to get the bots green, because just reverting the
original commit causes more failures. This should be replaced with a
proper fix by the author.

Added: 


Modified: 
clang/test/Analysis/builtin_signbit.cpp

Removed: 




diff  --git a/clang/test/Analysis/builtin_signbit.cpp 
b/clang/test/Analysis/builtin_signbit.cpp
index e02802c5a514b0b..c10aebbc8d176cc 100644
--- a/clang/test/Analysis/builtin_signbit.cpp
+++ b/clang/test/Analysis/builtin_signbit.cpp
@@ -5,6 +5,7 @@
 // RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-BE64
 // RUN: %clang -target powerpc64le-linux-gnu -emit-llvm -S -mabi=ibmlongdouble 
\
 // RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-LE
+// REQUIRES: asserts
 
 bool b;
 double d = -1.0;



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


[clang] c5dd1bb - Revert "Revert "[IR] Mark lshr and ashr constant expressions as undesirable""

2023-11-10 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-11-10T17:26:14-08:00
New Revision: c5dd1bbcc37e8811e7c6050159014d084eac6438

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

LOG: Revert "Revert "[IR] Mark lshr and ashr constant expressions as 
undesirable""

This reverts commit 8ee07a4be7f7d8654ecf25e7ce0a680975649544.

The revert is breaking AMDGPU backend tests (which I didn't have
enabled), and I don't want to risk breakages over the weekend, so just
revert for now.

Added: 


Modified: 
clang/test/Analysis/builtin_signbit.cpp
llvm/lib/IR/Constants.cpp
llvm/test/CodeGen/AArch64/stack-tagging-initializer-merge.ll

Removed: 




diff  --git a/clang/test/Analysis/builtin_signbit.cpp 
b/clang/test/Analysis/builtin_signbit.cpp
index a0bf7a45be1302b..e02802c5a514b0b 100644
--- a/clang/test/Analysis/builtin_signbit.cpp
+++ b/clang/test/Analysis/builtin_signbit.cpp
@@ -12,60 +12,72 @@ long double ld = -1.0L;
 // CHECK-BE32-LABEL: define dso_local void @_Z12test_signbitv(
 // CHECK-BE32-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-BE32-NEXT:  entry:
-// CHECK-BE32-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
+// CHECK-BE32-NEXT:[[TMP0:%.*]] = lshr i128 bitcast (ppc_fp128 
0xM3FF0 to i128), 64
+// CHECK-BE32-NEXT:[[TMP1:%.*]] = trunc i128 [[TMP0]] to i64
+// CHECK-BE32-NEXT:[[TMP2:%.*]] = icmp slt i64 [[TMP1]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL:%.*]] = zext i1 [[TMP2]] to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16
-// CHECK-BE32-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128
-// CHECK-BE32-NEXT:[[TMP2:%.*]] = lshr i128 [[TMP1]], 64
-// CHECK-BE32-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64
-// CHECK-BE32-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP4]] to i8
+// CHECK-BE32-NEXT:[[TMP3:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE32-NEXT:[[TMP4:%.*]] = bitcast ppc_fp128 [[TMP3]] to i128
+// CHECK-BE32-NEXT:[[TMP5:%.*]] = lshr i128 [[TMP4]], 64
+// CHECK-BE32-NEXT:[[TMP6:%.*]] = trunc i128 [[TMP5]] to i64
+// CHECK-BE32-NEXT:[[TMP7:%.*]] = icmp slt i64 [[TMP6]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP7]] to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL1]], ptr @b, align 1
 // CHECK-BE32-NEXT:store i8 0, ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP5:%.*]] = load double, ptr @d, align 8
-// CHECK-BE32-NEXT:[[CONV:%.*]] = fptrunc double [[TMP5]] to float
-// CHECK-BE32-NEXT:[[TMP6:%.*]] = bitcast float [[CONV]] to i32
-// CHECK-BE32-NEXT:[[TMP7:%.*]] = icmp slt i32 [[TMP6]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TMP7]] to i8
+// CHECK-BE32-NEXT:[[TMP8:%.*]] = load double, ptr @d, align 8
+// CHECK-BE32-NEXT:[[CONV:%.*]] = fptrunc double [[TMP8]] to float
+// CHECK-BE32-NEXT:[[TMP9:%.*]] = bitcast float [[CONV]] to i32
+// CHECK-BE32-NEXT:[[TMP10:%.*]] = icmp slt i32 [[TMP9]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TMP10]] to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL2]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[FROMBOOL3:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
+// CHECK-BE32-NEXT:[[TMP11:%.*]] = lshr i128 bitcast (ppc_fp128 
0xM3FF0 to i128), 64
+// CHECK-BE32-NEXT:[[TMP12:%.*]] = trunc i128 [[TMP11]] to i64
+// CHECK-BE32-NEXT:[[TMP13:%.*]] = icmp slt i64 [[TMP12]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL3:%.*]] = zext i1 [[TMP13]] to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL3]], ptr @b, align 1
-// CHECK-BE32-NEXT:[[TMP8:%.*]] = load ppc_fp128, ptr @ld, align 16
-// CHECK-BE32-NEXT:[[TMP9:%.*]] = bitcast ppc_fp128 [[TMP8]] to i128
-// CHECK-BE32-NEXT:[[TMP10:%.*]] = lshr i128 [[TMP9]], 64
-// CHECK-BE32-NEXT:[[TMP11:%.*]] = trunc i128 [[TMP10]] to i64
-// CHECK-BE32-NEXT:[[TMP12:%.*]] = icmp slt i64 [[TMP11]], 0
-// CHECK-BE32-NEXT:[[FROMBOOL4:%.*]] = zext i1 [[TMP12]] to i8
+// CHECK-BE32-NEXT:[[TMP14:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE32-NEXT:[[TMP15:%.*]] = bitcast ppc_fp128 [[TMP14]] to i128
+// CHECK-BE32-NEXT:[[TMP16:%.*]] = lshr i128 [[TMP15]], 64
+// CHECK-BE32-NEXT:[[TMP17:%.*]] = trunc i128 [[TMP16]] to i64
+// CHECK-BE32-NEXT:[[TMP18:%.*]] = icmp slt i64 [[TMP17]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL4:%.*]] = zext i1 [[TMP18]] to i8
 // CHECK-BE32-NEXT:store i8 [[FROMBOOL4]], ptr @b, align 1
 // 

[clang] 55ac332 - Revert "Revert "[Clang] Generate test checks (NFC)""

2023-11-10 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-11-10T17:24:39-08:00
New Revision: 55ac33235db3635a797f98f4539d665bfacf92df

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

LOG: Revert "Revert "[Clang] Generate test checks (NFC)""

This reverts commit 3bb7ecc5a515d2ddd2708257096e14e3fe3b839d.

The revert breaks AMDGPU backend tests (which I didn't have enabled
locally), and I don't want to risk more breakages before the weekend, so
just restore things as they were.

Added: 


Modified: 
clang/test/Analysis/builtin_signbit.cpp

Removed: 




diff  --git a/clang/test/Analysis/builtin_signbit.cpp 
b/clang/test/Analysis/builtin_signbit.cpp
index 251391952f9c586..a0bf7a45be1302b 100644
--- a/clang/test/Analysis/builtin_signbit.cpp
+++ b/clang/test/Analysis/builtin_signbit.cpp
@@ -1,46 +1,113 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
 // RUN: %clang -target powerpc-linux-gnu -emit-llvm -S -mabi=ibmlongdouble \
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-BE32
 // RUN: %clang -target powerpc64-linux-gnu -emit-llvm -S -mabi=ibmlongdouble \
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-BE
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-BE64
 // RUN: %clang -target powerpc64le-linux-gnu -emit-llvm -S -mabi=ibmlongdouble 
\
-// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN:   -O0 %s -o - | FileCheck %s --check-prefixes=CHECK-LE
 
 bool b;
 double d = -1.0;
 long double ld = -1.0L;
+// CHECK-BE32-LABEL: define dso_local void @_Z12test_signbitv(
+// CHECK-BE32-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-BE32-NEXT:  entry:
+// CHECK-BE32-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1
+// CHECK-BE32-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE32-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128
+// CHECK-BE32-NEXT:[[TMP2:%.*]] = lshr i128 [[TMP1]], 64
+// CHECK-BE32-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64
+// CHECK-BE32-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP4]] to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL1]], ptr @b, align 1
+// CHECK-BE32-NEXT:store i8 0, ptr @b, align 1
+// CHECK-BE32-NEXT:[[TMP5:%.*]] = load double, ptr @d, align 8
+// CHECK-BE32-NEXT:[[CONV:%.*]] = fptrunc double [[TMP5]] to float
+// CHECK-BE32-NEXT:[[TMP6:%.*]] = bitcast float [[CONV]] to i32
+// CHECK-BE32-NEXT:[[TMP7:%.*]] = icmp slt i32 [[TMP6]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL2:%.*]] = zext i1 [[TMP7]] to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL2]], ptr @b, align 1
+// CHECK-BE32-NEXT:[[FROMBOOL3:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL3]], ptr @b, align 1
+// CHECK-BE32-NEXT:[[TMP8:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE32-NEXT:[[TMP9:%.*]] = bitcast ppc_fp128 [[TMP8]] to i128
+// CHECK-BE32-NEXT:[[TMP10:%.*]] = lshr i128 [[TMP9]], 64
+// CHECK-BE32-NEXT:[[TMP11:%.*]] = trunc i128 [[TMP10]] to i64
+// CHECK-BE32-NEXT:[[TMP12:%.*]] = icmp slt i64 [[TMP11]], 0
+// CHECK-BE32-NEXT:[[FROMBOOL4:%.*]] = zext i1 [[TMP12]] to i8
+// CHECK-BE32-NEXT:store i8 [[FROMBOOL4]], ptr @b, align 1
+// CHECK-BE32-NEXT:ret void
+//
+// CHECK-BE64-LABEL: define dso_local void @_Z12test_signbitv(
+// CHECK-BE64-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-BE64-NEXT:  entry:
+// CHECK-BE64-NEXT:[[FROMBOOL:%.*]] = zext i1 icmp slt (i64 trunc (i128 
lshr (i128 bitcast (ppc_fp128 0xM3FF0 to i128), 
i128 64) to i64), i64 0) to i8
+// CHECK-BE64-NEXT:store i8 [[FROMBOOL]], ptr @b, align 1
+// CHECK-BE64-NEXT:[[TMP0:%.*]] = load ppc_fp128, ptr @ld, align 16
+// CHECK-BE64-NEXT:[[TMP1:%.*]] = bitcast ppc_fp128 [[TMP0]] to i128
+// CHECK-BE64-NEXT:[[TMP2:%.*]] = lshr i128 [[TMP1]], 64
+// CHECK-BE64-NEXT:[[TMP3:%.*]] = trunc i128 [[TMP2]] to i64
+// CHECK-BE64-NEXT:[[TMP4:%.*]] = icmp slt i64 [[TMP3]], 0
+// CHECK-BE64-NEXT:[[FROMBOOL1:%.*]] = zext i1 [[TMP4]] to i8
+// CHECK-BE64-NEXT:store i8 [[FROMBOOL1]], ptr @b, align 1
+// CHECK-BE64-NEXT:store i8 0, ptr @b, align 1
+// CHECK-BE64-NEXT:[[TMP5:%.*]] = load double, ptr @d, align 8
+// CHECK-BE64-NEXT:[[CONV:%.*]] = fptrunc double [[TMP5]] to float
+// CHECK-BE64-NEXT:[[TMP6:%.*]] = bitcast float 

[clang] [clang] Enable Wenum-constexpr-conversion also in system headers and … (PR #67528)

2023-10-16 Thread Shoaib Meenai via cfe-commits
Carlos =?utf-8?q?G=C3=A1lvez?= 
Message-ID:
In-Reply-To: 


smeenai wrote:

https://github.com/boostorg/mpl/issues/69 is still a problem, unfortunately.

https://github.com/llvm/llvm-project/pull/67528
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai closed 
https://github.com/llvm/llvm-project/pull/68060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/68060

>From b931e047168d2312f05c0fbf2813915cc4e06ae8 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 2 Oct 2023 17:50:36 -0700
Subject: [PATCH 1/4] [diag] Silence `-Wfixed-enum-extension` in C23

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html
---
 clang/lib/Parse/ParseDecl.cpp |  2 +-
 clang/test/Sema/fixed-enum.c  | 12 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a1491596ef6145c..735da4aafae1ca5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index c77f5b0cbe79c5b..73a3fd2b09114c0 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -4,13 +4,17 @@
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
+// RUN: %clang_cc1 -Weverything -std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
 
 enum X : int {e};
 #if defined(CXX11)
 // expected-warning@-2{{enumeration types with a fixed underlying type are 
incompatible with C++98}}
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
-#elif defined(OBJC)
+#elif defined(OBJC) || defined(C23)
 // No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
@@ -21,19 +25,19 @@ enum X : int {e};
 // Don't warn about the forward declaration in any language mode.
 enum Fwd : int;
 enum Fwd : int { e2 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 #endif
 
 // Always error on the incompatible redeclaration.
 enum BadFwd : int;
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-note@-4 {{previous declaration is here}}
 enum BadFwd : char { e3 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}

>From 862b7a64968ababc2d6b3495ba75271b764ca335 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 3 Oct 2023 07:57:39 -0700
Subject: [PATCH 2/4] Address comment

---
 clang/lib/Parse/ParseDecl.cpp | 4 ++--
 clang/test/Sema/fixed-enum.c  | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 735da4aafae1ca5..3cad57e719aad97 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5009,7 +5009,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 
   BaseRange = SourceRange(ColonLoc, 
DeclaratorInfo.getSourceRange().getEnd());
 
-  if (!getLangOpts().ObjC) {
+  if (!getLangOpts().ObjC && !getLangOpts().C23) {
 if (getLangOpts().CPlusPlus11)
   Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
   << BaseRange;
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else if (!getLangOpts().C23)
+else
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index 73a3fd2b09114c0..954ff8c452b80ca 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
+// 

[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/68060

>From b931e047168d2312f05c0fbf2813915cc4e06ae8 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 2 Oct 2023 17:50:36 -0700
Subject: [PATCH 1/4] [diag] Silence `-Wfixed-enum-extension` in C23

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html
---
 clang/lib/Parse/ParseDecl.cpp |  2 +-
 clang/test/Sema/fixed-enum.c  | 12 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a1491596ef6145c..735da4aafae1ca5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index c77f5b0cbe79c5b..73a3fd2b09114c0 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -4,13 +4,17 @@
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
+// RUN: %clang_cc1 -Weverything -std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
 
 enum X : int {e};
 #if defined(CXX11)
 // expected-warning@-2{{enumeration types with a fixed underlying type are 
incompatible with C++98}}
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
-#elif defined(OBJC)
+#elif defined(OBJC) || defined(C23)
 // No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
@@ -21,19 +25,19 @@ enum X : int {e};
 // Don't warn about the forward declaration in any language mode.
 enum Fwd : int;
 enum Fwd : int { e2 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 #endif
 
 // Always error on the incompatible redeclaration.
 enum BadFwd : int;
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-note@-4 {{previous declaration is here}}
 enum BadFwd : char { e3 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}

>From 862b7a64968ababc2d6b3495ba75271b764ca335 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 3 Oct 2023 07:57:39 -0700
Subject: [PATCH 2/4] Address comment

---
 clang/lib/Parse/ParseDecl.cpp | 4 ++--
 clang/test/Sema/fixed-enum.c  | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 735da4aafae1ca5..3cad57e719aad97 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5009,7 +5009,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 
   BaseRange = SourceRange(ColonLoc, 
DeclaratorInfo.getSourceRange().getEnd());
 
-  if (!getLangOpts().ObjC) {
+  if (!getLangOpts().ObjC && !getLangOpts().C23) {
 if (getLangOpts().CPlusPlus11)
   Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
   << BaseRange;
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else if (!getLangOpts().C23)
+else
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index 73a3fd2b09114c0..954ff8c452b80ca 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
+// 

[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/68060

>From b931e047168d2312f05c0fbf2813915cc4e06ae8 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 2 Oct 2023 17:50:36 -0700
Subject: [PATCH 1/3] [diag] Silence `-Wfixed-enum-extension` in C23

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html
---
 clang/lib/Parse/ParseDecl.cpp |  2 +-
 clang/test/Sema/fixed-enum.c  | 12 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a1491596ef6145c..735da4aafae1ca5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index c77f5b0cbe79c5b..73a3fd2b09114c0 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -4,13 +4,17 @@
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
+// RUN: %clang_cc1 -Weverything -std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
 
 enum X : int {e};
 #if defined(CXX11)
 // expected-warning@-2{{enumeration types with a fixed underlying type are 
incompatible with C++98}}
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
-#elif defined(OBJC)
+#elif defined(OBJC) || defined(C23)
 // No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
@@ -21,19 +25,19 @@ enum X : int {e};
 // Don't warn about the forward declaration in any language mode.
 enum Fwd : int;
 enum Fwd : int { e2 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 #endif
 
 // Always error on the incompatible redeclaration.
 enum BadFwd : int;
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-note@-4 {{previous declaration is here}}
 enum BadFwd : char { e3 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}

>From 862b7a64968ababc2d6b3495ba75271b764ca335 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 3 Oct 2023 07:57:39 -0700
Subject: [PATCH 2/3] Address comment

---
 clang/lib/Parse/ParseDecl.cpp | 4 ++--
 clang/test/Sema/fixed-enum.c  | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 735da4aafae1ca5..3cad57e719aad97 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5009,7 +5009,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 
   BaseRange = SourceRange(ColonLoc, 
DeclaratorInfo.getSourceRange().getEnd());
 
-  if (!getLangOpts().ObjC) {
+  if (!getLangOpts().ObjC && !getLangOpts().C23) {
 if (getLangOpts().CPlusPlus11)
   Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
   << BaseRange;
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else if (!getLangOpts().C23)
+else
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index 73a3fd2b09114c0..954ff8c452b80ca 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
+// 

[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits


@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)

smeenai wrote:

You're right, I hoisted the check up and added an additional test case for that 
combo.

https://github.com/llvm/llvm-project/pull/68060
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-03 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/68060

>From b931e047168d2312f05c0fbf2813915cc4e06ae8 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 2 Oct 2023 17:50:36 -0700
Subject: [PATCH 1/2] [diag] Silence `-Wfixed-enum-extension` in C23

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html
---
 clang/lib/Parse/ParseDecl.cpp |  2 +-
 clang/test/Sema/fixed-enum.c  | 12 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a1491596ef6145c..735da4aafae1ca5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index c77f5b0cbe79c5b..73a3fd2b09114c0 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -4,13 +4,17 @@
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
+// RUN: %clang_cc1 -Weverything -std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
 
 enum X : int {e};
 #if defined(CXX11)
 // expected-warning@-2{{enumeration types with a fixed underlying type are 
incompatible with C++98}}
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
-#elif defined(OBJC)
+#elif defined(OBJC) || defined(C23)
 // No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
@@ -21,19 +25,19 @@ enum X : int {e};
 // Don't warn about the forward declaration in any language mode.
 enum Fwd : int;
 enum Fwd : int { e2 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 #endif
 
 // Always error on the incompatible redeclaration.
 enum BadFwd : int;
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-note@-4 {{previous declaration is here}}
 enum BadFwd : char { e3 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}

>From 862b7a64968ababc2d6b3495ba75271b764ca335 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 3 Oct 2023 07:57:39 -0700
Subject: [PATCH 2/2] Address comment

---
 clang/lib/Parse/ParseDecl.cpp | 4 ++--
 clang/test/Sema/fixed-enum.c  | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 735da4aafae1ca5..3cad57e719aad97 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5009,7 +5009,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 
   BaseRange = SourceRange(ColonLoc, 
DeclaratorInfo.getSourceRange().getEnd());
 
-  if (!getLangOpts().ObjC) {
+  if (!getLangOpts().ObjC && !getLangOpts().C23) {
 if (getLangOpts().CPlusPlus11)
   Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
   << BaseRange;
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else if (!getLangOpts().C23)
+else
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index 73a3fd2b09114c0..954ff8c452b80ca 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
+// 

[clang] [diag] Silence `-Wfixed-enum-extension` in C23 (PR #68060)

2023-10-02 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai created 
https://github.com/llvm/llvm-project/pull/68060

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html


>From b931e047168d2312f05c0fbf2813915cc4e06ae8 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 2 Oct 2023 17:50:36 -0700
Subject: [PATCH] [diag] Silence `-Wfixed-enum-extension` in C23

The C23 standard supports enums with fixed underlying types (N3030 [1]),
so we shouldn't emit `-Wfixed-enum-extension` in C23 mode (since it's no
longer a Clang extension at that point).

[1] 
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Enhanced%20Enumerations.html
---
 clang/lib/Parse/ParseDecl.cpp |  2 +-
 clang/test/Sema/fixed-enum.c  | 12 
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a1491596ef6145c..735da4aafae1ca5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5019,7 +5019,7 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, 
DeclSpec ,
 else if (getLangOpts().MicrosoftExt)
   Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
   << BaseRange;
-else
+else if (!getLangOpts().C23)
   Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
   << BaseRange;
   }
diff --git a/clang/test/Sema/fixed-enum.c b/clang/test/Sema/fixed-enum.c
index c77f5b0cbe79c5b..73a3fd2b09114c0 100644
--- a/clang/test/Sema/fixed-enum.c
+++ b/clang/test/Sema/fixed-enum.c
@@ -4,13 +4,17 @@
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -pedantic-std=c11 -xc -DC11 -verify %s
 // RUN: %clang_cc1 -Weverything -std=c11 -xc -fms-extensions -DMS -verify %s
+// RUN: %clang_cc1 -Weverything -std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c2x -xc -DC23 -verify %s
+// RUN: %clang_cc1 -Weverything -std=c23 -xc -DC23 -verify %s
+// RUN: %clang_cc1 -pedantic-std=c23 -xc -DC23 -verify %s
 
 enum X : int {e};
 #if defined(CXX11)
 // expected-warning@-2{{enumeration types with a fixed underlying type are 
incompatible with C++98}}
 #elif defined(CXX03)
 // expected-warning@-4{{enumeration types with a fixed underlying type are a 
C++11 extension}}
-#elif defined(OBJC)
+#elif defined(OBJC) || defined(C23)
 // No diagnostic
 #elif defined(C11)
 // expected-warning@-8{{enumeration types with a fixed underlying type are a 
Clang extension}}
@@ -21,19 +25,19 @@ enum X : int {e};
 // Don't warn about the forward declaration in any language mode.
 enum Fwd : int;
 enum Fwd : int { e2 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 // expected-warning@-3 {{enumeration types with a fixed underlying type}}
 #endif
 
 // Always error on the incompatible redeclaration.
 enum BadFwd : int;
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-note@-4 {{previous declaration is here}}
 enum BadFwd : char { e3 };
-#ifndef OBJC
+#if !defined(OBJC) && !defined(C23)
 // expected-warning@-2 {{enumeration types with a fixed underlying type}}
 #endif
 // expected-error@-4 {{enumeration redeclared with different underlying type 
'char' (was 'int')}}

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


[clang] [Sema] Use underlying type of scoped enum for -Wformat diagnostics (PR #67378)

2023-10-02 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai closed 
https://github.com/llvm/llvm-project/pull/67378
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [Sema] Use underlying type of scoped enum for -Wformat diagnostics (PR #67378)

2023-10-02 Thread Shoaib Meenai via cfe-commits

smeenai wrote:

I have commit access. Thanks for the review!

https://github.com/llvm/llvm-project/pull/67378
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [Sema] Use underlying type of scoped enum for -Wformat diagnostics (PR #67378)

2023-10-02 Thread Shoaib Meenai via cfe-commits

smeenai wrote:

I updated the release notes. I was planning to ask for a pick into 17, but I'll 
just tweak the release notes for the pick and modify the Clang 18 release notes 
afterwards if it's accepted.

https://github.com/llvm/llvm-project/pull/67378
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [Sema] Use underlying type of scoped enum for -Wformat diagnostics (PR #67378)

2023-10-02 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/67378

>From a1c307ddcc309b6b915feaad6d09f74ecc3f6e79 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 25 Sep 2023 13:48:10 -0700
Subject: [PATCH 1/2] [Sema] Use underlying type of scoped enum for -Wformat
 diagnostics

Right now, `-Wformat` for a scoped enum will suggest a cast based on the
format specifier being used. This can lead to incorrect results, e.g.
attempting to format a scoped enum with `%s` would suggest casting to
`char *` instead of fixing the specifier. Change the logic to treat the
scoped enum's underlying type as the intended type to be printed, and
suggest format specifier changes and casts based on that.
---
 clang/lib/Sema/SemaChecking.cpp   | 25 +++--
 clang/test/FixIt/format-darwin-enum-class.cpp | 35 +++
 clang/test/FixIt/format.cpp   | 20 +--
 3 files changed, 65 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/FixIt/format-darwin-enum-class.cpp

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 1d56c495e899722..5af52ea5564248d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11345,12 +11345,15 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   ImplicitMatch == ArgType::NoMatchTypeConfusion)
 Match = ImplicitMatch;
   assert(Match != ArgType::MatchPromotion);
+
   // Look through unscoped enums to their underlying type.
   bool IsEnum = false;
   bool IsScopedEnum = false;
+  QualType IntendedTy = ExprTy;
   if (auto EnumTy = ExprTy->getAs()) {
+IntendedTy = EnumTy->getDecl()->getIntegerType();
 if (EnumTy->isUnscopedEnumerationType()) {
-  ExprTy = EnumTy->getDecl()->getIntegerType();
+  ExprTy = IntendedTy;
   // This controls whether we're talking about the underlying type or not,
   // which we only want to do when it's an unscoped enum.
   IsEnum = true;
@@ -11362,7 +11365,6 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   // %C in an Objective-C context prints a unichar, not a wchar_t.
   // If the argument is an integer of some kind, believe the %C and suggest
   // a cast instead of changing the conversion specifier.
-  QualType IntendedTy = ExprTy;
   if (isObjCContext() &&
   FS.getConversionSpecifier().getKind() == ConversionSpecifier::CArg) {
 if (ExprTy->isIntegralOrUnscopedEnumerationType() &&
@@ -11398,8 +11400,10 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
 std::tie(CastTy, CastTyName) = shouldNotPrintDirectly(S.Context, 
IntendedTy, E);
 if (!CastTy.isNull()) {
   // %zi/%zu and %td/%tu are OK to use for NSInteger/NSUInteger of type int
-  // (long in ASTContext). Only complain to pedants.
-  if ((CastTyName == "NSInteger" || CastTyName == "NSUInteger") &&
+  // (long in ASTContext). Only complain to pedants or when they're the
+  // underlying type of a scoped enum (which always needs a cast).
+  if (!IsScopedEnum &&
+  (CastTyName == "NSInteger" || CastTyName == "NSUInteger") &&
   (AT.isSizeT() || AT.isPtrdiffT()) &&
   AT.matchesType(S.Context, CastTy))
 Match = ArgType::NoMatchPedantic;
@@ -11454,20 +11458,15 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   // should be printed as 'long' for 64-bit compatibility.)
   // Rather than emitting a normal format/argument mismatch, we want to
   // add a cast to the recommended type (and correct the format string
-  // if necessary).
+  // if necessary). We should also do so for scoped enumerations.
   SmallString<16> CastBuf;
   llvm::raw_svector_ostream CastFix(CastBuf);
   CastFix << (S.LangOpts.CPlusPlus ? "static_cast<" : "(");
-  if (IsScopedEnum) {
-CastFix << AT.getRepresentativeType(S.Context).getAsString(
-S.Context.getPrintingPolicy());
-  } else {
-IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
-  }
+  IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
   CastFix << (S.LangOpts.CPlusPlus ? ">" : ")");
 
   SmallVector Hints;
-  if ((!AT.matchesType(S.Context, IntendedTy) && !IsScopedEnum) ||
+  if (AT.matchesType(S.Context, IntendedTy) != ArgType::Match ||
   ShouldNotPrintDirectly)
 Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str()));
 
@@ -11495,7 +11494,7 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
 Hints.push_back(FixItHint::CreateInsertion(After, ")"));
   }
 
-  if (ShouldNotPrintDirectly) {
+  if (ShouldNotPrintDirectly && !IsScopedEnum) {
 // The expression has a type that should not be printed directly.
 // We extract the name from the typedef because we don't want to show
 // the underlying type in the 

[clang] [Sema] Use underlying type of scoped enum for -Wformat diagnostics (PR #67378)

2023-10-02 Thread Shoaib Meenai via cfe-commits

smeenai wrote:

Ping.

https://github.com/llvm/llvm-project/pull/67378
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Modify BoundsSan to improve debuggability (PR #65972)

2023-09-29 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai closed 
https://github.com/llvm/llvm-project/pull/65972
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Use underlying type of scoped enum for -Wformat diagnostics (PR #67378)

2023-09-25 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai created 
https://github.com/llvm/llvm-project/pull/67378

Right now, `-Wformat` for a scoped enum will suggest a cast based on the
format specifier being used. This can lead to incorrect results, e.g.
attempting to format a scoped enum with `%s` would suggest casting to
`char *` instead of fixing the specifier. Change the logic to treat the
scoped enum's underlying type as the intended type to be printed, and
suggest format specifier changes and casts based on that.


>From a1c307ddcc309b6b915feaad6d09f74ecc3f6e79 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Mon, 25 Sep 2023 13:48:10 -0700
Subject: [PATCH] [Sema] Use underlying type of scoped enum for -Wformat
 diagnostics

Right now, `-Wformat` for a scoped enum will suggest a cast based on the
format specifier being used. This can lead to incorrect results, e.g.
attempting to format a scoped enum with `%s` would suggest casting to
`char *` instead of fixing the specifier. Change the logic to treat the
scoped enum's underlying type as the intended type to be printed, and
suggest format specifier changes and casts based on that.
---
 clang/lib/Sema/SemaChecking.cpp   | 25 +++--
 clang/test/FixIt/format-darwin-enum-class.cpp | 35 +++
 clang/test/FixIt/format.cpp   | 20 +--
 3 files changed, 65 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/FixIt/format-darwin-enum-class.cpp

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 1d56c495e899722..5af52ea5564248d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11345,12 +11345,15 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   ImplicitMatch == ArgType::NoMatchTypeConfusion)
 Match = ImplicitMatch;
   assert(Match != ArgType::MatchPromotion);
+
   // Look through unscoped enums to their underlying type.
   bool IsEnum = false;
   bool IsScopedEnum = false;
+  QualType IntendedTy = ExprTy;
   if (auto EnumTy = ExprTy->getAs()) {
+IntendedTy = EnumTy->getDecl()->getIntegerType();
 if (EnumTy->isUnscopedEnumerationType()) {
-  ExprTy = EnumTy->getDecl()->getIntegerType();
+  ExprTy = IntendedTy;
   // This controls whether we're talking about the underlying type or not,
   // which we only want to do when it's an unscoped enum.
   IsEnum = true;
@@ -11362,7 +11365,6 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   // %C in an Objective-C context prints a unichar, not a wchar_t.
   // If the argument is an integer of some kind, believe the %C and suggest
   // a cast instead of changing the conversion specifier.
-  QualType IntendedTy = ExprTy;
   if (isObjCContext() &&
   FS.getConversionSpecifier().getKind() == ConversionSpecifier::CArg) {
 if (ExprTy->isIntegralOrUnscopedEnumerationType() &&
@@ -11398,8 +11400,10 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
 std::tie(CastTy, CastTyName) = shouldNotPrintDirectly(S.Context, 
IntendedTy, E);
 if (!CastTy.isNull()) {
   // %zi/%zu and %td/%tu are OK to use for NSInteger/NSUInteger of type int
-  // (long in ASTContext). Only complain to pedants.
-  if ((CastTyName == "NSInteger" || CastTyName == "NSUInteger") &&
+  // (long in ASTContext). Only complain to pedants or when they're the
+  // underlying type of a scoped enum (which always needs a cast).
+  if (!IsScopedEnum &&
+  (CastTyName == "NSInteger" || CastTyName == "NSUInteger") &&
   (AT.isSizeT() || AT.isPtrdiffT()) &&
   AT.matchesType(S.Context, CastTy))
 Match = ArgType::NoMatchPedantic;
@@ -11454,20 +11458,15 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   // should be printed as 'long' for 64-bit compatibility.)
   // Rather than emitting a normal format/argument mismatch, we want to
   // add a cast to the recommended type (and correct the format string
-  // if necessary).
+  // if necessary). We should also do so for scoped enumerations.
   SmallString<16> CastBuf;
   llvm::raw_svector_ostream CastFix(CastBuf);
   CastFix << (S.LangOpts.CPlusPlus ? "static_cast<" : "(");
-  if (IsScopedEnum) {
-CastFix << AT.getRepresentativeType(S.Context).getAsString(
-S.Context.getPrintingPolicy());
-  } else {
-IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
-  }
+  IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
   CastFix << (S.LangOpts.CPlusPlus ? ">" : ")");
 
   SmallVector Hints;
-  if ((!AT.matchesType(S.Context, IntendedTy) && !IsScopedEnum) ||
+  if (AT.matchesType(S.Context, IntendedTy) != ArgType::Match ||
   ShouldNotPrintDirectly)
 Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str()));
 
@@ -11495,7 +11494,7 @@ 

[clang] [Driver] Fix detection of libc++ with empty sysroot. (PR #66947)

2023-09-22 Thread Shoaib Meenai via cfe-commits


@@ -316,6 +318,52 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
   }
 }
 
+MATCHER_P(jobHasArgs, Substr, "") {
+  const driver::Command  = arg;
+  std::string Args = "";
+  llvm::ListSeparator Sep(" ");
+  for (const char *Arg : C.getArguments()) {
+Args += Sep;
+Args += Arg;
+  }
+  if (is_style_windows(llvm::sys::path::Style::native))
+std::replace(Args.begin(), Args.end(), '\\', '/');
+  if (llvm::StringRef(Args).contains(Substr))
+return true;
+  *result_listener << "whose args are '" << Args << "'";

smeenai wrote:

Cool, sounds good.

https://github.com/llvm/llvm-project/pull/66947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Fix detection of libc++ with empty sysroot. (PR #66947)

2023-09-22 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai resolved 
https://github.com/llvm/llvm-project/pull/66947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Fix detection of libc++ with empty sysroot. (PR #66947)

2023-09-22 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai approved this pull request.


https://github.com/llvm/llvm-project/pull/66947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Fix detection of libc++ with empty sysroot. (PR #66947)

2023-09-22 Thread Shoaib Meenai via cfe-commits

smeenai wrote:

LGTM, thanks!

https://github.com/llvm/llvm-project/pull/66947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Fix detection of libc++ with empty sysroot. (PR #66947)

2023-09-22 Thread Shoaib Meenai via cfe-commits


@@ -316,6 +318,52 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
   }
 }
 
+MATCHER_P(jobHasArgs, Substr, "") {
+  const driver::Command  = arg;
+  std::string Args = "";
+  llvm::ListSeparator Sep(" ");
+  for (const char *Arg : C.getArguments()) {
+Args += Sep;
+Args += Arg;
+  }
+  if (is_style_windows(llvm::sys::path::Style::native))
+std::replace(Args.begin(), Args.end(), '\\', '/');
+  if (llvm::StringRef(Args).contains(Substr))
+return true;
+  *result_listener << "whose args are '" << Args << "'";

smeenai wrote:

Not familiar with the unit testing set up ... do you need the "whose args are" 
bit?

https://github.com/llvm/llvm-project/pull/66947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix fixit cast printing inside macros (PR #66853)

2023-09-20 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai closed 
https://github.com/llvm/llvm-project/pull/66853
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix fixit cast printing inside macros (PR #66853)

2023-09-20 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai updated 
https://github.com/llvm/llvm-project/pull/66853

>From 701b1d99515e40eec8dcbaba3a0b2dc436bf9652 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 19 Sep 2023 19:46:56 -0700
Subject: [PATCH] [Sema] Fix fixit cast printing inside macros

`Lexer::getLocForEndOfToken` is documented as returning an invalid
source location when the end of the token is inside a macro expansion.
We don't want that for this particular application, so just calculate
the end location directly instead.

Before this, format fix-its would omit the closing parenthesis (thus
producing invalid code) for macros, e.g.:

```
$ cat format.cpp
extern "C" int printf(const char *, ...);
enum class Foo { Bar };
void f(Foo foo) { LOG("%d\n", foo); }

$ clang -fsyntax-only format.cpp
format.cpp:4:29: warning: format specifies type 'int' but the argument has type 
'Foo' [-Wformat]
4 | void f(Foo f) { LOG("%d\n", f); }
  |  ~~ ^
  | static_cast(
format.cpp:3:25: note: expanded from macro 'LOG'
3 | #define LOG(...) printf(__VA_ARGS__)
  | ^~~
1 warning generated.
```

We now emit a valid fix-it:

```
$ clang -fsyntax-only format.cpp
format.cpp:4:31: warning: format specifies type 'int' but the argument has type 
'Foo' [-Wformat]
4 | void f(Foo foo) { LOG("%d\n", foo); }
  |~~ ^~~
  |   static_cast( )
format.cpp:3:25: note: expanded from macro 'LOG'
3 | #define LOG(...) printf(__VA_ARGS__)
  | ^~~
1 warning generated.
```

Fixes https://github.com/llvm/llvm-project/issues/63462
---
 clang/lib/Sema/SemaChecking.cpp |  6 -
 clang/test/FixIt/format.cpp | 48 ++---
 2 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index fad70223362eddd..b867d55c174e68b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11470,7 +11470,11 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
 Hints.push_back(
 FixItHint::CreateInsertion(E->getBeginLoc(), CastFix.str()));
 
-SourceLocation After = S.getLocForEndOfToken(E->getEndLoc());
+// We don't use getLocForEndOfToken because it returns invalid source
+// locations for macro expansions (by design).
+SourceLocation EndLoc = S.SourceMgr.getSpellingLoc(E->getEndLoc());
+SourceLocation After = EndLoc.getLocWithOffset(
+Lexer::MeasureTokenLength(EndLoc, S.SourceMgr, S.LangOpts));
 Hints.push_back(FixItHint::CreateInsertion(After, ")"));
   }
 
diff --git a/clang/test/FixIt/format.cpp b/clang/test/FixIt/format.cpp
index 9cc4c2600eb6670..5016ee587ed1c43 100644
--- a/clang/test/FixIt/format.cpp
+++ b/clang/test/FixIt/format.cpp
@@ -1,19 +1,61 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat %s
 // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wformat %s 
2>&1 | FileCheck %s
 
 extern "C" int printf(const char *, ...);
+#define LOG(...) printf(__VA_ARGS__)
 
 namespace N {
   enum class E { One };
 }
 
-void a() {
+struct S {
+  N::E Type;
+};
+
+void a(N::E NEVal, S *SPtr, S ) {
   printf("%d", N::E::One); // expected-warning{{format specifies type 'int' 
but the argument has type 'N::E'}}
   // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast("
   // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:25-[[@LINE-2]]:25}:")"
 
-  printf("%hd", N::E::One);
+  printf("%hd", N::E::One); // expected-warning{{format specifies type 'short' 
but the argument has type 'N::E'}}
   // CHECK: "static_cast("
 
-  printf("%hu", N::E::One);
+  printf("%hu", N::E::One); // expected-warning{{format specifies type 
'unsigned short' but the argument has type 'N::E'}}
   // CHECK: "static_cast("
+
+  LOG("%d", N::E::One); // expected-warning{{format specifies type 'int' but 
the argument has type 'N::E'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:"static_cast("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:22-[[@LINE-2]]:22}:")"
+
+  printf("%d", NEVal); // expected-warning{{format specifies type 'int' but 
the argument has type 'N::E'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:21-[[@LINE-2]]:21}:")"
+
+  LOG("%d", NEVal); // expected-warning{{format specifies type 'int' but the 
argument has type 'N::E'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:"static_cast("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:18-[[@LINE-2]]:18}:")"
+
+  printf(
+  "%d",
+  SPtr->Type // expected-warning{{format specifies type 'int' but the 
argument has type 'N::E'}}
+  );
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:7-[[@LINE-2]]:7}:"static_cast("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-3]]:17-[[@LINE-3]]:17}:")"
+
+  LOG( // 

[clang] [Driver] Fix detection of libc++ with empty sysroot. (PR #66947)

2023-09-20 Thread Shoaib Meenai via cfe-commits

smeenai wrote:

> Thanks for the quick response!
> 
> > The `sys::path::append` behavior here is surprising. I think it'd be better 
> > to change the computation of `SysRoot` in the function above (line 3102, 
> > which I can't comment because of GitHub, sigh) to default to 
> > `llvm::sys::path::get_separator()` if it's empty, to handle Windows slashes 
> > as well as be less confusing to read.
> 
> That sounds sensible to me in principle, but not trivial: presumably the 
> overrides of `Toolchain::getSysroot()` should have a consistent contract. 
> There are 6 overrides, where some explicitly return the empty string, and 25 
> callers some of which do things like `computeSysRoot() + "/include/c++/"` 
> (RISCVToolchain). I feel it's likely I'll break something on a platform I 
> don't understand before getting back to a good state :-)

I just meant to change 
https://github.com/llvm/llvm-project/blob/5eaa5312e7943e23155da4f0fbf07b55a200fc60/clang/lib/Driver/ToolChains/Gnu.cpp#L3102
 to something like (untested):

```
std::string SysRoot = computeSysRoot();
if (SysRoot.empty())
  SysRoot = llvm::sys::path::get_separator();
```

It's a local fix, but all the code here is pretty inconsistent anyway, so I 
don't feel too bad about it.

https://github.com/llvm/llvm-project/pull/66947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Fix detection of libc++ with empty sysroot. (PR #66947)

2023-09-20 Thread Shoaib Meenai via cfe-commits

smeenai wrote:

Sorry about the breakage.

The `sys::path::append` behavior here is surprising. I think it'd be better to 
change the computation of `SysRoot` in the function above (line 3102, which I 
can't comment because of GitHub, sigh) to default to 
`llvm::sys::path::get_separator()` if it's empty, to handle Windows slashes as 
well as be less confusing to read.

This is tricky to test because it requires no sysroot to be passed, but we 
might be able to do so with a VFS overlay. I'm okay adding the test afterwards 
though so we get the breakage fixed first, and I can also look into the test 
myself if you'd like.

https://github.com/llvm/llvm-project/pull/66947
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix fixit cast printing inside macros (PR #66853)

2023-09-19 Thread Shoaib Meenai via cfe-commits

smeenai wrote:

I updated the PR description with an example.

https://github.com/llvm/llvm-project/pull/66853
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix fixit cast printing inside macros (PR #66853)

2023-09-19 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai edited 
https://github.com/llvm/llvm-project/pull/66853
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Sema] Fix fixit cast printing inside macros (PR #66853)

2023-09-19 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai created 
https://github.com/llvm/llvm-project/pull/66853

`Lexer::getLocForEndOfToken` is documented as returning an invalid
source location when the end of the token is inside a macro expansion.
We don't want that for this particular application, so just calculate
the end location directly instead.

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


>From 66e12c0c192f6b490be5df694b2d7faedd1d1b74 Mon Sep 17 00:00:00 2001
From: Shoaib Meenai 
Date: Tue, 19 Sep 2023 19:46:56 -0700
Subject: [PATCH] [Sema] Fix fixit cast printing inside macros

`Lexer::getLocForEndOfToken` is documented as returning an invalid
source location when the end of the token is inside a macro expansion.
We don't want that for this particular application, so just calculate
the end location directly instead.

Fixes https://github.com/llvm/llvm-project/issues/63462
---
 clang/lib/Sema/SemaChecking.cpp | 5 -
 clang/test/FixIt/format.cpp | 5 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index fad70223362eddd..4fbdb315ddc87b4 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11470,7 +11470,10 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
 Hints.push_back(
 FixItHint::CreateInsertion(E->getBeginLoc(), CastFix.str()));
 
-SourceLocation After = S.getLocForEndOfToken(E->getEndLoc());
+// We don't use getLocForEndOfToken because it returns invalid source
+// locations for macro expansions (by design).
+SourceLocation After = E->getEndLoc().getLocWithOffset(
+Lexer::MeasureTokenLength(E->getEndLoc(), S.SourceMgr, 
S.LangOpts));
 Hints.push_back(FixItHint::CreateInsertion(After, ")"));
   }
 
diff --git a/clang/test/FixIt/format.cpp b/clang/test/FixIt/format.cpp
index 9cc4c2600eb6670..46a0a0a11cc850a 100644
--- a/clang/test/FixIt/format.cpp
+++ b/clang/test/FixIt/format.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wformat %s 
2>&1 | FileCheck %s
 
 extern "C" int printf(const char *, ...);
+#define LOG(...) printf(__VA_ARGS__)
 
 namespace N {
   enum class E { One };
@@ -16,4 +17,8 @@ void a() {
 
   printf("%hu", N::E::One);
   // CHECK: "static_cast("
+
+  LOG("%d", N::E::One); // expected-warning{{format specifies type 'int' but 
the argument has type 'N::E'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:13-[[@LINE-1]]:13}:"static_cast("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:22-[[@LINE-2]]:22}:")"
 }

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


[clang] 915ebb0 - [driver] Address missed feedback from https://reviews.llvm.org/D158476

2023-09-18 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-09-18T16:28:04-07:00
New Revision: 915ebb07dfc53486eccf0dc09b6411929a463e98

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

LOG: [driver] Address missed feedback from https://reviews.llvm.org/D158476

I missed this before I committed.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/test/Driver/android-unversioned-fallback-warning.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 130dbe870f26d9a..9b1578762e301f6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -346,7 +346,7 @@ Android Support
 
 - Android target triples are usually suffixed with a version. Clang searches 
for
   target-specific runtime and standard libraries in directories named after the
-  target (e.g. if you're building with ``-target 
aarch64-none-linux-android21``,
+  target (e.g. if you're building with 
``--target=aarch64-none-linux-android21``,
   Clang will look for ``lib/aarch64-none-linux-android21`` under its resource
   directory to find runtime libraries). If an exact match isn't found, Clang
   would previously fall back to a directory without any version (which would be

diff  --git a/clang/test/Driver/android-unversioned-fallback-warning.cpp 
b/clang/test/Driver/android-unversioned-fallback-warning.cpp
index c6c21d63fd41313..62a951d14effafc 100644
--- a/clang/test/Driver/android-unversioned-fallback-warning.cpp
+++ b/clang/test/Driver/android-unversioned-fallback-warning.cpp
@@ -11,12 +11,12 @@
 // RUN: mkdir -p %t/resource/lib/aarch64-none-linux-android23
 
 // Using an unversioned directory for an unversioned triple isn't a warning.
-// RUN: %clang -target aarch64-none-linux-android -ccc-install-dir %t/bin \
+// RUN: %clang --target=aarch64-none-linux-android -ccc-install-dir %t/bin \
 // RUN: -resource-dir %t/resource -### -c %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NO-WARNING %s
 // NO-WARNING-NOT: Using unversioned Android target directory
 
-// RUN: %clang -target aarch64-none-linux-android21 -ccc-install-dir %t/bin \
+// RUN: %clang --target=aarch64-none-linux-android21 -ccc-install-dir %t/bin \
 // RUN: -resource-dir %t/resource -### -c %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=ANDROID21 -DDIR=%t -DSEP=%{fs-sep} %s
 // ANDROID21-DAG: Using unversioned Android target directory 
[[DIR]]/bin[[SEP]]..[[SEP]]include[[SEP]]aarch64-none-linux-android
@@ -24,10 +24,10 @@
 // ANDROID21-DAG: Using unversioned Android target directory 
[[DIR]]/resource[[SEP]]lib[[SEP]]aarch64-none-linux-android
 
 // 23 or newer should use the versioned directory
-// RUN: %clang -target aarch64-none-linux-android23 -ccc-install-dir %t/bin \
+// RUN: %clang --target=aarch64-none-linux-android23 -ccc-install-dir %t/bin \
 // RUN: -resource-dir %t/resource -### -c %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NO-WARNING %s
 
-// RUN: %clang -target aarch64-none-linux-android28 -ccc-install-dir %t/bin \
+// RUN: %clang --target=aarch64-none-linux-android28 -ccc-install-dir %t/bin \
 // RUN: -resource-dir %t/resource -### -c %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=NO-WARNING %s



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


[clang] 58288c6 - [driver] Search for compatible Android runtime directories

2023-09-18 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-09-18T16:14:18-07:00
New Revision: 58288c6c1214f8a3a0e32e003406437652e098bd

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

LOG: [driver] Search for compatible Android runtime directories

Android triples include a version number, which makes direct triple
comparisons for per-target runtime directory searching not always work.
Instead, look for the triple with the highest compatible version number
and use that per-target runtime directory instead. This maintains the
existing fallback to a triple without any version number, but I'm hoping
we can remove that in the future. https://discourse.llvm.org/t/62717
discusses this further.

The one remaining triple mismatch after this is that Android armv7
triples usually have an environment of `androideabi`, which Clang
normalizes to `android`. If you use the `androideabi` triple when
building the runtimes with a per-target runtimes dir, the directory will
get created with `androideabi` in its name, but Clang's triple search
uses the normalized triple and will look for an `android` directory
instead. https://reviews.llvm.org/D140925 will fix that by normalizing
triples when creating the per-target runtimes directories as well.

Reviewed By: phosek, pirama

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

Added: 

clang/test/Driver/Inputs/basic_android_libcxx_tree/usr/lib/aarch64-unknown-linux-android23/libc++.so

clang/test/Driver/Inputs/basic_android_libcxx_tree/usr/lib/aarch64-unknown-linux-android29/libc++.so

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-unknown-linux-android23/libclang_rt.builtins.a

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-unknown-linux-android29/libclang_rt.builtins.a
clang/test/Driver/android-unversioned-fallback-warning.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/android-installed-libcxx.cpp
clang/test/Driver/linux-per-target-runtime-dir.c

Removed: 

clang/test/Driver/Inputs/basic_android_libcxx_tree/usr/lib/aarch64-unknown-linux-android21/libc++.so

clang/test/Driver/Inputs/resource_dir_with_per_target_subdir/lib/aarch64-unknown-linux-android21/libclang_rt.builtins.a



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d48bcb24e74ddb8..130dbe870f26d9a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -341,6 +341,23 @@ X86 Support
 Arm and AArch64 Support
 ^^^
 
+Android Support
+^^^
+
+- Android target triples are usually suffixed with a version. Clang searches 
for
+  target-specific runtime and standard libraries in directories named after the
+  target (e.g. if you're building with ``-target 
aarch64-none-linux-android21``,
+  Clang will look for ``lib/aarch64-none-linux-android21`` under its resource
+  directory to find runtime libraries). If an exact match isn't found, Clang
+  would previously fall back to a directory without any version (which would be
+  ``lib/aarch64-none-linux-android`` in our example). Clang will now look for
+  directories for lower versions and use the newest version it finds instead,
+  e.g. if you have ``lib/aarch64-none-linux-android21`` and
+  ``lib/aarch64-none-linux-android29``, ``-target 
aarch64-none-linux-android23``
+  will use the former and ``-target aarch64-none-linux-android30`` will use the
+  latter. Falling back to a versionless directory will now emit a warning, and
+  the fallback will be removed in Clang 19.
+
 Windows Support
 ^^^
 - Fixed an assertion failure that occurred due to a failure to propagate

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 9349ff85ca8a1d3..61ac792d6fda46a 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -749,4 +749,10 @@ def warn_drv_missing_multilib : Warning<
   InGroup>;
 def note_drv_available_multilibs : Note<
   "available multilibs are:%0">;
+
+def warn_android_unversioned_fallback : Warning<
+  "Using unversioned Android target directory %0 for target %1. Unversioned"
+  " directories will not be used in Clang 19. Provide a versioned directory"
+  " for the target version or lower instead.">,
+  InGroup>;
 }

diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 96d76c2384a9aa6..2d0c1f826c1728a 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -182,6 +182,9 @@ class ToolChain {
 EffectiveTriple = 

[clang] 1212d1b - [driver] Perform fallback target searches for stdlib

2023-09-18 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-09-18T12:18:51-07:00
New Revision: 1212d1b511251de69939c8aa380f660373e26419

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

LOG: [driver] Perform fallback target searches for stdlib

Searching for target-specific standard library header and library paths
should perform fallback searches for targets, the same way searching for
the runtime libraries does. It's important for the header and library
searches to be consistent, otherwise we could end up using mismatched
headers and libraries. (See also https://reviews.llvm.org/D146664.)

Reviewed By: phosek

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

Added: 
clang/test/Driver/Inputs/basic_android_libcxx_tree/usr/bin/.keep

clang/test/Driver/Inputs/basic_android_libcxx_tree/usr/lib/aarch64-unknown-linux-android/libc++.so

clang/test/Driver/Inputs/basic_android_libcxx_tree/usr/lib/aarch64-unknown-linux-android21/libc++.so

Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/VEToolchain.cpp
clang/test/Driver/android-installed-libcxx.cpp
clang/test/Driver/linux-per-target-runtime-dir.c

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 0b38b939a188ae1..96d76c2384a9aa6 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -209,6 +209,11 @@ class ToolChain {
   FileType Type,
   bool AddArch) const;
 
+  /// Find the target-specific subdirectory for the current target triple under
+  /// \p BaseDir, doing fallback triple searches as necessary.
+  /// \return The subdirectory path if it exists.
+  std::optional getTargetSubDirPath(StringRef BaseDir) const;
+
   /// \name Utilities for implementing subclasses.
   ///@{
   static void addSystemInclude(const llvm::opt::ArgList ,
@@ -504,8 +509,8 @@ class ToolChain {
   // Returns the target specific runtime path if it exists.
   std::optional getRuntimePath() const;
 
-  // Returns target specific standard library paths.
-  path_list getStdlibPaths() const;
+  // Returns target specific standard library path if it exists.
+  std::optional getStdlibPath() const;
 
   // Returns /lib// or /lib/.
   // This is used by runtimes (such as OpenMP) to find arch-specific libraries.

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 410757d5f9e1843..3a7e90e6b637707 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -88,8 +88,8 @@ ToolChain::ToolChain(const Driver , const llvm::Triple ,
 
   if (std::optional Path = getRuntimePath())
 getLibraryPaths().push_back(*Path);
-  for (const auto  : getStdlibPaths())
-addIfExists(getFilePaths(), Path);
+  if (std::optional Path = getStdlibPath())
+getFilePaths().push_back(*Path);
   for (const auto  : getArchSpecificLibPaths())
 addIfExists(getFilePaths(), Path);
 }
@@ -677,11 +677,12 @@ const char *ToolChain::getCompilerRTArgString(const 
llvm::opt::ArgList ,
   return Args.MakeArgString(getCompilerRT(Args, Component, Type));
 }
 
-std::optional ToolChain::getRuntimePath() const {
+std::optional
+ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
   auto getPathForTriple =
-  [this](const llvm::Triple ) -> std::optional {
-SmallString<128> P(D.ResourceDir);
-llvm::sys::path::append(P, "lib", Triple.str());
+  [&](const llvm::Triple ) -> std::optional {
+SmallString<128> P(BaseDir);
+llvm::sys::path::append(P, Triple.str());
 if (getVFS().exists(P))
   return std::string(P);
 return {};
@@ -725,13 +726,16 @@ std::optional ToolChain::getRuntimePath() 
const {
   return {};
 }
 
-ToolChain::path_list ToolChain::getStdlibPaths() const {
-  path_list Paths;
-  SmallString<128> P(D.Dir);
-  llvm::sys::path::append(P, "..", "lib", getTripleString());
-  Paths.push_back(std::string(P.str()));
+std::optional ToolChain::getRuntimePath() const {
+  SmallString<128> P(D.ResourceDir);
+  llvm::sys::path::append(P, "lib");
+  return getTargetSubDirPath(P);
+}
 
-  return Paths;
+std::optional ToolChain::getStdlibPath() const {
+  SmallString<128> P(D.Dir);
+  llvm::sys::path::append(P, "..", "lib");
+  return getTargetSubDirPath(P);
 }
 
 ToolChain::path_list ToolChain::getArchSpecificLibPaths() const {

diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index af34a46ae4f7d6a..55c966ff39cd451 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -257,8 

[clang] b1e3cd1 - [driver] Conditionally include installed libc++ headers for Android

2023-09-18 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-09-18T12:18:45-07:00
New Revision: b1e3cd1d79443603dc003441e07cdd8d30bb7f26

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

LOG: [driver] Conditionally include installed libc++ headers for Android

https://reviews.llvm.org/D71154 prevented Clang from search for libc++
headers installed alongside the driver when targeting Android. The
motivation was the NDK's use of a different libc++ inline namespace
(`__ndk1` instead of the standard `__1`), which made regular libc++
headers incompatible with the NDK's libc++ library.

Since then, libc++ has gained the ability to install its `__config_site`
header (which controls the inline namespace, among other things) to a
per-target include directory, which enables per-target customizations.
If this directory is present, the user has expressly built libc++ for
Android, and we should use those headers.

The motivation is that, with the current setup, if a user builds their
own libc++ for Android, they'll use the library they built themselves
but the NDK's headers instead of their own, which is surprising at best
and can cause all sorts of problems (e.g. if you built your own libc++
with a different ABI configuration). It's important to match the headers
and libraries in that scenario, and checking for an Android per-target
include directory lets us do so without regressing the original scenario
which https://reviews.llvm.org/D71154 was addressing.

While I'm here, switch to using sys::path::append instead of slashes
directly, to get system path separators on Windows, which is consistent
with how library paths are constructed (and that consistency will be
important in a follow-up, where we use a common search function for the
include and library path construction).

(As an aside, one of the motivations for https://reviews.llvm.org/D71154
was to support targeting both Android and Apple platforms, which
expected libc++ headers to be provided by the toolcain at the time.
Apple has since switched to including libc++ headers in the platform SDK
instead of in the toolchain, so that specific motivation no longer
applies either.)

Reviewed By: phosek

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

Added: 
clang/test/Driver/android-installed-libcxx.cpp

Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/android-ndk-standalone.cpp
clang/test/Driver/linux-header-search.cpp
clang/test/Driver/linux-musl-header-search.cpp
clang/test/Driver/linux-per-target-runtime-dir.c

Removed: 
clang/test/Driver/android-no-installed-libcxx.cpp



diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 7aeb8e29ebc5574..aa27584e2ebcc06 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -3102,32 +3102,44 @@ Generic_GCC::addLibCxxIncludePaths(const 
llvm::opt::ArgList ,
   std::string SysRoot = computeSysRoot();
   std::string Target = getTripleString();
 
-  auto AddIncludePath = [&](std::string Path) {
+  auto AddIncludePath = [&](StringRef Path, bool TargetDirRequired = false) {
 std::string Version = detectLibcxxVersion(Path);
 if (Version.empty())
   return false;
 
 // First add the per-target include path if it exists.
-std::string TargetDir = Path + "/" + Target + "/c++/" + Version;
+SmallString<128> TargetDir(Path);
+llvm::sys::path::append(TargetDir, Target, "c++", Version);
 if (D.getVFS().exists(TargetDir))
   addSystemInclude(DriverArgs, CC1Args, TargetDir);
+else if (TargetDirRequired)
+  return false;
 
 // Second add the generic one.
-addSystemInclude(DriverArgs, CC1Args, Path + "/c++/" + Version);
+SmallString<128> GenericDir(Path);
+llvm::sys::path::append(GenericDir, "c++", Version);
+addSystemInclude(DriverArgs, CC1Args, GenericDir);
 return true;
   };
 
-  // Android never uses the libc++ headers installed alongside the toolchain,
-  // which are generally incompatible with the NDK libraries anyway.
-  if (!getTriple().isAndroid())
-if (AddIncludePath(getDriver().Dir + "/../include"))
-  return;
+  // Android only uses the libc++ headers installed alongside the toolchain if
+  // they contain an Android-specific target include path, otherwise they're
+  // incompatible with the NDK libraries.
+  SmallString<128> DriverIncludeDir(getDriver().Dir);
+  llvm::sys::path::append(DriverIncludeDir, "..", "include");
+  if (AddIncludePath(DriverIncludeDir,
+ /*TargetDirRequired=*/getTriple().isAndroid()))
+return;
   // If this is a development, non-installed, clang, libcxx will
   // not be found at ../include/c++ but it likely to be found at
   // one of the following two locations:
-  if 

[clang] Modify BoundsSan to improve debuggability (PR #65972)

2023-09-12 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai review_requested 
https://github.com/llvm/llvm-project/pull/65972
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Modify BoundsSan to improve debuggability (PR #65972)

2023-09-12 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai review_requested 
https://github.com/llvm/llvm-project/pull/65972
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Modify BoundsSan to improve debuggability (PR #65972)

2023-09-12 Thread Shoaib Meenai via cfe-commits

https://github.com/smeenai review_requested 
https://github.com/llvm/llvm-project/pull/65972
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f41cd47 - [Driver] Enable stdlibxx-isystem test on Windows

2023-08-30 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-08-30T14:39:00-07:00
New Revision: f41cd477361b1891ca2702b66a8a66915258f15b

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

LOG: [Driver] Enable stdlibxx-isystem test on Windows

With `%/t`, we can now compare `-###` output against the installtion dir
without backslash escaping getting in the way. Having to check against
the doubled-up backslashes is ugly, but it's the pattern used in lots of
tests (including for things like debug info where an `-###` alternative
that didn't escape backslashes wouldn't help).

Added: 


Modified: 
clang/test/Driver/stdlibxx-isystem.cpp

Removed: 




diff  --git a/clang/test/Driver/stdlibxx-isystem.cpp 
b/clang/test/Driver/stdlibxx-isystem.cpp
index d4888984fdf115..cb23035559fb86 100644
--- a/clang/test/Driver/stdlibxx-isystem.cpp
+++ b/clang/test/Driver/stdlibxx-isystem.cpp
@@ -1,29 +1,28 @@
 // Backslash escaping makes matching against the installation directory fail on
 // Windows. Temporarily disable the test there until we add an option to print
 // the installation directory unescaped.
-// UNSUPPORTED: system-windows
 
 // By default, we should search for libc++ next to the driver.
 // RUN: mkdir -p %t/bin
 // RUN: mkdir -p %t/include/c++/v1
-// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
+// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %/t/bin \
 // RUN:   -stdlib=libc++ -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=LIBCXX %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %/t/bin \
 // RUN:   -stdlib=libc++ -fsyntax-only %s -### 2>&1 | \
 // RUN:   FileCheck -check-prefix=LIBCXX %s
 // LIBCXX: InstalledDir: [[INSTALLDIR:.+$]]
-// LIBCXX: "-internal-isystem" "[[INSTALLDIR]]/../include/c++/v1"
+// LIBCXX: "-internal-isystem" 
"[[INSTALLDIR]]{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1"
 
 // Passing -stdlib++-isystem should suppress the default search.
-// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
+// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %/t/bin \
 // RUN:   -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -stdlib=libc++ 
\
 // RUN:   -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NODEFAULT %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %/t/bin \
 // RUN:   -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -stdlib=libc++ 
\
 // RUN:   -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NODEFAULT %s
 // NODEFAULT: InstalledDir: [[INSTALLDIR:.+$]]
-// NODEFAULT-NOT: "-internal-isystem" "[[INSTALLDIR]]/../include/c++/v1"
+// NODEFAULT-NOT: "-internal-isystem" 
"[[INSTALLDIR]]{{/|}}..{{/|}}include{{/|}}c++{{/|}}v1"
 
 // And we should add it as an -internal-isystem.
 // RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \



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


[clang] b6a1473 - [driver] Refactor getRuntimePaths. NFC

2023-08-28 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-08-28T17:34:50-07:00
New Revision: b6a1473f97d38471b08331dee7ae7f6112c495c0

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

LOG: [driver] Refactor getRuntimePaths. NFC

This used to be getRuntimePath till https://reviews.llvm.org/D115049
added a fallback search path for Android. As far as I can tell, the
intent has always been to use the first existing path though instead of
actually supporting multiple runtime paths. We can move the existence
checks into getRuntimePath and have it return std::optional, which also
makes the `--print-runtime-dir` behavior much cleaner.

The motivation is a follow-up change to Android runtime path searches,
which is much nicer with this in place.

Reviewed By: phosek, MaskRay

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 2e74507f71267c..0b38b939a188ae 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -500,8 +501,8 @@ class ToolChain {
 StringRef Component,
 FileType Type = ToolChain::FT_Static) 
const;
 
-  // Returns target specific runtime paths.
-  path_list getRuntimePaths() const;
+  // Returns the target specific runtime path if it exists.
+  std::optional getRuntimePath() const;
 
   // Returns target specific standard library paths.
   path_list getStdlibPaths() const;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7b64ef4cc5db6e..07c4561c990aba 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2163,16 +2163,8 @@ bool Driver::HandleImmediateArgs(const Compilation ) {
   }
 
   if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
-std::string RuntimePath;
-// Get the first existing path, if any.
-for (auto Path : TC.getRuntimePaths()) {
-  if (getVFS().exists(Path)) {
-RuntimePath = Path;
-break;
-  }
-}
-if (!RuntimePath.empty())
-  llvm::outs() << RuntimePath << '\n';
+if (std::optional RuntimePath = TC.getRuntimePath())
+  llvm::outs() << *RuntimePath << '\n';
 else
   llvm::outs() << TC.getCompilerRTPath() << '\n';
 return false;

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 8dafc3d481c2e0..f40cee195fa559 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -86,8 +86,8 @@ ToolChain::ToolChain(const Driver , const llvm::Triple ,
   List.push_back(Path);
   };
 
-  for (const auto  : getRuntimePaths())
-addIfExists(getLibraryPaths(), Path);
+  if (std::optional Path = getRuntimePath())
+getLibraryPaths().push_back(*Path);
   for (const auto  : getStdlibPaths())
 addIfExists(getFilePaths(), Path);
   for (const auto  : getArchSpecificLibPaths())
@@ -677,15 +677,18 @@ const char *ToolChain::getCompilerRTArgString(const 
llvm::opt::ArgList ,
   return Args.MakeArgString(getCompilerRT(Args, Component, Type));
 }
 
-ToolChain::path_list ToolChain::getRuntimePaths() const {
-  path_list Paths;
-  auto addPathForTriple = [this, ](const llvm::Triple ) {
+std::optional ToolChain::getRuntimePath() const {
+  auto getPathForTriple =
+  [this](const llvm::Triple ) -> std::optional {
 SmallString<128> P(D.ResourceDir);
 llvm::sys::path::append(P, "lib", Triple.str());
-Paths.push_back(std::string(P.str()));
+if (getVFS().exists(P))
+  return std::string(P);
+return {};
   };
 
-  addPathForTriple(getTriple());
+  if (auto Path = getPathForTriple(getTriple()))
+return *Path;
 
   // When building with per target runtime directories, various ways of naming
   // the Arm architecture may have been normalised to simply "arm".
@@ -705,7 +708,8 @@ ToolChain::path_list ToolChain::getRuntimePaths() const {
   if (getTriple().getArch() == Triple::arm && !getTriple().isArmMClass()) {
 llvm::Triple ArmTriple = getTriple();
 ArmTriple.setArch(Triple::arm);
-addPathForTriple(ArmTriple);
+if (auto Path = getPathForTriple(ArmTriple))
+  return *Path;
   }
 
   // Android targets may include an API level at the end. We still want to fall
@@ -714,10 +718,11 @@ ToolChain::path_list ToolChain::getRuntimePaths() const {
   getTriple().getEnvironmentName() != "android") {
 llvm::Triple TripleWithoutLevel = getTriple();
 TripleWithoutLevel.setEnvironmentName("android");
-

[libunwind] 3da76c2 - [libunwind] Fix build with -Wunused-function

2023-07-27 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-07-27T20:22:16-07:00
New Revision: 3da76c2116179fdb3fff8feb4551209e4218746e

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

LOG: [libunwind] Fix build with -Wunused-function

https://reviews.llvm.org/D144252 removed -Wno-unused-function from the
libunwind build, but we have an unused function when you're building for
armv7 without assertions. Mark that function as possibly unused to avoid
the warning, and mark the parameter as a const pointer while I'm here to
make it clear that nothing is modified by a debugging function.

Reviewed By: #libunwind, philnik

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

Added: 


Modified: 
libunwind/src/Unwind-EHABI.cpp

Removed: 




diff  --git a/libunwind/src/Unwind-EHABI.cpp b/libunwind/src/Unwind-EHABI.cpp
index f387c5d3db4e65..05475c6ac1e2fe 100644
--- a/libunwind/src/Unwind-EHABI.cpp
+++ b/libunwind/src/Unwind-EHABI.cpp
@@ -885,8 +885,11 @@ _Unwind_GetLanguageSpecificData(struct _Unwind_Context 
*context) {
   return result;
 }
 
-static uint64_t ValueAsBitPattern(_Unwind_VRS_DataRepresentation 
representation,
-  void* valuep) {
+// Only used in _LIBUNWIND_TRACE_API, which is a no-op when assertions are
+// disabled.
+[[gnu::unused]] static uint64_t
+ValueAsBitPattern(_Unwind_VRS_DataRepresentation representation,
+  const void *valuep) {
   uint64_t value = 0;
   switch (representation) {
 case _UVRSD_UINT32:



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


[clang] 1df10f1 - [Frontend] Remove ShowIncludesPretendHeader

2023-06-21 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-06-21T15:48:28-07:00
New Revision: 1df10f15807f9b7deba3f714d27e21578a8b4748

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

LOG: [Frontend] Remove ShowIncludesPretendHeader

It hasn't been written to since https://reviews.llvm.org/D46652, so it
was always empty. I don't have enough context on that diff to know if
the removal of the write to ShowIncludesPretendHeader in that diff was
intentional, but no one's complained about it for five years, so I
assume we're okay to just get rid of it entirely.

Reviewed By: hans

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

Added: 


Modified: 
clang/include/clang/Frontend/DependencyOutputOptions.h
clang/lib/Frontend/HeaderIncludeGen.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/DependencyOutputOptions.h 
b/clang/include/clang/Frontend/DependencyOutputOptions.h
index e140ff9baa117..e4b26d92647d0 100644
--- a/clang/include/clang/Frontend/DependencyOutputOptions.h
+++ b/clang/include/clang/Frontend/DependencyOutputOptions.h
@@ -76,9 +76,6 @@ class DependencyOutputOptions {
   /// target.
   std::vector> ExtraDeps;
 
-  /// In /showIncludes mode, pretend the main TU is a header with this name.
-  std::string ShowIncludesPretendHeader;
-
   /// The file to write GraphViz-formatted header dependencies to.
   std::string DOTOutputFile;
 

diff  --git a/clang/lib/Frontend/HeaderIncludeGen.cpp 
b/clang/lib/Frontend/HeaderIncludeGen.cpp
index 27cd8b701a975..9ada227d42d62 100644
--- a/clang/lib/Frontend/HeaderIncludeGen.cpp
+++ b/clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -214,13 +214,8 @@ void HeaderIncludesCallback::FileChanged(SourceLocation 
Loc,
 
 // We track when we are done with the predefines by watching for the first
 // place where we drop back to a nesting depth of 1.
-if (CurrentIncludeDepth == 1 && !HasProcessedPredefines) {
-  if (!DepOpts.ShowIncludesPretendHeader.empty()) {
-PrintHeaderInfo(OutputFile, DepOpts.ShowIncludesPretendHeader,
-ShowDepth, 2, MSStyle);
-  }
+if (CurrentIncludeDepth == 1 && !HasProcessedPredefines)
   HasProcessedPredefines = true;
-}
 
 return;
   } else {
@@ -233,8 +228,6 @@ void HeaderIncludesCallback::FileChanged(SourceLocation Loc,
   unsigned IncludeDepth = CurrentIncludeDepth;
   if (!HasProcessedPredefines)
 --IncludeDepth; // Ignore indent from .
-  else if (!DepOpts.ShowIncludesPretendHeader.empty())
-++IncludeDepth; // Pretend inclusion by ShowIncludesPretendHeader.
 
   // FIXME: Identify headers in a more robust way than comparing their name to
   // "" and "" in a bunch of places.



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


[clang] 67a1129 - [Frontend] Don't output skipped includes from predefines

2023-06-21 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-06-21T15:48:27-07:00
New Revision: 67a11290df64fec44e671a1bdc3a225ed8a02962

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

LOG: [Frontend] Don't output skipped includes from predefines

`-H` displays a tree of included header files, but that tree is supposed
to omit two categories of header files:
1. Any header files pulled in via `-include`, which the code refers to
   as the "predefines".
2. Any header files whose inclusion was skipped because they'd already
   been included (assuming header guards or `#pragma once`).

`-fshow-skipped-includes` was intended to make `-H` display the second
category of files. It wasn't checking for the first category, however,
so you could end up with only the middle of the `-include` hierarchy
displayed, e.g. the added test would previously output:

```
... /data/users/smeenai/llvm-project/clang/test/Frontend/Inputs/test2.h
. /data/users/smeenai/llvm-project/clang/test/Frontend/Inputs/test.h
```

This diff adds a check to prevent that and correctly omit headers from
`-include` even when `-fshow-skipped-includes` is passed. While I'm
here, add tests for the interaction between `-fshow-skipped-includes`
and `-sys-header-deps` as well.

Reviewed By: hans

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

Added: 


Modified: 
clang/lib/Frontend/HeaderIncludeGen.cpp
clang/test/Frontend/print-header-includes.c

Removed: 




diff  --git a/clang/lib/Frontend/HeaderIncludeGen.cpp 
b/clang/lib/Frontend/HeaderIncludeGen.cpp
index 2ab4809402645..27cd8b701a975 100644
--- a/clang/lib/Frontend/HeaderIncludeGen.cpp
+++ b/clang/lib/Frontend/HeaderIncludeGen.cpp
@@ -49,6 +49,18 @@ class HeaderIncludesCallback : public PPCallbacks {
 
   void FileSkipped(const FileEntryRef , const Token ,
SrcMgr::CharacteristicKind FileType) override;
+
+private:
+  bool ShouldShowHeader(SrcMgr::CharacteristicKind HeaderType) {
+if (!DepOpts.IncludeSystemHeaders && isSystem(HeaderType))
+  return false;
+
+// Show the current header if we are (a) past the predefines, or (b) 
showing
+// all headers and in the predefines at a depth past the initial file and
+// command line buffers.
+return (HasProcessedPredefines ||
+(ShowAllHeaders && CurrentIncludeDepth > 2));
+  }
 };
 
 /// A callback for emitting header usage information to a file in JSON. Each
@@ -211,29 +223,22 @@ void HeaderIncludesCallback::FileChanged(SourceLocation 
Loc,
 }
 
 return;
-  } else
+  } else {
+return;
+  }
+
+  if (!ShouldShowHeader(NewFileType))
 return;
 
-  // Show the header if we are (a) past the predefines, or (b) showing all
-  // headers and in the predefines at a depth past the initial file and command
-  // line buffers.
-  bool ShowHeader = (HasProcessedPredefines ||
- (ShowAllHeaders && CurrentIncludeDepth > 2));
   unsigned IncludeDepth = CurrentIncludeDepth;
   if (!HasProcessedPredefines)
 --IncludeDepth; // Ignore indent from .
   else if (!DepOpts.ShowIncludesPretendHeader.empty())
 ++IncludeDepth; // Pretend inclusion by ShowIncludesPretendHeader.
 
-  if (!DepOpts.IncludeSystemHeaders && isSystem(NewFileType))
-ShowHeader = false;
-
-  // Dump the header include information we are past the predefines buffer or
-  // are showing all headers and this isn't the magic implicit 
-  // header.
   // FIXME: Identify headers in a more robust way than comparing their name to
   // "" and "" in a bunch of places.
-  if (ShowHeader && Reason == PPCallbacks::EnterFile &&
+  if (Reason == PPCallbacks::EnterFile &&
   UserLoc.getFilename() != StringRef("")) {
 PrintHeaderInfo(OutputFile, UserLoc.getFilename(), ShowDepth, IncludeDepth,
 MSStyle);
@@ -246,7 +251,7 @@ void HeaderIncludesCallback::FileSkipped(const FileEntryRef 
, const
   if (!DepOpts.ShowSkippedHeaderIncludes)
 return;
 
-  if (!DepOpts.IncludeSystemHeaders && isSystem(FileType))
+  if (!ShouldShowHeader(FileType))
 return;
 
   PrintHeaderInfo(OutputFile, SkippedFile.getName(), ShowDepth,

diff  --git a/clang/test/Frontend/print-header-includes.c 
b/clang/test/Frontend/print-header-includes.c
index c210e53ee96c6..77db5ad108e39 100644
--- a/clang/test/Frontend/print-header-includes.c
+++ b/clang/test/Frontend/print-header-includes.c
@@ -17,6 +17,29 @@
 // SKIPPED: .. {{.*test2.h}}
 // SKIPPED: .. {{.*test2.h}}
 
+// RUN: %clang_cc1 -isystem %S -isystem %S/Inputs/SystemHeaderPrefix \
+// RUN: -E -H -fshow-skipped-includes -sys-header-deps -o /dev/null %s 2> 
%t.stderr
+// RUN: FileCheck --check-prefix=SKIPPED-SYS < %t.stderr %s
+
+// SKIPPED-SYS: . {{.*noline.h}}
+// SKIPPED-SYS: . {{.*test.h}}
+// SKIPPED-SYS: .. {{.*test2.h}}
+// SKIPPED-SYS: 

[clang] 8f7b51e - [CodeGen] Make __clang_call_terminate have an unwind table entry

2023-05-25 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-05-25T10:56:23-07:00
New Revision: 8f7b51e4ec09f6f50ea6508a196ec607f0659179

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

LOG: [CodeGen] Make __clang_call_terminate have an unwind table entry

This enables unwinders to step past that frame on architectures that
don't use DWARF unwinding (such as armv7), e.g. when debugging. The
problem should theoretically be architecture-agnostic, but according to
https://discourse.llvm.org/t/51633/2 it gets masked on architectures
that use DWARF unwind info.

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

Reviewed By: efriedma, rnk

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

Added: 
clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp

Modified: 
clang/lib/CodeGen/ItaniumCXXABI.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 668660124c74..5dc21dd31e0a 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -4689,6 +4689,7 @@ static llvm::FunctionCallee 
getClangCallTerminateFn(CodeGenModule ) {
   cast(fnRef.getCallee()->stripPointerCasts());
   if (fn->empty()) {
 CGM.SetLLVMFunctionAttributes(GlobalDecl(), FI, fn, /*IsThunk=*/false);
+CGM.SetLLVMFunctionAttributesForDefinition(nullptr, fn);
 fn->setDoesNotThrow();
 fn->setDoesNotReturn();
 

diff  --git a/clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp 
b/clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
new file mode 100644
index ..ebf21c635da0
--- /dev/null
+++ b/clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,NOUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-funwind-tables=1 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,SYNCUNWIND %s
+// RUN: %clang_cc1 -triple=x86_64-linux-gnu -fexceptions -fcxx-exceptions 
-funwind-tables=2 -emit-llvm -o - %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,ASYNCUNWIND %s
+
+void caller(void callback()) noexcept { callback(); }
+
+// CHECK: define {{.*}}void @__clang_call_terminate({{[^)]*}}) #[[#ATTRNUM:]]
+// CHECK: attributes #[[#ATTRNUM]] = {
+// NOUNWIND-NOT: uwtable
+// NOUNWIND-SAME: }
+// SYNCUNWIND-SAME: uwtable(sync)
+// ASYNCUNWIND-SAME: uwtable{{ }}



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


[clang] df43ec3 - [Driver] Add test for -stdlib++-isystem with -nostdinc

2022-11-30 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2022-11-30T23:09:28-08:00
New Revision: df43ec30ab66f5af7bbf87e121e0fe26aad478b4

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

LOG: [Driver] Add test for -stdlib++-isystem with -nostdinc

This further clarifies the intent of the flag.

Added: 


Modified: 
clang/test/Driver/stdlibxx-isystem.cpp

Removed: 




diff  --git a/clang/test/Driver/stdlibxx-isystem.cpp 
b/clang/test/Driver/stdlibxx-isystem.cpp
index 827cdf9a7c71..d4888984fdf1 100644
--- a/clang/test/Driver/stdlibxx-isystem.cpp
+++ b/clang/test/Driver/stdlibxx-isystem.cpp
@@ -51,3 +51,13 @@
 // RUN:   -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -nostdinc++ \
 // RUN:   -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NOSTDINCXX %s
 // NOSTDINCXX-NOT: "-internal-isystem" "/tmp/foo" "-internal-isystem" 
"/tmp/bar"
+
+// It should take effect even if -nostdinc or -nostdlibinc are specified; only
+// -nostdinc++ should suppress it.
+// RUN: %clang -target aarch64-linux-gnu -ccc-install-dir %t/bin \
+// RUN:   -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -nostdinc \
+// RUN:   -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NOSTDINC %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %t/bin \
+// RUN:   -stdlib++-isystem /tmp/foo -stdlib++-isystem /tmp/bar -nostdlibinc \
+// RUN:   -fsyntax-only %s -### 2>&1 | FileCheck -check-prefix=NOSTDINC %s
+// NOSTDINC: "-internal-isystem" "/tmp/foo" "-internal-isystem" "/tmp/bar"



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


[clang] 42b3a5f - [clang] Add missing header include

2022-07-14 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2022-07-14T00:21:09-07:00
New Revision: 42b3a5fb463fd616d981888abaf0f48ab0065a8d

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

LOG: [clang] Add missing header include

With my version of the MSVC tools (14.11.25503), this was failing to
build because of missing declarations of `std::isalnum` and
`std::isdigit`. Include `` to get these.

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index b94ca887a056..97435f1a73de 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -52,6 +52,7 @@
 #include "llvm/Support/Process.h"
 #include "llvm/Support/TargetParser.h"
 #include "llvm/Support/YAMLParser.h"
+#include 
 
 using namespace clang::driver;
 using namespace clang::driver::tools;



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


[libunwind] 0be0a53 - [libunwind] Use process_vm_readv to avoid potential segfaults

2022-05-26 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2022-05-26T09:12:51-07:00
New Revision: 0be0a53df65cb402359c257922d80ab93d86fb40

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

LOG: [libunwind] Use process_vm_readv to avoid potential segfaults

We've observed segfaults in libunwind when attempting to check for the
Linux aarch64 sigreturn frame, presumably because of bad unwind info
leading to an incorrect PC that we attempt to read from. Use
process_vm_readv to read the memory safely instead.

The s390x code path should likely follow suit, but I don't have the
hardware to be able to test that, so I didn't modify it here either.

Reviewed By: MaskRay, rprichard, #libunwind

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

Added: 
libunwind/test/bad_unwind_info.pass.cpp

Modified: 
libunwind/src/UnwindCursor.hpp

Removed: 




diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 01f0c404a2ac4..6e8fc45ebfa8f 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -32,6 +32,9 @@
 
 #if defined(_LIBUNWIND_TARGET_LINUX) &&
\
 (defined(_LIBUNWIND_TARGET_AARCH64) || defined(_LIBUNWIND_TARGET_S390X))
+#include 
+#include 
+#include 
 #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1
 #endif
 
@@ -2620,16 +2623,28 @@ bool UnwindCursor::setInfoForSigReturn(Registers_arm64 &) {
   //
   // [1] 
https://github.com/torvalds/linux/blob/master/arch/arm64/kernel/vdso/sigreturn.S
   const pint_t pc = static_cast(this->getReg(UNW_REG_IP));
+  // The PC might contain an invalid address if the unwind info is bad, so
+  // directly accessing it could cause a segfault. Use process_vm_readv to read
+  // the memory safely instead. process_vm_readv was added in Linux 3.2, and
+  // AArch64 supported was added in Linux 3.7, so the syscall is guaranteed to
+  // be present. Unfortunately, there are Linux AArch64 environments where the
+  // libc wrapper for the syscall might not be present (e.g. Android 5), so 
call
+  // the syscall directly instead.
+  uint32_t instructions[2];
+  struct iovec local_iov = {, sizeof instructions};
+  struct iovec remote_iov = {reinterpret_cast(pc), sizeof 
instructions};
+  long bytesRead =
+  syscall(SYS_process_vm_readv, getpid(), _iov, 1, _iov, 1, 
0);
   // Look for instructions: mov x8, #0x8b; svc #0x0
-  if (_addressSpace.get32(pc) == 0xd2801168 &&
-  _addressSpace.get32(pc + 4) == 0xd401) {
-_info = {};
-_info.start_ip = pc;
-_info.end_ip = pc + 4;
-_isSigReturn = true;
-return true;
-  }
-  return false;
+  if (bytesRead != sizeof instructions || instructions[0] != 0xd2801168 ||
+  instructions[1] != 0xd401)
+return false;
+
+  _info = {};
+  _info.start_ip = pc;
+  _info.end_ip = pc + 4;
+  _isSigReturn = true;
+  return true;
 }
 
 template 

diff  --git a/libunwind/test/bad_unwind_info.pass.cpp 
b/libunwind/test/bad_unwind_info.pass.cpp
new file mode 100644
index 0..97427ea922737
--- /dev/null
+++ b/libunwind/test/bad_unwind_info.pass.cpp
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+// Ensure that libunwind doesn't crash on invalid info; the Linux aarch64
+// sigreturn frame check would previously attempt to access invalid memory in
+// this scenario.
+// REQUIRES: linux && (target={{aarch64-.+}} || target={{x86_64-.+}})
+
+// GCC doesn't support __attribute__((naked)) on AArch64.
+// UNSUPPORTED: gcc
+
+// Inline assembly is incompatible with MSAN.
+// UNSUPPORTED: msan
+
+#undef NDEBUG
+#include 
+#include 
+#include 
+
+__attribute__((naked)) void bad_unwind_info() {
+#if defined(__aarch64__)
+  __asm__("// not using 0 because unwinder was already resilient to that\n"
+  "mov x8, #4\n"
+  "stp x30, x8, [sp, #-16]!\n"
+  ".cfi_def_cfa_offset 16\n"
+  "// purposely use incorrect offset for x30\n"
+  ".cfi_offset x30, -8\n"
+  "bl  stepper\n"
+  "ldr x30, [sp], #16\n"
+  ".cfi_def_cfa_offset 0\n"
+  ".cfi_restore x30\n"
+  "ret\n");
+#elif defined(__x86_64__)
+  __asm__("pushq   %rbx\n"
+  ".cfi_def_cfa_offset 16\n"
+  "movq8(%rsp), %rbx\n"
+  "# purposely corrupt return value on stack\n"
+  "movq$4, 8(%rsp)\n"
+  "callq   stepper\n"
+  "movq%rbx, 8(%rsp)\n"
+  "popq%rbx\n"
+  

[libunwind] 3d2b5b7 - [libunwind] Factor out sigreturn check condition. NFC

2022-05-26 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2022-05-26T09:12:50-07:00
New Revision: 3d2b5b7b87857b0cc4c322cfc145c46c42fe2bbf

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

LOG: [libunwind] Factor out sigreturn check condition. NFC

Create a macro for this instead of duplicating the architecture checks
everywhere. (It's a little redundant to use it when we're checking for a
specific architecture, but I'm also applying it there for consistency.)

Reviewed By: rprichard, MaskRay, #libunwind

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

Added: 


Modified: 
libunwind/src/UnwindCursor.hpp

Removed: 




diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 7e56eff471596..01f0c404a2ac4 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -30,6 +30,11 @@
 #include 
 #endif
 
+#if defined(_LIBUNWIND_TARGET_LINUX) &&
\
+(defined(_LIBUNWIND_TARGET_AARCH64) || defined(_LIBUNWIND_TARGET_S390X))
+#define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1
+#endif
+
 #if defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
 // Provide a definition for the DISPATCHER_CONTEXT struct for old (Win7 and
 // earlier) SDKs.
@@ -953,7 +958,7 @@ class UnwindCursor : public AbstractUnwindCursor{
   }
 #endif
 
-#if defined(_LIBUNWIND_TARGET_LINUX) && (defined(_LIBUNWIND_TARGET_AARCH64) || 
defined(_LIBUNWIND_TARGET_S390X))
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
   bool setInfoForSigReturn() {
 R dummy;
 return setInfoForSigReturn(dummy);
@@ -962,14 +967,14 @@ class UnwindCursor : public AbstractUnwindCursor{
 R dummy;
 return stepThroughSigReturn(dummy);
   }
-  #if defined(_LIBUNWIND_TARGET_AARCH64)
+#if defined(_LIBUNWIND_TARGET_AARCH64)
   bool setInfoForSigReturn(Registers_arm64 &);
   int stepThroughSigReturn(Registers_arm64 &);
-  #endif
-  #if defined(_LIBUNWIND_TARGET_S390X)
+#endif
+#if defined(_LIBUNWIND_TARGET_S390X)
   bool setInfoForSigReturn(Registers_s390x &);
   int stepThroughSigReturn(Registers_s390x &);
-  #endif
+#endif
   template  bool setInfoForSigReturn(Registers &) {
 return false;
   }
@@ -1264,7 +1269,7 @@ class UnwindCursor : public AbstractUnwindCursor{
   unw_proc_info_t  _info;
   bool _unwindInfoMissing;
   bool _isSignalFrame;
-#if defined(_LIBUNWIND_TARGET_LINUX) && (defined(_LIBUNWIND_TARGET_AARCH64) || 
defined(_LIBUNWIND_TARGET_S390X))
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
   bool _isSigReturn = false;
 #endif
 };
@@ -2471,7 +2476,7 @@ int UnwindCursor::stepWithTBTable(pint_t pc, 
tbtable *TBTable,
 
 template 
 void UnwindCursor::setInfoBasedOnIPRegister(bool isReturnAddress) {
-#if defined(_LIBUNWIND_TARGET_LINUX) && (defined(_LIBUNWIND_TARGET_AARCH64) || 
defined(_LIBUNWIND_TARGET_S390X))
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
   _isSigReturn = false;
 #endif
 
@@ -2586,7 +2591,7 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
   }
 #endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
 
-#if defined(_LIBUNWIND_TARGET_LINUX) && (defined(_LIBUNWIND_TARGET_AARCH64) || 
defined(_LIBUNWIND_TARGET_S390X))
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
   if (setInfoForSigReturn())
 return;
 #endif
@@ -2595,7 +2600,8 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
   _unwindInfoMissing = true;
 }
 
-#if defined(_LIBUNWIND_TARGET_LINUX) && defined(_LIBUNWIND_TARGET_AARCH64)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) &&   
\
+defined(_LIBUNWIND_TARGET_AARCH64)
 template 
 bool UnwindCursor::setInfoForSigReturn(Registers_arm64 &) {
   // Look for the sigreturn trampoline. The trampoline's body is two
@@ -2657,9 +2663,11 @@ int UnwindCursor::stepThroughSigReturn(Registers_arm64 &) {
   _isSignalFrame = true;
   return UNW_STEP_SUCCESS;
 }
-#endif // defined(_LIBUNWIND_TARGET_LINUX) && 
defined(_LIBUNWIND_TARGET_AARCH64)
+#endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) &&
+   // defined(_LIBUNWIND_TARGET_AARCH64)
 
-#if defined(_LIBUNWIND_TARGET_LINUX) && defined(_LIBUNWIND_TARGET_S390X)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) &&   
\
+defined(_LIBUNWIND_TARGET_S390X)
 template 
 bool UnwindCursor::setInfoForSigReturn(Registers_s390x &) {
   // Look for the sigreturn trampoline. The trampoline's body is a
@@ -2755,7 +2763,8 @@ int UnwindCursor::stepThroughSigReturn(Registers_s390x &) {
 
   return UNW_STEP_SUCCESS;
 }
-#endif // defined(_LIBUNWIND_TARGET_LINUX) && defined(_LIBUNWIND_TARGET_S390X)
+#endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) &&
+   // defined(_LIBUNWIND_TARGET_S390X)
 
 template 
 int UnwindCursor::step() {
@@ -2765,7 +2774,7 @@ int UnwindCursor::step() {
 
   

[clang-tools-extra] 4baae16 - [pseudo] Fix pseudo-gen usage when cross-compiling

2022-05-25 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2022-05-25T11:08:21-07:00
New Revision: 4baae166ce33ac763bfc1813cf56b8d26e07fb1f

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

LOG: [pseudo] Fix pseudo-gen usage when cross-compiling

Use the LLVM build system's cross-compilation support for the tool, so
that the build works for both host and cross-compilation scenarios.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/pseudo/include/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/CMakeLists.txt 
b/clang-tools-extra/pseudo/include/CMakeLists.txt
index a79dd0dab8184..e4265b18c2b2e 100644
--- a/clang-tools-extra/pseudo/include/CMakeLists.txt
+++ b/clang-tools-extra/pseudo/include/CMakeLists.txt
@@ -1,25 +1,35 @@
 # The cxx.bnf grammar file
 set(cxx_bnf ${CMAKE_CURRENT_SOURCE_DIR}/../lib/cxx.bnf)
 
+# Using CMAKE_CROSSCOMPILING and not LLVM_USE_HOST_TOOLS because the latter is
+# also set for LLVM_OPTIMIZED_TABLEGEN, which we don't care about here.
+if(CMAKE_CROSSCOMPILING)
+  build_native_tool(pseudo-gen pseudo_gen)
+  set(pseudo_gen_target "${pseudo_gen}")
+else()
+  set(pseudo_gen $)
+  set(pseudo_gen_target pseudo-gen)
+endif()
+
 # Generate inc files.
 set(cxx_symbols_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXSymbols.inc)
 add_custom_command(OUTPUT ${cxx_symbols_inc}
-   COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pseudo-gen"
+   COMMAND "${pseudo_gen}"
  --grammar ${cxx_bnf}
  --emit-symbol-list
  -o ${cxx_symbols_inc}
COMMENT "Generating nonterminal symbol file for cxx grammar..."
-   DEPENDS pseudo-gen
+   DEPENDS ${pseudo_gen_target}
VERBATIM)
 
 set(cxx_bnf_inc ${CMAKE_CURRENT_BINARY_DIR}/CXXBNF.inc)
 add_custom_command(OUTPUT ${cxx_bnf_inc}
-   COMMAND "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/pseudo-gen"
+   COMMAND "${pseudo_gen}"
  --grammar ${cxx_bnf}
  --emit-grammar-content
  -o ${cxx_bnf_inc}
COMMENT "Generating bnf string file for cxx grammar..."
-   DEPENDS pseudo-gen
+   DEPENDS ${pseudo_gen_target}
VERBATIM)
 
 # add_custom_command does not create a new target, we need to deine a target



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


[clang] b4c1cbf - [hmaptool] Fix string decoding for Python 3

2022-03-03 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2022-03-03T15:18:21-08:00
New Revision: b4c1cbff79d0631c35ca2efa97bd2a47929945b8

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

LOG: [hmaptool] Fix string decoding for Python 3

Our "strings" were actually bytes, which made verbose dumping fail.
Decode them so they actually become strings.

Reviewed By: bruno

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

Added: 


Modified: 
clang/utils/hmaptool/hmaptool

Removed: 




diff  --git a/clang/utils/hmaptool/hmaptool b/clang/utils/hmaptool/hmaptool
index 73897c8bb8e9f..d7754632b162b 100755
--- a/clang/utils/hmaptool/hmaptool
+++ b/clang/utils/hmaptool/hmaptool
@@ -100,7 +100,7 @@ class HeaderMap(object):
 raise SystemExit("error: %s: invalid string index" % (
 idx,))
 end_idx = self.strtable.index(0, idx)
-return self.strtable[idx:end_idx]
+return self.strtable[idx:end_idx].decode()
 
 @property
 def mappings(self):



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


[clang] 0c1d330 - [hmaptool] Fix dumping

2022-03-03 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2022-03-03T15:18:09-08:00
New Revision: 0c1d330431f59011fd861e291d5048858a973c5a

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

LOG: [hmaptool] Fix dumping

It was complaining about too many values to unpack, since our struct
unpack format string specified six members, but we only had five
variables to unpack to. The sixth value is the max value length, but
it's not used in dumping, so we can ignore it.

Reviewed By: bruno

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

Added: 


Modified: 
clang/utils/hmaptool/hmaptool

Removed: 




diff  --git a/clang/utils/hmaptool/hmaptool b/clang/utils/hmaptool/hmaptool
index 7949002020489..73897c8bb8e9f 100755
--- a/clang/utils/hmaptool/hmaptool
+++ b/clang/utils/hmaptool/hmaptool
@@ -44,7 +44,7 @@ class HeaderMap(object):
 path,))
 
 (version, reserved, strtable_offset, num_entries,
- num_buckets) = struct.unpack(header_fmt, data)
+ num_buckets, _) = struct.unpack(header_fmt, data)
 
 if version != 1:
 raise SystemExit("error: %s: unknown headermap version: %r" % (



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


[clang] b846795 - [docs] [clang] Small documentation change for compilation databases

2022-01-22 Thread Shoaib Meenai via cfe-commits

Author: Dave
Date: 2022-01-22T17:30:34-08:00
New Revision: b8467952404c3598c9c901332607eb1886e1721c

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

LOG: [docs] [clang] Small documentation change for compilation databases

We have an page dedicated to compliation databases including
various ways to generate them, but we don't mention that clang
has a built in method to do this.  This addresses that.

Reviewed By: joerg

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

Added: 


Modified: 
clang/docs/JSONCompilationDatabase.rst

Removed: 




diff  --git a/clang/docs/JSONCompilationDatabase.rst 
b/clang/docs/JSONCompilationDatabase.rst
index 3595cf452f4ca..6fd17fe440add 100644
--- a/clang/docs/JSONCompilationDatabase.rst
+++ b/clang/docs/JSONCompilationDatabase.rst
@@ -29,6 +29,10 @@ system is not necessarily the best solution:
 Supported Systems
 =
 
+Clang has the ablity to generate compilation database fragments via
+the :option:`-MJ argument >`. You can concatenate those
+fragments together between ``[`` and ``]`` to create a compilation database.
+
 Currently `CMake `_ (since 2.8.5) supports generation
 of compilation databases for Unix Makefile builds (Ninja builds in the
 works) with the option ``CMAKE_EXPORT_COMPILE_COMMANDS``.



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


[clang-tools-extra] ba94b8b - [clangd] Attempt to fix buildbots

2021-10-25 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2021-10-25T20:16:59-07:00
New Revision: ba94b8bdffb4c65d5475746a6ba43d279683e5bd

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

LOG: [clangd] Attempt to fix buildbots

http://45.33.8.238/win/47615/step_4.txt is a sample error; I believe it
just needs the right header to be included.

Added: 


Modified: 
clang-tools-extra/clangd/support/ThreadCrashReporter.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/support/ThreadCrashReporter.cpp 
b/clang-tools-extra/clangd/support/ThreadCrashReporter.cpp
index e67900e6916d9..b0386ba0089d0 100644
--- a/clang-tools-extra/clangd/support/ThreadCrashReporter.cpp
+++ b/clang-tools-extra/clangd/support/ThreadCrashReporter.cpp
@@ -9,6 +9,7 @@
 #include "support/ThreadCrashReporter.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ThreadLocal.h"
+#include 
 
 namespace clang {
 namespace clangd {



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


[libunwind] adf1561 - [libunwind] Inform ASan that resumption is noreturn

2021-05-26 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2021-05-26T09:31:39-07:00
New Revision: adf1561d6ce8af057127c65af863b3f0e1c77e60

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

LOG: [libunwind] Inform ASan that resumption is noreturn

If you're building libunwind instrumented with ASan, `_Unwind_RaiseException`
will poison the stack and then transfer control in a manner which isn't
understood by ASan, so the stack will remain poisoned. This can cause
false positives, e.g. if you call an uninstrumented function (so it
doesn't re-poison the stack) after catching an exception. Add a call to
`__asan_handle_no_return` inside `__unw_resume` to get ASan to unpoison
the stack and avoid this.

`__unw_resume` seems like the appropriate place to make this call, since
it's used for resumption by all unwind implementations except SJLJ. SJLJ
uses `__builtin_longjmp` to handle resumption, which is already
recognized as noreturn (and therefore ASan adds the `__asan_handle_no_return`
call itself), so it doesn't need any special handling.

PR32434 is somewhat similar (in particular needing a component built
without ASan to trigger the bug), and rG781ef03e1012, the fix for that
bug, adds an interceptor for `_Unwind_RaiseException`. This interceptor
won't always be triggered though, e.g. if you statically link the
unwinder into libc++abi in a way that prevents interposing the unwinder
functions (e.g. marking the symbols as hidden, using `--exclude-libs`,
or using `-Bsymbolic`). rG53335d6d86d5 makes `__cxa_throw` call
`__asan_handle_no_return` explicitly, to similarly avoid relying on
interception.

Reviewed By: #libunwind, compnerd

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

Added: 


Modified: 
libunwind/src/libunwind.cpp

Removed: 




diff  --git a/libunwind/src/libunwind.cpp b/libunwind/src/libunwind.cpp
index eb2623e56430d..9b3b92bdff099 100644
--- a/libunwind/src/libunwind.cpp
+++ b/libunwind/src/libunwind.cpp
@@ -16,6 +16,9 @@
 
 #include 
 
+#if __has_feature(address_sanitizer)
+#include 
+#endif
 
 #if !defined(__USING_SJLJ_EXCEPTIONS__)
 #include "AddressSpace.hpp"
@@ -184,6 +187,10 @@ _LIBUNWIND_WEAK_ALIAS(__unw_get_proc_info, 
unw_get_proc_info)
 /// Resume execution at cursor position (aka longjump).
 _LIBUNWIND_HIDDEN int __unw_resume(unw_cursor_t *cursor) {
   _LIBUNWIND_TRACE_API("__unw_resume(cursor=%p)", static_cast(cursor));
+#if __has_feature(address_sanitizer)
+  // Inform the ASan runtime that now might be a good time to clean stuff up.
+  __asan_handle_no_return();
+#endif
   AbstractUnwindCursor *co = (AbstractUnwindCursor *)cursor;
   co->jumpto();
   return UNW_EUNSPEC;



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


[clang] 56f7e5a - [cmake] Add support for multiple distributions

2021-05-12 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2021-05-12T11:13:18-07:00
New Revision: 56f7e5a822b43578e086c40d063af2a2c0d214ee

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

LOG: [cmake] Add support for multiple distributions

LLVM's build system contains support for configuring a distribution, but
it can often be useful to be able to configure multiple distributions
(e.g. if you want separate distributions for the tools and the
libraries). Add this support to the build system, along with
documentation and usage examples.

Reviewed By: phosek

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

Added: 
clang/cmake/caches/MultiDistributionExample.cmake

Modified: 
clang/cmake/modules/AddClang.cmake
clang/cmake/modules/CMakeLists.txt
clang/cmake/modules/ClangConfig.cmake.in
flang/cmake/modules/AddFlang.cmake
flang/cmake/modules/CMakeLists.txt
flang/cmake/modules/FlangConfig.cmake.in
lld/cmake/modules/AddLLD.cmake
lld/cmake/modules/CMakeLists.txt
lld/cmake/modules/LLDConfig.cmake.in
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/CMakeLists.txt
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/cmake/modules/LLVMDistributionSupport.cmake
llvm/docs/BuildingADistribution.rst
llvm/docs/ReleaseNotes.rst
mlir/cmake/modules/AddMLIR.cmake
mlir/cmake/modules/CMakeLists.txt
mlir/cmake/modules/MLIRConfig.cmake.in

Removed: 




diff  --git a/clang/cmake/caches/MultiDistributionExample.cmake 
b/clang/cmake/caches/MultiDistributionExample.cmake
new file mode 100644
index 0..0c97611e252b4
--- /dev/null
+++ b/clang/cmake/caches/MultiDistributionExample.cmake
@@ -0,0 +1,74 @@
+# This file sets up a CMakeCache for a simple build with multiple 
distributions.
+# Note that for a real distribution, you likely want to perform a boostrap
+# build; see clang/cmake/caches/DistributionExample.cmake and the
+# BuildingADistribution documentation for details. This cache file doesn't
+# demonstrate bootstrapping so it can focus on the configuration details
+# specific to multiple distributions instead.
+
+# Build an optimized toolchain for an example set of targets.
+set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(LLVM_TARGETS_TO_BUILD
+  AArch64
+  ARM
+  X86
+CACHE STRING "")
+
+# Enable the LLVM projects and runtimes.
+set(LLVM_ENABLE_PROJECTS
+  clang
+  lld
+CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES
+  compiler-rt
+  libcxx
+  libcxxabi
+CACHE STRING "")
+
+# We'll build two distributions: Toolchain, which just holds the tools
+# (intended for most end users), and Development, which has libraries (for end
+# users who wish to develop their own tooling using those libraries). This will
+# produce the install-toolchain-distribution and 
install-development-distribution
+# targets to install the distributions.
+set(LLVM_DISTRIBUTIONS
+  Toolchain
+  Development
+CACHE STRING "")
+
+# We want to include the C++ headers in our distribution.
+set(LLVM_RUNTIME_DISTRIBUTION_COMPONENTS
+  cxx-headers
+CACHE STRING "")
+
+# You likely want more tools; this is just an example :) Note that we need to
+# include cxx-headers explicitly here (in addition to it being added to
+# LLVM_RUNTIME_DISTRIBUTION_COMPONENTS above).
+set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
+  builtins
+  clang
+  clang-resource-headers
+  cxx-headers
+  lld
+  llvm-objdump
+CACHE STRING "")
+
+# Note that we need to include the CMake exports targets for the distribution
+# (development-cmake-exports and clang-development-cmake-exports), as well as
+# the general CMake exports target for each project (cmake-exports and
+# clang-cmake-exports), in our list of targets. The distribution CMake exports
+# targets just install the CMake exports file for the distribution's targets,
+# whereas the project CMake exports targets install the rest of the project's
+# CMake exports (which are needed in order to import the project from other
+# CMake_projects via find_package, and include the distribution's CMake exports
+# file to get the exported targets).
+set(LLVM_Development_DISTRIBUTION_COMPONENTS
+  # LLVM
+  cmake-exports
+  development-cmake-exports
+  llvm-headers
+  llvm-libraries
+  # Clang
+  clang-cmake-exports
+  clang-development-cmake-exports
+  clang-headers
+  clang-libraries
+CACHE STRING "")

diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 704278a0e93bf..5752f4277444e 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -1,3 +1,5 @@
+include(LLVMDistributionSupport)
+
 function(clang_tablegen)
   # Syntax:
   # clang_tablegen output-file 

[clang] 33930a0 - [clang] Pass option directly to command. NFC

2021-03-25 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2021-03-25T11:36:06-07:00
New Revision: 33930a0787f6007ba7ebf36384115bebb412e08a

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

LOG: [clang] Pass option directly to command. NFC

This code was written back when LLVM's minimum required CMake version
was 2.8.8, and I assume ExternalProject_Add_Step didn't take this option
at that point. It does now though, so we should just use the option.
Setting the _EP_* property is entirely equivalent (and is in fact how
these commands behave internally), but that also feels like an internal
implementation detail we shouldn't be relying on.

Reviewed By: beanz

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 6535f84edbb7..e4d5dd77c69a 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -864,9 +864,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
 set(CLANG_BOOTSTRAP_TARGETS check-llvm check-clang check-all)
   endif()
   foreach(target ${CLANG_BOOTSTRAP_TARGETS})
-# exclude from main target
-set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES 
_EP_${target}_EXCLUDE_FROM_MAIN On)
-
 # Install targets have side effects, so we always want to execute them.
 # "install" is reserved by CMake and can't be used as a step name for
 # ExternalProject_Add_Step, so we can match against "^install-" instead of
@@ -884,6 +881,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
   COMMENT "Performing ${target} for '${NEXT_CLANG_STAGE}'"
   DEPENDEES configure
   ALWAYS ${step_always}
+  EXCLUDE_FROM_MAIN ON
   USES_TERMINAL 1
 )
 



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


[clang] 0135bc9 - [clang] Always execute multi-stage install steps

2021-03-25 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2021-03-25T11:36:00-07:00
New Revision: 0135bc996d82ff68677820c421b4d666590e4f31

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

LOG: [clang] Always execute multi-stage install steps

We want installs to be executed even if binaries haven't changed, e.g.
so that we can install to multiple places. This is consistent with how
non-multi-stage install targets (e.g. the regular install-distribution
target) behave.

Reviewed By: phosek

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index aa38110b6d22..6535f84edbb7 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -867,10 +867,23 @@ if (CLANG_ENABLE_BOOTSTRAP)
 # exclude from main target
 set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES 
_EP_${target}_EXCLUDE_FROM_MAIN On)
 
+# Install targets have side effects, so we always want to execute them.
+# "install" is reserved by CMake and can't be used as a step name for
+# ExternalProject_Add_Step, so we can match against "^install-" instead of
+# "^install" to get a tighter match. CMake's installation scripts already
+# skip up-to-date files, so there's no behavior change if you install to 
the
+# same destination multiple times.
+if(target MATCHES "^install-")
+  set(step_always ON)
+else()
+  set(step_always OFF)
+endif()
+
 ExternalProject_Add_Step(${NEXT_CLANG_STAGE} ${target}
   COMMAND ${CMAKE_COMMAND} --build  --target ${target}
   COMMENT "Performing ${target} for '${NEXT_CLANG_STAGE}'"
   DEPENDEES configure
+  ALWAYS ${step_always}
   USES_TERMINAL 1
 )
 



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


[clang] 9a2a167 - [DirectoryWatcher] Increase timeout to make test less flaky

2021-03-05 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2021-03-05T17:49:14-08:00
New Revision: 9a2a167b6ca7c35b60846592d7c11332c1f424e3

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

LOG: [DirectoryWatcher] Increase timeout to make test less flaky

We've observed this test being significantly flaky on our Mac CI
machines when we're running the full check-clang suite. It fails because
the wait_for condition isn't met within 3 seconds. We believe it's
because our CI machines are somewhat underpowered and pretty heavily
loaded when we're running the full check-clang suite.

I ran some experiments on increasing the timeout. I ran the full
check-clang suite 100 times with each timeout value and recorded how
many flaky failures we encountered in these tests. The results are:

3 second timeout (baseline): 20 failures
10 second timeout: 14 failures
20 second timeout: 4 failures
30 second timeout: 2 failures
40 second timeout: 1 failure
50 second timeout: 0 failures
60 second timeout: 0 failures

I ran another set of 100 tests for the 50 second timeout and observed
one flaky failure. By contrast, I ended up running check-clang 500 times
for the 60 second timeout and didn't observe a single flaky failure.
That's how the 60 second timeout value used in this patch was derived.

While a 60 second timeout might seem high, keep in mind that:
- This is a timeout, not a sleep; the test should require much less time
  the vast majority of instances, especially on more powerful machines.
- The long timeout is most likely to occur when other tests are also
  running at the same time, so the latency of the timeout will also be
  masked by the latency of the other tests.

See https://reviews.llvm.org/D58418?id=200123#inline-554211 for where
this timeout was originally introduced and the possibility of raising it
if it wasn't enough was discussed.

Reviewed By: plotfi

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

Added: 


Modified: 
clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Removed: 




diff  --git a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp 
b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
index 650c0fc49764..f0dc55a47bff 100644
--- a/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
+++ b/clang/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp
@@ -34,6 +34,17 @@ namespace {
 
 typedef DirectoryWatcher::Event::EventKind EventKind;
 
+// We've observed this test being significantly flaky when running on a heavily
+// loaded machine (e.g. when it's being run as part of the full check-clang
+// suite). Set a high timeout value to avoid this flakiness. The 60s timeout
+// value was determined empirically. It's a timeout value, not a sleep value,
+// and the test should require much less time in practice the vast majority of
+// instances. The cases where we do come close to (or still end up hitting) the
+// longer timeout are most likely to occur when other tests are also running at
+// the same time (e.g. as part of the full check-clang suite), in which case 
the
+// latency of the timeout will be masked by the latency of the other tests.
+constexpr std::chrono::seconds EventualResultTimeout(60);
+
 struct DirectoryWatcherTestFixture {
   std::string TestRootDir;
   std::string TestWatchedDir;
@@ -243,7 +254,7 @@ void checkEventualResultWithTimeout(VerifyingConsumer 
) {
   std::thread worker(std::move(task));
   worker.detach();
 
-  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(std::chrono::seconds(3)) ==
+  EXPECT_TRUE(WaitForExpectedStateResult.wait_for(EventualResultTimeout) ==
   std::future_status::ready)
   << "The expected result state wasn't reached before the time-out.";
   std::unique_lock L(TestConsumer.Mtx);



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


[clang] 4dbb3f5 - [clang] Add llvm-strip to test dependencies

2021-01-09 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2021-01-09T11:57:27-08:00
New Revision: 4dbb3f57c6fe581ef525dbe49a401f4bab834eff

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

LOG: [clang] Add llvm-strip to test dependencies

CodeGen/thinlto_embed_bitcode.ll relies on it.

Added: 


Modified: 
clang/test/CMakeLists.txt

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index a913b35ed567..562a14826033 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -122,6 +122,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-profdata
 llvm-readelf
 llvm-readobj
+llvm-strip
 llvm-symbolizer
 opt
 split-file



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


[clang-tools-extra] 6bd01b8 - [clangd] Account for vendor in version string

2020-11-02 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2020-11-02T09:04:44-08:00
New Revision: 6bd01b8184de93979756331c71af69b422f71103

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

LOG: [clangd] Account for vendor in version string

The vendor will be prefixed to the "clangd" and can be an arbitrary
string, so account for it in the test.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/test/log.test

Removed: 




diff  --git a/clang-tools-extra/clangd/test/log.test 
b/clang-tools-extra/clangd/test/log.test
index 68d6d29c6120..5d60c10eb917 100644
--- a/clang-tools-extra/clangd/test/log.test
+++ b/clang-tools-extra/clangd/test/log.test
@@ -1,5 +1,5 @@
 # RUN: env CLANGD_FLAGS=-index-file=no-such-index not clangd -lit-test 
&1 >/dev/null | FileCheck %s
-CHECK: I[{{.*}}] clangd version {{.*}}
+CHECK: I[{{.*}}]{{.*}} clangd version {{.*}}
 CHECK: Working directory: {{.*}}
 CHECK: argv[0]: clangd
 CHECK: argv[1]: -lit-test



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


[clang] 4e4ab8e - [clang] Limit scope of CLANG_VENDOR definition

2020-11-02 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2020-11-02T09:04:43-08:00
New Revision: 4e4ab8e0152b42baef5e5a1e2484d865e1a57e90

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

LOG: [clang] Limit scope of CLANG_VENDOR definition

It's only used by Version.cpp, so limit the definition to just that one
file instead of making all of Clang recompile if you change CLANG_VENDOR.

Reviewed By: phosek

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

Added: 


Modified: 
clang/CMakeLists.txt
clang/lib/Basic/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index a2b99e2e37e9..8c539e80946d 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -332,10 +332,6 @@ set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ 
Default Arch")
 set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
   "Vendor-specific text for showing with version information.")
 
-if( CLANG_VENDOR )
-  add_definitions( -DCLANG_VENDOR="${CLANG_VENDOR} " )
-endif()
-
 set(CLANG_REPOSITORY_STRING "" CACHE STRING
   "Vendor-specific text for showing the repository the source is taken from.")
 

diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index d259b951f2c2..0ca4148801fc 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -33,6 +33,11 @@ set_source_files_properties("${version_inc}"
   PROPERTIES GENERATED TRUE
  HEADER_FILE_ONLY TRUE)
 
+if(CLANG_VENDOR)
+  set_source_files_properties(Version.cpp
+PROPERTIES COMPILE_DEFINITIONS "CLANG_VENDOR=\"${CLANG_VENDOR} \"")
+endif()
+
 add_clang_library(clangBasic
   Attributes.cpp
   Builtins.cpp



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


[clang] 0c9230d - Reland [libclang] Install both libclang.a and libclang.so when LIBCLANG_BUILD_STATIC=ON

2020-05-06 Thread Shoaib Meenai via cfe-commits

Author: Han Zhu
Date: 2020-05-06T19:33:58-07:00
New Revision: 0c9230dad1692bc3d8f1ce2dddae413a115f2532

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

LOG: Reland [libclang] Install both libclang.a and libclang.so when 
LIBCLANG_BUILD_STATIC=ON

f8990feb125a enabled installing PIC version of both libclang.a and
libclang.so when LIBCLANG_BUILD_STATIC is ON. But it broke the no-PIC
build when LLVM_ENABLE_PIC=OFF with the following error:

```
CMake Error at
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/tools/libclang/CMakeLists.txt:123
(target_compile_definitions):
target_compile_definitions called with non-compilable target type
```

This is because as the code loops through ${name} and ${name}_static, it
introduced a side effect, which is adding an empty libclang_static to
targets. Later target_compile_definitions is called on libclang_static.
That function requires that target must have been created by a command
such as add_executable() or add_library(), so it crashed.

The solution is to not naively loop through both libclang and
libclang_static, but only the ones that are actually added by
llvm_add_library(). Here's the library build type to library target name
mapping:

| SHARED only | libclang |
| STATIC only | libclang |
| SHARED and STATIC | libclang and libclang_static |

So only when SHARED and STATIC are both set should we loop through two
targets. Explicitly parse the STATIC argument and set the list
accordingly.

Reviewed By: smeenai

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

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index c1bb386de6f7..704278a0e93b 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -45,7 +45,7 @@ endmacro()
 
 macro(add_clang_library name)
   cmake_parse_arguments(ARG
-"SHARED;INSTALL_WITH_TOOLCHAIN"
+"SHARED;STATIC;INSTALL_WITH_TOOLCHAIN"
 ""
 "ADDITIONAL_HEADERS"
 ${ARGN})
@@ -81,7 +81,10 @@ macro(add_clang_library name)
   ${ARG_ADDITIONAL_HEADERS} # It may contain unparsed unknown args.
   )
   endif()
-  if(ARG_SHARED)
+
+  if(ARG_SHARED AND ARG_STATIC)
+set(LIBTYPE SHARED STATIC)
+  elseif(ARG_SHARED)
 set(LIBTYPE SHARED)
   else()
 # llvm_add_library ignores BUILD_SHARED_LIBS if STATIC is explicitly set,
@@ -99,38 +102,45 @@ macro(add_clang_library name)
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
-  if(TARGET ${name})
-target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
-
-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
-  set(export_to_clangtargets)
-  if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
-  "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
-  NOT LLVM_DISTRIBUTION_COMPONENTS)
-set(export_to_clangtargets EXPORT ClangTargets)
-set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)
-  endif()
+  set(libs ${name})
+  if(ARG_SHARED AND ARG_STATIC)
+list(APPEND libs ${name}_static)
+  endif()
 
-  install(TARGETS ${name}
-COMPONENT ${name}
-${export_to_clangtargets}
-LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-RUNTIME DESTINATION bin)
-
-  if (NOT LLVM_ENABLE_IDE)
-add_llvm_install_targets(install-${name}
- DEPENDS ${name}
- COMPONENT ${name})
+  foreach(lib ${libs})
+if(TARGET ${lib})
+  target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
+
+  if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
+set(export_to_clangtargets)
+if(${lib} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+"clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+NOT LLVM_DISTRIBUTION_COMPONENTS)
+  set(export_to_clangtargets EXPORT ClangTargets)
+  set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)
+endif()
+
+install(TARGETS ${lib}
+  COMPONENT ${lib}
+  ${export_to_clangtargets}
+  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+  ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+  RUNTIME DESTINATION bin)
+
+if (NOT LLVM_ENABLE_IDE)
+  add_llvm_install_targets(install-${lib}
+   DEPENDS ${lib}
+   COMPONENT ${lib})
+endif()
+
+set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${lib})
   endif()
-
-  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
+  set_property(GLOBAL APPEND PROPERTY 

[clang] f8990fe - [libclang] Install both libclang.a and libclang.so when LIBCLANG_BUILD_STATIC=ON

2020-04-27 Thread Shoaib Meenai via cfe-commits

Author: Han Zhu
Date: 2020-04-27T13:37:07-07:00
New Revision: f8990feb125a0f8d3f2892a589bc6fad3c430858

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

LOG: [libclang] Install both libclang.a and libclang.so when 
LIBCLANG_BUILD_STATIC=ON

When LIBCLANG_BUILD_STATIC=ON and LLVM_ENABLE_PIC=ON, PIC version of
libclang.a and libclang.so are built as expected. However libclang.a is
not installed. Looking at the macro llvm_add_library(), when both SHARED
and STATIC are set, it renames the static library to ${name}_static and
then adds it to targets. But when add_clang_library() calls install, it
only checks if ${name} is in targets.

To work around this issue, loop through both ${name} and ${name}_static
and install both of them if they're in targets. This is still correct if
only shared or static library is built. In those cases, only ${name} is
added to targets and cmake install will generate the right install
script depending on the library's type.

Test Plan:
cmake with LIBCLANG_BUILD_STATIC=ON and then ninja install, from master
and this diff. Compare the result directory trees. Confirm that only
difference is the added libclang.a.

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

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index c1bb386de6f7..d68218eed073 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -99,38 +99,40 @@ macro(add_clang_library name)
   endif()
   llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
 
-  if(TARGET ${name})
-target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
-
-if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
-  set(export_to_clangtargets)
-  if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
-  "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
-  NOT LLVM_DISTRIBUTION_COMPONENTS)
-set(export_to_clangtargets EXPORT ClangTargets)
-set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)
+  foreach(lib ${name} ${name}_static)
+if(TARGET ${lib})
+  target_link_libraries(${lib} INTERFACE ${LLVM_COMMON_LIBS})
+
+  if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ARG_INSTALL_WITH_TOOLCHAIN)
+set(export_to_clangtargets)
+if(${lib} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+"clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+NOT LLVM_DISTRIBUTION_COMPONENTS)
+  set(export_to_clangtargets EXPORT ClangTargets)
+  set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)
+endif()
+
+install(TARGETS ${lib}
+  COMPONENT ${lib}
+  ${export_to_clangtargets}
+  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+  ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
+  RUNTIME DESTINATION bin)
+
+if (NOT LLVM_ENABLE_IDE)
+  add_llvm_install_targets(install-${lib}
+   DEPENDS ${lib}
+   COMPONENT ${lib})
+endif()
+
+set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${lib})
   endif()
-
-  install(TARGETS ${name}
-COMPONENT ${name}
-${export_to_clangtargets}
-LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-RUNTIME DESTINATION bin)
-
-  if (NOT LLVM_ENABLE_IDE)
-add_llvm_install_targets(install-${name}
- DEPENDS ${name}
- COMPONENT ${name})
-  endif()
-
-  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
+  set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${lib})
+else()
+  # Add empty "phony" target
+  add_custom_target(${lib})
 endif()
-set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
-  else()
-# Add empty "phony" target
-add_custom_target(${name})
-  endif()
+  endforeach()
 
   set_target_properties(${name} PROPERTIES FOLDER "Clang libraries")
   set_clang_windows_version_resource_properties(${name})



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


[clang] a299178 - [cmake] Fix -stripped for umbrella library install targets

2020-03-20 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2020-03-20T18:46:48-07:00
New Revision: a299178ae77a9d0c7d66f50d17483b7d18898ef0

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

LOG: [cmake] Fix -stripped for umbrella library install targets

Make the install-llvm-libraries-stripped and install-clang-libraries-stripped
targets depend on the individual library stripped install targets, so
that they actually install the libraries.

Added: 


Modified: 
clang/CMakeLists.txt
llvm/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index dc1413f4b597..db82d87b181f 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -588,6 +588,7 @@ if(CLANG_LIBS)
 add_dependencies(clang-libraries ${lib})
 if(NOT LLVM_ENABLE_IDE)
   add_dependencies(install-clang-libraries install-${lib})
+  add_dependencies(install-clang-libraries-stripped 
install-${lib}-stripped)
 endif()
   endforeach()
 endif()

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index a70178ee8bed..a4326377a0c3 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -1072,6 +1072,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   add_dependencies(llvm-libraries ${lib})
   if (NOT LLVM_ENABLE_IDE)
 add_dependencies(install-llvm-libraries install-${lib})
+add_dependencies(install-llvm-libraries-stripped 
install-${lib}-stripped)
   endif()
 endforeach()
   endif()



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


[clang] 14f8703 - [xray][clang] Always add xray-skip-entry/exit and xray-ignore-loops attrs

2020-02-11 Thread Shoaib Meenai via cfe-commits

Author: Ian Levesque
Date: 2020-02-11T14:00:41-08:00
New Revision: 14f870366a93ba0c6311883d900e24339681ba76

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

LOG: [xray][clang] Always add xray-skip-entry/exit and xray-ignore-loops attrs

The function attributes xray-skip-entry, xray-skip-exit, and
xray-ignore-loops were only being applied if a function had an
xray-instrument attribute, but they should apply if xray is enabled
globally too.

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

Added: 
clang/test/CodeGen/xray-attributes-skip-entry-exit.cpp
clang/test/Driver/XRay/xray-ignore-loops-flags.cpp

Modified: 
clang/include/clang/Driver/XRayArgs.h
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Driver/XRayArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/xray-ignore-loops.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/XRayArgs.h 
b/clang/include/clang/Driver/XRayArgs.h
index fa2583f4b966..96098bf629cd 100644
--- a/clang/include/clang/Driver/XRayArgs.h
+++ b/clang/include/clang/Driver/XRayArgs.h
@@ -30,6 +30,7 @@ class XRayArgs {
   bool XRayAlwaysEmitCustomEvents = false;
   bool XRayAlwaysEmitTypedEvents = false;
   bool XRayRT = true;
+  bool XRayIgnoreLoops = false;
 
 public:
   /// Parses the XRay arguments from an argument list.

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index af0adc213580..b7506b53030d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -814,23 +814,25 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   if (ShouldXRayInstrumentFunction())
 Fn->addFnAttr("xray-log-args",
   llvm::utostr(LogArgs->getArgumentCount()));
-if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-XRayInstrKind::FunctionExit)) {
-  Fn->addFnAttr("xray-skip-exit");
-}
-if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
-XRayInstrKind::FunctionEntry)) {
-  Fn->addFnAttr("xray-skip-entry");
-}
   }
 } else {
   if (ShouldXRayInstrumentFunction() && !CGM.imbueXRayAttrs(Fn, Loc))
 Fn->addFnAttr(
 "xray-instruction-threshold",
 llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
-  if (CGM.getCodeGenOpts().XRayIgnoreLoops) {
+}
+
+if (ShouldXRayInstrumentFunction()) {
+  if (CGM.getCodeGenOpts().XRayIgnoreLoops)
 Fn->addFnAttr("xray-ignore-loops");
-  }
+
+  if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+  XRayInstrKind::FunctionExit))
+Fn->addFnAttr("xray-skip-exit");
+
+  if (!CGM.getCodeGenOpts().XRayInstrumentationBundle.has(
+  XRayInstrKind::FunctionEntry))
+Fn->addFnAttr("xray-skip-entry");
 }
 
 unsigned Count, Offset;

diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 66c3959648ac..54c15685d389 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -101,6 +101,10 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList 
) {
 options::OPT_fnoxray_link_deps, true))
 XRayRT = false;
 
+  if (Args.hasFlag(options::OPT_fxray_ignore_loops,
+   options::OPT_fno_xray_ignore_loops, false))
+XRayIgnoreLoops = true;
+
   auto Bundles =
   Args.getAllArgValues(options::OPT_fxray_instrumentation_bundle);
   if (Bundles.empty())
@@ -197,6 +201,9 @@ void XRayArgs::addArgs(const ToolChain , const ArgList 
,
   if (XRayAlwaysEmitTypedEvents)
 CmdArgs.push_back("-fxray-always-emit-typedevents");
 
+  if (XRayIgnoreLoops)
+CmdArgs.push_back("-fxray-ignore-loops");
+
   CmdArgs.push_back(Args.MakeArgString(Twine(XRayInstructionThresholdOption) +
Twine(InstructionThreshold)));
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index e57c7ef55bb5..ae39066edd4c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1099,8 +1099,7 @@ static bool ParseCodeGenArgs(CodeGenOptions , 
ArgList , InputKind IK,
   Args.hasArg(OPT_fxray_always_emit_typedevents);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
-  Opts.XRayIgnoreLoops =
-  Args.hasArg(OPT_fxray_ignore_loops, OPT_fno_xray_ignore_loops, false);
+  Opts.XRayIgnoreLoops = Args.hasArg(OPT_fxray_ignore_loops);
 
   auto XRayInstrBundles =
   Args.getAllArgValues(OPT_fxray_instrumentation_bundle);

diff  --git a/clang/test/CodeGen/xray-attributes-skip-entry-exit.cpp 

Re: [clang] 0130b6c - Don't assume a reference refers to at least sizeof(T) bytes.

2020-01-31 Thread Shoaib Meenai via cfe-commits
Should this be cherry-picked to 10.0?

On 1/31/20, 7:09 PM, "cfe-commits on behalf of Richard Smith via cfe-commits" 
 
wrote:


Author: Richard Smith
Date: 2020-01-31T19:08:17-08:00
New Revision: 0130b6cb5a8d94511e2bb09ac2f5a613a59f70b4

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

LOG: Don't assume a reference refers to at least sizeof(T) bytes.

When T is a class type, only nvsize(T) bytes need be accessible through
the reference. We had matching bugs in the application of the
dereferenceable attribute and in -fsanitize=undefined.

Added: 


Modified: 
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/DeclCXX.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGenCXX/catch-undef-behavior.cpp
clang/test/CodeGenCXX/thunks.cpp

Removed: 





diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 2e8e31dbf4c7..6d3a833b5037 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1696,6 +1696,10 @@ class CXXRecordDecl : public RecordDecl {
   /// actually abstract.
   bool mayBeAbstract() const;
 
+  /// Determine whether it's impossible for a class to be derived from this
+  /// class. This is best-effort, and may conservatively return false.
+  bool isEffectivelyFinal() const;
+
   /// If this is the closure type of a lambda expression, retrieve the
   /// number to be used for name mangling in the Itanium C++ ABI.
   ///

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 227fe80ccab4..931a1141b1b4 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -1923,6 +1923,18 @@ bool CXXRecordDecl::mayBeAbstract() const {
   return false;
 }
 
+bool CXXRecordDecl::isEffectivelyFinal() const {
+  auto *Def = getDefinition();
+  if (!Def)
+return false;
+  if (Def->hasAttr())
+return true;
+  if (const auto *Dtor = Def->getDestructor())
+if (Dtor->hasAttr())
+  return true;
+  return false;
+}
+
 void CXXDeductionGuideDecl::anchor() {}
 
 bool ExplicitSpecifier::isEquivalent(const ExplicitSpecifier Other) const {
@@ -2142,12 +2154,8 @@ CXXMethodDecl 
*CXXMethodDecl::getDevirtualizedMethod(const Expr *Base,
   // Similarly, if the class itself or its destructor is marked 'final',
   // the class can't be derived from and we can therefore devirtualize the 
   // member function call.
-  if (BestDynamicDecl->hasAttr())
+  if (BestDynamicDecl->isEffectivelyFinal())
 return DevirtualizedMethod;
-  if (const auto *dtor = BestDynamicDecl->getDestructor()) {
-if (dtor->hasAttr())
-  return DevirtualizedMethod;
-  }
 
   if (const auto *DRE = dyn_cast(Base)) {
 if (const auto *VD = dyn_cast(DRE->getDecl()))

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 3f132a0a62aa..9ed2ccd54487 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2054,8 +2054,8 @@ void CodeGenModule::ConstructAttributeList(
   if (const auto *RefTy = RetTy->getAs()) {
 QualType PTy = RefTy->getPointeeType();
 if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
-  RetAttrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
-.getQuantity());
+  RetAttrs.addDereferenceableAttr(
+  getMinimumObjectSize(PTy).getQuantity());
 else if (getContext().getTargetAddressSpace(PTy) == 0 &&
  !CodeGenOpts.NullPointerIsValid)
   RetAttrs.addAttribute(llvm::Attribute::NonNull);
@@ -2164,8 +2164,8 @@ void CodeGenModule::ConstructAttributeList(
 if (const auto *RefTy = ParamType->getAs()) {
   QualType PTy = RefTy->getPointeeType();
   if (!PTy->isIncompleteType() && PTy->isConstantSizeType())
-Attrs.addDereferenceableAttr(getContext().getTypeSizeInChars(PTy)
-   .getQuantity());
+Attrs.addDereferenceableAttr(
+getMinimumObjectSize(PTy).getQuantity());
   else if (getContext().getTargetAddressSpace(PTy) == 0 &&
!CodeGenOpts.NullPointerIsValid)
 Attrs.addAttribute(llvm::Attribute::NonNull);

diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 

[clang-tools-extra] c72a6ac - Revert "[clang-tidy] readability-identifier-naming disregards parameters restrictions on main like functions"

2020-01-27 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2020-01-27T11:50:25-08:00
New Revision: c72a6ac4b630d2344dbea44a7d75fa61795dcd76

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

LOG: Revert "[clang-tidy] readability-identifier-naming disregards parameters 
restrictions on main like functions"

This reverts commit 27e3671ff49b72640f89c34a415412e400503442.

This was an accidental push, and the author requested a revert on IRC as
their local branch is in a bad state.

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-member-decl-usage.cpp

Removed: 

clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-main-like.cpp



diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 119502e91ffe..6a39ece09777 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -8,13 +8,15 @@
 
 #include "IdentifierNamingCheck.h"
 
+#include "../utils/ASTUtils.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/Frontend/CompilerInstance.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Lex/Preprocessor.h"
 #include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Format.h"
-#include "llvm/Support/Regex.h"
 
 #define DEBUG_TYPE "clang-tidy"
 
@@ -124,9 +126,7 @@ class IdentifierNamingCheckPPCallbacks : public PPCallbacks 
{
 
 IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name,
  ClangTidyContext *Context)
-: RenamerClangTidyCheck(Name, Context),
-  IgnoreFailedSplit(Options.get("IgnoreFailedSplit", 0)),
-  IgnoreMainLikeFunctions(Options.get("IgnoreMainLikeFunctions", 0)) {
+: RenamerClangTidyCheck(Name, Context) {
   auto const fromString = [](StringRef Str) {
 return llvm::StringSwitch>(Str)
 .Case("aNy_CasE", CT_AnyCase)
@@ -151,6 +151,8 @@ IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name,
   NamingStyles.push_back(llvm::None);
 }
   }
+
+  IgnoreFailedSplit = Options.get("IgnoreFailedSplit", 0);
 }
 
 IdentifierNamingCheck::~IdentifierNamingCheck() = default;
@@ -191,7 +193,6 @@ void 
IdentifierNamingCheck::storeOptions(ClangTidyOptions::OptionMap ) {
   }
 
   Options.store(Opts, "IgnoreFailedSplit", IgnoreFailedSplit);
-  Options.store(Opts, "IgnoreMainLikeFunctions", IgnoreMainLikeFunctions);
 }
 
 static bool matchesStyle(StringRef Name,
@@ -323,67 +324,6 @@ static std::string fixupWithCase(StringRef Name,
   return Fixup;
 }
 
-static bool isParamInMainLikeFunction(const ParmVarDecl ,
-  bool IncludeMainLike) {
-  const auto *FDecl =
-  dyn_cast_or_null(ParmDecl.getParentFunctionOrMethod());
-  if (!FDecl)
-return false;
-  if (FDecl->isMain())
-return true;
-  if (!IncludeMainLike)
-return false;
-  if (FDecl->getAccess() != AS_public && FDecl->getAccess() != AS_none)
-return false;
-  enum MainType { None, Main, WMain };
-  auto IsCharPtrPtr = [](QualType QType) -> MainType {
-if (QType.isNull())
-  return None;
-if (QType = QType->getPointeeType(), QType.isNull())
-  return None;
-if (QType = QType->getPointeeType(), QType.isNull())
-  return None;
-if (QType->isCharType())
-  return Main;
-if (QType->isWideCharType())
-  return WMain;
-return None;
-  };
-  auto IsIntType = [](QualType QType) {
-if (QType.isNull())
-  return false;
-if (const auto *Builtin =
-dyn_cast(QType->getUnqualifiedDesugaredType())) {
-  return Builtin->getKind() == BuiltinType::Int;
-}
-return false;
-  };
-  if (!IsIntType(FDecl->getReturnType()))
-return false;
-  if (FDecl->getNumParams() < 2 || FDecl->getNumParams() > 3)
-return false;
-  if (!IsIntType(FDecl->parameters()[0]->getType()))
-return false;
-  MainType Type = IsCharPtrPtr(FDecl->parameters()[1]->getType());
-  if (Type == None)
-return false;
-  if (FDecl->getNumParams() == 3 &&
-  IsCharPtrPtr(FDecl->parameters()[2]->getType()) != Type)
-return false;
-
-  if (Type == Main) {
-static llvm::Regex Matcher(
-"(^[Mm]ain([_A-Z]|$))|([a-z0-9_]Main([_A-Z]|$))|(_main(_|$))");
-assert(Matcher.isValid() && "Invalid Matcher for 

[clang] 1d62be2 - [clang][xray] Add -fxray-ignore-loops option

2020-01-17 Thread Shoaib Meenai via cfe-commits

Author: Ian Levesque
Date: 2020-01-17T13:32:24-08:00
New Revision: 1d62be244108547558c6d42ddcf2e4a7f3c6dd03

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

LOG: [clang][xray] Add -fxray-ignore-loops option

XRay allows tuning by minimum function size, but also always instruments
functions with loops in them. If the minimum function size is set to a
large value the loop instrumention ends up causing most functions to be
instrumented anyway. This adds a new flag, -fxray-ignore-loops, to disable
the loop detection logic.

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

Added: 
clang/test/CodeGen/xray-ignore-loops.cpp

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 50fc1836282f..9f4f83635673 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -106,6 +106,10 @@ CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 ///< Set when -fxray-always-emit-typedevents is enabled.
 CODEGENOPT(XRayAlwaysEmitTypedEvents , 1, 0)
 
+///< Set when -fxray-ignore-loops is enabled.
+CODEGENOPT(XRayIgnoreLoops , 1, 0)
+
+
 ///< Set the minimum number of instructions in a function to determine 
selective
 ///< XRay instrumentation.
 VALUE_CODEGENOPT(XRayInstructionThreshold , 32, 200)

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index abfa767afea8..ad829efe43da 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1292,6 +1292,13 @@ def fxray_always_emit_typedevents : Flag<["-"], 
"fxray-always-emit-typedevents">
 def fnoxray_always_emit_typedevents : Flag<["-"], 
"fno-xray-always-emit-typedevents">, Group,
   Flags<[CC1Option]>;
 
+def fxray_ignore_loops : Flag<["-"], "fxray-ignore-loops">, Group,
+  Flags<[CC1Option]>,
+  HelpText<"Don't instrument functions with loops unless they also meet the 
minimum function size">;
+def fno_xray_ignore_loops : Flag<["-"], "fno-xray-ignore-loops">, 
Group,
+  Flags<[CC1Option]>;
+
+
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,
   HelpText<"Tells clang to add the link dependencies for XRay.">;

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 2bf94f697e01..75f5c0e545d1 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -818,6 +818,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
 Fn->addFnAttr(
 "xray-instruction-threshold",
 llvm::itostr(CGM.getCodeGenOpts().XRayInstructionThreshold));
+  if (CGM.getCodeGenOpts().XRayIgnoreLoops) {
+Fn->addFnAttr("xray-ignore-loops");
+  }
 }
 
 if (const auto *Attr = D->getAttr()) {

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index e1e59565083b..3671e084b1ca 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1091,6 +1091,8 @@ static bool ParseCodeGenArgs(CodeGenOptions , 
ArgList , InputKind IK,
   Args.hasArg(OPT_fxray_always_emit_typedevents);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
+  Opts.XRayIgnoreLoops =
+  Args.hasArg(OPT_fxray_ignore_loops, OPT_fno_xray_ignore_loops, false);
 
   auto XRayInstrBundles =
   Args.getAllArgValues(OPT_fxray_instrumentation_bundle);

diff  --git a/clang/test/CodeGen/xray-ignore-loops.cpp 
b/clang/test/CodeGen/xray-ignore-loops.cpp
new file mode 100644
index ..17ea2afbeece
--- /dev/null
+++ b/clang/test/CodeGen/xray-ignore-loops.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fxray-instrument -fxray-ignore-loops -x c++ -std=c++11 
-emit-llvm -o - %s -triple x86_64-unknown-linux-gnu | FileCheck %s
+
+int foo() {
+  return 1;
+}
+
+// CHECK: define i32 @_Z3foov() #[[ATTRS:[0-9]+]] {
+// CHECK-DAG: attributes #[[ATTRS]] = {{.*}} "xray-ignore-loops" {{.*}}



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


[clang] 2c59c4f - [perf-training] Make training data location configurable

2019-12-14 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2019-12-14T09:46:41-08:00
New Revision: 2c59c4ffb9c111f8d87a65839697d03fc485c51c

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

LOG: [perf-training] Make training data location configurable

We may wish to keep the PGO training data outside the repository. Add a
CMake variable to allow referencing an external lit testsuite.

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

Added: 


Modified: 
clang/utils/perf-training/CMakeLists.txt
clang/utils/perf-training/lit.cfg
clang/utils/perf-training/lit.site.cfg.in
clang/utils/perf-training/order-files.lit.cfg
clang/utils/perf-training/order-files.lit.site.cfg.in

Removed: 




diff  --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index 39f9a4ca3c13..25bb7f49a5ef 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -10,6 +10,10 @@ endif ()
 
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} CLANG_TOOLS_DIR 
${LLVM_RUNTIME_OUTPUT_INTDIR})
 
+set(CLANG_PGO_TRAINING_DATA "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH
+  "The path to a lit testsuite containing samples for PGO and order file 
generation"
+  )
+
 if(LLVM_BUILD_INSTRUMENTED)
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in

diff  --git a/clang/utils/perf-training/lit.cfg 
b/clang/utils/perf-training/lit.cfg
index 671d44f83b94..67a42345da46 100644
--- a/clang/utils/perf-training/lit.cfg
+++ b/clang/utils/perf-training/lit.cfg
@@ -27,7 +27,7 @@ config.clang = lit.util.which('clang', 
config.clang_tools_dir).replace('\\', '/'
 config.name = 'Clang Perf Training'
 config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', 
'.modulemap']
 
-cc1_wrapper = '%s %s/perf-helper.py cc1' % (config.python_exe, 
config.test_source_root)
+cc1_wrapper = '%s %s/perf-helper.py cc1' % (config.python_exe, 
config.perf_helper_dir)
 
 use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
 config.test_format = lit.formats.ShTest(use_lit_shell == "0")

diff  --git a/clang/utils/perf-training/lit.site.cfg.in 
b/clang/utils/perf-training/lit.site.cfg.in
index 66683bcd5286..340a0e909b10 100644
--- a/clang/utils/perf-training/lit.site.cfg.in
+++ b/clang/utils/perf-training/lit.site.cfg.in
@@ -3,8 +3,9 @@
 import sys
 
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@"
 config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
-config.test_source_root = "@CMAKE_CURRENT_SOURCE_DIR@"
+config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_exe = "@PYTHON_EXECUTABLE@"
 

diff  --git a/clang/utils/perf-training/order-files.lit.cfg 
b/clang/utils/perf-training/order-files.lit.cfg
index 93904ec84a41..03c605c01c56 100644
--- a/clang/utils/perf-training/order-files.lit.cfg
+++ b/clang/utils/perf-training/order-files.lit.cfg
@@ -28,8 +28,8 @@ config.clang = os.path.realpath(lit.util.which('clang', 
config.clang_tools_dir))
 config.name = 'Clang Perf Training'
 config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', 
'.modulemap']
 
-dtrace_wrapper = '%s %s/perf-helper.py dtrace' % (config.python_exe, 
config.test_source_root)
-dtrace_wrapper_cc1 = '%s %s/perf-helper.py dtrace --cc1' % (config.python_exe, 
config.test_source_root)
+dtrace_wrapper = '%s %s/perf-helper.py dtrace' % (config.python_exe, 
config.perf_helper_dir)
+dtrace_wrapper_cc1 = '%s %s/perf-helper.py dtrace --cc1' % (config.python_exe, 
config.perf_helper_dir)
 
 if 'darwin' in config.target_triple:
 lit_config.note('using DTrace oneshot probe')

diff  --git a/clang/utils/perf-training/order-files.lit.site.cfg.in 
b/clang/utils/perf-training/order-files.lit.site.cfg.in
index 0490a217ad04..87406dbaf9a6 100644
--- a/clang/utils/perf-training/order-files.lit.site.cfg.in
+++ b/clang/utils/perf-training/order-files.lit.site.cfg.in
@@ -3,8 +3,9 @@
 import sys
 
 config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.perf_helper_dir = "@CMAKE_CURRENT_SOURCE_DIR@"
 config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
-config.test_source_root = "@CMAKE_CURRENT_SOURCE_DIR@"
+config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_exe = "@PYTHON_EXECUTABLE@"
 



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


[clang] 61c8ee6 - [clang] Move CLANG_BOOTSTRAP_CMAKE_ARGS above PASSTHROUGH_VARIABLES

2019-12-13 Thread Shoaib Meenai via cfe-commits

Author: Xin-Xin Wang
Date: 2019-12-13T19:05:04-08:00
New Revision: 61c8ee6a2fa490bc224d006cd03efd650f6561bb

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

LOG: [clang] Move CLANG_BOOTSTRAP_CMAKE_ARGS above PASSTHROUGH_VARIABLES

I want to pass some CMake cache files in CLANG_BOOTSTRAP_CMAKE_ARGS as
`-C .cmake` arguments. I want to be able to use the values
of the bootstrap passthrough variables in the cache files, so the cache
file arguments need to be after passthrough variables. This should be
safe because the values of passthrough variables are all constants and
can't refer to values in CLANG_BOOTSTRAP_CMAKE_ARGS.

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 45d2431a7462..bc172b468512 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -801,8 +801,8 @@ if (CLANG_ENABLE_BOOTSTRAP)
 # We shouldn't need to set this here, but INSTALL_DIR doesn't
 # seem to work, so instead I'm passing this through
 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-${CLANG_BOOTSTRAP_CMAKE_ARGS}
 ${PASSTHROUGH_VARIABLES}
+${CLANG_BOOTSTRAP_CMAKE_ARGS}
  -DCLANG_STAGE=${NEXT_CLANG_STAGE}
 ${COMPILER_OPTIONS}
 ${${CLANG_STAGE}_CONFIG}



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


Re: r367979 - [clang][DirectoryWatcher] Adding llvm::Expected error handling to create.

2019-08-06 Thread Shoaib Meenai via cfe-commits
You missed a semicolon after an assert, which broke asserts Mac builds. I fixed 
it in r367984.

From: cfe-commits  on behalf of Puyan Lotfi 
via cfe-commits 
Reply-To: Puyan Lotfi 
Date: Monday, August 5, 2019 at 10:11 PM
To: "cfe-commits@lists.llvm.org" 
Subject: r367979 - [clang][DirectoryWatcher] Adding llvm::Expected error 
handling to create.

Author: zer0
Date: Mon Aug  5 22:12:23 2019
New Revision: 367979

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D367979-26view-3Drev=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=6k2w1Mw8wKFqzKnFgq4r1I7Zmx7B-N-JdVMvtHYpjJs=GdHgTwHdRXipmG75D6eyJGuUUbCL0EMIl0YPYAY0y2U=
Log:
[clang][DirectoryWatcher] Adding llvm::Expected error handling to create.

Prior to this patch Unix style errno error reporting from the inotify layer was
used by DirectoryWatcher::create to simply return a nullptr on error. This
would generally be ok, except that in LLVM we have much more robust error
reporting through the facilities of llvm::Expected.

The other critical thing I stumbled across was that the unit tests for
DirectoryWatcher were not failing abruptly when inotify_init() was reporting an
error, but would continue with the testing and eventually hit a deadlock in a
pathological machine state (ie in the unit test, the return nullptr on ::create
was ignored).

Generally this pathological state never happens on any build bot, so it is
totally understandable that it was overlooked, but on a Linux desktop running
a dubious desktop environment (which I will not name) there is a chance that
said desktop environment could use up enough inotify instances to exceed the
user's limit. These are the conditions that led me to hit the deadlock I am
addressing in this patch with more robust error handling.

With the new llvm::Expected error handling when your system runs out of inotify
instances for your user, the unit test will be forced to handle the error or
crash and report the issue to the user instead of weirdly deadlocking on a
condition variable wait.

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D65704=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=6k2w1Mw8wKFqzKnFgq4r1I7Zmx7B-N-JdVMvtHYpjJs=vGtUV_-i1W7ejLSH8cWFnYlusAJMA8EK5kMTvuMmQB4=


Modified:
cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h
cfe/trunk/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp
cfe/trunk/lib/DirectoryWatcher/linux/DirectoryWatcher-linux.cpp
cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
cfe/trunk/unittests/DirectoryWatcher/DirectoryWatcherTest.cpp

Modified: cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_include_clang_DirectoryWatcher_DirectoryWatcher.h-3Frev-3D367979-26r1-3D367978-26r2-3D367979-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=6k2w1Mw8wKFqzKnFgq4r1I7Zmx7B-N-JdVMvtHYpjJs=VCfJ3mXkHYvO_8Iw35iGLiTPxX-OaQIrX9fUY22ukbw=
==
--- cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h (original)
+++ cfe/trunk/include/clang/DirectoryWatcher/DirectoryWatcher.h Mon Aug  5 
22:12:23 2019
@@ -11,6 +11,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
#include 
#include 
#include 
@@ -98,10 +99,11 @@ public:
 : Kind(Kind), Filename(Filename) {}
   };
-  /// Returns nullptr if \param Path doesn't exist or isn't a directory.
-  /// Returns nullptr if OS kernel API told us we can't start watching. In such
-  /// case it's unclear whether just retrying has any chance to succeeed.
-  static std::unique_ptr
+  /// Asserts if \param Path doesn't exist or isn't a directory.
+  /// Returns llvm::Expected Error if OS kernel API told us we can't start
+  /// watching. In such case it's unclear whether just retrying has any chance
+  /// to succeeed.
+  static llvm::Expected>
   create(llvm::StringRef Path,
  std::function Events,
 bool IsInitial)>

Modified: 
cfe/trunk/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp
URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_cfe_trunk_lib_DirectoryWatcher_default_DirectoryWatcher-2Dnot-2Dimplemented.cpp-3Frev-3D367979-26r1-3D367978-26r2-3D367979-26view-3Ddiff=DwIGaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=6k2w1Mw8wKFqzKnFgq4r1I7Zmx7B-N-JdVMvtHYpjJs=kOGSMivkTUI-mqfkDLYmSGfQM8CSoTUydr4qZdtcaAc=
==
--- cfe/trunk/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp 
(original)
+++ cfe/trunk/lib/DirectoryWatcher/default/DirectoryWatcher-not-implemented.cpp 
Mon Aug  5 22:12:23 2019
@@ -11,9 +11,11 @@
using namespace llvm;
using namespace clang;
-std::unique_ptr 

r367984 - [DirectoryWatcher] Fix asserts Mac builds

2019-08-06 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Tue Aug  6 00:13:53 2019
New Revision: 367984

URL: http://llvm.org/viewvc/llvm-project?rev=367984=rev
Log:
[DirectoryWatcher] Fix asserts Mac builds

Add a missing semicolon after an assert. Remove the period from the
assert message while I'm here, because we don't usually have those.

Modified:
cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp

Modified: cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp?rev=367984=367983=367984=diff
==
--- cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp (original)
+++ cfe/trunk/lib/DirectoryWatcher/mac/DirectoryWatcher-mac.cpp Tue Aug  6 
00:13:53 2019
@@ -210,7 +210,7 @@ llvm::Expected Result =
   llvm::make_unique(EventStream, Receiver, Path);


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


r367982 - [Driver] Introduce -stdlib++-isystem

2019-08-06 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Aug  5 23:48:43 2019
New Revision: 367982

URL: http://llvm.org/viewvc/llvm-project?rev=367982=rev
Log:
[Driver] Introduce -stdlib++-isystem

There are times when we wish to explicitly control the C++ standard
library search paths used by the driver. For example, when we're
building against the Android NDK, we might want to use the NDK's C++
headers (which have a custom inline namespace) even if we have C++
headers installed next to the driver. We might also be building against
a non-standard directory layout and wanting to specify the C++ standard
library include directories explicitly.

We could accomplish this by passing -nostdinc++ and adding an explicit
-isystem for our custom search directories. However, users of our
toolchain may themselves want to use -nostdinc++ and a custom C++ search
path (libc++'s build does this, for example), and our added -isystem
won't respect the -nostdinc++, leading to multiple C++ header
directories on the search path, which causes build failures.

Add a new driver option -stdlib++-isystem to support this use case.
Passing this option suppresses adding the default C++ library include
paths in the driver, and it also respects -nostdinc++ to allow users to
still override the C++ library paths themselves.

It's a bit unfortunate that we end up with both -stdlib++-isystem and
-cxx-isystem, but their semantics differ significantly. -cxx-isystem is
unaffected by -nostdinc++ and is added to the end of the search path
(which is not appropriate for C++ standard library headers, since they
often #include_next into other system headers), while -stdlib++-isystem
respects -nostdinc++, is added to the beginning of the search path, and
suppresses the default C++ library include paths.

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

Added:
cfe/trunk/test/Driver/stdlibxx-isystem.cpp
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/ToolChain.h
cfe/trunk/lib/Driver/ToolChain.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=367982=367981=367982=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Aug  5 23:48:43 2019
@@ -2642,6 +2642,10 @@ def std_EQ : Joined<["-", "--"], "std=">
   }]>;
 def stdlib_EQ : Joined<["-", "--"], "stdlib=">, Flags<[CC1Option]>,
   HelpText<"C++ standard library to use">, Values<"libc++,libstdc++,platform">;
+def stdlibxx_isystem : JoinedOrSeparate<["-"], "stdlib++-isystem">,
+  Group,
+  HelpText<"Use directory as the C++ standard library include path">,
+  Flags<[DriverOption]>, MetaVarName<"">;
 def unwindlib_EQ : Joined<["-", "--"], "unwindlib=">, Flags<[CC1Option]>,
   HelpText<"Unwind library to use">, Values<"libgcc,unwindlib,platform">;
 def sub__library : JoinedOrSeparate<["-"], "sub_library">;

Modified: cfe/trunk/include/clang/Driver/ToolChain.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=367982=367981=367982=diff
==
--- cfe/trunk/include/clang/Driver/ToolChain.h (original)
+++ cfe/trunk/include/clang/Driver/ToolChain.h Mon Aug  5 23:48:43 2019
@@ -542,6 +542,11 @@ public:
   AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList ,
llvm::opt::ArgStringList ) const;
 
+  /// AddClangCXXStdlibIsystemArgs - Add the clang -cc1 level arguments to set
+  /// the specified include paths for the C++ standard library.
+  void AddClangCXXStdlibIsystemArgs(const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const;
+
   /// Returns if the C++ standard library should be linked in.
   /// Note that e.g. -lm should still be linked even if this returns false.
   bool ShouldLinkCXXStdlib(const llvm::opt::ArgList ) const;

Modified: cfe/trunk/lib/Driver/ToolChain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=367982=367981=367982=diff
==
--- cfe/trunk/lib/Driver/ToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Aug  5 23:48:43 2019
@@ -832,6 +832,16 @@ void ToolChain::AddClangCXXStdlibInclude
   DriverArgs.AddAllArgs(CC1Args, options::OPT_stdlib_EQ);
 }
 
+void ToolChain::AddClangCXXStdlibIsystemArgs(
+const llvm::opt::ArgList ,
+llvm::opt::ArgStringList ) const {
+  DriverArgs.ClaimAllArgs(options::OPT_stdlibxx_isystem);
+  if (!DriverArgs.hasArg(options::OPT_nostdincxx))
+for (const auto  :
+ DriverArgs.getAllArgValues(options::OPT_stdlibxx_isystem))
+  addSystemInclude(DriverArgs, CC1Args, P);
+}
+
 bool ToolChain::ShouldLinkCXXStdlib(const llvm::opt::ArgList ) const {

Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-16 Thread Shoaib Meenai via cfe-commits
to make the clang dylib in a way that it could always be 
enabled.

Do we know where the nested generator expression was coming from?

-Chris




On Jul 12, 2019, at 8:32 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

Oops, sorry about the breakage.

Chris, aren't BUILD_SHARED_LIBS and the combined Clang dylib incompatible? 
Should we disable building the latter if the former is set?

From: Alex Bradbury mailto:a...@lowrisc.org>>
Date: Friday, July 12, 2019 at 2:02 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

On Thu, 11 Jul 2019 at 22:20, Shoaib Meenai via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D365825-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=R9NSZG1XQDVSiE0wJUgb1kMUrG6bJkG3v5GDcTdkpAk=
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D64579=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=mutN2zF1KixMEVFjNzG_Q7iVJzG5ECbrU4tX3AKWLVQ=

This seems to break a -DBUILD_SHARED_LIBS build for me. It fails at
the point of linking lib/libclang_shared.so.9svn with errors like:
ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by Attributes.cpp:34 
(/home/asb/llvm-project/clang/lib/Basic/Attributes.cpp:34)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::attr::getSubjectMatchRuleSpelling(clang::attr::SubjectMatchRule))

ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by TargetCXXABI.h:168 
(/home/asb/llvm-project/clang/include/clang/Basic/TargetCXXABI.h:168)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::TargetCXXABI::isMicrosoft()
 const)

ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by TargetCXXABI.h:149 
(/home/asb/llvm-project/clang/include/clang/Basic/TargetCXXABI.h:149)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::TargetCXXABI::isItaniumFamily()
 const)

ld.lld: error: undefined symbol: llvm::EnableABIBreakingChecks
referenced by Attributes.cpp
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(llvm::VerifyEnableABIBreakingChecks)

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


Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-12 Thread Shoaib Meenai via cfe-commits
I struggled for a while thinking why PRIVATE might be useful in a 
target_link_libraries call for a shared library, and then I found 
https://cmake.org/pipermail/cmake/2016-May/063400.html. The relevant bit is:

If you were paying careful attention, you would have noticed that when A
links in B as PRIVATE, the include directories of B never propagate to
something linking to A, but if A is a static library, then the *linking* of
B behaves as though the relationship was PUBLIC. This
PRIVATE-becomes-PUBLIC behaviour for static libraries only applies to the
*linking*, not to the other dependencies (compiler options/flags and
include search paths).

So PRIVATE/INTERFACE/PUBLIC doesn’t make any difference as far as the actual 
linking goes, but it does affect propagation of other options, and I think it’s 
valid to want to have a PRIVATE dependency for a static library.

From:  on behalf of Chris Bieneman 
Date: Friday, July 12, 2019 at 9:08 AM
To: Shoaib Meenai 
Cc: Alex Bradbury , cfe-commits 
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

Ah! I see what is going on here. This is kinda a silliness of CMake. `PRIVATE` 
linkage for a static archive is silly, and shouldn't be possible. All link 
dependencies for static archives are really `INTERFACE` dependencies, and it 
looks like CMake is doing something kinda silly instead of producing a 
reasonable error or warning like it probably should do.

For context, `PRIVATE` linkage in the context of that change would mean 
DirectoryWalker links something, but things that link DirectoryWalker don't. 
That just isn't possible with static archives, so they become interface 
dependencies (and CMake seems to insert a generator expression to make that 
work).

In `llvm_add_library` we always use `PRIVATE` linkage for shared libraries, and 
`INTERFACE` for static, which does the right thing.

Unless there is a better reason than a new patch coming in, I think the right 
fix is to revert this back and expect the new patch to correct its linkage 
behavior.

-Chris


On Jul 12, 2019, at 8:53 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

See 
https://reviews.llvm.org/D58418#1577670<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D58418-231577670=DwMFAg=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=BaInVCyhXHMyre_oyIEnYhuQC5zsW6p65QBgZLR7ujc=7bhRDMtKEyVqFDlMWzo361mQT2N8lcOt-YDh-XGjZok=>.
 More generally it would appear for any static library with a PRIVATE 
dependency though.

I guess an alternative would be to use the LINK_LIBRARIES property (which 
should be free of generator expressions, I believe) to propagate dependencies 
instead of INTERFACE_LINK_LIBRARIES, and just assume that no one is gonna set 
an INTERFACE dependency on a static library. (Supporting PRIVATE dependencies 
on a static library definitely seems more valuable than supporting INTERFACE 
dependencies.)

From: mailto:cbiene...@apple.com>> on behalf of Chris 
Bieneman mailto:be...@apple.com>>
Date: Friday, July 12, 2019 at 8:49 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: Alex Bradbury mailto:a...@lowrisc.org>>, cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

One of the benefits of the object library approach for generating the clang 
dylib is that it was compatible with BUILD_SHARED_LIBS. We had lots of issues 
with libLLVM where people using BUILD_SHARED_LIBS would make changes that broke 
it, so I was trying to make the clang dylib in a way that it could always be 
enabled.

Do we know where the nested generator expression was coming from?

-Chris



On Jul 12, 2019, at 8:32 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

Oops, sorry about the breakage.

Chris, aren't BUILD_SHARED_LIBS and the combined Clang dylib incompatible? 
Should we disable building the latter if the former is set?

From: Alex Bradbury mailto:a...@lowrisc.org>>
Date: Friday, July 12, 2019 at 2:02 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

On Thu, 11 Jul 2019 at 22:20, Shoaib Meenai via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D365825-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=R9NSZG1XQDVSiE0wJUgb1kMUrG6bJkG3v5GDcTdkpAk=
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar

Re: [PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-12 Thread Shoaib Meenai via cfe-commits
Sorry about the breakage. I reverted it in r365922.

On 7/12/19, 9:12 AM, "Brian Rzycki via Phabricator"  
wrote:

brzycki added a comment.

Hello @smeenai , this commit causes LLVM to fail to build when set set `-D 
BUILD_SHARED_LIBS=ON`. Here is the failing CMake and Ninja invocation:

  /tools/build/cmake-3.14.5/bin/cmake \
  -G Ninja  \
  -D CMAKE_MAKE_PROGRAM=/tools/build/ninja-1.9.0/ninja \
  -D CMAKE_C_COMPILER=/usr/lib/llvm-7/bin/clang \
  -D CMAKE_CXX_COMPILER=/usr/lib/llvm-7/bin/clang++ \
  -D CMAKE_BUILD_TYPE=Release \
  -D CMAKE_INSTALL_PREFIX=/work/upstream/install \
  -D LLVM_TOOL_CLANG_BUILD=ON \
  -D LIBCXX_INCLUDE_BENCHMARKS=ON \
  -D BUILD_SHARED_LIBS=ON \
  -D LLVM_ENABLE_ASSERTIONS=ON \
  -D LLVM_TARGETS_TO_BUILD=X86 \
  /work/upstream/llvm-project/llvm
  
  /tools/build/ninja-1.9.0/ninja -v install

I am able to successfully build LLVM when I change to `-D 
BUILD_SHARED_LIBS=OFF`.

The outputted errors happen during link time of 
`lib/libclang_shared.so.9svn`:

  FAILED: lib/libclang_shared.so.9svn
  
  ...
  
  
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenModule.cpp.o: In 
function `llvm::cl::opt >::~opt()':
  
CodeGenModule.cpp:(.text._ZN4llvm2cl3optIbLb0ENS0_6parserIbEEED2Ev[_ZN4llvm2cl3optIbLb0ENS0_6parserIbEEED2Ev]+0x7):
 undefined reference to `vtable for llvm::cl::Option'
  
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenModule.cpp.o: In 
function `clang::CodeGen::CodeGenModule::CodeGenModule(clang::ASTContext&, 
clang::HeaderSearchOptions const&, clang::PreprocessorOptions const&, 
clang::CodeGenOptions const&, llvm::Module&, clang::DiagnosticsEngine&, 
clang::CoverageSourceInfo*)':
  
CodeGenModule.cpp:(.text._ZN5clang7CodeGen13CodeGenModuleC2ERNS_10ASTContextERKNS_19HeaderSearchOptionsERKNS_19PreprocessorOptionsERKNS_14CodeGenOptionsERN4llvm6ModuleERNS_17DiagnosticsEngineEPNS_18CoverageSourceInfoE+0x57a):
 undefined reference to `llvm::FoldingSetBase::FoldingSetBase(unsigned int)'
  
CodeGenModule.cpp:(.text._ZN5clang7CodeGen13CodeGenModuleC2ERNS_10ASTContextERKNS_19HeaderSearchOptionsERKNS_19PreprocessorOptionsERKNS_14CodeGenOptionsERN4llvm6ModuleERNS_17DiagnosticsEngineEPNS_18CoverageSourceInfoE+0x5cc):
 undefined reference to `llvm::Type::getVoidTy(llvm::LLVMContext&)'
  
CodeGenModule.cpp:(.text._ZN5clang7CodeGen13CodeGenModuleC2ERNS_10ASTContextERKNS_19HeaderSearchOptionsERKNS_19PreprocessorOptionsERKNS_14CodeGenOptionsERN4llvm6ModuleERNS_17DiagnosticsEngineEPNS_18CoverageSourceInfoE+0x5d7):
 undefined reference to `llvm::Type::getInt8Ty(llvm::LLVMContext&)'
  
CodeGenModule.cpp:(.text._ZN5clang7CodeGen13CodeGenModuleC2ERNS_10ASTContextERKNS_19HeaderSearchOptionsERKNS_19PreprocessorOptionsERKNS_14CodeGenOptionsERN4llvm6ModuleERNS_17DiagnosticsEngineEPNS_18CoverageSourceInfoE+0x5e3):
 undefined reference to `llvm::Type::getInt16Ty(llvm::LLVMContext&)'
  
  ... (clipped thousands of similar errors)
  
  
WhitespaceManager.cpp:(.text._ZN5clang6formatL18AlignTokenSequenceIRZNS0_17WhitespaceManager28alignConsecutiveDeclarationsEvE3$_2EEvjjjOT_RN4llvm11SmallVectorINS2_6ChangeELj16EEE+0x129):
 undefined reference to `llvm::SmallVectorBase::grow_pod(void*, unsigned long, 
unsigned long)'
  
tools/clang/tools/clang-fuzzer/handle-cxx/CMakeFiles/obj.clangHandleCXX.dir/handle_cxx.cpp.o:
 In function `clang_fuzzer::HandleCXX(std::__cxx11::basic_string, std::allocator > const&, std::vector > const&)':
  
handle_cxx.cpp:(.text._ZN12clang_fuzzer9HandleCXXERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIPKcSaISA_EE+0x67):
 undefined reference to `llvm::SmallVectorBase::grow_pod(void*, unsigned long, 
unsigned long)'
  
handle_cxx.cpp:(.text._ZN12clang_fuzzer9HandleCXXERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIPKcSaISA_EE+0x32b):
 undefined reference to `llvm::MemoryBuffer::getMemBuffer(llvm::StringRef, 
llvm::StringRef, bool)'
  
handle_cxx.cpp:(.text._ZN12clang_fuzzer9HandleCXXERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERKSt6vectorIPKcSaISA_EE+0x669):
 undefined reference to `llvm::SmallVectorBase::grow_pod(void*, unsigned long, 
unsigned long)'
  clang: error: linker command failed with exit code 1 (use -v to see 
invocation)


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D64579_new_=DwIFAg=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=cpyWE0YV319Dd3hlteUrLx-qVuVLtE5TuYEWHimU5pE=ewqtR4F272LGTH1CzQZcQALTX6_rJIABb5AgGqr2s4Q=
 


https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D64579=DwIFAg=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=cpyWE0YV319Dd3hlteUrLx-qVuVLtE5TuYEWHimU5pE=oL7blc7PIIj9vcaNL2TKUMdmqc1iN_6Tv0ddCFde7as=
 






r365922 - Revert [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-12 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Jul 12 10:23:35 2019
New Revision: 365922

URL: http://llvm.org/viewvc/llvm-project?rev=365922=rev
Log:
Revert [clang-shlib] Fix clang-shlib for PRIVATE dependencies

This reverts r365825 (git commit 3173c60f96c3ccfc17d403a192ae58e720153c23)

This is breaking BUILD_SHARED_LIBS=ON builds. Reverting while I rethink it.

Modified:
cfe/trunk/tools/clang-shlib/CMakeLists.txt

Modified: cfe/trunk/tools/clang-shlib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-shlib/CMakeLists.txt?rev=365922=365921=365922=diff
==
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt Fri Jul 12 10:23:35 2019
@@ -7,35 +7,8 @@ get_property(clang_libs GLOBAL PROPERTY
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  # Use the static library for its dependencies. The objects that constitute 
the
-  # static library will appear on the link line before the library, so it'll
-  # just be ignored, but the dependencies of the library will still be linked
-  # correctly.
-  #
-  # We could propagate the dependencies manually using the library's
-  # INTERFACE_LINK_LIBRARIES property, but that will contain $
-  # generator expressions if a static library has a private dependency, so we
-  # can't use a $ generator expression to get the property
-  # (since it wouldn't evaluate any generator expressions inside the property).
-  # We could use get_property and do string manipulation to manually evaluate
-  # the $, but that would miss any dependencies added after we
-  # evaluate the get_property. We could also use the LINK_LIBRARIES property
-  # instead, which should be free of any generator expressions, but that's
-  # technically incorrect (it'd most likely work fine in practice, but still).
-  #
-  # Another alternative would be to use --whole-archive or equivalent instead 
of
-  # using the object library at all. However, CMake reorders static libraries 
on
-  # the link line so that a library appears after all its dependents, which can
-  # reorder static libraries out of their --whole-archive --no-whole-archive
-  # sandwich. It's really hard to avoid that reordering while still propagating
-  # dependencies, which defeats the whole point.
-  #
-  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
-  # which adds support for dependencies on object libraries. Until then, 
linking
-  # both the object and the static libraries seems like the least bad solution.
-  #
-  # TODO: Rework this when we bump our minimum CMake version to 3.12 or newer.
-  list(APPEND _DEPS ${lib})
+  list(APPEND _DEPS $)
+  list(APPEND _DEPS $)
 endforeach ()
 
 if (CLANG_LINK_CLANG_DYLIB)


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


Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-12 Thread Shoaib Meenai via cfe-commits
Reverted in r365922.

From:  on behalf of Chris Bieneman 
Date: Friday, July 12, 2019 at 9:08 AM
To: Shoaib Meenai 
Cc: Alex Bradbury , cfe-commits 
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

Ah! I see what is going on here. This is kinda a silliness of CMake. `PRIVATE` 
linkage for a static archive is silly, and shouldn't be possible. All link 
dependencies for static archives are really `INTERFACE` dependencies, and it 
looks like CMake is doing something kinda silly instead of producing a 
reasonable error or warning like it probably should do.

For context, `PRIVATE` linkage in the context of that change would mean 
DirectoryWalker links something, but things that link DirectoryWalker don't. 
That just isn't possible with static archives, so they become interface 
dependencies (and CMake seems to insert a generator expression to make that 
work).

In `llvm_add_library` we always use `PRIVATE` linkage for shared libraries, and 
`INTERFACE` for static, which does the right thing.

Unless there is a better reason than a new patch coming in, I think the right 
fix is to revert this back and expect the new patch to correct its linkage 
behavior.

-Chris


On Jul 12, 2019, at 8:53 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

See 
https://reviews.llvm.org/D58418#1577670<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D58418-231577670=DwMFAg=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=BaInVCyhXHMyre_oyIEnYhuQC5zsW6p65QBgZLR7ujc=7bhRDMtKEyVqFDlMWzo361mQT2N8lcOt-YDh-XGjZok=>.
 More generally it would appear for any static library with a PRIVATE 
dependency though.

I guess an alternative would be to use the LINK_LIBRARIES property (which 
should be free of generator expressions, I believe) to propagate dependencies 
instead of INTERFACE_LINK_LIBRARIES, and just assume that no one is gonna set 
an INTERFACE dependency on a static library. (Supporting PRIVATE dependencies 
on a static library definitely seems more valuable than supporting INTERFACE 
dependencies.)

From: mailto:cbiene...@apple.com>> on behalf of Chris 
Bieneman mailto:be...@apple.com>>
Date: Friday, July 12, 2019 at 8:49 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: Alex Bradbury mailto:a...@lowrisc.org>>, cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

One of the benefits of the object library approach for generating the clang 
dylib is that it was compatible with BUILD_SHARED_LIBS. We had lots of issues 
with libLLVM where people using BUILD_SHARED_LIBS would make changes that broke 
it, so I was trying to make the clang dylib in a way that it could always be 
enabled.

Do we know where the nested generator expression was coming from?

-Chris



On Jul 12, 2019, at 8:32 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

Oops, sorry about the breakage.

Chris, aren't BUILD_SHARED_LIBS and the combined Clang dylib incompatible? 
Should we disable building the latter if the former is set?

From: Alex Bradbury mailto:a...@lowrisc.org>>
Date: Friday, July 12, 2019 at 2:02 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

On Thu, 11 Jul 2019 at 22:20, Shoaib Meenai via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D365825-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=R9NSZG1XQDVSiE0wJUgb1kMUrG6bJkG3v5GDcTdkpAk=
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D64579=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=mutN2zF1KixMEVFjNzG_Q7iVJzG5ECbrU4tX3AKWLVQ=

This seems to break a -DBUILD_SHARED_LIBS build for me. It fails at
the point of linking lib/libclang_shared.so.9svn with errors like:
ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by Attributes.cpp:34 
(/home/asb/llvm-project/clang/lib/Basic/Attributes.cpp:34)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::attr::getSubjectMatchRuleSpelling(clang::attr::SubjectMatchRule))

ld.

Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-12 Thread Shoaib Meenai via cfe-commits
Hmm, I thought CMake did something more sensible with PRIVATE/INTERFACE/PUBLIC 
dependencies on static libraries, but now I’m not so sure…

I’m continuing to investigate more, but I’ll revert in the meantime.

From:  on behalf of Chris Bieneman 
Date: Friday, July 12, 2019 at 9:08 AM
To: Shoaib Meenai 
Cc: Alex Bradbury , cfe-commits 
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

Ah! I see what is going on here. This is kinda a silliness of CMake. `PRIVATE` 
linkage for a static archive is silly, and shouldn't be possible. All link 
dependencies for static archives are really `INTERFACE` dependencies, and it 
looks like CMake is doing something kinda silly instead of producing a 
reasonable error or warning like it probably should do.

For context, `PRIVATE` linkage in the context of that change would mean 
DirectoryWalker links something, but things that link DirectoryWalker don't. 
That just isn't possible with static archives, so they become interface 
dependencies (and CMake seems to insert a generator expression to make that 
work).

In `llvm_add_library` we always use `PRIVATE` linkage for shared libraries, and 
`INTERFACE` for static, which does the right thing.

Unless there is a better reason than a new patch coming in, I think the right 
fix is to revert this back and expect the new patch to correct its linkage 
behavior.

-Chris


On Jul 12, 2019, at 8:53 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

See 
https://reviews.llvm.org/D58418#1577670<https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D58418-231577670=DwMFAg=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=BaInVCyhXHMyre_oyIEnYhuQC5zsW6p65QBgZLR7ujc=7bhRDMtKEyVqFDlMWzo361mQT2N8lcOt-YDh-XGjZok=>.
 More generally it would appear for any static library with a PRIVATE 
dependency though.

I guess an alternative would be to use the LINK_LIBRARIES property (which 
should be free of generator expressions, I believe) to propagate dependencies 
instead of INTERFACE_LINK_LIBRARIES, and just assume that no one is gonna set 
an INTERFACE dependency on a static library. (Supporting PRIVATE dependencies 
on a static library definitely seems more valuable than supporting INTERFACE 
dependencies.)

From: mailto:cbiene...@apple.com>> on behalf of Chris 
Bieneman mailto:be...@apple.com>>
Date: Friday, July 12, 2019 at 8:49 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: Alex Bradbury mailto:a...@lowrisc.org>>, cfe-commits 
mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

One of the benefits of the object library approach for generating the clang 
dylib is that it was compatible with BUILD_SHARED_LIBS. We had lots of issues 
with libLLVM where people using BUILD_SHARED_LIBS would make changes that broke 
it, so I was trying to make the clang dylib in a way that it could always be 
enabled.

Do we know where the nested generator expression was coming from?

-Chris



On Jul 12, 2019, at 8:32 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

Oops, sorry about the breakage.

Chris, aren't BUILD_SHARED_LIBS and the combined Clang dylib incompatible? 
Should we disable building the latter if the former is set?

From: Alex Bradbury mailto:a...@lowrisc.org>>
Date: Friday, July 12, 2019 at 2:02 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

On Thu, 11 Jul 2019 at 22:20, Shoaib Meenai via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D365825-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=R9NSZG1XQDVSiE0wJUgb1kMUrG6bJkG3v5GDcTdkpAk=
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D64579=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=mutN2zF1KixMEVFjNzG_Q7iVJzG5ECbrU4tX3AKWLVQ=

This seems to break a -DBUILD_SHARED_LIBS build for me. It fails at
the point of linking lib/libclang_shared.so.9svn with errors like:
ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by Attributes.cpp:34 
(/home/asb/llvm-project/clang/lib/B

Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-12 Thread Shoaib Meenai via cfe-commits
See https://reviews.llvm.org/D58418#1577670. More generally it would appear for 
any static library with a PRIVATE dependency though.

I guess an alternative would be to use the LINK_LIBRARIES property (which 
should be free of generator expressions, I believe) to propagate dependencies 
instead of INTERFACE_LINK_LIBRARIES, and just assume that no one is gonna set 
an INTERFACE dependency on a static library. (Supporting PRIVATE dependencies 
on a static library definitely seems more valuable than supporting INTERFACE 
dependencies.)

From:  on behalf of Chris Bieneman 
Date: Friday, July 12, 2019 at 8:49 AM
To: Shoaib Meenai 
Cc: Alex Bradbury , cfe-commits 
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

One of the benefits of the object library approach for generating the clang 
dylib is that it was compatible with BUILD_SHARED_LIBS. We had lots of issues 
with libLLVM where people using BUILD_SHARED_LIBS would make changes that broke 
it, so I was trying to make the clang dylib in a way that it could always be 
enabled.

Do we know where the nested generator expression was coming from?

-Chris


On Jul 12, 2019, at 8:32 AM, Shoaib Meenai 
mailto:smee...@fb.com>> wrote:

Oops, sorry about the breakage.

Chris, aren't BUILD_SHARED_LIBS and the combined Clang dylib incompatible? 
Should we disable building the latter if the former is set?

From: Alex Bradbury mailto:a...@lowrisc.org>>
Date: Friday, July 12, 2019 at 2:02 AM
To: Shoaib Meenai mailto:smee...@fb.com>>
Cc: cfe-commits mailto:cfe-commits@lists.llvm.org>>
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

On Thu, 11 Jul 2019 at 22:20, Shoaib Meenai via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D365825-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=R9NSZG1XQDVSiE0wJUgb1kMUrG6bJkG3v5GDcTdkpAk=
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D64579=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=mutN2zF1KixMEVFjNzG_Q7iVJzG5ECbrU4tX3AKWLVQ=

This seems to break a -DBUILD_SHARED_LIBS build for me. It fails at
the point of linking lib/libclang_shared.so.9svn with errors like:
ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by Attributes.cpp:34 
(/home/asb/llvm-project/clang/lib/Basic/Attributes.cpp:34)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::attr::getSubjectMatchRuleSpelling(clang::attr::SubjectMatchRule))

ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by TargetCXXABI.h:168 
(/home/asb/llvm-project/clang/include/clang/Basic/TargetCXXABI.h:168)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::TargetCXXABI::isMicrosoft()
 const)

ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by TargetCXXABI.h:149 
(/home/asb/llvm-project/clang/include/clang/Basic/TargetCXXABI.h:149)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::TargetCXXABI::isItaniumFamily()
 const)

ld.lld: error: undefined symbol: llvm::EnableABIBreakingChecks
referenced by Attributes.cpp
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(llvm::VerifyEnableABIBreakingChecks)


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


Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-12 Thread Shoaib Meenai via cfe-commits
Oops, sorry about the breakage.

Chris, aren't BUILD_SHARED_LIBS and the combined Clang dylib incompatible? 
Should we disable building the latter if the former is set?

From: Alex Bradbury 
Date: Friday, July 12, 2019 at 2:02 AM
To: Shoaib Meenai 
Cc: cfe-commits 
Subject: Re: r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

On Thu, 11 Jul 2019 at 22:20, Shoaib Meenai via cfe-commits
mailto:cfe-commits@lists.llvm.org>> wrote:

Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: 
https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D365825-26view-3Drev=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=R9NSZG1XQDVSiE0wJUgb1kMUrG6bJkG3v5GDcTdkpAk=
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.

Differential Revision: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D64579=DwIBaQ=5VD0RTtNlTh3ycd41b3MUw=o3kDXzdBUE3ljQXKeTWOMw=ETCU2JhfBcjWz-nbe6LUVSRQR0T1f3wCzxLIhKlMmQo=mutN2zF1KixMEVFjNzG_Q7iVJzG5ECbrU4tX3AKWLVQ=

This seems to break a -DBUILD_SHARED_LIBS build for me. It fails at
the point of linking lib/libclang_shared.so.9svn with errors like:
ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by Attributes.cpp:34 
(/home/asb/llvm-project/clang/lib/Basic/Attributes.cpp:34)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::attr::getSubjectMatchRuleSpelling(clang::attr::SubjectMatchRule))

ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by TargetCXXABI.h:168 
(/home/asb/llvm-project/clang/include/clang/Basic/TargetCXXABI.h:168)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::TargetCXXABI::isMicrosoft()
 const)

ld.lld: error: undefined symbol: llvm::llvm_unreachable_internal(char
const*, char const*, unsigned int)
referenced by TargetCXXABI.h:149 
(/home/asb/llvm-project/clang/include/clang/Basic/TargetCXXABI.h:149)
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(clang::TargetCXXABI::isItaniumFamily()
 const)

ld.lld: error: undefined symbol: llvm::EnableABIBreakingChecks
referenced by Attributes.cpp
   
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Attributes.cpp.o:(llvm::VerifyEnableABIBreakingChecks)

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


r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: http://llvm.org/viewvc/llvm-project?rev=365825=rev
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.

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

Modified:
cfe/trunk/tools/clang-shlib/CMakeLists.txt

Modified: cfe/trunk/tools/clang-shlib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-shlib/CMakeLists.txt?rev=365825=365824=365825=diff
==
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt Thu Jul 11 14:20:38 2019
@@ -7,8 +7,35 @@ get_property(clang_libs GLOBAL PROPERTY
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute 
the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead 
of
+  # using the object library at all. However, CMake reorders static libraries 
on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, 
linking
+  # both the object and the static libraries seems like the least bad solution.
+  #
+  # TODO: Rework this when we bump our minimum CMake version to 3.12 or newer.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared


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


r357184 - [CodeGen] Add additional mangling for struct members of non trivial structs

2019-03-28 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Mar 28 10:01:20 2019
New Revision: 357184

URL: http://llvm.org/viewvc/llvm-project?rev=357184=rev
Log:
[CodeGen] Add additional mangling for struct members of non trivial structs

In https://bugs.llvm.org/show_bug.cgi?id=41206 we observe bad codegen
when embedding a non-trivial C struct within a C struct. This is due to
the fact that name mangling for non-trivial structs marks the two
structs as identical. This diff contains a fix for this issue.

Patch by Dan Zimmerman .

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

Added:
cfe/trunk/test/CodeGenObjC/nontrivial-c-struct-within-struct-name.m
Modified:
cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp
cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m

Modified: cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp?rev=357184=357183=357184=diff
==
--- cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp Thu Mar 28 10:01:20 2019
@@ -139,8 +139,8 @@ struct CopyStructVisitor : StructVisitor
 //  ::=  ["_" ]
 //  ::= +
 //  ::=  | 
-//  ::=  |  
|
-//   
+//  ::= "_S"  |
+//| 
 //  ::= "_AB"  "s"  "n"
 //  "_AE"
 //  ::= 
@@ -175,6 +175,7 @@ template  struct GenFuncN
   void visitStruct(QualType QT, const FieldDecl *FD,
CharUnits CurStructOffset) {
 CharUnits FieldOffset = CurStructOffset + asDerived().getFieldOffset(FD);
+appendStr("_S");
 asDerived().visitStructFields(QT, FieldOffset);
   }
 

Added: cfe/trunk/test/CodeGenObjC/nontrivial-c-struct-within-struct-name.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/nontrivial-c-struct-within-struct-name.m?rev=357184=auto
==
--- cfe/trunk/test/CodeGenObjC/nontrivial-c-struct-within-struct-name.m (added)
+++ cfe/trunk/test/CodeGenObjC/nontrivial-c-struct-within-struct-name.m Thu Mar 
28 10:01:20 2019
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios11 -fobjc-arc -emit-llvm -o - %s | 
FileCheck %s
+
+@class I;
+
+typedef struct {
+  I *name;
+} Foo;
+
+typedef struct {
+  Foo foo;
+} Bar;
+
+typedef struct {
+  Bar bar;
+} Baz;
+
+I *getI();
+
+void f() {
+  Foo foo = {getI()};
+  Bar bar = {foo};
+  Baz baz = {bar};
+}
+
+// CHECK: define linkonce_odr hidden void @__destructor_8_S_S_s0(i8** 
%[[DST:.*]])
+// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
+// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
+// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
+// CHECK: call void @__destructor_8_S_s0(i8** %[[V0]])
+// CHECK: ret void
+
+// CHECK: define linkonce_odr hidden void @__destructor_8_S_s0(i8** 
%[[DST:.*]])
+// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
+// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
+// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
+// CHECK: call void @__destructor_8_s0(i8** %[[V0]])
+// CHECK: ret void
+
+// CHECK: define linkonce_odr hidden void @__destructor_8_s0(i8** %dst)
+// CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
+// CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
+// CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
+// CHECK: call void @llvm.objc.storeStrong(i8** %[[V0]], i8* null)
+// CHECK: ret void

Modified: cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m?rev=357184=357183=357184=diff
==
--- cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m (original)
+++ cfe/trunk/test/CodeGenObjC/strong-in-c-struct.m Thu Mar 28 10:01:20 2019
@@ -89,12 +89,12 @@ void func(Strong *);
 // CHECK: define void @test_constructor_destructor_StrongOuter()
 // CHECK: %[[T:.*]] = alloca %[[STRUCT_STRONGOUTER:.*]], align 8
 // CHECK: %[[V0:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8**
-// CHECK: call void @__default_constructor_8_s16_s24(i8** %[[V0]])
+// CHECK: call void @__default_constructor_8_S_s16_s24(i8** %[[V0]])
 // CHECK: %[[V1:.*]] = bitcast %[[STRUCT_STRONGOUTER]]* %[[T]] to i8**
-// CHECK: call void @__destructor_8_s16_s24(i8** %[[V1]])
+// CHECK: call void @__destructor_8_S_s16_s24(i8** %[[V1]])
 // CHECK: ret void
 
-// CHECK: define linkonce_odr hidden void 
@__default_constructor_8_s16_s24(i8** %[[DST:.*]])
+// CHECK: define linkonce_odr hidden void 
@__default_constructor_8_S_s16_s24(i8** %[[DST:.*]])
 // CHECK: %[[DST_ADDR:.*]] = alloca i8**, align 8
 // CHECK: store i8** %[[DST]], i8*** %[[DST_ADDR]], align 8
 // CHECK: %[[V0:.*]] = load i8**, i8*** %[[DST_ADDR]], align 8
@@ -117,7 +117,7 @@ void func(Strong *);
 // CHECK: call void @llvm.memset.p0i8.i64(i8* align 

r357036 - [cmake] Reset variable before using it

2019-03-26 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Tue Mar 26 15:16:53 2019
New Revision: 357036

URL: http://llvm.org/viewvc/llvm-project?rev=357036=rev
Log:
[cmake] Reset variable before using it

A bunch of macros use the same variable name, and since CMake macros
don't get their own scope, the value persists across macro invocations,
and we can end up exporting targets which shouldn't be exported. Clear
the variable before each use to avoid this.

Converting these macros to functions would also help, since it would
avoid the variable leaking into its parent scope, and that's something I
plan to follow up with. It won't fully address the problem, however,
since functions still inherit variables from their parent scopes, so if
someone in the parent scope just happened to use the same variable name
we'd still have the same issue.

Modified:
cfe/trunk/cmake/modules/AddClang.cmake

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=357036=357035=357036=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Tue Mar 26 15:16:53 2019
@@ -89,7 +89,7 @@ macro(add_clang_library name)
 target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
 
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
-
+  set(export_to_clangtargets)
   if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
   "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
   NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -137,6 +137,7 @@ macro(add_clang_tool name)
   add_dependencies(${name} clang-resource-headers)
 
   if (CLANG_BUILD_TOOLS)
+set(export_to_clangtargets)
 if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
 NOT LLVM_DISTRIBUTION_COMPONENTS)
   set(export_to_clangtargets EXPORT ClangTargets)


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


r355853 - [clang] Add install targets for API headers

2019-03-11 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Mar 11 11:53:57 2019
New Revision: 355853

URL: http://llvm.org/viewvc/llvm-project?rev=355853=rev
Log:
[clang] Add install targets for API headers

Add an install target for clang's API headers, which allows them to be
included in distributions. The install rules already existed, but they
lacked a component and a target, making them only accessible via a full
install. These headers are useful for writing clang-based tooling, for
example. They're the clang equivalent to the llvm-headers target and
complement the clang-libraries target.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=355853=355852=355853=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Mon Mar 11 11:53:57 2019
@@ -388,6 +388,7 @@ include_directories(BEFORE
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   install(DIRECTORY include/clang include/clang-c
 DESTINATION include
+COMPONENT clang-headers
 FILES_MATCHING
 PATTERN "*.def"
 PATTERN "*.h"
@@ -397,12 +398,23 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 
   install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/clang
 DESTINATION include
+COMPONENT clang-headers
 FILES_MATCHING
 PATTERN "CMakeFiles" EXCLUDE
 PATTERN "*.inc"
 PATTERN "*.h"
 )
 
+  # Installing the headers needs to depend on generating any public
+  # tablegen'd headers.
+  add_custom_target(clang-headers DEPENDS clang-tablegen-targets)
+  set_target_properties(clang-headers PROPERTIES FOLDER "Misc")
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-clang-headers
+ DEPENDS clang-headers
+ COMPONENT clang-headers)
+  endif()
+
   install(PROGRAMS utils/bash-autocomplete.sh
 DESTINATION share/clang
 )

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=355853=355852=355853=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Mon Mar 11 11:53:57 2019
@@ -156,7 +156,9 @@ release of Clang. Users of the build sys
 - In 8.0.0 and below, the install-clang-headers target would install clang's
   resource directory headers. This installation is now performed by the
   install-clang-resource-headers target. Users of the old install-clang-headers
-  target should switch to the new install-clang-resource-headers target.
+  target should switch to the new install-clang-resource-headers target. The
+  install-clang-headers target now installs clang's API headers (corresponding
+  to its libraries), which is consistent with the install-llvm-headers target.
 
 -  ...
 


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


r355354 - [cmake] Create exports for umbrella library targets

2019-03-04 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Mar  4 16:38:32 2019
New Revision: 355354

URL: http://llvm.org/viewvc/llvm-project?rev=355354=rev
Log:
[cmake] Create exports for umbrella library targets

When using the umbrella llvm-libraries and clang-libraries targets, we
should export all library targets, otherwise they'll be part of our
distribution but not usable from the CMake package.

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

Modified:
cfe/trunk/cmake/modules/AddClang.cmake

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=355354=355353=355354=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Mon Mar  4 16:38:32 2019
@@ -91,6 +91,7 @@ macro(add_clang_library name)
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
 
   if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
+  "clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
   NOT LLVM_DISTRIBUTION_COMPONENTS)
 set(export_to_clangtargets EXPORT ClangTargets)
 set_property(GLOBAL PROPERTY CLANG_HAS_EXPORTS True)


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


r355340 - [build] Rename clang-headers to clang-resource-headers

2019-03-04 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Mar  4 13:19:53 2019
New Revision: 355340

URL: http://llvm.org/viewvc/llvm-project?rev=355340=rev
Log:
[build] Rename clang-headers to clang-resource-headers

Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].

I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html

Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille

Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, 
lldb-commits, cfe-commits, llvm-commits

Tags: #clang, #sanitizers, #lldb, #openmp, #llvm

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

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake
cfe/trunk/cmake/caches/BaremetalARM.cmake
cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
cfe/trunk/cmake/modules/AddClang.cmake
cfe/trunk/docs/LibTooling.rst
cfe/trunk/docs/ReleaseNotes.rst
cfe/trunk/examples/clang-interpreter/CMakeLists.txt
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/test/CMakeLists.txt
cfe/trunk/tools/driver/CMakeLists.txt
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=355340=355339=355340=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Mon Mar  4 13:19:53 2019
@@ -60,7 +60,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   LTO
   clang-format
-  clang-headers
+  clang-resource-headers
   cxx-headers
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")

Modified: cfe/trunk/cmake/caches/BaremetalARM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/BaremetalARM.cmake?rev=355340=355339=355340=diff
==
--- cfe/trunk/cmake/caches/BaremetalARM.cmake (original)
+++ cfe/trunk/cmake/caches/BaremetalARM.cmake Mon Mar  4 13:19:53 2019
@@ -41,7 +41,7 @@ set(LLVM_TOOLCHAIN_TOOLS
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   lld
-  clang-headers
+  clang-resource-headers
   builtins-armv6m-none-eabi
   builtins-armv7m-none-eabi
   builtins-armv7em-none-eabi

Modified: cfe/trunk/cmake/caches/DistributionExample-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/DistributionExample-stage2.cmake?rev=355340=355339=355340=diff
==
--- cfe/trunk/cmake/caches/DistributionExample-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/DistributionExample-stage2.cmake Mon Mar  4 13:19:53 
2019
@@ -23,7 +23,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   LTO
   clang-format
-  clang-headers
+  clang-resource-headers
   builtins
   runtimes
   ${LLVM_TOOLCHAIN_TOOLS}

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=355340=355339=355340=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Mon Mar  4 13:19:53 2019
@@ -167,7 +167,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   LTO
   clang-apply-replacements
   clang-format
-  clang-headers
+  clang-resource-headers
   clang-include-fixer
   clang-refactor
   clang-tidy

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=355340=355339=355340=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Mon Mar  4 13:19:53 2019
@@ -133,7 +133,7 @@ macro(add_clang_tool name)
   endif()
 
   add_clang_executable(${name} ${ARGN})
-  add_dependencies(${name} clang-headers)
+  add_dependencies(${name} clang-resource-headers)
 
   if (CLANG_BUILD_TOOLS)
 if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR

Modified: cfe/trunk/docs/LibTooling.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibTooling.rst?rev=355340=355339=355340=diff
==
--- cfe/trunk/docs/LibTooling.rst (original)
+++ cfe/trunk/docs/LibTooling.rst Mon Mar  

[clang-tools-extra] r355340 - [build] Rename clang-headers to clang-resource-headers

2019-03-04 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Mar  4 13:19:53 2019
New Revision: 355340

URL: http://llvm.org/viewvc/llvm-project?rev=355340=rev
Log:
[build] Rename clang-headers to clang-resource-headers

Summary:
The current install-clang-headers target installs clang's resource
directory headers. This is different from the install-llvm-headers
target, which installs LLVM's API headers. We want to introduce the
corresponding target to clang, and the natural name for that new target
would be install-clang-headers. Rename the existing target to
install-clang-resource-headers to free up the install-clang-headers name
for the new target, following the discussion on cfe-dev [1].

I didn't find any bots on zorg referencing install-clang-headers. I'll
send out another PSA to cfe-dev to accompany this rename.

[1] http://lists.llvm.org/pipermail/cfe-dev/2019-February/061365.html

Reviewers: beanz, phosek, tstellar, rnk, dim, serge-sans-paille

Subscribers: mgorny, javed.absar, jdoerfert, #sanitizers, openmp-commits, 
lldb-commits, cfe-commits, llvm-commits

Tags: #clang, #sanitizers, #lldb, #openmp, #llvm

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

Modified:
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/test/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt?rev=355340=355339=355340=diff
==
--- clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt Mon Mar  4 13:19:53 
2019
@@ -9,7 +9,7 @@ add_clang_tool(clang-tidy
   ClangTidyMain.cpp
   )
 add_dependencies(clang-tidy
-  clang-headers
+  clang-resource-headers
   )
 target_link_libraries(clang-tidy
   PRIVATE

Modified: clang-tools-extra/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/CMakeLists.txt?rev=355340=355339=355340=diff
==
--- clang-tools-extra/trunk/test/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/test/CMakeLists.txt Mon Mar  4 13:19:53 2019
@@ -59,7 +59,7 @@ set(CLANG_TOOLS_TEST_DEPS
   # For the clang-tidy libclang integration test.
   c-index-test
   # clang-tidy tests require it.
-  clang-headers
+  clang-resource-headers
 
   clang-tidy
 )


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


r354527 - [clang] Add CMake target for installing clang's CMake exports

2019-02-20 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Feb 20 15:16:15 2019
New Revision: 354527

URL: http://llvm.org/viewvc/llvm-project?rev=354527=rev
Log:
[clang] Add CMake target for installing clang's CMake exports

This mirrors LLVM's install-cmake-exports target.

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

Modified:
cfe/trunk/cmake/modules/CMakeLists.txt

Modified: cfe/trunk/cmake/modules/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/CMakeLists.txt?rev=354527=354526=354527=diff
==
--- cfe/trunk/cmake/modules/CMakeLists.txt (original)
+++ cfe/trunk/cmake/modules/CMakeLists.txt Wed Feb 20 15:16:15 2019
@@ -55,10 +55,19 @@ set(CLANG_CONFIG_EXPORTS_FILE)
 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   get_property(clang_has_exports GLOBAL PROPERTY CLANG_HAS_EXPORTS)
   if(clang_has_exports)
-install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+install(EXPORT ClangTargets DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
   endif()
 
   install(FILES
 ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/ClangConfig.cmake
-DESTINATION ${CLANG_INSTALL_PACKAGE_DIR})
+DESTINATION ${CLANG_INSTALL_PACKAGE_DIR}
+COMPONENT clang-cmake-exports)
+
+  if(NOT LLVM_ENABLE_IDE)
+# Add a dummy target so this can be used with LLVM_DISTRIBUTION_COMPONENTS
+add_custom_target(clang-cmake-exports)
+add_llvm_install_targets(install-clang-cmake-exports
+ COMPONENT clang-cmake-exports)
+  endif()
 endif()


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


r354525 - [clang] Switch to LLVM_ENABLE_IDE

2019-02-20 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Feb 20 15:08:43 2019
New Revision: 354525

URL: http://llvm.org/viewvc/llvm-project?rev=354525=rev
Log:
[clang] Switch to LLVM_ENABLE_IDE

r344555 switched LLVM to guarding install targets with LLVM_ENABLE_IDE
instead of CMAKE_CONFIGURATION_TYPES, which expresses the intent more
directly and can be overridden by a user. Make the corresponding change
in clang. LLVM_ENABLE_IDE is computed by HandleLLVMOptions, so it should
be available for both standalone and integrated builds.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/AddClang.cmake
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/tools/c-index-test/CMakeLists.txt
cfe/trunk/tools/diagtool/CMakeLists.txt
cfe/trunk/tools/libclang/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=354525=354524=354525=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -552,7 +552,7 @@ endif()
 add_custom_target(clang-libraries)
 set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-libraries
DEPENDS clang-libraries
COMPONENT clang-libraries)
@@ -563,7 +563,7 @@ if(CLANG_LIBS)
   list(REMOVE_DUPLICATES CLANG_LIBS)
   foreach(lib ${CLANG_LIBS})
 add_dependencies(clang-libraries ${lib})
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_dependencies(install-clang-libraries install-${lib})
 endif()
   endforeach()

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=354525=354524=354525=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Wed Feb 20 15:08:43 2019
@@ -103,7 +103,7 @@ macro(add_clang_library name)
 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-${name}
  DEPENDS ${name}
  COMPONENT ${name})
@@ -147,7 +147,7 @@ macro(add_clang_tool name)
   RUNTIME DESTINATION bin
   COMPONENT ${name})
 
-if(NOT CMAKE_CONFIGURATION_TYPES)
+if(NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=354525=354524=354525=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -178,7 +178,7 @@ install(
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
   DESTINATION 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include/cuda_wrappers)
 
-if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+if (NOT LLVM_ENABLE_IDE)
   add_llvm_install_targets(install-clang-headers
DEPENDS clang-headers
COMPONENT clang-headers)

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=354525=354524=354525=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -61,7 +61,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 RUNTIME DESTINATION "${INSTALL_DESTINATION}"
 COMPONENT c-index-test)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDE's.
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-c-index-test
  DEPENDS c-index-test
  COMPONENT c-index-test)

Modified: cfe/trunk/tools/diagtool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/diagtool/CMakeLists.txt?rev=354525=354524=354525=diff
==
--- cfe/trunk/tools/diagtool/CMakeLists.txt (original)
+++ cfe/trunk/tools/diagtool/CMakeLists.txt Wed Feb 20 15:08:43 2019
@@ -23,7 +23,7 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
 COMPONENT diagtool
 RUNTIME DESTINATION bin)
 
-  if (NOT CMAKE_CONFIGURATION_TYPES)
+  if (NOT LLVM_ENABLE_IDE)
 add_llvm_install_targets(install-diagtool
   DEPENDS diagtool
   

r354141 - [clang] Add build and install targets for clang libraries

2019-02-15 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Fri Feb 15 07:59:04 2019
New Revision: 354141

URL: http://llvm.org/viewvc/llvm-project?rev=354141=rev
Log:
[clang] Add build and install targets for clang libraries

This is modeled after the existing llvm-libraries target. It's a
convenient way to include all clang libraries in a distribution.

This differs slightly from the llvm-libraries target in that it adds any
library added via add_clang_library, whereas llvm-libraries only
includes targets added via add_llvm_library that didn't use the MODULE
or BUILDTREE_ONLY arguments. add_clang_library doesn't appear to have
any equivalents of those arguments, so the conditions don't apply.

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/AddClang.cmake

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=354141=354140=354141=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Feb 15 07:59:04 2019
@@ -543,6 +543,27 @@ if( CLANG_INCLUDE_DOCS )
   add_subdirectory(docs)
 endif()
 
+# Custom target to install all clang libraries.
+add_custom_target(clang-libraries)
+set_target_properties(clang-libraries PROPERTIES FOLDER "Misc")
+
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_llvm_install_targets(install-clang-libraries
+   DEPENDS clang-libraries
+   COMPONENT clang-libraries)
+endif()
+
+get_property(CLANG_LIBS GLOBAL PROPERTY CLANG_LIBS)
+if(CLANG_LIBS)
+  list(REMOVE_DUPLICATES CLANG_LIBS)
+  foreach(lib ${CLANG_LIBS})
+add_dependencies(clang-libraries ${lib})
+if(NOT CMAKE_CONFIGURATION_TYPES)
+  add_dependencies(install-clang-libraries install-${lib})
+endif()
+  endforeach()
+endif()
+
 add_subdirectory(cmake/modules)
 
 if(CLANG_STAGE)

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=354141=354140=354141=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Fri Feb 15 07:59:04 2019
@@ -108,6 +108,8 @@ macro(add_clang_library name)
  DEPENDS ${name}
  COMPONENT ${name})
   endif()
+
+  set_property(GLOBAL APPEND PROPERTY CLANG_LIBS ${name})
 endif()
 set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   else()


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


  1   2   3   4   >