[clang] [llvm] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)

2023-12-04 Thread Craig Topper via cfe-commits

topperc wrote:

> Here's a simple-ish example:
> 
> ```llvm
> ; Transforms/InstCombine/add.ll
> 
> define i5 @zext_sext_not(i4 %x) {
>   %zx = zext i4 %x to i5
>   %notx = xor i4 %x, 15
>   %snotx = sext i4 %notx to i5
>   %r = add i5 %zx, %snotx
>   ret i5 %r
> }
> =>
> define i5 @zext_sext_not(i4 %x) {
>   %zx = zext i4 %x to i5
>   %notx = xor i4 %x, 15
>   %snotx = sext i4 %notx to i5
>   %r = or disjoint i5 %zx, %snotx
>   ret i5 %r
> }
> Transformation doesn't verify! (unsound)
> ERROR: Target is more poisonous than source
> 
> Example:
> i4 %x = undef
> 
> Source:
> i5 %zx = #x00 (0) [based on undef value]
> i4 %notx = #xf (15, -1)   [based on undef value]
> i5 %snotx = #x1f (31, -1)
> i5 %r = #x1f (31, -1)
> 
> Target:
> i5 %zx = #x0f (15)
> i4 %notx = #xf (15, -1)
> i5 %snotx = #x1f (31, -1)
> i5 %r = poison
> Source value: #x1f (31, -1)
> Target value: poison
> ```
> 
> Essentially the code doesn't take into consideration that a same register may 
> have different values when it is undef.

Looks like this is caused by the checks in `haveNoCommonBitsSetSpecialCases`.

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


[clang] [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses. (PR #68618)

2023-12-04 Thread Yonggang Luo via cfe-commits

https://github.com/lygstate updated 
https://github.com/llvm/llvm-project/pull/68618

>From d1886bab8356262b1305093465658acffb4cafff Mon Sep 17 00:00:00 2001
From: Yonggang Luo 
Date: Tue, 10 Oct 2023 02:23:34 +0800
Subject: [PATCH] [clang] Fixes compile error that double colon operator cannot
 resolve macro with parentheses.

Error message:
```
In file included from ../src/amd/addrlib/src/core/addrobject.h:21:
../src/amd/addrlib/src/core/addrcommon.h:343:13: error: expected unqualified-id
out = ::_tzcnt_u32(mask);
^
/usr/lib/llvm-15/lib/clang/15.0.6/include/bmiintrin.h:74:27: note: expanded 
from macro '_tzcnt_u32'
#define _tzcnt_u32(a) (__tzcnt_u32((a)))
```

This is because both GCC/Clang doesn't support compiling the following code:
```
#ifdef _MSC_VER
#include 
#else
#include 
#endif

int f(int a) {
return ::(_tzcnt_u32)(a);
}
```

This is because the return statement expects an expression or braced init list: 
http://eel.is/c++draft/stmt.jump#general-1 but we really only need to care 
about the expression form (there's no braces in sight).
Grammatically, the leading :: will parse as a qualified-id because it matches 
the production for nested-name-specifier: 
http://eel.is/c++draft/expr.prim.id.qual#nt:qualified-id
That needs to be followed by an unqualified-id 
(http://eel.is/c++draft/expr.prim.id.unqual#nt:unqualified-id), but the open 
paren does not match any of the grammar productions, so this is a syntax error.

Closes: https://github.com/llvm/llvm-project/issues/64467

Signed-off-by: Yonggang Luo 
---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/lib/Headers/bmiintrin.h | 22 +++---
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 683d0026bb345..ee33f8f2ee399 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -651,6 +651,8 @@ Bug Fixes in This Version
 - Fixed false positive error emitted by clang when performing qualified name
   lookup and the current class instantiation has dependent bases.
   Fixes (`#13826 `_)
+- Fixes compile error that double colon operator cannot resolve macro with 
parentheses.
+  Fixes (`#64467 `_)- Clang 
now properly diagnoses use of stand-alone OpenMP directives after a
 - Clang's ``-Wchar-subscripts`` no longer warns on chars whose values are 
known non-negative constants.
   Fixes (`#18763 `_)
 
diff --git a/clang/lib/Headers/bmiintrin.h b/clang/lib/Headers/bmiintrin.h
index ffb94bea639af..bc7c8a03c5e2a 100644
--- a/clang/lib/Headers/bmiintrin.h
+++ b/clang/lib/Headers/bmiintrin.h
@@ -19,7 +19,7 @@
to use it as a potentially faster version of BSF. */
 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
-#define _tzcnt_u16(a) (__tzcnt_u16((a)))
+#define _tzcnt_u16 __tzcnt_u16
 
 /// Counts the number of trailing zero bits in the operand.
 ///
@@ -71,7 +71,7 @@ _mm_tzcnt_32(unsigned int __X)
   return (int)__builtin_ia32_tzcnt_u32(__X);
 }
 
-#define _tzcnt_u32(a) (__tzcnt_u32((a)))
+#define _tzcnt_u32 __tzcnt_u32
 
 #ifdef __x86_64__
 
@@ -109,7 +109,7 @@ _mm_tzcnt_64(unsigned long long __X)
   return (long long)__builtin_ia32_tzcnt_u64(__X);
 }
 
-#define _tzcnt_u64(a) (__tzcnt_u64((a)))
+#define _tzcnt_u64 __tzcnt_u64
 
 #endif /* __x86_64__ */
 
@@ -121,14 +121,14 @@ _mm_tzcnt_64(unsigned long long __X)
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("bmi")))
 
-#define _andn_u32(a, b)   (__andn_u32((a), (b)))
+#define _andn_u32 __andn_u32
 
 /* _bextr_u32 != __bextr_u32 */
-#define _blsi_u32(a)  (__blsi_u32((a)))
+#define _blsi_u32 __blsi_u32
 
-#define _blsmsk_u32(a)(__blsmsk_u32((a)))
+#define _blsmsk_u32 __blsmsk_u32
 
-#define _blsr_u32(a)  (__blsr_u32((a)))
+#define _blsr_u32 __blsr_u32
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.
@@ -272,14 +272,14 @@ __blsr_u32(unsigned int __X)
 
 #ifdef __x86_64__
 
-#define _andn_u64(a, b)   (__andn_u64((a), (b)))
+#define _andn_u64 __andn_u64
 
 /* _bextr_u64 != __bextr_u64 */
-#define _blsi_u64(a)  (__blsi_u64((a)))
+#define _blsi_u64 __blsi_u64
 
-#define _blsmsk_u64(a)(__blsmsk_u64((a)))
+#define _blsmsk_u64 __blsmsk_u64
 
-#define _blsr_u64(a)  (__blsr_u64((a)))
+#define _blsr_u64 __blsr_u64
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.

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


[clang] [llvm] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-04 Thread Mingming Liu via cfe-commits

https://github.com/minglotus-6 updated 
https://github.com/llvm/llvm-project/pull/74008

>From 4cb5b087485124a7f2375fdc018b42a0401e6409 Mon Sep 17 00:00:00 2001
From: mingmingl 
Date: Thu, 30 Nov 2023 15:41:37 -0800
Subject: [PATCH 1/3] [PGO][GlobalValue][LTO]In
 GlobalValues::getGlobalIdentifier, use semicolon as delimiter for
 local-linkage varibles.

Commit fe05193 (phab D156569), IRPGO names uses format
'[;]' while prior format is
[:'. The format change would break the use caes
demonstrated in (updated)
llvm/test/Transforms/PGOProfile/thinlto_indirect_call_promotion.ll

This patch changes GlobalValues::getGlobalIdentifer to use the
semicolon.

To elaborate on the scenario how things break without this PR
1. IRPGO raw profiles stores (compressed) IRPGO names of functions in
   one section, and per-function profile data in another section. One
   field in per-function profile data is the MD5 hash of IRPGO names.
2. When raw profiles are converted to indexed format profiles, the
   profiled address is mapped to the MD5 hash of the callee.
3. In thin-lto prelink pipeline, MD5 hash of IRPGO names will be
   annotated as value profiles, and used to import indirect-call-prom
   candidates. If the annotated MD5 hash is computed from the new format
   while import uses the prior format, the callee cannot be imported.

The updated test case Transforms/PGOProfile/thinlto_indirect_call_promotion.ll 
exercise the following path
- Annotate raw profiles and generate import summaries. Using the
  imported summaries, it tests that functions are correctly imported and
  ICP transformations happened.
---
 llvm/lib/IR/Globals.cpp   |   4 +-
 llvm/lib/ProfileData/InstrProf.cpp|  28 +--
 .../thinlto-function-summary-originalnames.ll |   6 +-
 llvm/test/ThinLTO/X86/memprof-basic.ll|  26 +++
 .../X86/memprof-duplicate-context-ids.ll  |  12 +--
 .../ThinLTO/X86/memprof-funcassigncloning.ll  |   6 +-
 llvm/test/ThinLTO/X86/memprof-indirectcall.ll |  32 
 llvm/test/ThinLTO/X86/memprof-inlined.ll  |  14 ++--
 .../Inputs/thinlto_icall_prom.profdata| Bin 0 -> 976 bytes
 .../Inputs/thinlto_indirect_call_promotion.ll |  32 ++--
 .../Inputs/update_icall_promotion_inputs.sh   |  70 ++
 .../thinlto_indirect_call_promotion.ll|  52 ++---
 12 files changed, 194 insertions(+), 88 deletions(-)
 create mode 100644 
llvm/test/Transforms/PGOProfile/Inputs/thinlto_icall_prom.profdata
 create mode 100644 
llvm/test/Transforms/PGOProfile/Inputs/update_icall_promotion_inputs.sh

diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 7bd4503a689e4..e821de3b198f1 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -158,9 +158,9 @@ std::string GlobalValue::getGlobalIdentifier(StringRef Name,
 // that it will stay the same, e.g., if the files are checked out from
 // version control in different locations.
 if (FileName.empty())
-  NewName = NewName.insert(0, ":");
+  NewName = NewName.insert(0, ";");
 else
-  NewName = NewName.insert(0, FileName.str() + ":");
+  NewName = NewName.insert(0, FileName.str() + ";");
   }
   return NewName;
 }
diff --git a/llvm/lib/ProfileData/InstrProf.cpp 
b/llvm/lib/ProfileData/InstrProf.cpp
index 236b083a1e215..d9ad5c8b6f683 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -246,11 +246,27 @@ std::string InstrProfError::message() const {
 
 char InstrProfError::ID = 0;
 
-std::string getPGOFuncName(StringRef RawFuncName,
-   GlobalValue::LinkageTypes Linkage,
+std::string getPGOFuncName(StringRef Name, GlobalValue::LinkageTypes Linkage,
StringRef FileName,
uint64_t Version LLVM_ATTRIBUTE_UNUSED) {
-  return GlobalValue::getGlobalIdentifier(RawFuncName, Linkage, FileName);
+  // Value names may be prefixed with a binary '1' to indicate
+  // that the backend should not modify the symbols due to any platform
+  // naming convention. Do not include that '1' in the PGO profile name.
+  if (Name[0] == '\1')
+Name = Name.substr(1);
+
+  std::string NewName = std::string(Name);
+  if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
+// For local symbols, prepend the main file name to distinguish them.
+// Do not include the full path in the file name since there's no guarantee
+// that it will stay the same, e.g., if the files are checked out from
+// version control in different locations.
+if (FileName.empty())
+  NewName = NewName.insert(0, ":");
+else
+  NewName = NewName.insert(0, FileName.str() + ":");
+  }
+  return NewName;
 }
 
 // Strip NumPrefix level of directory name from PathNameStr. If the number of
@@ -300,12 +316,8 @@ getIRPGONameForGlobalObject(const GlobalObject &GO,
 GlobalValue::LinkageTypes Linkage,
 StringRef FileName) {
   S

[llvm] [clang] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-04 Thread Mingming Liu via cfe-commits


@@ -246,11 +246,27 @@ std::string InstrProfError::message() const {
 
 char InstrProfError::ID = 0;
 
-std::string getPGOFuncName(StringRef RawFuncName,
-   GlobalValue::LinkageTypes Linkage,
+std::string getPGOFuncName(StringRef Name, GlobalValue::LinkageTypes Linkage,

minglotus-6 wrote:

undo the rename.

I didn't find a way to configure the Github notifications for real-time 
comments. Guess I'll need to combine email notifications.

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


[llvm] [libcxx] [compiler-rt] [flang] [clang] [libc] [clang-tools-extra] [NFC][ASAN] Replace AsanInitIsRunning with TryAsanInitFromRtl (PR #74171)

2023-12-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/74171

>From c630b3d042729fa2053866c959e8e05b8ce11267 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Fri, 1 Dec 2023 19:20:23 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?=
 =?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/lib/asan/asan_interceptors.h | 9 +++--
 compiler-rt/lib/asan/asan_rtl.cpp| 4 +++-
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/compiler-rt/lib/asan/asan_interceptors.h 
b/compiler-rt/lib/asan/asan_interceptors.h
index e355c1258a9fe..6a7748c8f9bb9 100644
--- a/compiler-rt/lib/asan/asan_interceptors.h
+++ b/compiler-rt/lib/asan/asan_interceptors.h
@@ -24,12 +24,9 @@ namespace __asan {
 void InitializeAsanInterceptors();
 void InitializePlatformInterceptors();
 
-#define ENSURE_ASAN_INITED()   \
-  do { \
-CHECK(!AsanInitIsRunning());   \
-if (UNLIKELY(!AsanInited())) { \
-  AsanInitFromRtl();   \
-}  \
+#define ENSURE_ASAN_INITED() \
+  do {   \
+AsanInitFromRtl();   \
   } while (0)
 
 }  // namespace __asan
diff --git a/compiler-rt/lib/asan/asan_rtl.cpp 
b/compiler-rt/lib/asan/asan_rtl.cpp
index d8bd19d8b79d4..b129e22813dac 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -520,7 +520,9 @@ static void AsanInitInternal() {
 // Initialize as requested from some part of ASan runtime library 
(interceptors,
 // allocator, etc).
 void AsanInitFromRtl() {
-  AsanInitInternal();
+  CHECK(!AsanInitIsRunning());
+  if (UNLIKELY(!AsanInited()))
+AsanInitInternal();
 }
 
 #if ASAN_DYNAMIC

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


[clang] b6d0ee0 - Revert HWASAN failure (#74163)

2023-12-04 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2023-12-02T04:39:14Z
New Revision: b6d0ee056d247e1ecfd4ecd3f97fb2d31740d79b

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

LOG: Revert HWASAN failure (#74163)

This is the failure:
https://lab.llvm.org/buildbot/#/builders/236/builds/7728/steps/10/logs/stdio

This started with eef8e1d206dc01c081a0ca29b7f9e0c39d33446e, but because
there were a couple of patches that came after that I had to revert all
3 of them because of merge conflicts.

Added: 


Modified: 
clang/test/Driver/aarch64-v95a.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64InstrFormats.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/AArch64SchedA64FX.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseN2.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseV1.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseV2.td
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/MC/AArch64/basic-a64-diagnostics.s
llvm/test/MC/AArch64/basic-a64-instructions.s
llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 
llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s
llvm/test/MC/AArch64/armv9.5a-cpa.s
llvm/test/MC/Disassembler/AArch64/armv9.5a-cpa.txt



diff  --git a/clang/test/Driver/aarch64-v95a.c 
b/clang/test/Driver/aarch64-v95a.c
index 366cade86a9fb..6044a4f155db0 100644
--- a/clang/test/Driver/aarch64-v95a.c
+++ b/clang/test/Driver/aarch64-v95a.c
@@ -13,8 +13,3 @@
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.5-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV95A-BE %s
 // GENERICV95A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+neon" "-target-feature" "+v9.5a"
 
-// = Features supported on aarch64 =
-
-// RUN: %clang -target aarch64 -march=armv9.5a+cpa -### -c %s 2>&1 | FileCheck 
-check-prefix=V95A-CPA %s
-// RUN: %clang -target aarch64 -march=armv9.5-a+cpa -### -c %s 2>&1 | 
FileCheck -check-prefix=V95A-CPA %s
-// V95A-CPA: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+neon" "-target-feature" "+v9.5a" "-target-feature" "+cpa"

diff  --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 0711f013a3779..17cafd146b0e7 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -173,7 +173,6 @@ enum ArchExtKind : unsigned {
   AEK_SMEF8F16 =  69, // FEAT_SME_F8F16
   AEK_SMEF8F32 =  70, // FEAT_SME_F8F32
   AEK_SMEFA64 =   71, // FEAT_SME_FA64
-  AEK_CPA =   72, // FEAT_CPA
   AEK_NUM_EXTENSIONS
 };
 using ExtensionBitset = Bitset;
@@ -296,7 +295,6 @@ inline constexpr ExtensionInfo Extensions[] = {
 {"sme-f8f16", AArch64::AEK_SMEF8F16, "+sme-f8f16", "-sme-f8f16", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-f8f32", AArch64::AEK_SMEF8F32, "+sme-f8f32", "-sme-f8f32", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-fa64",  AArch64::AEK_SMEFA64,  "+sme-fa64", "-sme-fa64",  FEAT_INIT, 
"", 0},
-{"cpa", AArch64::AEK_CPA, "+cpa", "-cpa", FEAT_INIT, "", 0},
 // Special cases
 {"none", AArch64::AEK_NONE, {}, {}, FEAT_INIT, "", 
ExtensionInfo::MaxFMVPriority},
 };
@@ -380,8 +378,7 @@ inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, 
AProfile, "armv9.3-a
 
AArch64::ExtensionBitset({AArch64::AEK_MOPS, AArch64::AEK_HBC}))};
 inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, 
"armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SPECRES2, AArch64::AEK_CSSC, 
AArch64::AEK_RASv2}))};
-inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts |
-
AArch64::ExtensionBitset({AArch64::AEK_CPA}))};
+inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more 
minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", (ARMV8_5A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SSBS,

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index d1dbced2466ea..ff256c9a8ccdf 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+

[clang] b6d0ee0 - Revert HWASAN failure (#74163)

2023-12-04 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2023-12-02T04:39:14Z
New Revision: b6d0ee056d247e1ecfd4ecd3f97fb2d31740d79b

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

LOG: Revert HWASAN failure (#74163)

This is the failure:
https://lab.llvm.org/buildbot/#/builders/236/builds/7728/steps/10/logs/stdio

This started with eef8e1d206dc01c081a0ca29b7f9e0c39d33446e, but because
there were a couple of patches that came after that I had to revert all
3 of them because of merge conflicts.

Added: 


Modified: 
clang/test/Driver/aarch64-v95a.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64InstrFormats.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/AArch64SchedA64FX.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseN2.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseV1.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseV2.td
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/MC/AArch64/basic-a64-diagnostics.s
llvm/test/MC/AArch64/basic-a64-instructions.s
llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 
llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s
llvm/test/MC/AArch64/armv9.5a-cpa.s
llvm/test/MC/Disassembler/AArch64/armv9.5a-cpa.txt



diff  --git a/clang/test/Driver/aarch64-v95a.c 
b/clang/test/Driver/aarch64-v95a.c
index 366cade86a9fb..6044a4f155db0 100644
--- a/clang/test/Driver/aarch64-v95a.c
+++ b/clang/test/Driver/aarch64-v95a.c
@@ -13,8 +13,3 @@
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.5-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV95A-BE %s
 // GENERICV95A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+neon" "-target-feature" "+v9.5a"
 
-// = Features supported on aarch64 =
-
-// RUN: %clang -target aarch64 -march=armv9.5a+cpa -### -c %s 2>&1 | FileCheck 
-check-prefix=V95A-CPA %s
-// RUN: %clang -target aarch64 -march=armv9.5-a+cpa -### -c %s 2>&1 | 
FileCheck -check-prefix=V95A-CPA %s
-// V95A-CPA: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+neon" "-target-feature" "+v9.5a" "-target-feature" "+cpa"

diff  --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 0711f013a3779..17cafd146b0e7 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -173,7 +173,6 @@ enum ArchExtKind : unsigned {
   AEK_SMEF8F16 =  69, // FEAT_SME_F8F16
   AEK_SMEF8F32 =  70, // FEAT_SME_F8F32
   AEK_SMEFA64 =   71, // FEAT_SME_FA64
-  AEK_CPA =   72, // FEAT_CPA
   AEK_NUM_EXTENSIONS
 };
 using ExtensionBitset = Bitset;
@@ -296,7 +295,6 @@ inline constexpr ExtensionInfo Extensions[] = {
 {"sme-f8f16", AArch64::AEK_SMEF8F16, "+sme-f8f16", "-sme-f8f16", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-f8f32", AArch64::AEK_SMEF8F32, "+sme-f8f32", "-sme-f8f32", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-fa64",  AArch64::AEK_SMEFA64,  "+sme-fa64", "-sme-fa64",  FEAT_INIT, 
"", 0},
-{"cpa", AArch64::AEK_CPA, "+cpa", "-cpa", FEAT_INIT, "", 0},
 // Special cases
 {"none", AArch64::AEK_NONE, {}, {}, FEAT_INIT, "", 
ExtensionInfo::MaxFMVPriority},
 };
@@ -380,8 +378,7 @@ inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, 
AProfile, "armv9.3-a
 
AArch64::ExtensionBitset({AArch64::AEK_MOPS, AArch64::AEK_HBC}))};
 inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, 
"armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SPECRES2, AArch64::AEK_CSSC, 
AArch64::AEK_RASv2}))};
-inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts |
-
AArch64::ExtensionBitset({AArch64::AEK_CPA}))};
+inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more 
minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", (ARMV8_5A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SSBS,

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index d1dbced2466ea..ff256c9a8ccdf 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+

[clang] b6d0ee0 - Revert HWASAN failure (#74163)

2023-12-04 Thread Kirill Stoimenov via cfe-commits

Author: Kirill Stoimenov
Date: 2023-12-02T04:39:14Z
New Revision: b6d0ee056d247e1ecfd4ecd3f97fb2d31740d79b

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

LOG: Revert HWASAN failure (#74163)

This is the failure:
https://lab.llvm.org/buildbot/#/builders/236/builds/7728/steps/10/logs/stdio

This started with eef8e1d206dc01c081a0ca29b7f9e0c39d33446e, but because
there were a couple of patches that came after that I had to revert all
3 of them because of merge conflicts.

Added: 


Modified: 
clang/test/Driver/aarch64-v95a.c
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64InstrFormats.td
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
llvm/lib/Target/AArch64/AArch64SchedA64FX.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseN2.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseV1.td
llvm/lib/Target/AArch64/AArch64SchedNeoverseV2.td
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
llvm/lib/Target/AArch64/SVEInstrFormats.td
llvm/test/MC/AArch64/basic-a64-diagnostics.s
llvm/test/MC/AArch64/basic-a64-instructions.s
llvm/test/MC/Disassembler/AArch64/basic-a64-instructions.txt
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 
llvm/test/MC/AArch64/SVE/armv9.5a-cpa.s
llvm/test/MC/AArch64/armv9.5a-cpa.s
llvm/test/MC/Disassembler/AArch64/armv9.5a-cpa.txt



diff  --git a/clang/test/Driver/aarch64-v95a.c 
b/clang/test/Driver/aarch64-v95a.c
index 366cade86a9fb..6044a4f155db0 100644
--- a/clang/test/Driver/aarch64-v95a.c
+++ b/clang/test/Driver/aarch64-v95a.c
@@ -13,8 +13,3 @@
 // RUN: %clang -target aarch64_be -mbig-endian -march=armv9.5-a -### -c %s 
2>&1 | FileCheck -check-prefix=GENERICV95A-BE %s
 // GENERICV95A-BE: "-cc1"{{.*}} "-triple" "aarch64_be{{.*}}" "-target-cpu" 
"generic" "-target-feature" "+neon" "-target-feature" "+v9.5a"
 
-// = Features supported on aarch64 =
-
-// RUN: %clang -target aarch64 -march=armv9.5a+cpa -### -c %s 2>&1 | FileCheck 
-check-prefix=V95A-CPA %s
-// RUN: %clang -target aarch64 -march=armv9.5-a+cpa -### -c %s 2>&1 | 
FileCheck -check-prefix=V95A-CPA %s
-// V95A-CPA: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "generic" 
"-target-feature" "+neon" "-target-feature" "+v9.5a" "-target-feature" "+cpa"

diff  --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h 
b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index 0711f013a3779..17cafd146b0e7 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -173,7 +173,6 @@ enum ArchExtKind : unsigned {
   AEK_SMEF8F16 =  69, // FEAT_SME_F8F16
   AEK_SMEF8F32 =  70, // FEAT_SME_F8F32
   AEK_SMEFA64 =   71, // FEAT_SME_FA64
-  AEK_CPA =   72, // FEAT_CPA
   AEK_NUM_EXTENSIONS
 };
 using ExtensionBitset = Bitset;
@@ -296,7 +295,6 @@ inline constexpr ExtensionInfo Extensions[] = {
 {"sme-f8f16", AArch64::AEK_SMEF8F16, "+sme-f8f16", "-sme-f8f16", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-f8f32", AArch64::AEK_SMEF8F32, "+sme-f8f32", "-sme-f8f32", 
FEAT_INIT, "+sme2,+fp8", 0},
 {"sme-fa64",  AArch64::AEK_SMEFA64,  "+sme-fa64", "-sme-fa64",  FEAT_INIT, 
"", 0},
-{"cpa", AArch64::AEK_CPA, "+cpa", "-cpa", FEAT_INIT, "", 0},
 // Special cases
 {"none", AArch64::AEK_NONE, {}, {}, FEAT_INIT, "", 
ExtensionInfo::MaxFMVPriority},
 };
@@ -380,8 +378,7 @@ inline constexpr ArchInfo ARMV9_3A  = { VersionTuple{9, 3}, 
AProfile, "armv9.3-a
 
AArch64::ExtensionBitset({AArch64::AEK_MOPS, AArch64::AEK_HBC}))};
 inline constexpr ArchInfo ARMV9_4A  = { VersionTuple{9, 4}, AProfile, 
"armv9.4-a", "+v9.4a", (ARMV9_3A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SPECRES2, AArch64::AEK_CSSC, 
AArch64::AEK_RASv2}))};
-inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts |
-
AArch64::ExtensionBitset({AArch64::AEK_CPA}))};
+inline constexpr ArchInfo ARMV9_5A  = { VersionTuple{9, 5}, AProfile, 
"armv9.5-a", "+v9.5a", (ARMV9_4A.DefaultExts)};
 // For v8-R, we do not enable crypto and align with GCC that enables a more 
minimal set of optional architecture extensions.
 inline constexpr ArchInfo ARMV8R= { VersionTuple{8, 0}, RProfile, 
"armv8-r", "+v8r", (ARMV8_5A.DefaultExts |
 
AArch64::ExtensionBitset({AArch64::AEK_SSBS,

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index d1dbced2466ea..ff256c9a8ccdf 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+

[clang] [llvm] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)

2023-12-04 Thread Craig Topper via cfe-commits

topperc wrote:

@nikic is something like this the right fix

```
diff --git a/llvm/lib/Analysis/ValueTracking.cpp 
b/llvm/lib/Analysis/ValueTracking.cpp
index 8c29c242215d..b03a56c922de 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -235,8 +235,11 @@ bool llvm::haveNoCommonBitsSet(const WithCache &LHSCache,
  "LHS and RHS should be integers");
 
   if (haveNoCommonBitsSetSpecialCases(LHS, RHS) ||
-  haveNoCommonBitsSetSpecialCases(RHS, LHS))
-return true;
+  haveNoCommonBitsSetSpecialCases(RHS, LHS)) {
+if (isGuaranteedNotToBeUndefOrPoison(LHS, SQ.AC, SQ.CxtI, SQ.DT) &&
+isGuaranteedNotToBeUndefOrPoison(RHS, SQ.AC, SQ.CxtI, SQ.DT))
+  return true;
+  }
 
   return KnownBits::haveNoCommonBitsSet(LHSCache.getKnownBits(SQ),
 RHSCache.getKnownBits(SQ));
```

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


[clang] [llvm] [PGO][GlobalValue][LTO]In GlobalValues::getGlobalIdentifier, use semicolon as delimiter for local-linkage varibles. (PR #74008)

2023-12-04 Thread Mingming Liu via cfe-commits


@@ -300,12 +316,8 @@ getIRPGONameForGlobalObject(const GlobalObject &GO,
 GlobalValue::LinkageTypes Linkage,
 StringRef FileName) {
   SmallString<64> Name;
-  if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
-Name.append(FileName.empty() ? "" : FileName);
-Name.append(";");
-  }
   Mangler().getNameWithPrefix(Name, &GO, /*CannotUsePrivateLabel=*/true);

minglotus-6 wrote:

To avoid subtle issues when linkage-name is different from mangled names,,I'm 
wondering if it warrants a change to use linkage-names (as opposed to mangled 
name) in `GlobalValue::getGlobalIdentifier` in this PR.  Global identifier is 
supposed to be hash of unique names, and linkage-name is already unique.

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


[clang] [libc] [flang] [llvm] [compiler-rt] [clang-tools-extra] [libcxx] [NFC][ASAN] Replace AsanInitIsRunning with TryAsanInitFromRtl (PR #74171)

2023-12-04 Thread Vitaly Buka via cfe-commits

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


[llvm] [clang] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)

2023-12-04 Thread Nuno Lopes via cfe-commits

nunoplopes wrote:

We don't have a `isGuaranteedNotToBeUndef` only function, so that's the only 
way. I would leave a fixme, since this call can be removed if we ever manage to 
kill undef.
Thanks for your help! 🙂

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


[clang] [clang-tools-extra] [llvm] [AArch64][Clang] Fix linker error for function multiversioning (PR #74358)

2023-12-04 Thread via cfe-commits

https://github.com/DanielKristofKiss created 
https://github.com/llvm/llvm-project/pull/74358

AArch64 part of https://github.com/llvm/llvm-project/pull/71706.

Default version is now mangled with .default.
Resolver for the TargetVersion need to be emitted from the
CodeGenModule::EmitMultiVersionFunctionDefinition.

>From 534fad70af45a6a22ba2d03f474089e896f4fcd6 Mon Sep 17 00:00:00 2001
From: Elizabeth Andrews 
Date: Thu, 26 Oct 2023 08:53:54 -0700
Subject: [PATCH 1/4] [Clang]  Fix linker error for function multiversioning
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Currently target_clones attribute results in a linker error when
there are no multi-versioned function declarations in the calling TU.

In the calling TU, the call is generated with the ‘normal’ assembly name.
This does not match any of the versions or the ifunc, since version mangling
includes a .versionstring, and the ifunc includes .ifunc suffix. The linker
error is not seen with GCC since the mangling for the ifunc symbol in GCC
is the ‘normal’ assembly name for function i.e. no ifunc suffix.

This PR removes the .ifunc suffix to match GCC. It also adds alias with
the .ifunc suffix so as to ensure backward compatibility.

The changes exclude aarch64 target because the mangling for default
versions on aarch64 does not include a .default suffix and is the
'normal' assembly name, unlike other targets. It is not clear to me
what the correct behavior for this target is.
---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/CodeGen/CodeGenModule.cpp  | 35 +---
 clang/test/CodeGen/attr-target-clones.c  | 33 +++---
 clang/test/CodeGenCXX/attr-target-clones.cpp | 27 +--
 4 files changed, 70 insertions(+), 26 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8bac599f88503..9e73fa03a0355 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -550,6 +550,7 @@ Bug Fixes in This Version
   Fixes (`#67687 `_)
 - Fix crash from constexpr evaluator evaluating uninitialized arrays as rvalue.
   Fixes (`#67317 `_)
+- Fix linker error when using multiversioned function defined in a different 
TU.
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 2e96fff808113..b54c4296a0f9d 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4098,8 +4098,26 @@ void CodeGenModule::emitMultiVersionFunctions() {
 }
 
 llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
-if (auto *IFunc = dyn_cast(ResolverConstant))
+if (auto *IFunc = dyn_cast(ResolverConstant)) {
   ResolverConstant = IFunc->getResolver();
+  // In Aarch64, default versions of multiversioned functions are mangled 
to
+  // their 'normal' assembly name. This deviates from other targets which
+  // append a '.default' string. As a result we need to continue appending
+  // .ifunc in Aarch64.
+  // FIXME: Should Aarch64 mangling for 'default' multiversion function and
+  // in turn ifunc function match that of other targets?
+  if (FD->isTargetClonesMultiVersion() &&
+  !getTarget().getTriple().isAArch64()) {
+const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
+llvm::FunctionType *DeclTy = getTypes().GetFunctionType(FI);
+std::string MangledName = getMangledNameImpl(
+*this, GD, FD, /*OmitMultiVersionMangling=*/true);
+auto *Alias = llvm::GlobalAlias::create(
+DeclTy, 0, llvm::Function::WeakODRLinkage, MangledName + ".ifunc",
+IFunc, &getModule());
+SetCommonAttributes(FD, Alias);
+  }
+}
 llvm::Function *ResolverFunc = cast(ResolverConstant);
 
 ResolverFunc->setLinkage(getMultiversionLinkage(*this, GD));
@@ -4266,10 +4284,19 @@ llvm::Constant 
*CodeGenModule::GetOrCreateMultiVersionResolver(GlobalDecl GD) {
   // Holds the name of the resolver, in ifunc mode this is the ifunc (which has
   // a separate resolver).
   std::string ResolverName = MangledName;
-  if (getTarget().supportsIFunc())
-ResolverName += ".ifunc";
-  else if (FD->isTargetMultiVersion())
+  if (getTarget().supportsIFunc()) {
+// In Aarch64, default versions of multiversioned functions are mangled to
+// their 'normal' assembly name. This deviates from other targets which
+// append a '.default' string. As a result we need to continue appending
+// .ifunc in Aarch64.
+// FIXME: Should Aarch64 mangling for 'default' multiversion function and
+// in turn ifunc function match that of other targets?
+if (!FD->isTargetClonesMultiVersion() ||
+getTarget().getTriple().isAArch64())
+  ResolverName += ".i

[libc] [flang] [clang-tools-extra] [llvm] [compiler-rt] [libcxx] [clang] [NFC][asan] Replace AsanInited/ENSURE_ASAN_INITED with TryAsanInitFromRtl (PR #74172)

2023-12-04 Thread Vitaly Buka via cfe-commits

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


[clang] [llvm] [clang-tools-extra] [AArch64][Clang] Fix linker error for function multiversioning (PR #74358)

2023-12-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Dani (DanielKristofKiss)


Changes

AArch64 part of https://github.com/llvm/llvm-project/pull/71706.

Default version is now mangled with .default.
Resolver for the TargetVersion need to be emitted from the
CodeGenModule::EmitMultiVersionFunctionDefinition.

---

Patch is 74.82 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74358.diff


9 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+6) 
- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+28-6) 
- (modified) clang/test/CodeGen/attr-target-clones-aarch64.c (+140-47) 
- (modified) clang/test/CodeGen/attr-target-clones.c (+22-12) 
- (modified) clang/test/CodeGen/attr-target-version.c (+395-154) 
- (modified) clang/test/CodeGenCXX/attr-target-clones-aarch64.cpp (+13-13) 
- (modified) clang/test/CodeGenCXX/attr-target-clones.cpp (+17-10) 
- (modified) clang/test/CodeGenCXX/attr-target-version.cpp (+98-70) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 43ea6a3ffd6e6..1d692a89f6287 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -648,6 +648,9 @@ Bug Fixes in This Version
 - Fixed false positive error emitted by clang when performing qualified name
   lookup and the current class instantiation has dependent bases.
   Fixes (`#13826 `_)
+- Fix the name of the ifunc symbol emitted for multiversion functions declared 
with the
+  ``target_clones`` attribute. This addresses a linker error that would 
otherwise occur
+  when these functions are referenced from other TUs.
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f2c4eb51b443d..35af8cee30e26 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2515,6 +2515,12 @@ example, the following will emit 4 versions of the 
function:
 __attribute__((target_clones("arch=atom,avx2","arch=ivybridge","default")))
 void foo() {}
 
+Dispatch is done via ``ifunc`` mechanism. The assembler name of the indirect
+function is the original assembler name of the multiversioned function. For
+backward compatibility, an alias to this function is currently generated
+with an ``.ifunc`` suffix. This symbol is deprecated and will be removed
+in the future.
+
 }];
 }
 
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index dea58a7ff4146..a71d6ba49f1bb 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1688,8 +1688,10 @@ static void AppendCPUSpecificCPUDispatchMangling(const 
CodeGenModule &CGM,
 static void AppendTargetVersionMangling(const CodeGenModule &CGM,
 const TargetVersionAttr *Attr,
 raw_ostream &Out) {
-  if (Attr->isDefaultVersion())
+  if (Attr->isDefaultVersion()) {
+Out << ".default";
 return;
+  }
   Out << "._";
   const TargetInfo &TI = CGM.getTarget();
   llvm::SmallVector Feats;
@@ -1752,8 +1754,10 @@ static void AppendTargetClonesMangling(const 
CodeGenModule &CGM,
   const TargetInfo &TI = CGM.getTarget();
   if (TI.getTriple().isAArch64()) {
 StringRef FeatureStr = Attr->getFeatureStr(VersionIndex);
-if (FeatureStr == "default")
+if (FeatureStr == "default") {
+  Out << ".default";
   return;
+}
 Out << "._";
 SmallVector Features;
 FeatureStr.split(Features, "+");
@@ -3999,6 +4003,8 @@ void 
CodeGenModule::EmitMultiVersionFunctionDefinition(GlobalDecl GD,
 EmitGlobalFunctionDefinition(GD.getWithMultiVersionIndex(I), nullptr);
 // Ensure that the resolver function is also emitted.
 GetOrCreateMultiVersionResolver(GD);
+  } else if (FD->hasAttr()) {
+GetOrCreateMultiVersionResolver(GD);
   } else
 EmitGlobalFunctionDefinition(GD, GV);
 }
@@ -4178,8 +4184,22 @@ void CodeGenModule::emitMultiVersionFunctions() {
 }
 
 llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
-if (auto *IFunc = dyn_cast(ResolverConstant))
+if (auto *IFunc = dyn_cast(ResolverConstant)) {
   ResolverConstant = IFunc->getResolver();
+  if (FD->isTargetClonesMultiVersion()) {
+const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
+llvm::FunctionType *DeclTy = getTypes().GetFunctionType(FI);
+std::string MangledName = getMangledNameImpl(
+*this, GD, FD, /*OmitMultiVersionMangling=*/true);
+// In prior versions of Clang, the mangling for ifuncs incorrectly
+// included an .ifunc suffix. This alias is generated for backward
+// compatibility and should be deprecated in the future.
+auto *Alias = llvm::GlobalAlias::create(
+

[clang] [libc] [flang] [llvm] [compiler-rt] [clang-tools-extra] [libcxx] [NFC][asan] Replace AsanInited/ENSURE_ASAN_INITED with TryAsanInitFromRtl (PR #74172)

2023-12-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/74172

>From 0d25d8cfc9de89a538a7ae3ae97ddc8a664a70d5 Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Fri, 1 Dec 2023 19:20:28 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
 =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/lib/asan/asan_interceptors.cpp | 36 --
 compiler-rt/lib/asan/asan_interceptors.h   |  9 ++
 compiler-rt/lib/asan/asan_internal.h   |  2 +-
 compiler-rt/lib/asan/asan_malloc_linux.cpp |  5 +--
 compiler-rt/lib/asan/asan_rtl.cpp  | 14 +++--
 5 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index e80f66142b7a2..a364b971bda8f 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -96,14 +96,16 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
   ASAN_WRITE_RANGE(ctx, ptr, size)
 #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
   ASAN_READ_RANGE(ctx, ptr, size)
-#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)\
-ASAN_INTERCEPTOR_ENTER(ctx, func);\
-do {  \
-  if (AsanInitIsRunning())\
-return REAL(func)(__VA_ARGS__);   \
-  if (SANITIZER_APPLE && UNLIKELY(!AsanInited())) \
-return REAL(func)(__VA_ARGS__);   \
-  ENSURE_ASAN_INITED();   \
+#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \
+ASAN_INTERCEPTOR_ENTER(ctx, func); \
+do {   \
+  if constexpr (SANITIZER_APPLE) { \
+if (UNLIKELY(!AsanInited()))   \
+  return REAL(func)(__VA_ARGS__);  \
+  } else { \
+if (!TryAsanInitFromRtl()) \
+  return REAL(func)(__VA_ARGS__);  \
+  }\
 } while (false)
 #define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
   do {\
@@ -534,16 +536,16 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, 
uptr size) {
 INTERCEPTOR(char *, strcpy, char *to, const char *from) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strcpy);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
-return REAL(strcpy)(to, from);
-#endif
-  // strcpy is called from malloc_default_purgeable_zone()
-  // in __asan::ReplaceSystemAlloc() on Mac.
-  if (AsanInitIsRunning()) {
-return REAL(strcpy)(to, from);
+  if constexpr (SANITIZER_APPLE) {
+// strcpy is called from malloc_default_purgeable_zone()
+// in __asan::ReplaceSystemAlloc() on Mac.
+if (UNLIKELY(!AsanInited()))
+  return REAL(strcpy)(to, from);
+  } else {
+if (!TryAsanInitFromRtl())
+  return REAL(strcpy)(to, from);
   }
-  ENSURE_ASAN_INITED();
+
   if (flags()->replace_str) {
 uptr from_size = internal_strlen(from) + 1;
 CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size);
diff --git a/compiler-rt/lib/asan/asan_interceptors.h 
b/compiler-rt/lib/asan/asan_interceptors.h
index e355c1258a9fe..6a7748c8f9bb9 100644
--- a/compiler-rt/lib/asan/asan_interceptors.h
+++ b/compiler-rt/lib/asan/asan_interceptors.h
@@ -24,12 +24,9 @@ namespace __asan {
 void InitializeAsanInterceptors();
 void InitializePlatformInterceptors();
 
-#define ENSURE_ASAN_INITED()   \
-  do { \
-CHECK(!AsanInitIsRunning());   \
-if (UNLIKELY(!AsanInited())) { \
-  AsanInitFromRtl();   \
-}  \
+#define ENSURE_ASAN_INITED() \
+  do {   \
+AsanInitFromRtl();   \
   } while (0)
 
 }  // namespace __asan
diff --git a/compiler-rt/lib/asan/asan_internal.h 
b/compiler-rt/lib/asan/asan_internal.h
index e2b1e9800f5be..5b97e77882cd6 100644
--- a/compiler-rt/lib/asan/asan_internal.h
+++ b/compiler-rt/lib/asan/asan_internal.h
@@ -60,6 +60,7 @@ class AsanThread;
 using __sanitizer::StackTrace;
 
 void AsanInitFromRtl();
+bool TryAsanInitFromRtl();
 
 // asan_win.cpp
 void InitializePlatformExceptionHandlers();
@@ -131,7 +132,6 @@ void InstallAtExitCheckLeaks();
   __asan_on_error()
 
 bool AsanInited();
-bool AsanInitIsRunning();  // Used to avoid infinite recursion in 
__asan_init().
 extern bool replace_intrin_cached;
 extern void (*death_callback)(void);
 // These magic values are written to shadow for better error
diff --git a/compiler-rt/lib/asan/asan_malloc_linux.cpp 
b/compiler-rt/lib/asan/asan_malloc_linux.cpp
index 0ba74c5d71432..eb29233c3cf82 100644
--- a/compiler-rt/lib/asan/asan_malloc_linux.cpp
+++ b/compiler-rt/lib

[llvm] [clang] [InstCombine] Infer disjoint flag on Or instructions. (PR #72912)

2023-12-04 Thread Nikita Popov via cfe-commits

nikic wrote:

> We don't have a `isGuaranteedNotToBeUndef` only function, so that's the only 
> way. I would leave a fixme, since this call can be removed if we ever manage 
> to kill undef.

I actually added this function earlier today.

> @nikic is something like this the right fix?

I'd move the calls to isGuaranteedNotToBeUndef into 
haveNoCommonBitsSetSpecialCases, so you can check the correct values.


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


[clang] [clang-tools-extra] [llvm] [AArch64][Clang] Fix linker error for function multiversioning (PR #74358)

2023-12-04 Thread Jon Roelofs via cfe-commits


@@ -4178,8 +4184,22 @@ void CodeGenModule::emitMultiVersionFunctions() {
 }
 
 llvm::Constant *ResolverConstant = GetOrCreateMultiVersionResolver(GD);
-if (auto *IFunc = dyn_cast(ResolverConstant))
+if (auto *IFunc = dyn_cast(ResolverConstant)) {
   ResolverConstant = IFunc->getResolver();
+  if (FD->isTargetClonesMultiVersion()) {
+const CGFunctionInfo &FI = getTypes().arrangeGlobalDeclaration(GD);
+llvm::FunctionType *DeclTy = getTypes().GetFunctionType(FI);
+std::string MangledName = getMangledNameImpl(
+*this, GD, FD, /*OmitMultiVersionMangling=*/true);
+// In prior versions of Clang, the mangling for ifuncs incorrectly
+// included an .ifunc suffix. This alias is generated for backward
+// compatibility and should be deprecated in the future.

jroelofs wrote:

```suggestion
// included an .ifunc suffix. This alias is generated for backward
// compatibility. It is deprecated, and may be removed in the future.
```

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


[clang] [clang] Improve bit-field in ref NTTP diagnostic (PR #71077)

2023-12-04 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

I want just note that it is probably not an improvement from the user's point 
of view, just a change of wording.

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


[clang] [clang-format] Fix a bug in `git-clang-format --binary` (PR #74293)

2023-12-04 Thread Björn Schäpers via cfe-commits

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


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


[clang] [clang-tools-extra] [clang][tidy] Ensure rewriter has the correct CWD (PR #67839)

2023-12-04 Thread Piotr Zegar via cfe-commits


@@ -227,6 +227,14 @@ class ErrorReporter {
   llvm::errs() << "Can't apply replacements for file " << File << "\n";
 }
   }
+
+  auto BuildDir = Context.getCurrentBuildDirectory();

PiotrZSL wrote:

I think you may need to do what is done in handleErrors method.
Simply remember old value, change new value to build directory, and after call 
to overwriteChangedFiles restore it.
By default getCurrentWorkingDirectory should return actually current working 
directory.

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


[clang] [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses. (PR #68618)

2023-12-04 Thread Yonggang Luo via cfe-commits

lygstate wrote:

ping for merge

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


[clang] [llvm] [clang] NFC: Deprecate `FileEntry::getName()` (PR #68157)

2023-12-04 Thread Jan Svoboda via cfe-commits

https://github.com/jansvoboda11 updated 
https://github.com/llvm/llvm-project/pull/68157

>From e3a96bef47d029e1109dcad51840bab672c7351c Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Tue, 3 Oct 2023 13:40:07 -0700
Subject: [PATCH 1/2] [clang] NFC: Deprecate `FileEntry::getName()`

---
 clang/include/clang/Basic/FileEntry.h | 1 +
 clang/unittests/Basic/FileManagerTest.cpp | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index bc65463735488..6351aeae92e2c 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -394,6 +394,7 @@ class FileEntry {
 
 public:
   ~FileEntry();
+  LLVM_DEPRECATED("Use FileEntryRef::getName() instead.", "")
   StringRef getName() const { return LastRef->getName(); }
 
   StringRef tryGetRealPathName() const { return RealPathName; }
diff --git a/clang/unittests/Basic/FileManagerTest.cpp 
b/clang/unittests/Basic/FileManagerTest.cpp
index bf30fabb7cd88..d32036d975ce9 100644
--- a/clang/unittests/Basic/FileManagerTest.cpp
+++ b/clang/unittests/Basic/FileManagerTest.cpp
@@ -284,7 +284,6 @@ TEST_F(FileManagerTest, 
getFileRefReturnsCorrectNameForDifferentStatPath) {
   ASSERT_FALSE(!F1Alias);
   ASSERT_FALSE(!F1Alias2);
   EXPECT_EQ("dir/f1.cpp", F1->getName());
-  EXPECT_EQ("dir/f1.cpp", F1->getFileEntry().getName());
   EXPECT_EQ("dir/f1.cpp", F1Alias->getName());
   EXPECT_EQ("dir/f1.cpp", F1Alias2->getName());
   EXPECT_EQ(&F1->getFileEntry(), &F1Alias->getFileEntry());
@@ -303,7 +302,6 @@ TEST_F(FileManagerTest, 
getFileRefReturnsCorrectNameForDifferentStatPath) {
   ASSERT_FALSE(!F2Alias);
   ASSERT_FALSE(!F2Alias2);
   EXPECT_EQ("dir/f2.cpp", F2->getName());
-  EXPECT_EQ("dir/f2.cpp", F2->getFileEntry().getName());
   EXPECT_EQ("dir/f2.cpp", F2Alias->getName());
   EXPECT_EQ("dir/f2.cpp", F2Alias2->getName());
   EXPECT_EQ(&F2->getFileEntry(), &F2Alias->getFileEntry());

>From d5f953f9f8880dd32ae21aa8cf3d0b30479b271c Mon Sep 17 00:00:00 2001
From: Jan Svoboda 
Date: Mon, 4 Dec 2023 11:55:07 -0800
Subject: [PATCH 2/2] [clang] Keep testing `getName()`, disable deprecation
 warnings

---
 clang/unittests/Basic/FileManagerTest.cpp |  6 ++
 llvm/include/llvm/Support/Compiler.h  | 19 +++
 2 files changed, 25 insertions(+)

diff --git a/clang/unittests/Basic/FileManagerTest.cpp 
b/clang/unittests/Basic/FileManagerTest.cpp
index d32036d975ce9..9de8b72bf5a78 100644
--- a/clang/unittests/Basic/FileManagerTest.cpp
+++ b/clang/unittests/Basic/FileManagerTest.cpp
@@ -284,6 +284,9 @@ TEST_F(FileManagerTest, 
getFileRefReturnsCorrectNameForDifferentStatPath) {
   ASSERT_FALSE(!F1Alias);
   ASSERT_FALSE(!F1Alias2);
   EXPECT_EQ("dir/f1.cpp", F1->getName());
+  LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_BEGIN
+  EXPECT_EQ("dir/f1.cpp", F1->getFileEntry().getName());
+  LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_END
   EXPECT_EQ("dir/f1.cpp", F1Alias->getName());
   EXPECT_EQ("dir/f1.cpp", F1Alias2->getName());
   EXPECT_EQ(&F1->getFileEntry(), &F1Alias->getFileEntry());
@@ -302,6 +305,9 @@ TEST_F(FileManagerTest, 
getFileRefReturnsCorrectNameForDifferentStatPath) {
   ASSERT_FALSE(!F2Alias);
   ASSERT_FALSE(!F2Alias2);
   EXPECT_EQ("dir/f2.cpp", F2->getName());
+  LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_BEGIN
+  EXPECT_EQ("dir/f2.cpp", F2->getFileEntry().getName());
+  LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_END
   EXPECT_EQ("dir/f2.cpp", F2Alias->getName());
   EXPECT_EQ("dir/f2.cpp", F2Alias2->getName());
   EXPECT_EQ(&F2->getFileEntry(), &F2Alias->getFileEntry());
diff --git a/llvm/include/llvm/Support/Compiler.h 
b/llvm/include/llvm/Support/Compiler.h
index 6b13952bb2f41..26a46a279e7b2 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -157,6 +157,25 @@
 #define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]]
 #endif
 
+// clang-format off
+#if defined(__clang__) || defined(__GNUC__)
+#define LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_BEGIN 
\
+  _Pragma("GCC diagnostic push")   
\
+  _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
+#define LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_END   
\
+  _Pragma("GCC diagnostic pop")
+#elif defined(_MSC_VER)
+#define LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_BEGIN 
\
+  _Pragma("warning(push)") 
\
+  _Pragma("warning(disable : 4996)")
+#define LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_END   
\
+  _Pragma("warning(pop)")
+#else
+#define LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_BEGIN
+#define LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_END
+#endif
+// clang-format on
+
 // Indicate that a non-static, non-const C++ member function reinitializes
 // the entire object to a known state, independent of the previous state of
 // the object.


[clang] [CUDA][Win32] Add `fma(long double,..)` to math forward declares. (PR #73756)

2023-12-04 Thread Evgeny Mankov via cfe-commits


@@ -70,6 +70,9 @@ __DEVICE__ double floor(double);
 __DEVICE__ float floor(float);
 __DEVICE__ double fma(double, double, double);
 __DEVICE__ float fma(float, float, float);
+#ifdef _MSC_VER
+__DEVICE__ long double fma(long double, long double, long double);

emankov wrote:

That's right, CUDA has provided `long double fma` since 10.2 but for `HOST` 
only:

```cpp
inline _LIBCUDACXX_INLINE_VISIBILITY long double fma(long double __lcpp_x, long 
double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return ::fmal(__lcpp_x, 
__lcpp_y, __lcpp_z);}
```

If a declaration of `device long double fma` is needed in order to parse it 
only and with disallowing its usage on GPU, then it is better to add it to 
`clang/lib/Headers/cuda_wrappers/cmath` under `_LIBCPP_STD_VER` and 
`_LIBCPP_HIDE_FROM_ABI`; and it would need a corresponding `GPU` test, of 
course.

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


[clang-tools-extra] [clang-tidy] add modernize-use-std-numbers (PR #66583)

2023-12-04 Thread Piotr Zegar via cfe-commits

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


[clang-tools-extra] [clang-tidy] add modernize-use-std-numbers (PR #66583)

2023-12-04 Thread Piotr Zegar via cfe-commits

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

LGTM, this should be merged so other llvm users could test it.
As check is complicated I expect that there can be some false-positives or 
issues reported when llvm 18 would release.

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


[clang-tools-extra] [clang-tidy] add modernize-use-std-numbers (PR #66583)

2023-12-04 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,58 @@
+.. title:: clang-tidy - modernize-use-std-numbers
+
+modernize-use-std-numbers
+=
+
+Finds constants and function calls to math functions that can be replaced
+with c++20's mathematical constants from the ``numbers`` header and offers
+fix-it hints.
+Does not match the use of variables with that value, and instead,
+offers a replacement at the definition of those variables.
+Function calls that match the pattern of how the constant is calculated are
+matched and replaced with the ``std::numbers`` constant.
+The use of macros gets replaced with the corresponding ``std::numbers``
+constant, instead of changing the macro definition.
+
+The following list of constants from the ``numbers`` header are supported:
+
+* e
+* log2e
+* log10e
+* pi
+* inv_pi
+* inv_sqrtpi
+* ln2
+* ln10
+* sqrt2
+* sqrt3
+* inv_sqrt3
+* egamma
+* phi
+
+The list currently includes all constants as of C++20.
+
+The replacements use the type of the matched constant and can remove explicit 
casts,
+i.e., switching between ``std::numbers::e``, ``std::numbers::e_v`` and 
``std::numbers::e_v``
+where appropriate.
+
+.. code-block:: c++
+
+double sqrt(double);
+double log2(double);
+void sink(auto&&) {}
+void floatSink(float);
+
+#define MY_PI 3.1415926
+
+void foo() {
+const double Pi = 3.141592653589;   // const double Pi = 
std::numbers::pi
+const auto Use = Pi / 2;// no match for Pi
+static constexpr double Euler = 2.7182818;  // static constexpr double 
Euler = std::numbers::e;
+
+log2(exp(1));   // std::numbers::log2e;
+log2(Euler);// std::numbers::log2e;
+1 / sqrt(MY_PI);// 
std::numbers::inv_sqrtpi;
+sink(MY_PI);// sink(std::numbers::pi);
+floatSink(MY_PI);   // 
floatSink(std::numbers::pi);
+floatSink(static_cast(MY_PI));   // 
floatSink(std::numbers::pi_v);
+}

PiotrZSL wrote:

Add documentation for check configuration: IncludeStyle and DiffThreshold

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


[clang] [analyzer] Switch to PostStmt callbacks in ArrayBoundV2 (PR #72107)

2023-12-04 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.

I wish we could clean up `checkLocation` to work as expected for all cases. It 
is more future proof in the sense that if C++ introduces new kinds of 
statements or expressions that could index into something (like 
multi-dimensional `operator[]`), checks continue to work without change after 
the analysis engine is updated. 

It is a higher-level abstraction that lets checker authors focus on the 
semantics without having to enumerate all the patterns the check might be 
interested in which is often impossible in C++, let alone considering all the 
extensions implemented by Clang. So, these high-level abstractions supposed to 
deduplicate a lot of work by doing all the pattern matching once and for all in 
the engine, so checkers could benefit from this work without duplicating some 
of that pattern matching in every checker.

All that being said, I understand that it is more practical to just work these 
engine problems around in this check for now as we do not have a volunteer to 
revamp `checkLocation` at the moment. I know @steakhal looked into it, but it 
turned out to be a bigger fish than we expected.  So, I'd say let's land this 
as a practical middle-term solution on the hope that we will be able to come 
back and clean this up at some point using something that is more future proof. 

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


[clang] [analyzer] Switch to PostStmt callbacks in ArrayBoundV2 (PR #72107)

2023-12-04 Thread Gábor Horváth via cfe-commits

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


[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

2023-12-04 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/74365

`-arch` is a Darwin-specific option that is ignored for other targets
and not known by GCC.
```
% clang -arch arm64 -c a.c
clang: warning: argument unused during compilation: '-arch arm64' 
[-Wunused-command-line-argument]
```

We are utilizing TargetSpecific (from https://reviews.llvm.org/D151590)
to make more options lead to errors for unsupported targets.


>From 8de8d31f941eda119456a0656856b0d22282acba Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Mon, 4 Dec 2023 12:16:36 -0800
Subject: [PATCH] [Driver] Mark -arch as TargetSpecific

`-arch` is a Darwin-specific option that is ignored for other targets
and not known by GCC.
```
% clang -arch arm64 -c a.c
clang: warning: argument unused during compilation: '-arch arm64' 
[-Wunused-command-line-argument]
```

We are utilizing TargetSpecific (from https://reviews.llvm.org/D151590)
to make more options lead to errors for unsupported targets.
---
 clang/include/clang/Driver/Options.td | 2 +-
 clang/test/Driver/arc-exceptions.m| 4 ++--
 clang/test/Driver/arm-arch-darwin.c   | 5 +++--
 clang/test/Frontend/darwin-eabi.c | 6 +++---
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1d04e4f6e7e6d..8c6d1f61ebcf2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -994,7 +994,7 @@ def all__load : Flag<["-"], "all_load">;
 def allowable__client : Separate<["-"], "allowable_client">;
 def ansi : Flag<["-", "--"], "ansi">, Group;
 def arch__errors__fatal : Flag<["-"], "arch_errors_fatal">;
-def arch : Separate<["-"], "arch">, Flags<[NoXarchOption]>;
+def arch : Separate<["-"], "arch">, Flags<[NoXarchOption,TargetSpecific]>;
 def arch__only : Separate<["-"], "arch_only">;
 def autocomplete : Joined<["--"], "autocomplete=">;
 def bind__at__load : Flag<["-"], "bind_at_load">;
diff --git a/clang/test/Driver/arc-exceptions.m 
b/clang/test/Driver/arc-exceptions.m
index 4501ccd073823..c1dd02d59988c 100644
--- a/clang/test/Driver/arc-exceptions.m
+++ b/clang/test/Driver/arc-exceptions.m
@@ -1,5 +1,5 @@
-// RUN: %clang -### -x objective-c -arch x86_64 -fobjc-arc -fsyntax-only %s 2> 
%t.log
+// RUN: %clang -### -x objective-c --target=x86_64-apple-macos10.6 -fobjc-arc 
-fsyntax-only %s 2> %t.log
 // RUN: grep objective-c %t.log
 // RUN: not grep "fobjc-arc-exceptions" %t.log
-// RUN: %clang -### -x objective-c++ -arch x86_64 -fobjc-arc -fsyntax-only %s 
2> %t.log
+// RUN: %clang -### -x objective-c++ --target=x86_64-apple-macos10.6 
-fobjc-arc -fsyntax-only %s 2> %t.log
 // RUN: grep "fobjc-arc-exceptions" %t.log
diff --git a/clang/test/Driver/arm-arch-darwin.c 
b/clang/test/Driver/arm-arch-darwin.c
index 55089619d1e71..c523622964738 100644
--- a/clang/test/Driver/arm-arch-darwin.c
+++ b/clang/test/Driver/arm-arch-darwin.c
@@ -1,6 +1,7 @@
 // On Darwin, arch should override CPU for triple purposes
 // RUN: %clang -target armv7m-apple-darwin -arch armv7m -mcpu=cortex-m4 -### 
-c %s 2>&1 | FileCheck -check-prefix=CHECK-V7M-DARWIN %s
 // CHECK-V7M-DARWIN: "-cc1"{{.*}} "-triple" "thumbv7m-{{.*}} "-target-cpu" 
"cortex-m4"
-// RUN: %clang -target armv7m -arch armv7m -mcpu=cortex-m4 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V7M-OVERRIDDEN %s
-// CHECK-V7M-OVERRIDDEN: "-cc1"{{.*}} "-triple" "thumbv7em-{{.*}} 
"-target-cpu" "cortex-m4"
 
+/// -arch is unsupported for non-Darwin targets.
+// RUN: not %clang --target=armv7m -arch armv7m -mcpu=cortex-m4 -### -c %s 
2>&1 | FileCheck -check-prefix=ERR %s
+// ERR: unsupported option '-arch' for target 'armv7m'
diff --git a/clang/test/Frontend/darwin-eabi.c 
b/clang/test/Frontend/darwin-eabi.c
index 27471e6cfb0e6..9d62632891cbe 100644
--- a/clang/test/Frontend/darwin-eabi.c
+++ b/clang/test/Frontend/darwin-eabi.c
@@ -1,6 +1,6 @@
-// RUN: %clang -arch armv6m -dM -E %s | FileCheck %s
-// RUN: %clang -arch armv7m -dM -E %s | FileCheck %s
-// RUN: %clang -arch armv7em -dM -E %s | FileCheck %s
+// RUN: %clang --target=armv6m-apple-darwin -dM -E %s | FileCheck %s
+// RUN: %clang --target=armv7m-apple-darwin -dM -E %s | FileCheck %s
+// RUN: %clang --target=armv7em-apple-darwin -dM -E %s | FileCheck %s
 // RUN: %clang_cc1 -triple thumbv7m-apple-unknown-macho -dM -E %s | FileCheck 
%s
 
 // CHECK-NOT: __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__

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


[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

2023-12-04 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Fangrui Song (MaskRay)


Changes

`-arch` is a Darwin-specific option that is ignored for other targets
and not known by GCC.
```
% clang -arch arm64 -c a.c
clang: warning: argument unused during compilation: '-arch arm64' 
[-Wunused-command-line-argument]
```

We are utilizing TargetSpecific (from https://reviews.llvm.org/D151590)
to make more options lead to errors for unsupported targets.


---
Full diff: https://github.com/llvm/llvm-project/pull/74365.diff


4 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+1-1) 
- (modified) clang/test/Driver/arc-exceptions.m (+2-2) 
- (modified) clang/test/Driver/arm-arch-darwin.c (+3-2) 
- (modified) clang/test/Frontend/darwin-eabi.c (+3-3) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1d04e4f6e7e6d..8c6d1f61ebcf2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -994,7 +994,7 @@ def all__load : Flag<["-"], "all_load">;
 def allowable__client : Separate<["-"], "allowable_client">;
 def ansi : Flag<["-", "--"], "ansi">, Group;
 def arch__errors__fatal : Flag<["-"], "arch_errors_fatal">;
-def arch : Separate<["-"], "arch">, Flags<[NoXarchOption]>;
+def arch : Separate<["-"], "arch">, Flags<[NoXarchOption,TargetSpecific]>;
 def arch__only : Separate<["-"], "arch_only">;
 def autocomplete : Joined<["--"], "autocomplete=">;
 def bind__at__load : Flag<["-"], "bind_at_load">;
diff --git a/clang/test/Driver/arc-exceptions.m 
b/clang/test/Driver/arc-exceptions.m
index 4501ccd073823..c1dd02d59988c 100644
--- a/clang/test/Driver/arc-exceptions.m
+++ b/clang/test/Driver/arc-exceptions.m
@@ -1,5 +1,5 @@
-// RUN: %clang -### -x objective-c -arch x86_64 -fobjc-arc -fsyntax-only %s 2> 
%t.log
+// RUN: %clang -### -x objective-c --target=x86_64-apple-macos10.6 -fobjc-arc 
-fsyntax-only %s 2> %t.log
 // RUN: grep objective-c %t.log
 // RUN: not grep "fobjc-arc-exceptions" %t.log
-// RUN: %clang -### -x objective-c++ -arch x86_64 -fobjc-arc -fsyntax-only %s 
2> %t.log
+// RUN: %clang -### -x objective-c++ --target=x86_64-apple-macos10.6 
-fobjc-arc -fsyntax-only %s 2> %t.log
 // RUN: grep "fobjc-arc-exceptions" %t.log
diff --git a/clang/test/Driver/arm-arch-darwin.c 
b/clang/test/Driver/arm-arch-darwin.c
index 55089619d1e71..c523622964738 100644
--- a/clang/test/Driver/arm-arch-darwin.c
+++ b/clang/test/Driver/arm-arch-darwin.c
@@ -1,6 +1,7 @@
 // On Darwin, arch should override CPU for triple purposes
 // RUN: %clang -target armv7m-apple-darwin -arch armv7m -mcpu=cortex-m4 -### 
-c %s 2>&1 | FileCheck -check-prefix=CHECK-V7M-DARWIN %s
 // CHECK-V7M-DARWIN: "-cc1"{{.*}} "-triple" "thumbv7m-{{.*}} "-target-cpu" 
"cortex-m4"
-// RUN: %clang -target armv7m -arch armv7m -mcpu=cortex-m4 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-V7M-OVERRIDDEN %s
-// CHECK-V7M-OVERRIDDEN: "-cc1"{{.*}} "-triple" "thumbv7em-{{.*}} 
"-target-cpu" "cortex-m4"
 
+/// -arch is unsupported for non-Darwin targets.
+// RUN: not %clang --target=armv7m -arch armv7m -mcpu=cortex-m4 -### -c %s 
2>&1 | FileCheck -check-prefix=ERR %s
+// ERR: unsupported option '-arch' for target 'armv7m'
diff --git a/clang/test/Frontend/darwin-eabi.c 
b/clang/test/Frontend/darwin-eabi.c
index 27471e6cfb0e6..9d62632891cbe 100644
--- a/clang/test/Frontend/darwin-eabi.c
+++ b/clang/test/Frontend/darwin-eabi.c
@@ -1,6 +1,6 @@
-// RUN: %clang -arch armv6m -dM -E %s | FileCheck %s
-// RUN: %clang -arch armv7m -dM -E %s | FileCheck %s
-// RUN: %clang -arch armv7em -dM -E %s | FileCheck %s
+// RUN: %clang --target=armv6m-apple-darwin -dM -E %s | FileCheck %s
+// RUN: %clang --target=armv7m-apple-darwin -dM -E %s | FileCheck %s
+// RUN: %clang --target=armv7em-apple-darwin -dM -E %s | FileCheck %s
 // RUN: %clang_cc1 -triple thumbv7m-apple-unknown-macho -dM -E %s | FileCheck 
%s
 
 // CHECK-NOT: __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__

``




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


[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

2023-12-04 Thread Jon Roelofs via cfe-commits

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


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


[clang] [clang] Enhance handling of Apple-specific '-arch'/'-target' option values (PR #72821)

2023-12-04 Thread Fangrui Song via cfe-commits

MaskRay wrote:

`-arch ` is also related to universal binary that many other targets don't 
support (and they likely don't endorse such an approach). For ELF we should 
definitely encourage `--target=` for cross compilation. (`-target ` has been 
deprecated since Clang 3.2). Picking a default version for macOS is quite odd 
as well.

I think we should reject `-arch ` like many other target-specific options. 
https://maskray.me/blog/2023-08-25-clang-wunused-command-line-argument

Created https://github.com/llvm/llvm-project/pull/74365

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


[clang-tools-extra] [clang-tidy] add modernize-use-std-numbers (PR #66583)

2023-12-04 Thread Julian Schmidt via cfe-commits


@@ -0,0 +1,58 @@
+.. title:: clang-tidy - modernize-use-std-numbers
+
+modernize-use-std-numbers
+=
+
+Finds constants and function calls to math functions that can be replaced
+with c++20's mathematical constants from the ``numbers`` header and offers
+fix-it hints.
+Does not match the use of variables with that value, and instead,
+offers a replacement at the definition of those variables.
+Function calls that match the pattern of how the constant is calculated are
+matched and replaced with the ``std::numbers`` constant.
+The use of macros gets replaced with the corresponding ``std::numbers``
+constant, instead of changing the macro definition.
+
+The following list of constants from the ``numbers`` header are supported:
+
+* e
+* log2e
+* log10e
+* pi
+* inv_pi
+* inv_sqrtpi
+* ln2
+* ln10
+* sqrt2
+* sqrt3
+* inv_sqrt3
+* egamma
+* phi
+
+The list currently includes all constants as of C++20.
+
+The replacements use the type of the matched constant and can remove explicit 
casts,
+i.e., switching between ``std::numbers::e``, ``std::numbers::e_v`` and 
``std::numbers::e_v``
+where appropriate.
+
+.. code-block:: c++
+
+double sqrt(double);
+double log2(double);
+void sink(auto&&) {}
+void floatSink(float);
+
+#define MY_PI 3.1415926
+
+void foo() {
+const double Pi = 3.141592653589;   // const double Pi = 
std::numbers::pi
+const auto Use = Pi / 2;// no match for Pi
+static constexpr double Euler = 2.7182818;  // static constexpr double 
Euler = std::numbers::e;
+
+log2(exp(1));   // std::numbers::log2e;
+log2(Euler);// std::numbers::log2e;
+1 / sqrt(MY_PI);// 
std::numbers::inv_sqrtpi;
+sink(MY_PI);// sink(std::numbers::pi);
+floatSink(MY_PI);   // 
floatSink(std::numbers::pi);
+floatSink(static_cast(MY_PI));   // 
floatSink(std::numbers::pi_v);
+}

5chmidti wrote:

Done

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


[clang-tools-extra] [clang-tidy] add modernize-use-std-numbers (PR #66583)

2023-12-04 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

Force push to resolve conflicts

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


[clang-tools-extra] [clang-tidy] add modernize-use-std-numbers (PR #66583)

2023-12-04 Thread Julian Schmidt via cfe-commits

5chmidti wrote:

I fetched from the wrong remote. Conflicts are resolved. The options docs were 
added in 284fa1b94ef72c29f13a2ec50ca76b429c842b0c

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


[clang] [clang] Enhance handling of Apple-specific '-arch'/'-target' option values (PR #72821)

2023-12-04 Thread James Y Knight via cfe-commits

jyknight wrote:

I don't think this is a good idea.

Not only is that weird to magically switch to an apple build from a non-apple 
platform, this is also not even a particularly useful behavior for an Apple 
platform, where "darwin" is basically deprecated, and you're supposed to use a 
target of x86_64-apple-macos11 (or ios/watchos/etc).

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


[clang] [clang] Improve bit-field in ref NTTP diagnostic (PR #71077)

2023-12-04 Thread Andrey Ali Khan Bolshakov via cfe-commits

https://github.com/bolshakov-a updated 
https://github.com/llvm/llvm-project/pull/71077

>From e5ad8f5b00a297ef745e1b9341df32b80a7c6b77 Mon Sep 17 00:00:00 2001
From: Bolshakov 
Date: Thu, 2 Nov 2023 19:20:27 +0300
Subject: [PATCH] [clang] Improve bit-field in ref NTTP diagnostic

Prior to this, attempts to bind a bit-field to an NTTP of reference type
produced an error because references to subobjects in NTTPs are
disallowed. But C++20 allows references to subobjects in NTTPs generally
(see P1907R1). Without this change, implementing P1907R1 would cause
a bug allowing bit-fields to be bound to reference template arguments.

Extracted from https://reviews.llvm.org/D140996
---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/include/clang/Basic/DiagnosticSemaKinds.td   |  2 ++
 clang/lib/Sema/SemaOverload.cpp| 10 ++
 clang/test/CXX/drs/dr12xx.cpp  |  2 +-
 clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp |  6 ++
 5 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c7a948fd3fae5..01a927b2bc17e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -503,6 +503,8 @@ Improvements to Clang's diagnostics
48 | static_assert(1 << 4 == 15);
   |   ~~~^
 
+- Clang now diagnoses attempts to bind a bitfield to an NTTP of a reference 
type as erroneous
+  converted constant expression and not as a reference to subobject.
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6dfb2d7195203..b95d2bea00a5e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2251,6 +2251,8 @@ def warn_cxx17_compat_aggregate_init_paren_list : Warning<
 def err_reference_bind_to_bitfield : Error<
   "%select{non-const|volatile}0 reference cannot bind to "
   "bit-field%select{| %1}2">;
+def err_reference_bind_to_bitfield_in_cce : Error<
+  "reference cannot bind to bit-field in converted constant expression">;
 def err_reference_bind_to_vector_element : Error<
   "%select{non-const|volatile}0 reference cannot bind to vector element">;
 def err_reference_bind_to_matrix_element : Error<
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5026e1d603e5e..ebbd4f48b57f8 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6056,6 +6056,16 @@ static ExprResult BuildConvertedConstantExpression(Sema 
&S, Expr *From,
   diag::err_typecheck_converted_constant_expression_indirect)
<< From->getType() << From->getSourceRange() << T;
   }
+  // 'TryCopyInitialization' returns incorrect info for attempts to bind
+  // a reference to a bit-field due to C++ [over.ics.ref]p4. Namely,
+  // 'SCS->DirectBinding' occurs to be set to 'true' despite it is not
+  // the direct binding according to C++ [dcl.init.ref]p5. Hence, check this
+  // case explicitly.
+  if (From->refersToBitField() && T.getTypePtr()->isReferenceType()) {
+return S.Diag(From->getBeginLoc(),
+  diag::err_reference_bind_to_bitfield_in_cce)
+   << From->getSourceRange();
+  }
 
   // Usually we can simply apply the ImplicitConversionSequence we formed
   // earlier, but that's not guaranteed to work when initializing an object of
diff --git a/clang/test/CXX/drs/dr12xx.cpp b/clang/test/CXX/drs/dr12xx.cpp
index c23a515ba56cb..81c113d4c1c5a 100644
--- a/clang/test/CXX/drs/dr12xx.cpp
+++ b/clang/test/CXX/drs/dr12xx.cpp
@@ -138,7 +138,7 @@ namespace dr1295 { // dr1295: 4
 #if __cplusplus <= 201402L
   // expected-error@-2 {{does not refer to any declaration}} expected-note@-3 
{{here}}
 #else
-  // expected-error@-4 {{refers to subobject}}
+  // expected-error@-4 {{reference cannot bind to bit-field in converted 
constant expression}}
 #endif
 
 #if __cplusplus >= 201103L
diff --git a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp 
b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
index 792dc78464b2a..982f6ec221570 100644
--- a/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
+++ b/clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp
@@ -93,6 +93,12 @@ namespace ConvertedConstant {
   template  struct X {};
   void f(X<1.0f>) {}
   void g(X<2>) {}
+
+  struct {
+int i : 2;
+  } b;
+  template  struct Y {};
+  void f(Y) {} // expected-error {{reference cannot bind to bit-field in 
converted constant expression}}
 }
 
 namespace CopyCounting {

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


[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

2023-12-04 Thread James Y Knight via cfe-commits

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


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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/74006

>From a6ea5e2da353ba006083082976065c9a8a988cbc Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 6 Nov 2023 14:22:02 -0800
Subject: [PATCH 1/2] [clang][modules] Reset codegen options.

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with `-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  87 +--
 clang/include/clang/Basic/CodeGenOptions.h|   4 +
 clang/include/clang/Basic/DebugOptions.def| 146 ++
 clang/include/module.modulemap|   1 +
 clang/lib/Basic/CodeGenOptions.cpp|  35 +
 clang/lib/Frontend/CompilerInvocation.cpp |  14 +-
 clang/test/ClangScanDeps/strip-codegen-args.m |  58 +++
 7 files changed, 259 insertions(+), 86 deletions(-)
 create mode 100644 clang/include/clang/Basic/DebugOptions.def
 create mode 100644 clang/test/ClangScanDeps/strip-codegen-args.m

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed..506db4068f490 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -178,8 +164,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
-   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -187,8 +171,6 @@ CODEGENOPT(NoWarn 

[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits


@@ -515,6 +430,8 @@ ENUM_CODEGENOPT(ZeroCallUsedRegs, 
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind,
 /// non-deleting destructors. (No effect on Microsoft ABI.)
 CODEGENOPT(CtorDtorReturnThis, 1, 0)
 
+#include "DebugOptions.def"

ributzka wrote:

I added the FIXME.

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits


@@ -4770,9 +4770,20 @@ std::string CompilerInvocation::getModuleHash() const {
 
   // When compiling with -gmodules, also hash -fdebug-prefix-map as it
   // affects the debug info in the PCM.
-  if (getCodeGenOpts().DebugTypeExtRefs)
+  if (getHeaderSearchOpts().ModuleFormat == "obj") {

ributzka wrote:

I reverted this particular change, to preserve existing behavior. I created a 
separate if condition for my changes after this code.

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


[clang] e77bfaa - [clang][NFC] Fill in historical data on when C++ DRs 500-599 were fixed

2023-12-04 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2023-12-05T00:42:13+03:00
New Revision: e77bfaaf9d66748fc2dc3a710a0c9b4665dd3034

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

LOG: [clang][NFC] Fill in historical data on when C++ DRs 500-599 were fixed

Added: 


Modified: 
clang/test/CXX/drs/dr5xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index a3563481eac68..204d07f04f4e5 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -381,7 +381,7 @@ namespace dr532 { // dr532: 3.5
 
 // dr533: na
 
-namespace dr534 { // dr534: yes
+namespace dr534 { // dr534: 2.9
   struct S {};
   template void operator+(S, T);
   template void operator+(S, T*) {} // expected-error 
{{function template partial spec}}
@@ -511,7 +511,7 @@ namespace dr542 { // dr542: yes
 #endif
 }
 
-namespace dr543 { // dr543: yes
+namespace dr543 { // dr543: 3.0
   // In C++98+DR543, this is valid because value-initialization doesn't call a
   // trivial default constructor, so we never notice that defining the
   // constructor would be ill-formed.
@@ -544,7 +544,7 @@ namespace dr546 { // dr546: yes
   template void A::f() { T::error; }
 }
 
-namespace dr547 { // dr547: yes
+namespace dr547 { // dr547: 3.2
   template struct X;
   template struct X {};
   template X f(T C::*) { return X(); }
@@ -607,7 +607,7 @@ namespace dr553 {
 // dr554: na
 // dr556: na
 
-namespace dr557 { // dr557: yes
+namespace dr557 { // dr557: 3.1
   template struct S {
 friend void f(S *);
 friend void g(S > *);
@@ -618,7 +618,7 @@ namespace dr557 { // dr557: yes
   }
 }
 
-namespace dr558 { // dr558: yes
+namespace dr558 { // dr558: 2.9
   wchar_t a = L'\uD7FF';
   wchar_t b = L'\xD7FF';
   wchar_t c = L'\uD800'; // expected-error {{invalid universal character}}
@@ -674,7 +674,7 @@ namespace dr566 { // dr566: yes
 
 // dr567: na
 
-namespace dr568 { // dr568: yes c++11
+namespace dr568 { // dr568: 3.0 c++11
   // FIXME: This is a DR issue against C++98, so should probably apply there
   // too.
   struct x { int y; };
@@ -762,7 +762,7 @@ namespace dr573 { // dr573: no
   template struct T;
 }
 
-namespace dr574 { // dr574: yes
+namespace dr574 { // dr574: 3.0
   struct A {
 A &operator=(const A&) const; // expected-note {{
diff erent qualifiers}}
   };
@@ -827,13 +827,13 @@ namespace dr575 { // dr575: yes
   void *p = h((void*)0);
 }
 
-namespace dr576 { // dr576: yes
+namespace dr576 { // dr576: 3.5
   typedef void f() {} // expected-error {{function definition declared 
'typedef'}}
   void f(typedef int n); // expected-error {{invalid storage class}}
   void f(char c) { typedef int n; }
 }
 
-namespace dr577 { // dr577: yes
+namespace dr577 { // dr577: 3.5
   typedef void V;
   typedef const void CV;
   void a(void);
@@ -910,7 +910,7 @@ namespace dr583 { // dr583: 4
 
 // dr584: na
 
-namespace dr585 { // dr585: yes
+namespace dr585 { // dr585: 3.0
   template struct T;
   struct A {
 friend T;
@@ -938,7 +938,7 @@ namespace dr585 { // dr585: yes
 
 // dr586: na
 
-namespace dr587 { // dr587: yes
+namespace dr587 { // dr587: 3.2
   template void f(bool b, const T x, T y) {
 const T *p = &(b ? x : y);
   }

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 4d918224ded46..0d315a82eeaba 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -3243,7 +3243,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/534.html";>534
 CD1
 template-names and operator-function-ids
-Yes
+Clang 2.9
   
   
 https://cplusplus.github.io/CWG/issues/535.html";>535
@@ -3299,7 +3299,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/543.html";>543
 CD1
 Value initialization and default constructors
-Yes
+Clang 3.0
   
   
 https://cplusplus.github.io/CWG/issues/544.html";>544
@@ -3323,7 +3323,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/547.html";>547
 C++11
 Partial specialization on member function types
-Yes
+Clang 3.2
   
   
 https://cplusplus.github.io/CWG/issues/548.html";>548
@@ -3383,13 +3383,13 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/557.html";>557
 CD1
 Does argument-dependent lookup cause template instantiation?
-Yes
+Clang 3.1
   
   
 https://cplusplus.github.io/CWG/issues/558.html";>558
 CD1
 Excluded characters in universal character names
-Yes
+Clang 2.9
   
   
 https://cplusplus.github.io/CWG/issues/559.html";>559
@@ -3449,7 +3449,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/

[clang] [clang][NFC] Refactor expected directives in C++ DRs 500-599 (PR #74373)

2023-12-04 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/74373

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.

>From 1e5ede1925b8cfdae93415abfddb930aaaf3241e Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 5 Dec 2023 00:37:51 +0300
Subject: [PATCH]  [clang][NFC] Refactor expected directives in C++ DRs 500-599

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.
---
 clang/test/CXX/drs/dr5xx.cpp | 595 +--
 1 file changed, 361 insertions(+), 234 deletions(-)

diff --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index 204d07f04f4e5..21a6646d4abcf 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -1,20 +1,21 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++98 %s 
-verify=expected,cxx98-11,cxx98-14,cxx98-17,cxx98 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s 
-verify=expected,cxx98-11,cxx98-14,cxx98-17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s 
-verify=expected,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s 
-verify=expected,since-cxx17,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s 
-verify=expected,since-cxx20,since-cxx17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 %s 
-verify=expected,since-cxx23,since-cxx20,since-cxx17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
 // with -verify.
 __extension__ typedef __SIZE_TYPE__ size_t;
-void *operator new(size_t); // expected-error 0-1{{missing exception spec}} 
expected-note{{candidate}}
+void *operator new(size_t); // #dr5xx-global-operator-new
+// cxx98-error@-1 {{'operator new' is missing exception specification 
'throw(std::bad_alloc)'}}
 #if __cplusplus > 201402L
 namespace std {
   enum class align_val_t : size_t {};
 }
-void *operator new(size_t, std::align_val_t); // expected-note{{candidate}}
+void *operator new(size_t, std::align_val_t); // 
#dr5xx-global-operator-new-aligned
 #endif
 
 namespace dr500 { // dr500: dup 372
@@ -33,7 +34,8 @@ namespace dr501 { // dr501: yes
   struct A {
 friend void f() {}
 void g() {
-  void (*p)() = &f; // expected-error {{undeclared identifier}}
+  void (*p)() = &f;
+  // expected-error@-1 {{use of undeclared identifier 'f'}}
 }
   };
 }
@@ -45,7 +47,8 @@ namespace dr502 { // dr502: yes
 void q1() { f(e); }
 void q2() { Q arr[sizeof(E)]; f(arr); }
 void q3() { Q arr[e]; f(arr); }
-void sanity() { Q arr[1]; f(arr); } // expected-error {{undeclared 
identifier 'f'}}
+void sanity() { Q arr[1]; f(arr); }
+// expected-error@-1 {{use of undeclared identifier 'f'}}
   };
   int f(A::E);
   template int f(Q (&)[N]);
@@ -53,14 +56,22 @@ namespace dr502 { // dr502: yes
 }
 
 namespace dr505 { // dr505: yes
-  const char *exts = "\e\(\{\[\%"; // expected-error 5{{use of non-standard 
escape}}
-  const char *unknown = "\Q"; // expected-error {{unknown escape sequence}}
+  const char *exts = "\e\(\{\[\%";
+  // expected-error@-1 {{use of non-standard escape character '\e'}}
+  // expected-error@-2 {{use of non-standard escape character '\('}}
+  // expected-error@-3 {{use of non-standard escape character '\{'}}
+  // expected-error@-4 {{use of non-standard escape character '\['}}
+  // expected-error@-5 {{use of non-standard escape character '\%'}}
+  const char *unknown = "\Q";
+  // expected-error@-1 {{unknown escape sequence '\Q'}}
 }
 
 namespace dr506 { // dr506: yes
   struct NonPod { ~NonPod(); };
   void f(...);
-  void g(NonPod np) { f(np); } // expected-error {{cannot pass}}
+  void g(NonPod np) { f(np); }
+  // cxx98-error@-1 {{cannot pass object of non-POD type 'NonPod' through 
variadic function; call will abort at runtime}}
+  // since-cxx11-error@-2 {{cannot pass object of non-trivial type 'NonPod' 
through variadic function; call will abort at runtime}}
 }
 
 // FIXME: Add tests here once DR260 is resolved.
@@ -71,15 +82,13 @@ namespace dr506 { // dr

[clang] [clang][NFC] Refactor expected directives in C++ DRs 500-599 (PR #74373)

2023-12-04 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

This PR is created to check the patch against CI.

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


[clang] [clang][NFC] Refactor expected directives in C++ DRs 500-599 (PR #74373)

2023-12-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch continues the work started with 
ea5b1ef016d020c37f903d6c7d4f623be975dab8. See that commit and its corresponding 
PR for details.

---

Patch is 47.59 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74373.diff


1 Files Affected:

- (modified) clang/test/CXX/drs/dr5xx.cpp (+361-234) 


``diff
diff --git a/clang/test/CXX/drs/dr5xx.cpp b/clang/test/CXX/drs/dr5xx.cpp
index 204d07f04f4e5..21a6646d4abcf 100644
--- a/clang/test/CXX/drs/dr5xx.cpp
+++ b/clang/test/CXX/drs/dr5xx.cpp
@@ -1,20 +1,21 @@
-// RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++23 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++98 %s 
-verify=expected,cxx98-11,cxx98-14,cxx98-17,cxx98 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++11 %s 
-verify=expected,cxx98-11,cxx98-14,cxx98-17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 %s 
-verify=expected,cxx98-14,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s 
-verify=expected,since-cxx17,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s 
-verify=expected,since-cxx20,since-cxx17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 %s 
-verify=expected,since-cxx23,since-cxx20,since-cxx17,since-cxx11 -fexceptions 
-fcxx-exceptions -pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
 // with -verify.
 __extension__ typedef __SIZE_TYPE__ size_t;
-void *operator new(size_t); // expected-error 0-1{{missing exception spec}} 
expected-note{{candidate}}
+void *operator new(size_t); // #dr5xx-global-operator-new
+// cxx98-error@-1 {{'operator new' is missing exception specification 
'throw(std::bad_alloc)'}}
 #if __cplusplus > 201402L
 namespace std {
   enum class align_val_t : size_t {};
 }
-void *operator new(size_t, std::align_val_t); // expected-note{{candidate}}
+void *operator new(size_t, std::align_val_t); // 
#dr5xx-global-operator-new-aligned
 #endif
 
 namespace dr500 { // dr500: dup 372
@@ -33,7 +34,8 @@ namespace dr501 { // dr501: yes
   struct A {
 friend void f() {}
 void g() {
-  void (*p)() = &f; // expected-error {{undeclared identifier}}
+  void (*p)() = &f;
+  // expected-error@-1 {{use of undeclared identifier 'f'}}
 }
   };
 }
@@ -45,7 +47,8 @@ namespace dr502 { // dr502: yes
 void q1() { f(e); }
 void q2() { Q arr[sizeof(E)]; f(arr); }
 void q3() { Q arr[e]; f(arr); }
-void sanity() { Q arr[1]; f(arr); } // expected-error {{undeclared 
identifier 'f'}}
+void sanity() { Q arr[1]; f(arr); }
+// expected-error@-1 {{use of undeclared identifier 'f'}}
   };
   int f(A::E);
   template int f(Q (&)[N]);
@@ -53,14 +56,22 @@ namespace dr502 { // dr502: yes
 }
 
 namespace dr505 { // dr505: yes
-  const char *exts = "\e\(\{\[\%"; // expected-error 5{{use of non-standard 
escape}}
-  const char *unknown = "\Q"; // expected-error {{unknown escape sequence}}
+  const char *exts = "\e\(\{\[\%";
+  // expected-error@-1 {{use of non-standard escape character '\e'}}
+  // expected-error@-2 {{use of non-standard escape character '\('}}
+  // expected-error@-3 {{use of non-standard escape character '\{'}}
+  // expected-error@-4 {{use of non-standard escape character '\['}}
+  // expected-error@-5 {{use of non-standard escape character '\%'}}
+  const char *unknown = "\Q";
+  // expected-error@-1 {{unknown escape sequence '\Q'}}
 }
 
 namespace dr506 { // dr506: yes
   struct NonPod { ~NonPod(); };
   void f(...);
-  void g(NonPod np) { f(np); } // expected-error {{cannot pass}}
+  void g(NonPod np) { f(np); }
+  // cxx98-error@-1 {{cannot pass object of non-POD type 'NonPod' through 
variadic function; call will abort at runtime}}
+  // since-cxx11-error@-2 {{cannot pass object of non-trivial type 'NonPod' 
through variadic function; call will abort at runtime}}
 }
 
 // FIXME: Add tests here once DR260 is resolved.
@@ -71,15 +82,13 @@ namespace dr506 { // dr506: yes
 // dr510: na
 
 namespace dr512 { // dr512: yes
-  struct A {
-A(int);
+  struct A { // #dr512-A
+A(int); // #dr512-A-ctor
   };
   union U { A a; };
-#if __cplusplus < 201103L
-  // expected-error@-2 {{has a non-trivial default constructor}}

[clang] 78940a4 - [clang-format] Fix a bug in `git-clang-format --binary` (#74293)

2023-12-04 Thread via cfe-commits

Author: Owen Pan
Date: 2023-12-04T13:49:23-08:00
New Revision: 78940a4e1f7f484d8a2dd0c646e288d6a5bf2f81

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

LOG: [clang-format] Fix a bug in `git-clang-format --binary` (#74293)

This is a rework of #74176, which erroneously changed the default
clang-format filename (`clang-format`, `clang-format.exe`, etc.) to an
absolute pathname. Instead, we should do that only if the name is a
pathname, e.g. `./clang-format`,
`llvm-project/build/bin/clang-format.exe`, etc. See also
https://github.com/llvm/llvm-project/pull/74176#issuecomment-1837921351.

Added: 


Modified: 
clang/tools/clang-format/git-clang-format

Removed: 




diff  --git a/clang/tools/clang-format/git-clang-format 
b/clang/tools/clang-format/git-clang-format
index 6e827e17b4ee2..f7b25b7deae2b 100755
--- a/clang/tools/clang-format/git-clang-format
+++ b/clang/tools/clang-format/git-clang-format
@@ -153,7 +153,10 @@ def main():
   else:
 if len(commits) > 2:
   die('at most two commits allowed; %d given' % len(commits))
-  opts.binary=os.path.abspath(opts.binary)
+
+  if os.path.dirname(opts.binary):
+opts.binary = os.path.abspath(opts.binary)
+
   changed_lines = compute_
diff _and_extract_lines(commits, files, opts.staged)
   if opts.verbose >= 1:
 ignored_files = set(changed_lines)



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


[clang] [clang-format] Fix a bug in `git-clang-format --binary` (PR #74293)

2023-12-04 Thread Owen Pan via cfe-commits

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Jan Svoboda via cfe-commits

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

LGTM, nice!

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits

ributzka wrote:

Thanks for the reviews

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


[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka updated 
https://github.com/llvm/llvm-project/pull/74006

>From 416c233bf334fd96ec6e5b54971f3ae5c6b99843 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 6 Nov 2023 14:22:02 -0800
Subject: [PATCH] [clang][modules] Reset codegen options.

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with `-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  88 +--
 clang/include/clang/Basic/CodeGenOptions.h|   4 +
 clang/include/clang/Basic/DebugOptions.def| 146 ++
 clang/include/module.modulemap|   1 +
 clang/lib/Basic/CodeGenOptions.cpp|  35 +
 clang/lib/Frontend/CompilerInvocation.cpp |  13 ++
 clang/test/ClangScanDeps/strip-codegen-args.m |  58 +++
 7 files changed, 260 insertions(+), 85 deletions(-)
 create mode 100644 clang/include/clang/Basic/DebugOptions.def
 create mode 100644 clang/test/ClangScanDeps/strip-codegen-args.m

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed..0acb5ae134ea2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -178,8 +164,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
-   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -187,8 +171,6 @@ CODEGENOPT(NoWarn 

[clang] [libclang/python] Fix some minor typos (PR #74292)

2023-12-04 Thread Craig Hesling via cfe-commits

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


[clang] fef1854 - [clang][modules] Reset codegen options. (#74006)

2023-12-04 Thread via cfe-commits

Author: Juergen Ributzka
Date: 2023-12-04T13:54:57-08:00
New Revision: fef1854318bd797c1f8a141d4b45b113b04860d1

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

LOG: [clang][modules] Reset codegen options. (#74006)

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with
`-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.

Added: 
clang/include/clang/Basic/DebugOptions.def
clang/test/ClangScanDeps/strip-codegen-args.m

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/CodeGenOptions.h
clang/include/module.modulemap
clang/lib/Basic/CodeGenOptions.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed..0acb5ae134ea2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -178,8 +164,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
-   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -187,8 +171,6 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when 
-Wa,--no-warn is enabled.
 CODEGENOPT(NoTypeCheck   , 1, 0) //

[clang] [clang][modules] Reset codegen options. (PR #74006)

2023-12-04 Thread Juergen Ributzka via cfe-commits

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


[clang] [libclang/python] Fix some minor typos (PR #74292)

2023-12-04 Thread Craig Hesling via cfe-commits

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


[flang] [clang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)

2023-12-04 Thread Andrzej Warzyński via cfe-commits

https://github.com/banach-space created 
https://github.com/llvm/llvm-project/pull/74377

This patch renames `flang-new` as `flang`. Similarly to Clang, Flang's
driver executable will be called:

  * `flang-`

A symlink called `flang` pointing at `flang-` will be
created at build time. This is consistent with Clang.

For backwards compatibility, a symlink `flang-new` pointing to
`flang-` is also created. This will be removed in the
future.


From e5ebda3272925b4f5956c15d0e61f7fbc0016129 Mon Sep 17 00:00:00 2001
From: Andrzej Warzynski 
Date: Sat, 2 Dec 2023 14:01:02 +
Subject: [PATCH] [flang][driver] Rename `flang-new` as `flang`

This patch renames `flang-new` as `flang`. Similarly to Clang, Flang's
driver executable will be called:

  * `flang-`

A symlink called `flang` pointing at `flang-` will be
created at build time. This is consistent with Clang.

For backwards compatibility, a symlink `flang-new` pointing to
`flang-` is also created. This will be removed in the
future.
---
 clang/lib/Driver/Driver.cpp   |  2 +-
 clang/lib/Driver/ToolChain.cpp|  3 +
 clang/lib/Driver/ToolChains/Flang.cpp | 10 +--
 clang/test/Driver/flang/flang.f90 |  2 +-
 clang/test/Driver/flang/flang_ucase.F90   |  2 +-
 .../Driver/flang/multiple-inputs-mixed.f90|  2 +-
 clang/test/Driver/flang/multiple-inputs.f90   |  4 +-
 flang/docs/FlangDriver.md | 70 +--
 flang/docs/ImplementingASemanticCheck.md  |  4 +-
 flang/docs/Overview.md| 12 ++--
 .../FlangOmpReport/FlangOmpReport.cpp |  2 +-
 .../ExecuteCompilerInvocation.cpp |  3 +-
 flang/test/CMakeLists.txt |  2 +-
 flang/test/Driver/compiler_options.f90|  4 +-
 .../test/Driver/disable-ext-name-interop.f90  |  2 +-
 flang/test/Driver/driver-help-hidden.f90  |  6 +-
 flang/test/Driver/driver-version.f90  |  4 +-
 flang/test/Driver/escaped-backslash.f90   |  4 +-
 flang/test/Driver/fdefault.f90| 28 
 flang/test/Driver/flarge-sizes.f90| 20 +++---
 flang/test/Driver/frontend-forwarding.f90 |  4 +-
 flang/test/Driver/intrinsic-module-path.f90   |  2 +-
 flang/test/Driver/lto-flags.f90   |  2 +-
 flang/test/Driver/macro-def-undef.F90 |  4 +-
 flang/test/Driver/missing-input.f90   | 14 ++--
 flang/test/Driver/multiple-input-files.f90|  2 +-
 flang/test/Driver/omp-driver-offload.f90  | 52 +++---
 .../predefined-macros-compiler-version.F90|  4 +-
 flang/test/Driver/std2018-wrong.f90   |  2 +-
 flang/test/Driver/std2018.f90 |  2 +-
 .../Driver/supported-suffices/f03-suffix.f03  |  2 +-
 .../Driver/supported-suffices/f08-suffix.f08  |  2 +-
 flang/test/Driver/use-module-error.f90|  4 +-
 flang/test/Driver/use-module.f90  |  4 +-
 flang/test/Driver/version-loops.f90   | 18 ++---
 .../Intrinsics/command_argument_count.f90 |  4 +-
 flang/test/Lower/Intrinsics/exit.f90  |  2 +-
 .../test/Lower/Intrinsics/ieee_is_normal.f90  |  2 +-
 .../OpenMP/Todo/omp-declarative-allocate.f90  |  2 +-
 .../OpenMP/Todo/omp-declare-reduction.f90 |  2 +-
 .../Lower/OpenMP/Todo/omp-declare-simd.f90|  2 +-
 flang/test/lit.cfg.py |  4 +-
 flang/tools/f18/CMakeLists.txt|  6 +-
 flang/tools/flang-driver/CMakeLists.txt   | 22 --
 flang/tools/flang-driver/driver.cpp   |  7 +-
 45 files changed, 186 insertions(+), 171 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 6f5ff81410326..9a161ffd7cfc5 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1954,7 +1954,7 @@ void Driver::PrintHelp(bool ShowHidden) const {
 
 void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {
   if (IsFlangMode()) {
-OS << getClangToolFullVersion("flang-new") << '\n';
+OS << getClangToolFullVersion("flang") << '\n';
   } else {
 // FIXME: The following handlers should use a callback mechanism, we don't
 // know what the client would like to do.
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index ab19166f18c2d..eb5bd8d033bb4 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -310,6 +310,9 @@ static const DriverSuffix *FindDriverSuffix(StringRef 
ProgName, size_t &Pos) {
   {"cl", "--driver-mode=cl"},
   {"++", "--driver-mode=g++"},
   {"flang", "--driver-mode=flang"},
+  // For backwards compatibility, we create a symlink for `flang` called
+  // `flang-new`. This will be removed in the future.
+  {"flang-new", "--driver-mode=flang"},
   {"clang-dxc", "--driver-mode=dxc"},
   };
 
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 98b337e60e4ff..5683240e8a435 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp

[clang] [flang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)

2023-12-04 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Andrzej Warzyński (banach-space)


Changes

This patch renames `flang-new` as `flang`. Similarly to Clang, Flang's
driver executable will be called:

  * `flang-`

A symlink called `flang` pointing at `flang-` will be
created at build time. This is consistent with Clang.

For backwards compatibility, a symlink `flang-new` pointing to
`flang-` is also created. This will be removed in the
future.


---

Patch is 59.98 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74377.diff


45 Files Affected:

- (modified) clang/lib/Driver/Driver.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChain.cpp (+3) 
- (modified) clang/lib/Driver/ToolChains/Flang.cpp (+6-4) 
- (modified) clang/test/Driver/flang/flang.f90 (+1-1) 
- (modified) clang/test/Driver/flang/flang_ucase.F90 (+1-1) 
- (modified) clang/test/Driver/flang/multiple-inputs-mixed.f90 (+1-1) 
- (modified) clang/test/Driver/flang/multiple-inputs.f90 (+2-2) 
- (modified) flang/docs/FlangDriver.md (+35-35) 
- (modified) flang/docs/ImplementingASemanticCheck.md (+2-2) 
- (modified) flang/docs/Overview.md (+6-6) 
- (modified) flang/examples/FlangOmpReport/FlangOmpReport.cpp (+1-1) 
- (modified) flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp (+1-2) 
- (modified) flang/test/CMakeLists.txt (+1-1) 
- (modified) flang/test/Driver/compiler_options.f90 (+2-2) 
- (modified) flang/test/Driver/disable-ext-name-interop.f90 (+1-1) 
- (modified) flang/test/Driver/driver-help-hidden.f90 (+3-3) 
- (modified) flang/test/Driver/driver-version.f90 (+2-2) 
- (modified) flang/test/Driver/escaped-backslash.f90 (+2-2) 
- (modified) flang/test/Driver/fdefault.f90 (+14-14) 
- (modified) flang/test/Driver/flarge-sizes.f90 (+10-10) 
- (modified) flang/test/Driver/frontend-forwarding.f90 (+2-2) 
- (modified) flang/test/Driver/intrinsic-module-path.f90 (+1-1) 
- (modified) flang/test/Driver/lto-flags.f90 (+1-1) 
- (modified) flang/test/Driver/macro-def-undef.F90 (+2-2) 
- (modified) flang/test/Driver/missing-input.f90 (+7-7) 
- (modified) flang/test/Driver/multiple-input-files.f90 (+1-1) 
- (modified) flang/test/Driver/omp-driver-offload.f90 (+26-26) 
- (modified) flang/test/Driver/predefined-macros-compiler-version.F90 (+2-2) 
- (modified) flang/test/Driver/std2018-wrong.f90 (+1-1) 
- (modified) flang/test/Driver/std2018.f90 (+1-1) 
- (modified) flang/test/Driver/supported-suffices/f03-suffix.f03 (+1-1) 
- (modified) flang/test/Driver/supported-suffices/f08-suffix.f08 (+1-1) 
- (modified) flang/test/Driver/use-module-error.f90 (+2-2) 
- (modified) flang/test/Driver/use-module.f90 (+2-2) 
- (modified) flang/test/Driver/version-loops.f90 (+9-9) 
- (modified) flang/test/Lower/Intrinsics/command_argument_count.f90 (+2-2) 
- (modified) flang/test/Lower/Intrinsics/exit.f90 (+1-1) 
- (modified) flang/test/Lower/Intrinsics/ieee_is_normal.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/Todo/omp-declarative-allocate.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/Todo/omp-declare-reduction.f90 (+1-1) 
- (modified) flang/test/Lower/OpenMP/Todo/omp-declare-simd.f90 (+1-1) 
- (modified) flang/test/lit.cfg.py (+2-2) 
- (modified) flang/tools/f18/CMakeLists.txt (+3-3) 
- (modified) flang/tools/flang-driver/CMakeLists.txt (+16-6) 
- (modified) flang/tools/flang-driver/driver.cpp (+4-3) 


``diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 6f5ff81410326..9a161ffd7cfc5 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1954,7 +1954,7 @@ void Driver::PrintHelp(bool ShowHidden) const {
 
 void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const {
   if (IsFlangMode()) {
-OS << getClangToolFullVersion("flang-new") << '\n';
+OS << getClangToolFullVersion("flang") << '\n';
   } else {
 // FIXME: The following handlers should use a callback mechanism, we don't
 // know what the client would like to do.
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index ab19166f18c2d..eb5bd8d033bb4 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -310,6 +310,9 @@ static const DriverSuffix *FindDriverSuffix(StringRef 
ProgName, size_t &Pos) {
   {"cl", "--driver-mode=cl"},
   {"++", "--driver-mode=g++"},
   {"flang", "--driver-mode=flang"},
+  // For backwards compatibility, we create a symlink for `flang` called
+  // `flang-new`. This will be removed in the future.
+  {"flang-new", "--driver-mode=flang"},
   {"clang-dxc", "--driver-mode=dxc"},
   };
 
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 98b337e60e4ff..5683240e8a435 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -739,14 +739,16 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   CmdAr

[clang] [flang] [flang][driver] Rename `flang-new` as `flang` (PR #74377)

2023-12-04 Thread Thorsten Schütt via cfe-commits

tschuett wrote:

Are you going to add an entry to the [Release 
Nodes](https://github.com/llvm/llvm-project/blob/main/flang/docs/ReleaseNotes.md)?

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


[clang] [CUDA][Win32] Add `fma(long double,..)` to math forward declares. (PR #73756)

2023-12-04 Thread Artem Belevich via cfe-commits


@@ -70,6 +70,9 @@ __DEVICE__ double floor(double);
 __DEVICE__ float floor(float);
 __DEVICE__ double fma(double, double, double);
 __DEVICE__ float fma(float, float, float);
+#ifdef _MSC_VER
+__DEVICE__ long double fma(long double, long double, long double);

Artem-B wrote:

We already have a handful of MSVC-specific no-implementation functions declared 
here, so one more is OK.
I just want to document it better.

You may want to add a macro with a descriptive name. (E.g. 
`CUDA_ALLOW_LONG_DOUBLE_MATH_FUNCTION_DECLS`) and have it defined for MSVC, 
along with the comment why it's needed. Then replace the existing `#if 
_MSC_VER` with it.

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


[clang] 1157bee - Revert "[clang][modules] Reset codegen options. (#74006)"

2023-12-04 Thread Juergen Ributzka via cfe-commits

Author: Juergen Ributzka
Date: 2023-12-04T14:28:22-08:00
New Revision: 1157bee5ce2c7acb803cda5003b2ea9d0ed962e2

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

LOG: Revert "[clang][modules] Reset codegen options. (#74006)"

This reverts commit fef1854318bd797c1f8a141d4b45b113b04860d1.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/CodeGenOptions.h
clang/include/module.modulemap
clang/lib/Basic/CodeGenOptions.cpp
clang/lib/Frontend/CompilerInvocation.cpp

Removed: 
clang/include/clang/Basic/DebugOptions.def
clang/test/ClangScanDeps/strip-codegen-args.m



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0acb5ae134ea2..675645cd534ed 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,8 +28,12 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
+ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
+llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
+CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -69,6 +73,10 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
+CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
+ ///< each (it means check
+ ///< the original debug info
+ ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -105,10 +113,16 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
+CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
+  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
+///< Set when -femit-dwarf-unwind is passed.
+ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
+llvm::EmitDwarfUnwindType::Default)
+
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -164,6 +178,8 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
+CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
+   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -171,6 +187,8 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when 
-Wa,--no-warn is enabled.
 CODEGENOPT(NoTypeCheck   , 1, 0) ///< Set when -Wa,--no-type-check is 
enabled.
 CODEGENOPT(MisExpect , 1, 0) ///< Set when -Wmisexpect is enabled
 CODEGENOPT(EnableSegmentedStacks , 1, 0) ///< Set when -fsplit-stack is 
enabled.
+CODEGENOPT(NoInlineLineTables, 1, 0) ///< Whether debug info should contain
+ ///< inline line tables.
 CODEGENOPT(StackClashProtector, 1, 0) ///< Set when -fstack-clash-protection 
is enabled.
 CODEGENOPT(NoImplicitFloat   , 1, 0) ///< Set when -mno-implicit-float is 
enabled.
 CODEGENOPT(NullPointerIsValid , 1, 0) ///< Assume Null pointer deference is 
defined.
@@ -323,6 +341,37 @@ VALUE_CODEGENOPT(Sta

[clang] [llvm] [clang] NFC: Deprecate `FileEntry::getName()` (PR #68157)

2023-12-04 Thread Ben Barham via cfe-commits

bnbarham wrote:

🎉 thanks @jansvoboda11 for slogging through all these!

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


[clang] Thread safety analysis: Fix a bug in handling temporary constructors (PR #74020)

2023-12-04 Thread Ziqing Luo via cfe-commits

https://github.com/ziqingluo-90 updated 
https://github.com/llvm/llvm-project/pull/74020

>From 00083bb1573561361ff0782f425ebec2a5218f34 Mon Sep 17 00:00:00 2001
From: ziqingluo-90 
Date: Mon, 4 Dec 2023 14:37:10 -0800
Subject: [PATCH] Thread safety analysis: Fix a bug in handling temporary
 constructors

Extends the lifetime of the map `ConstructedObjects` to be of the
whole CFG so that the map can connect temporary Ctor and Dtor in
different CFG blocks.
---
 clang/lib/Analysis/ThreadSafety.cpp   | 27 +--
 .../SemaCXX/warn-thread-safety-analysis.cpp   |  8 ++
 2 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index 7fdf22c2f3919..b65d4dfab8dea 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1010,6 +1010,8 @@ class ThreadSafetyAnalyzer {
   ThreadSafetyHandler &Handler;
   const FunctionDecl *CurrentFunction;
   LocalVariableMap LocalVarMap;
+  // Maps constructed objects to `this` placeholder prior to initialization.
+  llvm::SmallDenseMap ConstructedObjects;
   FactManager FactMan;
   std::vector BlockInfo;
 
@@ -1530,7 +1532,6 @@ void ThreadSafetyAnalyzer::getEdgeLockset(FactSet& Result,
 }
 
 namespace {
-
 /// We use this class to visit different types of expressions in
 /// CFGBlocks, and build up the lockset.
 /// An expression may cause us to add or remove locks from the lockset, or else
@@ -1543,8 +1544,6 @@ class BuildLockset : public 
ConstStmtVisitor {
   FactSet FSet;
   // The fact set for the function on exit.
   const FactSet &FunctionExitFSet;
-  /// Maps constructed objects to `this` placeholder prior to initialization.
-  llvm::SmallDenseMap ConstructedObjects;
   LocalVariableMap::Context LVarCtx;
   unsigned CtxIndex;
 
@@ -1808,7 +1807,7 @@ void BuildLockset::handleCall(const Expr *Exp, const 
NamedDecl *D,
   std::pair Placeholder =
   Analyzer->SxBuilder.createThisPlaceholder(Exp);
   [[maybe_unused]] auto inserted =
-  ConstructedObjects.insert({Exp, Placeholder.first});
+  Analyzer->ConstructedObjects.insert({Exp, Placeholder.first});
   assert(inserted.second && "Are we visiting the same expression again?");
   if (isa(Exp))
 Self = Placeholder.first;
@@ -2128,10 +2127,10 @@ void BuildLockset::VisitDeclStmt(const DeclStmt *S) {
 E = EWC->getSubExpr()->IgnoreParens();
   E = UnpackConstruction(E);
 
-  if (auto Object = ConstructedObjects.find(E);
-  Object != ConstructedObjects.end()) {
+  if (auto Object = Analyzer->ConstructedObjects.find(E);
+  Object != Analyzer->ConstructedObjects.end()) {
 Object->second->setClangDecl(VD);
-ConstructedObjects.erase(Object);
+Analyzer->ConstructedObjects.erase(Object);
   }
 }
   }
@@ -2140,11 +2139,11 @@ void BuildLockset::VisitDeclStmt(const DeclStmt *S) {
 void BuildLockset::VisitMaterializeTemporaryExpr(
 const MaterializeTemporaryExpr *Exp) {
   if (const ValueDecl *ExtD = Exp->getExtendingDecl()) {
-if (auto Object =
-ConstructedObjects.find(UnpackConstruction(Exp->getSubExpr()));
-Object != ConstructedObjects.end()) {
+if (auto Object = Analyzer->ConstructedObjects.find(
+UnpackConstruction(Exp->getSubExpr()));
+Object != Analyzer->ConstructedObjects.end()) {
   Object->second->setClangDecl(ExtD);
-  ConstructedObjects.erase(Object);
+  Analyzer->ConstructedObjects.erase(Object);
 }
   }
 }
@@ -2487,15 +2486,15 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
 
   // Clean up constructed object even if there are no attributes to
   // keep the number of objects in limbo as small as possible.
-  if (auto Object = LocksetBuilder.ConstructedObjects.find(
+  if (auto Object = LocksetBuilder.Analyzer->ConstructedObjects.find(
   TD.getBindTemporaryExpr()->getSubExpr());
-  Object != LocksetBuilder.ConstructedObjects.end()) {
+  Object != LocksetBuilder.Analyzer->ConstructedObjects.end()) {
 const auto *DD = TD.getDestructorDecl(AC.getASTContext());
 if (DD->hasAttrs())
   // TODO: the location here isn't quite correct.
   LocksetBuilder.handleCall(nullptr, DD, Object->second,
 
TD.getBindTemporaryExpr()->getEndLoc());
-LocksetBuilder.ConstructedObjects.erase(Object);
+LocksetBuilder.Analyzer->ConstructedObjects.erase(Object);
   }
   break;
 }
diff --git a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp 
b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
index 205cfa284f6c9..dfb966d3b5902 100644
--- a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -1702,6 +1702,8 @@ struct TestScopedLockable {
 
   bool 

[llvm] [compiler-rt] [flang] [clang] [libcxx] [clang-tools-extra] [libc] [NFC][asan] Replace AsanInited/ENSURE_ASAN_INITED with TryAsanInitFromRtl (PR #74172)

2023-12-04 Thread Vitaly Buka via cfe-commits

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


[clang-tools-extra] [libc] [clang] [libcxx] [compiler-rt] [llvm] [flang] [NFC][asan] Replace a few `#if SANITIZER_APPLE` with `if (SANITIZER_APPLE` (PR #74173)

2023-12-04 Thread Vitaly Buka via cfe-commits

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


[llvm] [compiler-rt] [flang] [clang] [libcxx] [clang-tools-extra] [libc] [NFC][asan] Replace a few `#if SANITIZER_APPLE` with `if (SANITIZER_APPLE` (PR #74173)

2023-12-04 Thread Vitaly Buka via cfe-commits

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


[clang-tools-extra] [libc] [clang] [libcxx] [compiler-rt] [llvm] [flang] [NFC][asan] Inline ENSURE_ASAN_INITED macro (PR #74174)

2023-12-04 Thread Vitaly Buka via cfe-commits

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


[clang-tools-extra] [lldb] [libc] [mlir] [clang] [libcxx] [polly] [compiler-rt] [lld] [llvm] [flang] [NFC][asan] Inline ENSURE_ASAN_INITED macro (PR #74174)

2023-12-04 Thread Vitaly Buka via cfe-commits

https://github.com/vitalybuka updated 
https://github.com/llvm/llvm-project/pull/74174

>From 71e54faa238765cb9df656a3f6e347a2d04f989a Mon Sep 17 00:00:00 2001
From: Vitaly Buka 
Date: Fri, 1 Dec 2023 19:20:37 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20change?=
 =?UTF-8?q?s=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4

[skip ci]
---
 compiler-rt/lib/asan/asan_interceptors.cpp | 54 ++
 compiler-rt/lib/asan/asan_interceptors.h   |  9 ++--
 compiler-rt/lib/asan/asan_internal.h   |  2 +-
 compiler-rt/lib/asan/asan_malloc_linux.cpp |  5 +-
 compiler-rt/lib/asan/asan_rtl.cpp  | 14 +-
 5 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index e80f66142b7a2..1a1a26a7cd8bf 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -96,14 +96,16 @@ DECLARE_REAL_AND_INTERCEPTOR(void, free, void *)
   ASAN_WRITE_RANGE(ctx, ptr, size)
 #define COMMON_INTERCEPTOR_READ_RANGE(ctx, ptr, size) \
   ASAN_READ_RANGE(ctx, ptr, size)
-#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...)\
-ASAN_INTERCEPTOR_ENTER(ctx, func);\
-do {  \
-  if (AsanInitIsRunning())\
-return REAL(func)(__VA_ARGS__);   \
-  if (SANITIZER_APPLE && UNLIKELY(!AsanInited())) \
-return REAL(func)(__VA_ARGS__);   \
-  ENSURE_ASAN_INITED();   \
+#  define COMMON_INTERCEPTOR_ENTER(ctx, func, ...) \
+ASAN_INTERCEPTOR_ENTER(ctx, func); \
+do {   \
+  if constexpr (SANITIZER_APPLE) { \
+if (UNLIKELY(!AsanInited()))   \
+  return REAL(func)(__VA_ARGS__);  \
+  } else { \
+if (!TryAsanInitFromRtl()) \
+  return REAL(func)(__VA_ARGS__);  \
+  }\
 } while (false)
 #define COMMON_INTERCEPTOR_DIR_ACQUIRE(ctx, path) \
   do {\
@@ -534,16 +536,16 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, 
uptr size) {
 INTERCEPTOR(char *, strcpy, char *to, const char *from) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strcpy);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
-return REAL(strcpy)(to, from);
-#endif
-  // strcpy is called from malloc_default_purgeable_zone()
-  // in __asan::ReplaceSystemAlloc() on Mac.
-  if (AsanInitIsRunning()) {
-return REAL(strcpy)(to, from);
+  if constexpr (SANITIZER_APPLE) {
+// strcpy is called from malloc_default_purgeable_zone()
+// in __asan::ReplaceSystemAlloc() on Mac.
+if (UNLIKELY(!AsanInited()))
+  return REAL(strcpy)(to, from);
+  } else {
+if (!TryAsanInitFromRtl())
+  return REAL(strcpy)(to, from);
   }
-  ENSURE_ASAN_INITED();
+
   if (flags()->replace_str) {
 uptr from_size = internal_strlen(from) + 1;
 CHECK_RANGES_OVERLAP("strcpy", to, from_size, from, from_size);
@@ -556,9 +558,8 @@ INTERCEPTOR(char *, strcpy, char *to, const char *from) {
 INTERCEPTOR(char*, strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!TryAsanInitFromRtl()))
 return internal_strdup(s);
-  ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
   if (flags()->replace_str) {
 ASAN_READ_RANGE(ctx, s, length + 1);
@@ -575,9 +576,8 @@ INTERCEPTOR(char*, strdup, const char *s) {
 INTERCEPTOR(char*, __strdup, const char *s) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, strdup);
-  if (UNLIKELY(!AsanInited()))
+  if (UNLIKELY(!TryAsanInitFromRtl()))
 return internal_strdup(s);
-  ENSURE_ASAN_INITED();
   uptr length = internal_strlen(s);
   if (flags()->replace_str) {
 ASAN_READ_RANGE(ctx, s, length + 1);
@@ -635,10 +635,8 @@ INTERCEPTOR_STRTO_BASE(long long, __isoc23_strtoll)
 INTERCEPTOR(int, atoi, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atoi);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(atoi)(nptr);
-#  endif
   ENSURE_ASAN_INITED();
   if (!flags()->replace_str) {
 return REAL(atoi)(nptr);
@@ -657,10 +655,8 @@ INTERCEPTOR(int, atoi, const char *nptr) {
 INTERCEPTOR(long, atol, const char *nptr) {
   void *ctx;
   ASAN_INTERCEPTOR_ENTER(ctx, atol);
-#if SANITIZER_APPLE
-  if (UNLIKELY(!AsanInited()))
+  if (SANITIZER_APPLE && UNLIKELY(!AsanInited()))
 return REAL(atol)(nptr);
-#  endif
   ENSURE_ASAN_INITED();
   if (!flags()->replace_str) {
 return REAL(atol)(nptr);
@@ -696,10 +692,8 @@ static void AtCxaAtexit(v

[clang-tools-extra] [lldb] [libc] [mlir] [clang] [libcxx] [polly] [compiler-rt] [lld] [llvm] [flang] [NFC][asan] Inline ENSURE_ASAN_INITED macro (PR #74174)

2023-12-04 Thread Vitaly Buka via cfe-commits

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


[llvm] [compiler-rt] [flang] [clang] [libcxx] [lldb] [libc] [lld] [hwasan] Use ErrorAction::Recover in interceptors (PR #74000)

2023-12-04 Thread Vitaly Buka via cfe-commits

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


[clang] Thread safety analysis: Fix a bug in handling temporary constructors (PR #74020)

2023-12-04 Thread Ziqing Luo via cfe-commits

ziqingluo-90 wrote:

@aaronpuchert Thanks for your comment!  I have addressed them.   Do you mind to 
take an another look and approve it if it looks good to you?

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


[clang] [clang-format] Remove duplicates in @property using std::set (PR #74235)

2023-12-04 Thread via cfe-commits

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


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


[clang] [Driver] Mark -arch as TargetSpecific (PR #74365)

2023-12-04 Thread Brad Smith via cfe-commits

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


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


[clang-tools-extra] [Clangd] Sanitize path before recording into IncludeStructure during buildPreamble (PR #70798)

2023-12-04 Thread via cfe-commits

https://github.com/Maddobun updated 
https://github.com/llvm/llvm-project/pull/70798

>From 0572afa42e4e6ca1d1de0e9df045828552cb4480 Mon Sep 17 00:00:00 2001
From: Leo Zhu 
Date: Wed, 8 Nov 2023 11:10:13 -0500
Subject: [PATCH 1/3] Convert URI to uppercase drive letter during parsing

---
 clang-tools-extra/clangd/URI.cpp | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clangd/URI.cpp b/clang-tools-extra/clangd/URI.cpp
index ca65df329aeeb..4bd4b6db9f51d 100644
--- a/clang-tools-extra/clangd/URI.cpp
+++ b/clang-tools-extra/clangd/URI.cpp
@@ -165,8 +165,7 @@ std::string URI::toString() const {
 return Result;
   // If authority if empty, we only print body if it starts with "/"; 
otherwise,
   // the URI is invalid.
-  if (!Authority.empty() || llvm::StringRef(Body).startswith("/"))
-  {
+  if (!Authority.empty() || llvm::StringRef(Body).startswith("/")) {
 Result.append("//");
 percentEncode(Authority, Result);
   }
@@ -192,6 +191,10 @@ llvm::Expected URI::parse(llvm::StringRef OrigUri) {
 Uri = Uri.substr(Pos);
   }
   U.Body = percentDecode(Uri);
+  if (clang::clangd::isWindowsPath(U.Body)) {
+Pos = U.Body.find(":");
+U.Body.at(Pos - 1) = std::toupper(U.Body.at(Pos - 1));
+  }
   return U;
 }
 

>From 5a4b2ed67032a75cec7fde6a3e8c589c13d0fef5 Mon Sep 17 00:00:00 2001
From: Leo Zhu 
Date: Thu, 9 Nov 2023 16:27:24 -0500
Subject: [PATCH 2/3] Add check for scheme

---
 clang-tools-extra/clangd/URI.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/URI.cpp b/clang-tools-extra/clangd/URI.cpp
index 4bd4b6db9f51d..e448d1b216d90 100644
--- a/clang-tools-extra/clangd/URI.cpp
+++ b/clang-tools-extra/clangd/URI.cpp
@@ -191,7 +191,7 @@ llvm::Expected URI::parse(llvm::StringRef OrigUri) {
 Uri = Uri.substr(Pos);
   }
   U.Body = percentDecode(Uri);
-  if (clang::clangd::isWindowsPath(U.Body)) {
+  if (U.scheme() == "file" && clang::clangd::isWindowsPath(U.Body)) {
 Pos = U.Body.find(":");
 U.Body.at(Pos - 1) = std::toupper(U.Body.at(Pos - 1));
   }

>From a6daa54182b9eb62e57eba96f2d9e3103aeaf8b3 Mon Sep 17 00:00:00 2001
From: Leo Zhu 
Date: Mon, 4 Dec 2023 18:26:33 -0500
Subject: [PATCH 3/3] fix

---
 clang-tools-extra/clangd/URI.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/URI.cpp b/clang-tools-extra/clangd/URI.cpp
index e448d1b216d90..4493e2d2198bf 100644
--- a/clang-tools-extra/clangd/URI.cpp
+++ b/clang-tools-extra/clangd/URI.cpp
@@ -191,7 +191,9 @@ llvm::Expected URI::parse(llvm::StringRef OrigUri) {
 Uri = Uri.substr(Pos);
   }
   U.Body = percentDecode(Uri);
-  if (U.scheme() == "file" && clang::clangd::isWindowsPath(U.Body)) {
+  if (U.scheme() == "file" &&
+  (clang::clangd::isWindowsPath(U.Body.substr(Pos + 1)) ||
+   (clang::clangd::isWindowsPath(U.Body.substr(Pos) {
 Pos = U.Body.find(":");
 U.Body.at(Pos - 1) = std::toupper(U.Body.at(Pos - 1));
   }

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


[llvm] [compiler-rt] [flang] [openmp] [clang] [libcxx] [clang-tools-extra] [libc] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits

https://github.com/pizzud updated 
https://github.com/llvm/llvm-project/pull/67467

>From 6d5d35e1273f595e8a0382053d5183cbce7a9d8a Mon Sep 17 00:00:00 2001
From: David Pizzuto 
Date: Tue, 26 Sep 2023 10:45:42 -0700
Subject: [PATCH 1/3] [clang-tidy] Add bugprone-move-shared-pointer-contents
 check.

This check detects moves of the contents of a shared pointer rather than the
pointer itself. Other code with a reference to the shared pointer is probably
not expecting the move.

The set of shared pointer classes is configurable via options to allow 
individual
projects to cover additional types.
---
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  2 +
 .../MoveSharedPointerContentsCheck.cpp| 60 
 .../bugprone/MoveSharedPointerContentsCheck.h | 37 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |  6 ++
 .../bugprone/move-shared-pointer-contents.rst | 17 +
 .../docs/clang-tidy/checks/list.rst   |  2 +
 .../bugprone/move-shared-pointer-contents.cpp | 68 +++
 8 files changed, 195 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/move-shared-pointer-contents.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/move-shared-pointer-contents.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index a67a91eedd104..7f4a504f9930f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -39,6 +39,7 @@
 #include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
+#include "MoveSharedPointerContentsCheck.h"
 #include "MultiLevelImplicitPointerConversionCheck.h"
 #include "MultipleNewInOneExpressionCheck.h"
 #include "MultipleStatementMacroCheck.h"
@@ -125,6 +126,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-move-shared-pointer-contents");
 CheckFactories.registerCheck(
 "bugprone-switch-missing-default-case");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 3c768021feb15..c017f0c0cc520 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -23,6 +23,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  MoveSharedPointerContentsCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
   IncDecInConditionsCheck.cpp
   IncorrectRoundingsCheck.cpp
@@ -35,6 +36,7 @@ add_clang_library(clangTidyBugproneModule
   MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
+  MoveSharedPointerContentsCheck.cpp
   MultiLevelImplicitPointerConversionCheck.cpp
   MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
new file mode 100644
index 0..b4a393b7f2f20
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
@@ -0,0 +1,60 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))) {}
+
+MoveSharedPointerContentsCheck::~MoveSharedPointerContentsCheck() = default;
+
+bool MoveSharedPointerContentsCheck::isLanguageVersionSupported(
+const LangOptions &LangOptions) const {
+  return LangOptions

[llvm] [compiler-rt] [flang] [openmp] [clang] [libcxx] [clang-tools-extra] [libc] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits

https://github.com/pizzud updated 
https://github.com/llvm/llvm-project/pull/67467

>From 6d5d35e1273f595e8a0382053d5183cbce7a9d8a Mon Sep 17 00:00:00 2001
From: David Pizzuto 
Date: Tue, 26 Sep 2023 10:45:42 -0700
Subject: [PATCH 1/4] [clang-tidy] Add bugprone-move-shared-pointer-contents
 check.

This check detects moves of the contents of a shared pointer rather than the
pointer itself. Other code with a reference to the shared pointer is probably
not expecting the move.

The set of shared pointer classes is configurable via options to allow 
individual
projects to cover additional types.
---
 .../bugprone/BugproneTidyModule.cpp   |  3 +
 .../clang-tidy/bugprone/CMakeLists.txt|  2 +
 .../MoveSharedPointerContentsCheck.cpp| 60 
 .../bugprone/MoveSharedPointerContentsCheck.h | 37 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |  6 ++
 .../bugprone/move-shared-pointer-contents.rst | 17 +
 .../docs/clang-tidy/checks/list.rst   |  2 +
 .../bugprone/move-shared-pointer-contents.cpp | 68 +++
 8 files changed, 195 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/move-shared-pointer-contents.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/move-shared-pointer-contents.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index a67a91eedd104..7f4a504f9930f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -39,6 +39,7 @@
 #include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
+#include "MoveSharedPointerContentsCheck.h"
 #include "MultiLevelImplicitPointerConversionCheck.h"
 #include "MultipleNewInOneExpressionCheck.h"
 #include "MultipleStatementMacroCheck.h"
@@ -125,6 +126,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-move-shared-pointer-contents");
 CheckFactories.registerCheck(
 "bugprone-switch-missing-default-case");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 3c768021feb15..c017f0c0cc520 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -23,6 +23,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  MoveSharedPointerContentsCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
   IncDecInConditionsCheck.cpp
   IncorrectRoundingsCheck.cpp
@@ -35,6 +36,7 @@ add_clang_library(clangTidyBugproneModule
   MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
+  MoveSharedPointerContentsCheck.cpp
   MultiLevelImplicitPointerConversionCheck.cpp
   MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
new file mode 100644
index 0..b4a393b7f2f20
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/MoveSharedPointerContentsCheck.cpp
@@ -0,0 +1,60 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))) {}
+
+MoveSharedPointerContentsCheck::~MoveSharedPointerContentsCheck() = default;
+
+bool MoveSharedPointerContentsCheck::isLanguageVersionSupported(
+const LangOptions &LangOptions) const {
+  return LangOptions

[clang-tools-extra] [clang] [libc] [libcxx] [llvm] [compiler-rt] [openmp] [flang] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -0,0 +1,51 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))) {}
+
+void MoveSharedPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(hasName("std::move"))),

pizzud wrote:

Done.

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


[compiler-rt] [clang-tools-extra] [libcxx] [libc] [llvm] [flang] [openmp] [clang] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -0,0 +1,51 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))) {}

pizzud wrote:

Switched to ::. Is the Boost version really still so widely used to justify 
this in 2023 when std::shared_ptr has been around since C++11?

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


[llvm] [libc] [clang-tools-extra] [compiler-rt] [flang] [clang] [libcxx] [openmp] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -0,0 +1,39 @@
+//===--- MoveSharedPointerContentsCheck.h - clang-tidy --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MOVESHAREDPOINTERCONTENTSCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MOVESHAREDPOINTERCONTENTSCHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "llvm/ADT/StringRef.h"
+#include 
+
+namespace clang::tidy::bugprone {
+
+/// Detects calls to move the contents out of a ``std::shared_ptr`` rather than
+/// moving the pointer itself. In other words, calling ``std::move(*p)``.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/bugprone/move-shared-pointer-contents.html
+class MoveSharedPointerContentsCheck : public ClangTidyCheck {
+public:
+  MoveSharedPointerContentsCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  bool
+  isLanguageVersionSupported(const LangOptions &LangOptions) const override {
+return LangOptions.CPlusPlus11;
+  }
+

pizzud wrote:

I've been warned off IgnoreUnlessSpelledInSource in the past since it won't 
match hits in headers, only .cc files, and we now want to catch template 
instantiations. I'll use TK_AsIs.

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


[llvm] [compiler-rt] [flang] [openmp] [clang] [libcxx] [clang-tools-extra] [libc] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -0,0 +1,51 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))) {}
+
+void MoveSharedPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(hasName("std::move"))),
+  hasArgument(0, cxxOperatorCallExpr(hasOverloadedOperatorName("*"),

pizzud wrote:

The current implementation actually catches this by dint of the 
unaryOperator(hasOperatorName("*")). I have some fear it'll be overbroad but 
haven't managed to construct a problematic case yet.

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


[clang-tools-extra] [clang] [libc] [libcxx] [llvm] [compiler-rt] [openmp] [flang] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -25,6 +25,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  MoveSharedPointerContentsCheck.cpp

pizzud wrote:

Done, bad merge.

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


[llvm] [libc] [clang-tools-extra] [compiler-rt] [flang] [clang] [libcxx] [openmp] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -0,0 +1,51 @@
+//===--- MoveSharedPointerContentsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MoveSharedPointerContentsCheck.h"
+#include "../ClangTidyCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+MoveSharedPointerContentsCheck::MoveSharedPointerContentsCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SharedPointerClasses(utils::options::parseStringList(
+  Options.get("SharedPointerClasses", "std::shared_ptr"))) {}
+
+void MoveSharedPointerContentsCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  callExpr(
+  callee(functionDecl(hasName("std::move"))),
+  hasArgument(0, cxxOperatorCallExpr(hasOverloadedOperatorName("*"),
+ callee(cxxMethodDecl(ofClass(
+ 
matchers::matchesAnyListedName(
+ SharedPointerClasses)
+ .bind("op")))
+  .bind("call"),
+  this);
+}
+
+void MoveSharedPointerContentsCheck::check(
+const MatchFinder::MatchResult &Result) {
+  const auto *Call = Result.Nodes.getNodeAs("call");
+  const auto *Op = Result.Nodes.getNodeAs("op");
+
+  diag(Call->getBeginLoc(),
+   "don't move the contents out of a shared pointer, as other accessors "
+   "expect them to remain in a determinate state")
+  << FixItHint::CreateInsertion(Call->getBeginLoc(), "*")

pizzud wrote:

Done.

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


[clang-tools-extra] [clang] [libc] [libcxx] [llvm] [compiler-rt] [openmp] [flang] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -118,6 +119,7 @@ Clang-Tidy Checks
:doc:`bugprone-posix-return `, "Yes"
:doc:`bugprone-redundant-branch-condition 
`, "Yes"
:doc:`bugprone-reserved-identifier `, "Yes"
+   :doc:`bugprone-shared-pointer-contents-move 
`, "Yes"

pizzud wrote:

Done.

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


[llvm] [compiler-rt] [flang] [openmp] [clang] [libcxx] [clang-tools-extra] [libc] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -107,6 +107,7 @@ Clang-Tidy Checks
:doc:`bugprone-misplaced-pointer-arithmetic-in-alloc 
`, "Yes"
:doc:`bugprone-misplaced-widening-cast `,
:doc:`bugprone-move-forwarding-reference 
`, "Yes"
+   :doc:`bugprone-move-shared-pointer-contents 
`, "Yes"

pizzud wrote:

Done.

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


[llvm] [libc] [clang-tools-extra] [compiler-rt] [flang] [clang] [libcxx] [openmp] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits


@@ -0,0 +1,75 @@
+// RUN: %check_clang_tidy %s bugprone-move-shared-pointer-contents %t -- 
-config="{CheckOptions: 
{bugprone-move-shared-pointer-contents.SharedPointerClasses: 
'std::shared_ptr;my::OtherSharedPtr;'}}"
+
+// Some dummy definitions we'll need.
+
+namespace std {
+
+using size_t = int;
+
+template  struct remove_reference;
+template  struct remove_reference { typedef _Tp type; };
+template  struct remove_reference<_Tp &> { typedef _Tp type; };
+template  struct remove_reference<_Tp &&> { typedef _Tp type; };
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
+  return static_cast::type &&>(__t);
+}
+
+template 
+struct shared_ptr {
+  shared_ptr();
+  T *get() const;
+  explicit operator bool() const;
+  void reset(T *ptr);
+  T &operator*() const;
+  T *operator->() const;
+};
+
+}  // namespace std
+
+namespace my {
+template 
+using OtherSharedPtr = std::shared_ptr;
+}  // namespace my
+
+void correct() {
+  std::shared_ptr p;
+  int x = *std::move(p);
+}
+
+void simpleFinding() {
+  std::shared_ptr p;
+  int y = std::move(*p);
+  // CHECK-FIXES: *std::move(p)
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:11: warning: don't move the contents out of a 
shared pointer, as other accessors expect them to remain in a determinate state 
[bugprone-move-shared-pointer-contents]
+
+void aliasedType() {
+  using int_ptr = std::shared_ptr;
+  int_ptr p;
+  int x = std::move(*p);
+  // CHECK-FIXES: *std::move(p)
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:11: warning: don't move the contents out of a 
shared pointer, as other accessors expect them to remain in a determinate state 
[bugprone-move-shared-pointer-contents]
+
+void configWorks() {
+  my::OtherSharedPtr p;
+  int x = std::move(*p);

pizzud wrote:

Done, though my full rule-of-five implementation might be overkill.

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


[llvm] [compiler-rt] [flang] [openmp] [clang] [libcxx] [clang-tools-extra] [libc] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)

2023-12-04 Thread via cfe-commits

pizzud wrote:

Try searching for `unresolvedLookupExpr` & `UnresolvedLookupExpr` in the 
clang-tidy directory. There is a high probability that another check has done 
something related/similar.
> 
> https://github.com/llvm/llvm-project/blob/2b7191c8993b5608ddb8b89c049717b497265796/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp#L46-L47

Thanks, this was super helpful and exactly what I was looking for!

I think the missing insight was that I could go from the lookup -> decls.

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


[llvm] [clang] [clang] NFC: Deprecate `FileEntry::getName()` (PR #68157)

2023-12-04 Thread Jan Svoboda via cfe-commits


@@ -284,7 +284,6 @@ TEST_F(FileManagerTest, 
getFileRefReturnsCorrectNameForDifferentStatPath) {
   ASSERT_FALSE(!F1Alias);
   ASSERT_FALSE(!F1Alias2);
   EXPECT_EQ("dir/f1.cpp", F1->getName());
-  EXPECT_EQ("dir/f1.cpp", F1->getFileEntry().getName());

jansvoboda11 wrote:

I created `LLVM_IGNORE_DEPRECATIONS_OF_DECLARATIONS_{BEGIN,END}`. Let me know 
if you think this makes sense to keep in LLVM's Support library, or would make 
more local.

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


[clang] [clang][modules] Reset codegen options (take 2). (PR #74388)

2023-12-04 Thread Juergen Ributzka via cfe-commits

https://github.com/ributzka created 
https://github.com/llvm/llvm-project/pull/74388

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with
`-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.


>From 797167e975fc2706f19c1cc8dc6603906ea732c8 Mon Sep 17 00:00:00 2001
From: Juergen Ributzka 
Date: Mon, 4 Dec 2023 13:54:57 -0800
Subject: [PATCH] [clang][modules] Reset codegen options (take 2).

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with
`-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  88 +--
 clang/include/clang/Basic/CodeGenOptions.h|   4 +
 clang/include/clang/Basic/DebugOptions.def| 146 ++
 clang/include/module.modulemap|   1 +
 clang/lib/Basic/CodeGenOptions.cpp|  35 +
 clang/lib/Frontend/CompilerInvocation.cpp |  13 ++
 clang/test/ClangScanDeps/strip-codegen-args.m |  58 +++
 7 files changed, 260 insertions(+), 85 deletions(-)
 create mode 100644 clang/include/clang/Basic/DebugOptions.def
 create mode 100644 clang/test/ClangScanDeps/strip-codegen-args.m

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed..0acb5ae134ea2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 

[clang] [clang][modules] Reset codegen options (take 2). (PR #74388)

2023-12-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Juergen Ributzka (ributzka)


Changes

CodeGen options do not affect the AST, so they usually can be ignored.
The only exception to the rule is when a PCM is created with
`-gmodules`.
In that case the Clang module format is switched to object file
container and contains also serialized debug information that can be
affected by debug options. There the following approach was choosen:

1.) Split out all the debug options into a separate `DebugOptions.def`
file. The file is included by `CodeGenOptions.def`, so the change is
transparent to all existing users of `CodeGenOptions.def`.
2.) Reset all CodeGen options, but excluding affecting debug options.
3.) Conditionally reset debug options that can affect the PCM.

This fixes rdar://113135909.


---

Patch is 21.40 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/74388.diff


7 Files Affected:

- (modified) clang/include/clang/Basic/CodeGenOptions.def (+3-85) 
- (modified) clang/include/clang/Basic/CodeGenOptions.h (+4) 
- (added) clang/include/clang/Basic/DebugOptions.def (+146) 
- (modified) clang/include/module.modulemap (+1) 
- (modified) clang/lib/Basic/CodeGenOptions.cpp (+35) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+13) 
- (added) clang/test/ClangScanDeps/strip-codegen-args.m (+58) 


``diff
diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 675645cd534ed..0acb5ae134ea2 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -28,12 +28,8 @@ CODEGENOPT(Name, Bits, Default)
 #endif
 
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
-ENUM_CODEGENOPT(CompressDebugSections, llvm::DebugCompressionType, 2,
-llvm::DebugCompressionType::None)
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
-CODEGENOPT(Dwarf64   , 1, 0) ///< -gdwarf64.
-CODEGENOPT(Dwarf32   , 1, 1) ///< -gdwarf32.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new
 CODEGENOPT(AssumeUniqueVTables , 1, 1) ///< Assume a class has only one vtable.
@@ -73,10 +69,6 @@ CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug 
information for the new
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
-CODEGENOPT(EnableDIPreservationVerify, 1, 0) ///< Enable di preservation verify
- ///< each (it means check
- ///< the original debug info
- ///< metadata preservation).
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs
  ///< is specified.
 CODEGENOPT(DisableTailCalls  , 1, 0) ///< Do not emit tail calls.
@@ -113,16 +105,10 @@ CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if 
-mindirect-branch-cs-prefix
 CODEGENOPT(XRayInstrumentFunctions , 1, 0) ///< Set when -fxray-instrument is
///< enabled.
 CODEGENOPT(StackSizeSection  , 1, 0) ///< Set when -fstack-size-section is 
enabled.
-CODEGENOPT(ForceDwarfFrameSection , 1, 0) ///< Set when -fforce-dwarf-frame is
-  ///< enabled.
 
 ///< Set when -femit-compact-unwind-non-canonical is enabled.
 CODEGENOPT(EmitCompactUnwindNonCanonical, 1, 0)
 
-///< Set when -femit-dwarf-unwind is passed.
-ENUM_CODEGENOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
-llvm::EmitDwarfUnwindType::Default)
-
 ///< Set when -fxray-always-emit-customevents is enabled.
 CODEGENOPT(XRayAlwaysEmitCustomEvents , 1, 0)
 
@@ -178,8 +164,6 @@ CODEGENOPT(IncrementalLinkerCompatible, 1, 0) ///< Emit an 
object file which can
 CODEGENOPT(MergeAllConstants , 1, 1) ///< Merge identical constants.
 CODEGENOPT(MergeFunctions, 1, 0) ///< Set when -fmerge-functions is 
enabled.
 CODEGENOPT(NoCommon  , 1, 0) ///< Set when -fno-common or C++ is 
enabled.
-CODEGENOPT(NoDwarfDirectoryAsm , 1, 0) ///< Set when -fno-dwarf-directory-asm 
is
-   ///< enabled.
 CODEGENOPT(NoExecStack   , 1, 0) ///< Set when -Wa,--noexecstack is 
enabled.
 CODEGENOPT(FatalWarnings , 1, 0) ///< Set when -Wa,--fatal-warnings is
  ///< enabled.
@@ -187,8 +171,6 @@ CODEGENOPT(NoWarn, 1, 0) ///< Set when 
-Wa,--no-warn is enabled.
 CODEGENOPT(NoTypeCheck   , 1, 0) ///< Set when -Wa,--no-type-check is 
enabled.
 CODEGENOPT(MisExpect , 1, 0) ///< Set when -Wmisexpect is en

[clang] Thread safety analysis: Fix a bug in handling temporary constructors (PR #74020)

2023-12-04 Thread Aaron Puchert via cfe-commits


@@ -1530,7 +1532,6 @@ void ThreadSafetyAnalyzer::getEdgeLockset(FactSet& Result,
 }
 
 namespace {
-

aaronpuchert wrote:

Nitpick: can you undo the whitespace change?

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


[clang] Thread safety analysis: Fix a bug in handling temporary constructors (PR #74020)

2023-12-04 Thread Aaron Puchert via cfe-commits


@@ -2487,15 +2486,15 @@ void 
ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
 
   // Clean up constructed object even if there are no attributes to
   // keep the number of objects in limbo as small as possible.
-  if (auto Object = LocksetBuilder.ConstructedObjects.find(
+  if (auto Object = LocksetBuilder.Analyzer->ConstructedObjects.find(
   TD.getBindTemporaryExpr()->getSubExpr());
-  Object != LocksetBuilder.ConstructedObjects.end()) {
+  Object != LocksetBuilder.Analyzer->ConstructedObjects.end()) {
 const auto *DD = TD.getDestructorDecl(AC.getASTContext());
 if (DD->hasAttrs())
   // TODO: the location here isn't quite correct.
   LocksetBuilder.handleCall(nullptr, DD, Object->second,
 
TD.getBindTemporaryExpr()->getEndLoc());
-LocksetBuilder.ConstructedObjects.erase(Object);
+LocksetBuilder.Analyzer->ConstructedObjects.erase(Object);

aaronpuchert wrote:

We're in `ThreadSafetyAnalyzer` here, so you should be able to drop 
`LocksetBuilder.Analyzer->` and refer to the member directly.

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


[compiler-rt] [llvm] [clang] [libcxx] [mlir] [flang] [clang-tools-extra] [mlir] Fix a zero stride canonicalizer crash (PR #74200)

2023-12-04 Thread Kai Sasaki via cfe-commits

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

Thanks for the update. It LGTM.

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


[clang] 924f6ca - [clang-format] Remove duplicates in @property using std::set (#74235)

2023-12-04 Thread via cfe-commits

Author: Owen Pan
Date: 2023-12-04T16:33:20-08:00
New Revision: 924f6ca1bdc49efe776d7f5cfd43d421b65346ba

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

LOG: [clang-format] Remove duplicates in @property using std::set (#74235)

Re-implement ObjCPropertyAttributeOrder using std::set for sorting and
removing duplicates. (We can't use llvm::SmallSet because it's
unordered.)

Added: 


Modified: 
clang/lib/Format/ObjCPropertyAttributeOrderFixer.cpp
clang/lib/Format/ObjCPropertyAttributeOrderFixer.h
clang/unittests/Format/ObjCPropertyAttributeOrderFixerTest.cpp

Removed: 




diff  --git a/clang/lib/Format/ObjCPropertyAttributeOrderFixer.cpp 
b/clang/lib/Format/ObjCPropertyAttributeOrderFixer.cpp
index 20108306f1039..c91d6251425ea 100644
--- a/clang/lib/Format/ObjCPropertyAttributeOrderFixer.cpp
+++ b/clang/lib/Format/ObjCPropertyAttributeOrderFixer.cpp
@@ -15,8 +15,6 @@
 
 #include "ObjCPropertyAttributeOrderFixer.h"
 
-#include "llvm/ADT/Sequence.h"
-
 #include 
 
 namespace clang {
@@ -25,26 +23,20 @@ namespace format {
 ObjCPropertyAttributeOrderFixer::ObjCPropertyAttributeOrderFixer(
 const Environment &Env, const FormatStyle &Style)
 : TokenAnalyzer(Env, Style) {
-
   // Create an "order priority" map to use to sort properties.
-  unsigned index = 0;
+  unsigned Index = 0;
   for (const auto &Property : Style.ObjCPropertyAttributeOrder)
-SortOrderMap[Property] = index++;
+SortOrderMap[Property] = Index++;
 }
 
 struct ObjCPropertyEntry {
-  StringRef Attribute; // eg, "readwrite"
-  StringRef Value; // eg, the "foo" of the attribute "getter=foo"
+  StringRef Attribute; // eg, `readwrite`
+  StringRef Value; // eg, the `foo` of the attribute `getter=foo`
 };
 
-static bool isObjCPropertyAttribute(const FormatToken *Tok) {
-  // Most attributes look like identifiers, but `class` is a keyword.
-  return Tok->isOneOf(tok::identifier, tok::kw_class);
-}
-
 void ObjCPropertyAttributeOrderFixer::sortPropertyAttributes(
 const SourceManager &SourceMgr, tooling::Replacements &Fixes,
-const FormatToken *BeginTok, const FormatToken *EndTok) const {
+const FormatToken *BeginTok, const FormatToken *EndTok) {
   assert(BeginTok);
   assert(EndTok);
   assert(EndTok->Previous);
@@ -53,8 +45,16 @@ void ObjCPropertyAttributeOrderFixer::sortPropertyAttributes(
   if (BeginTok == EndTok || BeginTok->Next == EndTok)
 return;
 
+  // Use a set to sort attributes and remove duplicates.
+  std::set Ordinals;
+
+  // Create a "remapping index" on how to reorder the attributes.
+  SmallVector Indices;
+
   // Collect the attributes.
-  SmallVector PropertyAttributes;
+  SmallVector PropertyAttributes;
+  bool HasDuplicates = false;
+  int Index = 0;
   for (auto Tok = BeginTok; Tok != EndTok; Tok = Tok->Next) {
 assert(Tok);
 if (Tok->is(tok::comma)) {
@@ -62,13 +62,14 @@ void 
ObjCPropertyAttributeOrderFixer::sortPropertyAttributes(
   continue;
 }
 
-if (!isObjCPropertyAttribute(Tok)) {
+// Most attributes look like identifiers, but `class` is a keyword.
+if (!Tok->isOneOf(tok::identifier, tok::kw_class)) {
   // If we hit any other kind of token, just bail.
   return;
 }
 
-// Memoize the attribute. (Note that 'class' is a legal attribute!)
-PropertyAttributes.push_back({Tok->TokenText, StringRef{}});
+const StringRef Attribute{Tok->TokenText};
+StringRef Value;
 
 // Also handle `getter=getFoo` attributes.
 // (Note: no check needed against `EndTok`, since its type is not
@@ -82,49 +83,66 @@ void 
ObjCPropertyAttributeOrderFixer::sortPropertyAttributes(
 return;
   }
   Tok = Tok->Next;
-  PropertyAttributes.back().Value = Tok->TokenText;
+  Value = Tok->TokenText;
+}
+
+auto It = SortOrderMap.find(Attribute);
+if (It == SortOrderMap.end())
+  It = SortOrderMap.insert({Attribute, SortOrderMap.size()}).first;
+
+// Sort the indices based on the priority stored in `SortOrderMap`.
+const auto Ordinal = It->second;
+if (!Ordinals.insert(Ordinal).second) {
+  HasDuplicates = true;
+  continue;
 }
+
+if (Ordinal >= Indices.size())
+  Indices.resize(Ordinal + 1);
+Indices[Ordinal] = Index++;
+
+// Memoize the attribute.
+PropertyAttributes.push_back({Attribute, Value});
   }
 
-  // There's nothing to do unless there's more than one attribute.
-  if (PropertyAttributes.size() < 2)
-return;
+  if (!HasDuplicates) {
+// There's nothing to do unless there's more than one attribute.
+if (PropertyAttributes.size() < 2)
+  return;
 
-  // Create a "remapping index" on how to reorder the attributes.
-  SmallVector Indices =
-  llvm::to_vector<8>(llvm::seq(0, PropertyAttributes.size()));
-
-  // So

[clang] [clang-format] Remove duplicates in @property using std::set (PR #74235)

2023-12-04 Thread Owen Pan via cfe-commits

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


[clang] [llvm] [SimplifyCFG] Not folding branch in loop header with constant iterations (PR #74268)

2023-12-04 Thread via cfe-commits

bcl5980 wrote:

AMDGPU can not unorll this case:

https://godbolt.org/z/4Pq3bnzTT

But the same code in X86 looks can unroll:

https://godbolt.org/z/zr8aTG1KW

We may need to continue debug on it.

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


[llvm] [clang] [SimplifyCFG] Not folding branch in loop header with constant iterations (PR #74268)

2023-12-04 Thread via cfe-commits

xiangzh1 wrote:

> AMDGPU can not unorll this case:
> 
> https://godbolt.org/z/4Pq3bnzTT
> 
> But the same code in X86 looks can unroll:
> 
> https://godbolt.org/z/zr8aTG1KW
> 
> We may need to continue debug on it.

X86 do very conservative unroll too,its upper bound send to 4 (default is 8), 
if we not fold the loop branch, it can fully unroll (16)

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


[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)

2023-12-04 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/74399

This is a minor improvement to #73491.

>From ee039e7c50751fabdbaadae73a0a09bc905620f2 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Mon, 4 Dec 2023 17:33:47 -0800
Subject: [PATCH] [clang-format][NFC] Use `prog` in clang-format-diff.py

This is a minor improvement to #73491.
---
 clang/tools/clang-format/clang-format-diff.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/tools/clang-format/clang-format-diff.py 
b/clang/tools/clang-format/clang-format-diff.py
index b25ee8f433751..946e28163420d 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -37,9 +37,8 @@
 
 
 def main():
-basename = os.path.basename(sys.argv[0])
 parser = argparse.ArgumentParser(
-description=__doc__.format(clang_format_diff=basename),
+description=__doc__.format(clang_format_diff='%(prog)s'),
 formatter_class=argparse.RawDescriptionHelpFormatter,
 )
 parser.add_argument(

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


[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)

2023-12-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

This is a minor improvement to #73491.

---
Full diff: https://github.com/llvm/llvm-project/pull/74399.diff


1 Files Affected:

- (modified) clang/tools/clang-format/clang-format-diff.py (+1-2) 


``diff
diff --git a/clang/tools/clang-format/clang-format-diff.py 
b/clang/tools/clang-format/clang-format-diff.py
index b25ee8f433751..946e28163420d 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -37,9 +37,8 @@
 
 
 def main():
-basename = os.path.basename(sys.argv[0])
 parser = argparse.ArgumentParser(
-description=__doc__.format(clang_format_diff=basename),
+description=__doc__.format(clang_format_diff='%(prog)s'),
 formatter_class=argparse.RawDescriptionHelpFormatter,
 )
 parser.add_argument(

``




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


[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)

2023-12-04 Thread via cfe-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
192439db6e3fcccf98c850bda1b970a11c590bbb..ee039e7c50751fabdbaadae73a0a09bc905620f2
 clang/tools/clang-format/clang-format-diff.py
``





View the diff from darker here.


``diff
--- clang-format-diff.py2023-12-05 01:33:47.00 +
+++ clang-format-diff.py2023-12-05 01:40:08.802548 +
@@ -36,11 +36,11 @@
 from io import BytesIO as StringIO
 
 
 def main():
 parser = argparse.ArgumentParser(
-description=__doc__.format(clang_format_diff='%(prog)s'),
+description=__doc__.format(clang_format_diff="%(prog)s"),
 formatter_class=argparse.RawDescriptionHelpFormatter,
 )
 parser.add_argument(
 "-i",
 action="store_true",

``




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


[clang] [clang-format][NFC] Use `prog` in clang-format-diff.py (PR #74399)

2023-12-04 Thread Owen Pan via cfe-commits

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/74399

>From ee039e7c50751fabdbaadae73a0a09bc905620f2 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Mon, 4 Dec 2023 17:33:47 -0800
Subject: [PATCH 1/2] [clang-format][NFC] Use `prog` in clang-format-diff.py

This is a minor improvement to #73491.
---
 clang/tools/clang-format/clang-format-diff.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/tools/clang-format/clang-format-diff.py 
b/clang/tools/clang-format/clang-format-diff.py
index b25ee8f433751..946e28163420d 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -37,9 +37,8 @@
 
 
 def main():
-basename = os.path.basename(sys.argv[0])
 parser = argparse.ArgumentParser(
-description=__doc__.format(clang_format_diff=basename),
+description=__doc__.format(clang_format_diff='%(prog)s'),
 formatter_class=argparse.RawDescriptionHelpFormatter,
 )
 parser.add_argument(

>From d8b2dab602b41deda70abd0f219ca88d5fd69c36 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Mon, 4 Dec 2023 17:41:58 -0800
Subject: [PATCH 2/2] Use double quotes instead.

---
 clang/tools/clang-format/clang-format-diff.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/tools/clang-format/clang-format-diff.py 
b/clang/tools/clang-format/clang-format-diff.py
index 946e28163420d..9f3538608aaba 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -38,7 +38,7 @@
 
 def main():
 parser = argparse.ArgumentParser(
-description=__doc__.format(clang_format_diff='%(prog)s'),
+description=__doc__.format(clang_format_diff="%(prog)s"),
 formatter_class=argparse.RawDescriptionHelpFormatter,
 )
 parser.add_argument(

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


[clang] [llvm] [SimplifyCFG] Not folding branch in loop header with constant iterations (PR #74268)

2023-12-04 Thread via cfe-commits

xiangzh1 wrote:

I think we should follow this principle:
if a loop required to be unroll later, we should not distroy the loop count 
info.

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


  1   2   3   4   >