[clang] [NFC][C++][Modules] Mark P2788R0(DR) as implemented and added more test (PR #144214)

2025-07-08 Thread via cfe-commits

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


[clang] [NFC] [C++] [Modules] Mark P2788 as implemented and add test (PR #147138)

2025-07-08 Thread via cfe-commits

yronglin wrote:

Can you add the test from https://github.com/llvm/llvm-project/pull/144214? I 
think we also need to check that in clang/test/CXX/basic/basic.link/p3.cpp

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


[clang] [NFC][C++][Modules] Mark P2788R0(DR) as implemented and added more test (PR #144214)

2025-07-08 Thread via cfe-commits

yronglin wrote:

Duplicated with https://github.com/llvm/llvm-project/pull/147138, I think we 
can close this one.

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


[clang] [RISCV] Split out the intrinsic tests for bfloat16 into a separate directory named zvfbfmin. NFC. (PR #147644)

2025-07-08 Thread Brandon Wu via cfe-commits

https://github.com/4vtomat approved this pull request.

I agree with you that it's easier to maintain, btw are you going to do that for 
all extensions?

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


[clang] 6ee3751 - [RISCV] Correct type lowering of struct of fixed-vector array in VLS (#147173)

2025-07-08 Thread via cfe-commits

Author: Brandon Wu
Date: 2025-07-08T21:14:40-07:00
New Revision: 6ee375147b0b70cd44d06b83dc366c5862599280

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

LOG: [RISCV] Correct type lowering of struct of fixed-vector array in VLS 
(#147173)

Currently, struct of fixed-vector array is flattened and lowered to
scalable vector. However only struct of 1-element-fixed-vector array
should be lowered that way, struct of fixed-vector array of length >1
should be lowered to vector tuple type.

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/418/files#diff-3a934f00cffdb3e509722753126a2cf6082a7648ab3b9ca8cbb0e84f8a6a12edR555-R558

Added: 


Modified: 
clang/lib/CodeGen/Targets/RISCV.cpp
clang/test/CodeGen/RISCV/riscv-vector-callingconv-llvm-ir.c
clang/test/CodeGen/RISCV/riscv-vector-callingconv-llvm-ir.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/Targets/RISCV.cpp 
b/clang/lib/CodeGen/Targets/RISCV.cpp
index cc3d487da83b5..e3232b61a693c 100644
--- a/clang/lib/CodeGen/Targets/RISCV.cpp
+++ b/clang/lib/CodeGen/Targets/RISCV.cpp
@@ -441,98 +441,74 @@ bool RISCVABIInfo::detectVLSCCEligibleStruct(QualType Ty, 
unsigned ABIVLen,
   // __attribute__((vector_size(64))) int d;
   //   }
   //
-  // Struct of 1 fixed-length vector is passed as a scalable vector.
-  // Struct of >1 fixed-length vectors are passed as vector tuple.
-  // Struct of 1 array of fixed-length vectors is passed as a scalable vector.
-  // Otherwise, pass the struct indirectly.
-
-  if (llvm::StructType *STy = dyn_cast(CGT.ConvertType(Ty))) 
{
-unsigned NumElts = STy->getStructNumElements();
-if (NumElts > 8)
-  return false;
+  // 1. Struct of 1 fixed-length vector is passed as a scalable vector.
+  // 2. Struct of >1 fixed-length vectors are passed as vector tuple.
+  // 3. Struct of an array with 1 element of fixed-length vectors is passed as 
a
+  //scalable vector.
+  // 4. Struct of an array with >1 elements of fixed-length vectors is passed 
as
+  //vector tuple.
+  // 5. Otherwise, pass the struct indirectly.
+
+  llvm::StructType *STy = dyn_cast(CGT.ConvertType(Ty));
+  if (!STy)
+return false;
 
-auto *FirstEltTy = STy->getElementType(0);
-if (!STy->containsHomogeneousTypes())
-  return false;
+  unsigned NumElts = STy->getStructNumElements();
+  if (NumElts > 8)
+return false;
 
-// Check structure of fixed-length vectors and turn them into vector tuple
-// type if legal.
-if (auto *FixedVecTy = dyn_cast(FirstEltTy)) {
-  if (NumElts == 1) {
-// Handle single fixed-length vector.
-VLSType = llvm::ScalableVectorType::get(
-FixedVecTy->getElementType(),
-llvm::divideCeil(FixedVecTy->getNumElements() *
- llvm::RISCV::RVVBitsPerBlock,
- ABIVLen));
-// Check registers needed <= 8.
-return llvm::divideCeil(
-   FixedVecTy->getNumElements() *
-   FixedVecTy->getElementType()->getScalarSizeInBits(),
-   ABIVLen) <= 8;
-  }
-  // LMUL
-  // = fixed-length vector size / ABIVLen
-  // = 8 * I8EltCount / RVVBitsPerBlock
-  // =>
-  // I8EltCount
-  // = (fixed-length vector size * RVVBitsPerBlock) / (ABIVLen * 8)
-  unsigned I8EltCount = llvm::divideCeil(
-  FixedVecTy->getNumElements() *
-  FixedVecTy->getElementType()->getScalarSizeInBits() *
-  llvm::RISCV::RVVBitsPerBlock,
-  ABIVLen * 8);
-  VLSType = llvm::TargetExtType::get(
-  getVMContext(), "riscv.vector.tuple",
-  llvm::ScalableVectorType::get(llvm::Type::getInt8Ty(getVMContext()),
-I8EltCount),
-  NumElts);
-  // Check registers needed <= 8.
-  return NumElts *
- llvm::divideCeil(
- FixedVecTy->getNumElements() *
- FixedVecTy->getElementType()->getScalarSizeInBits(),
- ABIVLen) <=
- 8;
-}
+  auto *FirstEltTy = STy->getElementType(0);
+  if (!STy->containsHomogeneousTypes())
+return false;
 
-// If elements are not fixed-length vectors, it should be an array.
+  if (auto *ArrayTy = dyn_cast(FirstEltTy)) {
+// Only struct of single array is accepted
 if (NumElts != 1)
   return false;
+FirstEltTy = ArrayTy->getArrayElementType();
+NumElts = ArrayTy->getNumElements();
+  }
 
-// Check array of fixed-length vector and turn it into scalable vector type
-// if legal.
-if (auto *ArrTy = dyn_cast(FirstEltTy)) {
-  unsigned NumArrElt = ArrTy->getNumElements();
-  if (NumArrElt > 8)
-return false;
+  auto *FixedVecTy = dyn_cast(Firs

[clang] [RISCV] Correct type lowering of struct of fixed-vector array in VLS (PR #147173)

2025-07-08 Thread Brandon Wu via cfe-commits

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


[clang] [clang-format] Split line comments separated by backslashes (PR #147648)

2025-07-08 Thread Owen Pan via cfe-commits

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

Fixes #147341

>From 3efb5ca11d67ad36c4cbb1ea78220a1ca69a8339 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 8 Jul 2025 21:16:12 -0700
Subject: [PATCH] [clang-format] Split line comments separated by backslashes

Fixes #147341
---
 clang/docs/ClangFormatStyleOptions.rst|  6 +++---
 clang/include/clang/Format/Format.h   |  6 +++---
 clang/lib/Format/FormatTokenLexer.cpp | 20 ++-
 clang/unittests/Format/FormatTestComments.cpp | 18 -
 clang/unittests/Format/TokenAnnotatorTest.cpp |  7 +++
 5 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index c61c808831704..ab374c1886165 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1554,9 +1554,9 @@ the configuration (without a prefix: ``Auto``).
 
 .. code-block:: c++
 
-  #define A
  \
-int ;  
  \
-int b; 
  \
+  #define A\
+int ;  \
+int b; \
 int dd;
 
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 5d1fdb153b26e..74b516fe4f071 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -513,9 +513,9 @@ struct FormatStyle {
 ENAS_LeftWithLastLine,
 /// Align escaped newlines in the right-most column.
 /// \code
-///   #define A
  \
-/// int ;  
  \
-/// int b; 
  \
+///   #define A
\
+/// int ;  
\
+/// int b; 
\
 /// int dd;
 /// \endcode
 ENAS_Right,
diff --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index 40b62b2a993d8..91460ad5f4038 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -1336,16 +1336,18 @@ FormatToken *FormatTokenLexer::getNextToken() {
   // finds comments that contain a backslash followed by a line break, 
truncates
   // the comment token at the backslash, and resets the lexer to restart behind
   // the backslash.
-  if ((Style.isJavaScript() || Style.isJava()) && FormatTok->is(tok::comment) 
&&
-  FormatTok->TokenText.starts_with("//")) {
-size_t BackslashPos = FormatTok->TokenText.find('\\');
-while (BackslashPos != StringRef::npos) {
-  if (BackslashPos + 1 < FormatTok->TokenText.size() &&
-  FormatTok->TokenText[BackslashPos + 1] == '\n') {
-truncateToken(BackslashPos + 1);
-break;
+  if ((Style.isCpp() || Style.isJavaScript() || Style.isJava()) &&
+  FormatTok->is(tok::comment)) {
+if (const auto Text = FormatTok->TokenText; Text.starts_with("//")) {
+  for (auto Pos = Text.find('\\'); Pos++ != StringRef::npos;
+   Pos = Text.find('\\', Pos)) {
+if (Pos < Text.size() && Text[Pos] == '\n' &&
+(!Style.isCpp() ||
+ Text.substr(Pos + 1).ltrim().starts_with("//"))) {
+  truncateToken(Pos);
+  break;
+}
   }
-  BackslashPos = FormatTok->TokenText.find('\\', BackslashPos + 1);
 }
   }
 
diff --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index a16fbffb76270..88707551b7698 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -747,16 +747,14 @@ TEST_F(FormatTestComments, 
DontSplitLineCommentsWithEscapedNewlines) {
"   // AAA\\\n"
"   // AAA",
getLLVMStyleWithColumns(50)));
-  // FIXME: One day we might want to implement adjustment of leading whitespace
-  // of the consecutive lines in this kind of comment:
-  EXPECT_EQ("double\n"
-"a; // AAA\\\n"
-"  // AAA\\\n"
-"  // AAA",
-format("double a; // AAA\\\n"
-   

[clang] [clang-format] Split line comments separated by backslashes (PR #147648)

2025-07-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fixes #147341

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


5 Files Affected:

- (modified) clang/docs/ClangFormatStyleOptions.rst (+3-3) 
- (modified) clang/include/clang/Format/Format.h (+3-3) 
- (modified) clang/lib/Format/FormatTokenLexer.cpp (+11-9) 
- (modified) clang/unittests/Format/FormatTestComments.cpp (+8-10) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+7) 


``diff
diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index c61c808831704..ab374c1886165 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1554,9 +1554,9 @@ the configuration (without a prefix: ``Auto``).
 
 .. code-block:: c++
 
-  #define A
  \
-int ;  
  \
-int b; 
  \
+  #define A\
+int ;  \
+int b; \
 int dd;
 
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 5d1fdb153b26e..74b516fe4f071 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -513,9 +513,9 @@ struct FormatStyle {
 ENAS_LeftWithLastLine,
 /// Align escaped newlines in the right-most column.
 /// \code
-///   #define A
  \
-/// int ;  
  \
-/// int b; 
  \
+///   #define A
\
+/// int ;  
\
+/// int b; 
\
 /// int dd;
 /// \endcode
 ENAS_Right,
diff --git a/clang/lib/Format/FormatTokenLexer.cpp 
b/clang/lib/Format/FormatTokenLexer.cpp
index 40b62b2a993d8..91460ad5f4038 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -1336,16 +1336,18 @@ FormatToken *FormatTokenLexer::getNextToken() {
   // finds comments that contain a backslash followed by a line break, 
truncates
   // the comment token at the backslash, and resets the lexer to restart behind
   // the backslash.
-  if ((Style.isJavaScript() || Style.isJava()) && FormatTok->is(tok::comment) 
&&
-  FormatTok->TokenText.starts_with("//")) {
-size_t BackslashPos = FormatTok->TokenText.find('\\');
-while (BackslashPos != StringRef::npos) {
-  if (BackslashPos + 1 < FormatTok->TokenText.size() &&
-  FormatTok->TokenText[BackslashPos + 1] == '\n') {
-truncateToken(BackslashPos + 1);
-break;
+  if ((Style.isCpp() || Style.isJavaScript() || Style.isJava()) &&
+  FormatTok->is(tok::comment)) {
+if (const auto Text = FormatTok->TokenText; Text.starts_with("//")) {
+  for (auto Pos = Text.find('\\'); Pos++ != StringRef::npos;
+   Pos = Text.find('\\', Pos)) {
+if (Pos < Text.size() && Text[Pos] == '\n' &&
+(!Style.isCpp() ||
+ Text.substr(Pos + 1).ltrim().starts_with("//"))) {
+  truncateToken(Pos);
+  break;
+}
   }
-  BackslashPos = FormatTok->TokenText.find('\\', BackslashPos + 1);
 }
   }
 
diff --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index a16fbffb76270..88707551b7698 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -747,16 +747,14 @@ TEST_F(FormatTestComments, 
DontSplitLineCommentsWithEscapedNewlines) {
"   // AAA\\\n"
"   // AAA",
getLLVMStyleWithColumns(50)));
-  // FIXME: One day we might want to implement adjustment of leading whitespace
-  // of the consecutive lines in this kind of comment:
-  EXPECT_EQ("double\n"
-"a; // AAA\\\n"
-"  // AAA\\\n"
-"  // AAA",
-format("double a; // AAA\\\n"
-   "  // AAA\\\n"
-   "  // AAA",
-   getL

[clang] [llvm] Fix Windows EH IP2State tables (remove +1 bias) (PR #144745)

2025-07-08 Thread Eli Friedman via cfe-commits


@@ -2660,6 +2644,133 @@ void X86AsmPrinter::emitCallInstruction(const 
llvm::MCInst &MCI) {
   OutStreamer->emitInstruction(MCI, getSubtargetInfo());
 }
 
+// Checks whether a NOP is required after a CALL and inserts the NOP, if
+// necessary.
+void X86AsmPrinter::emitNopAfterCallForWindowsEH(const MachineInstr *MI) {
+  if (needsNopAfterCallForWindowsEH(MI))
+EmitAndCountInstruction(MCInstBuilder(X86::NOOP));
+}
+
+// Determines whether a NOP is required after a CALL, so that Windows EH
+// IP2State tables have the correct information.
+//
+// On most Windows platforms (AMD64, ARM64, ARM32, IA64, but *not* x86-32),
+// exception handling works by looking up instruction pointers in lookup
+// tables. These lookup tables are stored in .xdata sections in executables.
+// One element of the lookup tables are the "IP2State" tables (Instruction
+// Pointer to State).
+//
+// If a function has any instructions that require cleanup during exception
+// unwinding, then it will have an IP2State table. Each entry in the IP2State
+// table describes a range of bytes in the function's instruction stream, and
+// associates an "EH state number" with that range of instructions. A value of
+// -1 means "the null state", which does not require any code to execute.
+// A value other than -1 is an index into the State table.
+//
+// The entries in the IP2State table contain byte offsets within the 
instruction
+// stream of the function. The Windows ABI requires that these offsets are
+// aligned to instruction boundaries; they are not permitted to point to a byte
+// that is not the first byte of an instruction.
+//
+// Unfortunately, CALL instructions present a problem during unwinding. CALL
+// instructions push the address of the instruction after the CALL instruction,
+// so that execution can resume after the CALL. If the CALL is the last
+// instruction within an IP2State region, then the return address (on the 
stack)
+// points to the *next* IP2State region. This means that the unwinder will
+// use the wrong cleanup funclet during unwinding.
+//
+// To fix this problem, MSVC will insert a NOP after a CALL instruction, if the
+// CALL instruction is the last instruction within an IP2State region. The NOP
+// is placed within the same IP2State region as the CALL, so that the return
+// address points to the NOP and the unwinder will locate the correct region.
+//
+// Previously, LLVM fixed this by adding 1 to the instruction offsets in the
+// IP2State table. This caused the instruction boundary to point *within* the
+// instruction after a CALL. This works for the purposes of unwinding, since
+// there are no AMD64 instructions that can be encoded in a single byte and
+// which throw C++ exceptions. Unfortunately, this violates the Windows ABI
+// specification, which requires that the IP2State table entries point to the
+// boundaries between exceptions.
+//
+// To fix this properly, LLVM will now insert a 1-byte NOP after CALL
+// instructions, in the same situations that MSVC does. In performance tests,
+// the NOP has no detectable significance. The NOP is rarely inserted, since
+// it is only inserted when the CALL is the last instruction before an IP2State
+// transition or the CALL is the last instruction before the function epilogue.
+//
+// NOP padding is only necessary on Windows AMD64 targets. On ARM64 and ARM32,
+// instructions have a fixed size so the unwinder knows how to "back up" by
+// one instruction.
+//
+// Interaction with Import Call Optimization (ICO):
+//
+// Import Call Optimization (ICO) is a compiler + OS feature on Windows which
+// improves the performance and security of DLL imports. ICO relies on using a
+// specific CALL idiom that can be replaced by the OS DLL loader. This removes
+// a load and indirect CALL and replaces it with a single direct CALL.
+//
+// To achieve this, ICO also inserts NOPs after the CALL instruction. If the
+// end of the CALL is aligned with an EH state transition, we *also* insert
+// a single-byte NOP.  **Both forms of NOPs must be preserved.**  They cannot
+// be combined into a single larger NOP; nor can the second NOP be removed.
+//
+// This is necessary because, if ICO is active and the call site is modified
+// by the loader, the loader will end up overwriting the NOPs that were 
inserted
+// for ICO. That means that those NOPs cannot be used for the correct
+// termination of the exception handling region (the IP2State transition),
+// so we still need an additional NOP instruction.  The NOPs cannot be combined
+// into a longer NOP (which is ordinarily desirable) because then ICO would
+// split one instruction, producing a malformed instruction after the ICO call.

efriedma-quic wrote:

It's theoretically faster to decode a single nop, vs. multiple nops, on some 
processors.  Unlikely to be measurable in most cases.

https://github.com/llvm/llvm-project/pull/144745
___

[clang] [llvm] Fix Windows EH IP2State tables (remove +1 bias) (PR #144745)

2025-07-08 Thread Eli Friedman via cfe-commits


@@ -9,7 +9,6 @@ define i32 @foobar() gc "statepoint-example" personality ptr 
@__gxx_personality_
 ; CHECK-NEXT:.seh_endprologue
 ; CHECK-NEXT:callq bar
 ; CHECK-NEXT:  .Ltmp0:
-; CHECK-NEXT:nop

efriedma-quic wrote:

So the conclusion here is this particular case doesn't need the nop?  Fine, I 
guess.

I suspect there's an underlying issue with the algorithm, though.  Consider the 
following C++ function:

```C++
[[noreturn]] void g1();
void g2();
struct A { ~A(); };
void f(bool b) {
  if (b == false)
g1();
  A a;
  g2();
}
```

Compile with:

```
clang -O2 --target=x86_64-windows-msvc -mllvm -opt-bisect-limit=127
```

Produces:

```
pushq   %rbp
.seh_pushreg %rbp
subq$48, %rsp
.seh_stackalloc 48
leaq48(%rsp), %rbp
.seh_setframe %rbp, 48
.seh_endprologue
movq$-2, -8(%rbp)
testb   %cl, %cl
jne .LBB0_2
jmp .LBB0_1
.LBB0_1:# %if.then
callq   "?g1@@YAXXZ"
.LBB0_2:# %if.end
.Ltmp0: # EH_LABEL
callq   "?g2@@YAXXZ"
nop
[...]
```

You end up in the wrong region if g1 unwinds, I think.

(Not sure off the top of my head how to reproduce this without 
opt-bisect-limit, but I'm sure there's some way.)

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


[clang] [llvm] Fix Windows EH IP2State tables (remove +1 bias) (PR #144745)

2025-07-08 Thread Eli Friedman via cfe-commits


@@ -2537,26 +2538,6 @@ void X86AsmPrinter::emitInstruction(const MachineInstr 
*MI) {
 
   case X86::SEH_BeginEpilogue: {
 assert(MF->hasWinCFI() && "SEH_ instruction in function without WinCFI?");
-// Windows unwinder will not invoke function's exception handler if IP is
-// either in prologue or in epilogue.  This behavior causes a problem when 
a
-// call immediately precedes an epilogue, because the return address points
-// into the epilogue.  To cope with that, we insert a 'nop' if it ends up
-// immediately after a CALL in the final emitted code.
-MachineBasicBlock::const_iterator MBBI(MI);
-// Check if preceded by a call and emit nop if so.
-for (MBBI = PrevCrossBBInst(MBBI);
- MBBI != MachineBasicBlock::const_iterator();
- MBBI = PrevCrossBBInst(MBBI)) {

efriedma-quic wrote:

I'm seeing a warning "unused function PrevCrossBBInst"

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


[clang] [llvm] Fix Windows EH IP2State tables (remove +1 bias) (PR #144745)

2025-07-08 Thread Eli Friedman via cfe-commits


@@ -9,7 +9,6 @@ define i32 @foobar() gc "statepoint-example" personality ptr 
@__gxx_personality_
 ; CHECK-NEXT:.seh_endprologue
 ; CHECK-NEXT:callq bar
 ; CHECK-NEXT:  .Ltmp0:
-; CHECK-NEXT:nop

efriedma-quic wrote:

Looking a bit more, if you drop the `[[noreturn]]` and the opt-bisect-limit 
flag, you get the same result.

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


[clang] Sema: filter out invalid base-specifiers before attaching (PR #147213)

2025-07-08 Thread Corentin Jabot via cfe-commits

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

LGTM

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


[clang] Sema: filter out invalid base-specifiers before attaching (PR #147213)

2025-07-08 Thread Corentin Jabot via cfe-commits


@@ -2252,7 +2252,10 @@ void Parser::ParseBaseClause(Decl *ClassDecl) {
   while (true) {
 // Parse a base-specifier.
 BaseResult Result = ParseBaseSpecifier(ClassDecl);
-if (Result.isInvalid()) {
+// Skip any base-specifier we couldn’t actually build into a usable
+// CXXBaseSpecifier (covers both syntactic invalidity and
+// other un-usable cases).

cor3ntin wrote:

```suggestion
```

This comment isn't very useful

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


[clang] Sema: filter out invalid base-specifiers before attaching (PR #147213)

2025-07-08 Thread Corentin Jabot via cfe-commits


@@ -0,0 +1,13 @@
+// Tests that invalid base-specifiers no longer crash the compiler.
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+
+class X; // expected-note {{forward declaration of 'X'}} expected-note 
{{forward declaration of 'X'}}
+
+class A : X { // expected-error {{base class has incomplete type}}
+};
+
+class Y : int { // expected-error {{expected class name}}
+};
+
+class Z : X*, virtual int { // expected-error {{base class has incomplete 
type}} expected-error {{expected class name}}
+};

cor3ntin wrote:

```suggestion

namespace GH147186 {

class X; // expected-note {{forward declaration of 'X'}} expected-note 
{{forward declaration of 'X'}}

class A : X { // expected-error {{base class has incomplete type}}
};

class Y : int { // expected-error {{expected class name}}
};

class Z : X*, virtual int { // expected-error {{base class has incomplete 
type}} expected-error {{expected class name}}
};
}
```

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


[clang] [RISCV] Split out the intrinsic tests for bfloat16 into a separate directory named zvfbfmin. NFC. (PR #147644)

2025-07-08 Thread Jim Lin via cfe-commits

tclin914 wrote:

> I agree with you that it's easier to maintain, btw are you going to do that 
> for all extensions?

For now, I'm going to do this for zvfh/zvfhmin/zvfbfmin/zvfbfwma.

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


[clang] Sema: filter out invalid base-specifiers before attaching (PR #147213)

2025-07-08 Thread Corentin Jabot via cfe-commits

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


[clang] Sema: filter out invalid base-specifiers before attaching (PR #147213)

2025-07-08 Thread Corentin Jabot via cfe-commits


@@ -923,6 +923,7 @@ Bug Fixes to C++ Support
 - Improved handling of variables with ``consteval`` constructors, to
   consistently treat the initializer as manifestly constant-evaluated.
   (#GH135281)
+- Switch `ParseBaseClause` to use `BaseResult::isUsable()` instead of 
`isInvalid()`, fixing dropped or mis-parsed base specifiers in C++ classes. 
(#GH147186)

cor3ntin wrote:

```suggestion
- Fix a crash in the presence of invalid base classes. (#GH147186)
```

Release notes are meant to be user-facing

https://github.com/llvm/llvm-project/pull/147213
___
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 portability-avoid-platform-specific-fundamental-types (PR #146970)

2025-07-08 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,260 @@
+//===--- AvoidPlatformSpecificFundamentalTypesCheck.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 "AvoidPlatformSpecificFundamentalTypesCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/TargetInfo.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::portability {
+
+AvoidPlatformSpecificFundamentalTypesCheck::
+AvoidPlatformSpecificFundamentalTypesCheck(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  WarnOnFloats(Options.get("WarnOnFloats", true)),
+  WarnOnInts(Options.get("WarnOnInts", true)),
+  WarnOnChars(Options.get("WarnOnChars", true)),
+  IncludeInserter(Options.getLocalOrGlobal("IncludeStyle",
+   utils::IncludeSorter::IS_LLVM),
+  areDiagsSelfContained()) {}
+
+void AvoidPlatformSpecificFundamentalTypesCheck::registerPPCallbacks(
+const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) 
{
+  IncludeInserter.registerPreprocessor(PP);
+}
+
+void AvoidPlatformSpecificFundamentalTypesCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "WarnOnFloats", WarnOnFloats);
+  Options.store(Opts, "WarnOnInts", WarnOnInts);
+  Options.store(Opts, "WarnOnChars", WarnOnChars);
+  Options.store(Opts, "IncludeStyle", IncludeInserter.getStyle());
+}
+
+std::string AvoidPlatformSpecificFundamentalTypesCheck::getFloatReplacement(
+const BuiltinType *BT, ASTContext &Context) const {
+  const TargetInfo &Target = Context.getTargetInfo();
+
+  auto GetReplacementType = [](unsigned Width) {
+switch (Width) {
+// This is ambiguous by default since it could be bfloat16 or float16
+case 16U:
+  return "";
+case 32U:
+  return "float32_t";
+case 64U:
+  return "float64_t";
+case 128U:
+  return "float128_t";
+default:
+  return "";
+}
+  };
+
+  switch (BT->getKind()) {
+  // Not an ambiguous type
+  case BuiltinType::BFloat16:
+return "bfloat16_t";
+  case BuiltinType::Half:
+return GetReplacementType(Target.getHalfWidth());
+  case BuiltinType::Float:
+return GetReplacementType(Target.getFloatWidth());
+  case BuiltinType::Double:
+return GetReplacementType(Target.getDoubleWidth());
+  default:
+return "";
+  }
+}
+
+void AvoidPlatformSpecificFundamentalTypesCheck::registerMatchers(
+MatchFinder *Finder) {
+  // Build the list of type strings to match
+  std::vector TypeStrings;
+
+  // Add integer types if the option is enabled
+  if (WarnOnInts) {
+TypeStrings.insert(TypeStrings.end(), {"short",

vbvictor wrote:

For `typedef`'s you would check underlying type with this type-matcher.
Also, You'll need to check for unqualified desugared types if you want to 
detect this case:
```cpp
using MyLong = long;
MyLong global_long = 100L; // Warning
```
Or you deliberately want to omit this case? 

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


[clang] [NFC][PowerPC][clang] Update clang/test/Driver/aix-default-target-triple.c for AIX specific targets (PR #147584)

2025-07-08 Thread Tony Varghese via cfe-commits

https://github.com/tonykuttai updated 
https://github.com/llvm/llvm-project/pull/147584

>From 8530b1d115c06c1796b640ce16de47fce684a469 Mon Sep 17 00:00:00 2001
From: Tony Varghese 
Date: Tue, 8 Jul 2025 18:55:31 +
Subject: [PATCH 1/2] [NFC][PowerPC][clang] Update
 clang/test/Driver/aix-default-target-triple.c for AIX specifc targets

---
 clang/test/Driver/aix-default-target-triple.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/test/Driver/aix-default-target-triple.c 
b/clang/test/Driver/aix-default-target-triple.c
index afad278de78d0..e08cfaf97d349 100644
--- a/clang/test/Driver/aix-default-target-triple.c
+++ b/clang/test/Driver/aix-default-target-triple.c
@@ -3,6 +3,7 @@
 // and doesn't fall back to "unknown" due to constructor ambiguity.
 
 // REQUIRES: system-aix
+// SUPPORTED: target={{.*}}-aix{{.*}}
 // RUN: %clang -v %s -c 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET
 
 // Test that the target triple contains AIX and is not "unknown"

>From a735ffe5c80d2af208a83a53fbf751a40c792d1f Mon Sep 17 00:00:00 2001
From: Tony Varghese 
Date: Tue, 8 Jul 2025 18:55:31 +
Subject: [PATCH 2/2] [NFC][PowerPC][clang] Update
 clang/test/Driver/aix-default-target-triple.c for AIX specifc targets.

---
 clang/test/Driver/aix-default-target-triple.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/test/Driver/aix-default-target-triple.c 
b/clang/test/Driver/aix-default-target-triple.c
index e08cfaf97d349..d7a9b8c1cd1e0 100644
--- a/clang/test/Driver/aix-default-target-triple.c
+++ b/clang/test/Driver/aix-default-target-triple.c
@@ -2,13 +2,12 @@
 // This test verifies that the default target triple is correctly resolved
 // and doesn't fall back to "unknown" due to constructor ambiguity.
 
-// REQUIRES: system-aix
-// SUPPORTED: target={{.*}}-aix{{.*}}
+// REQUIRES: system-aix, target={{.*}}-aix{{.*}}
 // RUN: %clang -v %s -c 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET
 
 // Test that the target triple contains AIX and is not "unknown"
 // The target should be something like "powerpc-ibm-aix7.3.0.0"
-// CHECK-TARGET: Target: {{.*}}aix{{.*}}
+// CHECK-TARGET: Target: {{.*}}-aix{{.*}}
 
 int main() {
 return 0;

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


[clang] [NFC][PowerPC][clang] Update clang/test/Driver/aix-default-target-triple.c for AIX specific targets (PR #147584)

2025-07-08 Thread Tony Varghese via cfe-commits

https://github.com/tonykuttai updated 
https://github.com/llvm/llvm-project/pull/147584

>From 8530b1d115c06c1796b640ce16de47fce684a469 Mon Sep 17 00:00:00 2001
From: Tony Varghese 
Date: Tue, 8 Jul 2025 18:55:31 +
Subject: [PATCH 1/2] [NFC][PowerPC][clang] Update
 clang/test/Driver/aix-default-target-triple.c for AIX specifc targets

---
 clang/test/Driver/aix-default-target-triple.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/test/Driver/aix-default-target-triple.c 
b/clang/test/Driver/aix-default-target-triple.c
index afad278de78d0..e08cfaf97d349 100644
--- a/clang/test/Driver/aix-default-target-triple.c
+++ b/clang/test/Driver/aix-default-target-triple.c
@@ -3,6 +3,7 @@
 // and doesn't fall back to "unknown" due to constructor ambiguity.
 
 // REQUIRES: system-aix
+// SUPPORTED: target={{.*}}-aix{{.*}}
 // RUN: %clang -v %s -c 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET
 
 // Test that the target triple contains AIX and is not "unknown"

>From a735ffe5c80d2af208a83a53fbf751a40c792d1f Mon Sep 17 00:00:00 2001
From: Tony Varghese 
Date: Tue, 8 Jul 2025 18:55:31 +
Subject: [PATCH 2/2] [NFC][PowerPC][clang] Update
 clang/test/Driver/aix-default-target-triple.c for AIX specifc targets.

---
 clang/test/Driver/aix-default-target-triple.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/test/Driver/aix-default-target-triple.c 
b/clang/test/Driver/aix-default-target-triple.c
index e08cfaf97d349..d7a9b8c1cd1e0 100644
--- a/clang/test/Driver/aix-default-target-triple.c
+++ b/clang/test/Driver/aix-default-target-triple.c
@@ -2,13 +2,12 @@
 // This test verifies that the default target triple is correctly resolved
 // and doesn't fall back to "unknown" due to constructor ambiguity.
 
-// REQUIRES: system-aix
-// SUPPORTED: target={{.*}}-aix{{.*}}
+// REQUIRES: system-aix, target={{.*}}-aix{{.*}}
 // RUN: %clang -v %s -c 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET
 
 // Test that the target triple contains AIX and is not "unknown"
 // The target should be something like "powerpc-ibm-aix7.3.0.0"
-// CHECK-TARGET: Target: {{.*}}aix{{.*}}
+// CHECK-TARGET: Target: {{.*}}-aix{{.*}}
 
 int main() {
 return 0;

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


[clang-tools-extra] fbc4255 - [clang-tidy] Teach `modernize-type-traits` about more type traits (#147074)

2025-07-08 Thread via cfe-commits

Author: Victor Chernyakin
Date: 2025-07-09T08:21:40+03:00
New Revision: fbc4255ffcb8412a098926c7fc1ede823d6fb0e5

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

LOG: [clang-tidy] Teach `modernize-type-traits` about more type traits (#147074)

These new traits come from various standard versions:

C++14:

 - `tuple_element_t`

C++17:

- `is_placeholder_v`
- `is_bind_expression_v`
- `ratio_equal_v`
- `ratio_not_equal_v`
- `ratio_less_v`
- `ratio_less_equal_v`
- `ratio_greater_v`
- `ratio_greater_equal_v`
- `is_error_code_enum_v`
- `is_error_condition_enum_v`
- `is_execution_policy_v`
- `tuple_size_v`
- `variant_size_v`
- `uses_allocator_v`
- `variant_alternative_t`

C++20:

  - `compare_three_way_result_t`
  - `common_comparison_category_t`
  - `unwrap_ref_decay_t`
  - `unwrap_reference_t`

C++23:

- `is_implicit_lifetime_v`

C++26:

- `is_nothrow_relocatable_v`
- `is_replaceable_v`
- `is_trivially_relocatable_v`
- `is_virtual_base_of_v`

This doesn't add `treat_as_floating_point_v` or `is_clock_v` because
they require more invasive changes; instead I've opened #147072 to track
them.

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/modernize/type-traits.rst
clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
index c0766395ec5cc..ff0b3213cb58f 100644
--- a/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
@@ -15,6 +15,9 @@ using namespace clang::ast_matchers;
 
 namespace clang::tidy::modernize {
 
+// FIXME: Add chrono::treat_as_floating_point_v and chrono::is_clock_v.
+// This will require restructuring the code to handle type traits not
+// defined directly in std.
 static const llvm::StringSet<> ValueTraits = {
 "alignment_of",
 "conjunction",
@@ -28,6 +31,7 @@ static const llvm::StringSet<> ValueTraits = {
 "is_array",
 "is_assignable",
 "is_base_of",
+"is_bind_expression",
 "is_bounded_array",
 "is_class",
 "is_compound",
@@ -40,10 +44,14 @@ static const llvm::StringSet<> ValueTraits = {
 "is_destructible",
 "is_empty",
 "is_enum",
+"is_error_code_enum",
+"is_error_condition_enum",
+"is_execution_policy",
 "is_final",
 "is_floating_point",
 "is_function",
 "is_fundamental",
+"is_implicit_lifetime",
 "is_integral",
 "is_invocable",
 "is_invocable_r",
@@ -65,14 +73,17 @@ static const llvm::StringSet<> ValueTraits = {
 "is_nothrow_invocable_r",
 "is_nothrow_move_assignable",
 "is_nothrow_move_constructible",
+"is_nothrow_relocatable",
 "is_nothrow_swappable",
 "is_nothrow_swappable_with",
 "is_null_pointer",
 "is_object",
+"is_placeholder",
 "is_pointer",
 "is_pointer_interconvertible_base_of",
 "is_polymorphic",
 "is_reference",
+"is_replaceable",
 "is_rvalue_reference",
 "is_same",
 "is_scalar",
@@ -91,15 +102,26 @@ static const llvm::StringSet<> ValueTraits = {
 "is_trivially_destructible",
 "is_trivially_move_assignable",
 "is_trivially_move_constructible",
+"is_trivially_relocatable",
 "is_unbounded_array",
 "is_union",
 "is_unsigned",
+"is_virtual_base_of",
 "is_void",
 "is_volatile",
 "negation",
 "rank",
+"ratio_equal",
+"ratio_greater_equal",
+"ratio_greater",
+"ratio_less_equal",
+"ratio_less",
+"ratio_not_equal",
 "reference_constructs_from_temporary",
 "reference_converts_from_temporary",
+"tuple_size",
+"uses_allocator",
+"variant_size",
 };
 
 static const llvm::StringSet<> TypeTraits = {
@@ -130,6 +152,12 @@ static const llvm::StringSet<> TypeTraits = {
 "result_of",
 "invoke_result",
 "type_identity",
+"compare_three_way_result",
+"common_comparison_category",
+"unwrap_ref_decay",
+"unwrap_reference",
+"tuple_element",
+"variant_alternative",
 };
 
 static DeclarationName getName(const DependentScopeDeclRefExpr &D) {

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index e021d6350694e..6856aa257d670 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -281,6 +281,9 @@ Changes in existing checks
   excluding variables with ``thread_local`` storage class specifier from being
   matched.
 
+- Improved :doc:`modernize-type-traits
+  ` check by detecting more type 
traits.
+
 - Improved :doc:`modernize-use-default-member-init
 

[clang-tools-extra] [clang-tidy] Teach `modernize-type-traits` about more type traits (PR #147074)

2025-07-08 Thread Baranov Victor via cfe-commits

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


[clang-tools-extra] [clang-tidy] Teach `modernize-type-traits` about more type traits (PR #147074)

2025-07-08 Thread via cfe-commits

github-actions[bot] wrote:



@localspook Congratulations on having your first Pull Request (PR) merged into 
the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[clang] [CIR] Add support for parsing complete records (PR #147403)

2025-07-08 Thread Henrich Lauko via cfe-commits

xlauko wrote:

Can you add to CIR_RecordType description an example with packed/padded flag?

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Henrich Lauko via cfe-commits

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


[clang] Add warning for blocks capturing {'this', raw pointers, references} (PR #144388)

2025-07-08 Thread Sylvain Defresne via cfe-commits


@@ -1641,6 +1641,17 @@ def warn_implicitly_retains_self : Warning <
   "block implicitly retains 'self'; explicitly mention 'self' to indicate "
   "this is intended behavior">,
   InGroup>, DefaultIgnore;
+def warn_blocks_capturing_this : Warning<"block implicitly captures 'this'">,
+ InGroup>,
+ DefaultIgnore;
+def warn_blocks_capturing_reference
+: Warning<"block implicitly captures a C++ reference">,
+  InGroup>,
+  DefaultIgnore;
+def warn_blocks_capturing_raw_pointer
+: Warning<"block implicitly captures a raw pointer">,

sdefresne wrote:

Thank you.

I'll work on writing an RFC.

Regarding `__attribute__((noescape))`, my current patch already respect this 
and do not report captures from blocks marked with this attribute.

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


[clang] [Clang] Fix crash on `void{}` (PR #147514)

2025-07-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Corentin Jabot (cor3ntin)


Changes

Caused by an incorrect assertion.

Fixes #116440

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGExprScalar.cpp (+3-1) 
- (modified) clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp (+9) 


``diff
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index fc441dd92d1ee..44931d0481e26 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2114,8 +2114,10 @@ static int getAsInt32(llvm::ConstantInt *C, llvm::Type 
*I32Ty) {
 Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
   bool Ignore = TestAndClearIgnoreResultAssign();
   (void)Ignore;
-  assert (Ignore == false && "init list ignored");
   unsigned NumInitElements = E->getNumInits();
+  assert(Ignore == false ||
+ (NumInitElements == 0 && E->getType()->isVoidType()) &&
+ "init list ignored");
 
   // HLSL initialization lists in the AST are an expansion which can contain
   // side-effecting expressions wrapped in opaque value expressions. To 
properly
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp 
b/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
index 2f6a6820a7589..478ad40359727 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
@@ -5,3 +5,12 @@ void f()
   // CHECK: store i32 0
   int i{};
 }
+
+
+namespace GH116440 {
+void f() {
+  void{};
+  void();
+}
+
+}

``




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


[clang] [Clang] Fix crash on `void{}` (PR #147514)

2025-07-08 Thread Corentin Jabot via cfe-commits

https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/147514

Caused by an incorrect assertion.

Fixes #116440

>From 4b536efe500f3b9099d1cf1a1a8775633e193249 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Tue, 8 Jul 2025 14:34:16 +0200
Subject: [PATCH] [Clang] Fix crash on `void{}`

Caused by an incorrect assertion.

Fixes #116440
---
 clang/lib/CodeGen/CGExprScalar.cpp  | 4 +++-
 clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp | 9 +
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index fc441dd92d1ee..44931d0481e26 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2114,8 +2114,10 @@ static int getAsInt32(llvm::ConstantInt *C, llvm::Type 
*I32Ty) {
 Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
   bool Ignore = TestAndClearIgnoreResultAssign();
   (void)Ignore;
-  assert (Ignore == false && "init list ignored");
   unsigned NumInitElements = E->getNumInits();
+  assert(Ignore == false ||
+ (NumInitElements == 0 && E->getType()->isVoidType()) &&
+ "init list ignored");
 
   // HLSL initialization lists in the AST are an expansion which can contain
   // side-effecting expressions wrapped in opaque value expressions. To 
properly
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp 
b/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
index 2f6a6820a7589..478ad40359727 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-scalars.cpp
@@ -5,3 +5,12 @@ void f()
   // CHECK: store i32 0
   int i{};
 }
+
+
+namespace GH116440 {
+void f() {
+  void{};
+  void();
+}
+
+}

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


[clang] [clang-tools-extra] [lldb] [clang] Extend SourceLocation to 64 bits. (PR #147292)

2025-07-08 Thread Erich Keane via cfe-commits

erichkeane wrote:

> > Why is this a new review? What changed from the last one I looked at?
> 
> Ah, right -- this patch is actually derived from the previous one, and it is 
> simpler. That older patch became a bit outdated since some of its changes 
> were split out and already landed in main. I found it easier to start fresh 
> with a new patch rather than rebasing the old one.
> 
> That said, if you’d prefer to stick with the old review (to preserve the 
> initial comments there), I can force-push this patch to the old review 
> instead.

Ah, not a problem, the new one is fine.  I was just very thrown/wondering why I 
was reviewing something so similar again.

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


[clang] 77ea912 - [clang][diagnostics] Refactor "warn_doc_container_decl_mismatch" to use enum_select (#147120)

2025-07-08 Thread via cfe-commits

Author: Ayokunle Amodu
Date: 2025-07-08T06:15:41-07:00
New Revision: 77ea912a796e00f86a6a114de45c01017a9d51d3

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

LOG: [clang][diagnostics] Refactor "warn_doc_container_decl_mismatch" to use 
enum_select (#147120)

Related: https://github.com/llvm/llvm-project/issues/123121

This patch refactors the `warn_doc_container_decl_mismatch` diagnostic
to use `enum_select` instead of `select`. This gets rid of magic numbers
and improves readability in the caller site.

@cor3ntin @erichkeane

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticCommentKinds.td
clang/lib/AST/CommentSema.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticCommentKinds.td 
b/clang/include/clang/Basic/DiagnosticCommentKinds.td
index 1122ace3027d8..0ce53b395ecee 100644
--- a/clang/include/clang/Basic/DiagnosticCommentKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommentKinds.td
@@ -90,8 +90,10 @@ def warn_doc_api_container_decl_mismatch : Warning<
   InGroup, DefaultIgnore;
 
 def warn_doc_container_decl_mismatch : Warning<
-  "'%select{\\|@}0%select{classdesign|coclass|dependency|helper"
-  
"|helperclass|helps|instancesize|ownership|performance|security|superclass}1' "
+  "'%select{\\|@}0%enum_select{%ClassDesign{classdesign}|"
+  
"%CoClass{coclass}|%Dependency{dependency}|%Helper{helper}|%HelperClass{helperclass}|"
+  "%Helps{helps}|%InstanceSize{instancesize}|%Ownership{ownership}|"
+  "%Performance{performance}|%Security{security}|%Superclass{superclass}}1' "
   "command should not be used in a comment attached to a non-container 
declaration">,
   InGroup, DefaultIgnore;
 

diff  --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 36a9ebe14d7da..95f6bf79d118c 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -171,50 +171,49 @@ void Sema::checkContainerDecl(const BlockCommandComment 
*Comment) {
   const CommandInfo *Info = Traits.getCommandInfo(Comment->getCommandID());
   if (!Info->IsRecordLikeDetailCommand || isRecordLikeDecl())
 return;
-  unsigned DiagSelect;
+  std::optional DiagSelect;
   switch (Comment->getCommandID()) {
 case CommandTraits::KCI_classdesign:
-  DiagSelect = 1;
+  DiagSelect = diag::DocCommandKind::ClassDesign;
   break;
 case CommandTraits::KCI_coclass:
-  DiagSelect = 2;
+  DiagSelect = diag::DocCommandKind::CoClass;
   break;
 case CommandTraits::KCI_dependency:
-  DiagSelect = 3;
+  DiagSelect = diag::DocCommandKind::Dependency;
   break;
 case CommandTraits::KCI_helper:
-  DiagSelect = 4;
+  DiagSelect = diag::DocCommandKind::Helper;
   break;
 case CommandTraits::KCI_helperclass:
-  DiagSelect = 5;
+  DiagSelect = diag::DocCommandKind::HelperClass;
   break;
 case CommandTraits::KCI_helps:
-  DiagSelect = 6;
+  DiagSelect = diag::DocCommandKind::Helps;
   break;
 case CommandTraits::KCI_instancesize:
-  DiagSelect = 7;
+  DiagSelect = diag::DocCommandKind::InstanceSize;
   break;
 case CommandTraits::KCI_ownership:
-  DiagSelect = 8;
+  DiagSelect = diag::DocCommandKind::Ownership;
   break;
 case CommandTraits::KCI_performance:
-  DiagSelect = 9;
+  DiagSelect = diag::DocCommandKind::Performance;
   break;
 case CommandTraits::KCI_security:
-  DiagSelect = 10;
+  DiagSelect = diag::DocCommandKind::Security;
   break;
 case CommandTraits::KCI_superclass:
-  DiagSelect = 11;
+  DiagSelect = diag::DocCommandKind::Superclass;
   break;
 default:
-  DiagSelect = 0;
+  DiagSelect = std::nullopt;
   break;
   }
   if (DiagSelect)
 Diag(Comment->getLocation(), diag::warn_doc_container_decl_mismatch)
-<< Comment->getCommandMarker()
-<< (DiagSelect-1)
-<< Comment->getSourceRange();
+<< Comment->getCommandMarker() << (*DiagSelect)
+<< Comment->getSourceRange();
 }
 
 /// Turn a string into the corresponding PassDirection or -1 if it's not



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


[clang] [clang][diagnostics] Refactor "warn_doc_container_decl_mismatch" to use enum_select (PR #147120)

2025-07-08 Thread Erich Keane via cfe-commits

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


[clang] [llvm] [PowerPC][clang] Fix triple constructor ambiguity causing "unknown" target triple on AIX (PR #147488)

2025-07-08 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,15 @@
+// Test for the Triple constructor ambiguity fix on AIX
+// This test verifies that the default target triple is correctly resolved
+// and doesn't fall back to "unknown" due to constructor ambiguity.
+
+// REQUIRES: system-aix
+// RUN: %clang -v %s -c 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET
+
+// Test that the target triple contains AIX and is not "unknown"
+// The target should be something like "powerpc-ibm-aix7.3.0.0"
+// CHECK-TARGET: Target: {{.*}}aix{{.*}}
+// CHECK-TARGET-NOT: error: unknown target triple 'unknown'

arsenm wrote:

```suggestion
```

Negative checks of error messages are far too brittle, just rely on it not 
erroring? 

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


[clang] [llvm] [PowerPC][clang] Fix triple constructor ambiguity causing "unknown" target triple on AIX (PR #147488)

2025-07-08 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,15 @@
+// Test for the Triple constructor ambiguity fix on AIX
+// This test verifies that the default target triple is correctly resolved
+// and doesn't fall back to "unknown" due to constructor ambiguity.
+
+// REQUIRES: system-aix
+// RUN: %clang -v %s -c 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET

arsenm wrote:

```suggestion
// RUN: %clang -v %s -c | FileCheck %s --check-prefix=CHECK-TARGET
```

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


[clang] [llvm] [PowerPC][clang] Fix triple constructor ambiguity causing "unknown" target triple on AIX (PR #147488)

2025-07-08 Thread Matt Arsenault via cfe-commits

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

lgtm with test nits 

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


[clang] [llvm] [PowerPC][clang] Fix triple constructor ambiguity causing "unknown" target triple on AIX (PR #147488)

2025-07-08 Thread Matt Arsenault via cfe-commits

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


[clang] [llvm] [clang] Avoid printing overly large integer/_BitInt numbers in static assertion failure diagnostics #71675 (PR #145053)

2025-07-08 Thread Erich Keane via cfe-commits


@@ -2278,8 +2285,28 @@ void APInt::toString(SmallVectorImpl &Str, 
unsigned Radix, bool Signed,
 }
   } else {
 int Pos = 0;
+// The value of cutOffSize is not special, it is just a number of
+// characters that gives us enough info without losing readability.
+constexpr int cutOffSize = 20;
 while (Tmp.getBoolValue()) {
   uint64_t Digit;
+  if (truncate && Pos == cutOffSize) {
+unsigned numDigits = (int32_t)(Tmp.logBase2()/log2(Radix))+1;
+if(numDigits-cutOffSize > 0) {
+  // Calculating pow of exponents over 30 takes a long time.
+  // To keep note printing time short(under 3s), values with more 
digits
+  // will only return the last 20 digits.
+  if(numDigits < 30) {
+APInt divider = 
APIntOps::pow(APInt(Tmp.getBitWidth(),Radix),numDigits-cutOffSize);
+Tmp = Tmp.udiv(divider);
+Str.append(3,'.');
+  }
+  else {
+Str.append(3,'.');

erichkeane wrote:

I think that sounds like it could work?  I'm not sure of the size 
implications...

One thing to note, 'exactly 20' numbers in the 1st number isn't important.  
What IS important is 'enough of the first few that a couple of patterns are 
obvious', so the numbers have to be accurate, but the number OF them isn't 
important.  

I'm not sure I have a better idea, but I'm still thinking :)  Have an attempt 
at the above and see if it works out.


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


[clang-tools-extra] [clang-tidy] support ak_attr_info in diagnostic forwarding (PR #147503)

2025-07-08 Thread Mikael Holmén via cfe-commits

mikaelholmen wrote:

> Did any of the builders caught this, or it is some local configuration? 
> Asking just in case if we should create one for catching such CE's.

I saw it locally when compiling with -Wall -Werror. I don't know if any builder 
use -Werror? I don't see any sign of it in 
https://github.com/llvm/llvm-project/pull/144619 at least.

https://github.com/llvm/llvm-project/pull/147503
___
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-concise-preprocessor-directives` (PR #146830)

2025-07-08 Thread Victor Chernyakin via cfe-commits

localspook wrote:

When we're ready to merge, someone please do it for me, I don't have write 
permissions.

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


[clang] Propose new ClangIR Maintainer (PR #147365)

2025-07-08 Thread Aaron Ballman via cfe-commits

https://github.com/AaronBallman commented:

Awesome! We just need @xlauko to explicitly approve and then we're good to go!

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


[clang] Propose new ClangIR Maintainer (PR #147365)

2025-07-08 Thread Henrich Lauko via cfe-commits

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


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


[clang] [C23][Parser] Diagnostic for attribute declaration where statement is required (PR #146224)

2025-07-08 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/146224

>From 43e2dc670d7c9ed5e23b5d26dff1e273c84b5a53 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Thu, 3 Jul 2025 02:15:22 +0800
Subject: [PATCH 1/6] [C23][Parser] Diagnostic for attribute declaration where
 statement is required

Signed-off-by: yronglin 
---
 clang/docs/ReleaseNotes.rst   |  4 ++
 .../clang/Basic/DiagnosticParseKinds.td   |  4 ++
 clang/include/clang/Parse/Parser.h|  5 ++-
 clang/lib/Parse/ParseStmt.cpp | 40 ++-
 clang/test/Parser/statements.c| 30 ++
 clang/test/Sema/c2x-fallthrough.c | 15 ---
 6 files changed, 82 insertions(+), 16 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3d893e0aa8e2c..60e7390c31e9b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -747,6 +747,10 @@ Bug Fixes in This Version
 - Fixed an infinite recursion when checking constexpr destructors. (#GH141789)
 - Fixed a crash when a malformed using declaration appears in a ``constexpr`` 
function. (#GH144264)
 - Fixed a bug when use unicode character name in macro concatenation. 
(#GH145240)
+- In C23, something like [[/*possible attributes*/]]; is an attribute 
declaration, not a statement. So it is not
+  allowed by the syntax in places where a statement is required, specifically 
as the secondary block of a
+  selection or iteration statement. This differs from C++, since C++ allows 
declaration statements. 
+  Clang now warning this patterns. (#GH141659)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6c30da376dafb..9115b60cb0ed0 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -276,6 +276,10 @@ def err_expected_while : Error<"expected 'while' in 
do/while loop">;
 
 def err_expected_semi_after_stmt : Error<"expected ';' after %0 statement">;
 def err_expected_semi_after_expr : Error<"expected ';' after expression">;
+def warn_expected_stmt_before_semi_in_secondary_block : Warning<
+  "expected a statement before ';' but got an attribute declaration, "
+  "it is not allowed by the syntax in places where a statement is required">,
+  InGroup;
 def err_extraneous_token_before_semi : Error<"extraneous '%0' before ';'">;
 
 def err_expected_semi_after_method_proto : Error<
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index a47e23ffbd357..cca4f14a2942a 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -7168,13 +7168,16 @@ class Parser : public CodeCompletionHandler {
 AllowStandaloneOpenMPDirectives = 0x2,
 /// This context is at the top level of a GNU statement expression.
 InStmtExpr = 0x4,
+/// This context is the C99 secondary-block in selection or iteration
+/// statement.
+SecondaryBlockInC = 0x8,
 
 /// The context of a regular substatement.
 SubStmt = 0,
 /// The context of a compound-statement.
 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
 
-LLVM_MARK_AS_BITMASK_ENUM(InStmtExpr)
+LLVM_MARK_AS_BITMASK_ENUM(SecondaryBlockInC)
   };
 
   /// Act on an expression statement that might be the last statement in a
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 8217151a0259a..6080fb782dfbe 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -63,7 +63,8 @@ Parser::ParseStatementOrDeclaration(StmtVector &Stmts,
   // at the start of the statement. Thus, we're not using MaybeParseAttributes
   // here because we don't want to allow arbitrary orderings.
   ParsedAttributes CXX11Attrs(AttrFactory);
-  MaybeParseCXX11Attributes(CXX11Attrs, /*MightBeObjCMessageSend*/ true);
+  bool HasStdAttr =
+  MaybeParseCXX11Attributes(CXX11Attrs, /*MightBeObjCMessageSend*/ true);
   ParsedAttributes GNUOrMSAttrs(AttrFactory);
   if (getLangOpts().OpenCL)
 MaybeParseGNUAttributes(GNUOrMSAttrs);
@@ -80,6 +81,12 @@ Parser::ParseStatementOrDeclaration(StmtVector &Stmts,
   assert((CXX11Attrs.empty() || Res.isInvalid() || Res.isUsable()) &&
  "attributes on empty statement");
 
+  if (HasStdAttr && getLangOpts().C23 &&
+  (StmtCtx & ParsedStmtContext::SecondaryBlockInC) != ParsedStmtContext{} 
&&
+  isa_and_present(Res.get()))
+Diag(Res.get()->getBeginLoc(),
+ diag::warn_expected_stmt_before_semi_in_secondary_block);
+
   if (CXX11Attrs.empty() || Res.isInvalid())
 return Res;
 
@@ -1491,6 +1498,10 @@ StmtResult Parser::ParseIfStatement(SourceLocation 
*TrailingElseLoc) {
 
   SourceLocation InnerStatementTrailingElseLoc;
   StmtResult ThenStmt;
+  ParsedStmtContext StmtCtx = getLangOpts().C99
+  

[clang] [llvm] [AMDGPU] Add support for `v_cvt_f16_bf8` on gfx1250 (PR #146305)

2025-07-08 Thread Shilei Tian via cfe-commits


@@ -2,51 +2,41 @@
 # RUN: llvm-mc -triple=amdgcn -mcpu=gfx1250 -mattr=+real-true16 -disassemble 
-show-encoding < %s | FileCheck -check-prefixes=GFX1250,GFX1250-REAL16 %s
 # RUN: llvm-mc -triple=amdgcn -mcpu=gfx1250 -mattr=-real-true16 -disassemble 
-show-encoding < %s | FileCheck -check-prefixes=GFX1250,GFX1250-FAKE16 %s
 
-0x05,0x00,0xf2,0xd5,0xc1,0x00,0x00,0x00
-# GFX1250: v_cvt_f32_bf16_e64 v5, -1   ; encoding: 
[0x05,0x00,0xf2,0xd5,0xc1,0x00,0x00,0x00]

shiltian wrote:

That is a mistake…Thanks for catching it. I'll update it right away.

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


[clang] [C23][Parser] Diagnostic for attribute declaration where statement is required (PR #146224)

2025-07-08 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/146224

>From 43e2dc670d7c9ed5e23b5d26dff1e273c84b5a53 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Thu, 3 Jul 2025 02:15:22 +0800
Subject: [PATCH 1/6] [C23][Parser] Diagnostic for attribute declaration where
 statement is required

Signed-off-by: yronglin 
---
 clang/docs/ReleaseNotes.rst   |  4 ++
 .../clang/Basic/DiagnosticParseKinds.td   |  4 ++
 clang/include/clang/Parse/Parser.h|  5 ++-
 clang/lib/Parse/ParseStmt.cpp | 40 ++-
 clang/test/Parser/statements.c| 30 ++
 clang/test/Sema/c2x-fallthrough.c | 15 ---
 6 files changed, 82 insertions(+), 16 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3d893e0aa8e2c..60e7390c31e9b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -747,6 +747,10 @@ Bug Fixes in This Version
 - Fixed an infinite recursion when checking constexpr destructors. (#GH141789)
 - Fixed a crash when a malformed using declaration appears in a ``constexpr`` 
function. (#GH144264)
 - Fixed a bug when use unicode character name in macro concatenation. 
(#GH145240)
+- In C23, something like [[/*possible attributes*/]]; is an attribute 
declaration, not a statement. So it is not
+  allowed by the syntax in places where a statement is required, specifically 
as the secondary block of a
+  selection or iteration statement. This differs from C++, since C++ allows 
declaration statements. 
+  Clang now warning this patterns. (#GH141659)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6c30da376dafb..9115b60cb0ed0 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -276,6 +276,10 @@ def err_expected_while : Error<"expected 'while' in 
do/while loop">;
 
 def err_expected_semi_after_stmt : Error<"expected ';' after %0 statement">;
 def err_expected_semi_after_expr : Error<"expected ';' after expression">;
+def warn_expected_stmt_before_semi_in_secondary_block : Warning<
+  "expected a statement before ';' but got an attribute declaration, "
+  "it is not allowed by the syntax in places where a statement is required">,
+  InGroup;
 def err_extraneous_token_before_semi : Error<"extraneous '%0' before ';'">;
 
 def err_expected_semi_after_method_proto : Error<
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index a47e23ffbd357..cca4f14a2942a 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -7168,13 +7168,16 @@ class Parser : public CodeCompletionHandler {
 AllowStandaloneOpenMPDirectives = 0x2,
 /// This context is at the top level of a GNU statement expression.
 InStmtExpr = 0x4,
+/// This context is the C99 secondary-block in selection or iteration
+/// statement.
+SecondaryBlockInC = 0x8,
 
 /// The context of a regular substatement.
 SubStmt = 0,
 /// The context of a compound-statement.
 Compound = AllowDeclarationsInC | AllowStandaloneOpenMPDirectives,
 
-LLVM_MARK_AS_BITMASK_ENUM(InStmtExpr)
+LLVM_MARK_AS_BITMASK_ENUM(SecondaryBlockInC)
   };
 
   /// Act on an expression statement that might be the last statement in a
diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 8217151a0259a..6080fb782dfbe 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -63,7 +63,8 @@ Parser::ParseStatementOrDeclaration(StmtVector &Stmts,
   // at the start of the statement. Thus, we're not using MaybeParseAttributes
   // here because we don't want to allow arbitrary orderings.
   ParsedAttributes CXX11Attrs(AttrFactory);
-  MaybeParseCXX11Attributes(CXX11Attrs, /*MightBeObjCMessageSend*/ true);
+  bool HasStdAttr =
+  MaybeParseCXX11Attributes(CXX11Attrs, /*MightBeObjCMessageSend*/ true);
   ParsedAttributes GNUOrMSAttrs(AttrFactory);
   if (getLangOpts().OpenCL)
 MaybeParseGNUAttributes(GNUOrMSAttrs);
@@ -80,6 +81,12 @@ Parser::ParseStatementOrDeclaration(StmtVector &Stmts,
   assert((CXX11Attrs.empty() || Res.isInvalid() || Res.isUsable()) &&
  "attributes on empty statement");
 
+  if (HasStdAttr && getLangOpts().C23 &&
+  (StmtCtx & ParsedStmtContext::SecondaryBlockInC) != ParsedStmtContext{} 
&&
+  isa_and_present(Res.get()))
+Diag(Res.get()->getBeginLoc(),
+ diag::warn_expected_stmt_before_semi_in_secondary_block);
+
   if (CXX11Attrs.empty() || Res.isInvalid())
 return Res;
 
@@ -1491,6 +1498,10 @@ StmtResult Parser::ParseIfStatement(SourceLocation 
*TrailingElseLoc) {
 
   SourceLocation InnerStatementTrailingElseLoc;
   StmtResult ThenStmt;
+  ParsedStmtContext StmtCtx = getLangOpts().C99
+  

[clang] [C23][Parser] Diagnostic for attribute declaration where statement is required (PR #146224)

2025-07-08 Thread via cfe-commits


@@ -276,6 +276,9 @@ def err_expected_while : Error<"expected 'while' in 
do/while loop">;
 
 def err_expected_semi_after_stmt : Error<"expected ';' after %0 statement">;
 def err_expected_semi_after_expr : Error<"expected ';' after expression">;
+def warn_attr_in_secondary_block : ExtWarn<
+  "ISO C does not allow an attribute list to appear here">,
+  InGroup;

yronglin wrote:

Fixed.

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


[clang] [analyzer] Enforce not making overly complicated symbols (PR #144327)

2025-07-08 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

Thank you for the very through statistical analysis and visualization -- this 
paints a clear picture about the effects of the change.

> In conclusion, in contrast to the originally proposed variant of this patch 
> this evolved version is more controversial and the benefits are not clear 
> cut. I don't think it's simpler than the original variant, so I think we 
> reached a stale mate.
> 
> Unfortunately, I can't invest more time into this PR right now, so I'll close 
> this.

I'm sad that this "check complexity at the beginning of `evalBinOp`" idea 
didn't provide convincing results :slightly_frowning_face:

I don't see a theoretical reason why are these benefits less clear cut than 
your originally proposed change. (By the way, I'm not sure whether this variant 
causes more regressions than the originally proposed variant, because the 
statistics that you published originally don't provide information about entry 
points that became slower.)

> I had migrate the uses of the internal `evalBinOpXX` APIs to use the 
> top-level `evalBinOp` from checkers and other recursive places, to ensure 
> that the check withing `evalBinOp` is honored.

This is probably irrelevant now, but as far as I see it would've been enough to 
put the complexity checking to the beginning of `evalBinOpNN` (instead of 
`evalBinOp`) because it's the only "branch" of `evalBinOp` that can create 
complex symbols. (Pointer arithmetic is represented in a different way...)

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


[clang] [Clang] suppress deprecated field warnings in implicit special-member functions (PR #147400)

2025-07-08 Thread Corentin Jabot via cfe-commits


@@ -547,6 +547,15 @@ static void DoEmitAvailabilityWarning(Sema &S, 
AvailabilityResult K,
 return;
   }
   case AR_Deprecated:
+// Suppress -Wdeprecated-declarations in purely implicit special-member 
functions.
+if (auto *MD = dyn_cast_if_present(S.getCurFunctionDecl());
+MD && MD->isImplicit() && MD->isDefaulted() &&
+(isa(MD) ||
+MD->isCopyAssignmentOperator() ||
+MD->isMoveAssignmentOperator())) {
+return;
+}
+

cor3ntin wrote:

This can be simplified to


```suggestion
// Suppress -Wdeprecated-declarations in implicit functions.
if (auto *FD = dyn_cast_if_present(S.getCurFunctionDecl());
FD && FD->isImplicit())
  return; 

```

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


[clang] [Clang] suppress deprecated field warnings in implicit special-member functions (PR #147400)

2025-07-08 Thread Shashi Shankar via cfe-commits


@@ -547,6 +547,15 @@ static void DoEmitAvailabilityWarning(Sema &S, 
AvailabilityResult K,
 return;
   }
   case AR_Deprecated:
+// Suppress -Wdeprecated-declarations in purely implicit special-member 
functions.
+if (auto *MD = dyn_cast_if_present(S.getCurFunctionDecl());
+MD && MD->isImplicit() && MD->isDefaulted() &&
+(isa(MD) ||
+MD->isCopyAssignmentOperator() ||
+MD->isMoveAssignmentOperator())) {
+return;
+}
+

shashi1687 wrote:

 **“dyn_cast_if_present” causes compile errors**

There is no FunctionDeck class in Clang’s AST, so that cast will never compile. 
The correct cast here is to CXXMethodDecl (or at most to FunctionDecl). We’ve 
updated the code to use:

```
if (auto *MD = dyn_cast_if_present(…);
MD && MD->isImplicit() /*…etc…*/ )
  return;

```
This change compiles cleanly and continues to limit suppression to only the 
implicitly-generated special-member methods.

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


[clang] [Clang] Do not mark ambiguous specialization invalid. (PR #147275)

2025-07-08 Thread Corentin Jabot via cfe-commits

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

>From 346ac892d7575ac779295b9db11bc895f37f160e Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Mon, 7 Jul 2025 12:41:53 +0200
Subject: [PATCH 1/4] [Clang] Do not mark ambiguous specialization invalid.

When a specialization was ambiguous, we would mark it as invalid,
even if the specialization occured in an immediate context.

This would subsequently lead to scenarios where invalid
specialization produced no diagnostics, causing crashes
during codegen.

Fixes #51866
---
 clang/docs/ReleaseNotes.rst|  1 +
 clang/lib/Sema/SemaTemplateInstantiate.cpp |  1 -
 clang/test/SemaTemplate/partial-order.cpp  | 26 ++
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a6be59f1d6bd7..9dea124e47c31 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -903,6 +903,7 @@ Bug Fixes to C++ Support
 - Fix a bug where private access specifier of overloaded function not 
respected. (#GH107629)
 - Correctly handle allocations in the condition of a ``if 
constexpr``.(#GH120197) (#GH134820)
 - Fixed a crash when handling invalid member using-declaration in C++20+ mode. 
(#GH63254)
+- Fix a crash when trying to instantiate an ambiguous specialization. 
(#GH51866)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index a1c7143e3b874..9140f00fcd740 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -4111,7 +4111,6 @@ static ActionResult 
getPatternForClassTemplateSpecialization(
 if (Ambiguous) {
   // Partial ordering did not produce a clear winner. Complain.
   Inst.Clear();
-  ClassTemplateSpec->setInvalidDecl();
   S.Diag(PointOfInstantiation,
  diag::err_partial_spec_ordering_ambiguous)
   << ClassTemplateSpec;
diff --git a/clang/test/SemaTemplate/partial-order.cpp 
b/clang/test/SemaTemplate/partial-order.cpp
index db2624d1766bc..2619524b147ae 100644
--- a/clang/test/SemaTemplate/partial-order.cpp
+++ b/clang/test/SemaTemplate/partial-order.cpp
@@ -47,3 +47,29 @@ namespace GH132562 {
 // expected-note@-2 {{value of type 'const J' is not implicitly 
convertible to 'int'}}
   } // namespace t3
 } // namespace GH132562
+
+namespace GH51866 {
+
+template  struct Trait;
+template 
+requires T::one
+struct Trait {}; // #gh51866-one
+template 
+requires T::two
+struct Trait {}; // #gh51866-two
+
+struct Y {
+static constexpr bool one = true;
+static constexpr bool two = true;
+};
+
+template 
+concept C = sizeof(Trait) != 0;
+
+static_assert(!C);
+
+Trait t;
+// expected-error@-1{{ambiguous partial specializations of 
'Trait'}}
+// expected-note@#gh51866-one{{partial specialization matches}}
+// expected-note@#gh51866-two{{partial specialization matches}}
+}

>From e648ea731ab7fafde2d82ae8eef30739f522e0a8 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Mon, 7 Jul 2025 16:04:23 +0200
Subject: [PATCH 2/4] marck the class as invalid outside of immediate contexts

---
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 9140f00fcd740..cb1e417b82b31 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -4111,6 +4111,10 @@ static ActionResult 
getPatternForClassTemplateSpecialization(
 if (Ambiguous) {
   // Partial ordering did not produce a clear winner. Complain.
   Inst.Clear();
+
+  if (!S.isSFINAEContext())
+ClassTemplateSpec->setInvalidDecl();
+
   S.Diag(PointOfInstantiation,
  diag::err_partial_spec_ordering_ambiguous)
   << ClassTemplateSpec;

>From 678a275e5a0650f8635f1d0bee2514062bdc5226 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Tue, 8 Jul 2025 15:47:42 +0200
Subject: [PATCH 3/4] Update SemaTemplateInstantiate.cpp

---
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index cb1e417b82b31..0dbbfca5e4623 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -4112,8 +4112,7 @@ static ActionResult 
getPatternForClassTemplateSpecialization(
   // Partial ordering did not produce a clear winner. Complain.
   Inst.Clear();
 
-  if (!S.isSFINAEContext())
-ClassTemplateSpec->setInvalidDecl();
+  ClassTemplateSpec->setInvalidDecl();
 
   S.Diag(PointOfInstantiation,
  diag::err_partial_spec_ordering_ambiguous)

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Donát Nagy via cfe-commits

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


[clang] f72e53f - [clang][CompundLiteralExpr] Don't defer evaluation for CLEs (#137163)

2025-07-08 Thread via cfe-commits

Author: kadir çetinkaya
Date: 2025-07-08T16:00:40+02:00
New Revision: f72e53f35070140cbd6d4acdf7f8bc37f72d0445

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

LOG: [clang][CompundLiteralExpr] Don't defer evaluation for CLEs (#137163)

Previously we would defer evaluation of CLEs until LValue to RValue
conversions, which would result in creating values within wrong scope
and triggering use-after-frees.

This patch instead eagerly evaluates CLEs, within the scope requiring
them. This requires storing an extra pointer for CLE expressions with
static storage.

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

Added: 
clang/test/AST/static-compound-literals-crash.cpp
clang/test/AST/static-compound-literals-reeval.cpp
clang/test/AST/static-compound-literals.cpp

Modified: 
clang/include/clang/AST/Expr.h
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprConstant.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index d95396fd59b95..523c0326d47ef 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3534,6 +3534,10 @@ class CompoundLiteralExpr : public Expr {
   /// The int part of the pair stores whether this expr is file scope.
   llvm::PointerIntPair TInfoAndScope;
   Stmt *Init;
+
+  /// Value of constant literals with static storage duration.
+  mutable APValue *StaticValue = nullptr;
+
 public:
   CompoundLiteralExpr(SourceLocation lparenloc, TypeSourceInfo *tinfo,
   QualType T, ExprValueKind VK, Expr *init, bool fileScope)
@@ -3563,6 +3567,10 @@ class CompoundLiteralExpr : public Expr {
 TInfoAndScope.setPointer(tinfo);
   }
 
+  bool hasStaticStorage() const { return isFileScope() && isGLValue(); }
+  APValue &getOrCreateStaticValue(ASTContext &Ctx) const;
+  APValue &getStaticValue() const;
+
   SourceLocation getBeginLoc() const LLVM_READONLY {
 // FIXME: Init should never be null.
 if (!Init)

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 642867c0942b5..36fd5ee271e03 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -5446,3 +5446,17 @@ ConvertVectorExpr *ConvertVectorExpr::Create(
   return new (Mem) ConvertVectorExpr(SrcExpr, TI, DstType, VK, OK, BuiltinLoc,
  RParenLoc, FPFeatures);
 }
+
+APValue &CompoundLiteralExpr::getOrCreateStaticValue(ASTContext &Ctx) const {
+  assert(hasStaticStorage());
+  if (!StaticValue) {
+StaticValue = new (Ctx) APValue;
+Ctx.addDestruction(StaticValue);
+  }
+  return *StaticValue;
+}
+
+APValue &CompoundLiteralExpr::getStaticValue() const {
+  assert(StaticValue);
+  return *StaticValue;
+}

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 81c778e2cfca6..60c658a8d8f99 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -48,6 +48,7 @@
 #include "clang/AST/OptionalDiagnostic.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/DiagnosticSema.h"
@@ -4534,6 +4535,30 @@ static CompleteObject findCompleteObject(EvalInfo &Info, 
const Expr *E,
 
 BaseVal = MTE->getOrCreateValue(false);
 assert(BaseVal && "got reference to unevaluated temporary");
+  } else if (const CompoundLiteralExpr *CLE =
+ dyn_cast_or_null(Base)) {
+// According to GCC info page:
+//
+// 6.28 Compound Literals
+//
+// As an optimization, G++ sometimes gives array compound literals
+// longer lifetimes: when the array either appears outside a function 
or
+// has a const-qualified type. If foo and its initializer had elements
+// of type char *const rather than char *, or if foo were a global
+// variable, the array would have static storage duration. But it is
+// probably safest just to avoid the use of array compound literals in
+// C++ code.
+//
+// Obey that rule by checking constness for converted array types.
+if (QualType CLETy = CLE->getType(); CLETy->isArrayType() &&
+ !LValType->isArrayType() &&
+ !CLETy.isConstant(Info.Ctx)) {
+  Info.FFDiag(E);
+  Info.Note(CLE->getExprLoc(), diag::note_declared_at);
+  return CompleteObject();
+}
+
+BaseVal = &CLE->getStaticValue();
   } else {
 if (!IsAccess)
   return CompleteObject(LVal.getLValueBase(), nullptr, BaseType);
@@ -4599,44 +4624,7 @@ handleLValueToRValueConversion(EvalInfo &Info, const 
Expr *Conv, QualType 

[clang] [clang][CompundLiteralExpr] Don't defer evaluation for CLEs (PR #137163)

2025-07-08 Thread kadir çetinkaya via cfe-commits

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Henrich Lauko via cfe-commits


@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
   }];
 }
 
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 
64]>> {
+  let summary = "Reverse the bit pattern of the operand integer";
+  let description = [{
+The `cir.bit.reverse` operation reverses the bits of the operand integer.
+Its only argument must be of unsigned integer types of width 8, 16, 32, or
+64.
+
+This operation covers the C/C++ builtin function `__builtin_bitreverse`.
+
+Example:
+
+```mlir
+%1 = cir.bit.reverse %0 : !u32i

xlauko wrote:

```suggestion
%1 = cir.bit.reverse( %0 : !u32i) : !u32i
```

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Henrich Lauko via cfe-commits


@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
   }];
 }
 
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 
64]>> {

xlauko wrote:

```suggestion
def CIR_BitReverseOp : CIR_BitOpBase<"bit.reverse", 
  CIR_UIntOfWidths<[8, 16, 32, 64]>
> {
```

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Henrich Lauko via cfe-commits


@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
   }];
 }
 
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 
64]>> {

xlauko wrote:

I would also suggest to rename to `bitreverse` to mirror builtins name. Also 
dot slightly implies some "namespace".

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Henrich Lauko via cfe-commits


@@ -190,6 +190,26 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl 
&gd, unsigned builtinID,
 expectedValue, probAttr);
 return RValue::get(result);
   }
+
+  case Builtin::BI__builtin_bswap16:
+  case Builtin::BI__builtin_bswap32:
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI_byteswap_ushort:
+  case Builtin::BI_byteswap_ulong:
+  case Builtin::BI_byteswap_uint64: {
+mlir::Value arg = emitScalarExpr(e->getArg(0));
+return RValue::get(
+builder.create(getLoc(e->getSourceRange()), arg));

xlauko wrote:

Lets pull out `mlir::Location loc = getLoc(e->getSourceRange())` to the 
beginning of the function and use it throughout the function. This will reduce 
a lot of unnecessary indent.

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Henrich Lauko via cfe-commits


@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
   }];
 }
 
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 
64]>> {
+  let summary = "Reverse the bit pattern of the operand integer";
+  let description = [{
+The `cir.bit.reverse` operation reverses the bits of the operand integer.
+Its only argument must be of unsigned integer types of width 8, 16, 32, or
+64.
+
+This operation covers the C/C++ builtin function `__builtin_bitreverse`.
+
+Example:
+
+```mlir
+%1 = cir.bit.reverse %0 : !u32i
+```
+  }];
+}
+
+//===--===//
+// ByteswapOp
+//===--===//
+
+def ByteSwapOp : CIR_Op<"bswap", [Pure, SameOperandsAndResultType]> {

xlauko wrote:

This operation has same format results and arguments as `CIR_BitOpBase`. 
It can be used here too.

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Henrich Lauko via cfe-commits


@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
   }];
 }
 
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 
64]>> {
+  let summary = "Reverse the bit pattern of the operand integer";
+  let description = [{
+The `cir.bit.reverse` operation reverses the bits of the operand integer.
+Its only argument must be of unsigned integer types of width 8, 16, 32, or
+64.
+
+This operation covers the C/C++ builtin function `__builtin_bitreverse`.
+
+Example:
+
+```mlir
+%1 = cir.bit.reverse %0 : !u32i
+```
+  }];
+}
+
+//===--===//
+// ByteswapOp
+//===--===//
+
+def ByteSwapOp : CIR_Op<"bswap", [Pure, SameOperandsAndResultType]> {

xlauko wrote:

```suggestion
def CIR_ByteSwapOp : CIR_Op<"bswap", [Pure, SameOperandsAndResultType]> {
```

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Henrich Lauko via cfe-commits


@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
   }];
 }
 
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 
64]>> {

xlauko wrote:

These are inherited from `CIR_BitOpBase`.

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


[clang] [llvm] [SYCL] Add offload wrapping for SYCL kind. (PR #147508)

2025-07-08 Thread Maksim Sabianin via cfe-commits

https://github.com/maksimsab created 
https://github.com/llvm/llvm-project/pull/147508

None

>From 524da07f8449154a40796c5734d674df64e3f9af Mon Sep 17 00:00:00 2001
From: "Sabianin, Maksim" 
Date: Mon, 7 Jul 2025 08:30:12 -0700
Subject: [PATCH] [SYCL] Add offload wrapping for SYCL kind.

---
 clang/test/Driver/linker-wrapper-image.c  |  35 ++
 clang/test/Driver/linker-wrapper.c|   2 +-
 .../tools/clang-linker-wrapper/CMakeLists.txt |   1 +
 .../ClangLinkerWrapper.cpp|  41 +-
 .../llvm/Frontend/SYCL/OffloadWrapper.h   |  44 ++
 llvm/include/llvm/Object/OffloadBinary.h  |   9 +-
 llvm/lib/Frontend/CMakeLists.txt  |   1 +
 llvm/lib/Frontend/SYCL/CMakeLists.txt |  14 +
 llvm/lib/Frontend/SYCL/OffloadWrapper.cpp | 513 ++
 llvm/lib/Object/OffloadBinary.cpp |  11 +
 llvm/unittests/Object/OffloadingTest.cpp  |   9 +
 11 files changed, 675 insertions(+), 5 deletions(-)
 create mode 100644 llvm/include/llvm/Frontend/SYCL/OffloadWrapper.h
 create mode 100644 llvm/lib/Frontend/SYCL/CMakeLists.txt
 create mode 100644 llvm/lib/Frontend/SYCL/OffloadWrapper.cpp

diff --git a/clang/test/Driver/linker-wrapper-image.c 
b/clang/test/Driver/linker-wrapper-image.c
index c0de56d58196a..67bb21bfe49b4 100644
--- a/clang/test/Driver/linker-wrapper-image.c
+++ b/clang/test/Driver/linker-wrapper-image.c
@@ -1,6 +1,7 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
+// REQUIRES: spirv-registered-target
 
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
 
@@ -263,3 +264,37 @@
 //  HIP: while.end:
 // HIP-NEXT:   ret void
 // HIP-NEXT: }
+
+// RUN: clang-offload-packager -o %t.out 
--image=file=%t.elf.o,kind=sycl,triple=spirv64-unknown-unknown,arch=generic
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
+// RUN:   -fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --print-wrapped-module --dry-run 
--host-triple=x86_64-unknown-linux-gnu \
+// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefixes=SYCL
+// RUN: clang-linker-wrapper --print-wrapped-module --dry-run 
--host-triple=x86_64-unknown-linux-gnu -r \
+// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefixes=SYCL
+
+//  SYCL: %__sycl.tgt_device_image = type { i16, i8, i8, ptr, ptr, ptr, 
ptr, ptr, ptr, ptr, ptr, ptr }
+// SYCL-NEXT: %__sycl.tgt_bin_desc = type { i16, i16, ptr, ptr, ptr }
+
+//  SYCL: @.sycl_offloading.target.0 = internal unnamed_addr constant [1 x 
i8] zeroinitializer
+// SYCL-NEXT: @.sycl_offloading.opts.compile.0 = internal unnamed_addr 
constant [1 x i8] zeroinitializer
+// SYCL-NEXT: @.sycl_offloading.opts.link.0 = internal unnamed_addr constant 
[1 x i8] zeroinitializer
+// SYCL-NEXT: @.sycl_offloading.0.data = internal unnamed_addr constant [0 x 
i8] zeroinitializer
+// SYCL-NEXT: @.sycl_offloading.0.info = internal local_unnamed_addr constant 
[2 x i64] [i64 ptrtoint (ptr @.sycl_offloading.0.data to i64), i64 0], section 
".tgtimg", align 16
+// SYCL-NEXT: @llvm.used = appending global [1 x ptr] [ptr 
@.sycl_offloading.0.info], section "llvm.metadata"
+// SYCL-NEXT: @.sycl_offloading.device_images = internal unnamed_addr constant 
[1 x %__sycl.tgt_device_image] [%__sycl.tgt_device_image { i16 3, i8 8, i8 0, 
ptr @.sycl_offloading.target.0, ptr @.sycl_offloading.opts.compile.0, ptr 
@.sycl_offloading.opts.link.0, ptr @.sycl_offloading.0.data, ptr 
@.sycl_offloading.0.data, ptr null, ptr null, ptr null, ptr null }]
+// SYCL-NEXT: @.sycl_offloading.descriptor = internal constant 
%__sycl.tgt_bin_desc { i16 1, i16 1, ptr @.sycl_offloading.device_images, ptr 
null, ptr null }
+// SYCL-NEXT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 1, ptr @sycl.descriptor_reg, ptr null }]
+// SYCL-NEXT: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 1, ptr @sycl.descriptor_unreg, ptr null }]
+
+//  SYCL: define internal void @sycl.descriptor_reg() section 
".text.startup" {
+// SYCL-NEXT: entry:
+// SYCL-NEXT:   call void @__sycl_register_lib(ptr 
@.sycl_offloading.descriptor)
+// SYCL-NEXT:   ret void
+// SYCL-NEXT: }
+
+//  SYCL: define internal void @sycl.descriptor_unreg() section 
".text.startup" {
+// SYCL-NEXT: entry:
+// SYCL-NEXT:   call void @__sycl_unregister_lib(ptr 
@.sycl_offloading.descriptor)
+// SYCL-NEXT:   ret void
+// SYCL-NEXT: }
diff --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index 80b1a5745a123..5ab8a09660e57 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -54,7 +54,7 @@ __attribute__((visibility("protected"), used)) int x;
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%t.spirv.bc,kind=sycl,triple=spirv64-unknown-unknown,arch=generic
 // RUN: %clang -cc1 %s

[clang] [llvm] [SYCL] Add offload wrapping for SYCL kind. (PR #147508)

2025-07-08 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Maksim Sabianin (maksimsab)


Changes



---

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


11 Files Affected:

- (modified) clang/test/Driver/linker-wrapper-image.c (+35) 
- (modified) clang/test/Driver/linker-wrapper.c (+1-1) 
- (modified) clang/tools/clang-linker-wrapper/CMakeLists.txt (+1) 
- (modified) clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp (+40-1) 
- (added) llvm/include/llvm/Frontend/SYCL/OffloadWrapper.h (+44) 
- (modified) llvm/include/llvm/Object/OffloadBinary.h (+6-3) 
- (modified) llvm/lib/Frontend/CMakeLists.txt (+1) 
- (added) llvm/lib/Frontend/SYCL/CMakeLists.txt (+14) 
- (added) llvm/lib/Frontend/SYCL/OffloadWrapper.cpp (+513) 
- (modified) llvm/lib/Object/OffloadBinary.cpp (+11) 
- (modified) llvm/unittests/Object/OffloadingTest.cpp (+9) 


``diff
diff --git a/clang/test/Driver/linker-wrapper-image.c 
b/clang/test/Driver/linker-wrapper-image.c
index c0de56d58196a..67bb21bfe49b4 100644
--- a/clang/test/Driver/linker-wrapper-image.c
+++ b/clang/test/Driver/linker-wrapper-image.c
@@ -1,6 +1,7 @@
 // REQUIRES: x86-registered-target
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
+// REQUIRES: spirv-registered-target
 
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.elf.o
 
@@ -263,3 +264,37 @@
 //  HIP: while.end:
 // HIP-NEXT:   ret void
 // HIP-NEXT: }
+
+// RUN: clang-offload-packager -o %t.out 
--image=file=%t.elf.o,kind=sycl,triple=spirv64-unknown-unknown,arch=generic
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o \
+// RUN:   -fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --print-wrapped-module --dry-run 
--host-triple=x86_64-unknown-linux-gnu \
+// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefixes=SYCL
+// RUN: clang-linker-wrapper --print-wrapped-module --dry-run 
--host-triple=x86_64-unknown-linux-gnu -r \
+// RUN:   --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefixes=SYCL
+
+//  SYCL: %__sycl.tgt_device_image = type { i16, i8, i8, ptr, ptr, ptr, 
ptr, ptr, ptr, ptr, ptr, ptr }
+// SYCL-NEXT: %__sycl.tgt_bin_desc = type { i16, i16, ptr, ptr, ptr }
+
+//  SYCL: @.sycl_offloading.target.0 = internal unnamed_addr constant [1 x 
i8] zeroinitializer
+// SYCL-NEXT: @.sycl_offloading.opts.compile.0 = internal unnamed_addr 
constant [1 x i8] zeroinitializer
+// SYCL-NEXT: @.sycl_offloading.opts.link.0 = internal unnamed_addr constant 
[1 x i8] zeroinitializer
+// SYCL-NEXT: @.sycl_offloading.0.data = internal unnamed_addr constant [0 x 
i8] zeroinitializer
+// SYCL-NEXT: @.sycl_offloading.0.info = internal local_unnamed_addr constant 
[2 x i64] [i64 ptrtoint (ptr @.sycl_offloading.0.data to i64), i64 0], section 
".tgtimg", align 16
+// SYCL-NEXT: @llvm.used = appending global [1 x ptr] [ptr 
@.sycl_offloading.0.info], section "llvm.metadata"
+// SYCL-NEXT: @.sycl_offloading.device_images = internal unnamed_addr constant 
[1 x %__sycl.tgt_device_image] [%__sycl.tgt_device_image { i16 3, i8 8, i8 0, 
ptr @.sycl_offloading.target.0, ptr @.sycl_offloading.opts.compile.0, ptr 
@.sycl_offloading.opts.link.0, ptr @.sycl_offloading.0.data, ptr 
@.sycl_offloading.0.data, ptr null, ptr null, ptr null, ptr null }]
+// SYCL-NEXT: @.sycl_offloading.descriptor = internal constant 
%__sycl.tgt_bin_desc { i16 1, i16 1, ptr @.sycl_offloading.device_images, ptr 
null, ptr null }
+// SYCL-NEXT: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 1, ptr @sycl.descriptor_reg, ptr null }]
+// SYCL-NEXT: @llvm.global_dtors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 1, ptr @sycl.descriptor_unreg, ptr null }]
+
+//  SYCL: define internal void @sycl.descriptor_reg() section 
".text.startup" {
+// SYCL-NEXT: entry:
+// SYCL-NEXT:   call void @__sycl_register_lib(ptr 
@.sycl_offloading.descriptor)
+// SYCL-NEXT:   ret void
+// SYCL-NEXT: }
+
+//  SYCL: define internal void @sycl.descriptor_unreg() section 
".text.startup" {
+// SYCL-NEXT: entry:
+// SYCL-NEXT:   call void @__sycl_unregister_lib(ptr 
@.sycl_offloading.descriptor)
+// SYCL-NEXT:   ret void
+// SYCL-NEXT: }
diff --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index 80b1a5745a123..5ab8a09660e57 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -54,7 +54,7 @@ __attribute__((visibility("protected"), used)) int x;
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%t.spirv.bc,kind=sycl,triple=spirv64-unknown-unknown,arch=generic
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
-// RUN: not clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu 
--dry-run \
+// RUN: clang-linker-wrapper -

[clang-tools-extra] [clang-tidy] support ak_attr_info in diagnostic forwarding (PR #147503)

2025-07-08 Thread Aaron Ballman via cfe-commits

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

LGTM!

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Sirui Mu via cfe-commits


@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
   }];
 }
 
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 
64]>> {
+  let summary = "Reverse the bit pattern of the operand integer";
+  let description = [{
+The `cir.bit.reverse` operation reverses the bits of the operand integer.
+Its only argument must be of unsigned integer types of width 8, 16, 32, or
+64.
+
+This operation covers the C/C++ builtin function `__builtin_bitreverse`.
+
+Example:
+
+```mlir
+%1 = cir.bit.reverse %0 : !u32i

Lancern wrote:

It looks like we don't have to spell `!u32i` twice since all bit operations are 
`SameOperandsAndResultType`. I'll make a patch to simplify this later.

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


[clang] [CIR] Add bit reverse and byte reverse operations (PR #147200)

2025-07-08 Thread Sirui Mu via cfe-commits


@@ -2661,6 +2661,55 @@ def BitPopcountOp : CIR_BitOpBase<"bit.popcnt",
   }];
 }
 
+def BitReverseOp : CIR_BitOpBase<"bit.reverse", CIR_UIntOfWidths<[8, 16, 32, 
64]>> {

Lancern wrote:

Well I think we need to think about what the exact scope of `CIR_BitOpBase` is 
and whether the bit reverse operation should be one of it. I'm naming it 
`bit.reverse` because I think it should follow the `CIR_BitOpBase` convention.

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


[clang] [PowerPC][NFC] Define new alias for mma accumulate builtins (PR #147382)

2025-07-08 Thread Amy Kwan via cfe-commits


@@ -35,6 +35,13 @@
 #define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE)   
\
   CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
 
+#define UNALIASED_CUSTOM_MMA_BUILTIN(ID, TYPES, FEATURE)   
\

amy-kwan wrote:

Can we document this new `define` to explain it for someone who is not familiar 
with the code?

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


[clang] [llvm] [openmp] [clang][OpenMP] New OpenMP 6.0 threadset clause (PR #135807)

2025-07-08 Thread via cfe-commits

https://github.com/Ritanya-B-Bharadwaj updated 
https://github.com/llvm/llvm-project/pull/135807

>From 9c56e59ba9984c14c15a8d5a95a02e7192a64e8f Mon Sep 17 00:00:00 2001
From: Ritanya B Bharadwaj 
Date: Sun, 6 Apr 2025 09:33:06 -0500
Subject: [PATCH 1/7] [OpenMP] Parsing Support of ThreadSets in Task

---
 clang/include/clang/AST/OpenMPClause.h| 80 +++
 clang/include/clang/AST/RecursiveASTVisitor.h |  6 ++
 clang/include/clang/Basic/OpenMPKinds.def |  8 +-
 clang/include/clang/Basic/OpenMPKinds.h   |  7 ++
 clang/include/clang/Sema/SemaOpenMP.h |  6 ++
 clang/lib/AST/OpenMPClause.cpp|  7 ++
 clang/lib/AST/StmtProfile.cpp |  2 +
 clang/lib/Basic/OpenMPKinds.cpp   |  9 +++
 clang/lib/Parse/ParseOpenMP.cpp   |  1 +
 clang/lib/Sema/SemaOpenMP.cpp | 21 +
 clang/lib/Sema/TreeTransform.h|  7 ++
 clang/lib/Serialization/ASTReader.cpp | 11 +++
 clang/lib/Serialization/ASTWriter.cpp |  6 ++
 clang/tools/libclang/CIndex.cpp   |  2 +
 llvm/include/llvm/Frontend/OpenMP/OMP.td  |  4 +
 15 files changed, 176 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 572e62249b46f..81420384f885c 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1332,6 +1332,86 @@ class OMPDefaultClause : public OMPClause {
   }
 };
 
+/// This represents 'threadset' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp parallel threadset(shared)
+/// \endcode
+/// In this example directive '#pragma omp parallel' has simple 'threadset'
+/// clause with kind 'shared'.
+class OMPThreadsetClause : public OMPClause {
+  friend class OMPClauseReader;
+
+  /// Location of '('.
+  SourceLocation LParenLoc;
+
+  /// A kind of the 'threadset' clause.
+  OpenMPThreadsetKind Kind = OMPC_THREADSET_unknown;
+
+  /// Start location of the kind in source code.
+  SourceLocation KindLoc;
+
+  /// Set kind of the clauses.
+  ///
+  /// \param K Argument of clause.
+  void setThreadsetKind(OpenMPThreadsetKind K) { Kind = K; }
+
+  /// Set argument location.
+  ///
+  /// \param KLoc Argument location.
+  void setThreadsetKindLoc(SourceLocation KLoc) { KindLoc = KLoc; }
+
+public:
+  /// Build 'threadset' clause with argument \a A ('none' or 'shared').
+  ///
+  /// \param A Argument of the clause ('none' or 'shared').
+  /// \param ALoc Starting location of the argument.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  OMPThreadsetClause(OpenMPThreadsetKind A, SourceLocation ALoc,
+ SourceLocation StartLoc, SourceLocation LParenLoc,
+ SourceLocation EndLoc)
+  : OMPClause(llvm::omp::OMPC_threadset, StartLoc, EndLoc),
+LParenLoc(LParenLoc), Kind(A), KindLoc(ALoc) {}
+
+  /// Build an empty clause.
+  OMPThreadsetClause()
+  : OMPClause(llvm::omp::OMPC_threadset, SourceLocation(),
+  SourceLocation()) {}
+
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+
+  /// Returns the location of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// Returns kind of the clause.
+  OpenMPThreadsetKind getThreadsetKind() const { return Kind; }
+
+  /// Returns location of clause kind.
+  SourceLocation getThreadsetKindLoc() const { return KindLoc; }
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == llvm::omp::OMPC_threadset;
+  }
+};
+
 /// This represents 'proc_bind' clause in the '#pragma omp ...'
 /// directive.
 ///
diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 0530996ed20d3..d86c7d4577ac6 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3410,6 +3410,12 @@ bool 
RecursiveASTVisitor::VisitOMPDefaultClause(OMPDefaultClause *) {
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPThreadsetClause(
+OMPThreadsetClause *) {
+  return true;
+}
+
 template 
 bool RecursiveASTVisitor::VisitOMPProcBindClause(OMPProcBindClause *) 
{
   return true;
diff --git a/clang/include/clang/Basic/OpenMPKinds.def 
b/clang/include/clang/Basic/OpenMPKinds.def
index b0de65df7e397..5b8889b8f7a34 100644
--- a/clang/include/clang/B

[clang] [Sema] Remove an unnecessary cast (NFC) (PR #147546)

2025-07-08 Thread Kazu Hirata via cfe-commits

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


[clang] d0c1f14 - [Sema] Remove an unnecessary cast (NFC) (#147546)

2025-07-08 Thread via cfe-commits

Author: Kazu Hirata
Date: 2025-07-08T12:47:03-07:00
New Revision: d0c1f148ced2a599dc36046f3bd46af64e3f5ed0

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

LOG: [Sema] Remove an unnecessary cast (NFC) (#147546)

D is already of CXXMethodDecl *.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index a25bfd1c48dee..c6633cbe51cef 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3029,7 +3029,7 @@ Decl *TemplateDeclInstantiator::VisitCXXMethodDecl(
   LocalInstantiationScope Scope(SemaRef, MergeWithParentScope);
 
   Sema::LambdaScopeForCallOperatorInstantiationRAII LambdaScope(
-  SemaRef, const_cast(D), TemplateArgs, Scope);
+  SemaRef, D, TemplateArgs, Scope);
 
   // Instantiate enclosing template arguments for friends.
   SmallVector TempParamLists;



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


[clang] Propogate linker flags when -static-pie is enabled in BareMetal Toolchain (PR #147589)

2025-07-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Garvit Gupta (quic-garvgupt)


Changes



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


9 Files Affected:

- (modified) clang/include/clang/Driver/CommonArgs.h (+2) 
- (modified) clang/lib/Driver/ToolChains/BareMetal.cpp (+15-4) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+12) 
- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (-12) 
- (modified) clang/test/Driver/aarch64-toolchain.c (+12) 
- (modified) clang/test/Driver/arm-toolchain.c (+12) 
- (modified) clang/test/Driver/baremetal.cpp (+26) 
- (modified) clang/test/Driver/riscv32-toolchain.c (+13) 
- (modified) clang/test/Driver/riscv64-toolchain.c (+13) 


``diff
diff --git a/clang/include/clang/Driver/CommonArgs.h 
b/clang/include/clang/Driver/CommonArgs.h
index 26aa3ccf84786..d8877903c892f 100644
--- a/clang/include/clang/Driver/CommonArgs.h
+++ b/clang/include/clang/Driver/CommonArgs.h
@@ -85,6 +85,8 @@ const char *RelocationModelName(llvm::Reloc::Model Model);
 std::tuple
 ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args);
 
+bool getStaticPIE(const llvm::opt::ArgList &Args, const ToolChain &TC);
+
 unsigned ParseFunctionAlignment(const ToolChain &TC,
 const llvm::opt::ArgList &Args);
 
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index e670696cd59ae..6ee3fbe400566 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -599,11 +599,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   const Driver &D = getToolChain().getDriver();
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  const bool IsStaticPIE = getStaticPIE(Args, TC);
 
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
   CmdArgs.push_back("-Bstatic");
+  if(IsStaticPIE) {
+CmdArgs.push_back("-pie");
+CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
+  }
 
   if (const char *LDMOption = getLDMOption(TC.getTriple(), Args)) {
 CmdArgs.push_back("-m");
@@ -633,14 +640,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 
   const char *CRTBegin, *CRTEnd;
   if (NeedCRTs) {
-if (!Args.hasArg(options::OPT_r))
-  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (!Args.hasArg(options::OPT_r)) {
+  const char *crt = "crt0.o";
+  if (IsStaticPIE)
+crt = "rcrt1.o";
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crt)));
+}
 if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) {
   auto RuntimeLib = TC.GetRuntimeLibType(Args);
   switch (RuntimeLib) {
   case (ToolChain::RLT_Libgcc): {
-CRTBegin = "crtbegin.o";
-CRTEnd = "crtend.o";
+CRTBegin = IsStaticPIE ? "crtbeginS.o" : "crtbegin.o";
+CRTEnd = IsStaticPIE ? "crtendS.o" : "crtend.o";
 break;
   }
   case (ToolChain::RLT_CompilerRT): {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index bdd77ac84913c..f8f97b02a5f95 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2089,6 +2089,18 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const 
ArgList &Args) {
   return std::make_tuple(RelocM, 0U, false);
 }
 
+bool tools::getStaticPIE(const ArgList &Args, const ToolChain &TC) {
+  bool HasStaticPIE = Args.hasArg(options::OPT_static_pie);
+  if (HasStaticPIE && Args.hasArg(options::OPT_no_pie)) {
+const Driver &D = TC.getDriver();
+const llvm::opt::OptTable &Opts = D.getOpts();
+StringRef StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
+StringRef NoPIEName = Opts.getOptionName(options::OPT_nopie);
+D.Diag(diag::err_drv_cannot_mix_options) << StaticPIEName << NoPIEName;
+  }
+  return HasStaticPIE;
+}
+
 // `-falign-functions` indicates that the functions should be aligned to the
 // backend's preferred alignment.
 //
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index f5e2655857432..01b146db24f3e 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -219,18 +219,6 @@ void tools::gcc::Linker::RenderExtraToolArgs(const 
JobAction &JA,
   // The types are (hopefully) good enough.
 }
 
-static bool getStaticPIE(const ArgList &Args, const ToolChain &TC) {
-  bool HasStaticPIE = Args.hasArg(options::OPT_static_pie);
-  if (HasStaticPIE && Args.hasArg(options::OPT_no_pie)) {
-const Driver &D = TC.getDriver();
-const llvm::opt::OptTable &Opts = D.getOpts();
-StringRef StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
-StringRef NoPIEName = Opts.getOptionName(options::OP

[clang] [clang][test] Fix RUN lines in cxx2a-constexpr-dynalloc.cpp (PR #147590)

2025-07-08 Thread Timm Baeder via cfe-commits

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

These were added in https://github.com/llvm/llvm-project/pull/147303, but the 
-fexperimental-new-constant-interpreter was missing.

>From d37db46dd55d3948cd6c7d002c9e9dd5edc2568c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Tue, 8 Jul 2025 21:46:51 +0200
Subject: [PATCH] [clang][test] Fix RUN lines in cxx2a-constexpr-dynalloc.cpp

These were added in https://github.com/llvm/llvm-project/pull/147303,
but the -fexperimental-new-constant-interpreter was missing.
---
 clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp 
b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
index 86bed5f14441e..25cd2c9538a90 100644
--- a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
+++ b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
@@ -3,10 +3,10 @@
 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
 // RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
 
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s 
-DNEW=__builtin_operator_new -DDELETE=__builtin_operator_delete
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=operator new" 
"-DDELETE=operator delete"
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
-// RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s 
-DNEW=__builtin_operator_new -DDELETE=__builtin_operator_delete 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=operator new" 
"-DDELETE=operator delete" -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete" -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete" -fexperimental-new-constant-interpreter
 
 constexpr bool alloc_from_user_code() {
   void *p = NEW(sizeof(int)); // expected-note {{cannot allocate untyped 
memory in a constant expression; use 'std::allocator::allocate'}}

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


[clang] [clang][test] Fix RUN lines in cxx2a-constexpr-dynalloc.cpp (PR #147590)

2025-07-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

These were added in https://github.com/llvm/llvm-project/pull/147303, but the 
-fexperimental-new-constant-interpreter was missing.

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


1 Files Affected:

- (modified) clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp (+4-4) 


``diff
diff --git a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp 
b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
index 86bed5f14441e..25cd2c9538a90 100644
--- a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
+++ b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
@@ -3,10 +3,10 @@
 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
 // RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
 
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s 
-DNEW=__builtin_operator_new -DDELETE=__builtin_operator_delete
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=operator new" 
"-DDELETE=operator delete"
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
-// RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s 
-DNEW=__builtin_operator_new -DDELETE=__builtin_operator_delete 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=operator new" 
"-DDELETE=operator delete" -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete" -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete" -fexperimental-new-constant-interpreter
 
 constexpr bool alloc_from_user_code() {
   void *p = NEW(sizeof(int)); // expected-note {{cannot allocate untyped 
memory in a constant expression; use 'std::allocator::allocate'}}

``




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


[clang] Propogate linker flags when -static-pie is enabled in BareMetal Toolchain (PR #147589)

2025-07-08 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,c,h -- 
clang/include/clang/Driver/CommonArgs.h 
clang/lib/Driver/ToolChains/BareMetal.cpp 
clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Gnu.cpp 
clang/test/Driver/aarch64-toolchain.c clang/test/Driver/arm-toolchain.c 
clang/test/Driver/baremetal.cpp clang/test/Driver/riscv32-toolchain.c 
clang/test/Driver/riscv64-toolchain.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 6ee3fbe40..73adeaa3d 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -605,7 +605,7 @@ void baremetal::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
   CmdArgs.push_back("-Bstatic");
-  if(IsStaticPIE) {
+  if (IsStaticPIE) {
 CmdArgs.push_back("-pie");
 CmdArgs.push_back("--no-dynamic-linker");
 CmdArgs.push_back("-z");

``




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


[clang] [clang-tools-extra] [ASTMatchers][NFC] Replace `makeMatcher` function with CTAD (PR #147197)

2025-07-08 Thread Baranov Victor via cfe-commits

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


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


[clang] Propogate linker flags when -static-pie is enabled in BareMetal Toolchain (PR #147589)

2025-07-08 Thread Garvit Gupta via cfe-commits

https://github.com/quic-garvgupt updated 
https://github.com/llvm/llvm-project/pull/147589

>From 6f96fc844751a95ee18b69ddb850ddd2fe76a89c Mon Sep 17 00:00:00 2001
From: Garvit Gupta 
Date: Tue, 8 Jul 2025 07:21:37 -0700
Subject: [PATCH 1/2] Propogate appropriate linker flags for `-static-pie` in
 BareMetal toolchain

Change-Id: I2ad7cd9d2677334de21ae8abade874ca7b7106b5
---
 clang/include/clang/Driver/CommonArgs.h|  2 ++
 clang/lib/Driver/ToolChains/BareMetal.cpp  | 19 
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 12 ++
 clang/lib/Driver/ToolChains/Gnu.cpp| 12 --
 clang/test/Driver/baremetal.cpp| 26 ++
 5 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/clang/include/clang/Driver/CommonArgs.h 
b/clang/include/clang/Driver/CommonArgs.h
index 26aa3ccf84786..d8877903c892f 100644
--- a/clang/include/clang/Driver/CommonArgs.h
+++ b/clang/include/clang/Driver/CommonArgs.h
@@ -85,6 +85,8 @@ const char *RelocationModelName(llvm::Reloc::Model Model);
 std::tuple
 ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args);
 
+bool getStaticPIE(const llvm::opt::ArgList &Args, const ToolChain &TC);
+
 unsigned ParseFunctionAlignment(const ToolChain &TC,
 const llvm::opt::ArgList &Args);
 
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index e670696cd59ae..6ee3fbe400566 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -599,11 +599,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
   const Driver &D = getToolChain().getDriver();
   const llvm::Triple::ArchType Arch = TC.getArch();
   const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
+  const bool IsStaticPIE = getStaticPIE(Args, TC);
 
   if (!D.SysRoot.empty())
 CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
 
   CmdArgs.push_back("-Bstatic");
+  if(IsStaticPIE) {
+CmdArgs.push_back("-pie");
+CmdArgs.push_back("--no-dynamic-linker");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
+  }
 
   if (const char *LDMOption = getLDMOption(TC.getTriple(), Args)) {
 CmdArgs.push_back("-m");
@@ -633,14 +640,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 
   const char *CRTBegin, *CRTEnd;
   if (NeedCRTs) {
-if (!Args.hasArg(options::OPT_r))
-  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
+if (!Args.hasArg(options::OPT_r)) {
+  const char *crt = "crt0.o";
+  if (IsStaticPIE)
+crt = "rcrt1.o";
+  CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crt)));
+}
 if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) {
   auto RuntimeLib = TC.GetRuntimeLibType(Args);
   switch (RuntimeLib) {
   case (ToolChain::RLT_Libgcc): {
-CRTBegin = "crtbegin.o";
-CRTEnd = "crtend.o";
+CRTBegin = IsStaticPIE ? "crtbeginS.o" : "crtbegin.o";
+CRTEnd = IsStaticPIE ? "crtendS.o" : "crtend.o";
 break;
   }
   case (ToolChain::RLT_CompilerRT): {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index bdd77ac84913c..9e16cba0c7e25 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -2089,6 +2089,18 @@ tools::ParsePICArgs(const ToolChain &ToolChain, const 
ArgList &Args) {
   return std::make_tuple(RelocM, 0U, false);
 }
 
+bool getStaticPIE(const ArgList &Args, const ToolChain &TC) {
+  bool HasStaticPIE = Args.hasArg(options::OPT_static_pie);
+  if (HasStaticPIE && Args.hasArg(options::OPT_no_pie)) {
+const Driver &D = TC.getDriver();
+const llvm::opt::OptTable &Opts = D.getOpts();
+StringRef StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
+StringRef NoPIEName = Opts.getOptionName(options::OPT_nopie);
+D.Diag(diag::err_drv_cannot_mix_options) << StaticPIEName << NoPIEName;
+  }
+  return HasStaticPIE;
+}
+
 // `-falign-functions` indicates that the functions should be aligned to the
 // backend's preferred alignment.
 //
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index f5e2655857432..01b146db24f3e 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -219,18 +219,6 @@ void tools::gcc::Linker::RenderExtraToolArgs(const 
JobAction &JA,
   // The types are (hopefully) good enough.
 }
 
-static bool getStaticPIE(const ArgList &Args, const ToolChain &TC) {
-  bool HasStaticPIE = Args.hasArg(options::OPT_static_pie);
-  if (HasStaticPIE && Args.hasArg(options::OPT_no_pie)) {
-const Driver &D = TC.getDriver();
-const llvm::opt::OptTable &Opts = D.getOpts();
-StringRef StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
-StringRef NoPIEName = Opts.getOptionName(opti

[clang] f7a0922 - [clang][test] Fix RUN lines in cxx2a-constexpr-dynalloc.cpp (#147590)

2025-07-08 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-07-09T07:59:45+02:00
New Revision: f7a09222f42a3fbb44ecbf8b1dd52583fb60efa8

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

LOG: [clang][test] Fix RUN lines in cxx2a-constexpr-dynalloc.cpp (#147590)

These were added in https://github.com/llvm/llvm-project/pull/147303,
but the -fexperimental-new-constant-interpreter was missing.

Added: 


Modified: 
clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp

Removed: 




diff  --git a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp 
b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
index 86bed5f14441e..25cd2c9538a90 100644
--- a/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
+++ b/clang/test/SemaCXX/cxx2a-constexpr-dynalloc.cpp
@@ -3,10 +3,10 @@
 // RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
 // RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
 
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s 
-DNEW=__builtin_operator_new -DDELETE=__builtin_operator_delete
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=operator new" 
"-DDELETE=operator delete"
-// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
-// RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete"
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s 
-DNEW=__builtin_operator_new -DDELETE=__builtin_operator_delete 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=operator new" 
"-DDELETE=operator delete" -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2a -verify=expected,cxx20 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete" -fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -std=c++2c -verify=expected,cxx26 %s "-DNEW=::operator new" 
"-DDELETE=::operator delete" -fexperimental-new-constant-interpreter
 
 constexpr bool alloc_from_user_code() {
   void *p = NEW(sizeof(int)); // expected-note {{cannot allocate untyped 
memory in a constant expression; use 'std::allocator::allocate'}}



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


[clang] [clang][test] Fix RUN lines in cxx2a-constexpr-dynalloc.cpp (PR #147590)

2025-07-08 Thread Timm Baeder via cfe-commits

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


[clang] [REAPPLY][Clang-Repl] Add support for out-of-process execution. #110418 (PR #144064)

2025-07-08 Thread Anutosh Bhat via cfe-commits

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


[clang] [RISCV] Split out the intrinsic tests for bfloat16 into a separate directory named zvfbfmin. NFC. (PR #147644)

2025-07-08 Thread Jim Lin via cfe-commits

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


[clang] [Clang] disallow # operators in attribute argument lists (PR #147308)

2025-07-08 Thread Oleksandr T. via cfe-commits

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

>From 8f1c383f8f84fb636af4a78e0ff504830f9272f5 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Mon, 7 Jul 2025 17:20:48 +0300
Subject: [PATCH 1/3] [Clang] disallow  operator in attribute argument lists

---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 ++
 clang/lib/Parse/ParseDecl.cpp | 7 +++
 clang/test/Parser/cxx0x-attributes.cpp| 5 +
 4 files changed, 15 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a6be59f1d6bd7..b8032ee9c03da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -673,6 +673,7 @@ Improvements to Clang's diagnostics
   false positives in exception-heavy code, though only simple patterns
   are currently recognized.
 
+- Clang now rejects ``#`` operators in attribute argument lists. (#GH147217)
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 6c30da376dafb..b39e2a7359c22 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -830,6 +830,8 @@ def err_ms_property_expected_comma_or_rparen : Error<
   "expected ',' or ')' at end of property accessor list">;
 def err_ms_property_initializer : Error<
   "property declaration cannot have a default member initializer">;
+def err_invalid_attribute_argument
+: Error<"'%0' is not allowed in attribute argument lists">;
 
 def err_assume_attr_expects_cond_expr : Error<
   "use of this expression in an %0 attribute requires parentheses">;
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 7e739e09b15e8..059636653723c 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -488,6 +488,13 @@ unsigned Parser::ParseAttributeArgsCommon(
   bool AttributeHasVariadicIdentifierArg =
   attributeHasVariadicIdentifierArg(*AttrName, Form.getSyntax(), 
ScopeName);
 
+  if (Tok.is(tok::hash) || Tok.is(tok::hashhash)) {
+Diag(Tok.getLocation(), diag::err_invalid_attribute_argument)
+<< PP.getSpelling(Tok);
+SkipUntil(tok::r_paren, StopAtSemi);
+return 0;
+  }
+
   // Interpret "kw_this" as an identifier if the attributed requests it.
   if (ChangeKWThisToIdent && Tok.is(tok::kw_this))
 Tok.setKind(tok::identifier);
diff --git a/clang/test/Parser/cxx0x-attributes.cpp 
b/clang/test/Parser/cxx0x-attributes.cpp
index 372a373a49ec5..d343cd4f3a93e 100644
--- a/clang/test/Parser/cxx0x-attributes.cpp
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -477,3 +477,8 @@ namespace P2361 {
 }
 
 alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced 
attributes; expected attributes here}}
+
+namespace GH147217 {
+  [[clang::annotate(#)]] void a();  // expected-error {{'#' is not allowed 
in attribute argument lists}}
+  [[clang::annotate(##)]] void b(); // expected-error {{'##' is not 
allowed in attribute argument lists}}
+}

>From 962f703e11a25f6ddf9b0ba5ac045456d5167242 Mon Sep 17 00:00:00 2001
From: Oleksandr Tarasiuk 
Date: Mon, 7 Jul 2025 18:49:55 +0300
Subject: [PATCH 2/3] update diagnostic message

---
 clang/include/clang/Basic/DiagnosticParseKinds.td | 2 +-
 clang/test/Parser/cxx0x-attributes.cpp| 6 --
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index b39e2a7359c22..d53ef7a93bfda 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -831,7 +831,7 @@ def err_ms_property_expected_comma_or_rparen : Error<
 def err_ms_property_initializer : Error<
   "property declaration cannot have a default member initializer">;
 def err_invalid_attribute_argument
-: Error<"'%0' is not allowed in attribute argument lists">;
+: Error<"'%0' is not allowed in an attribute argument list">;
 
 def err_assume_attr_expects_cond_expr : Error<
   "use of this expression in an %0 attribute requires parentheses">;
diff --git a/clang/test/Parser/cxx0x-attributes.cpp 
b/clang/test/Parser/cxx0x-attributes.cpp
index d343cd4f3a93e..f5a3039c4470c 100644
--- a/clang/test/Parser/cxx0x-attributes.cpp
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -479,6 +479,8 @@ namespace P2361 {
 alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced 
attributes; expected attributes here}}
 
 namespace GH147217 {
-  [[clang::annotate(#)]] void a();  // expected-error {{'#' is not allowed 
in attribute argument lists}}
-  [[clang::annotate(##)]] void b(); // expected-error {{'##' is not 
allowed in attribute argument lists}}
+  [[clang::annotate(#)]] void a();// expected-error {{'#' is not allo

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread via cfe-commits
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy ,
=?utf-8?q?Donát?= Nagy 
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- 
clang/test/Analysis/test-member-invalidation.cpp 
clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
clang/lib/StaticAnalyzer/Checkers/NoOwnershipChangeVisitor.h 
clang/test/Analysis/new.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index 526e1e6e8..073d80dc8 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -384,14 +384,13 @@ struct DynMemFrontend : virtual public CheckerFrontend, 
public BT_PROVIDERS... {
 
//===--===//
 
 class MallocChecker
-: public CheckerFamily,
- check::EndFunction, check::PreCall, check::PostCall,
- eval::Call, check::NewAllocator,
- check::PostStmt, check::PostObjCMessage,
- check::Location, eval::Assume> {
+: public CheckerFamily<
+  check::DeadSymbols, check::PointerEscape, check::ConstPointerEscape,
+  check::PreStmt, check::EndFunction, check::PreCall,
+  check::PostCall, eval::Call, check::NewAllocator,
+  check::PostStmt, check::PostObjCMessage, check::Location,
+  eval::Assume> {
 public:
-
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
   /// In optimistic mode, the checker assumes that all user-defined functions
@@ -3918,7 +3917,8 @@ void ento::registerDynamicMemoryModeling(CheckerManager 
&Mgr) {
   Chk->ShouldIncludeOwnershipAnnotatedFunctions =
   Mgr.getAnalyzerOptions().getCheckerBooleanOption(DMMName, "Optimistic");
   Chk->ShouldRegisterNoOwnershipChangeVisitor =
-  Mgr.getAnalyzerOptions().getCheckerBooleanOption(DMMName, 
"AddNoOwnershipChangeNotes");
+  Mgr.getAnalyzerOptions().getCheckerBooleanOption(
+  DMMName, "AddNoOwnershipChangeNotes");
 }
 
 bool ento::shouldRegisterDynamicMemoryModeling(const CheckerManager &mgr) {

``




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


[clang] [llvm] [WebAssembly,llvm] Add llvm.wasm.ref.test.func intrinsic (PR #147076)

2025-07-08 Thread Hood Chatham via cfe-commits

hoodmane wrote:

Okay I opened https://github.com/llvm/llvm-project/pull/147486/ with a second 
option. I think that's a bit cleaner, I modified SelectionDAG to be able to 
emit CImm arguments rather than going to all this trouble to avoid it.

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


[clang] [NFC] [C++] [Modules] Mark P2115 as implemented and add test (PR #147489)

2025-07-08 Thread Ashwin Kishin Banwari via cfe-commits

https://github.com/kish1n created 
https://github.com/llvm/llvm-project/pull/147489

This is already implemented. Proposal: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2115r0.html

>From 9d24a78f734e5398a1bfc977b77b3287a5f5203e Mon Sep 17 00:00:00 2001
From: Ashwin Banwari 
Date: Tue, 8 Jul 2025 02:06:35 -0700
Subject: [PATCH 1/2] mark P2115 as implemented and add test

---
 clang/test/SemaCXX/P2115.cpp | 21 +
 1 file changed, 21 insertions(+)
 create mode 100644 clang/test/SemaCXX/P2115.cpp

diff --git a/clang/test/SemaCXX/P2115.cpp b/clang/test/SemaCXX/P2115.cpp
new file mode 100644
index 00..4389be992440b4
--- /dev/null
+++ b/clang/test/SemaCXX/P2115.cpp
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+
+// RUN: %clang -std=c++20 -fmodule-header %t/A.h -o %t/A.pcm
+// RUN: %clang -std=c++20 -fmodule-header %t/B.h -o %t/B.pcm
+// RUN: %clang -std=c++20 -fsyntax-only -fmodule-file=%t/A.pcm 
-fmodule-file=%t/B.pcm %t/main.cpp
+
+//--- A.h
+// expected-no-diagnostics
+enum { A = 0 };
+
+//--- B.h
+// expected-no-diagnostics
+enum { B = 1 };
+
+//--- main.cpp
+// expected-no-diagnostics
+import "A.h";
+import "B.h";
+int main() {}

>From bd4c208d9bc1b4de4bd1dfdc18abafc25c581f59 Mon Sep 17 00:00:00 2001
From: Ashwin Banwari 
Date: Tue, 8 Jul 2025 02:09:43 -0700
Subject: [PATCH 2/2] add to cxx_status

---
 clang/www/cxx_status.html | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 831f79f7cf17a0..1920c8fc79396b 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -935,7 +935,7 @@ C++20 implementation status
   
   
 https://wg21.link/p2115r0";>P2115R0
-Partial
+Yes
   
   
 https://wg21.link/p1815r2";>P1815R2

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


[clang] [NFC] [C++] [Modules] Mark P2115 as implemented and add test (PR #147489)

2025-07-08 Thread Ashwin Kishin Banwari via cfe-commits

kish1n wrote:

@ChuanqiXu9 

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


[clang] [NFC][PowerPC][clang] Update clang/test/Driver/aix-default-target-triple.c for AIX specific targets (PR #147584)

2025-07-08 Thread Hubert Tong via cfe-commits

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


[clang] [NFC][PowerPC][clang] Update clang/test/Driver/aix-default-target-triple.c for AIX specific targets (PR #147584)

2025-07-08 Thread Hubert Tong via cfe-commits

https://github.com/hubert-reinterpretcast approved this pull request.

LGTM with suggested changes.

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


[clang] [CIR] Fold ComplexRealOp from ComplexCreateOp (PR #147592)

2025-07-08 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper created 
https://github.com/llvm/llvm-project/pull/147592

Folding ComplexRealOp if the operand is ComplexCreateOp, inspired by MLIR 
Complex dialect

Ref: 
https://github.com/llvm/llvm-project/blob/8b65c9d1ed298a9f4be675d1da9d678fd61ff2b0/mlir/lib/Dialect/Complex/IR/ComplexOps.cpp#L237-L245

https://github.com/llvm/llvm-project/issues/141365

>From 316b23e92cf55a407fdaa7d9aa5fd92a24754fee Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Tue, 8 Jul 2025 22:07:09 +0200
Subject: [PATCH] [CIR] Fold ComplexRealOp from ComplexCreateOp

---
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp|  5 +
 .../test/CIR/Transforms/complex-real-fold.cir  | 18 +-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index 8512b229c2663..ed70e52aaefe6 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -2066,6 +2066,11 @@ LogicalResult cir::ComplexRealOp::verify() {
 }
 
 OpFoldResult cir::ComplexRealOp::fold(FoldAdaptor adaptor) {
+  if (auto complexCreateOp = dyn_cast_or_null(
+  getOperand().getDefiningOp())) {
+return complexCreateOp.getOperand(0);
+  }
+
   auto complex =
   mlir::cast_if_present(adaptor.getOperand());
   return complex ? complex.getReal() : nullptr;
diff --git a/clang/test/CIR/Transforms/complex-real-fold.cir 
b/clang/test/CIR/Transforms/complex-real-fold.cir
index 1cab9be616af0..630dd679f67af 100644
--- a/clang/test/CIR/Transforms/complex-real-fold.cir
+++ b/clang/test/CIR/Transforms/complex-real-fold.cir
@@ -1,4 +1,4 @@
-// RUN: cir-opt %s -cir-canonicalize -o - | FileCheck %s
+// RUN: cir-opt %s -cir-canonicalize  -o - -split-input-file | FileCheck %s
 
 !s32i = !cir.int
 
@@ -21,3 +21,19 @@ module {
   // CHECK: }
 
 }
+
+// -
+
+!s32i = !cir.int
+
+module {
+  cir.func dso_local @fold_complex_real_from_create_test(%arg0: !s32i, %arg1: 
!s32i) -> !s32i {
+%0 = cir.complex.create %arg0, %arg1 : !s32i -> !cir.complex
+%1 = cir.complex.real %0 : !cir.complex -> !s32i
+cir.return %1 : !s32i
+  }
+
+  // CHECK: cir.func dso_local 
@fold_complex_real_from_create_test(%[[ARG_0:.*]]: !s32i, %[[ARG_1:.*]]: !s32i) 
-> !s32i {
+  // CHECK:   cir.return %[[ARG_0]] : !s32i
+  // CHECK: }
+}

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


[clang] [PowerPC][NFC] Define new alias for mma accumulate builtins (PR #147382)

2025-07-08 Thread Lei Huang via cfe-commits

https://github.com/lei137 updated 
https://github.com/llvm/llvm-project/pull/147382

>From 36d2b8fc61ab67b8d8010e8b33e3e871f8e1c4f2 Mon Sep 17 00:00:00 2001
From: Lei Huang 
Date: Fri, 4 Jul 2025 14:53:15 -0500
Subject: [PATCH 1/5] define new alias for accumulate builtins

---
 clang/include/clang/Basic/BuiltinsPPC.def | 99 +--
 1 file changed, 21 insertions(+), 78 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 7c278d6841c74..67ba4394b9ed7 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -35,6 +35,13 @@
 #define UNALIASED_CUSTOM_BUILTIN(ID, TYPES, ACCUMULATE, FEATURE)   
\
   CUSTOM_BUILTIN(ID, ID, TYPES, ACCUMULATE, FEATURE)
 
+#define UNALIASED_CUSTOM_ACCUMULATE_BUILTIN(ID, TYPES, FEATURE) \
+  UNALIASED_CUSTOM_BUILTIN(ID, TYPES, false, FEATURE)  \
+  UNALIASED_CUSTOM_BUILTIN(ID##nn, TYPES, true, FEATURE)  \
+  UNALIASED_CUSTOM_BUILTIN(ID##np, TYPES, true, FEATURE)  \
+  UNALIASED_CUSTOM_BUILTIN(ID##pn, TYPES, true, FEATURE)  \
+  UNALIASED_CUSTOM_BUILTIN(ID##pp, TYPES, true, FEATURE)
+
 // GCC predefined macros to rename builtins, undef them to keep original names.
 #if defined(__GNUC__) && !defined(__clang__)
 #undef __builtin_vsx_xvnmaddadp
@@ -1032,12 +1039,6 @@ UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2, "vW512*VV", 
false,
  "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_xvi16ger2s, "vW512*VV", false,
  "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2, "vW512*VV", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32ger, "vW512*VV", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf64ger, "vW512*W256V", false,
- "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_pmxvi4ger8, "vW512*VVi15i15i255", false,
  "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_pmxvi8ger4, "vW512*VVi15i15i15", false,
@@ -1046,12 +1047,6 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2, 
"vW512*VVi15i15i3", false,
  "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2s, "vW512*VVi15i15i3", false,
  "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2, "vW512*VVi15i15i3", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32ger, "vW512*VVi15i15", false,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf64ger, "vW512*W256Vi15i3", false,
- "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_xvi4ger8pp, "vW512*VV", true,
  "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_xvi8ger4pp, "vW512*VV", true,
@@ -1072,85 +1067,33 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2pp, 
"vW512*VVi15i15i3", true,
  "mma,paired-vector-memops")
 UNALIASED_CUSTOM_BUILTIN(mma_pmxvi16ger2spp, "vW512*VVi15i15i3", true,
  "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pp, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2pn, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2np, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf16ger2nn, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pp, "vW512*VVi15i15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2pn, "vW512*VVi15i15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2np, "vW512*VVi15i15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf16ger2nn, "vW512*VVi15i15i3", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpp, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32gerpn, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernp, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_xvf32gernn, "vW512*VV", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpp, "vW512*VVi15i15", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gerpn, "vW512*VVi15i15", true,
- "mma,paired-vector-memops")
-UNALIASED_CUSTOM_BUILTIN(mma_pmxvf32gernp, "vW512*VVi15i15", true,
- "mma,paired-vector-memops")
-UNALIASED_

[clang-tools-extra] [clang-tidy][NFC] Do less unnecessary work in `NoLintDirectiveHandler` (PR #147553)

2025-07-08 Thread Julian Schmidt via cfe-commits

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


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


[clang] [clang] Consistently handle consteval constructors for variables. (PR #144970)

2025-07-08 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic updated 
https://github.com/llvm/llvm-project/pull/144970

>From b1f7402423af22b0ea8cdf0b3d3734bcce68a636 Mon Sep 17 00:00:00 2001
From: Eli Friedman 
Date: Thu, 19 Jun 2025 18:29:49 -0700
Subject: [PATCH 1/2] [clang] Consistently handle consteval constructors for
 variables.

443377a9d1a8d4a69a317a1a892184c59dd0aec6 handled simple variables
definitions, but it didn't handle uninitialized variables with a
constexpr constructor, and it didn't handle template instantiation.

Fixes #135281 .
---
 clang/include/clang/Sema/Sema.h   |  1 +
 clang/lib/Parse/ParseDecl.cpp |  1 +
 clang/lib/Sema/SemaCoroutine.cpp  |  3 +-
 clang/lib/Sema/SemaDeclCXX.cpp| 26 ++
 clang/lib/Sema/SemaExpr.cpp   | 19 +++
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  3 +-
 .../SemaCXX/cxx2b-consteval-propagate.cpp | 34 +++
 7 files changed, 61 insertions(+), 26 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 9397546c8fc5d..e335814a910cc 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6759,6 +6759,7 @@ class Sema final : public SemaBase {
   EK_Decltype,
   EK_TemplateArgument,
   EK_AttrArgument,
+  EK_VariableInit,
   EK_Other
 } ExprContext;
 
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 7e739e09b15e8..c34a1fb6004a9 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2710,6 +2710,7 @@ Decl 
*Parser::ParseDeclarationAfterDeclaratorAndAttributes(
 break;
   }
   case InitKind::Uninitialized: {
+InitializerScopeRAII InitScope(*this, D, ThisDecl);
 Actions.ActOnUninitializedDecl(ThisDecl);
 break;
   }
diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index a1389c6c034b1..d193a33f22393 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -783,7 +783,8 @@ static bool checkSuspensionContext(Sema &S, SourceLocation 
Loc,
   const auto ExprContext = S.currentEvaluationContext().ExprContext;
   const bool BadContext =
   S.isUnevaluatedContext() ||
-  ExprContext != Sema::ExpressionEvaluationContextRecord::EK_Other;
+  (ExprContext != Sema::ExpressionEvaluationContextRecord::EK_Other &&
+   ExprContext != 
Sema::ExpressionEvaluationContextRecord::EK_VariableInit);
   if (BadContext) {
 S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
 return false;
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 16645ecf411e5..d8e749276e85d 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18937,7 +18937,8 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl 
*D) {
 EnterDeclaratorContext(S, D->getDeclContext());
 
   PushExpressionEvaluationContext(
-  ExpressionEvaluationContext::PotentiallyEvaluated, D);
+  ExpressionEvaluationContext::PotentiallyEvaluated, D,
+  ExpressionEvaluationContextRecord::EK_VariableInit);
 }
 
 void Sema::ActOnCXXExitDeclInitializer(Scope *S, Decl *D) {
@@ -18946,29 +18947,6 @@ void Sema::ActOnCXXExitDeclInitializer(Scope *S, Decl 
*D) {
   if (S && D->isOutOfLine())
 ExitDeclaratorContext(S);
 
-  if (getLangOpts().CPlusPlus23) {
-// An expression or conversion is 'manifestly constant-evaluated' if it is:
-// [...]
-// - the initializer of a variable that is usable in constant expressions 
or
-//   has constant initialization.
-if (auto *VD = dyn_cast(D);
-VD && (VD->isUsableInConstantExpressions(Context) ||
-   VD->hasConstantInitialization())) {
-  // An expression or conversion is in an 'immediate function context' if 
it
-  // is potentially evaluated and either:
-  // [...]
-  // - it is a subexpression of a manifestly constant-evaluated expression
-  //   or conversion.
-  ExprEvalContexts.back().InImmediateFunctionContext = true;
-}
-  }
-
-  // Unless the initializer is in an immediate function context (as determined
-  // above), this will evaluate all contained immediate function calls as
-  // constant expressions. If the initializer IS an immediate function context,
-  // the initializer has been determined to be a constant expression, and all
-  // such evaluations will be elided (i.e., as if we "knew the whole time" that
-  // it was a constant expression).
   PopExpressionEvaluationContext();
 }
 
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index a3f534ee6712e..d74885491448a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -17935,6 +17935,25 @@ HandleImmediateInvocations(Sema &SemaRef,
   Rec.isImmediateFunctionContext() || 
SemaRef.RebuildingImmediateInvocation)
 return;
 
+  // An expression or conversion is 'manifestly constant-evaluated' if it i

[clang] [clang] Consistently handle consteval constructors for variables. (PR #144970)

2025-07-08 Thread Eli Friedman via cfe-commits

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


[clang] 6a99326 - [clang] Consistently handle consteval constructors for variables. (#144970)

2025-07-08 Thread via cfe-commits

Author: Eli Friedman
Date: 2025-07-08T14:47:04-07:00
New Revision: 6a993264ee0105da32a6a57fb077796076cf6bf4

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

LOG: [clang] Consistently handle consteval constructors for variables. (#144970)

443377a9d1a8d4a69a317a1a892184c59dd0aec6 handled simple variable
definitions, but it didn't handle uninitialized variables with a
consteval constructor, and it didn't handle template instantiation.

Fixes #135281 .

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Sema/Sema.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaCXX/cxx2b-consteval-propagate.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a919f3a71c9cf..8b4f9229c4463 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -920,6 +920,9 @@ Bug Fixes to C++ Support
 - Correctly handle allocations in the condition of a ``if 
constexpr``.(#GH120197) (#GH134820)
 - Fixed a crash when handling invalid member using-declaration in C++20+ mode. 
(#GH63254)
 - Fix a crash when trying to instantiate an ambiguous specialization. 
(#GH51866)
+- Improved handling of variables with ``consteval`` constructors, to
+  consistently treat the initializer as manifestly constant-evaluated.
+  (#GH135281)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b281b1cfef96a..a21836dffb0e6 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -6761,6 +6761,7 @@ class Sema final : public SemaBase {
   EK_Decltype,
   EK_TemplateArgument,
   EK_AttrArgument,
+  EK_VariableInit,
   EK_Other
 } ExprContext;
 

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 7e739e09b15e8..c34a1fb6004a9 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -2710,6 +2710,7 @@ Decl 
*Parser::ParseDeclarationAfterDeclaratorAndAttributes(
 break;
   }
   case InitKind::Uninitialized: {
+InitializerScopeRAII InitScope(*this, D, ThisDecl);
 Actions.ActOnUninitializedDecl(ThisDecl);
 break;
   }

diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index a1389c6c034b1..d193a33f22393 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -783,7 +783,8 @@ static bool checkSuspensionContext(Sema &S, SourceLocation 
Loc,
   const auto ExprContext = S.currentEvaluationContext().ExprContext;
   const bool BadContext =
   S.isUnevaluatedContext() ||
-  ExprContext != Sema::ExpressionEvaluationContextRecord::EK_Other;
+  (ExprContext != Sema::ExpressionEvaluationContextRecord::EK_Other &&
+   ExprContext != 
Sema::ExpressionEvaluationContextRecord::EK_VariableInit);
   if (BadContext) {
 S.Diag(Loc, diag::err_coroutine_unevaluated_context) << Keyword;
 return false;

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index f0247f865ba40..a49a8abb677c5 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -18892,7 +18892,8 @@ void Sema::ActOnCXXEnterDeclInitializer(Scope *S, Decl 
*D) {
 EnterDeclaratorContext(S, D->getDeclContext());
 
   PushExpressionEvaluationContext(
-  ExpressionEvaluationContext::PotentiallyEvaluated, D);
+  ExpressionEvaluationContext::PotentiallyEvaluated, D,
+  ExpressionEvaluationContextRecord::EK_VariableInit);
 }
 
 void Sema::ActOnCXXExitDeclInitializer(Scope *S, Decl *D) {
@@ -18901,29 +18902,6 @@ void Sema::ActOnCXXExitDeclInitializer(Scope *S, Decl 
*D) {
   if (S && D->isOutOfLine())
 ExitDeclaratorContext(S);
 
-  if (getLangOpts().CPlusPlus23) {
-// An expression or conversion is 'manifestly constant-evaluated' if it is:
-// [...]
-// - the initializer of a variable that is usable in constant expressions 
or
-//   has constant initialization.
-if (auto *VD = dyn_cast(D);
-VD && (VD->isUsableInConstantExpressions(Context) ||
-   VD->hasConstantInitialization())) {
-  // An expression or conversion is in an 'immediate function context' if 
it
-  // is potentially evaluated and either:
-  // [...]
-  // - it is a subexpression of a manifestly constant-evaluated expression
-  //   or conversion.
-  ExprEvalContexts.back().InImmediateFunctionContext = true;
-}
-  }
-
-  // Unless the initializer is in an immediate function context (as determined
-  // above), this will evaluate all contained immediate function calls 

[clang] [llvm] [AMDGPU] Add support for `v_cvt_f32_fp8` on gfx1250 (PR #147579)

2025-07-08 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,llvm` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'LLVM :: CodeGen/X86/sse2-intrinsics-fast-isel.ll' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
/buildbot/worker/arc-folder/build/bin/llc < 
/buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
 -show-mc-encoding -fast-isel -mtriple=i386-unknown-unknown -mattr=+sse2 | 
/buildbot/worker/arc-folder/build/bin/FileCheck 
/buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
 --check-prefixes=CHECK,X86,SSE,X86-SSE # RUN: at line 2
+ /buildbot/worker/arc-folder/build/bin/FileCheck 
/buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll
 --check-prefixes=CHECK,X86,SSE,X86-SSE
+ /buildbot/worker/arc-folder/build/bin/llc -show-mc-encoding -fast-isel 
-mtriple=i386-unknown-unknown -mattr=+sse2
LLVM ERROR: Cannot select: intrinsic %llvm.x86.sse2.clflush
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.  Program arguments: /buildbot/worker/arc-folder/build/bin/llc 
-show-mc-encoding -fast-isel -mtriple=i386-unknown-unknown -mattr=+sse2
1.  Running pass 'Function Pass Manager' on module ''.
2.  Running pass 'X86 DAG->DAG Instruction Selection' on function 
'@test_mm_clflush'
 #0 0x0231ba18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/buildbot/worker/arc-folder/build/bin/llc+0x231ba18)
 #1 0x02318945 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x7f9383419630 __restore_rt sigaction.c:0:0
 #3 0x7f93821693d7 raise (/usr/lib64/libc.so.6+0x363d7)
 #4 0x7f938216aac8 abort (/usr/lib64/libc.so.6+0x37ac8)
 #5 0x0071b00f llvm::json::operator==(llvm::json::Value const&, 
llvm::json::Value const&) (.cold) JSON.cpp:0:0
 #6 0x020abcc9 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) 
(/buildbot/worker/arc-folder/build/bin/llc+0x20abcc9)
 #7 0x020b0779 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, 
unsigned char const*, unsigned int) 
(/buildbot/worker/arc-folder/build/bin/llc+0x20b0779)
 #8 0x009587a7 (anonymous 
namespace)::X86DAGToDAGISel::Select(llvm::SDNode*) X86ISelDAGToDAG.cpp:0:0
 #9 0x020a758f llvm::SelectionDAGISel::DoInstructionSelection() 
(/buildbot/worker/arc-folder/build/bin/llc+0x20a758f)
#10 0x020b7108 llvm::SelectionDAGISel::CodeGenAndEmitDAG() 
(/buildbot/worker/arc-folder/build/bin/llc+0x20b7108)
#11 0x020ba85e 
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) 
(/buildbot/worker/arc-folder/build/bin/llc+0x20ba85e)
#12 0x020bb9f5 
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) 
(/buildbot/worker/arc-folder/build/bin/llc+0x20bb9f5)
#13 0x020a6daf 
llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) 
(/buildbot/worker/arc-folder/build/bin/llc+0x20a6daf)
#14 0x011fc387 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) 
MachineFunctionPass.cpp:0:0
#15 0x01857002 llvm::FPPassManager::runOnFunction(llvm::Function&) 
(/buildbot/worker/arc-folder/build/bin/llc+0x1857002)
#16 0x018573a1 llvm::FPPassManager::runOnModule(llvm::Module&) 
(/buildbot/worker/arc-folder/build/bin/llc+0x18573a1)
#17 0x01857fb7 llvm::legacy::PassManagerImpl::run(llvm::Module&) 
(/buildbot/worker/arc-folder/build/bin/llc+0x1857fb7)
#18 0x007f7722 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x007235a6 main (/buildbot/worker/arc-folder/build/bin/llc+0x7235a6)
#20 0x7f938215 __libc_start_main (/usr/lib64/libc.so.6+0x22555)
#21 0x007ed986 _start 
(/buildbot/worker/arc-folder/build/bin/llc+0x7ed986)
/buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll:399:14:
 error: SSE-LABEL: expected string not found in input
; SSE-LABEL: test_mm_bsrli_si128:
 ^
:170:21: note: scanning from here
test_mm_bslli_si128: # @test_mm_bslli_si128
^
:178:9: note: possible intended match here
 .globl test_mm_bsrli_si128 # 
^

Input file: 
Check file: 
/buildbot/worker/arc-folder/llvm-project/llvm/test/CodeGen/X86/sse2-intrinsics-fast-isel.ll

-dump-input=help explains the following input dump.
...

```



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


[clang] [HLSL][RootSignature] Implement diagnostic for missed comma (PR #147350)

2025-07-08 Thread Finn Plummer via cfe-commits

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


[clang] [llvm] [NFC][HLSL] Move resource range logic from `SemaHLSL` to `RootSignatureValidations` (PR #147117)

2025-07-08 Thread Finn Plummer via cfe-commits

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


[clang] [llvm] [NVPTX] Fix v2i8 call lowering, use generic ld/st nodes for call params (PR #146930)

2025-07-08 Thread Alex MacLean via cfe-commits


@@ -1487,14 +1380,39 @@ SDValue 
NVPTXTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
   // After all vararg is processed, 'VAOffset' holds the size of the
   // vararg byte array.
 
-  SDValue VADeclareParam; // vararg byte array
+  SDValue VADeclareParam = SDValue();   // vararg byte array
   const unsigned FirstVAArg = CLI.NumFixedArgs; // position of first variadic
   unsigned VAOffset = 0;  // current offset in the param array
 
   const unsigned UniqueCallSite = GlobalUniqueCallSite++;
-  SDValue TempChain = Chain;
-  Chain = DAG.getCALLSEQ_START(Chain, UniqueCallSite, 0, dl);
-  SDValue InGlue = Chain.getValue(1);
+  const SDValue CallChain = CLI.Chain;
+  const SDValue StartChain =
+  DAG.getCALLSEQ_START(CallChain, UniqueCallSite, 0, dl);
+  SDValue DeclareGlue = StartChain.getValue(1);
+
+  SmallVector CallPrereqs{StartChain};
+
+  const auto DeclareScalarParam = [&](SDValue Symbol, unsigned Size) {
+// PTX ABI requires integral types to be at least 32 bits in size. FP16 is
+// loaded/stored using i16, so it's handled here as well.
+const unsigned SizeBits = promoteScalarArgumentSize(Size * 8);
+SDValue Declare =
+DAG.getNode(NVPTXISD::DeclareScalarParam, dl, {MVT::Other, MVT::Glue},
+{StartChain, Symbol, GetI32(SizeBits), DeclareGlue});
+CallPrereqs.push_back(Declare);

AlexMaclean wrote:

I think in this case it is appropriate to update state within this lambda. 
CallPrereqs is a big list of everything that needs to happen before we make the 
call. We always want to add all the param declarations to this list, so we'd 
need to pass the same thing in every single place these functions are called, 
or update immediately after in every location. Since the state is just a list 
(which we won't remove items from or even use within the lambda) of all these 
params I think this is the best approach and not too confusing in this case. 

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


[clang] [llvm] [WebAssembly,llvm] Add llvm.wasm.ref.test.func intrinsic (PR #147076)

2025-07-08 Thread Hood Chatham via cfe-commits

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


[clang] [llvm] [Clang-Repl] Add pipe-based redirection and fetch PID of launched executor (PR #147478)

2025-07-08 Thread Abhinav Kumar via cfe-commits

https://github.com/kr-2003 updated 
https://github.com/llvm/llvm-project/pull/147478

>From fbe4344831538480be33accd35ef618c6d0e50b3 Mon Sep 17 00:00:00 2001
From: kr-2003 
Date: Tue, 1 Jul 2025 18:55:21 +0530
Subject: [PATCH 1/6] pipes for redirection in oop jit

---
 .../clang/Interpreter/RemoteJITUtils.h|  6 +++-
 clang/lib/Interpreter/RemoteJITUtils.cpp  | 32 ++-
 llvm/lib/ExecutionEngine/Orc/LLJIT.cpp| 15 +
 3 files changed, 45 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/Interpreter/RemoteJITUtils.h 
b/clang/include/clang/Interpreter/RemoteJITUtils.h
index 8705a3b1f669d..825143f008a45 100644
--- a/clang/include/clang/Interpreter/RemoteJITUtils.h
+++ b/clang/include/clang/Interpreter/RemoteJITUtils.h
@@ -26,7 +26,7 @@
 
 llvm::Expected>
 launchExecutor(llvm::StringRef ExecutablePath, bool UseSharedMemory,
-   llvm::StringRef SlabAllocateSizeString);
+   llvm::StringRef SlabAllocateSizeString, int stdin_fd = 0, int 
stdout_fd = 1, int stderr_fd = 2);
 
 /// Create a JITLinkExecutor that connects to the given network address
 /// through a TCP socket. A valid NetworkAddress provides hostname and port,
@@ -35,4 +35,8 @@ llvm::Expected>
 connectTCPSocket(llvm::StringRef NetworkAddress, bool UseSharedMemory,
  llvm::StringRef SlabAllocateSizeString);
 
+/// Get the PID of the last launched executor.
+/// This is useful for debugging or for cleanup purposes.
+pid_t getLastLaunchedExecutorPID();
+
 #endif // LLVM_CLANG_INTERPRETER_REMOTEJITUTILS_H
diff --git a/clang/lib/Interpreter/RemoteJITUtils.cpp 
b/clang/lib/Interpreter/RemoteJITUtils.cpp
index c0e663b764785..8324aeaaf689c 100644
--- a/clang/lib/Interpreter/RemoteJITUtils.cpp
+++ b/clang/lib/Interpreter/RemoteJITUtils.cpp
@@ -33,6 +33,8 @@
 using namespace llvm;
 using namespace llvm::orc;
 
+static std::atomic LaunchedExecutorPID{-1};
+
 Expected getSlabAllocSize(StringRef SizeString) {
   SizeString = SizeString.trim();
 
@@ -91,7 +93,7 @@ createSharedMemoryManager(SimpleRemoteEPC &SREPC,
 
 Expected>
 launchExecutor(StringRef ExecutablePath, bool UseSharedMemory,
-   llvm::StringRef SlabAllocateSizeString) {
+   llvm::StringRef SlabAllocateSizeString, int stdin_fd, int 
stdout_fd, int stderr_fd) {
 #ifndef LLVM_ON_UNIX
   // FIXME: Add support for Windows.
   return make_error("-" + ExecutablePath +
@@ -134,6 +136,28 @@ launchExecutor(StringRef ExecutablePath, bool 
UseSharedMemory,
 close(ToExecutor[WriteEnd]);
 close(FromExecutor[ReadEnd]);
 
+if (stdin_fd != 0) {
+  dup2(stdin_fd, STDIN_FILENO);
+  if (stdin_fd != STDIN_FILENO)
+close(stdin_fd);
+}
+
+if (stdout_fd != 1) {
+  dup2(stdout_fd, STDOUT_FILENO);
+  if (stdout_fd != STDOUT_FILENO)
+close(stdout_fd);
+
+  setvbuf(stdout, NULL, _IONBF, 0);
+}
+
+if (stderr_fd != 2) {
+  dup2(stderr_fd, STDERR_FILENO);
+  if (stderr_fd != STDERR_FILENO)
+close(stderr_fd);
+
+  setvbuf(stderr, NULL, _IONBF, 0);
+}
+
 // Execute the child process.
 std::unique_ptr ExecutorPath, FDSpecifier;
 {
@@ -155,6 +179,8 @@ launchExecutor(StringRef ExecutablePath, bool 
UseSharedMemory,
  << ExecutorPath.get() << "\"\n";
   exit(1);
 }
+  } else {
+ LaunchedExecutorPID = ChildPID;
   }
   // else we're the parent...
 
@@ -265,3 +291,7 @@ connectTCPSocket(StringRef NetworkAddress, bool 
UseSharedMemory,
   std::move(S), *SockFD, *SockFD);
 #endif
 }
+
+pid_t getLastLaunchedExecutorPID() {
+  return LaunchedExecutorPID;
+}
diff --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp 
b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 4e3c09e970cbe..67bb7dd8ad08f 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -632,16 +632,19 @@ Error ORCPlatformSupport::initialize(orc::JITDylib &JD) {
   int32_t result;
   auto E = ES.callSPSWrapper(WrapperAddr->getAddress(),
  result, DSOHandles[&JD]);
-  if (result)
+  if (E)
+return E;
+  else if (result)
 return make_error("dlupdate failed",
inconvertibleErrorCode());
-  return E;
-}
-return ES.callSPSWrapper(WrapperAddr->getAddress(),
-   DSOHandles[&JD], JD.getName(),
-   int32_t(ORC_RT_RTLD_LAZY));
+} else
+  return ES.callSPSWrapper(WrapperAddr->getAddress(),
+ DSOHandles[&JD], JD.getName(),
+ int32_t(ORC_RT_RTLD_LAZY));
   } else
 return WrapperAddr.takeError();
+
+  return Error::success();
 }
 
 Error ORCPlatformSupport::deinitialize(orc::JITDylib &JD) {

>From b207b1f4c4e639d86d0a03d28437f7e170f5d400 Mon Sep 17 00:00:00 2001
From: kr-2003 
Date: Mon, 7 Jul 2025 11:50:20 +0530

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat updated 
https://github.com/llvm/llvm-project/pull/147080

From c0e669a4f31702a871fce4c8c3805b322c331afd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Don=C3=A1t=20Nagy?= 
Date: Wed, 2 Jul 2025 15:09:42 +0200
Subject: [PATCH 01/10] [analyzer] Connversion to CheckerFamily: MallocChecker

This commit converts MallocChecker to the new checker family framework
that was introduced in the recent commit
6833076a5d9f5719539a24e900037da5a3979289 -- and gets rid of some
awkward unintended interactions between the checker frontends.
---
 .../StaticAnalyzer/Checkers/MallocChecker.cpp | 414 --
 clang/test/Analysis/new.cpp   |  40 +-
 .../Analysis/test-member-invalidation.cpp |  47 ++
 3 files changed, 227 insertions(+), 274 deletions(-)
 create mode 100644 clang/test/Analysis/test-member-invalidation.cpp

diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index a33e61fabc2c1..9e7540eecc8ee 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -333,11 +333,55 @@ template  static bool 
isStandardNewDelete(const T &FD) {
   return isStandardDelete(FD) || isStandardNew(FD);
 }
 
+namespace {
+
 
//===--===//
-// Definition of the MallocChecker class.
+// Utility classes that provide access to the bug types and can model that some
+// of the bug types are shared by multiple checker frontends.
 
//===--===//
 
-namespace {
+#define BUGTYPE_PROVIDER(NAME, DEF)
\
+  struct NAME : virtual public CheckerFrontend {   
\
+BugType NAME##Bug{this, DEF, categories::MemoryError}; 
\
+  };
+
+BUGTYPE_PROVIDER(DoubleFree, "Double free")
+// TODO: Remove DoubleDelete as a separate bug type and when it would be
+// emitted, emit DoubleFree reports instead. (Note that DoubleFree is already
+// used for all allocation families, not just malloc/free.)
+BUGTYPE_PROVIDER(DoubleDelete, "Double delete")
+
+struct Leak : virtual public CheckerFrontend {
+  // Leaks should not be reported if they are post-dominated by a sink:
+  // (1) Sinks are higher importance bugs.
+  // (2) NoReturnFunctionChecker uses sink nodes to represent paths ending
+  // with __noreturn functions such as assert() or exit(). We choose not
+  // to report leaks on such paths.
+  BugType LeakBug{this, "Memory leak", categories::MemoryError,
+  /*SuppressOnSink=*/true};
+};
+
+BUGTYPE_PROVIDER(UseFree, "Use-after-free")
+BUGTYPE_PROVIDER(BadFree, "Bad free")
+BUGTYPE_PROVIDER(FreeAlloca, "Free 'alloca()'")
+BUGTYPE_PROVIDER(MismatchedDealloc, "Bad deallocator")
+BUGTYPE_PROVIDER(OffsetFree, "Offset free")
+BUGTYPE_PROVIDER(UseZeroAllocated, "Use of zero allocated")
+
+template 
+struct DynMemFrontend : virtual public CheckerFrontend, public BT_PROVIDERS... 
{
+  template  const T *getAs() const {
+if constexpr (std::is_same_v)
+  return static_cast(this);
+if constexpr ((std::is_same_v || ...))
+  return static_cast(this);
+return nullptr;
+  }
+};
+
+//===--===//
+// Definition of the MallocChecker class.
+//===--===//
 
 class MallocChecker
 : public Checker
+  MallocChecker;
+  DynMemFrontend
+  NewDeleteChecker;
+  DynMemFrontend NewDeleteLeaksChecker;
+  DynMemFrontend MismatchedDeallocatorChecker;
+  DynMemFrontend InnerPointerChecker;
+  // This last frontend is associated with a single bug type which is not used
+  // elsewhere and has a different bug category, so it's declared separately.
+  CheckerFrontendWithBugType TaintedAllocChecker{"Tainted Memory Allocation",
+ categories::TaintedData};
 
   using LeakInfo = std::pair;
 
-  bool ChecksEnabled[CK_NumCheckKinds] = {false};
-  CheckerNameRef CheckNames[CK_NumCheckKinds];
-
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
   bool evalCall(const CallEvent &Call, CheckerContext &C) const;
@@ -402,16 +449,19 @@ class MallocChecker
   const char *NL, const char *Sep) const override;
 
 private:
-  mutable std::unique_ptr BT_DoubleFree[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_DoubleDelete;
-  mutable std::unique_ptr BT_Leak[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_UseFree[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_BadFree[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_FreeAlloca[CK_NumCheckKinds];
-  mutable std::unique_ptr BT_MismatchedDealloc;
-  mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
-  mutable std::uniqu

[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Donát Nagy via cfe-commits


@@ -333,11 +333,55 @@ template  static bool 
isStandardNewDelete(const T &FD) {
   return isStandardDelete(FD) || isStandardNew(FD);
 }
 
+namespace {
+
 
//===--===//
-// Definition of the MallocChecker class.
+// Utility classes that provide access to the bug types and can model that some
+// of the bug types are shared by multiple checker frontends.
 
//===--===//
 
-namespace {
+#define BUGTYPE_PROVIDER(NAME, DEF)
\
+  struct NAME : virtual public CheckerFrontend {   
\
+BugType NAME##Bug{this, DEF, categories::MemoryError}; 
\
+  };
+
+BUGTYPE_PROVIDER(DoubleFree, "Double free")
+// TODO: Remove DoubleDelete as a separate bug type and when it would be
+// emitted, emit DoubleFree reports instead. (Note that DoubleFree is already
+// used for all allocation families, not just malloc/free.)
+BUGTYPE_PROVIDER(DoubleDelete, "Double delete")
+
+struct Leak : virtual public CheckerFrontend {
+  // Leaks should not be reported if they are post-dominated by a sink:
+  // (1) Sinks are higher importance bugs.
+  // (2) NoReturnFunctionChecker uses sink nodes to represent paths ending
+  // with __noreturn functions such as assert() or exit(). We choose not
+  // to report leaks on such paths.
+  BugType LeakBug{this, "Memory leak", categories::MemoryError,
+  /*SuppressOnSink=*/true};
+};
+
+BUGTYPE_PROVIDER(UseFree, "Use-after-free")
+BUGTYPE_PROVIDER(BadFree, "Bad free")
+BUGTYPE_PROVIDER(FreeAlloca, "Free 'alloca()'")
+BUGTYPE_PROVIDER(MismatchedDealloc, "Bad deallocator")
+BUGTYPE_PROVIDER(OffsetFree, "Offset free")
+BUGTYPE_PROVIDER(UseZeroAllocated, "Use of zero allocated")
+

NagyDonat wrote:

Done in 
https://github.com/llvm/llvm-project/pull/147080/commits/43eb9222e92dd75b246cd0a786fcce377d95793f

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


[clang] [analyzer] Conversion to CheckerFamily: MallocChecker (PR #147080)

2025-07-08 Thread Donát Nagy via cfe-commits


@@ -333,11 +333,55 @@ template  static bool 
isStandardNewDelete(const T &FD) {
   return isStandardDelete(FD) || isStandardNew(FD);
 }
 
+namespace {
+
 
//===--===//
-// Definition of the MallocChecker class.
+// Utility classes that provide access to the bug types and can model that some
+// of the bug types are shared by multiple checker frontends.
 
//===--===//
 
-namespace {
+#define BUGTYPE_PROVIDER(NAME, DEF)
\
+  struct NAME : virtual public CheckerFrontend {   
\
+BugType NAME##Bug{this, DEF, categories::MemoryError}; 
\
+  };
+
+BUGTYPE_PROVIDER(DoubleFree, "Double free")
+// TODO: Remove DoubleDelete as a separate bug type and when it would be
+// emitted, emit DoubleFree reports instead. (Note that DoubleFree is already
+// used for all allocation families, not just malloc/free.)
+BUGTYPE_PROVIDER(DoubleDelete, "Double delete")
+
+struct Leak : virtual public CheckerFrontend {
+  // Leaks should not be reported if they are post-dominated by a sink:
+  // (1) Sinks are higher importance bugs.
+  // (2) NoReturnFunctionChecker uses sink nodes to represent paths ending
+  // with __noreturn functions such as assert() or exit(). We choose not
+  // to report leaks on such paths.
+  BugType LeakBug{this, "Memory leak", categories::MemoryError,
+  /*SuppressOnSink=*/true};
+};
+
+BUGTYPE_PROVIDER(UseFree, "Use-after-free")
+BUGTYPE_PROVIDER(BadFree, "Bad free")
+BUGTYPE_PROVIDER(FreeAlloca, "Free 'alloca()'")
+BUGTYPE_PROVIDER(MismatchedDealloc, "Bad deallocator")
+BUGTYPE_PROVIDER(OffsetFree, "Offset free")
+BUGTYPE_PROVIDER(UseZeroAllocated, "Use of zero allocated")
+
+template 
+struct DynMemFrontend : virtual public CheckerFrontend, public BT_PROVIDERS... 
{
+  template  const T *getAs() const {
+if constexpr (std::is_same_v)
+  return static_cast(this);
+if constexpr ((std::is_same_v || ...))
+  return static_cast(this);
+return nullptr;

NagyDonat wrote:

No, this is a branch that can actually occur during normal operation of the 
checker.

For example if `getRelevantFrontendAs(AF_InnerBuffer)` is called, then it 
will invoke `InnerPointerChecker.getAs()` which returns `nullptr` to 
signify that `InnerPointerChecker` does not inherit from `Leak` and cannot emit 
reports with bug type `LeakBug`.

Should I add a comment to clarify this?

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


  1   2   3   4   >