[clang] [lld] [llvm] [mlir] [IR] Introduce `U` to `DataLayout` to represent undesirable address space if a target has it (PR #108786)

2024-10-26 Thread Shilei Tian via cfe-commits

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


[clang] [lld] [llvm] [mlir] [IR] Introduce `U` to `DataLayout` to represent undesirable address space if a target has it (PR #108786)

2024-10-26 Thread Shilei Tian via cfe-commits

shiltian wrote:

It seems like we can’t reach consensus on how to move forward with this. I 
already worked my issue around so I guess we no longer need this PR.

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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Peilin Ye via cfe-commits

https://github.com/peilin-ye updated 
https://github.com/llvm/llvm-project/pull/108636

>From 8ab5d1c2e36dfa44be637478deeabaa4f586dcee Mon Sep 17 00:00:00 2001
From: Peilin Ye 
Date: Sat, 5 Oct 2024 06:44:21 +
Subject: [PATCH 1/3] [BPF] Rename isST*() and isLD*() functions in
 BPFMISimplifyPatchable.cpp (NFC)

We are planning to add load (specifically, atomic acquiring load, or
"load-acquire") instructions under the STX instruction class.  To make
that easier, rename the isST*() and isLD*() helper functions based on
what the instructions actually do, rather than their instruction class.
---
 .../lib/Target/BPF/BPFMISimplifyPatchable.cpp | 22 +--
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp 
b/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp
index 39390e8c38f8c1..4a1684ccebb793 100644
--- a/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp
+++ b/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp
@@ -94,35 +94,35 @@ void BPFMISimplifyPatchable::initialize(MachineFunction 
&MFParm) {
   LLVM_DEBUG(dbgs() << "*** BPF simplify patchable insts pass ***\n\n");
 }
 
-static bool isST(unsigned Opcode) {
+static bool isStoreImm(unsigned Opcode) {
   return Opcode == BPF::STB_imm || Opcode == BPF::STH_imm ||
  Opcode == BPF::STW_imm || Opcode == BPF::STD_imm;
 }
 
-static bool isSTX32(unsigned Opcode) {
+static bool isStore32(unsigned Opcode) {
   return Opcode == BPF::STB32 || Opcode == BPF::STH32 || Opcode == BPF::STW32;
 }
 
-static bool isSTX64(unsigned Opcode) {
+static bool isStore64(unsigned Opcode) {
   return Opcode == BPF::STB || Opcode == BPF::STH || Opcode == BPF::STW ||
  Opcode == BPF::STD;
 }
 
-static bool isLDX32(unsigned Opcode) {
+static bool isLoad32(unsigned Opcode) {
   return Opcode == BPF::LDB32 || Opcode == BPF::LDH32 || Opcode == BPF::LDW32;
 }
 
-static bool isLDX64(unsigned Opcode) {
+static bool isLoad64(unsigned Opcode) {
   return Opcode == BPF::LDB || Opcode == BPF::LDH || Opcode == BPF::LDW ||
  Opcode == BPF::LDD;
 }
 
-static bool isLDSX(unsigned Opcode) {
+static bool isLoadSext(unsigned Opcode) {
   return Opcode == BPF::LDBSX || Opcode == BPF::LDHSX || Opcode == BPF::LDWSX;
 }
 
 bool BPFMISimplifyPatchable::isLoadInst(unsigned Opcode) {
-  return isLDX32(Opcode) || isLDX64(Opcode) || isLDSX(Opcode);
+  return isLoad32(Opcode) || isLoad64(Opcode) || isLoadSext(Opcode);
 }
 
 void BPFMISimplifyPatchable::checkADDrr(MachineRegisterInfo *MRI,
@@ -143,11 +143,11 @@ void 
BPFMISimplifyPatchable::checkADDrr(MachineRegisterInfo *MRI,
 MachineInstr *DefInst = MO.getParent();
 unsigned Opcode = DefInst->getOpcode();
 unsigned COREOp;
-if (isLDX64(Opcode) || isLDSX(Opcode))
+if (isLoad64(Opcode) || isLoadSext(Opcode))
   COREOp = BPF::CORE_LD64;
-else if (isLDX32(Opcode))
+else if (isLoad32(Opcode))
   COREOp = BPF::CORE_LD32;
-else if (isSTX64(Opcode) || isSTX32(Opcode) || isST(Opcode))
+else if (isStore64(Opcode) || isStore32(Opcode) || isStoreImm(Opcode))
   COREOp = BPF::CORE_ST;
 else
   continue;
@@ -160,7 +160,7 @@ void BPFMISimplifyPatchable::checkADDrr(MachineRegisterInfo 
*MRI,
 // Reject the form:
 //   %1 = ADD_rr %2, %3
 //   *(type *)(%2 + 0) = %1
-if (isSTX64(Opcode) || isSTX32(Opcode)) {
+if (isStore64(Opcode) || isStore32(Opcode)) {
   const MachineOperand &Opnd = DefInst->getOperand(0);
   if (Opnd.isReg() && Opnd.getReg() == MO.getReg())
 continue;

>From 4b3b71ffebca7fcc1c083e9f269f08332cbdff0b Mon Sep 17 00:00:00 2001
From: Peilin Ye 
Date: Sat, 5 Oct 2024 07:31:54 +
Subject: [PATCH 2/3] [BPF] Add load-acquire and store-release instructions
 under -mcpu=v4

As discussed in [1], introduce BPF instructions with load-acquire and
store-release semantics under -mcpu=v4.

The following new flags are defined:

  BPF_ATOMIC_LOAD   0x10
  BPF_ATOMIC_STORE  0x20

  BPF_RELAXED:   0x0
  BPF_CONSUME:   0x1
  BPF_ACQUIRE:   0x2
  BPF_RELEASE:   0x3
  BPF_ACQ_REL:   0x4
  BPF_SEQ_CST:   0x5

A "load-acquire" is a BPF_STX | BPF_ATOMIC instruction with the 'imm'
field set to BPF_ATOMIC_LOAD | BPF_ACQUIRE (0x12).

Similarly, a "store-release" is a BPF_STX | BPF_ATOMIC instruction with
the 'imm' field set to BPF_ATOMIC_STORE | BPF_RELEASE (0x23).

Unlike existing atomic operations that only support BPF_W (32-bit) and
BPF_DW (64-bit) size modifiers, load-acquires and store-releases also
support BPF_B (8-bit) and BPF_H (16-bit).  An 8- or 16-bit load-acquire
zero-extends the value before writing it to a 32-bit register, just like
ARM64 instruction LDAPRH and friends.

As an example, for -march=bpfel (big-endian):

  long foo(long *ptr) {
  return __atomic_load_n(ptr, __ATOMIC_ACQUIRE);
  }

foo() can be compiled to:

  db 10 00 00 12 00 00 00  r0 = load_acquire((u64 *)(r1 + 0x0))
  95 00 00 00 00 00 00 00  exit

  opcode (0xdb): BPF_ATOMIC | BPF_DW | BPF_STX
  imm (

[clang] [clang][bytecode][NFC] Make CheckVolatile static (PR #113785)

2024-10-26 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-aarch64-quick` 
running on `linaro-clang-aarch64-quick` while building `clang` at step 5 "ninja 
check 1".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/65/builds/6735


Here is the relevant piece of the build log for the reference

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clangd Unit Tests :: ./ClangdTests/248/316' FAILED 

Script(shard):
--
GTEST_OUTPUT=json:/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests-Clangd
 Unit Tests-2252767-248-316.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=316 
GTEST_SHARD_INDEX=248 
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests
--

Note: This is test shard 249 of 316.
[==] Running 4 tests from 4 test suites.
[--] Global test environment set-up.
[--] 1 test from CommandMangler
[ RUN  ] CommandMangler.Sysroot
[   OK ] CommandMangler.Sysroot (46 ms)
[--] 1 test from CommandMangler (46 ms total)

[--] 1 test from GlobalCompilationDatabaseTest
[ RUN  ] GlobalCompilationDatabaseTest.FallbackCommand
[   OK ] GlobalCompilationDatabaseTest.FallbackCommand (31 ms)
[--] 1 test from GlobalCompilationDatabaseTest (31 ms total)

[--] 1 test from CrossFileRenameTests
[ RUN  ] CrossFileRenameTests.WithUpToDateIndex
ASTWorker building file /clangd-test/foo.h version null with command 
[/clangd-test]
clang -xobjective-c++ /clangd-test/foo.h
Driver produced command: cc1 -cc1 -triple aarch64-unknown-linux-gnu 
-fsyntax-only -disable-free -clear-ast-before-backend -main-file-name foo.h 
-mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=non-leaf 
-fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases 
-funwind-tables=2 -target-cpu generic -target-feature +v8a -target-feature 
+fp-armv8 -target-feature +neon -target-abi aapcs -debugger-tuning=gdb 
-fdebug-compilation-dir=/clangd-test -fcoverage-compilation-dir=/clangd-test 
-resource-dir lib/clang/20 -internal-isystem lib/clang/20/include 
-internal-isystem /usr/local/include -internal-externc-isystem /include 
-internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 
-fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf 
-fobjc-runtime=gcc -fobjc-encode-cxx-class-template-spec -fobjc-exceptions 
-fcxx-exceptions -fexceptions -no-round-trip-args -target-feature -fmv 
-faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x objective-c++ /clangd-test/foo.h
Building first preamble for /clangd-test/foo.h version null
Built preamble of size 714228 for file /clangd-test/foo.h version null in 0.40 
seconds
indexed preamble AST for /clangd-test/foo.h version null:
  symbol slab: 0 symbols, 120 bytes
  ref slab: 0 symbols, 0 refs, 128 bytes
  relations slab: 0 relations, 24 bytes
not idle after addDocument
UNREACHABLE executed at 
../llvm/clang-tools-extra/clangd/unittests/SyncAPI.cpp:22!
indexed file AST for /clangd-test/foo.h version null:
  symbol slab: 3 symbols, 4912 bytes
  ref slab: 3 symbols, 5 refs, 4320 bytes
  relations slab: 0 relations, 24 bytes
Build dynamic index for main-file symbols with estimated memory usage of 12648 
bytes
 #0 0xdc88d6d4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xfca6d4)
 #1 0xdc88b6e0 llvm::sys::RunSignalHandlers() 
(/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xfc86e0)
 #2 0xdc88de20 SignalHandler(int) Signals.cpp:0:0
 #3 0x86df6598 (linux-vdso.so.1+0x598)
 #4 0x8695f200 __pthread_kill_implementation 
./nptl/./nptl/pthread_kill.c:44:76
 #5 0x8691a67c gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #6 0x86907130 abort ./stdlib/./stdlib/abort.c:81:7
 #7 0xdc83b424 llvm::RTTIRoot::anchor() 
(/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xf78424)
 #8 0xdc6f945c 
clang::clangd::runCodeComplete(clang::clangd::ClangdServer&, llvm::StringRef, 
clang::clangd::Position, clang::clangd::CodeCompleteOptions) 
(/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0xe3645c)
 #9 0xdc650e08 clang::clangd::(anonymous 
namespace)::CrossFileRenameTests_WithUpToDateIndex_Test::TestBody() 
RenameTests.cpp:0:0
#10 0xdc8e823c testing::Test::Run() 
(/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x102523c)
#11 0xdc8e94f8 testing::TestInfo::Run() 
(/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/tools/clang/tools/extra/clangd/unittests/./ClangdTests+0x10264f8)
...

```



https://

[clang] [Clang] prevent assertion failure from an invalid template instantiation pattern when adding instantiated params to the scope in friend functions with defaulted params (PR #113777)

2024-10-26 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/113777

>From 78019b9d9dc138f38bb5b32576b621351ae6427c Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 27 Oct 2024 01:07:57 +0300
Subject: [PATCH] [Clang] prevent assertion failure from an invalid template
 instantiation pattern when adding instantiated params to the scope in friend
 functions with defaulted params

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 
 clang/test/CXX/temp/temp.res/p4.cpp| 7 +++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6a95337815174b..428ec8c87a432e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Bug Fixes to C++ Support
   const-default-constructible even if a union member has a default member 
initializer.
   (#GH95854).
 - Fixed an assertion failure when evaluating an invalid expression in an array 
initializer (#GH112140)
+- Fixed an assertion failure caused by an invalid template instantiation 
pattern
+  for adding instantiated parameters to the scope in friend functions with 
defaulted parameters. (#GH113324).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 6a55861fe5af3b..cddfcc48312042 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3435,10 +3435,10 @@ bool Sema::SubstDefaultArgument(
   //   template void f(T a, int = decltype(a)());
   //   void g() { f(0); }
   LIS = std::make_unique(*this);
-  FunctionDecl *PatternFD = FD->getTemplateInstantiationPattern(
-  /*ForDefinition*/ false);
-  if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
-return true;
+  if (FunctionDecl *PatternFD =
+  FD->getTemplateInstantiationPattern(/*ForDefinition*/ false))
+if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, 
TemplateArgs))
+  return true;
 }
 
 runWithSufficientStackSpace(Loc, [&] {
diff --git a/clang/test/CXX/temp/temp.res/p4.cpp 
b/clang/test/CXX/temp/temp.res/p4.cpp
index f54d8649f5da88..62bd766e7e1140 100644
--- a/clang/test/CXX/temp/temp.res/p4.cpp
+++ b/clang/test/CXX/temp/temp.res/p4.cpp
@@ -185,3 +185,10 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct ct {
+  friend void f(ct, int = 0); // expected-error {{friend declaration 
specifying a default argument must be a definition}}
+};
+void test() { f(ct<>{}); }
+}

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


[clang] Draft (PR #113796)

2024-10-26 Thread via cfe-commits

https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/113796

None

>From aa9e5c50287aa3d60fe1145ccda6b1e5f90c53a8 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Sun, 27 Oct 2024 14:15:23 +0800
Subject: [PATCH] add Binary search operations (on sorted ranges)

---
 clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index b46bd2e4d7a4b5..48d1afc378d54f 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -3547,6 +3547,7 @@ SYMBOL(as_rvalue_view, std::ranges::, )
 SYMBOL(basic_istream_view, std::ranges::, )
 SYMBOL(begin, std::ranges::, )
 SYMBOL(bidirectional_range, std::ranges::, )
+SYMBOL(binary_search, std::ranges::, )
 SYMBOL(binary_transform_result, std::ranges::, )
 SYMBOL(borrowed_iterator_t, std::ranges::, )
 SYMBOL(borrowed_range, std::ranges::, )
@@ -3592,6 +3593,7 @@ SYMBOL(enable_view, std::ranges::, )
 SYMBOL(end, std::ranges::, )
 SYMBOL(ends_with, std::ranges::, )
 SYMBOL(equal, std::ranges::, )
+SYMBOL(equal_range, std::ranges::, )
 SYMBOL(equal_to, std::ranges::, )
 SYMBOL(fill, std::ranges::, )
 SYMBOL(fill_n, std::ranges::, )
@@ -3643,6 +3645,7 @@ SYMBOL(lazy_split_view, std::ranges::, )
 SYMBOL(less, std::ranges::, )
 SYMBOL(less_equal, std::ranges::, )
 SYMBOL(lexicographical_compare, std::ranges::, )
+SYMBOL(lower_bound, std::ranges::, )
 SYMBOL(make_heap, std::ranges::, )
 SYMBOL(max, std::ranges::, )
 SYMBOL(max_element, std::ranges::, )
@@ -3765,6 +3768,7 @@ SYMBOL(uninitialized_value_construct_n, std::ranges::, 
)
 SYMBOL(unique, std::ranges::, )
 SYMBOL(unique_copy, std::ranges::, )
 SYMBOL(unique_copy_result, std::ranges::, )
+SYMBOL(upper_bound, std::ranges::, )
 SYMBOL(values_view, std::ranges::, )
 SYMBOL(view, std::ranges::, )
 SYMBOL(view_base, std::ranges::, )

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


[clang] [Tooling/Inclusion] Add binary search related `std::range` symbols to the mapping. (PR #113796)

2024-10-26 Thread via cfe-commits

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


[clang] [Tooling/Inclusion] Add binary search related `std::range` symbols to the mapping. (PR #113796)

2024-10-26 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (c8ef)


Changes

Fixes #94459.

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


1 Files Affected:

- (modified) clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc (+4) 


``diff
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index b46bd2e4d7a4b5..48d1afc378d54f 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -3547,6 +3547,7 @@ SYMBOL(as_rvalue_view, std::ranges::, )
 SYMBOL(basic_istream_view, std::ranges::, )
 SYMBOL(begin, std::ranges::, )
 SYMBOL(bidirectional_range, std::ranges::, )
+SYMBOL(binary_search, std::ranges::, )
 SYMBOL(binary_transform_result, std::ranges::, )
 SYMBOL(borrowed_iterator_t, std::ranges::, )
 SYMBOL(borrowed_range, std::ranges::, )
@@ -3592,6 +3593,7 @@ SYMBOL(enable_view, std::ranges::, )
 SYMBOL(end, std::ranges::, )
 SYMBOL(ends_with, std::ranges::, )
 SYMBOL(equal, std::ranges::, )
+SYMBOL(equal_range, std::ranges::, )
 SYMBOL(equal_to, std::ranges::, )
 SYMBOL(fill, std::ranges::, )
 SYMBOL(fill_n, std::ranges::, )
@@ -3643,6 +3645,7 @@ SYMBOL(lazy_split_view, std::ranges::, )
 SYMBOL(less, std::ranges::, )
 SYMBOL(less_equal, std::ranges::, )
 SYMBOL(lexicographical_compare, std::ranges::, )
+SYMBOL(lower_bound, std::ranges::, )
 SYMBOL(make_heap, std::ranges::, )
 SYMBOL(max, std::ranges::, )
 SYMBOL(max_element, std::ranges::, )
@@ -3765,6 +3768,7 @@ SYMBOL(uninitialized_value_construct_n, std::ranges::, 
)
 SYMBOL(unique, std::ranges::, )
 SYMBOL(unique_copy, std::ranges::, )
 SYMBOL(unique_copy_result, std::ranges::, )
+SYMBOL(upper_bound, std::ranges::, )
 SYMBOL(values_view, std::ranges::, )
 SYMBOL(view, std::ranges::, )
 SYMBOL(view_base, std::ranges::, )

``




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


[clang] [Tooling/Inclusion] Add binary search related `std::range` symbols to the mapping. (PR #113796)

2024-10-26 Thread via cfe-commits

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


[clang] [Tooling/Inclusion] Add binary search related `std::range` symbols to the mapping. (PR #113796)

2024-10-26 Thread via cfe-commits

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


[clang] [llvm] [RISCV]Add svvptc extension (PR #113758)

2024-10-26 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-backend-risc-v

@llvm/pr-subscribers-clang-driver

Author: None (dong-miao)


Changes

This commit adds the Obviating Memory-Management Instructions after Marking 
PTEs Valid (Svvptc) extension.
Specification 
link:[https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc](https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc)

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


7 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+9) 
- (modified) llvm/docs/RISCVUsage.rst (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+4) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+3) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 342d6e921a5a83..2d7376f8fe9401 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -146,6 +146,7 @@
 // CHECK-NEXT: svinval  1.0   'Svinval' (Fine-Grained 
Address-Translation Cache Invalidation)
 // CHECK-NEXT: svnapot  1.0   'Svnapot' (NAPOT Translation 
Contiguity)
 // CHECK-NEXT: svpbmt   1.0   'Svpbmt' (Page-Based Memory 
Types)
+// CHECK-NEXT: svvptc   1.0   'Svvptc' (Obviating 
Memory-Management Instructions after Marking PTEs Valid)
 // CHECK-NEXT: xcvalu   1.0   'XCValu' (CORE-V ALU 
Operations)
 // CHECK-NEXT: xcvbi1.0   'XCVbi' (CORE-V Immediate 
Branching)
 // CHECK-NEXT: xcvbitmanip  1.0   'XCVbitmanip' (CORE-V Bit 
Manipulation)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 98ad564d2b8408..5b4d42b053edc6 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -51,6 +51,7 @@
 // CHECK-NOT: __riscv_svinval {{.*$}}
 // CHECK-NOT: __riscv_svnapot {{.*$}}
 // CHECK-NOT: __riscv_svpbmt {{.*$}}
+// CHECK-NOT: __riscv_svvptc {{.*$}}
 // CHECK-NOT: __riscv_v {{.*$}}
 // CHECK-NOT: __riscv_v_elen {{.*$}}
 // CHECK-NOT: __riscv_v_elen_fp {{.*$}}
@@ -507,6 +508,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
 // CHECK-SVPBMT-EXT: __riscv_svpbmt 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// CHECK-SVVPTC-EXT: __riscv_svvptc 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32iv1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index ab58cdaa1b2f95..958168772fe413 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -155,6 +155,7 @@ on support follow.
  ``Svinval``   Assembly Support
  ``Svnapot``   Assembly Support
  ``Svpbmt``Supported
+ ``Svvptc``Supported
  ``V`` Supported
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 778df542022f22..3b86bc69153631 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1029,6 +1029,10 @@ def FeatureStdExtSvpbmt
 : RISCVExtension<"svpbmt", 1, 0,
  "'Svpbmt' (Page-Based Memory Types)">;
 
+def FeatureStdExtSvvptc
+: RISCVExtension<"svvptc", 1, 0,
+ "'svvptc' (Obviating Memory-Management Instructions after 
Marking PTEs Valid)">; 
+
 // Pointer Masking extensions
 
 // A supervisor-level extension that provides pointer masking for the next 
lower
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index e9743d484f776f..2d07919e042edc 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -62,6 +62,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVNAPOT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVINVAL %s
+; RUN: llc -mtriple=riscv32 -mattr=+svvptc %s -o - | FileCheck 
--check-p

[clang] [llvm] [RISCV]Add svvptc extension (PR #113758)

2024-10-26 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: None (dong-miao)


Changes

This commit adds the Obviating Memory-Management Instructions after Marking 
PTEs Valid (Svvptc) extension.
Specification 
link:[https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc](https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc)

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


7 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) clang/test/Preprocessor/riscv-target-features.c (+9) 
- (modified) llvm/docs/RISCVUsage.rst (+1) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+4) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+4) 
- (modified) llvm/test/MC/RISCV/attribute-arch.s (+3) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 342d6e921a5a83..2d7376f8fe9401 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -146,6 +146,7 @@
 // CHECK-NEXT: svinval  1.0   'Svinval' (Fine-Grained 
Address-Translation Cache Invalidation)
 // CHECK-NEXT: svnapot  1.0   'Svnapot' (NAPOT Translation 
Contiguity)
 // CHECK-NEXT: svpbmt   1.0   'Svpbmt' (Page-Based Memory 
Types)
+// CHECK-NEXT: svvptc   1.0   'Svvptc' (Obviating 
Memory-Management Instructions after Marking PTEs Valid)
 // CHECK-NEXT: xcvalu   1.0   'XCValu' (CORE-V ALU 
Operations)
 // CHECK-NEXT: xcvbi1.0   'XCVbi' (CORE-V Immediate 
Branching)
 // CHECK-NEXT: xcvbitmanip  1.0   'XCVbitmanip' (CORE-V Bit 
Manipulation)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 98ad564d2b8408..5b4d42b053edc6 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -51,6 +51,7 @@
 // CHECK-NOT: __riscv_svinval {{.*$}}
 // CHECK-NOT: __riscv_svnapot {{.*$}}
 // CHECK-NOT: __riscv_svpbmt {{.*$}}
+// CHECK-NOT: __riscv_svvptc {{.*$}}
 // CHECK-NOT: __riscv_v {{.*$}}
 // CHECK-NOT: __riscv_v_elen {{.*$}}
 // CHECK-NOT: __riscv_v_elen_fp {{.*$}}
@@ -507,6 +508,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
 // CHECK-SVPBMT-EXT: __riscv_svpbmt 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// CHECK-SVVPTC-EXT: __riscv_svvptc 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32iv1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index ab58cdaa1b2f95..958168772fe413 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -155,6 +155,7 @@ on support follow.
  ``Svinval``   Assembly Support
  ``Svnapot``   Assembly Support
  ``Svpbmt``Supported
+ ``Svvptc``Supported
  ``V`` Supported
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 778df542022f22..3b86bc69153631 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1029,6 +1029,10 @@ def FeatureStdExtSvpbmt
 : RISCVExtension<"svpbmt", 1, 0,
  "'Svpbmt' (Page-Based Memory Types)">;
 
+def FeatureStdExtSvvptc
+: RISCVExtension<"svvptc", 1, 0,
+ "'svvptc' (Obviating Memory-Management Instructions after 
Marking PTEs Valid)">; 
+
 // Pointer Masking extensions
 
 // A supervisor-level extension that provides pointer masking for the next 
lower
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index e9743d484f776f..2d07919e042edc 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -62,6 +62,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVNAPOT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVINVAL %s
+; RUN: llc -mtriple=riscv32 -mattr=+svvptc %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVVPTC %s
 ; RUN: llc -mtrip

[clang] [llvm] [RISCV]Add svvptc extension (PR #113758)

2024-10-26 Thread via cfe-commits

https://github.com/dong-miao created 
https://github.com/llvm/llvm-project/pull/113758

This commit adds the Obviating Memory-Management Instructions after Marking 
PTEs Valid (Svvptc) extension.
Specification 
link:[https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc](https://github.com/riscv/riscv-isa-manual/blob/main/src/supervisor.adoc)

>From 6424bebfcf16ef9694d7406b0298045da2d426bf Mon Sep 17 00:00:00 2001
From: dong-miao <601183...@qq.com>
Date: Sat, 26 Oct 2024 06:49:04 +
Subject: [PATCH] [RISCV]Add svvptc extensions

---
 clang/test/Driver/print-supported-extensions-riscv.c | 1 +
 clang/test/Preprocessor/riscv-target-features.c  | 9 +
 llvm/docs/RISCVUsage.rst | 1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td   | 4 
 llvm/test/CodeGen/RISCV/attributes.ll| 4 
 llvm/test/MC/RISCV/attribute-arch.s  | 3 +++
 llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 1 +
 7 files changed, 23 insertions(+)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 342d6e921a5a83..2d7376f8fe9401 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -146,6 +146,7 @@
 // CHECK-NEXT: svinval  1.0   'Svinval' (Fine-Grained 
Address-Translation Cache Invalidation)
 // CHECK-NEXT: svnapot  1.0   'Svnapot' (NAPOT Translation 
Contiguity)
 // CHECK-NEXT: svpbmt   1.0   'Svpbmt' (Page-Based Memory 
Types)
+// CHECK-NEXT: svvptc   1.0   'Svvptc' (Obviating 
Memory-Management Instructions after Marking PTEs Valid)
 // CHECK-NEXT: xcvalu   1.0   'XCValu' (CORE-V ALU 
Operations)
 // CHECK-NEXT: xcvbi1.0   'XCVbi' (CORE-V Immediate 
Branching)
 // CHECK-NEXT: xcvbitmanip  1.0   'XCVbitmanip' (CORE-V Bit 
Manipulation)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 98ad564d2b8408..5b4d42b053edc6 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -51,6 +51,7 @@
 // CHECK-NOT: __riscv_svinval {{.*$}}
 // CHECK-NOT: __riscv_svnapot {{.*$}}
 // CHECK-NOT: __riscv_svpbmt {{.*$}}
+// CHECK-NOT: __riscv_svvptc {{.*$}}
 // CHECK-NOT: __riscv_v {{.*$}}
 // CHECK-NOT: __riscv_v_elen {{.*$}}
 // CHECK-NOT: __riscv_v_elen_fp {{.*$}}
@@ -507,6 +508,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
 // CHECK-SVPBMT-EXT: __riscv_svpbmt 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// CHECK-SVVPTC-EXT: __riscv_svvptc 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32iv1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index ab58cdaa1b2f95..958168772fe413 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -155,6 +155,7 @@ on support follow.
  ``Svinval``   Assembly Support
  ``Svnapot``   Assembly Support
  ``Svpbmt``Supported
+ ``Svvptc``Supported
  ``V`` Supported
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 778df542022f22..3b86bc69153631 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1029,6 +1029,10 @@ def FeatureStdExtSvpbmt
 : RISCVExtension<"svpbmt", 1, 0,
  "'Svpbmt' (Page-Based Memory Types)">;
 
+def FeatureStdExtSvvptc
+: RISCVExtension<"svvptc", 1, 0,
+ "'svvptc' (Obviating Memory-Management Instructions after 
Marking PTEs Valid)">; 
+
 // Pointer Masking extensions
 
 // A supervisor-level extension that provides pointer masking for the next 
lower
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index e9743d484f776f..2d07919e042edc 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -62,6 +62,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVNAPOT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-pr

[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits


@@ -143,32 +165,33 @@ def _GetSymbols(pool, root_dir, index_page_name, 
namespace, variants_to_accept):
 with open(index_page_path, "r") as f:
 # Read each symbol page in parallel.
 results = []  # (symbol_name, promise of [header...])
+symbols_by_page = collections.defaultdict(list)

vvd170501 wrote:

On my machine it took about 3 minutes for the generator to run, so I tried to 
optimize it by grouping symbols that are defined on the same page (now it takes 
2 minutes).
If the diff is too large or complex, I can move the commit with optimizations 
to a separate PR.

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


[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits

https://github.com/vvd170501 updated 
https://github.com/llvm/llvm-project/pull/113612

>From 96662cb7f681e7158c05a0190894de70eee03d67 Mon Sep 17 00:00:00 2001
From: Vadim Dudkin 
Date: Thu, 24 Oct 2024 23:18:52 +0300
Subject: [PATCH 01/13] Update std symbol mapping to v20230810; Move assertion
 to detect all ungrouped mappings

---
 .../Inclusions/Stdlib/StandardLibrary.cpp |   8 +-
 .../Inclusions/Stdlib/StdSpecialSymbolMap.inc | 131 +-
 .../Inclusions/Stdlib/StdSymbolMap.inc| 171 --
 3 files changed, 200 insertions(+), 110 deletions(-)

diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp 
b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index 0832bcf66145fa..49e5765af112ff 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -115,15 +115,17 @@ static int initialize(Lang Language) {
   NSLen = 0;
 }
 
-if (SymIndex >= 0 &&
-Mapping->SymbolNames[SymIndex].qualifiedName() == QName) {
-  // Not a new symbol, use the same index.
+if (SymIndex > 0) {
   assert(llvm::none_of(llvm::ArrayRef(Mapping->SymbolNames, SymIndex),
[&QName](const SymbolHeaderMapping::SymbolName &S) {
  return S.qualifiedName() == QName;
}) &&
  "The symbol has been added before, make sure entries in the .inc "
  "file are grouped by symbol name!");
+}
+if (SymIndex >= 0 &&
+Mapping->SymbolNames[SymIndex].qualifiedName() == QName) {
+  // Not a new symbol, use the same index.
 } else {
   // First symbol or new symbol, increment next available index.
   ++SymIndex;
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
index 0d351d688a3296..13060a0cc1d529 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
@@ -233,6 +233,23 @@ SYMBOL(ssize, std::, )
 SYMBOL(ssize, std::, )
 SYMBOL(ssize, std::, )
 
+// Overloads for different containers, actual header depends on function arg.
+// Probably should use a special handler, like with std::move.
+SYMBOL(erase, std::, )
+SYMBOL(erase, std::, )
+SYMBOL(erase, std::, )
+SYMBOL(erase, std::, )
+SYMBOL(erase, std::, )
+SYMBOL(erase_if, std::, )
+SYMBOL(erase_if, std::, )
+SYMBOL(erase_if, std::, )
+SYMBOL(erase_if, std::, )
+SYMBOL(erase_if, std::, )
+SYMBOL(erase_if, std::, )
+SYMBOL(erase_if, std::, )
+SYMBOL(erase_if, std::, )
+SYMBOL(erase_if, std::, )
+
 // Add headers for generic integer-type abs.
 // Ignore other variants (std::complex, std::valarray, std::intmax_t)
 SYMBOL(abs, std::, )
@@ -242,9 +259,78 @@ SYMBOL(abs, None, )
 SYMBOL(abs, None, )
 SYMBOL(abs, None, )
 
-// Only add headers for the generic atomic template.
+// Same as abs - ignore variants (std::complex, std::valarray)
+SYMBOL(acos, std::, )
+SYMBOL(acos, None, )
+SYMBOL(acos, None, )
+SYMBOL(acosh, std::, )
+SYMBOL(acosh, None, )
+SYMBOL(acosh, None, )
+SYMBOL(asin, std::, )
+SYMBOL(asin, None, )
+SYMBOL(asin, None, )
+SYMBOL(asinh, std::, )
+SYMBOL(asinh, None, )
+SYMBOL(asinh, None, )
+SYMBOL(atan, std::, )
+SYMBOL(atan, None, )
+SYMBOL(atan, None, )
+SYMBOL(atan2, std::, )
+SYMBOL(atan2, None, )
+SYMBOL(atan2, None, )
+SYMBOL(atanh, std::, )
+SYMBOL(atanh, None, )
+SYMBOL(atanh, None, )
+SYMBOL(cos, std::, )
+SYMBOL(cos, None, )
+SYMBOL(cos, None, )
+SYMBOL(cosh, std::, )
+SYMBOL(cosh, None, )
+SYMBOL(cosh, None, )
+SYMBOL(exp, std::, )
+SYMBOL(exp, None, )
+SYMBOL(exp, None, )
+SYMBOL(log, std::, )
+SYMBOL(log, None, )
+SYMBOL(log, None, )
+SYMBOL(log10, std::, )
+SYMBOL(log10, None, )
+SYMBOL(log10, None, )
+SYMBOL(pow, std::, )
+SYMBOL(pow, None, )
+SYMBOL(pow, None, )
+SYMBOL(sin, std::, )
+SYMBOL(sin, None, )
+SYMBOL(sin, None, )
+SYMBOL(sinh, std::, )
+SYMBOL(sinh, None, )
+SYMBOL(sinh, None, )
+SYMBOL(sqrt, std::, )
+SYMBOL(sqrt, None, )
+SYMBOL(sqrt, None, )
+SYMBOL(tan, std::, )
+SYMBOL(tan, None, )
+SYMBOL(tan, None, )
+SYMBOL(tanh, std::, )
+SYMBOL(tanh, None, )
+SYMBOL(tanh, None, )
+
+// Only add headers for the generic atomic template
+// and atomic_* template functions.
 // Ignore variants (std::weak_ptr, std::shared_ptr).
 SYMBOL(atomic, std::, )
+SYMBOL(atomic_compare_exchange_strong, std::, )
+SYMBOL(atomic_compare_exchange_strong_explicit, std::, )
+SYMBOL(atomic_compare_exchange_weak, std::, )
+SYMBOL(atomic_compare_exchange_weak_explicit, std::, )
+SYMBOL(atomic_exchange, std::, )
+SYMBOL(atomic_exchange_explicit, std::, )
+SYMBOL(atomic_is_lock_free, std::, )
+SYMBOL(atomic_load, std::, )
+SYMBOL(atomic_load_explicit, std::, )
+SYMBOL(atomic_store, std::, )
+SYMBOL(atomic_store_explicit, std::, )
+
 // atomic_* family symbols.  is for C compatibility.
 SYMBOL(atomic_bool, std::, )
 SYMBOL(atomic_bool, None, )
@@ -355,18 

[libunwind] [libunwind][AArch64] Protect PC within libunwind's context. (PR #113368)

2024-10-26 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss updated 
https://github.com/llvm/llvm-project/pull/113368

>From 3dd2f4da57eb164e67fd54b66c09cc8b771ee24f Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Wed, 16 Oct 2024 14:48:25 -0700
Subject: [PATCH 1/6] [libunwind][AArch64] Protect PC within libunwind's
 context.

Libunwind manages the regiser context including the program counter
which is used effectively as return address.
To increase the robustness of libunwind let's protect the stored address
with PAC. Since there is no unwind info for this let's use the A key and
the base address of the context/registers as modifier.
__libunwind_Registers_arm64_jumpto can go anywhere where the given buffer
's PC points to. After this patch it needs a signed PC therefore the context
 is more harder to cract outside of libunwind.

The register value is internal to libunwind and the change is not visible
on the the APIs.
w
---
 libunwind/src/Registers.hpp| 91 --
 libunwind/src/UnwindRegistersRestore.S |  8 ++-
 libunwind/src/UnwindRegistersSave.S|  8 ++-
 3 files changed, 99 insertions(+), 8 deletions(-)

diff --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp
index 861e6b5f6f2c58..91bd95b1306169 100644
--- a/libunwind/src/Registers.hpp
+++ b/libunwind/src/Registers.hpp
@@ -1823,9 +1823,61 @@ extern "C" void *__libunwind_cet_get_jump_target() {
 #endif
 
 class _LIBUNWIND_HIDDEN Registers_arm64 {
+protected:
+  /// The program counter is used effectively as a return address
+  /// when the context is restored therefore protect it with PAC.
+  /// The base address of the context is used with the A key for
+  /// authentication and signing. Return address authentication is
+  /// still managed according to the unwind info.
+  inline uint64_t getAuthSalt() const {
+return reinterpret_cast(this);
+  }
+#if defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  // Authenticate the given pointer and return with the raw value
+  // if the authentication is succeeded.
+  inline uint64_t auth(uint64_t ptr, uint64_t salt) const {
+register uint64_t x17 __asm("x17") = ptr;
+register uint64_t x16 __asm("x16") = salt;
+asm("hint  0xc" // autia1716
+: "+r"(x17)
+: "r"(x16)
+:);
+
+uint64_t checkValue = ptr;
+// Support for machines without FPAC.
+// Strip the upper bits with `XPACLRI` and compare with the
+// authenticated value.
+asm("mov   x30, %[checkValue] \r\n"
+"hint  0x7\r\n"
+"mov   %[checkValue], x30 \r\n"
+: [checkValue] "+r"(checkValue)
+:
+: "x30");
+if (x17 != checkValue)
+  _LIBUNWIND_ABORT("IP PAC authentication failure");
+return x17;
+  }
+
+  // Sign the PC with the A-KEY and the current salt.
+  inline void updatePC(uint64_t value) {
+register uint64_t x17 __asm("x17") = value;
+register uint64_t x16 __asm("x16") = getAuthSalt();
+asm("hint 0x8" : "+r"(x17) : "r"(x16)); // pacia1716
+_registers.__pc = x17;
+  }
+#else //! defined(_LIBUNWIND_IS_NATIVE_ONLY)
+  // Remote unwinding is not supported by this protection.
+  inline uint64_t auth(uint64_t ptr, uint64_t salt) const { return ptr; }
+  inline void updatePC(uint64_t value) { _registers.__pc = value; }
+#endif
+
 public:
   Registers_arm64();
   Registers_arm64(const void *registers);
+  Registers_arm64(const Registers_arm64 &other);
+  Registers_arm64(const Registers_arm64 &&other) = delete;
+  Registers_arm64 &operator=(const Registers_arm64 &other);
+  Registers_arm64 &operator=(Registers_arm64 &&other) = delete;
 
   boolvalidRegister(int num) const;
   uint64_tgetRegister(int num) const;
@@ -1845,8 +1897,14 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   uint64_t  getSP() const { return _registers.__sp; }
   void  setSP(uint64_t value) { _registers.__sp = value; }
-  uint64_t  getIP() const { return _registers.__pc; }
-  void  setIP(uint64_t value) { _registers.__pc = value; }
+  uint64_t getIP() const { return auth(_registers.__pc, getAuthSalt()); }
+  void setIP(uint64_t value) {
+// First authenticate the current value of the IP to ensure the context
+// is still valid. This also ensure the setIP can't be used for signing
+// arbitrary values.
+auth(_registers.__pc, getAuthSalt());
+updatePC(value);
+  }
   uint64_t  getFP() const { return _registers.__fp; }
   void  setFP(uint64_t value) { _registers.__fp = value; }
 
@@ -1862,8 +1920,8 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
 
   GPRs_registers;
   double  _vectorHalfRegisters[32];
-  // Currently only the lower double in 128-bit vectore registers
-  // is perserved during unwinding.  We could define new register
+  // Currently only the lower double in 128-bit vector registers
+  // is preserved during unwinding.  We could define new register
   // numbers (> 96) which mean whole vector registers, then this
   // struct would need to change

[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits


@@ -232,6 +232,47 @@ SYMBOL(ssize, std::, )
 SYMBOL(ssize, std::, )
 SYMBOL(ssize, std::, )
 SYMBOL(ssize, std::, )
+// C++ [range.access.general]: ... the customization point objects
+// in [range.access] are available when the header  is included.
+SYMBOL(begin, std::ranges::, )
+SYMBOL(begin, std::ranges::, )
+SYMBOL(cbegin, std::ranges::, )
+SYMBOL(cbegin, std::ranges::, )
+SYMBOL(cdata, std::ranges::, )
+SYMBOL(cdata, std::ranges::, )
+SYMBOL(cend, std::ranges::, )
+SYMBOL(cend, std::ranges::, )
+SYMBOL(crbegin, std::ranges::, )
+SYMBOL(crbegin, std::ranges::, )
+SYMBOL(crend, std::ranges::, )
+SYMBOL(crend, std::ranges::, )
+SYMBOL(data, std::ranges::, )
+SYMBOL(data, std::ranges::, )
+SYMBOL(empty, std::ranges::, )
+SYMBOL(empty, std::ranges::, )
+SYMBOL(end, std::ranges::, )
+SYMBOL(end, std::ranges::, )
+SYMBOL(rbegin, std::ranges::, )
+SYMBOL(rbegin, std::ranges::, )
+SYMBOL(rend, std::ranges::, )
+SYMBOL(rend, std::ranges::, )
+SYMBOL(size, std::ranges::, )
+SYMBOL(size, std::ranges::, )
+SYMBOL(ssize, std::ranges::, )
+SYMBOL(ssize, std::ranges::, )
+
+// FIXME lost after generator update - variants, probably should not be removed
+SYMBOL(abs, std::chrono::, )
+SYMBOL(ceil, std::chrono::, )
+SYMBOL(floor, std::chrono::, )
+SYMBOL(from_stream, std::chrono::, )
+SYMBOL(round, std::chrono::, )
+SYMBOL(begin, std::filesystem::, )
+SYMBOL(end, std::filesystem::, )
+SYMBOL(get, std::ranges::, )
+
+// Ignore specializations
+SYMBOL(hash, std::, )

vvd170501 wrote:

Not sure if it's better to keep `` or replace it with `/*no 
headers*/`

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


[clang] [clang-format] convert path to Windows path if user is using a MSYS2 shell (PR #111526)

2024-10-26 Thread via cfe-commits

MarcelHB wrote:

I'd appreciate this fix, too.

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


[clang-tools-extra] [clang-tidy] Do not emit file path for anonymous enums in `readability-enum-initial-value` check (PR #112496)

2024-10-26 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti approved this pull request.


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


[clang] [llvm] [RISCV]Add svvptc extension (PR #113758)

2024-10-26 Thread via cfe-commits

https://github.com/dong-miao updated 
https://github.com/llvm/llvm-project/pull/113758

>From 6424bebfcf16ef9694d7406b0298045da2d426bf Mon Sep 17 00:00:00 2001
From: dong-miao <601183...@qq.com>
Date: Sat, 26 Oct 2024 06:49:04 +
Subject: [PATCH 1/5] [RISCV]Add svvptc extensions

---
 clang/test/Driver/print-supported-extensions-riscv.c | 1 +
 clang/test/Preprocessor/riscv-target-features.c  | 9 +
 llvm/docs/RISCVUsage.rst | 1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td   | 4 
 llvm/test/CodeGen/RISCV/attributes.ll| 4 
 llvm/test/MC/RISCV/attribute-arch.s  | 3 +++
 llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 1 +
 7 files changed, 23 insertions(+)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 342d6e921a5a83..2d7376f8fe9401 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -146,6 +146,7 @@
 // CHECK-NEXT: svinval  1.0   'Svinval' (Fine-Grained 
Address-Translation Cache Invalidation)
 // CHECK-NEXT: svnapot  1.0   'Svnapot' (NAPOT Translation 
Contiguity)
 // CHECK-NEXT: svpbmt   1.0   'Svpbmt' (Page-Based Memory 
Types)
+// CHECK-NEXT: svvptc   1.0   'Svvptc' (Obviating 
Memory-Management Instructions after Marking PTEs Valid)
 // CHECK-NEXT: xcvalu   1.0   'XCValu' (CORE-V ALU 
Operations)
 // CHECK-NEXT: xcvbi1.0   'XCVbi' (CORE-V Immediate 
Branching)
 // CHECK-NEXT: xcvbitmanip  1.0   'XCVbitmanip' (CORE-V Bit 
Manipulation)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 98ad564d2b8408..5b4d42b053edc6 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -51,6 +51,7 @@
 // CHECK-NOT: __riscv_svinval {{.*$}}
 // CHECK-NOT: __riscv_svnapot {{.*$}}
 // CHECK-NOT: __riscv_svpbmt {{.*$}}
+// CHECK-NOT: __riscv_svvptc {{.*$}}
 // CHECK-NOT: __riscv_v {{.*$}}
 // CHECK-NOT: __riscv_v_elen {{.*$}}
 // CHECK-NOT: __riscv_v_elen_fp {{.*$}}
@@ -507,6 +508,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
 // CHECK-SVPBMT-EXT: __riscv_svpbmt 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// CHECK-SVVPTC-EXT: __riscv_svvptc 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32iv1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index ab58cdaa1b2f95..958168772fe413 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -155,6 +155,7 @@ on support follow.
  ``Svinval``   Assembly Support
  ``Svnapot``   Assembly Support
  ``Svpbmt``Supported
+ ``Svvptc``Supported
  ``V`` Supported
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 778df542022f22..3b86bc69153631 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1029,6 +1029,10 @@ def FeatureStdExtSvpbmt
 : RISCVExtension<"svpbmt", 1, 0,
  "'Svpbmt' (Page-Based Memory Types)">;
 
+def FeatureStdExtSvvptc
+: RISCVExtension<"svvptc", 1, 0,
+ "'svvptc' (Obviating Memory-Management Instructions after 
Marking PTEs Valid)">; 
+
 // Pointer Masking extensions
 
 // A supervisor-level extension that provides pointer masking for the next 
lower
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index e9743d484f776f..2d07919e042edc 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -62,6 +62,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVNAPOT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVINVAL %s
+; RUN: llc -mtriple=riscv32 -mattr=+svvptc %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVVPTC %s
 ; RUN: llc -mtriple=riscv32 -mattr=+xcvalu %s -o - | FileCheck 
--check-prefix=RV32XCVALU %s
 ; RUN: llc -mtriple=riscv32 -mattr=+xcvbitmanip

[clang] [sema] enhance error handling for compound stmt body in `StmtExpr` (PR #113760)

2024-10-26 Thread Congcong Cai via cfe-commits

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


[clang] [sema] enhance error handling for compound stmt body in `StmtExpr` (PR #113760)

2024-10-26 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Congcong Cai (HerrCai0907)


Changes

Mark the whole StmtExpr invalid when the last statement in compound statement 
is invalid.
Because the last statement need to do copy initialization, it causes subsequent 
errors to simply ignore last invalid statement.


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


2 Files Affected:

- (modified) clang/lib/Parse/ParseStmt.cpp (+9) 
- (added) clang/test/SemaCXX/gh113468.cpp (+12) 


``diff
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 60d647da48f053..6d0de38095b999 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1243,6 +1243,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool 
isStmtExpr) {
   ParsedStmtContext::Compound |
   (isStmtExpr ? ParsedStmtContext::InStmtExpr : ParsedStmtContext());
 
+  bool LastIsError = false;
   while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
  Tok.isNot(tok::eof)) {
 if (Tok.is(tok::annot_pragma_unused)) {
@@ -1299,7 +1300,15 @@ StmtResult Parser::ParseCompoundStatementBody(bool 
isStmtExpr) {
 
 if (R.isUsable())
   Stmts.push_back(R.get());
+LastIsError = R.isInvalid();
   }
+  // StmtExpr needs to do copy initialization for last statement.
+  // If last statement is invalid, the last statement in `Stmts` will be
+  // incorrect. Then the whole compound statement should also be marked as
+  // invalid to prevent subsequent errors.
+  if (isStmtExpr && LastIsError && !Stmts.empty())
+return StmtError();
+
   // Warn the user that using option `-ffp-eval-method=source` on a
   // 32-bit target and feature `sse` disabled, or using
   // `pragma clang fp eval_method=source` and feature `sse` disabled, is not
diff --git a/clang/test/SemaCXX/gh113468.cpp b/clang/test/SemaCXX/gh113468.cpp
new file mode 100644
index 00..94551986b0efaa
--- /dev/null
+++ b/clang/test/SemaCXX/gh113468.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+constexpr int expr() {
+  if (({
+int f;
+f = 0;
+if (f)
+  break; // expected-error {{'break' statement not in loop or switch 
statement}}
+  }))
+return 2;
+  return 1;
+}

``




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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Yingchi Long via cfe-commits


@@ -703,6 +715,39 @@ SDValue BPFTargetLowering::LowerSELECT_CC(SDValue Op, 
SelectionDAG &DAG) const {
   return DAG.getNode(BPFISD::SELECT_CC, DL, VTs, Ops);
 }
 
+SDValue BPFTargetLowering::LowerATOMIC_LOAD(SDValue Op,
+SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic load is not supported";
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);
+
+  return Op;
+}
+
+SDValue BPFTargetLowering::LowerATOMIC_STORE(SDValue Op,
+ SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic store is not supported";
+  EVT VT = Op.getOperand(1).getValueType();
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  // Promote operand #1 (value to store) if necessary.
+  if (!isTypeLegal(VT))
+return SDValue();
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);

inclyc wrote:

> We're starting from `ACQUIRE` and `RELEASE`. `SEQ_CST` will be supported if 
> needed.

Currently as per my understanding the new instructions does not have this 
ordering field (the asm, the encoding)? Make `SEQ_CST` asserted out may cause 
further ugly workarounds, if the kernel does not frozen the instructions, can 
we add such ordering specification/field?

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


[clang] [libcxx] [clang] Warn about memset/memcpy to NonTriviallyCopyable types (PR #111434)

2024-10-26 Thread Nikolas Klauser via cfe-commits

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

The libc++ LGTM.

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


[clang] [libcxx] [clang] Warn about memset/memcpy to NonTriviallyCopyable types (PR #111434)

2024-10-26 Thread Nikolas Klauser via cfe-commits

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


[clang] [Tooling/Inclusion] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits

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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

2024-10-26 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti updated 
https://github.com/llvm/llvm-project/pull/81640

>From 1796e5d2c44bae890c13b2af3fc7e4ec36e716dd Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Tue, 13 Feb 2024 18:59:16 +0100
Subject: [PATCH 1/3] [clangd] fix extract-to-function for overloaded operators

When selecting code that contains the use of overloaded operators,
the SelectionTree will attribute the operator to the operator
declaration, not to the `CXXOperatorCallExpr`. To allow
extract-to-function to work with these operators, make unselected
`CXXOperatorCallExpr`s valid root statements, just like `DeclStmt`s.

Fixes clangd/clangd#1254
---
 .../refactor/tweaks/ExtractFunction.cpp   | 15 +++---
 .../unittests/tweaks/ExtractFunctionTests.cpp | 47 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 ++
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 0302839c58252e..aae480175b33f6 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -56,6 +56,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -70,7 +71,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/raw_os_ostream.h"
 #include 
 
 namespace clang {
@@ -104,9 +104,12 @@ bool isRootStmt(const Node *N) {
   // Root statement cannot be partially selected.
   if (N->Selected == SelectionTree::Partial)
 return false;
-  // Only DeclStmt can be an unselected RootStmt since VarDecls claim the 
entire
-  // selection range in selectionTree.
-  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get())
+  // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
+  // selection range in selectionTree. Additionally, an CXXOperatorCallExpr of 
a
+  // binary operation can be unselected because it's children claim the entire
+  // selection range in the selection tree (e.g. <<).
+  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get() 
&&
+  !N->ASTNode.get())
 return false;
   return true;
 }
@@ -913,8 +916,8 @@ Expected ExtractFunction::apply(const 
Selection &Inputs) {
 
   tooling::Replacements OtherEdit(
   createForwardDeclaration(*ExtractedFunc, SM));
-  if (auto PathAndEdit = Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc),
- OtherEdit))
+  if (auto PathAndEdit =
+  Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc), OtherEdit))
 MultiFileEffect->ApplyEdits.try_emplace(PathAndEdit->first,
 PathAndEdit->second);
   else
diff --git a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
index dec63d454d52c6..8e347b516c6ffe 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -571,6 +571,53 @@ int getNum(bool Superstitious, int Min, int Max) {
   EXPECT_EQ(apply(Before), After);
 }
 
+TEST_F(ExtractFunctionTest, OverloadedOperators) {
+  Context = File;
+  std::string Before = R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+  int main() {
+[[foo(1, 2);
+foo(3, 4);
+stream << 42;
+stream + 42;
+stream | 42;
+foo(1, 2);
+foo(3, 4);]]
+  })cpp";
+  std::string After =
+  R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+  void extracted() {
+foo(1, 2);
+foo(3, 4);
+stream << 42;
+stream + 42;
+stream | 42;
+foo(1, 2);
+foo(3, 4);
+}
+int main() {
+extracted();
+  })cpp";
+  EXPECT_EQ(apply(Before), After);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a604e9276668ae..1cd7c6b6ae5adf 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -69,6 +69,9 @@ Code complet

[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

2024-10-26 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti commented:

CC @HighCommander4 @kadircet 

Technically, Sam told me last EuroLLVM that he had some refactor of the 
`SelectionTree` that would resolve issues like this in the general case, but as 
it is unclear that those changes will get in someday/in the 'near' future, I 
think that this PR makes sense to merge. Even though this is kind of a band-aid 
fix. Thoughts?

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


[clang] [llvm] [RISCV]Add svvptc extension (PR #113758)

2024-10-26 Thread via cfe-commits

https://github.com/dong-miao updated 
https://github.com/llvm/llvm-project/pull/113758

>From 6424bebfcf16ef9694d7406b0298045da2d426bf Mon Sep 17 00:00:00 2001
From: dong-miao <601183...@qq.com>
Date: Sat, 26 Oct 2024 06:49:04 +
Subject: [PATCH 1/3] [RISCV]Add svvptc extensions

---
 clang/test/Driver/print-supported-extensions-riscv.c | 1 +
 clang/test/Preprocessor/riscv-target-features.c  | 9 +
 llvm/docs/RISCVUsage.rst | 1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td   | 4 
 llvm/test/CodeGen/RISCV/attributes.ll| 4 
 llvm/test/MC/RISCV/attribute-arch.s  | 3 +++
 llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 1 +
 7 files changed, 23 insertions(+)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 342d6e921a5a83..2d7376f8fe9401 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -146,6 +146,7 @@
 // CHECK-NEXT: svinval  1.0   'Svinval' (Fine-Grained 
Address-Translation Cache Invalidation)
 // CHECK-NEXT: svnapot  1.0   'Svnapot' (NAPOT Translation 
Contiguity)
 // CHECK-NEXT: svpbmt   1.0   'Svpbmt' (Page-Based Memory 
Types)
+// CHECK-NEXT: svvptc   1.0   'Svvptc' (Obviating 
Memory-Management Instructions after Marking PTEs Valid)
 // CHECK-NEXT: xcvalu   1.0   'XCValu' (CORE-V ALU 
Operations)
 // CHECK-NEXT: xcvbi1.0   'XCVbi' (CORE-V Immediate 
Branching)
 // CHECK-NEXT: xcvbitmanip  1.0   'XCVbitmanip' (CORE-V Bit 
Manipulation)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 98ad564d2b8408..5b4d42b053edc6 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -51,6 +51,7 @@
 // CHECK-NOT: __riscv_svinval {{.*$}}
 // CHECK-NOT: __riscv_svnapot {{.*$}}
 // CHECK-NOT: __riscv_svpbmt {{.*$}}
+// CHECK-NOT: __riscv_svvptc {{.*$}}
 // CHECK-NOT: __riscv_v {{.*$}}
 // CHECK-NOT: __riscv_v_elen {{.*$}}
 // CHECK-NOT: __riscv_v_elen_fp {{.*$}}
@@ -507,6 +508,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
 // CHECK-SVPBMT-EXT: __riscv_svpbmt 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// CHECK-SVVPTC-EXT: __riscv_svvptc 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32iv1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index ab58cdaa1b2f95..958168772fe413 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -155,6 +155,7 @@ on support follow.
  ``Svinval``   Assembly Support
  ``Svnapot``   Assembly Support
  ``Svpbmt``Supported
+ ``Svvptc``Supported
  ``V`` Supported
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 778df542022f22..3b86bc69153631 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1029,6 +1029,10 @@ def FeatureStdExtSvpbmt
 : RISCVExtension<"svpbmt", 1, 0,
  "'Svpbmt' (Page-Based Memory Types)">;
 
+def FeatureStdExtSvvptc
+: RISCVExtension<"svvptc", 1, 0,
+ "'svvptc' (Obviating Memory-Management Instructions after 
Marking PTEs Valid)">; 
+
 // Pointer Masking extensions
 
 // A supervisor-level extension that provides pointer masking for the next 
lower
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index e9743d484f776f..2d07919e042edc 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -62,6 +62,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVNAPOT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVINVAL %s
+; RUN: llc -mtriple=riscv32 -mattr=+svvptc %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVVPTC %s
 ; RUN: llc -mtriple=riscv32 -mattr=+xcvalu %s -o - | FileCheck 
--check-prefix=RV32XCVALU %s
 ; RUN: llc -mtriple=riscv32 -mattr=+xcvbitmanip

[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

2024-10-26 Thread Julian Schmidt via cfe-commits


@@ -104,9 +104,12 @@ bool isRootStmt(const Node *N) {
   // Root statement cannot be partially selected.
   if (N->Selected == SelectionTree::Partial)
 return false;
-  // Only DeclStmt can be an unselected RootStmt since VarDecls claim the 
entire
-  // selection range in selectionTree.
-  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get())
+  // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
+  // selection range in selectionTree. Additionally, a CXXOperatorCallExpr of a
+  // binary operation can be unselected because it's children claim the entire

5chmidti wrote:

```suggestion
  // selection range in selectionTree. Additionally, a CXXOperatorCallExpr of a
  // binary operation can be unselected because its children claim the entire
```

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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

2024-10-26 Thread Julian Schmidt via cfe-commits

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


[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits

https://github.com/vvd170501 updated 
https://github.com/llvm/llvm-project/pull/113612

>From 853881983faeeb5b7e0582d3e94037c12df12c7c Mon Sep 17 00:00:00 2001
From: vvd170501 <36827317+vvd170...@users.noreply.github.com>
Date: Sat, 26 Oct 2024 00:17:26 +0300
Subject: [PATCH 1/4] Fix variant parsing

---
 .../include-mapping/cppreference_parser.py| 33 ---
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/clang/tools/include-mapping/cppreference_parser.py 
b/clang/tools/include-mapping/cppreference_parser.py
index f2ea55384fac80..70e403bba64917 100644
--- a/clang/tools/include-mapping/cppreference_parser.py
+++ b/clang/tools/include-mapping/cppreference_parser.py
@@ -7,7 +7,7 @@
 #
 # 
======#
 
-from bs4 import BeautifulSoup, NavigableString
+from bs4 import BeautifulSoup, NavigableString, Tag
 
 import collections
 import multiprocessing
@@ -89,6 +89,23 @@ def _ParseSymbolPage(symbol_page_html, symbol_name):
 return headers or all_headers
 
 
+def _ParseSymbolVariant(caption):
+if not (isinstance(caption, NavigableString) and "(" in caption):
+return None
+
+if ')' in caption.text:  # (locale), (algorithm), etc.
+return caption.text.strip(" ()")
+
+second_part = caption.next_sibling
+if isinstance(second_part, Tag) and second_part.name == "code":
+# (std::complex), etc.
+third_part = second_part.next_sibling
+if isinstance(third_part, NavigableString) and 
third_part.text.startswith(')'):
+return second_part.text
+return None
+
+
+
 def _ParseIndexPage(index_page_html):
 """Parse index page.
 The index page lists all std symbols and hrefs to their detailed pages
@@ -107,9 +124,7 @@ def _ParseIndexPage(index_page_html):
 # This accidentally accepts begin/end despite the (iterator) caption: 
the
 # (since C++11) note is first. They are good symbols, so the bug is 
unfixed.
 caption = symbol_href.next_sibling
-variant = None
-if isinstance(caption, NavigableString) and "(" in caption:
-variant = caption.text.strip(" ()")
+variant = _ParseSymbolVariant(caption)
 symbol_tt = symbol_href.find("tt")
 if symbol_tt:
 symbols.append(
@@ -192,6 +207,16 @@ def GetSymbols(parse_pages):
 variants_to_accept = {
 # std::remove<> has variant algorithm.
 "std::remove": ("algorithm"),
+# These functions don't have a generic version, and all variants are 
defined in 
+"std::chrono::abs": ("std::chrono::duration"),
+"std::chrono::ceil": ("std::chrono::duration"),
+"std::chrono::floor": ("std::chrono::duration"),
+"std::chrono::from_stream": ("std::chrono::day"),
+"std::chrono::round": ("std::chrono::duration"),
+# Same, but in 
+"std::filesystem::begin": ("std::filesystem::directory_iterator"),
+"std::filesystem::end": ("std::filesystem::directory_iterator"),
+"std::ranges::get": ("std::ranges::subrange"),
 }
 symbols = []
 # Run many workers to process individual symbol pages under the symbol 
index.

>From 09a421726314f2d9edb110e33106b3194e9f7014 Mon Sep 17 00:00:00 2001
From: vvd170501 <36827317+vvd170...@users.noreply.github.com>
Date: Sat, 26 Oct 2024 06:38:41 +0300
Subject: [PATCH 2/4] Parse symbols with qualified name (not sure if it works
 in this revision)

---
 clang/tools/include-mapping/cppreference_parser.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/clang/tools/include-mapping/cppreference_parser.py 
b/clang/tools/include-mapping/cppreference_parser.py
index 70e403bba64917..d63be5d241884b 100644
--- a/clang/tools/include-mapping/cppreference_parser.py
+++ b/clang/tools/include-mapping/cppreference_parser.py
@@ -40,7 +40,7 @@ def _HasClass(tag, *classes):
 return False
 
 
-def _ParseSymbolPage(symbol_page_html, symbol_name):
+def _ParseSymbolPage(symbol_page_html, symbol_name, qual_name):
 """Parse symbol page and retrieve the include header defined in this page.
 The symbol page provides header for the symbol, specifically in
 "Defined in header " section. An example:
@@ -69,7 +69,7 @@ def _ParseSymbolPage(symbol_page_html, symbol_name):
 was_decl = True
 # Symbols are in the first cell.
 found_symbols = row.find("td").stripped_strings
-if not symbol_name in found_symbols:
+if not (symbol_name in found_symbols or qual_name in 
found_symbols):
 continue
 headers.update(current_headers)
 elif _HasClass(row, "t-dsc-header"):
@@ -137,9 +137,9 @@ def _ParseIndexPage(index_page_html):
 return symbols
 
 
-def _ReadSymbolPage(path, name):
+def _ReadSymbolPage(path, name, qual_name):
 with open(path) as f:
-return _ParseSymbolPage(f.read(),

[clang] [llvm] [RISCV]Add svvptc extension (PR #113758)

2024-10-26 Thread via cfe-commits

https://github.com/dong-miao updated 
https://github.com/llvm/llvm-project/pull/113758

>From 6424bebfcf16ef9694d7406b0298045da2d426bf Mon Sep 17 00:00:00 2001
From: dong-miao <601183...@qq.com>
Date: Sat, 26 Oct 2024 06:49:04 +
Subject: [PATCH 1/2] [RISCV]Add svvptc extensions

---
 clang/test/Driver/print-supported-extensions-riscv.c | 1 +
 clang/test/Preprocessor/riscv-target-features.c  | 9 +
 llvm/docs/RISCVUsage.rst | 1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td   | 4 
 llvm/test/CodeGen/RISCV/attributes.ll| 4 
 llvm/test/MC/RISCV/attribute-arch.s  | 3 +++
 llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 1 +
 7 files changed, 23 insertions(+)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 342d6e921a5a83..2d7376f8fe9401 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -146,6 +146,7 @@
 // CHECK-NEXT: svinval  1.0   'Svinval' (Fine-Grained 
Address-Translation Cache Invalidation)
 // CHECK-NEXT: svnapot  1.0   'Svnapot' (NAPOT Translation 
Contiguity)
 // CHECK-NEXT: svpbmt   1.0   'Svpbmt' (Page-Based Memory 
Types)
+// CHECK-NEXT: svvptc   1.0   'Svvptc' (Obviating 
Memory-Management Instructions after Marking PTEs Valid)
 // CHECK-NEXT: xcvalu   1.0   'XCValu' (CORE-V ALU 
Operations)
 // CHECK-NEXT: xcvbi1.0   'XCVbi' (CORE-V Immediate 
Branching)
 // CHECK-NEXT: xcvbitmanip  1.0   'XCVbitmanip' (CORE-V Bit 
Manipulation)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 98ad564d2b8408..5b4d42b053edc6 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -51,6 +51,7 @@
 // CHECK-NOT: __riscv_svinval {{.*$}}
 // CHECK-NOT: __riscv_svnapot {{.*$}}
 // CHECK-NOT: __riscv_svpbmt {{.*$}}
+// CHECK-NOT: __riscv_svvptc {{.*$}}
 // CHECK-NOT: __riscv_v {{.*$}}
 // CHECK-NOT: __riscv_v_elen {{.*$}}
 // CHECK-NOT: __riscv_v_elen_fp {{.*$}}
@@ -507,6 +508,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
 // CHECK-SVPBMT-EXT: __riscv_svpbmt 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// CHECK-SVVPTC-EXT: __riscv_svvptc 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32iv1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index ab58cdaa1b2f95..958168772fe413 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -155,6 +155,7 @@ on support follow.
  ``Svinval``   Assembly Support
  ``Svnapot``   Assembly Support
  ``Svpbmt``Supported
+ ``Svvptc``Supported
  ``V`` Supported
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 778df542022f22..3b86bc69153631 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1029,6 +1029,10 @@ def FeatureStdExtSvpbmt
 : RISCVExtension<"svpbmt", 1, 0,
  "'Svpbmt' (Page-Based Memory Types)">;
 
+def FeatureStdExtSvvptc
+: RISCVExtension<"svvptc", 1, 0,
+ "'svvptc' (Obviating Memory-Management Instructions after 
Marking PTEs Valid)">; 
+
 // Pointer Masking extensions
 
 // A supervisor-level extension that provides pointer masking for the next 
lower
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index e9743d484f776f..2d07919e042edc 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -62,6 +62,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVNAPOT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVINVAL %s
+; RUN: llc -mtriple=riscv32 -mattr=+svvptc %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVVPTC %s
 ; RUN: llc -mtriple=riscv32 -mattr=+xcvalu %s -o - | FileCheck 
--check-prefix=RV32XCVALU %s
 ; RUN: llc -mtriple=riscv32 -mattr=+xcvbitmanip

[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vadim D. (vvd170501)


Changes

Fixes #113494

---

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


4 Files Affected:

- (modified) clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp (+5-3) 
- (modified) clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc 
(+40-6) 
- (modified) clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc (+93-23) 
- (modified) clang/tools/include-mapping/cppreference_parser.py (+57-24) 


``diff
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp 
b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
index 0832bcf66145fa..49e5765af112ff 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp
@@ -115,15 +115,17 @@ static int initialize(Lang Language) {
   NSLen = 0;
 }
 
-if (SymIndex >= 0 &&
-Mapping->SymbolNames[SymIndex].qualifiedName() == QName) {
-  // Not a new symbol, use the same index.
+if (SymIndex > 0) {
   assert(llvm::none_of(llvm::ArrayRef(Mapping->SymbolNames, SymIndex),
[&QName](const SymbolHeaderMapping::SymbolName &S) {
  return S.qualifiedName() == QName;
}) &&
  "The symbol has been added before, make sure entries in the .inc "
  "file are grouped by symbol name!");
+}
+if (SymIndex >= 0 &&
+Mapping->SymbolNames[SymIndex].qualifiedName() == QName) {
+  // Not a new symbol, use the same index.
 } else {
   // First symbol or new symbol, increment next available index.
   ++SymIndex;
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
index 0d351d688a3296..307118bd650df6 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSpecialSymbolMap.inc
@@ -232,6 +232,37 @@ SYMBOL(ssize, std::, )
 SYMBOL(ssize, std::, )
 SYMBOL(ssize, std::, )
 SYMBOL(ssize, std::, )
+// C++ [range.access.general]: ... the customization point objects
+// in [range.access] are available when the header  is included.
+SYMBOL(begin, std::ranges::, )
+SYMBOL(begin, std::ranges::, )
+SYMBOL(cbegin, std::ranges::, )
+SYMBOL(cbegin, std::ranges::, )
+SYMBOL(cdata, std::ranges::, )
+SYMBOL(cdata, std::ranges::, )
+SYMBOL(cend, std::ranges::, )
+SYMBOL(cend, std::ranges::, )
+SYMBOL(crbegin, std::ranges::, )
+SYMBOL(crbegin, std::ranges::, )
+SYMBOL(crend, std::ranges::, )
+SYMBOL(crend, std::ranges::, )
+SYMBOL(data, std::ranges::, )
+SYMBOL(data, std::ranges::, )
+SYMBOL(empty, std::ranges::, )
+SYMBOL(empty, std::ranges::, )
+SYMBOL(end, std::ranges::, )
+SYMBOL(end, std::ranges::, )
+SYMBOL(rbegin, std::ranges::, )
+SYMBOL(rbegin, std::ranges::, )
+SYMBOL(rend, std::ranges::, )
+SYMBOL(rend, std::ranges::, )
+SYMBOL(size, std::ranges::, )
+SYMBOL(size, std::ranges::, )
+SYMBOL(ssize, std::ranges::, )
+SYMBOL(ssize, std::ranges::, )
+
+// Ignore specializations
+SYMBOL(hash, std::, )
 
 // Add headers for generic integer-type abs.
 // Ignore other variants (std::complex, std::valarray, std::intmax_t)
@@ -352,20 +383,23 @@ SYMBOL(get, std::, /*no headers*/)
 // providing the type.
 SYMBOL(make_error_code, std::, /*no headers*/)
 SYMBOL(make_error_condition, std::, /*no headers*/)
+// Similar to std::get, has variants for multiple containers
+// (vector, deque, list, etc.)
+SYMBOL(erase, std::, /*no headers*/)
+SYMBOL(erase_if, std::, /*no headers*/)
 
 // cppreference symbol index page was missing these symbols.
 // Remove them when the cppreference offline archive catches up.
-SYMBOL(index_sequence, std::, )
-SYMBOL(index_sequence_for, std::, )
-SYMBOL(make_index_sequence, std::, )
-SYMBOL(make_integer_sequence, std::, )
+SYMBOL(regular_invocable, std::, )
 
 // Symbols missing from the generated symbol map as reported by users.
 // Remove when the generator starts producing them.
-SYMBOL(make_any, std::, )
-SYMBOL(any_cast, std::, )
 SYMBOL(div, std::, )
 SYMBOL(abort, std::, )
+SYMBOL(atomic_wait, std::, )
+SYMBOL(atomic_wait_explicit, std::, )
+SYMBOL(move_backward, std::, )
+SYMBOL(month_weekday, std::chrono::, )
 
 // These are C symbols that are not under std namespace.
 SYMBOL(localtime_r, None, )
diff --git a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc 
b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
index b46bd2e4d7a4b5..b4afd0228694ff 100644
--- a/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
+++ b/clang/lib/Tooling/Inclusions/Stdlib/StdSymbolMap.inc
@@ -6,7 +6,7 @@
 // This file was generated automatically by
 // clang/tools/include-mapping/gen_std.py, DO NOT EDIT!
 //
-// Generated from cppreference offline HTML book (modified on 2022-07-30).
+// Generated from cppreference offline HTML book (modified on 2

[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits


@@ -352,20 +383,23 @@ SYMBOL(get, std::, /*no headers*/)
 // providing the type.
 SYMBOL(make_error_code, std::, /*no headers*/)
 SYMBOL(make_error_condition, std::, /*no headers*/)
+// Similar to std::get, has variants for multiple containers
+// (vector, deque, list, etc.)
+SYMBOL(erase, std::, /*no headers*/)
+SYMBOL(erase_if, std::, /*no headers*/)
 
 // cppreference symbol index page was missing these symbols.
 // Remove them when the cppreference offline archive catches up.
-SYMBOL(index_sequence, std::, )
-SYMBOL(index_sequence_for, std::, )
-SYMBOL(make_index_sequence, std::, )
-SYMBOL(make_integer_sequence, std::, )
+SYMBOL(regular_invocable, std::, )
 
 // Symbols missing from the generated symbol map as reported by users.
 // Remove when the generator starts producing them.
-SYMBOL(make_any, std::, )
-SYMBOL(any_cast, std::, )
 SYMBOL(div, std::, )
 SYMBOL(abort, std::, )
+SYMBOL(atomic_wait, std::, )
+SYMBOL(atomic_wait_explicit, std::, )
+SYMBOL(move_backward, std::, )
+SYMBOL(month_weekday, std::chrono::, )

vvd170501 wrote:

These symbols and `std::regular_invocable` were lost in newer edits, but should 
be back in the next release of offline archive

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


[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits

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


[clang] [llvm] [AMDGPU] Add a type for the named barrier (PR #113614)

2024-10-26 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-x86_64-debian-fast` 
running on `gribozavr4` while building `clang,llvm` at step 5 
"build-unified-tree".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/56/builds/10701


Here is the relevant piece of the build log for the reference

```
Step 5 (build-unified-tree) failure: build (failure)
...
31.005 [2981/96/2950] Building CXX object 
lib/Target/PowerPC/CMakeFiles/LLVMPowerPCCodeGen.dir/GISel/PPCRegisterBankInfo.cpp.o
31.017 [2980/96/2951] Building CXX object 
lib/Target/PowerPC/CMakeFiles/LLVMPowerPCCodeGen.dir/GISel/PPCLegalizerInfo.cpp.o
31.028 [2979/96/2952] Building CXX object 
lib/Target/PowerPC/MCTargetDesc/CMakeFiles/LLVMPowerPCDesc.dir/PPCInstPrinter.cpp.o
31.044 [2978/96/2953] Building CXX object 
lib/Target/PowerPC/MCTargetDesc/CMakeFiles/LLVMPowerPCDesc.dir/PPCMCAsmInfo.cpp.o
31.053 [2977/96/2954] Building CXX object 
lib/Target/PowerPC/MCTargetDesc/CMakeFiles/LLVMPowerPCDesc.dir/PPCMCCodeEmitter.cpp.o
31.060 [2976/96/2955] Building CXX object 
lib/Target/PowerPC/MCTargetDesc/CMakeFiles/LLVMPowerPCDesc.dir/PPCPredicates.cpp.o
31.072 [2975/96/2956] Building CXX object 
lib/Target/PowerPC/MCTargetDesc/CMakeFiles/LLVMPowerPCDesc.dir/PPCELFObjectWriter.cpp.o
31.108 [2974/96/2957] Building CXX object 
lib/Target/PowerPC/MCTargetDesc/CMakeFiles/LLVMPowerPCDesc.dir/PPCXCOFFObjectWriter.cpp.o
31.117 [2973/96/2958] Building CXX object 
lib/Target/Sparc/CMakeFiles/LLVMSparcCodeGen.dir/SparcMachineFunctionInfo.cpp.o
31.125 [2972/96/2959] Building CXX object 
tools/clang/tools/extra/clang-include-fixer/plugin/CMakeFiles/obj.clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o
FAILED: 
tools/clang/tools/extra/clang-include-fixer/plugin/CMakeFiles/obj.clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/tools/extra/clang-include-fixer/plugin
 
-I/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-include-fixer/plugin
 -I/b/1/clang-x86_64-debian-fast/llvm.src/clang/include 
-I/b/1/clang-x86_64-debian-fast/llvm.obj/tools/clang/include 
-I/b/1/clang-x86_64-debian-fast/llvm.obj/include 
-I/b/1/clang-x86_64-debian-fast/llvm.src/llvm/include -std=c++11 
-Wdocumentation -Wno-documentation-deprecated-sync -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti 
-UNDEBUG -std=c++17 -MD -MT 
tools/clang/tools/extra/clang-include-fixer/plugin/CMakeFiles/obj.clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o
 -MF 
tools/clang/tools/extra/clang-include-fixer/plugin/CMakeFiles/obj.clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o.d
 -o 
tools/clang/tools/extra/clang-include-fixer/plugin/CMakeFiles/obj.clangIncludeFixerPlugin.dir/IncludeFixerPlugin.cpp.o
 -c 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp
In file included from 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp:9:
In file included from 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-include-fixer/plugin/../IncludeFixer.h:15:
In file included from 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Sema/ExternalSemaSource.h:17:
In file included from 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/Sema/TypoCorrection.h:17:
In file included from 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/Decl.h:17:
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/APValue.h:372:14:
 warning: parameter 'UninitArray' not found in the function declaration 
[-Wdocumentation]
  /// \param UninitArray Marker. Pass an empty UninitArray.
 ^~~
/b/1/clang-x86_64-debian-fast/llvm.src/clang/include/clang/AST/APValue.h:380:14:
 warning: parameter 'UninitStruct' not found in the function declaration 
[-Wdocumentation]
  /// \param UninitStruct Marker. Pass an empty UninitStruct.
 ^~~~
In file included from 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-include-fixer/plugin/IncludeFixerPlugin.cpp:9:
In file included from 
/b/1/clang-x86_64-debian-fast/llvm.src/clang-tools-extra/clang-include-fixer/plugin/../IncludeFixer.h:15:
In file inc

[libcxx] [libcxxabi] [libunwind] [llvm] [runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler (PR #108357)

2024-10-26 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> > Actually this PR is the case of 
> > https://lab.llvm.org/buildbot/#/builders/164/builds/3908, not #113491
> 
> Sorry about that.
> 
> Are you able to dig up any of the cmake configure logs from these builds, so 
> that we can figure out how this ends up breaking things? Because as in most 
> of these cases, the visible output in the buildbot logs mostly say that some 
> configure checks end up going the wrong way, but we can't really see why.

@vitalybuka Are you able to pull out some details to help figure out what this 
really broke here?

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


[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread via cfe-commits


@@ -0,0 +1,548 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++23 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++2c -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++2c -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+
+// cwg1884: partial
+
+// _N4993_.[basic.link]/11:
+// For any two declarations of an entity E:
+//   — If one declares E to be a variable or function,
+// the other shall declare E as one of the same type.
+//   — If one declares E to be an enumerator, the other shall do so.
+//   — If one declares E to be a namespace, the other shall do so.
+//   — If one declares E to be a type,
+// the other shall declare E to be a type of the same kind (9.2.9.5).
+//   — If one declares E to be a class template,
+// the other shall do so with the same kind and an equivalent 
template-head (13.7.7.2).
+// [Note 5 : The declarations can supply different default template 
arguments. — end note]
+//   — If one declares E to be a function template or a (partial 
specialization of a) variable template,
+// the other shall declare E to be one with an equivalent template-head 
and type.
+//   — If one declares E to be an alias template,
+// the other shall declare E to be one with an equivalent template-head 
and defining-type-id.
+//   — If one declares E to be a concept, the other shall do so.
+// Types are compared after all adjustments of types (during which typedefs 
(9.2.4) are replaced by their definitions);
+// declarations for an array object can specify array types that differ by the 
presence or absence of a major array bound (9.3.4.5).
+// No diagnostic is required if neither declaration is reachable from the 
other.
+
+// The structure of the test is the following. First, module cwg1884_A
+// provides all (significant) kinds of entities, each named 'a' through 'k'.
+// Then the .cpp file does MxN kind of testing, where it tests one kind of 
entity
+// against every other kind.
+
+//--- cwg1884_A.cppm
+export module cwg1884_A;
+
+export {
+int a;
+void b();
+enum E { c };
+namespace d {}
+struct e;
+class f;
+template 
+class g;
+template 
+void h(int);
+template 
+int i;
+template 
+using j = int;
+template 
+concept k = true;
+} // export
+
+
+//--- cwg1884.cpp
+import cwg1884_A;
+
+// int a;
+
+void a();
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+enum Ea {
+  a
+  // since-cxx20-error@-1 {{redefinition of 'a'}}
+  //   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+};
+namespace a {} // #cwg1884-namespace-a
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+struct a;
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@#cwg1884-namespace-a {{previous definition is here}}
+class a;
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@#cwg1884-namespace-a {{previous definition is here}}
+template 
+class a;
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+template 
+void a(int);
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+template 
+int a;
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+template 
+int a;
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+// since-cxx20-error@-3 {{expected ';' after top level declarator}}
+template 
+using a = int;
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+t

[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread via cfe-commits


@@ -0,0 +1,548 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++23 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++2c -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++2c -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+
+// cwg1884: partial

cor3ntin wrote:

can you explain what is partial in the comment, as well as the commented code?

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


[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread via cfe-commits


@@ -0,0 +1,42 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++23 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++2c -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++2c -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+
+// cwg279: no
+
+//--- cwg279_A.cppm
+export module cwg279_A;
+
+export {
+struct S; // #cwg279-S
+extern S *q; // #cwg279-q
+
+struct S2 {}; // #cwg279-S2
+extern S2 *q2; // #cwg279-q2
+} // export
+
+//--- cwg279.cpp
+import cwg279_A;
+
+// FIXME: We should use markers instead. They are less fragile,

cor3ntin wrote:

Can you add a test with `struct S {}` (no typedef)  - which should pass

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


[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread via cfe-commits


@@ -0,0 +1,548 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm

cor3ntin wrote:

```suggestion
// RUN: %clang_cc1 -std=c++20 -verify -pedantic-errors -fexceptions 
-fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
```

This is a DR to c++98 (that we can't test in older language modes)


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


[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread via cfe-commits


@@ -0,0 +1,42 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++23 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++2c -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++2c -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm

cor3ntin wrote:

Really no need to test in all language modes something we don't support

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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Yingchi Long via cfe-commits


@@ -703,6 +715,39 @@ SDValue BPFTargetLowering::LowerSELECT_CC(SDValue Op, 
SelectionDAG &DAG) const {
   return DAG.getNode(BPFISD::SELECT_CC, DL, VTs, Ops);
 }
 
+SDValue BPFTargetLowering::LowerATOMIC_LOAD(SDValue Op,
+SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic load is not supported";
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);
+
+  return Op;
+}
+
+SDValue BPFTargetLowering::LowerATOMIC_STORE(SDValue Op,
+ SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic store is not supported";
+  EVT VT = Op.getOperand(1).getValueType();
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  // Promote operand #1 (value to store) if necessary.
+  if (!isTypeLegal(VT))
+return SDValue();

inclyc wrote:

Please remove this branch before merging :

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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Yingchi Long via cfe-commits


@@ -0,0 +1,106 @@
+; RUN: llc < %s -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding \
+; RUN:   | FileCheck -check-prefixes=CHECK-LE %s
+; RUN: llc < %s -march=bpfeb -mcpu=v4 -verify-machineinstrs -show-mc-encoding \
+; RUN:   | FileCheck -check-prefixes=CHECK-BE %s
+
+; Source:
+;   char load_acquire_i8(char *p) {
+; return __atomic_load_n(p, __ATOMIC_ACQUIRE);
+;   }
+;   short load_acquire_i16(short *p) {
+; return __atomic_load_n(p, __ATOMIC_ACQUIRE);
+;   }
+;   int load_acquire_i32(int *p) {
+; return __atomic_load_n(p, __ATOMIC_ACQUIRE);
+;   }
+;   long load_acquire_i64(long *p) {
+; return __atomic_load_n(p, __ATOMIC_ACQUIRE);
+;   }
+;   void store_release_i8(char *p, char v) {
+; __atomic_store_n(p, v, __ATOMIC_RELEASE);
+;   }
+;   void store_release_i16(short *p, short v) {
+; __atomic_store_n(p, v, __ATOMIC_RELEASE);
+;   }
+;   void store_release_i32(int *p, int v) {
+; __atomic_store_n(p, v, __ATOMIC_RELEASE);
+;   }
+;   void store_release_i64(long *p, long v) {
+; __atomic_store_n(p, v, __ATOMIC_RELEASE);
+;   }
+
+; CHECK-LABEL: load_acquire_i8
+; CHECK-LE: w0 = load_acquire((u8 *)(r1 + 0)) # encoding: 
[0xd3,0x10,0x00,0x00,0x10,0x00,0x00,0x00]
+; CHECK-BE: w0 = load_acquire((u8 *)(r1 + 0)) # encoding: 
[0xd3,0x01,0x00,0x00,0x00,0x00,0x00,0x10]
+define dso_local i8 @load_acquire_i8(ptr nocapture noundef readonly %p) 
local_unnamed_addr {
+entry:

inclyc wrote:

Better place those `CHECK` labels inside the function, you can use 
`update_llc_test_checks.py` to generate those assertions automatically.

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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Matt Arsenault via cfe-commits


@@ -703,6 +715,39 @@ SDValue BPFTargetLowering::LowerSELECT_CC(SDValue Op, 
SelectionDAG &DAG) const {
   return DAG.getNode(BPFISD::SELECT_CC, DL, VTs, Ops);
 }
 
+SDValue BPFTargetLowering::LowerATOMIC_LOAD(SDValue Op,
+SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic load is not supported";
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);
+
+  return Op;
+}
+
+SDValue BPFTargetLowering::LowerATOMIC_STORE(SDValue Op,
+ SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic store is not supported";
+  EVT VT = Op.getOperand(1).getValueType();
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  // Promote operand #1 (value to store) if necessary.
+  if (!isTypeLegal(VT))
+return SDValue();
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);

arsenm wrote:

I mean how can you support atomics at all and not the sequentially consistent. 
Do you just need to emit an additional fence or something?

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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Yingchi Long via cfe-commits


@@ -0,0 +1,106 @@
+; RUN: llc < %s -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding \
+; RUN:   | FileCheck -check-prefixes=CHECK-LE %s
+; RUN: llc < %s -march=bpfeb -mcpu=v4 -verify-machineinstrs -show-mc-encoding \
+; RUN:   | FileCheck -check-prefixes=CHECK-BE %s
+
+; Source:

inclyc wrote:

This IR file is simple enough, thus doesn't need the source.

Usually when testing a single instruction, we just write the IR files by hands, 
instead of generating them from clang.

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


[clang] [llvm] Reland "[LLVM] Add IRNormalizer Pass" (PR #113780)

2024-10-26 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 74e1554d7b4013a975cf5fb8df64a6419bb14a45 
9a8172cd4168e4b9b45a9f973ab34aa1266816f8 --extensions h,cpp -- 
llvm/include/llvm/Transforms/Utils/IRNormalizer.h 
llvm/lib/Transforms/Utils/IRNormalizer.cpp 
llvm/include/llvm/Passes/StandardInstrumentations.h 
llvm/lib/Passes/PassBuilder.cpp llvm/lib/Passes/StandardInstrumentations.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Transforms/Utils/IRNormalizer.cpp 
b/llvm/lib/Transforms/Utils/IRNormalizer.cpp
index 5a7d2d8aa8..8f527cb690 100644
--- a/llvm/lib/Transforms/Utils/IRNormalizer.cpp
+++ b/llvm/lib/Transforms/Utils/IRNormalizer.cpp
@@ -26,8 +26,8 @@
 #include "llvm/IR/Module.h"
 #include "llvm/InitializePasses.h"
 #include "llvm/Pass.h"
-#include "llvm/Passes/StandardInstrumentations.h"
 #include "llvm/PassRegistry.h"
+#include "llvm/Passes/StandardInstrumentations.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Transforms/Utils.h"
 #include 

``




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


[clang] [Clang] prevent assertion failure from an invalid template instantiation pattern when adding instantiated params to the scope in friend functions with defaulted params (PR #113777)

2024-10-26 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk created 
https://github.com/llvm/llvm-project/pull/113777

Fixes #113324

>From 78019b9d9dc138f38bb5b32576b621351ae6427c Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 27 Oct 2024 01:07:57 +0300
Subject: [PATCH] [Clang] prevent assertion failure from an invalid template
 instantiation pattern when adding instantiated params to the scope in friend
 functions with defaulted params

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 8 
 clang/test/CXX/temp/temp.res/p4.cpp| 7 +++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6a95337815174b..428ec8c87a432e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Bug Fixes to C++ Support
   const-default-constructible even if a union member has a default member 
initializer.
   (#GH95854).
 - Fixed an assertion failure when evaluating an invalid expression in an array 
initializer (#GH112140)
+- Fixed an assertion failure caused by an invalid template instantiation 
pattern
+  for adding instantiated parameters to the scope in friend functions with 
defaulted parameters. (#GH113324).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 6a55861fe5af3b..cddfcc48312042 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3435,10 +3435,10 @@ bool Sema::SubstDefaultArgument(
   //   template void f(T a, int = decltype(a)());
   //   void g() { f(0); }
   LIS = std::make_unique(*this);
-  FunctionDecl *PatternFD = FD->getTemplateInstantiationPattern(
-  /*ForDefinition*/ false);
-  if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
-return true;
+  if (FunctionDecl *PatternFD =
+  FD->getTemplateInstantiationPattern(/*ForDefinition*/ false))
+if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, 
TemplateArgs))
+  return true;
 }
 
 runWithSufficientStackSpace(Loc, [&] {
diff --git a/clang/test/CXX/temp/temp.res/p4.cpp 
b/clang/test/CXX/temp/temp.res/p4.cpp
index f54d8649f5da88..62bd766e7e1140 100644
--- a/clang/test/CXX/temp/temp.res/p4.cpp
+++ b/clang/test/CXX/temp/temp.res/p4.cpp
@@ -185,3 +185,10 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct ct {
+  friend void f(ct, int = 0); // expected-error {{friend declaration 
specifying a default argument must be a definition}}
+};
+void test() { f(ct<>{}); }
+}

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


[clang] [Clang] prevent assertion failure from an invalid template instantiation pattern when adding instantiated params to the scope in friend functions with defaulted params (PR #113777)

2024-10-26 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Oleksandr T. (a-tarasyuk)


Changes

Fixes #113324

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


3 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+4-4) 
- (modified) clang/test/CXX/temp/temp.res/p4.cpp (+7) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6a95337815174b..428ec8c87a432e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -561,6 +561,8 @@ Bug Fixes to C++ Support
   const-default-constructible even if a union member has a default member 
initializer.
   (#GH95854).
 - Fixed an assertion failure when evaluating an invalid expression in an array 
initializer (#GH112140)
+- Fixed an assertion failure caused by an invalid template instantiation 
pattern
+  for adding instantiated parameters to the scope in friend functions with 
defaulted parameters. (#GH113324).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 6a55861fe5af3b..cddfcc48312042 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3435,10 +3435,10 @@ bool Sema::SubstDefaultArgument(
   //   template void f(T a, int = decltype(a)());
   //   void g() { f(0); }
   LIS = std::make_unique(*this);
-  FunctionDecl *PatternFD = FD->getTemplateInstantiationPattern(
-  /*ForDefinition*/ false);
-  if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, TemplateArgs))
-return true;
+  if (FunctionDecl *PatternFD =
+  FD->getTemplateInstantiationPattern(/*ForDefinition*/ false))
+if (addInstantiatedParametersToScope(FD, PatternFD, *LIS, 
TemplateArgs))
+  return true;
 }
 
 runWithSufficientStackSpace(Loc, [&] {
diff --git a/clang/test/CXX/temp/temp.res/p4.cpp 
b/clang/test/CXX/temp/temp.res/p4.cpp
index f54d8649f5da88..62bd766e7e1140 100644
--- a/clang/test/CXX/temp/temp.res/p4.cpp
+++ b/clang/test/CXX/temp/temp.res/p4.cpp
@@ -185,3 +185,10 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct ct {
+  friend void f(ct, int = 0); // expected-error {{friend declaration 
specifying a default argument must be a definition}}
+};
+void test() { f(ct<>{}); }
+}

``




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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Peilin Ye via cfe-commits


@@ -0,0 +1,106 @@
+; RUN: llc < %s -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding \
+; RUN:   | FileCheck -check-prefixes=CHECK-LE %s
+; RUN: llc < %s -march=bpfeb -mcpu=v4 -verify-machineinstrs -show-mc-encoding \
+; RUN:   | FileCheck -check-prefixes=CHECK-BE %s
+
+; Source:
+;   char load_acquire_i8(char *p) {
+; return __atomic_load_n(p, __ATOMIC_ACQUIRE);
+;   }
+;   short load_acquire_i16(short *p) {
+; return __atomic_load_n(p, __ATOMIC_ACQUIRE);
+;   }
+;   int load_acquire_i32(int *p) {
+; return __atomic_load_n(p, __ATOMIC_ACQUIRE);
+;   }
+;   long load_acquire_i64(long *p) {
+; return __atomic_load_n(p, __ATOMIC_ACQUIRE);
+;   }
+;   void store_release_i8(char *p, char v) {
+; __atomic_store_n(p, v, __ATOMIC_RELEASE);
+;   }
+;   void store_release_i16(short *p, short v) {
+; __atomic_store_n(p, v, __ATOMIC_RELEASE);
+;   }
+;   void store_release_i32(int *p, int v) {
+; __atomic_store_n(p, v, __ATOMIC_RELEASE);
+;   }
+;   void store_release_i64(long *p, long v) {
+; __atomic_store_n(p, v, __ATOMIC_RELEASE);
+;   }
+
+; CHECK-LABEL: load_acquire_i8
+; CHECK-LE: w0 = load_acquire((u8 *)(r1 + 0)) # encoding: 
[0xd3,0x10,0x00,0x00,0x10,0x00,0x00,0x00]
+; CHECK-BE: w0 = load_acquire((u8 *)(r1 + 0)) # encoding: 
[0xd3,0x01,0x00,0x00,0x00,0x00,0x00,0x10]
+define dso_local i8 @load_acquire_i8(ptr nocapture noundef readonly %p) 
local_unnamed_addr {
+entry:

peilin-ye wrote:

Got it, thanks for reviewing this!  I'll run `acquire-release.ll` through 
`update_llc_test_checks.py`.

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


[clang] [Clang] prevent setting default lexical access specifier for missing primary declarations (PR #112424)

2024-10-26 Thread Oleksandr T. via cfe-commits


@@ -39,7 +39,8 @@ bool Sema::SetMemberAccessSpecifier(NamedDecl *MemberDecl,
 AccessSpecifier LexicalAS) {
   if (!PrevMemberDecl) {
 // Use the lexical access specifier.
-MemberDecl->setAccess(LexicalAS);

a-tarasyuk wrote:

@shafik could you take a look at the latest changes? thanks

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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Peilin Ye via cfe-commits


@@ -703,6 +715,39 @@ SDValue BPFTargetLowering::LowerSELECT_CC(SDValue Op, 
SelectionDAG &DAG) const {
   return DAG.getNode(BPFISD::SELECT_CC, DL, VTs, Ops);
 }
 
+SDValue BPFTargetLowering::LowerATOMIC_LOAD(SDValue Op,
+SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic load is not supported";
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);
+
+  return Op;
+}
+
+SDValue BPFTargetLowering::LowerATOMIC_STORE(SDValue Op,
+ SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic store is not supported";
+  EVT VT = Op.getOperand(1).getValueType();
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  // Promote operand #1 (value to store) if necessary.
+  if (!isTypeLegal(VT))
+return SDValue();
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);

peilin-ye wrote:

I see.

> Currently as per my understanding the new instructions does not have this 
> ordering field (the asm, the encoding)?

Right now, `BPF_LOAD_ACQ` and `BPF_STORE_REL` use bit `4-7` of the `imm` field. 
 If we ever need `SEQ_CST`, we can add a new flag to bit `0-3` to indicate 
"this atomic load is sequentially consistent", similar to what we already do 
for other `BPF_ATOMIC` instructions: e.g. `BPF_XOR` in `imm{4-7}` means "it's 
an atomic XOR", then `BPF_FETCH` in `imm{0-3}` indicates whether "it returns 
the old value" or not.
- - -
Right now, this PR does:
```
   | imm{0-3} | imm{4-7}|
 - |  | --- |
 load-acquire  | 0x0  | BPF_LOAD_ACQ (0x1)  |
 store-release | 0x0  | BPF_STORE_REL (0x2) |

```
Let me change it to (encodings unchanged):
```
   | imm{0-3}  | imm{4-7}|
 - | - | --- |
 load-acquire  | BPF_ACQUIRE (0x0) | BPF_LOAD (0x1)  |
 store-release | BPF_RELEASE (0x0) | BPF_STORE (0x2) |
```
So that, in the future, we can have e.g.:
```
   | imm{0-3}  | imm{4-7}|
 - | - | --- |
 load-acquire  | BPF_ACQUIRE (0x0) | BPF_LOAD (0x1)  |
 load-seq_cst  | BPF_SEQ_CST (0x1) | BPF_LOAD (0x1)  |
 store-release | BPF_RELEASE (0x0) | BPF_STORE (0x2) |
 store-seq_cst | BPF_SEQ_CST (0x1) | BPF_STORE (0x2) |
```


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


[clang] [llvm] [BPF] Add load-acquire and store-release instructions under -mcpu=v4 (PR #108636)

2024-10-26 Thread Peilin Ye via cfe-commits


@@ -703,6 +715,39 @@ SDValue BPFTargetLowering::LowerSELECT_CC(SDValue Op, 
SelectionDAG &DAG) const {
   return DAG.getNode(BPFISD::SELECT_CC, DL, VTs, Ops);
 }
 
+SDValue BPFTargetLowering::LowerATOMIC_LOAD(SDValue Op,
+SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic load is not supported";
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);
+
+  return Op;
+}
+
+SDValue BPFTargetLowering::LowerATOMIC_STORE(SDValue Op,
+ SelectionDAG &DAG) const {
+  const char *Msg =
+  "sequentially consistent (seq_cst) atomic store is not supported";
+  EVT VT = Op.getOperand(1).getValueType();
+  SDNode *N = Op.getNode();
+  SDLoc DL(N);
+
+  // Promote operand #1 (value to store) if necessary.
+  if (!isTypeLegal(VT))
+return SDValue();
+
+  if (cast(N)->getMergedOrdering() ==
+  AtomicOrdering::SequentiallyConsistent)
+fail(DL, DAG, Msg);

peilin-ye wrote:

> Let me change it to (encodings unchanged):
> ``` 
>   | imm{0-3}  | imm{4-7}|
> - | - | --- |
> load-acquire  | BPF_ACQUIRE (0x0) | BPF_LOAD (0x1)  |
> store-release | BPF_RELEASE (0x0) | BPF_STORE (0x2) |
> ```

Actually, let's change the encoding and define [all 6 of 
them](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf#page=1817)
 once and for all:
```
namespace std {
  enum class memory_order : unspecified {
relaxed, consume, acquire, release, acq_rel, seq_cst
  };
}
```
Will explain more after the push.

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


[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-26 Thread Justin Bogner via cfe-commits

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


[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-26 Thread Justin Bogner via cfe-commits

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

A few last minor nitpicks, but this LGTM!

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


[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-26 Thread Justin Bogner via cfe-commits


@@ -5897,7 +5897,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   // Emit any call-associated writebacks immediately.  Arguably this
   // should happen after any return-value munging.
   if (CallArgs.hasWritebacks())
-emitWritebacks(*this, CallArgs);
+CodeGenFunction::EmitWritebacks(CallArgs);

bogner wrote:

We're in `CodeGenFunction`, aren't we? I think this can just be spelled 
`EmitWritebacks(CallArgs);`

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


[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-26 Thread Justin Bogner via cfe-commits


@@ -5460,9 +5460,8 @@ LValue CodeGenFunction::EmitOpaqueValueLValue(const 
OpaqueValueExpr *e) {
   return getOrCreateOpaqueLValueMapping(e);
 }
 
-void CodeGenFunction::EmitHLSLOutArgExpr(const HLSLOutArgExpr *E,
- CallArgList &Args, QualType Ty) {
-
+std::pair
+CodeGenFunction::EmitHLSLOutArgLValues(const HLSLOutArgExpr *E, QualType Ty) {

bogner wrote:

Is `EmitHLSLOutArgLValues` used any other than in 
`CodeGenFunction::EmitHLSLOutArgExpr` at this point? I think we can avoid 
splitting this method in two.

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


[clang] [llvm] Adding splitdouble HLSL function (PR #109331)

2024-10-26 Thread Justin Bogner via cfe-commits


@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --version 5

bogner wrote:

Are these assertions actually autogenerated? They look like they've been 
written by hand to me (which is fine, but if that's the case, please remove the 
misleading comment)

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


[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [analyzer] Fix a crash from element region construction during `ArrayInitLoopExpr` analysis (PR #113570)

2024-10-26 Thread Balazs Benics via cfe-commits

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


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


[clang] [analyzer] Fix a crash from element region construction during `ArrayInitLoopExpr` analysis (PR #113570)

2024-10-26 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-libc-amdgpu-runtime` running on `omp-vega20-1` while building 
`clang` at step 10 "Add check check-offload".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/73/builds/7599


Here is the relevant piece of the build log for the reference

```
Step 10 (Add check check-offload) failure: 1200 seconds without output running 
[b'ninja', b'-j 32', b'check-offload'], attempting to kill
...
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug47654.cpp 
(866 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/test_libc.cpp 
(867 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug49779.cpp 
(868 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug50022.cpp 
(869 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/wtime.c (870 
of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu :: offloading/bug49021.cpp (871 
of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu :: 
offloading/std_complex_arithmetic.cpp (872 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: 
offloading/complex_reduction.cpp (873 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug49021.cpp 
(874 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: 
offloading/std_complex_arithmetic.cpp (875 of 879)
command timed out: 1200 seconds without output running [b'ninja', b'-j 32', 
b'check-offload'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1237.972714

```



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


[clang] [compiler-rt] [flang] [libc] [libcxx] [lld] [lldb] [llvm] [mlir] Optimize __insert_with_sentinel Function in std::vector (PR #113727)

2024-10-26 Thread Peng Liu via cfe-commits
Martin =?utf-8?q?Storsjö?= ,Thomas Fransham
 ,davidtrevelyan
 ,
Andrzej =?utf-8?q?Warzyński?= ,Louis Dionne
 ,Alex =?utf-8?q?Rønne?= Petersen ,lntue
 ,Shih-Po Hung ,Peng Liu
 ,Peng Liu 
Message-ID:
In-Reply-To: 


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


[clang] [sema] enhance error handling for compound stmt body in `StmtExpr` (PR #113760)

2024-10-26 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/113760

Mark the whole StmtExpr invalid when the last statement in compound statement 
is invalid.
Because the last statement need to do copy initialization, it causes subsequent 
errors to simply ignore last invalid statement.


>From 1ea7857b255f9a260ece14891f4a3a423468a605 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Sat, 26 Oct 2024 21:19:04 +0800
Subject: [PATCH] [sema] enhance error handling for compound stmt body in
 `StmtExpr`

Mark the whole StmtExpr invalid when the last statement in compound statement 
is invalid.
Because the last statement need to do copy initialization, it causes subsequent 
errors to simply ignore last invalid statement.
---
 clang/lib/Parse/ParseStmt.cpp   |  9 +
 clang/test/SemaCXX/gh113468.cpp | 12 
 2 files changed, 21 insertions(+)
 create mode 100644 clang/test/SemaCXX/gh113468.cpp

diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 60d647da48f053..6d0de38095b999 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -1243,6 +1243,7 @@ StmtResult Parser::ParseCompoundStatementBody(bool 
isStmtExpr) {
   ParsedStmtContext::Compound |
   (isStmtExpr ? ParsedStmtContext::InStmtExpr : ParsedStmtContext());
 
+  bool LastIsError = false;
   while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
  Tok.isNot(tok::eof)) {
 if (Tok.is(tok::annot_pragma_unused)) {
@@ -1299,7 +1300,15 @@ StmtResult Parser::ParseCompoundStatementBody(bool 
isStmtExpr) {
 
 if (R.isUsable())
   Stmts.push_back(R.get());
+LastIsError = R.isInvalid();
   }
+  // StmtExpr needs to do copy initialization for last statement.
+  // If last statement is invalid, the last statement in `Stmts` will be
+  // incorrect. Then the whole compound statement should also be marked as
+  // invalid to prevent subsequent errors.
+  if (isStmtExpr && LastIsError && !Stmts.empty())
+return StmtError();
+
   // Warn the user that using option `-ffp-eval-method=source` on a
   // 32-bit target and feature `sse` disabled, or using
   // `pragma clang fp eval_method=source` and feature `sse` disabled, is not
diff --git a/clang/test/SemaCXX/gh113468.cpp b/clang/test/SemaCXX/gh113468.cpp
new file mode 100644
index 00..94551986b0efaa
--- /dev/null
+++ b/clang/test/SemaCXX/gh113468.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+constexpr int expr() {
+  if (({
+int f;
+f = 0;
+if (f)
+  break; // expected-error {{'break' statement not in loop or switch 
statement}}
+  }))
+return 2;
+  return 1;
+}

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


[clang] [analyzer] Fix a crash from element region construction during `ArrayInitLoopExpr` analysis (PR #113570)

2024-10-26 Thread via cfe-commits

isuckatcs wrote:

@steakhal I wanted to wait for the pipeline to pass before merging. Shouldn't 
we only merge patches with a green pipeline?

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


[clang] [compiler-rt] [flang] [libc] [libcxx] [lld] [lldb] [llvm] [mlir] Optimize __insert_with_sentinel Function in std::vector (PR #113727)

2024-10-26 Thread via cfe-commits
Martin =?utf-8?q?Storsjö?= ,Thomas Fransham
 ,davidtrevelyan
 ,
Andrzej =?utf-8?q?Warzyński?= ,Louis Dionne
 ,Alex =?utf-8?q?Rønne?= Petersen ,lntue
 ,Shih-Po Hung ,Peng Liu
 ,Peng Liu 
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 8c4bc1e75de27adfbaead34b895b0efbaf17bd02 
3b5b692134d48ce4ebc2f21b9a4b569d24ddf9a3 --extensions ,cpp,cppm,c,h -- 
clang/test/Format/error-unfound-files.cpp 
flang/include/flang/Optimizer/Transforms/CUFCommon.h 
flang/lib/Optimizer/Transforms/CUFCommon.cpp 
libcxx/include/__locale_dir/locale_base_api/freebsd.h 
clang/include/clang/Lex/Preprocessor.h 
clang/include/clang/Serialization/ASTBitCodes.h 
clang/lib/Basic/Targets/WebAssembly.cpp clang/lib/CodeGen/CodeGenFunction.cpp 
clang/lib/Lex/HeaderSearch.cpp clang/lib/Serialization/ASTWriter.cpp 
clang/test/CodeGen/rtsan_attribute_inserted.c 
clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c 
clang/test/Modules/no-external-type-id.cppm 
clang/test/Preprocessor/wasm-target-features.c 
clang/tools/clang-format/ClangFormat.cpp 
compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp 
flang/lib/Optimizer/Transforms/CUFAddConstructor.cpp 
libc/src/math/generic/atan2.cpp libc/src/math/generic/cbrt.cpp 
libc/src/math/generic/cbrtf.cpp libc/src/math/generic/log.cpp 
libc/src/math/generic/log10.cpp libc/src/math/generic/log10f.cpp 
libc/src/math/generic/log1p.cpp libc/src/math/generic/log2.cpp 
libc/src/math/generic/log2f.cpp libc/src/math/generic/logf.cpp 
libc/src/math/generic/pow.cpp libc/src/math/generic/powf.cpp 
libc/src/math/generic/sin.cpp libc/src/math/generic/tan.cpp 
libc/test/src/math/cbrt_test.cpp libc/test/src/math/smoke/HypotTest.h 
libc/test/src/math/smoke/acosf_test.cpp 
libc/test/src/math/smoke/acoshf_test.cpp 
libc/test/src/math/smoke/asinf_test.cpp 
libc/test/src/math/smoke/asinhf_test.cpp 
libc/test/src/math/smoke/atan2_test.cpp libc/test/src/math/smoke/atanf_test.cpp 
libc/test/src/math/smoke/atanhf_test.cpp libc/test/src/math/smoke/cbrt_test.cpp 
libc/test/src/math/smoke/cbrtf_test.cpp libc/test/src/math/smoke/cos_test.cpp 
libc/test/src/math/smoke/cosf_test.cpp libc/test/src/math/smoke/coshf_test.cpp 
libc/test/src/math/smoke/cospif_test.cpp libc/test/src/math/smoke/erff_test.cpp 
libc/test/src/math/smoke/exp10_test.cpp 
libc/test/src/math/smoke/exp10f_test.cpp libc/test/src/math/smoke/exp2_test.cpp 
libc/test/src/math/smoke/exp2f_test.cpp 
libc/test/src/math/smoke/exp2m1f_test.cpp libc/test/src/math/smoke/exp_test.cpp 
libc/test/src/math/smoke/expf_test.cpp libc/test/src/math/smoke/expm1_test.cpp 
libc/test/src/math/smoke/expm1f_test.cpp 
libc/test/src/math/smoke/hypotf_test.cpp 
libc/test/src/math/smoke/log10_test.cpp 
libc/test/src/math/smoke/log10f_test.cpp 
libc/test/src/math/smoke/log1p_test.cpp 
libc/test/src/math/smoke/log1pf_test.cpp libc/test/src/math/smoke/log2_test.cpp 
libc/test/src/math/smoke/log2f_test.cpp libc/test/src/math/smoke/log_test.cpp 
libc/test/src/math/smoke/logf_test.cpp libc/test/src/math/smoke/pow_test.cpp 
libc/test/src/math/smoke/powf_test.cpp libc/test/src/math/smoke/sin_test.cpp 
libc/test/src/math/smoke/sinf_test.cpp libc/test/src/math/smoke/sinhf_test.cpp 
libc/test/src/math/smoke/sinpif_test.cpp libc/test/src/math/smoke/tan_test.cpp 
libc/test/src/math/smoke/tanf_test.cpp libc/test/src/math/smoke/tanhf_test.cpp 
libcxx/include/__locale_dir/locale_base_api.h libcxx/include/__vector/vector.h 
libcxx/include/version 
libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
 
libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
 
libcxx/test/std/language.support/support.limits/support.limits.general/optional.version.compile.pass.cpp
 
libcxx/test/std/language.support/support.limits/support.limits.general/variant.version.compile.pass.cpp
 
libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
 libcxx/test/support/test_macros.h 
lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
 llvm/include/llvm/ADT/StringRef.h 
llvm/include/llvm/Analysis/TargetLibraryInfo.h 
llvm/include/llvm/Bitcode/LLVMBitCodes.h 
llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h 
llvm/lib/Bitcode/Reader/BitcodeReader.cpp 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp 
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/lib/IR/Verifier.cpp 
llvm/lib/Support/StringRef.cpp llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp 
llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp 
llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp 
llvm/lib/Target/X86/X86TargetTransformInfo.cpp 
llvm/lib/Target/X86/X86TargetTransformInfo.h 
llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp 
llvm/lib/Transforms/Utils/CodeExtractor.cpp 
llvm/lib/Transforms/Vectorize/Loo

[clang] a917ae0 - [analyzer] Fix a crash from element region construction during `ArrayInitLoopExpr` analysis (#113570)

2024-10-26 Thread via cfe-commits

Author: isuckatcs
Date: 2024-10-26T17:41:55+02:00
New Revision: a917ae0b4fc0d792ee0e2c512c4ea539f98e1204

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

LOG: [analyzer] Fix a crash from element region construction during 
`ArrayInitLoopExpr` analysis (#113570)

This patch generalizes the way element regions are constructed when an
`ArrayInitLoopExpr` is being analyzed. Previously the base region of the
`ElementRegion` was determined with pattern matching, which led to
crashes, when an unhandled pattern was encountered.

Fixes #112813

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/test/Analysis/array-init-loop.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp 
b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
index c50db1e0e2f863..ccc3097e8d2f97 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -513,70 +513,25 @@ ProgramStateRef 
ExprEngine::updateObjectsUnderConstruction(
 static ProgramStateRef
 bindRequiredArrayElementToEnvironment(ProgramStateRef State,
   const ArrayInitLoopExpr *AILE,
-  const LocationContext *LCtx, SVal Idx) {
-  // The ctor in this case is guaranteed to be a copy ctor, otherwise we hit a
-  // compile time error.
-  //
-  //  -ArrayInitLoopExpr<-- we're here
-  //   |-OpaqueValueExpr
-  //   | `-DeclRefExpr  <-- match this
-  //   `-CXXConstructExpr
-  // `-ImplicitCastExpr
-  //   `-ArraySubscriptExpr
-  // |-ImplicitCastExpr
-  // | `-OpaqueValueExpr
-  // |   `-DeclRefExpr
-  // `-ArrayInitIndexExpr
-  //
-  // The resulting expression might look like the one below in an implicit
-  // copy/move ctor.
-  //
-  //   ArrayInitLoopExpr<-- we're here
-  //   |-OpaqueValueExpr
-  //   | `-MemberExpr   <-- match this
-  //   |  (`-CXXStaticCastExpr) <-- move ctor only
-  //   | `-DeclRefExpr
-  //   `-CXXConstructExpr
-  // `-ArraySubscriptExpr
-  //   |-ImplicitCastExpr
-  //   | `-OpaqueValueExpr
-  //   |   `-MemberExpr
-  //   | `-DeclRefExpr
-  //   `-ArrayInitIndexExpr
-  //
-  // The resulting expression for a multidimensional array.
-  // ArrayInitLoopExpr  <-- we're here
-  // |-OpaqueValueExpr
-  // | `-DeclRefExpr<-- match this
-  // `-ArrayInitLoopExpr
-  //   |-OpaqueValueExpr
-  //   | `-ArraySubscriptExpr
-  //   |   |-ImplicitCastExpr
-  //   |   | `-OpaqueValueExpr
-  //   |   |   `-DeclRefExpr
-  //   |   `-ArrayInitIndexExpr
-  //   `-CXXConstructExpr <-- extract this
-  // ` ...
-
-  const auto *OVESrc = AILE->getCommonExpr()->getSourceExpr();
+  const LocationContext *LCtx, NonLoc Idx) 
{
+  SValBuilder &SVB = State->getStateManager().getSValBuilder();
+  MemRegionManager &MRMgr = SVB.getRegionManager();
+  ASTContext &Ctx = SVB.getContext();
 
   // HACK: There is no way we can put the index of the array element into the
   // CFG unless we unroll the loop, so we manually select and bind the required
   // parameter to the environment.
-  const auto *CE =
+  const Expr *SourceArray = AILE->getCommonExpr()->getSourceExpr();
+  const auto *Ctor =
   cast(extractElementInitializerFromNestedAILE(AILE));
 
-  SVal Base = UnknownVal();
-  if (const auto *ME = dyn_cast(OVESrc))
-Base = State->getSVal(ME, LCtx);
-  else if (const auto *DRE = dyn_cast(OVESrc))
-Base = State->getLValue(cast(DRE->getDecl()), LCtx);
-  else
-llvm_unreachable("ArrayInitLoopExpr contains unexpected source 
expression");
-
-  SVal NthElem = State->getLValue(CE->getType(), Idx, Base);
+  const auto *SourceArrayRegion =
+  cast(State->getSVal(SourceArray, LCtx).getAsRegion());
+  const ElementRegion *ElementRegion =
+  MRMgr.getElementRegion(Ctor->getType(), Idx, SourceArrayRegion, Ctx);
 
-  return State->BindExpr(CE->getArg(0), LCtx, NthElem);
+  return State->BindExpr(Ctor->getArg(0), LCtx,
+ loc::MemRegionVal(ElementRegion));
 }
 
 void ExprEngine::handleConstructor(const Expr *E,

diff  --git a/clang/test/Analysis/array-init-loop.cpp 
b/clang/test/Analysis/array-init-loop.cpp
index 4ab4489fc882f3..b28468b7f560b2 100644
--- a/clang/test/Analysis/array-init-loop.cpp
+++ b/clang/test/Analysis/array-init-loop.cpp
@@ -330,3 +330,41 @@ void no_crash() {
 }
 
 } // namespace crash
+
+namespace array_subscript_initializer {
+struct S {
+  int x;
+};
+
+void no_crash() {
+  S arr[][2] = {{1, 2}};
+
+  const auto [a, b] = arr[0]; // no-crash
+
+  clang_analyzer_eval(a.x == 1); // expected-warning{

[clang] [analyzer] Fix a crash from element region construction during `ArrayInitLoopExpr` analysis (PR #113570)

2024-10-26 Thread Balazs Benics via cfe-commits

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


[clang] [analyzer] Fix a crash from element region construction during `ArrayInitLoopExpr` analysis (PR #113570)

2024-10-26 Thread Balazs Benics via cfe-commits

steakhal wrote:

> @steakhal I wanted to wait for the pipeline to pass before merging. Shouldn't 
> we only merge patches with a green pipeline?

The full pipeline will never be green. Downstream I wouldn't do this, but here 
I think we did what is reasonable. Waited enough. We can always revert with a 
single push of a button.


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


[clang] [compiler-rt] [llvm] [rtsan][llvm][NFC] Rename sanitize_realtime_unsafe attr to sanitize_realtime_blocking (PR #113155)

2024-10-26 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-aarch64-linux-bootstrap-hwasan` running on `sanitizer-buildbot12` 
while building `clang,compiler-rt,llvm` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/55/builds/3099


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 83147 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.
FAIL: lld :: ELF/error-limit-no-newlines.s (81106 of 83147)
 TEST 'lld :: ELF/error-limit-no-newlines.s' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llvm-mc
 -filetype=obj -triple=x86_64 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/lld/test/ELF/error-limit-no-newlines.s
 -o 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp1.o
+ 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/llvm-mc
 -filetype=obj -triple=x86_64 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/lld/test/ELF/error-limit-no-newlines.s
 -o 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp1.o
RUN: at line 3: not 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/ld.lld
 --error-limit=1 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp1.o
 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp1.o
 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp1.o
 -o /dev/null 
2>/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp.output
+ not 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/ld.lld
 --error-limit=1 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp1.o
 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp1.o
 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp1.o
 -o /dev/null
RUN: at line 4: echo "END" >> 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/tools/lld/test/ELF/Output/error-limit-no-newlines.s.tmp.output
+ echo END
RUN: at line 5: 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm_build_hwasan/bin/FileCheck
 
/home/b/sanitizer-aarch64-linux-bootstrap-hwasan/build/llvm-project/lld/test/ELF/error-lim

[clang] [Clang] Add __ugly__ spelling for the msvc attribute scope (PR #113765)

2024-10-26 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff d906ac52ab8ee46090a6696f4ffb34c40ee6abb7 
68f3617027fa09b531b5e3eaea6a025c6783a258 --extensions cpp,h -- 
clang/include/clang/Basic/Attributes.h clang/lib/Basic/Attributes.cpp 
clang/lib/Sema/SemaCodeComplete.cpp 
clang/test/SemaCXX/cxx2a-ms-no-unique-address.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Basic/Attributes.h 
b/clang/include/clang/Basic/Attributes.h
index 9fa7e5ce55..498a4a2e41 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -23,7 +23,7 @@ int hasAttribute(AttributeCommonInfo::Syntax Syntax,
  const IdentifierInfo *Scope, const IdentifierInfo *Attr,
  const TargetInfo &Target, const LangOptions &LangOpts);
 
-inline const char* deuglifyAttrScope(StringRef Scope) {
+inline const char *deuglifyAttrScope(StringRef Scope) {
   if (Scope == "_Clang")
 return "clang";
   if (Scope == "__gnu__")
@@ -33,7 +33,7 @@ inline const char* deuglifyAttrScope(StringRef Scope) {
   return nullptr;
 }
 
-inline const char* uglifyAttrScope(StringRef Scope) {
+inline const char *uglifyAttrScope(StringRef Scope) {
   if (Scope == "clang")
 return "_Clang";
   if (Scope == "gnu")

``




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


[clang] [llvm] [HLSL][SPIRV] Added clamp intrinsic (PR #113394)

2024-10-26 Thread Farzon Lotfi via cfe-commits

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

LGTM

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


[clang] [clang-format] Enable sorting includes although formatting disabled (PR #113771)

2024-10-26 Thread Martin Lambertsen via cfe-commits

https://github.com/marlamb created 
https://github.com/llvm/llvm-project/pull/113771

Projects exist, which do not want to use an automated formatting, but
could benefit from sorting the includes, especially to include the main
headers first in order to improve the self-consistency of headers.

While this was possible with `clang-format` for some time, it was
disabled with commit `61dc0f2b593da149a4c0cea67819cd7bdbdd50b8`. The
main reason was that it is confusing for users.

This commit enables sorting the includes more explicitly, to allow the
feature without confusing users.

>From 1f7b4cb87d16f0928140e916919cf5e1b07963a7 Mon Sep 17 00:00:00 2001
From: Martin Lambertsen 
Date: Sat, 26 Oct 2024 21:41:37 +0200
Subject: [PATCH] [clang-format] Enable sorting includes although formatting
 disabled

Projects exist, which do not want to use an automated formatting, but
could benefit from sorting the includes, especially to include the main
headers first in order to improve the self-consistency of headers.

While this was possible with `clang-format` for some time, it was
disabled with commit `61dc0f2b593da149a4c0cea67819cd7bdbdd50b8`. The
main reason was that it is confusing for users.

This commit enables sorting the includes more explicitly, to allow the
feature without confusing users.
---
 clang/include/clang/Format/Format.h | 13 +
 clang/lib/Format/Format.cpp | 21 +++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index c9b72e65cb236d..6acb8ba81dabfd 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2656,6 +2656,18 @@ struct FormatStyle {
   /// \version 12
   EmptyLineBeforeAccessModifierStyle EmptyLineBeforeAccessModifier;
 
+  /// TODO: Descriptive comment.
+  enum EnableSortIncludesOptions : int8_t {
+/// TODO: Descriptive comment.
+ESI_Always,
+/// TODO: Descriptive comment.
+ESI_IfFormatEnabled,
+/// TODO: Descriptive comment.
+ESI_Never,
+  };
+
+  EnableSortIncludesOptions EnableSortIncludes;
+
   /// If ``true``, clang-format detects whether function calls and
   /// definitions are formatted with one parameter per line.
   ///
@@ -5203,6 +5215,7 @@ struct FormatStyle {
DisableFormat == R.DisableFormat &&
EmptyLineAfterAccessModifier == R.EmptyLineAfterAccessModifier &&
EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier &&
+   EnableSortIncludes == R.EnableSortIncludes &&
ExperimentalAutoDetectBinPacking ==
R.ExperimentalAutoDetectBinPacking &&
FixNamespaceComments == R.FixNamespaceComments &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 0cf4cdbeab31f3..f675d108e52df4 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -361,6 +361,16 @@ struct ScalarEnumerationTraits<
   }
 };
 
+template <>
+struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO,
+  FormatStyle::EnableSortIncludesOptions &Value) {
+IO.enumCase(Value, "Always", FormatStyle::ESI_Always);
+IO.enumCase(Value, "IfFormatEnabled", FormatStyle::ESI_IfFormatEnabled);
+IO.enumCase(Value, "Never", FormatStyle::ESI_Never);
+  }
+};
+
 template <>
 struct ScalarEnumerationTraits {
   static void enumeration(IO &IO, FormatStyle::IndentExternBlockStyle &Value) {
@@ -1024,6 +1034,7 @@ template <> struct MappingTraits {
Style.EmptyLineAfterAccessModifier);
 IO.mapOptional("EmptyLineBeforeAccessModifier",
Style.EmptyLineBeforeAccessModifier);
+IO.mapOptional("EnableSortIncludes", Style.EnableSortIncludes);
 IO.mapOptional("ExperimentalAutoDetectBinPacking",
Style.ExperimentalAutoDetectBinPacking);
 IO.mapOptional("FixNamespaceComments", Style.FixNamespaceComments);
@@ -1531,6 +1542,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.DisableFormat = false;
   LLVMStyle.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Never;
   LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
+  LLVMStyle.EnableSortIncludes = FormatStyle::ESI_Always;
   LLVMStyle.ExperimentalAutoDetectBinPacking = false;
   LLVMStyle.FixNamespaceComments = true;
   LLVMStyle.ForEachMacros.push_back("foreach");
@@ -1837,6 +1849,7 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind 
Language) {
 FormatStyle::SIS_WithoutElse;
 ChromiumStyle.BreakAfterJavaFieldAnnotations = true;
 ChromiumStyle.ContinuationIndentWidth = 8;
+ChromiumStyle.EnableSortIncludes = FormatStyle::ESI_Always;
 ChromiumStyle.IndentWidth = 4;
 // See styleguide for import groups:
 // 
https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/java/java.md#Import-Order
@@ -1980,7 +1993,7 @@ FormatStyle getClangFormatStyle() {
 Forma

[clang] [clang-format] Enable sorting includes although formatting disabled (PR #113771)

2024-10-26 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[clang] [llvm] [HLSL][SPIRV] Added clamp intrinsic (PR #113394)

2024-10-26 Thread Farzon Lotfi via cfe-commits


@@ -83,12 +83,210 @@ entry:
   ret i64 %0
 }
 
-declare half @llvm.dx.clamp.f16(half, half, half)
-declare float @llvm.dx.clamp.f32(float, float, float)
-declare double @llvm.dx.clamp.f64(double, double, double)
-declare i16 @llvm.dx.clamp.i16(i16, i16, i16)
-declare i32 @llvm.dx.clamp.i32(i32, i32, i32)
-declare i64 @llvm.dx.clamp.i64(i64, i64, i64)
+declare half @llvm.dx.nclamp.f16(half, half, half)

farzonl wrote:

Move these declare(s) to line 230 where all the other declare are.

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


[clang] [clang-format] Enable sorting includes although formatting disabled (PR #113771)

2024-10-26 Thread Martin Lambertsen via cfe-commits

marlamb wrote:

The PR as of now is far from being complete, but before putting the effort in 
adding tests/documentation etc. it would be great to have some feedback, if the 
feature is seen worth being offered and if the proposal looks roughly 
acceptable. I have to admit I am not really happy about it myself, but the 
alternative I see (putting it into the `SortIncludes` directly, which would 
interfere with the `CaseSensitive` and `CaseInsensitive`) looks even less 
user-friendly.

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


[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread Vlad Serebrennikov via cfe-commits

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


[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits

https://github.com/vvd170501 updated 
https://github.com/llvm/llvm-project/pull/113612

>From 489d258577552cde839f0949a1ce24d4b1f72103 Mon Sep 17 00:00:00 2001
From: vvd170501 <36827317+vvd170...@users.noreply.github.com>
Date: Sat, 26 Oct 2024 00:17:26 +0300
Subject: [PATCH 1/4] Fix variant parsing

---
 .../include-mapping/cppreference_parser.py| 23 +++
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/clang/tools/include-mapping/cppreference_parser.py 
b/clang/tools/include-mapping/cppreference_parser.py
index f2ea55384fac80..ff8d16bd792b33 100644
--- a/clang/tools/include-mapping/cppreference_parser.py
+++ b/clang/tools/include-mapping/cppreference_parser.py
@@ -7,7 +7,7 @@
 #
 # 
======#
 
-from bs4 import BeautifulSoup, NavigableString
+from bs4 import BeautifulSoup, NavigableString, Tag
 
 import collections
 import multiprocessing
@@ -89,6 +89,23 @@ def _ParseSymbolPage(symbol_page_html, symbol_name):
 return headers or all_headers
 
 
+def _ParseSymbolVariant(caption):
+if not (isinstance(caption, NavigableString) and "(" in caption):
+return None
+
+if ')' in caption.text:  # (locale), (algorithm), etc.
+return caption.text.strip(" ()")
+
+second_part = caption.next_sibling
+if isinstance(second_part, Tag) and second_part.name == "code":
+# (std::complex), etc.
+third_part = second_part.next_sibling
+if isinstance(third_part, NavigableString) and 
third_part.text.startswith(')'):
+return second_part.text
+return None
+
+
+
 def _ParseIndexPage(index_page_html):
 """Parse index page.
 The index page lists all std symbols and hrefs to their detailed pages
@@ -107,9 +124,7 @@ def _ParseIndexPage(index_page_html):
 # This accidentally accepts begin/end despite the (iterator) caption: 
the
 # (since C++11) note is first. They are good symbols, so the bug is 
unfixed.
 caption = symbol_href.next_sibling
-variant = None
-if isinstance(caption, NavigableString) and "(" in caption:
-variant = caption.text.strip(" ()")
+variant = _ParseSymbolVariant(caption)
 symbol_tt = symbol_href.find("tt")
 if symbol_tt:
 symbols.append(

>From 2a4796c7618575bac80817bfe33774860564b8be Mon Sep 17 00:00:00 2001
From: vvd170501 <36827317+vvd170...@users.noreply.github.com>
Date: Sat, 26 Oct 2024 06:38:41 +0300
Subject: [PATCH 2/4] Parse symbols with qualified name (not sure if it works
 in this revision)

---
 clang/tools/include-mapping/cppreference_parser.py | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/clang/tools/include-mapping/cppreference_parser.py 
b/clang/tools/include-mapping/cppreference_parser.py
index ff8d16bd792b33..110c8b1cf2b11f 100644
--- a/clang/tools/include-mapping/cppreference_parser.py
+++ b/clang/tools/include-mapping/cppreference_parser.py
@@ -40,7 +40,7 @@ def _HasClass(tag, *classes):
 return False
 
 
-def _ParseSymbolPage(symbol_page_html, symbol_name):
+def _ParseSymbolPage(symbol_page_html, symbol_name, qual_name):
 """Parse symbol page and retrieve the include header defined in this page.
 The symbol page provides header for the symbol, specifically in
 "Defined in header " section. An example:
@@ -69,7 +69,7 @@ def _ParseSymbolPage(symbol_page_html, symbol_name):
 was_decl = True
 # Symbols are in the first cell.
 found_symbols = row.find("td").stripped_strings
-if not symbol_name in found_symbols:
+if not (symbol_name in found_symbols or qual_name in 
found_symbols):
 continue
 headers.update(current_headers)
 elif _HasClass(row, "t-dsc-header"):
@@ -137,9 +137,9 @@ def _ParseIndexPage(index_page_html):
 return symbols
 
 
-def _ReadSymbolPage(path, name):
+def _ReadSymbolPage(path, name, qual_name):
 with open(path) as f:
-return _ParseSymbolPage(f.read(), name)
+return _ParseSymbolPage(f.read(), name, qual_name)
 
 
 def _GetSymbols(pool, root_dir, index_page_name, namespace, 
variants_to_accept):
@@ -161,8 +161,9 @@ def _GetSymbols(pool, root_dir, index_page_name, namespace, 
variants_to_accept):
 for symbol_name, symbol_page_path, variant in 
_ParseIndexPage(f.read()):
 # Variant symbols (e.g. the std::locale version of isalpha) add 
ambiguity.
 # FIXME: use these as a fallback rather than ignoring entirely.
+qualified_symbol_name = (namespace or "") + symbol_name
 variants_for_symbol = variants_to_accept.get(
-(namespace or "") + symbol_name, ()
+qualified_symbol_name, ()
 )
 if variant and variant not in variants_for_symbol:
 continue
@@ -171,7 +172,7 @@ def _GetSymbols(pool, root_dir

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-26 Thread Jesse Huang via cfe-commits

https://github.com/jaidTw updated 
https://github.com/llvm/llvm-project/pull/112477

>From fe4a28fb691b69d9af384f1dc2f0667761adef44 Mon Sep 17 00:00:00 2001
From: Jesse Huang 
Date: Sun, 13 Oct 2024 15:11:06 +0800
Subject: [PATCH 1/6] [Clang][RISCV] Support -fcf-protection=return for RISC-V

---
 clang/lib/Basic/Targets/RISCV.h   | 7 +++
 clang/lib/CodeGen/CodeGenFunction.cpp | 4 
 2 files changed, 11 insertions(+)

diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index bf40edb8683b3e..3f2cee72fc3731 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -141,6 +141,13 @@ class RISCVTargetInfo : public TargetInfo {
 return true;
   }
 
+  bool
+  checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override {
+if (ISAInfo->hasExtension("zimop"))
+  return true;
+return TargetInfo::checkCFProtectionReturnSupported(Diags);
+  }
+
   CFBranchLabelSchemeKind getDefaultCFBranchLabelScheme() const override {
 return CFBranchLabelSchemeKind::FuncSig;
   }
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 2306043c90f406..d8f0f7c14f6b40 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -899,6 +899,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   if (CodeGenOpts.PointerAuth.IndirectGotos)
 Fn->addFnAttr("ptrauth-indirect-gotos");
 
+  // Add return control flow integrity attributes.
+  if (CodeGenOpts.CFProtectionReturn)
+Fn->addFnAttr("hw-shadow-stack");
+
   // Apply xray attributes to the function (as a string, for now)
   bool AlwaysXRayAttr = false;
   if (const auto *XRayAttr = D ? D->getAttr() : nullptr) {

>From 7dc168af5758d130042c71ba5d6249c042bc356c Mon Sep 17 00:00:00 2001
From: Jesse Huang 
Date: Wed, 23 Oct 2024 14:42:35 +0800
Subject: [PATCH 2/6] [Clang][RISCV] Add RISCV check for hw-shadow-stack

---
 clang/lib/CodeGen/CodeGenFunction.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index d8f0f7c14f6b40..cca52f3769845e 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -899,8 +899,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
   if (CodeGenOpts.PointerAuth.IndirectGotos)
 Fn->addFnAttr("ptrauth-indirect-gotos");
 
-  // Add return control flow integrity attributes.
-  if (CodeGenOpts.CFProtectionReturn)
+  // Add return control flow integrity attributes for RISCV.
+  if (CodeGenOpts.CFProtectionReturn &&
+  getContext().getTargetInfo().getTriple().isRISCV())
 Fn->addFnAttr("hw-shadow-stack");
 
   // Apply xray attributes to the function (as a string, for now)

>From 42132c246058f6c1aaa646266847a3b8c854 Mon Sep 17 00:00:00 2001
From: Jesse Huang 
Date: Thu, 24 Oct 2024 15:39:07 +0800
Subject: [PATCH 3/6] [Clang][RISCV] Add function attribute in RISC-V specific
 code

---
 clang/lib/CodeGen/CodeGenFunction.cpp | 5 -
 clang/lib/CodeGen/Targets/RISCV.cpp   | 7 +--
 2 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index cca52f3769845e..2306043c90f406 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -899,11 +899,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, 
QualType RetTy,
   if (CodeGenOpts.PointerAuth.IndirectGotos)
 Fn->addFnAttr("ptrauth-indirect-gotos");
 
-  // Add return control flow integrity attributes for RISCV.
-  if (CodeGenOpts.CFProtectionReturn &&
-  getContext().getTargetInfo().getTriple().isRISCV())
-Fn->addFnAttr("hw-shadow-stack");
-
   // Apply xray attributes to the function (as a string, for now)
   bool AlwaysXRayAttr = false;
   if (const auto *XRayAttr = D ? D->getAttr() : nullptr) {
diff --git a/clang/lib/CodeGen/Targets/RISCV.cpp 
b/clang/lib/CodeGen/Targets/RISCV.cpp
index fd72fe673b9b14..b04e436c665f52 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -594,6 +594,11 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
 const auto *FD = dyn_cast_or_null(D);
 if (!FD) return;
 
+auto *Fn = cast(GV);
+
+if (CGM.getCodeGenOpts().CFProtectionReturn)
+  Fn->addFnAttr("hw-shadow-stack");
+
 const auto *Attr = FD->getAttr();
 if (!Attr)
   return;
@@ -604,8 +609,6 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
 case RISCVInterruptAttr::machine: Kind = "machine"; break;
 }
 
-auto *Fn = cast(GV);
-
 Fn->addFnAttr("interrupt", Kind);
   }
 };

>From 2b6bdc5e95043a0f481314c0c2e5441804addf06 Mon Sep 17 00:00:00 2001
From: Jesse Huang 
Date: Fri, 25 Oct 2024 14:13:45 +0800
Subject: [PATCH 4/6] [Clang] Add test for hw-shadodw-stack

---
 clang/test/CodeGen/RISCV/attr-hw-shadow-stack

[clang] [llvm] [AMDGPU] Add a type for the named barrier (PR #113614)

2024-10-26 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-x86_64-debian-dylib` 
running on `gribozavr4` while building `clang,llvm` at step 5 
"build-unified-tree".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/60/builds/11107


Here is the relevant piece of the build log for the reference

```
Step 5 (build-unified-tree) failure: build (failure)
...
23.865 [3534/96/3387] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86LowerTileCopy.cpp.o
23.873 [3533/96/3388] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86LowerAMXIntrinsics.cpp.o
23.889 [3532/96/3389] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FastTileConfig.cpp.o
23.904 [3531/96/3390] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86TileConfig.cpp.o
23.929 [3530/96/3391] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FastPreTileConfig.cpp.o
23.945 [3529/96/3392] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86ExpandPseudo.cpp.o
23.961 [3528/96/3393] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86PreTileConfig.cpp.o
23.977 [3527/96/3394] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FastISel.cpp.o
24.001 [3526/96/3395] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FixupLEAs.cpp.o
24.002 [3525/96/3396] Building CXX object 
tools/clang/lib/CrossTU/CMakeFiles/obj.clangCrossTU.dir/CrossTranslationUnit.cpp.o
FAILED: 
tools/clang/lib/CrossTU/CMakeFiles/obj.clangCrossTU.dir/CrossTranslationUnit.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ 
-DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/clang/lib/CrossTU 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/lib/CrossTU 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/include 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/clang/include 
-I/b/1/llvm-x86_64-debian-dylib/build/include 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti 
-UNDEBUG -std=c++17 -MD -MT 
tools/clang/lib/CrossTU/CMakeFiles/obj.clangCrossTU.dir/CrossTranslationUnit.cpp.o
 -MF 
tools/clang/lib/CrossTU/CMakeFiles/obj.clangCrossTU.dir/CrossTranslationUnit.cpp.o.d
 -o 
tools/clang/lib/CrossTU/CMakeFiles/obj.clangCrossTU.dir/CrossTranslationUnit.cpp.o
 -c 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/lib/CrossTU/CrossTranslationUnit.cpp
In file included from 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/lib/CrossTU/CrossTranslationUnit.cpp:18:
In file included from 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/include/clang/Frontend/ASTUnit.h:29:
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/include/clang/Serialization/ASTBitCodes.h:1156:1:
 error: static_assert failed due to requirement 'PREDEF_TYPE_LAST_ID < 
NUM_PREDEF_TYPE_IDS' "Too many enumerators in PredefinedTypeIDs. Review the 
value of NUM_PREDEF_TYPE_IDS"
static_assert(PREDEF_TYPE_LAST_ID < NUM_PREDEF_TYPE_IDS,
^ ~
1 error generated.
24.003 [3525/95/3397] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FixupBWInsts.cpp.o
24.003 [3525/94/3398] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FixupInstTuning.cpp.o
24.004 [3525/93/3399] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FixupVectorConstants.cpp.o
24.041 [3525/92/3400] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86DynAllocaExpander.cpp.o
24.043 [3525/91/3401] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FlagsCopyLowering.cpp.o
24.057 [3525/90/3402] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86AvoidStoreForwardingBlocks.cpp.o
24.058 [3525/89/3403] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86FixupSetCC.cpp.o
24.088 [3525/88/3404] Building CXX object 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTStructuralEquivalence.cpp.o
24.203 [3525/87/3405] Building CXX object 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseInit.cpp.o
24.225 [3525/86/3406] Building CXX object 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseHLSL.cpp.o
24.564 [3525/85/3407] Building AMDGPUGenCa

[clang] Update std symbols mapping (PR #113612)

2024-10-26 Thread Vadim D. via cfe-commits


@@ -598,7 +598,6 @@ SYMBOL(aligned_union_t, std::, )
 SYMBOL(alignment_of, std::, )
 SYMBOL(alignment_of_v, std::, )
 SYMBOL(all_of, std::, )
-SYMBOL(allocate_at_least, std::, )

vvd170501 wrote:

Was replaced with `std::allocator_traits<>::allocate_at_least` in 
[P2652R2](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2652r2.html)

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


[clang] [llvm] [RISCV]Add svvptc extension (PR #113758)

2024-10-26 Thread via cfe-commits

https://github.com/dong-miao updated 
https://github.com/llvm/llvm-project/pull/113758

>From 6424bebfcf16ef9694d7406b0298045da2d426bf Mon Sep 17 00:00:00 2001
From: dong-miao <601183...@qq.com>
Date: Sat, 26 Oct 2024 06:49:04 +
Subject: [PATCH 1/4] [RISCV]Add svvptc extensions

---
 clang/test/Driver/print-supported-extensions-riscv.c | 1 +
 clang/test/Preprocessor/riscv-target-features.c  | 9 +
 llvm/docs/RISCVUsage.rst | 1 +
 llvm/lib/Target/RISCV/RISCVFeatures.td   | 4 
 llvm/test/CodeGen/RISCV/attributes.ll| 4 
 llvm/test/MC/RISCV/attribute-arch.s  | 3 +++
 llvm/unittests/TargetParser/RISCVISAInfoTest.cpp | 1 +
 7 files changed, 23 insertions(+)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 342d6e921a5a83..2d7376f8fe9401 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -146,6 +146,7 @@
 // CHECK-NEXT: svinval  1.0   'Svinval' (Fine-Grained 
Address-Translation Cache Invalidation)
 // CHECK-NEXT: svnapot  1.0   'Svnapot' (NAPOT Translation 
Contiguity)
 // CHECK-NEXT: svpbmt   1.0   'Svpbmt' (Page-Based Memory 
Types)
+// CHECK-NEXT: svvptc   1.0   'Svvptc' (Obviating 
Memory-Management Instructions after Marking PTEs Valid)
 // CHECK-NEXT: xcvalu   1.0   'XCValu' (CORE-V ALU 
Operations)
 // CHECK-NEXT: xcvbi1.0   'XCVbi' (CORE-V Immediate 
Branching)
 // CHECK-NEXT: xcvbitmanip  1.0   'XCVbitmanip' (CORE-V Bit 
Manipulation)
diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 98ad564d2b8408..5b4d42b053edc6 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -51,6 +51,7 @@
 // CHECK-NOT: __riscv_svinval {{.*$}}
 // CHECK-NOT: __riscv_svnapot {{.*$}}
 // CHECK-NOT: __riscv_svpbmt {{.*$}}
+// CHECK-NOT: __riscv_svvptc {{.*$}}
 // CHECK-NOT: __riscv_v {{.*$}}
 // CHECK-NOT: __riscv_v_elen {{.*$}}
 // CHECK-NOT: __riscv_v_elen_fp {{.*$}}
@@ -507,6 +508,14 @@
 // RUN:   -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
 // CHECK-SVPBMT-EXT: __riscv_svpbmt 100{{$}}
 
+// RUN: %clang --target=riscv32-unknown-linux-gnu \
+// RUN:   -march=rv32isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// RUN: %clang --target=riscv64-unknown-linux-gnu \
+// RUN:   -march=rv64isvvptc -E -dM %s \
+// RUN:   -o - | FileCheck --check-prefix=CHECK-SVVPTC-EXT %s
+// CHECK-SVVPTC-EXT: __riscv_svvptc 100{{$}}
+
 // RUN: %clang --target=riscv32-unknown-linux-gnu \
 // RUN:   -march=rv32iv1p0 -E -dM %s \
 // RUN:   -o - | FileCheck --check-prefix=CHECK-V-EXT %s
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index ab58cdaa1b2f95..958168772fe413 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -155,6 +155,7 @@ on support follow.
  ``Svinval``   Assembly Support
  ``Svnapot``   Assembly Support
  ``Svpbmt``Supported
+ ``Svvptc``Supported
  ``V`` Supported
  ``Za128rs``   Supported (`See note 
<#riscv-profiles-extensions-note>`__)
  ``Za64rs``Supported (`See note 
<#riscv-profiles-extensions-note>`__)
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 778df542022f22..3b86bc69153631 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -1029,6 +1029,10 @@ def FeatureStdExtSvpbmt
 : RISCVExtension<"svpbmt", 1, 0,
  "'Svpbmt' (Page-Based Memory Types)">;
 
+def FeatureStdExtSvvptc
+: RISCVExtension<"svvptc", 1, 0,
+ "'svvptc' (Obviating Memory-Management Instructions after 
Marking PTEs Valid)">; 
+
 // Pointer Masking extensions
 
 // A supervisor-level extension that provides pointer masking for the next 
lower
diff --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index e9743d484f776f..2d07919e042edc 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -62,6 +62,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVNAPOT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVINVAL %s
+; RUN: llc -mtriple=riscv32 -mattr=+svvptc %s -o - | FileCheck 
--check-prefixes=CHECK,RV32SVVPTC %s
 ; RUN: llc -mtriple=riscv32 -mattr=+xcvalu %s -o - | FileCheck 
--check-prefix=RV32XCVALU %s
 ; RUN: llc -mtriple=riscv32 -mattr=+xcvbitmanip

[clang] 4102625 - [rtsan][llvm][NFC] Rename sanitize_realtime_unsafe attr to sanitize_realtime_blocking (#113155)

2024-10-26 Thread via cfe-commits

Author: davidtrevelyan
Date: 2024-10-26T13:06:11+01:00
New Revision: 4102625380823e58d7b13f01b5bd979a29bce19e

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

LOG: [rtsan][llvm][NFC] Rename sanitize_realtime_unsafe attr to 
sanitize_realtime_blocking (#113155)

# What

This PR renames the newly-introduced llvm attribute
`sanitize_realtime_unsafe` to `sanitize_realtime_blocking`. Likewise,
sibling variables such as `SanitizeRealtimeUnsafe` are renamed to
`SanitizeRealtimeBlocking` respectively. There are no other functional
changes.


# Why?

- There are a number of problems that can cause a function to be
real-time "unsafe",
- we wish to communicate what problems rtsan detects and *why* they're
unsafe, and
- a generic "unsafe" attribute is, in our opinion, too broad a net -
which may lead to future implementations that need extra contextual
information passed through them in order to communicate meaningful
reasons to users.
- We want to avoid this situation and make the runtime library boundary
API/ABI as simple as possible, and
- we believe that restricting the scope of attributes to names like
`sanitize_realtime_blocking` is an effective means of doing so.

We also feel that the symmetry between `[[clang::blocking]]` and
`sanitize_realtime_blocking` is easier to follow as a developer.

# Concerns

- I'm aware that the LLVM attribute `sanitize_realtime_unsafe` has been
part of the tree for a few weeks now (introduced here:
https://github.com/llvm/llvm-project/pull/106754). Given that it hasn't
been released in version 20 yet, am I correct in considering this to not
be a breaking change?

Added: 
llvm/test/Instrumentation/RealtimeSanitizer/rtsan_blocking.ll

Modified: 
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGen/rtsan_attribute_inserted.c
clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c
compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
llvm/docs/LangRef.rst
llvm/include/llvm/Bitcode/LLVMBitCodes.h
llvm/include/llvm/IR/Attributes.td
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp
llvm/lib/Transforms/Utils/CodeExtractor.cpp
llvm/test/Bitcode/attributes.ll
llvm/test/Bitcode/compatibility.ll
llvm/test/Verifier/rtsan-attrs.ll

Removed: 
llvm/test/Instrumentation/RealtimeSanitizer/rtsan_unsafe.ll



diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 573ced0857d5f5..6ead45793742d6 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -852,7 +852,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType 
RetTy,
 if (Fe.Effect.kind() == FunctionEffect::Kind::NonBlocking)
   Fn->addFnAttr(llvm::Attribute::SanitizeRealtime);
 else if (Fe.Effect.kind() == FunctionEffect::Kind::Blocking)
-  Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeUnsafe);
+  Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeBlocking);
   }
 
   // Apply fuzzing attribute to the function.

diff  --git a/clang/test/CodeGen/rtsan_attribute_inserted.c 
b/clang/test/CodeGen/rtsan_attribute_inserted.c
index b21ecb6b6b06a9..cebfe43c81234c 100644
--- a/clang/test/CodeGen/rtsan_attribute_inserted.c
+++ b/clang/test/CodeGen/rtsan_attribute_inserted.c
@@ -8,4 +8,4 @@ float process(float *a) [[clang::nonblocking]] { return *a; }
 int spinlock(int *a) [[clang::blocking]] { return *a; }
 // CHECK: @spinlock{{.*}} #1 {
 // CHECK: attributes #1 = {
-// CHECK-SAME: {{.*sanitize_realtime_unsafe .*}}
+// CHECK-SAME: {{.*sanitize_realtime_blocking .*}}

diff  --git a/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c 
b/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c
index 0f43007c5e4c16..86305080c94ace 100644
--- a/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c
+++ b/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c
@@ -5,4 +5,4 @@ int spinlock(int *a) [[clang::blocking]] { return *a; }
 
 // Without the -fsanitize=realtime flag, we shouldn't attach the attributes.
 // CHECK-NOT: {{.*sanitize_realtime .*}}
-// CHECK-NOT: {{.*sanitize_realtime_unsafe .*}}
+// CHECK-NOT: {{.*sanitize_realtime_blocking .*}}

diff  --git a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp 
b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
index 9e455f0326a549..ed9ee4ded7b059 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
@@ -204,11 +204,11 @@ TEST(TestRtsan, ThrowingAnExceptionDiesWhenRealtime) {
 
 TEST(TestRtsan, DoesNotDieIfTurnedOff) {
   std::mutex mutex;
-  auto RealtimeUnsafeFunc = [&]

[clang] [compiler-rt] [llvm] [rtsan][llvm][NFC] Rename sanitize_realtime_unsafe attr to sanitize_realtime_blocking (PR #113155)

2024-10-26 Thread via cfe-commits

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


[clang] [clang-format] add MaxSingleLinesInBracedList style option (PR #112482)

2024-10-26 Thread Gedare Bloom via cfe-commits

gedare wrote:

> > There will be bugs if/when people use this option with small values for the 
> > limit, as it will interact weirdly with both the braced list initializer 
> > formatting rules, and also with the `AvoidBinPacking` logic of the 
> > continuation indenter.
> 
> Can you give some examples?

```
echo "vector x{, 2, 3, 4, 5};" > a.txt
echo "vector x{, 2, 3, 4, 5, 6};" > b.txt
```

LLVM style, actual output OK:
```
clang-format --style="{BasedOnStyle: llvm, ColumnLimit: 20}" a.txt

vector x{,
  2, 3,
  4, 5};
```
```
clang-format --style="{BasedOnStyle: llvm, ColumnLimit: 20}" b.txt

vector x{
, 2, 3,
4,5, 6};
```

LLVM with braced list and no binpack, actual output OK:

```
clang-format --style="{BasedOnStyle: llvm, ColumnLimit: 20, BinPackArguments: 
false, Cpp11BracedListStyle: true}" a.txt

vector x{,
  2,
  3,
  4,
  5};
```
```
clang-format --style="{BasedOnStyle: llvm, ColumnLimit: 20, BinPackArguments: 
false, Cpp11BracedListStyle: true}" b.txt

vector x{,
  2,
  3,
  4,
  5,
  6};
```

Same, but limit single entry lines to 3, Actual output not OK for a.txt, OK for 
b.txt
```
clang-format --style="{BasedOnStyle: llvm, ColumnLimit: 20, BinPackArguments: 
false, Cpp11BracedListStyle: true, MaxSingleLinesInBracedList: 3}" a.txt

vector x{,
  2,
  3,
  4,
  5};
```
```
clang-format --style="{BasedOnStyle: llvm, ColumnLimit: 20, BinPackArguments: 
false, Cpp11BracedListStyle: true, MaxSingleLinesInBracedList: 3}" b.txt

vector x{
, 2, 3,
4,5, 6};
```

The expected output for a.txt should be something like:
```
vector x{
, 2, 3,
4,5};
```

So the maximum limit is not enforced in certain cases. I only see this with 
small values of `MaxSingleLinesInBracedList` (below 5 or so).

I would be just as happy with making the current hard-coded limit of 20 be 
optional to disable. This limit doesn't seem to bother many people.


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


[clang] [clang-format] add MaxSingleLinesInBracedList style option (PR #112482)

2024-10-26 Thread Gedare Bloom via cfe-commits

gedare wrote:

So it turns out that this buggy behavior I'm seeing is also present in 
unmodified clang-format when the first item in the list is longer than the rest 
of the items. For example:
```
echo "vector x{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 
15, 16, 17, 18, 19, 20, 21, 22, 23, 24};" > c.txt
clang-format --style=llvm c.txt

vector x{1,
  2,
  3,
  4,
  5,
  6,
  7,
  8,
  9,
  10,
  11,
  12,
  13,
  14,
  15,
  16,
  17,
  18,
  19,
  20,
  21,
  22,
  23,
  24};
```

versus:
```
echo "vector x{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 
18, 19, 20, 21, 22, 23, 24};" > d.txt
vector x{1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12,
  13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
```


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


[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,548 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm

Endilll wrote:

I don't want readers of the test to have a misconception that this is tested in 
C++17 and earlier modes. Even you just paid attention to the fact that this DR, 
which is applied to C++98, is only tested in C++20 mode and newer. So I 
consider using `since-cxx20` prefix a feature.

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


[clang] [Clang] Add __ugly__ spelling for the msvc attribute scope (PR #113765)

2024-10-26 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 created 
https://github.com/llvm/llvm-project/pull/113765

This is required to avoid macro clashing when using attributes like 
`[[msvc::no_unique_address]]`.

This patch also refactor the logic for attribute scope __uglification__ into a 
single place to make it easier to add additional cases in case another one is 
required at some point again.



>From 68f3617027fa09b531b5e3eaea6a025c6783a258 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Sat, 26 Oct 2024 17:57:09 +0200
Subject: [PATCH] [Clang] Add __ugly__ spelling for the msvc attribute scope

---
 clang/include/clang/Basic/Attributes.h| 24 +++
 clang/lib/Basic/Attributes.cpp| 23 +++---
 clang/lib/Sema/SemaCodeComplete.cpp   | 23 --
 .../SemaCXX/cxx2a-ms-no-unique-address.cpp|  3 +++
 4 files changed, 40 insertions(+), 33 deletions(-)

diff --git a/clang/include/clang/Basic/Attributes.h 
b/clang/include/clang/Basic/Attributes.h
index 61666a6f4d9ac4..9fa7e5ce55d491 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -23,6 +23,30 @@ int hasAttribute(AttributeCommonInfo::Syntax Syntax,
  const IdentifierInfo *Scope, const IdentifierInfo *Attr,
  const TargetInfo &Target, const LangOptions &LangOpts);
 
+inline const char* deuglifyAttrScope(StringRef Scope) {
+  if (Scope == "_Clang")
+return "clang";
+  if (Scope == "__gnu__")
+return "gnu";
+  if (Scope == "__msvc__")
+return "msvc";
+  return nullptr;
+}
+
+inline const char* uglifyAttrScope(StringRef Scope) {
+  if (Scope == "clang")
+return "_Clang";
+  if (Scope == "gnu")
+return "__gnu__";
+  if (Scope == "msvc")
+return "__msvc__";
+  return nullptr;
+}
+
+inline bool isPotentiallyUglyScope(StringRef Scope) {
+  return Scope == "gnu" || Scope == "clang" || Scope == "msvc";
+}
+
 } // end namespace clang
 
 #endif // LLVM_CLANG_BASIC_ATTRIBUTES_H
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index 867d241a2cf847..4afa129e3b 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -38,10 +38,8 @@ int clang::hasAttribute(AttributeCommonInfo::Syntax Syntax,
 
   // Normalize the scope name, but only for gnu and clang attributes.
   StringRef ScopeName = Scope ? Scope->getName() : "";
-  if (ScopeName == "__gnu__")
-ScopeName = "gnu";
-  else if (ScopeName == "_Clang")
-ScopeName = "clang";
+  if (const char *prettyName = deuglifyAttrScope(ScopeName))
+ScopeName = prettyName;
 
   // As a special case, look for the omp::sequence and omp::directive
   // attributes. We support those, but not through the typical attribute
@@ -87,10 +85,8 @@ normalizeAttrScopeName(const IdentifierInfo *Scope,
   StringRef ScopeName = Scope->getName();
   if (SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
   SyntaxUsed == AttributeCommonInfo::AS_C23) {
-if (ScopeName == "__gnu__")
-  ScopeName = "gnu";
-else if (ScopeName == "_Clang")
-  ScopeName = "clang";
+if (const char *prettySpelling = deuglifyAttrScope(ScopeName))
+  return prettySpelling;
   }
   return ScopeName;
 }
@@ -100,12 +96,11 @@ static StringRef normalizeAttrName(const IdentifierInfo 
*Name,
AttributeCommonInfo::Syntax SyntaxUsed) {
   // Normalize the attribute name, __foo__ becomes foo. This is only allowable
   // for GNU attributes, and attributes using the double square bracket syntax.
-  bool ShouldNormalize =
-  SyntaxUsed == AttributeCommonInfo::AS_GNU ||
-  ((SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
-SyntaxUsed == AttributeCommonInfo::AS_C23) &&
-   (NormalizedScopeName.empty() || NormalizedScopeName == "gnu" ||
-NormalizedScopeName == "clang"));
+  bool ShouldNormalize = SyntaxUsed == AttributeCommonInfo::AS_GNU ||
+ ((SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
+   SyntaxUsed == AttributeCommonInfo::AS_C23) &&
+  (NormalizedScopeName.empty() ||
+   isPotentiallyUglyScope(NormalizedScopeName)));
   StringRef AttrName = Name->getName();
   if (ShouldNormalize && AttrName.size() >= 4 && AttrName.starts_with("__") &&
   AttrName.ends_with("__"))
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 3e31f3d82657a3..732da9ceb0628f 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -25,6 +25,7 @@
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/AttributeCommonInfo.h"
+#include "clang/Basic/Attributes.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/Specifiers.h"
@@ -4579,22 +4580,6 @@ void SemaCodeCompletion::CodeCompleteDeclSpec(Scope *S, 
DeclSpec &DS,
 Res

[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/113736

>From b23ce76d3db79eab6433bef1bd3fc9d26bcb3309 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Fri, 25 Oct 2024 23:05:06 +0300
Subject: [PATCH 1/2] [clang][NFC] Add test for CWG issues about linkage in
 cross-TU context

---
 clang/test/CXX/drs/cwg1884.cpp | 548 +
 clang/test/CXX/drs/cwg18xx.cpp |   2 +
 clang/test/CXX/drs/cwg279.cpp  |  42 +++
 clang/test/CXX/drs/cwg2xx.cpp  |   2 +
 clang/test/CXX/drs/cwg3xx.cpp  |   2 +
 clang/www/cxx_dr_status.html   |   6 +-
 6 files changed, 599 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/CXX/drs/cwg1884.cpp
 create mode 100644 clang/test/CXX/drs/cwg279.cpp

diff --git a/clang/test/CXX/drs/cwg1884.cpp b/clang/test/CXX/drs/cwg1884.cpp
new file mode 100644
index 00..d8fa9c4373765c
--- /dev/null
+++ b/clang/test/CXX/drs/cwg1884.cpp
@@ -0,0 +1,548 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++23 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++2c -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg1884_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg1884_A.pcm
+// RUN: %clang_cc1 -std=c++2c -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg1884.cpp 
-fmodule-file=cwg1884_A=%t/cwg1884_A.pcm
+
+// cwg1884: partial
+
+// _N4993_.[basic.link]/11:
+// For any two declarations of an entity E:
+//   — If one declares E to be a variable or function,
+// the other shall declare E as one of the same type.
+//   — If one declares E to be an enumerator, the other shall do so.
+//   — If one declares E to be a namespace, the other shall do so.
+//   — If one declares E to be a type,
+// the other shall declare E to be a type of the same kind (9.2.9.5).
+//   — If one declares E to be a class template,
+// the other shall do so with the same kind and an equivalent 
template-head (13.7.7.2).
+// [Note 5 : The declarations can supply different default template 
arguments. — end note]
+//   — If one declares E to be a function template or a (partial 
specialization of a) variable template,
+// the other shall declare E to be one with an equivalent template-head 
and type.
+//   — If one declares E to be an alias template,
+// the other shall declare E to be one with an equivalent template-head 
and defining-type-id.
+//   — If one declares E to be a concept, the other shall do so.
+// Types are compared after all adjustments of types (during which typedefs 
(9.2.4) are replaced by their definitions);
+// declarations for an array object can specify array types that differ by the 
presence or absence of a major array bound (9.3.4.5).
+// No diagnostic is required if neither declaration is reachable from the 
other.
+
+// The structure of the test is the following. First, module cwg1884_A
+// provides all (significant) kinds of entities, each named 'a' through 'k'.
+// Then the .cpp file does MxN kind of testing, where it tests one kind of 
entity
+// against every other kind.
+
+//--- cwg1884_A.cppm
+export module cwg1884_A;
+
+export {
+int a;
+void b();
+enum E { c };
+namespace d {}
+struct e;
+class f;
+template 
+class g;
+template 
+void h(int);
+template 
+int i;
+template 
+using j = int;
+template 
+concept k = true;
+} // export
+
+
+//--- cwg1884.cpp
+import cwg1884_A;
+
+// int a;
+
+void a();
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+enum Ea {
+  a
+  // since-cxx20-error@-1 {{redefinition of 'a'}}
+  //   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+};
+namespace a {} // #cwg1884-namespace-a
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@cwg1884_A.cppm:42 {{previous definition is here}}
+struct a;
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@#cwg1884-namespace-a {{previous definition is here}}
+class a;
+// since-cxx20-error@-1 {{redefinition of 'a' as different kind of symbol}}
+//   since-cxx20-note@#cwg1884-namespace-a {{previous definition is here}}
+template 
+cl

[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,42 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++23 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++2c -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++2c -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+
+// cwg279: no
+
+//--- cwg279_A.cppm
+export module cwg279_A;
+
+export {
+struct S; // #cwg279-S
+extern S *q; // #cwg279-q
+
+struct S2 {}; // #cwg279-S2
+extern S2 *q2; // #cwg279-q2
+} // export
+
+//--- cwg279.cpp
+import cwg279_A;
+
+// FIXME: We should use markers instead. They are less fragile,

Endilll wrote:

It should, but doesn't actually pass. Maybe I'd doing something wrong with 
modules.

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


[clang] Add clang/docs/FunctionEffectAnalysis.rst. (PR #109855)

2024-10-26 Thread Doug Wyatt via cfe-commits

dougsonos wrote:

Ping

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


[clang] [clang][NFC] Add test for CWG issues about linkage in cross-TU context (PR #113736)

2024-10-26 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,42 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file --leading-lines %s %t
+// RUN: %clang_cc1 -std=c++20 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++20 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++23 -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++23 -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++2c -pedantic-errors -fexceptions -fcxx-exceptions 
%t/cwg279_A.cppm -triple x86_64-unknown-unknown -emit-module-interface -o 
%t/cwg279_A.pcm
+// RUN: %clang_cc1 -std=c++2c -verify=since-cxx20 -pedantic-errors 
-fexceptions -fcxx-exceptions -triple x86_64-unknown-unknown %t/cwg279.cpp 
-fmodule-file=cwg279_A=%t/cwg279_A.pcm

Endilll wrote:

Status of support and number of language modes the test is run in is 
orthogonal. Moreover, this is consistent with the rest of the C++ DR tests.

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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

2024-10-26 Thread via cfe-commits

BenBlumer wrote:

I'm a bit of a outsider to the LLVM project, but I'd say a fix to a broken,
already shipped, feature now is better than a general fix down the line.

On Sat, Oct 26, 2024, 3:23 AM Julian Schmidt ***@***.***>
wrote:

> ***@***. commented on this pull request.
>
> CC @HighCommander4  @kadircet
> 
>
> Technically, Sam told me last EuroLLVM that he had some refactor of the
> SelectionTree that would resolve issues like this in the general case,
> but as it is unclear that those changes will get in someday/in the 'near'
> future, I think that this PR makes sense to merge. Even though this is kind
> of a band-aid fix. Thoughts?
> --
>
> In clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
> :
>
> > +  // selection range in selectionTree. Additionally, a CXXOperatorCallExpr 
> > of a
> +  // binary operation can be unselected because it's children claim the 
> entire
>
> ⬇️ Suggested change
>
> -  // selection range in selectionTree. Additionally, a CXXOperatorCallExpr 
> of a
> -  // binary operation can be unselected because it's children claim the 
> entire
> +  // selection range in selectionTree. Additionally, a CXXOperatorCallExpr 
> of a
> +  // binary operation can be unselected because its children claim the entire
>
> —
> Reply to this email directly, view it on GitHub
> ,
> or unsubscribe
> 
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>


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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

2024-10-26 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti updated 
https://github.com/llvm/llvm-project/pull/81640

>From 1796e5d2c44bae890c13b2af3fc7e4ec36e716dd Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Tue, 13 Feb 2024 18:59:16 +0100
Subject: [PATCH 1/3] [clangd] fix extract-to-function for overloaded operators

When selecting code that contains the use of overloaded operators,
the SelectionTree will attribute the operator to the operator
declaration, not to the `CXXOperatorCallExpr`. To allow
extract-to-function to work with these operators, make unselected
`CXXOperatorCallExpr`s valid root statements, just like `DeclStmt`s.

Fixes clangd/clangd#1254
---
 .../refactor/tweaks/ExtractFunction.cpp   | 15 +++---
 .../unittests/tweaks/ExtractFunctionTests.cpp | 47 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 ++
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 0302839c58252e..aae480175b33f6 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -56,6 +56,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -70,7 +71,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/raw_os_ostream.h"
 #include 
 
 namespace clang {
@@ -104,9 +104,12 @@ bool isRootStmt(const Node *N) {
   // Root statement cannot be partially selected.
   if (N->Selected == SelectionTree::Partial)
 return false;
-  // Only DeclStmt can be an unselected RootStmt since VarDecls claim the 
entire
-  // selection range in selectionTree.
-  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get())
+  // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
+  // selection range in selectionTree. Additionally, an CXXOperatorCallExpr of 
a
+  // binary operation can be unselected because it's children claim the entire
+  // selection range in the selection tree (e.g. <<).
+  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get() 
&&
+  !N->ASTNode.get())
 return false;
   return true;
 }
@@ -913,8 +916,8 @@ Expected ExtractFunction::apply(const 
Selection &Inputs) {
 
   tooling::Replacements OtherEdit(
   createForwardDeclaration(*ExtractedFunc, SM));
-  if (auto PathAndEdit = Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc),
- OtherEdit))
+  if (auto PathAndEdit =
+  Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc), OtherEdit))
 MultiFileEffect->ApplyEdits.try_emplace(PathAndEdit->first,
 PathAndEdit->second);
   else
diff --git a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
index dec63d454d52c6..8e347b516c6ffe 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -571,6 +571,53 @@ int getNum(bool Superstitious, int Min, int Max) {
   EXPECT_EQ(apply(Before), After);
 }
 
+TEST_F(ExtractFunctionTest, OverloadedOperators) {
+  Context = File;
+  std::string Before = R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+  int main() {
+[[foo(1, 2);
+foo(3, 4);
+stream << 42;
+stream + 42;
+stream | 42;
+foo(1, 2);
+foo(3, 4);]]
+  })cpp";
+  std::string After =
+  R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+  void extracted() {
+foo(1, 2);
+foo(3, 4);
+stream << 42;
+stream + 42;
+stream | 42;
+foo(1, 2);
+foo(3, 4);
+}
+int main() {
+extracted();
+  })cpp";
+  EXPECT_EQ(apply(Before), After);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index a604e9276668ae..1cd7c6b6ae5adf 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -69,6 +69,9 @@ Code complet

[clang] [clang] Prefer StringRef::substr(0, N) to slice(0, N) (NFC) (PR #113784)

2024-10-26 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/113784

I'm planning to migrate StringRef to std::string_view
eventually. Since std::string_view does not have slice, this patch
migrates slice(0, N) to substr(0, N).


>From aafa1a3f55712b6f278190bc87bef414a04d2ba1 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 26 Oct 2024 19:18:40 -0700
Subject: [PATCH] [clang] Prefer StringRef::substr(0, N) to slice(0, N) (NFC)

I'm planning to migrate StringRef to std::string_view
eventually. Since std::string_view does not have slice, this patch
migrates slice(0, N) to substr(0, N).
---
 clang/lib/AST/DeclBase.cpp  | 2 +-
 clang/lib/Basic/Module.cpp  | 2 +-
 clang/lib/Driver/Driver.cpp | 2 +-
 clang/lib/Driver/Job.cpp| 2 +-
 clang/lib/Driver/ToolChain.cpp  | 4 ++--
 clang/lib/Driver/ToolChains/Clang.cpp   | 4 ++--
 clang/lib/Driver/ToolChains/Darwin.cpp  | 4 ++--
 clang/lib/Driver/ToolChains/Gnu.cpp | 2 +-
 clang/lib/Frontend/PrecompiledPreamble.cpp  | 2 +-
 clang/lib/Frontend/TextDiagnostic.cpp   | 2 +-
 clang/lib/InstallAPI/DirectoryScanner.cpp   | 2 +-
 clang/lib/Sema/SemaAvailability.cpp | 2 +-
 clang/lib/Serialization/ASTWriter.cpp   | 2 +-
 clang/lib/Support/RISCVVIntrinsicUtils.cpp  | 2 +-
 .../Tooling/DependencyScanning/DependencyScanningWorker.cpp | 2 +-
 clang/utils/TableGen/ClangDiagnosticsEmitter.cpp| 6 +++---
 16 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 48b91dca1f6d91..d36cabd70d62db 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -631,7 +631,7 @@ static StringRef getRealizedPlatform(const AvailabilityAttr 
*A,
 return RealizedPlatform;
   size_t suffix = RealizedPlatform.rfind("_app_extension");
   if (suffix != StringRef::npos)
-return RealizedPlatform.slice(0, suffix);
+return RealizedPlatform.substr(0, suffix);
   return RealizedPlatform;
 }
 
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index a7a3f6b37efef1..f74d9908261aa3 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -74,7 +74,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, 
StringRef Feature) {
 auto Pos = LHS.find('-');
 if (Pos == StringRef::npos)
   return false;
-SmallString<128> NewLHS = LHS.slice(0, Pos);
+SmallString<128> NewLHS = LHS.substr(0, Pos);
 NewLHS += LHS.slice(Pos+1, LHS.size());
 return NewLHS == RHS;
   };
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 9878a9dad78d40..a92031e3787270 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6875,7 +6875,7 @@ static void applyOneOverrideOption(raw_ostream &OS,
  Edit.slice(2, Edit.size() - 1).contains('/')) {
 StringRef MatchPattern = Edit.substr(2).split('/').first;
 StringRef ReplPattern = Edit.substr(2).split('/').second;
-ReplPattern = ReplPattern.slice(0, ReplPattern.size() - 1);
+ReplPattern = ReplPattern.substr(0, ReplPattern.size() - 1);
 
 for (unsigned i = 1, e = Args.size(); i != e; ++i) {
   // Ignore end-of-line response file markers
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index fe2f7242b04a51..01af5306e4f31b 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -189,7 +189,7 @@ rewriteIncludes(const llvm::ArrayRef &Args, 
size_t Idx,
"Expecting -I or -F");
 StringRef Inc = FlagRef.slice(2, StringRef::npos);
 if (getAbsPath(Inc, NewInc)) {
-  SmallString<128> NewArg(FlagRef.slice(0, 2));
+  SmallString<128> NewArg(FlagRef.substr(0, 2));
   NewArg += NewInc;
   IncFlags.push_back(std::move(NewArg));
 }
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 4df31770950858..4efeecca2475bc 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -441,7 +441,7 @@ static const DriverSuffix *parseDriverSuffix(StringRef 
ProgName, size_t &Pos) {
   if (!DS) {
 // Try again after stripping trailing -component.
 // clang++-tot -> clang++
-ProgName = ProgName.slice(0, ProgName.rfind('-'));
+ProgName = ProgName.substr(0, ProgName.rfind('-'));
 DS = FindDriverSuffix(ProgName, Pos);
   }
   return DS;
@@ -464,7 +464,7 @@ ToolChain::getTargetAndModeFromProgramName(StringRef PN) {
 
   // Infer target from the prefix.
   StringRef Prefix(ProgName);
-  Prefix = Prefix.slice(0, LastComponent);
+  Prefix = Prefix.substr(0, LastComponent);
   std::string IgnoredError;
   bool IsRegistered =
   llvm::TargetRegistry::lookupTarget(std::string(P

[clang] [clang] Prefer StringRef::substr(0, N) to slice(0, N) (NFC) (PR #113784)

2024-10-26 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes

I'm planning to migrate StringRef to std::string_view
eventually. Since std::string_view does not have slice, this patch
migrates slice(0, N) to substr(0, N).


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


16 Files Affected:

- (modified) clang/lib/AST/DeclBase.cpp (+1-1) 
- (modified) clang/lib/Basic/Module.cpp (+1-1) 
- (modified) clang/lib/Driver/Driver.cpp (+1-1) 
- (modified) clang/lib/Driver/Job.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChain.cpp (+2-2) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2-2) 
- (modified) clang/lib/Driver/ToolChains/Darwin.cpp (+2-2) 
- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+1-1) 
- (modified) clang/lib/Frontend/PrecompiledPreamble.cpp (+1-1) 
- (modified) clang/lib/Frontend/TextDiagnostic.cpp (+1-1) 
- (modified) clang/lib/InstallAPI/DirectoryScanner.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaAvailability.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+1-1) 
- (modified) clang/lib/Support/RISCVVIntrinsicUtils.cpp (+1-1) 
- (modified) clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp 
(+1-1) 
- (modified) clang/utils/TableGen/ClangDiagnosticsEmitter.cpp (+3-3) 


``diff
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 48b91dca1f6d91..d36cabd70d62db 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -631,7 +631,7 @@ static StringRef getRealizedPlatform(const AvailabilityAttr 
*A,
 return RealizedPlatform;
   size_t suffix = RealizedPlatform.rfind("_app_extension");
   if (suffix != StringRef::npos)
-return RealizedPlatform.slice(0, suffix);
+return RealizedPlatform.substr(0, suffix);
   return RealizedPlatform;
 }
 
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index a7a3f6b37efef1..f74d9908261aa3 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -74,7 +74,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target, 
StringRef Feature) {
 auto Pos = LHS.find('-');
 if (Pos == StringRef::npos)
   return false;
-SmallString<128> NewLHS = LHS.slice(0, Pos);
+SmallString<128> NewLHS = LHS.substr(0, Pos);
 NewLHS += LHS.slice(Pos+1, LHS.size());
 return NewLHS == RHS;
   };
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 9878a9dad78d40..a92031e3787270 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6875,7 +6875,7 @@ static void applyOneOverrideOption(raw_ostream &OS,
  Edit.slice(2, Edit.size() - 1).contains('/')) {
 StringRef MatchPattern = Edit.substr(2).split('/').first;
 StringRef ReplPattern = Edit.substr(2).split('/').second;
-ReplPattern = ReplPattern.slice(0, ReplPattern.size() - 1);
+ReplPattern = ReplPattern.substr(0, ReplPattern.size() - 1);
 
 for (unsigned i = 1, e = Args.size(); i != e; ++i) {
   // Ignore end-of-line response file markers
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index fe2f7242b04a51..01af5306e4f31b 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -189,7 +189,7 @@ rewriteIncludes(const llvm::ArrayRef &Args, 
size_t Idx,
"Expecting -I or -F");
 StringRef Inc = FlagRef.slice(2, StringRef::npos);
 if (getAbsPath(Inc, NewInc)) {
-  SmallString<128> NewArg(FlagRef.slice(0, 2));
+  SmallString<128> NewArg(FlagRef.substr(0, 2));
   NewArg += NewInc;
   IncFlags.push_back(std::move(NewArg));
 }
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 4df31770950858..4efeecca2475bc 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -441,7 +441,7 @@ static const DriverSuffix *parseDriverSuffix(StringRef 
ProgName, size_t &Pos) {
   if (!DS) {
 // Try again after stripping trailing -component.
 // clang++-tot -> clang++
-ProgName = ProgName.slice(0, ProgName.rfind('-'));
+ProgName = ProgName.substr(0, ProgName.rfind('-'));
 DS = FindDriverSuffix(ProgName, Pos);
   }
   return DS;
@@ -464,7 +464,7 @@ ToolChain::getTargetAndModeFromProgramName(StringRef PN) {
 
   // Infer target from the prefix.
   StringRef Prefix(ProgName);
-  Prefix = Prefix.slice(0, LastComponent);
+  Prefix = Prefix.substr(0, LastComponent);
   std::string IgnoredError;
   bool IsRegistered =
   llvm::TargetRegistry::lookupTarget(std::string(Prefix), IgnoredError);
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 04b3832327a99c..b39c8b03aed709 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -183,7 +183,7 @@ static void ParseMRecip(const Driver &D, const ArgList 
&Args,
 size_t RefStepLoc;
 if (!getRefinementStep(Val, D, *A, RefStepLoc))
   return;
-StringR

[clang] [clang][bytecode][NFC] Make CheckVolatile static (PR #113785)

2024-10-26 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/113785

None

>From ff68ca5f76a9c005b6a3016c041ad8fb83f47602 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 27 Oct 2024 04:09:49 +0100
Subject: [PATCH] [clang][bytecode][NFC] Make CheckVolatile static

---
 clang/lib/AST/ByteCode/Interp.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index fdc4b38b8aa6dc..c8ce08aa3eef21 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -507,8 +507,8 @@ bool CheckMutable(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
   return false;
 }
 
-bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
-   AccessKinds AK) {
+static bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
+  AccessKinds AK) {
   assert(Ptr.isLive());
 
   // FIXME: This check here might be kinda expensive. Maybe it would be better

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


[clang] [clang][bytecode][NFC] Only do CheckConstant checks for global pointers (PR #113786)

2024-10-26 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/113786

We can check isStatic() early here and save ourselves some work.

>From e759b44c22bcdd374550929c0c673d414f30e4ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sun, 27 Oct 2024 04:08:52 +0100
Subject: [PATCH] [clang][bytecode][NFC] Only do CheckConstant checks for
 global pointers

We can check isStatic() early here and save ourselves some work.
---
 clang/lib/AST/ByteCode/Interp.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index fdc4b38b8aa6dc..9763cabab3cd7d 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -394,7 +394,7 @@ bool CheckConstant(InterpState &S, CodePtr OpPC, const 
Descriptor *Desc) {
 }
 
 static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
-  if (!Ptr.isBlockPointer())
+  if (!Ptr.isStatic() || !Ptr.isBlockPointer())
 return true;
   return CheckConstant(S, OpPC, Ptr.getDeclDesc());
 }

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


[clang] [clang][bytecode][NFC] Make CheckVolatile static (PR #113785)

2024-10-26 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+2-2) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index fdc4b38b8aa6dc..c8ce08aa3eef21 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -507,8 +507,8 @@ bool CheckMutable(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
   return false;
 }
 
-bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
-   AccessKinds AK) {
+static bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
+  AccessKinds AK) {
   assert(Ptr.isLive());
 
   // FIXME: This check here might be kinda expensive. Maybe it would be better

``




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


[clang] [clang][bytecode][NFC] Only do CheckConstant checks for global pointers (PR #113786)

2024-10-26 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

We can check isStatic() early here and save ourselves some work.

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


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+1-1) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index fdc4b38b8aa6dc..9763cabab3cd7d 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -394,7 +394,7 @@ bool CheckConstant(InterpState &S, CodePtr OpPC, const 
Descriptor *Desc) {
 }
 
 static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
-  if (!Ptr.isBlockPointer())
+  if (!Ptr.isStatic() || !Ptr.isBlockPointer())
 return true;
   return CheckConstant(S, OpPC, Ptr.getDeclDesc());
 }

``




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


  1   2   >