[clang] [flang] [flang] Align `-x f95[-cpp-input]` language modes with `gfortran` (PR #127986)

2025-02-21 Thread Iñaki Amatria Barral via cfe-commits

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


[clang] [llvm] [RISCV][MC] Implement MC for Base P extension (PR #123271)

2025-02-21 Thread via cfe-commits

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


[clang] [flang] [flang][OpenMP] Upstream `do concurrent` loop-nest detection. (PR #127595)

2025-02-21 Thread Kareem Ergawy via cfe-commits

ergawy wrote:

Thanks @skatrak and @bhandarkar-pranav for the approval.

@kiranchandramohan @clementval I think there is a pretty simple solution that 
enables us to mark multi-range loop nests. I think we can add an optional 
attribute to the `fir::DoLoopOp` to store the loop nest depth: `nest_depth(n)`. 
So for the following input:
```fortran
do concurrent (i=1:10, j=1:10)
end do
```
The MLIR would look like this:
```mlir
fir.do_loop %arg0 = %10 to %11 step %c1 unordered nest_depth(2) {
  %14 = fir.convert %arg0 : (index) -> i32
  fir.store %14 to %3#1 : !fir.ref
  fir.do_loop %arg1 = %12 to %13 step %c1_2 unordered {
%15 = fir.convert %arg1 : (index) -> i32
fir.store %15 to %1#1 : !fir.ref

  }
}
```
I think this is a non-distruptive change to the op that enables us to model 
loop nests more easily.

@clementval as for the locality specifiers, I am working on a PoC (based-on 
which I will write an RFC) to have a shared "Data Environemt" dialect that can 
be used across `do concurrent`, OpenMP, and OpenACC. I published what I have so 
far in https://github.com/llvm/llvm-project/pull/128148.

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


[clang] [clang-tools-extra] [Clang] Default the warning for chained comparison to an error. (PR #128145)

2025-02-21 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/128145

>From 55dcf33ba907e8c273ee3dfe196b71bc4b70c325 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Fri, 21 Feb 2025 08:41:07 +0100
Subject: [PATCH] [Clang] Default the warning for chained comparison to an
 error.

Boolean constructs of the form `a < b < c`
never express the likely intent of the user and
we have been warning on them since clang 19.

WG21 is likely to deprecate or make that construct in the future.
To gain more experience and to improve safety, this patches preempt
future language evolution by turning
warn_consecutive_comparison in an error, by default
(which can be disabled with `-Wno-error=parentheses`)
---
 .../test/clang-tidy/checkers/bugprone/chained-comparison.c | 2 +-
 .../clang-tidy/checkers/bugprone/chained-comparison.cpp| 2 +-
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/include/clang/Basic/DiagnosticSemaKinds.td   | 2 +-
 clang/test/Sema/bool-compare.c | 4 ++--
 clang/test/Sema/parentheses.cpp| 4 ++--
 clang/test/SemaCXX/bool-compare.cpp| 7 +++
 clang/test/SemaCXX/cxx2a-adl-only-template-id.cpp  | 2 +-
 clang/test/SemaTemplate/typo-dependent-name.cpp| 2 +-
 clang/test/SemaTemplate/typo-template-name.cpp | 2 +-
 10 files changed, 15 insertions(+), 14 deletions(-)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c
index 53c6139dcfbc2..7a4322c6a00c0 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-chained-comparison %t
+// RUN: %check_clang_tidy --extra-arg=-Wno-error=parentheses %s 
bugprone-chained-comparison %t
 
 void badly_chained_1(int x, int y, int z)
 {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp
index 8a664aa205acf..88813f72e37ca 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++98-or-later %s bugprone-chained-comparison %t
+// RUN: %check_clang_tidy -std=c++98-or-later 
--extra-arg=-Wno-error=parentheses %s bugprone-chained-comparison %t
 
 void badly_chained_1(int x, int y, int z)
 {
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e1c61992512b5..01c58295613d7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -147,6 +147,8 @@ Improvements to Clang's diagnostics
 - The ``-Wunsafe-buffer-usage`` warning has been updated to warn
   about unsafe libc function calls.  Those new warnings are emitted
   under the subgroup ``-Wunsafe-buffer-usage-in-libc-call``.
+- Diagnostics on chained comparisons (``a < b < c``) are now an error by 
default. This can be disabled with
+  ``-Wno-error=parentheses``.
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index feef50812eca9..f4f1bc67724a1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7126,7 +7126,7 @@ def note_precedence_conditional_first : Note<
 
 def warn_consecutive_comparison : Warning<
   "comparisons like 'X<=Y<=Z' don't have their mathematical meaning">,
-  InGroup;
+  InGroup, DefaultError;
 
 def warn_enum_constant_in_bool_context : Warning<
   "converting the enum constant to a boolean">,
diff --git a/clang/test/Sema/bool-compare.c b/clang/test/Sema/bool-compare.c
index 2308dc4bf2bb2..861f47864ddd9 100644
--- a/clang/test/Sema/bool-compare.c
+++ b/clang/test/Sema/bool-compare.c
@@ -85,7 +85,7 @@ void f(int x, int y, int z) {
   if ((ayy z)  {} // no warning
   if((a(zy)  {} // expected-warning {{comparisons like 'X<=Y<=Z' don't 
have their mathematical meaning}}
+  if (zy)  {} // expected-error {{comparisons like 'X<=Y<=Z' don't have 
their mathematical meaning}}
   if (z > (a(a&1 | FileCheck %s
+// RUN: %clang_cc1 -Wno-error=parentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wno-error=parentheses -fsyntax-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 bool someConditionFunc();
 
diff --git a/clang/test/SemaCXX/bool-compare.cpp 
b/clang/test/SemaCXX/bool-compare.cpp
index 4e33e076a7de4..077d55ff9367d 100644
--- a/clang/test/SemaCXX/bool-compare.cpp
+++ b/clang/test/SemaCXX/bool-compare.cpp
@@ -98,7 +98,7 @@ void f(int x, int y, int z) {
   if ((ayy z)  {} // no warning
   if((a(zy)  {} // expected-warning {{comparisons 

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 6 "test-build-unified-tree-check-all".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.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/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/AST/ByteCode/libcxx/primi

[clang] [clang][LoongArch] Add OHOS target (PR #127555)

2025-02-21 Thread Lu Weining via cfe-commits

SixWeining wrote:

> > Could you add some tests in ohos.c with the `--sysroot` option specified?
> 
> Could I confirm what the test targeting the `--sysroot` option is for? Is it 
> also intended to test the `page-size`?

I mean the purpose is to check whether clang driver passes correct options to 
cc1 or lld. For example, the `ld-musl-loongarch64.so.1`, `crti.o`, `crt1.o`, 
etc.

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


[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 Thread Timm Baeder via cfe-commits

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


[clang] 97ed201 - [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (#128141)

2025-02-21 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-02-21T09:47:08+01:00
New Revision: 97ed2019c41f2c0208699ab3593b681487754d58

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

LOG: [clang][bytecode] Use ExtendingDecl mechanism for primitives as well 
(#128141)

... when creating the temporary variables for a
MaterializeTemporaryExpr.

Added: 
clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp

Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/lib/AST/ByteCode/Compiler.h

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index a35aa9471a73d..91e0484da0e58 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -567,8 +567,8 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
 // Location for the SubExpr.
 // Since SubExpr is of complex type, visiting it results in a pointer
 // anyway, so we just create a temporary pointer variable.
-unsigned SubExprOffset = allocateLocalPrimitive(
-SubExpr, PT_Ptr, /*IsConst=*/true, /*IsExtended=*/false);
+unsigned SubExprOffset =
+allocateLocalPrimitive(SubExpr, PT_Ptr, /*IsConst=*/true);
 if (!this->visit(SubExpr))
   return false;
 if (!this->emitSetLocal(PT_Ptr, SubExprOffset, CE))
@@ -611,8 +611,8 @@ bool Compiler::VisitCastExpr(const CastExpr *CE) {
 
 const auto *VT = CE->getType()->getAs();
 PrimType ElemT = classifyPrim(SubExpr->getType());
-unsigned ElemOffset = allocateLocalPrimitive(
-SubExpr, ElemT, /*IsConst=*/true, /*IsExtended=*/false);
+unsigned ElemOffset =
+allocateLocalPrimitive(SubExpr, ElemT, /*IsConst=*/true);
 
 // Prepare a local variable for the scalar value.
 if (!this->visit(SubExpr))
@@ -1104,7 +1104,7 @@ bool Compiler::VisitComplexBinOp(const 
BinaryOperator *E) {
   PrimType ResultElemT = this->classifyComplexElementType(E->getType());
   unsigned ResultOffset = ~0u;
   if (!DiscardResult)
-ResultOffset = this->allocateLocalPrimitive(E, PT_Ptr, true, false);
+ResultOffset = this->allocateLocalPrimitive(E, PT_Ptr, /*IsConst=*/true);
 
   // Save result pointer in ResultOffset
   if (!this->DiscardResult) {
@@ -1178,14 +1178,14 @@ bool Compiler::VisitComplexBinOp(const 
BinaryOperator *E) {
 
   // Evaluate LHS and save value to LHSOffset.
   if (LHSType->isAnyComplexType()) {
-LHSOffset = this->allocateLocalPrimitive(LHS, PT_Ptr, true, false);
+LHSOffset = this->allocateLocalPrimitive(LHS, PT_Ptr, /*IsConst=*/true);
 if (!this->visit(LHS))
   return false;
 if (!this->emitSetLocal(PT_Ptr, LHSOffset, E))
   return false;
   } else {
 PrimType LHST = classifyPrim(LHSType);
-LHSOffset = this->allocateLocalPrimitive(LHS, LHST, true, false);
+LHSOffset = this->allocateLocalPrimitive(LHS, LHST, /*IsConst=*/true);
 if (!this->visit(LHS))
   return false;
 if (!this->emitSetLocal(LHST, LHSOffset, E))
@@ -1195,14 +1195,14 @@ bool Compiler::VisitComplexBinOp(const 
BinaryOperator *E) {
   // Same with RHS.
   unsigned RHSOffset;
   if (RHSType->isAnyComplexType()) {
-RHSOffset = this->allocateLocalPrimitive(RHS, PT_Ptr, true, false);
+RHSOffset = this->allocateLocalPrimitive(RHS, PT_Ptr, /*IsConst=*/true);
 if (!this->visit(RHS))
   return false;
 if (!this->emitSetLocal(PT_Ptr, RHSOffset, E))
   return false;
   } else {
 PrimType RHST = classifyPrim(RHSType);
-RHSOffset = this->allocateLocalPrimitive(RHS, RHST, true, false);
+RHSOffset = this->allocateLocalPrimitive(RHS, RHST, /*IsConst=*/true);
 if (!this->visit(RHS))
   return false;
 if (!this->emitSetLocal(RHST, RHSOffset, E))
@@ -1342,14 +1342,16 @@ bool Compiler::VisitVectorBinOp(const 
BinaryOperator *E) {
   PrimType ResultElemT = this->classifyVectorElementType(E->getType());
 
   // Evaluate LHS and save value to LHSOffset.
-  unsigned LHSOffset = this->allocateLocalPrimitive(LHS, PT_Ptr, true, false);
+  unsigned LHSOffset =
+  this->allocateLocalPrimitive(LHS, PT_Ptr, /*IsConst=*/true);
   if (!this->visit(LHS))
 return false;
   if (!this->emitSetLocal(PT_Ptr, LHSOffset, E))
 return false;
 
   // Evaluate RHS and save value to RHSOffset.
-  unsigned RHSOffset = this->allocateLocalPrimitive(RHS, PT_Ptr, true, false);
+  unsigned RHSOffset =
+  this->allocateLocalPrimitive(RHS, PT_Ptr, /*IsConst=*/true);
   if (!this->visit(RHS))
 return false;
   if (!this->emitSetLocal(PT_Ptr, RHSOffset, E))
@@ -2710,8 +2712,8 @@ bool Compiler::VisitMaterializeTemporaryExpr(
   // For everyhing else, use local variables.
   if (SubExprT) {
 bool IsConst = SubExpr->getType().isConstQualified();
-unsigned LocalIndex = allocateLocalPrimitive(E, *SubExprT, IsConst,
-  

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 6 
"test-build-unified-tree-check-all".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /buildbot/worker/arc-folder/build/bin/clang -cc1 
-internal-isystem /buildbot/worker/arc-folder/build/lib/clang/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ /buildbot/worker/arc-folder/build/bin/clang -cc1 -internal-isystem 
/buildbot/worker/arc-folder/build/lib/clang/21/include -nostdsysteminc 
-std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl::__type>' 
requested here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 192: (skipping 3 contexts in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/buildbot/worker/arc-folder/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 2

[clang] [clang-tools-extra] [Clang] Default the warning for chained comparison to an error. (PR #128145)

2025-02-21 Thread via cfe-commits

cor3ntin wrote:

I wonder if we should remove the `bugprone-chained-comparison` tidy check - not 
sure there is value in both clang and clang tidy having the same warning. But I 
don't know what our policy is in that regard.

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


[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 6 
"test-build-unified-tree-check-clang".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ /b/1/llvm-x86_64-debian-dylib/build/bin/clang -cc1 -internal-isystem 
/b/1/llvm-x86_64-debian-dylib/build/lib/clang/21/include -nostdsysteminc 
-std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl::__type>' 
requested here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 192: (skipping 3 contexts in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/b/1/llvm-x86_64-debian-dylib/llvm-

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ /home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/bin/clang -cc1 
-internal-isystem 
/home/tcwg-buildbot/worker/clang-aarch64-quick/stage1/lib/clang/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl::__type>' 
requested here
  File 
/home/tcwg-buildbot/worker/clang-aarch64-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 6 
"test-build-unified-tree-check-all".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.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/21/include -nostdsysteminc 
-std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl::__type>' 
requested here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 192: (skipping 3 contexts in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 201: while 

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 6 "Add check check-clang".

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


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

```
Step 6 (Add check check-clang) failure: test (failure)
 TEST 'Clang :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.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/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of 

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-m68k-linux-cross` 
running on `suse-gary-m68k-cross` while building `clang` at step 5 "ninja check 
1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/clang
 -cc1 -internal-isystem 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/lib/clang/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/bin/clang
 -cc1 -internal-isystem 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/stage1/lib/clang/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/var/lib/buildbot/workers/suse-gary-m68k-cross/clang-m68k-linux-cross/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line

[clang] [RFC] Initial implementation of P2719 (PR #113510)

2025-02-21 Thread Oliver Hunt via cfe-commits

ojhunt wrote:

These updates in principle bring the major semantics up to match P2719r4

Primary changes:
* CV qualifiers are dropped
* size and alignment parameters become mandatory, semantics for placement 
cleanup are updated to permit this, and to permit cleanup when the cleanup 
operator delete "matches" a usual deallocation function
* the allocation and cleanup delete operators must be either both type aware or 
neither type aware

To do:
* A class that defines a type aware new or delete must define a complementary 
type aware operator


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


[clang] [llvm] [AArch64][SVE] Lower unpredicated loads/stores as LDR/STR. (PR #127837)

2025-02-21 Thread Ricardo Jesus via cfe-commits

rj-jesus wrote:

Thank you very much for checking! If you have any other comments please let me 
know.

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


[clang] [llvm] [AArch64][SVE] Lower unpredicated loads/stores as LDR/STR. (PR #127837)

2025-02-21 Thread David Green via cfe-commits

davemgreen wrote:

It probably needs to not happen with -fno-unaligned-access (or +strict-align), 
unless the load / store is known to be 16byte aligned. See 
https://github.com/llvm/llvm-project/issues/119732 from recently. (Also I guess 
they shouldn't work in BE, but I believe that is not supported for scalable 
vectors).

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


[clang] [llvm] [AArch64][SVE] Lower unpredicated loads/stores as LDR/STR. (PR #127837)

2025-02-21 Thread Ricardo Jesus via cfe-commits

rj-jesus wrote:

Thanks for the pointer, @davemgreen. You're right, with `+strict-align` this 
has to be 16B aligned.
This is also only valid for LE, but this should already be enforced.

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


[clang] [analyzer] Add time-trace scopes for high-level analyzer steps (PR #125508)

2025-02-21 Thread Arseniy Zaostrovnykh via cfe-commits


@@ -179,8 +181,41 @@ bool CoreEngine::ExecuteWorkList(const LocationContext *L, 
unsigned MaxSteps,
   return WList->hasWork();
 }
 
-void CoreEngine::dispatchWorkItem(ExplodedNode* Pred, ProgramPoint Loc,
-  const WorkListUnit& WU) {
+static std::string timeTraceScopeName(const ProgramPoint &Loc) {
+  if (llvm::timeTraceProfilerEnabled()) {
+return llvm::formatv("Loc {0}",
+ ProgramPoint::getProgramPointKindName(Loc.getKind()))
+.str();
+  }
+  return "";
+}
+
+static llvm::TimeTraceMetadata timeTraceMetadata(const ExplodedNode *Pred,
+ const ProgramPoint &Loc) {
+  // If time-trace profiler is not enabled, this function is never called.
+  assert(llvm::timeTraceProfilerEnabled());
+  std::string Detail = "";
+  if (const auto SP = Loc.getAs()) {
+if (const Stmt *S = SP->getStmt())
+  Detail = S->getStmtClassName();
+  }
+  auto SLoc = Loc.getSourceLocation();
+  if (!SLoc)
+return llvm::TimeTraceMetadata{Detail, ""};
+  const auto &SM = Pred->getLocationContext()
+   ->getAnalysisDeclContext()
+   ->getASTContext()
+   .getSourceManager();
+  auto Line = SM.getPresumedLineNumber(*SLoc);
+  auto Fname = SM.getFilename(*SLoc);
+  return llvm::TimeTraceMetadata{Detail, Fname.str(), static_cast(Line)};
+}
+
+void CoreEngine::dispatchWorkItem(ExplodedNode *Pred, ProgramPoint Loc,
+  const WorkListUnit &WU) {
+  llvm::TimeTraceScope tcs{timeTraceScopeName(Loc), [Loc, Pred]() {
+ return timeTraceMetadata(Pred, Loc);
+   }};

necto wrote:

I have no objection. just wanted to make it shorter so that it can be seen from 
lower resolution

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


[clang] [clang][LoongArch] Add OHOS target (PR #127555)

2025-02-21 Thread via cfe-commits


@@ -235,3 +235,24 @@
 
 // CHECK-OHOS-PTHREAD-NOT: -lpthread
 
+// RUN: %clang -### --target=aarch64-linux-ohos %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-MAXPAGESIZE-4KB %s
+// RUN: %clang -### --target=aarch64-none-linux-gnu %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-MAXPAGESIZE %s
+// RUN: %clang -### --target=loongarch64-linux-ohos %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-MAXPAGESIZE-16KB %s
+// RUN: %clang -### --target=loongarch64-linux-gnu %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-MAXPAGESIZE %s
+// RUN: %clang -### --target=riscv64-linux-ohos %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-MAXPAGESIZE-4KB %s
+// RUN: %clang -### --target=riscv64-unknown-linux-gnu %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-MAXPAGESIZE %s
+// RUN: %clang -### --target=x86_64-linux-ohos %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-MAXPAGESIZE-4KB %s
+// RUN: %clang -### --target=x86_64-none-linux-gnu %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-MAXPAGESIZE %s
+
+
+// CHECK-MAXPAGESIZE-4KB: "-z" "max-page-size=4096"
+// CHECK-MAXPAGESIZE-16KB: "-z" "max-page-size=16384"
+// CHECK-NO-MAXPAGESIZE-NOT: "-z" "max-page-size=4096" "-z" 
"max-page-size=16384"

Ami-zhang wrote:

Do you mean there's no need to add a `CHECK-NO-MAXPAGESIZE` for `gnu` without 
max-page-size? If so, I can remove those checks.

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


[clang] [clang][LoongArch] Add OHOS target (PR #127555)

2025-02-21 Thread via cfe-commits

Ami-zhang wrote:

> Could you add some tests in ohos.c with the `--sysroot` option specified?

Could I confirm what the test targeting the `--sysroot` option is for? Is it 
also intended to test the `page-size`?

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


[clang] [clang][LoongArch] Add OHOS target (PR #127555)

2025-02-21 Thread Lu Weining via cfe-commits


@@ -235,3 +235,24 @@
 
 // CHECK-OHOS-PTHREAD-NOT: -lpthread
 
+// RUN: %clang -### --target=aarch64-linux-ohos %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-MAXPAGESIZE-4KB %s
+// RUN: %clang -### --target=aarch64-none-linux-gnu %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-MAXPAGESIZE %s
+// RUN: %clang -### --target=loongarch64-linux-ohos %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-MAXPAGESIZE-16KB %s
+// RUN: %clang -### --target=loongarch64-linux-gnu %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-MAXPAGESIZE %s
+// RUN: %clang -### --target=riscv64-linux-ohos %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-MAXPAGESIZE-4KB %s
+// RUN: %clang -### --target=riscv64-unknown-linux-gnu %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-MAXPAGESIZE %s
+// RUN: %clang -### --target=x86_64-linux-ohos %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-MAXPAGESIZE-4KB %s
+// RUN: %clang -### --target=x86_64-none-linux-gnu %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=CHECK-NO-MAXPAGESIZE %s
+
+
+// CHECK-MAXPAGESIZE-4KB: "-z" "max-page-size=4096"
+// CHECK-MAXPAGESIZE-16KB: "-z" "max-page-size=16384"
+// CHECK-NO-MAXPAGESIZE-NOT: "-z" "max-page-size=4096" "-z" 
"max-page-size=16384"

SixWeining wrote:

Yes, I think it could be removed.

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


[clang] ad3f7d2 - [clang][bytecode][test] Qualify a std::move call

2025-02-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2025-02-21T09:57:16+01:00
New Revision: ad3f7d2c71b062dd1c2fb1fa78e81cc7b3ba53e9

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

LOG: [clang][bytecode][test] Qualify a std::move call

Try to fix the test failures introduced by 
97ed2019c41f2c0208699ab3593b681487754d58

See https://github.com/llvm/llvm-project/pull/128141

Added: 


Modified: 
clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp

Removed: 




diff  --git a/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp 
b/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
index 475f7ffef4525..f70f412466543 100644
--- a/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+++ b/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
@@ -165,7 +165,7 @@ using iter_value_t =
   int>::value_type;
 namespace ranges {
 struct Trans_NS___iter_move___fn {
-  template  auto operator()(_Ip __i) const -> 
decltype(move(*(__i)));
+  template  auto operator()(_Ip __i) const -> 
decltype(std::move(*(__i)));
 };
 inline namespace {
 auto iter_move = Trans_NS___iter_move___fn{};



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


[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 7 
"test-build-unified-tree-check-all".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -cc1 
-internal-isystem 
/build/buildbot/premerge-monolithic-linux/build/lib/clang/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl::__type>' 
requested here
  File 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituti

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 5 "ninja check 1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ /home/tcwg-buildbot/worker/clang-armv8-quick/stage1/bin/clang -cc1 
-internal-isystem 
/home/tcwg-buildbot/worker/clang-armv8-quick/stage1/lib/clang/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl::__type>' 
requested here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/home/tcwg-buildbot/worker/clang-armv8-quick/llvm/cl

[clang] [clang] Predefine `_CRT_USE_BUILTIN_OFFSETOF` in MS-compatible modes (PR #127568)

2025-02-21 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/127568

>From 2c9e6e45944891af54cba9648297a996bb4d8cca Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 18 Feb 2025 14:03:35 +0800
Subject: [PATCH 1/2] [clang] Predefine `_CRT_USE_BUILTIN_OFFSETOF` in
 MS-compatible modes

This patch makes Clang predefine `_CRT_USE_BUILTIN_OFFSETOF` in
MS-compatible modes. The macro can make the offsetof provided by MS
UCRT's `` to select the `__builtin_offsetof` version,
so with it Clang (Clang-cl) can directly consume UCRT's `offsetof`.

MSVC predefines the macro as `1` since at least VS 2017 19.14, but I
think it's also OK to define it in "older" compatible modes.
---
 clang/lib/Basic/Targets/OSTargets.cpp |  2 ++
 clang/test/Sema/offsetof-ucrt.c   | 17 +
 clang/test/SemaCXX/offsetof-ucrt.cpp  | 17 +
 3 files changed, 36 insertions(+)
 create mode 100644 clang/test/Sema/offsetof-ucrt.c
 create mode 100644 clang/test/SemaCXX/offsetof-ucrt.cpp

diff --git a/clang/lib/Basic/Targets/OSTargets.cpp 
b/clang/lib/Basic/Targets/OSTargets.cpp
index 8af6623e5cb15..2e57c286c9a16 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -220,6 +220,8 @@ static void addVisualCDefines(const LangOptions &Opts, 
MacroBuilder &Builder) {
 Builder.defineMacro("_MSC_FULL_VER", Twine(Opts.MSCompatibilityVersion));
 // FIXME We cannot encode the revision information into 32-bits
 Builder.defineMacro("_MSC_BUILD", Twine(1));
+// https://github.com/llvm/llvm-project/issues/59689
+Builder.defineMacro("_CRT_USE_BUILTIN_OFFSETOF", Twine(1));
 
 if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(LangOptions::MSVC2015))
   Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1));
diff --git a/clang/test/Sema/offsetof-ucrt.c b/clang/test/Sema/offsetof-ucrt.c
new file mode 100644
index 0..60c9ae3b5650e
--- /dev/null
+++ b/clang/test/Sema/offsetof-ucrt.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -verify 
-fms-compatibility
+// expected-no-diagnostics
+
+typedef __typeof__(sizeof(0)) size_t;
+
+#if defined _MSC_VER && !defined _CRT_USE_BUILTIN_OFFSETOF
+#ifdef __cplusplus
+#define offsetof(s,m) ((::size_t)&reinterpret_casts*)0)->m)))
+#else
+#define offsetof(s,m) ((size_t)&(((s*)0)->m))
+#endif
+#else
+#define offsetof(s,m) __builtin_offsetof(s,m)
+#endif
+
+struct S { int a; };
+_Static_assert(offsetof(struct S, a) == 0, "");
diff --git a/clang/test/SemaCXX/offsetof-ucrt.cpp 
b/clang/test/SemaCXX/offsetof-ucrt.cpp
new file mode 100644
index 0..a679fa01133f4
--- /dev/null
+++ b/clang/test/SemaCXX/offsetof-ucrt.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -verify 
-fms-compatibility
+// expected-no-diagnostics
+
+typedef __typeof__(sizeof(0)) size_t;
+
+#if defined _MSC_VER && !defined _CRT_USE_BUILTIN_OFFSETOF
+#ifdef __cplusplus
+#define offsetof(s,m) ((::size_t)&reinterpret_casts*)0)->m)))
+#else
+#define offsetof(s,m) ((size_t)&(((s*)0)->m))
+#endif
+#else
+#define offsetof(s,m) __builtin_offsetof(s,m)
+#endif
+
+struct S { int a; };
+_Static_assert(offsetof(S, a) == 0, "");

>From 4dc9bed47d7b4802e91b1774d8371e169f3f942c Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Fri, 21 Feb 2025 17:00:37 +0800
Subject: [PATCH 2/2] Address @AaronBallman's review comments

---
 clang/lib/Basic/Targets/OSTargets.cpp |  2 +-
 clang/test/Sema/offsetof-ucrt.c   | 11 +++
 clang/test/SemaCXX/offsetof-ucrt.cpp  | 11 +++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Basic/Targets/OSTargets.cpp 
b/clang/lib/Basic/Targets/OSTargets.cpp
index 2e57c286c9a16..e744e84a5b079 100644
--- a/clang/lib/Basic/Targets/OSTargets.cpp
+++ b/clang/lib/Basic/Targets/OSTargets.cpp
@@ -220,7 +220,7 @@ static void addVisualCDefines(const LangOptions &Opts, 
MacroBuilder &Builder) {
 Builder.defineMacro("_MSC_FULL_VER", Twine(Opts.MSCompatibilityVersion));
 // FIXME We cannot encode the revision information into 32-bits
 Builder.defineMacro("_MSC_BUILD", Twine(1));
-// https://github.com/llvm/llvm-project/issues/59689
+// Exposed by MSVC, used in their stddef.h.
 Builder.defineMacro("_CRT_USE_BUILTIN_OFFSETOF", Twine(1));
 
 if (Opts.CPlusPlus11 && Opts.isCompatibleWithMSVC(LangOptions::MSVC2015))
diff --git a/clang/test/Sema/offsetof-ucrt.c b/clang/test/Sema/offsetof-ucrt.c
index 60c9ae3b5650e..05c3d87ce66ca 100644
--- a/clang/test/Sema/offsetof-ucrt.c
+++ b/clang/test/Sema/offsetof-ucrt.c
@@ -1,8 +1,19 @@
 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -verify 
-fms-compatibility
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -verify
 // expected-no-diagnostics
 
 typedef __typeof__(sizeof(0)) size_t;
 
+#ifdef _MSC_VER
+#ifndef _CRT_USE_BUILTIN_OFFSETOF
+#error _CRT_USE_BUILTIN_OFFSETOF should be predefined in MSVC-compatible modes.
+#endif
+#

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 7 "ninja check 1".

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


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

```
Step 7 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.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/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/localdisk2/buildbot/

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 7 
"test-build-unified-tree-check-all".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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\21\include -nostdsysteminc 
-std=c++2c -fexperimental-new-constant-interpreter -verify=expected,both 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.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\21\include' 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp'
# .---command stderr
# | error: 'both-warning' diagnostics seen but not expected: 
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
# | error: 'both-note' diagnostics seen but not expected: 
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 182: in instantiation of requirement here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 182: in instantiation of requirement here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl::__type>' 
requested here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST\ByteCode\libcxx\primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
# |   File 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\AST

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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-4` while building `clang` at step 6 
"test-build-unified-tree-check-all".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl::__type>' 
requested here
  File 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AS

[clang] [clang] Predefine `_CRT_USE_BUILTIN_OFFSETOF` in MS-compatible modes (PR #127568)

2025-02-21 Thread A. Jiang via cfe-commits


@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -verify 
-fms-compatibility

frederick-vs-ja wrote:

Added. I decided to add the positive and negative tests together. Luckily, 
UCRT's `` selects `__builtin_offsetof` when `_MSC_VER` isn't defined.

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


[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 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` at step 6 "test-build-unified-tree-check-all".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

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/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.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/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/b

[clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-02-21 Thread Carlos Galvez via cfe-commits

https://github.com/carlosgalvezp created 
https://github.com/llvm/llvm-project/pull/128150

Currently, clang-tidy processes the entire TranslationUnit, including 
declarations in system headers. However, the work done in system headers is 
discarded at the very end when presenting results, unless the SystemHeaders 
option is active.

This is a lot of wasted work, and makes clang-tidy very slow. In comparison, 
clangd only processes declarations in the main file, and it's claimed to be 10x 
faster than clang-tidy:

https://github.com/lljbash/clangd-tidy

To solve this problem, we can apply a similar solution done in clangd into 
clang-tidy. We do this by changing the traversal scope from the default 
TranslationUnitDecl, to only contain the top-level declarations that are _not_ 
part of system headers. We do this by prepending a new ASTConsumer to the list 
of consumers: this new consumer sets the traversal scope in the ASTContext, 
which is later used by the MatchASTConsumer.

Note: this behavior is not active if the user requests warnings from system 
headers via the SystemHeaders option.

Note2: out of all the unit tests, only one of them fails:

readability/identifier-naming-anon-record-fields.cpp

This is because the limited traversal scope no longer includes the 
"IndirectFieldDecl" that appears in the AST when having a global scope 
anonymous union.

I have not found a way to make this one work. However, it does seem like a very 
niche use case, and the benefits of a 10x faster clang-tidy largely outweigh 
the false negative now introduced by this patch. This use case is therefore 
removed from the unit test to make it pass.

Note3: I have purposely decided to make this new feature enabled by default, 
instead of adding a new "opt-in/opt-out" flag. Having a new flag would mean 
duplicating all our tests to ensure they work in both modes, which would be 
infeasible. Having it enabled by default allow people to get the benefits 
immediately. Given that all unit tests pass, the risk for regressions is low. 
Even if that's the case, the only issue would be false negatives (fewer things 
are detected), which are much more tolerable than false positives.

Credits: original implementation by @njames93, here: 
https://reviews.llvm.org/D150126

This implementation is simpler in the sense that it does not consider 
HeaderFilterRegex to filter even further. A follow-up patch could include the 
functionality if wanted.

Fixes #52959

>From 7961d8adf9a4473989ea89b8dc74d51a2d269e99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= 
Date: Thu, 20 Feb 2025 12:37:15 +
Subject: [PATCH] [clang-tidy] Avoid processing declarations in system headers

Currently, clang-tidy processes the entire TranslationUnit, including
declarations in system headers. However, the work done in system
headers is discarded at the very end when presenting results, unless
the SystemHeaders option is active.

This is a lot of wasted work, and makes clang-tidy very slow.
In comparison, clangd only processes declarations in the main file,
and it's claimed to be 10x faster than clang-tidy:

https://github.com/lljbash/clangd-tidy

To solve this problem, we can apply a similar solution done in clangd
into clang-tidy. We do this by changing the traversal scope from the
default TranslationUnitDecl, to only contain the top-level declarations
that are _not_ part of system headers. We do this by prepending a new
ASTConsumer to the list of consumers: this new consumer sets the
traversal scope in the ASTContext, which is later used by the
MatchASTConsumer.

Note: this behavior is not active if the user requests warnings from
system headers via the SystemHeaders option.

Note2: out of all the unit tests, only one of them fails:

readability/identifier-naming-anon-record-fields.cpp

This is because the limited traversal scope no longer includes the
"IndirectFieldDecl" that appears in the AST when having a global
scope anonymous union.

I have not found a way to make this one work. However, it does seem
like a very niche use case, and the benefits of a 10x faster clang-tidy
largely outweigh the false negative now introduced by this patch. This
use case is therefore removed from the unit test to make it pass.

Note3: I have purposely decided to make this new feature enabled by
default, instead of adding a new "opt-in/opt-out" flag. Having a new
flag would mean duplicating all our tests to ensure they work in both
modes, which would be infeasible. Having it enabled by default allow
people to get the benefits immediately. Given that all unit tests pass,
the risk for regressions is low. Even if that's the case, the only
issue would be false negatives (fewer things are detected), which
are much more tolerable than false positives.

Credits: original implementation by @njames93, here:
https://reviews.llvm.org/D150126

This implementation is simpler in the sense that it does not consider
HeaderFilterRegex to filter even further. A follow-up patch 

[clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-02-21 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-tidy

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

Author: Carlos Galvez (carlosgalvezp)


Changes

Currently, clang-tidy processes the entire TranslationUnit, including 
declarations in system headers. However, the work done in system headers is 
discarded at the very end when presenting results, unless the SystemHeaders 
option is active.

This is a lot of wasted work, and makes clang-tidy very slow. In comparison, 
clangd only processes declarations in the main file, and it's claimed to be 10x 
faster than clang-tidy:

https://github.com/lljbash/clangd-tidy

To solve this problem, we can apply a similar solution done in clangd into 
clang-tidy. We do this by changing the traversal scope from the default 
TranslationUnitDecl, to only contain the top-level declarations that are _not_ 
part of system headers. We do this by prepending a new ASTConsumer to the list 
of consumers: this new consumer sets the traversal scope in the ASTContext, 
which is later used by the MatchASTConsumer.

Note: this behavior is not active if the user requests warnings from system 
headers via the SystemHeaders option.

Note2: out of all the unit tests, only one of them fails:

readability/identifier-naming-anon-record-fields.cpp

This is because the limited traversal scope no longer includes the 
"IndirectFieldDecl" that appears in the AST when having a global scope 
anonymous union.

I have not found a way to make this one work. However, it does seem like a very 
niche use case, and the benefits of a 10x faster clang-tidy largely outweigh 
the false negative now introduced by this patch. This use case is therefore 
removed from the unit test to make it pass.

Note3: I have purposely decided to make this new feature enabled by default, 
instead of adding a new "opt-in/opt-out" flag. Having a new flag would mean 
duplicating all our tests to ensure they work in both modes, which would be 
infeasible. Having it enabled by default allow people to get the benefits 
immediately. Given that all unit tests pass, the risk for regressions is low. 
Even if that's the case, the only issue would be false negatives (fewer things 
are detected), which are much more tolerable than false positives.

Credits: original implementation by @njames93, here: 
https://reviews.llvm.org/D150126

This implementation is simpler in the sense that it does not consider 
HeaderFilterRegex to filter even further. A follow-up patch could include the 
functionality if wanted.

Fixes #52959

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


5 Files Affected:

- (modified) clang-tools-extra/clang-tidy/ClangTidy.cpp (+54) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-anon-record-fields.cpp
 (-18) 
- (modified) clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp 
(-7) 
- (modified) 
clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp (+2-2) 


``diff
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 959b11777e88d..6edaea30768b1 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -339,6 +339,56 @@ class ClangTidyASTConsumer : public MultiplexConsumer {
   void anchor() override {};
 };
 
+/// ASTConsumer that filters top-level declarations that are in system headers,
+/// and sets the AST traversal scope to only cover the declarations in user
+/// headers. This makes all clang-tidy checks avoid spending time processing
+/// declarations in system headers. The results are discarded anyway when
+/// presenting the results.
+class IgnoreSystemHeadersConsumer : public ASTConsumer {
+public:
+  void Initialize(ASTContext &Context) override {
+// Make sure the main file ID always gets included.
+Cache.insert(
+std::make_pair(Context.getSourceManager().getMainFileID(), true));
+  }
+
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (Decl *D : DG) {
+  if (shouldKeepDecl(D))
+Decls.push_back(D);
+}
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+Ctx.setTraversalScope(Decls);
+  }
+
+private:
+  llvm::DenseMap Cache;
+  std::vector Decls;
+
+  bool shouldKeepDecl(Decl *D) {
+auto &SM = D->getASTContext().getSourceManager();
+FileID FID = SM.getDecomposedExpansionLoc(D->getLocation()).first;
+
+// Invalid file, keep the declaration to be on the safe side
+if (FID.isInvalid() || FID == FileID::getSentinel())
+  return true;
+
+// Check the cache
+auto [Item, Inserted] = Cache.try_emplace(FID, true);
+if (!Inserted)
+  return Item->second;
+
+// If not in the cache, check and update
+SrcMgr::SLocEntry Entry =
+SM.getLocalSLocEntry(static_cast(FID.getHashValue()));
+Item->second = !SrcMgr::isSystem(Entry.getFile().getFileCharacter

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/clang -cc1 
-internal-isystem 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/lib/clang/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ /vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/bin/clang -cc1 
-internal-isystem 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/build/lib/clang/21/include 
-nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of function template specialization 
'std::ranges::__for_each::operator()' requested here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = std::__projected_impl::__type]
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/vol/worker/clang-debian-cpp20/clang-debian-cpp20/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readab

[clang] [flang] [flang][Driver] Add support of -fd-lines-as-comments and -fd-lines-as-code flags (PR #127605)

2025-02-21 Thread Jean-Didier PAILLEUX via cfe-commits

https://github.com/JDPailleux updated 
https://github.com/llvm/llvm-project/pull/127605

>From 75c8eb0bf27529c629da02b140502e7557b9be46 Mon Sep 17 00:00:00 2001
From: Jean-Didier Pailleux 
Date: Tue, 18 Feb 2025 10:12:32 +0100
Subject: [PATCH] [flang][Driver] Add support of -fd-lines-as-comments and
 -fd-lines-as-code flags

---
 clang/include/clang/Driver/Options.td | 12 --
 clang/lib/Driver/ToolChains/Flang.cpp |  2 ++
 flang/lib/Frontend/CompilerInvocation.cpp | 26 
 flang/test/Driver/fd-lines-as.f90 | 29 +++
 flang/test/Preprocessing/fd-lines-as.f90  | 23 ++
 5 files changed, 90 insertions(+), 2 deletions(-)
 create mode 100644 flang/test/Driver/fd-lines-as.f90
 create mode 100644 flang/test/Preprocessing/fd-lines-as.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 5ad187926e710..91d57bb73e5bb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6747,8 +6747,16 @@ defm backtrace : BooleanFFlag<"backtrace">, 
Group;
 defm bounds_check : BooleanFFlag<"bounds-check">, Group;
 defm check_array_temporaries : BooleanFFlag<"check-array-temporaries">, 
Group;
 defm cray_pointer : BooleanFFlag<"cray-pointer">, Group;
-defm d_lines_as_code : BooleanFFlag<"d-lines-as-code">, Group;
-defm d_lines_as_comments : BooleanFFlag<"d-lines-as-comments">, 
Group;
+defm d_lines_as_code : BooleanFFlag<"d-lines-as-code">,
+   HelpText<"Treat fixed form lines with 'd' or 'D' in the 
"
+"first column as blank.">,
+   Group,
+   Visibility<[FlangOption, FC1Option]>;
+defm d_lines_as_comments : BooleanFFlag<"d-lines-as-comments">,
+   HelpText<"Treat fixed form lines with 'd' or 'D' in 
"
+"the first column as comments.">,
+   Group,
+   Visibility<[FlangOption, FC1Option]>;
 defm dollar_ok : BooleanFFlag<"dollar-ok">, Group;
 defm dump_fortran_optimized : BooleanFFlag<"dump-fortran-optimized">, 
Group;
 defm dump_fortran_original : BooleanFFlag<"dump-fortran-original">, 
Group;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 9ad795edd724d..4c452491fa415 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -60,6 +60,8 @@ void Flang::addFortranDialectOptions(const ArgList &Args,
 options::OPT_frealloc_lhs,
 options::OPT_fno_realloc_lhs,
 options::OPT_fsave_main_program,
+options::OPT_fd_lines_as_code,
+options::OPT_fd_lines_as_comments,
 options::OPT_fno_save_main_program});
 }
 
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index f3d9432c62d3b..cb01b1f9ff16f 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -957,6 +957,32 @@ static bool parseDialectArgs(CompilerInvocation &res, 
llvm::opt::ArgList &args,
  clang::DiagnosticsEngine &diags) {
   unsigned numErrorsBefore = diags.getNumErrors();
 
+  // -fd-lines-as-code
+  if (args.hasArg(clang::driver::options::OPT_fd_lines_as_code)) {
+if (res.getFrontendOpts().fortranForm == FortranForm::FreeForm) {
+  const unsigned fdLinesAsWarning = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Warning,
+  "‘-fd-lines-as-code’ has no effect in free form.");
+  diags.Report(fdLinesAsWarning);
+} else {
+  res.getFrontendOpts().features.Enable(
+  Fortran::common::LanguageFeature::OldDebugLines, true);
+}
+  }
+
+  // -fd-lines-as-comments
+  if (args.hasArg(clang::driver::options::OPT_fd_lines_as_comments)) {
+if (res.getFrontendOpts().fortranForm == FortranForm::FreeForm) {
+  const unsigned fdLinesAsWarning = diags.getCustomDiagID(
+  clang::DiagnosticsEngine::Warning,
+  "‘-fd-lines-as-comments’ has no effect in free form.");
+  diags.Report(fdLinesAsWarning);
+} else {
+  res.getFrontendOpts().features.Enable(
+  Fortran::common::LanguageFeature::OldDebugLines, false);
+}
+  }
+
   // -fdefault* family
   if (args.hasArg(clang::driver::options::OPT_fdefault_real_8)) {
 res.getDefaultKinds().set_defaultRealKind(8);
diff --git a/flang/test/Driver/fd-lines-as.f90 
b/flang/test/Driver/fd-lines-as.f90
new file mode 100644
index 0..ea06a39378e28
--- /dev/null
+++ b/flang/test/Driver/fd-lines-as.f90
@@ -0,0 +1,29 @@
+! Ensure arguments -fd-lines-as-comments and -fd-lines-as-code as expected.
+
+!--
+! FLANG DRIVER (flang)
+!--
+! Default behavior is equivalent as -fd-

[clang] [clang][bytecode] Use ExtendingDecl mechanism for primitives as well (PR #128141)

2025-02-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-ppc64le-linux-test-suite` running on `ppc64le-clang-test-suite` while 
building `clang` at step 6 "test-build-unified-tree-check-all".

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


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 :: 
AST/ByteCode/libcxx/primitive-temporary.cpp' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/clang
 -cc1 -internal-isystem 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/lib/clang/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
+ 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/bin/clang
 -cc1 -internal-isystem 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/build/lib/clang/21/include
 -nostdsysteminc -std=c++2c -fexperimental-new-constant-interpreter 
-verify=expected,both 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
error: 'both-warning' diagnostics seen but not expected: 
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 168: unqualified call to 'std::move'
error: 'both-note' diagnostics seen but not expected: 
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: while substituting deduced template arguments into function template 
'operator()' [with _Ip = T *]
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 182: in instantiation of requirement here
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 181: while substituting template arguments into constraint expression here
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while checking the satisfaction of concept 
'__indirectly_readable_impl' requested here
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 188: while substituting template arguments into constraint expression here
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: (skipping 1 context in backtrace; use -ftemplate-backtrace-limit=0 
to see all)
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 221: while substituting template arguments into constraint expression here
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while checking constraint satisfaction for template 'projected' required here
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 238: while substituting template arguments into constraint expression here
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: while checking constraint satisfaction for template 'operator()' required here
  File 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-test-suite/clang-ppc64le-test-suite/llvm-project/clang/test/AST/ByteCode/libcxx/primitive-temporary.cpp
 Line 268: in instantiation of fu

[clang] [Clang] Implement CWG2918 'Consideration of constraints for address of overloaded function' (PR #127773)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -1773,20 +1773,19 @@ bool Sema::IsAtLeastAsConstrained(NamedDecl *D1,
   NamedDecl *D2,
   MutableArrayRef AC2,
   bool &Result) {
+#ifndef NDEBUG
   if (const auto *FD1 = dyn_cast(D1)) {
 auto IsExpectedEntity = [](const FunctionDecl *FD) {
   FunctionDecl::TemplatedKind Kind = FD->getTemplatedKind();

erichkeane wrote:

Yeah, sorry, I thought I deleted this comment.  

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


[clang] Reapply "[Analyzer][CFG] Correctly handle rebuilt default arg and default init expression" (PR #127338)

2025-02-21 Thread Jan Voung via cfe-commits

jvoung wrote:

In case others notice similar in ClangTidy 
(`bugprone-unchecked-optional-access`), we are seeing crashes after this change 
https://github.com/llvm/llvm-project/issues/128068

I'm not yet sure the best fix.

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


[clang] [CIR] Better handling of `void` function return (PR #128089)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -331,9 +335,38 @@ FuncType FuncType::clone(TypeRange inputs, TypeRange 
results) const {
   return get(llvm::to_vector(inputs), results[0], isVarArg());
 }
 
-mlir::ParseResult parseFuncTypeArgs(mlir::AsmParser &p,
-llvm::SmallVector ¶ms,
-bool &isVarArg) {
+// A special parser is needed for function returning void to handle the missing
+// type.
+static mlir::ParseResult parseFuncTypeReturn(mlir::AsmParser &p,
+ mlir::Type &optionalReturnType) {
+  if (succeeded(p.parseOptionalLParen())) {
+// If we have already a '(', the function has no return type
+optionalReturnType = {};
+return mlir::success();
+  }
+  mlir::Type type;
+  if (p.parseType(type))
+return mlir::failure();
+  if (isa(type))
+// An explicit !cir.void means also no return type.
+optionalReturnType = {};
+  else
+// Otherwise use the actual type.
+optionalReturnType = type;
+  return p.parseLParen();
+}
+
+// A special pretty-printer for function returning or not a result.
+static void printFuncTypeReturn(mlir::AsmPrinter &p,
+mlir::Type optionalReturnType) {
+  if (optionalReturnType)
+p << optionalReturnType << ' ';
+  p << '(';
+}
+
+static mlir::ParseResult
+parseFuncTypeArgs(mlir::AsmParser &p, llvm::SmallVector ¶ms,
+  bool &isVarArg) {
   isVarArg = false;
   // `(` `)`
   if (succeeded(p.parseOptionalRParen()))

erichkeane wrote:

@lanza @bcardosolopes Anyone have any ideas here?  This parsing is REALLY 
weird, but we still need a way to know that we're 'done'.

The other alternative is to change how these are printed/read (so it is 
something like: `(returnType)(Arg1, Arg2)` with whatever delimiters make 
sense), but I'm not sure that is something that can be done sensibly.

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


[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2025-02-21 Thread Denis Mikhailov via cfe-commits


@@ -0,0 +1,130 @@
+//===--- AmbiguousSmartptrResetCallCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AmbiguousSmartptrResetCallCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+
+AST_MATCHER(CXXMethodDecl, hasOnlyDefaultParameters) {
+  for (const auto *Param : Node.parameters()) {
+if (!Param->hasDefaultArg())
+  return false;
+  }
+
+  return true;
+}
+
+const auto DefaultSmartPointers = "::std::shared_ptr;::std::unique_ptr;"
+  "::boost::shared_ptr;::boost::scoped_ptr";

denzor200 wrote:

Since this check is unable to handle the issue with `::boost::scoped_ptr`, here 
I requested another check to get rid of scoped_ptr: 
https://github.com/llvm/llvm-project/issues/128179

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -2862,6 +2862,30 @@ bool QualType::isTriviallyRelocatableType(const 
ASTContext &Context) const {
   }
 }
 
+bool QualType::isCppTriviallyRelocatableType(const ASTContext &Context) const {
+  QualType BaseElementType = Context.getBaseElementType(*this);
+  if (BaseElementType->isIncompleteType())
+return false;
+  if (BaseElementType->isScalarType())
+return true;
+  if (const auto *RD = BaseElementType->getAsCXXRecordDecl())
+return RD->isTriviallyRelocatable();
+  return false;
+}
+
+bool QualType::isReplaceableType(const ASTContext &Context) const {
+  if (isConstQualified())

Sirraide wrote:

Don’t we also need to check `isVolatileQualified()` here?

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -1057,12 +1057,24 @@ def ext_ms_abstract_keyword : ExtWarn<
   "'abstract' keyword is a Microsoft extension">,
   InGroup;
 
+def ext_relocatable_keyword : ExtWarn<
+  "'%select{trivially_relocatable|replaceable}0_if_eligible' "
+  "keyword is a C++2c extension">,
+  InGroup;
+def warn_relocatable_keyword  : Warning<
+  "'%select{trivially_relocatable|replaceable}0_if_eligible' "
+  "keyword is incompatible with standards before C++2c">,
+  DefaultIgnore, InGroup;
+
 def err_access_specifier_interface : Error<
   "interface types cannot specify '%select{private|protected}0' access">;
 
 def err_duplicate_class_virt_specifier : Error<
   "class already marked '%0'">;
 
+def err_duplicate_class_relocation_specifier : Error<
+  "class already marked 
%select{'trivially_relocatable_if_eligible'|'replaceable_if_eligible'}0">;

Sirraide wrote:

```suggestion
  "class already marked 
'%select{trivially_relocatable|replaceable}0_if_eligible'">;
```
nit (might as well do this the same way as above)

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


[clang] 4d6167e - [Clang] [Tests] Canonicalise CLANG_ENABLE_OBJC_REWRITER properly (#125117)

2025-02-21 Thread via cfe-commits

Author: Sirraide
Date: 2025-02-21T15:37:57+01:00
New Revision: 4d6167ed96d324cb1decb350c6d6d31090182040

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

LOG: [Clang] [Tests] Canonicalise CLANG_ENABLE_OBJC_REWRITER properly (#125117)

Canonicalise this CMake variable properly as suggested in
https://github.com/llvm/llvm-project/pull/119269#discussion_r1935034073

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index b796a51ef600e..4ff81e7055c57 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -9,6 +9,7 @@ llvm_canonicalize_cmake_booleans(
   CLANG_PLUGIN_SUPPORT
   CLANG_SPAWN_CC1
   CLANG_ENABLE_CIR
+  CLANG_ENABLE_OBJC_REWRITER
   ENABLE_BACKTRACES
   LLVM_BUILD_EXAMPLES
   LLVM_BYE_LINK_INTO_TOOLS

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 6890da5327cb9..80cded2625df4 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -22,7 +22,7 @@ config.host_cxx = "@CMAKE_CXX_COMPILER@"
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 config.have_zstd = @LLVM_ENABLE_ZSTD@
-config.clang_objc_rewriter = "@CLANG_ENABLE_OBJC_REWRITER@" == "ON"
+config.clang_objc_rewriter = @CLANG_ENABLE_OBJC_REWRITER@
 config.clang_default_pie_on_linux = @CLANG_DEFAULT_PIE_ON_LINUX@
 config.clang_default_cxx_stdlib = "@CLANG_DEFAULT_CXX_STDLIB@"
 config.clang_staticanalyzer = @CLANG_ENABLE_STATIC_ANALYZER@



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


[clang] [Clang] [Tests] Canonicalise CLANG_ENABLE_OBJC_REWRITER properly (PR #125117)

2025-02-21 Thread via cfe-commits

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -7258,6 +7261,221 @@ void Sema::CheckCompletedCXXClass(Scope *S, 
CXXRecordDecl *Record) {
   }
 }
 
+static bool hasSuitableConstructorForReplaceability(CXXRecordDecl *D,
+bool Implicit) {
+  assert(D->hasDefinition() && !D->isInvalidDecl());
+
+  bool HasDeletedMoveConstructor = false;
+  bool HasDeletedCopyConstructor = false;
+  bool HasMoveConstructor = D->needsImplicitMoveConstructor();
+  bool HasDefaultedMoveConstructor = D->needsImplicitMoveConstructor();
+  bool HasDefaultedCopyConstructor = D->needsImplicitMoveConstructor();
+
+  for (const Decl *D : D->decls()) {
+auto *MD = dyn_cast(D);
+if (!MD || MD->isIneligibleOrNotSelected())
+  continue;
+
+if (MD->isMoveConstructor()) {
+  HasMoveConstructor = true;
+  if (MD->isDefaulted())
+HasDefaultedMoveConstructor = true;
+  if (MD->isDeleted())
+HasDeletedMoveConstructor = true;
+}
+if (MD->isCopyConstructor()) {
+  if (MD->isDefaulted())
+HasDefaultedCopyConstructor = true;
+  if (MD->isDeleted())
+HasDeletedCopyConstructor = true;
+}
+  }
+
+  if (HasMoveConstructor)
+return !HasDeletedMoveConstructor &&
+   (Implicit ? HasDefaultedMoveConstructor : true);
+  return !HasDeletedCopyConstructor &&
+ (Implicit ? HasDefaultedCopyConstructor : true);
+  ;
+}
+
+static bool hasSuitableMoveAssignmentOperatorForReplaceability(CXXRecordDecl 
*D,
+   bool Implicit) {
+  assert(D->hasDefinition() && !D->isInvalidDecl());
+
+  if (D->hasExplicitlyDeletedMoveAssignment())
+return false;
+
+  bool HasDeletedMoveAssignment = false;
+  bool HasDeletedCopyAssignment = false;
+  bool HasMoveAssignment = D->needsImplicitMoveAssignment();
+  bool HasDefaultedMoveAssignment = D->needsImplicitMoveAssignment();
+  bool HasDefaultedCopyAssignment = D->needsImplicitCopyAssignment();
+
+  for (const Decl *D : D->decls()) {
+auto *MD = dyn_cast(D);
+if (!MD || MD->isIneligibleOrNotSelected())
+  continue;
+
+if (MD->isMoveAssignmentOperator()) {
+  HasMoveAssignment = true;
+  if (MD->isDefaulted())
+HasDefaultedMoveAssignment = true;
+  if (MD->isDeleted())
+HasDeletedMoveAssignment = true;
+}
+if (MD->isCopyAssignmentOperator()) {
+  if (MD->isDefaulted())
+HasDefaultedCopyAssignment = true;
+  if (MD->isDeleted())
+HasDeletedCopyAssignment = true;
+}
+  }
+
+  if (HasMoveAssignment)
+return !HasDeletedMoveAssignment &&
+   (Implicit ? HasDefaultedMoveAssignment : true);
+  return !HasDeletedCopyAssignment &&
+ (Implicit ? HasDefaultedCopyAssignment : true);
+}
+
+void Sema::CheckCXX2CTriviallyRelocatable(CXXRecordDecl *D) {

Sirraide wrote:

When it comes to this function, I’m having to think pretty hard to try and pair 
the code here w/ the wording on the standard; imo it would help if you could 
add some comments that briefly show which sections in this function correspond 
to what condition(s) in the standard. 

Also, I think factoring most of this out into either a lambda or a separate 
function so we can early-return whenever `IsTriviallyRelocatable` is set to 
`false` here would aid readability as well.

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


[clang] b732e14 - [Clang] Default the warning for chained comparison to an error. (#128145)

2025-02-21 Thread via cfe-commits

Author: cor3ntin
Date: 2025-02-21T15:52:09+01:00
New Revision: b732e14cb5681abff78e3873987a2a8b39549c83

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

LOG: [Clang] Default the warning for chained comparison to an error. (#128145)

Boolean constructs of the form `a < b < c`
never express the likely intent of the user and
we have been warning on them since clang 19.

WG21 is likely to deprecate or make that construct in the future. To
gain more experience and to improve safety, this patches preempt future
language evolution by turning
warn_consecutive_comparison in an error, by default (which can be
disabled with `-Wno-error=parentheses`)

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c
clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/Sema/bool-compare.c
clang/test/Sema/parentheses.cpp
clang/test/SemaCXX/bool-compare.cpp
clang/test/SemaCXX/cxx2a-adl-only-template-id.cpp
clang/test/SemaTemplate/typo-dependent-name.cpp
clang/test/SemaTemplate/typo-template-name.cpp

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c
index 53c6139dcfbc2..7a4322c6a00c0 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.c
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-chained-comparison %t
+// RUN: %check_clang_tidy --extra-arg=-Wno-error=parentheses %s 
bugprone-chained-comparison %t
 
 void badly_chained_1(int x, int y, int z)
 {

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp
index 8a664aa205acf..88813f72e37ca 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/chained-comparison.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++98-or-later %s bugprone-chained-comparison %t
+// RUN: %check_clang_tidy -std=c++98-or-later 
--extra-arg=-Wno-error=parentheses %s bugprone-chained-comparison %t
 
 void badly_chained_1(int x, int y, int z)
 {

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e1c61992512b5..01c58295613d7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -147,6 +147,8 @@ Improvements to Clang's diagnostics
 - The ``-Wunsafe-buffer-usage`` warning has been updated to warn
   about unsafe libc function calls.  Those new warnings are emitted
   under the subgroup ``-Wunsafe-buffer-usage-in-libc-call``.
+- Diagnostics on chained comparisons (``a < b < c``) are now an error by 
default. This can be disabled with
+  ``-Wno-error=parentheses``.
 
 Improvements to Clang's time-trace
 --

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index feef50812eca9..f4f1bc67724a1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7126,7 +7126,7 @@ def note_precedence_conditional_first : Note<
 
 def warn_consecutive_comparison : Warning<
   "comparisons like 'X<=Y<=Z' don't have their mathematical meaning">,
-  InGroup;
+  InGroup, DefaultError;
 
 def warn_enum_constant_in_bool_context : Warning<
   "converting the enum constant to a boolean">,

diff  --git a/clang/test/Sema/bool-compare.c b/clang/test/Sema/bool-compare.c
index 2308dc4bf2bb2..861f47864ddd9 100644
--- a/clang/test/Sema/bool-compare.c
+++ b/clang/test/Sema/bool-compare.c
@@ -85,7 +85,7 @@ void f(int x, int y, int z) {
   if ((ayy z)  {} // no warning
   if((a(zy)  {} // expected-warning {{comparisons like 'X<=Y<=Z' don't 
have their mathematical meaning}}
+  if (zy)  {} // expected-error {{comparisons like 'X<=Y<=Z' don't have 
their mathematical meaning}}
   if (z > (a(a&1 | FileCheck %s
+// RUN: %clang_cc1 -Wno-error=parentheses -fsyntax-only -verify %s
+// RUN: %clang_cc1 -Wno-error=parentheses -fsyntax-only 
-fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s
 
 bool someConditionFunc();
 

diff  --git a/clang/test/SemaCXX/bool-compare.cpp 
b/clang/test/SemaCXX/bool-compare.cpp
index 4e33e076a7de4..077d55ff9367d 100644
--- a/clang/test/SemaCXX/bool-compare.cpp
+++ b/clang/test/SemaCXX/bool-compare.cpp
@@ -98,7 +98,7 @@ void f(int x, int y, int z) {
   if ((ayy z)  {} // no warning
   if((a(zy)  {} // expected-warning {{comparisons like 'X<=Y<=Z' don't

[clang] [Clang] [Tests] Canonicalise CLANG_ENABLE_OBJC_REWRITER properly (PR #125117)

2025-02-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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-libc-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib
  -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 -Xoffload-linker -lc -Xoffload-linker -lm 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fprofile-generate  -Xclang "-fprofile-instrument=llvm"
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp -I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib
 -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 -Xoffload-linker -lc -Xoffload-linker -lm 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fprofile-generate -Xclang -fprofile-instrument=llvm
# RUN: at line 3
env LLVM_PROFILE_FILE=llvm.profraw 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
 2>&1
# executed command: env LLVM_PROFILE_FILE=llvm.profraw 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/Output/pgo1.c.tmp
# RUN: at line 4
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-profdata
 show --all-functions --counts  amdgcn-amd-amdhsa.llvm.profraw | 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
  --check-prefix="LLVM-PGO"
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-profdata
 show --all-functions --counts amdgcn-amd-amdhsa.llvm.profraw
# executed command: 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/FileCheck
 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test/offloading/pgo1.c
 --check-prefix=LLVM-PGO
# RUN: at line 8
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/offload/test 
-I 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offl

[clang] [clang-tools-extra] [Clang] Default the warning for chained comparison to an error. (PR #128145)

2025-02-21 Thread via cfe-commits

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


[clang] [clang] Predefine `_CRT_USE_BUILTIN_OFFSETOF` in MS-compatible modes (PR #127568)

2025-02-21 Thread Aaron Ballman via cfe-commits

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

LGTM! When landing, please add a release note to `clang/docs/ReleaseNotes.rst` 
so users know about the change.

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -0,0 +1,272 @@
+// RUN: %clang_cc1 -std=c++2c -verify %s
+
+class Trivial {};
+struct NonRelocatable {
+~NonRelocatable();
+};
+static NonRelocatable NonRelocatable_g;
+
+class A trivially_relocatable_if_eligible {};
+class B trivially_relocatable_if_eligible : Trivial{};
+class C trivially_relocatable_if_eligible {
+int a;
+void* b;
+int c[3];
+Trivial d[3];
+NonRelocatable& e = NonRelocatable_g;
+};
+class D trivially_relocatable_if_eligible : Trivial {};
+class E trivially_relocatable_if_eligible : virtual Trivial {};
+
+class F trivially_relocatable_if_eligible : NonRelocatable {};
+
+class I trivially_relocatable_if_eligible {
+NonRelocatable a;
+NonRelocatable b[1];
+const NonRelocatable c;
+const NonRelocatable d[1];
+};
+
+class J trivially_relocatable_if_eligible:  virtual Trivial, NonRelocatable {
+NonRelocatable a;
+};
+
+class G trivially_relocatable_if_eligible {
+G(G&&);
+};
+
+class H trivially_relocatable_if_eligible {
+~H();
+};
+
+struct Incomplete; // expected-note {{forward declaration of 'Incomplete'}}
+static_assert(__builtin_is_cpp_trivially_relocatable(Incomplete));  // 
expected-error {{incomplete type 'Incomplete' used in type trait expression}}
+static_assert(__builtin_is_cpp_trivially_relocatable(Trivial));
+static_assert(__builtin_is_cpp_trivially_relocatable(G));
+static_assert(__builtin_is_cpp_trivially_relocatable(H));
+static_assert(__builtin_is_cpp_trivially_relocatable(int));
+static_assert(__builtin_is_cpp_trivially_relocatable(void*));
+static_assert(!__builtin_is_cpp_trivially_relocatable(int&));
+static_assert(!__builtin_is_cpp_trivially_relocatable(Trivial&));
+static_assert(__builtin_is_cpp_trivially_relocatable(const Trivial));
+static_assert(__builtin_is_cpp_trivially_relocatable(Trivial[1]));
+
+struct UserDtr {
+~UserDtr();
+};
+
+struct DefaultedDtr {
+~DefaultedDtr() = default;
+};
+struct UserMoveWithDefaultCopy {
+UserMoveWithDefaultCopy(UserMoveWithDefaultCopy&&);
+UserMoveWithDefaultCopy(const UserMoveWithDefaultCopy&) = default;
+};
+
+struct UserMove{
+UserMove(UserMove&&);
+};
+
+struct UserMoveDefault{
+UserMoveDefault(UserMoveDefault&&) = default;
+};
+
+struct UserCopy{
+UserCopy(const UserCopy&);
+};
+
+struct UserCopyDefault{
+UserCopyDefault(const UserCopyDefault&) = default;
+};
+
+
+struct UserDeletedMove{
+UserDeletedMove(UserDeletedMove&) = delete;
+UserDeletedMove(const UserDeletedMove&) = default;
+};
+
+static_assert(!__builtin_is_cpp_trivially_relocatable(UserDtr));
+static_assert(__builtin_is_cpp_trivially_relocatable(DefaultedDtr));
+static_assert(!__builtin_is_cpp_trivially_relocatable(UserMoveWithDefaultCopy));
+static_assert(!__builtin_is_cpp_trivially_relocatable(UserMove));
+static_assert(!__builtin_is_cpp_trivially_relocatable(UserCopy));
+static_assert(__builtin_is_cpp_trivially_relocatable(UserMoveDefault));
+static_assert(__builtin_is_cpp_trivially_relocatable(UserCopyDefault));
+static_assert(__builtin_is_cpp_trivially_relocatable(UserDeletedMove));
+
+template 
+class TestDependentErrors trivially_relocatable_if_eligible : T {};
+TestDependentErrors Ok;
+TestDependentErrors Err;
+
+struct DeletedMove {
+DeletedMove(DeletedMove&&) = delete;
+};
+struct DeletedCopy {
+DeletedCopy(const DeletedCopy&) = delete;
+};
+struct DeletedMoveAssign {
+DeletedMoveAssign& operator=(DeletedMoveAssign&&) = delete;
+};
+
+static_assert(!__builtin_is_cpp_trivially_relocatable(DeletedMove));
+static_assert(!__builtin_is_cpp_trivially_relocatable(DeletedCopy));
+static_assert(!__builtin_is_cpp_trivially_relocatable(DeletedMoveAssign));
+
+union U {
+G g;
+};
+static_assert(!__is_trivially_copyable(U));
+static_assert(__builtin_is_cpp_trivially_relocatable(U));
+
+
+namespace replaceable {
+
+struct DeletedMove {
+DeletedMove(DeletedMove&&) = delete;
+};
+struct DeletedCopy {
+DeletedCopy(const DeletedCopy&) = delete;
+};
+struct DeletedMoveAssign {
+DeletedMoveAssign& operator=(DeletedMoveAssign&&) = delete;
+};
+
+struct DefaultedMove {
+DefaultedMove(DefaultedMove&&) = default;
+DefaultedMove& operator=(DefaultedMove&&) = default;
+};
+struct DefaultedCopy {
+DefaultedCopy(const DefaultedCopy&) = default;
+DefaultedCopy(DefaultedCopy&&) = default;
+DefaultedCopy& operator=(DefaultedCopy&&) = default;
+};
+struct DefaultedMoveAssign {
+DefaultedMoveAssign(DefaultedMoveAssign&&) = default;
+DefaultedMoveAssign& operator=(DefaultedMoveAssign&&) = default;
+};
+
+struct UserProvidedMove {
+UserProvidedMove(UserProvidedMove&&){};
+};
+struct UserProvidedCopy {
+UserProvidedCopy(const UserProvidedCopy&) {};
+};
+struct UserProvidedMoveAssign {
+UserProvidedMoveAssign& operator=(const UserProvidedMoveAssign&){return 
*this;};
+};
+
+struct Empty{};
+static_assert(__builtin_is_replaceable(Empty));
+struct S1 replaceable_if_eligible{};
+static_assert(__builtin_is_replaceable(

[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -0,0 +1,272 @@
+// RUN: %clang_cc1 -std=c++2c -verify %s
+
+class Trivial {};
+struct NonRelocatable {
+~NonRelocatable();
+};
+static NonRelocatable NonRelocatable_g;
+
+class A trivially_relocatable_if_eligible {};
+class B trivially_relocatable_if_eligible : Trivial{};
+class C trivially_relocatable_if_eligible {
+int a;
+void* b;
+int c[3];
+Trivial d[3];
+NonRelocatable& e = NonRelocatable_g;

Sirraide wrote:

Maybe add some `const`/`volatile` members too.

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -1875,6 +1875,54 @@ static ExprResult BuiltinIsWithinLifetime(Sema &S, 
CallExpr *TheCall) {
 << 0;
 return ExprError();
   }
+  return TheCall;
+}
+
+static ExprResult BuiltinTriviallyRelocate(Sema &S, CallExpr *TheCall) {
+  if (S.checkArgCount(TheCall, 3))
+return ExprError();
+
+  QualType Dest = TheCall->getArg(0)->getType();
+  if (!Dest->isPointerType() || Dest.getCVRQualifiers() != 0) {
+S.Diag(TheCall->getArg(0)->getExprLoc(),
+   diag::err_builtin_trivially_relocate_invalid_arg_type)
+<< /*a pointer*/ 0;
+return ExprError();
+  }
+
+  QualType T = Dest->getPointeeType();
+  if (S.RequireCompleteType(TheCall->getBeginLoc(), T,
+diag::err_incomplete_type))
+return ExprError();
+
+  if (T.isConstQualified() ||
+  !T.isCppTriviallyRelocatableType(S.getASTContext())) {
+S.Diag(TheCall->getArg(0)->getExprLoc(),
+   diag::err_builtin_trivially_relocate_invalid_arg_type)
+<< (T.isConstQualified() ? /*non-const*/ 1 : /*relocatable*/ 2);
+return ExprError();
+  }
+
+  TheCall->setType(Dest);
+
+  QualType Src = TheCall->getArg(1)->getType();
+  if (Src.getCanonicalType() != Dest.getCanonicalType()) {
+S.Diag(TheCall->getArg(0)->getExprLoc(),
+   diag::err_builtin_trivially_relocate_invalid_arg_type)
+<< /*the same*/ 3;
+return ExprError();
+  }
+
+  Expr *SizeExpr = TheCall->getArg(2);
+  ExprResult Size = S.DefaultLvalueConversion(SizeExpr);

Sirraide wrote:

On that note, don’t we also need to perform `DefaultLvalueConversion` on the 
two pointer arguments?

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -2692,16 +2693,75 @@ bool Parser::isCXX11FinalKeyword() const {
  Specifier == VirtSpecifiers::VS_Sealed;
 }
 
+bool Parser::isCXX2CTriviallyRelocatableKeyword(Token Tok) const {
+  if (!getLangOpts().CPlusPlus || Tok.isNot(tok::identifier))
+return false;
+  if (!Ident_trivially_relocatable_if_eligible)
+Ident_trivially_relocatable_if_eligible =
+&PP.getIdentifierTable().get("trivially_relocatable_if_eligible");
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  return II == Ident_trivially_relocatable_if_eligible;
+}
+
+bool Parser::isCXX2CTriviallyRelocatableKeyword() const {
+  return isCXX2CTriviallyRelocatableKeyword(Tok);
+}
+
+void Parser::ParseOptionalCXX2CTriviallyRelocatableSpecifier(
+TriviallyRelocatableSpecifier &TRS) {
+  assert(isCXX2CTriviallyRelocatableKeyword() &&
+ "expected a trivially_relocatable specifier");
+
+  Diag(Tok.getLocation(), getLangOpts().CPlusPlus26
+  ? diag::warn_relocatable_keyword
+  : diag::ext_relocatable_keyword)
+  << /*relocatable*/ 0;
+
+  TRS = Actions.ActOnTriviallyRelocatableSpecifier(ConsumeToken());
+}
+
+bool Parser::isCXX2CReplaceableKeyword(Token Tok) const {
+  if (!getLangOpts().CPlusPlus || Tok.isNot(tok::identifier))
+return false;
+  if (!Ident_replaceable_if_eligible)
+Ident_replaceable_if_eligible =
+&PP.getIdentifierTable().get("replaceable_if_eligible");
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  return II == Ident_replaceable_if_eligible;
+}
+
+bool Parser::isCXX2CReplaceableKeyword() const {
+  return isCXX2CReplaceableKeyword(Tok);
+}
+
+void Parser::ParseOptionalCXX2CReplaceableSpecifier(ReplaceableSpecifier &MRS) 
{
+  assert(isCXX2CReplaceableKeyword() &&
+ "expected a replaceable_if_eligible specifier");
+
+  Diag(Tok.getLocation(), getLangOpts().CPlusPlus26
+  ? diag::warn_relocatable_keyword
+  : diag::ext_relocatable_keyword)
+  << /*replaceable*/ 1;
+
+  MRS = Actions.ActOnReplaceableSpecifier(ConsumeToken());
+}
+
 /// isClassCompatibleKeyword - Determine whether the next token is a C++11
 /// 'final' or Microsoft 'sealed' or 'abstract' contextual keywords.

Sirraide wrote:

nit: we might want to update this comment now

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -1875,6 +1875,54 @@ static ExprResult BuiltinIsWithinLifetime(Sema &S, 
CallExpr *TheCall) {
 << 0;
 return ExprError();
   }
+  return TheCall;
+}
+
+static ExprResult BuiltinTriviallyRelocate(Sema &S, CallExpr *TheCall) {
+  if (S.checkArgCount(TheCall, 3))
+return ExprError();
+
+  QualType Dest = TheCall->getArg(0)->getType();
+  if (!Dest->isPointerType() || Dest.getCVRQualifiers() != 0) {
+S.Diag(TheCall->getArg(0)->getExprLoc(),
+   diag::err_builtin_trivially_relocate_invalid_arg_type)
+<< /*a pointer*/ 0;
+return ExprError();
+  }
+
+  QualType T = Dest->getPointeeType();
+  if (S.RequireCompleteType(TheCall->getBeginLoc(), T,
+diag::err_incomplete_type))
+return ExprError();
+
+  if (T.isConstQualified() ||
+  !T.isCppTriviallyRelocatableType(S.getASTContext())) {
+S.Diag(TheCall->getArg(0)->getExprLoc(),
+   diag::err_builtin_trivially_relocate_invalid_arg_type)
+<< (T.isConstQualified() ? /*non-const*/ 1 : /*relocatable*/ 2);
+return ExprError();
+  }
+
+  TheCall->setType(Dest);
+
+  QualType Src = TheCall->getArg(1)->getType();
+  if (Src.getCanonicalType() != Dest.getCanonicalType()) {
+S.Diag(TheCall->getArg(0)->getExprLoc(),

Sirraide wrote:

```suggestion
S.Diag(TheCall->getArg(1)->getExprLoc(),
```
Do we maybe want to point to the location of the `src` argument instead of the 
`dest` argument here?

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -7258,6 +7261,221 @@ void Sema::CheckCompletedCXXClass(Scope *S, 
CXXRecordDecl *Record) {
   }
 }
 
+static bool hasSuitableConstructorForReplaceability(CXXRecordDecl *D,
+bool Implicit) {
+  assert(D->hasDefinition() && !D->isInvalidDecl());
+
+  bool HasDeletedMoveConstructor = false;
+  bool HasDeletedCopyConstructor = false;
+  bool HasMoveConstructor = D->needsImplicitMoveConstructor();
+  bool HasDefaultedMoveConstructor = D->needsImplicitMoveConstructor();
+  bool HasDefaultedCopyConstructor = D->needsImplicitMoveConstructor();
+
+  for (const Decl *D : D->decls()) {
+auto *MD = dyn_cast(D);
+if (!MD || MD->isIneligibleOrNotSelected())
+  continue;
+
+if (MD->isMoveConstructor()) {
+  HasMoveConstructor = true;
+  if (MD->isDefaulted())
+HasDefaultedMoveConstructor = true;
+  if (MD->isDeleted())
+HasDeletedMoveConstructor = true;
+}
+if (MD->isCopyConstructor()) {
+  if (MD->isDefaulted())
+HasDefaultedCopyConstructor = true;
+  if (MD->isDeleted())
+HasDeletedCopyConstructor = true;
+}
+  }
+
+  if (HasMoveConstructor)
+return !HasDeletedMoveConstructor &&
+   (Implicit ? HasDefaultedMoveConstructor : true);
+  return !HasDeletedCopyConstructor &&
+ (Implicit ? HasDefaultedCopyConstructor : true);
+  ;
+}
+
+static bool hasSuitableMoveAssignmentOperatorForReplaceability(CXXRecordDecl 
*D,
+   bool Implicit) {
+  assert(D->hasDefinition() && !D->isInvalidDecl());
+
+  if (D->hasExplicitlyDeletedMoveAssignment())
+return false;
+
+  bool HasDeletedMoveAssignment = false;
+  bool HasDeletedCopyAssignment = false;
+  bool HasMoveAssignment = D->needsImplicitMoveAssignment();
+  bool HasDefaultedMoveAssignment = D->needsImplicitMoveAssignment();
+  bool HasDefaultedCopyAssignment = D->needsImplicitCopyAssignment();
+
+  for (const Decl *D : D->decls()) {
+auto *MD = dyn_cast(D);
+if (!MD || MD->isIneligibleOrNotSelected())
+  continue;
+
+if (MD->isMoveAssignmentOperator()) {
+  HasMoveAssignment = true;
+  if (MD->isDefaulted())
+HasDefaultedMoveAssignment = true;
+  if (MD->isDeleted())
+HasDeletedMoveAssignment = true;
+}
+if (MD->isCopyAssignmentOperator()) {
+  if (MD->isDefaulted())
+HasDefaultedCopyAssignment = true;
+  if (MD->isDeleted())
+HasDeletedCopyAssignment = true;
+}
+  }
+
+  if (HasMoveAssignment)
+return !HasDeletedMoveAssignment &&
+   (Implicit ? HasDefaultedMoveAssignment : true);
+  return !HasDeletedCopyAssignment &&
+ (Implicit ? HasDefaultedCopyAssignment : true);
+}
+
+void Sema::CheckCXX2CTriviallyRelocatable(CXXRecordDecl *D) {

Sirraide wrote:

Also, I wonder if having separate functions for e.g. `isDefaultMovable()` and 
`isEligibleForTrivialRelocation()` might help here.

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -0,0 +1,272 @@
+// RUN: %clang_cc1 -std=c++2c -verify %s
+
+class Trivial {};
+struct NonRelocatable {
+~NonRelocatable();
+};
+static NonRelocatable NonRelocatable_g;
+
+class A trivially_relocatable_if_eligible {};
+class B trivially_relocatable_if_eligible : Trivial{};
+class C trivially_relocatable_if_eligible {
+int a;
+void* b;
+int c[3];
+Trivial d[3];
+NonRelocatable& e = NonRelocatable_g;
+};
+class D trivially_relocatable_if_eligible : Trivial {};
+class E trivially_relocatable_if_eligible : virtual Trivial {};
+
+class F trivially_relocatable_if_eligible : NonRelocatable {};
+
+class I trivially_relocatable_if_eligible {
+NonRelocatable a;
+NonRelocatable b[1];
+const NonRelocatable c;
+const NonRelocatable d[1];
+};
+
+class J trivially_relocatable_if_eligible:  virtual Trivial, NonRelocatable {
+NonRelocatable a;
+};
+
+class G trivially_relocatable_if_eligible {
+G(G&&);
+};
+
+class H trivially_relocatable_if_eligible {
+~H();
+};
+
+struct Incomplete; // expected-note {{forward declaration of 'Incomplete'}}
+static_assert(__builtin_is_cpp_trivially_relocatable(Incomplete));  // 
expected-error {{incomplete type 'Incomplete' used in type trait expression}}
+static_assert(__builtin_is_cpp_trivially_relocatable(Trivial));
+static_assert(__builtin_is_cpp_trivially_relocatable(G));
+static_assert(__builtin_is_cpp_trivially_relocatable(H));
+static_assert(__builtin_is_cpp_trivially_relocatable(int));
+static_assert(__builtin_is_cpp_trivially_relocatable(void*));
+static_assert(!__builtin_is_cpp_trivially_relocatable(int&));
+static_assert(!__builtin_is_cpp_trivially_relocatable(Trivial&));
+static_assert(__builtin_is_cpp_trivially_relocatable(const Trivial));
+static_assert(__builtin_is_cpp_trivially_relocatable(Trivial[1]));

Sirraide wrote:

Are VLA’s trivially relocatable? Either way, we probably want a test for that 
too

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -0,0 +1,272 @@
+// RUN: %clang_cc1 -std=c++2c -verify %s
+
+class Trivial {};
+struct NonRelocatable {
+~NonRelocatable();
+};
+static NonRelocatable NonRelocatable_g;
+
+class A trivially_relocatable_if_eligible {};
+class B trivially_relocatable_if_eligible : Trivial{};
+class C trivially_relocatable_if_eligible {
+int a;
+void* b;
+int c[3];
+Trivial d[3];
+NonRelocatable& e = NonRelocatable_g;
+};
+class D trivially_relocatable_if_eligible : Trivial {};
+class E trivially_relocatable_if_eligible : virtual Trivial {};
+
+class F trivially_relocatable_if_eligible : NonRelocatable {};
+
+class I trivially_relocatable_if_eligible {
+NonRelocatable a;
+NonRelocatable b[1];
+const NonRelocatable c;
+const NonRelocatable d[1];
+};
+
+class J trivially_relocatable_if_eligible:  virtual Trivial, NonRelocatable {
+NonRelocatable a;
+};
+
+class G trivially_relocatable_if_eligible {
+G(G&&);
+};
+
+class H trivially_relocatable_if_eligible {
+~H();
+};
+
+struct Incomplete; // expected-note {{forward declaration of 'Incomplete'}}
+static_assert(__builtin_is_cpp_trivially_relocatable(Incomplete));  // 
expected-error {{incomplete type 'Incomplete' used in type trait expression}}
+static_assert(__builtin_is_cpp_trivially_relocatable(Trivial));
+static_assert(__builtin_is_cpp_trivially_relocatable(G));
+static_assert(__builtin_is_cpp_trivially_relocatable(H));
+static_assert(__builtin_is_cpp_trivially_relocatable(int));
+static_assert(__builtin_is_cpp_trivially_relocatable(void*));
+static_assert(!__builtin_is_cpp_trivially_relocatable(int&));
+static_assert(!__builtin_is_cpp_trivially_relocatable(Trivial&));
+static_assert(__builtin_is_cpp_trivially_relocatable(const Trivial));
+static_assert(__builtin_is_cpp_trivially_relocatable(Trivial[1]));
+
+struct UserDtr {
+~UserDtr();
+};
+
+struct DefaultedDtr {
+~DefaultedDtr() = default;
+};
+struct UserMoveWithDefaultCopy {
+UserMoveWithDefaultCopy(UserMoveWithDefaultCopy&&);
+UserMoveWithDefaultCopy(const UserMoveWithDefaultCopy&) = default;
+};
+
+struct UserMove{
+UserMove(UserMove&&);
+};
+
+struct UserMoveDefault{
+UserMoveDefault(UserMoveDefault&&) = default;
+};
+
+struct UserCopy{
+UserCopy(const UserCopy&);
+};
+
+struct UserCopyDefault{
+UserCopyDefault(const UserCopyDefault&) = default;
+};
+
+
+struct UserDeletedMove{
+UserDeletedMove(UserDeletedMove&) = delete;
+UserDeletedMove(const UserDeletedMove&) = default;
+};
+
+static_assert(!__builtin_is_cpp_trivially_relocatable(UserDtr));
+static_assert(__builtin_is_cpp_trivially_relocatable(DefaultedDtr));
+static_assert(!__builtin_is_cpp_trivially_relocatable(UserMoveWithDefaultCopy));
+static_assert(!__builtin_is_cpp_trivially_relocatable(UserMove));
+static_assert(!__builtin_is_cpp_trivially_relocatable(UserCopy));
+static_assert(__builtin_is_cpp_trivially_relocatable(UserMoveDefault));
+static_assert(__builtin_is_cpp_trivially_relocatable(UserCopyDefault));
+static_assert(__builtin_is_cpp_trivially_relocatable(UserDeletedMove));
+
+template 
+class TestDependentErrors trivially_relocatable_if_eligible : T {};
+TestDependentErrors Ok;
+TestDependentErrors Err;
+
+struct DeletedMove {
+DeletedMove(DeletedMove&&) = delete;
+};
+struct DeletedCopy {
+DeletedCopy(const DeletedCopy&) = delete;
+};
+struct DeletedMoveAssign {
+DeletedMoveAssign& operator=(DeletedMoveAssign&&) = delete;
+};
+
+static_assert(!__builtin_is_cpp_trivially_relocatable(DeletedMove));
+static_assert(!__builtin_is_cpp_trivially_relocatable(DeletedCopy));
+static_assert(!__builtin_is_cpp_trivially_relocatable(DeletedMoveAssign));
+
+union U {
+G g;
+};
+static_assert(!__is_trivially_copyable(U));
+static_assert(__builtin_is_cpp_trivially_relocatable(U));
+
+
+namespace replaceable {
+
+struct DeletedMove {
+DeletedMove(DeletedMove&&) = delete;
+};
+struct DeletedCopy {
+DeletedCopy(const DeletedCopy&) = delete;
+};
+struct DeletedMoveAssign {
+DeletedMoveAssign& operator=(DeletedMoveAssign&&) = delete;
+};
+
+struct DefaultedMove {
+DefaultedMove(DefaultedMove&&) = default;
+DefaultedMove& operator=(DefaultedMove&&) = default;
+};
+struct DefaultedCopy {
+DefaultedCopy(const DefaultedCopy&) = default;
+DefaultedCopy(DefaultedCopy&&) = default;
+DefaultedCopy& operator=(DefaultedCopy&&) = default;
+};
+struct DefaultedMoveAssign {
+DefaultedMoveAssign(DefaultedMoveAssign&&) = default;
+DefaultedMoveAssign& operator=(DefaultedMoveAssign&&) = default;
+};
+
+struct UserProvidedMove {
+UserProvidedMove(UserProvidedMove&&){};
+};
+struct UserProvidedCopy {
+UserProvidedCopy(const UserProvidedCopy&) {};
+};
+struct UserProvidedMoveAssign {
+UserProvidedMoveAssign& operator=(const UserProvidedMoveAssign&){return 
*this;};
+};
+
+struct Empty{};
+static_assert(__builtin_is_replaceable(Empty));
+struct S1 replaceable_if_eligible{};
+static_assert(__builtin_is_replaceable(

[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits

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


[clang] [clang][analyzer] Add checker 'alpha.core.FixedAddressDereference' (PR #127191)

2025-02-21 Thread Balázs Kéri via cfe-commits

https://github.com/balazske updated 
https://github.com/llvm/llvm-project/pull/127191

From 1f2ad6d5ce6f11fb031ec2175527f56ea86761ec Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20K=C3=A9ri?= 
Date: Mon, 3 Feb 2025 15:35:31 +0100
Subject: [PATCH 1/5] [clang][analyzer] Add checker
 'alpha.core.FixedAddressDereference'

---
 clang/docs/analyzer/checkers.rst  |  38 
 .../clang/StaticAnalyzer/Checkers/Checkers.td |  26 +--
 .../Checkers/DereferenceChecker.cpp   |  63 ++-
 clang/test/Analysis/concrete-address.c| 162 +-
 clang/test/Analysis/misc-ps.m |   4 +-
 5 files changed, 271 insertions(+), 22 deletions(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 707067358fdfe..c5e10f5a8bbf2 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -129,6 +129,8 @@ The ``SuppressAddressSpaces`` option suppresses
 warnings for null dereferences of all pointers with address spaces. You can
 disable this behavior with the option
 ``-analyzer-config core.NullDereference:SuppressAddressSpaces=false``.
+Value of this option is used for checker :ref:`_core-FixedAddressDereference`
+too.
 *Defaults to true*.
 
 .. code-block:: objc
@@ -2919,6 +2921,42 @@ Check for assignment of a fixed address to a pointer.
p = (int *) 0x1; // warn
  }
 
+.. _alpha-core-FixedAddressDereference:
+
+alpha.core.FixedAddressDereference (C, C++, ObjC)
+"
+Check for dereferences of fixed values used as pointers.
+
+Similarly as at :ref:`_core-NullDereference`, the checker specifically does
+not report dereferences for x86 and x86-64 targets when the
+address space is 256 (x86 GS Segment), 257 (x86 FS Segment), or 258 (x86 SS
+segment). (See `X86/X86-64 Language Extensions
+`__
+for reference.)
+
+If you want to disable this behavior, set the ``SuppressAddressSpaces`` option
+of checker ``core.NullDereference`` to false, like
+``-analyzer-config core.NullDereference:SuppressAddressSpaces=false``. The 
value
+of this option is used for both checkers.
+
+.. code-block:: c
+
+ void test1() {
+   int *p = (int *)0x020;
+   int x = p[0]; // warn
+ }
+
+ void test2(int *p) {
+   if (p == (int *)-1)
+ *p = 0; // warn
+ }
+
+ void test3() {
+   int (*p_function)(char, char);
+   p_function = (int (*)(char, char))0x04080;
+   int x = (*p_function)('x', 'y'); // NO warning yet at functon pointer calls
+ }
+
 .. _alpha-core-PointerArithm:
 
 alpha.core.PointerArithm (C)
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 9bf491eac1e0e..44ca28c003b06 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -211,17 +211,15 @@ def DereferenceModeling : Checker<"DereferenceModeling">,
   Documentation,
   Hidden;
 
-def NullDereferenceChecker : Checker<"NullDereference">,
-  HelpText<"Check for dereferences of null pointers">,
-  CheckerOptions<[
-CmdLineOption
-  ]>,
-  Documentation,
-  Dependencies<[DereferenceModeling]>;
+def NullDereferenceChecker
+: Checker<"NullDereference">,
+  HelpText<"Check for dereferences of null pointers">,
+  CheckerOptions<[CmdLineOption<
+  Boolean, "SuppressAddressSpaces",
+  "Suppresses warning when pointer dereferences an address space",
+  "true", Released>]>,
+  Documentation,
+  Dependencies<[DereferenceModeling]>;
 
 def NonNullParamChecker : Checker<"NonNullParamChecker">,
   HelpText<"Check for null pointers passed as arguments to a function whose "
@@ -285,6 +283,12 @@ def FixedAddressChecker : Checker<"FixedAddr">,
   HelpText<"Check for assignment of a fixed address to a pointer">,
   Documentation;
 
+def FixedAddressDereferenceChecker
+: Checker<"FixedAddressDereference">,
+  HelpText<"Check for dereferences of fixed values used as pointers">,
+  Documentation,
+  Dependencies<[DereferenceModeling]>;
+
 def PointerArithChecker : Checker<"PointerArithm">,
   HelpText<"Check for pointer arithmetic on locations other than array "
"elements">,
diff --git a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
index e9e2771c739b6..6a3f70e62e77b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
@@ -31,7 +31,12 @@ class DereferenceChecker
 : public Checker< check::Location,
   check::Bind,
   EventDispatcher > {
-  enum DerefKind { NullPointer, UndefinedPointerValue, AddressOfLabel };
+  enum DerefKind {
+NullPointer,
+UndefinedPointerValue,
+AddressOfLabel,
+FixedAddress
+  };
 
   void reportBu

[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -7258,6 +7261,221 @@ void Sema::CheckCompletedCXXClass(Scope *S, 
CXXRecordDecl *Record) {
   }
 }
 
+static bool hasSuitableConstructorForReplaceability(CXXRecordDecl *D,
+bool Implicit) {
+  assert(D->hasDefinition() && !D->isInvalidDecl());
+
+  bool HasDeletedMoveConstructor = false;
+  bool HasDeletedCopyConstructor = false;
+  bool HasMoveConstructor = D->needsImplicitMoveConstructor();
+  bool HasDefaultedMoveConstructor = D->needsImplicitMoveConstructor();
+  bool HasDefaultedCopyConstructor = D->needsImplicitMoveConstructor();
+
+  for (const Decl *D : D->decls()) {
+auto *MD = dyn_cast(D);
+if (!MD || MD->isIneligibleOrNotSelected())
+  continue;
+
+if (MD->isMoveConstructor()) {
+  HasMoveConstructor = true;
+  if (MD->isDefaulted())
+HasDefaultedMoveConstructor = true;
+  if (MD->isDeleted())
+HasDeletedMoveConstructor = true;
+}
+if (MD->isCopyConstructor()) {
+  if (MD->isDefaulted())
+HasDefaultedCopyConstructor = true;
+  if (MD->isDeleted())
+HasDeletedCopyConstructor = true;
+}
+  }
+
+  if (HasMoveConstructor)
+return !HasDeletedMoveConstructor &&
+   (Implicit ? HasDefaultedMoveConstructor : true);
+  return !HasDeletedCopyConstructor &&
+ (Implicit ? HasDefaultedCopyConstructor : true);
+  ;
+}
+
+static bool hasSuitableMoveAssignmentOperatorForReplaceability(CXXRecordDecl 
*D,
+   bool Implicit) {
+  assert(D->hasDefinition() && !D->isInvalidDecl());
+
+  if (D->hasExplicitlyDeletedMoveAssignment())
+return false;
+
+  bool HasDeletedMoveAssignment = false;
+  bool HasDeletedCopyAssignment = false;
+  bool HasMoveAssignment = D->needsImplicitMoveAssignment();
+  bool HasDefaultedMoveAssignment = D->needsImplicitMoveAssignment();
+  bool HasDefaultedCopyAssignment = D->needsImplicitCopyAssignment();
+
+  for (const Decl *D : D->decls()) {
+auto *MD = dyn_cast(D);
+if (!MD || MD->isIneligibleOrNotSelected())
+  continue;
+
+if (MD->isMoveAssignmentOperator()) {
+  HasMoveAssignment = true;
+  if (MD->isDefaulted())
+HasDefaultedMoveAssignment = true;
+  if (MD->isDeleted())
+HasDeletedMoveAssignment = true;
+}
+if (MD->isCopyAssignmentOperator()) {
+  if (MD->isDefaulted())
+HasDefaultedCopyAssignment = true;
+  if (MD->isDeleted())
+HasDeletedCopyAssignment = true;
+}
+  }
+
+  if (HasMoveAssignment)
+return !HasDeletedMoveAssignment &&
+   (Implicit ? HasDefaultedMoveAssignment : true);
+  return !HasDeletedCopyAssignment &&
+ (Implicit ? HasDefaultedCopyAssignment : true);
+}
+
+void Sema::CheckCXX2CTriviallyRelocatable(CXXRecordDecl *D) {
+  if (D->isInvalidDecl())
+return;
+
+  assert(D->hasDefinition());
+
+  bool MarkedTriviallyRelocatable =
+  D->getTriviallyRelocatableSpecifier().isSet();
+
+  bool IsTriviallyRelocatable = true;
+  for (const CXXBaseSpecifier &B : D->bases()) {
+const auto *BaseDecl = B.getType()->getAsCXXRecordDecl();
+if (!BaseDecl)
+  continue;
+if (B.isVirtual() ||
+(!BaseDecl->isDependentType() && !BaseDecl->isTriviallyRelocatable())) 
{
+  IsTriviallyRelocatable = false;
+}
+  }
+
+  for (const FieldDecl *Field : D->fields()) {
+if (Field->getType()->isDependentType())
+  continue;
+if (Field->getType()->isReferenceType())
+  continue;
+QualType T = getASTContext().getBaseElementType(
+Field->getType().getUnqualifiedType());
+if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
+  if (RD->isTriviallyRelocatable())
+continue;
+  IsTriviallyRelocatable = false;
+  break;
+}
+  }
+
+  if (!D->isDependentType() && !MarkedTriviallyRelocatable) {
+bool HasSuitableMoveCtr = D->needsImplicitMoveConstructor();
+bool HasSuitableCopyCtr = false;
+if (D->hasUserDeclaredDestructor()) {
+  const auto *Dtr = D->getDestructor();
+  if (Dtr && (!Dtr->isDefaulted() || Dtr->isDeleted()))
+IsTriviallyRelocatable = false;
+}
+if (IsTriviallyRelocatable && !HasSuitableMoveCtr) {
+  for (const CXXConstructorDecl *CD : D->ctors()) {
+if (CD->isMoveConstructor() && CD->isDefaulted() &&
+!CD->isIneligibleOrNotSelected()) {
+  HasSuitableMoveCtr = true;
+  break;
+}
+  }
+}
+if (!HasSuitableMoveCtr && !D->hasMoveConstructor()) {
+  HasSuitableCopyCtr = D->needsImplicitCopyConstructor();
+  if (!HasSuitableCopyCtr) {
+for (const CXXConstructorDecl *CD : D->ctors()) {
+  if (CD->isCopyConstructor() && CD->isDefaulted() &&
+  !CD->isIneligibleOrNotSelected()) {
+HasSuitableCopyCtr = true;
+break;
+  }
+}
+  }
+}
+
+if (D->isUnion() && !D->hasUserDeclaredCopyConstructor() &&
+  

[clang] [clang-tools-extra] [Clang] Default the warning for chained comparison to an error. (PR #128145)

2025-02-21 Thread Erich Keane via cfe-commits

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

I think this is a great idea to do now, if we have to revert it, it is 
information for the WG21 paper.  BUT I think this is completely reasonable.

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


[clang] [CIR] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-02-21 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,201 @@
+//- LowerCIRToMLIR.cpp - Lowering from CIR to MLIR 
===//
+//
+// 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
+//
+//===--===//
+//
+// This file implements lowering of CIR operations to MLIR.
+//
+//===--===//
+
+#include "mlir/Dialect/MemRef/IR/MemRef.h"
+#include "mlir/IR/BuiltinDialect.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Pass/PassManager.h"
+#include "mlir/Transforms/DialectConversion.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+#include "clang/CIR/LowerToLLVM.h"
+#include "clang/CIR/MissingFeatures.h"
+#include "llvm/ADT/TypeSwitch.h"
+#include "llvm/Support/TimeProfiler.h"
+
+using namespace cir;
+using namespace llvm;
+
+namespace cir {
+
+struct ConvertCIRToMLIRPass
+: public mlir::PassWrapper> {
+  void getDependentDialects(mlir::DialectRegistry ®istry) const override {
+registry.insert();
+  }
+  void runOnOperation() final;
+
+  StringRef getDescription() const override {
+return "Convert the CIR dialect module to MLIR standard dialects";
+  }
+
+  StringRef getArgument() const override { return "cir-to-mlir"; }
+};
+
+class CIRGlobalOpLowering : public mlir::OpConversionPattern {
+public:
+  using OpConversionPattern::OpConversionPattern;
+  mlir::LogicalResult
+  matchAndRewrite(cir::GlobalOp op, OpAdaptor adaptor,
+  mlir::ConversionPatternRewriter &rewriter) const override {
+auto moduleOp = op->getParentOfType();
+if (!moduleOp)
+  return mlir::failure();
+
+mlir::OpBuilder b(moduleOp.getContext());
+
+const auto cirSymType = op.getSymType();
+assert(!cir::MissingFeatures::convertTypeForMemory());
+auto convertedType = getTypeConverter()->convertType(cirSymType);
+if (!convertedType)
+  return mlir::failure();
+auto memrefType = dyn_cast(convertedType);

AaronBallman wrote:

Ah, good to know, thank you!

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


[clang] Reapply "[Analyzer][CFG] Correctly handle rebuilt default arg and default init expression" (PR #127338)

2025-02-21 Thread via cfe-commits

yronglin wrote:

> In case others notice similar in ClangTidy 
> (`bugprone-unchecked-optional-access`), we are seeing crashes after this 
> change #128068
> 
> I'm not yet sure the best fix.

Can you try to revert this change to see if the crash issue can be fixed? It 
looks like I missing some changes in dataflow.

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


[clang] [CIR] Initial implementation of lowering CIR to MLIR (PR #127835)

2025-02-21 Thread Andrzej Warzyński via cfe-commits


@@ -2958,6 +2958,8 @@ defm clangir : BoolFOption<"clangir",
   BothFlags<[], [ClangOption, CC1Option], "">>;
 def emit_cir : Flag<["-"], "emit-cir">, Visibility<[ClangOption, CC1Option]>,
   Group, HelpText<"Build ASTs and then lower to ClangIR">;
+def emit_cir_mlir : Flag<["-"], "emit-cir-mlir">, Visibility<[CC1Option]>, 
Group,

banach-space wrote:

No objections. In fact, `-emit-mlir` is a misnomer and `emit_mlir_EQ` would 
make more sense to me. 

>  Does flang have the ability to lower to MLIR core dialects? I think that's 
> what we're saying we'd like -emit-mlir with no argument to do in clang.

The semantics in Flang and Clang can differ. Whenever that's the case, please 
use `HelpTextForVariant` in Options.td to document that.

That said,`-emit-mlir` is very ambiguous - there's no single MLIR 
representation.

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


[clang] [clang][dataflow] Add test repro for a crash (PR #128065)

2025-02-21 Thread Jan Voung via cfe-commits

https://github.com/jvoung updated 
https://github.com/llvm/llvm-project/pull/128065

>From a7002fb5a61c2f6f3c4df2347b6d5f861bf45f8e Mon Sep 17 00:00:00 2001
From: Jan Voung 
Date: Thu, 20 Feb 2025 19:40:16 +
Subject: [PATCH 1/3] [clang][dataflow] Add test repro for a crash

An issue with looking up the "this" when a default init of
field2 refers to field1.
---
 .../UncheckedOptionalAccessModelTest.cpp  | 19 +++
 1 file changed, 19 insertions(+)

diff --git 
a/clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
index 19c3ff49eab27..6ece51d84cbff 100644
--- 
a/clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ 
b/clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -3863,6 +3863,25 @@ TEST_P(UncheckedOptionalAccessTest, 
ConstBoolAccessorWithModInBetween) {
   )cc");
 }
 
+TEST_P(UncheckedOptionalAccessTest, ConstructorOtherStructField) {
+  // Repro for a crash.
+  ExpectDiagnosticsFor(R"cc(
+#include "unchecked_optional_access_test.h"
+struct NonTrivDtor {
+  NonTrivDtor(int x);
+  ~NonTrivDtor() {}
+};
+struct Other {
+  $ns::$optional x = $ns::nullopt;
+  NonTrivDtor y = x.has_value() ? NonTrivDtor(*x) : NonTrivDtor(-1);
+};
+struct target {
+  target() { Other{}; }
+};
+  )cc");
+}
+
+
 // FIXME: Add support for:
 // - constructors (copy, move)
 // - assignment operators (default, copy, move)

>From 04dbe940b2579b75db4c3b40a2b63a01416e17eb Mon Sep 17 00:00:00 2001
From: Jan Voung 
Date: Fri, 21 Feb 2025 14:52:31 +
Subject: [PATCH 2/3] Revert "Reapply "[Analyzer][CFG] Correctly handle rebuilt
 default arg and default init expression" (#127338)"

This reverts commit d235b72178adc710bf704078fbe0cd687642f3e0.
---
 clang/docs/ReleaseNotes.rst   |  4 -
 clang/lib/AST/ParentMap.cpp   | 17 -
 clang/lib/Analysis/CFG.cpp| 54 +++--
 clang/lib/Analysis/ReachableCode.cpp  | 37 +
 clang/lib/Sema/SemaExpr.cpp   |  9 +--
 clang/lib/StaticAnalyzer/Core/ExprEngine.cpp  | 56 ++
 clang/test/AST/ast-dump-recovery.cpp  |  2 +-
 .../Analysis/lifetime-extended-regions.cpp|  7 +-
 clang/test/SemaCXX/cxx2c-placeholder-vars.cpp |  8 +-
 clang/test/SemaCXX/warn-unreachable.cpp   | 75 ---
 10 files changed, 61 insertions(+), 208 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e1c61992512b5..dcdd03bf5f34b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -282,10 +282,6 @@ Code Completion
 Static Analyzer
 ---
 
-- Clang currently support extending lifetime of object bound to
-  reference members of aggregates in CFG and ExprEngine, that are
-  created from default member initializer.
-
 New features
 
 
diff --git a/clang/lib/AST/ParentMap.cpp b/clang/lib/AST/ParentMap.cpp
index 580613b2618fb..e62e71bf5a514 100644
--- a/clang/lib/AST/ParentMap.cpp
+++ b/clang/lib/AST/ParentMap.cpp
@@ -13,7 +13,6 @@
 #include "clang/AST/ParentMap.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/Expr.h"
-#include "clang/AST/ExprCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "llvm/ADT/DenseMap.h"
 
@@ -104,22 +103,6 @@ static void BuildParentMap(MapTy& M, Stmt* S,
   BuildParentMap(M, SubStmt, OVMode);
 }
 break;
-  case Stmt::CXXDefaultArgExprClass:
-if (auto *Arg = dyn_cast(S)) {
-  if (Arg->hasRewrittenInit()) {
-M[Arg->getExpr()] = S;
-BuildParentMap(M, Arg->getExpr(), OVMode);
-  }
-}
-break;
-  case Stmt::CXXDefaultInitExprClass:
-if (auto *Init = dyn_cast(S)) {
-  if (Init->hasRewrittenInit()) {
-M[Init->getExpr()] = S;
-BuildParentMap(M, Init->getExpr(), OVMode);
-  }
-}
-break;
   default:
 for (Stmt *SubStmt : S->children()) {
   if (SubStmt) {
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index c82dbc42fb9d8..3e144395cffc6 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -556,10 +556,6 @@ class CFGBuilder {
 
 private:
   // Visitors to walk an AST and construct the CFG.
-  CFGBlock *VisitCXXDefaultArgExpr(CXXDefaultArgExpr *Default,
-   AddStmtChoice asc);
-  CFGBlock *VisitCXXDefaultInitExpr(CXXDefaultInitExpr *Default,
-AddStmtChoice asc);
   CFGBlock *VisitInitListExpr(InitListExpr *ILE, AddStmtChoice asc);
   CFGBlock *VisitAddrLabelExpr(AddrLabelExpr *A, AddStmtChoice asc);
   CFGBlock *VisitAttributedStmt(AttributedStmt *A, AddStmtChoice asc);
@@ -2267,10 +2263,16 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
asc, ExternallyDestructed);
 
 case Stmt::CXXDefaultArgExprClass:
-  return VisitCXXDefaultArgEx

[clang] Reapply "[Analyzer][CFG] Correctly handle rebuilt default arg and default init expression" (PR #127338)

2025-02-21 Thread via cfe-commits

yronglin wrote:

> Thanks for the warning! It's a cool feature, but the diagnostic is IMHO not 
> super great at the moment.
> 
> I'm doing the cleanup for the warning in Chromium at the moment, and here's 
> an example that's now analyzed (from 
> https://source.chromium.org/chromium/chromium/src/+/main:net/dns/httpssvc_metrics.cc;l=25?q=httpssvc_metrics):
> 
> ```
> enum HttpssvcDnsRcode TranslateDnsRcodeForHttpssvcExperiment(uint8_t rcode) {
>   switch (rcode) {
> case dns_protocol::kRcodeNOERROR:
>   return HttpssvcDnsRcode::kNoError;
> case dns_protocol::kRcodeFORMERR:
>   return HttpssvcDnsRcode::kFormErr;
> case dns_protocol::kRcodeSERVFAIL:
>   return HttpssvcDnsRcode::kServFail;
> case dns_protocol::kRcodeNXDOMAIN:
>   return HttpssvcDnsRcode::kNxDomain;
> case dns_protocol::kRcodeNOTIMP:
>   return HttpssvcDnsRcode::kNotImp;
> case dns_protocol::kRcodeREFUSED:
>   return HttpssvcDnsRcode::kRefused;
> default:
>   return HttpssvcDnsRcode::kUnrecognizedRcode;
>   }
>   NOTREACHED();
> }
> ```
> 
> Here's the diagnostic:
> 
> ```
> [4890/84790] CXX obj/net/dns/dns/httpssvc_metrics.o
> In file included from ../../net/dns/httpssvc_metrics.cc:5:
> In file included from ../../net/dns/httpssvc_metrics.h:13:
> In file included from ../../base/containers/flat_set.h:12:
> In file included from ../../base/containers/flat_tree.h:19:
> ../../base/check.h:200:11: warning: code will never be executed 
> [-Wunreachable-code]
>   200 |   base::Location::CurrentWithoutFunctionName());
>   |   ^~
> 1 warning generated.
> ```
> 
> It points to somewhere in the implementation of `NOTREACHED()`. It does not 
> mention where the invocation of that macro that causes the diagnostic is. (At 
> least it prints the right cc file, but not where in that file I'm supposed to 
> look.)

Thanks a lot for report this! 100% agree that we need to find the correct 
source location. I'm not sure it's the same issue with 
https://github.com/llvm/llvm-project/issues/123064, I try to find a reproducer.

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -127,6 +127,33 @@ class AccessSpecDecl : public Decl {
   static bool classofKind(Kind K) { return K == AccessSpec; }
 };
 
+enum class RelocatableOrReplaceableClassSpecifierKind {
+  Relocatable,
+  Replaceable
+};
+
+template 
+class BasicRelocatableOrReplaceableClassSpecifier {
+public:
+  BasicRelocatableOrReplaceableClassSpecifier() = default;
+  BasicRelocatableOrReplaceableClassSpecifier(SourceLocation Begin)
+  : Loc(Begin) {}
+  void Set(SourceLocation Begin) { Loc = Begin; }
+
+  bool isSet() const { return !Loc.isInvalid(); }
+
+  SourceLocation getLocation() const { return Loc; }
+
+private:
+  SourceLocation Loc;

erichkeane wrote:

Is there intent for this to 'have' more to it?  At the moment, this seems like 
it has weak justification over a `SourceLocation`.

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -2692,16 +2693,75 @@ bool Parser::isCXX11FinalKeyword() const {
  Specifier == VirtSpecifiers::VS_Sealed;
 }
 
+bool Parser::isCXX2CTriviallyRelocatableKeyword(Token Tok) const {
+  if (!getLangOpts().CPlusPlus || Tok.isNot(tok::identifier))
+return false;
+  if (!Ident_trivially_relocatable_if_eligible)
+Ident_trivially_relocatable_if_eligible =
+&PP.getIdentifierTable().get("trivially_relocatable_if_eligible");
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  return II == Ident_trivially_relocatable_if_eligible;
+}
+
+bool Parser::isCXX2CTriviallyRelocatableKeyword() const {
+  return isCXX2CTriviallyRelocatableKeyword(Tok);
+}
+
+void Parser::ParseOptionalCXX2CTriviallyRelocatableSpecifier(
+TriviallyRelocatableSpecifier &TRS) {
+  assert(isCXX2CTriviallyRelocatableKeyword() &&

erichkeane wrote:

The name 'ParseOptional' here implies to me that we'll return true/false based 
on whether the next one IS this keyword, and fill it in only if that is the 
case.  But this is parsing one we already know is there?

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


[clang] [Clang] Add __has_target_builtin macro (PR #126324)

2025-02-21 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> As for next steps, I think we need a broader community discussion on this, so 
> I would recommend an RFC proposing an approach. I don't know whether that's 
> changing the behavior of `__has_builtin`, proposing `__can_use_builtin` and 
> deprecating `__has_builtin`, or something else; I don't have enough expertise 
> in offloading to feel like I should set the direction in that way. But I 
> think the most conservative approach would be to introduce 
> `__can_use_builtin` and deprecate `__has_builtin` as being a confused 
> interface.

I'm not a fan of deprecating `__has_builtin` because it's been around for quite 
awhile and it perfectly fine at doing what it says in the standardized 
languages. Offloading languages are kind of in this 'whatever works' area, so I 
don't think we should change behavior too much around their edge cases.

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -3808,13 +3866,39 @@ void Parser::ParseCXXMemberSpecification(SourceLocation 
RecordLoc,
   SourceLocation AbstractLoc;
   bool IsFinalSpelledSealed = false;
   bool IsAbstract = false;
+  TriviallyRelocatableSpecifier TriviallyRelocatable;
+  ReplaceableSpecifier Replacable;
 
   // Parse the optional 'final' keyword.
   if (getLangOpts().CPlusPlus && Tok.is(tok::identifier)) {
 while (true) {
   VirtSpecifiers::Specifier Specifier = isCXX11VirtSpecifier(Tok);
-  if (Specifier == VirtSpecifiers::VS_None)
-break;
+  if (Specifier == VirtSpecifiers::VS_None) {
+if (isCXX2CTriviallyRelocatableKeyword(Tok)) {
+  if (TriviallyRelocatable.isSet()) {
+auto Skipped = Tok;
+ConsumeToken();
+Diag(Skipped, diag::err_duplicate_class_relocation_specifier)
+<< 0 << TriviallyRelocatable.getLocation();
+  } else {
+ParseOptionalCXX2CTriviallyRelocatableSpecifier(

erichkeane wrote:

Based on the use, it makes sense to me to just omit `Optional` from these 
function names.

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -3808,13 +3866,39 @@ void Parser::ParseCXXMemberSpecification(SourceLocation 
RecordLoc,
   SourceLocation AbstractLoc;
   bool IsFinalSpelledSealed = false;
   bool IsAbstract = false;
+  TriviallyRelocatableSpecifier TriviallyRelocatable;
+  ReplaceableSpecifier Replacable;
 
   // Parse the optional 'final' keyword.
   if (getLangOpts().CPlusPlus && Tok.is(tok::identifier)) {
 while (true) {
   VirtSpecifiers::Specifier Specifier = isCXX11VirtSpecifier(Tok);
-  if (Specifier == VirtSpecifiers::VS_None)
-break;
+  if (Specifier == VirtSpecifiers::VS_None) {
+if (isCXX2CTriviallyRelocatableKeyword(Tok)) {
+  if (TriviallyRelocatable.isSet()) {
+auto Skipped = Tok;
+ConsumeToken();
+Diag(Skipped, diag::err_duplicate_class_relocation_specifier)
+<< 0 << TriviallyRelocatable.getLocation();

erichkeane wrote:

Comment on the 0/1 in these please.  
```suggestion
<< /*trivial_relocatable*/0 << 
TriviallyRelocatable.getLocation();
```

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -1057,12 +1057,24 @@ def ext_ms_abstract_keyword : ExtWarn<
   "'abstract' keyword is a Microsoft extension">,
   InGroup;
 
+def ext_relocatable_keyword : ExtWarn<
+  "'%select{trivially_relocatable|replaceable}0_if_eligible' "
+  "keyword is a C++2c extension">,
+  InGroup;
+def warn_relocatable_keyword  : Warning<
+  "'%select{trivially_relocatable|replaceable}0_if_eligible' "
+  "keyword is incompatible with standards before C++2c">,
+  DefaultIgnore, InGroup;
+
 def err_access_specifier_interface : Error<
   "interface types cannot specify '%select{private|protected}0' access">;
 
 def err_duplicate_class_virt_specifier : Error<
   "class already marked '%0'">;
 
+def err_duplicate_class_relocation_specifier : Error<
+  "class already marked 
%select{'trivially_relocatable_if_eligible'|'replaceable_if_eligible'}0">;

erichkeane wrote:

Agreed they should be the same, but I want them all this way :) 

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -1057,12 +1057,24 @@ def ext_ms_abstract_keyword : ExtWarn<
   "'abstract' keyword is a Microsoft extension">,
   InGroup;
 
+def ext_relocatable_keyword : ExtWarn<
+  "'%select{trivially_relocatable|replaceable}0_if_eligible' "

erichkeane wrote:

Please put the `_if_eligible` inside the select.  I get that it results in 
duplication, but having full-keywords in diagnostics makes them easier to 
search and makes this less awkward.  

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -1826,6 +1827,12 @@ The following type trait primitives are supported by 
Clang. Those traits marked
   functionally equivalent to copying the underlying bytes and then dropping the
   source object on the floor. This is true of trivial types and types which
   were made trivially relocatable via the ``clang::trivial_abi`` attribute.
+* ``__builtin_is_cpp_trivially_relocatable`` (C++): Returns true if and object
+  is trivially relocatable, as defined by the C++26 standard.

erichkeane wrote:

Can we get a stable-name cite here?

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


[clang] [CIR] Better handling of `void` function return (PR #128089)

2025-02-21 Thread Henrich Lauko via cfe-commits


@@ -375,11 +409,48 @@ void printFuncTypeArgs(mlir::AsmPrinter &p, 
mlir::ArrayRef params,
   p << ')';
 }
 
+// Use a custom parser to handle the optional return and argument types without
+// an optional anchor.
+static mlir::ParseResult parseFuncType(mlir::AsmParser &p,
+   mlir::Type &optionalReturnTypes,
+   llvm::SmallVector ¶ms,
+   bool &isVarArg) {
+  if (failed(parseFuncTypeReturn(p, optionalReturnTypes)))
+return failure();
+  return parseFuncTypeArgs(p, params, isVarArg);
+}
+
+static void printFuncType(mlir::AsmPrinter &p, mlir::Type optionalReturnTypes,
+  mlir::ArrayRef params, bool isVarArg) {
+  printFuncTypeReturn(p, optionalReturnTypes);
+  printFuncTypeArgs(p, params, isVarArg);
+}
+
+// Return the actual return type or an explicit !cir.void if the function does
+// not return anything
+mlir::Type FuncType::getReturnType() const {
+  if (isVoid())
+return cir::VoidType::get(getContext());
+  return static_cast(getImpl())->optionalReturnType;
+}
+
+/// Returns the result type of the function as an ArrayRef, enabling better
+/// integration with generic MLIR utilities.
 llvm::ArrayRef FuncType::getReturnTypes() const {
-  return static_cast(getImpl())->returnType;
+  if (isVoid())
+return {};
+  return static_cast(getImpl())->optionalReturnType;

xlauko wrote:

```suggestion
  return getOptionalReturnType();
```

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


[clang] [CIR] Better handling of `void` function return (PR #128089)

2025-02-21 Thread Henrich Lauko via cfe-commits


@@ -375,11 +409,48 @@ void printFuncTypeArgs(mlir::AsmPrinter &p, 
mlir::ArrayRef params,
   p << ')';
 }
 
+// Use a custom parser to handle the optional return and argument types without
+// an optional anchor.
+static mlir::ParseResult parseFuncType(mlir::AsmParser &p,
+   mlir::Type &optionalReturnTypes,
+   llvm::SmallVector ¶ms,
+   bool &isVarArg) {
+  if (failed(parseFuncTypeReturn(p, optionalReturnTypes)))
+return failure();
+  return parseFuncTypeArgs(p, params, isVarArg);
+}
+
+static void printFuncType(mlir::AsmPrinter &p, mlir::Type optionalReturnTypes,
+  mlir::ArrayRef params, bool isVarArg) {
+  printFuncTypeReturn(p, optionalReturnTypes);
+  printFuncTypeArgs(p, params, isVarArg);
+}
+
+// Return the actual return type or an explicit !cir.void if the function does
+// not return anything
+mlir::Type FuncType::getReturnType() const {
+  if (isVoid())
+return cir::VoidType::get(getContext());
+  return static_cast(getImpl())->optionalReturnType;

xlauko wrote:

```suggestion
  return getOptionalReturnType();
```

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


[clang] [llvm] [Clang][LLVM] Implement single-single vectors MOP4{A/S} (PR #127797)

2025-02-21 Thread Virginia Cangelosi via cfe-commits

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -1826,6 +1827,12 @@ The following type trait primitives are supported by 
Clang. Those traits marked
   functionally equivalent to copying the underlying bytes and then dropping the
   source object on the floor. This is true of trivial types and types which
   were made trivially relocatable via the ``clang::trivial_abi`` attribute.
+* ``__builtin_is_cpp_trivially_relocatable`` (C++): Returns true if and object

erichkeane wrote:

```suggestion
* ``__builtin_is_cpp_trivially_relocatable`` (C++): Returns true if an object
```

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -3808,13 +3866,39 @@ void Parser::ParseCXXMemberSpecification(SourceLocation 
RecordLoc,
   SourceLocation AbstractLoc;
   bool IsFinalSpelledSealed = false;
   bool IsAbstract = false;
+  TriviallyRelocatableSpecifier TriviallyRelocatable;
+  ReplaceableSpecifier Replacable;
 
   // Parse the optional 'final' keyword.
   if (getLangOpts().CPlusPlus && Tok.is(tok::identifier)) {
 while (true) {
   VirtSpecifiers::Specifier Specifier = isCXX11VirtSpecifier(Tok);
-  if (Specifier == VirtSpecifiers::VS_None)
-break;
+  if (Specifier == VirtSpecifiers::VS_None) {
+if (isCXX2CTriviallyRelocatableKeyword(Tok)) {
+  if (TriviallyRelocatable.isSet()) {
+auto Skipped = Tok;
+ConsumeToken();
+Diag(Skipped, diag::err_duplicate_class_relocation_specifier)
+<< 0 << TriviallyRelocatable.getLocation();
+  } else {
+ParseOptionalCXX2CTriviallyRelocatableSpecifier(
+TriviallyRelocatable);
+  }
+  continue;
+} else if (isCXX2CReplaceableKeyword(Tok)) {
+  if (Replacable.isSet()) {
+auto Skipped = Tok;
+ConsumeToken();
+Diag(Skipped, diag::err_duplicate_class_relocation_specifier)
+<< 1 << Replacable.getLocation();

erichkeane wrote:

here too.

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


[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2025-02-21 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,130 @@
+//===--- AmbiguousSmartptrResetCallCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AmbiguousSmartptrResetCallCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+
+AST_MATCHER(CXXMethodDecl, hasOnlyDefaultParameters) {
+  for (const auto *Param : Node.parameters()) {
+if (!Param->hasDefaultArg())
+  return false;
+  }
+
+  return true;
+}
+
+const auto DefaultSmartPointers = "::std::shared_ptr;::std::unique_ptr;"
+  "::boost::shared_ptr;::boost::scoped_ptr";

vbvictor wrote:

Thank you for pointing that out. I have written a note in documentation that 
says the check may not provide correct fix-its on user-defined types. I guess I 
will also include `::boost::scoped_ptr` as an example.
As for `::boost::scoped_ptr` the correct fix-it would be `ptr.reset(nullptr)` 
or `ptr.reset(0)`

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread via cfe-commits


@@ -2862,6 +2862,30 @@ bool QualType::isTriviallyRelocatableType(const 
ASTContext &Context) const {
   }
 }
 
+bool QualType::isCppTriviallyRelocatableType(const ASTContext &Context) const {
+  QualType BaseElementType = Context.getBaseElementType(*this);

Sirraide wrote:

Iirc `getBaseElementTypeUnsafe()` does less work, and we don’t care about cv 
qualifiers anyway here from what I can tell.

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


[clang] [Clang] Implement the core language parts of P2786 - Trivial relocation (PR #127636)

2025-02-21 Thread Erich Keane via cfe-commits


@@ -3625,6 +3632,21 @@ Query for this feature with 
``__has_builtin(__builtin_operator_new)`` or
 replaceable global (de)allocation functions, but do support calling at 
least
 ``::operator new(size_t)`` and ``::operator delete(void*)``.
 
+
+``__builtin_trivially_relocate``
+---
+
+**Syntax**:
+
+.. code-block:: c
+
+  T* __builtin_trivially_relocate(T* dest, T* src, size_t count)
+
+Trivially relocates ``count`` objects of relocatable, complete type ``T``
+from ``src`` to ``dest`` and returns ``dest``.
+This builtin is used to implement ``std::trivially_relocate``.

erichkeane wrote:

Do we need anything special for `std::trivially_relocate_at` and 
`std::relocate`?

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


[clang] [llvm] [polly] [DAG] shouldReduceLoadWidth - hasOneUse should check just the loaded value - not the chain (PR #128167)

2025-02-21 Thread Simon Pilgrim via cfe-commits

https://github.com/RKSimon updated 
https://github.com/llvm/llvm-project/pull/128167

>From e73c264d0937a11fd3b08ac18a6465c6826d31f1 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Fri, 21 Feb 2025 11:57:07 +
Subject: [PATCH 1/3] [DAG] shouldReduceLoadWidth - hasOneUse check for just be
 for the loaded value, not the chain etc.

The hasOneUse check was failing in any case where the load was part of a chain 
- we should only be checking if the loaded value has one use, and any updates 
to the chain should be handled by the fold calling shouldReduceLoadWidth.

I've updated the x86 implementation to match, although it has no effect here 
yet (I'm still looking at how to improve the x86 implementation) as the inner 
for loop was discarding chain uses anyway.

By using hasNUsesOfValue instead this patch exposes a missing dependency on the 
LLVMSelectionDAG library in a lot of tools + unittests, we can either update 
the CMakeLists.txt dependencies or make SDNode::hasNUsesOfValue inline - no 
string opinions on this tbh.

Noticed while fighting the x86 regressions in #122671
---
 llvm/include/llvm/CodeGen/TargetLowering.h|   2 +-
 llvm/lib/Target/X86/X86ISelLowering.cpp   |   3 +-
 llvm/test/CodeGen/AArch64/merge-store.ll  |   4 +-
 .../CodeGen/AArch64/sme-framelower-use-bp.ll  |  51 ++-
 .../sve-fixed-length-extract-subvector.ll | 234 +-
 .../AMDGPU/kernel-argument-dag-lowering.ll|   4 +-
 llvm/test/CodeGen/ARM/vpadd.ll|   2 +-
 llvm/test/CodeGen/RISCV/rvv/extractelt-fp.ll  |   4 +-
 .../rvv/fixed-vectors-extract-subvector.ll| 298 ++
 llvm/tools/llvm-extract/CMakeLists.txt|   1 +
 llvm/tools/llvm-reduce/CMakeLists.txt |   1 +
 llvm/unittests/Analysis/CMakeLists.txt|   1 +
 llvm/unittests/Frontend/CMakeLists.txt|   1 +
 llvm/unittests/IR/CMakeLists.txt  |   1 +
 .../Transforms/Coroutines/CMakeLists.txt  |   1 +
 .../Transforms/Instrumentation/CMakeLists.txt |   1 +
 .../Transforms/Scalar/CMakeLists.txt  |   1 +
 .../unittests/Transforms/Utils/CMakeLists.txt |   1 +
 18 files changed, 225 insertions(+), 386 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index a4c3d042fe3a4..c77f8fb11f2b8 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -1817,7 +1817,7 @@ class TargetLoweringBase {
  EVT NewVT) const {
 // By default, assume that it is cheaper to extract a subvector from a wide
 // vector load rather than creating multiple narrow vector loads.
-if (NewVT.isVector() && !Load->hasOneUse())
+if (NewVT.isVector() && !Load->hasNUsesOfValue(1, 0))
   return false;
 
 return true;
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 683c8c3bdf96d..68ea9f6828e50 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -3260,7 +3260,8 @@ bool X86TargetLowering::shouldReduceLoadWidth(SDNode 
*Load,
   // those uses are extracted directly into a store, then the extract + store
   // can be store-folded. Therefore, it's probably not worth splitting the 
load.
   EVT VT = Load->getValueType(0);
-  if ((VT.is256BitVector() || VT.is512BitVector()) && !Load->hasOneUse()) {
+  if ((VT.is256BitVector() || VT.is512BitVector()) &&
+  !Load->hasNUsesOfValue(1, 0)) {
 for (SDUse &Use : Load->uses()) {
   // Skip uses of the chain value. Result 0 of the node is the load value.
   if (Use.getResNo() != 0)
diff --git a/llvm/test/CodeGen/AArch64/merge-store.ll 
b/llvm/test/CodeGen/AArch64/merge-store.ll
index 6653984562ae6..74e3a6d27d3e0 100644
--- a/llvm/test/CodeGen/AArch64/merge-store.ll
+++ b/llvm/test/CodeGen/AArch64/merge-store.ll
@@ -11,14 +11,14 @@ define void @blam() {
 ; SPLITTING-NEXT:adrp x8, g1
 ; SPLITTING-NEXT:add x8, x8, :lo12:g1
 ; SPLITTING-NEXT:adrp x9, g0
-; SPLITTING-NEXT:ldr q0, [x9, :lo12:g0]
+; SPLITTING-NEXT:ldr d0, [x9, :lo12:g0]
 ; SPLITTING-NEXT:str d0, [x8]
 ; SPLITTING-NEXT:ret
 ;
 ; MISALIGNED-LABEL: blam:
 ; MISALIGNED:   // %bb.0:
 ; MISALIGNED-NEXT:adrp x8, g0
-; MISALIGNED-NEXT:ldr q0, [x8, :lo12:g0]
+; MISALIGNED-NEXT:ldr d0, [x8, :lo12:g0]
 ; MISALIGNED-NEXT:adrp x8, g1
 ; MISALIGNED-NEXT:add x8, x8, :lo12:g1
 ; MISALIGNED-NEXT:str d0, [x8]
diff --git a/llvm/test/CodeGen/AArch64/sme-framelower-use-bp.ll 
b/llvm/test/CodeGen/AArch64/sme-framelower-use-bp.ll
index 8d028c11b4a6b..15bf6a45f7541 100644
--- a/llvm/test/CodeGen/AArch64/sme-framelower-use-bp.ll
+++ b/llvm/test/CodeGen/AArch64/sme-framelower-use-bp.ll
@@ -531,18 +531,18 @@ define void @quux() #1 {
 ; CHECK-NEXT:ldr x18, [x19, #80] // 8-byte Folded Reload
 ; CHECK-NEXT:ldr x0, [x19, #72] // 8-byte Folded Reload
 ; CHECK-NEXT:ldr x1, [x19, #64] // 8-byte Fol

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2025-02-21 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,130 @@
+//===--- AmbiguousSmartptrResetCallCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AmbiguousSmartptrResetCallCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+namespace {
+
+AST_MATCHER(CXXMethodDecl, hasOnlyDefaultParameters) {
+  for (const auto *Param : Node.parameters()) {
+if (!Param->hasDefaultArg())
+  return false;
+  }
+
+  return true;
+}
+
+const auto DefaultSmartPointers = "::std::shared_ptr;::std::unique_ptr;"
+  "::boost::shared_ptr;::boost::scoped_ptr";

vbvictor wrote:

I think we should stick to 100% correct fix-its for default-defined types and 
warn users about incorrect behavoir of other types that lack `operator=` or 
`operator=` doesn't expect `std::nullptr_t`.

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


[clang] [CLANG-CL] Remove the 'static' declaration specifier for _FUNCTION_ in (PR #128184)

2025-02-21 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam created 
https://github.com/llvm/llvm-project/pull/128184

MSVC mode.

>From bcf2a4708c3f9ae88f5fddafe02c95533601c887 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Fri, 21 Feb 2025 07:14:02 -0800
Subject: [PATCH] [CLANG-CL] Remove the 'static' declaration specifier for
 _FUNCTION_ in MSVC mode.

---
 clang/lib/AST/Expr.cpp |  8 +--
 clang/test/SemaCXX/source_location.cpp | 31 ++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b747aa8df807d..14d0955503634 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -747,8 +747,12 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 if (const CXXMethodDecl *MD = dyn_cast(FD)) {
   if (MD->isVirtual() && IK != 
PredefinedIdentKind::PrettyFunctionNoVirtual)
 Out << "virtual ";
-  if (MD->isStatic())
-Out << "static ";
+  if (MD->isStatic()) {
+bool IsFunctionInMSVCCommpatEnv =
+IK == PredefinedIdentKind::Function && LO.MSVCCompat;
+if (ForceElaboratedPrinting && !IsFunctionInMSVCCommpatEnv)
+  Out << "static ";
+  }
 }
 
 class PrettyCallbacks final : public PrintingCallbacks {
diff --git a/clang/test/SemaCXX/source_location.cpp 
b/clang/test/SemaCXX/source_location.cpp
index 069a9004927a9..a9fca2a17c939 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -524,6 +524,37 @@ TestClass t2;
 TestStruct t3;
 TestEnum t4;
 
+class A { int b;};
+namespace inner {
+  template 
+  class C {
+  public:
+template 
+static void f(int i) {
+  (void)i;
+#ifdef MS
+ static_assert(is_equal(__FUNCTION__, "test_func::inner::C::f"));
+#else
+ static_assert(is_equal(__FUNCTION__, "f"));
+#endif
+}
+template 
+static void f(double f) {
+  (void)f;
+#ifdef MS
+ static_assert(is_equal(__FUNCTION__, "test_func::inner::C::f"));
+#else
+ static_assert(is_equal(__FUNCTION__, "f"));
+#endif
+}
+  };
+}
+
+  void foo() {
+  test_func::inner::C::f(1);
+  test_func::inner::C::f(1.0);
+}
+
 } // namespace test_func
 
 

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


[clang] [CLANG-CL] Remove the 'static' specifier for _FUNCTION_ in MSVC mode. (PR #128184)

2025-02-21 Thread Zahira Ammarguellat via cfe-commits

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


[clang] Check for mutability better (PR #127843)

2025-02-21 Thread Devon Loehr via cfe-commits

https://github.com/DKLoehr updated 
https://github.com/llvm/llvm-project/pull/127843

>From 7a919e29b221f1070c420e263760b7071dc01da8 Mon Sep 17 00:00:00 2001
From: Devon Loehr 
Date: Thu, 20 Feb 2025 15:19:13 +
Subject: [PATCH 1/3] Implement mutable check in Sema

---
 clang/lib/Sema/SemaDecl.cpp | 35 +++
 1 file changed, 19 insertions(+), 16 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 362df485a025c..3f3fea7e23814 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13440,6 +13440,23 @@ bool 
Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated(
   return true;
 }
 
+// Determine whether the object seems mutable for the purpose of diagnosing
+// possible unique object duplication, i.e. non-const-qualified, and
+// not an always-constant type like a function.
+// Not perfect: doesn't account for mutable members, for example, or
+// elements of container types.
+// For nested pointers, any individual level being non-const is sufficient.
+bool looksMutable(QualType T, const ASTContext &Ctx) {
+  T = T.getNonReferenceType();
+  if (T->isFunctionType())
+return false;
+  if (!T.isConstant(Ctx))
+return true;
+  if (T->isPointerType())
+return looksMutable(T->getPointeeType(), Ctx);
+  return false;
+}
+
 void Sema::DiagnoseUniqueObjectDuplication(const VarDecl *VD) {
   // If this object has external linkage and hidden visibility, it might be
   // duplicated when built into a shared library, which causes problems if it's
@@ -13454,24 +13471,10 @@ void Sema::DiagnoseUniqueObjectDuplication(const 
VarDecl *VD) {
   !VD->isTemplated() &&
   GloballyUniqueObjectMightBeAccidentallyDuplicated(VD)) {
 
-// Check mutability. For pointers, ensure that both the pointer and the
-// pointee are (recursively) const.
-QualType Type = VD->getType().getNonReferenceType();
-if (!Type.isConstant(VD->getASTContext())) {
+QualType Type = VD->getType();
+if (looksMutable(Type, VD->getASTContext())) {
   Diag(VD->getLocation(), diag::warn_possible_object_duplication_mutable)
   << VD;
-} else {
-  while (Type->isPointerType()) {
-Type = Type->getPointeeType();
-if (Type->isFunctionType())
-  break;
-if (!Type.isConstant(VD->getASTContext())) {
-  Diag(VD->getLocation(),
-   diag::warn_possible_object_duplication_mutable)
-  << VD;
-  break;
-}
-  }
 }
 
 // To keep false positives low, only warn if we're certain that the

>From 2e9bafe0191e9c9c694d5bb70e188607daae8bf5 Mon Sep 17 00:00:00 2001
From: Devon Loehr 
Date: Thu, 20 Feb 2025 15:20:06 +
Subject: [PATCH 2/3] Add test

---
 clang/test/SemaCXX/unique_object_duplication.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/test/SemaCXX/unique_object_duplication.h 
b/clang/test/SemaCXX/unique_object_duplication.h
index a59a8f91da8b8..861175766db70 100644
--- a/clang/test/SemaCXX/unique_object_duplication.h
+++ b/clang/test/SemaCXX/unique_object_duplication.h
@@ -99,6 +99,9 @@ inline void has_thread_local() {
   thread_local int disallowedThreadLocal = 0; // hidden-warning 
{{'disallowedThreadLocal' may be duplicated when built into a shared library: 
it is mutable, has hidden visibility, and external linkage}}
 }
 
+// Functions themselves are always immutable, so referencing them is okay
+inline auto& allowedFunctionReference = has_static_locals_external;
+
 } // namespace StaticLocalTest
 
 /**

>From be5482201c6d5004cc0a2cf48d1941f45905f5e7 Mon Sep 17 00:00:00 2001
From: Devon Loehr 
Date: Fri, 21 Feb 2025 15:18:29 +
Subject: [PATCH 3/3] Make function static

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

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3f3fea7e23814..7633651337aa3 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13446,7 +13446,7 @@ bool 
Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated(
 // Not perfect: doesn't account for mutable members, for example, or
 // elements of container types.
 // For nested pointers, any individual level being non-const is sufficient.
-bool looksMutable(QualType T, const ASTContext &Ctx) {
+static bool looksMutable(QualType T, const ASTContext &Ctx) {
   T = T.getNonReferenceType();
   if (T->isFunctionType())
 return false;

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


[clang] Remove xbegin and _xend (PR #126952)

2025-02-21 Thread Devon Loehr via cfe-commits

DKLoehr wrote:

Just checking in, this was approved a few days ago but hasn't been merged yet.

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


[clang] Check for mutability better (PR #127843)

2025-02-21 Thread Devon Loehr via cfe-commits

DKLoehr wrote:

Good call, changed.

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


[clang] [clang-tools-extra] [Clang] Default the warning for chained comparison to an error. (PR #128145)

2025-02-21 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-tools-extra,clang` at step 13 "test-suite".

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


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

```
Step 13 (test-suite) failure: test (failure)
...
size..interp: 28 
size..note.ABI-tag: 32 
size..note.gnu.property: 32 
size..plt: 64 
size..rela.dyn: 192 
size..rela.plt: 72 
size..rodata: 4 
size..text: 469 
**
NOEXE: test-suite :: 
SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-20180921-1.test 
(1230 of 2521)
 TEST 'test-suite :: 
SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-20180921-1.test' 
FAILED 
Executable 
'/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/test/sandbox/build/SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-20180921-1'
 is missing

PASS: test-suite :: 
SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-20150611-1.test 
(1231 of 2521)
** TEST 'test-suite :: 
SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-20150611-1.test' 
RESULTS **
compile_time: 0. 
exec_time: 0.0004 
hash: "33c0674fdb7ff53933d688c4e1550c4d" 
link_time: 0.0157 
size: 22848 
size..bss: 20 
size..comment: 154 
size..data: 4 
size..data.rel.ro: 8 
size..dynamic: 480 
size..dynstr: 136 
size..dynsym: 144 
size..eh_frame: 124 
size..eh_frame_hdr: 36 
size..fini: 13 
size..fini_array: 8 
size..gnu.build.attributes: 5004 
size..gnu.hash: 28 
size..gnu.version: 12 
size..gnu.version_r: 48 
size..got: 40 
size..got.plt: 32 
size..init: 27 
size..init_array: 8 
size..interp: 28 
size..note.ABI-tag: 32 
size..note.gnu.property: 32 
size..plt: 32 
size..rela.dyn: 192 
size..rela.plt: 24 
size..rodata: 4 
size..text: 367 
**
PASS: test-suite :: 
SingleSource/Regression/C/gcc-c-torture/execute/GCC-C-execute-20170401-1.test 
(1232 of 2521)

```



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


[clang] [WIP][clang]: Implement a conditional lifetimebound_if builtin. (PR #125520)

2025-02-21 Thread Haojian Wu via cfe-commits

hokein wrote:

Another thought for supporting the `emplace_back(Args...)` case (for STL only). 

The underlying implementation of the `emplace_back` relies on 
`std::allocator_traits::construct(Alloc& a, T* p, Args&&... args)`, so we could 
use the `lifetime_capture_by` annotation in the instantiated function (this 
annotation can be relatively easy to infer in clang).  

For example, consider an instantiated template (note that the function 
parameter should be an non-const rvalue reference):  

```cpp
construct(std::string_view* p, std::string&& arg 
[[clang::lifetime_capture_by(p)]]);
```  

Here, we annotate `arg` with `lifetime_capture_by(p)`, which should allow us to 
detect cases like:  

```cpp
construct(&view, std::string()); // Detects dangling pointer
```  

However, this approach doesn’t work for `emplace_back`, because in that case, 
we only see perfect forwarding in the function arguments 
(`construct(std::__to_address(__tx.__pos_), std::forward<_Args>(__args)...);`)

### Potential Extension:  

We could consider extending the analysis scope for non-const rvalue references. 
Specifically if a non-const rvalue reference parameter is annotated, we could 
always emit a warning when this function is being called. 

Example:  

```cpp
void add(std::vector& container, std::string&& s 
[[clang::lifetime_capture_by]]);

void test() {  
std::vector abc;  
add(abc, std::string());  // Case 1: Warning, point to a dead object  

std::string b;  
add(abc, std::move(b));   // Case 2: point to a moved-from object  

add(abc, b); // invalid c++ code, cannot bind a lvalue to rvalue reference
}
```  

For non-const rvalue reference function parameters, there are only two legal 
options to pass the argument:  
1. A temporary object.  
2. A non-const object explicitly marked with `std::move()`.  

- **Case 1)** is a clear use-after-free issue, which is already detected by the 
current implementation.  
- **Case 2)** is a bit subtle. The moved-from object is still alive but in a 
valid-but-unspecified state. While it’s technically possible to use the object 
after a `std::move()`, the general programming guideline is to avoid doing so, 
as it could lead to potential use-after-move issues (we have a use-after-move 
clang-tidy check).

If we extend the analysis to warn on Case (2), we should be able to detect the 
`emplace_back` case. However, I’m not sure whether making the compiler stricter 
on this is a feasible idea.


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


[clang] d2d1f14 - [z/OS] Add option to target older versions of LE on z/OS (#123399)

2025-02-21 Thread via cfe-commits

Author: Sean Perry
Date: 2025-02-21T10:30:35-05:00
New Revision: d2d1f143e5087e9490416bd98e49fd2f8fb5dd01

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

LOG: [z/OS] Add option to target older versions of LE on z/OS (#123399)

Add an option similar to the -qtarget option in XL to allow the user to
say they want to be able to run the generated program on an older
version of the LE environment. This option will do two things:
- set the `__TARGET_LIBS` macro so the system headers exclude newer
interfaces when targeting older environments
- set the arch level to match the minimum arch level for that older
version of LE. It doesn't happen right now since all of the supported LE
versions have a the same minimum ach level. So the option doesn't change
this yet.

The user can specify three different kinds of arguments:
1. -mzos-target=zosv*V*r*R* - where V & R are the version and release
2. -mzos-target=0x4vrr - v, r, m, p are the hex values for the
version, release, and modlevel
3. -mzos-target=current - uses the latest version of LE the system
headers have support for

Added: 
clang/test/Preprocessor/zos-target.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/SystemZ.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 2e571ee33cafa..8f532a63f9e04 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -279,6 +279,11 @@ def err_cpu_unsupported_isa
 def err_arch_unsupported_isa
   : Error<"architecture '%0' does not support '%1' execution mode">;
 
+def err_zos_target_release_discontinued
+  : Error<"z/OS target level \"%0\" is discontinued">;
+def err_zos_target_unrecognized_release
+  : Error<"z/OS target level \"%0\" is invalid">;
+
 def err_drv_I_dash_not_supported : Error<
   "'%0' not supported, please use -iquote instead">;
 def err_drv_unknown_argument : Error<"unknown argument: '%0'">;

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e6932821d8af8..e521cbf678d93 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4728,6 +4728,7 @@ def mwatchsimulator_version_min_EQ : Joined<["-"], 
"mwatchsimulator-version-min=
 def march_EQ : Joined<["-"], "march=">, Group,
   Flags<[TargetSpecific]>, Visibility<[ClangOption, CLOption, DXCOption, 
FlangOption]>,
   HelpText<"For a list of available architectures for the target use 
'-mcpu=help'">;
+def mzos_target_EQ : Joined<["-"], "mzos-target=">, Group, 
Visibility<[ClangOption, CC1Option]>, HelpText<"Set the z/OS release of the 
runtime environment">;
 def masm_EQ : Joined<["-"], "masm=">, Group, Visibility<[ClangOption, 
FlangOption]>;
 def inline_asm_EQ : Joined<["-"], "inline-asm=">, Group,
   Visibility<[ClangOption, CC1Option]>,

diff  --git a/clang/lib/Basic/Targets/SystemZ.cpp 
b/clang/lib/Basic/Targets/SystemZ.cpp
index 0e9a61c6a01c8..e15563fb3a784 100644
--- a/clang/lib/Basic/Targets/SystemZ.cpp
+++ b/clang/lib/Basic/Targets/SystemZ.cpp
@@ -15,6 +15,7 @@
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringSwitch.h"
 
 using namespace clang;
@@ -178,6 +179,21 @@ void SystemZTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 Builder.defineMacro("__VX__");
   if (Opts.ZVector)
 Builder.defineMacro("__VEC__", "10305");
+
+  /* Set __TARGET_LIB__ only if a value was given.  If no value was given  */
+  /* we rely on the LE headers to define __TARGET_LIB__.   */
+  if (!getTriple().getOSVersion().empty()) {
+llvm::VersionTuple V = getTriple().getOSVersion();
+// Create string with form: 0xPVRR, where P=4
+std::string Str("0x");
+unsigned int Librel = 0x4000;
+Librel |= V.getMajor() << 24;
+Librel |= (V.getMinor() ? V.getMinor().value() : 1) << 16;
+Librel |= V.getSubminor() ? V.getSubminor().value() : 0;
+Str += llvm::utohexstr(Librel);
+
+Builder.defineMacro("__TARGET_LIB__", Str.c_str());
+  }
 }
 
 llvm::SmallVector

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 50941d2aaa429..eca96c1cce7f7 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -564,6 +564,72 @@ DerivedArgList *Driver::TranslateInputArgs(const 
InputArgList &Args) const {
   return DAL;
 }
 
+static void setZosTargetVersion(const Driver &D, llvm::Triple &Target,
+StringRef A

[clang] [z/OS] Add option to target older versions of LE on z/OS (PR #123399)

2025-02-21 Thread Sean Perry via cfe-commits

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


[clang] [CLANG-CL] Remove the 'static' specifier for _FUNCTION_ in MSVC mode. (PR #128184)

2025-02-21 Thread Zahira Ammarguellat via cfe-commits

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


[clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-02-21 Thread via cfe-commits


@@ -339,6 +339,35 @@ class ClangTidyASTConsumer : public MultiplexConsumer {
   void anchor() override {};
 };
 
+/// ASTConsumer that filters top-level declarations that are in system headers,
+/// and sets the AST traversal scope to only cover the declarations in user
+/// headers. This makes all clang-tidy checks avoid spending time processing
+/// declarations in system headers. The results are discarded anyway when
+/// presenting the results.
+class IgnoreSystemHeadersConsumer : public ASTConsumer {
+public:
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (Decl *D : DG) {
+  if (!isInSystemHeader(D))
+Decls.push_back(D);
+}
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+Ctx.setTraversalScope(Decls);
+  }
+
+private:
+  std::vector Decls;
+
+  bool isInSystemHeader(Decl *D) {
+SourceManager &SM = D->getASTContext().getSourceManager();

EugeneZelenko wrote:

Should be `const`. Same below.

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


[clang-tools-extra] [clang-tidy] Avoid processing declarations in system headers (PR #128150)

2025-02-21 Thread via cfe-commits


@@ -339,6 +339,35 @@ class ClangTidyASTConsumer : public MultiplexConsumer {
   void anchor() override {};
 };
 
+/// ASTConsumer that filters top-level declarations that are in system headers,
+/// and sets the AST traversal scope to only cover the declarations in user
+/// headers. This makes all clang-tidy checks avoid spending time processing
+/// declarations in system headers. The results are discarded anyway when
+/// presenting the results.
+class IgnoreSystemHeadersConsumer : public ASTConsumer {
+public:
+  bool HandleTopLevelDecl(DeclGroupRef DG) override {
+for (Decl *D : DG) {
+  if (!isInSystemHeader(D))
+Decls.push_back(D);
+}
+return true;
+  }
+
+  void HandleTranslationUnit(ASTContext &Ctx) override {
+Ctx.setTraversalScope(Decls);
+  }
+
+private:
+  std::vector Decls;

EugeneZelenko wrote:

Please include `vector`.

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


[clang] 6dca33c - Check for mutability better (#127843)

2025-02-21 Thread via cfe-commits

Author: Devon Loehr
Date: 2025-02-21T16:41:04+01:00
New Revision: 6dca33ce20693381beab9817c12d512dfdac0b02

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

LOG: Check for mutability better (#127843)

This PR adds a function to determine if a type "looks" mutable. Since
it's impossible to be totally sure if something can or can't be modified
in C++, this makes a best-effort attempt to determine if variables of
that type can be modified or not.

The motivation for this change is the -Wunique-object-duplication
warning, which had a false positive due to a missed case while checking
for mutability. Pulling the logic into a separate function allows it to
be written much more cleanly. There should be no behavior change, except
that we no longer report function references to be mutable.

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/SemaCXX/unique_object_duplication.h

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 32cc9d33730d5..4b5351410f459 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13441,6 +13441,23 @@ bool 
Sema::GloballyUniqueObjectMightBeAccidentallyDuplicated(
   return true;
 }
 
+// Determine whether the object seems mutable for the purpose of diagnosing
+// possible unique object duplication, i.e. non-const-qualified, and
+// not an always-constant type like a function.
+// Not perfect: doesn't account for mutable members, for example, or
+// elements of container types.
+// For nested pointers, any individual level being non-const is sufficient.
+static bool looksMutable(QualType T, const ASTContext &Ctx) {
+  T = T.getNonReferenceType();
+  if (T->isFunctionType())
+return false;
+  if (!T.isConstant(Ctx))
+return true;
+  if (T->isPointerType())
+return looksMutable(T->getPointeeType(), Ctx);
+  return false;
+}
+
 void Sema::DiagnoseUniqueObjectDuplication(const VarDecl *VD) {
   // If this object has external linkage and hidden visibility, it might be
   // duplicated when built into a shared library, which causes problems if it's
@@ -13455,24 +13472,10 @@ void Sema::DiagnoseUniqueObjectDuplication(const 
VarDecl *VD) {
   !VD->isTemplated() &&
   GloballyUniqueObjectMightBeAccidentallyDuplicated(VD)) {
 
-// Check mutability. For pointers, ensure that both the pointer and the
-// pointee are (recursively) const.
-QualType Type = VD->getType().getNonReferenceType();
-if (!Type.isConstant(VD->getASTContext())) {
+QualType Type = VD->getType();
+if (looksMutable(Type, VD->getASTContext())) {
   Diag(VD->getLocation(), diag::warn_possible_object_duplication_mutable)
   << VD;
-} else {
-  while (Type->isPointerType()) {
-Type = Type->getPointeeType();
-if (Type->isFunctionType())
-  break;
-if (!Type.isConstant(VD->getASTContext())) {
-  Diag(VD->getLocation(),
-   diag::warn_possible_object_duplication_mutable)
-  << VD;
-  break;
-}
-  }
 }
 
 // To keep false positives low, only warn if we're certain that the

diff  --git a/clang/test/SemaCXX/unique_object_duplication.h 
b/clang/test/SemaCXX/unique_object_duplication.h
index a59a8f91da8b8..861175766db70 100644
--- a/clang/test/SemaCXX/unique_object_duplication.h
+++ b/clang/test/SemaCXX/unique_object_duplication.h
@@ -99,6 +99,9 @@ inline void has_thread_local() {
   thread_local int disallowedThreadLocal = 0; // hidden-warning 
{{'disallowedThreadLocal' may be duplicated when built into a shared library: 
it is mutable, has hidden visibility, and external linkage}}
 }
 
+// Functions themselves are always immutable, so referencing them is okay
+inline auto& allowedFunctionReference = has_static_locals_external;
+
 } // namespace StaticLocalTest
 
 /**



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


[clang] Check for mutability better (PR #127843)

2025-02-21 Thread Hans Wennborg via cfe-commits

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


[clang-tools-extra] [clang-tidy] Add new check `readability-use-numeric-limits` (PR #127430)

2025-02-21 Thread Katherine Whitlock via cfe-commits


@@ -0,0 +1,164 @@
+//===--- UseNumericLimitsCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UseNumericLimitsCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Preprocessor.h"
+#include 
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::readability {
+
+UseNumericLimitsCheck::UseNumericLimitsCheck(StringRef Name,
+ ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  SignedConstants{
+  {std::numeric_limits::min(),
+   "std::numeric_limits::min()"},
+  {std::numeric_limits::max(),
+   "std::numeric_limits::max()"},
+  {std::numeric_limits::min(),
+   "std::numeric_limits::min()"},
+  {std::numeric_limits::max(),
+   "std::numeric_limits::max()"},
+  {std::numeric_limits::min(),
+   "std::numeric_limits::min()"},
+  {std::numeric_limits::max(),
+   "std::numeric_limits::max()"},
+  {std::numeric_limits::min(),
+   "std::numeric_limits::min()"},
+  {std::numeric_limits::max(),
+   "std::numeric_limits::max()"},
+

stellar-aria wrote:

clang-format did not affect this, so I removed the line manually

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


  1   2   3   4   5   >