[clang] [clang][bytecode] Cast fixed-point cmp result to int if necessary (PR #110469)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 7 (Add check check-offload) failure: test (failure)
 TEST 'libomptarget :: amdgcn-amd-amdhsa :: 
offloading/pgo1.c' FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib 
 -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fprofile-instr-generate  -Xclang "-fprofile-instrument=clang"
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib 
-fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fprofile-instr-generate -Xclang -fprofile-instrument=clang
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 2>&1 | 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
  --check-prefix="CLANG-PGO"
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
# note: command had no output on stdout or stderr
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 --check-prefix=CLANG-PGO
# .---command stderr
# | 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c:32:20:
 error: CLANG-PGO-NEXT: expected string not found in input
# | // CLANG-PGO-NEXT: [ 0 11 20 ]
# |^
# | :3:28: note: scanning from here
# |  Counters =
# |^
# | :4:1: note: possible intended match here
# | [ 0 12 20 ]
# | ^
# | 
# | Input file: 
# | Check file: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<
# |1: === GPU Profile === 
# |2: Target: amdgcn-amd-amdhsa 
# |3:  Counters = 
# | next:32'0X error: no match found
# |4: [ 0 12 20 ] 
# | next:32'0 
# | next:32'1 ?

[clang] [clang][bytecode] Remove superfluous check from fixed-point div (PR #110478)

2024-09-30 Thread Timm Baeder via cfe-commits

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


[clang] 79382eb - [clang][bytecode] Remove superfluous check from fixed-point div (#110478)

2024-09-30 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-30T12:13:21+02:00
New Revision: 79382eb97adff71dbc9d4969431dd4a0967ee7ad

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

LOG: [clang][bytecode] Remove superfluous check from fixed-point div (#110478)

We shouldn't do this check for fixed-point values, at least the current
interpreter doesn't do it.

Added: 


Modified: 
clang/lib/AST/ByteCode/Interp.h
clang/test/Frontend/fixed_point_div_const.c

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 68c04587a4919e..8a3c6810e0e11b 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -235,14 +235,16 @@ bool CheckDivRem(InterpState &S, CodePtr OpPC, const T 
&LHS, const T &RHS) {
 return false;
   }
 
-  if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) {
-APSInt LHSInt = LHS.toAPSInt();
-SmallString<32> Trunc;
-(-LHSInt.extend(LHSInt.getBitWidth() + 1)).toString(Trunc, 10);
-const SourceInfo &Loc = S.Current->getSource(OpPC);
-const Expr *E = S.Current->getExpr(OpPC);
-S.CCEDiag(Loc, diag::note_constexpr_overflow) << Trunc << E->getType();
-return false;
+  if constexpr (!std::is_same_v) {
+if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) 
{
+  APSInt LHSInt = LHS.toAPSInt();
+  SmallString<32> Trunc;
+  (-LHSInt.extend(LHSInt.getBitWidth() + 1)).toString(Trunc, 10);
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  const Expr *E = S.Current->getExpr(OpPC);
+  S.CCEDiag(Loc, diag::note_constexpr_overflow) << Trunc << E->getType();
+  return false;
+}
   }
   return true;
 }

diff  --git a/clang/test/Frontend/fixed_point_div_const.c 
b/clang/test/Frontend/fixed_point_div_const.c
index 46935207d186a8..66c028e608db60 100644
--- a/clang/test/Frontend/fixed_point_div_const.c
+++ b/clang/test/Frontend/fixed_point_div_const.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
 
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - -fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
+
 // Division between 
diff erent fixed point types
 short _Accum sa_const = 1.0hk / 2.0hk;
 // CHECK-DAG: @sa_const  = {{.*}}global i16 64, align 2



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


[clang] [llvm] Thin9 (PR #110483)

2024-09-30 Thread Kyungwoo Lee via cfe-commits

https://github.com/kyulee-com created 
https://github.com/llvm/llvm-project/pull/110483

None

>From c1a0219457a3c162d7fa6b9d70750ba7a040d9f2 Mon Sep 17 00:00:00 2001
From: Kyungwoo Lee 
Date: Fri, 26 Apr 2024 20:02:52 -0700
Subject: [PATCH 1/7] [ThinLTO][NFC] Prep for two-codegen rounds

---
 clang/lib/CodeGen/BackendUtil.cpp  |  8 ++--
 llvm/include/llvm/LTO/LTOBackend.h |  1 +
 llvm/lib/LTO/LTO.cpp   | 75 --
 llvm/lib/LTO/LTOBackend.cpp|  6 ++-
 4 files changed, 49 insertions(+), 41 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7fa69420298160..a1909d45b4d944 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1286,10 +1286,10 @@ static void runThinLTOBackend(
 Conf.CGFileType = getCodeGenFileType(Action);
 break;
   }
-  if (Error E =
-  thinBackend(Conf, -1, AddStream, *M, *CombinedIndex, ImportList,
-  ModuleToDefinedGVSummaries[M->getModuleIdentifier()],
-  /* ModuleMap */ nullptr, CGOpts.CmdArgs)) {
+  if (Error E = thinBackend(
+  Conf, -1, AddStream, *M, *CombinedIndex, ImportList,
+  ModuleToDefinedGVSummaries[M->getModuleIdentifier()],
+  /* ModuleMap */ nullptr, Conf.CodeGenOnly, CGOpts.CmdArgs)) {
 handleAllErrors(std::move(E), [&](ErrorInfoBase &EIB) {
   errs() << "Error running ThinLTO backend: " << EIB.message() << '\n';
 });
diff --git a/llvm/include/llvm/LTO/LTOBackend.h 
b/llvm/include/llvm/LTO/LTOBackend.h
index de89f4bb10dff2..8516398510d4b8 100644
--- a/llvm/include/llvm/LTO/LTOBackend.h
+++ b/llvm/include/llvm/LTO/LTOBackend.h
@@ -56,6 +56,7 @@ Error thinBackend(const Config &C, unsigned Task, AddStreamFn 
AddStream,
   const FunctionImporter::ImportMapTy &ImportList,
   const GVSummaryMapTy &DefinedGlobals,
   MapVector *ModuleMap,
+  bool CodeGenOnly,
   const std::vector &CmdArgs = 
std::vector());
 
 Error finalizeOptimizationRemarks(
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index a88124dacfaefd..f4c25f80811a85 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1473,7 +1473,8 @@ class InProcessThinBackend : public ThinBackendProc {
 return MOrErr.takeError();
 
   return thinBackend(Conf, Task, AddStream, **MOrErr, CombinedIndex,
- ImportList, DefinedGlobals, &ModuleMap);
+ ImportList, DefinedGlobals, &ModuleMap,
+ Conf.CodeGenOnly);
 };
 
 auto ModuleID = BM.getModuleIdentifier();
@@ -1839,45 +1840,49 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache 
Cache,
 
   TimeTraceScopeExit.release();
 
-  std::unique_ptr BackendProc =
-  ThinLTO.Backend(Conf, ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
-  AddStream, Cache);
-
   auto &ModuleMap =
   ThinLTO.ModulesToCompile ? *ThinLTO.ModulesToCompile : ThinLTO.ModuleMap;
 
-  auto ProcessOneModule = [&](int I) -> Error {
-auto &Mod = *(ModuleMap.begin() + I);
-// Tasks 0 through ParallelCodeGenParallelismLevel-1 are reserved for
-// combined module and parallel code generation partitions.
-return BackendProc->start(RegularLTO.ParallelCodeGenParallelismLevel + I,
-  Mod.second, ImportLists[Mod.first],
-  ExportLists[Mod.first], ResolvedODR[Mod.first],
-  ThinLTO.ModuleMap);
+  auto RunBackends = [&](ThinBackendProc *BackendProcess) -> Error {
+auto ProcessOneModule = [&](int I) -> Error {
+  auto &Mod = *(ModuleMap.begin() + I);
+  // Tasks 0 through ParallelCodeGenParallelismLevel-1 are reserved for
+  // combined module and parallel code generation partitions.
+  return BackendProcess->start(
+  RegularLTO.ParallelCodeGenParallelismLevel + I, Mod.second,
+  ImportLists[Mod.first], ExportLists[Mod.first],
+  ResolvedODR[Mod.first], ThinLTO.ModuleMap);
+};
+
+if (BackendProcess->getThreadCount() == 1) {
+  // Process the modules in the order they were provided on the
+  // command-line. It is important for this codepath to be used for
+  // WriteIndexesThinBackend, to ensure the emitted LinkedObjectsFile lists
+  // ThinLTO objects in the same order as the inputs, which otherwise would
+  // affect the final link order.
+  for (int I = 0, E = ModuleMap.size(); I != E; ++I)
+if (Error E = ProcessOneModule(I))
+  return E;
+} else {
+  // When executing in parallel, process largest bitsize modules first to
+  // improve parallelism, and avoid starving the thread pool near the end.
+  // This saves about 15 sec on a 36-core machine while link `clang.exe`
+  // (out of 100 sec).
+  std::vector ModulesVec;
+  ModulesVec.reserve(ModuleMap.size());
+   

[clang] fix access checking about function overloading (PR #107768)

2024-09-30 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

What's the status here?

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


[clang] Revert "[clang] Reland: Instantiate concepts with sugared template arguments (#101782)" (PR #102551)

2024-09-30 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

Looks like the regression is due to the sugar preservation caused declaration 
referenced by VLAs to make their way into the constraint evaluation, whereas 
they don't appear in the instantiation scope.

Do you have any thoughts?

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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-bootstrap-ubsan` running on `sanitizer-buildbot4` while 
building `clang,libcxxabi` at step 2 "annotate".

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


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-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld.lld: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/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: 85931 tests, 88 workers --
Testing:  0.. 
FAIL: Clang :: CodeGenCXX/mangle-concept.cpp (8688 of 85931)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang 
-cc1 -internal-isystem 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck
 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/clang 
-cc1 -internal-isystem 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build_ubsan/bin/FileCheck
 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/home/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/home/b/sanitizer-x86_64-linux-boo

[clang] [Clang][HIP] Warn when __AMDGCN_WAVEFRONT_SIZE is used in host code without relying on target-dependent overload resolution (PR #109663)

2024-09-30 Thread Fabian Ritter via cfe-commits

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


[clang] [clang][bytecode] Handle DiscardResult for fixed-point literals (PR #110475)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


3 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+3) 
- (modified) clang/test/AST/ByteCode/fixed-point.cpp (+2) 
- (modified) clang/test/Frontend/fixed_point_crash.c (+1) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c24c4b6db2a5bf..0399f1fcbc7a93 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -763,6 +763,9 @@ bool Compiler::VisitFixedPointLiteral(const 
FixedPointLiteral *E) {
   assert(E->getType()->isFixedPointType());
   assert(classifyPrim(E) == PT_FixedPoint);
 
+  if (DiscardResult)
+return true;
+
   auto Sem = Ctx.getASTContext().getFixedPointSemantics(E->getType());
   APInt Value = E->getValue();
   return this->emitConstFixedPoint(FixedPoint(Value, Sem), E);
diff --git a/clang/test/AST/ByteCode/fixed-point.cpp 
b/clang/test/AST/ByteCode/fixed-point.cpp
index 48673d8be6f601..4bf80ba7c58f02 100644
--- a/clang/test/AST/ByteCode/fixed-point.cpp
+++ b/clang/test/AST/ByteCode/fixed-point.cpp
@@ -11,6 +11,8 @@ static_assert(1.0k != 1.0k); // both-error {{failed due to 
requirement '1.0k !=
 static_assert(1.0k != 1); // both-error {{failed due to requirement '1.0k != 
1'}}
 static_assert(-12.0k == -(-(-12.0k)));
 
+constexpr _Accum acc = (0.5r, 6.9k);
+
 /// Zero-init.
 constexpr _Accum A{};
 static_assert(A == 0.0k);
diff --git a/clang/test/Frontend/fixed_point_crash.c 
b/clang/test/Frontend/fixed_point_crash.c
index 3b397400ca..9cfe6ba64c519d 100644
--- a/clang/test/Frontend/fixed_point_crash.c
+++ b/clang/test/Frontend/fixed_point_crash.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -ffixed-point %s
+// RUN: %clang_cc1 -verify -ffixed-point %s 
-fexperimental-new-constant-interpreter
 
 union a {
   _Accum x;

``




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


[clang] [llvm] [ARM] Fix musttail calls (PR #109943)

2024-09-30 Thread Oliver Stannard via cfe-commits

https://github.com/ostannard updated 
https://github.com/llvm/llvm-project/pull/109943

>From 9b2646806978429395232ed596429ef281bcb26b Mon Sep 17 00:00:00 2001
From: Oliver Stannard 
Date: Thu, 9 May 2024 12:58:41 +0100
Subject: [PATCH 1/9] [ARM] Re-generate a test

---
 llvm/test/CodeGen/ARM/fp-arg-shuffle.ll | 24 
 1 file changed, 24 insertions(+)

diff --git a/llvm/test/CodeGen/ARM/fp-arg-shuffle.ll 
b/llvm/test/CodeGen/ARM/fp-arg-shuffle.ll
index 4996cc8ecbf022..36f5a4b30af409 100644
--- a/llvm/test/CodeGen/ARM/fp-arg-shuffle.ll
+++ b/llvm/test/CodeGen/ARM/fp-arg-shuffle.ll
@@ -1,8 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
 ; RUN: llc -mtriple=arm-eabi -mattr=+neon -float-abi=soft %s -o - | FileCheck 
%s
 
 ; CHECK: function1
 ; CHECK-NOT: vmov
 define double @function1(double %a, double %b, double %c, double %d, double 
%e, double %f) nounwind noinline ssp {
+; CHECK-LABEL: function1:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:.save {r4, r5, r11, lr}
+; CHECK-NEXT:push {r4, r5, r11, lr}
+; CHECK-NEXT:.pad #32
+; CHECK-NEXT:sub sp, sp, #32
+; CHECK-NEXT:add lr, sp, #64
+; CHECK-NEXT:vldr d16, [sp, #56]
+; CHECK-NEXT:str r2, [sp, #16]
+; CHECK-NEXT:ldm lr, {r4, r5, r12, lr}
+; CHECK-NEXT:str r3, [sp, #20]
+; CHECK-NEXT:mov r3, r5
+; CHECK-NEXT:str r0, [sp, #24]
+; CHECK-NEXT:mov r0, r12
+; CHECK-NEXT:str r1, [sp, #28]
+; CHECK-NEXT:mov r1, lr
+; CHECK-NEXT:mov r2, r4
+; CHECK-NEXT:vldr d17, [sp, #48]
+; CHECK-NEXT:vstmia sp, {d16, d17}
+; CHECK-NEXT:bl function2
+; CHECK-NEXT:add sp, sp, #32
+; CHECK-NEXT:pop {r4, r5, r11, lr}
+; CHECK-NEXT:mov pc, lr
 entry:
   %call = tail call double @function2(double %f, double %e, double %d, double 
%c, double %b, double %a) nounwind
   ret double %call

>From 07a5a3dea3c295db81fac6ef50a1b2371f9894cf Mon Sep 17 00:00:00 2001
From: Oliver Stannard 
Date: Tue, 24 Sep 2024 10:46:47 +0100
Subject: [PATCH 2/9] [ARM] Fix comment typo

---
 llvm/lib/Target/ARM/ARMISelLowering.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 1733424a8b669f..673cd57b45a96b 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -2408,8 +2408,8 @@ 
ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 isTailCall = false;
 
   // For both the non-secure calls and the returns from a CMSE entry function,
-  // the function needs to do some extra work afte r the call, or before the
-  // return, respectively, thus it cannot end with atail call
+  // the function needs to do some extra work after the call, or before the
+  // return, respectively, thus it cannot end with a tail call
   if (isCmseNSCall || AFI->isCmseNSEntryFunction())
 isTailCall = false;
 

>From 7773f66a711879ec884b92f56cc45e89ac44095b Mon Sep 17 00:00:00 2001
From: Oliver Stannard 
Date: Thu, 9 May 2024 13:00:46 +0100
Subject: [PATCH 3/9] [ARM] Add debug trace for tail-call optimisation

There are lots of reasons a call might not be eligible for tail-call
optimisation, this adds debug trace to help understand the compiler's
decisions here.
---
 llvm/lib/Target/ARM/ARMISelLowering.cpp | 64 +++--
 1 file changed, 49 insertions(+), 15 deletions(-)

diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 673cd57b45a96b..078a12246c2e08 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -3047,8 +3047,10 @@ bool 
ARMTargetLowering::IsEligibleForTailCallOptimization(
 for (const CCValAssign &AL : ArgLocs)
   if (AL.isRegLoc())
 AddressRegisters.erase(AL.getLocReg());
-if (AddressRegisters.empty())
+if (AddressRegisters.empty()) {
+  LLVM_DEBUG(dbgs() << "false (no reg to hold function pointer)\n");
   return false;
+}
   }
 
   // Look for obvious safe cases to perform tail call optimization that do not
@@ -3057,18 +3059,26 @@ bool 
ARMTargetLowering::IsEligibleForTailCallOptimization(
   // Exception-handling functions need a special set of instructions to 
indicate
   // a return to the hardware. Tail-calling another function would probably
   // break this.
-  if (CallerF.hasFnAttribute("interrupt"))
+  if (CallerF.hasFnAttribute("interrupt")) {
+LLVM_DEBUG(dbgs() << "false (interrupt attribute)\n");
 return false;
+  }
 
-  if (canGuaranteeTCO(CalleeCC, 
getTargetMachine().Options.GuaranteedTailCallOpt))
+  if (canGuaranteeTCO(CalleeCC,
+  getTargetMachine().Options.GuaranteedTailCallOpt)) {
+LLVM_DEBUG(dbgs() << (CalleeCC == CallerCC ? "true" : "false")
+  << " (guaranteed tail-call CC)\n");
 return CalleeCC == CallerCC;
+  }
 
   // Also avoid sibcall optimizatio

[clang] [clang][bytecode] Handle DiscardResult for fixed-point literals (PR #110475)

2024-09-30 Thread Timm Baeder via cfe-commits

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

None

>From b69e9bb4bca8710fae493086e4c4250a5ab1f249 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 30 Sep 2024 11:14:05 +0200
Subject: [PATCH] [clang][bytecode] Handle DiscardResult for fixed-point
 literals

---
 clang/lib/AST/ByteCode/Compiler.cpp | 3 +++
 clang/test/AST/ByteCode/fixed-point.cpp | 2 ++
 clang/test/Frontend/fixed_point_crash.c | 1 +
 3 files changed, 6 insertions(+)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c24c4b6db2a5bf..0399f1fcbc7a93 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -763,6 +763,9 @@ bool Compiler::VisitFixedPointLiteral(const 
FixedPointLiteral *E) {
   assert(E->getType()->isFixedPointType());
   assert(classifyPrim(E) == PT_FixedPoint);
 
+  if (DiscardResult)
+return true;
+
   auto Sem = Ctx.getASTContext().getFixedPointSemantics(E->getType());
   APInt Value = E->getValue();
   return this->emitConstFixedPoint(FixedPoint(Value, Sem), E);
diff --git a/clang/test/AST/ByteCode/fixed-point.cpp 
b/clang/test/AST/ByteCode/fixed-point.cpp
index 48673d8be6f601..4bf80ba7c58f02 100644
--- a/clang/test/AST/ByteCode/fixed-point.cpp
+++ b/clang/test/AST/ByteCode/fixed-point.cpp
@@ -11,6 +11,8 @@ static_assert(1.0k != 1.0k); // both-error {{failed due to 
requirement '1.0k !=
 static_assert(1.0k != 1); // both-error {{failed due to requirement '1.0k != 
1'}}
 static_assert(-12.0k == -(-(-12.0k)));
 
+constexpr _Accum acc = (0.5r, 6.9k);
+
 /// Zero-init.
 constexpr _Accum A{};
 static_assert(A == 0.0k);
diff --git a/clang/test/Frontend/fixed_point_crash.c 
b/clang/test/Frontend/fixed_point_crash.c
index 3b397400ca..9cfe6ba64c519d 100644
--- a/clang/test/Frontend/fixed_point_crash.c
+++ b/clang/test/Frontend/fixed_point_crash.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -ffixed-point %s
+// RUN: %clang_cc1 -verify -ffixed-point %s 
-fexperimental-new-constant-interpreter
 
 union a {
   _Accum x;

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


[clang] [Clang] Implement CWG 2707 "Deduction guides cannot have a trailing requires-clause" (PR #110473)

2024-09-30 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/110473

>From f0692e16f08fc40865cc83aa6c3eb73f5d11144a Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Mon, 30 Sep 2024 16:57:14 +0800
Subject: [PATCH] [Clang] Implement CWG 2707 "Deduction guides cannot have a
 trailing requires-clause"

---
 clang/docs/ReleaseNotes.rst   |  3 ++
 clang/include/clang/AST/DeclCXX.h |  9 --
 .../clang/Basic/DiagnosticSemaKinds.td|  2 --
 clang/lib/AST/DeclCXX.cpp |  9 +++---
 clang/lib/Sema/SemaDecl.cpp   | 11 +++-
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  2 +-
 clang/test/CXX/dcl/dcl.decl/p3.cpp|  2 +-
 clang/test/CXX/drs/cwg27xx.cpp| 28 +++
 clang/www/cxx_dr_status.html  |  4 +--
 9 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1fbcac807d0b30..34ff107ef6b124 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -202,6 +202,9 @@ Resolutions to C++ Defect Reports
 - Reject explicit object parameters with type ``void`` (``this void``).
   (`CWG2915: Explicit object parameters of type void 
`_).
 
+- Clang now allows trailing requires clause on explicit deduction guides.
+  (`CWG2707: Deduction guides cannot have a trailing requires-clause 
`_).
+
 C Language Changes
 --
 
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 252e6e92564142..2693cc0e95b4b2 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1965,9 +1965,11 @@ class CXXDeductionGuideDecl : public FunctionDecl {
 ExplicitSpecifier ES,
 const DeclarationNameInfo &NameInfo, QualType T,
 TypeSourceInfo *TInfo, SourceLocation EndLocation,
-CXXConstructorDecl *Ctor, DeductionCandidate Kind)
+CXXConstructorDecl *Ctor, DeductionCandidate Kind,
+Expr *TrailingRequiresClause)
   : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
- SC_None, false, false, ConstexprSpecKind::Unspecified),
+ SC_None, false, false, ConstexprSpecKind::Unspecified,
+ TrailingRequiresClause),
 Ctor(Ctor), ExplicitSpec(ES) {
 if (EndLocation.isValid())
   setRangeEnd(EndLocation);
@@ -1987,7 +1989,8 @@ class CXXDeductionGuideDecl : public FunctionDecl {
  ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T,
  TypeSourceInfo *TInfo, SourceLocation EndLocation,
  CXXConstructorDecl *Ctor = nullptr,
- DeductionCandidate Kind = DeductionCandidate::Normal);
+ DeductionCandidate Kind = DeductionCandidate::Normal,
+ Expr *TrailingRequiresClause = nullptr);
 
   static CXXDeductionGuideDecl *CreateDeserialized(ASTContext &C,
GlobalDeclID ID);
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f3d5d4c56606cc..93533000c76686 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3050,8 +3050,6 @@ def note_is_deducible_constraint_evaluated_to_false : 
Note<
   "cannot deduce template arguments for %0 from %1">;
 def err_constrained_virtual_method : Error<
   "virtual function cannot have a requires clause">;
-def err_trailing_requires_clause_on_deduction_guide : Error<
-  "deduction guide cannot have a requires clause">;
 def err_constrained_non_templated_function
 : Error<"non-templated function cannot have a requires clause">;
 def err_non_temp_spec_requires_clause : Error<
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 01143391edab40..f5a0aa8f82512e 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2211,9 +2211,10 @@ CXXDeductionGuideDecl *CXXDeductionGuideDecl::Create(
 ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
 ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T,
 TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl 
*Ctor,
-DeductionCandidate Kind) {
-  return new (C, DC) CXXDeductionGuideDecl(C, DC, StartLoc, ES, NameInfo, T,
-   TInfo, EndLocation, Ctor, Kind);
+DeductionCandidate Kind, Expr *TrailingRequiresClause) {
+  return new (C, DC)
+  CXXDeductionGuideDecl(C, DC, StartLoc, ES, NameInfo, T, TInfo,
+EndLocation, Ctor, Kind, TrailingRequiresClause);
 }
 
 CXXDeductionGuideDecl *
@@ -2221,7 +,7 @@ CXXDeductionGuideDecl::CreateDeserialized(ASTCo

[clang] [llvm] [ARM] Fix musttail calls (PR #109943)

2024-09-30 Thread Oliver Stannard via cfe-commits

ostannard wrote:

That rebase picked up a test failure in 
`CodeGen/AArch64/sme-callee-save-restore-pairs.ll` which looks related to this 
but isn't, I'll rebase again over the fix.

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


[clang] [Clang][HIP] Warn when __AMDGCN_WAVEFRONT_SIZE is used in host code without relying on target-dependent overload resolution (PR #109663)

2024-09-30 Thread Fabian Ritter via cfe-commits

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


[clang] [Clang][HIP] Warn when __AMDGCN_WAVEFRONT_SIZE is used in host code without relying on target-dependent overload resolution (PR #109663)

2024-09-30 Thread Fabian Ritter via cfe-commits

ritter-x2a wrote:

Ping.

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


[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet updated 
https://github.com/llvm/llvm-project/pull/110091

From 02e1677ed40ef23792943d9b2cb895ba80312ee9 Mon Sep 17 00:00:00 2001
From: Kadir Cetinkaya 
Date: Thu, 26 Sep 2024 10:55:49 +0200
Subject: [PATCH] [clangd] Improve filtering logic for undesired proto symbols

This used to filter any names with `_` in them, apart from
enum-constants. Resulting in discrepancies in behavior when we had
fields that have `_` in the name, or for accessors like `set_`, `has_`.

The logic seems to be trying to filter mangled names for nested entries,
so adjusted logic to only do so for top-level decls, while still
preserving some public top-level helpers.

Heuristics are still leaning towards false-negatives, e.g. if a
top-level entity has `_` in its name (`message Foo_Bar {}`), it'll be
filtered, or an enum that prefixes its type name to constants
(`enum Foo { Foo_OK }`).
---
 .../clangd/index/SymbolCollector.cpp  | 69 +++
 .../clangd/unittests/SymbolCollectorTests.cpp | 64 ++---
 2 files changed, 111 insertions(+), 22 deletions(-)

diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index a76894cf0855f3..d1d744a21cfd55 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -41,6 +41,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -75,18 +76,62 @@ bool isPrivateProtoDecl(const NamedDecl &ND) {
   if (ND.getIdentifier() == nullptr)
 return false;
   auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
+  // There are some internal helpers like _internal_set_foo();
+  if (Name.contains("_internal_"))
+return true;
+
+  // https://protobuf.dev/reference/cpp/cpp-generated/#nested-types
+  // Nested entities (messages/enums) has two names, one at the top-level 
scope,
+  // with a mangled name created by prepending all the outer types. These names
+  // are almost never preferred by the developers, so exclude them from index.
+  // e.g.
+  //   message Foo {
+  //message Bar {}
+  //enum E { A }
+  //   }
+  //
+  // yields:
+  //   class Foo_Bar {};
+  //   enum Foo_E { Foo_E_A };
+  //   class Foo {
+  //using Bar = Foo_Bar;
+  //static constexpr Foo_E A = Foo_E_A;
+  //   };
+
+  // We get rid of Foo_Bar and Foo_E by discarding any top-level entries with
+  // `_` in the name. This relies on original message/enum not having `_` in 
the
+  // name. Hence might go wrong in certain cases.
+  if (ND.getDeclContext()->isNamespace()) {
+// Strip off some known public suffix helpers for enums, rest of the 
helpers
+// are generated inside record decls so we don't care.
+// https://protobuf.dev/reference/cpp/cpp-generated/#enum
+Name.consume_back("_descriptor");
+Name.consume_back("_IsValid");
+Name.consume_back("_Name");
+Name.consume_back("_Parse");
+Name.consume_back("_MIN");
+Name.consume_back("_MAX");
+Name.consume_back("_ARRAYSIZE");
+return Name.contains('_');
+  }
+
+  // EnumConstantDecls need some special attention, despite being nested in a
+  // TagDecl, they might still have mangled names. We filter those by checking
+  // if it has parent's name as a prefix.
+  // This might go wrong if a nested entity has a name that starts with 
parent's
+  // name, e.g: enum Foo { Foo_X }.
+  if (llvm::isa(&ND)) {
+auto *DC = llvm::cast(ND.getDeclContext());
+if (!DC || !DC->getIdentifier())
+  return false;
+auto CtxName = DC->getIdentifier()->getName();
+return !CtxName.empty() && Name.consume_front(CtxName) &&
+   Name.consume_front("_");
+  }
+
+  // Now we're only left with fields/methods without an `_internal_` in the
+  // name, they're intended for public use.
+  return false;
 }
 
 // We only collect #include paths for symbols that are suitable for global code
diff --git a/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp 
b/clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
index 0666be95b6b9ee..e8088cb37fa51c 

[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread kadir çetinkaya via cfe-commits


@@ -75,18 +76,61 @@ bool isPrivateProtoDecl(const NamedDecl &ND) {
   if (ND.getIdentifier() == nullptr)
 return false;
   auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
+  // There are some internal helpers like _internal_set_foo();
+  if (Name.contains("_internal_"))
+return true;
+
+  // https://protobuf.dev/reference/cpp/cpp-generated/#nested-types
+  // Nested entities (messages/enums) has two names, one at the top-level 
scope,
+  // with a mangled name created by prepending all the outer types. These names
+  // are almost never preferred by the developers, so exclude them from index.
+  // e.g.
+  // message Foo {
+  //  message Bar {}
+  //  enum E { A }
+  // }
+  // yields:
+  // class Foo_Bar {};
+  // enum Foo_E { Foo_E_A };
+  // class Foo {
+  //  using Bar = Foo_Bar;
+  //  static constexpr Foo_E A = Foo_E_A;
+  // };
+
+  // We get rid of Foo_Bar and Foo_E by discarding any top-level entries with
+  // `_` in the name. This relies on original message/enum not having `_` in 
the
+  // name. Hence might go wrong in certain cases.
+  if (ND.getDeclContext()->isNamespace()) {
+// Strip off some known public suffix helpers for enums, rest of the 
helpers
+// are generated inside record decls so we don't care.
+// https://protobuf.dev/reference/cpp/cpp-generated/#enum
+Name.consume_back("_descriptor");
+Name.consume_back("_IsValid");
+Name.consume_back("_Name");
+Name.consume_back("_Parse");
+Name.consume_back("_MIN");
+Name.consume_back("_MAX");
+Name.consume_back("_ARRAYSIZE");
+return Name.contains('_');
+  }
+
+  // EnumConstantDecls need some special attention, despite being nested in a
+  // TagDecl, they might still have mangled names. We filter those by checking
+  // if it has parent's name as a prefix.
+  // This might go wrong if a nested entity has a name that starts with 
parent's
+  // name, e.g: enum Foo { Foo_X }.
+  if (llvm::isa(&ND)) {
+auto *DC = llvm::cast(ND.getDeclContext());
+if (!DC || !DC->getIdentifier())
+  return false;
+auto CtxName = DC->getIdentifier()->getName();
+return !CtxName.empty() && Name.consume_front(CtxName) &&
+   Name.consume_front("_");

kadircet wrote:

i'd rather keep it as-is, since `CtxName + "_"` might trigger an extra string 
allocation

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


[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread kadir çetinkaya via cfe-commits


@@ -75,18 +76,61 @@ bool isPrivateProtoDecl(const NamedDecl &ND) {
   if (ND.getIdentifier() == nullptr)
 return false;
   auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
+  // There are some internal helpers like _internal_set_foo();

kadircet wrote:

I feel like that FIXME might still apply. I think it's rather about passing in 
a custom filter, similar to `FileFilter`, so I am more inclined towards keeping 
it

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-09-30 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -2808,27 +2825,63 @@ void ExprEngine::processBranch(const Stmt *Condition,
   std::tie(StTrue, StFalse) = *KnownCondValueAssumption;
 else {
   assert(!isa(Condition));
+  // TODO: instead of this shortcut perhaps it would be better to "rejoin"
+  // the common execution path with
+  // StTrue = StFalse = PrevState;

steakhal wrote:

I'd rather drop this, as it's not clear when could we achieve this. 
Unactionable comments are not useful long term. I'd expect contributors being 
able to push for a change like this be able to pinpoint this location in source 
code without any external help. For anyone else, it's just noise and confusing.

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-09-30 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -2808,27 +2825,63 @@ void ExprEngine::processBranch(const Stmt *Condition,
   std::tie(StTrue, StFalse) = *KnownCondValueAssumption;
 else {
   assert(!isa(Condition));
+  // TODO: instead of this shortcut perhaps it would be better to "rejoin"
+  // the common execution path with
+  // StTrue = StFalse = PrevState;
   builder.generateNode(PrevState, true, PredN);
   builder.generateNode(PrevState, false, PredN);
   continue;
 }
 if (StTrue && StFalse)
   assert(!isa(Condition));
 
+const Expr *EagerlyAssumeExpr =
+PrevState->get();
+const Expr *ConditionExpr = dyn_cast(Condition);
+if (ConditionExpr)
+  ConditionExpr = ConditionExpr->IgnoreParenCasts();
+bool DidEagerlyAssume = EagerlyAssumeExpr == ConditionExpr;
+bool BothFeasible = (DidEagerlyAssume || (StTrue && StFalse)) &&
+builder.isFeasible(true) && builder.isFeasible(false);
+
 // Process the true branch.
 if (builder.isFeasible(true)) {
-  if (StTrue)
+  if (StTrue) {
+if (BothFeasible && IterationsFinishedInLoop &&
+*IterationsFinishedInLoop >= 2) {
+  // When programmers write a loop, they imply that at least two
+  // iterations are possible (otherwise they would just write an `if`),
+  // but the third iteration is not implied: there are situations where
+  // the programmer knows that there won't be a third iteration (e.g.
+  // they iterate over a structure that has <= 2 elements) but this is
+  // not marked in the source code.
+  // Checkers may use this heuristic mark to discard results found on
+  // branches that contain this "weak" assumption.
+  StTrue = recordWeakLoopAssumption(StTrue);
+}
 builder.generateNode(StTrue, true, PredN);
-  else
+  } else {
 builder.markInfeasible(true);
+  }
 }
 
 // Process the false branch.
 if (builder.isFeasible(false)) {
-  if (StFalse)
+  if (StFalse) {
+if (BothFeasible && IterationsFinishedInLoop &&
+*IterationsFinishedInLoop == 0) {

steakhal wrote:

I'd prefer no `value_or` here TBH.

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-09-30 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -441,10 +441,33 @@ void CoreEngine::HandleCallEnter(const CallEnter &CE, 
ExplodedNode *Pred) {
 void CoreEngine::HandleBranch(const Stmt *Cond, const Stmt *Term,
 const CFGBlock * B, ExplodedNode *Pred) {
   assert(B->succ_size() == 2);
+
+  const LocationContext *LC = Pred->getLocationContext();
+  BlockCounter Counter = WList->getBlockCounter();
+  unsigned BlockCount =
+  Counter.getNumVisited(LC->getStackFrame(), B->getBlockID());
+  std::optional IterationsFinishedInLoop = std::nullopt;
+  if (isa(Term)) {
+// FIXME: This code approximates the number of finished iteration based on
+// the block count, i.e. the number of evaluations of the terminator block
+// on the current execution path (which includes the current evaluation, so
+// is always at least 1). This is probably acceptable for the
+// checker-specific false positive suppression that currently uses this
+// value, but it would be better to calcuate an accurate count of
+// iterations.

steakhal wrote:

The formatting seems off. Some lines are not really padded up to (or close to) 
80 cols.

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-09-30 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 


https://github.com/steakhal commented:

Looks convincing. Suppression like this is probably not the best we can 
achieve, but if it reduces the FPs by 2-3x, then I'm all in!
I'm putting this PR to the test downstream to see the overall feel we would get.
I'll report back once I have some time to eval the diffs :D

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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-09-30 Thread Balazs Benics via cfe-commits
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 


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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-09-30 Thread Donát Nagy via cfe-commits


@@ -2808,27 +2825,63 @@ void ExprEngine::processBranch(const Stmt *Condition,
   std::tie(StTrue, StFalse) = *KnownCondValueAssumption;
 else {
   assert(!isa(Condition));
+  // TODO: instead of this shortcut perhaps it would be better to "rejoin"
+  // the common execution path with
+  // StTrue = StFalse = PrevState;

NagyDonat wrote:

You're right that this comment is confusing, I'll probably eliminate it by 
implementing the (relatively modest) change that I described -- or at least 
tried to describe ;) -- in it.

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


[clang] [compiler-rt] [llvm] [FMV][AArch64] Unify features ssbs and ssbs2. (PR #110297)

2024-09-30 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea updated 
https://github.com/llvm/llvm-project/pull/110297

>From 82047dc021979fe58001b15c740649c3d44dd23b Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Fri, 27 Sep 2024 16:37:26 +0100
Subject: [PATCH] [FMV][AArch64] Unify features ssbs and ssbs2.

According to https://developer.arm.com/documentation/102105/latest
Arm Architecture Reference Manual for A-profile architecture:
Known issues

2.206 D22789
In section C5.2.25 "SSBS, Speculative Store Bypass Safe",
under the heading 'Configurations', the text that reads:

"This register is present only when FEAT_SSBS is implemented.
Otherwise, direct accesses to SSBS are UNDEFINED."

is changed to read:

"This register is present only when FEAT_SSBS2 is implemented.
Otherwise, direct accesses to SSBS are UNDEFINED."

This suggests that it's not worth splitting FEAT_SSBS2 from FEAT_SSBS
in the compiler, since FEAT_SSBS cannot be used for predicating the
MRS/MSR instructions. Those can access PSTATE.SSBS only when FEAT_SSBS2
is available. Moreover, there are no hardware implementations which
implement FEAT_SSBS without FEAT_SSBS2, therefore unifying these
features in the specification should not be a regression for feature
detection.

Approved in ACLE as https://github.com/ARM-software/acle/pull/350
---
 clang/test/CodeGen/aarch64-fmv-dependencies.c |   7 +-
 clang/test/CodeGen/attr-target-version.c  | 103 +-
 .../CodeGenCXX/attr-target-clones-aarch64.cpp |  10 +-
 clang/test/Sema/attr-target-clones-aarch64.c  |   5 +-
 clang/test/SemaCXX/attr-target-version.cpp|   4 +-
 .../builtins/cpu_model/AArch64CPUFeatures.inc |   2 +-
 .../builtins/cpu_model/aarch64/fmv/apple.inc  |   4 -
 .../builtins/cpu_model/aarch64/fmv/mrs.inc|   4 +-
 .../llvm/TargetParser/AArch64CPUFeatures.inc  |   2 +-
 llvm/lib/Target/AArch64/AArch64FMV.td |   3 +-
 10 files changed, 66 insertions(+), 78 deletions(-)

diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c 
b/clang/test/CodeGen/aarch64-fmv-dependencies.c
index 681f7e82634fa8..f4229a5d233970 100644
--- a/clang/test/CodeGen/aarch64-fmv-dependencies.c
+++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c
@@ -135,12 +135,9 @@ __attribute__((target_version("sme-i16i64"))) int 
fmv(void) { return 0; }
 // CHECK: define dso_local i32 @fmv._Msme2() #[[sme2:[0-9]+]] {
 __attribute__((target_version("sme2"))) int fmv(void) { return 0; }
 
-// CHECK: define dso_local i32 @fmv._Mssbs() #[[ATTR0:[0-9]+]] {
+// CHECK: define dso_local i32 @fmv._Mssbs() #[[ssbs:[0-9]+]] {
 __attribute__((target_version("ssbs"))) int fmv(void) { return 0; }
 
-// CHECK: define dso_local i32 @fmv._Mssbs2() #[[ssbs2:[0-9]+]] {
-__attribute__((target_version("ssbs2"))) int fmv(void) { return 0; }
-
 // CHECK: define dso_local i32 @fmv._Msve() #[[sve:[0-9]+]] {
 __attribute__((target_version("sve"))) int fmv(void) { return 0; }
 
@@ -219,7 +216,7 @@ int caller() {
 // CHECK: attributes #[[sme_f64f64]] = { {{.*}} 
"target-features"="+bf16,+fp-armv8,+neon,+outline-atomics,+sme,+sme-f64f64,+v8a"
 // CHECK: attributes #[[sme_i16i64]] = { {{.*}} 
"target-features"="+bf16,+fp-armv8,+neon,+outline-atomics,+sme,+sme-i16i64,+v8a"
 // CHECK: attributes #[[sme2]] = { {{.*}} 
"target-features"="+bf16,+fp-armv8,+neon,+outline-atomics,+sme,+sme2,+v8a"
-// CHECK: attributes #[[ssbs2]] = { {{.*}} 
"target-features"="+fp-armv8,+neon,+outline-atomics,+ssbs,+v8a"
+// CHECK: attributes #[[ssbs]] = { {{.*}} 
"target-features"="+fp-armv8,+neon,+outline-atomics,+ssbs,+v8a"
 // CHECK: attributes #[[sve]] = { {{.*}} 
"target-features"="+fp-armv8,+fullfp16,+neon,+outline-atomics,+sve,+v8a"
 // CHECK: attributes #[[sve_bf16_ebf16]] = { {{.*}} 
"target-features"="+bf16,+fp-armv8,+fullfp16,+neon,+outline-atomics,+sve,+v8a"
 // CHECK: attributes #[[sve_i8mm]] = { {{.*}} 
"target-features"="+fp-armv8,+fullfp16,+i8mm,+neon,+outline-atomics,+sve,+v8a"
diff --git a/clang/test/CodeGen/attr-target-version.c 
b/clang/test/CodeGen/attr-target-version.c
index 228435a0494c3e..e74e8c254b3952 100644
--- a/clang/test/CodeGen/attr-target-version.c
+++ b/clang/test/CodeGen/attr-target-version.c
@@ -296,7 +296,7 @@ int caller(void) { return used_def_without_default_decl() + 
used_decl_without_de
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@fmv_c._Mssbs
-// CHECK-SAME: () #[[ATTR9]] {
+// CHECK-SAME: () #[[ATTR13:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:ret void
 //
@@ -354,14 +354,14 @@ int caller(void) { return used_def_without_default_decl() 
+ used_decl_without_de
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@unused_with_forward_default_decl._Mmops
-// CHECK-SAME: () #[[ATTR14:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR15:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:ret i32 0
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define 
{{[^@]+}}@unused_with_implicit_extern_forward_default_decl._Mdotprod

[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2 instruction (PR #97602)

2024-09-30 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/97602

>From ac405d7516ea92cf3c63220d1bdf0677dd7dd372 Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Wed, 3 Jul 2024 15:55:45 +
Subject: [PATCH 1/7] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2
 instruction

This patch adds these intrinsics:

  // Variants are also available for:
  // [_s8], [_u16], [_s16], [_u32], [_s32], [_u64], [_s64]
  // [_bf16], [_f16], [_f32], [_f64]
  void svwrite_lane_zt[_u8](uint64_t zt0, svuint8_t zt, uint64_t idx) 
__arm_streaming __arm_inout("zt0");
  void svwrite_zt[_u8](uint64_t zt0, svuint8_t zt) __arm_streaming 
__arm_inout("zt0");

according to PR#324[1]
[1]https://github.com/ARM-software/acle/pull/324
---
 clang/include/clang/Basic/arm_sme.td  |   6 +
 .../acle_sme2_write_lane_zt.c | 401 ++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  15 +-
 llvm/include/llvm/IR/IntrinsicsAArch64.td |   9 +
 .../Target/AArch64/AArch64ISelLowering.cpp|   2 +
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |   2 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td|  42 +-
 .../AArch64/sme2-intrinsics-read-zt.ll| 162 +++
 8 files changed, 636 insertions(+), 3 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-read-zt.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ae6b55e98827ff..52997f67b5cd9f 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -817,4 +817,10 @@ multiclass ZAReadzArray{
 
 defm SVREADZ_VG2 :  ZAReadzArray<"2">;
 defm SVREADZ_VG4 :  ZAReadzArray<"4">;
+
+let SMETargetGuard = "sme2,sme-lutv2" in {
+  def SVLUTI4_ZT_X4 : SInst<"svluti4_zt_{d}_x4", "4i2.u", "cUc", MergeNone, 
"aarch64_sme_luti4_zt_x4", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>]>;
+  def SVWRITE_LANE_ZT : SInst<"svwrite_lane_zt[_{d}]", "vidi", 
"cUcsUsiUilUlfhdb", MergeNone, "aarch64_sme_write_lane_zt", [IsStreaming, 
IsInOutZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>;
+  def SVWRITE_ZT : SInst<"svwrite_zt[_{d}]", "vid", "cUcsUsiUilUlfhdb", 
MergeNone, "aarch64_sme_write_zt", [IsStreaming, IsInOutZT0], [ImmCheck<0, 
ImmCheck0_0>]>;
+}
 } // let SVETargetGuard = InvalidMode
diff --git 
a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
new file mode 100644
index 00..9bdc3481953a21
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
@@ -0,0 +1,401 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 
-Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++  -triple aarch64-none-linux-gnu -target-feature 
+bf16 -target-feature +sme -target-feature +sme2 -target-feature  +sme-lutv2  
-O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-CXX
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS   -triple aarch64-none-linux-gnu 
-target-feature +bf16 -target-feature +sme -target-feature +sme2 
-target-feature  +sme-lutv2  -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -x c++  -triple 
aarch64-none-linux-gnu -target-feature +bf16 -target-feature +sme 
-target-feature +sme2 -target-feature +sme-lutv2 -O2 -Werror -Wall -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-CXX
+
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 -S 
-Werror -Wall -o /dev/null %s
+// REQUIRES: aarch64-registered-target
+
+#ifdef SVE_OVERLOADED_FORMS
+#define SVE_ACLE_FUNC(A1,A2_UNUSED) A1
+#else
+#define SVE_ACLE_FUNC(A1,A2) A1##A2
+#endif
+
+#include 
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_u8_1(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 
0,  [[V]], i32 1)
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LABEL: define dso_local void 
@_Z23test_write_lane_zt_u8_1u11__SVUint8_t(
+// CHECK-CXX-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-CXX-NEXT:  [[ENTRY:.*:]]
+// CHECK-CXX-NEXT:tail call void 
@llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 0,  [[V]], i32 1)
+// CHECK-CXX-NEXT:ret void
+//
+void test_write_lane_zt_u8_1(svuint8_t v) __arm_streaming __arm_inout("zt0") {
+  SVE_ACLE_FUNC(svwrite_lane_zt, _u8)(0, v, 1);
+}
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_s8_2(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  [

[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2 instruction (#97755) (PR #109953)

2024-09-30 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/109953

>From bef293187f32e4e197035eda299f73a5fd8f8684 Mon Sep 17 00:00:00 2001
From: CarolineConcatto 
Date: Wed, 25 Sep 2024 09:53:23 +0100
Subject: [PATCH 1/3] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2
 instruction (#97755)

This patch was reverted because of a failing C test.
It now has being solved and can be merged into main again

This patch adds these intrinsics:

// Variants are also available for: _s8
svuint8x4_t svluti4_zt_u8_x4(uint64_t zt0, svuint8x2_t zn)
__arm_streaming __arm_in("zt0");

according to PR#324[1]
[1]ARM-software/acle#324

OBS.: Fix the clang test  run line

Address comments about the functions SelectMultiVectorLuti
---
 clang/include/clang/Basic/arm_sme.td  |  5 ++
 .../acle_sme2_luti4_zt.c  | 86 +++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  5 ++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  6 ++
 .../Target/AArch64/AArch64ISelDAGToDAG.cpp| 54 ++--
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |  2 +-
 .../CodeGen/AArch64/sme2-intrinsics-luti4.ll  | 17 
 7 files changed, 165 insertions(+), 10 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-luti4.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ae6b55e98827ff..9c9f31f3884069 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -817,4 +817,9 @@ multiclass ZAReadzArray{
 
 defm SVREADZ_VG2 :  ZAReadzArray<"2">;
 defm SVREADZ_VG4 :  ZAReadzArray<"4">;
+
+let SMETargetGuard = "sme2,sme-lutv2" in {
+  def SVLUTI4_ZT_X4 : SInst<"svluti4_zt_{d}_x4", "4i2.u", "cUc", MergeNone, 
"aarch64_sme_luti4_zt_x4", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>]>;
+}
+
 } // let SVETargetGuard = InvalidMode
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
new file mode 100644
index 00..fc4b6fa299f90f
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
@@ -0,0 +1,86 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+
+#include 
+
+// CHECK-LABEL: define dso_local { , , 
,  } @test_luti4_zt_u8_x4(
+// CHECK-SAME:  [[OP_COERCE0:%.*]],  
[[OP_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca { , , ,  }, align 16
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { , , ,  } 
@llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0,  [[OP_COERCE0]], 
 [[OP_COERCE1]])
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , , ,  } [[TMP0]], 0
+// CHECK-NEXT:[[TMP2:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( poison,  [[TMP1]], i64 0)
+// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , ,  } [[TMP0]], 1
+// CHECK-NEXT:[[TMP4:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP2]],  [[TMP3]], i64 16)
+// CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , ,  } [[TMP0]], 2
+// CHECK-NEXT:[[TMP6:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP4]],  [[TMP5]], i64 32)
+// CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , ,  } [[TMP0]], 3
+// CHECK-NEXT:[[TMP8:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP6]],  [[TMP7]], i64 48)
+// CHECK-NEXT:store  [[TMP8]], ptr [[RETVAL]], align 16
+// CHECK-NEXT:[[TMP9:%.*]] = load { , , ,  }, ptr [[RETVAL]], align 16
+// CHECK-NEXT:ret { , , ,  } [[TMP9]]
+//
+// CPP-CHECK-LABEL: define dso_local { , , 
,  } @_Z19test_luti4_zt_u8_x411svuint8x2_t(
+// CPP-CHECK-SAME:  [[OP_COERCE0:%.*]],  
[[OP_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] {
+// CPP-CHECK-NEXT:  [[ENTRY:.*:]]
+// CPP-CHECK-NEXT:[[RETVAL:%.*]] = alloca { , , ,  }, align 16
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call { , , ,  } 
@llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0,  [[OP_COERCE0]], 
 [[OP_COERCE1]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , 
, ,  } [[TMP0]], 0
+// CPP-CHECK-NEXT:[[TMP2:%.*]] = t

[clang] [clang][bytecode] Cast fixed-point cmp result to int if necessary (PR #110469)

2024-09-30 Thread Timm Baeder via cfe-commits

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

This is the case in C.

>From 4c2de21a53bc6b048c3d7fc8e2a333fd7d13cdcb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 30 Sep 2024 11:00:37 +0200
Subject: [PATCH] [clang][bytecode] Cast fixed-point cmp result to int if
 necessary

This is the case in C.
---
 clang/lib/AST/ByteCode/Compiler.cpp   | 23 ++-
 clang/test/Frontend/fixed_point_comparisons.c |  3 +++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c24c4b6db2a5bf..5ad5899739909f 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1542,19 +1542,30 @@ bool Compiler::VisitFixedPointBinOp(const 
BinaryOperator *E) {
 return true;
   };
 
+  auto MaybeCastToBool = [&](bool Result) {
+if (!Result)
+  return false;
+PrimType T = classifyPrim(E);
+if (DiscardResult)
+  return this->emitPop(T, E);
+if (T != PT_Bool)
+  return this->emitCast(PT_Bool, T, E);
+return true;
+  };
+
   switch (E->getOpcode()) {
   case BO_EQ:
-return this->emitEQFixedPoint(E);
+return MaybeCastToBool(this->emitEQFixedPoint(E));
   case BO_NE:
-return this->emitNEFixedPoint(E);
+return MaybeCastToBool(this->emitNEFixedPoint(E));
   case BO_LT:
-return this->emitLTFixedPoint(E);
+return MaybeCastToBool(this->emitLTFixedPoint(E));
   case BO_LE:
-return this->emitLEFixedPoint(E);
+return MaybeCastToBool(this->emitLEFixedPoint(E));
   case BO_GT:
-return this->emitGTFixedPoint(E);
+return MaybeCastToBool(this->emitGTFixedPoint(E));
   case BO_GE:
-return this->emitGEFixedPoint(E);
+return MaybeCastToBool(this->emitGEFixedPoint(E));
   case BO_Add:
 return ConvertResult(this->emitAddFixedPoint(E));
   case BO_Sub:
diff --git a/clang/test/Frontend/fixed_point_comparisons.c 
b/clang/test/Frontend/fixed_point_comparisons.c
index 59c4405e41c031..39e62bce51e2b2 100644
--- a/clang/test/Frontend/fixed_point_comparisons.c
+++ b/clang/test/Frontend/fixed_point_comparisons.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - | FileCheck %s --check-prefixes=CHECK,UNPADDED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,PADDED
 
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - -fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,UNPADDED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,PADDED
+
 // Fixed point against other fixed point
 _Bool b_eq_true = 2.5hk == 2.5uhk;  // CHECK-DAG: @b_eq_true  = {{.*}}global 
i8 1, align 1
 _Bool b_eq_false = 2.5hk == 2.4uhk; // CHECK-DAG: @b_eq_false = {{.*}}global 
i8 0, align 1

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


[clang] [clang][bytecode] Cast fixed-point cmp result to int if necessary (PR #110469)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

This is the case in C.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+17-6) 
- (modified) clang/test/Frontend/fixed_point_comparisons.c (+3) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c24c4b6db2a5bf..5ad5899739909f 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1542,19 +1542,30 @@ bool Compiler::VisitFixedPointBinOp(const 
BinaryOperator *E) {
 return true;
   };
 
+  auto MaybeCastToBool = [&](bool Result) {
+if (!Result)
+  return false;
+PrimType T = classifyPrim(E);
+if (DiscardResult)
+  return this->emitPop(T, E);
+if (T != PT_Bool)
+  return this->emitCast(PT_Bool, T, E);
+return true;
+  };
+
   switch (E->getOpcode()) {
   case BO_EQ:
-return this->emitEQFixedPoint(E);
+return MaybeCastToBool(this->emitEQFixedPoint(E));
   case BO_NE:
-return this->emitNEFixedPoint(E);
+return MaybeCastToBool(this->emitNEFixedPoint(E));
   case BO_LT:
-return this->emitLTFixedPoint(E);
+return MaybeCastToBool(this->emitLTFixedPoint(E));
   case BO_LE:
-return this->emitLEFixedPoint(E);
+return MaybeCastToBool(this->emitLEFixedPoint(E));
   case BO_GT:
-return this->emitGTFixedPoint(E);
+return MaybeCastToBool(this->emitGTFixedPoint(E));
   case BO_GE:
-return this->emitGEFixedPoint(E);
+return MaybeCastToBool(this->emitGEFixedPoint(E));
   case BO_Add:
 return ConvertResult(this->emitAddFixedPoint(E));
   case BO_Sub:
diff --git a/clang/test/Frontend/fixed_point_comparisons.c 
b/clang/test/Frontend/fixed_point_comparisons.c
index 59c4405e41c031..39e62bce51e2b2 100644
--- a/clang/test/Frontend/fixed_point_comparisons.c
+++ b/clang/test/Frontend/fixed_point_comparisons.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - | FileCheck %s --check-prefixes=CHECK,UNPADDED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,PADDED
 
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - -fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,UNPADDED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,PADDED
+
 // Fixed point against other fixed point
 _Bool b_eq_true = 2.5hk == 2.5uhk;  // CHECK-DAG: @b_eq_true  = {{.*}}global 
i8 1, align 1
 _Bool b_eq_false = 2.5hk == 2.4uhk; // CHECK-DAG: @b_eq_false = {{.*}}global 
i8 0, align 1

``




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


[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Nondeterministic pointer usage improvements (PR #110471)

2024-09-30 Thread via cfe-commits

https://github.com/vabridgers created 
https://github.com/llvm/llvm-project/pull/110471

RFC: This PR is not ready to merge yet, preliminary comments are welcome.
 Here are some questions to consider...

Q) Is the name and file location ok in the directory structure?
   I initially chose bugprone and NondeterministicPointerUsage as a
   starting point for review.
Q) I wrote an explanation for the check based on internal discussion
   since I felt like this was missing. Please check and comment.
Q) There are more ways to iterate over an unordered container
   than captured here. Do those need to be detected as well?
Q) I squashed PointerIteration and PointerSorting. I think that works
   in this case, but interested to hear your comments about that.
Q) I ended up expanding upon the C++ simulation header, but had thoughts
   about breaking that up into multiple smaller files. Maybe there's an
   opportunity to refactor some C++ simulation files across multiple
   checkers as a seperate PR first, or maybe even as part of this one?

This change moves the alpha.nondeterministic.PointerSorting and 
alpha.nondeterministic.PointerIteration static analyzer checkers to a single 
clang-tidy check. Those checkers were implemented as clang-tidy checks wrapped 
in the static analyzer framework. The documentation was updated to describe 
what the checks can and cannot do, and testing was completed on a broad set of 
open source projects.

>From faf36443aa357ebfe2adf3c180542071e62d11d4 Mon Sep 17 00:00:00 2001
From: einvbri 
Date: Thu, 26 Sep 2024 16:24:59 +0200
Subject: [PATCH] [clang-tidy] [analyzer] Nondeterministic pointer usage
 improvements

RFC: This PR is not ready to merge yet, preliminary comments are welcome.
 Here are some questions to consider...

Q) Is the name and file location ok in the directory structure?
   I initially chose bugprone and NondeterministicPointerUsage as a
   starting point for review.
Q) I wrote an explanation for the check based on internal discussion
   since I felt like this was missing. Please check and comment.
Q) There are more ways to iterate over an unordered container
   than captured here. Do those need to be detected as well?
Q) I squashed PointerIteration and PointerSorting. I think that works
   in this case, but interested to hear your comments about that.
Q) I ended up expanding upon the C++ simulation header, but had thoughts
   about breaking that up into multiple smaller files. Maybe there's an
   opportunity to refactor some C++ simulation files across multiple
   checkers as a seperate PR first, or maybe even as part of this one?

This change moves the alpha.nondeterministic.PointerSorting and
alpha.nondeterministic.PointerIteration static analyzer checkers to
a single clang-tidy check. Those checkers were implemented as clang-tidy
checks wrapped in the static analyzer framework. The documentation was
updated to describe what the checks can and cannot do, and testing
was completed on a broad set of open source projects.
---
 .../bugprone/BugproneTidyModule.cpp   |3 +
 .../clang-tidy/bugprone/CMakeLists.txt|1 +
 .../NondeterministicPointerUsageCheck.cpp |   67 +
 .../NondeterministicPointerUsageCheck.h   |   36 +
 .../nondeterministic-pointer-usage.rst|   31 +
 .../Inputs/system-header-simulator-cxx.h  | 1450 +
 .../nondeterministic-pointer-usage.cpp|   69 +
 clang/docs/analyzer/checkers.rst  |   31 -
 .../clang/StaticAnalyzer/Checkers/Checkers.td |   18 -
 .../StaticAnalyzer/Checkers/CMakeLists.txt|2 -
 .../Checkers/PointerIterationChecker.cpp  |  101 --
 .../Checkers/PointerSortingChecker.cpp|  115 --
 clang/test/Analysis/ptr-sort.cpp  |   36 -
 13 files changed, 1657 insertions(+), 303 deletions(-)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/nondeterministic-pointer-usage.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator-cxx.h
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/nondeterministic-pointer-usage.cpp
 delete mode 100644 
clang/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp
 delete mode 100644 clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp
 delete mode 100644 clang/test/Analysis/ptr-sort.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d17..7c177196d76f58 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -48,6 +48,7 @@
 #include "MultipleStatementMacroCheck.h"
 #include "NoEscapeCheck.h"
 #include "NonZeroEnumToBoolConver

[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Nondeterministic pointer usage improvements (PR #110471)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (vabridgers)


Changes

RFC: This PR is not ready to merge yet, preliminary comments are welcome.
 Here are some questions to consider...

Q) Is the name and file location ok in the directory structure?
   I initially chose bugprone and NondeterministicPointerUsage as a
   starting point for review.
Q) I wrote an explanation for the check based on internal discussion
   since I felt like this was missing. Please check and comment.
Q) There are more ways to iterate over an unordered container
   than captured here. Do those need to be detected as well?
Q) I squashed PointerIteration and PointerSorting. I think that works
   in this case, but interested to hear your comments about that.
Q) I ended up expanding upon the C++ simulation header, but had thoughts
   about breaking that up into multiple smaller files. Maybe there's an
   opportunity to refactor some C++ simulation files across multiple
   checkers as a seperate PR first, or maybe even as part of this one?

This change moves the alpha.nondeterministic.PointerSorting and 
alpha.nondeterministic.PointerIteration static analyzer checkers to a single 
clang-tidy check. Those checkers were implemented as clang-tidy checks wrapped 
in the static analyzer framework. The documentation was updated to describe 
what the checks can and cannot do, and testing was completed on a broad set of 
open source projects.

---

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


13 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp (+3) 
- (modified) clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt (+1) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp 
(+67) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.h (+36) 
- (added) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/nondeterministic-pointer-usage.rst
 (+31) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator-cxx.h
 (+1450) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/nondeterministic-pointer-usage.cpp
 (+69) 
- (modified) clang/docs/analyzer/checkers.rst (-31) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (-18) 
- (modified) clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt (-2) 
- (removed) clang/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp 
(-101) 
- (removed) clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp (-115) 
- (removed) clang/test/Analysis/ptr-sort.cpp (-36) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d17..7c177196d76f58 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -48,6 +48,7 @@
 #include "MultipleStatementMacroCheck.h"
 #include "NoEscapeCheck.h"
 #include "NonZeroEnumToBoolConversionCheck.h"
+#include "NondeterministicPointerUsageCheck.h"
 #include "NotNullTerminatedResultCheck.h"
 #include "OptionalValueConversionCheck.h"
 #include "ParentVirtualCallCheck.h"
@@ -179,6 +180,8 @@ class BugproneModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
 CheckFactories.registerCheck("bugprone-no-escape");
+CheckFactories.registerCheck(
+"bugprone-nondeterministic-pointer-usage");
 CheckFactories.registerCheck(
 "bugprone-non-zero-enum-to-bool-conversion");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac58..5628572b984226 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -44,6 +44,7 @@ add_clang_library(clangTidyBugproneModule
   MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
   NoEscapeCheck.cpp
+  NondeterministicPointerUsageCheck.cpp
   NonZeroEnumToBoolConversionCheck.cpp
   NotNullTerminatedResultCheck.cpp
   OptionalValueConversionCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp
new file mode 100644
index 00..ddc314af739d97
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp
@@ -0,0 +1,67 @@
+//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===

[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Nondeterministic pointer usage improvements (PR #110471)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: None (vabridgers)


Changes

RFC: This PR is not ready to merge yet, preliminary comments are welcome.
 Here are some questions to consider...

Q) Is the name and file location ok in the directory structure?
   I initially chose bugprone and NondeterministicPointerUsage as a
   starting point for review.
Q) I wrote an explanation for the check based on internal discussion
   since I felt like this was missing. Please check and comment.
Q) There are more ways to iterate over an unordered container
   than captured here. Do those need to be detected as well?
Q) I squashed PointerIteration and PointerSorting. I think that works
   in this case, but interested to hear your comments about that.
Q) I ended up expanding upon the C++ simulation header, but had thoughts
   about breaking that up into multiple smaller files. Maybe there's an
   opportunity to refactor some C++ simulation files across multiple
   checkers as a seperate PR first, or maybe even as part of this one?

This change moves the alpha.nondeterministic.PointerSorting and 
alpha.nondeterministic.PointerIteration static analyzer checkers to a single 
clang-tidy check. Those checkers were implemented as clang-tidy checks wrapped 
in the static analyzer framework. The documentation was updated to describe 
what the checks can and cannot do, and testing was completed on a broad set of 
open source projects.

---

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


13 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp (+3) 
- (modified) clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt (+1) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp 
(+67) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.h (+36) 
- (added) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/nondeterministic-pointer-usage.rst
 (+31) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator-cxx.h
 (+1450) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/nondeterministic-pointer-usage.cpp
 (+69) 
- (modified) clang/docs/analyzer/checkers.rst (-31) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (-18) 
- (modified) clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt (-2) 
- (removed) clang/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp 
(-101) 
- (removed) clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp (-115) 
- (removed) clang/test/Analysis/ptr-sort.cpp (-36) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d17..7c177196d76f58 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -48,6 +48,7 @@
 #include "MultipleStatementMacroCheck.h"
 #include "NoEscapeCheck.h"
 #include "NonZeroEnumToBoolConversionCheck.h"
+#include "NondeterministicPointerUsageCheck.h"
 #include "NotNullTerminatedResultCheck.h"
 #include "OptionalValueConversionCheck.h"
 #include "ParentVirtualCallCheck.h"
@@ -179,6 +180,8 @@ class BugproneModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
 CheckFactories.registerCheck("bugprone-no-escape");
+CheckFactories.registerCheck(
+"bugprone-nondeterministic-pointer-usage");
 CheckFactories.registerCheck(
 "bugprone-non-zero-enum-to-bool-conversion");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac58..5628572b984226 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -44,6 +44,7 @@ add_clang_library(clangTidyBugproneModule
   MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
   NoEscapeCheck.cpp
+  NondeterministicPointerUsageCheck.cpp
   NonZeroEnumToBoolConversionCheck.cpp
   NotNullTerminatedResultCheck.cpp
   OptionalValueConversionCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp
new file mode 100644
index 00..ddc314af739d97
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp
@@ -0,0 +1,67 @@
+//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---

[clang] [clang-tools-extra] RFC: [clang-tidy] [analyzer] Nondeterministic pointer usage improvements (PR #110471)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: None (vabridgers)


Changes

RFC: This PR is not ready to merge yet, preliminary comments are welcome.
 Here are some questions to consider...

Q) Is the name and file location ok in the directory structure?
   I initially chose bugprone and NondeterministicPointerUsage as a
   starting point for review.
Q) I wrote an explanation for the check based on internal discussion
   since I felt like this was missing. Please check and comment.
Q) There are more ways to iterate over an unordered container
   than captured here. Do those need to be detected as well?
Q) I squashed PointerIteration and PointerSorting. I think that works
   in this case, but interested to hear your comments about that.
Q) I ended up expanding upon the C++ simulation header, but had thoughts
   about breaking that up into multiple smaller files. Maybe there's an
   opportunity to refactor some C++ simulation files across multiple
   checkers as a seperate PR first, or maybe even as part of this one?

This change moves the alpha.nondeterministic.PointerSorting and 
alpha.nondeterministic.PointerIteration static analyzer checkers to a single 
clang-tidy check. Those checkers were implemented as clang-tidy checks wrapped 
in the static analyzer framework. The documentation was updated to describe 
what the checks can and cannot do, and testing was completed on a broad set of 
open source projects.

---

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


13 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp (+3) 
- (modified) clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt (+1) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp 
(+67) 
- (added) 
clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.h (+36) 
- (added) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/nondeterministic-pointer-usage.rst
 (+31) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/Inputs/system-header-simulator-cxx.h
 (+1450) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/nondeterministic-pointer-usage.cpp
 (+69) 
- (modified) clang/docs/analyzer/checkers.rst (-31) 
- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (-18) 
- (modified) clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt (-2) 
- (removed) clang/lib/StaticAnalyzer/Checkers/PointerIterationChecker.cpp 
(-101) 
- (removed) clang/lib/StaticAnalyzer/Checkers/PointerSortingChecker.cpp (-115) 
- (removed) clang/test/Analysis/ptr-sort.cpp (-36) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d17..7c177196d76f58 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -48,6 +48,7 @@
 #include "MultipleStatementMacroCheck.h"
 #include "NoEscapeCheck.h"
 #include "NonZeroEnumToBoolConversionCheck.h"
+#include "NondeterministicPointerUsageCheck.h"
 #include "NotNullTerminatedResultCheck.h"
 #include "OptionalValueConversionCheck.h"
 #include "ParentVirtualCallCheck.h"
@@ -179,6 +180,8 @@ class BugproneModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "bugprone-narrowing-conversions");
 CheckFactories.registerCheck("bugprone-no-escape");
+CheckFactories.registerCheck(
+"bugprone-nondeterministic-pointer-usage");
 CheckFactories.registerCheck(
 "bugprone-non-zero-enum-to-bool-conversion");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac58..5628572b984226 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -44,6 +44,7 @@ add_clang_library(clangTidyBugproneModule
   MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
   NoEscapeCheck.cpp
+  NondeterministicPointerUsageCheck.cpp
   NonZeroEnumToBoolConversionCheck.cpp
   NotNullTerminatedResultCheck.cpp
   OptionalValueConversionCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp
new file mode 100644
index 00..ddc314af739d97
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerUsageCheck.cpp
@@ -0,0 +1,67 @@
+//===--- NondetermnisticPointerUsageCheck.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===

[clang] [Clang] Implement CWG 2707 "Deduction guides cannot have a trailing requires-clause" (PR #110473)

2024-09-30 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/110473

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

>From 0a0654909088b11eb360835999d67cc9d633ef91 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Mon, 30 Sep 2024 16:57:14 +0800
Subject: [PATCH] [Clang] Implement CWG 2707 "Deduction guides cannot have a
 trailing requires-clause"

---
 clang/docs/ReleaseNotes.rst   |  3 ++
 clang/include/clang/AST/DeclCXX.h |  9 --
 .../clang/Basic/DiagnosticSemaKinds.td|  2 --
 clang/lib/AST/DeclCXX.cpp |  9 +++---
 clang/lib/Sema/SemaDecl.cpp   | 11 +++-
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  2 +-
 clang/test/CXX/dcl/dcl.decl/p3.cpp|  2 +-
 clang/test/CXX/drs/cwg27xx.cpp| 28 +++
 clang/www/cxx_dr_status.html  |  4 +--
 9 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1fbcac807d0b30..34ff107ef6b124 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -202,6 +202,9 @@ Resolutions to C++ Defect Reports
 - Reject explicit object parameters with type ``void`` (``this void``).
   (`CWG2915: Explicit object parameters of type void 
`_).
 
+- Clang now allows trailing requires clause on explicit deduction guides.
+  (`CWG2707: Deduction guides cannot have a trailing requires-clause 
`_).
+
 C Language Changes
 --
 
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 252e6e92564142..2693cc0e95b4b2 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1965,9 +1965,11 @@ class CXXDeductionGuideDecl : public FunctionDecl {
 ExplicitSpecifier ES,
 const DeclarationNameInfo &NameInfo, QualType T,
 TypeSourceInfo *TInfo, SourceLocation EndLocation,
-CXXConstructorDecl *Ctor, DeductionCandidate Kind)
+CXXConstructorDecl *Ctor, DeductionCandidate Kind,
+Expr *TrailingRequiresClause)
   : FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
- SC_None, false, false, ConstexprSpecKind::Unspecified),
+ SC_None, false, false, ConstexprSpecKind::Unspecified,
+ TrailingRequiresClause),
 Ctor(Ctor), ExplicitSpec(ES) {
 if (EndLocation.isValid())
   setRangeEnd(EndLocation);
@@ -1987,7 +1989,8 @@ class CXXDeductionGuideDecl : public FunctionDecl {
  ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T,
  TypeSourceInfo *TInfo, SourceLocation EndLocation,
  CXXConstructorDecl *Ctor = nullptr,
- DeductionCandidate Kind = DeductionCandidate::Normal);
+ DeductionCandidate Kind = DeductionCandidate::Normal,
+ Expr *TrailingRequiresClause = nullptr);
 
   static CXXDeductionGuideDecl *CreateDeserialized(ASTContext &C,
GlobalDeclID ID);
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f3d5d4c56606cc..93533000c76686 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3050,8 +3050,6 @@ def note_is_deducible_constraint_evaluated_to_false : 
Note<
   "cannot deduce template arguments for %0 from %1">;
 def err_constrained_virtual_method : Error<
   "virtual function cannot have a requires clause">;
-def err_trailing_requires_clause_on_deduction_guide : Error<
-  "deduction guide cannot have a requires clause">;
 def err_constrained_non_templated_function
 : Error<"non-templated function cannot have a requires clause">;
 def err_non_temp_spec_requires_clause : Error<
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 01143391edab40..f5a0aa8f82512e 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2211,9 +2211,10 @@ CXXDeductionGuideDecl *CXXDeductionGuideDecl::Create(
 ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
 ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T,
 TypeSourceInfo *TInfo, SourceLocation EndLocation, CXXConstructorDecl 
*Ctor,
-DeductionCandidate Kind) {
-  return new (C, DC) CXXDeductionGuideDecl(C, DC, StartLoc, ES, NameInfo, T,
-   TInfo, EndLocation, Ctor, Kind);
+DeductionCandidate Kind, Expr *TrailingRequiresClause) {
+  return new (C, DC)
+  CXXDeductionGuideDecl(C, DC, StartLoc, ES, NameInfo, T, TInfo,
+EndLocation, Ctor, Kind, TrailingRequiresClause);
 }
 
 CXXDeductionGuideDecl *
@@ -2221,7 

[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits

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

Thanks, the logic looks reasonable to me.

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


[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits


@@ -75,18 +76,61 @@ bool isPrivateProtoDecl(const NamedDecl &ND) {
   if (ND.getIdentifier() == nullptr)
 return false;
   auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
+  // There are some internal helpers like _internal_set_foo();
+  if (Name.contains("_internal_"))
+return true;
+
+  // https://protobuf.dev/reference/cpp/cpp-generated/#nested-types
+  // Nested entities (messages/enums) has two names, one at the top-level 
scope,
+  // with a mangled name created by prepending all the outer types. These names
+  // are almost never preferred by the developers, so exclude them from index.
+  // e.g.
+  // message Foo {

hokein wrote:

nit: can you add 2 leading spaces in the code example? that would make the code 
easier to read.

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


[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits


@@ -75,18 +76,61 @@ bool isPrivateProtoDecl(const NamedDecl &ND) {
   if (ND.getIdentifier() == nullptr)
 return false;
   auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
+  // There are some internal helpers like _internal_set_foo();
+  if (Name.contains("_internal_"))
+return true;
+
+  // https://protobuf.dev/reference/cpp/cpp-generated/#nested-types
+  // Nested entities (messages/enums) has two names, one at the top-level 
scope,
+  // with a mangled name created by prepending all the outer types. These names
+  // are almost never preferred by the developers, so exclude them from index.
+  // e.g.
+  // message Foo {
+  //  message Bar {}
+  //  enum E { A }
+  // }
+  // yields:
+  // class Foo_Bar {};
+  // enum Foo_E { Foo_E_A };
+  // class Foo {
+  //  using Bar = Foo_Bar;
+  //  static constexpr Foo_E A = Foo_E_A;
+  // };
+
+  // We get rid of Foo_Bar and Foo_E by discarding any top-level entries with
+  // `_` in the name. This relies on original message/enum not having `_` in 
the
+  // name. Hence might go wrong in certain cases.
+  if (ND.getDeclContext()->isNamespace()) {
+// Strip off some known public suffix helpers for enums, rest of the 
helpers
+// are generated inside record decls so we don't care.
+// https://protobuf.dev/reference/cpp/cpp-generated/#enum
+Name.consume_back("_descriptor");
+Name.consume_back("_IsValid");
+Name.consume_back("_Name");
+Name.consume_back("_Parse");
+Name.consume_back("_MIN");
+Name.consume_back("_MAX");
+Name.consume_back("_ARRAYSIZE");
+return Name.contains('_');
+  }
+
+  // EnumConstantDecls need some special attention, despite being nested in a
+  // TagDecl, they might still have mangled names. We filter those by checking
+  // if it has parent's name as a prefix.
+  // This might go wrong if a nested entity has a name that starts with 
parent's
+  // name, e.g: enum Foo { Foo_X }.
+  if (llvm::isa(&ND)) {
+auto *DC = llvm::cast(ND.getDeclContext());
+if (!DC || !DC->getIdentifier())
+  return false;
+auto CtxName = DC->getIdentifier()->getName();
+return !CtxName.empty() && Name.consume_front(CtxName) &&
+   Name.consume_front("_");

hokein wrote:

nit: return `!CtxName.empty() && Name.consume_front(CtxName + "_")`;

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


[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits


@@ -75,18 +76,61 @@ bool isPrivateProtoDecl(const NamedDecl &ND) {
   if (ND.getIdentifier() == nullptr)
 return false;
   auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
+  // There are some internal helpers like _internal_set_foo();

hokein wrote:

There is a FIXME on L68 (cannot make a comment on the unmodified line in 
GitHub), it is probably stale, just removing it?

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


[clang-tools-extra] [clangd] Improve filtering logic for undesired proto symbols (PR #110091)

2024-09-30 Thread Haojian Wu via cfe-commits

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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 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,libcxxabi` at 
step 5 "ninja check 1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/clang 
-cc1 -internal-isystem 
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple aarch64-unknown-linux-gnu 
-o - 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/FileCheck 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
+ /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/clang -cc1 
-internal-isystem 
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple aarch64-unknown-linux-gnu 
-o - 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/FileCheck 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/FileCheck 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`llvm-clang-x86_64-gcc-ubuntu` running on `sie-linux-worker3` while building 
`clang,libcxxabi` at step 6 "test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang -cc1 
-internal-isystem 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-cc1 -internal-isystem 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 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,libcxxabi` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -cc1 
-internal-isystem /b/1/clang-x86_64-debian-fast/llvm.obj/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
-fclang-abi-compat=latest | 
/b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -cc1 -internal-isystem 
/b/1/clang-x86_64-debian-fast/llvm.obj/lib/clang/20/include -nostdsysteminc 
-verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu -o - 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
-fclang-abi-compat=latest
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 39: redefinition of 'h'
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 38: default template argument not permitted on a friend template
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 45: redefinition of 'j'
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 44: default template argument not permitted on a friend template
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 51: redefinition of 'l'
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 55: in instantiation of template class 'test2::A' requested here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 39: previous definition is here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 45: previous definition is here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp 
Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 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,libcxxabi` at step 6 
"test-build-unified-tree-check-clang".

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


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

```
Step 6 (test-build-unified-tree-check-clang) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 
-internal-isystem /b/1/llvm-x86_64-debian-dylib/build/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 -internal-isystem 
/b/1/llvm-x86_64-debian-dylib/build/lib/clang/20/include -nostdsysteminc 
-verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu -o - 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `arc-builder` running on 
`arc-worker` while building `clang,libcxxabi` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /buildbot/worker/arc-folder/build/bin/clang -cc1 
-internal-isystem /buildbot/worker/arc-folder/build/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | /buildbot/worker/arc-folder/build/bin/FileCheck 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem 
/buildbot/worker/arc-folder/build/lib/clang/20/include -nostdsysteminc -verify 
-std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu -o - 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ /buildbot/worker/arc-folder/build/bin/FileCheck 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  /buildbot/worker/arc-folder/build/bin/FileCheck 
/buildbot/worker/arc-folder/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-cmake-x86_64-avx512-linux` running on `avx512-intel64` while building 
`clang,libcxxabi` at step 7 "ninja check 1".

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


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

```
Step 7 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang
 -cc1 -internal-isystem 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck
 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
+ 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang
 -cc1 -internal-isystem 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck
 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck
 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang,libcxxabi` at step 7 
"test-build-unified-tree-check-all".

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2 instruction (PR #97602)

2024-09-30 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/97602

>From ac405d7516ea92cf3c63220d1bdf0677dd7dd372 Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Wed, 3 Jul 2024 15:55:45 +
Subject: [PATCH 1/7] [Clang][LLVM][AArch64] Add intrinsic for MOVT SME2
 instruction

This patch adds these intrinsics:

  // Variants are also available for:
  // [_s8], [_u16], [_s16], [_u32], [_s32], [_u64], [_s64]
  // [_bf16], [_f16], [_f32], [_f64]
  void svwrite_lane_zt[_u8](uint64_t zt0, svuint8_t zt, uint64_t idx) 
__arm_streaming __arm_inout("zt0");
  void svwrite_zt[_u8](uint64_t zt0, svuint8_t zt) __arm_streaming 
__arm_inout("zt0");

according to PR#324[1]
[1]https://github.com/ARM-software/acle/pull/324
---
 clang/include/clang/Basic/arm_sme.td  |   6 +
 .../acle_sme2_write_lane_zt.c | 401 ++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  15 +-
 llvm/include/llvm/IR/IntrinsicsAArch64.td |   9 +
 .../Target/AArch64/AArch64ISelLowering.cpp|   2 +
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |   2 +-
 llvm/lib/Target/AArch64/SMEInstrFormats.td|  42 +-
 .../AArch64/sme2-intrinsics-read-zt.ll| 162 +++
 8 files changed, 636 insertions(+), 3 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-read-zt.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ae6b55e98827ff..52997f67b5cd9f 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -817,4 +817,10 @@ multiclass ZAReadzArray{
 
 defm SVREADZ_VG2 :  ZAReadzArray<"2">;
 defm SVREADZ_VG4 :  ZAReadzArray<"4">;
+
+let SMETargetGuard = "sme2,sme-lutv2" in {
+  def SVLUTI4_ZT_X4 : SInst<"svluti4_zt_{d}_x4", "4i2.u", "cUc", MergeNone, 
"aarch64_sme_luti4_zt_x4", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>]>;
+  def SVWRITE_LANE_ZT : SInst<"svwrite_lane_zt[_{d}]", "vidi", 
"cUcsUsiUilUlfhdb", MergeNone, "aarch64_sme_write_lane_zt", [IsStreaming, 
IsInOutZT0], [ImmCheck<0, ImmCheck0_0>, ImmCheck<2, ImmCheck0_3>]>;
+  def SVWRITE_ZT : SInst<"svwrite_zt[_{d}]", "vid", "cUcsUsiUilUlfhdb", 
MergeNone, "aarch64_sme_write_zt", [IsStreaming, IsInOutZT0], [ImmCheck<0, 
ImmCheck0_0>]>;
+}
 } // let SVETargetGuard = InvalidMode
diff --git 
a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
new file mode 100644
index 00..9bdc3481953a21
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_write_lane_zt.c
@@ -0,0 +1,401 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 
-Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -x c++  -triple aarch64-none-linux-gnu -target-feature 
+bf16 -target-feature +sme -target-feature +sme2 -target-feature  +sme-lutv2  
-O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-CXX
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS   -triple aarch64-none-linux-gnu 
-target-feature +bf16 -target-feature +sme -target-feature +sme2 
-target-feature  +sme-lutv2  -O2 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -x c++  -triple 
aarch64-none-linux-gnu -target-feature +bf16 -target-feature +sme 
-target-feature +sme2 -target-feature +sme-lutv2 -O2 -Werror -Wall -emit-llvm 
-o - %s | FileCheck %s -check-prefix CHECK-CXX
+
+// RUN: %clang_cc1  -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 -O2 -S 
-Werror -Wall -o /dev/null %s
+// REQUIRES: aarch64-registered-target
+
+#ifdef SVE_OVERLOADED_FORMS
+#define SVE_ACLE_FUNC(A1,A2_UNUSED) A1
+#else
+#define SVE_ACLE_FUNC(A1,A2) A1##A2
+#endif
+
+#include 
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_u8_1(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:tail call void @llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 
0,  [[V]], i32 1)
+// CHECK-NEXT:ret void
+//
+// CHECK-CXX-LABEL: define dso_local void 
@_Z23test_write_lane_zt_u8_1u11__SVUint8_t(
+// CHECK-CXX-SAME:  [[V:%.*]]) local_unnamed_addr 
#[[ATTR0:[0-9]+]] {
+// CHECK-CXX-NEXT:  [[ENTRY:.*:]]
+// CHECK-CXX-NEXT:tail call void 
@llvm.aarch64.sme.write.lane.zt.nxv16i8(i32 0,  [[V]], i32 1)
+// CHECK-CXX-NEXT:ret void
+//
+void test_write_lane_zt_u8_1(svuint8_t v) __arm_streaming __arm_inout("zt0") {
+  SVE_ACLE_FUNC(svwrite_lane_zt, _u8)(0, v, 1);
+}
+
+// CHECK-LABEL: define dso_local void @test_write_lane_zt_s8_2(
+// CHECK-SAME:  [[V:%.*]]) local_unnamed_addr #[[ATTR0]] {
+// CHECK-NEXT:  [

[clang] [llvm] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2 instruction (#97755) (PR #109953)

2024-09-30 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/109953

>From bef293187f32e4e197035eda299f73a5fd8f8684 Mon Sep 17 00:00:00 2001
From: CarolineConcatto 
Date: Wed, 25 Sep 2024 09:53:23 +0100
Subject: [PATCH 1/3] [Clang][LLVM][AArch64] Add intrinsic for LUTI4 SME2
 instruction (#97755)

This patch was reverted because of a failing C test.
It now has being solved and can be merged into main again

This patch adds these intrinsics:

// Variants are also available for: _s8
svuint8x4_t svluti4_zt_u8_x4(uint64_t zt0, svuint8x2_t zn)
__arm_streaming __arm_in("zt0");

according to PR#324[1]
[1]ARM-software/acle#324

OBS.: Fix the clang test  run line

Address comments about the functions SelectMultiVectorLuti
---
 clang/include/clang/Basic/arm_sme.td  |  5 ++
 .../acle_sme2_luti4_zt.c  | 86 +++
 .../aarch64-sme2-intrinsics/acle_sme2_imm.cpp |  5 ++
 llvm/include/llvm/IR/IntrinsicsAArch64.td |  6 ++
 .../Target/AArch64/AArch64ISelDAGToDAG.cpp| 54 ++--
 .../lib/Target/AArch64/AArch64SMEInstrInfo.td |  2 +-
 .../CodeGen/AArch64/sme2-intrinsics-luti4.ll  | 17 
 7 files changed, 165 insertions(+), 10 deletions(-)
 create mode 100644 
clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
 create mode 100644 llvm/test/CodeGen/AArch64/sme2-intrinsics-luti4.ll

diff --git a/clang/include/clang/Basic/arm_sme.td 
b/clang/include/clang/Basic/arm_sme.td
index ae6b55e98827ff..9c9f31f3884069 100644
--- a/clang/include/clang/Basic/arm_sme.td
+++ b/clang/include/clang/Basic/arm_sme.td
@@ -817,4 +817,9 @@ multiclass ZAReadzArray{
 
 defm SVREADZ_VG2 :  ZAReadzArray<"2">;
 defm SVREADZ_VG4 :  ZAReadzArray<"4">;
+
+let SMETargetGuard = "sme2,sme-lutv2" in {
+  def SVLUTI4_ZT_X4 : SInst<"svluti4_zt_{d}_x4", "4i2.u", "cUc", MergeNone, 
"aarch64_sme_luti4_zt_x4", [IsStreaming, IsInZT0], [ImmCheck<0, ImmCheck0_0>]>;
+}
+
 } // let SVETargetGuard = InvalidMode
diff --git a/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c 
b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
new file mode 100644
index 00..fc4b6fa299f90f
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_luti4_zt.c
@@ -0,0 +1,86 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
+
+// REQUIRES: aarch64-registered-target
+
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 
-disable-O0-optnone -Werror -Wall -emit-llvm -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +bf16 
-target-feature +sme -target-feature +sme2 -target-feature +sme-lutv2 
-disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+
+#include 
+
+// CHECK-LABEL: define dso_local { , , 
,  } @test_luti4_zt_u8_x4(
+// CHECK-SAME:  [[OP_COERCE0:%.*]],  
[[OP_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca { , , ,  }, align 16
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { , , ,  } 
@llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0,  [[OP_COERCE0]], 
 [[OP_COERCE1]])
+// CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , , ,  } [[TMP0]], 0
+// CHECK-NEXT:[[TMP2:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( poison,  [[TMP1]], i64 0)
+// CHECK-NEXT:[[TMP3:%.*]] = extractvalue { , , ,  } [[TMP0]], 1
+// CHECK-NEXT:[[TMP4:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP2]],  [[TMP3]], i64 16)
+// CHECK-NEXT:[[TMP5:%.*]] = extractvalue { , , ,  } [[TMP0]], 2
+// CHECK-NEXT:[[TMP6:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP4]],  [[TMP5]], i64 32)
+// CHECK-NEXT:[[TMP7:%.*]] = extractvalue { , , ,  } [[TMP0]], 3
+// CHECK-NEXT:[[TMP8:%.*]] = tail call  
@llvm.vector.insert.nxv64i8.nxv16i8( [[TMP6]],  [[TMP7]], i64 48)
+// CHECK-NEXT:store  [[TMP8]], ptr [[RETVAL]], align 16
+// CHECK-NEXT:[[TMP9:%.*]] = load { , , ,  }, ptr [[RETVAL]], align 16
+// CHECK-NEXT:ret { , , ,  } [[TMP9]]
+//
+// CPP-CHECK-LABEL: define dso_local { , , 
,  } @_Z19test_luti4_zt_u8_x411svuint8x2_t(
+// CPP-CHECK-SAME:  [[OP_COERCE0:%.*]],  
[[OP_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] {
+// CPP-CHECK-NEXT:  [[ENTRY:.*:]]
+// CPP-CHECK-NEXT:[[RETVAL:%.*]] = alloca { , , ,  }, align 16
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call { , , ,  } 
@llvm.aarch64.sme.luti4.zt.x4.nxv16i8(i32 0,  [[OP_COERCE0]], 
 [[OP_COERCE1]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = extractvalue { , 
, ,  } [[TMP0]], 0
+// CPP-CHECK-NEXT:[[TMP2:%.*]] = t

[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/clang 
-cc1 -internal-isystem 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple 
armv8l-unknown-linux-gnueabihf -o - 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/FileCheck 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
+ /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/FileCheck 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
+ /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/clang -cc1 
-internal-isystem 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple 
armv8l-unknown-linux-gnueabihf -o - 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/FileCheck 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-x86_64-sie-win` 
running on `sie-win-worker` while building `clang,libcxxabi` at step 7 
"test-build-unified-tree-check-all".

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stdout):
--
# RUN: at line 1
z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe -cc1 -internal-isystem 
Z:\b\llvm-clang-x86_64-sie-win\build\lib\clang\20\include -nostdsysteminc 
-verify -std=c++20 -emit-llvm -triple x86_64-sie-ps5 -o - 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 -fclang-abi-compat=latest | 
z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe' -cc1 
-internal-isystem 'Z:\b\llvm-clang-x86_64-sie-win\build\lib\clang\20\include' 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-sie-ps5 -o - 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp'
 -fclang-abi-compat=latest
# .---command stderr
# | error: 'expected-error' diagnostics seen but not expected: 
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 39: redefinition of 'h'
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 45: redefinition of 'j'
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 51: redefinition of 'l'
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
# | error: 'expected-note' diagnostics seen but not expected: 
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 39: previous definition is here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 45: previous definition is here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
 Line 51: previous definition is here
# | 10 errors generated.
# `-
# error: command failed with exit status: 1
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe' 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp'
# .---command stderr
# | FileCheck error: '' is empty.
# | FileCheck command line:  
z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\CodeGenCXX\mangle-concept.cpp
# `-
# error: command failed with exit status: 2

--




```



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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` 
running on `doug-worker-5` while building `clang,libcxxabi` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-cc1 -internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple arm64-apple-darwin23.6.0 
-o - 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple arm64-apple-darwin23.6.0 
-o - 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [llvm] [ARM] Fix musttail calls (PR #109943)

2024-09-30 Thread Oliver Stannard via cfe-commits

https://github.com/ostannard updated 
https://github.com/llvm/llvm-project/pull/109943

>From 298ea9851435433c24f9ae516ff4fe03ba19521c Mon Sep 17 00:00:00 2001
From: Oliver Stannard 
Date: Thu, 9 May 2024 12:58:41 +0100
Subject: [PATCH 1/9] [ARM] Re-generate a test

---
 llvm/test/CodeGen/ARM/fp-arg-shuffle.ll | 24 
 1 file changed, 24 insertions(+)

diff --git a/llvm/test/CodeGen/ARM/fp-arg-shuffle.ll 
b/llvm/test/CodeGen/ARM/fp-arg-shuffle.ll
index 4996cc8ecbf022..36f5a4b30af409 100644
--- a/llvm/test/CodeGen/ARM/fp-arg-shuffle.ll
+++ b/llvm/test/CodeGen/ARM/fp-arg-shuffle.ll
@@ -1,8 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
 ; RUN: llc -mtriple=arm-eabi -mattr=+neon -float-abi=soft %s -o - | FileCheck 
%s
 
 ; CHECK: function1
 ; CHECK-NOT: vmov
 define double @function1(double %a, double %b, double %c, double %d, double 
%e, double %f) nounwind noinline ssp {
+; CHECK-LABEL: function1:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:.save {r4, r5, r11, lr}
+; CHECK-NEXT:push {r4, r5, r11, lr}
+; CHECK-NEXT:.pad #32
+; CHECK-NEXT:sub sp, sp, #32
+; CHECK-NEXT:add lr, sp, #64
+; CHECK-NEXT:vldr d16, [sp, #56]
+; CHECK-NEXT:str r2, [sp, #16]
+; CHECK-NEXT:ldm lr, {r4, r5, r12, lr}
+; CHECK-NEXT:str r3, [sp, #20]
+; CHECK-NEXT:mov r3, r5
+; CHECK-NEXT:str r0, [sp, #24]
+; CHECK-NEXT:mov r0, r12
+; CHECK-NEXT:str r1, [sp, #28]
+; CHECK-NEXT:mov r1, lr
+; CHECK-NEXT:mov r2, r4
+; CHECK-NEXT:vldr d17, [sp, #48]
+; CHECK-NEXT:vstmia sp, {d16, d17}
+; CHECK-NEXT:bl function2
+; CHECK-NEXT:add sp, sp, #32
+; CHECK-NEXT:pop {r4, r5, r11, lr}
+; CHECK-NEXT:mov pc, lr
 entry:
   %call = tail call double @function2(double %f, double %e, double %d, double 
%c, double %b, double %a) nounwind
   ret double %call

>From 6655a8d08ce72abff9412131ecfb888f697075c9 Mon Sep 17 00:00:00 2001
From: Oliver Stannard 
Date: Tue, 24 Sep 2024 10:46:47 +0100
Subject: [PATCH 2/9] [ARM] Fix comment typo

---
 llvm/lib/Target/ARM/ARMISelLowering.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 1733424a8b669f..673cd57b45a96b 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -2408,8 +2408,8 @@ 
ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 isTailCall = false;
 
   // For both the non-secure calls and the returns from a CMSE entry function,
-  // the function needs to do some extra work afte r the call, or before the
-  // return, respectively, thus it cannot end with atail call
+  // the function needs to do some extra work after the call, or before the
+  // return, respectively, thus it cannot end with a tail call
   if (isCmseNSCall || AFI->isCmseNSEntryFunction())
 isTailCall = false;
 

>From 29e76182969fd23bac570179e69a503f123df41d Mon Sep 17 00:00:00 2001
From: Oliver Stannard 
Date: Thu, 9 May 2024 13:00:46 +0100
Subject: [PATCH 3/9] [ARM] Add debug trace for tail-call optimisation

There are lots of reasons a call might not be eligible for tail-call
optimisation, this adds debug trace to help understand the compiler's
decisions here.
---
 llvm/lib/Target/ARM/ARMISelLowering.cpp | 64 +++--
 1 file changed, 49 insertions(+), 15 deletions(-)

diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 673cd57b45a96b..078a12246c2e08 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -3047,8 +3047,10 @@ bool 
ARMTargetLowering::IsEligibleForTailCallOptimization(
 for (const CCValAssign &AL : ArgLocs)
   if (AL.isRegLoc())
 AddressRegisters.erase(AL.getLocReg());
-if (AddressRegisters.empty())
+if (AddressRegisters.empty()) {
+  LLVM_DEBUG(dbgs() << "false (no reg to hold function pointer)\n");
   return false;
+}
   }
 
   // Look for obvious safe cases to perform tail call optimization that do not
@@ -3057,18 +3059,26 @@ bool 
ARMTargetLowering::IsEligibleForTailCallOptimization(
   // Exception-handling functions need a special set of instructions to 
indicate
   // a return to the hardware. Tail-calling another function would probably
   // break this.
-  if (CallerF.hasFnAttribute("interrupt"))
+  if (CallerF.hasFnAttribute("interrupt")) {
+LLVM_DEBUG(dbgs() << "false (interrupt attribute)\n");
 return false;
+  }
 
-  if (canGuaranteeTCO(CalleeCC, 
getTargetMachine().Options.GuaranteedTailCallOpt))
+  if (canGuaranteeTCO(CalleeCC,
+  getTargetMachine().Options.GuaranteedTailCallOpt)) {
+LLVM_DEBUG(dbgs() << (CalleeCC == CallerCC ? "true" : "false")
+  << " (guaranteed tail-call CC)\n");
 return CalleeCC == CallerCC;
+  }
 
   // Also avoid sibcall optimizatio

[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-a-1` while building `clang,libcxxabi` 
at step 4 "annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[1325/1327] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests
[1326/1327] Running the Clang regression tests
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using clang: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/clang
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126:
 note: Did not find clang-repl in 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/ld.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/lld-link
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/ld64.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/wasm-ld
-- Testing: 21274 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 
FAIL: Clang :: CodeGenCXX/mangle-concept.cpp (8697 of 21274)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/clang -cc1 
-internal-isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/clang 
-cc1 -internal-isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-8ofqkhlk/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/

[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread Richard Smith via cfe-commits

zygoloid wrote:

Should this have `-fclang-abi-compat` support?

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


[clang] [clang][bytecode] Remove superfluous check from fixed-point div (PR #110478)

2024-09-30 Thread Timm Baeder via cfe-commits

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

We shouldn't do this check for fixed-point values, at least the current 
interpreter doesn't do it.

>From 2be9e0aa010451324cd3a1e873fb8640535823d7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Mon, 30 Sep 2024 11:39:57 +0200
Subject: [PATCH] [clang][bytecode] Remove superfluous check from fixed-point
 div

We shouldn't do this check for fixed-point values, at least the current
interpreter doesn't do it.
---
 clang/lib/AST/ByteCode/Interp.h | 18 ++
 clang/test/Frontend/fixed_point_div_const.c |  3 +++
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 68c04587a4919e..8a3c6810e0e11b 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -235,14 +235,16 @@ bool CheckDivRem(InterpState &S, CodePtr OpPC, const T 
&LHS, const T &RHS) {
 return false;
   }
 
-  if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) {
-APSInt LHSInt = LHS.toAPSInt();
-SmallString<32> Trunc;
-(-LHSInt.extend(LHSInt.getBitWidth() + 1)).toString(Trunc, 10);
-const SourceInfo &Loc = S.Current->getSource(OpPC);
-const Expr *E = S.Current->getExpr(OpPC);
-S.CCEDiag(Loc, diag::note_constexpr_overflow) << Trunc << E->getType();
-return false;
+  if constexpr (!std::is_same_v) {
+if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) 
{
+  APSInt LHSInt = LHS.toAPSInt();
+  SmallString<32> Trunc;
+  (-LHSInt.extend(LHSInt.getBitWidth() + 1)).toString(Trunc, 10);
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  const Expr *E = S.Current->getExpr(OpPC);
+  S.CCEDiag(Loc, diag::note_constexpr_overflow) << Trunc << E->getType();
+  return false;
+}
   }
   return true;
 }
diff --git a/clang/test/Frontend/fixed_point_div_const.c 
b/clang/test/Frontend/fixed_point_div_const.c
index 46935207d186a8..66c028e608db60 100644
--- a/clang/test/Frontend/fixed_point_div_const.c
+++ b/clang/test/Frontend/fixed_point_div_const.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
 
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - -fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
+
 // Division between different fixed point types
 short _Accum sa_const = 1.0hk / 2.0hk;
 // CHECK-DAG: @sa_const  = {{.*}}global i16 64, align 2

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


[clang] [clang][bytecode] Remove superfluous check from fixed-point div (PR #110478)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

We shouldn't do this check for fixed-point values, at least the current 
interpreter doesn't do it.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.h (+10-8) 
- (modified) clang/test/Frontend/fixed_point_div_const.c (+3) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 68c04587a4919e..8a3c6810e0e11b 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -235,14 +235,16 @@ bool CheckDivRem(InterpState &S, CodePtr OpPC, const T 
&LHS, const T &RHS) {
 return false;
   }
 
-  if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) {
-APSInt LHSInt = LHS.toAPSInt();
-SmallString<32> Trunc;
-(-LHSInt.extend(LHSInt.getBitWidth() + 1)).toString(Trunc, 10);
-const SourceInfo &Loc = S.Current->getSource(OpPC);
-const Expr *E = S.Current->getExpr(OpPC);
-S.CCEDiag(Loc, diag::note_constexpr_overflow) << Trunc << E->getType();
-return false;
+  if constexpr (!std::is_same_v) {
+if (LHS.isSigned() && LHS.isMin() && RHS.isNegative() && RHS.isMinusOne()) 
{
+  APSInt LHSInt = LHS.toAPSInt();
+  SmallString<32> Trunc;
+  (-LHSInt.extend(LHSInt.getBitWidth() + 1)).toString(Trunc, 10);
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  const Expr *E = S.Current->getExpr(OpPC);
+  S.CCEDiag(Loc, diag::note_constexpr_overflow) << Trunc << E->getType();
+  return false;
+}
   }
   return true;
 }
diff --git a/clang/test/Frontend/fixed_point_div_const.c 
b/clang/test/Frontend/fixed_point_div_const.c
index 46935207d186a8..66c028e608db60 100644
--- a/clang/test/Frontend/fixed_point_div_const.c
+++ b/clang/test/Frontend/fixed_point_div_const.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
 
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - -fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,UNSIGNED
+
 // Division between different fixed point types
 short _Accum sa_const = 1.0hk / 2.0hk;
 // CHECK-DAG: @sa_const  = {{.*}}global i16 64, align 2

``




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


[libclc] 9f3728d - [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (#109926)

2024-09-30 Thread via cfe-commits

Author: Fraser Cormack
Date: 2024-09-30T10:48:30+01:00
New Revision: 9f3728d15721830ef1d29a8ae1af97124bc26b47

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

LOG: [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (#109926)

The `ARCHIVE` artifact kind is not valid for `install(FILES ...)`.

Additionally, install wasn't resolving the target's `TARGET_FILE`
properly and was trying to find it in the top-level build directory, rather than
in the libclc binary directory. This is because our `TARGET_FILE`
properties were being set to relative paths. The cmake behaviour they
are trying to mimic - `$` - provides an absolute path.

As such this patch updates instances where we set the `TARGET_FILE`
property to return an absolute path.

Added: 


Modified: 
libclc/CMakeLists.txt
libclc/cmake/modules/AddLibclc.cmake

Removed: 




diff  --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 1bf7eb2ca7ed7e..260e4d433a1d49 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -221,8 +221,10 @@ if( ENABLE_RUNTIME_SUBNORMAL )
TARGET ${file}
INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/generic/lib/${file}.ll
 )
-install( FILES $ ARCHIVE
-  DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
+install(
+  FILES $
+  DESTINATION "${CMAKE_INSTALL_DATADIR}/clc"
+)
   endforeach()
 endif()
 
@@ -426,9 +428,9 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
   add_custom_target( ${builtins_opt_lib_tgt}
 ALL DEPENDS ${builtins_opt_lib_tgt}.bc
   )
-  set_target_properties( ${builtins_opt_lib_tgt}
-PROPERTIES TARGET_FILE ${builtins_opt_lib_tgt}.bc
-   FOLDER "libclc/Device IR/Opt"
+  set_target_properties( ${builtins_opt_lib_tgt} PROPERTIES
+TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${builtins_opt_lib_tgt}.bc
+FOLDER "libclc/Device IR/Opt"
   )
 
   set( builtins_opt_lib 
$ )

diff  --git a/libclc/cmake/modules/AddLibclc.cmake 
b/libclc/cmake/modules/AddLibclc.cmake
index 839815d8cc6fff..f2032660ba99b0 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -113,7 +113,7 @@ function(link_bc)
 
   add_custom_target( ${ARG_TARGET} ALL DEPENDS ${ARG_TARGET}.bc )
   set_target_properties( ${ARG_TARGET} PROPERTIES
-TARGET_FILE ${ARG_TARGET}.bc
+TARGET_FILE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET}.bc
 FOLDER "libclc/Device IR/Linking"
   )
 endfunction()



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


[clang] [HLSL] Use HLSLToolChain for Vulkan (PR #110306)

2024-09-30 Thread Nathan Gauër via cfe-commits

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


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


[clang] [analyzer] Suppress out of bounds reports after weak loop assumptions (PR #109804)

2024-09-30 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 



@@ -323,12 +342,13 @@ class ExprEngine {
 
   /// ProcessBranch - Called by CoreEngine.  Used to generate successor
   ///  nodes by processing the 'effects' of a branch condition.
-  void processBranch(const Stmt *Condition,
- NodeBuilderContext& BuilderCtx,
- ExplodedNode *Pred,
- ExplodedNodeSet &Dst,
- const CFGBlock *DstT,
- const CFGBlock *DstF);
+  /// If the branch condition is a loop condition, IterationsFinishedInLoop is
+  /// the number of already finished iterations (0, 1, 2...); otherwise it's
+  /// std::nullopt.

isuckatcs wrote:

> We could introduce it, but we'd need to maintain a nested stack of loops (1 
> iteration in that while, then 2 iterations in the for, then 1 iteration in 
> this other for in the function called there...) to correctly monitor the 
> number of iterations.

You can bind the current iteration number to the AST node of the loop, as it 
happens with nested `ArrayInitLoopExpr` IIRC. I'm sure we already have 
something similar implemented.

I'd prefer using state traits here instead of modifying the engine API.



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


[libclc] [libclc] Fix installation w/ ENABLE_RUNTIME_SUBNORMAL (PR #109926)

2024-09-30 Thread Fraser Cormack via cfe-commits

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


[clang] dc6e480 - [clang][bytecode] Cast fixed-point cmp result to int if necessary (#110469)

2024-09-30 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-30T12:01:10+02:00
New Revision: dc6e4805a0a563052c0c8d81628718fcd6acb193

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

LOG: [clang][bytecode] Cast fixed-point cmp result to int if necessary (#110469)

This is the case in C.

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/Frontend/fixed_point_comparisons.c

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c24c4b6db2a5bf..5ad5899739909f 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1542,19 +1542,30 @@ bool Compiler::VisitFixedPointBinOp(const 
BinaryOperator *E) {
 return true;
   };
 
+  auto MaybeCastToBool = [&](bool Result) {
+if (!Result)
+  return false;
+PrimType T = classifyPrim(E);
+if (DiscardResult)
+  return this->emitPop(T, E);
+if (T != PT_Bool)
+  return this->emitCast(PT_Bool, T, E);
+return true;
+  };
+
   switch (E->getOpcode()) {
   case BO_EQ:
-return this->emitEQFixedPoint(E);
+return MaybeCastToBool(this->emitEQFixedPoint(E));
   case BO_NE:
-return this->emitNEFixedPoint(E);
+return MaybeCastToBool(this->emitNEFixedPoint(E));
   case BO_LT:
-return this->emitLTFixedPoint(E);
+return MaybeCastToBool(this->emitLTFixedPoint(E));
   case BO_LE:
-return this->emitLEFixedPoint(E);
+return MaybeCastToBool(this->emitLEFixedPoint(E));
   case BO_GT:
-return this->emitGTFixedPoint(E);
+return MaybeCastToBool(this->emitGTFixedPoint(E));
   case BO_GE:
-return this->emitGEFixedPoint(E);
+return MaybeCastToBool(this->emitGEFixedPoint(E));
   case BO_Add:
 return ConvertResult(this->emitAddFixedPoint(E));
   case BO_Sub:

diff  --git a/clang/test/Frontend/fixed_point_comparisons.c 
b/clang/test/Frontend/fixed_point_comparisons.c
index 59c4405e41c031..39e62bce51e2b2 100644
--- a/clang/test/Frontend/fixed_point_comparisons.c
+++ b/clang/test/Frontend/fixed_point_comparisons.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - | FileCheck %s --check-prefixes=CHECK,UNPADDED
 // RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s 
--check-prefixes=CHECK,PADDED
 
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm 
%s -o - -fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,UNPADDED
+// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu 
-fpadding-on-unsigned-fixed-point -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s 
--check-prefixes=CHECK,PADDED
+
 // Fixed point against other fixed point
 _Bool b_eq_true = 2.5hk == 2.5uhk;  // CHECK-DAG: @b_eq_true  = {{.*}}global 
i8 1, align 1
 _Bool b_eq_false = 2.5hk == 2.4uhk; // CHECK-DAG: @b_eq_false = {{.*}}global 
i8 0, align 1



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


[clang] [clang][bytecode] Cast fixed-point cmp result to int if necessary (PR #110469)

2024-09-30 Thread Timm Baeder via cfe-commits

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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread Haojian Wu via cfe-commits

hokein wrote:

> Should this have -fclang-abi-compat support?

(It seems like we should, although I don’t have direct experience with it.)

This is a bug fix for 
https://github.com/llvm/llvm-project/commit/4b163e343cfa54c8d55c9da73c70d58f55ea9df2,
 which is released in Clang 18 and Clang 19. Therefore, we should likely add 
-fclang-abi-compat for `Ver19`?

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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-fast` running on `sanitizer-buildbot4` while building 
`clang,libcxxabi` at step 2 "annotate".

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


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-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: 
/home/b/sanitizer-x86_64-linux-fast/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: 85930 of 85931 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 
FAIL: Clang :: CodeGenCXX/mangle-concept.cpp (24954 of 85930)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang -cc1 
-internal-isystem 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang 
-cc1 -internal-isystem 
/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39

[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-09-30 Thread Donát Nagy via cfe-commits

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


[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-09-30 Thread Donát Nagy via cfe-commits


@@ -43,6 +43,12 @@ void FixedAddressChecker::checkPreStmt(const BinaryOperator 
*B,
   if (!T->isPointerType())
 return;
 
+  // Omit warning if the RHS has already pointer type.
+  // The value may come from a variable and is candidate for a previous warning
+  // from the checker.

NagyDonat wrote:

```suggestion
  // Omit warning if the RHS has already pointer type. Without this passing
  // around one fixed value in several pointer variables would produce several
  // redundant warnings.
```

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


[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-09-30 Thread Donát Nagy via cfe-commits

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

Looks good to me, nice little improvement :)

I reworded a comment in an inline suggestion because I felt that it was a bit 
difficult to understand; but feel free to change it further if you'd prefer.

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


[clang] 93eaa99 - [abi] [ItaniumMangle] Remove a test case that fails due to expected r… (#110467)

2024-09-30 Thread via cfe-commits

Author: Viktoriia Bakalova
Date: 2024-09-30T10:40:57+02:00
New Revision: 93eaa992896d74eddaf51e8e2601fabc41a1e316

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

LOG: [abi] [ItaniumMangle] Remove a test case that fails due to expected r… 
(#110467)

…edefinition failures.

Added: 


Modified: 
clang/test/CodeGenCXX/mangle-concept.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/mangle-concept.cpp 
b/clang/test/CodeGenCXX/mangle-concept.cpp
index 966117544bfec1..6053511c00a7b5 100644
--- a/clang/test/CodeGenCXX/mangle-concept.cpp
+++ b/clang/test/CodeGenCXX/mangle-concept.cpp
@@ -52,7 +52,6 @@ namespace test2 {
   };
 
   A ai;
-  A aj;
 
   // CHECK-LABEL: define {{.*}}@{{.*}}test2{{.*}}use
   void use() {
@@ -77,28 +76,6 @@ namespace test2 {
 // CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
 // CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
 l(ai);
-
-// CHECK: call {{.*}}@_ZN5test21AIbEF1fEzQ4TrueIT_E(
-// CLANG17: call {{.*}}@_ZN5test21fEz(
-f(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
-// CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
-g(aj);
-// CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
-// CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
-h(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
-i(aj);
-// CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
-j(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1kITk4TruevQ4TrueIT_EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
-k(aj);
-// CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
-// CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
-l(aj);
   }
 }
 



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


[clang] [abi] [ItaniumMangle] Remove a test case that fails due to expected r… (PR #110467)

2024-09-30 Thread Viktoriia Bakalova via cfe-commits

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


[clang] [abi] [ItaniumMangle] Remove a test case that fails due to expected r… (PR #110467)

2024-09-30 Thread Viktoriia Bakalova via cfe-commits

https://github.com/VitaNuo created 
https://github.com/llvm/llvm-project/pull/110467

…edefinition failures.

>From 1557e3b9d672bb1f2fce745d664c039d578e5d0c Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova 
Date: Mon, 30 Sep 2024 08:39:48 +
Subject: [PATCH] [abi] [ItaniumMangle] Remove a test case that fails due to
 expected redefinition failures.

---
 clang/test/CodeGenCXX/mangle-concept.cpp | 23 ---
 1 file changed, 23 deletions(-)

diff --git a/clang/test/CodeGenCXX/mangle-concept.cpp 
b/clang/test/CodeGenCXX/mangle-concept.cpp
index 966117544bfec1..6053511c00a7b5 100644
--- a/clang/test/CodeGenCXX/mangle-concept.cpp
+++ b/clang/test/CodeGenCXX/mangle-concept.cpp
@@ -52,7 +52,6 @@ namespace test2 {
   };
 
   A ai;
-  A aj;
 
   // CHECK-LABEL: define {{.*}}@{{.*}}test2{{.*}}use
   void use() {
@@ -77,28 +76,6 @@ namespace test2 {
 // CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
 // CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
 l(ai);
-
-// CHECK: call {{.*}}@_ZN5test21AIbEF1fEzQ4TrueIT_E(
-// CLANG17: call {{.*}}@_ZN5test21fEz(
-f(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
-// CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
-g(aj);
-// CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
-// CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
-h(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
-i(aj);
-// CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
-j(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1kITk4TruevQ4TrueIT_EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
-k(aj);
-// CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
-// CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
-l(aj);
   }
 }
 

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


[clang] [abi] [ItaniumMangle] Remove a test case that fails due to expected r… (PR #110467)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Viktoriia Bakalova (VitaNuo)


Changes

…edefinition failures.

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


1 Files Affected:

- (modified) clang/test/CodeGenCXX/mangle-concept.cpp (-23) 


``diff
diff --git a/clang/test/CodeGenCXX/mangle-concept.cpp 
b/clang/test/CodeGenCXX/mangle-concept.cpp
index 966117544bfec1..6053511c00a7b5 100644
--- a/clang/test/CodeGenCXX/mangle-concept.cpp
+++ b/clang/test/CodeGenCXX/mangle-concept.cpp
@@ -52,7 +52,6 @@ namespace test2 {
   };
 
   A ai;
-  A aj;
 
   // CHECK-LABEL: define {{.*}}@{{.*}}test2{{.*}}use
   void use() {
@@ -77,28 +76,6 @@ namespace test2 {
 // CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
 // CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
 l(ai);
-
-// CHECK: call {{.*}}@_ZN5test21AIbEF1fEzQ4TrueIT_E(
-// CLANG17: call {{.*}}@_ZN5test21fEz(
-f(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
-// CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
-g(aj);
-// CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
-// CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
-h(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
-i(aj);
-// CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
-j(aj);
-// CHECK: call {{.*}}@_ZN5test21AIbEF1kITk4TruevQ4TrueIT_EEEvz(
-// CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
-k(aj);
-// CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
-// CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
-l(aj);
   }
 }
 

``




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


[clang] [llvm] [ARM] Fix musttail calls (PR #109943)

2024-09-30 Thread Oliver Stannard via cfe-commits

ostannard wrote:

The libc++ test failures look unrelated, rebased onto current main to check.

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


[clang] [clang] Fix static analyzer concerns (PR #110243)

2024-09-30 Thread Mariya Podchishchaeva via cfe-commits

https://github.com/Fznamznon updated 
https://github.com/llvm/llvm-project/pull/110243

>From 314a8f4d4f8e003881bed0c320f9ee80ba0b8f8c Mon Sep 17 00:00:00 2001
From: "Podchishchaeva, Mariya" 
Date: Fri, 27 Sep 2024 04:00:31 -0700
Subject: [PATCH] [clang] Fix static analyzer concerns

It seems in checkOpenMPIterationSpace `OrderedLoopCountExpr` can also be
null, so check before dereferencing.
---
 clang/lib/Sema/SemaOpenMP.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 9afb8cea26fe78..8615da4b044a82 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -9195,7 +9195,7 @@ static bool checkOpenMPIterationSpace(
 SemaRef.Diag(CollapseLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 0 << CollapseLoopCountExpr->getSourceRange();
-  else
+  else if (OrderedLoopCountExpr)
 SemaRef.Diag(OrderedLoopCountExpr->getExprLoc(),
  diag::note_omp_collapse_ordered_expr)
 << 1 << OrderedLoopCountExpr->getSourceRange();

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


[clang] 147558e - [clang][ItaniumMangle] Mangle friend function templates with a constr… (#110247)

2024-09-30 Thread via cfe-commits

Author: Viktoriia Bakalova
Date: 2024-09-30T09:29:02+02:00
New Revision: 147558e31c2b8d2986fc13cf6f9e2bf6a120f2e6

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

LOG: [clang][ItaniumMangle] Mangle friend function templates with a constr… 
(#110247)

…aint that depends on a template parameter from an enclosing template as
members of the enclosing class.

Such function templates should be considered member-like constrained
friends per [temp.friend]p9 and
https://github.com/itanium-cxx-abi/cxx-abi/issues/24#issuecomment-934977198).

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ItaniumMangle.cpp
clang/test/CodeGenCXX/mangle-concept.cpp
libcxxabi/test/test_demangle.pass.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28c759538f7df6..35c31452cef411 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -447,6 +447,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure in debug mode, and potential crashes in release 
mode, when
   diagnosing a failed cast caused indirectly by a failed implicit conversion 
to the type of the constructor parameter.
 - Fixed an assertion failure by adjusting integral to boolean vector 
conversions (#GH108326)
+- Mangle friend function templates with a constraint that depends on a 
template parameter from an enclosing template as members of the enclosing 
class. (#GH110247)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index f043da23ff1680..117255178eebb4 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -693,7 +693,7 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const 
Decl *D) {
 if (VD->isExternC())
   return getASTContext().getTranslationUnitDecl();
 
-  if (const auto *FD = dyn_cast(D)) {
+  if (const auto *FD = D->getAsFunction()) {
 if (FD->isExternC())
   return getASTContext().getTranslationUnitDecl();
 // Member-like constrained friends are mangled as if they were members of

diff  --git a/clang/test/CodeGenCXX/mangle-concept.cpp 
b/clang/test/CodeGenCXX/mangle-concept.cpp
index 91dc1b0e688e0d..966117544bfec1 100644
--- a/clang/test/CodeGenCXX/mangle-concept.cpp
+++ b/clang/test/CodeGenCXX/mangle-concept.cpp
@@ -52,30 +52,53 @@ namespace test2 {
   };
 
   A ai;
+  A aj;
 
   // CHECK-LABEL: define {{.*}}@{{.*}}test2{{.*}}use
   void use() {
 // CHECK: call {{.*}}@_ZN5test21AIiEF1fEzQ4TrueIT_E(
 // CLANG17: call {{.*}}@_ZN5test21fEz(
 f(ai);
-// CHECK: call {{.*}}@_ZN5test2F1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
+// CHECK: call {{.*}}@_ZN5test21AIiEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
 // CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
 g(ai);
 // CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
 // CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
 h(ai);
-// CHECK: call {{.*}}@_ZN5test2F1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
+// CHECK: call {{.*}}@_ZN5test21AIiEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
 // CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
 i(ai);
 // CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
 // CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
 j(ai);
-// CHECK: call {{.*}}@_ZN5test2F1kITk4TruevQ4TrueIT_EEEvz(
+// CHECK: call {{.*}}@_ZN5test21AIiEF1kITk4TruevQ4TrueIT_EEEvz(
 // CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
 k(ai);
 // CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
 // CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
 l(ai);
+
+// CHECK: call {{.*}}@_ZN5test21AIbEF1fEzQ4TrueIT_E(
+// CLANG17: call {{.*}}@_ZN5test21fEz(
+f(aj);
+// CHECK: call {{.*}}@_ZN5test21AIbEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
+// CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
+g(aj);
+// CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
+// CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
+h(aj);
+// CHECK: call {{.*}}@_ZN5test21AIbEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
+// CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
+i(aj);
+// CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
+// CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
+j(aj);
+// CHECK: call {{.*}}@_ZN5test21AIbEF1kITk4TruevQ4TrueIT_EEEvz(
+// CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
+k(aj);
+// CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
+// CLANG17: call {{.*}}@_ZN5test21lIvEEvz(
+l(aj);
   }
 }
 

diff  --git a/libcxxabi/test/test_demangle.pass.cpp 
b/libcxxabi/test/test_demangle.pass.cpp
index 17786a3a486fcd..eb32b4679aff0c 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30128,11 +30128,15 @@ const char* cases[][2] =
 // C++20 concepts, see 
https://github.com/itanium-cxx-abi

[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread Viktoriia Bakalova via cfe-commits

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


[clang] 0d384fe - [clang][analyzer] Move 'alpha.core.PointerSub' checker into 'security.PointerSub' (#107596)

2024-09-30 Thread via cfe-commits

Author: Balázs Kéri
Date: 2024-09-30T09:16:27+02:00
New Revision: 0d384fe978f9675be9fe960940daa2fd599104ed

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

LOG: [clang][analyzer] Move 'alpha.core.PointerSub' checker into 
'security.PointerSub' (#107596)

Added: 


Modified: 
clang/docs/analyzer/checkers.rst
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/test/Analysis/casts.c
clang/test/Analysis/pointer-sub-notes.c
clang/test/Analysis/pointer-sub.c

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 9847d449d76d04..a22bda189dd295 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1544,6 +1544,49 @@ Warn on ``mmap()`` calls with both writable and 
executable access.
//   code
  }
 
+.. _security-PointerSub:
+
+security.PointerSub (C)
+"""
+Check for pointer subtractions on two pointers pointing to 
diff erent memory
+chunks. According to the C standard §6.5.6 only subtraction of pointers that
+point into (or one past the end) the same array object is valid (for this
+purpose non-array variables are like arrays of size 1). This checker only
+searches for 
diff erent memory objects at subtraction, but does not check if the
+array index is correct. Furthermore, only cases are reported where
+stack-allocated objects are involved (no warnings on pointers to memory
+allocated by `malloc`).
+
+.. code-block:: c
+
+ void test() {
+   int a, b, c[10], d[10];
+   int x = &c[3] - &c[1];
+   x = &d[4] - &c[1]; // warn: 'c' and 'd' are 
diff erent arrays
+   x = (&a + 1) - &a;
+   x = &b - &a; // warn: 'a' and 'b' are 
diff erent variables
+ }
+
+ struct S {
+   int x[10];
+   int y[10];
+ };
+
+ void test1() {
+   struct S a[10];
+   struct S b;
+   int d = &a[4] - &a[6];
+   d = &a[0].x[3] - &a[0].x[1];
+   d = a[0].y - a[0].x; // warn: 'S.b' and 'S.a' are 
diff erent objects
+   d = (char *)&b.y - (char *)&b.x; // warn: 
diff erent members of the same object
+   d = (char *)&b.y - (char *)&b; // warn: object of type S is not the same 
array as a member of it
+ }
+
+There may be existing applications that use code like above for calculating
+offsets of members in a structure, using pointer subtractions. This is still
+undefined behavior according to the standard and code like this can be replaced
+with the `offsetof` macro.
+
 .. _security-putenv-stack-array:
 
 security.PutenvStackArray (C)
@@ -2761,49 +2804,6 @@ Check for pointer arithmetic on locations other than 
array elements.
p = &x + 1; // warn
  }
 
-.. _alpha-core-PointerSub:
-
-alpha.core.PointerSub (C)
-"
-Check for pointer subtractions on two pointers pointing to 
diff erent memory
-chunks. According to the C standard §6.5.6 only subtraction of pointers that
-point into (or one past the end) the same array object is valid (for this
-purpose non-array variables are like arrays of size 1). This checker only
-searches for 
diff erent memory objects at subtraction, but does not check if the
-array index is correct. Furthermore, only cases are reported where
-stack-allocated objects are involved (no warnings on pointers to memory
-allocated by `malloc`).
-
-.. code-block:: c
-
- void test() {
-   int a, b, c[10], d[10];
-   int x = &c[3] - &c[1];
-   x = &d[4] - &c[1]; // warn: 'c' and 'd' are 
diff erent arrays
-   x = (&a + 1) - &a;
-   x = &b - &a; // warn: 'a' and 'b' are 
diff erent variables
- }
-
- struct S {
-   int x[10];
-   int y[10];
- };
-
- void test1() {
-   struct S a[10];
-   struct S b;
-   int d = &a[4] - &a[6];
-   d = &a[0].x[3] - &a[0].x[1];
-   d = a[0].y - a[0].x; // warn: 'S.b' and 'S.a' are 
diff erent objects
-   d = (char *)&b.y - (char *)&b.x; // warn: 
diff erent members of the same object
-   d = (char *)&b.y - (char *)&b; // warn: object of type S is not the same 
array as a member of it
- }
-
-There may be existing applications that use code like above for calculating
-offsets of members in a structure, using pointer subtractions. This is still
-undefined behavior according to the standard and code like this can be replaced
-with the `offsetof` macro.
-
 .. _alpha-core-StackAddressAsyncEscape:
 
 alpha.core.StackAddressAsyncEscape (ObjC)

diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 747ebd8c2e4dee..6bc389f9da265f 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -290,11 +290,6 @@ def PointerArithChecker : Checker<"PointerArithm">,
"elements">,
   Documentation;
 
-def PointerSubChecker : Checker<"PointerSub">,
-  HelpText<"Check for pointer su

[clang] [clang][analyzer] Move 'alpha.core.PointerSub' checker into 'security.PointerSub' (PR #107596)

2024-09-30 Thread Balázs Kéri via cfe-commits

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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread Viktoriia Bakalova via cfe-commits

https://github.com/VitaNuo updated 
https://github.com/llvm/llvm-project/pull/110247

>From f8d897f5f3a89a5664e95a45948f9725101aa36f Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova 
Date: Fri, 27 Sep 2024 11:33:17 +
Subject: [PATCH 1/5] [clang][ItaniumMangle] Mangle friend function templates
 with a constraint that depends on a template parameter from an enclosing
 template as members of the enclosing class.

Such function templates should be considered member-like constrained friends 
per [temp.friend]p9 and 
https://github.com/itanium-cxx-abi/cxx-abi/issues/24#issuecomment-934977198).
---
 clang/lib/AST/ItaniumMangle.cpp  | 8 
 clang/test/CodeGenCXX/mangle-concept.cpp | 6 +++---
 libcxxabi/test/test_demangle.pass.cpp| 6 +++---
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index b6e1da0c3192da..172561f73b9a74 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2270,6 +2270,14 @@ void CXXNameMangler::mangleTemplatePrefix(GlobalDecl GD,
 mangleTemplateParameter(TTP->getDepth(), TTP->getIndex());
   } else {
 const DeclContext *DC = Context.getEffectiveDeclContext(ND);
+if (const auto *FD = dyn_cast(GD.getDecl())) {
+  // Member-like constrained friends are mangled as if they were members of
+  // the enclosing class.
+  if (FD->getTemplatedDecl()->isMemberLikeConstrainedFriend() &&
+  getASTContext().getLangOpts().getClangABICompat() >
+  LangOptions::ClangABI::Ver17)
+  DC = GD.getDecl()->getLexicalDeclContext()->getRedeclContext();
+}
 manglePrefix(DC, NoFunction);
 if (isa(ND) || isa(ND))
   mangleUnqualifiedName(GD, DC, nullptr);
diff --git a/clang/test/CodeGenCXX/mangle-concept.cpp 
b/clang/test/CodeGenCXX/mangle-concept.cpp
index 91dc1b0e688e0d..6053511c00a7b5 100644
--- a/clang/test/CodeGenCXX/mangle-concept.cpp
+++ b/clang/test/CodeGenCXX/mangle-concept.cpp
@@ -58,19 +58,19 @@ namespace test2 {
 // CHECK: call {{.*}}@_ZN5test21AIiEF1fEzQ4TrueIT_E(
 // CLANG17: call {{.*}}@_ZN5test21fEz(
 f(ai);
-// CHECK: call {{.*}}@_ZN5test2F1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
+// CHECK: call {{.*}}@_ZN5test21AIiEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E(
 // CLANG17: call {{.*}}@_ZN5test21gIvEEvz(
 g(ai);
 // CHECK: call {{.*}}@_ZN5test21hIvEEvzQ4TrueITL0__E(
 // CLANG17: call {{.*}}@_ZN5test21hIvEEvz(
 h(ai);
-// CHECK: call {{.*}}@_ZN5test2F1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
+// CHECK: call {{.*}}@_ZN5test21AIiEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz(
 // CLANG17: call {{.*}}@_ZN5test21iIvEEvz(
 i(ai);
 // CHECK: call {{.*}}@_ZN5test21jIvQ4TrueITL0__EEEvz(
 // CLANG17: call {{.*}}@_ZN5test21jIvEEvz(
 j(ai);
-// CHECK: call {{.*}}@_ZN5test2F1kITk4TruevQ4TrueIT_EEEvz(
+// CHECK: call {{.*}}@_ZN5test21AIiEF1kITk4TruevQ4TrueIT_EEEvz(
 // CLANG17: call {{.*}}@_ZN5test21kIvEEvz(
 k(ai);
 // CHECK: call {{.*}}@_ZN5test21lITk4TruevEEvz(
diff --git a/libcxxabi/test/test_demangle.pass.cpp 
b/libcxxabi/test/test_demangle.pass.cpp
index 17786a3a486fcd..efe482aad1b76c 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30128,11 +30128,11 @@ const char* cases[][2] =
 // C++20 concepts, see 
https://github.com/itanium-cxx-abi/cxx-abi/issues/24.
 {"_Z2f0IiE1SIX1CIT_EEEv", "S> f0()"},
 {"_ZN5test21AIiEF1fEzQ4TrueIT_E", "test2::A::friend f(...) requires 
True"},
-{"_ZN5test2F1gIvEEvzQaa4TrueIT_E4TrueITL0__E", "void test2::friend 
g(...) requires True && True"},
+{"_ZN5test21AIiEF1gIvEEvzQaa4TrueIT_E4TrueITL0__E", "void 
test2::A::friend g(...) requires True && True"},
 {"_ZN5test21hIvEEvzQ4TrueITL0__E", "void test2::h(...) requires 
True"},
-{"_ZN5test2F1iIvQaa4TrueIT_E4TrueITL0__EEEvz", "void test2::friend 
i(...)"},
+{"_ZN5test21AIiEF1iIvQaa4TrueIT_E4TrueITL0__EEEvz", "void 
test2::A::friend i(...)"},
 {"_ZN5test21jIvQ4TrueITL0__EEEvz", "void test2::j(...)"},
-{"_ZN5test2F1kITk4TruevQ4TrueIT_EEEvz", "void test2::friend k(...)"},
+{"_ZN5test21AIiEF1kITk4TruevQ4TrueIT_EEEvz", "void test2::A::friend 
k(...)"},
 {"_ZN5test21lITk4TruevEEvz", "void test2::l(...)"},
 {"_ZN5test31dITnDaLi0EEEvv", "void test3::d<0>()"},
 {"_ZN5test31eITnDcLi0EEEvv", "void test3::e<0>()"},

>From 7f61556ecdef242043e24a7f514fe8f80d559200 Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova 
Date: Fri, 27 Sep 2024 11:42:04 +
Subject: [PATCH 2/5] fixup! [clang][ItaniumMangle] Mangle friend function
 templates with a constraint that depends on a template parameter from an
 enclosing template as members of the enclosing class.

---
 clang/lib/AST/ItaniumMangle.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 172561f73b9a74..0e5963b91f3253 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++

[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread Viktoriia Bakalova via cfe-commits


@@ -704,6 +704,15 @@ ItaniumMangleContextImpl::getEffectiveDeclContext(const 
Decl *D) {
   return D->getLexicalDeclContext()->getRedeclContext();
   }
 
+  if (const auto *FTD = dyn_cast(D)) {
+// Member-like constrained friends are mangled as if they were members of

VitaNuo wrote:

Great idea!

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


[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-09-30 Thread Balázs Kéri via cfe-commits

https://github.com/balazske created 
https://github.com/llvm/llvm-project/pull/110458

If a fixed value is assigned to a pointer variable, the checker did emit a 
warning. If the pointer variable is assigned to another pointer variable, this 
resulted in another warning. The checker now emits warning only if a value with 
non-pointer type is assigned (to a pointer variable).

From eb03076eca550ea53143bc753639f22bbb7caa35 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Mon, 30 Sep 2024 09:19:52 +0200
Subject: [PATCH] [clang][analyzer] Less redundant warnings from
 FixedAddressChecker

If a fixed value is assigned to a pointer variable, the checker
did emit a warning. If the pointer variable is assigned to another
pointer variable, this resulted in another warning.
The checker now emits warning only if a value with non-pointer type is assigned
(to a pointer variable).
---
 clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp | 6 ++
 clang/test/Analysis/ptr-arith.c   | 4 
 2 files changed, 10 insertions(+)

diff --git a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
index e7fde3edc7f9ee..87ba8e070b328a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
@@ -43,6 +43,12 @@ void FixedAddressChecker::checkPreStmt(const BinaryOperator 
*B,
   if (!T->isPointerType())
 return;
 
+  // Omit warning if the RHS has already pointer type.
+  // The value may come from a variable and is candidate for a previous warning
+  // from the checker.
+  if (B->getRHS()->IgnoreParenCasts()->getType()->isPointerType())
+return;
+
   SVal RV = C.getSVal(B->getRHS());
 
   if (!RV.isConstant() || RV.isZeroConstant())
diff --git a/clang/test/Analysis/ptr-arith.c b/clang/test/Analysis/ptr-arith.c
index 020a5006292306..b5ccd2c207ead1 100644
--- a/clang/test/Analysis/ptr-arith.c
+++ b/clang/test/Analysis/ptr-arith.c
@@ -42,6 +42,10 @@ domain_port (const char *domain_b, const char *domain_e,
 void f4(void) {
   int *p;
   p = (int*) 0x1; // expected-warning{{Using a fixed address is not 
portable because that address will probably not be valid in all environments or 
platforms}}
+
+  int *p1;
+  p1 = p; // no warning
+
   long x = 0x10100;
   x += 10;
   p = (int*) x; // expected-warning{{Using a fixed address is not portable 
because that address will probably not be valid in all environments or 
platforms}}

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


[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Balázs Kéri (balazske)


Changes

If a fixed value is assigned to a pointer variable, the checker did emit a 
warning. If the pointer variable is assigned to another pointer variable, this 
resulted in another warning. The checker now emits warning only if a value with 
non-pointer type is assigned (to a pointer variable).

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


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp (+6) 
- (modified) clang/test/Analysis/ptr-arith.c (+4) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
index e7fde3edc7f9ee..87ba8e070b328a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
@@ -43,6 +43,12 @@ void FixedAddressChecker::checkPreStmt(const BinaryOperator 
*B,
   if (!T->isPointerType())
 return;
 
+  // Omit warning if the RHS has already pointer type.
+  // The value may come from a variable and is candidate for a previous warning
+  // from the checker.
+  if (B->getRHS()->IgnoreParenCasts()->getType()->isPointerType())
+return;
+
   SVal RV = C.getSVal(B->getRHS());
 
   if (!RV.isConstant() || RV.isZeroConstant())
diff --git a/clang/test/Analysis/ptr-arith.c b/clang/test/Analysis/ptr-arith.c
index 020a5006292306..b5ccd2c207ead1 100644
--- a/clang/test/Analysis/ptr-arith.c
+++ b/clang/test/Analysis/ptr-arith.c
@@ -42,6 +42,10 @@ domain_port (const char *domain_b, const char *domain_e,
 void f4(void) {
   int *p;
   p = (int*) 0x1; // expected-warning{{Using a fixed address is not 
portable because that address will probably not be valid in all environments or 
platforms}}
+
+  int *p1;
+  p1 = p; // no warning
+
   long x = 0x10100;
   x += 10;
   p = (int*) x; // expected-warning{{Using a fixed address is not portable 
because that address will probably not be valid in all environments or 
platforms}}

``




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


[clang] [clang][analyzer] Less redundant warnings from FixedAddressChecker (PR #110458)

2024-09-30 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balázs Kéri (balazske)


Changes

If a fixed value is assigned to a pointer variable, the checker did emit a 
warning. If the pointer variable is assigned to another pointer variable, this 
resulted in another warning. The checker now emits warning only if a value with 
non-pointer type is assigned (to a pointer variable).

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


2 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp (+6) 
- (modified) clang/test/Analysis/ptr-arith.c (+4) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
index e7fde3edc7f9ee..87ba8e070b328a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/FixedAddressChecker.cpp
@@ -43,6 +43,12 @@ void FixedAddressChecker::checkPreStmt(const BinaryOperator 
*B,
   if (!T->isPointerType())
 return;
 
+  // Omit warning if the RHS has already pointer type.
+  // The value may come from a variable and is candidate for a previous warning
+  // from the checker.
+  if (B->getRHS()->IgnoreParenCasts()->getType()->isPointerType())
+return;
+
   SVal RV = C.getSVal(B->getRHS());
 
   if (!RV.isConstant() || RV.isZeroConstant())
diff --git a/clang/test/Analysis/ptr-arith.c b/clang/test/Analysis/ptr-arith.c
index 020a5006292306..b5ccd2c207ead1 100644
--- a/clang/test/Analysis/ptr-arith.c
+++ b/clang/test/Analysis/ptr-arith.c
@@ -42,6 +42,10 @@ domain_port (const char *domain_b, const char *domain_e,
 void f4(void) {
   int *p;
   p = (int*) 0x1; // expected-warning{{Using a fixed address is not 
portable because that address will probably not be valid in all environments or 
platforms}}
+
+  int *p1;
+  p1 = p; // no warning
+
   long x = 0x10100;
   x += 10;
   p = (int*) x; // expected-warning{{Using a fixed address is not portable 
because that address will probably not be valid in all environments or 
platforms}}

``




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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`llvm-clang-x86_64-sie-ubuntu-fast` running on `sie-linux-worker` while 
building `clang,libcxxabi` at step 6 "test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-cc1 -internal-isystem 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-scei-ps4 -o - 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-cc1 -internal-isystem 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-scei-ps4 -o - 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [clang-format] Fix a bug in annotating angles containing FatArrow (PR #108671)

2024-09-30 Thread Emilia Kond via cfe-commits


@@ -243,14 +244,16 @@ class AnnotatingParser {
   // operator that was misinterpreted because we are parsing template
   // parameters.
   // FIXME: This is getting out of hand, write a decent parser.
-  if (InExpr && !Line.startsWith(tok::kw_template) &&
+  if (InExpr && !SeenFatArrow && !Line.startsWith(tok::kw_template) &&
   Prev.is(TT_BinaryOperator)) {
 const auto Precedence = Prev.getPrecedence();
 if (Precedence > prec::Conditional && Precedence < prec::Relational)
   return false;
   }
   if (Prev.isOneOf(tok::question, tok::colon) && !Style.isProto())
 SeenTernaryOperator = true;
+  else if (Prev.is(TT_FatArrow))

rymiel wrote:

> If they were to just change handling of ternary expressions, but they changed 
> behavior for expressions that don't have ? in them, it sounds like an 
> unintended change.

All these template edge-cases weren't being represented in testing. My change 
broke no tests, but it caused a lot of fallout in the issues. I regret making 
that change, but by now it's too late. I'm sorry

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


[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-ve-ninja` running on 
`hpce-ve-main` while building `clang,libcxxabi` at step 4 "annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/ve-linux.py ...' (failure)
...
[293/299] Linking CXX executable tools/clang/unittests/Driver/ClangDriverTests
[294/299] Linking CXX executable tools/clang/unittests/CodeGen/ClangCodeGenTests
[295/299] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests
[296/299] Linking CXX executable tools/clang/unittests/Frontend/FrontendTests
[297/299] Linking CXX executable 
tools/clang/unittests/Interpreter/ExceptionTests/ClangReplInterpreterExceptionTests
[298/299] Linking CXX executable 
tools/clang/unittests/Interpreter/ClangReplInterpreterTests
[298/299] Running the Clang regression tests
-- Testing: 21100 tests, 48 workers --
llvm-lit: 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using clang: 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang
Testing:  0.. 10.. 20.. 30.. 
FAIL: Clang :: CodeGenCXX/mangle-concept.cpp (8704 of 21100)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang -cc1 
-internal-isystem 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
+ /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang -cc1 
-internal-isystem 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/lib/clang/20/include 
-nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
+ /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
error: 'expected-error' diagnostics seen but not expected: 
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/CodeGenCXX/mangle-concept.cpp

--


Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

Failed Tests (1):
  Clang :: CodeGenCXX/mangle-concept.cpp


Testing Time: 51.05s

Total Discovered Tests: 45230
  Skipped  :10 (0.02%)
  Unsupported  :  3778 (8.35%)
Step 8 (check-llvm) failure: check-llvm (failure)
...
[293/299] Linking CXX executable tools/clang/unittests/Driver/ClangDriverTests
[294/299] Linking CXX executable tools/clang/unittests/CodeGen/ClangCodeGenTests
[295/299] Linking CX

[clang] [libcxxabi] [clang][ItaniumMangle] Mangle friend function templates with a constr… (PR #110247)

2024-09-30 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-sles-build-only` running on `rocm-worker-hw-04-sles` while 
building `clang,libcxxabi` at step 6 "Add check check-clang".

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


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

```
Step 6 (Add check check-clang) failure: test (failure)
 TEST 'Clang :: CodeGenCXX/mangle-concept.cpp' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang -cc1 
-internal-isystem 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest | 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
+ 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-cc1 -internal-isystem 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/lib/clang/20/include
 -nostdsysteminc -verify -std=c++20 -emit-llvm -triple x86_64-unknown-linux-gnu 
-o - 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 -fclang-abi-compat=latest
error: 'expected-error' diagnostics seen but not expected: 
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: redefinition of 'h'
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 38: default template argument not permitted on a friend template
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: redefinition of 'j'
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 44: default template argument not permitted on a friend template
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: redefinition of 'l'
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 50: default template argument not permitted on a friend template
error: 'expected-note' diagnostics seen but not expected: 
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 55: in instantiation of template class 'test2::A' requested here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 39: previous definition is here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 45: previous definition is here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp
 Line 51: previous definition is here
10 errors generated.
FileCheck error: '' is empty.
FileCheck command line:  
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/CodeGenCXX/mangle-concept.cpp

--




```



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


[clang] [llvm] [AMDGPU] Convert AMDGPUResourceUsageAnalysis pass from Module to MF pass (PR #102913)

2024-09-30 Thread Janek van Oirschot via cfe-commits

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


[clang] [Clang][CodeGen] Emit load of value (PR #110487)

2024-09-30 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Bill Wendling (bwendling)


Changes

We were missing a load of the value after emitting the MemberExpr. This was 
causing __builtin_dynamic_object_size to return 0 incorrectly.

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGExpr.cpp (+1) 
- (added) clang/test/CodeGen/attr-counted-by-pr110385.c (+74) 


``diff
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index df4994ba9af6e1..4e26e9f7076777 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1169,6 +1169,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfCountedByField(
 LValue LV = EmitMemberExpr(ME);
 Address Addr = LV.getAddress();
 Res = Addr.emitRawPointer(*this);
+Res = Builder.CreateAlignedLoad(Res->getType(), Res, getPointerAlign());
   } else if (StructBase->getType()->isPointerType()) {
 LValueBaseInfo BaseInfo;
 TBAAAccessInfo TBAAInfo;
diff --git a/clang/test/CodeGen/attr-counted-by-pr110385.c 
b/clang/test/CodeGen/attr-counted-by-pr110385.c
new file mode 100644
index 00..1f11bc1a04c81b
--- /dev/null
+++ b/clang/test/CodeGen/attr-counted-by-pr110385.c
@@ -0,0 +1,74 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fstrict-flex-arrays=2 
-emit-llvm -o - %s | FileCheck %s
+
+struct bch_val {
+  unsigned long int __nothing[0];
+};
+
+struct bch_xattr {
+  struct bch_val v;
+  unsigned char x_type;
+  unsigned char x_name_len;
+  unsigned char x_name[] __attribute__((__counted_by__(x_name_len)));
+};
+
+struct bkey_s_c {
+  const struct bch_val *v;
+};
+
+struct bkey_s_c_xattr {
+  union {
+const struct bch_xattr *v;
+struct bkey_s_c s_c;
+  };
+};
+
+// CHECK-LABEL: define dso_local i64 @test1(
+// CHECK-SAME: ptr [[K_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[K:%.*]] = alloca [[STRUCT_BKEY_S_C:%.*]], align 8
+// CHECK-NEXT:[[XATTR:%.*]] = alloca [[STRUCT_BKEY_S_C_XATTR:%.*]], align 8
+// CHECK-NEXT:[[COERCE_DIVE:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C]], ptr [[K]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[K_COERCE]], ptr [[COERCE_DIVE]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR]], ptr [[XATTR]], i32 0, i32 0
+// CHECK-NEXT:[[V:%.*]] = getelementptr inbounds nuw [[STRUCT_BKEY_S_C]], 
ptr [[K]], i32 0, i32 0
+// CHECK-NEXT:[[TMP1:%.*]] = load ptr, ptr [[V]], align 8
+// CHECK-NEXT:[[ADD_PTR:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_VAL:%.*]], ptr [[TMP1]], i64 0
+// CHECK-NEXT:store ptr [[ADD_PTR]], ptr [[TMP0]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR]], ptr [[XATTR]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[TMP2]], align 8
+// CHECK-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_XATTR:%.*]], ptr [[TMP3]], i32 0, i32 2
+// CHECK-NEXT:[[DOT_COUNTED_BY_LOAD:%.*]] = load i8, ptr 
[[DOT_COUNTED_BY_GEP]], align 4
+// CHECK-NEXT:[[TMP4:%.*]] = zext i8 [[DOT_COUNTED_BY_LOAD]] to i64
+// CHECK-NEXT:[[TMP5:%.*]] = mul nuw i64 [[TMP4]], 1
+// CHECK-NEXT:[[TMP6:%.*]] = icmp sgt i64 [[TMP4]], -1
+// CHECK-NEXT:[[TMP7:%.*]] = select i1 [[TMP6]], i64 [[TMP5]], i64 0
+// CHECK-NEXT:ret i64 [[TMP7]]
+//
+unsigned long int test1(struct bkey_s_c k) {
+  struct bkey_s_c_xattr xattr = (struct bkey_s_c_xattr){
+  .v = (struct bch_xattr *)(k.v - __builtin_offsetof(struct bch_xattr, v))
+  };
+
+  return __builtin_dynamic_object_size(xattr.v->x_name, 0);
+}
+
+// CHECK-LABEL: define dso_local i64 @test2(
+// CHECK-SAME: ptr noundef [[XATTR:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[XATTR_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[XATTR]], ptr [[XATTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[XATTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR:%.*]], ptr [[TMP0]], i32 0, i32 0
+// CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP1]], align 8
+// CHECK-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_XATTR:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:[[DOT_COUNTED_BY_LOAD:%.*]] = load i8, ptr 
[[DOT_COUNTED_BY_GEP]], align 4
+// CHECK-NEXT:[[TMP3:%.*]] = zext i8 [[DOT_COUNTED_BY_LOAD]] to i64
+// CHECK-NEXT:[[TMP4:%.*]] = mul nuw i64 [[TMP3]], 1
+// CHECK-NEXT:[[TMP5:%.*]] = icmp sgt i64 [[TMP3]], -1
+// CHECK-NEXT:[[TMP6:%.*]] = select i1 [[TMP5]], i64 [[TMP4]], i64 0
+// CHECK-NEXT:ret i64 [[TMP6]]
+//
+unsigned long int test2(struct bkey_s_c_xattr *xattr) {
+  return __builtin_dynamic_object_size(xattr->v->x_name, 0);
+}

``




https://github.com/llvm/ll

[clang] [Clang][CodeGen] Emit load of value (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits

https://github.com/bwendling created 
https://github.com/llvm/llvm-project/pull/110487

We were missing a load of the value after emitting the MemberExpr. This was 
causing __builtin_dynamic_object_size to return 0 incorrectly.

>From 375a71d114fffb94c16455f476364a7de9e08191 Mon Sep 17 00:00:00 2001
From: Bill Wendling 
Date: Mon, 30 Sep 2024 03:41:15 -0700
Subject: [PATCH] [Clang][CodeGen] Emit load of value

We were missing a load of the value after emitting the MemberExpr. This
was causing __builtin_dynamic_object_size to return 0 incorrectly.

Signed-off-by: Bill Wendling 
---
 clang/lib/CodeGen/CGExpr.cpp  |  1 +
 clang/test/CodeGen/attr-counted-by-pr110385.c | 74 +++
 2 files changed, 75 insertions(+)
 create mode 100644 clang/test/CodeGen/attr-counted-by-pr110385.c

diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index df4994ba9af6e1..4e26e9f7076777 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -1169,6 +1169,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfCountedByField(
 LValue LV = EmitMemberExpr(ME);
 Address Addr = LV.getAddress();
 Res = Addr.emitRawPointer(*this);
+Res = Builder.CreateAlignedLoad(Res->getType(), Res, getPointerAlign());
   } else if (StructBase->getType()->isPointerType()) {
 LValueBaseInfo BaseInfo;
 TBAAAccessInfo TBAAInfo;
diff --git a/clang/test/CodeGen/attr-counted-by-pr110385.c 
b/clang/test/CodeGen/attr-counted-by-pr110385.c
new file mode 100644
index 00..1f11bc1a04c81b
--- /dev/null
+++ b/clang/test/CodeGen/attr-counted-by-pr110385.c
@@ -0,0 +1,74 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 4
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fstrict-flex-arrays=2 
-emit-llvm -o - %s | FileCheck %s
+
+struct bch_val {
+  unsigned long int __nothing[0];
+};
+
+struct bch_xattr {
+  struct bch_val v;
+  unsigned char x_type;
+  unsigned char x_name_len;
+  unsigned char x_name[] __attribute__((__counted_by__(x_name_len)));
+};
+
+struct bkey_s_c {
+  const struct bch_val *v;
+};
+
+struct bkey_s_c_xattr {
+  union {
+const struct bch_xattr *v;
+struct bkey_s_c s_c;
+  };
+};
+
+// CHECK-LABEL: define dso_local i64 @test1(
+// CHECK-SAME: ptr [[K_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[K:%.*]] = alloca [[STRUCT_BKEY_S_C:%.*]], align 8
+// CHECK-NEXT:[[XATTR:%.*]] = alloca [[STRUCT_BKEY_S_C_XATTR:%.*]], align 8
+// CHECK-NEXT:[[COERCE_DIVE:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C]], ptr [[K]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[K_COERCE]], ptr [[COERCE_DIVE]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR]], ptr [[XATTR]], i32 0, i32 0
+// CHECK-NEXT:[[V:%.*]] = getelementptr inbounds nuw [[STRUCT_BKEY_S_C]], 
ptr [[K]], i32 0, i32 0
+// CHECK-NEXT:[[TMP1:%.*]] = load ptr, ptr [[V]], align 8
+// CHECK-NEXT:[[ADD_PTR:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_VAL:%.*]], ptr [[TMP1]], i64 0
+// CHECK-NEXT:store ptr [[ADD_PTR]], ptr [[TMP0]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR]], ptr [[XATTR]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[TMP2]], align 8
+// CHECK-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_XATTR:%.*]], ptr [[TMP3]], i32 0, i32 2
+// CHECK-NEXT:[[DOT_COUNTED_BY_LOAD:%.*]] = load i8, ptr 
[[DOT_COUNTED_BY_GEP]], align 4
+// CHECK-NEXT:[[TMP4:%.*]] = zext i8 [[DOT_COUNTED_BY_LOAD]] to i64
+// CHECK-NEXT:[[TMP5:%.*]] = mul nuw i64 [[TMP4]], 1
+// CHECK-NEXT:[[TMP6:%.*]] = icmp sgt i64 [[TMP4]], -1
+// CHECK-NEXT:[[TMP7:%.*]] = select i1 [[TMP6]], i64 [[TMP5]], i64 0
+// CHECK-NEXT:ret i64 [[TMP7]]
+//
+unsigned long int test1(struct bkey_s_c k) {
+  struct bkey_s_c_xattr xattr = (struct bkey_s_c_xattr){
+  .v = (struct bch_xattr *)(k.v - __builtin_offsetof(struct bch_xattr, v))
+  };
+
+  return __builtin_dynamic_object_size(xattr.v->x_name, 0);
+}
+
+// CHECK-LABEL: define dso_local i64 @test2(
+// CHECK-SAME: ptr noundef [[XATTR:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[XATTR_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[XATTR]], ptr [[XATTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[XATTR_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds nuw 
[[STRUCT_BKEY_S_C_XATTR:%.*]], ptr [[TMP0]], i32 0, i32 0
+// CHECK-NEXT:[[TMP2:%.*]] = load ptr, ptr [[TMP1]], align 8
+// CHECK-NEXT:[[DOT_COUNTED_BY_GEP:%.*]] = getelementptr inbounds 
[[STRUCT_BCH_XATTR:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:[[DOT_COUNTED_BY_LOAD:%.*]] = load i8, ptr 
[[DOT_COUNTED_BY_GEP]], align 4
+// CHECK-NEXT:[[TMP3:%.*]] = zext i8 [[DOT_COUNTED_BY_LOAD]] to i64
+// CHECK-NEXT:[[TMP4:%.*]] = mul nuw i64 [[TMP3]], 1
+// CHEC

[clang] [Clang][CodeGen] Emit load of value (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits

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


[clang] [clang][bytecode] Handle DiscardResult for fixed-point literals (PR #110475)

2024-09-30 Thread Timm Baeder via cfe-commits

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


[clang] 3c85102 - [clang][bytecode] Handle DiscardResult for fixed-point literals (#110475)

2024-09-30 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-30T12:42:18+02:00
New Revision: 3c85102756ca0737e2282794451889cac502389f

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

LOG: [clang][bytecode] Handle DiscardResult for fixed-point literals (#110475)

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/fixed-point.cpp
clang/test/Frontend/fixed_point_crash.c

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 5ad5899739909f..680be736aa6471 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -763,6 +763,9 @@ bool Compiler::VisitFixedPointLiteral(const 
FixedPointLiteral *E) {
   assert(E->getType()->isFixedPointType());
   assert(classifyPrim(E) == PT_FixedPoint);
 
+  if (DiscardResult)
+return true;
+
   auto Sem = Ctx.getASTContext().getFixedPointSemantics(E->getType());
   APInt Value = E->getValue();
   return this->emitConstFixedPoint(FixedPoint(Value, Sem), E);

diff  --git a/clang/test/AST/ByteCode/fixed-point.cpp 
b/clang/test/AST/ByteCode/fixed-point.cpp
index 48673d8be6f601..4bf80ba7c58f02 100644
--- a/clang/test/AST/ByteCode/fixed-point.cpp
+++ b/clang/test/AST/ByteCode/fixed-point.cpp
@@ -11,6 +11,8 @@ static_assert(1.0k != 1.0k); // both-error {{failed due to 
requirement '1.0k !=
 static_assert(1.0k != 1); // both-error {{failed due to requirement '1.0k != 
1'}}
 static_assert(-12.0k == -(-(-12.0k)));
 
+constexpr _Accum acc = (0.5r, 6.9k);
+
 /// Zero-init.
 constexpr _Accum A{};
 static_assert(A == 0.0k);

diff  --git a/clang/test/Frontend/fixed_point_crash.c 
b/clang/test/Frontend/fixed_point_crash.c
index 3b397400ca..9cfe6ba64c519d 100644
--- a/clang/test/Frontend/fixed_point_crash.c
+++ b/clang/test/Frontend/fixed_point_crash.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify -ffixed-point %s
+// RUN: %clang_cc1 -verify -ffixed-point %s 
-fexperimental-new-constant-interpreter
 
 union a {
   _Accum x;



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


[clang] [flang] [flang][preprocessor] Don't expand INCLUDE under -E by default (PR #110333)

2024-09-30 Thread via cfe-commits

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

LGTM

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


[clang] [Clang] Fix 'counted_by' for nested struct pointers (PR #110437)

2024-09-30 Thread Bill Wendling via cfe-commits

bwendling wrote:

Thanks for this, but I think the issue is more basic. We should be issuing a 
"load" instruction after the `EmitMemberExpr` call. (That's what happens 
outside of using this in `__builtin_dynamic_object_size`.)

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


[clang] [Clang] prevent recovery call expression from proceeding with explicit attributes and undeclared templates (PR #107786)

2024-09-30 Thread Oleksandr T. via cfe-commits

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

>From e9948a1004cc2b486a0422d83e88392754e9f7e9 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 23 Sep 2024 17:17:30 +0300
Subject: [PATCH 1/2] [Clang] prevent recovery call expression from proceeding
 with explicit attributes and undeclared templates

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/Sema/Sema.h   |  4 ++-
 clang/lib/Sema/SemaExpr.cpp   | 12 +--
 clang/lib/Sema/SemaOverload.cpp   |  2 +-
 .../SemaTemplate/recovery-crash-cxx20.cpp | 32 +++
 5 files changed, 48 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/SemaTemplate/recovery-crash-cxx20.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b47e06cb0c5d68..110f75d739c072 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -424,6 +424,8 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure in debug mode, and potential crashes in release 
mode, when
   diagnosing a failed cast caused indirectly by a failed implicit conversion 
to the type of the constructor parameter.
 - Fixed an assertion failure by adjusting integral to boolean vector 
conversions (#GH108326)
+- Fixed an assertion failure when invoking recovery call expressions with 
explicit attributes
+  and undeclared templates. (#GH107047, #GH49093)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e1c3a99cfa167e..b2eefdbd1c56d1 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6753,7 +6753,9 @@ class Sema final : public SemaBase {
   ///
   /// Return \c true if the error is unrecoverable, or \c false if the caller
   /// should attempt to recover using these lookup results.
-  bool DiagnoseDependentMemberLookup(const LookupResult &R);
+  bool DiagnoseDependentMemberLookup(
+  const LookupResult &R,
+  TemplateArgumentListInfo *ExplicitTemplateArgs = nullptr);
 
   /// Diagnose an empty lookup.
   ///
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 66df9c969256a2..a5770ae8848517 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2385,7 +2385,15 @@ static void emitEmptyLookupTypoDiagnostic(
  SemaRef.PDiag(NoteID));
 }
 
-bool Sema::DiagnoseDependentMemberLookup(const LookupResult &R) {
+bool Sema::DiagnoseDependentMemberLookup(
+const LookupResult &R, TemplateArgumentListInfo *ExplicitTemplateArgs) {
+  auto IsTemplated = [](NamedDecl *D) { return D->isTemplated(); };
+  if (ExplicitTemplateArgs && !llvm::all_of(R, IsTemplated)) {
+Diag(R.getNameLoc(), diag::err_non_template_in_template_id)
+<< R.getLookupName();
+return true;
+  }
+
   // During a default argument instantiation the CurContext points
   // to a CXXMethodDecl; but we can't apply a this-> fixit inside a
   // function parameter list, hence add an explicit check.
@@ -2487,7 +2495,7 @@ bool Sema::DiagnoseEmptyLookup(Scope *S, CXXScopeSpec 
&SS, LookupResult &R,
   R.resolveKind();
 }
 
-return DiagnoseDependentMemberLookup(R);
+return DiagnoseDependentMemberLookup(R, ExplicitTemplateArgs);
   }
 
   R.clear();
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index d304f322aced64..fe9b16e1890c16 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -13860,7 +13860,7 @@ BuildRecoveryCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
 // enclosing class.
 // FIXME: We should also explain why the candidates found by name lookup
 // were not viable.
-if (SemaRef.DiagnoseDependentMemberLookup(R))
+if (SemaRef.DiagnoseDependentMemberLookup(R, ExplicitTemplateArgs))
   return ExprError();
   } else {
 // We had viable candidates and couldn't recover; let the caller diagnose
diff --git a/clang/test/SemaTemplate/recovery-crash-cxx20.cpp 
b/clang/test/SemaTemplate/recovery-crash-cxx20.cpp
new file mode 100644
index 00..3651b986dfd989
--- /dev/null
+++ b/clang/test/SemaTemplate/recovery-crash-cxx20.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
+
+namespace GH49093 {
+  class B {
+  public:
+static int a() { return 0; }
+decltype(a< 0 >(0)) test; // expected-error {{'a' does not name a template 
but is followed by template arguments}}
+  };
+
+  struct C {
+  static int a() { return 0; }
+  decltype(a < 0 > (0)) test; // expected-error {{'a' does not name a 
template but is followed by template arguments}}
+  };
+
+  void test_is_bool(bool t) {}
+  void test_is_bool(int t) {}
+
+  int main() {
+B b;
+test_is_bool(b.test);
+
+C c;
+test_is_bool(c.test);
+  }
+}
+
+namespace GH107047 {
+  struct A {
+static constexpr auto test() { return 1; }
+   

[clang] [Clang] fix overload resolution for object parameters with top-level cv-qualifiers in member functions (PR #110435)

2024-09-30 Thread Oleksandr T. via cfe-commits

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

>From c52634882631a71fad956a70179b480abf13006a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 29 Sep 2024 22:01:38 +0300
Subject: [PATCH] [Clang] fix overload resolution for object parameters with
 top-level cv-qualifiers in member functions

---
 clang/docs/ReleaseNotes.rst| 1 +
 clang/lib/Sema/SemaOverload.cpp| 3 +++
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++
 3 files changed, 11 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28c759538f7df6..1bec2838765dab 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -447,6 +447,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure in debug mode, and potential crashes in release 
mode, when
   diagnosing a failed cast caused indirectly by a failed implicit conversion 
to the type of the constructor parameter.
 - Fixed an assertion failure by adjusting integral to boolean vector 
conversions (#GH108326)
+- Fixed overload handling for object parameters with top-level cv-qualifiers 
in explicit member functions (#GH100394)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 0c1e054f7c30a4..7c40bab70bbe9d 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1511,6 +1511,9 @@ static bool IsOverloadOrOverrideImpl(Sema &SemaRef, 
FunctionDecl *New,
   auto NewObjectType = New->getFunctionObjectParameterReferenceType();
   auto OldObjectType = Old->getFunctionObjectParameterReferenceType();
 
+  if (NewObjectType.isConstQualified() != OldObjectType.isConstQualified())
+return false;
+
   auto IsImplicitWithNoRefQual = [](const CXXMethodDecl *F) {
 return F->getRefQualifier() == RQ_None &&
!F->isExplicitObjectMemberFunction();
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 63bf92e8d5edd3..5fd02502ce6df4 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1073,3 +1073,10 @@ int main() {
   return foo[]; // expected-error {{no viable overloaded operator[] for type 
'Foo'}}
 }
 }
+
+namespace GH100394 {
+struct C {
+  void f(this const C);
+  void f() const ;  // ok
+};
+}

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


[clang] [Clang][CodeGen] Emit load of value (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits

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


[clang] [Clang][CodeGen] Emit load of GEP after EmitMemberExpr (PR #110487)

2024-09-30 Thread Bill Wendling via cfe-commits

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


[clang] [Clang] Extend lifetime of temporaries in mem-default-init for P2718R0 (PR #86960)

2024-09-30 Thread via cfe-commits

yronglin wrote:

friendly ping~

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


[clang-tools-extra] 3d9cf8b - [clangd] Improve filtering logic for undesired proto symbols (#110091)

2024-09-30 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2024-09-30T14:40:54+02:00
New Revision: 3d9cf8b397f61f6259049a625f4888a119352e0d

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

LOG: [clangd] Improve filtering logic for undesired proto symbols (#110091)

This used to filter any names with `_` in them, apart from
enum-constants. Resulting in discrepancies in behavior when we had
fields that have `_` in the name, or for accessors like `set_`, `has_`.

The logic seems to be trying to filter mangled names for nested entries,
so adjusted logic to only do so for top-level decls, while still
preserving some public top-level helpers.

Heuristics are still leaning towards false-negatives, e.g. if a
top-level entity has `_` in its name (`message Foo_Bar {}`), it'll be
filtered, or an enum that prefixes its type name to constants
(`enum Foo { Foo_OK }`).

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index a76894cf0855f3..d1d744a21cfd55 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -41,6 +41,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
@@ -75,18 +76,62 @@ bool isPrivateProtoDecl(const NamedDecl &ND) {
   if (ND.getIdentifier() == nullptr)
 return false;
   auto Name = ND.getIdentifier()->getName();
-  if (!Name.contains('_'))
-return false;
-  // Nested proto entities (e.g. Message::Nested) have top-level decls
-  // that shouldn't be used (Message_Nested). Ignore them completely.
-  // The nested entities are dangling type aliases, we may want to reconsider
-  // including them in the future.
-  // For enum constants, SOME_ENUM_CONSTANT is not private and should be
-  // indexed. Outer_INNER is private. This heuristic relies on naming style, it
-  // will include OUTER_INNER and exclude some_enum_constant.
-  // FIXME: the heuristic relies on naming style (i.e. no underscore in
-  // user-defined names) and can be improved.
-  return (ND.getKind() != Decl::EnumConstant) || llvm::any_of(Name, islower);
+  // There are some internal helpers like _internal_set_foo();
+  if (Name.contains("_internal_"))
+return true;
+
+  // https://protobuf.dev/reference/cpp/cpp-generated/#nested-types
+  // Nested entities (messages/enums) has two names, one at the top-level 
scope,
+  // with a mangled name created by prepending all the outer types. These names
+  // are almost never preferred by the developers, so exclude them from index.
+  // e.g.
+  //   message Foo {
+  //message Bar {}
+  //enum E { A }
+  //   }
+  //
+  // yields:
+  //   class Foo_Bar {};
+  //   enum Foo_E { Foo_E_A };
+  //   class Foo {
+  //using Bar = Foo_Bar;
+  //static constexpr Foo_E A = Foo_E_A;
+  //   };
+
+  // We get rid of Foo_Bar and Foo_E by discarding any top-level entries with
+  // `_` in the name. This relies on original message/enum not having `_` in 
the
+  // name. Hence might go wrong in certain cases.
+  if (ND.getDeclContext()->isNamespace()) {
+// Strip off some known public suffix helpers for enums, rest of the 
helpers
+// are generated inside record decls so we don't care.
+// https://protobuf.dev/reference/cpp/cpp-generated/#enum
+Name.consume_back("_descriptor");
+Name.consume_back("_IsValid");
+Name.consume_back("_Name");
+Name.consume_back("_Parse");
+Name.consume_back("_MIN");
+Name.consume_back("_MAX");
+Name.consume_back("_ARRAYSIZE");
+return Name.contains('_');
+  }
+
+  // EnumConstantDecls need some special attention, despite being nested in a
+  // TagDecl, they might still have mangled names. We filter those by checking
+  // if it has parent's name as a prefix.
+  // This might go wrong if a nested entity has a name that starts with 
parent's
+  // name, e.g: enum Foo { Foo_X }.
+  if (llvm::isa(&ND)) {
+auto *DC = llvm::cast(ND.getDeclContext());
+if (!DC || !DC->getIdentifier())
+  return false;
+auto CtxName = DC->getIdentifier()->getName();
+return !CtxName.empty() && Name.consume_front(CtxName) &&
+   Name.consume_front("_");
+  }
+
+  // Now we're only left with fields/methods without an `_internal_` in the
+  // name, they're intended for public use.
+  return false;
 }
 
 // We only collect #include paths for symbols that are suitable for global code

diff  --git a/clang-tools-extra/clangd/unittest

  1   2   3   4   5   6   >