[clang] [llvm] [RISCV] Xqci Extensions v0.10.0 (PR #137881)

2025-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Sam Elliott (lenary)


Changes

This updates all the extensions to their version in the v0.10.0 spec.

All changes from this version are already implemented or are not relevant to 
LLVM.

This change also alphabetises the lists of Xqci extensions, to make future 
checks easier, and removes irrelevant info from the usage docs.

---

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


5 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+7-7) 
- (modified) llvm/docs/RISCVUsage.rst (+20-20) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+73-73) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+9-9) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+13-13) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index b10850aadddc3..d96077e787960 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -200,21 +200,21 @@
 // CHECK-NEXT: ssctr1.0   'Ssctr' (Control Transfer 
Records Supervisor Level)
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqccmp   0.1   'Xqccmp' (Qualcomm 16-bit 
Push/Pop and Double Moves)
-// CHECK-NEXT: xqcia0.4   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
+// CHECK-NEXT: xqcia0.7   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
 // CHECK-NEXT: xqciac   0.3   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
 // CHECK-NEXT: xqcibi   0.2   'Xqcibi' (Qualcomm uC Branch 
Immediate Extension)
-// CHECK-NEXT: xqcibm   0.4   'Xqcibm' (Qualcomm uC Bit 
Manipulation Extension)
-// CHECK-NEXT: xqcicli  0.2   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
+// CHECK-NEXT: xqcibm   0.7   'Xqcibm' (Qualcomm uC Bit 
Manipulation Extension)
+// CHECK-NEXT: xqcicli  0.3   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
 // CHECK-NEXT: xqcicm   0.2   'Xqcicm' (Qualcomm uC 
Conditional Move Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
-// CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
-// CHECK-NEXT: xqciint  0.4   'Xqciint' (Qualcomm uC 
Interrupts Extension)
+// CHECK-NEXT: xqcicsr  0.3   'Xqcicsr' (Qualcomm uC CSR 
Extension)
+// CHECK-NEXT: xqciint  0.7   'Xqciint' (Qualcomm uC 
Interrupts Extension)
 // CHECK-NEXT: xqciio   0.1   'Xqciio' (Qualcomm uC 
External Input Output Extension)
 // CHECK-NEXT: xqcilb   0.2   'Xqcilb' (Qualcomm uC Long 
Branch Extension)
 // CHECK-NEXT: xqcili   0.2   'Xqcili' (Qualcomm uC Load 
Large Immediate Extension)
 // CHECK-NEXT: xqcilia  0.2   'Xqcilia' (Qualcomm uC Large 
Immediate Arithmetic Extension)
-// CHECK-NEXT: xqcilo   0.2   'Xqcilo' (Qualcomm uC Large 
Offset Load Store Extension)
-// CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
+// CHECK-NEXT: xqcilo   0.3   'Xqcilo' (Qualcomm uC Large 
Offset Load Store Extension)
+// CHECK-NEXT: xqcilsm  0.5   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
 // CHECK-NEXT: xqcisim  0.2   'Xqcisim' (Qualcomm uC 
Simulation Hint Extension)
 // CHECK-NEXT: xqcisls  0.2   'Xqcisls' (Qualcomm uC 
Scaled Load Store Extension)
 // CHECK-NEXT: xqcisync 0.2   'Xqcisync' (Qualcomm uC Sync 
Delay Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index d0689b779f551..49635273a036f 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -440,58 +440,58 @@ The current vendor extensions supported are:
   LLVM implements `version 0.1 of the 16-bit Push/Pop instructions and 
double-moves extension specification 
`__
 by Qualcomm. All instructions are prefixed with `qc.` as described in the 
specification.
 
 ``experimental-Xqcia``
-  LLVM implements `version 0.4 of the Qualcomm uC Arithmetic extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
+  LLVM implements `version 0.7 of the Qualcomm uC Arithmetic extensi

[clang] [llvm] [RISCV] Xqci Extensions v0.10.0 (PR #137881)

2025-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Sam Elliott (lenary)


Changes

This updates all the extensions to their version in the v0.10.0 spec.

All changes from this version are already implemented or are not relevant to 
LLVM.

This change also alphabetises the lists of Xqci extensions, to make future 
checks easier, and removes irrelevant info from the usage docs.

---

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


5 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+7-7) 
- (modified) llvm/docs/RISCVUsage.rst (+20-20) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+73-73) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+9-9) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+13-13) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index b10850aadddc3..d96077e787960 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -200,21 +200,21 @@
 // CHECK-NEXT: ssctr1.0   'Ssctr' (Control Transfer 
Records Supervisor Level)
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqccmp   0.1   'Xqccmp' (Qualcomm 16-bit 
Push/Pop and Double Moves)
-// CHECK-NEXT: xqcia0.4   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
+// CHECK-NEXT: xqcia0.7   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
 // CHECK-NEXT: xqciac   0.3   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
 // CHECK-NEXT: xqcibi   0.2   'Xqcibi' (Qualcomm uC Branch 
Immediate Extension)
-// CHECK-NEXT: xqcibm   0.4   'Xqcibm' (Qualcomm uC Bit 
Manipulation Extension)
-// CHECK-NEXT: xqcicli  0.2   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
+// CHECK-NEXT: xqcibm   0.7   'Xqcibm' (Qualcomm uC Bit 
Manipulation Extension)
+// CHECK-NEXT: xqcicli  0.3   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
 // CHECK-NEXT: xqcicm   0.2   'Xqcicm' (Qualcomm uC 
Conditional Move Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
-// CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
-// CHECK-NEXT: xqciint  0.4   'Xqciint' (Qualcomm uC 
Interrupts Extension)
+// CHECK-NEXT: xqcicsr  0.3   'Xqcicsr' (Qualcomm uC CSR 
Extension)
+// CHECK-NEXT: xqciint  0.7   'Xqciint' (Qualcomm uC 
Interrupts Extension)
 // CHECK-NEXT: xqciio   0.1   'Xqciio' (Qualcomm uC 
External Input Output Extension)
 // CHECK-NEXT: xqcilb   0.2   'Xqcilb' (Qualcomm uC Long 
Branch Extension)
 // CHECK-NEXT: xqcili   0.2   'Xqcili' (Qualcomm uC Load 
Large Immediate Extension)
 // CHECK-NEXT: xqcilia  0.2   'Xqcilia' (Qualcomm uC Large 
Immediate Arithmetic Extension)
-// CHECK-NEXT: xqcilo   0.2   'Xqcilo' (Qualcomm uC Large 
Offset Load Store Extension)
-// CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
+// CHECK-NEXT: xqcilo   0.3   'Xqcilo' (Qualcomm uC Large 
Offset Load Store Extension)
+// CHECK-NEXT: xqcilsm  0.5   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
 // CHECK-NEXT: xqcisim  0.2   'Xqcisim' (Qualcomm uC 
Simulation Hint Extension)
 // CHECK-NEXT: xqcisls  0.2   'Xqcisls' (Qualcomm uC 
Scaled Load Store Extension)
 // CHECK-NEXT: xqcisync 0.2   'Xqcisync' (Qualcomm uC Sync 
Delay Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index d0689b779f551..49635273a036f 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -440,58 +440,58 @@ The current vendor extensions supported are:
   LLVM implements `version 0.1 of the 16-bit Push/Pop instructions and 
double-moves extension specification 
`__
 by Qualcomm. All instructions are prefixed with `qc.` as described in the 
specification.
 
 ``experimental-Xqcia``
-  LLVM implements `version 0.4 of the Qualcomm uC Arithmetic extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
+  LLVM implements `version 0.7 of the Qualcomm uC Arithmetic extension 
spe

[clang] [llvm] [RISCV] Xqci Extensions v0.10.0 (PR #137881)

2025-04-29 Thread via cfe-commits

llvmbot wrote:




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

Author: Sam Elliott (lenary)


Changes

This updates all the extensions to their version in the v0.10.0 spec.

All changes from this version are already implemented or are not relevant to 
LLVM.

This change also alphabetises the lists of Xqci extensions, to make future 
checks easier, and removes irrelevant info from the usage docs.

---

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


5 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+7-7) 
- (modified) llvm/docs/RISCVUsage.rst (+20-20) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+73-73) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+9-9) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+13-13) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index b10850aadddc3..d96077e787960 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -200,21 +200,21 @@
 // CHECK-NEXT: ssctr1.0   'Ssctr' (Control Transfer 
Records Supervisor Level)
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqccmp   0.1   'Xqccmp' (Qualcomm 16-bit 
Push/Pop and Double Moves)
-// CHECK-NEXT: xqcia0.4   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
+// CHECK-NEXT: xqcia0.7   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
 // CHECK-NEXT: xqciac   0.3   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
 // CHECK-NEXT: xqcibi   0.2   'Xqcibi' (Qualcomm uC Branch 
Immediate Extension)
-// CHECK-NEXT: xqcibm   0.4   'Xqcibm' (Qualcomm uC Bit 
Manipulation Extension)
-// CHECK-NEXT: xqcicli  0.2   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
+// CHECK-NEXT: xqcibm   0.7   'Xqcibm' (Qualcomm uC Bit 
Manipulation Extension)
+// CHECK-NEXT: xqcicli  0.3   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
 // CHECK-NEXT: xqcicm   0.2   'Xqcicm' (Qualcomm uC 
Conditional Move Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
-// CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
-// CHECK-NEXT: xqciint  0.4   'Xqciint' (Qualcomm uC 
Interrupts Extension)
+// CHECK-NEXT: xqcicsr  0.3   'Xqcicsr' (Qualcomm uC CSR 
Extension)
+// CHECK-NEXT: xqciint  0.7   'Xqciint' (Qualcomm uC 
Interrupts Extension)
 // CHECK-NEXT: xqciio   0.1   'Xqciio' (Qualcomm uC 
External Input Output Extension)
 // CHECK-NEXT: xqcilb   0.2   'Xqcilb' (Qualcomm uC Long 
Branch Extension)
 // CHECK-NEXT: xqcili   0.2   'Xqcili' (Qualcomm uC Load 
Large Immediate Extension)
 // CHECK-NEXT: xqcilia  0.2   'Xqcilia' (Qualcomm uC Large 
Immediate Arithmetic Extension)
-// CHECK-NEXT: xqcilo   0.2   'Xqcilo' (Qualcomm uC Large 
Offset Load Store Extension)
-// CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
+// CHECK-NEXT: xqcilo   0.3   'Xqcilo' (Qualcomm uC Large 
Offset Load Store Extension)
+// CHECK-NEXT: xqcilsm  0.5   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
 // CHECK-NEXT: xqcisim  0.2   'Xqcisim' (Qualcomm uC 
Simulation Hint Extension)
 // CHECK-NEXT: xqcisls  0.2   'Xqcisls' (Qualcomm uC 
Scaled Load Store Extension)
 // CHECK-NEXT: xqcisync 0.2   'Xqcisync' (Qualcomm uC Sync 
Delay Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index d0689b779f551..49635273a036f 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -440,58 +440,58 @@ The current vendor extensions supported are:
   LLVM implements `version 0.1 of the 16-bit Push/Pop instructions and 
double-moves extension specification 
`__
 by Qualcomm. All instructions are prefixed with `qc.` as described in the 
specification.
 
 ``experimental-Xqcia``
-  LLVM implements `version 0.4 of the Qualcomm uC Arithmetic extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
+  LLVM implements `version 0.7 of the Qualcomm uC Arithmetic exten

[clang] [llvm] [clang] Add spir_kernel attribute (PR #137882)

2025-04-29 Thread Nick Sarnie via cfe-commits

https://github.com/sarnex created 
https://github.com/llvm/llvm-project/pull/137882

None

>From 48a7768a33434e16c795ab8d575beb91480146f1 Mon Sep 17 00:00:00 2001
From: "Sarnie, Nick" 
Date: Tue, 29 Apr 2025 14:40:43 -0700
Subject: [PATCH] [clang] Add spir_kernel attribute

Signed-off-by: Sarnie, Nick 
---
 clang/include/clang/Basic/Attr.td   |  8 
 clang/include/clang/Basic/Specifiers.h  |  1 +
 clang/lib/AST/ItaniumMangle.cpp |  1 +
 clang/lib/AST/Type.cpp  |  2 ++
 clang/lib/AST/TypePrinter.cpp   |  3 +++
 clang/lib/Basic/Targets/SPIR.h  |  6 --
 clang/lib/CodeGen/CGCall.cpp|  2 ++
 clang/lib/CodeGen/CGDebugInfo.cpp   |  2 ++
 clang/lib/CodeGen/Targets/SPIR.cpp  | 17 +
 clang/lib/Sema/SemaDeclAttr.cpp |  6 ++
 ...gma-attribute-supported-attributes-list.test |  1 +
 clang/test/Misc/spir-kernel-attr.c  | 10 ++
 llvm/include/llvm/BinaryFormat/Dwarf.def|  1 +
 .../llvm/DebugInfo/DWARF/DWARFTypePrinter.h |  3 +++
 14 files changed, 61 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Misc/spir-kernel-attr.c

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dcdcff8c46fe2..36946e7117e5f 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -472,7 +472,9 @@ def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetX86_64 : TargetArch<["x86_64"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
+def TargetSPIR : TargetArch<["spir", "spir64"]>;
 def TargetSPIRV : TargetArch<["spirv", "spirv32", "spirv64"]>;
+def TargetAnySPIR : TargetArch;
 def TargetWebAssembly : TargetArch<["wasm32", "wasm64"]>;
 def TargetNVPTX : TargetArch<["nvptx", "nvptx64"]>;
 def TargetWindows : TargetSpec {
@@ -1504,6 +1506,12 @@ def NVPTXKernel : InheritableAttr, 
TargetSpecificAttr {
   let Documentation = [Undocumented];
 }
 
+def SPIRKernel : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [Clang<"spir_kernel">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];
+}
+
 def HIPManaged : InheritableAttr {
   let Spellings = [GNU<"managed">, Declspec<"__managed__">];
   let Subjects = SubjectList<[Var]>;
diff --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index 491badcc804e7..f9a72f378490e 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -289,6 +289,7 @@ namespace clang {
 CC_AAPCS_VFP,  // __attribute__((pcs("aapcs-vfp")))
 CC_IntelOclBicc,   // __attribute__((intel_ocl_bicc))
 CC_SpirFunction,   // default for OpenCL functions on SPIR target
+CC_SpirKernel, // __attribute__((spir_kernel))
 CC_OpenCLKernel,   // inferred for OpenCL kernels
 CC_Swift,  // __attribute__((swiftcall))
 CC_SwiftAsync, // __attribute__((swiftasynccall))
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 33a8728728574..c16005ccaf51f 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3532,6 +3532,7 @@ StringRef 
CXXNameMangler::getCallingConvQualifierName(CallingConv CC) {
   case CC_AMDGPUKernelCall:
   case CC_IntelOclBicc:
   case CC_SpirFunction:
+  case CC_SpirKernel:
   case CC_OpenCLKernel:
   case CC_PreserveMost:
   case CC_PreserveAll:
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index d298f1cff73cf..ac33fb9bcad44 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3592,6 +3592,8 @@ StringRef FunctionType::getNameForCallConv(CallingConv 
CC) {
   case CC_AMDGPUKernelCall: return "amdgpu_kernel";
   case CC_IntelOclBicc: return "intel_ocl_bicc";
   case CC_SpirFunction: return "spir_function";
+  case CC_SpirKernel:
+return "spir_kernel";
   case CC_OpenCLKernel: return "opencl_kernel";
   case CC_Swift: return "swiftcall";
   case CC_SwiftAsync: return "swiftasynccall";
diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index cba1a2d98d660..5aa37ca9ec17f 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1115,6 +1115,9 @@ void TypePrinter::printFunctionAfter(const 
FunctionType::ExtInfo &Info,
 case CC_OpenCLKernel:
   // Do nothing. These CCs are not available as attributes.
   break;
+case CC_SpirKernel:
+  OS << " __attribute__((spir_kernel))";
+  break;
 case CC_Swift:
   OS << " __attribute__((swiftcall))";
   break;
diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h
index bf249e271a870..43c71a1aeb5d5 100644
--- a/clang/lib/Basic/Targets/SPIR.h
+++ b/clang/lib/Basic/Targets/SPIR.h
@@ -191,8 +191,10 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public 
TargetInfo {
 

[clang-tools-extra] [clang-doc] Add start and end line numbers (PR #137732)

2025-04-29 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/137732

>From 2d9fbe622785e052e848290f52e2cbbb9994d5fc Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 3 Apr 2025 17:07:01 -0400
Subject: [PATCH] [clang-doc] Add start and end line numbers

This patch adds start and end line numbers to clang-doc. Currently
clang-doc only encodes the start line numbers of records, struct, etc.
This patch adds start and end line number to clang-doc bitcode which is
passed to the generator. This will be used by the mustache backend to
generate line ranges.

Co-author: Paul Kirth 
---
 clang-tools-extra/clang-doc/BitcodeReader.cpp |  6 +-
 clang-tools-extra/clang-doc/BitcodeWriter.cpp | 12 ++--
 clang-tools-extra/clang-doc/HTMLGenerator.cpp | 11 +--
 clang-tools-extra/clang-doc/MDGenerator.cpp   |  6 +-
 clang-tools-extra/clang-doc/Mapper.cpp| 17 -
 clang-tools-extra/clang-doc/Mapper.h  |  3 +
 clang-tools-extra/clang-doc/Representation.h  | 24 +++
 clang-tools-extra/clang-doc/Serialize.cpp | 67 ---
 clang-tools-extra/clang-doc/Serialize.h   | 28 
 clang-tools-extra/clang-doc/YAMLGenerator.cpp |  2 +-
 .../unittests/clang-doc/BitcodeTest.cpp   | 26 +++
 .../unittests/clang-doc/ClangDocTest.cpp  |  4 +-
 .../unittests/clang-doc/HTMLGeneratorTest.cpp | 26 ---
 .../unittests/clang-doc/MDGeneratorTest.cpp   | 17 ++---
 .../unittests/clang-doc/MergeTest.cpp | 36 +-
 .../unittests/clang-doc/SerializeTest.cpp | 61 +
 .../unittests/clang-doc/YAMLGeneratorTest.cpp | 16 ++---
 17 files changed, 189 insertions(+), 173 deletions(-)

diff --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp 
b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index 92674c5507e74..f8e338eb7c6ed 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -79,7 +79,8 @@ static llvm::Error decodeRecord(const Record &R, 
std::optional &Field,
   if (R[0] > INT_MAX)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"integer too large to parse");
-  Field.emplace(static_cast(R[0]), Blob, static_cast(R[1]));
+  Field.emplace(static_cast(R[0]), static_cast(R[1]), Blob,
+static_cast(R[2]));
   return llvm::Error::success();
 }
 
@@ -130,7 +131,8 @@ static llvm::Error decodeRecord(const Record &R,
   if (R[0] > INT_MAX)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"integer too large to parse");
-  Field.emplace_back(static_cast(R[0]), Blob, static_cast(R[1]));
+  Field.emplace_back(static_cast(R[0]), static_cast(R[1]), Blob,
+ static_cast(R[2]));
   return llvm::Error::success();
 }
 
diff --git a/clang-tools-extra/clang-doc/BitcodeWriter.cpp 
b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
index 6545629f1c739..f0a445e606bff 100644
--- a/clang-tools-extra/clang-doc/BitcodeWriter.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
@@ -78,13 +78,16 @@ static void 
genLocationAbbrev(std::shared_ptr &Abbrev) {
   {// 0. Fixed-size integer (line number)
llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,
  BitCodeConstants::LineNumberSize),
-   // 1. Boolean (IsFileInRootDir)
+   // 1. Fixed-size integer (start line number)
+   llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,
+ BitCodeConstants::LineNumberSize),
+   // 2. Boolean (IsFileInRootDir)
llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,
  BitCodeConstants::BoolSize),
-   // 2. Fixed-size integer (length of the following string (filename))
+   // 3. Fixed-size integer (length of the following string (filename))
llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,
  BitCodeConstants::StringLengthSize),
-   // 3. The string blob
+   // 4. The string blob
llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob)});
 }
 
@@ -357,7 +360,8 @@ void ClangDocBitcodeWriter::emitRecord(const Location &Loc, 
RecordId ID) {
   if (!prepRecordData(ID, true))
 return;
   // FIXME: Assert that the line number is of the appropriate size.
-  Record.push_back(Loc.LineNumber);
+  Record.push_back(Loc.StartLineNumber);
+  Record.push_back(Loc.EndLineNumber);
   assert(Loc.Filename.size() < (1U << BitCodeConstants::StringLengthSize));
   Record.push_back(Loc.IsFileInRootDir);
   Record.push_back(Loc.Filename.size());
diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 6d061b33a67c1..4ad5ba29b28b8 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -455,7 +455,7 @@ static std::unique_ptr writeSourceFileRef(const 
ClangDocContext &CDCtx,
 
   if (!L.IsFileInRootDir && !CDCtx.RepositoryUrl)
 ret

[clang] 44d8aa8 - [clang][NFC] Convert `Parser::CachedInitKind` to scoped enum

2025-04-29 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-04-30T05:49:29+03:00
New Revision: 44d8aa8139e02e7b1642f284b32757ee446a88e6

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

LOG: [clang][NFC] Convert `Parser::CachedInitKind` to scoped enum

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseCXXInlineMethods.cpp
clang/lib/Parse/ParseDecl.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 4158712a258cc..28046993f847e 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -84,6 +84,8 @@ enum class ParsedTemplateKind {
   ExplicitInstantiation
 };
 
+enum class CachedInitKind { DefaultArgument, DefaultInitializer };
+
 /// Parser - This implements a parser for the C family of languages.  After
 /// parsing units of the grammar, productions are invoked to handle whatever 
has
 /// been read.
@@ -1646,11 +1648,6 @@ class Parser : public CodeCompletionHandler {
   void DeallocateParsedClasses(ParsingClass *Class);
   void PopParsingClass(Sema::ParsingClassState);
 
-  enum CachedInitKind {
-CIK_DefaultArgument,
-CIK_DefaultInitializer
-  };
-
   NamedDecl *ParseCXXInlineMethodDef(AccessSpecifier AS,
  const ParsedAttributesView &AccessAttrs,
  ParsingDeclarator &D,

diff  --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp 
b/clang/lib/Parse/ParseCXXInlineMethods.cpp
index 78eddfa8b3530..e76435d0e9de7 100644
--- a/clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp
@@ -266,7 +266,7 @@ void Parser::ParseCXXNonStaticMemberInitializer(Decl *VarD) 
{
 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/true);
   } else {
 // Consume everything up to (but excluding) the comma or semicolon.
-ConsumeAndStoreInitializer(Toks, CIK_DefaultInitializer);
+ConsumeAndStoreInitializer(Toks, CachedInitKind::DefaultInitializer);
   }
 
   // Store an artificial EOF token to ensure that we don't run off the end of
@@ -1238,7 +1238,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens 
&Toks,
 TPResult Result = TPResult::Error;
 ConsumeToken();
 switch (CIK) {
-case CIK_DefaultInitializer:
+case CachedInitKind::DefaultInitializer:
   Result = TryParseInitDeclaratorList();
   // If we parsed a complete, ambiguous init-declarator-list, this
   // is only syntactically-valid if it's followed by a semicolon.
@@ -1246,7 +1246,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens 
&Toks,
 Result = TPResult::False;
   break;
 
-case CIK_DefaultArgument:
+case CachedInitKind::DefaultArgument:
   bool InvalidAsDeclaration = false;
   Result = TryParseParameterDeclarationClause(
   &InvalidAsDeclaration, /*VersusTemplateArg=*/true);
@@ -1372,7 +1372,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens 
&Toks,
 // and return it.  Otherwise, this is a spurious RHS token, which we
 // consume and pass on to downstream code to diagnose.
 case tok::r_paren:
-  if (CIK == CIK_DefaultArgument)
+  if (CIK == CachedInitKind::DefaultArgument)
 return true; // End of the default argument.
   if (ParenCount && !IsFirstToken)
 return false;
@@ -1406,7 +1406,7 @@ bool Parser::ConsumeAndStoreInitializer(CachedTokens 
&Toks,
   ConsumeStringToken();
   break;
 case tok::semi:
-  if (CIK == CIK_DefaultInitializer)
+  if (CIK == CachedInitKind::DefaultInitializer)
 return true; // End of the default initializer.
   [[fallthrough]];
 default:

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 5f521935447e7..ec3e3ca29c637 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -8156,7 +8156,8 @@ void Parser::ParseParameterDeclarationClause(
   DefArgToks.reset(new CachedTokens);
 
   SourceLocation ArgStartLoc = NextToken().getLocation();
-  ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument);
+  ConsumeAndStoreInitializer(*DefArgToks,
+ CachedInitKind::DefaultArgument);
   Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
 ArgStartLoc);
 } else {



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


[clang] [flang] [llvm] [TargetVerifier][AMDGPU] Add TargetVerifier. (PR #123609)

2025-04-29 Thread via cfe-commits

jofrn wrote:

> I still can't figure it out why we need TargetVerifier.h and 
> TargetVerifier.cpp in the first place.

If we want to call TargetVerify from StandardInstrumentations.cpp, then we need 
it because this is a target-independent location to run TargetVerify in between 
each pass. Working on removing it at the moment.

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


[clang] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic` (PR #137849)

2025-04-29 Thread Yingwei Zheng via cfe-commits

https://github.com/dtcxzyw updated 
https://github.com/llvm/llvm-project/pull/137849

>From f1db3a540ec1383451955efab62b64ed8d180349 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Wed, 30 Apr 2025 01:26:41 +0800
Subject: [PATCH 1/2] [Clang][CodeGen] Check
 `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic`

---
 clang/lib/CodeGen/CGExprScalar.cpp   |  3 ++-
 .../test/CodeGen/catch-nullptr-and-nonzero-offset.c  | 12 
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 8dbbcdaef25d8..d214d2af52563 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4238,7 +4238,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
   else
 elemTy = CGF.ConvertTypeForMem(elementType);
 
-  if (CGF.getLangOpts().PointerOverflowDefined)
+  if (CGF.getLangOpts().PointerOverflowDefined ||
+  CGF.isUnderlyingBasePointerConstantNull(pointerOperand))
 return CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr");
 
   return CGF.EmitCheckedInBoundsGEP(
diff --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index 63b6db2c2adeb..c5ae3f8bcc368 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -431,6 +431,18 @@ char *void_ptr(void *base, unsigned long offset) {
   return base + offset;
 }
 
+int *constant_null_add(long offset) {
+  // CHECK: define{{.*}} ptr @constant_null_add(i64 noundef %[[OFFSET:.*]])
+  // CHECK-NEXT: [[ENTRY:.*]]:
+  // CHECK-NEXT:   %[[OFFSET_ADDR:.*]] = alloca i64, align 8
+  // CHECK-NEXT:   store i64 %[[OFFSET]], ptr %[[OFFSET_ADDR]], align 8
+  // CHECK-NEXT:   %[[OFFSET_RELOADED:.*]] = load i64, ptr %[[OFFSET_ADDR]], 
align 8
+  // CHECK-NEXT:   %[[ADD_PTR:.*]] = getelementptr i32, ptr null, i64 
%[[OFFSET_RELOADED]]
+  // CHECK-NEXT:   ret ptr %[[ADD_PTR]]
+#line 1800
+  return (int *)0 + offset;
+}
+
 #ifdef __cplusplus
 }
 #endif

>From 2796472ca05332419cade01afbea08d8f9446d76 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Wed, 30 Apr 2025 14:48:54 +0800
Subject: [PATCH 2/2] [Clang][CodeGen] Re-enable ubsan check

---
 clang/lib/CodeGen/CGExprScalar.cpp|  3 +-
 .../catch-nullptr-and-nonzero-offset.c| 38 ++-
 2 files changed, 31 insertions(+), 10 deletions(-)

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index d214d2af52563..96e48d65e8ace 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -4239,7 +4239,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
 elemTy = CGF.ConvertTypeForMem(elementType);
 
   if (CGF.getLangOpts().PointerOverflowDefined ||
-  CGF.isUnderlyingBasePointerConstantNull(pointerOperand))
+  (!CGF.SanOpts.has(SanitizerKind::PointerOverflow) &&
+   CGF.isUnderlyingBasePointerConstantNull(pointerOperand)))
 return CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr");
 
   return CGF.EmitCheckedInBoundsGEP(
diff --git a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c 
b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
index c5ae3f8bcc368..338f85f2d2fbd 100644
--- a/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
+++ b/clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
@@ -1,9 +1,9 @@
-// RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s
+// RUN: %clang_cc1 -x c -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow 
-fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void 
@__ubsan_handle_pointer_overflow" 
--check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow 
-fsanitize-recover=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu 
| FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" 
--check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
 // RUN: %clang_cc1 -x c -fsanitize=pointer-overflow 
-fsanitize-trap=pointer-overflow -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s -implicit-check-not="call void @__ubsan_handle_pointer_overflow" 
--check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
 
-// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s
+// RUN: %clang_cc1 -x c++ -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s --check-prefixes=CHECK,CHECK-NOSANITIZE
 // RUN: %clang_cc1 -x c++ -fsanitize=pointer-overflow 
-fno-sanitize-recover=pointer-overflow -emit-llvm %s -o - -triple 
x86_64-linux-gnu | FileCheck 

[clang] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic` (PR #137849)

2025-04-29 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> While we should omit inbounds, I think it would be good to not suppress the 
> sanitizer. If the sanitizer doesn't warn about it, then things will never get 
> better :(

Fixed.

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


[clang] 4bf93c0 - Thread Safety Analysis: Fix style

2025-04-29 Thread Marco Elver via cfe-commits

Author: Marco Elver
Date: 2025-04-30T08:49:15+02:00
New Revision: 4bf93c098c8b04a06f228b05732d691d0ce2babc

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

LOG: Thread Safety Analysis: Fix style

Comment fix and apply new clang-format style in
ScopedLockableFactEntry::unlock().

Factored out from https://github.com/llvm/llvm-project/pull/137133

NFC.

Added: 


Modified: 
clang/lib/Analysis/ThreadSafety.cpp

Removed: 




diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index f50c2adda4bc0..7e86af6b4a317 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -119,7 +119,7 @@ class FactEntry : public CapabilityExpr {
   /// Exclusive or shared.
   LockKind LKind : 8;
 
-  // How it was acquired.
+  /// How it was acquired.
   SourceKind Source : 8;
 
   /// Where it was acquired.
@@ -1011,8 +1011,8 @@ class ScopedLockableFactEntry : public FactEntry {
   SourceLocation loc, ThreadSafetyHandler *Handler) const {
 if (FSet.findLock(FactMan, Cp)) {
   FSet.removeLock(FactMan, Cp);
-  FSet.addLock(FactMan, std::make_unique(
-!Cp, LK_Exclusive, loc));
+  FSet.addLock(FactMan,
+   std::make_unique(!Cp, LK_Exclusive, 
loc));
 } else if (Handler) {
   SourceLocation PrevLoc;
   if (const FactEntry *Neg = FSet.findLock(FactMan, !Cp))



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


[clang] [Clang][Sema] Handle invalid variable template specialization whose type depends on itself (PR #134522)

2025-04-29 Thread Yanzuo Liu via cfe-commits


@@ -7594,6 +7594,54 @@ ASTContext::getCanonicalTemplateArgument(const 
TemplateArgument &Arg) const {
   llvm_unreachable("Unhandled template argument kind");
 }
 
+bool ASTContext::isSameTemplateArgument(const TemplateArgument &Arg1,
+const TemplateArgument &Arg2) const {

zwuis wrote:

Oops. I didn't know that `isSameTemplateArg` in SemaTemplateDeduction.cpp was 
changed and I need to rebase. Thanks for your reminder.

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


[clang] e8c684a - [clang][NFC] Convert `Parser::ParenParseOption` to scoped enum

2025-04-29 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-04-30T07:01:01+03:00
New Revision: e8c684a0e4299077904892d11b1906f8e660eb01

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

LOG: [clang][NFC] Convert `Parser::ParenParseOption` to scoped enum

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 5248cb2219d73..01862e4534664 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -107,6 +107,15 @@ enum class TypeCastState { NotTypeCast = 0, MaybeTypeCast, 
IsTypeCast };
 /// Control what ParseCastExpression will parse.
 enum class CastParseKind { AnyCastExpr = 0, UnaryExprOnly, PrimaryExprOnly };
 
+/// ParenParseOption - Control what ParseParenExpression will parse.
+enum class ParenParseOption {
+  SimpleExpr,  // Only parse '(' expression ')'
+  FoldExpr,// Also allow fold-expression 
+  CompoundStmt,// Also allow '(' compound-statement ')'
+  CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}'
+  CastExpr // Also allow '(' type-name ')' 
+};
+
 /// Parser - This implements a parser for the C family of languages.  After
 /// parsing units of the grammar, productions are invoked to handle whatever 
has
 /// been read.
@@ -1951,14 +1960,6 @@ class Parser : public CodeCompletionHandler {
   /// used for misc language extensions.
   bool ParseSimpleExpressionList(SmallVectorImpl &Exprs);
 
-  /// ParenParseOption - Control what ParseParenExpression will parse.
-  enum ParenParseOption {
-SimpleExpr,  // Only parse '(' expression ')'
-FoldExpr,// Also allow fold-expression 
-CompoundStmt,// Also allow '(' compound-statement ')'
-CompoundLiteral, // Also allow '(' type-name ')' '{' ... '}'
-CastExpr // Also allow '(' type-name ')' 
-  };
   ExprResult ParseParenExpression(ParenParseOption &ExprType,
 bool stopIfCastExpr,
 bool isTypeCast,

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 8c821ef0c95bf..a5dd08529cf37 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -1105,7 +1105,7 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
 ParenExprType = ParenParseOption::CastExpr;
 break;
   case CastParseKind::PrimaryExprOnly:
-ParenExprType = FoldExpr;
+ParenExprType = ParenParseOption::FoldExpr;
 break;
 }
 ParsedType CastTy;
@@ -1121,17 +1121,19 @@ ExprResult Parser::ParseCastExpression(CastParseKind 
ParseKind,
   return Res;
 
 switch (ParenExprType) {
-case SimpleExpr:   break;// Nothing else to do.
-case CompoundStmt: break;  // Nothing else to do.
-case CompoundLiteral:
+case ParenParseOption::SimpleExpr:
+  break; // Nothing else to do.
+case ParenParseOption::CompoundStmt:
+  break; // Nothing else to do.
+case ParenParseOption::CompoundLiteral:
   // We parsed '(' type-name ')' '{' ... '}'.  If any suffixes of
   // postfix-expression exist, parse them now.
   break;
-case CastExpr:
+case ParenParseOption::CastExpr:
   // We have parsed the cast-expression and no postfix-expr pieces are
   // following.
   return Res;
-case FoldExpr:
+case ParenParseOption::FoldExpr:
   // We only parsed a fold-expression. There might be postfix-expr pieces
   // afterwards; parse them now.
   break;
@@ -2528,7 +2530,7 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token 
&OpTok,
 // type-name, or it is a unary-expression that starts with a compound
 // literal, or starts with a primary-expression that is a parenthesized
 // expression.
-ParenParseOption ExprType = CastExpr;
+ParenParseOption ExprType = ParenParseOption::CastExpr;
 SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
 
 Operand = ParseParenExpression(ExprType, true/*stopIfCastExpr*/,
@@ -2537,7 +2539,7 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token 
&OpTok,
 
 // If ParseParenExpression parsed a '(typename)' sequence only, then this 
is
 // a type.
-if (ExprType == CastExpr) {
+if (ExprType == ParenParseOption::CastExpr) {
   isCastExpr = true;
   return ExprEmpty();
 }
@@ -3095,7 +3097,7 @@ Parser::ParseParenExpression(ParenParseOption &ExprType, 
bool stopIfCastExpr,
 cutOffParsing();
 Actions.CodeCompletion().CodeCompleteExpression(
 getCurScope(), PreferredType.get(Tok.getLocation()),
-/*IsParenthesized=*/ExprT

[clang] [clang-format] Add OneLineFormatOffRegex option (PR #137577)

2025-04-29 Thread via cfe-commits

dyung wrote:

@owenca your change seems to be causing a unit test failure in 
CodeGenTest.TestNonAlterTest which is impacting quite a few bots. Can you take 
a look and revert if you need time to investigate?

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


[clang] 4075a36 - [clang][NFC] Convert `Parser::CastParseKind` to scoped enum

2025-04-29 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-04-30T06:48:37+03:00
New Revision: 4075a3698a3fdda3a77ce2456e3bfefbc0f0c56e

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

LOG: [clang][NFC] Convert `Parser::CastParseKind` to scoped enum

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseExpr.cpp
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Parse/ParseOpenMP.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 3a5e42e60fae8..5248cb2219d73 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -104,6 +104,9 @@ enum class ObjCTypeQual {
 /// TypeCastState - State whether an expression is or may be a type cast.
 enum class TypeCastState { NotTypeCast = 0, MaybeTypeCast, IsTypeCast };
 
+/// Control what ParseCastExpression will parse.
+enum class CastParseKind { AnyCastExpr = 0, UnaryExprOnly, PrimaryExprOnly };
+
 /// Parser - This implements a parser for the C family of languages.  After
 /// parsing units of the grammar, productions are invoked to handle whatever 
has
 /// been read.
@@ -1888,14 +1891,7 @@ class Parser : public CodeCompletionHandler {
 
   ExprResult ParseExpressionWithLeadingExtension(SourceLocation ExtLoc);
 
-  ExprResult ParseRHSOfBinaryExpression(ExprResult LHS,
-prec::Level MinPrec);
-  /// Control what ParseCastExpression will parse.
-  enum CastParseKind {
-AnyCastExpr = 0,
-UnaryExprOnly,
-PrimaryExprOnly
-  };
+  ExprResult ParseRHSOfBinaryExpression(ExprResult LHS, prec::Level MinPrec);
 
   bool isRevertibleTypeTrait(const IdentifierInfo *Id,
  clang::tok::TokenKind *Kind = nullptr);

diff  --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 2013386a1ea53..8c821ef0c95bf 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -157,7 +157,7 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation 
ExtLoc) {
 // Silence extension warnings in the sub-expression
 ExtensionRAIIObject O(Diags);
 
-LHS = ParseCastExpression(AnyCastExpr);
+LHS = ParseCastExpression(CastParseKind::AnyCastExpr);
   }
 
   if (!LHS.isInvalid())
@@ -181,9 +181,9 @@ ExprResult Parser::ParseAssignmentExpression(TypeCastState 
isTypeCast) {
   if (Tok.is(tok::kw_co_yield))
 return ParseCoyieldExpression();
 
-  ExprResult LHS = ParseCastExpression(AnyCastExpr,
-   /*isAddressOfOperand=*/false,
-   isTypeCast);
+  ExprResult LHS =
+  ParseCastExpression(CastParseKind::AnyCastExpr,
+  /*isAddressOfOperand=*/false, isTypeCast);
   return ParseRHSOfBinaryExpression(LHS, prec::Assignment);
 }
 
@@ -195,8 +195,9 @@ ExprResult Parser::ParseConditionalExpression() {
 return ExprError();
   }
 
-  ExprResult LHS = ParseCastExpression(
-  AnyCastExpr, /*isAddressOfOperand=*/false, TypeCastState::NotTypeCast);
+  ExprResult LHS = ParseCastExpression(CastParseKind::AnyCastExpr,
+   /*isAddressOfOperand=*/false,
+   TypeCastState::NotTypeCast);
   return ParseRHSOfBinaryExpression(LHS, prec::Conditional);
 }
 
@@ -227,7 +228,8 @@ 
Parser::ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast) {
  Sema::ExpressionEvaluationContext::ConstantEvaluated &&
  "Call this function only if your ExpressionEvaluationContext is "
  "already ConstantEvaluated");
-  ExprResult LHS(ParseCastExpression(AnyCastExpr, false, isTypeCast));
+  ExprResult LHS(
+  ParseCastExpression(CastParseKind::AnyCastExpr, false, isTypeCast));
   ExprResult Res(ParseRHSOfBinaryExpression(LHS, prec::Conditional));
   return Actions.ActOnConstantExpression(Res);
 }
@@ -273,8 +275,8 @@ ExprResult Parser::ParseArrayBoundExpression() {
 ExprResult Parser::ParseCaseExpression(SourceLocation CaseLoc) {
   EnterExpressionEvaluationContext ConstantEvaluated(
   Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated);
-  ExprResult LHS(
-  ParseCastExpression(AnyCastExpr, false, TypeCastState::NotTypeCast));
+  ExprResult LHS(ParseCastExpression(CastParseKind::AnyCastExpr, false,
+ TypeCastState::NotTypeCast));
   ExprResult Res(ParseRHSOfBinaryExpression(LHS, prec::Conditional));
   return Actions.ActOnCaseExpr(CaseLoc, Res);
 }
@@ -288,7 +290,7 @@ ExprResult Parser::ParseCaseExpression(SourceLocation 
CaseLoc) {
 ExprResult Parser::ParseConstraintExpression() {
   EnterExpressionEvaluationContext ConstantEvaluated(
   Actions, Sema::ExpressionEvaluationContext::Unevaluated);
-  ExprResult 

[clang] [clang-format] Add OneLineFormatOffRegex option (PR #137577)

2025-04-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-aarch64-sve2-vla-2stage` running on `linaro-g4-01` while building 
`clang` at step 12 "ninja check 2".

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


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

```
Step 12 (ninja check 2) failure: stage 2 checked (failure)
 TEST 'Clang-Unit :: ./AllClangUnitTests/48/51' FAILED 

Script(shard):
--
GTEST_OUTPUT=json:/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla-2stage/stage2/tools/clang/unittests/./AllClangUnitTests-Clang-Unit-3551089-48-51.json
 GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=51 GTEST_SHARD_INDEX=48 
/home/tcwg-buildbot/worker/clang-aarch64-sve2-vla-2stage/stage2/tools/clang/unittests/./AllClangUnitTests
--

Note: This is test shard 49 of 51.
[==] Running 505 tests from 116 test suites.
[--] Global test environment set-up.
[--] 1 test from DirectoryEntryTest
[ RUN  ] DirectoryEntryTest.isSameRef
[   OK ] DirectoryEntryTest.isSameRef (0 ms)
[--] 1 test from DirectoryEntryTest (0 ms total)

[--] 1 test from MinimizeSourceToDependencyDirectivesTest
[ RUN  ] MinimizeSourceToDependencyDirectivesTest.EmptyHash
[   OK ] MinimizeSourceToDependencyDirectivesTest.EmptyHash (0 ms)
[--] 1 test from MinimizeSourceToDependencyDirectivesTest (0 ms total)

[--] 1 test from HeaderMapTest
[ RUN  ] HeaderMapTest.lookupFilename
[   OK ] HeaderMapTest.lookupFilename (0 ms)
[--] 1 test from HeaderMapTest (0 ms total)

[--] 1 test from ModuleDeclStateTest
[ RUN  ] ModuleDeclStateTest.ModuleImplementationPartition
[   OK ] ModuleDeclStateTest.ModuleImplementationPartition (0 ms)
[--] 1 test from ModuleDeclStateTest (0 ms total)

[--] 1 test from ToolChainTest
[ RUN  ] ToolChainTest.VFSGCCInstallation
[   OK ] ToolChainTest.VFSGCCInstallation (1 ms)
[--] 1 test from ToolChainTest (1 ms total)

[--] 1 test from MultilibTest
[ RUN  ] MultilibTest.SelectHard
[   OK ] MultilibTest.SelectHard (0 ms)
[--] 1 test from MultilibTest (0 ms total)

[--] 2 tests from ExprMutationAnalyzerTest
[ RUN  ] ExprMutationAnalyzerTest.FollowRefModified
[   OK ] ExprMutationAnalyzerTest.FollowRefModified (7 ms)
[ RUN  ] ExprMutationAnalyzerTest.PointeeMutatedByPassAsArgument
[   OK ] ExprMutationAnalyzerTest.PointeeMutatedByPassAsArgument (5 ms)
[--] 2 tests from ExprMutationAnalyzerTest (12 ms total)

[--] 1 test from ASTOpsTest
[ RUN  ] ASTOpsTest.ReferencedDeclsOnUnionInitList
[   OK ] ASTOpsTest.ReferencedDeclsOnUnionInitList (2 ms)
[--] 1 test from ASTOpsTest (2 ms total)
...

```



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


[clang] 5f22b84 - [clang][NFC] Convert `Parser::IfExistsBehavior` to scoped enum

2025-04-29 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-04-30T07:08:47+03:00
New Revision: 5f22b84b653e9b76a21ea4ea2ae864173242f237

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

LOG: [clang][NFC] Convert `Parser::IfExistsBehavior` to scoped enum

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseInit.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 01862e4534664..5b68447274c70 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -116,6 +116,18 @@ enum class ParenParseOption {
   CastExpr // Also allow '(' type-name ')' 
 };
 
+/// Describes the behavior that should be taken for an __if_exists
+/// block.
+enum class IfExistsBehavior {
+  /// Parse the block; this code is always used.
+  Parse,
+  /// Skip the block entirely; this code is never used.
+  Skip,
+  /// Parse the block as a dependent block, which may be used in
+  /// some template instantiations but not others.
+  Dependent
+};
+
 /// Parser - This implements a parser for the C family of languages.  After
 /// parsing units of the grammar, productions are invoked to handle whatever 
has
 /// been read.
@@ -2225,18 +2237,6 @@ class Parser : public CodeCompletionHandler {
  SourceLocation *TrailingElseLoc,
  ParsedAttributes &Attrs);
 
-  /// Describes the behavior that should be taken for an __if_exists
-  /// block.
-  enum IfExistsBehavior {
-/// Parse the block; this code is always used.
-IEB_Parse,
-/// Skip the block entirely; this code is never used.
-IEB_Skip,
-/// Parse the block as a dependent block, which may be used in
-/// some template instantiations but not others.
-IEB_Dependent
-  };
-
   /// Describes the condition of a Microsoft __if_exists or
   /// __if_not_exists block.
   struct IfExistsCondition {

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 662d5e1e031ec..9308c4ade3da6 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -5289,17 +5289,17 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration(
   }
 
   switch (Result.Behavior) {
-  case IEB_Parse:
+  case IfExistsBehavior::Parse:
 // Parse the declarations below.
 break;
 
-  case IEB_Dependent:
+  case IfExistsBehavior::Dependent:
 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
 << Result.IsIfExists;
 // Fall through to skip.
 [[fallthrough]];
 
-  case IEB_Skip:
+  case IfExistsBehavior::Skip:
 Braces.skipToEnd();
 return;
   }

diff  --git a/clang/lib/Parse/ParseInit.cpp b/clang/lib/Parse/ParseInit.cpp
index 86696329ea02e..a4ac692f429f7 100644
--- a/clang/lib/Parse/ParseInit.cpp
+++ b/clang/lib/Parse/ParseInit.cpp
@@ -595,17 +595,17 @@ bool 
Parser::ParseMicrosoftIfExistsBraceInitializer(ExprVector &InitExprs,
   }
 
   switch (Result.Behavior) {
-  case IEB_Parse:
+  case IfExistsBehavior::Parse:
 // Parse the declarations below.
 break;
 
-  case IEB_Dependent:
+  case IfExistsBehavior::Dependent:
 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
   << Result.IsIfExists;
 // Fall through to skip.
 [[fallthrough]];
 
-  case IEB_Skip:
+  case IfExistsBehavior::Skip:
 Braces.skipToEnd();
 return false;
   }

diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index f50a245621185..bdd02469a85bb 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -2825,7 +2825,7 @@ void Parser::ParseMicrosoftIfExistsStatement(StmtVector 
&Stmts) {
   // This is not the same behavior as Visual C++, which don't treat this as a
   // compound statement, but for Clang's type checking we can't have anything
   // inside these braces escaping to the surrounding code.
-  if (Result.Behavior == IEB_Dependent) {
+  if (Result.Behavior == IfExistsBehavior::Dependent) {
 if (!Tok.is(tok::l_brace)) {
   Diag(Tok, diag::err_expected) << tok::l_brace;
   return;
@@ -2852,14 +2852,14 @@ void Parser::ParseMicrosoftIfExistsStatement(StmtVector 
&Stmts) {
   }
 
   switch (Result.Behavior) {
-  case IEB_Parse:
+  case IfExistsBehavior::Parse:
 // Parse the statements below.
 break;
 
-  case IEB_Dependent:
+  case IfExistsBehavior::Dependent:
 llvm_unreachable("Dependent case handled above");
 
-  case IEB_Skip:
+  case IfExistsBehavior::Skip:
 Braces.skipToEnd();
 return;
   }

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 183181fd3bac7..a610e56760328 100644
--- a/clang/

[clang] [CIR] Upstream global initialization for VectorType (PR #137511)

2025-04-29 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/137511

>From 68dbe83ed57bb6da0cc3a5a61eec35ef63914317 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 26 Apr 2025 18:43:00 +0200
Subject: [PATCH 1/3] [CIR] Upstream global initialization for VectorType

---
 .../include/clang/CIR/Dialect/IR/CIRAttrs.td  | 33 ++-
 clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp  | 23 -
 clang/lib/CIR/Dialect/IR/CIRAttrs.cpp | 88 +++
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp   |  2 +-
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 40 +++--
 clang/test/CIR/CodeGen/vector-ext.cpp | 11 ++-
 clang/test/CIR/CodeGen/vector.cpp |  9 ++
 7 files changed, 196 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index fb3f7b1632436..624a82762ab18 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -204,7 +204,7 @@ def ConstArrayAttr : CIR_Attr<"ConstArray", "const_array", 
[TypedAttrInterface]>
 }]>
   ];
 
-  // Printing and parsing available in CIRDialect.cpp
+  // Printing and parsing available in CIRAttrs.cpp
   let hasCustomAssemblyFormat = 1;
 
   // Enable verifier.
@@ -215,6 +215,37 @@ def ConstArrayAttr : CIR_Attr<"ConstArray", "const_array", 
[TypedAttrInterface]>
   }];
 }
 
+//===--===//
+// ConstVectorAttr
+//===--===//
+
+def ConstVectorAttr : CIR_Attr<"ConstVector", "const_vector",
+   [TypedAttrInterface]> {
+  let summary = "A constant vector from ArrayAttr";
+  let description = [{
+A CIR vector attribute is an array of literals of the specified attribute
+types.
+  }];
+
+  let parameters = (ins AttributeSelfTypeParameter<"">:$type,
+   "mlir::ArrayAttr":$elts);
+
+  // Define a custom builder for the type; that removes the need to pass in an
+  // MLIRContext instance, as it can be inferred from the `type`.
+  let builders = [
+AttrBuilderWithInferredContext<(ins "cir::VectorType":$type,
+   "mlir::ArrayAttr":$elts), [{
+  return $_get(type.getContext(), type, elts);
+}]>
+  ];
+
+  // Printing and parsing available in CIRAttrs.cpp
+  let hasCustomAssemblyFormat = 1;
+
+  // Enable verifier.
+  let genVerifyDecl = 1;
+}
+
 
//===--===//
 // ConstPtrAttr
 
//===--===//
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
index b9a74e90a5960..6e5c7b8fb51f8 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprConstant.cpp
@@ -373,8 +373,27 @@ mlir::Attribute ConstantEmitter::tryEmitPrivate(const 
APValue &value,
  elements, typedFiller);
   }
   case APValue::Vector: {
-cgm.errorNYI("ConstExprEmitter::tryEmitPrivate vector");
-return {};
+const QualType elementType =
+destType->castAs()->getElementType();
+const unsigned numElements = value.getVectorLength();
+
+SmallVector elements;
+elements.reserve(numElements);
+
+for (unsigned i = 0; i < numElements; ++i) {
+  const mlir::Attribute element =
+  tryEmitPrivateForMemory(value.getVectorElt(i), elementType);
+  if (!element)
+return {};
+  elements.push_back(element);
+}
+
+const auto desiredVecTy =
+mlir::cast(cgm.convertType(destType));
+
+return cir::ConstVectorAttr::get(
+desiredVecTy,
+mlir::ArrayAttr::get(cgm.getBuilder().getContext(), elements));
   }
   case APValue::MemberPointer: {
 cgm.errorNYI("ConstExprEmitter::tryEmitPrivate member pointer");
diff --git a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp 
b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
index a940651f1e9eb..fff849b141562 100644
--- a/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRAttrs.cpp
@@ -299,6 +299,94 @@ void ConstArrayAttr::print(AsmPrinter &printer) const {
   printer << ">";
 }
 
+//===--===//
+// CIR ConstVectorAttr
+//===--===//
+
+LogicalResult cir::ConstVectorAttr::verify(
+function_ref<::mlir::InFlightDiagnostic()> emitError, Type type,
+ArrayAttr elts) {
+
+  if (!mlir::isa(type)) {
+return emitError() << "type of cir::ConstVectorAttr is not a "
+  "cir::VectorType: "
+   << type;
+  }
+
+  const auto vecType = mlir::cast(type);
+
+  if (vecType.getSize() != elts.size()) {
+return emitError()
+   << "number of constant elem

[clang] 78a1d92 - [clang][NFC] Convert `Parser::TentativeCXXTypeIdContext` to scoped enum

2025-04-29 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-04-30T07:14:31+03:00
New Revision: 78a1d92870b596c67ee301b96d3a7864bafaab92

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

LOG: [clang][NFC] Convert `Parser::TentativeCXXTypeIdContext` to scoped enum

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseTemplate.cpp
clang/lib/Parse/ParseTentative.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index 5b68447274c70..1c31ec7c89715 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -128,6 +128,16 @@ enum class IfExistsBehavior {
   Dependent
 };
 
+/// Specifies the context in which type-id/expression
+/// disambiguation will occur.
+enum class TentativeCXXTypeIdContext {
+  InParens,
+  Unambiguous,
+  AsTemplateArgument,
+  InTrailingReturnType,
+  AsGenericSelectionArgument,
+};
+
 /// Parser - This implements a parser for the C family of languages.  After
 /// parsing units of the grammar, productions are invoked to handle whatever 
has
 /// been read.
@@ -2628,22 +2638,12 @@ class Parser : public CodeCompletionHandler {
   DeclSpec::FriendSpecified IsFriend = DeclSpec::FriendSpecified::No,
   const ParsedTemplateInfo *TemplateInfo = nullptr);
 
-  /// Specifies the context in which type-id/expression
-  /// disambiguation will occur.
-  enum TentativeCXXTypeIdContext {
-TypeIdInParens,
-TypeIdUnambiguous,
-TypeIdAsTemplateArgument,
-TypeIdInTrailingReturnType,
-TypeIdAsGenericSelectionArgument,
-  };
-
   /// isTypeIdInParens - Assumes that a '(' was parsed and now we want to know
   /// whether the parens contain an expression or a type-id.
   /// Returns true for a type-id and false for an expression.
   bool isTypeIdInParens(bool &isAmbiguous) {
 if (getLangOpts().CPlusPlus)
-  return isCXXTypeId(TypeIdInParens, isAmbiguous);
+  return isCXXTypeId(TentativeCXXTypeIdContext::InParens, isAmbiguous);
 isAmbiguous = false;
 return isTypeSpecifierQualifier();
   }
@@ -2662,7 +2662,8 @@ class Parser : public CodeCompletionHandler {
   bool isTypeIdForGenericSelection() {
 if (getLangOpts().CPlusPlus) {
   bool isAmbiguous;
-  return isCXXTypeId(TypeIdAsGenericSelectionArgument, isAmbiguous);
+  return isCXXTypeId(TentativeCXXTypeIdContext::AsGenericSelectionArgument,
+ isAmbiguous);
 }
 return isTypeSpecifierQualifier();
   }
@@ -2673,7 +2674,7 @@ class Parser : public CodeCompletionHandler {
   bool isTypeIdUnambiguously() {
 if (getLangOpts().CPlusPlus) {
   bool isAmbiguous;
-  return isCXXTypeId(TypeIdUnambiguous, isAmbiguous);
+  return isCXXTypeId(TentativeCXXTypeIdContext::Unambiguous, isAmbiguous);
 }
 return isTypeSpecifierQualifier();
   }

diff  --git a/clang/lib/Parse/ParseTemplate.cpp 
b/clang/lib/Parse/ParseTemplate.cpp
index 34c68ae9ccea6..dbe5e94747c67 100644
--- a/clang/lib/Parse/ParseTemplate.cpp
+++ b/clang/lib/Parse/ParseTemplate.cpp
@@ -1506,7 +1506,7 @@ ParsedTemplateArgument Parser::ParseTemplateArgument() {
 Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated,
 /*LambdaContextDecl=*/nullptr,
 
/*ExprContext=*/Sema::ExpressionEvaluationContextRecord::EK_TemplateArgument);
-  if (isCXXTypeId(TypeIdAsTemplateArgument)) {
+  if (isCXXTypeId(TentativeCXXTypeIdContext::AsTemplateArgument)) {
 TypeResult TypeArg = ParseTypeName(
 /*Range=*/nullptr, DeclaratorContext::TemplateArg);
 return Actions.ActOnTemplateTypeArgument(TypeArg);

diff  --git a/clang/lib/Parse/ParseTentative.cpp 
b/clang/lib/Parse/ParseTentative.cpp
index 0994ff126e7e5..ce538532dc4f4 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -607,23 +607,23 @@ Parser::isCXXConditionDeclarationOrInitStatement(bool 
CanBeInitStatement,
 return ConditionOrInitStatement::Expression;
 }
 
-  /// Determine whether the next set of tokens contains a type-id.
-  ///
-  /// The context parameter states what context we're parsing right
-  /// now, which affects how this routine copes with the token
-  /// following the type-id. If the context is TypeIdInParens, we have
-  /// already parsed the '(' and we will cease lookahead when we hit
-  /// the corresponding ')'. If the context is
-  /// TypeIdAsTemplateArgument, we've already parsed the '<' or ','
-  /// before this template argument, and will cease lookahead when we
-  /// hit a '>', '>>' (in C++0x), or ','; or, in C++0x, an ellipsis immediately
-  /// preceding such. Returns true for a type-id and false for an expression.
-  /// If during the disambiguation process a parsing error is encountered,
-  /// the function returns true to let th

[clang] [clang-format] Add OneLineFormatOffRegex option (PR #137577)

2025-04-29 Thread Owen Pan via cfe-commits

owenca wrote:

@dyung I don't see anything in this patch could cause a failure in CodGen 
tests. Have you verified it e.g. by running the tests on 
f1750300aad0e49383cd4b206e2354f1300a40a8?

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


[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)

2025-04-29 Thread Urvi Rav via cfe-commits

https://github.com/ravurvi20 updated 
https://github.com/llvm/llvm-project/pull/128640

>From 6ebd5991788608fbd104ea9c23230912044462d3 Mon Sep 17 00:00:00 2001
From: Urvi Rav 
Date: Tue, 25 Feb 2025 00:49:07 -0600
Subject: [PATCH 1/6] default clause replaced by otherwise clause for
 metadirective

---
 .../clang/Basic/DiagnosticParseKinds.td   |  4 ++
 clang/lib/Parse/ParseOpenMP.cpp   | 20 ++
 clang/test/OpenMP/metadirective_messages.cpp  | 61 +--
 3 files changed, 68 insertions(+), 17 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c513dab810d1f..4b8449e9ee9b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1657,6 +1657,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">;
 def err_omp_missing_comma : Error< "missing ',' after %0">;
 def err_omp_expected_context_selector
 : Error<"expected valid context selector in %0">;
+def err_omp_unknown_clause
+: Error<"unknown clause '%0' in %1">;
+def warn_omp_default_deprecated : Warning<"'default' clause for"
+  " 'metadirective' is deprecated; use 'otherwise' instead">, 
InGroup;
 def err_omp_requires_out_inout_depend_type : Error<
   "reserved locator 'omp_all_memory' requires 'out' or 'inout' "
   "dependency types">;
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 42e6aac681c1c..3b86847e937a2 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2759,6 +2759,19 @@ StmtResult 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(
   OpenMPClauseKind CKind = Tok.isAnnotation()
? OMPC_unknown
: getOpenMPClauseKind(PP.getSpelling(Tok));
+  // Check if the clause is unrecognized.
+  if (getLangOpts().OpenMP < 52 &&
+  (CKind == OMPC_unknown || CKind == OMPC_otherwise)) {
+Diag(Tok, diag::err_omp_unknown_clause)
+<< PP.getSpelling(Tok) << "metadirective";
+  }
+  if (getLangOpts().OpenMP >= 52 && CKind == OMPC_unknown) {
+Diag(Tok, diag::err_omp_unknown_clause)
+<< PP.getSpelling(Tok) << "metadirective";
+  }
+  if (CKind == OMPC_default && getLangOpts().OpenMP >= 52) {
+Diag(Tok, diag::warn_omp_default_deprecated);
+  }
   SourceLocation Loc = ConsumeToken();
 
   // Parse '('.
@@ -2785,6 +2798,13 @@ StmtResult 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(
   return Directive;
 }
   }
+  if (CKind == OMPC_otherwise) {
+// Check for 'otherwise' keyword.
+if (Tok.is(tok::identifier) &&
+Tok.getIdentifierInfo()->getName() == "otherwise") {
+  ConsumeToken(); // Consume 'otherwise'
+}
+  }
   // Skip Directive for now. We will parse directive in the second 
iteration
   int paren = 0;
   while (Tok.isNot(tok::r_paren) || paren != 0) {
diff --git a/clang/test/OpenMP/metadirective_messages.cpp 
b/clang/test/OpenMP/metadirective_messages.cpp
index 7fce9fa446058..40ea37845fdff 100644
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ b/clang/test/OpenMP/metadirective_messages.cpp
@@ -2,21 +2,48 @@
 
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify -fopenmp-simd -x c++ 
-std=c++14 -fexceptions -fcxx-exceptions %s
 
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify=expected,omp52 -fopenmp 
-fopenmp-version=52 -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo() {
-#pragma omp metadirective // expected-error {{expected expression}}
-  ;
-#pragma omp metadirective when() // expected-error {{expected valid context 
selector in when clause}} expected-error {{expected expression}} 
expected-warning {{expected identifier or string literal describing a context 
set; set skipped}} expected-note {{context set options are: 'construct' 
'device' 'target_device' 'implementation' 'user'}} expected-note {{the ignored 
set spans until here}}
-  ;
-#pragma omp metadirective when(device{}) // expected-warning {{expected '=' 
after the context set name "device"; '=' assumed}} expected-warning {{expected 
identifier or string literal describing a context selector; selector skipped}} 
expected-note {{context selector options are: 'kind' 'arch' 'isa'}} 
expected-note {{the ignored selector spans until here}} expected-error 
{{expected valid context selector in when clause}} expected-error {{expected 
expression}}
-  ;
-#pragma omp metadirective when(device{arch(nvptx)}) // expected-error 
{{missing ':' in when clause}} expected-error {{expected expression}} 
expected-warning {{expected '=' after the context set name "device"; '=' 
assumed}}
-  ;
-#pragma omp metadirective when(device{arch(nvptx)}: ) default() // 
expected-warning {{expected '=' after the context set name "device"; '=' 
assumed}}
-  ;
-#pragma omp metadirective when(device

[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-04-29 Thread Jiuyang Liu via cfe-commits


@@ -1197,6 +1197,73 @@ def HasVendorXSfvcp : 
Predicate<"Subtarget->hasVendorXSfvcp()">,
   AssemblerPredicate<(all_of FeatureVendorXSfvcp),
   "'XSfvcp' (SiFive Custom Vector Coprocessor 
Interface Instructions)">;
 
+def FeatureVendorXSfmmbase
+: RISCVExtension<0, 6,
+ "All non arithmetic instructions for all TEWs and 
sf.vtzero",
+ [FeatureStdExtZve32x]>;
+def HasVendorXSfmmbase : Predicate<"Subtarget->hasVendorXSfmmbase()">,
+ AssemblerPredicate<(all_of FeatureVendorXSfmmbase),
+ "'XSfmmbase' (All non arithmetic instructions for 
all TEWs and sf.vtzero)">;
+
+def FeatureVendorXSfmm32a8f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: fp8",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+def HasVendorXSfmm32a8f : Predicate<"Subtarget->hasVendorXSfmm32a8f()">,
+  AssemblerPredicate<(all_of FeatureVendorXSfmm32a8f),
+  "'XSfmm32a8f' (TEW=32-bit accumulation, operands 
- float: fp8)">;
+
+def FeatureVendorXSfmm32a16f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: 16b, widen=2 
(IEEE, BF)",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+
+def FeatureVendorXSfmm32a32f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: 32b",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+
+def FeatureVendorXSfmm32a8i
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - int: 8b",
+ [FeatureVendorXSfmmbase]>;
+def HasVendorXSfmm32a8i : Predicate<"Subtarget->hasVendorXSfmm32a8i()">,
+  AssemblerPredicate<(all_of FeatureVendorXSfmm32a8i),
+  "'XSfmm32a8i' (TEW=32-bit accumulation, operands 
- int: 8b)">;
+
+def FeatureVendorXSfmm64a64f
+: RISCVExtension<0, 6,
+ "TEW=64-bit accumulation, operands - float: fp64",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve64d]>;
+def HasVendorXSfmm32a16fOrXSfmm32a32fOrXSfmm64a64f
+: Predicate<"Subtarget->hasVendorXSfmm32a16fOrXSfmm32a32fOrXSfmm64a64f()">,
+AssemblerPredicate<(any_of FeatureVendorXSfmm32a16f,
+   FeatureVendorXSfmm32a32f,
+   FeatureVendorXSfmm64a64f),
+"'XSfmm32a16f' (TEW=32-bit accumulation, operands - float: 
16b, widen=2 (IEEE, BF)), or "
+"'XSfmm32a32f' (TEW=32-bit accumulation, operands - float: 
32b), or "
+"'XSfmm64a64f' (TEW=64-bit accumulation, operands - float: 
fp64)">;
+
+def FeatureVendorXSfmm16t
+: RISCVExtension<0, 6,
+ "TE=16 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl64b], "XSfmmTE", 
"16">;
+
+def FeatureVendorXSfmm32t
+: RISCVExtension<0, 6,
+ "TE=32 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl128b], 
"XSfmmTE", "32">;
+
+def FeatureVendorXSfmm64t
+: RISCVExtension<0, 6,
+ "TE=64 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl256b], 
"XSfmmTE", "64">;
+
+def FeatureVendorXSfmm128t
+: RISCVExtension<0, 6,
+ "TE=128 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl512b], 
"XSfmmTE", "128">;

sequencer wrote:

Not so big TE, that’s not reasonable, however, VLEN=4K where TE=1K is a 
possible option in our case, so I may asking increase the maximum TE larger, 
e.g. 1K?

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


[clang] default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (PR #128640)

2025-04-29 Thread Urvi Rav via cfe-commits

https://github.com/ravurvi20 updated 
https://github.com/llvm/llvm-project/pull/128640

>From 6ebd5991788608fbd104ea9c23230912044462d3 Mon Sep 17 00:00:00 2001
From: Urvi Rav 
Date: Tue, 25 Feb 2025 00:49:07 -0600
Subject: [PATCH 1/6] default clause replaced by otherwise clause for
 metadirective

---
 .../clang/Basic/DiagnosticParseKinds.td   |  4 ++
 clang/lib/Parse/ParseOpenMP.cpp   | 20 ++
 clang/test/OpenMP/metadirective_messages.cpp  | 61 +--
 3 files changed, 68 insertions(+), 17 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index c513dab810d1f..4b8449e9ee9b6 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1657,6 +1657,10 @@ def err_omp_expected_colon : Error<"missing ':' in %0">;
 def err_omp_missing_comma : Error< "missing ',' after %0">;
 def err_omp_expected_context_selector
 : Error<"expected valid context selector in %0">;
+def err_omp_unknown_clause
+: Error<"unknown clause '%0' in %1">;
+def warn_omp_default_deprecated : Warning<"'default' clause for"
+  " 'metadirective' is deprecated; use 'otherwise' instead">, 
InGroup;
 def err_omp_requires_out_inout_depend_type : Error<
   "reserved locator 'omp_all_memory' requires 'out' or 'inout' "
   "dependency types">;
diff --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 42e6aac681c1c..3b86847e937a2 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2759,6 +2759,19 @@ StmtResult 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(
   OpenMPClauseKind CKind = Tok.isAnnotation()
? OMPC_unknown
: getOpenMPClauseKind(PP.getSpelling(Tok));
+  // Check if the clause is unrecognized.
+  if (getLangOpts().OpenMP < 52 &&
+  (CKind == OMPC_unknown || CKind == OMPC_otherwise)) {
+Diag(Tok, diag::err_omp_unknown_clause)
+<< PP.getSpelling(Tok) << "metadirective";
+  }
+  if (getLangOpts().OpenMP >= 52 && CKind == OMPC_unknown) {
+Diag(Tok, diag::err_omp_unknown_clause)
+<< PP.getSpelling(Tok) << "metadirective";
+  }
+  if (CKind == OMPC_default && getLangOpts().OpenMP >= 52) {
+Diag(Tok, diag::warn_omp_default_deprecated);
+  }
   SourceLocation Loc = ConsumeToken();
 
   // Parse '('.
@@ -2785,6 +2798,13 @@ StmtResult 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(
   return Directive;
 }
   }
+  if (CKind == OMPC_otherwise) {
+// Check for 'otherwise' keyword.
+if (Tok.is(tok::identifier) &&
+Tok.getIdentifierInfo()->getName() == "otherwise") {
+  ConsumeToken(); // Consume 'otherwise'
+}
+  }
   // Skip Directive for now. We will parse directive in the second 
iteration
   int paren = 0;
   while (Tok.isNot(tok::r_paren) || paren != 0) {
diff --git a/clang/test/OpenMP/metadirective_messages.cpp 
b/clang/test/OpenMP/metadirective_messages.cpp
index 7fce9fa446058..40ea37845fdff 100644
--- a/clang/test/OpenMP/metadirective_messages.cpp
+++ b/clang/test/OpenMP/metadirective_messages.cpp
@@ -2,21 +2,48 @@
 
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify -fopenmp-simd -x c++ 
-std=c++14 -fexceptions -fcxx-exceptions %s
 
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -verify=expected,omp52 -fopenmp 
-fopenmp-version=52 -ferror-limit 100 -o - %s -Wuninitialized
+
 void foo() {
-#pragma omp metadirective // expected-error {{expected expression}}
-  ;
-#pragma omp metadirective when() // expected-error {{expected valid context 
selector in when clause}} expected-error {{expected expression}} 
expected-warning {{expected identifier or string literal describing a context 
set; set skipped}} expected-note {{context set options are: 'construct' 
'device' 'target_device' 'implementation' 'user'}} expected-note {{the ignored 
set spans until here}}
-  ;
-#pragma omp metadirective when(device{}) // expected-warning {{expected '=' 
after the context set name "device"; '=' assumed}} expected-warning {{expected 
identifier or string literal describing a context selector; selector skipped}} 
expected-note {{context selector options are: 'kind' 'arch' 'isa'}} 
expected-note {{the ignored selector spans until here}} expected-error 
{{expected valid context selector in when clause}} expected-error {{expected 
expression}}
-  ;
-#pragma omp metadirective when(device{arch(nvptx)}) // expected-error 
{{missing ':' in when clause}} expected-error {{expected expression}} 
expected-warning {{expected '=' after the context set name "device"; '=' 
assumed}}
-  ;
-#pragma omp metadirective when(device{arch(nvptx)}: ) default() // 
expected-warning {{expected '=' after the context set name "device"; '=' 
assumed}}
-  ;
-#pragma omp metadirective when(device

[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-29 Thread Justin Bogner via cfe-commits


@@ -1,108 +1,160 @@
-// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
-// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx
-// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
-// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTARGET=spv
-
-// CHECK-LABEL: test_lerp_double
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
-// CHECK: ret float %hlsl.lerp
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple  
dxil-pc-shadermodel6.3-library %s -emit-llvm -O1 -o - | FileCheck %s 
--check-prefixes=CHECK -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx

bogner wrote:

I mean, these tests are checking that a single function maps to a single 
intrinsic - unless we start adding passes that replace a target specific 
intrinsic with another I don't see what could possibly change here.

These are really tests that we have the right set of overloads, and that they 
map to the obvious implementation. Most, if not all, of the logic that's 
interesting for these tests is in Sema anyway. The only other kind of bug that 
these are likely to catch in practice is that we literally lower to the wrong 
operation. "If you pass in these arguments, it generates something sane - if 
you pass in those, it's an error".

I guess I'm fine with changing these to be `-O0` tests, but that's mostly 
because I'm 100% convinced it doesn't matter. I definitely do not agree that 
those prove anything that these don't, and the tests are enough harder to read 
and write that I do think they're worse from the point of view of reviewability 
and understanding the code via the tests.

FWIW, it's incredibly prevalent in the clang CodeGen tests to use `-O1` so that 
the tests are more readable (as the allocas for stack variables are just 
generally noisy):
```shell
$ grep -rho -- " -O[0-9]" clang/test/CodeGen  | sort | uniq -c
354  -O0
997  -O1
418  -O2
219  -O3
```

> Why cant you just do a CHECK-COUNT?

Because you can't capture 3 patterns with `CHECK-COUNT`? As written, the tests 
pattern match the result of the fptrunc and make sure it's used in the call to 
the intrinsic. Since it's the same argument across the board, this keeps things 
concise.

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


[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-29 Thread Justin Bogner via cfe-commits

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


[clang-tools-extra] [clang-doc] Add start and end line numbers (PR #137732)

2025-04-29 Thread Daniel Thornburgh via cfe-commits

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


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


[clang] [llvm] [AArch64][SelectionDAG] Add CodeGen support for scalar FEAT_CPA (PR #105669)

2025-04-29 Thread Alexander Richardson via cfe-commits


@@ -2602,6 +2605,100 @@ SDValue DAGCombiner::foldSubToAvg(SDNode *N, const 
SDLoc &DL) {
   return SDValue();
 }
 
+/// Try to fold a pointer arithmetic node.
+/// This needs to be done separately from normal addition, because pointer
+/// addition is not commutative.
+/// This function was adapted from DAGCombiner::visitPTRADD() from the Morello
+/// project, which is based on CHERI.
+SDValue DAGCombiner::visitPTRADD(SDNode *N) {
+  SDValue N0 = N->getOperand(0);
+  SDValue N1 = N->getOperand(1);
+  EVT PtrVT = N0.getValueType();
+  EVT IntVT = N1.getValueType();
+  SDLoc DL(N);
+
+  // fold (ptradd undef, y) -> undef
+  if (N0.isUndef())
+return N0;
+
+  // fold (ptradd x, undef) -> undef
+  if (N1.isUndef())
+return DAG.getUNDEF(PtrVT);
+
+  // fold (ptradd x, 0) -> x
+  if (isNullConstant(N1))
+return N0;
+
+  if (N0.getOpcode() == ISD::PTRADD &&
+  !reassociationCanBreakAddressingModePattern(ISD::PTRADD, DL, N, N0, N1)) 
{
+SDValue X = N0.getOperand(0);
+SDValue Y = N0.getOperand(1);
+SDValue Z = N1;
+bool N0OneUse = N0.hasOneUse();
+bool YIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Y);
+bool ZIsConstant = DAG.isConstantIntBuildVectorOrConstantInt(Z);
+bool ZOneUse = Z.hasOneUse();
+
+// (ptradd (ptradd x, y), z) -> (ptradd x, (add y, z)) if:
+//   * x is a null pointer; or
+//   * y is a constant and z has one use; or
+//   * y is a constant and (ptradd x, y) has one use; or
+//   * (ptradd x, y) and z have one use and z is not a constant.
+if (isNullConstant(X) || (YIsConstant && ZOneUse) ||
+(YIsConstant && N0OneUse) || (N0OneUse && ZOneUse && !ZIsConstant)) {
+  SDValue Add = DAG.getNode(ISD::ADD, DL, IntVT, {Y, Z});
+
+  // Calling visit() can replace the Add node with ISD::DELETED_NODE if
+  // there aren't any users, so keep a handle around whilst we visit it.
+  HandleSDNode ADDHandle(Add);
+
+  SDValue VisitedAdd = visit(Add.getNode());
+  if (VisitedAdd) {
+// If visit() returns the same node, it means the SDNode was RAUW'd, 
and
+// therefore we have to load the new value to perform the checks 
whether
+// the reassociation fold is profitable.
+if (VisitedAdd.getNode() == Add.getNode())
+  Add = ADDHandle.getValue();
+else
+  Add = VisitedAdd;
+  }

arichardson wrote:

That's a good question - I believe that code might be my fault. It just seemed 
like the easiest way to avoid the assertion we were seeing before.

I *believe* adding the Add to the worklist should result in the same end result 
with less code complexity.

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


[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Farzon Lotfi via cfe-commits

farzonl wrote:

Since we are open to this for lerp I think we should file a similar issue for 
`pow(vector<*>, scalar>);`  Its much more user friendlly if we had an overload 
that would let us use a scalar  for the exponent.

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


[clang] [llvm] [clang] Add spir_kernel attribute (PR #137882)

2025-04-29 Thread Nick Sarnie via cfe-commits

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


[clang] [llvm] [clang] Add spir_kernel attribute (PR #137882)

2025-04-29 Thread Nick Sarnie via cfe-commits

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


[clang] [NFC][clang] No sharedlibs for UEFI (PR #137872)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/137872

>From 60473fc01469167d742cee1fcdc1b05b93482f94 Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Tue, 29 Apr 2025 13:21:16 -0700
Subject: [PATCH] [NFC][clang] No sharedlibs for UEFI

There is no support for shared libraries for UEFI target. Remove the
incorrect -dll flag set from UEFI toolchain.
---
 clang/lib/Driver/ToolChains/UEFI.cpp  | 3 ---
 clang/test/Driver/uefi-constructed-args.c | 1 -
 2 files changed, 4 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/UEFI.cpp 
b/clang/lib/Driver/ToolChains/UEFI.cpp
index a9d7e7892c5a6..fbef72e34a3b1 100644
--- a/clang/lib/Driver/ToolChains/UEFI.cpp
+++ b/clang/lib/Driver/ToolChains/UEFI.cpp
@@ -80,9 +80,6 @@ void tools::uefi::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   // "Terminal Service Aware" flag is not needed for UEFI applications.
   CmdArgs.push_back("-tsaware:no");
 
-  // EFI_APPLICATION to be linked as DLL by default.
-  CmdArgs.push_back("-dll");
-
   if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
 CmdArgs.push_back("-debug");
 
diff --git a/clang/test/Driver/uefi-constructed-args.c 
b/clang/test/Driver/uefi-constructed-args.c
index 44d2271e0c8ba..49ede47a8953e 100644
--- a/clang/test/Driver/uefi-constructed-args.c
+++ b/clang/test/Driver/uefi-constructed-args.c
@@ -11,5 +11,4 @@
 // CHECK-SAME: "-subsystem:efi_application"
 // CHECK-SAME: "-entry:EfiMain"
 // CHECK-SAME: "-tsaware:no"
-// CHECK-SAME: "-dll"
 // CHECK-SAME: "-debug"

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


[clang] [clang] ownership_returns attribute takes no more than 2 arguments (PR #137897)

2025-04-29 Thread via cfe-commits

https://github.com/halbi2 created 
https://github.com/llvm/llvm-project/pull/137897

Fixes #137896

>From 1497e17e86b437b59f35e80624a33034a97d2426 Mon Sep 17 00:00:00 2001
From: halbi2 
Date: Tue, 29 Apr 2025 19:41:27 -0400
Subject: [PATCH] [clang] ownership_returns attribute takes no more than 2
 arguments

Fixes #137896
---
 clang/lib/Sema/SemaDeclAttr.cpp  | 2 +-
 clang/test/Sema/attr-ownership.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 413999b95b998..8499141c30bce 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1483,7 +1483,7 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 break;
   case OwnershipAttr::Returns:
 if (AL.getNumArgs() > 2) {
-  S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
+  S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 2;
   return;
 }
 break;
diff --git a/clang/test/Sema/attr-ownership.c b/clang/test/Sema/attr-ownership.c
index d2e40538a40f0..515428d7d6c44 100644
--- a/clang/test/Sema/attr-ownership.c
+++ b/clang/test/Sema/attr-ownership.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -Wno-strict-prototypes
 
 void f1(void) __attribute__((ownership_takes("foo"))); // expected-error 
{{'ownership_takes' attribute requires parameter 1 to be an identifier}}
-void *f2(void) __attribute__((ownership_returns(foo, 1, 2)));  // 
expected-error {{'ownership_returns' attribute takes no more than 1 argument}}
+void *f2(void) __attribute__((ownership_returns(foo, 1, 2)));  // 
expected-error {{'ownership_returns' attribute takes no more than 2 arguments}}
 void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error 
{{'ownership_holds' attribute parameter 1 is out of bounds}}
 void *f4(void) __attribute__((ownership_returns(foo)));
 void f5(void) __attribute__((ownership_holds(foo)));  // expected-error 
{{'ownership_holds' attribute takes at least 2 arguments}}

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


[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-29 Thread Justin Bogner via cfe-commits

https://github.com/bogner created 
https://github.com/llvm/llvm-project/pull/137898

These tests had checks across multiple functions, because none of the hlsl 
header implementation functions were inlined. Switch the run lines to use -O1 
instead of -disable-llvm-passes and rewrite the tests to actually look at the 
whole function.

Note - this would be simpler with update_cc_test_checks, but the differences 
between DX and SPIRV are difficult to account for with those scripts.

>From 2c9a706a1cbd418ff4116a6f118a56a588f91a7e Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Tue, 29 Apr 2025 16:26:33 -0700
Subject: [PATCH] [HLSL] Make lerp overload tests stricter. NFC

These tests had checks across multiple functions, because none of the hlsl
header implementation functions were inlined. Switch the run lines to use -O1
instead of -disable-llvm-passes and rewrite the tests to actually look at the
whole function.

Note - this would be simpler with update_cc_test_checks, but the differences
between DX and SPIRV are difficult to account for with those scripts.
---
 .../CodeGenHLSL/builtins/lerp-overloads.hlsl  | 190 +++---
 1 file changed, 121 insertions(+), 69 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl 
b/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl
index 6e452481e2fa2..9c613ce2db27d 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl
@@ -1,108 +1,160 @@
-// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
-// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx
-// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
-// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTARGET=spv
-
-// CHECK-LABEL: test_lerp_double
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
-// CHECK: ret float %hlsl.lerp
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple  
dxil-pc-shadermodel6.3-library %s -emit-llvm -O1 -o - | FileCheck %s 
--check-prefixes=CHECK -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple 
spirv-unknown-vulkan-compute %s -emit-llvm -O1 -o - | FileCheck %s 
--check-prefixes=CHECK -DFNATTRS="spir_func noundef nofpclass(nan inf)" 
-DTARGET=spv
+
+// CHECK: define [[FNATTRS]] float @_Z16test_lerp_doubled(
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT:[[CONV:%.*]] = fptrunc {{.*}} double [[P0:%.*]] to float
+// CHECK-NEXT:[[LERP:%.*]] = tail call {{.*}} float 
@llvm.[[TARGET]].lerp.f32(float [[CONV]], float [[CONV]], float [[CONV]])
+// CHECK-NEXT:ret float [[LERP]]
 float test_lerp_double(double p0) { return lerp(p0, p0, p0); }
 
-// CHECK-LABEL: test_lerp_double2
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].lerp.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, <2 x 
float> %{{.*}})
-// CHECK: ret <2 x float> %hlsl.lerp
+// CHECK: define [[FNATTRS]] <2 x float> @_Z17test_lerp_double2Dv2_d(
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT:[[CONV:%.*]] = fptrunc {{.*}} <2 x double> [[P0:%.*]] to <2 
x float>
+// CHECK-NEXT:[[LERP:%.*]] = tail call {{.*}} <2 x float> 
@llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV]], <2 x float> [[CONV]], <2 x 
float> [[CONV]])
+// CHECK-NEXT:ret <2 x float> [[LERP]]
 float2 test_lerp_double2(double2 p0) { return lerp(p0, p0, p0); }
 
-// CHECK-LABEL: test_lerp_double3
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x 
float> %{{.*}})
-// CHECK: ret <3 x float> %hlsl.lerp
+// CHECK: define [[FNATTRS]] <3 x float> @_Z17test_lerp_double3Dv3_d(
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[CONV:%.*]] = fptrunc {{.*}} <3 x double> [[P0:%.*]] to <3 
x float>
+// CHECK-NEXT:[[LERP:%.*]] = tail call {{.*}} <3 x float> 
@llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV]], <3 x float> [[CONV]], <3 x 
float> [[CONV]])
+// CHECK-NEXT:ret <3 x float> [[LERP]]
+//
 float3 test_lerp_double3(double3 p0) { return lerp(p0, p0, p0); }
 
-// CHECK-LABEL: test_lerp_double4
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
-// CHECK: ret <4 x float> %hlsl.lerp
+// CHECK: define [[FNATTRS]] <4 x float> @_Z17test_lerp_double4Dv4_d(
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[CONV:%.*]] = fptrunc {{.*}} <4 x double> [[P0:%.*]] to <4 
x float>
+// CHECK-NEXT:[[LERP:%.*]] = tail call 

[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-hlsl

Author: Justin Bogner (bogner)


Changes

These tests had checks across multiple functions, because none of the hlsl 
header implementation functions were inlined. Switch the run lines to use -O1 
instead of -disable-llvm-passes and rewrite the tests to actually look at the 
whole function.

Note - this would be simpler with update_cc_test_checks, but the differences 
between DX and SPIRV are difficult to account for with those scripts.

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


1 Files Affected:

- (modified) clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl (+121-69) 


``diff
diff --git a/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl 
b/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl
index 6e452481e2fa2..9c613ce2db27d 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp-overloads.hlsl
@@ -1,108 +1,160 @@
-// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
-// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx
-// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
-// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTARGET=spv
-
-// CHECK-LABEL: test_lerp_double
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
-// CHECK: ret float %hlsl.lerp
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple  
dxil-pc-shadermodel6.3-library %s -emit-llvm -O1 -o - | FileCheck %s 
--check-prefixes=CHECK -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple 
spirv-unknown-vulkan-compute %s -emit-llvm -O1 -o - | FileCheck %s 
--check-prefixes=CHECK -DFNATTRS="spir_func noundef nofpclass(nan inf)" 
-DTARGET=spv
+
+// CHECK: define [[FNATTRS]] float @_Z16test_lerp_doubled(
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT:[[CONV:%.*]] = fptrunc {{.*}} double [[P0:%.*]] to float
+// CHECK-NEXT:[[LERP:%.*]] = tail call {{.*}} float 
@llvm.[[TARGET]].lerp.f32(float [[CONV]], float [[CONV]], float [[CONV]])
+// CHECK-NEXT:ret float [[LERP]]
 float test_lerp_double(double p0) { return lerp(p0, p0, p0); }
 
-// CHECK-LABEL: test_lerp_double2
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].lerp.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, <2 x 
float> %{{.*}})
-// CHECK: ret <2 x float> %hlsl.lerp
+// CHECK: define [[FNATTRS]] <2 x float> @_Z17test_lerp_double2Dv2_d(
+// CHECK-NEXT: [[ENTRY:.*:]]
+// CHECK-NEXT:[[CONV:%.*]] = fptrunc {{.*}} <2 x double> [[P0:%.*]] to <2 
x float>
+// CHECK-NEXT:[[LERP:%.*]] = tail call {{.*}} <2 x float> 
@llvm.[[TARGET]].lerp.v2f32(<2 x float> [[CONV]], <2 x float> [[CONV]], <2 x 
float> [[CONV]])
+// CHECK-NEXT:ret <2 x float> [[LERP]]
 float2 test_lerp_double2(double2 p0) { return lerp(p0, p0, p0); }
 
-// CHECK-LABEL: test_lerp_double3
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x 
float> %{{.*}})
-// CHECK: ret <3 x float> %hlsl.lerp
+// CHECK: define [[FNATTRS]] <3 x float> @_Z17test_lerp_double3Dv3_d(
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[CONV:%.*]] = fptrunc {{.*}} <3 x double> [[P0:%.*]] to <3 
x float>
+// CHECK-NEXT:[[LERP:%.*]] = tail call {{.*}} <3 x float> 
@llvm.[[TARGET]].lerp.v3f32(<3 x float> [[CONV]], <3 x float> [[CONV]], <3 x 
float> [[CONV]])
+// CHECK-NEXT:ret <3 x float> [[LERP]]
+//
 float3 test_lerp_double3(double3 p0) { return lerp(p0, p0, p0); }
 
-// CHECK-LABEL: test_lerp_double4
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
-// CHECK: ret <4 x float> %hlsl.lerp
+// CHECK: define [[FNATTRS]] <4 x float> @_Z17test_lerp_double4Dv4_d(
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[CONV:%.*]] = fptrunc {{.*}} <4 x double> [[P0:%.*]] to <4 
x float>
+// CHECK-NEXT:[[LERP:%.*]] = tail call {{.*}} <4 x float> 
@llvm.[[TARGET]].lerp.v4f32(<4 x float> [[CONV]], <4 x float> [[CONV]], <4 x 
float> [[CONV]])
+// CHECK-NEXT:ret <4 x float> [[LERP]]
+//
 float4 test_lerp_double4(double4 p0) { return lerp(p0, p0, p0); }
 
-// CHECK-LABEL: test_lerp_int
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
-// CHECK: ret float %hlsl.lerp
+// CHECK: define [[FNATTRS]] float @_Z13test_lerp_inti(
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NE

[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

2025-04-29 Thread via cfe-commits

https://github.com/halbi2 created 
https://github.com/llvm/llvm-project/pull/137899

Fixes #133380

>From 8b6c722cda78edf307432cc52274db2271170033 Mon Sep 17 00:00:00 2001
From: halbi2 
Date: Mon, 28 Apr 2025 20:07:43 -0400
Subject: [PATCH] [clang] Warn about deprecated volatile-qualified return types

Fixes #133380
---
 clang/lib/Sema/SemaType.cpp  | 10 +-
 clang/test/CXX/expr/expr.const/p2-0x.cpp |  2 +-
 clang/test/SemaCXX/deprecated.cpp|  7 +++
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 6e7ee8b5506ff..31bdc97d014d6 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5056,13 +5056,13 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
   S.Diag(DeclType.Loc, diag::err_func_returning_qualified_void) << T;
 } else
   diagnoseRedundantReturnTypeQualifiers(S, T, D, chunkIndex);
-
-// C++2a [dcl.fct]p12:
-//   A volatile-qualified return type is deprecated
-if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
-  S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
   }
 
+  // C++2a [dcl.fct]p12:
+  //   A volatile-qualified return type is deprecated
+  if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
+S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
+
   // Objective-C ARC ownership qualifiers are ignored on the function
   // return type (by type canonicalization). Complain if this attribute
   // was written here.
diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp 
b/clang/test/CXX/expr/expr.const/p2-0x.cpp
index df5ce108aca82..c6c3381be5523 100644
--- a/clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -356,7 +356,7 @@ namespace LValueToRValue {
   // - a non-volatile glvalue of literal type that refers to a non-volatile
   //   temporary object whose lifetime has not ended, initialized with a
   //   constant expression;
-  constexpr volatile S f() { return S(); }
+  constexpr volatile S f() { return S(); } // cxx20-warning 
{{volatile-qualified return type 'volatile S' is deprecated}}
   static_assert(f().i, ""); // expected-error {{constant expression}} 
expected-note {{read of volatile-qualified type}}
   static_assert(((volatile const S&&)(S)0).i, ""); // expected-error 
{{constant expression}} expected-note {{read of volatile-qualified type}}
 }
diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index a24b40d8e622a..061fa8b54dff1 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -231,6 +231,13 @@ namespace DeprecatedVolatile {
 a = c = a;
 b += a;
   }
+
+  volatile struct amber jurassic();
+// cxx20-warning@-1 {{volatile-qualified return type 'volatile struct 
amber' is deprecated}}
+  void trex(volatile short left_arm, volatile struct amber right_arm);
+// cxx20-warning@-1 {{volatile-qualified parameter type 'volatile short' 
is deprecated}}
+// cxx20-warning@-1 {{volatile-qualified parameter type 'volatile struct 
amber' is deprecated}}
+  void fly(volatile struct pterosaur* pteranodon);
 }
 
 namespace ArithConv {

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


[clang] [clang] ownership_returns attribute takes no more than 2 arguments (PR #137897)

2025-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (halbi2)


Changes

Fixes #137896

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+1-1) 
- (modified) clang/test/Sema/attr-ownership.c (+1-1) 


``diff
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 413999b95b998..8499141c30bce 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1483,7 +1483,7 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const 
ParsedAttr &AL) {
 break;
   case OwnershipAttr::Returns:
 if (AL.getNumArgs() > 2) {
-  S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 1;
+  S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments) << AL << 2;
   return;
 }
 break;
diff --git a/clang/test/Sema/attr-ownership.c b/clang/test/Sema/attr-ownership.c
index d2e40538a40f0..515428d7d6c44 100644
--- a/clang/test/Sema/attr-ownership.c
+++ b/clang/test/Sema/attr-ownership.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 %s -verify -fsyntax-only -Wno-strict-prototypes
 
 void f1(void) __attribute__((ownership_takes("foo"))); // expected-error 
{{'ownership_takes' attribute requires parameter 1 to be an identifier}}
-void *f2(void) __attribute__((ownership_returns(foo, 1, 2)));  // 
expected-error {{'ownership_returns' attribute takes no more than 1 argument}}
+void *f2(void) __attribute__((ownership_returns(foo, 1, 2)));  // 
expected-error {{'ownership_returns' attribute takes no more than 2 arguments}}
 void f3(void) __attribute__((ownership_holds(foo, 1))); // expected-error 
{{'ownership_holds' attribute parameter 1 is out of bounds}}
 void *f4(void) __attribute__((ownership_returns(foo)));
 void f5(void) __attribute__((ownership_holds(foo)));  // expected-error 
{{'ownership_holds' attribute takes at least 2 arguments}}

``




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


[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Justin Bogner via cfe-commits


@@ -106,3 +102,17 @@ float3 test_lerp_uint64_t3(uint64_t3 p0) { return lerp(p0, 
p0, p0); }
 // CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
 // CHECK: ret <4 x float> %hlsl.lerp
 float4 test_lerp_uint64_t4(uint64_t4 p0) { return lerp(p0, p0, p0); }
+
+// CHECK-LABEL: test_lerp_half_scalar
+// NATIVE_HALF: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x half> 
@llvm.[[TARGET]].lerp.v3f16(<3 x half> %{{.*}}, <3 x half> %{{.*}}, <3 x half> 
%{{.*}})
+// NATIVE_HALF: ret <3 x half> %hlsl.lerp
+// NO_HALF: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x 
float> %{{.*}})
+// NO_HALF: ret <3 x float> %hlsl.lerp
+half3 test_lerp_half_scalar(half3 x, half3 y, half s) { return lerp(x, y, s); }

bogner wrote:

https://github.com/llvm/llvm-project/pull/137898

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


[clang] [clang] Warn about deprecated volatile-qualified return types (PR #137899)

2025-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (halbi2)


Changes

Fixes #133380

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


3 Files Affected:

- (modified) clang/lib/Sema/SemaType.cpp (+5-5) 
- (modified) clang/test/CXX/expr/expr.const/p2-0x.cpp (+1-1) 
- (modified) clang/test/SemaCXX/deprecated.cpp (+7) 


``diff
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 6e7ee8b5506ff..31bdc97d014d6 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5056,13 +5056,13 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
   S.Diag(DeclType.Loc, diag::err_func_returning_qualified_void) << T;
 } else
   diagnoseRedundantReturnTypeQualifiers(S, T, D, chunkIndex);
-
-// C++2a [dcl.fct]p12:
-//   A volatile-qualified return type is deprecated
-if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
-  S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
   }
 
+  // C++2a [dcl.fct]p12:
+  //   A volatile-qualified return type is deprecated
+  if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
+S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
+
   // Objective-C ARC ownership qualifiers are ignored on the function
   // return type (by type canonicalization). Complain if this attribute
   // was written here.
diff --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp 
b/clang/test/CXX/expr/expr.const/p2-0x.cpp
index df5ce108aca82..c6c3381be5523 100644
--- a/clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -356,7 +356,7 @@ namespace LValueToRValue {
   // - a non-volatile glvalue of literal type that refers to a non-volatile
   //   temporary object whose lifetime has not ended, initialized with a
   //   constant expression;
-  constexpr volatile S f() { return S(); }
+  constexpr volatile S f() { return S(); } // cxx20-warning 
{{volatile-qualified return type 'volatile S' is deprecated}}
   static_assert(f().i, ""); // expected-error {{constant expression}} 
expected-note {{read of volatile-qualified type}}
   static_assert(((volatile const S&&)(S)0).i, ""); // expected-error 
{{constant expression}} expected-note {{read of volatile-qualified type}}
 }
diff --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index a24b40d8e622a..061fa8b54dff1 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -231,6 +231,13 @@ namespace DeprecatedVolatile {
 a = c = a;
 b += a;
   }
+
+  volatile struct amber jurassic();
+// cxx20-warning@-1 {{volatile-qualified return type 'volatile struct 
amber' is deprecated}}
+  void trex(volatile short left_arm, volatile struct amber right_arm);
+// cxx20-warning@-1 {{volatile-qualified parameter type 'volatile short' 
is deprecated}}
+// cxx20-warning@-1 {{volatile-qualified parameter type 'volatile struct 
amber' is deprecated}}
+  void fly(volatile struct pterosaur* pteranodon);
 }
 
 namespace ArithConv {

``




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


[clang] [HLSL] Resource initialization by constructors (PR #135120)

2025-04-29 Thread Ashley Coleman via cfe-commits

https://github.com/V-FEXrt approved this pull request.


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


[clang] [clang AST] move mangling API to namespace clang to allow calls from swift-frontend (PR #137884)

2025-04-29 Thread Peter Rong via cfe-commits

https://github.com/DataCorrupted created 
https://github.com/llvm/llvm-project/pull/137884

When implementing `@objcDirect` in Swfit, Swift needs to mangle a `Decl` that 
is not a clang Node. 

Rewriting the ObjC's mangling logic in swift is redundant, we can just call 
clang API since swift depends on clang already.

We are separating this from #126639 so we can draft the proposal on the swift 
side. #126639  will be worked to depend on this PR.

Tests: No new tests, old ones should pass with no problem.



  



Rate limit · GitHub


  body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe 
UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;
font-size: 14px;
line-height: 1.5;
margin: 0;
  }

  .container { margin: 50px auto; max-width: 600px; text-align: center; 
padding: 0 24px; }

  a { color: #0366d6; text-decoration: none; }
  a:hover { text-decoration: underline; }

  h1 { line-height: 60px; font-size: 48px; font-weight: 300; margin: 0px; 
text-shadow: 0 1px 0 #fff; }
  p { color: rgba(0, 0, 0, 0.5); margin: 20px 0 40px; }

  ul { list-style: none; margin: 25px 0; padding: 0; }
  li { display: table-cell; font-weight: bold; width: 1%; }

  .logo { display: inline-block; margin-top: 35px; }
  .logo-img-2x { display: none; }
  @media
  only screen and (-webkit-min-device-pixel-ratio: 2),
  only screen and (   min--moz-device-pixel-ratio: 2),
  only screen and ( -o-min-device-pixel-ratio: 2/1),
  only screen and (min-device-pixel-ratio: 2),
  only screen and (min-resolution: 192dpi),
  only screen and (min-resolution: 2dppx) {
.logo-img-1x { display: none; }
.logo-img-2x { display: inline-block; }
  }

  #suggestions {
margin-top: 35px;
color: #ccc;
  }
  #suggestions a {
color: #66;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
  }


  
  



  Whoa there!
  You have exceeded a secondary rate limit.
Please wait a few minutes before you try again;
in some cases this may take up to an hour.
  
  
https://support.github.com/contact";>Contact Support —
https://githubstatus.com";>GitHub Status —
https://twitter.com/githubstatus";>@githubstatus
  

  

  

  

  

  


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


[clang] [HLSL][RootSignature] Add lexing support for floating points (PR #137720)

2025-04-29 Thread Damyan Pepper via cfe-commits

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


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


[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)

2025-04-29 Thread Gedare Bloom via cfe-commits

https://github.com/gedare updated 
https://github.com/llvm/llvm-project/pull/108332

>From 64000ad7d2310ac916b37ed808997bfcb6b9f324 Mon Sep 17 00:00:00 2001
From: Gedare Bloom 
Date: Thu, 20 Jun 2024 17:35:39 -0600
Subject: [PATCH 1/2] Format: add AlignAfterControlStatement

Introduce new style option to allow overriding the breaking after the
opening parenthesis for control statements (if/for/while/switch).

Fixes #67738.
Fixes #79176.
Fixes #80123.
---
 clang/include/clang/Format/Format.h|  17 ++
 clang/lib/Format/ContinuationIndenter.cpp  |  70 +++--
 clang/lib/Format/Format.cpp|  11 +
 clang/lib/Format/TokenAnnotator.cpp|   7 +-
 clang/unittests/Format/ConfigParseTest.cpp |   8 +
 clang/unittests/Format/FormatTest.cpp  | 299 +
 6 files changed, 390 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index f6ceef08b46da..274a9e4ee272a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,6 +62,22 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
+  /// Different styles for breaking the parenthesis after a control statement
+  /// (``if/switch/while/for ...``).
+  /// \version 21
+  enum BreakAfterControlStatementStyle : int8_t {
+/// Use the default behavior.
+BACSS_Default,
+/// Force break after the left parenthesis of a control statement only
+/// when the expression exceeds the column limit, and align on the
+/// ``ContinuationIndentWidth``.
+BACSS_MultiLine,
+/// Do not force a break after the control statment.
+BACSS_No,
+  };
+
+  BreakAfterControlStatementStyle AlignAfterControlStatement;
+
   /// Different styles for aligning after open brackets.
   enum BracketAlignmentStyle : int8_t {
 /// Align parameters on the open bracket, e.g.:
@@ -5283,6 +5299,7 @@ struct FormatStyle {
   bool operator==(const FormatStyle &R) const {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
+   AlignAfterControlStatement == R.AlignAfterControlStatement &&
AlignArrayOfStructures == R.AlignArrayOfStructures &&
AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
AlignConsecutiveBitFields == R.AlignConsecutiveBitFields &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 55e1d1ceb55b7..08558d6550832 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -814,6 +814,11 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
   // parenthesis by disallowing any further line breaks if there is no line
   // break after the opening parenthesis. Don't break if it doesn't conserve
   // columns.
+  auto IsOtherConditional = [&](const FormatToken &Tok) {
+return Tok.isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch) ||
+   (Style.isJavaScript() && Tok.is(Keywords.kw_await) && Tok.Previous 
&&
+Tok.Previous->is(tok::kw_for));
+  };
   auto IsOpeningBracket = [&](const FormatToken &Tok) {
 auto IsStartOfBracedList = [&]() {
   return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
@@ -825,26 +830,37 @@ void 
ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
 }
 if (!Tok.Previous)
   return true;
-if (Tok.Previous->isIf())
-  return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak;
-return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
-  tok::kw_switch) &&
-   !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await));
+if (Tok.Previous->isIf()) {
+  /* For backward compatibility, use AlignAfterOpenBracket
+   * in case AlignAfterControlStatement is not initialized */
+  return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine 
||
+(Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
+ Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
+}
+if (IsOtherConditional(*Tok.Previous)) {
+  return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
+}
+if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
+   Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+  return !Tok.Previous->is(TT_CastRParen) &&
+ !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
+}
+return false;
   };
   auto IsFunctionCallParen = [](const FormatToken &Tok) {
 return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous &&
Tok.Previous->is(tok::identifier);
   };
-  auto IsInTemplateString = [this](const FormatToken &Tok) {
+  auto IsInTemplateString = [this](const FormatToken &Tok, bool NestBlocks) {
 if (!Style.isJavaScript())
 

[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)

2025-04-29 Thread Gedare Bloom via cfe-commits

https://github.com/gedare updated 
https://github.com/llvm/llvm-project/pull/108332

>From 64000ad7d2310ac916b37ed808997bfcb6b9f324 Mon Sep 17 00:00:00 2001
From: Gedare Bloom 
Date: Thu, 20 Jun 2024 17:35:39 -0600
Subject: [PATCH 1/3] Format: add AlignAfterControlStatement

Introduce new style option to allow overriding the breaking after the
opening parenthesis for control statements (if/for/while/switch).

Fixes #67738.
Fixes #79176.
Fixes #80123.
---
 clang/include/clang/Format/Format.h|  17 ++
 clang/lib/Format/ContinuationIndenter.cpp  |  70 +++--
 clang/lib/Format/Format.cpp|  11 +
 clang/lib/Format/TokenAnnotator.cpp|   7 +-
 clang/unittests/Format/ConfigParseTest.cpp |   8 +
 clang/unittests/Format/FormatTest.cpp  | 299 +
 6 files changed, 390 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index f6ceef08b46da..274a9e4ee272a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,6 +62,22 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
+  /// Different styles for breaking the parenthesis after a control statement
+  /// (``if/switch/while/for ...``).
+  /// \version 21
+  enum BreakAfterControlStatementStyle : int8_t {
+/// Use the default behavior.
+BACSS_Default,
+/// Force break after the left parenthesis of a control statement only
+/// when the expression exceeds the column limit, and align on the
+/// ``ContinuationIndentWidth``.
+BACSS_MultiLine,
+/// Do not force a break after the control statment.
+BACSS_No,
+  };
+
+  BreakAfterControlStatementStyle AlignAfterControlStatement;
+
   /// Different styles for aligning after open brackets.
   enum BracketAlignmentStyle : int8_t {
 /// Align parameters on the open bracket, e.g.:
@@ -5283,6 +5299,7 @@ struct FormatStyle {
   bool operator==(const FormatStyle &R) const {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
+   AlignAfterControlStatement == R.AlignAfterControlStatement &&
AlignArrayOfStructures == R.AlignArrayOfStructures &&
AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
AlignConsecutiveBitFields == R.AlignConsecutiveBitFields &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 55e1d1ceb55b7..08558d6550832 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -814,6 +814,11 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
   // parenthesis by disallowing any further line breaks if there is no line
   // break after the opening parenthesis. Don't break if it doesn't conserve
   // columns.
+  auto IsOtherConditional = [&](const FormatToken &Tok) {
+return Tok.isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch) ||
+   (Style.isJavaScript() && Tok.is(Keywords.kw_await) && Tok.Previous 
&&
+Tok.Previous->is(tok::kw_for));
+  };
   auto IsOpeningBracket = [&](const FormatToken &Tok) {
 auto IsStartOfBracedList = [&]() {
   return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
@@ -825,26 +830,37 @@ void 
ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
 }
 if (!Tok.Previous)
   return true;
-if (Tok.Previous->isIf())
-  return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak;
-return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
-  tok::kw_switch) &&
-   !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await));
+if (Tok.Previous->isIf()) {
+  /* For backward compatibility, use AlignAfterOpenBracket
+   * in case AlignAfterControlStatement is not initialized */
+  return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine 
||
+(Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
+ Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
+}
+if (IsOtherConditional(*Tok.Previous)) {
+  return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
+}
+if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
+   Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+  return !Tok.Previous->is(TT_CastRParen) &&
+ !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
+}
+return false;
   };
   auto IsFunctionCallParen = [](const FormatToken &Tok) {
 return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous &&
Tok.Previous->is(tok::identifier);
   };
-  auto IsInTemplateString = [this](const FormatToken &Tok) {
+  auto IsInTemplateString = [this](const FormatToken &Tok, bool NestBlocks) {
 if (!Style.isJavaScript())
 

[clang] 4595e80 - [clang][NFC] Convert `Parser::AnnotatedNameKind` to scoped enum

2025-04-29 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-04-30T02:23:39+03:00
New Revision: 4595e8092ed5ce69b3ce33e989d7bea3a25fc289

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

LOG: [clang][NFC] Convert `Parser::AnnotatedNameKind` to scoped enum

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseStmt.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index d9cf3813a1828..dbbb80fdd9943 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -51,6 +51,19 @@ namespace clang {
   struct OMPTraitSet;
   class OMPTraitInfo;
 
+enum class AnnotatedNameKind {
+  /// Annotation has failed and emitted an error.
+  Error,
+  /// The identifier is a tentatively-declared name.
+  TentativeDecl,
+  /// The identifier is a template name. FIXME: Add an annotation for that.
+  TemplateName,
+  /// The identifier can't be resolved.
+  Unresolved,
+  /// Annotation was successful.
+  Success
+};
+
 /// Parser - This implements a parser for the C family of languages.  After
 /// parsing units of the grammar, productions are invoked to handle whatever 
has
 /// been read.
@@ -940,19 +953,6 @@ class Parser : public CodeCompletionHandler {
   }
 
 private:
-  enum AnnotatedNameKind {
-/// Annotation has failed and emitted an error.
-ANK_Error,
-/// The identifier is a tentatively-declared name.
-ANK_TentativeDecl,
-/// The identifier is a template name. FIXME: Add an annotation for that.
-ANK_TemplateName,
-/// The identifier can't be resolved.
-ANK_Unresolved,
-/// Annotation was successful.
-ANK_Success
-  };
-
   AnnotatedNameKind
   TryAnnotateName(CorrectionCandidateCallback *CCC = nullptr,
   ImplicitTypenameContext AllowImplicitTypename =

diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 4e801f4ef890f..f50a245621185 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -216,7 +216,7 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
   // Try to limit which sets of keywords should be included in typo
   // correction based on what the next token is.
   StatementFilterCCC CCC(Next);
-  if (TryAnnotateName(&CCC) == ANK_Error) {
+  if (TryAnnotateName(&CCC) == AnnotatedNameKind::Error) {
 // Handle errors here by skipping up to the next semicolon or '}', and
 // eat the semicolon if that's what stopped us.
 SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);

diff  --git a/clang/lib/Parse/ParseTentative.cpp 
b/clang/lib/Parse/ParseTentative.cpp
index ff27ef70944a4..0994ff126e7e5 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1401,11 +1401,11 @@ 
Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
   // to types and identifiers, in order to try to recover from errors.
   TentativeParseCCC CCC(Next);
   switch (TryAnnotateName(&CCC)) {
-  case ANK_Error:
+  case AnnotatedNameKind::Error:
 return TPResult::Error;
-  case ANK_TentativeDecl:
+  case AnnotatedNameKind::TentativeDecl:
 return TPResult::False;
-  case ANK_TemplateName:
+  case AnnotatedNameKind::TemplateName:
 // In C++17, this could be a type template for class template argument
 // deduction. Try to form a type annotation for it. If we're in a
 // template template argument, we'll undo this when checking the
@@ -1420,9 +1420,9 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext 
AllowImplicitTypename,
 // A bare type template-name which can't be a template template
 // argument is an error, and was probably intended to be a type.
 return GreaterThanIsOperator ? TPResult::True : TPResult::False;
-  case ANK_Unresolved:
+  case AnnotatedNameKind::Unresolved:
 return InvalidAsDeclSpec ? TPResult::Ambiguous : TPResult::False;
-  case ANK_Success:
+  case AnnotatedNameKind::Success:
 break;
   }
   assert(Tok.isNot(tok::identifier) &&
@@ -1694,11 +1694,11 @@ 
Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
   // Try to resolve the name. If it doesn't exist, assume it was
   // intended to name a type and keep disambiguating.
   switch (TryAnnotateName(/*CCC=*/nullptr, AllowImplicitTypename)) {
-  case ANK_Error:
+  case AnnotatedNameKind::Error:
 return TPResult::Error;
-  case ANK_TentativeDecl:
+  case AnnotatedNameKind::TentativeDecl:
 return TPResult::Fa

[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)

2025-04-29 Thread Gedare Bloom via cfe-commits

gedare wrote:


> > > I prefer that we limit this to breaking after the left parenthesis of a 
> > > control statement, with true/false or Always, Never, Multiline, 
> > > BlockIndent, etc.
> > 
> > 
> > if I understand you correctly, you would like a new style option added for 
> > setting break option for all control statements in the same way?
> 
> Yes.

This is basically re-written as requested. The Alignment is determined by the 
value of AlignAfterOpenBracket, except that because there is a forced break 
with `MultiLine` the alignment will happen at the Continuation Indent.  So 
using the new option with `MultiLine` and `AlignAfterOpenBracket.Align` is 
equivalent to using `AlignAfterOpenBracket.AlwaysBreak` with `MultiLine`.


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


[clang] [llvm] [clang] Implement JSON formatted -ftime-report (PR #137737)

2025-04-29 Thread Arthur Eubanks via cfe-commits

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

lgtm, although I'd like @AaronBallman to take a quick look to make sure this 
seems ok (e.g. naming)

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


[clang] [llvm] [clang] Implement JSON formatted -ftime-report (PR #137737)

2025-04-29 Thread Arthur Eubanks via cfe-commits

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


[clang] [llvm] [clang] Implement JSON formatted -ftime-report (PR #137737)

2025-04-29 Thread Arthur Eubanks via cfe-commits


@@ -442,10 +442,6 @@ void TimerGroup::clearAll() {
 
 void TimerGroup::printJSONValue(raw_ostream &OS, const PrintRecord &R,
 const char *suffix, double Value) {
-  assert(yaml::needsQuotes(Name) == yaml::QuotingType::None &&

aeubanks wrote:

can you explain this change?

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


[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)

2025-04-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Maksim Ivanov (emaxx-google)


Changes

This commit fixes the nondeterminism issue in C++ header module enabled builds 
which were observed after
https://github.com/llvm/llvm-project/pull/132401.

The issue was related to the fact that the hash set operation in 
MemberPointerType::Profile() was triggering getMostRecentDecl(). The root cause 
seems to be that the latter was leading to the reentrant modification of the 
hash set, with some probability (likely depending on the actual values of 
hashes).

We haven't been able to come up with a deterministic regression test for this 
fix.

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


2 Files Affected:

- (modified) clang/include/clang/AST/Type.h (+2-1) 
- (modified) clang/lib/AST/Type.cpp (+7-3) 


``diff
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 3e1fb05ad537c..c93cbae767db8 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -3602,6 +3602,7 @@ class MemberPointerType : public Type, public 
llvm::FoldingSetNode {
   }
 
   NestedNameSpecifier *getQualifier() const { return Qualifier; }
+  CXXRecordDecl *getCXXRecordDecl() const;
   CXXRecordDecl *getMostRecentCXXRecordDecl() const;
 
   bool isSugared() const;
@@ -3610,7 +3611,7 @@ class MemberPointerType : public Type, public 
llvm::FoldingSetNode {
   }
 
   void Profile(llvm::FoldingSetNodeID &ID) {
-Profile(ID, getPointeeType(), getQualifier(), 
getMostRecentCXXRecordDecl());
+Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl());
   }
 
   static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee,
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 111a642173418..a149eac7e4555 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -5275,10 +5275,14 @@ void MemberPointerType::Profile(llvm::FoldingSetNodeID 
&ID, QualType Pointee,
 ID.AddPointer(Cls->getCanonicalDecl());
 }
 
+CXXRecordDecl *MemberPointerType::getCXXRecordDecl() const {
+  return dyn_cast(getCanonicalTypeInternal())
+  ->getQualifier()
+  ->getAsRecordDecl();
+}
+
 CXXRecordDecl *MemberPointerType::getMostRecentCXXRecordDecl() const {
-  auto *RD = dyn_cast(getCanonicalTypeInternal())
- ->getQualifier()
- ->getAsRecordDecl();
+  auto *RD = getCXXRecordDecl();
   if (!RD)
 return nullptr;
   return RD->getMostRecentNonInjectedDecl();

``




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


[clang] [clang] Fix nondeterminism in MemberPointerType (PR #137910)

2025-04-29 Thread Maksim Ivanov via cfe-commits

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


[clang] Silence spurious -Wnontrivial-memcall warnings in C mode (PR #137429)

2025-04-29 Thread Akira Hatanaka via cfe-commits

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


[clang] 6bb4ce0 - Silence spurious -Wnontrivial-memcall warnings in C mode (#137429)

2025-04-29 Thread via cfe-commits

Author: Akira Hatanaka
Date: 2025-04-29T18:37:57-07:00
New Revision: 6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18

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

LOG: Silence spurious -Wnontrivial-memcall warnings in C mode (#137429)

clang currently issues a warning when memset is used on a struct that
contains an address-discriminated pointer field, even though this is
entirely valid behavior.

For example:

```
struct S {
  int * __ptrauth(1, 1, 100) p;
} s;

memset(&s, 0, sizeof(struct S));
```

Only allow the warning to be emitted in C++ mode to silence the warning.

rdar://142495870

Added: 
clang/test/Sema/warn-nontrivial-struct-memaccess-ptrauth.c

Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 018d121ad8ab5..d2cad8a6fd608 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -9735,9 +9735,9 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
   // completed later. GCC does not diagnose such code, but we may want to
   // consider diagnosing it in the future, perhaps under a 
diff erent, but
   // related, diagnostic group.
-  bool MayBeTriviallyCopyableCXXRecord =
-  RT->isIncompleteType() ||
-  RT->desugar().isTriviallyCopyableType(Context);
+  bool NonTriviallyCopyableCXXRecord =
+  getLangOpts().CPlusPlus && !RT->isIncompleteType() &&
+  !RT->desugar().isTriviallyCopyableType(Context);
 
   if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
   RT->getDecl()->isNonTrivialToPrimitiveDefaultInitialize()) {
@@ -9746,7 +9746,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
 << ArgIdx << FnName << PointeeTy << 0);
 SearchNonTrivialToInitializeField::diag(PointeeTy, Dest, *this);
   } else if ((BId == Builtin::BImemset || BId == Builtin::BIbzero) &&
- !MayBeTriviallyCopyableCXXRecord && ArgIdx == 0) {
+ NonTriviallyCopyableCXXRecord && ArgIdx == 0) {
 // FIXME: Limiting this warning to dest argument until we decide
 // whether it's valid for source argument too.
 DiagRuntimeBehavior(Dest->getExprLoc(), Dest,
@@ -9759,7 +9759,7 @@ void Sema::CheckMemaccessArguments(const CallExpr *Call,
 << ArgIdx << FnName << PointeeTy << 1);
 SearchNonTrivialToCopyField::diag(PointeeTy, Dest, *this);
   } else if ((BId == Builtin::BImemcpy || BId == Builtin::BImemmove) &&
- !MayBeTriviallyCopyableCXXRecord && ArgIdx == 0) {
+ NonTriviallyCopyableCXXRecord && ArgIdx == 0) {
 // FIXME: Limiting this warning to dest argument until we decide
 // whether it's valid for source argument too.
 DiagRuntimeBehavior(Dest->getExprLoc(), Dest,

diff  --git a/clang/test/Sema/warn-nontrivial-struct-memaccess-ptrauth.c 
b/clang/test/Sema/warn-nontrivial-struct-memaccess-ptrauth.c
new file mode 100644
index 0..9cdb98e55458b
--- /dev/null
+++ b/clang/test/Sema/warn-nontrivial-struct-memaccess-ptrauth.c
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls 
-fptrauth-intrinsics -fsyntax-only -verify=c,expected %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls 
-fptrauth-intrinsics -fsyntax-only -verify=c,expected %s
+// RUN: %clang_cc1 -triple arm64-apple-ios -fptrauth-calls 
-fptrauth-intrinsics -fsyntax-only -x c++ -verify=cxx,expected %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls 
-fptrauth-intrinsics -fsyntax-only -x c++ -verify=cxx,expected %s
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+void *memset(void *, int, __SIZE_TYPE__);
+void bzero(void *, __SIZE_TYPE__);
+void *memcpy(void *, const void *, __SIZE_TYPE__);
+void *memmove(void *, const void *, __SIZE_TYPE__);
+
+#if defined __cplusplus
+}
+#endif
+
+#define AQ __ptrauth(1,1,50)
+#define IQ __ptrauth(1,0,50)
+
+struct PtrAuthTrivial {
+  int f0;
+  int * IQ f1;
+};
+
+struct PtrAuthNonTrivial0 {
+  int f0;
+  int * AQ f1; // c-note 2 {{non-trivial to copy}}
+  int f2;
+};
+
+struct PtrAuthNonTrivial1 {
+  int * AQ f0; // c-note 2 {{non-trivial to copy}}
+  int f1;
+  struct PtrAuthNonTrivial0 f2;
+};
+
+void testPtrAuthTrivial(struct PtrAuthTrivial *d, struct PtrAuthTrivial *s) {
+  memset(d, 0, sizeof(struct PtrAuthTrivial));
+  memset(d, 1, sizeof(struct PtrAuthTrivial));
+  bzero(d, sizeof(struct PtrAuthTrivial));
+  memcpy(d, s, sizeof(struct PtrAuthTrivial));
+  memmove(d, s, sizeof(struct PtrAuthTrivial));
+}
+
+void testPtrAuthNonTrivial1(struct PtrAuthNonTrivial1 *d,
+struct PtrAuthNonTrivial1 *s) {
+  memset(d, 0, sizeof

[clang] [llvm] [RISCV] Xqci Extensions v0.10.0 (PR #137881)

2025-04-29 Thread Sam Elliott via cfe-commits

https://github.com/lenary updated 
https://github.com/llvm/llvm-project/pull/137881

>From 77e11986173c1687db5694544337026badb37448 Mon Sep 17 00:00:00 2001
From: Sam Elliott 
Date: Tue, 29 Apr 2025 14:28:43 -0700
Subject: [PATCH 1/2] [RISCV] Xqci Extensions v0.10.0

This updates all the extensions to their version in the v0.10.0 spec.

All changes from this version are already implemented or are not
relevant to LLVM.
---
 .../Driver/print-supported-extensions-riscv.c |  14 +-
 llvm/docs/RISCVUsage.rst  |  40 ++---
 llvm/lib/Target/RISCV/RISCVFeatures.td| 146 +-
 llvm/test/CodeGen/RISCV/attributes.ll |  18 +--
 .../TargetParser/RISCVISAInfoTest.cpp |  26 ++--
 5 files changed, 122 insertions(+), 122 deletions(-)

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index b10850aadddc3..d96077e787960 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -200,21 +200,21 @@
 // CHECK-NEXT: ssctr1.0   'Ssctr' (Control Transfer 
Records Supervisor Level)
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqccmp   0.1   'Xqccmp' (Qualcomm 16-bit 
Push/Pop and Double Moves)
-// CHECK-NEXT: xqcia0.4   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
+// CHECK-NEXT: xqcia0.7   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
 // CHECK-NEXT: xqciac   0.3   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
 // CHECK-NEXT: xqcibi   0.2   'Xqcibi' (Qualcomm uC Branch 
Immediate Extension)
-// CHECK-NEXT: xqcibm   0.4   'Xqcibm' (Qualcomm uC Bit 
Manipulation Extension)
-// CHECK-NEXT: xqcicli  0.2   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
+// CHECK-NEXT: xqcibm   0.7   'Xqcibm' (Qualcomm uC Bit 
Manipulation Extension)
+// CHECK-NEXT: xqcicli  0.3   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
 // CHECK-NEXT: xqcicm   0.2   'Xqcicm' (Qualcomm uC 
Conditional Move Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
-// CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
-// CHECK-NEXT: xqciint  0.4   'Xqciint' (Qualcomm uC 
Interrupts Extension)
+// CHECK-NEXT: xqcicsr  0.3   'Xqcicsr' (Qualcomm uC CSR 
Extension)
+// CHECK-NEXT: xqciint  0.7   'Xqciint' (Qualcomm uC 
Interrupts Extension)
 // CHECK-NEXT: xqciio   0.1   'Xqciio' (Qualcomm uC 
External Input Output Extension)
 // CHECK-NEXT: xqcilb   0.2   'Xqcilb' (Qualcomm uC Long 
Branch Extension)
 // CHECK-NEXT: xqcili   0.2   'Xqcili' (Qualcomm uC Load 
Large Immediate Extension)
 // CHECK-NEXT: xqcilia  0.2   'Xqcilia' (Qualcomm uC Large 
Immediate Arithmetic Extension)
-// CHECK-NEXT: xqcilo   0.2   'Xqcilo' (Qualcomm uC Large 
Offset Load Store Extension)
-// CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
+// CHECK-NEXT: xqcilo   0.3   'Xqcilo' (Qualcomm uC Large 
Offset Load Store Extension)
+// CHECK-NEXT: xqcilsm  0.5   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
 // CHECK-NEXT: xqcisim  0.2   'Xqcisim' (Qualcomm uC 
Simulation Hint Extension)
 // CHECK-NEXT: xqcisls  0.2   'Xqcisls' (Qualcomm uC 
Scaled Load Store Extension)
 // CHECK-NEXT: xqcisync 0.2   'Xqcisync' (Qualcomm uC Sync 
Delay Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index d0689b779f551..49635273a036f 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -440,58 +440,58 @@ The current vendor extensions supported are:
   LLVM implements `version 0.1 of the 16-bit Push/Pop instructions and 
double-moves extension specification 
`__
 by Qualcomm. All instructions are prefixed with `qc.` as described in the 
specification.
 
 ``experimental-Xqcia``
-  LLVM implements `version 0.4 of the Qualcomm uC Arithmetic extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
+  LLVM implements `version 0.7 of the Qualcomm uC Arithmetic extension 
specification 


[clang] [clang AST] move mangling API to namespace clang to allow calls from swift-frontend (PR #137884)

2025-04-29 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,h -- 
clang/include/clang/AST/Mangle.h clang/lib/AST/Mangle.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h
index 1afbf80df..ca72dcfd4 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -43,9 +43,9 @@ class VarDecl;
 /// Extract mangling function name from MangleContext such that swift can call
 /// it to prepare for ObjCDirect in swift.
 void mangleObjCMethodName(raw_ostream &OS, bool includePrefixByte,
-  bool isInstanceMethod, StringRef ClassName,
-  std::optional CategoryName,
-  StringRef MethodName);
+  bool isInstanceMethod, StringRef ClassName,
+  std::optional CategoryName,
+  StringRef MethodName);
 
 /// MangleContext - Context for tracking state which persists across multiple
 /// calls to the C++ name mangler.

``




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


[clang-tools-extra] [clang-doc] Add start and end line numbers (PR #137732)

2025-04-29 Thread Paul Kirth via cfe-commits


@@ -795,43 +787,52 @@ emitInfo(const CXXMethodDecl *D, const FullComment *FC, 
int LineNumber,
 }
 
 std::pair, std::unique_ptr>
-emitInfo(const TypedefDecl *D, const FullComment *FC, int LineNumber,
- StringRef File, bool IsFileInRootDir, bool PublicOnly) {
-  TypedefInfo Info;
+emitInfo(const TypedefDecl *D, const FullComment *FC, Location Loc,
+ bool PublicOnly) {
 
+  TypedefInfo Info;
+  ASTContext &Context = D->getASTContext();
   bool IsInAnonymousNamespace = false;
   populateInfo(Info, D, FC, IsInAnonymousNamespace);
+
   if (!shouldSerializeInfo(PublicOnly, IsInAnonymousNamespace, D))
 return {};
 
-  Info.DefLoc.emplace(LineNumber, File, IsFileInRootDir);
+  Info.DefLoc = Loc;
   auto &LO = D->getLangOpts();
   Info.Underlying = getTypeInfoForType(D->getUnderlyingType(), LO);
+
   if (Info.Underlying.Type.Name.empty()) {
 // Typedef for an unnamed type. This is like "typedef struct { } Foo;"
 // The record serializer explicitly checks for this syntax and constructs
 // a record with that name, so we don't want to emit a duplicate here.
 return {};
   }
   Info.IsUsing = false;
-
+  if (RawComment *Comment = D->getASTContext().getRawCommentForDeclNoCache(D)) 
{
+Comment->setAttached();
+if (comments::FullComment *Fc = Comment->parse(Context, nullptr, D)) {
+  Info.Description.emplace_back();
+  parseFullComment(Fc, Info.Description.back());
+}
+  }

ilovepi wrote:

Removed.

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


[clang] [clang][headers][Apple] Don't include_next float.h to avoid an unnecessary module dependency (PR #137432)

2025-04-29 Thread John McCall via cfe-commits

rjmccall wrote:

Messing around with `#include_next` is scary, but the problems are always 
thorny reasons that only come up in intense testing; I don't see anything 
obviously wrong, and I trust @ian-twilightcoder to have done the investigation 
properly. LGTM.

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


[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)

2025-04-29 Thread Gedare Bloom via cfe-commits

https://github.com/gedare updated 
https://github.com/llvm/llvm-project/pull/108332

>From 64000ad7d2310ac916b37ed808997bfcb6b9f324 Mon Sep 17 00:00:00 2001
From: Gedare Bloom 
Date: Thu, 20 Jun 2024 17:35:39 -0600
Subject: [PATCH 1/4] Format: add AlignAfterControlStatement

Introduce new style option to allow overriding the breaking after the
opening parenthesis for control statements (if/for/while/switch).

Fixes #67738.
Fixes #79176.
Fixes #80123.
---
 clang/include/clang/Format/Format.h|  17 ++
 clang/lib/Format/ContinuationIndenter.cpp  |  70 +++--
 clang/lib/Format/Format.cpp|  11 +
 clang/lib/Format/TokenAnnotator.cpp|   7 +-
 clang/unittests/Format/ConfigParseTest.cpp |   8 +
 clang/unittests/Format/FormatTest.cpp  | 299 +
 6 files changed, 390 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index f6ceef08b46da..274a9e4ee272a 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -62,6 +62,22 @@ struct FormatStyle {
   /// \version 3.3
   int AccessModifierOffset;
 
+  /// Different styles for breaking the parenthesis after a control statement
+  /// (``if/switch/while/for ...``).
+  /// \version 21
+  enum BreakAfterControlStatementStyle : int8_t {
+/// Use the default behavior.
+BACSS_Default,
+/// Force break after the left parenthesis of a control statement only
+/// when the expression exceeds the column limit, and align on the
+/// ``ContinuationIndentWidth``.
+BACSS_MultiLine,
+/// Do not force a break after the control statment.
+BACSS_No,
+  };
+
+  BreakAfterControlStatementStyle AlignAfterControlStatement;
+
   /// Different styles for aligning after open brackets.
   enum BracketAlignmentStyle : int8_t {
 /// Align parameters on the open bracket, e.g.:
@@ -5283,6 +5299,7 @@ struct FormatStyle {
   bool operator==(const FormatStyle &R) const {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
+   AlignAfterControlStatement == R.AlignAfterControlStatement &&
AlignArrayOfStructures == R.AlignArrayOfStructures &&
AlignConsecutiveAssignments == R.AlignConsecutiveAssignments &&
AlignConsecutiveBitFields == R.AlignConsecutiveBitFields &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 55e1d1ceb55b7..08558d6550832 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -814,6 +814,11 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
&State, bool DryRun,
   // parenthesis by disallowing any further line breaks if there is no line
   // break after the opening parenthesis. Don't break if it doesn't conserve
   // columns.
+  auto IsOtherConditional = [&](const FormatToken &Tok) {
+return Tok.isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch) ||
+   (Style.isJavaScript() && Tok.is(Keywords.kw_await) && Tok.Previous 
&&
+Tok.Previous->is(tok::kw_for));
+  };
   auto IsOpeningBracket = [&](const FormatToken &Tok) {
 auto IsStartOfBracedList = [&]() {
   return Tok.is(tok::l_brace) && Tok.isNot(BK_Block) &&
@@ -825,26 +830,37 @@ void 
ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
 }
 if (!Tok.Previous)
   return true;
-if (Tok.Previous->isIf())
-  return Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak;
-return !Tok.Previous->isOneOf(TT_CastRParen, tok::kw_for, tok::kw_while,
-  tok::kw_switch) &&
-   !(Style.isJavaScript() && Tok.Previous->is(Keywords.kw_await));
+if (Tok.Previous->isIf()) {
+  /* For backward compatibility, use AlignAfterOpenBracket
+   * in case AlignAfterControlStatement is not initialized */
+  return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine 
||
+(Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
+ Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
+}
+if (IsOtherConditional(*Tok.Previous)) {
+  return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
+}
+if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
+   Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+  return !Tok.Previous->is(TT_CastRParen) &&
+ !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
+}
+return false;
   };
   auto IsFunctionCallParen = [](const FormatToken &Tok) {
 return Tok.is(tok::l_paren) && Tok.ParameterCount > 0 && Tok.Previous &&
Tok.Previous->is(tok::identifier);
   };
-  auto IsInTemplateString = [this](const FormatToken &Tok) {
+  auto IsInTemplateString = [this](const FormatToken &Tok, bool NestBlocks) {
 if (!Style.isJavaScript())
 

[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)

2025-04-29 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 h,cpp -- 
clang/include/clang/Format/Format.h clang/lib/Format/ContinuationIndenter.cpp 
clang/lib/Format/Format.cpp clang/lib/Format/TokenAnnotator.cpp 
clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 08558d655..f4e48b7e3 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -834,16 +834,15 @@ void 
ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   /* For backward compatibility, use AlignAfterOpenBracket
* in case AlignAfterControlStatement is not initialized */
   return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine 
||
-(Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
- Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
+ (Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
+  Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
 }
-if (IsOtherConditional(*Tok.Previous)) {
+if (IsOtherConditional(*Tok.Previous))
   return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
-}
 if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
-   Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
   return !Tok.Previous->is(TT_CastRParen) &&
- !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
+ !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
 }
 return false;
   };
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index e6a82a093..cd7e4cb06 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -202,8 +202,10 @@ template <> struct 
MappingTraits {
   }
 };
 
-template <> struct 
ScalarEnumerationTraits {
-  static void enumeration(IO &IO, FormatStyle::BreakAfterControlStatementStyle 
&Value) {
+template <>
+struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO,
+  FormatStyle::BreakAfterControlStatementStyle &Value) 
{
 IO.enumCase(Value, "Default", FormatStyle::BACSS_Default);
 IO.enumCase(Value, "MultiLine", FormatStyle::BACSS_MultiLine);
 IO.enumCase(Value, "No", FormatStyle::BACSS_No);
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 39ddb63d4..881d40abf 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -6221,7 +6221,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
 const FormatToken *Previous = Right.MatchingParen->Previous;
 if (!Previous)
   return true;
-if (Previous->isIf() || Previous->isOneOf(tok::kw_for, tok::kw_while, 
tok::kw_switch)) {
+if (Previous->isIf() ||
+Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch)) {
   return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
 }
 return true;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 7841caefd..a314a0bff 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9797,7 +9797,6 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
"}",
Style);
 
-
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
   Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
 

``




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


[clang] [llvm] [clang] Implement JSON formatted -ftime-report (PR #137737)

2025-04-29 Thread Alan Zhao via cfe-commits

https://github.com/alanzhao1 updated 
https://github.com/llvm/llvm-project/pull/137737

>From 1f0529aa5fbf9c4c1b3f0e58eaf5e527dc1605f2 Mon Sep 17 00:00:00 2001
From: Alan Zhao 
Date: Mon, 28 Apr 2025 16:21:29 -0700
Subject: [PATCH 1/2] [clang] Implement JSON formatted -ftime-report

This patch adds a new flag, -ftime-report-json, which outputs the same
information as -ftime-report but as JSON instead of -ftime-report's
pretty printed format.
---
 clang/include/clang/Basic/CodeGenOptions.def |  3 ++-
 clang/include/clang/Driver/Options.td|  5 +
 clang/lib/Driver/ToolChains/Clang.cpp|  1 +
 clang/lib/Frontend/CompilerInvocation.cpp| 13 ++---
 clang/test/Misc/time-passes.c|  8 
 clang/tools/driver/cc1_main.cpp  |  9 -
 llvm/lib/Support/Timer.cpp   |  4 
 7 files changed, 34 insertions(+), 9 deletions(-)

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index c5990fb248689..927972015c3dc 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -318,8 +318,9 @@ CODEGENOPT(SpeculativeLoadHardening, 1, 0) ///< Enable 
speculative load hardenin
 CODEGENOPT(FineGrainedBitfieldAccesses, 1, 0) ///< Enable fine-grained 
bitfield accesses.
 CODEGENOPT(StrictEnums   , 1, 0) ///< Optimize based on strict enum 
definition.
 CODEGENOPT(StrictVTablePointers, 1, 0) ///< Optimize based on the strict 
vtable pointers
-CODEGENOPT(TimePasses, 1, 0) ///< Set when -ftime-report or 
-ftime-report= is enabled.
+CODEGENOPT(TimePasses, 1, 0) ///< Set when -ftime-report or 
-ftime-report= or -ftime-report-json is enabled.
 CODEGENOPT(TimePassesPerRun  , 1, 0) ///< Set when -ftime-report=per-pass-run 
is enabled.
+CODEGENOPT(TimePassesJson, 1, 0) ///< Set when -ftime-report-json is 
enabled.
 CODEGENOPT(TimeTrace , 1, 0) ///< Set when -ftime-trace is enabled.
 VALUE_CODEGENOPT(TimeTraceGranularity, 32, 500) ///< Minimum time granularity 
(in microseconds),
///< traced by time profiler
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a9f4083920663..c822736e5d585 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4083,6 +4083,11 @@ defm ms_tls_guards : BoolFOption<"ms-tls-guards",
 def ftime_report : Flag<["-"], "ftime-report">, Group,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   MarshallingInfoFlag>;
+def ftime_report_json
+: Flag<["-"], "ftime-report-json">,
+  Group,
+  Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+  MarshallingInfoFlag>;
 def ftime_report_EQ: Joined<["-"], "ftime-report=">, Group,
   Visibility<[ClangOption, CC1Option]>, Values<"per-pass,per-pass-run">,
   MarshallingInfoFlag>,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 762f8af886920..a2462b8f7a63b 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7011,6 +7011,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_parseable_fixits);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_ftime_report_json);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
   Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 8ff62ae2552c3..c7d11e6027ccf 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1699,6 +1699,9 @@ void CompilerInvocationBase::GenerateCodeGenArgs(const 
CodeGenOptions &Opts,
   GenerateArg(Consumer, OPT_ftime_report_EQ, "per-pass-run");
 else
   GenerateArg(Consumer, OPT_ftime_report);
+
+if (Opts.TimePassesJson)
+  GenerateArg(Consumer, OPT_ftime_report_json);
   }
 
   if (Opts.PrepareForLTO && !Opts.PrepareForThinLTO)
@@ -2000,12 +2003,13 @@ bool 
CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
 : llvm::codegenoptions::DebugTemplateNamesKind::Mangled);
   }
 
-  if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ)) {
+  if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ,
+ OPT_ftime_report_json)) {
 Opts.TimePasses = true;
 
 // -ftime-report= is only for new pass manager.
-if (A->getOption().getID() == OPT_ftime_report_EQ) {
-  StringRef Val = A->getValue();
+if (const Arg *EQ = Args.getLastArg(OPT_ftime_report_EQ)) {
+  StringRef Val = EQ->getValue();
   if (Val == "per-pass")

[clang] Better diagnostics when assertion fails in `consteval` (PR #130458)

2025-04-29 Thread JJ Marr via cfe-commits

https://github.com/jj-marr updated 
https://github.com/llvm/llvm-project/pull/130458

>From d06c5ab5c30e535893335af798df339b0e9c6878 Mon Sep 17 00:00:00 2001
From: JJ Marr 
Date: Sat, 8 Mar 2025 22:00:45 -0500
Subject: [PATCH] Explain which assertion failed during consteval

---
 .../clang/Basic/DiagnosticSemaKinds.td|  2 ++
 clang/lib/AST/ExprConstant.cpp| 11 ++
 clang/test/SemaCXX/consteval-assert.cpp   | 20 +++
 3 files changed, 33 insertions(+)
 create mode 100644 clang/test/SemaCXX/consteval-assert.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 4c96142e28134..58f32066f5da5 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -162,6 +162,8 @@ def err_ice_too_large : Error<
   "integer constant expression evaluates to value %0 that cannot be "
   "represented in a %1-bit %select{signed|unsigned}2 integer type">;
 def err_expr_not_string_literal : Error<"expression is not a string literal">;
+def note_constexpr_assert_failed : Note<
+  "assertion failed in constant evaluation: '%0'">;
 
 // Semantic analysis of constant literals.
 def ext_predef_outside_function : Warning<
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f2e49b9ea669e..3467a4d71acd5 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -8409,6 +8409,17 @@ class ExprEvaluatorBase
 return false;
 }
 
+// If an assertion fails during constant evaluation, give a specific note 
explaining that
+if (FD->getName() == "__assert_fail") {
+  const Expr *AssertionExpr = E->getArg(0);
+  const StringLiteral *AssertionText = 
dyn_cast(AssertionExpr->IgnoreParens()->IgnoreParenImpCasts());
+
+  Info.FFDiag(E->getBeginLoc(), diag::note_constexpr_assert_failed)
+  << (AssertionText ? AssertionText->getString() : "");
+
+  return false;
+}
+
 SmallVector CovariantAdjustmentPath;
 if (This) {
   auto *NamedMember = dyn_cast(FD);
diff --git a/clang/test/SemaCXX/consteval-assert.cpp 
b/clang/test/SemaCXX/consteval-assert.cpp
new file mode 100644
index 0..d253db2a3ddde
--- /dev/null
+++ b/clang/test/SemaCXX/consteval-assert.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++23 -verify=expected,cxx20_plus %s
+
+#ifdef __ASSERT_FUNCTION
+#undef __ASSERT_FUNCTION
+#endif
+extern "C" void __assert_fail(const char*, const char*, unsigned, const char*);
+
+#define assert(cond) \
+  ((cond) ? (void)0 : __assert_fail(#cond, __FILE__, __LINE__, __func__))
+
+consteval int square(int x) {
+  int result = x * x;
+  assert(result == 42); // expected-note {{assertion failed in constant 
evaluation: 'result == 42'}}
+  return result;
+}
+
+void test() {
+  auto val = square(2); // expected-note {{in call to 'square(2)'}} \
+  // expected-error {{call to consteval function 'square' is not a constant 
expression}}
+}

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


[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-04-29 Thread Craig Topper via cfe-commits


@@ -1197,6 +1197,73 @@ def HasVendorXSfvcp : 
Predicate<"Subtarget->hasVendorXSfvcp()">,
   AssemblerPredicate<(all_of FeatureVendorXSfvcp),
   "'XSfvcp' (SiFive Custom Vector Coprocessor 
Interface Instructions)">;
 
+def FeatureVendorXSfmmbase
+: RISCVExtension<0, 6,
+ "All non arithmetic instructions for all TEWs and 
sf.vtzero",
+ [FeatureStdExtZve32x]>;
+def HasVendorXSfmmbase : Predicate<"Subtarget->hasVendorXSfmmbase()">,
+ AssemblerPredicate<(all_of FeatureVendorXSfmmbase),
+ "'XSfmmbase' (All non arithmetic instructions for 
all TEWs and sf.vtzero)">;
+
+def FeatureVendorXSfmm32a8f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: fp8",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+def HasVendorXSfmm32a8f : Predicate<"Subtarget->hasVendorXSfmm32a8f()">,
+  AssemblerPredicate<(all_of FeatureVendorXSfmm32a8f),
+  "'XSfmm32a8f' (TEW=32-bit accumulation, operands 
- float: fp8)">;
+
+def FeatureVendorXSfmm32a16f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: 16b, widen=2 
(IEEE, BF)",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+
+def FeatureVendorXSfmm32a32f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: 32b",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+
+def FeatureVendorXSfmm32a8i
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - int: 8b",
+ [FeatureVendorXSfmmbase]>;
+def HasVendorXSfmm32a8i : Predicate<"Subtarget->hasVendorXSfmm32a8i()">,
+  AssemblerPredicate<(all_of FeatureVendorXSfmm32a8i),
+  "'XSfmm32a8i' (TEW=32-bit accumulation, operands 
- int: 8b)">;
+
+def FeatureVendorXSfmm64a64f
+: RISCVExtension<0, 6,
+ "TEW=64-bit accumulation, operands - float: fp64",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve64d]>;
+def HasVendorXSfmm32a16fOrXSfmm32a32fOrXSfmm64a64f
+: Predicate<"Subtarget->hasVendorXSfmm32a16fOrXSfmm32a32fOrXSfmm64a64f()">,
+AssemblerPredicate<(any_of FeatureVendorXSfmm32a16f,
+   FeatureVendorXSfmm32a32f,
+   FeatureVendorXSfmm64a64f),
+"'XSfmm32a16f' (TEW=32-bit accumulation, operands - float: 
16b, widen=2 (IEEE, BF)), or "
+"'XSfmm32a32f' (TEW=32-bit accumulation, operands - float: 
32b), or "
+"'XSfmm64a64f' (TEW=64-bit accumulation, operands - float: 
fp64)">;
+
+def FeatureVendorXSfmm16t
+: RISCVExtension<0, 6,
+ "TE=16 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl64b], "XSfmmTE", 
"16">;
+
+def FeatureVendorXSfmm32t
+: RISCVExtension<0, 6,
+ "TE=32 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl128b], 
"XSfmmTE", "32">;
+
+def FeatureVendorXSfmm64t
+: RISCVExtension<0, 6,
+ "TE=64 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl256b], 
"XSfmmTE", "64">;
+
+def FeatureVendorXSfmm128t
+: RISCVExtension<0, 6,
+ "TE=128 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl512b], 
"XSfmmTE", "128">;

topperc wrote:

Are you asking me to add FeatureVendorXSfmm16384t?

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


[clang] [clang-format] Add OneLineFormatOffRegex option (PR #137577)

2025-04-29 Thread via cfe-commits

dyung wrote:

> @dyung I don't see anything in this patch could cause a failure in CodGen 
> tests. Have you verified it e.g. by running the tests on 
> [f175030](https://github.com/llvm/llvm-project/commit/f1750300aad0e49383cd4b206e2354f1300a40a8)?

One of the bots did.
- f1750300aad0e49383cd4b206e2354f1300a40a8 
(https://lab.llvm.org/buildbot/#/builders/144/builds/23924): pass
- b8bb1ccb4f9126d1bc9817be24e17f186a75a08b 
(https://lab.llvm.org/buildbot/#/builders/144/builds/23925): fail

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


[clang] [Clang][CodeGen] Check `isUnderlyingBasePointerConstantNull` in `emitPointerArithmetic` (PR #137849)

2025-04-29 Thread Yingwei Zheng via cfe-commits


@@ -4238,7 +4238,8 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF,
   else
 elemTy = CGF.ConvertTypeForMem(elementType);
 
-  if (CGF.getLangOpts().PointerOverflowDefined)
+  if (CGF.getLangOpts().PointerOverflowDefined ||
+  CGF.isUnderlyingBasePointerConstantNull(pointerOperand))

dtcxzyw wrote:

`BinaryOperator::isNullPointerArithmeticExtension` only allows the pointer 
operand to be a constant null. But `isUnderlyingBasePointerConstantNull` also 
catches `((struct S*)0)->field`.
I think it is safe to remove this workaround and fall through to the 
`isUnderlyingBasePointerConstantNull` check.


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


[clang] [CIR] Upstream initial support for union type (PR #137501)

2025-04-29 Thread Iris Shi via cfe-commits

https://github.com/el-ev updated 
https://github.com/llvm/llvm-project/pull/137501

>From b8011997fdc2548be80dd9305d758466a66cee4c Mon Sep 17 00:00:00 2001
From: Iris Shi <0...@owo.li>
Date: Sun, 27 Apr 2025 15:16:19 +0800
Subject: [PATCH 1/2] [CIR] Upstream initial support for union type

---
 .../include/clang/CIR/Dialect/IR/CIRTypes.td  |   1 +
 clang/lib/CIR/CodeGen/CIRGenExpr.cpp  |  25 ++--
 clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp |   2 +-
 .../CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp |  94 +++-
 clang/lib/CIR/Dialect/IR/CIRTypes.cpp |  40 --
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp |  15 +-
 clang/test/CIR/CodeGen/union.c| 135 +-
 7 files changed, 276 insertions(+), 36 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td 
b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
index 0a821e152d353..afb7da1fa011d 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRTypes.td
@@ -494,6 +494,7 @@ def CIR_RecordType : CIR_Type<"Record", "record",
 bool isComplete() const { return !isIncomplete(); };
 bool isIncomplete() const;
 
+mlir::Type getLargestMember(const mlir::DataLayout &dataLayout) const;
 size_t getNumElements() const { return getMembers().size(); };
 std::string getKindAsStr() {
   switch (getKind()) {
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
index 0a518c0fd935d..9069d1a2cf6ac 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
@@ -317,20 +317,25 @@ LValue CIRGenFunction::emitLValueForField(LValue base, 
const FieldDecl *field) {
   }
 
   unsigned recordCVR = base.getVRQualifiers();
-  if (rec->isUnion()) {
-cgm.errorNYI(field->getSourceRange(), "emitLValueForField: union");
-return LValue();
-  }
 
-  assert(!cir::MissingFeatures::preservedAccessIndexRegion());
   llvm::StringRef fieldName = field->getName();
-  const CIRGenRecordLayout &layout =
-  cgm.getTypes().getCIRGenRecordLayout(field->getParent());
-  unsigned fieldIndex = layout.getCIRFieldNo(field);
 
-  assert(!cir::MissingFeatures::lambdaFieldToName());
+  if (rec->isUnion()) {
+unsigned fieldIndex = field->getFieldIndex();
+assert(!cir::MissingFeatures::lambdaFieldToName());
+addr = emitAddrOfFieldStorage(addr, field, fieldName, fieldIndex);
+
+  } else {
+assert(!cir::MissingFeatures::preservedAccessIndexRegion());
+
+const CIRGenRecordLayout &layout =
+cgm.getTypes().getCIRGenRecordLayout(field->getParent());
+unsigned fieldIndex = layout.getCIRFieldNo(field);
 
-  addr = emitAddrOfFieldStorage(addr, field, fieldName, fieldIndex);
+assert(!cir::MissingFeatures::lambdaFieldToName());
+
+addr = emitAddrOfFieldStorage(addr, field, fieldName, fieldIndex);
+  }
 
   // If this is a reference field, load the reference right now.
   if (fieldType->isReferenceType()) {
diff --git a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
index 368a6cb27c0fd..e006a77c6e7d6 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExprAggregate.cpp
@@ -1,4 +1,4 @@
-//===--- CIRGenExprAgg.cpp - Emit CIR Code from Aggregate Expressions 
-===//
+//===- CIRGenExprAggregrate.cpp - Emit CIR Code from Aggregate Expressions 
===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp 
b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
index 83aba256cd48e..7b9631daacfdd 100644
--- a/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenRecordLayoutBuilder.cpp
@@ -56,7 +56,7 @@ struct CIRRecordLowering final {
   };
   // The constructor.
   CIRRecordLowering(CIRGenTypes &cirGenTypes, const RecordDecl *recordDecl,
-bool isPacked);
+bool packed);
 
   /// Constructs a MemberInfo instance from an offset and mlir::Type.
   MemberInfo makeStorageInfo(CharUnits offset, mlir::Type data) {
@@ -64,6 +64,7 @@ struct CIRRecordLowering final {
   }
 
   void lower();
+  void lowerUnion();
 
   /// Determines if we need a packed llvm struct.
   void determinePacked();
@@ -83,6 +84,10 @@ struct CIRRecordLowering final {
 return CharUnits::fromQuantity(dataLayout.layout.getTypeABIAlignment(Ty));
   }
 
+  bool isZeroInitializable(const FieldDecl *fd) {
+return cirGenTypes.isZeroInitializable(fd->getType());
+  }
+
   /// Wraps cir::IntType with some implicit arguments.
   mlir::Type getUIntNType(uint64_t numBits) {
 unsigned alignedBits = llvm::PowerOf2Ceil(numBits);
@@ -121,6 +126,13 @@ struct CIRRecordLowering final {
   /// Fills out the structures that are ultimately consumed.
   void fillOutputFields();
 
+  void appendPaddingBytes(CharU

[clang-tools-extra] 97ec3ef - [clang-doc] Add start and end line numbers (#137732)

2025-04-29 Thread via cfe-commits

Author: Paul Kirth
Date: 2025-04-29T14:57:35-07:00
New Revision: 97ec3ef4ab0eaf5e1fde9a3bf4bf4a9aaad49f33

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

LOG: [clang-doc] Add start and end line numbers (#137732)

This patch adds start and end line numbers to clang-doc. Currently
clang-doc only encodes the start line numbers of records, struct, etc.
This patch adds start and end line number to clang-doc bitcode which is
passed to the generator. This will be used by the mustache backend to
generate line ranges. Based on the orginal patch in #135081.

Co-author: Paul Kirth 

Co-authored-by: PeterChou1 

Added: 


Modified: 
clang-tools-extra/clang-doc/BitcodeReader.cpp
clang-tools-extra/clang-doc/BitcodeWriter.cpp
clang-tools-extra/clang-doc/HTMLGenerator.cpp
clang-tools-extra/clang-doc/MDGenerator.cpp
clang-tools-extra/clang-doc/Mapper.cpp
clang-tools-extra/clang-doc/Mapper.h
clang-tools-extra/clang-doc/Representation.h
clang-tools-extra/clang-doc/Serialize.cpp
clang-tools-extra/clang-doc/Serialize.h
clang-tools-extra/clang-doc/YAMLGenerator.cpp
clang-tools-extra/unittests/clang-doc/BitcodeTest.cpp
clang-tools-extra/unittests/clang-doc/ClangDocTest.cpp
clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MDGeneratorTest.cpp
clang-tools-extra/unittests/clang-doc/MergeTest.cpp
clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
clang-tools-extra/unittests/clang-doc/YAMLGeneratorTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/BitcodeReader.cpp 
b/clang-tools-extra/clang-doc/BitcodeReader.cpp
index 92674c5507e74..f8e338eb7c6ed 100644
--- a/clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -79,7 +79,8 @@ static llvm::Error decodeRecord(const Record &R, 
std::optional &Field,
   if (R[0] > INT_MAX)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"integer too large to parse");
-  Field.emplace(static_cast(R[0]), Blob, static_cast(R[1]));
+  Field.emplace(static_cast(R[0]), static_cast(R[1]), Blob,
+static_cast(R[2]));
   return llvm::Error::success();
 }
 
@@ -130,7 +131,8 @@ static llvm::Error decodeRecord(const Record &R,
   if (R[0] > INT_MAX)
 return llvm::createStringError(llvm::inconvertibleErrorCode(),
"integer too large to parse");
-  Field.emplace_back(static_cast(R[0]), Blob, static_cast(R[1]));
+  Field.emplace_back(static_cast(R[0]), static_cast(R[1]), Blob,
+ static_cast(R[2]));
   return llvm::Error::success();
 }
 

diff  --git a/clang-tools-extra/clang-doc/BitcodeWriter.cpp 
b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
index 6545629f1c739..f0a445e606bff 100644
--- a/clang-tools-extra/clang-doc/BitcodeWriter.cpp
+++ b/clang-tools-extra/clang-doc/BitcodeWriter.cpp
@@ -78,13 +78,16 @@ static void 
genLocationAbbrev(std::shared_ptr &Abbrev) {
   {// 0. Fixed-size integer (line number)
llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,
  BitCodeConstants::LineNumberSize),
-   // 1. Boolean (IsFileInRootDir)
+   // 1. Fixed-size integer (start line number)
+   llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,
+ BitCodeConstants::LineNumberSize),
+   // 2. Boolean (IsFileInRootDir)
llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,
  BitCodeConstants::BoolSize),
-   // 2. Fixed-size integer (length of the following string (filename))
+   // 3. Fixed-size integer (length of the following string (filename))
llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Fixed,
  BitCodeConstants::StringLengthSize),
-   // 3. The string blob
+   // 4. The string blob
llvm::BitCodeAbbrevOp(llvm::BitCodeAbbrevOp::Blob)});
 }
 
@@ -357,7 +360,8 @@ void ClangDocBitcodeWriter::emitRecord(const Location &Loc, 
RecordId ID) {
   if (!prepRecordData(ID, true))
 return;
   // FIXME: Assert that the line number is of the appropriate size.
-  Record.push_back(Loc.LineNumber);
+  Record.push_back(Loc.StartLineNumber);
+  Record.push_back(Loc.EndLineNumber);
   assert(Loc.Filename.size() < (1U << BitCodeConstants::StringLengthSize));
   Record.push_back(Loc.IsFileInRootDir);
   Record.push_back(Loc.Filename.size());

diff  --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp 
b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 6d061b33a67c1..4ad5ba29b28b8 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -455,7 +455,7 @@ static std::unique_ptr write

[clang-tools-extra] [clang-doc] Add start and end line numbers (PR #137732)

2025-04-29 Thread Paul Kirth via cfe-commits

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


[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Damyan Pepper via cfe-commits

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


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


[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Damyan Pepper via cfe-commits


@@ -106,3 +102,17 @@ float3 test_lerp_uint64_t3(uint64_t3 p0) { return lerp(p0, 
p0, p0); }
 // CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
 // CHECK: ret <4 x float> %hlsl.lerp
 float4 test_lerp_uint64_t4(uint64_t4 p0) { return lerp(p0, p0, p0); }
+
+// CHECK-LABEL: test_lerp_half_scalar
+// NATIVE_HALF: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x half> 
@llvm.[[TARGET]].lerp.v3f16(<3 x half> %{{.*}}, <3 x half> %{{.*}}, <3 x half> 
%{{.*}})
+// NATIVE_HALF: ret <3 x half> %hlsl.lerp
+// NO_HALF: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x 
float> %{{.*}})
+// NO_HALF: ret <3 x float> %hlsl.lerp
+half3 test_lerp_half_scalar(half3 x, half3 y, half s) { return lerp(x, y, s); }

damyanp wrote:

Would we not want something to see how `s` gets turned into a `3 x float`, or 
is that exercised enough elsewhere?

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


[clang] [clang AST] move mangling API to namespace clang to allow calls from swift-frontend (PR #137884)

2025-04-29 Thread Peter Rong via cfe-commits

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


[clang] [NFC][clang] No sharedlibs for UEFI (PR #137872)

2025-04-29 Thread Petr Hosek via cfe-commits

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


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


[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Justin Bogner via cfe-commits


@@ -277,6 +277,12 @@ constexpr bool4 isinf(double4 V) { return 
isinf((float4)V); }
 // lerp builtins overloads
 
//===--===//
 
+template 
+constexpr __detail::enable_if_t<(N > 1 && N <= 4), vector>

bogner wrote:

I also think it feels a bit odd, but I was following the examples from 
[clamp](https://github.com/llvm/llvm-project/issues#128230) and 
[min/max](https://github.com/llvm/llvm-project/issues#128231). I think if we're 
going to move them, we should do all of these together.

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


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

2025-04-29 Thread via cfe-commits


@@ -0,0 +1,1100 @@
+//===-- RISCVInstrInfoP.td - RISC-V 'P' instructions ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the RISC-V instructions from the standard 'Base P'
+// Packed SIMD instruction set extension.
+//
+//  This version is still experimental as the 'P' extension hasn't been
+//  ratified yet.
+//
+//===--===//
+
+//===--===//
+// Operand and SDNode transformation definitions.
+//===--===//
+
+def RVPGPRPairRV32 : RegisterOperand {
+  let ParserMatchClass = GPRPairRV32Operand;
+  let EncoderMethod = "getRVPGPRPair";
+  let DecoderMethod = "decodeRVPGPRPair";
+}
+
+def simm10 : RISCVSImmLeafOp<10> {
+  let MCOperandPredicate = [{
+int64_t Imm;
+if (!MCOp.evaluateAsConstantImm(Imm))
+  return false;
+return isInt<10>(Imm);
+  }];
+}
+
+//===--===//
+// Instruction class templates
+//===--===//
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm9 funct7, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins simm10:$simm10),
+  opcodestr, "$rd, $simm10"> {
+  bits<10> simm10;
+
+  let Inst{31-25} = funct7;
+  let Inst{24-15} = simm10;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm9Rdp funct7, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs RVPGPRPairRV32:$rdp),
+  (ins simm10:$simm10),
+  opcodestr, "$rdp, $simm10"> {
+  bits<10> simm10;
+  bits<4> rdp;
+
+  let Inst{31-25} = funct7;
+  let Inst{24-15} = simm10;
+  let Inst{11-8}  = rdp;
+  let Inst{7} = 0b0;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm8 funct8, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins uimm8:$uimm8),
+  opcodestr, "$rd, $uimm8"> {
+  bits<8> uimm8;
+
+  let Inst{31-24} = funct8;
+  let Inst{23-16} = uimm8;
+  let Inst{15}= 0b0;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm8Rdp funct8, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs RVPGPRPairRV32:$rdp),
+  (ins uimm8:$uimm8), opcodestr, "$rdp, $uimm8"> {
+  bits<8> uimm8;
+  bits<4> rdp;
+
+  let Inst{31-24} = funct8;
+  let Inst{23-16} = uimm8;
+  let Inst{15}= 0b0;
+  let Inst{11-8}  = rdp;
+  let Inst{7} = 0b0;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm5 f, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd),
+(ins GPR:$rs1, uimm5:$uimm5), opcodestr, "$rd, $rs1, $uimm5"> {
+  bits<5> uimm5;
+  let Inst{31}= 0b1;
+  let Inst{30-28} = f;
+  let Inst{27}= 0b0;
+  let Inst{26-25} = 0b01;
+  let Inst{24-20} = uimm5;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm4 f, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd),
+(ins GPR:$rs1, uimm4:$uimm4), opcodestr, "$rd, $rs1, $uimm4"> {
+  bits<4> uimm4;
+  let Inst{31}= 0b1;
+  let Inst{30-28} = f;
+  let Inst{27}= 0b0;
+  let Inst{26-24} = 0b001;
+  let Inst{23-20} = uimm4;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryImm3 f, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd),
+(ins GPR:$rs1, uimm3:$uimm3), opcodestr, "$rd, $rs1, $uimm3"> {
+  bits<3> uimm3;
+  let Inst{31}= 0b1;
+  let Inst{30-28} = f;
+  let Inst{27}= 0b0;
+  let Inst{26-23} = 0b0001;
+  let Inst{22-20} = uimm3;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryWUF w, bits<5> uf, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs GPR:$rd), (ins GPR:$rs1),
+  opcodestr, "$rd, $rs1">  {
+  let Inst{31-27} = 0b11100;
+  let Inst{26-25} = w;
+  let Inst{24-20} = uf;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryWUFRs1pRdp w, bits<5> uf, string opcodestr>
+: RVInstIBase<0b010, OPC_OP_IMM_32, (outs RVPGPRPairRV32:$rdp),
+  (ins RVPGPRPairRV32:$rs1p), opcodestr, "$rdp, $rs1p">  {
+  bits<4> rs1p;
+  bits<4> rdp;
+
+  let Inst{31-27} = 0b01100;
+  let Inst{26-25} = w;
+  let Inst{24-20} = uf;
+  let Inst{19-16} = rs1p;
+  let Inst{15}= 0b0;
+  let Inst{11-8}  = rdp;
+  let Inst{7} = 0b0;
+}
+
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in
+class RVPUnaryF f, bit aft, bits<7> wuimm, string o

[clang] [CIR] Upstream initial support for union type (PR #137501)

2025-04-29 Thread Iris Shi via cfe-commits


@@ -5,25 +5,146 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
 // RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
 
+union U1 {

el-ev wrote:

Padded and packed unions are added, `CIRGenTypes::isZeroInitializable` doesn't 
contain a path that returns false without triggering errorNYI.

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


[clang] [clang AST] move mangling API to namespace clang to allow calls from swift-frontend (PR #137884)

2025-04-29 Thread Peter Rong via cfe-commits

https://github.com/DataCorrupted updated 
https://github.com/llvm/llvm-project/pull/137884

>From f6166a6c2ab45edaa0ff273e2ba917fff778a243 Mon Sep 17 00:00:00 2001
From: Peter Rong 
Date: Tue, 29 Apr 2025 14:24:49 -0700
Subject: [PATCH 1/2] [clang] change mangling API to allow calls from
 swift-frontend

Signed-off-by: Peter Rong 
---
 clang/include/clang/AST/Mangle.h |  7 ++
 clang/lib/AST/Mangle.cpp | 37 +++-
 2 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h
index a0162fb7125fe..1afbf80df40cf 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -40,6 +40,13 @@ struct ThisAdjustment;
 struct ThunkInfo;
 class VarDecl;
 
+/// Extract mangling function name from MangleContext such that swift can call
+/// it to prepare for ObjCDirect in swift.
+void mangleObjCMethodName(raw_ostream &OS, bool includePrefixByte,
+  bool isInstanceMethod, StringRef ClassName,
+  std::optional CategoryName,
+  StringRef MethodName);
+
 /// MangleContext - Context for tracking state which persists across multiple
 /// calls to the C++ name mangler.
 class MangleContext {
diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 741c031a40385..9652fdbc4e125 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -29,6 +29,23 @@
 
 using namespace clang;
 
+void clang::mangleObjCMethodName(raw_ostream &OS, bool includePrefixByte,
+ bool isInstanceMethod, StringRef ClassName,
+ std::optional CategoryName,
+ StringRef MethodName) {
+  // \01+[ContainerName(CategoryName) SelectorName]
+  if (includePrefixByte)
+OS << "\01";
+  OS << (isInstanceMethod ? '-' : '+');
+  OS << '[';
+  OS << ClassName;
+  if (CategoryName)
+OS << "(" << *CategoryName << ")";
+  OS << " ";
+  OS << MethodName;
+  OS << ']';
+}
+
 // FIXME: For blocks we currently mimic GCC's mangling scheme, which leaves
 // much to be desired. Come up with a better mangling scheme.
 
@@ -362,26 +379,26 @@ void MangleContext::mangleObjCMethodName(const 
ObjCMethodDecl *MD,
   }
 
   // \01+[ContainerName(CategoryName) SelectorName]
-  if (includePrefixByte) {
-OS << '\01';
-  }
-  OS << (MD->isInstanceMethod() ? '-' : '+') << '[';
+  auto CategoryName = std::optional();
+  StringRef ClassName = "";
   if (const auto *CID = MD->getCategory()) {
 if (const auto *CI = CID->getClassInterface()) {
-  OS << CI->getName();
+  ClassName = CI->getName();
   if (includeCategoryNamespace) {
-OS << '(' << *CID << ')';
+CategoryName = CID->getName();
   }
 }
   } else if (const auto *CD =
  dyn_cast(MD->getDeclContext())) {
-OS << CD->getName();
+ClassName = CD->getName();
   } else {
 llvm_unreachable("Unexpected ObjC method decl context");
   }
-  OS << ' ';
-  MD->getSelector().print(OS);
-  OS << ']';
+  std::string MethodName;
+  llvm::raw_string_ostream MethodNameOS(MethodName);
+  MD->getSelector().print(MethodNameOS);
+  clang::mangleObjCMethodName(OS, includePrefixByte, MD->isInstanceMethod(),
+  ClassName, CategoryName, MethodName);
 }
 
 void MangleContext::mangleObjCMethodNameAsSourceName(const ObjCMethodDecl *MD,

>From 165f5119fd701ee42ca205ee259d8f65a10a0925 Mon Sep 17 00:00:00 2001
From: Peter Rong 
Date: Tue, 29 Apr 2025 14:52:14 -0700
Subject: [PATCH 2/2] Format

---
 clang/include/clang/AST/Mangle.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/Mangle.h b/clang/include/clang/AST/Mangle.h
index 1afbf80df40cf..ca72dcfd4483d 100644
--- a/clang/include/clang/AST/Mangle.h
+++ b/clang/include/clang/AST/Mangle.h
@@ -43,9 +43,9 @@ class VarDecl;
 /// Extract mangling function name from MangleContext such that swift can call
 /// it to prepare for ObjCDirect in swift.
 void mangleObjCMethodName(raw_ostream &OS, bool includePrefixByte,
-  bool isInstanceMethod, StringRef ClassName,
-  std::optional CategoryName,
-  StringRef MethodName);
+  bool isInstanceMethod, StringRef ClassName,
+  std::optional CategoryName,
+  StringRef MethodName);
 
 /// MangleContext - Context for tracking state which persists across multiple
 /// calls to the C++ name mangler.

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


[clang] [nfc][clang] Rename function (PR #137874)

2025-04-29 Thread Prabhu Rajasekaran via cfe-commits

https://github.com/Prabhuk updated 
https://github.com/llvm/llvm-project/pull/137874

>From 45778ad1a6cd0d7ce6333f6e8b69d4f4138b962e Mon Sep 17 00:00:00 2001
From: prabhukr 
Date: Tue, 29 Apr 2025 13:43:32 -0700
Subject: [PATCH] [nfc][clang] Rename function

Rename function to meet the coding guidelines. I am working on a similar
function in a subsequent PR. Landing this as NFC first to isolate this
change.
---
 clang/lib/CodeGen/CodeGenModule.cpp | 6 +++---
 clang/lib/CodeGen/CodeGenModule.h   | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index e917f3c42da06..447204d6c23af 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2661,7 +2661,7 @@ void 
CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
   // Skip available_externally functions. They won't be codegen'ed in the
   // current module anyway.
   if (getContext().GetGVALinkageForFunction(FD) != GVA_AvailableExternally)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 }
   }
 
@@ -2868,7 +2868,7 @@ static void setLinkageForGV(llvm::GlobalValue *GV, const 
NamedDecl *ND) {
 GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage);
 }
 
-void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
llvm::Function *F) {
   // Only if we are checking indirect calls.
   if (!LangOpts.Sanitize.has(SanitizerKind::CFIICall))
@@ -3016,7 +3016,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, 
llvm::Function *F,
   // jump table.
   if (!CodeGenOpts.SanitizeCfiCrossDso ||
   !CodeGenOpts.SanitizeCfiCanonicalJumpTables)
-CreateFunctionTypeMetadataForIcall(FD, F);
+createFunctionTypeMetadataForIcall(FD, F);
 
   if (LangOpts.Sanitize.has(SanitizerKind::KCFI))
 setKCFIType(FD, F);
diff --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 59f400570fb7a..1db5c3bc4e4ef 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1633,7 +1633,7 @@ class CodeGenModule : public CodeGenTypeCache {
   llvm::Metadata *CreateMetadataIdentifierGeneralized(QualType T);
 
   /// Create and attach type metadata to the given function.
-  void CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
+  void createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
   llvm::Function *F);
 
   /// Set type metadata to the given function.

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


[clang] [clang] Merge gtest binaries into AllClangUnitTests (PR #134196)

2025-04-29 Thread Reid Kleckner via cfe-commits

rnk wrote:

I disabled the failing test in 743c32eb8195c248c699c61ffbac141947b8e6ab.

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


[clang] [nfc][clang] Rename function (PR #137874)

2025-04-29 Thread Paul Kirth via cfe-commits

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

LGTM

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


[clang] 557ddc2 - [clang][headers][Apple] Don't include_next float.h to avoid an unnecessary module dependency (#137432)

2025-04-29 Thread via cfe-commits

Author: Ian Anderson
Date: 2025-04-29T14:59:28-07:00
New Revision: 557ddc2e5d066dbc9900cb158a842b9cd5864d8a

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

LOG: [clang][headers][Apple] Don't include_next float.h to avoid an unnecessary 
module dependency (#137432)

float.h doesn't define anything in Apple's SDKs that the clang float.h
doesn't undefine, so all the include_next does is add an unnecessary
module dependency. Skip the include_next and completely shadow the SDK
header.

Added: 


Modified: 
clang/lib/Headers/float.h

Removed: 




diff  --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h
index e5c439a9d47ae..84551af473b28 100644
--- a/clang/lib/Headers/float.h
+++ b/clang/lib/Headers/float.h
@@ -18,21 +18,12 @@
  * additional definitions provided for Windows.
  * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx
  *
- * Also fall back on Darwin and AIX to allow additional definitions and
+ * Also fall back on AIX to allow additional definitions and
  * implementation-defined values.
  */
-#if (defined(__APPLE__) || defined(__MINGW32__) || defined(_MSC_VER) ||
\
- defined(_AIX)) && 
\
+#if (defined(__MINGW32__) || defined(_MSC_VER) || defined(_AIX)) &&
\
 __STDC_HOSTED__ && __has_include_next()
 
-/* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
- * of #include_next to keep Metrowerks compilers happy. Avoid this
- * extra indirection.
- */
-#ifdef __APPLE__
-#define _FLOAT_H_
-#endif
-
 #  include_next 
 
 /* Undefine anything that we'll be redefining below. */



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


[clang] [clang][headers][Apple] Don't include_next float.h to avoid an unnecessary module dependency (PR #137432)

2025-04-29 Thread Ian Anderson via cfe-commits

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


[clang] [HLSL] Overloads for `lerp` with a scalar weight (PR #137877)

2025-04-29 Thread Farzon Lotfi via cfe-commits

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


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


[clang] [clang][SPIRV] Add builtin for OpGenericCastToPtrExplicit and its SPIR-V friendly binding (PR #137805)

2025-04-29 Thread Victor Lomuller via cfe-commits


@@ -35,8 +35,10 @@ static constexpr Builtin::Info BuiltinInfos[] = {
 static_assert(std::size(BuiltinInfos) == NumBuiltins);
 
 llvm::SmallVector
-SPIRVTargetInfo::getTargetBuiltins() const {
-  return {{&BuiltinStrings, BuiltinInfos}};
+BaseSPIRTargetInfo::getTargetBuiltins() const {
+  if (getTriple().isSPIRV())
+return {{&BuiltinStrings, BuiltinInfos}};

Naghasan wrote:

@farzonl Apply the suggestion, although you can't really split into 2 distinct 
set cleanly (common + vk and common + cl) due to the ID assignment (part is 
done dynamically). So I went for a unique set and diagnose when vk builtins are 
used with spirv32 or spirv32 or when cl builtins are used with spirv.

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


[clang-tools-extra] [clang-doc] Add start and end line numbers (PR #137732)

2025-04-29 Thread Paul Kirth via cfe-commits

ilovepi wrote:

hmm. Premege checks are broken due to #137876. Given that they  passed before, 
still pass locally, and I only removed some extraneous code I'm landing this 
w/o them passing.

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


[clang] 7ecd81e - [clang][NFC] Convert `Parser::ExtraSemiKind` to scoped enum

2025-04-29 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2025-04-30T02:31:31+03:00
New Revision: 7ecd81e266174253786e084c100c22c65a214b5d

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

LOG: [clang][NFC] Convert `Parser::ExtraSemiKind` to scoped enum

Added: 


Modified: 
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseObjc.cpp
clang/lib/Parse/Parser.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index dbbb80fdd9943..491abae96160f 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -64,6 +64,14 @@ enum class AnnotatedNameKind {
   Success
 };
 
+/// The kind of extra semi diagnostic to emit.
+enum class ExtraSemiKind {
+  OutsideFunction = 0,
+  InsideStruct = 1,
+  InstanceVariableList = 2,
+  AfterMemberFunctionDefinition = 3
+};
+
 /// Parser - This implements a parser for the C family of languages.  After
 /// parsing units of the grammar, productions are invoked to handle whatever 
has
 /// been read.
@@ -1120,14 +1128,6 @@ class Parser : public CodeCompletionHandler {
   /// to the semicolon, consumes that extra token.
   bool ExpectAndConsumeSemi(unsigned DiagID , StringRef TokenUsed = "");
 
-  /// The kind of extra semi diagnostic to emit.
-  enum ExtraSemiKind {
-OutsideFunction = 0,
-InsideStruct = 1,
-InstanceVariableList = 2,
-AfterMemberFunctionDefinition = 3
-  };
-
   /// Consume any extra semi-colons until the end of the line.
   void ConsumeExtraSemi(ExtraSemiKind Kind, DeclSpec::TST T = TST_unspecified);
 

diff  --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 69d40baaf4298..7eb6bb97b6622 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -5187,7 +5187,7 @@ void Parser::ParseStructUnionBody(SourceLocation 
RecordLoc,
 
 // Check for extraneous top-level semicolon.
 if (Tok.is(tok::semi)) {
-  ConsumeExtraSemi(InsideStruct, TagType);
+  ConsumeExtraSemi(ExtraSemiKind::InsideStruct, TagType);
   continue;
 }
 

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 51fe0663a8d1a..6deb9b73998ae 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -3295,7 +3295,7 @@ Parser::DeclGroupPtrTy 
Parser::ParseCXXClassMemberDeclaration(
 
   // Consume the ';' - it's optional unless we have a delete or default
   if (Tok.is(tok::semi))
-ConsumeExtraSemi(AfterMemberFunctionDefinition);
+ConsumeExtraSemi(ExtraSemiKind::AfterMemberFunctionDefinition);
 
   return DeclGroupPtrTy::make(DeclGroupRef(FunDecl));
 }
@@ -3649,7 +3649,7 @@ Parser::DeclGroupPtrTy 
Parser::ParseCXXClassMemberDeclarationWithPragmas(
 
   case tok::semi:
 // Check for extraneous top-level semicolon.
-ConsumeExtraSemi(InsideStruct, TagType);
+ConsumeExtraSemi(ExtraSemiKind::InsideStruct, TagType);
 return nullptr;
 
 // Handle pragmas that can appear as member declarations.
@@ -5313,7 +5313,7 @@ void Parser::ParseMicrosoftIfExistsClassDeclaration(
 
 // Check for extraneous top-level semicolon.
 if (Tok.is(tok::semi)) {
-  ConsumeExtraSemi(InsideStruct, TagType);
+  ConsumeExtraSemi(ExtraSemiKind::InsideStruct, TagType);
   continue;
 }
 

diff  --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index d872177b3d7aa..40bc459523e8d 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -1972,7 +1972,7 @@ void 
Parser::ParseObjCClassInstanceVariables(ObjCContainerDecl *interfaceDecl,
 
 // Check for extraneous top-level semicolon.
 if (Tok.is(tok::semi)) {
-  ConsumeExtraSemi(InstanceVariableList);
+  ConsumeExtraSemi(ExtraSemiKind::InstanceVariableList);
   continue;
 }
 

diff  --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index 0954c31519c5a..c45ed4182997b 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -24,6 +24,7 @@
 #include "clang/Sema/ParsedTemplate.h"
 #include "clang/Sema/Scope.h"
 #include "clang/Sema/SemaCodeCompletion.h"
+#include "llvm/ADT/STLForwardCompat.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TimeProfiler.h"
 using namespace clang;
@@ -213,7 +214,7 @@ void Parser::ConsumeExtraSemi(ExtraSemiKind Kind, 
DeclSpec::TST TST) {
 
   // C++11 allows extra semicolons at namespace scope, but not in any of the
   // other contexts.
-  if (Kind == OutsideFunction && getLangOpts().CPlusPlus) {
+  if (Kind == ExtraSemiKind::OutsideFunction && getLangOpts().CPlusPlus) {
 if (getLangOpts().CPlusPlus11)
   Diag(StartLoc, diag::warn_cxx98_compat_top_level_semi)

[clang] [llvm] [clang] Implement JSON formatted -ftime-report (PR #137737)

2025-04-29 Thread Arthur Eubanks via cfe-commits


@@ -296,7 +296,14 @@ int cc1_main(ArrayRef Argv, const char 
*Argv0, void *MainAddr) {
 
   // If any timers were active but haven't been destroyed yet, print their
   // results now.  This happens in -disable-free mode.
-  llvm::TimerGroup::printAll(llvm::errs());
+  // llvm::TimerGroup::printAll(llvm::errs());

aeubanks wrote:

leftover code

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


[clang] [clang-format] Add AlignAfterOpenBracketOptions (PR #108332)

2025-04-29 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,h -- 
clang/include/clang/Format/Format.h clang/lib/Format/ContinuationIndenter.cpp 
clang/lib/Format/Format.cpp clang/lib/Format/TokenAnnotator.cpp 
clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 08558d655..f4e48b7e3 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -834,16 +834,15 @@ void 
ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun,
   /* For backward compatibility, use AlignAfterOpenBracket
* in case AlignAfterControlStatement is not initialized */
   return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine 
||
-(Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
- Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
+ (Style.AlignAfterControlStatement == FormatStyle::BACSS_Default &&
+  Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak);
 }
-if (IsOtherConditional(*Tok.Previous)) {
+if (IsOtherConditional(*Tok.Previous))
   return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
-}
 if (Style.AlignAfterOpenBracket == FormatStyle::BAS_AlwaysBreak ||
-   Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
+Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
   return !Tok.Previous->is(TT_CastRParen) &&
- !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
+ !(Style.isJavaScript() && Tok.is(Keywords.kw_await));
 }
 return false;
   };
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index e6a82a093..cd7e4cb06 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -202,8 +202,10 @@ template <> struct 
MappingTraits {
   }
 };
 
-template <> struct 
ScalarEnumerationTraits {
-  static void enumeration(IO &IO, FormatStyle::BreakAfterControlStatementStyle 
&Value) {
+template <>
+struct ScalarEnumerationTraits {
+  static void enumeration(IO &IO,
+  FormatStyle::BreakAfterControlStatementStyle &Value) 
{
 IO.enumCase(Value, "Default", FormatStyle::BACSS_Default);
 IO.enumCase(Value, "MultiLine", FormatStyle::BACSS_MultiLine);
 IO.enumCase(Value, "No", FormatStyle::BACSS_No);
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 39ddb63d4..881d40abf 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -6221,7 +6221,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine 
&Line,
 const FormatToken *Previous = Right.MatchingParen->Previous;
 if (!Previous)
   return true;
-if (Previous->isIf() || Previous->isOneOf(tok::kw_for, tok::kw_while, 
tok::kw_switch)) {
+if (Previous->isIf() ||
+Previous->isOneOf(tok::kw_for, tok::kw_while, tok::kw_switch)) {
   return Style.AlignAfterControlStatement == FormatStyle::BACSS_MultiLine;
 }
 return true;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 7841caefd..a314a0bff 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -9797,7 +9797,6 @@ TEST_F(FormatTest, AlignAfterConditionalStatements) {
"}",
Style);
 
-
   Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
   Style.AlignAfterControlStatement = FormatStyle::BACSS_MultiLine;
 

``




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


[clang] f175030 - [HLSL] Resource initialization by constructors (#135120)

2025-04-29 Thread via cfe-commits

Author: Helena Kotas
Date: 2025-04-29T18:42:22-07:00
New Revision: f1750300aad0e49383cd4b206e2354f1300a40a8

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

LOG: [HLSL] Resource initialization by constructors (#135120)

- Adds resource constructor that takes explicit binding for all resource
classes.
- Updates implementation of default resource constructor to initialize
resource handle to `poison`.
- Removes initialization of resource classes from Codegen.
- Initialization of `cbuffer` still needs to happen in `CGHLSLRuntime`
because it does not have a corresponding resource class type.
- Adds `ImplicitCastExpr` for builtin function calls. Sema adds these
automatically when a method of a template class is instantiated, but
some resource classes like `ByteAddressBuffer` are not templates so they
need to have this added explicitly.

Design proposal: llvm/wg-hlsl#197

Closes #134154

Added: 


Modified: 
clang/include/clang/Basic/Builtins.td
clang/include/clang/Sema/SemaHLSL.h
clang/lib/CodeGen/CGHLSLBuiltins.cpp
clang/lib/CodeGen/CGHLSLRuntime.cpp
clang/lib/CodeGen/CGHLSLRuntime.h
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.cpp
clang/lib/Sema/HLSLBuiltinTypeDeclBuilder.h
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaHLSL.cpp
clang/test/AST/HLSL/ByteAddressBuffers-AST.hlsl
clang/test/AST/HLSL/StructuredBuffers-AST.hlsl
clang/test/AST/HLSL/TypedBuffers-AST.hlsl
clang/test/CodeGenHLSL/builtins/ByteAddressBuffers-constructors.hlsl
clang/test/CodeGenHLSL/builtins/RWBuffer-constructor-opt.hlsl
clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
clang/test/CodeGenHLSL/builtins/StructuredBuffers-constructors.hlsl
clang/test/CodeGenHLSL/cbuffer.hlsl
clang/test/CodeGenHLSL/cbuffer_with_packoffset.hlsl
clang/test/CodeGenHLSL/resource-bindings.hlsl
clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 74a11257b373d..37bdac814a347 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4801,6 +4801,18 @@ def HLSLResourceGetPointer : LangBuiltin<"HLSL_LANG"> {
   let Prototype = "void(...)";
 }
 
+def HLSLResourceUninitializedHandle : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_resource_uninitializedhandle"];
+  let Attributes = [NoThrow];
+  let Prototype = "void(...)";
+}
+
+def HLSLResourceHandleFromBinding : LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_resource_handlefrombinding"];
+  let Attributes = [NoThrow];
+  let Prototype = "void(...)";
+}
+
 def HLSLAll : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_all"];
   let Attributes = [NoThrow, Const];

diff  --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
index e97736b18eee3..5d260acf92abb 100644
--- a/clang/include/clang/Sema/SemaHLSL.h
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -105,6 +105,7 @@ class SemaHLSL : public SemaBase {
  HLSLParamModifierAttr::Spelling Spelling);
   void ActOnTopLevelFunction(FunctionDecl *FD);
   void ActOnVariableDeclarator(VarDecl *VD);
+  bool ActOnUninitializedVarDecl(VarDecl *D);
   void ActOnEndOfTranslationUnit(TranslationUnitDecl *TU);
   void CheckEntryPoint(FunctionDecl *FD);
   void CheckSemanticAnnotation(FunctionDecl *EntryPoint, const Decl *Param,

diff  --git a/clang/lib/CodeGen/CGHLSLBuiltins.cpp 
b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
index 044d427688267..5d93df34c66b2 100644
--- a/clang/lib/CodeGen/CGHLSLBuiltins.cpp
+++ b/clang/lib/CodeGen/CGHLSLBuiltins.cpp
@@ -285,6 +285,24 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 RetTy, CGM.getHLSLRuntime().getCreateResourceGetPointerIntrinsic(),
 ArrayRef{HandleOp, IndexOp});
   }
+  case Builtin::BI__builtin_hlsl_resource_uninitializedhandle: {
+llvm::Type *HandleTy = CGM.getTypes().ConvertType(E->getType());
+return llvm::PoisonValue::get(HandleTy);
+  }
+  case Builtin::BI__builtin_hlsl_resource_handlefrombinding: {
+llvm::Type *HandleTy = CGM.getTypes().ConvertType(E->getType());
+Value *RegisterOp = EmitScalarExpr(E->getArg(1));
+Value *SpaceOp = EmitScalarExpr(E->getArg(2));
+Value *RangeOp = EmitScalarExpr(E->getArg(3));
+Value *IndexOp = EmitScalarExpr(E->getArg(4));
+// FIXME: NonUniformResourceIndex bit is not yet implemented
+// (llvm/llvm-project#135452)
+Value *NonUniform =
+llvm::ConstantInt::get(llvm::Type::getInt1Ty(getLLVMContext()), false);
+return Builder.CreateIntrinsic(
+HandleTy, CGM.getHLSLRuntime

[clang] [HLSL] Resource initialization by constructors (PR #135120)

2025-04-29 Thread Helena Kotas via cfe-commits

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


[clang] [CIR] Upstream initial support for union type (PR #137501)

2025-04-29 Thread Iris Shi via cfe-commits


@@ -306,3 +320,71 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *rd, 
cir::RecordType *ty) {
   // TODO: implement verification
   return rl;
 }
+
+void CIRRecordLowering::lowerUnion() {
+  CharUnits layoutSize = astRecordLayout.getSize();
+  mlir::Type storageType = nullptr;
+  bool seenNamedMember = false;
+
+  // Iterate through the fields setting bitFieldInfo and the Fields array. Also
+  // locate the "most appropriate" storage type.  The heuristic for finding the

el-ev wrote:

Removed

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


[clang] [CIR] Upstream initial support for union type (PR #137501)

2025-04-29 Thread Iris Shi via cfe-commits


@@ -306,3 +320,71 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *rd, 
cir::RecordType *ty) {
   // TODO: implement verification
   return rl;
 }
+
+void CIRRecordLowering::lowerUnion() {
+  CharUnits layoutSize = astRecordLayout.getSize();
+  mlir::Type storageType = nullptr;
+  bool seenNamedMember = false;
+
+  // Iterate through the fields setting bitFieldInfo and the Fields array. Also
+  // locate the "most appropriate" storage type.  The heuristic for finding the
+  // storage type isn't necessary, the first (non-0-length-bitfield) field's
+  // type would work fine and be simpler but would be different than what we've
+  // been doing and cause lit tests to change.
+  for (const FieldDecl *field : recordDecl->fields()) {
+mlir::Type fieldType;
+if (field->isBitField())
+  cirGenTypes.getCGModule().errorNYI(recordDecl->getSourceRange(),
+ "bitfields in lowerUnion");
+else
+  fieldType = getStorageType(field);
+
+fields[field->getCanonicalDecl()] = 0;

el-ev wrote:

Renamed them to `fieldIdxMap`

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


[clang] [C] Warn on uninitialized const objects (PR #137166)

2025-04-29 Thread Nathan Chancellor via cfe-commits

nathanchance wrote:

> This case might be reasonable to handle differently, but I'm on the fence 
> too. There's two cases for structure members, broadly:
> 
> 1) Don't initialize the `const` field, don't ever read the `const` field.
> 
> 2) Rely on the fact that you can overwrite a `const` if the top-level object 
> was not declared `const`.

Yes, this appears to be the case for the 10 or so unique cases that I found in 
the kernel.

> In both cases, the code is valid and so the warning is a false positive. In 
> both cases, the code is dangerous and the warning is useful. So I kind of 
> think this is a case where we split the field diagnostic out into its own 
> group. So we'd have `-Wdefault-const-init-field` which covers field 
> initialization cases, and it would be grouped under `-Wdefault-const-init` 
> which covers both fields and variables. WDYT?

Yes, that seems like a reasonable place to start. I would be happy to test such 
a change.



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


[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-04-29 Thread Craig Topper via cfe-commits


@@ -1197,6 +1197,73 @@ def HasVendorXSfvcp : 
Predicate<"Subtarget->hasVendorXSfvcp()">,
   AssemblerPredicate<(all_of FeatureVendorXSfvcp),
   "'XSfvcp' (SiFive Custom Vector Coprocessor 
Interface Instructions)">;
 
+def FeatureVendorXSfmmbase
+: RISCVExtension<0, 6,
+ "All non arithmetic instructions for all TEWs and 
sf.vtzero",
+ [FeatureStdExtZve32x]>;
+def HasVendorXSfmmbase : Predicate<"Subtarget->hasVendorXSfmmbase()">,
+ AssemblerPredicate<(all_of FeatureVendorXSfmmbase),
+ "'XSfmmbase' (All non arithmetic instructions for 
all TEWs and sf.vtzero)">;
+
+def FeatureVendorXSfmm32a8f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: fp8",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+def HasVendorXSfmm32a8f : Predicate<"Subtarget->hasVendorXSfmm32a8f()">,
+  AssemblerPredicate<(all_of FeatureVendorXSfmm32a8f),
+  "'XSfmm32a8f' (TEW=32-bit accumulation, operands 
- float: fp8)">;
+
+def FeatureVendorXSfmm32a16f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: 16b, widen=2 
(IEEE, BF)",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+
+def FeatureVendorXSfmm32a32f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: 32b",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+
+def FeatureVendorXSfmm32a8i
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - int: 8b",
+ [FeatureVendorXSfmmbase]>;
+def HasVendorXSfmm32a8i : Predicate<"Subtarget->hasVendorXSfmm32a8i()">,
+  AssemblerPredicate<(all_of FeatureVendorXSfmm32a8i),
+  "'XSfmm32a8i' (TEW=32-bit accumulation, operands 
- int: 8b)">;
+
+def FeatureVendorXSfmm64a64f
+: RISCVExtension<0, 6,
+ "TEW=64-bit accumulation, operands - float: fp64",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve64d]>;
+def HasVendorXSfmm32a16fOrXSfmm32a32fOrXSfmm64a64f
+: Predicate<"Subtarget->hasVendorXSfmm32a16fOrXSfmm32a32fOrXSfmm64a64f()">,
+AssemblerPredicate<(any_of FeatureVendorXSfmm32a16f,
+   FeatureVendorXSfmm32a32f,
+   FeatureVendorXSfmm64a64f),
+"'XSfmm32a16f' (TEW=32-bit accumulation, operands - float: 
16b, widen=2 (IEEE, BF)), or "
+"'XSfmm32a32f' (TEW=32-bit accumulation, operands - float: 
32b), or "
+"'XSfmm64a64f' (TEW=64-bit accumulation, operands - float: 
fp64)">;
+
+def FeatureVendorXSfmm16t
+: RISCVExtension<0, 6,
+ "TE=16 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl64b], "XSfmmTE", 
"16">;
+
+def FeatureVendorXSfmm32t
+: RISCVExtension<0, 6,
+ "TE=32 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl128b], 
"XSfmmTE", "32">;
+
+def FeatureVendorXSfmm64t
+: RISCVExtension<0, 6,
+ "TE=64 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl256b], 
"XSfmmTE", "64">;
+
+def FeatureVendorXSfmm128t
+: RISCVExtension<0, 6,
+ "TE=128 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl512b], 
"XSfmmTE", "128">;

topperc wrote:

SiFive does not implement a TE that large so I'm a little hesitant to add an 
extension in our vendor namespace for it.

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


[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)

2025-04-29 Thread Jiuyang Liu via cfe-commits


@@ -1197,6 +1197,73 @@ def HasVendorXSfvcp : 
Predicate<"Subtarget->hasVendorXSfvcp()">,
   AssemblerPredicate<(all_of FeatureVendorXSfvcp),
   "'XSfvcp' (SiFive Custom Vector Coprocessor 
Interface Instructions)">;
 
+def FeatureVendorXSfmmbase
+: RISCVExtension<0, 6,
+ "All non arithmetic instructions for all TEWs and 
sf.vtzero",
+ [FeatureStdExtZve32x]>;
+def HasVendorXSfmmbase : Predicate<"Subtarget->hasVendorXSfmmbase()">,
+ AssemblerPredicate<(all_of FeatureVendorXSfmmbase),
+ "'XSfmmbase' (All non arithmetic instructions for 
all TEWs and sf.vtzero)">;
+
+def FeatureVendorXSfmm32a8f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: fp8",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+def HasVendorXSfmm32a8f : Predicate<"Subtarget->hasVendorXSfmm32a8f()">,
+  AssemblerPredicate<(all_of FeatureVendorXSfmm32a8f),
+  "'XSfmm32a8f' (TEW=32-bit accumulation, operands 
- float: fp8)">;
+
+def FeatureVendorXSfmm32a16f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: 16b, widen=2 
(IEEE, BF)",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+
+def FeatureVendorXSfmm32a32f
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - float: 32b",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve32f]>;
+
+def FeatureVendorXSfmm32a8i
+: RISCVExtension<0, 6,
+ "TEW=32-bit accumulation, operands - int: 8b",
+ [FeatureVendorXSfmmbase]>;
+def HasVendorXSfmm32a8i : Predicate<"Subtarget->hasVendorXSfmm32a8i()">,
+  AssemblerPredicate<(all_of FeatureVendorXSfmm32a8i),
+  "'XSfmm32a8i' (TEW=32-bit accumulation, operands 
- int: 8b)">;
+
+def FeatureVendorXSfmm64a64f
+: RISCVExtension<0, 6,
+ "TEW=64-bit accumulation, operands - float: fp64",
+ [FeatureVendorXSfmmbase, FeatureStdExtZve64d]>;
+def HasVendorXSfmm32a16fOrXSfmm32a32fOrXSfmm64a64f
+: Predicate<"Subtarget->hasVendorXSfmm32a16fOrXSfmm32a32fOrXSfmm64a64f()">,
+AssemblerPredicate<(any_of FeatureVendorXSfmm32a16f,
+   FeatureVendorXSfmm32a32f,
+   FeatureVendorXSfmm64a64f),
+"'XSfmm32a16f' (TEW=32-bit accumulation, operands - float: 
16b, widen=2 (IEEE, BF)), or "
+"'XSfmm32a32f' (TEW=32-bit accumulation, operands - float: 
32b), or "
+"'XSfmm64a64f' (TEW=64-bit accumulation, operands - float: 
fp64)">;
+
+def FeatureVendorXSfmm16t
+: RISCVExtension<0, 6,
+ "TE=16 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl64b], "XSfmmTE", 
"16">;
+
+def FeatureVendorXSfmm32t
+: RISCVExtension<0, 6,
+ "TE=32 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl128b], 
"XSfmmTE", "32">;
+
+def FeatureVendorXSfmm64t
+: RISCVExtension<0, 6,
+ "TE=64 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl256b], 
"XSfmmTE", "64">;
+
+def FeatureVendorXSfmm128t
+: RISCVExtension<0, 6,
+ "TE=128 configuration",
+ [FeatureVendorXSfmmbase, FeatureStdExtZvl512b], 
"XSfmmTE", "128">;

sequencer wrote:

Thanks, that’s reasonable, we will maintain a patch based on this PR and wait 
for the ratification of AME or VME later. 

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


[clang] [CIR] Upstream initial support for union type (PR #137501)

2025-04-29 Thread Iris Shi via cfe-commits


@@ -306,3 +320,71 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *rd, 
cir::RecordType *ty) {
   // TODO: implement verification
   return rl;
 }
+
+void CIRRecordLowering::lowerUnion() {
+  CharUnits layoutSize = astRecordLayout.getSize();
+  mlir::Type storageType = nullptr;
+  bool seenNamedMember = false;
+
+  // Iterate through the fields setting bitFieldInfo and the Fields array. Also
+  // locate the "most appropriate" storage type.  The heuristic for finding the
+  // storage type isn't necessary, the first (non-0-length-bitfield) field's
+  // type would work fine and be simpler but would be different than what we've
+  // been doing and cause lit tests to change.
+  for (const FieldDecl *field : recordDecl->fields()) {
+mlir::Type fieldType;
+if (field->isBitField())
+  cirGenTypes.getCGModule().errorNYI(recordDecl->getSourceRange(),
+ "bitfields in lowerUnion");
+else
+  fieldType = getStorageType(field);
+
+fields[field->getCanonicalDecl()] = 0;
+
+// Compute zero-initializable status.
+// This union might not be zero initialized: it may contain a pointer to
+// data member which might have some exotic initialization sequence.
+// If this is the case, then we aught not to try and come up with a 
"better"
+// type, it might not be very easy to come up with a Constant which
+// correctly initializes it.
+if (!seenNamedMember) {
+  seenNamedMember = field->getIdentifier();
+  if (!seenNamedMember)
+if (const RecordDecl *fieldRD = field->getType()->getAsRecordDecl())
+  seenNamedMember = fieldRD->findFirstNamedDataMember();
+  if (seenNamedMember && !isZeroInitializable(field)) {
+zeroInitializable = zeroInitializableAsBase = false;
+storageType = fieldType;
+  }
+}
+
+// Because our union isn't zero initializable, we won't be getting a better
+// storage type.
+if (!zeroInitializable)
+  continue;
+
+// Conditionally update our storage type if we've got a new "better" one.
+if (!storageType || getAlignment(fieldType) > getAlignment(storageType) ||
+(getAlignment(fieldType) == getAlignment(storageType) &&
+ getSize(fieldType) > getSize(storageType)))
+  storageType = fieldType;
+
+// NOTE(cir): Track all union member's types, not just the largest one. It
+// allows for proper type-checking and retain more info for analisys.
+fieldTypes.push_back(fieldType);
+  }
+
+  if (!storageType)
+cirGenTypes.getCGModule().errorNYI(recordDecl->getSourceRange(),
+   "No-storage Union NYI");
+
+  if (layoutSize < getSize(storageType))
+storageType = getByteArrayType(layoutSize);
+
+  // NOTE(cir): Defer padding calculations to the lowering process.

el-ev wrote:

It was indeed confusing and not true, removed.

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


[clang] [CIR] Upstream initial support for union type (PR #137501)

2025-04-29 Thread Iris Shi via cfe-commits


@@ -306,3 +320,71 @@ CIRGenTypes::computeRecordLayout(const RecordDecl *rd, 
cir::RecordType *ty) {
   // TODO: implement verification
   return rl;
 }
+
+void CIRRecordLowering::lowerUnion() {
+  CharUnits layoutSize = astRecordLayout.getSize();
+  mlir::Type storageType = nullptr;
+  bool seenNamedMember = false;
+
+  // Iterate through the fields setting bitFieldInfo and the Fields array. Also
+  // locate the "most appropriate" storage type.  The heuristic for finding the
+  // storage type isn't necessary, the first (non-0-length-bitfield) field's
+  // type would work fine and be simpler but would be different than what we've
+  // been doing and cause lit tests to change.
+  for (const FieldDecl *field : recordDecl->fields()) {
+mlir::Type fieldType;
+if (field->isBitField())
+  cirGenTypes.getCGModule().errorNYI(recordDecl->getSourceRange(),
+ "bitfields in lowerUnion");
+else
+  fieldType = getStorageType(field);
+
+fields[field->getCanonicalDecl()] = 0;
+
+// Compute zero-initializable status.
+// This union might not be zero initialized: it may contain a pointer to
+// data member which might have some exotic initialization sequence.
+// If this is the case, then we aught not to try and come up with a 
"better"
+// type, it might not be very easy to come up with a Constant which
+// correctly initializes it.
+if (!seenNamedMember) {

el-ev wrote:

If the first named member is a `RecordDecl`, it will trigger `ClangIR code gen 
Not Yet Implemented: isZeroInitializable for RecordType: 'S'`

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


[clang] [CIR] Cleanup support for C functions (PR #136854)

2025-04-29 Thread Iris Shi via cfe-commits

https://github.com/el-ev updated 
https://github.com/llvm/llvm-project/pull/136854

>From fd1d37ebf0f1c4a23f573444f30730b0f65630bf Mon Sep 17 00:00:00 2001
From: Iris Shi <0...@owo.li>
Date: Wed, 23 Apr 2025 20:23:09 +0800
Subject: [PATCH 1/2] [CIR] Cleanup support for C functions

---
 clang/lib/CIR/CodeGen/CIRGenCall.cpp   | 82 +++-
 clang/lib/CIR/CodeGen/CIRGenFunctionInfo.h | 90 +-
 clang/lib/CIR/CodeGen/CIRGenModule.cpp | 17 +++-
 clang/lib/CIR/CodeGen/CIRGenTypes.cpp  | 37 -
 clang/lib/CIR/CodeGen/CIRGenTypes.h| 12 ++-
 clang/lib/CIR/CodeGen/TargetInfo.cpp   | 10 ++-
 clang/test/CIR/CodeGen/basic.c | 13 
 7 files changed, 232 insertions(+), 29 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenCall.cpp 
b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
index 69266f79a88a5..b223bc494f928 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCall.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenCall.cpp
@@ -13,20 +13,76 @@
 
 #include "CIRGenCall.h"
 #include "CIRGenFunction.h"
+#include "CIRGenFunctionInfo.h"
 #include "clang/CIR/MissingFeatures.h"
 
 using namespace clang;
 using namespace clang::CIRGen;
 
-CIRGenFunctionInfo *CIRGenFunctionInfo::create(CanQualType resultType) {
-  void *buffer = operator new(totalSizeToAlloc(1));
+CIRGenFunctionInfo *
+CIRGenFunctionInfo::create(CanQualType resultType,
+   llvm::ArrayRef argTypes,
+   RequiredArgs required) {
+  void *buffer = operator new(totalSizeToAlloc(argTypes.size() + 1));
 
   CIRGenFunctionInfo *fi = new (buffer) CIRGenFunctionInfo();
+
+  fi->required = required;
+  fi->numArgs = argTypes.size();
   fi->getArgsBuffer()[0].type = resultType;
+  for (unsigned i = 0; i < argTypes.size(); ++i)
+fi->getArgsBuffer()[i + 1].type = argTypes[i];
 
   return fi;
 }
 
+cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &fi) {
+  bool inserted = functionsBeingProcessed.insert(&fi).second;
+  assert(inserted && "Recursively being processed?");
+
+  mlir::Type resultType = nullptr;
+  const cir::ABIArgInfo &retAI = fi.getReturnInfo();
+
+  switch (retAI.getKind()) {
+  case cir::ABIArgInfo::Ignore:
+// TODO(CIR): This should probably be the None type from the builtin
+// dialect.
+resultType = nullptr;
+break;
+
+  case cir::ABIArgInfo::Direct:
+resultType = retAI.getCoerceToType();
+break;
+
+  default:
+assert(false && "NYI");
+  }
+
+  SmallVector argTypes;
+  unsigned argNo = 0;
+  CIRGenFunctionInfo::const_arg_iterator it = fi.arg_begin(),
+ ie = it + fi.getNumRequiredArgs();
+  for (; it != ie; ++it, ++argNo) {
+const auto &argInfo = it->info;
+
+switch (argInfo.getKind()) {
+default:
+  llvm_unreachable("NYI");
+case cir::ABIArgInfo::Direct:
+  mlir::Type argType = argInfo.getCoerceToType();
+  argTypes.push_back(argType);
+  break;
+}
+  }
+
+  bool erased = functionsBeingProcessed.erase(&fi);
+  assert(erased && "Not in set?");
+
+  return cir::FuncType::get(argTypes,
+(resultType ? resultType : builder.getVoidTy()),
+fi.isVariadic());
+}
+
 CIRGenCallee CIRGenCallee::prepareConcreteCallee(CIRGenFunction &cgf) const {
   assert(!cir::MissingFeatures::opCallVirtual());
   return *this;
@@ -35,6 +91,9 @@ CIRGenCallee 
CIRGenCallee::prepareConcreteCallee(CIRGenFunction &cgf) const {
 static const CIRGenFunctionInfo &
 arrangeFreeFunctionLikeCall(CIRGenTypes &cgt, CIRGenModule &cgm,
 const FunctionType *fnType) {
+
+  RequiredArgs required = RequiredArgs::All;
+
   if (const auto *proto = dyn_cast(fnType)) {
 if (proto->isVariadic())
   cgm.errorNYI("call to variadic function");
@@ -49,7 +108,7 @@ arrangeFreeFunctionLikeCall(CIRGenTypes &cgt, CIRGenModule 
&cgm,
   CanQualType retType = fnType->getReturnType()
 ->getCanonicalTypeUnqualified()
 .getUnqualifiedType();
-  return cgt.arrangeCIRFunctionInfo(retType);
+  return cgt.arrangeCIRFunctionInfo(retType, {}, required);
 }
 
 const CIRGenFunctionInfo &
@@ -71,6 +130,23 @@ static cir::CIRCallOpInterface 
emitCallLikeOp(CIRGenFunction &cgf,
   return builder.createCallOp(callLoc, directFuncOp);
 }
 
+const CIRGenFunctionInfo &
+CIRGenTypes::arrangeFreeFunctionType(CanQual fpt) {
+  SmallVector argTypes;
+  for (unsigned i = 0, e = fpt->getNumParams(); i != e; ++i)
+argTypes.push_back(fpt->getParamType(i));
+  RequiredArgs required = RequiredArgs::forPrototypePlus(fpt);
+
+  CanQualType resultType = fpt->getReturnType().getUnqualifiedType();
+  return arrangeCIRFunctionInfo(resultType, argTypes, required);
+}
+
+const CIRGenFunctionInfo &
+CIRGenTypes::arrangeFreeFunctionType(CanQual fnpt) {
+  CanQualType resultType = fnpt->getReturnType().getUnqualifiedType();
+  return arrangeCIRFunctionInfo(resultType, {}, RequiredArgs(0));

[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-29 Thread Farzon Lotfi via cfe-commits


@@ -1,108 +1,160 @@
-// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
-// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx
-// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple \
-// RUN:   spirv-unknown-vulkan-compute %s -emit-llvm -disable-llvm-passes \
-// RUN:   -o - | FileCheck %s --check-prefixes=CHECK \
-// RUN:   -DFNATTRS="spir_func noundef nofpclass(nan inf)" -DTARGET=spv
-
-// CHECK-LABEL: test_lerp_double
-// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
-// CHECK: ret float %hlsl.lerp
+// RUN: %clang_cc1 -std=hlsl202x -finclude-default-header -x hlsl -triple  
dxil-pc-shadermodel6.3-library %s -emit-llvm -O1 -o - | FileCheck %s 
--check-prefixes=CHECK -DFNATTRS="noundef nofpclass(nan inf)" -DTARGET=dx

farzonl wrote:

why do you need O1 for this  you can check for fptrunc without you just can't 
do CHECK-NEXT it would have to be all CHECK calls.

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


[clang] [llvm] [HLSL] Allow resource annotations to specify only register space (PR #135287)

2025-04-29 Thread Helena Kotas via cfe-commits

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


[clang] Silence spurious -Wnontrivial-memcall warnings in C mode (PR #137429)

2025-04-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `clang` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/8/11 (2145 of 2154)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/9/11 (2146 of 2154)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/0/2 (2147 of 2154)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/1/2 (2148 of 2154)
PASS: lldb-unit :: Utility/./UtilityTests/4/9 (2149 of 2154)
PASS: lldb-unit :: Host/./HostTests/7/13 (2150 of 2154)
PASS: lldb-unit :: Target/./TargetTests/11/14 (2151 of 2154)
PASS: lldb-unit :: Host/./HostTests/12/13 (2152 of 2154)
PASS: lldb-unit :: Process/gdb-remote/./ProcessGdbRemoteTests/8/9 (2153 of 2154)
UNRESOLVED: lldb-api :: tools/lldb-server/TestLldbGdbServer.py (2154 of 2154)
 TEST 'lldb-api :: tools/lldb-server/TestLldbGdbServer.py' 
FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-server
 -p TestLldbGdbServer.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18)
  clang revision 6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18
  llvm revision 6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_another_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_minus_one_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_zero_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_writes_all_gpr_registers_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for th

[clang] [HLSL] Make lerp overload tests stricter. NFC (PR #137898)

2025-04-29 Thread Farzon Lotfi via cfe-commits

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


[clang] Silence spurious -Wnontrivial-memcall warnings in C mode (PR #137429)

2025-04-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running 
on `linaro-lldb-arm-ubuntu` while building `clang` at step 6 "test".

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: tools/lldb-dap/disconnect/TestDAP_disconnect.py (1177 of 3009)
PASS: lldb-api :: 
tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py (1178 
of 3009)
PASS: lldb-api :: tools/lldb-dap/io/TestDAP_io.py (1179 of 3009)
PASS: lldb-api :: tools/lldb-dap/locations/TestDAP_locations.py (1180 of 3009)
PASS: lldb-api :: tools/lldb-dap/memory/TestDAP_memory.py (1181 of 3009)
PASS: lldb-api :: tools/lldb-dap/optimized/TestDAP_optimized.py (1182 of 3009)
PASS: lldb-api :: tools/lldb-dap/output/TestDAP_output.py (1183 of 3009)
PASS: lldb-api :: tools/lldb-dap/launch/TestDAP_launch.py (1184 of 3009)
PASS: lldb-api :: tools/lldb-dap/repl-mode/TestDAP_repl_mode_detection.py (1185 
of 3009)
UNRESOLVED: lldb-api :: tools/lldb-dap/evaluate/TestDAP_evaluate.py (1186 of 
3009)
 TEST 'lldb-api :: 
tools/lldb-dap/evaluate/TestDAP_evaluate.py' FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py 
-u CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env 
LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch 
armv8l --build-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil 
--make /usr/bin/gmake --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/tools/lldb-dap/evaluate
 -p TestDAP_evaluate.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18)
  clang revision 6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18
  llvm revision 6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
= DEBUG ADAPTER PROTOCOL LOGS =
1745978185.242013454 --> (stdin/stdout) 
{"command":"initialize","type":"request","arguments":{"adapterID":"lldb-native","clientID":"vscode","columnsStartAt1":true,"linesStartAt1":true,"locale":"en-us","pathFormat":"path","supportsRunInTerminalRequest":true,"supportsVariablePaging":true,"supportsVariableType":true,"supportsStartDebuggingRequest":true,"supportsProgressReporting":true,"$__lldb_sourceInitFile":false},"seq":1}
1745978185.246627569 <-- (stdin/stdout) {"body":{"$__lldb_version":"lldb 
version 21.0.0git (https://github.com/llvm/llvm-project.git revision 
6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18)\n  clang revision 
6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18\n  llvm revision 
6bb4ce0f6ff462b58bacc8dbc47719b7009f9b18","completionTriggerCharacters":["."," 
","\t"],"exceptionBreakpointFilters":[{"default":false,"filter":"cpp_catch","label":"C++
 Catch"},{"default":false,"filter":"cpp_throw","label":"C++ 
Throw"},{"default":false,"filter":"objc_catch","label":"Objective-C 
Catch"},{"default":false,"filter":"objc_throw","label":"Objective-C 
Throw"}],"supportTerminateDebuggee":true,"supportsBreakpointLocationsRequest":true,"supportsCancelRequest":true,"supportsCompletionsRequest":true,"supportsConditionalBreakpoints":true,"supportsConfigurationDoneRequest":true,"supportsDataBreakpoints":true,"supportsDelayedStackTraceLoading":true,"supportsDisassembleRequest":true,"supportsEvaluateForHovers":true,"supportsExceptionInfoRequest":true,"supportsExceptionOptions":true,"supportsFunctionBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsInstructionBreakpoints":true,"supportsLogPoints":true,"supportsModulesRequest":true,"supportsReadMemoryRequest":true,"supportsRestartRequest":true,"supportsSetVariable":true,"supportsStepInTargetsRequest":true,"supportsSteppingGranularity":true,"supportsValueFormattingOptions":true},"command":"initialize","request_seq":1,"seq":0,"success":true,"type":"response"}
1745978185.24

[clang] [clang][lex] Introduce new single-module-parse mode (PR #135813)

2025-04-29 Thread Michael Spencer via cfe-commits

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

I think this looks good overall. I'm a little concerned that the single file 
and single module names are similar while having quite different semantics, but 
single file is never actually exposed to users, so they won't be confused. I 
don't have any better suggestions for naming, but if you come up with one feel 
free to rename it (or rename single file).

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


  1   2   3   4   5   6   >