[libclc] [libclc] Skip opt command if opt_flags is empty (PR #130882)

2025-03-21 Thread Wenju He via cfe-commits


@@ -342,22 +342,32 @@ function(add_libclc_builtin_set)
 
   set( builtins_opt_lib_tgt builtins.opt.${ARG_ARCH_SUFFIX} )
 
-  # Add opt target
-  add_custom_command( OUTPUT ${builtins_opt_lib_tgt}.bc
-COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${builtins_opt_lib_tgt}.bc
-  ${builtins_link_lib}
-DEPENDS ${opt_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
-  )
-  add_custom_target( ${builtins_opt_lib_tgt}
-ALL DEPENDS ${builtins_opt_lib_tgt}.bc
-  )
+  if( ${ARG_OPT_FLAGS} STREQUAL "" )

wenju-he wrote:

let me know if it worth to update PR to unifies the code path and avoids early 
exit. Otherwise I'll close this PR.

The original request of this PR is to disable opt -O3. But things has changed 
and the request is irrelevant.
Though in practice it might still make sense to apply the PR to avoid code 
diverge like for SPIR-V.

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


[clang] [libclang/python] Change all global variables to snake case (PR #132378)

2025-03-21 Thread Vlad Serebrennikov via cfe-commits


@@ -10,7 +10,7 @@
 import sys
 from pathlib import Path
 
-kInputsDir = os.path.join(os.path.dirname(__file__), "INPUTS")
+k_inputs_dir = os.path.join(os.path.dirname(__file__), "INPUTS")

Endilll wrote:

"Konstant", I guess

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


[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)

2025-03-21 Thread Sumit Agarwal via cfe-commits


@@ -2473,11 +2473,9 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned 
BuiltinID, CallExpr *TheCall) {
 break;
   }
   case Builtin::BI__builtin_hlsl_dot2add: {
-// Check number of arguments should be 3
 if (SemaRef.checkArgCount(TheCall, 3))
   return true;
 
-// Check first two arguments are vector of length 2 with half data type
 auto checkHalfVectorOfSize2 = [](clang::QualType PassedType) -> bool {

sumitsays wrote:

Makes sense. I am thinking on it a bit stretched: Now we don't need to do any 
semantics check (just need to set the type) because we are explicitly 
specifying the exact overload.
Isn't it? 

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


[clang] [libclang/python] Change all global variables to snake case (PR #132378)

2025-03-21 Thread Vlad Serebrennikov via cfe-commits

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


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


[clang] [libc] [clang] diagnose invalid member pointer class on instantiation (PR #132516)

2025-03-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libc

Author: Matheus Izvekov (mizvekov)


Changes

This moves the diagnostic for member pointers pointing into non-class into 
BuildMemberPointer, so that it can be used from RebuildMemberPointer, when 
instantiating templates.

Also adds a minor tweak to the diagnostic when the member pointer is anonymous, 
which was previously untested.

Also reverts https://github.com/llvm/llvm-project/pull/132501, which disabled a 
failing test due to the regression which is now fixed.

No changelog, since this fixes a regression which has not been released yet.

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

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


6 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1-1) 
- (modified) clang/include/clang/Sema/Sema.h (+1-1) 
- (modified) clang/lib/Sema/SemaType.cpp (+22-20) 
- (modified) clang/lib/Sema/TreeTransform.h (+8-7) 
- (modified) clang/test/SemaCXX/member-pointer.cpp (+11) 
- (modified) libc/test/src/__support/CPP/type_traits_test.cpp (+1-3) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0cee58d8de513..c77cde297dc32 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6976,7 +6976,7 @@ def err_illegal_decl_mempointer_to_reference : Error<
 def err_illegal_decl_mempointer_to_void : Error<
   "'%0' declared as a member pointer to void">;
 def err_illegal_decl_mempointer_in_nonclass
-: Error<"'%0' does not point into a class">;
+: Error<"%0 does not point into a class">;
 def err_reference_to_void : Error<"cannot form a reference to 'void'">;
 def err_nonfunction_block_type : Error<
   "block pointer to non-function type is invalid">;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e215f07e2bf0a..04c25121f4c23 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -14885,7 +14885,7 @@ class Sema final : public SemaBase {
   ///
   /// \returns a member pointer type, if successful, or a NULL type if there 
was
   /// an error.
-  QualType BuildMemberPointerType(QualType T, NestedNameSpecifier *Qualifier,
+  QualType BuildMemberPointerType(QualType T, const CXXScopeSpec &SS,
   CXXRecordDecl *Cls, SourceLocation Loc,
   DeclarationName Entity);
 
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 39717386b0d08..aec33303780a0 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -2685,10 +2685,23 @@ QualType Sema::BuildFunctionType(QualType T,
   return Context.getFunctionType(T, ParamTypes, EPI);
 }
 
-QualType Sema::BuildMemberPointerType(QualType T,
-  NestedNameSpecifier *Qualifier,
+QualType Sema::BuildMemberPointerType(QualType T, const CXXScopeSpec &SS,
   CXXRecordDecl *Cls, SourceLocation Loc,
   DeclarationName Entity) {
+  if (!Cls && !isDependentScopeSpecifier(SS)) {
+Cls = dyn_cast_or_null(computeDeclContext(SS));
+if (!Cls) {
+  auto D =
+  Diag(SS.getBeginLoc(), diag::err_illegal_decl_mempointer_in_nonclass)
+  << SS.getRange();
+  if (const IdentifierInfo *II = Entity.getAsIdentifierInfo())
+D << II;
+  else
+D << "member pointer";
+  return QualType();
+}
+  }
+
   // Verify that we're not building a pointer to pointer to function with
   // exception specification.
   if (CheckDistantExceptionSpec(T)) {
@@ -2730,7 +2743,7 @@ QualType Sema::BuildMemberPointerType(QualType T,
   if (T->isFunctionType())
 adjustMemberFunctionCC(T, /*HasThisPointer=*/true, IsCtorOrDtor, Loc);
 
-  return Context.getMemberPointerType(T, Qualifier, Cls);
+  return Context.getMemberPointerType(T, SS.getScopeRep(), Cls);
 }
 
 QualType Sema::BuildBlockPointerType(QualType T,
@@ -5344,20 +5357,9 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
 // Avoid emitting extra errors if we already errored on the scope.
 D.setInvalidType(true);
 AreDeclaratorChunksValid = false;
-  } else if (auto *RD =
- dyn_cast_or_null(S.computeDeclContext(SS));
- RD || S.isDependentScopeSpecifier(SS)) {
-T = S.BuildMemberPointerType(T, SS.getScopeRep(), RD, DeclType.Loc,
- D.getIdentifier());
   } else {
-S.Diag(DeclType.Mem.Scope().getBeginLoc(),
- diag::err_illegal_decl_mempointer_in_nonclass)
-  << (D.getIdentifier() ? D.getIdentifier()->getName() : "type name")
-  << DeclType.Mem.Scope().getRange();
-D.setInvalidType(true);
-AreDeclaratorChunksValid = false;
-// FIXME: Maybe we could mod

[clang] [libclang/python] Add equality comparison operators for File (PR #130383)

2025-03-21 Thread Jannick Kremer via cfe-commits


@@ -16,3 +17,16 @@ def test_file(self):
 self.assertEqual(str(file), "t.c")
 self.assertEqual(file.name, "t.c")
 self.assertEqual(repr(file), "")
+
+def test_file_eq(self):
+path = os.path.join(kInputsDir, "hello.cpp")
+header_path = os.path.join(kInputsDir, "header3.h")
+tu = TranslationUnit.from_source(path)

DeinAlptraum wrote:

I added the test with in-memory files first to check, because I suspect this 
might be a problem with those specifically... I'll abuse the CI for testing 
here since I can't reproduce the issue locally.
Will try using disk files for the test afterwards.

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


[clang] [llvm] [flang-rt] Pass the whole path of libflang_rt.runtime.a to linker on AIX (PR #131041)

2025-03-21 Thread Daniel Chen via cfe-commits

DanielCChen wrote:

The intention is to make this PR for flang-rt only. As discussed with 
@daltenty, I remove the NFC-change of adding an overriding `getCompilerRT` in 
`AIX.cpp` as it actually breaches into clang space.

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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

2025-03-21 Thread Kazu Hirata via cfe-commits

kazutakahirata wrote:

> hi @kazutakahirata i had fixed the failure in #132502 and was just about to 
> merge it.

Oops.  Sorry about that.  Would you mind relanding this and #132502, maybe in a 
single merge?

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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

2025-03-21 Thread Sudharsan Veeravalli via cfe-commits

svs-quic wrote:

hi @kazutakahirata i had fixed the failure in #132502 and was just about to 
merge it. 


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


[clang] [clang] Placement new error when modifying consts (PR #132460)

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

tbaederr wrote:

The tests should go into a file not under `ByteCode/` since they aren't 
specific to the bytecode interpreter. There should be existing placement new 
tests in `SemaCXX/`.

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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-aarch64-sve-vls` 
running on `linaro-g3-04` while building `clang,llvm` at step 6 "build stage 1".

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


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

```
Step 6 (build stage 1) failure: 'ninja' (failure)
...
[187/527] Linking CXX executable bin/llvm-cxxdump
[188/527] Linking CXX executable bin/llvm-symbolizer
[189/527] Linking CXX executable bin/llvm-xray
[190/527] Linking CXX executable bin/obj2yaml
[191/527] Linking CXX executable bin/llvm-tli-checker
[192/527] Linking CXX executable bin/dexp
[193/527] Linking CXX executable bin/clangd
[194/527] Linking CXX executable bin/clangd-indexer
[195/527] Linking CXX executable bin/clangd-fuzzer
[196/527] Building CXX object 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
FAILED: 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 
/usr/local/bin/c++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/lib/Target/RISCV/AsmParser
 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/llvm/lib/Target/RISCV/AsmParser
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/llvm/lib/Target/RISCV 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/lib/Target/RISCV 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/llvm/include 
-mcpu=neoverse-512tvb -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17 -fvisibility=hidden 
 -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 -MF 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o.d
 -o 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 -c 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/llvm/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
../llvm/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:778:5: error: no 
type named 'VariantKind' in 'llvm::RISCVMCExpr'; did you mean 
'llvm::MCSymbolRefExpr::VariantKind'?
  778 | RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
  | ^~~~
  | llvm::MCSymbolRefExpr::VariantKind
../llvm/llvm/include/llvm/MC/MCExpr.h:196:8: note: 
'llvm::MCSymbolRefExpr::VariantKind' declared here
  196 |   enum VariantKind : uint16_t {
  |^
../llvm/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:778:30: error: 
cannot initialize a variable of type 'llvm::MCSymbolRefExpr::VariantKind' with 
an rvalue of type 'llvm::RISCVMCExpr::Specifier'
  778 | RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
  |  ^
../llvm/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:780:61: error: 
non-const lvalue reference to type 'RISCVMCExpr::Specifier' cannot bind to a 
value of unrelated type 'llvm::MCSymbolRefExpr::VariantKind'
  780 | bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
  | ^~
../llvm/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:518:59: note: 
passing argument to parameter 'VK' here
  518 |   RISCVMCExpr::Specifier &VK) {
  |   ^
../llvm/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:784:15: warning: 
comparison of different enumeration types ('llvm::MCSymbolRefExpr::VariantKind' 
and 'llvm::RISCVMCExpr::Specifier') [-Wenum-compare]
  784 |VK == RISCVMCExpr::VK_None;
  |~~ ^  
1 warning and 3 errors generated.
[197/527] Building CXX object 
tools/llvm-exegesis/lib/RISCV/CMakeFiles/LLVMExegesisRISCV.dir/RISCVExegesisPostprocessing.cpp.o
[198/527] Building CXX object 
tools/llvm-exegesis/lib/RISCV/CMakeFiles/LLVMExegesisRISCV.dir/RISCVExegesisPreprocessing.cpp.o
[199/527] Building CXX object 
tools/llvm-exegesis/lib/RISCV/CMakeFiles/LLVMExegesisRISCV.dir/Target.cpp.o
ninja: build stopped: subcommand failed.

```



https://github.com/llvm/llvm-project/pull/132184
___
cfe-commits mailing list
cfe-commits@lists.llv

[clang] [llvm] [HLSL] Implement the `smoothstep` intrinsic (PR #132288)

2025-03-21 Thread Kaitlin Peng via cfe-commits

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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-aarch64-linux-fuzzer` running on `sanitizer-buildbot11` while 
building `clang,llvm` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[101/229] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVInstPrinter.cpp.o
[102/229] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVELFObjectWriter.cpp.o
[103/229] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVMCExpr.cpp.o
[104/229] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVTargetStreamer.cpp.o
[105/229] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVAsmBackend.cpp.o
[106/229] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVBaseInfo.cpp.o
[107/229] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVMCCodeEmitter.cpp.o
[108/229] Building CXX object 
lib/Target/RISCV/MCA/CMakeFiles/LLVMRISCVTargetMCA.dir/RISCVCustomBehaviour.cpp.o
[109/229] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVELFStreamer.cpp.o
[110/229] Building CXX object 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
FAILED: 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ 
-DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/lib/Target/RISCV/AsmParser
 
-I/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/lib/Target/RISCV/AsmParser
 
-I/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/lib/Target/RISCV
 -I/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/lib/Target/RISCV 
-I/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm_build0/include 
-I/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/include -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -std=c++17 -fvisibility=hidden 
 -fno-exceptions -funwind-tables -fno-rtti -MD -MT 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 -MF 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o.d
 -o 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 -c 
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:778:5:
 error: no type named 'VariantKind' in 'llvm::RISCVMCExpr'; did you mean 
'llvm::MCSymbolRefExpr::VariantKind'?
  778 | RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
  | ^~~~
  | llvm::MCSymbolRefExpr::VariantKind
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/include/llvm/MC/MCExpr.h:196:8:
 note: 'llvm::MCSymbolRefExpr::VariantKind' declared here
  196 |   enum VariantKind : uint16_t {
  |^
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:778:30:
 error: cannot initialize a variable of type 
'llvm::MCSymbolRefExpr::VariantKind' with an rvalue of type 
'llvm::RISCVMCExpr::Specifier'
  778 | RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
  |  ^
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:780:61:
 error: non-const lvalue reference to type 'RISCVMCExpr::Specifier' cannot bind 
to a value of unrelated type 'llvm::MCSymbolRefExpr::VariantKind'
  780 | bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
  | ^~
/home/b/sanitizer-aarch64-linux-fuzzer/build/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:518:59:
 note: passing argument to parameter 'VK' here
  518 |   RISCVMCExpr::Specifier &VK) {
  |  

[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang,llvm` at step 6 
"build-unified-tree".

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


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

```
Step 6 (build-unified-tree) failure: build (failure)
...
14.376 [3718/58/155] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVELFObjectWriter.cpp.o
14.407 [3717/58/156] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVMCExpr.cpp.o
14.521 [3716/58/157] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVAsmBackend.cpp.o
15.247 [3715/58/158] Linking CXX executable bin/dexp
15.409 [3714/58/159] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVMCCodeEmitter.cpp.o
15.437 [3713/58/160] Linking CXX executable bin/clangd-indexer
15.591 [3712/58/161] Linking CXX executable bin/llvm-cxxdump
15.781 [3711/58/162] Building CXX object 
lib/CodeGen/AsmPrinter/CMakeFiles/LLVMAsmPrinter.dir/AsmPrinter.cpp.o
15.879 [3710/58/163] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVBaseInfo.cpp.o
16.000 [3710/57/164] Building CXX object 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
FAILED: 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/build/buildbot/premerge-monolithic-linux/build/lib/Target/RISCV/AsmParser 
-I/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/Target/RISCV/AsmParser
 -I/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/Target/RISCV 
-I/build/buildbot/premerge-monolithic-linux/build/lib/Target/RISCV 
-I/build/buildbot/premerge-monolithic-linux/build/include 
-I/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include -gmlt 
-fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -fvisibility=hidden  
-fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 -MF 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o.d
 -o 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 -c 
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:778:5:
 error: no type named 'VariantKind' in 'llvm::RISCVMCExpr'; did you mean 
'llvm::MCSymbolRefExpr::VariantKind'?
RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
^~~~
llvm::MCSymbolRefExpr::VariantKind
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include/llvm/MC/MCExpr.h:196:8:
 note: 'llvm::MCSymbolRefExpr::VariantKind' declared here
  enum VariantKind : uint16_t {
   ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:778:30:
 error: cannot initialize a variable of type 
'llvm::MCSymbolRefExpr::VariantKind' with an rvalue of type 
'llvm::RISCVMCExpr::Specifier'
RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
 ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:780:61:
 error: non-const lvalue reference to type 'RISCVMCExpr::Specifier' cannot bind 
to a value of unrelated type 'llvm::MCSymbolRefExpr::VariantKind'
bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
^~
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:518:59:
 note: passing argument to parameter 'VK' here
  RISCVMCExpr::Specifier &VK) {
  ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:784:15:
 warning: comparison of different enumeration types 
('llvm::MCSymbolRefExpr::VariantKind' and 'llvm::RISCVMCExpr::Specifie

[clang] [clang-tools-extra] [lldb] [llvm] [clang-doc] Add regression test for test comments in macros (PR #132360)

2025-03-21 Thread via cfe-commits

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


[clang] [llvm] [HLSL] Implement dot2add intrinsic (PR #131237)

2025-03-21 Thread Sumit Agarwal via cfe-commits


@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -finclude-default-header -triple 
dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only 
-disable-llvm-passes -verify
+
+float test_too_few_arg() {
+  return __builtin_hlsl_dot2add();
+  // expected-error@-1 {{too few arguments to function call, expected 3, have 
0}}
+}
+
+float test_too_many_arg(half2 p1, half2 p2, float p3) {
+  return __builtin_hlsl_dot2add(p1, p2, p3, p1);
+  // expected-error@-1 {{too many arguments to function call, expected 3, have 
4}}
+}
+
+float test_float_arg2_type(half2 p1, float2 p2, float p3) {
+  return __builtin_hlsl_dot2add(p1, p2, p3);
+  // expected-error@-1 {{passing 'float2' (aka 'vector') to 
parameter of incompatible type '__attribute__((__vector_size__(2 * 
sizeof(half half' (vector of 2 'half' values)}}
+}
+
+float test_float_arg1_type(float2 p1, half2 p2, float p3) {
+  return __builtin_hlsl_dot2add(p1, p2, p3);
+  // expected-error@-1 {{passing 'float2' (aka 'vector') to 
parameter of incompatible type '__attribute__((__vector_size__(2 * 
sizeof(half half' (vector of 2 'half' values)}}
+}
+
+float test_double_arg3_type(half2 p1, half2 p2, double p3) {
+  return __builtin_hlsl_dot2add(p1, p2, p3);
+  // expected-error@-1 {{passing 'double' to parameter of incompatible type 
'float'}}
+}
+
+float test_float_arg1_arg2_type(float2 p1, float2 p2, float p3) {
+  return __builtin_hlsl_dot2add(p1, p2, p3);
+  // expected-error@-1 {{passing 'float2' (aka 'vector') to 
parameter of incompatible type '__attribute__((__vector_size__(2 * 
sizeof(half half' (vector of 2 'half' values)}}
+}
+
+float test_int16_arg1_arg2_type(int16_t2 p1, int16_t2 p2, float p3) {
+  return __builtin_hlsl_dot2add(p1, p2, p3);
+  // expected-error@-1 {{passing 'int16_t2' (aka 'vector') to 
parameter of incompatible type '__attribute__((__vector_size__(2 * 
sizeof(half half' (vector of 2 'half' values)}}
+}

sumitsays wrote:

I tried testing `dot2add` and found that it is not throwing error when we pass 
incorrect type. Then I tried adding `__detail::enable_if` attribute in 
`hlsl_intrinsic.h` but realized that we can only use `__details::enable_if` 
when the intrinsic is templated. 
So, I thought even if we are not testing `dot2add` directly, the end user (when 
use `dot2add` from hlsl) will still get an error because ultimately the 
corresponding builtin will get called.

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


[clang] [clang][analyzer] Ignore unnamed bitfields in UninitializedObject (PR #132427)

2025-03-21 Thread Abhinav Kumar via cfe-commits

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

>From 72aafcc255bbcfccb3fa5317e260faf97a3dfed5 Mon Sep 17 00:00:00 2001
From: kr-2003 
Date: Fri, 21 Mar 2025 20:45:11 +0530
Subject: [PATCH 1/3] [clang][analyzer] Removed warnings for unnamed bitfields

---
 .../UninitializedObject/UninitializedObjectChecker.cpp| 4 
 1 file changed, 4 insertions(+)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index 6e1222fedad3e..bf954c3711309 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -332,6 +332,10 @@ bool FindUninitializedFields::isNonUnionUninit(const 
TypedValueRegion *R,
 }
 
 if (isPrimitiveType(T)) {
+  if (I->isUnnamedBitField()) {
+IsAnyFieldInitialized = true;
+continue;
+  }
   if (isPrimitiveUninit(V)) {
 if (addFieldToUninits(LocalChain.add(RegularField(FR
   ContainsUninitField = true;

>From ff01085e3e7aaab4a5dd54e69b3f5be19d43001f Mon Sep 17 00:00:00 2001
From: kr-2003 
Date: Fri, 21 Mar 2025 22:46:33 +0530
Subject: [PATCH 2/3] removed IsAnyFieldInitialized after isUnnamedBitField

---
 .../Checkers/UninitializedObject/UninitializedObjectChecker.cpp  | 1 -
 1 file changed, 1 deletion(-)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
index bf954c3711309..bf7759975b3ec 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -333,7 +333,6 @@ bool FindUninitializedFields::isNonUnionUninit(const 
TypedValueRegion *R,
 
 if (isPrimitiveType(T)) {
   if (I->isUnnamedBitField()) {
-IsAnyFieldInitialized = true;
 continue;
   }
   if (isPrimitiveUninit(V)) {

>From fdff9198f3355ff2f27da5f8682875ba500cbeb9 Mon Sep 17 00:00:00 2001
From: kr-2003 
Date: Sat, 22 Mar 2025 03:34:17 +0530
Subject: [PATCH 3/3] added regression tests for unnamed bitfield

---
 .../Analysis/cxx-uninitialized-object.cpp | 21 +++
 1 file changed, 21 insertions(+)

diff --git a/clang/test/Analysis/cxx-uninitialized-object.cpp 
b/clang/test/Analysis/cxx-uninitialized-object.cpp
index e3fa8ae8d7f29..43b1628388509 100644
--- a/clang/test/Analysis/cxx-uninitialized-object.cpp
+++ b/clang/test/Analysis/cxx-uninitialized-object.cpp
@@ -1182,3 +1182,24 @@ void fComplexTest() {
   // TODO: we should emit a warning for x2.x and x2.y.
   ComplexUninitTest x2;
 }
+
+struct PaddingBitfieldTest {
+  int a;
+  long long : 7; // padding, previously flagged as uninitialized
+  PaddingBitfieldTest(int a) : a(a) {}
+};
+
+void fPaddingBitfieldTest() {
+  PaddingBitfieldTest pb(42);
+  // no-warning: Unnamed bitfield is now ignored, fixing false positive
+}
+
+struct NamedBitfieldTest {
+  int b; 
+  long long named : 7; // expected-note{{uninitialized field 'this->named'}}
+  NamedBitfieldTest(int b) : b(b) {} // expected-warning{{1 uninitialized 
field at the end of the constructor call}}
+};
+
+void fNamedBitfieldTest() {
+  NamedBitfieldTest nb(42); 
+}

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


[clang] [Clang] Introduce __builtin_is_modifiable_lvalue() (PR #132524)

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

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


[clang] [Clang] Introduce __builtin_is_modifiable_lvalue() (PR #132524)

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

tbaederr wrote:

It looks like this is similar to `__builtin_constant_p` - what is the proposed 
behavior wrt. side effects in the evaluated expression? gcc and clang disagree 
about this a lot currently: https://godbolt.org/z/rbneznT9z

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


[clang] 3840f78 - [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (#132184)

2025-03-21 Thread via cfe-commits

Author: quic_hchandel
Date: 2025-03-22T07:57:07+05:30
New Revision: 3840f787a21a66686f5d8bf61877d41f3a65f205

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

LOG: [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (#132184)

This extension adds nine instructions, eight for non-memory-mapped
devices synchronization and delay instruction.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/tag/Xqci-0.7.0

This patch adds assembler only support.

Co-authored-by: Sudharsan Veeravalli 

Added: 
llvm/test/MC/RISCV/xqcisync-invalid.s
llvm/test/MC/RISCV/xqcisync-valid.s

Modified: 
clang/test/Driver/print-supported-extensions-riscv.c
llvm/docs/RISCVUsage.rst
llvm/docs/ReleaseNotes.md
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td
llvm/lib/TargetParser/RISCVISAInfo.cpp
llvm/test/CodeGen/RISCV/attributes.ll
llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Removed: 




diff  --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index d6c50da75fe4f..b5533b54347b9 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -213,6 +213,7 @@
 // CHECK-NEXT: xqcilsm  0.2   '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)
 // CHECK-NEXT: xrivosvisni  0.1   'XRivosVisni' (Rivos Vector 
Integer Small New)
 // CHECK-NEXT: xrivosvizip  0.1   'XRivosVizip' (Rivos Vector 
Register Zips)
 // CHECK-EMPTY:

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 4f261f06ce633..8735b274a805f 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -485,6 +485,9 @@ The current vendor extensions supported are:
 ``experimental-Xqcisls``
   LLVM implements `version 0.2 of the Qualcomm uC Scaled Load Store extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
+``experimental-Xqcisync``
+  LLVM implements `version 0.2 of the Qualcomm uC Sync Delay extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
+
 ``Xmipscmove``
   LLVM implements conditional move for the `p8700 processor 
` by MIPS.
 

diff  --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 157065cb86214..1e39f761ecdad 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -140,6 +140,8 @@ Changes to the RISC-V Backend
 * Added non-quadratic ``log-vrgather`` cost model for ``vrgather.vv`` 
instruction
 * Adds experimental assembler support for the Qualcomm uC 'Xqcisim` 
(Simulation Hint)
   extension.
+* Adds experimental assembler support for the Qualcomm uC 'Xqcisync` (Sync 
Delay)
+  extension.
 * Adds assembler support for the 'Zilsd` (Load/Store Pair Instructions)
   extension.
 * Adds assembler support for the 'Zclsd` (Compressed Load/Store Pair 
Instructions)

diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 5833ce2270e72..04fe46ad12836 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -772,6 +772,18 @@ struct RISCVOperand final : public MCParsedAsmOperand {
VK == RISCVMCExpr::VK_None;
   }
 
+  bool isUImm5Slist() const {
+if (!isImm())
+  return false;
+RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
+int64_t Imm;
+bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
+return IsConstantImm &&
+   ((Imm == 0) || (Imm == 1) || (Imm == 2) || (Imm == 4) ||
+(Imm == 8) || (Imm == 16) || (Imm == 15) || (Imm == 31)) &&
+   VK == RISCVMCExpr::VK_None;
+  }
+
   bool isUImm8GE32() const {
 int64_t Imm;
 RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_Non

[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

2025-03-21 Thread Sudharsan Veeravalli via cfe-commits

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


[clang] [libc] [clang] diagnose invalid member pointer class on instantiation (PR #132516)

2025-03-21 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang][bytecode] Support overlapping regions in __builtin_memmove (PR #132523)

2025-03-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Unfortunately, a few circumstances make the implementation here less than 
ideal, but we need to handle overlapping regions anyway.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp (+29-12) 
- (modified) clang/test/AST/ByteCode/builtin-functions.cpp (+1-2) 


``diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
index 6b8860c09167c..239b3104e89f1 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
@@ -19,6 +19,8 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/Basic/TargetInfo.h"
 
+#include 
+
 using namespace clang;
 using namespace clang::interp;
 
@@ -450,33 +452,48 @@ bool clang::interp::DoBitCastPtr(InterpState &S, CodePtr 
OpPC,
   return Success;
 }
 
+using PrimTypeVariant =
+std::variant, Integral<8, true>, Integral<16, false>,
+ Integral<16, true>, Integral<32, false>, Integral<32, true>,
+ Integral<64, false>, Integral<64, true>, IntegralAP,
+ IntegralAP, Boolean, Floating>;
+
+// NB: This implementation isn't exactly ideal, but:
+//   1) We can't just do a bitcast here since we need to be able to
+//  copy pointers.
+//   2) This also needs to handle overlapping regions.
+//   3) We currently have no way of iterating over the fields of a pointer
+//  backwards.
 bool clang::interp::DoMemcpy(InterpState &S, CodePtr OpPC,
  const Pointer &SrcPtr, const Pointer &DestPtr,
  Bits Size) {
   assert(SrcPtr.isBlockPointer());
   assert(DestPtr.isBlockPointer());
 
-  unsigned SrcStartOffset = SrcPtr.getByteOffset();
-  unsigned DestStartOffset = DestPtr.getByteOffset();
-
+  llvm::SmallVector Values;
   enumeratePointerFields(SrcPtr, S.getContext(), Size,
  [&](const Pointer &P, PrimType T, Bits BitOffset,
  Bits FullBitWidth, bool PackedBools) -> bool {
-   unsigned SrcOffsetDiff =
-   P.getByteOffset() - SrcStartOffset;
-
-   Pointer DestP =
-   Pointer(DestPtr.asBlockPointer().Pointee,
-   DestPtr.asBlockPointer().Base,
-   DestStartOffset + SrcOffsetDiff);
+   TYPE_SWITCH(T, { Values.push_back(P.deref()); });
+   return true;
+ });
 
+  unsigned ValueIndex = 0;
+  enumeratePointerFields(DestPtr, S.getContext(), Size,
+ [&](const Pointer &P, PrimType T, Bits BitOffset,
+ Bits FullBitWidth, bool PackedBools) -> bool {
TYPE_SWITCH(T, {
- DestP.deref() = P.deref();
- DestP.initialize();
+ P.deref() = std::get(Values[ValueIndex]);
+ P.initialize();
});
 
+   ++ValueIndex;
return true;
  });
 
+  // We should've read all the values into DestPtr.
+  assert(ValueIndex == Values.size());
+
   return true;
 }
diff --git a/clang/test/AST/ByteCode/builtin-functions.cpp 
b/clang/test/AST/ByteCode/builtin-functions.cpp
index 3dd348031fec1..13a34f71a6354 100644
--- a/clang/test/AST/ByteCode/builtin-functions.cpp
+++ b/clang/test/AST/ByteCode/builtin-functions.cpp
@@ -1276,7 +1276,6 @@ namespace BuiltinMemcpy {
   static_assert(test_incomplete_array_type() == 1234); // both-error 
{{constant}} both-note {{in call}}
 
 
-  /// FIXME: memmove needs to support overlapping memory regions.
   constexpr bool memmoveOverlapping() {
 char s1[] {1, 2, 3};
 __builtin_memmove(s1, s1 + 1, 2 * sizeof(char));
@@ -1289,7 +1288,7 @@ namespace BuiltinMemcpy {
 
 return Result1 && Result2;
   }
-  static_assert(memmoveOverlapping()); // expected-error {{failed}}
+  static_assert(memmoveOverlapping());
 }
 
 namespace Memcmp {

``




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


[clang] 597accf - [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (#131976)

2025-03-21 Thread via cfe-commits

Author: Ben Shi
Date: 2025-03-22T13:22:32+08:00
New Revision: 597accfea6150e77304427fb97d0c3798178e040

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

LOG: [clang][CodeGen][AVR] Fix a crash in AVRABIInfo (#131976)

fixes https://github.com/llvm/llvm-project/issues/131967

Added: 


Modified: 
clang/lib/CodeGen/Targets/AVR.cpp
clang/test/CodeGen/avr/argument.c

Removed: 




diff  --git a/clang/lib/CodeGen/Targets/AVR.cpp 
b/clang/lib/CodeGen/Targets/AVR.cpp
index 26e2a22f14d1e..5399d12f7ce80 100644
--- a/clang/lib/CodeGen/Targets/AVR.cpp
+++ b/clang/lib/CodeGen/Targets/AVR.cpp
@@ -59,7 +59,7 @@ class AVRABIInfo : public DefaultABIInfo {
 unsigned TySize = getContext().getTypeSize(Ty);
 
 // An int8 type argument always costs two registers like an int16.
-if (TySize == 8 && NumRegs >= 2) {
+if (TySize == 8 && NumRegs >= 2 && Ty->isIntegralOrEnumerationType()) {
   NumRegs -= 2;
   return ABIArgInfo::getExtend(Ty);
 }

diff  --git a/clang/test/CodeGen/avr/argument.c 
b/clang/test/CodeGen/avr/argument.c
index 31bf678c05a54..1776cd7cf2c01 100644
--- a/clang/test/CodeGen/avr/argument.c
+++ b/clang/test/CodeGen/avr/argument.c
@@ -114,3 +114,13 @@ struct s15 fooa(char a, char b) {
   x.arr[1] = b;
   return x;
 }
+
+struct s8_t {
+  char a;
+};
+
+// AVR:  define {{.*}} i8 @foob(i8 {{.*}})
+// TINY: define {{.*}} i8 @foob(i8 {{.*}})
+char foob(struct s8_t a) {
+  return a.a + 1;
+}



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


[clang] [llvm] [RISCV] Implement the implications of C extension (PR #132259)

2025-03-21 Thread Jesse Huang via cfe-commits


@@ -378,6 +370,14 @@ def FeatureStdExtZca
  "part of the C extension, excluding compressed "
  "floating point loads/stores">;
 
+def FeatureStdExtC
+: RISCVExtension<2, 0, "Compressed Instructions", [FeatureStdExtZca]>,
+  RISCVExtensionBitmask<0, 2>;
+def HasStdExtC : Predicate<"Subtarget->hasStdExtC()">,
+ AssemblerPredicate<(all_of FeatureStdExtC),
+"'C' (Compressed Instructions)">;
+
+
 def HasStdExtCOrZca
 : Predicate<"Subtarget->hasStdExtCOrZca()">,
   AssemblerPredicate<(any_of FeatureStdExtC, FeatureStdExtZca),

jaidTw wrote:

Thanks for the pointer, I will take a look on it

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


[clang] [llvm] [RISCV] Implement the implications of C extension (PR #132259)

2025-03-21 Thread Jesse Huang via cfe-commits

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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcisync (Sync Delay) extension (PR #132184)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `publish-sphinx-docs` 
running on `as-worker-4` while building `clang,llvm` at step 5 
"build-docs-llvm-html-docs-clang-html-docs-clang...".

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


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

```
Step 5 (build-docs-llvm-html-docs-clang-html-docs-clang...) failure: build 
(failure)
...
841.337 [2765/24/2485] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVRedundantCopyElimination.cpp.o
844.240 [2764/24/2486] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVSelectionDAGInfo.cpp.o
847.714 [2763/24/2487] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVMoveMerger.cpp.o
848.213 [2762/24/2488] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVPushPopOptimizer.cpp.o
850.222 [2761/24/2489] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVVectorPeephole.cpp.o
850.564 [2760/24/2490] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVInstrInfo.cpp.o
850.688 [2759/24/2491] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVRegisterInfo.cpp.o
851.368 [2758/24/2492] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVVectorMaskDAGMutation.cpp.o
851.557 [2757/24/2493] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVVMV0Elimination.cpp.o
851.741 [2756/24/2494] Building CXX object 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
FAILED: 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbot/as-worker-4/publish-sphinx-docs/build/lib/Target/RISCV/AsmParser
 
-I/home/buildbot/as-worker-4/publish-sphinx-docs/llvm-project/llvm/lib/Target/RISCV/AsmParser
 
-I/home/buildbot/as-worker-4/publish-sphinx-docs/llvm-project/llvm/lib/Target/RISCV
 -I/home/buildbot/as-worker-4/publish-sphinx-docs/build/lib/Target/RISCV 
-I/home/buildbot/as-worker-4/publish-sphinx-docs/build/include 
-I/home/buildbot/as-worker-4/publish-sphinx-docs/llvm-project/llvm/include 
-fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move 
-Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor 
-Wsuggest-override -Wno-comment -Wno-misleading-indentation -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG -fvisibility=hidden  
-fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 -MF 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o.d
 -o 
lib/Target/RISCV/AsmParser/CMakeFiles/LLVMRISCVAsmParser.dir/RISCVAsmParser.cpp.o
 -c 
/home/buildbot/as-worker-4/publish-sphinx-docs/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
/home/buildbot/as-worker-4/publish-sphinx-docs/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:
 In member function ‘bool {anonymous}::RISCVOperand::isUImm5Slist() const’:
/home/buildbot/as-worker-4/publish-sphinx-docs/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:778:18:
 error: ‘VariantKind’ is not a member of ‘llvm::RISCVMCExpr’
  778 | RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_None;
  |  ^~~
/home/buildbot/as-worker-4/publish-sphinx-docs/llvm-project/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:780:61:
 error: ‘VK’ was not declared in this scope
  780 | bool IsConstantImm = evaluateConstantImm(getImm(), Imm, VK);
  | ^~
852.418 [2756/23/2495] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVTargetObjectFile.cpp.o
852.435 [2756/22/2496] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVVLOptimizer.cpp.o
853.126 [2756/21/2497] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVSubtarget.cpp.o
853.269 [2756/20/2498] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/RISCVZacasABIFix.cpp.o
853.859 [2756/19/2499] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVMCAsmInfo.cpp.o
854.410 [2756/18/2500] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles/LLVMRISCVDesc.dir/RISCVAsmBackend.cpp.o
854.543 [2756/17/2501] Building CXX object 
lib/Target/RISCV/CMakeFiles/LLVMRISCVCodeGen.dir/GISel/RISCVCallLowering.cpp.o
854.633 [2756/16/2502] Building CXX object 
lib/Target/RISCV/MCTargetD

[clang] 20b5728 - [RISCV] Implement the implications of C extension (#132259)

2025-03-21 Thread via cfe-commits

Author: Jesse Huang
Date: 2025-03-22T14:48:52+08:00
New Revision: 20b5728b7b1ccc4509a316efb270d46cc9526d69

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

LOG: [RISCV] Implement the implications of C extension (#132259)

Implement the following implications according to the [Zc
spec](https://github.com/riscvarchive/riscv-code-size-reduction/blob/main/Zc-specification/Zc.adoc#13-c)

> As C defines the same instructions as Zca, Zcf and Zcd, the rule is
that:
> * C always implies Zca
> * C+F implies Zcf (RV32 only)
> * C+D implies Zcd

Added: 


Modified: 
clang/test/CodeGen/RISCV/riscv-func-attr-target.c
clang/test/CodeGen/attr-target-clones-riscv.c
clang/test/CodeGen/attr-target-version-riscv.c
clang/test/CodeGenCXX/attr-target-clones-riscv.cpp
clang/test/CodeGenCXX/attr-target-version-riscv.cpp
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/lib/TargetParser/RISCVISAInfo.cpp
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/MC/RISCV/attribute-arch.s
llvm/test/MC/RISCV/attribute.s
llvm/test/MC/RISCV/option-arch.s
llvm/unittests/TargetParser/RISCVISAInfoTest.cpp

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c 
b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
index cd83876ec5f90..c5189d6aab28f 100644
--- a/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
+++ b/clang/test/CodeGen/RISCV/riscv-func-attr-target.c
@@ -85,11 +85,11 @@ int test_vsetvlmax_e64m1() {
 // CHECK: attributes #2 = { 
{{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zaamo,+zalrsc,+zbb,+zifencei,+zmmul,-relax,-zfa"
 }
 // CHECK: attributes #3 = { 
{{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+v,+zaamo,+zalrsc,+zbb,+zicond,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl128b,+zvl32b,+zvl64b,-relax,-zfa"
 }
 // Make sure we append negative features if we override the arch
-// CHECK: attributes #4 = { 
{{.*}}"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zbb,+zicsr,+zifencei,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
+// CHECK: attributes #4 = { 
{{.*}}"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zbb,+zca,+zcd,+zicsr,+zifencei,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
 // CHECK: attributes #5 = { 
{{.*}}"target-features"="+64bit,+m,+save-restore,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
 // CHECK: attributes #6 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+a,+m,+save-restore,+zaamo,+zalrsc,+zbb,+zifencei,+zmmul,-relax,-zfa"
 }
 // CHECK: attributes #7 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+m,+save-restore,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
-// CHECK: attributes #8 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
+// CHECK: attributes #8 = { {{.*}}"target-cpu"="sifive-u54" 
"target-features"="+64bit,+a,+c,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zca,+zcd,+zicsr,+zifencei,+zmmul,{{(-[[:alnum:]-]+)(,-[[:alnum:]-]+)*}}"
 }
 // CHECK: attributes #9 = { 
{{.*}}"target-features"="+64bit,+a,+m,+save-restore,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32x,+zvl32b,-relax,-zbb,-zfa"
 }
 // CHECK: attributes #11 = { 
{{.*}}"target-features"="+64bit,+a,+f,+m,+save-restore,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zvl32b,-relax,-zbb,-zfa"
 }
 // CHECK: attributes #12 = { 
{{.*}}"target-features"="+64bit,+a,+d,+f,+m,+save-restore,+zaamo,+zalrsc,+zicsr,+zifencei,+zmmul,+zve32f,+zve32x,+zve64d,+zve64f,+zve64x,+zvl32b,+zvl64b,-relax,-zbb,-zfa"
 }

diff  --git a/clang/test/CodeGen/attr-target-clones-riscv.c 
b/clang/test/CodeGen/attr-target-clones-riscv.c
index 2e8018c707d96..642302ba9d229 100644
--- a/clang/test/CodeGen/attr-target-clones-riscv.c
+++ b/clang/test/CodeGen/attr-target-clones-riscv.c
@@ -370,7 +370,7 @@ int bar() { return foo1() + foo2() + foo3() + foo4() + 
foo5() + foo6() + foo7()
 // CHECK: attributes #[[ATTR0]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+i" }
 // CHECK: attributes #[[ATTR1]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+i,+m,+zmmul" }
 // CHECK: attributes #[[ATTR2]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+i,+zbb" }
-// CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"target-features"="+64bit,+c,+i,+zbb" }
+// CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone 
"no-trapping-math"="true" "stack-protector-buffer-size"="8" 
"tar

[clang] Optimize Module Dependency Handling for Efficient Memory Usage (PR #132294)

2025-03-21 Thread Ayush Pareek via cfe-commits

ayushpareek2003 wrote:

@Bigcheese sir please have a look

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


[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

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


@@ -0,0 +1,8040 @@
+//===-- AArch64.cpp - Emit LLVM Code for builtins 
-===//

davemgreen wrote:

This looks like it should be Arm.cpp, as it is the common code between the Arm 
and AArch64 backends.

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


[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Alexandros Lamprineas via cfe-commits


@@ -1,1145 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
-
-int __attribute__((target_version("rng+flagm+fp16fml"))) fmv(void) { return 1; 
}
-int __attribute__((target_version("flagm2+sme-i16i64"))) fmv(void) { return 2; 
}
-int __attribute__((target_version("lse+sha2"))) fmv(void) { return 3; }
-int __attribute__((target_version("dotprod+wfxt"))) fmv(void) { return 4; }
-int __attribute__((target_version("fp16fml+memtag"))) fmv(void) { return 5; }
-int __attribute__((target_version("fp+aes"))) fmv(void) { return 6; }
-int __attribute__((target_version("crc+wfxt"))) fmv(void) { return 7; }
-int __attribute__((target_version("bti"))) fmv(void) { return 8; }
-int __attribute__((target_version("sme2"))) fmv(void) { return 9; }
-int __attribute__((target_version("default"))) fmv(void) { return 0; }
-int __attribute__((target_version("wfxt+simd"))) fmv_one(void) { return 1; }
-int __attribute__((target_version("dpb"))) fmv_one(void) { return 2; }
-int __attribute__((target_version("default"))) fmv_one(void) { return 0; }
-int __attribute__((target_version("fp"))) fmv_two(void) { return 1; }
-int __attribute__((target_version("simd"))) fmv_two(void) { return 2; }
-int __attribute__((target_version("fp16+simd"))) fmv_two(void) { return 4; }
-int __attribute__((target_version("default"))) fmv_two(void) { return 0; }
-int foo() {
-  return fmv()+fmv_one()+fmv_two();
-}
-
-inline int __attribute__((target_version("sha2+aes+f64mm"))) fmv_inline(void) 
{ return 1; }
-inline int __attribute__((target_version("fp16+fcma+rdma+sme+ fp16 "))) 
fmv_inline(void) { return 2; }
-inline int __attribute__((target_version("sha3+i8mm+f32mm"))) fmv_inline(void) 
{ return 12; }
-inline int __attribute__((target_version("dit+bf16"))) fmv_inline(void) { 
return 8; }
-inline int __attribute__((target_version("dpb+rcpc2 "))) fmv_inline(void) { 
return 6; }
-inline int __attribute__((target_version(" dpb2 + jscvt"))) fmv_inline(void) { 
return 7; }
-inline int __attribute__((target_version("rcpc+frintts"))) fmv_inline(void) { 
return 3; }
-inline int __attribute__((target_version("sve+bf16"))) fmv_inline(void) { 
return 4; }
-inline int __attribute__((target_version("sve2-aes+sve2-sha3"))) 
fmv_inline(void) { return 5; }
-inline int __attribute__((target_version("sve2+sve2-aes+sve2-bitperm"))) 
fmv_inline(void) { return 9; }
-inline int __attribute__((target_version("sve2-sm4+memtag"))) fmv_inline(void) 
{ return 10; }
-inline int __attribute__((target_version("memtag+rcpc3+mops"))) 
fmv_inline(void) { return 11; }
-inline int __attribute__((target_version("aes+dotprod"))) fmv_inline(void) { 
return 13; }
-inline int __attribute__((target_version("simd+fp16fml"))) fmv_inline(void) { 
return 14; }
-inline int __attribute__((target_version("fp+sm4"))) fmv_inline(void) { return 
15; }
-inline int __attribute__((target_version("lse+rdm"))) fmv_inline(void) { 
return 16; }
-inline int __attribute__((target_version("default"))) fmv_inline(void) { 
return 3; }
-
-__attribute__((target_version("wfxt"))) int fmv_e(void);
-int fmv_e(void) { return 20; }
-
-static __attribute__((target_version("sb"))) inline int fmv_d(void);
-static __attribute__((target_version("default"))) inline int fmv_d(void);
-
-int __attribute__((target_version("default"))) fmv_default(void) { return 111; 
}
-int fmv_default(void);
-
-void fmv_c(void);
-void __attribute__((target_version("ssbs"))) fmv_c(void){};
-void __attribute__((target_version("default"))) fmv_c(void){};
-
-int goo() {
-  fmv_inline();
-  fmv_e();
-  fmv_d();
-  fmv_c();
-  return fmv_default();
-}
-static inline int __attribute__((target_version("sb"))) fmv_d(void) { return 
0; }
-static inline int __attribute__((target_version(" default "))) fmv_d(void) { 
return 1; }
-
-static void func(void) {}
-inline __attribute__((target_version("default"))) void recb(void) { func(); }
-inline __attribute__((target_version("default"))) void reca(void) { recb(); }
-void recur(void) { reca(); }
-
-int __attribute__((target_version("default"))) main(void) {
-  recur();
-  return goo();
-}
-
-typedef int (*Fptr)();
-void f(Fptr);
-int hoo(void) {
-  f(fmv);
-  Fptr fp1 = &fmv;
-  Fptr fp2 = fmv;
-  return fp1() + fp2();
-}
-
-// This should generate one target version but no resolver.
-__attribute__((target_version("default"))) int 
unused_with_forward_default_decl(void);
-__attribute__((target_version("mops"))) int 
unused_with_forward_default_decl(void) { return 0; }
-
-// This should also generate one target version but no resolver.
-extern int unused_with_implicit_extern_forward_default_decl(void);
-__attribute__((target_v

[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)

2025-03-21 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov created 
https://github.com/llvm/llvm-project/pull/132387

This changes exposes a low-level helper that is used to implement 
`forEachArgumentWithParamType` but can also be used without matchers, e.g. if 
performance is a concern.

Commit f5ee10538b68835112323c241ca7db67ca78bf62 introduced a copy of the 
implementation of the `forEachArgumentWithParamType` matcher that was needed 
for optimizing performance of `-Wunsafe-buffer-usage`.

This change shares the code between the two so that we do not repeat ourselves 
and any bugfixes or changes will be picked up by both implementations in the 
future.

>From ef63166c24f7328af8177220be706a573d97009e Mon Sep 17 00:00:00 2001
From: Ilya Biryukov 
Date: Fri, 21 Mar 2025 11:42:32 +0100
Subject: [PATCH] [NFC] [ASTMatchers] Share code of
 `forEachArgumentWithParamType` with UnsafeBufferUsage

This changes exposes a low-level helper that is also used to implement
`forEachArgumentWithParamType`, but can be used without matchers, e.g.
if performance is a concern.

Commit f5ee10538b68835112323c241ca7db67ca78bf62 introduced a copy of the
implementation of the `forEachArgumentWithParamType` matcher that was
needed for optimizing performance of `-Wunsafe-buffer-usage`.

This change will ensure the code is shared so that we do not repeat
ourselves and any bugfixes or changes will be picked up by both
implementations in the future.
---
 clang/include/clang/ASTMatchers/ASTMatchers.h |  75 +++--
 .../clang/ASTMatchers/LowLevelHelpers.h   |  37 ++
 clang/lib/ASTMatchers/CMakeLists.txt  |   1 +
 clang/lib/ASTMatchers/LowLevelHelpers.cpp | 105 ++
 clang/lib/Analysis/UnsafeBufferUsage.cpp  |  95 +---
 5 files changed, 162 insertions(+), 151 deletions(-)
 create mode 100644 clang/include/clang/ASTMatchers/LowLevelHelpers.h
 create mode 100644 clang/lib/ASTMatchers/LowLevelHelpers.cpp

diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 738617759eb29..26a58cea49b5a 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -71,6 +71,7 @@
 #include "clang/AST/TypeLoc.h"
 #include "clang/ASTMatchers/ASTMatchersInternal.h"
 #include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/ASTMatchers/LowLevelHelpers.h"
 #include "clang/Basic/AttrKinds.h"
 #include "clang/Basic/ExceptionSpecificationType.h"
 #include "clang/Basic/FileManager.h"
@@ -5215,68 +5216,26 @@ AST_POLYMORPHIC_MATCHER_P2(forEachArgumentWithParamType,
   // argument of the method which should not be matched against a parameter, so
   // we skip over it here.
   BoundNodesTreeBuilder Matches;
-  unsigned ArgIndex =
-  cxxOperatorCallExpr(
-  callee(cxxMethodDecl(unless(isExplicitObjectMemberFunction()
-  .matches(Node, Finder, &Matches)
-  ? 1
-  : 0;
-  const FunctionProtoType *FProto = nullptr;
-
-  if (const auto *Call = dyn_cast(&Node)) {
-if (const auto *Value =
-dyn_cast_or_null(Call->getCalleeDecl())) {
-  QualType QT = Value->getType().getCanonicalType();
-
-  // This does not necessarily lead to a `FunctionProtoType`,
-  // e.g. K&R functions do not have a function prototype.
-  if (QT->isFunctionPointerType())
-FProto = QT->getPointeeType()->getAs();
-
-  if (QT->isMemberFunctionPointerType()) {
-const auto *MP = QT->getAs();
-assert(MP && "Must be member-pointer if its a memberfunctionpointer");
-FProto = MP->getPointeeType()->getAs();
-assert(FProto &&
-   "The call must have happened through a member function "
-   "pointer");
-  }
-}
-  }
 
-  unsigned ParamIndex = 0;
   bool Matched = false;
-  unsigned NumArgs = Node.getNumArgs();
-  if (FProto && FProto->isVariadic())
-NumArgs = std::min(NumArgs, FProto->getNumParams());
-
-  for (; ArgIndex < NumArgs; ++ArgIndex, ++ParamIndex) {
+  auto ProcessParamAndArg = [&](QualType ParamType, const Expr *Arg) {
 BoundNodesTreeBuilder ArgMatches(*Builder);
-if (ArgMatcher.matches(*(Node.getArg(ArgIndex)->IgnoreParenCasts()), 
Finder,
-   &ArgMatches)) {
-  BoundNodesTreeBuilder ParamMatches(ArgMatches);
+if (!ArgMatcher.matches(*Arg, Finder, &ArgMatches))
+  return;
+BoundNodesTreeBuilder ParamMatches(std::move(ArgMatches));
+if (!ParamMatcher.matches(ParamType, Finder, &ParamMatches))
+  return;
+Result.addMatch(ParamMatches);
+Matched = true;
+return;
+  };
+  if (auto *Call = llvm::dyn_cast(&Node))
+matchEachArgumentWithParamType(*Call, ProcessParamAndArg);
+  else if (auto *Construct = llvm::dyn_cast(&Node))
+matchEachArgumentWithParamType(*Construct, ProcessParamAndArg);
+  else
+return false;
 
-  // This test is cheaper compared to the big matcher in the next if.
-  // Therefore, please keep this order.
-  

[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Alexandros Lamprineas via cfe-commits


@@ -1,1145 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
-
-int __attribute__((target_version("rng+flagm+fp16fml"))) fmv(void) { return 1; 
}
-int __attribute__((target_version("flagm2+sme-i16i64"))) fmv(void) { return 2; 
}
-int __attribute__((target_version("lse+sha2"))) fmv(void) { return 3; }
-int __attribute__((target_version("dotprod+wfxt"))) fmv(void) { return 4; }
-int __attribute__((target_version("fp16fml+memtag"))) fmv(void) { return 5; }
-int __attribute__((target_version("fp+aes"))) fmv(void) { return 6; }
-int __attribute__((target_version("crc+wfxt"))) fmv(void) { return 7; }
-int __attribute__((target_version("bti"))) fmv(void) { return 8; }
-int __attribute__((target_version("sme2"))) fmv(void) { return 9; }
-int __attribute__((target_version("default"))) fmv(void) { return 0; }
-int __attribute__((target_version("wfxt+simd"))) fmv_one(void) { return 1; }
-int __attribute__((target_version("dpb"))) fmv_one(void) { return 2; }
-int __attribute__((target_version("default"))) fmv_one(void) { return 0; }
-int __attribute__((target_version("fp"))) fmv_two(void) { return 1; }
-int __attribute__((target_version("simd"))) fmv_two(void) { return 2; }
-int __attribute__((target_version("fp16+simd"))) fmv_two(void) { return 4; }
-int __attribute__((target_version("default"))) fmv_two(void) { return 0; }
-int foo() {
-  return fmv()+fmv_one()+fmv_two();
-}
-
-inline int __attribute__((target_version("sha2+aes+f64mm"))) fmv_inline(void) 
{ return 1; }
-inline int __attribute__((target_version("fp16+fcma+rdma+sme+ fp16 "))) 
fmv_inline(void) { return 2; }
-inline int __attribute__((target_version("sha3+i8mm+f32mm"))) fmv_inline(void) 
{ return 12; }
-inline int __attribute__((target_version("dit+bf16"))) fmv_inline(void) { 
return 8; }
-inline int __attribute__((target_version("dpb+rcpc2 "))) fmv_inline(void) { 
return 6; }
-inline int __attribute__((target_version(" dpb2 + jscvt"))) fmv_inline(void) { 
return 7; }
-inline int __attribute__((target_version("rcpc+frintts"))) fmv_inline(void) { 
return 3; }
-inline int __attribute__((target_version("sve+bf16"))) fmv_inline(void) { 
return 4; }
-inline int __attribute__((target_version("sve2-aes+sve2-sha3"))) 
fmv_inline(void) { return 5; }
-inline int __attribute__((target_version("sve2+sve2-aes+sve2-bitperm"))) 
fmv_inline(void) { return 9; }
-inline int __attribute__((target_version("sve2-sm4+memtag"))) fmv_inline(void) 
{ return 10; }
-inline int __attribute__((target_version("memtag+rcpc3+mops"))) 
fmv_inline(void) { return 11; }
-inline int __attribute__((target_version("aes+dotprod"))) fmv_inline(void) { 
return 13; }
-inline int __attribute__((target_version("simd+fp16fml"))) fmv_inline(void) { 
return 14; }
-inline int __attribute__((target_version("fp+sm4"))) fmv_inline(void) { return 
15; }
-inline int __attribute__((target_version("lse+rdm"))) fmv_inline(void) { 
return 16; }
-inline int __attribute__((target_version("default"))) fmv_inline(void) { 
return 3; }
-
-__attribute__((target_version("wfxt"))) int fmv_e(void);
-int fmv_e(void) { return 20; }
-
-static __attribute__((target_version("sb"))) inline int fmv_d(void);
-static __attribute__((target_version("default"))) inline int fmv_d(void);
-
-int __attribute__((target_version("default"))) fmv_default(void) { return 111; 
}
-int fmv_default(void);
-
-void fmv_c(void);
-void __attribute__((target_version("ssbs"))) fmv_c(void){};
-void __attribute__((target_version("default"))) fmv_c(void){};
-
-int goo() {
-  fmv_inline();
-  fmv_e();
-  fmv_d();
-  fmv_c();
-  return fmv_default();
-}
-static inline int __attribute__((target_version("sb"))) fmv_d(void) { return 
0; }
-static inline int __attribute__((target_version(" default "))) fmv_d(void) { 
return 1; }
-
-static void func(void) {}
-inline __attribute__((target_version("default"))) void recb(void) { func(); }
-inline __attribute__((target_version("default"))) void reca(void) { recb(); }
-void recur(void) { reca(); }
-
-int __attribute__((target_version("default"))) main(void) {
-  recur();
-  return goo();
-}
-
-typedef int (*Fptr)();
-void f(Fptr);
-int hoo(void) {
-  f(fmv);
-  Fptr fp1 = &fmv;
-  Fptr fp2 = fmv;
-  return fp1() + fp2();
-}
-
-// This should generate one target version but no resolver.
-__attribute__((target_version("default"))) int 
unused_with_forward_default_decl(void);
-__attribute__((target_version("mops"))) int 
unused_with_forward_default_decl(void) { return 0; }
-
-// This should also generate one target version but no resolver.
-extern int unused_with_implicit_extern_forward_default_decl(void);
-__attribute__((target_v

[clang] [clang-format] Fix the indent of the ternary operator when AlignOperands and BreakBeforeTernaryOperators is specified. (PR #100860)

2025-03-21 Thread via cfe-commits

https://github.com/mydeveloperday requested changes to this pull request.

This change is subjective not objective. Other people will have other views as 
such this can't come in like this or we'll change 1000s lines of code without 
people having control to keep this current style.

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


[clang] [clang] Fix nullptr dereference when checking friend default comparison (PR #132320)

2025-03-21 Thread Chongzhi Deng via cfe-commits

https://github.com/BruceAko updated 
https://github.com/llvm/llvm-project/pull/132320

>From bcf24c8442023fbe9283b0746ea5d2ba3ecfb86f Mon Sep 17 00:00:00 2001
From: BruceAko 
Date: Fri, 21 Mar 2025 07:54:16 +
Subject: [PATCH] [clang] Fix nullptr dereference when checking friend default
 comparison

Fix comparison check for explicitly defaulted functions by using 
declaresSameEntity for friend declarations.
---
 clang/lib/Sema/SemaDeclCXX.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a1551e8027cd3..3298fc84db4e7 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9039,8 +9039,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;

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


[clang] [clang] Fix nullptr dereference when checking friend default comparison (PR #132320)

2025-03-21 Thread Chongzhi Deng via cfe-commits

https://github.com/BruceAko updated 
https://github.com/llvm/llvm-project/pull/132320

>From 3268a174a694eacb57fe13b732ef961dc94bee0b Mon Sep 17 00:00:00 2001
From: BruceAko 
Date: Fri, 21 Mar 2025 07:54:16 +
Subject: [PATCH] [clang] Fix nullptr dereference when checking friend default
 comparison

Fix comparison check for explicitly defaulted functions by using 
declaresSameEntity for friend declarations.
---
 clang/lib/Sema/SemaDeclCXX.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a1551e8027cd3..ad4a6779a1fcf 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -9039,8 +9039,7 @@ bool Sema::CheckExplicitlyDefaultedComparison(Scope *S, 
FunctionDecl *FD,
   return true;
 
 if (llvm::none_of(RD->friends(), [&](const FriendDecl *F) {
-  return FD->getCanonicalDecl() ==
- F->getFriendDecl()->getCanonicalDecl();
+  return declaresSameEntity(F->getFriendDecl(), FD);
 })) {
   Diag(FD->getLocation(), diag::err_defaulted_comparison_not_friend)
   << int(DCK) << int(0) << RD;

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


[clang] Reapply "[Clang] Improve diagnostics for expansion length mismatch" (PR #121044)

2025-03-21 Thread Younan Zhang via cfe-commits


@@ -749,132 +759,124 @@ ExprResult Sema::CheckPackExpansion(Expr *Pattern, 
SourceLocation EllipsisLoc,
 PackExpansionExpr(Context.DependentTy, Pattern, EllipsisLoc, 
NumExpansions);
 }
 
+static bool IsUnexpandedPackExpansion(const TemplateArgument &TA) {
+  if (!TA.isPackExpansion())
+return false;
+
+  if (TA.getKind() == TemplateArgument::Type)
+return !TA.getAsType()->getAs()->getNumExpansions();
+
+  if (TA.getKind() == TemplateArgument::Expression)
+return !cast(TA.getAsExpr())->getNumExpansions();
+
+  return !TA.getNumTemplateExpansions();
+}
+
 bool Sema::CheckParameterPacksForExpansion(
 SourceLocation EllipsisLoc, SourceRange PatternRange,
 ArrayRef Unexpanded,
 const MultiLevelTemplateArgumentList &TemplateArgs, bool &ShouldExpand,
 bool &RetainExpansion, std::optional &NumExpansions) {
   ShouldExpand = true;
   RetainExpansion = false;
-  std::pair FirstPack;
-  bool HaveFirstPack = false;
-  std::optional NumPartialExpansions;
-  SourceLocation PartiallySubstitutedPackLoc;
-  typedef LocalInstantiationScope::DeclArgumentPack DeclArgumentPack;
+  std::pair FirstPack;
+  std::optional> PartialExpansion;
+  std::optional CurNumExpansions, CurMaximumOfLeastExpansions;
 
-  for (UnexpandedParameterPack ParmPack : Unexpanded) {
+  for (auto [P, Loc] : Unexpanded) {
 // Compute the depth and index for this parameter pack.
-unsigned Depth = 0, Index = 0;
-IdentifierInfo *Name;
-bool IsVarDeclPack = false;
-FunctionParmPackExpr *BindingPack = nullptr;
-
-if (const TemplateTypeParmType *TTP =
-ParmPack.first.dyn_cast()) {
-  Depth = TTP->getDepth();
-  Index = TTP->getIndex();
-  Name = TTP->getIdentifier();
-} else {
-  NamedDecl *ND = cast(ParmPack.first);
-  if (isa(ND))
-IsVarDeclPack = true;
-  else if (isa(ND)) {
+std::optional> Pos;
+unsigned NewPackSize, PendingPackExpansionSize = 0;
+const auto *ND = dyn_cast_if_present(P);
+if (ND) {
+  if (isa(ND)) {
+auto *DAP = dyn_cast(
+*CurrentInstantiationScope->findInstantiationOf(ND));
+if (!DAP) {
+  // We can't expand this function parameter pack, so we can't expand
+  // the pack expansion.
+  ShouldExpand = false;
+  continue;
+}
+NewPackSize = DAP->size();
+  } else if (isa(ND)) {
 // Find the instantiated BindingDecl and check it for a resolved pack.
-llvm::PointerUnion *Instantiation =
-CurrentInstantiationScope->findInstantiationOf(ND);
+llvm::PointerUnion
+*Instantiation = 
CurrentInstantiationScope->findInstantiationOf(ND);
 Decl *B = cast(*Instantiation);
 Expr *BindingExpr = cast(B)->getBinding();
-BindingPack = cast_if_present(BindingExpr);
+auto *BindingPack = cast_if_present(BindingExpr);
 if (!BindingPack) {
   ShouldExpand = false;
   continue;
 }
+NewPackSize = BindingPack->getNumExpansions();
   } else
-std::tie(Depth, Index) = getDepthAndIndex(ND);
-
-  Name = ND->getIdentifier();
+Pos = getDepthAndIndex(ND);
+} else if (const auto *TTP = dyn_cast(P)) {
+  Pos = {TTP->getDepth(), TTP->getIndex()};
+  ND = TTP->getDecl();
+  // FIXME: We either should have some fallback for canonical TTP, or
+  //never have canonical TTP here.
+} else if (const auto *STP =
+   dyn_cast(P)) {
+  NewPackSize = STP->getNumArgs();
+  PendingPackExpansionSize = llvm::count_if(
+  STP->getArgumentPack().getPackAsArray(), IsUnexpandedPackExpansion);
+  ND = STP->getReplacedParameter();
+} else {
+  const auto *SEP = cast(P);
+  NewPackSize = SEP->getArgumentPack().pack_size();
+  PendingPackExpansionSize = llvm::count_if(
+  SEP->getArgumentPack().getPackAsArray(), IsUnexpandedPackExpansion);
+  ND = SEP->getParameterPack();
 }
 
-// Determine the size of this argument pack.
-unsigned NewPackSize, PendingPackExpansionSize = 0;
-if (IsVarDeclPack) {
-  // Figure out whether we're instantiating to an argument pack or not.
-  llvm::PointerUnion *Instantiation =
-  CurrentInstantiationScope->findInstantiationOf(
-  cast(ParmPack.first));
-  if (isa(*Instantiation)) {
-// We could expand this function parameter pack.
-NewPackSize = cast(*Instantiation)->size();
-  } else {
-// We can't expand this function parameter pack, so we can't expand
-// the pack expansion.
-ShouldExpand = false;
-continue;
-  }
-} else if (BindingPack) {
-  NewPackSize = BindingPack->getNumExpansions();
-} else {
+if (Pos) {
   // If we don't have a template argument at this depth/index, then we
   // cannot expand the pack expansion. Make a note of this, but we still
   // want to check any parameter

[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

2025-03-21 Thread Donát Nagy via cfe-commits


@@ -1403,6 +1403,16 @@ void NullabilityChecker::printState(raw_ostream &Out, 
ProgramStateRef State,
   }
 }
 
+// The checker group "nullability" consists of the checkers that are
+// implemented as the parts of the checker class `NullabilityChecker`. These
+// checkers share a checker option "nullability:NoDiagnoseCallsToSystemHeaders"
+// which semantically belongs to the whole group and not just one checker from
+// it. As this is a unique situation (I don't know about any other similar
+// group-level option) there is no mechanism to inject this group name from
+// e.g. Checkers.td, so I'm just hardcoding it here. (These are old stable
+// checkers, I don't think that their name will change.)
+#define CHECKER_GROUP_NAME "nullability"

NagyDonat wrote:

Yes, that's probably a better choice.

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


[clang] [Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (PR #132348)

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


@@ -1518,6 +1518,50 @@ static void verifyDiagnosticWording(const Record &Diag) {
   // runs into odd situations like [[clang::warn_unused_result]],
   // #pragma clang, or --unwindlib=libgcc.
 }
+
+/// ClangDiagsCompatIDsEmitter - Emit a set of 'compatibility diagnostic ids'
+/// that map to a set of 2 regular diagnostic ids each and which are used to
+/// simplify emitting compatibility warnings.
+void clang::EmitClangDiagsCompatIDs(const llvm::RecordKeeper &Records,

erichkeane wrote:

Are we anticipating doing this multiple times?  Why the `BEGIN` and `END`?  Is 
the idea that we'd have a different list for parse vs sema?  I'd prefer we get 
1 list, then we don't need `BEGIN` and `END`, but I haven't thought through 
this enough.

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


[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

2025-03-21 Thread Donát Nagy via cfe-commits

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


[clang] [clang][scan-build] Treat --use-cc and --use-c++ as shell commands (PR #131932)

2025-03-21 Thread Florian Ragwitz via cfe-commits

https://github.com/rafl updated https://github.com/llvm/llvm-project/pull/131932

>From 3bdcfbbb56e80c1724a6e46597d0141c118c68cc Mon Sep 17 00:00:00 2001
From: Florian Ragwitz 
Date: Tue, 18 Mar 2025 15:35:42 -0700
Subject: [PATCH 1/5] [clang][scan-build] Treat --use-cc and --use-c++ as shell
 commands

So that things like --use-cc="ccache gcc" work.

Fixes #26594.

Also use the slightly simpler shellwords instead of quotewords.
---
 clang/tools/scan-build/libexec/ccc-analyzer | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/clang/tools/scan-build/libexec/ccc-analyzer 
b/clang/tools/scan-build/libexec/ccc-analyzer
index 74f812aef8fdf..655ded4b102be 100755
--- a/clang/tools/scan-build/libexec/ccc-analyzer
+++ b/clang/tools/scan-build/libexec/ccc-analyzer
@@ -63,6 +63,7 @@ sub SearchInPath {
 }
 
 my $Compiler;
+my @CompilerArgs;
 my $Clang;
 my $DefaultCCompiler;
 my $DefaultCXXCompiler;
@@ -89,7 +90,7 @@ if (`uname -s` =~ m/Darwin/) {
 }
 
 if ($FindBin::Script =~ /c\+\+-analyzer/) {
-  $Compiler = $ENV{'CCC_CXX'};
+  ($Compiler, @CompilerArgs) = shellwords($ENV{'CCC_CXX'});
   if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { 
$Compiler = $DefaultCXXCompiler; }
 
   $Clang = $ENV{'CLANG_CXX'};
@@ -98,7 +99,7 @@ if ($FindBin::Script =~ /c\+\+-analyzer/) {
   $IsCXX = 1
 }
 else {
-  $Compiler = $ENV{'CCC_CC'};
+  ($Compiler, @CompilerArgs) = shellwords($ENV{'CCC_CC'});
   if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { 
$Compiler = $DefaultCCompiler; }
 
   $Clang = $ENV{'CLANG'};
@@ -199,7 +200,7 @@ sub GetCCArgs {
   die "could not find clang line\n" if (!defined $line);
   # Strip leading and trailing whitespace characters.
   $line =~ s/^\s+|\s+$//g;
-  my @items = quotewords('\s+', 0, $line);
+  my @items = shellwords($line);
   my $cmd = shift @items;
   die "cannot find 'clang' in 'clang' command\n" if (!($cmd =~ /clang/ || 
basename($cmd) =~ /llvm/));
   # If this is the llvm-driver the internal command will look like "llvm clang 
...".
@@ -462,9 +463,9 @@ my $Output;
 my %Uniqued;
 
 # Forward arguments to gcc.
-my $Status = system($Compiler,@ARGV);
+my $Status = system($Compiler,@CompilerArgs,@ARGV);
 if (defined $ENV{'CCC_ANALYZER_LOG'}) {
-  print STDERR "$Compiler @ARGV\n";
+  print STDERR "$Compiler @CompilerArgs @ARGV\n";
 }
 if ($Status) { exit($Status >> 8); }
 

>From 6806e42d3c76455be44d6d6bbf8e5041dd331bed Mon Sep 17 00:00:00 2001
From: Florian Ragwitz 
Date: Fri, 21 Mar 2025 06:04:45 -0700
Subject: [PATCH 2/5] [clang][scan-build] Minor simplification/refactor of
 environment detection

I want to adjust the logic for CCC_CC and CCC_CXX defaults, so not
repeating that logic twice is convenient.

As a nice side-effect, we end up with fewer globals and less code.

Contains no behavioural changes, except for checking for /usr/bin/xcrun
even if we're not on OSX when there's an -isysroot parameter, which
should be fine. We also don't call uname -s twice.
---
 clang/tools/scan-build/libexec/ccc-analyzer | 80 +
 1 file changed, 35 insertions(+), 45 deletions(-)

diff --git a/clang/tools/scan-build/libexec/ccc-analyzer 
b/clang/tools/scan-build/libexec/ccc-analyzer
index 655ded4b102be..9166ae61f12c1 100755
--- a/clang/tools/scan-build/libexec/ccc-analyzer
+++ b/clang/tools/scan-build/libexec/ccc-analyzer
@@ -62,53 +62,42 @@ sub SearchInPath {
 return 0;
 }
 
-my $Compiler;
-my @CompilerArgs;
-my $Clang;
-my $DefaultCCompiler;
-my $DefaultCXXCompiler;
-my $IsCXX;
-my $AnalyzerTarget;
-
-# If on OSX, use xcrun to determine the SDK root.
-my $UseXCRUN = 0;
-
-if (`uname -s` =~ m/Darwin/) {
-  $DefaultCCompiler = 'clang';
-  $DefaultCXXCompiler = 'clang++';
-  # Older versions of OSX do not have xcrun to
-  # query the SDK location.
-  if (-x "/usr/bin/xcrun") {
-$UseXCRUN = 1;
-  }
-} elsif (`uname -s` =~ m/(FreeBSD|OpenBSD)/) {
-  $DefaultCCompiler = 'cc';
-  $DefaultCXXCompiler = 'c++';
-} else {
-  $DefaultCCompiler = 'gcc';
-  $DefaultCXXCompiler = 'g++';
-}
-
-if ($FindBin::Script =~ /c\+\+-analyzer/) {
-  ($Compiler, @CompilerArgs) = shellwords($ENV{'CCC_CXX'});
-  if (!defined $Compiler || (! -x $Compiler && ! SearchInPath($Compiler))) { 
$Compiler = $DefaultCXXCompiler; }
-
-  $Clang = $ENV{'CLANG_CXX'};
-  if (!defined $Clang || ! -x $Clang) { $Clang = 'clang++'; }
-
-  $IsCXX = 1
+{
+  my ($DefaultCCompiler, $DefaultCXXCompiler);
+
+  my $os = `uname -s`;
+  if ($os =~ m/Darwin/) {
+$DefaultCCompiler = 'clang';
+$DefaultCXXCompiler = 'clang++';
+  } elsif ($os =~ m/(FreeBSD|OpenBSD)/) {
+$DefaultCCompiler = 'cc';
+$DefaultCXXCompiler = 'c++';
+  } else {
+$DefaultCCompiler = 'gcc';
+$DefaultCXXCompiler = 'g++';
+  }
+
+  sub DetermineCompiler {
+my ($is_cxx) = @_;
+my $default = $is_cxx ? $DefaultCXXCompiler : $DefaultCCompiler;
+my $opt = $ENV{$is_cxx ? 'CCC_CXX' : 'CCC_CC'};
+return $default unless defined $opt;
+my ($comp, @args) = 

[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

2025-03-21 Thread Donát Nagy via cfe-commits


@@ -112,25 +112,30 @@ class NullabilityChecker
   void printState(raw_ostream &Out, ProgramStateRef State, const char *NL,
   const char *Sep) const override;
 
-  enum CheckKind {
-CK_NullPassedToNonnull,
-CK_NullReturnedFromNonnull,
-CK_NullableDereferenced,
-CK_NullablePassedToNonnull,
-CK_NullableReturnedFromNonnull,
-CK_NumCheckKinds
+  // FIXME: This enumeration of checker parts is extremely similar to the
+  // ErrorKind enum. It would be nice to unify them to simplify the code.
+  enum : CheckerPartIdx {
+NullPassedToNonnullChecker,
+NullReturnedFromNonnullChecker,
+NullableDereferencedChecker,
+NullablePassedToNonnullChecker,
+NullableReturnedFromNonnullChecker,
+NumCheckerParts
   };
 
-  bool ChecksEnabled[CK_NumCheckKinds] = {false};
-  CheckerNameRef CheckNames[CK_NumCheckKinds];
-  mutable std::unique_ptr BTs[CK_NumCheckKinds];
-
-  const std::unique_ptr &getBugType(CheckKind Kind) const {
-if (!BTs[Kind])
-  BTs[Kind].reset(new BugType(CheckNames[Kind], "Nullability",
-  categories::MemoryError));
-return BTs[Kind];
-  }
+  // FIXME: Currently the `Description` fields of these `BugType`s are all
+  // identical ("Nullability") -- they should be more descriptive than this.
+  BugType BugTypes[NumCheckerParts] = {
+  {this, NullPassedToNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullReturnedFromNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullableDereferencedChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullablePassedToNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullableReturnedFromNonnullChecker, "Nullability",
+   categories::MemoryError}};

NagyDonat wrote:

> I have something like this in mind:

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


[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

2025-03-21 Thread Donát Nagy via cfe-commits

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


[clang] [llvm] [X86][AVX10.2] Remove YMM rounding from VMINMAXP[H,S,D] (PR #132405)

2025-03-21 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang created 
https://github.com/llvm/llvm-project/pull/132405

Ref: https://cdrdv2.intel.com/v1/dl/getContent/784343

>From 4da792e1397d893b4be997039d24cf933d9702b9 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Fri, 21 Mar 2025 22:42:10 +0800
Subject: [PATCH] [X86][AVX10.2] Remove YMM rounding from VMINMAXP[H,S,D]

Ref: https://cdrdv2.intel.com/v1/dl/getContent/784343
---
 clang/include/clang/Basic/BuiltinsX86.td  |   6 +-
 clang/lib/Headers/avx10_2minmaxintrin.h   |  81 +++-
 clang/lib/Sema/SemaX86.cpp|   9 +-
 .../CodeGen/X86/avx10_2_512minmax-error.c |  11 --
 .../test/CodeGen/X86/avx10_2minmax-builtins.c |  72 ++-
 llvm/include/llvm/IR/IntrinsicsX86.td |  16 +--
 llvm/lib/Target/X86/X86InstrAVX10.td  |  11 +-
 llvm/lib/Target/X86/X86IntrinsicsInfo.h   |  12 +-
 .../CodeGen/X86/avx10_2minmax-intrinsics.ll   | 122 +++---
 .../MC/Disassembler/X86/avx10.2minmax-32.txt  |  24 
 .../MC/Disassembler/X86/avx10.2minmax-64.txt  |  24 
 llvm/test/MC/X86/avx10.2minmax-32-att.s   |  24 
 llvm/test/MC/X86/avx10.2minmax-32-intel.s |  24 
 llvm/test/MC/X86/avx10.2minmax-64-att.s   |  24 
 llvm/test/MC/X86/avx10.2minmax-64-intel.s |  24 
 15 files changed, 63 insertions(+), 421 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index ea0d6df4a33c2..adb174a9fc62d 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -4823,7 +4823,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxpd256_round_mask : X86Builtin<"_Vector<4, double>(_Vector<4, 
double>, _Vector<4, double>, _Constant int, _Vector<4, double>, unsigned char, 
_Constant int)">;
+  def vminmaxpd256_mask : X86Builtin<"_Vector<4, double>(_Vector<4, double>, 
_Vector<4, double>, _Constant int, _Vector<4, double>, unsigned char)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
@@ -4835,7 +4835,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxph256_round_mask : X86Builtin<"_Vector<16, _Float16>(_Vector<16, 
_Float16>, _Vector<16, _Float16>, _Constant int, _Vector<16, _Float16>, 
unsigned short, _Constant int)">;
+  def vminmaxph256_mask : X86Builtin<"_Vector<16, _Float16>(_Vector<16, 
_Float16>, _Vector<16, _Float16>, _Constant int, _Vector<16, _Float16>, 
unsigned short)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
@@ -4847,7 +4847,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxps256_round_mask : X86Builtin<"_Vector<8, float>(_Vector<8, 
float>, _Vector<8, float>, _Constant int, _Vector<8, float>, unsigned char, 
_Constant int)">;
+  def vminmaxps256_mask : X86Builtin<"_Vector<8, float>(_Vector<8, float>, 
_Vector<8, float>, _Constant int, _Vector<8, float>, unsigned char)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
diff --git a/clang/lib/Headers/avx10_2minmaxintrin.h 
b/clang/lib/Headers/avx10_2minmaxintrin.h
index 8164d49d89f1f..809a01b04f13e 100644
--- a/clang/lib/Headers/avx10_2minmaxintrin.h
+++ b/clang/lib/Headers/avx10_2minmaxintrin.h
@@ -66,34 +66,19 @@
   (__v2df)_mm_setzero_pd(), (__mmask8)(U)))
 
 #define _mm256_minmax_pd(A, B, C)  
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)_mm256_setzero_pd(), (__mmask8)-1, _MM_FROUND_NO_EXC))
+  (__v4df)_mm256_setzero_pd(), (__mmask8)-1))
 
 #define _mm256_mask_minmax_pd(W, U, A, B, C)   
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)(__m256d)(W), (__mmask8)(U), _MM_FROUND_NO_EXC))
+  (__v4df)(__m256d)(W), (__mmask8)(U)))
 
 #define _mm256_maskz_minmax_pd(U, A, B, C) 
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)_mm256_setze

[clang] [Clang] Fix various bugs in alias CTAD transform (PR #132061)

2025-03-21 Thread Younan Zhang via cfe-commits

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

>From fb9fa67da10a7dbfb2db5520d2773085585f4c14 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Thu, 20 Mar 2025 00:54:54 +0800
Subject: [PATCH 1/5] [Clang] Fix various bugs in alias CTAD transform

---
 clang/lib/Sema/SemaTemplateDeductionGuide.cpp |  11 +-
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  31 +++--
 clang/lib/Sema/TreeTransform.h|   6 +
 clang/test/SemaCXX/ctad.cpp   | 115 +-
 4 files changed, 149 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp 
b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
index ee89ee8594bc4..63a100545b5e7 100644
--- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
+++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp
@@ -1077,7 +1077,11 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   // !!NOTE: DeduceResults respects the sequence of template parameters of
   // the deduction guide f.
   for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
-if (const auto &D = DeduceResults[Index]; !D.isNull()) // Deduced
+const auto &D = DeduceResults[Index];
+bool NonDeduced =
+D.isNull() || (D.getKind() == TemplateArgument::Pack &&
+   D.pack_size() == 1 && D.pack_begin()->isNull());
+if (!NonDeduced)
   DeducedArgs.push_back(D);
 else
   NonDeducedTemplateParamsInFIndex.push_back(Index);
@@ -1141,7 +1145,10 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   Args.addOuterTemplateArguments(TransformedDeducedAliasArgs);
   for (unsigned Index = 0; Index < DeduceResults.size(); ++Index) {
 const auto &D = DeduceResults[Index];
-if (D.isNull()) {
+bool NonDeduced =
+D.isNull() || (D.getKind() == TemplateArgument::Pack &&
+   D.pack_size() == 1 && D.pack_begin()->isNull());
+if (NonDeduced) {
   // 2): Non-deduced template parameters would be substituted later.
   continue;
 }
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 19c27a76b182c..9371b578c8558 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1348,6 +1348,16 @@ std::optional 
Sema::isSFINAEContext() const {
   return std::nullopt;
 }
 
+static TemplateArgument
+getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg) {
+  assert(S.ArgumentPackSubstitutionIndex >= 0);
+  assert(S.ArgumentPackSubstitutionIndex < (int)Arg.pack_size());
+  Arg = Arg.pack_begin()[S.ArgumentPackSubstitutionIndex];
+  if (Arg.isPackExpansion())
+Arg = Arg.getPackExpansionPattern();
+  return Arg;
+}
+
 //===--===/
 // Template Instantiation for Types
 //===--===/
@@ -1467,10 +1477,16 @@ namespace {
   }
 }
 
-static TemplateArgument
+bool HeuristicallyComputeSizeOfPackExpr() const {
+  return !TemplateArgs.isRewrite();
+}
+
+TemplateArgument
 getTemplateArgumentPackPatternForRewrite(const TemplateArgument &TA) {
   if (TA.getKind() != TemplateArgument::Pack)
 return TA;
+  if (SemaRef.ArgumentPackSubstitutionIndex != -1)
+return getPackSubstitutedTemplateArgument(SemaRef, TA);
   assert(TA.pack_size() == 1 &&
  "unexpected pack arguments in template rewrite");
   TemplateArgument Arg = *TA.pack_begin();
@@ -1630,6 +1646,9 @@ namespace {
   std::vector TArgs;
   switch (Arg.getKind()) {
   case TemplateArgument::Pack:
+assert(SemaRef.CodeSynthesisContexts.empty() ||
+   SemaRef.CodeSynthesisContexts.back().Kind ==
+   Sema::CodeSynthesisContext::BuildingDeductionGuides);
 // Literally rewrite the template argument pack, instead of unpacking
 // it.
 for (auto &pack : Arg.getPackAsArray()) {
@@ -1869,16 +1888,6 @@ bool TemplateInstantiator::AlreadyTransformed(QualType 
T) {
   return true;
 }
 
-static TemplateArgument
-getPackSubstitutedTemplateArgument(Sema &S, TemplateArgument Arg) {
-  assert(S.ArgumentPackSubstitutionIndex >= 0);
-  assert(S.ArgumentPackSubstitutionIndex < (int)Arg.pack_size());
-  Arg = Arg.pack_begin()[S.ArgumentPackSubstitutionIndex];
-  if (Arg.isPackExpansion())
-Arg = Arg.getPackExpansionPattern();
-  return Arg;
-}
-
 Decl *TemplateInstantiator::TransformDecl(SourceLocation Loc, Decl *D) {
   if (!D)
 return nullptr;
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index b5de98e3989ea..5d96c3fcf92e3 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -3660,6 +3660,8 @@ class TreeTransform {
 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
   }
 
+  bool HeuristicallyComputeSizeOfPackExpr() const { return true; }
+
 

[clang] [llvm] [X86][AVX10.2] Remove YMM rounding from VMINMAXP[H,S,D] (PR #132405)

2025-03-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Phoebe Wang (phoebewang)


Changes

Ref: https://cdrdv2.intel.com/v1/dl/getContent/784343

---

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


15 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsX86.td (+3-3) 
- (modified) clang/lib/Headers/avx10_2minmaxintrin.h (+18-63) 
- (modified) clang/lib/Sema/SemaX86.cpp (+3-6) 
- (modified) clang/test/CodeGen/X86/avx10_2_512minmax-error.c (-11) 
- (modified) clang/test/CodeGen/X86/avx10_2minmax-builtins.c (+9-63) 
- (modified) llvm/include/llvm/IR/IntrinsicsX86.td (+8-8) 
- (modified) llvm/lib/Target/X86/X86InstrAVX10.td (+1-10) 
- (modified) llvm/lib/Target/X86/X86IntrinsicsInfo.h (+6-6) 
- (modified) llvm/test/CodeGen/X86/avx10_2minmax-intrinsics.ll (+15-107) 
- (modified) llvm/test/MC/Disassembler/X86/avx10.2minmax-32.txt (-24) 
- (modified) llvm/test/MC/Disassembler/X86/avx10.2minmax-64.txt (-24) 
- (modified) llvm/test/MC/X86/avx10.2minmax-32-att.s (-24) 
- (modified) llvm/test/MC/X86/avx10.2minmax-32-intel.s (-24) 
- (modified) llvm/test/MC/X86/avx10.2minmax-64-att.s (-24) 
- (modified) llvm/test/MC/X86/avx10.2minmax-64-intel.s (-24) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index ea0d6df4a33c2..adb174a9fc62d 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -4823,7 +4823,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxpd256_round_mask : X86Builtin<"_Vector<4, double>(_Vector<4, 
double>, _Vector<4, double>, _Constant int, _Vector<4, double>, unsigned char, 
_Constant int)">;
+  def vminmaxpd256_mask : X86Builtin<"_Vector<4, double>(_Vector<4, double>, 
_Vector<4, double>, _Constant int, _Vector<4, double>, unsigned char)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
@@ -4835,7 +4835,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxph256_round_mask : X86Builtin<"_Vector<16, _Float16>(_Vector<16, 
_Float16>, _Vector<16, _Float16>, _Constant int, _Vector<16, _Float16>, 
unsigned short, _Constant int)">;
+  def vminmaxph256_mask : X86Builtin<"_Vector<16, _Float16>(_Vector<16, 
_Float16>, _Vector<16, _Float16>, _Constant int, _Vector<16, _Float16>, 
unsigned short)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
@@ -4847,7 +4847,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxps256_round_mask : X86Builtin<"_Vector<8, float>(_Vector<8, 
float>, _Vector<8, float>, _Constant int, _Vector<8, float>, unsigned char, 
_Constant int)">;
+  def vminmaxps256_mask : X86Builtin<"_Vector<8, float>(_Vector<8, float>, 
_Vector<8, float>, _Constant int, _Vector<8, float>, unsigned char)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
diff --git a/clang/lib/Headers/avx10_2minmaxintrin.h 
b/clang/lib/Headers/avx10_2minmaxintrin.h
index 8164d49d89f1f..809a01b04f13e 100644
--- a/clang/lib/Headers/avx10_2minmaxintrin.h
+++ b/clang/lib/Headers/avx10_2minmaxintrin.h
@@ -66,34 +66,19 @@
   (__v2df)_mm_setzero_pd(), (__mmask8)(U)))
 
 #define _mm256_minmax_pd(A, B, C)  
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)_mm256_setzero_pd(), (__mmask8)-1, _MM_FROUND_NO_EXC))
+  (__v4df)_mm256_setzero_pd(), (__mmask8)-1))
 
 #define _mm256_mask_minmax_pd(W, U, A, B, C)   
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)(__m256d)(W), (__mmask8)(U), _MM_FROUND_NO_EXC))
+  (__v4df)(__m256d)(W), (__mmask8)(U)))
 
 #define _mm256_maskz_minmax_pd(U, A, B, C) 
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)_mm256_setzero_pd(), (__mmask8)(U), _MM_FROUND_NO_EXC))
-
-#define _mm256_minmax_round_pd(A, B, C, R)  

[clang] [clang][analyzer] Move 'alpha.core.FixedAddressDereference' out of alpha (PR #132404)

2025-03-21 Thread Donát Nagy via cfe-commits

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


[clang] [clang][analyzer] Move 'alpha.core.FixedAddressDereference' out of alpha (PR #132404)

2025-03-21 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat commented:

Thanks, I'm happy to see that this checker is out of alpha :smile: 

Please evaluate the behavior of this checker on some open source projects. (Or 
if you have already done an analysis with this version of the checker, then 
please attach a link to it.)

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


[clang] [Clang] Fix various bugs in alias CTAD transform (PR #132061)

2025-03-21 Thread Younan Zhang via cfe-commits


@@ -1072,12 +1072,25 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   AliasRhsTemplateArgs, TDeduceInfo, DeduceResults,
   /*NumberOfArgumentsMustMatch=*/false);
 
+  static auto IsNonDeducedArgument = [&](const DeducedTemplateArgument &TA) {
+// The following cases indicate the template argument is non-deducible:
+//   1. The result is null. E.g. When it comes from a default template
+//   argument that doesn't appear in the alias declaration.
+//   2. The template parameter is a pack and that cannot be deduced from
+//   the arguments within the alias declaration.
+// Non-deducible template parameters will persist in the transformed
+// deduction guide.
+return TA.isNull() || (TA.getKind() == TemplateArgument::Pack &&
+   TA.pack_size() == 1 && TA.pack_begin()->isNull());

zyn0217 wrote:

(Oh silly me I thought I have asked myself the same question but I quickly 
forgot to get to it again...)

Yes you're right, we should traverse each element of the pack. I added a test 
case to reflect that: 
https://github.com/llvm/llvm-project/pull/132061/commits/74ec072d116b48147ba06fd45db57fbbcc03

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


[clang] [clang][analyzer] Move 'alpha.core.FixedAddressDereference' out of alpha (PR #132404)

2025-03-21 Thread Donát Nagy via cfe-commits

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


[clang] [clang][scan-build] Treat --use-cc and --use-c++ as shell commands (PR #131932)

2025-03-21 Thread Florian Ragwitz via cfe-commits

rafl wrote:

> I'd prefer option 2, because why else would we have a default compiler if 
> that wasn't used in some workflows. A warning could never hurt.

`--use-cc`/`--use-c++`/`CCC_CC`/`CCC_CXX` are optional, so the default would 
still be used when those options are not specified, which might be the majority 
of use-cases.

I've added a few additional commits:

* 6806e42d3c76 includes some minor simplifications and deduplicates the logic 
we're talking about without changing behaviour.
*  e101c97b60f2 implements option 2, as that was your preference.
*  b086d3ecad7e implements my preferred option 3. I'd happy to drop this commit 
if we wanna stick with option 2 instead.
* 805396fa1ec1 brings the handling of `CLANG`/`CLANG_CXX` in line with 
`CCC_CC`/`CCC_CXX` if we end up going for option 3. We'd also drop this if we 
go for option 2.

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


[clang] [NFC][analyzer] Multipart checker refactor 2: NullabilityChecker (PR #132250)

2025-03-21 Thread Balazs Benics via cfe-commits
=?utf-8?q?Don=C3=A1t?= Nagy ,
=?utf-8?q?Don=C3=A1t?= Nagy ,
=?utf-8?q?Don=C3=A1t?= Nagy 
Message-ID:
In-Reply-To: 



@@ -112,25 +112,30 @@ class NullabilityChecker
   void printState(raw_ostream &Out, ProgramStateRef State, const char *NL,
   const char *Sep) const override;
 
-  enum CheckKind {
-CK_NullPassedToNonnull,
-CK_NullReturnedFromNonnull,
-CK_NullableDereferenced,
-CK_NullablePassedToNonnull,
-CK_NullableReturnedFromNonnull,
-CK_NumCheckKinds
+  // FIXME: This enumeration of checker parts is extremely similar to the
+  // ErrorKind enum. It would be nice to unify them to simplify the code.
+  enum : CheckerPartIdx {
+NullPassedToNonnullChecker,
+NullReturnedFromNonnullChecker,
+NullableDereferencedChecker,
+NullablePassedToNonnullChecker,
+NullableReturnedFromNonnullChecker,
+NumCheckerParts
   };
 
-  bool ChecksEnabled[CK_NumCheckKinds] = {false};
-  CheckerNameRef CheckNames[CK_NumCheckKinds];
-  mutable std::unique_ptr BTs[CK_NumCheckKinds];
-
-  const std::unique_ptr &getBugType(CheckKind Kind) const {
-if (!BTs[Kind])
-  BTs[Kind].reset(new BugType(CheckNames[Kind], "Nullability",
-  categories::MemoryError));
-return BTs[Kind];
-  }
+  // FIXME: Currently the `Description` fields of these `BugType`s are all
+  // identical ("Nullability") -- they should be more descriptive than this.
+  BugType BugTypes[NumCheckerParts] = {
+  {this, NullPassedToNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullReturnedFromNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullableDereferencedChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullablePassedToNonnullChecker, "Nullability",
+   categories::MemoryError},
+  {this, NullableReturnedFromNonnullChecker, "Nullability",
+   categories::MemoryError}};

steakhal wrote:

Feel free to flash out an implementation. I'm happy that it inspired you.
I'd suggest blocking this PR until you played with the new ideas first.
There shouldn't be a rush for migrating to the current framework I think.

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


[clang] [llvm] [X86][AVX10.2] Remove YMM rounding from VMINMAXP[H,S,D] (PR #132405)

2025-03-21 Thread Phoebe Wang via cfe-commits

https://github.com/phoebewang updated 
https://github.com/llvm/llvm-project/pull/132405

>From 4da792e1397d893b4be997039d24cf933d9702b9 Mon Sep 17 00:00:00 2001
From: "Wang, Phoebe" 
Date: Fri, 21 Mar 2025 22:42:10 +0800
Subject: [PATCH 1/2] [X86][AVX10.2] Remove YMM rounding from VMINMAXP[H,S,D]

Ref: https://cdrdv2.intel.com/v1/dl/getContent/784343
---
 clang/include/clang/Basic/BuiltinsX86.td  |   6 +-
 clang/lib/Headers/avx10_2minmaxintrin.h   |  81 +++-
 clang/lib/Sema/SemaX86.cpp|   9 +-
 .../CodeGen/X86/avx10_2_512minmax-error.c |  11 --
 .../test/CodeGen/X86/avx10_2minmax-builtins.c |  72 ++-
 llvm/include/llvm/IR/IntrinsicsX86.td |  16 +--
 llvm/lib/Target/X86/X86InstrAVX10.td  |  11 +-
 llvm/lib/Target/X86/X86IntrinsicsInfo.h   |  12 +-
 .../CodeGen/X86/avx10_2minmax-intrinsics.ll   | 122 +++---
 .../MC/Disassembler/X86/avx10.2minmax-32.txt  |  24 
 .../MC/Disassembler/X86/avx10.2minmax-64.txt  |  24 
 llvm/test/MC/X86/avx10.2minmax-32-att.s   |  24 
 llvm/test/MC/X86/avx10.2minmax-32-intel.s |  24 
 llvm/test/MC/X86/avx10.2minmax-64-att.s   |  24 
 llvm/test/MC/X86/avx10.2minmax-64-intel.s |  24 
 15 files changed, 63 insertions(+), 421 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index ea0d6df4a33c2..adb174a9fc62d 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -4823,7 +4823,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxpd256_round_mask : X86Builtin<"_Vector<4, double>(_Vector<4, 
double>, _Vector<4, double>, _Constant int, _Vector<4, double>, unsigned char, 
_Constant int)">;
+  def vminmaxpd256_mask : X86Builtin<"_Vector<4, double>(_Vector<4, double>, 
_Vector<4, double>, _Constant int, _Vector<4, double>, unsigned char)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
@@ -4835,7 +4835,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxph256_round_mask : X86Builtin<"_Vector<16, _Float16>(_Vector<16, 
_Float16>, _Vector<16, _Float16>, _Constant int, _Vector<16, _Float16>, 
unsigned short, _Constant int)">;
+  def vminmaxph256_mask : X86Builtin<"_Vector<16, _Float16>(_Vector<16, 
_Float16>, _Vector<16, _Float16>, _Constant int, _Vector<16, _Float16>, 
unsigned short)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
@@ -4847,7 +4847,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
RequiredVectorWidth<128>] i
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, RequiredVectorWidth<256>] 
in {
-  def vminmaxps256_round_mask : X86Builtin<"_Vector<8, float>(_Vector<8, 
float>, _Vector<8, float>, _Constant int, _Vector<8, float>, unsigned char, 
_Constant int)">;
+  def vminmaxps256_mask : X86Builtin<"_Vector<8, float>(_Vector<8, float>, 
_Vector<8, float>, _Constant int, _Vector<8, float>, unsigned char)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, RequiredVectorWidth<512>] 
in {
diff --git a/clang/lib/Headers/avx10_2minmaxintrin.h 
b/clang/lib/Headers/avx10_2minmaxintrin.h
index 8164d49d89f1f..809a01b04f13e 100644
--- a/clang/lib/Headers/avx10_2minmaxintrin.h
+++ b/clang/lib/Headers/avx10_2minmaxintrin.h
@@ -66,34 +66,19 @@
   (__v2df)_mm_setzero_pd(), (__mmask8)(U)))
 
 #define _mm256_minmax_pd(A, B, C)  
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)_mm256_setzero_pd(), (__mmask8)-1, _MM_FROUND_NO_EXC))
+  (__v4df)_mm256_setzero_pd(), (__mmask8)-1))
 
 #define _mm256_mask_minmax_pd(W, U, A, B, C)   
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)(__m256d)(W), (__mmask8)(U), _MM_FROUND_NO_EXC))
+  (__v4df)(__m256d)(W), (__mmask8)(U)))
 
 #define _mm256_maskz_minmax_pd(U, A, B, C) 
\
-  ((__m256d)__builtin_ia32_vminmaxpd256_round_mask(
\
+  ((__m256d)__builtin_ia32_vminmaxpd256_mask(  
\
   (__v4df)(__m256d)(A), (__v4df)(__m256d)(B), (int)(C),
\
-  (__v4df)_mm256_setzero_pd(), (__mmask8)(U), _MM_FROUND_NO_EXC))
-
-#def

[clang] 924c7ea - [X86][AVX10.2] Remove YMM rounding from VCVT2PS2PHX (#132397)

2025-03-21 Thread via cfe-commits

Author: Phoebe Wang
Date: 2025-03-21T22:51:51+08:00
New Revision: 924c7ea76af0c3ab53dc7287d046fb614b4e33dc

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

LOG: [X86][AVX10.2] Remove YMM rounding from VCVT2PS2PHX (#132397)

Ref: https://cdrdv2.intel.com/v1/dl/getContent/784343

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsX86.td
clang/lib/Headers/avx10_2convertintrin.h
clang/lib/Sema/SemaX86.cpp
clang/test/CodeGen/X86/avx10_2convert-builtins.c
llvm/include/llvm/IR/IntrinsicsX86.td
llvm/lib/Target/X86/X86InstrAVX10.td
llvm/lib/Target/X86/X86IntrinsicsInfo.h
llvm/test/CodeGen/X86/avx10_2convert-intrinsics.ll
llvm/test/MC/Disassembler/X86/avx10.2convert-32.txt
llvm/test/MC/Disassembler/X86/avx10.2convert-64.txt
llvm/test/MC/X86/avx10.2convert-32-att.s
llvm/test/MC/X86/avx10.2convert-32-intel.s
llvm/test/MC/X86/avx10.2convert-64-att.s
llvm/test/MC/X86/avx10.2convert-64-intel.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsX86.td 
b/clang/include/clang/Basic/BuiltinsX86.td
index ea0d6df4a33c2..ef6bd77ae93ab 100644
--- a/clang/include/clang/Basic/BuiltinsX86.td
+++ b/clang/include/clang/Basic/BuiltinsX86.td
@@ -5006,7 +5006,7 @@ let Features = "avx10.2-256", Attributes = [NoThrow, 
Const, RequiredVectorWidth<
 }
 
 let Features = "avx10.2-256", Attributes = [NoThrow, Const, 
RequiredVectorWidth<256>] in {
-  def vcvt2ps2phx256_mask : X86Builtin<"_Vector<16, _Float16>(_Vector<8, 
float>, _Vector<8, float>, _Vector<16, _Float16>, unsigned short, _Constant 
int)">;
+  def vcvt2ps2phx256_mask : X86Builtin<"_Vector<16, _Float16>(_Vector<8, 
float>, _Vector<8, float>, _Vector<16, _Float16>, unsigned short)">;
 }
 
 let Features = "avx10.2-512", Attributes = [NoThrow, Const, 
RequiredVectorWidth<512>] in {

diff  --git a/clang/lib/Headers/avx10_2convertintrin.h 
b/clang/lib/Headers/avx10_2convertintrin.h
index f89ba6e830c49..19d91d41f7bde 100644
--- a/clang/lib/Headers/avx10_2convertintrin.h
+++ b/clang/lib/Headers/avx10_2convertintrin.h
@@ -178,8 +178,7 @@ _mm_maskz_cvtx2ps_ph(__mmask8 __U, __m128 __A, __m128 __B) {
 static __inline__ __m256h __DEFAULT_FN_ATTRS256 _mm256_cvtx2ps_ph(__m256 __A,
   __m256 __B) {
   return (__m256h)__builtin_ia32_vcvt2ps2phx256_mask(
-  (__v8sf)__A, (__v8sf)__B, (__v16hf)_mm256_setzero_ph(), (__mmask16)(-1),
-  _MM_FROUND_CUR_DIRECTION);
+  (__v8sf)__A, (__v8sf)__B, (__v16hf)_mm256_setzero_ph(), (__mmask16)(-1));
 }
 
 /// Convert two 256-bit vectors, \a __A and \a __B, containing packed
@@ -223,8 +222,7 @@ static __inline__ __m256h __DEFAULT_FN_ATTRS256 
_mm256_cvtx2ps_ph(__m256 __A,
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
 _mm256_mask_cvtx2ps_ph(__m256h __W, __mmask16 __U, __m256 __A, __m256 __B) {
   return (__m256h)__builtin_ia32_vcvt2ps2phx256_mask(
-  (__v8sf)__A, (__v8sf)__B, (__v16hf)__W, (__mmask16)__U,
-  _MM_FROUND_CUR_DIRECTION);
+  (__v8sf)__A, (__v8sf)__B, (__v16hf)__W, (__mmask16)__U);
 }
 
 /// Convert two 256-bit vectors, \a __A and \a __B, containing packed
@@ -266,142 +264,9 @@ _mm256_mask_cvtx2ps_ph(__m256h __W, __mmask16 __U, __m256 
__A, __m256 __B) {
 static __inline__ __m256h __DEFAULT_FN_ATTRS256
 _mm256_maskz_cvtx2ps_ph(__mmask16 __U, __m256 __A, __m256 __B) {
   return (__m256h)__builtin_ia32_vcvt2ps2phx256_mask(
-  (__v8sf)__A, (__v8sf)__B, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U,
-  _MM_FROUND_CUR_DIRECTION);
+  (__v8sf)__A, (__v8sf)__B, (__v16hf)_mm256_setzero_ph(), (__mmask16)__U);
 }
 
-/// Convert two 256-bit vectors, \a __A and \a __B, containing packed
-///single-precision (32-bit) floating-point elements to a 256-bit vector
-///containing FP16 elements. Rounding mode \a __R needs to be provided.
-///   
-/// \code{.operation}
-/// FOR i := 0 to 15 
-///IF i < 8
-///dst.fp16[i] := convert_fp32_to_fp16(__B.fp32[i])
-///ELSE
-///dst.fp16[i] := convert_fp32_to_fp16(__A.fp32[i - 8])
-///FI
-/// ENDFOR
-///
-/// dst[MAX:256] := 0
-/// \endcode
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the \c VCVT2PS2PHX instruction.
-///
-/// \param __A
-///A 256-bit vector of [8 x float].
-/// \param __B
-///A 256-bit vector of [8 x float].
-/// \param __R
-///Rounding mode. Valid inputs are: _MM_FROUND_CUR_DIRECTION or
-///result of bitwise or of _MM_FROUND_NO_EXC with at most one of the 
following:
-///_MM_FROUND_TO_NEAREST_INT, _MM_FROUND_TO_NEG_INF, _MM_FROUND_TO_POS_INF,
-///_MM_FROUND_TO_ZERO.
-/// \returns
-///A 256-bit vector of [16 x fp16]. Lower elements correspond to the
-///(converted) elements from \a __B; higher order elements correspond to 
the

[clang] [Clang] add emit -Wignored-base-class-qualifiers diagnostic for cv-qualified base classes (PR #132116)

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

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

I'm happy when Aaron is happy with commit message/etc.  THOUGH we should do 
`Fixes: #` in it so it auto-closes the bug.

I suspect we'll have to merge this for you, so if you notice CI has passed, 
feel free to ping us and we'll do it.

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


[clang] [Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (PR #132348)

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


@@ -1518,6 +1518,50 @@ static void verifyDiagnosticWording(const Record &Diag) {
   // runs into odd situations like [[clang::warn_unused_result]],
   // #pragma clang, or --unwindlib=libgcc.
 }
+
+/// ClangDiagsCompatIDsEmitter - Emit a set of 'compatibility diagnostic ids'
+/// that map to a set of 2 regular diagnostic ids each and which are used to
+/// simplify emitting compatibility warnings.
+void clang::EmitClangDiagsCompatIDs(const llvm::RecordKeeper &Records,

erichkeane wrote:

Since I'm awful at reading code that generates other code... could you 
copy/paste the generated stuff here in github?

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


[compiler-rt] [libcxx] [libcxxabi] [libunwind] [lldb] [llvm] [compiler-rt] Disable LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON on AIX. (PR #131200)

2025-03-21 Thread Daniel Chen via cfe-commits


@@ -223,6 +223,13 @@ endif()
 # This can be used to detect whether we're in the runtimes build.
 set(LLVM_RUNTIMES_BUILD ON)
 
+if (LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND UNIX AND ${CMAKE_SYSTEM_NAME} 
MATCHES "AIX")
+  # Set LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF as AIX doesn't support it
+  message(WARNING
+  "LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON is not supported on AIX. 
LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is set to OFF.")
+  set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR OFF CACHE BOOL "" FORCE)
+endif()

DanielCChen wrote:

We could make it work as there is not technically impossibility, but our 
decision is not to support two runtime paths on AIX.
@daltenty Could you please comment on if we can issue  `FATAL_ERROR` instead of 
force setting it to `OFF` on AIX?

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


[libclc] libclc: erfc: fix fp32 implementation (PR #132390)

2025-03-21 Thread Romaric Jodin via cfe-commits

https://github.com/rjodinchr updated 
https://github.com/llvm/llvm-project/pull/132390

>From 95eeda421b4cdc468f828d36146d609e80d195d9 Mon Sep 17 00:00:00 2001
From: Romaric Jodin 
Date: Fri, 21 Mar 2025 13:51:41 +0100
Subject: [PATCH] libclc: erfc: fix fp32 implementation

On some implementation, the current implementation lead to slight
accuracy issues.
While the maths behing this implementation is correct, it does not
take into account the accumulation of errors coming from other
operators that do not provide correct rounding (like the exp
function).
To avoid it, compute staticaly exp(-0.5625).

Fix #124939
---
 libclc/generic/lib/math/erf.cl  | 11 ++-
 libclc/generic/lib/math/erfc.cl | 11 ++-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/libclc/generic/lib/math/erf.cl b/libclc/generic/lib/math/erf.cl
index 8349f306a63f7..79fdecdc866fd 100644
--- a/libclc/generic/lib/math/erf.cl
+++ b/libclc/generic/lib/math/erf.cl
@@ -23,7 +23,7 @@
 
 #define erx   8.4506291151e-01f/* 0x3f58560b */
 
-// Coefficients for approximation to  erf on [00.84375]
+// Coefficients for approximation to  erf on [0, 0.84375]
 
 #define efx   1.2837916613e-01f/* 0x3e0375d4 */
 #define efx8  1.0270333290e+00f/* 0x3f8375d4 */
@@ -39,7 +39,7 @@
 #define qq4   1.3249473704e-04f/* 0x390aee49 */
 #define qq5  -3.9602282413e-06f/* 0xb684e21a */
 
-// Coefficients for approximation to  erf  in [0.843751.25]
+// Coefficients for approximation to  erf  in [0.84375, 1.25]
 
 #define pa0  -2.3621185683e-03f/* 0xbb1acdc6 */
 #define pa1   4.1485610604e-01f/* 0x3ed46805 */
@@ -55,7 +55,7 @@
 #define qa5   1.3637083583e-02f/* 0x3c5f6e13 */
 #define qa6   1.1984500103e-02f/* 0x3c445aa3 */
 
-// Coefficients for approximation to  erfc in [1.251/0.35]
+// Coefficients for approximation to  erfc in [1.25, 1/0.35]
 
 #define ra0  -9.8649440333e-03f/* 0xbc21a093 */
 #define ra1  -6.9385856390e-01f/* 0xbf31a0b7 */
@@ -74,7 +74,7 @@
 #define sa7   6.5702495575e+00f/* 0x40d23f7c */
 #define sa8  -6.0424413532e-02f/* 0xbd777f97 */
 
-// Coefficients for approximation to  erfc in [1/.3528]
+// Coefficients for approximation to  erfc in [1/0.35, 28]
 
 #define rb0  -9.8649431020e-03f/* 0xbc21a092 */
 #define rb1  -7.9928326607e-01f/* 0xbf4c9dd4 */
@@ -130,7 +130,8 @@ _CLC_OVERLOAD _CLC_DEF float erf(float x) {
 
 // |x| < 6
 float z = as_float(ix & 0xf000);
-float r = exp(mad(-z, z, -0.5625f)) * exp(mad(z-absx, z+absx, q));
+float r = exp(-z * z) * exp(mad(z - absx, z + absx, q));
+r *= 0x1.23ba94p-1; // exp(-0.5625)
 r = 1.0f - MATH_DIVIDE(r,  absx);
 ret = absx < 6.0f ? r : ret;
 
diff --git a/libclc/generic/lib/math/erfc.cl b/libclc/generic/lib/math/erfc.cl
index 01526d7ae1eb5..05492972ed434 100644
--- a/libclc/generic/lib/math/erfc.cl
+++ b/libclc/generic/lib/math/erfc.cl
@@ -23,7 +23,7 @@
 
 #define erx_f   8.4506291151e-01f/* 0x3f58560b */
 
-// Coefficients for approximation to  erf on [00.84375]
+// Coefficients for approximation to  erf on [0, 0.84375]
 
 #define efx   1.2837916613e-01f/* 0x3e0375d4 */
 #define efx8  1.0270333290e+00f/* 0x3f8375d4 */
@@ -39,7 +39,7 @@
 #define qq4   1.3249473704e-04f/* 0x390aee49 */
 #define qq5  -3.9602282413e-06f/* 0xb684e21a */
 
-// Coefficients for approximation to  erf  in [0.843751.25]
+// Coefficients for approximation to  erf  in [0.84375, 1.25]
 
 #define pa0  -2.3621185683e-03f/* 0xbb1acdc6 */
 #define pa1   4.1485610604e-01f/* 0x3ed46805 */
@@ -55,7 +55,7 @@
 #define qa5   1.3637083583e-02f/* 0x3c5f6e13 */
 #define qa6   1.1984500103e-02f/* 0x3c445aa3 */
 
-// Coefficients for approximation to  erfc in [1.251/0.35]
+// Coefficients for approximation to  erfc in [1.25, 1/0.35]
 
 #define ra0  -9.8649440333e-03f/* 0xbc21a093 */
 #define ra1  -6.9385856390e-01f/* 0xbf31a0b7 */
@@ -74,7 +74,7 @@
 #define sa7   6.5702495575e+00f/* 0x40d23f7c */
 #define sa8  -6.0424413532e-02f/* 0xbd777f97 */
 
-// Coefficients for approximation to  erfc in [1/.3528]
+// Coefficients for approximation to  erfc in [1/0.35, 28]
 
 #define rb0  -9.8649431020e-03f/* 0xbc21a092 */
 #define rb1  -7.9928326607e-01f/* 0xbf4c9dd4 */
@@ -131,7 +131,8 @@ _CLC_OVERLOAD _CLC_DEF float erfc(float x) {
 float ret = 0.0f;
 
 float z = as_float(ix & 0xf000);
-float r = exp(mad(-z, z, -0.5625f)) * exp(mad(z - absx, z + absx, q));
+float r = exp(-z * z) * exp(mad(z - absx, z + absx, q));
+r *= 0x1.23ba94p-1; // exp(-0.5625)
 r = MATH_DIVIDE(r, absx);
 t = 2.0f - r;
 r = x < 0.0f ? t : r;

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


[libclc] libclc: erfc: fix fp32 implementation (PR #132390)

2025-03-21 Thread Romaric Jodin via cfe-commits

rjodinchr wrote:

@frasercrmck could you review please?

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


[clang] [NFC] [ASTMatchers] Share code of `forEachArgumentWithParamType` with UnsafeBufferUsage (PR #132387)

2025-03-21 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 387f3e8f986d53067a68aa0d7b058a0ce81ec941 
ef63166c24f7328af8177220be706a573d97009e --extensions h,cpp -- 
clang/include/clang/ASTMatchers/LowLevelHelpers.h 
clang/lib/ASTMatchers/LowLevelHelpers.cpp 
clang/include/clang/ASTMatchers/ASTMatchers.h 
clang/lib/Analysis/UnsafeBufferUsage.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/ASTMatchers/LowLevelHelpers.cpp 
b/clang/lib/ASTMatchers/LowLevelHelpers.cpp
index d051430ba9..eb2604c625 100644
--- a/clang/lib/ASTMatchers/LowLevelHelpers.cpp
+++ b/clang/lib/ASTMatchers/LowLevelHelpers.cpp
@@ -77,7 +77,8 @@ static void matchEachArgumentWithParamTypeImpl(
 QualType ParamType;
 if (FProto && FProto->getNumParams() > ParamIndex)
   ParamType = FProto->getParamType(ParamIndex);
-else if (const FunctionDecl *FD = getCallee(Node); FD && 
FD->getNumParams() > ParamIndex)
+else if (const FunctionDecl *FD = getCallee(Node);
+ FD && FD->getNumParams() > ParamIndex)
   ParamType = FD->getParamDecl(ParamIndex)->getType();
 else
   continue;

``




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


[clang] [Clang] [NFC] Introduce a helper for emitting compatibility diagnostics (PR #132348)

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


@@ -769,6 +770,51 @@ StringRef DiagnosticIDs::getNearestOption(diag::Flavor 
Flavor,
   return Best;
 }
 
+unsigned DiagnosticIDs::getCompatDiagId(const LangOptions &LangOpts,
+unsigned CompatDiagId) {
+  struct CompatDiag {
+unsigned StdVer;
+unsigned DiagId;
+unsigned PreDiagId;
+  };
+
+  // We encode the standard version such that C++98 < C++11 < C++14 etc. The
+  // actual numbers don't really matter for this, but the definitions of the
+  // compat diags in the Tablegen file use the standard version number (i.e.
+  // 98, 11, 14, etc.), so we base the encoding here on that.
+#define DIAG_COMPAT_IDS_BEGIN()
+#define DIAG_COMPAT_IDS_END()
+#define DIAG_COMPAT_ID(Value, Name, Std, Diag, DiagPre)
\
+  {Std == 98 ? 1998 : 2000 + Std, diag::Diag, diag::DiagPre},

erichkeane wrote:

Since this function is only handling C++ compat instead of C compat as well... 
should we name this `getCXXCompatDiagId`?  OR BETTER: Can we just expand this 
whole thing to work for C as well?


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


[clang] [mlir] [mlir] Fix typo of tests (NFC) (PR #132394)

2025-03-21 Thread via cfe-commits

https://github.com/Zhenhang1213 created 
https://github.com/llvm/llvm-project/pull/132394

None

>From 019e9432080f21ceef3c5fa0465705c090ead33a Mon Sep 17 00:00:00 2001
From: Austin 
Date: Tue, 25 Feb 2025 01:24:24 +0800
Subject: [PATCH 1/3] [ARM] Introduce -mtp=auto and make it the default

This adds a new value auto to the possible values of the existing -mtp= clang 
option which controls how the thread pointer is found. auto means the same as 
soft if the target architecture doesn't support a hardware thread pointer at 
all; otherwise it means the same as cp15.

This behavior is the default in gcc version 7.3.0 and later. The new auto 
option is therefore also the default in clang, so this change aligns clang with 
gcc.
---
 clang/include/clang/Driver/Options.td| 2 +-
 clang/lib/Driver/ToolChains/Arch/ARM.cpp | 6 +-
 clang/lib/Driver/ToolChains/Arch/ARM.h   | 1 +
 clang/test/Driver/arm-thread-pointer.c   | 6 +-
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e521cbf678d93..2bd6076bea5d4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4711,7 +4711,7 @@ def mexecute_only : Flag<["-"], "mexecute-only">, 
Group,
 def mno_execute_only : Flag<["-"], "mno-execute-only">, 
Group,
   HelpText<"Allow generation of data access to code sections (ARM only)">;
 let Flags = [TargetSpecific] in {
-def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, 
Values<"soft,cp15,tpidrurw,tpidruro,tpidrprw,el0,el1,el2,el3,tpidr_el0,tpidr_el1,tpidr_el2,tpidr_el3,tpidrro_el0">,
+def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, 
Values<"soft,cp15,tpidrurw,tpidruro,tpidrprw,el0,el1,el2,el3,tpidr_el0,tpidr_el1,tpidr_el2,tpidr_el3,tpidrro_el0,auto">,
   HelpText<"Thread pointer access method. "
"For AArch32: 'soft' uses a function call, or 'tpidrurw', 
'tpidruro' or 'tpidrprw' use the three CP15 registers. 'cp15' is an alias for 
'tpidruro'. "
"For AArch64: 'tpidr_el0', 'tpidr_el1', 'tpidr_el2', 'tpidr_el3' or 
'tpidrro_el0' use the five system registers. 'elN' is an alias for 
'tpidr_elN'.">;
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 3aee540d501be..ec0be8f9dc587 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -223,6 +223,7 @@ arm::ReadTPMode arm::getReadTPMode(const Driver &D, const 
ArgList &Args,
 .Case("tpidruro", ReadTPMode::TPIDRURO)
 .Case("tpidrprw", ReadTPMode::TPIDRPRW)
 .Case("soft", ReadTPMode::Soft)
+.Case("auto", ReadTPMode::Auto)
 .Default(ReadTPMode::Invalid);
 if ((ThreadPointer == ReadTPMode::TPIDRURW ||
  ThreadPointer == ReadTPMode::TPIDRURO ||
@@ -239,7 +240,7 @@ arm::ReadTPMode arm::getReadTPMode(const Driver &D, const 
ArgList &Args,
   D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args);
 return ReadTPMode::Invalid;
   }
-  return ReadTPMode::Soft;
+  return ReadTPMode::Auto;
 }
 
 void arm::setArchNameInTriple(const Driver &D, const ArgList &Args,
@@ -580,6 +581,9 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver 
&D,
 Features.push_back("+read-tp-tpidruro");
   if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::TPIDRPRW)
 Features.push_back("+read-tp-tpidrprw");
+  if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::Auto &&
+  isHardTPSupported(Triple) && !ForAS)
+Features.push_back("+read-tp-tpidruro");
 
   const Arg *ArchArg = Args.getLastArg(options::OPT_march_EQ);
   const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.h 
b/clang/lib/Driver/ToolChains/Arch/ARM.h
index a23a8793a89e2..622383cf0025d 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.h
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -41,6 +41,7 @@ enum class ReadTPMode {
   TPIDRURW,
   TPIDRURO,
   TPIDRPRW,
+  Auto,
 };
 
 enum class FloatABI {
diff --git a/clang/test/Driver/arm-thread-pointer.c 
b/clang/test/Driver/arm-thread-pointer.c
index 5521e1865b276..985c5046f6d26 100644
--- a/clang/test/Driver/arm-thread-pointer.c
+++ b/clang/test/Driver/arm-thread-pointer.c
@@ -42,4 +42,8 @@
 
 // RUN: %clang --target=armv7-linux -### -S %s 2>&1 | \
 // RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s
-// ARMv7_THREAD_POINTER_NON-NOT: "-target-feature" "+read-tp-tpidruro"
+// ARMv7_THREAD_POINTER_NON: "-target-feature" "+read-tp-tpidruro"
+
+// RUN: %clang --target=armv7-linux -mtp=auto -### -S %s 2>&1 | \
+// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_Auto %s
+// ARMv7_THREAD_POINTER_Auto: "-target-feature" "+read-tp-tpidruro"

>From d77c8bb953b41fa062bc6b34fad880e4fa2f264e Mon Sep 17 00:00:00 2001
From: Austin 
Date: Tue, 25 Feb 2025 01:24:24 +0800
Subject: [PATCH 2/3] [ARM] Introduce -mtp=auto and make it the default

This adds a new value auto to the possible

[clang] [mlir] [mlir] Fix typo of tests (NFC) (PR #132394)

2025-03-21 Thread via cfe-commits

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


[clang] [Clang] Fix various bugs in alias CTAD transform (PR #132061)

2025-03-21 Thread Matheus Izvekov via cfe-commits


@@ -1072,12 +1072,25 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef,
   AliasRhsTemplateArgs, TDeduceInfo, DeduceResults,
   /*NumberOfArgumentsMustMatch=*/false);
 
+  static auto IsNonDeducedArgument = [&](const DeducedTemplateArgument &TA) {
+// The following cases indicate the template argument is non-deducible:
+//   1. The result is null. E.g. When it comes from a default template
+//   argument that doesn't appear in the alias declaration.
+//   2. The template parameter is a pack and that cannot be deduced from
+//   the arguments within the alias declaration.
+// Non-deducible template parameters will persist in the transformed
+// deduction guide.
+return TA.isNull() || (TA.getKind() == TemplateArgument::Pack &&
+   TA.pack_size() == 1 && TA.pack_begin()->isNull());

mizvekov wrote:

I find the special case here a bit odd.

We do have the concept of a partially deduced pack.
Why does that blow up here? Why doesn't that problem extend to wholly undeduced 
packs of size greater than one?

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


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

2025-03-21 Thread Gábor Horváth via cfe-commits

Xazax-hun wrote:

Building a full parent map makes sense to me, but I have mixed feelings about 
modifying the `ParentMap` ctor that everyone uses. What if one of the clients 
do not want a full map? I think the change might need to be more targeted. 
Either passing on option to `ParentMap` or create a new overload for the ctor 
and update the use in the matcher library. 

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


[clang] [clang-tools-extra] Reland: [clang] NFC: Clear some uses of MemberPointerType::getClass (PR #132317)

2025-03-21 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

I'm going to go ahead and merge it, since this is such a small trivial and 
obviously correct fix for a relanding.

Otherwise, this blocks relanding a much bigger patch, which is a rebase burden.

We can always make amendments post commit if anyone feels like it.

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


[clang] [Clang][CodeGen][UBSan] Add more precise attributes to recoverable ubsan handlers (PR #130990)

2025-03-21 Thread Yingwei Zheng via cfe-commits

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


[clang] [clang-tools-extra] [lldb] Reland: [clang] preserve class type sugar when taking pointer to member (PR #132401)

2025-03-21 Thread Michael Buch via cfe-commits

https://github.com/Michael137 commented:

LLDB changes LGTM

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


[clang] [Clang][CodeGen][UBSan] Add more precise attributes to recoverable ubsan handlers (PR #130990)

2025-03-21 Thread Yingwei Zheng via cfe-commits

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


[clang] [Clang] add emit -Wignored-base-class-qualifiers diagnostic for cv-qualified base classes (PR #132116)

2025-03-21 Thread via cfe-commits

MagentaTreehouse wrote:

I suggest backporting to the 20 release. Wdyt? (If we decide so, the release 
notes would go into 20 instead of main)

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


[clang] [NFC][Static Analyzer] Rename and discuss about `NotNullConstraint` & `NotNullBufferConstraint` (PR #131374)

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

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

Rename looks good. According to the format check code should be reformatted. Do 
not forget to remove the "discuss" part from the commit title.

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


[clang] Minor unused variable error for sanitizer builds (PR #132372)

2025-03-21 Thread CHANDRA GHALE via cfe-commits

https://github.com/chandraghale created 
https://github.com/llvm/llvm-project/pull/132372

Fix to issue [https://github.com/llvm/llvm-project/issues/132371 
](https://github.com/llvm/llvm-project/issues/132371 )
Minor error ,  sanitizer builds are failing for unused variable.  
sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:11764:17:
 error: unused variable 'I' [-Werror,-Wunused-variable]
 11764 |   for (unsigned I : llvm::seq(NumFlags))

This was modified as part of 
[https://github.com/llvm/llvm-project/pull/129938](https://github.com/llvm/llvm-project/pull/129938)
 , which got missed. 

>From 7769abef03a3a657942c24f794541ea01eee6743 Mon Sep 17 00:00:00 2001
From: Chandra Ghale 
Date: Fri, 21 Mar 2025 05:48:03 -0500
Subject: [PATCH] Minor unused variable error for sanitizer builds

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

diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 930134bcd6501..c66ea5a2c0346 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -11761,7 +11761,7 @@ void 
OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
   unsigned NumFlags = Record.readInt();
   SmallVector Flags;
   Flags.reserve(NumFlags);
-  for (unsigned I : llvm::seq(NumFlags))
+  for ([[maybe_unused]] unsigned I : llvm::seq(NumFlags))
 Flags.push_back(Record.readInt());
   C->setPrivateVariableReductionFlags(Flags);
 }

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


[clang] Minor unused variable error for sanitizer builds (PR #132372)

2025-03-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: CHANDRA GHALE (chandraghale)


Changes

Fix to issue [https://github.com/llvm/llvm-project/issues/132371 
](https://github.com/llvm/llvm-project/issues/132371 )
Minor error ,  sanitizer builds are failing for unused variable.  
sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:11764:17:
 error: unused variable 'I' [-Werror,-Wunused-variable]
 11764 |   for (unsigned I : llvm::seq(NumFlags))

This was modified as part of 
[https://github.com/llvm/llvm-project/pull/129938](https://github.com/llvm/llvm-project/pull/129938)
 , which got missed. 

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


1 Files Affected:

- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) 


``diff
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 930134bcd6501..c66ea5a2c0346 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -11761,7 +11761,7 @@ void 
OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
   unsigned NumFlags = Record.readInt();
   SmallVector Flags;
   Flags.reserve(NumFlags);
-  for (unsigned I : llvm::seq(NumFlags))
+  for ([[maybe_unused]] unsigned I : llvm::seq(NumFlags))
 Flags.push_back(Record.readInt());
   C->setPrivateVariableReductionFlags(Flags);
 }

``




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


[clang] Minor unused variable error for sanitizer builds (PR #132372)

2025-03-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: CHANDRA GHALE (chandraghale)


Changes

Fix to issue [https://github.com/llvm/llvm-project/issues/132371 
](https://github.com/llvm/llvm-project/issues/132371 )
Minor error ,  sanitizer builds are failing for unused variable.  
sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:11764:17:
 error: unused variable 'I' [-Werror,-Wunused-variable]
 11764 |   for (unsigned I : llvm::seq(NumFlags))

This was modified as part of 
[https://github.com/llvm/llvm-project/pull/129938](https://github.com/llvm/llvm-project/pull/129938)
 , which got missed. 

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


1 Files Affected:

- (modified) clang/lib/Serialization/ASTReader.cpp (+1-1) 


``diff
diff --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 930134bcd6501..c66ea5a2c0346 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -11761,7 +11761,7 @@ void 
OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
   unsigned NumFlags = Record.readInt();
   SmallVector Flags;
   Flags.reserve(NumFlags);
-  for (unsigned I : llvm::seq(NumFlags))
+  for ([[maybe_unused]] unsigned I : llvm::seq(NumFlags))
 Flags.push_back(Record.readInt());
   C->setPrivateVariableReductionFlags(Flags);
 }

``




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


[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Tomas Matheson via cfe-commits


@@ -0,0 +1,790 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
+
+// Test all of the AArch64 feature detection bitmasks in the resolver.
+
+// RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o 
- %s | FileCheck %s
+
+__attribute__((target_clones("aes", "bf16"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("bti"))) int fmv(void) { return 0; }

tmatheson-arm wrote:

The original returned different values for each function, any value in doing 
the same here?

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


[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Tomas Matheson via cfe-commits


@@ -0,0 +1,790 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
+
+// Test all of the AArch64 feature detection bitmasks in the resolver.
+
+// RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o 
- %s | FileCheck %s
+
+__attribute__((target_clones("aes", "bf16"))) int fmv(void) { return 0; }

tmatheson-arm wrote:

Why are these two features done differently? target_clones vs target_version

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


[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Tomas Matheson via cfe-commits


@@ -1,1145 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
-
-int __attribute__((target_version("rng+flagm+fp16fml"))) fmv(void) { return 1; 
}

tmatheson-arm wrote:

Do we have anything testing multiple features in one string now?

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


[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Alexandros Lamprineas via cfe-commits


@@ -1,1145 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature -fmv 
-emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NOFMV
-
-int __attribute__((target_version("rng+flagm+fp16fml"))) fmv(void) { return 1; 
}

labrinea wrote:

We have semantic and name mangling tests in place. I may add a test to show the 
bitmask construction works. Also I may be adding a test to show that features 
coming from the command line are not exempt from detection.

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


[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Alexandros Lamprineas via cfe-commits


@@ -0,0 +1,790 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
+
+// Test all of the AArch64 feature detection bitmasks in the resolver.
+
+// RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o 
- %s | FileCheck %s
+
+__attribute__((target_clones("aes", "bf16"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("bti"))) int fmv(void) { return 0; }

labrinea wrote:

No

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


[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Alexandros Lamprineas via cfe-commits


@@ -0,0 +1,790 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
+
+// Test all of the AArch64 feature detection bitmasks in the resolver.
+
+// RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o 
- %s | FileCheck %s
+
+__attribute__((target_clones("aes", "bf16"))) int fmv(void) { return 0; }

labrinea wrote:

To demonstrate that target_clones works.

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


[clang] [NFC][FMV][AArch64] Tidy up codegen tests. (PR #132273)

2025-03-21 Thread Alexandros Lamprineas via cfe-commits


@@ -0,0 +1,790 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals 
--include-generated-funcs --global-value-regex ".*"
+
+// Test all of the AArch64 feature detection bitmasks in the resolver.
+
+// RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o 
- %s | FileCheck %s
+
+__attribute__((target_clones("aes", "bf16"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("bti"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("crc"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("dit"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("dotprod"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("dpb"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("dpb2"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("f32mm"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("f64mm"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("fcma"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("flagm"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("flagm2"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("fp"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("fp16"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("fp16fml"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("frintts"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("i8mm"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("jscvt"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("lse"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("memtag"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("mops"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("rcpc"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("rcpc2"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("rcpc3"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("rdm"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("rng"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sb"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sha2"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sha3"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("simd"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sm4"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sme"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sme-f64f64"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sme-i16i64"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sme2"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("ssbs"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sve"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sve2"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sve2-aes"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sve2-bitperm"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sve2-sha3"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("sve2-sm4"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("wfxt"))) int fmv(void) { return 0; }
+
+__attribute__((target_version("default"))) int fmv(void);
+
+int caller() {
+  return fmv();

labrinea wrote:

I am not seeing much value on this. We only want to see the ifunc symbol being 
referenced upon call.

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


[clang] [libclang/python] Add some bindings to the `Cursor` interface (PR #132377)

2025-03-21 Thread Jannick Kremer via cfe-commits

https://github.com/DeinAlptraum created 
https://github.com/llvm/llvm-project/pull/132377

Make Cursor hashable
Add `Cursor.has_attr()`
Add `Cursor.specialized_template`

>From c433f194600d72a3902c4eed304439d6e3f2f62b Mon Sep 17 00:00:00 2001
From: Mathias Stearn 
Date: Thu, 19 Dec 2024 16:22:04 +0100
Subject: [PATCH] [libclang/python] Add some bindings to the Cursor interface

Make Cursor hashable
Add Cursor.has_attr()
Add Cursor.specialized_template
---
 clang/bindings/python/clang/cindex.py | 17 
 .../python/tests/cindex/test_cursor.py| 40 +++
 clang/docs/ReleaseNotes.rst   |  6 +++
 3 files changed, 63 insertions(+)

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 879a0a3c5c58c..090ee899ad60e 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -1561,6 +1561,9 @@ def __eq__(self, other):
 def __ne__(self, other):
 return not self.__eq__(other)
 
+def __hash__(self) -> int:
+return self.hash
+
 def is_definition(self):
 """
 Returns true if the declaration pointed at by the cursor is also a
@@ -2035,6 +2038,13 @@ def lexical_parent(self):
 
 return self._lexical_parent
 
+@property
+def specialized_template(self) -> Cursor | None:
+"""Return the primary template that this cursor is a specialization 
of, if any."""
+return Cursor.from_cursor_result(
+conf.lib.clang_getSpecializedCursorTemplate(self), self
+)
+
 @property
 def translation_unit(self):
 """Returns the TranslationUnit to which this Cursor belongs."""
@@ -2178,6 +2188,12 @@ def get_bitfield_width(self):
 """
 return conf.lib.clang_getFieldDeclBitWidth(self)  # type: ignore 
[no-any-return]
 
+def has_attrs(self) -> bool:
+"""
+Determine whether the given cursor has any attributes.
+"""
+return bool(conf.lib.clang_Cursor_hasAttrs(self))
+
 @staticmethod
 def from_result(res, arg):
 assert isinstance(res, Cursor)
@@ -3932,6 +3948,7 @@ def set_property(self, property, value):
 ("clang_getCursorType", [Cursor], Type),
 ("clang_getCursorUSR", [Cursor], _CXString),
 ("clang_Cursor_getMangling", [Cursor], _CXString),
+("clang_Cursor_hasAttrs", [Cursor], c_uint),
 # ("clang_getCXTUResourceUsage",
 #  [TranslationUnit],
 #  CXTUResourceUsage),
diff --git a/clang/bindings/python/tests/cindex/test_cursor.py 
b/clang/bindings/python/tests/cindex/test_cursor.py
index c6aa65ce3c29f..9947f551cc2f8 100644
--- a/clang/bindings/python/tests/cindex/test_cursor.py
+++ b/clang/bindings/python/tests/cindex/test_cursor.py
@@ -4,6 +4,7 @@
 AvailabilityKind,
 BinaryOperator,
 Config,
+Cursor,
 CursorKind,
 PrintingPolicy,
 PrintingPolicyProperty,
@@ -995,3 +996,42 @@ def test_pretty_print(self):
 pp.set_property(PrintingPolicyProperty.Bool, False)
 self.assertEqual(pp.get_property(PrintingPolicyProperty.Bool), False)
 self.assertEqual(f.pretty_printed(pp), "void f(_Bool x) {\n}\n")
+
+def test_has_attrs(self):
+tu = get_tu(
+"""
+struct A;
+struct A final {};
+
+struct B;
+struct B {};
+""",
+lang="cpp",
+)
+A = get_cursor(tu, "A")
+B = get_cursor(tu, "B")
+self.assertTrue(A.get_definition().has_attrs())
+self.assertFalse(B.get_definition().has_attrs())
+
+def test_hash(self):
+def accumulate_cursors(cursor: Cursor, all_cursors: list[Cursor]):
+all_cursors.append(cursor)
+for child in cursor.get_children():
+all_cursors = accumulate_cursors(child, all_cursors)
+return all_cursors
+
+tu = get_tu(kInput)
+all_cursors = accumulate_cursors(tu.cursor, [])
+cursor_hashes = set()
+for cursor in all_cursors:
+self.assertNotIn(hash(cursor), cursor_hashes)
+cursor_hashes.add(hash(cursor))
+
+def test_specialized_template(self):
+tu = get_tu(kTemplateArgTest, lang="cpp")
+foos = get_cursors(tu, "foo")
+prime_foo = foos[1].specialized_template
+
+self.assertNotEqual(foos[0], foos[1])
+self.assertEqual(foos[0], prime_foo)
+self.assertIsNone(tu.cursor.specialized_template)
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a25808e36bd51..ab68be3702840 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -442,6 +442,12 @@ Sanitizers
 
 Python Binding Changes
 --
+- Made ``Cursor`` hashable.
+- Added ``Cursor.has_attrs``, a binding for ``clang_Cursor_hasAttrs``, to check
+  whether a cursor has any attributes.
+- Added ``Cursor.specialized_template``, a binding for
+  ``clang_getSpecializedCursorTemplate``, to retrieve the primary template that
+  the cursor is a sp

[clang] [llvm] [AArch64] Add initial support for -mcpu=olympus. (PR #132368)

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

rj-jesus wrote:

Hi, Olympus is the core in the NVIDIA Vera CPU announced at GTC.

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


[clang] Minor unused variable error for sanitizer builds (PR #132372)

2025-03-21 Thread CHANDRA GHALE via cfe-commits


@@ -11761,7 +11761,7 @@ void 
OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
   unsigned NumFlags = Record.readInt();
   SmallVector Flags;
   Flags.reserve(NumFlags);
-  for (unsigned I : llvm::seq(NumFlags))
+  for ([[maybe_unused]] unsigned I : llvm::seq(NumFlags))

chandraghale wrote:

it does

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


[clang] [libclang/python] Change all global variables to snake case (PR #132378)

2025-03-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Jannick Kremer (DeinAlptraum)


Changes



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


7 Files Affected:

- (modified) clang/bindings/python/clang/cindex.py (+5-5) 
- (modified) clang/bindings/python/tests/cindex/test_cdb.py (+10-10) 
- (modified) clang/bindings/python/tests/cindex/test_cursor.py (+13-13) 
- (modified) clang/bindings/python/tests/cindex/test_index.py (+3-3) 
- (modified) clang/bindings/python/tests/cindex/test_location.py (+8-8) 
- (modified) clang/bindings/python/tests/cindex/test_translation_unit.py 
(+16-16) 
- (modified) clang/bindings/python/tests/cindex/test_type.py (+4-4) 


``diff
diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 879a0a3c5c58c..e881bf131d6c4 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -2786,7 +2786,7 @@ class _CXUnsavedFile(Structure):
 # Functions calls through the python interface are rather slow. Fortunately,
 # for most symboles, we do not need to perform a function call. Their spelling
 # never changes and is consequently provided by this spelling cache.
-SpellingCache = {
+spelling_cache = {
 # 0: CompletionChunk.Kind("Optional"),
 # 1: CompletionChunk.Kind("TypedText"),
 # 2: CompletionChunk.Kind("Text"),
@@ -2832,8 +2832,8 @@ def __repr__(self):
 
 @CachedProperty
 def spelling(self):
-if self.__kindNumber in SpellingCache:
-return SpellingCache[self.__kindNumber]
+if self.__kindNumber in spelling_cache:
+return spelling_cache[self.__kindNumber]
 return _CXString.from_result(
 conf.lib.clang_getCompletionChunkText(self.cs, self.key)
 )
@@ -3830,7 +3830,7 @@ def set_property(self, property, value):
 fields_visit_callback = CFUNCTYPE(c_int, Cursor, py_object)
 
 # Functions strictly alphabetical order.
-functionList: list[LibFunc] = [
+function_list: list[LibFunc] = [
 (
 "clang_annotateTokens",
 [TranslationUnit, POINTER(Token), c_uint, POINTER(Cursor)],
@@ -4108,7 +4108,7 @@ def register_functions(lib: CDLL, ignore_errors: bool) -> 
None:
 def register(item: LibFunc) -> None:
 register_function(lib, item, ignore_errors)
 
-for f in functionList:
+for f in function_list:
 register(f)
 
 
diff --git a/clang/bindings/python/tests/cindex/test_cdb.py 
b/clang/bindings/python/tests/cindex/test_cdb.py
index 342a544c86337..c7727b729ad33 100644
--- a/clang/bindings/python/tests/cindex/test_cdb.py
+++ b/clang/bindings/python/tests/cindex/test_cdb.py
@@ -10,7 +10,7 @@
 import sys
 from pathlib import Path
 
-kInputsDir = os.path.join(os.path.dirname(__file__), "INPUTS")
+k_inputs_dir = os.path.join(os.path.dirname(__file__), "INPUTS")
 
 
 @unittest.skipIf(sys.platform == "win32", "TODO: Fix these tests on Windows")
@@ -34,23 +34,23 @@ def test_create_fail(self):
 
 def test_create(self):
 """Check we can load a compilation database"""
-CompilationDatabase.fromDirectory(kInputsDir)
+CompilationDatabase.fromDirectory(k_inputs_dir)
 
 def test_lookup_succeed(self):
 """Check we get some results if the file exists in the db"""
-cdb = CompilationDatabase.fromDirectory(kInputsDir)
+cdb = CompilationDatabase.fromDirectory(k_inputs_dir)
 cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project.cpp")
 self.assertNotEqual(len(cmds), 0)
 
 def test_lookup_succeed_pathlike(self):
 """Same as test_lookup_succeed, but with PathLikes"""
-cdb = CompilationDatabase.fromDirectory(Path(kInputsDir))
+cdb = CompilationDatabase.fromDirectory(Path(k_inputs_dir))
 cmds = 
cdb.getCompileCommands(Path("/home/john.doe/MyProject/project.cpp"))
 self.assertNotEqual(len(cmds), 0)
 
 def test_all_compilecommand(self):
 """Check we get all results from the db"""
-cdb = CompilationDatabase.fromDirectory(kInputsDir)
+cdb = CompilationDatabase.fromDirectory(k_inputs_dir)
 cmds = cdb.getAllCompileCommands()
 self.assertEqual(len(cmds), 3)
 expected = [
@@ -100,7 +100,7 @@ def test_all_compilecommand(self):
 
 def test_1_compilecommand(self):
 """Check file with single compile command"""
-cdb = CompilationDatabase.fromDirectory(kInputsDir)
+cdb = CompilationDatabase.fromDirectory(k_inputs_dir)
 file = "/home/john.doe/MyProject/project.cpp"
 cmds = cdb.getCompileCommands(file)
 self.assertEqual(len(cmds), 1)
@@ -119,7 +119,7 @@ def test_1_compilecommand(self):
 
 def test_2_compilecommand(self):
 """Check file with 2 compile commands"""
-cdb = CompilationDatabase.fromDirectory(kInputsDir)
+cdb = CompilationDatabase.fromDirectory(k_inputs_dir)
 cmds = cdb.getCompileCommands("/home/john.doe/MyProject/project2.cpp")
 s

[clang] Minor unused variable error for sanitizer builds (PR #132372)

2025-03-21 Thread Younan Zhang via cfe-commits


@@ -11761,7 +11761,7 @@ void 
OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
   unsigned NumFlags = Record.readInt();
   SmallVector Flags;
   Flags.reserve(NumFlags);
-  for (unsigned I : llvm::seq(NumFlags))
+  for ([[maybe_unused]] unsigned I : llvm::seq(NumFlags))

zyn0217 wrote:

Well, let's go ahead as is.

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


[clang] [llvm] Revert "[X86][AVX10.2] Support YMM rounding new instructions (#101825)" (PR #132362)

2025-03-21 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> LGTM - do we have to remove avx10-256 as well (and just use prefer vector 
> width) or will that remain in some form?

Yes, we will remove avx10-256 and evex512 finally.

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


[clang] Minor unused variable error for sanitizer builds (PR #132372)

2025-03-21 Thread CHANDRA GHALE via cfe-commits

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


[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

2025-03-21 Thread CHANDRA GHALE via cfe-commits

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


[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

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

llvm-ci wrote:

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

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


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

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: types/TestDoubleTypes.py (517 of 2798)
PASS: lldb-api :: 
lang/cpp/frame-var-depth-and-elem-count/TestFrameVarDepthAndElemCount.py (518 
of 2798)
PASS: lldb-api :: functionalities/rerun/TestRerun.py (519 of 2798)
PASS: lldb-api :: commands/expression/rdar44436068/Test128BitsInteger.py (520 
of 2798)
PASS: lldb-api :: 
functionalities/data-formatter/type_summary_list_script/TestTypeSummaryListScript.py
 (521 of 2798)
PASS: lldb-api :: 
functionalities/breakpoint/breakpoint_options/TestBreakpointOptions.py (522 of 
2798)
PASS: lldb-api :: 
functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneBreakpoint.py
 (523 of 2798)
PASS: lldb-api :: 
commands/expression/persistent_types/TestNestedPersistentTypes.py (524 of 2798)
PASS: lldb-api :: lang/c/non-mangled/TestCNonMangled.py (525 of 2798)
PASS: lldb-api :: commands/expression/bitfield_enums/TestBitfieldEnums.py (526 
of 2798)
FAIL: lldb-api :: 
functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py
 (527 of 2798)
 TEST 'lldb-api :: 
functionalities/breakpoint/breakpoint_reset_upon_run/TestBreakpointResetUponRun.py'
 FAILED 
Script:
--
/usr/bin/python3 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/dotest.py -u 
CXXFLAGS -u CFLAGS --env 
LLVM_LIBS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./lib --env 
LLVM_INCLUDE_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/include --env 
LLVM_TOOLS_DIR=/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --arch x86_64 
--build-dir /home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/worker/2.0.1/lldb-x86_64-debian/build/./bin/lldb --compiler 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/clang --dsymutil 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin/dsymutil --make 
/usr/bin/gmake --llvm-tools-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./bin --lldb-obj-root 
/home/worker/2.0.1/lldb-x86_64-debian/build/tools/lldb --lldb-libs-dir 
/home/worker/2.0.1/lldb-x86_64-debian/build/./lib -t 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run
 -p TestBreakpointResetUponRun.py
--
Exit Code: -11

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

--
Command Output (stderr):
--
Change dir to: 
/home/worker/2.0.1/lldb-x86_64-debian/llvm-project/lldb/test/API/functionalities/breakpoint/breakpoint_reset_upon_run
UNSUPPORTED: LLDB 
(/home/worker/2.0.1/lldb-x86_64-debian/build/bin/clang-x86_64) :: 
test_hitcount_reset_upon_run_dsym 
(TestBreakpointResetUponRun.HitcountResetUponRun.test_hitcount_reset_upon_run_dsym)
 (test case does not fall in any category of interest for this run) 
runCmd: settings clear -all

output: 

runCmd: settings set symbols.enable-external-lookup false

output: 

runCmd: settings set target.inherit-tcc true

output: 

runCmd: settings set target.disable-aslr false

output: 

runCmd: settings set target.detach-on-error false

output: 

```



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


[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-aarch64-linux` 
running on `sanitizer-buildbot7` while building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[4679/5460] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterDecl.cpp.o
[4680/5460] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/RefactoringCallbacks.cpp.o
[4681/5460] Building CXX object 
tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/IndexingContext.cpp.o
[4682/5460] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReaderStmt.cpp.o
[4683/5460] Building CXX object 
tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/Rename/RenamingAction.cpp.o
[4684/5460] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/AnalyzerOptions.cpp.o
[4685/5460] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/BasicValueFactory.cpp.o
[4686/5460] Building CXX object 
tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/IndexDecl.cpp.o
[4687/5460] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTUnit.cpp.o
[4688/5460] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
FAILED: 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/b/sanitizer-aarch64-linux/build/llvm_build0/bin/clang++ -DCLANG_EXPORTS 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/b/sanitizer-aarch64-linux/build/build_default/tools/clang/lib/Serialization
 -I/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/include 
-I/home/b/sanitizer-aarch64-linux/build/build_default/tools/clang/include 
-I/home/b/sanitizer-aarch64-linux/build/build_default/include 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/include -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -MF 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o.d
 -o 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -c 
/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp
/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:11764:17:
 error: unused variable 'I' [-Werror,-Wunused-variable]
 11764 |   for (unsigned I : llvm::seq(NumFlags))
   | ^
1 error generated.
[4689/5460] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/FrontendActions.cpp.o
[4690/5460] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/Transformer.cpp.o
[4691/5460] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/Stencil.cpp.o
[4692/5460] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenModule.cpp.o
[4693/5460] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/DynamicExtent.cpp.o
[4694/5460] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/RewriteRule.cpp.o
[4695/5460] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CheckerRegistryData.cpp.o
[4696/5460] Building CXX object 
tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/USRGeneration.cpp.o
[4697/5460] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/ConstraintManager.cpp.o
[4698/5460] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/EntryPointStats.cpp.o
[4699/5460] Bu

[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-21 Thread Jonathan Thackray via cfe-commits


@@ -0,0 +1,105 @@
+//===-- CGBuiltin.h - Emit LLVM Code for builtins 
-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+#define LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H
+
+#include "CodeGenFunction.h"
+
+// Many of MSVC builtins are on x64, ARM and AArch64; to avoid repeating code,
+// we handle them here.
+enum class clang::CodeGen::CodeGenFunction::MSVCIntrin {

jthackray wrote:

Sorry, this isn't practical. Doing this means also renaming these functions to 
`namespace clang::CodeGen` in `CGBuiltin.cpp` too, and then rename all calls to 
them. So the ripple effect causes a really large diff.

My aim for this change was to split CGBuiltin.cpp, with the fewest possible 
changes to the code. You're welcome to try your suggested change after I've 
merged this PR.

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


[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

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

llvm-ci wrote:

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

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


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

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

Command Output (stdout):
--
# RUN: at line 1
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib 
 -fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo1.c.tmp
 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fcreate-profile  -Xarch_device -fprofile-generate
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -nogpulib 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 
-Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -Wl,-rpath,/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib 
-fopenmp-targets=amdgcn-amd-amdhsa 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo1.c
 -o 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo1.c.tmp
 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib/libomptarget.devicertl.a
 -fcreate-profile -Xarch_device -fprofile-generate
# note: command had no output on stdout or stderr
# RUN: at line 3
env LLVM_PROFILE_FILE=pgo1.c.llvm.profraw  
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo1.c.tmp
 2>&1
# executed command: env LLVM_PROFILE_FILE=pgo1.c.llvm.profraw 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload/test/amdgcn-amd-amdhsa/offloading/gpupgo/Output/pgo1.c.tmp
# note: command had no output on stdout or stderr
# RUN: at line 5
llvm-profdata show --all-functions --counts  
amdgcn-amd-amdhsa.pgo1.c.llvm.profraw |  
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo1.c
 --check-prefix="LLVM-PGO"
# executed command: llvm-profdata show --all-functions --counts 
amdgcn-amd-amdhsa.pgo1.c.llvm.profraw
# note: command had no output on stdout or stderr
# executed command: 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/FileCheck 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test/offloading/gpupgo/pgo1.c
 --check-prefix=LLVM-PGO
# note: command had no output on stdout or stderr
# RUN: at line 9
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./bin/clang 
-fopenmp-I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.src/offload/test -I 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -L 
/home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/runtimes/runtimes-bins/offload
 -L /home/ompworker/bbot/openmp-offload-amdgpu-runtime/llvm.build/./lib -L 
/home/ompworker/bbot/openmp-offload-amdgpu-ru

[clang] [NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (PR #132252)

2025-03-21 Thread Jonathan Thackray via cfe-commits


@@ -0,0 +1,8040 @@
+//===-- AArch64.cpp - Emit LLVM Code for builtins 
-===//

jthackray wrote:

Thanks, fixed.

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


[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` 
running on `ppc64le-sanitizer` while building `clang` at step 2 "annotate".

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[3964/4152] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/ABIInfoImpl.cpp.o
[3965/4152] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/FrontendAction.cpp.o
[3966/4152] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaInit.cpp.o
[3967/4152] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenTypes.cpp.o
[3968/4152] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CodeGenTBAA.cpp.o
[3969/4152] Building CXX object 
tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/WebKit/MemoryUnsafeCastChecker.cpp.o
[3970/4152] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/PPC.cpp.o
[3971/4152] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTUnit.cpp.o
[3972/4152] Building CXX object 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseDecl.cpp.o
[3973/4152] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
FAILED: 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm_build0/bin/clang++
 -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/lib/Serialization
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Serialization
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -MF 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o.d
 -o 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Serialization/ASTReader.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:11764:17:
 error: unused variable 'I' [-Werror,-Wunused-variable]
 11764 |   for (unsigned I : llvm::seq(NumFlags))
   | ^
1 error generated.
[3974/4152] Building CXX object 
tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/GCDAntipatternChecker.cpp.o
[3975/4152] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/LoongArch.cpp.o
[3976/4152] Building CXX object 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTDumper.cpp.o
[3977/4152] Building CXX object 
tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/USRGeneration.cpp.o
[3978/4152] Building CXX object 
tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/IndexTypeSourceInfo.cpp.o
[3979/4152] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/AnalysisBasedWarnings.cpp.o
[3980/4152] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/Targets/AMDGPU.cpp.o
[3981/4152] Building CXX object 
tools/clang/lib/Analysis/F

[clang] [OpenMP 6.0] Parse/Sema support for reduction over private variable with reduction clause. (PR #129938)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`ppc64le-lld-multistage-test` running on `ppc64le-lld-multistage-test` while 
building `clang` at step 12 "build-stage2-unified-tree".

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


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

```
Step 12 (build-stage2-unified-tree) failure: build (failure)
...
436.783 [884/519/5090] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGCUDANV.cpp.o
436.953 [884/518/5091] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGDeclCXX.cpp.o
437.010 [884/517/5092] Building CXX object 
tools/llvm-exegesis/lib/Mips/CMakeFiles/LLVMExegesisMips.dir/Target.cpp.o
437.082 [884/516/5093] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGExprComplex.cpp.o
437.085 [884/515/5094] Building CXX object 
tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/AnalyzerOptionsTest.cpp.o
437.087 [884/514/5095] Building CXX object 
unittests/Target/VE/CMakeFiles/VETests.dir/MachineInstrTest.cpp.o
437.108 [884/513/5096] Building CXX object 
lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/HexagonISelDAGToDAGHVX.cpp.o
437.110 [884/512/5097] Building CXX object 
tools/clang/unittests/StaticAnalyzer/CMakeFiles/StaticAnalysisTests.dir/Z3CrosscheckOracleTest.cpp.o
437.149 [884/511/5098] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaAPINotes.cpp.o
437.192 [884/510/5099] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
FAILED: 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 
ccache 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/install/stage1/bin/clang++
 -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/lib/Serialization
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Serialization
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -MF 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o.d
 -o 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Serialization/ASTReader.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Serialization/ASTReader.cpp:11764:17:
 error: unused variable 'I' [-Werror,-Wunused-variable]
 11764 |   for (unsigned I : llvm::seq(NumFlags))
   | ^
1 error generated.
437.204 [884/509/5100] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaLambda.cpp.o
437.207 [884/508/5101] Building CXX object 
lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/HexagonGenInsert.cpp.o
437.340 [884/507/5102] Building CXX object 
lib/Target/Hexagon/CMakeFiles/LLVMHexagonCodeGen.dir/HexagonLoopIdiomRecognition.cpp.o
437.380 [884/506/5103] Building CXX object 
tools/llvm-exegesis/lib/CMakeFiles/LLVMExegesis.dir/LatencyBenchmarkRunner.cpp.o
437.388 [884/505/5104] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGRecordLayoutBuilder.cpp.o
437.425 [884/504/5105] Building CXX object 
lib/Target/RISCV/MCTargetDesc/CMakeFiles

[libclc] [libclc] link_bc target should depends on target builtins.link.clc-arch_suffix (PR #132338)

2025-03-21 Thread Wenju He via cfe-commits

wenju-he wrote:

I've tested on Windows for half a day, it seems this PR can fix the issue.

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


[clang] [alpha.webkit.UnretainedLambdaCapturesChecker] Add the support for protectedSelf (PR #132363)

2025-03-21 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa created 
https://github.com/llvm/llvm-project/pull/132363

This PR adds the support for treating capturing of "self" as safe if the lambda 
simultaneously captures "protectedSelf", which is a RetainPtr of "self".

This PR also fixes a bug that the checker wasn't generating a warning when 
"self" is implicitly captured. Note when "self" is implicitly captured, we use 
the lambda's getBeginLoc as a fallback source location.

In addition, this PR also fixes a bug that the checker wasn't generating 
warnings for lambda caotures when ARC is enabled. While ARC protects variables 
in the stack, it does not automatically extend the lifetime of a lambda 
capture. So we now call RetainTypeChecker's isUnretained with ignoreARC set to 
true.

>From cf415a9cf9933bc4e55d3c8da9b27551b09061fe Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Fri, 21 Mar 2025 02:32:49 -0700
Subject: [PATCH] [alpha.webkit.UnretainedLambdaCapturesChecker] Add the
 support for protectedSelf

This PR adds the support for treating capturing of "self" as safe if the lambda 
simultaneously
captures "protectedSelf", which is a RetainPtr of "self".

This PR also fixes a bug that the checker wasn't generating a warning when 
"self" is implicitly
captured. Note when "self" is implicitly captured, we use the lambda's 
getBeginLoc as a fallback
source location.

In addition, this PR also fixes a bug that the checker wasn't generating 
warnings for lambda
caotures when ARC is enabled. While ARC protects variables in the stack, it 
does not
automatically extend the lifetime of a lambda capture. So we now call 
RetainTypeChecker's
isUnretained with ignoreARC set to true.
---
 .../Checkers/WebKit/PtrTypesSemantics.cpp |  2 +-
 .../WebKit/RawPtrRefLambdaCapturesChecker.cpp | 58 +++
 .../WebKit/unretained-lambda-captures-arc.mm  |  8 +++
 .../WebKit/unretained-lambda-captures.mm  | 16 +
 4 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index b4d2353a03cd2..a161cf644b7d9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -147,7 +147,7 @@ bool isCtorOfCheckedPtr(const clang::FunctionDecl *F) {
 bool isCtorOfRetainPtr(const clang::FunctionDecl *F) {
   const std::string &FunctionName = safeGetName(F);
   return FunctionName == "RetainPtr" || FunctionName == "adoptNS" ||
- FunctionName == "adoptCF";
+ FunctionName == "adoptCF" || FunctionName == "retainPtr";
 }
 
 bool isCtorOfSafePtr(const clang::FunctionDecl *F) {
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp
index 8496a75c1b84f..e8dcf3aaf518e 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp
@@ -36,6 +36,7 @@ class RawPtrRefLambdaCapturesChecker
   : Bug(this, description, "WebKit coding guidelines") {}
 
   virtual std::optional isUnsafePtr(QualType) const = 0;
+  virtual bool isPtrType(const std::string &) const = 0;
   virtual const char *ptrKind(QualType QT) const = 0;
 
   void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR,
@@ -68,6 +69,15 @@ class RawPtrRefLambdaCapturesChecker
 return DynamicRecursiveASTVisitor::TraverseCXXMethodDecl(CXXMD);
   }
 
+  bool TraverseObjCMethodDecl(ObjCMethodDecl *OCMD) override {
+llvm::SaveAndRestore SavedDecl(ClsType);
+if (OCMD && OCMD->isInstanceMethod()) {
+  if (auto *ImplParamDecl = OCMD->getSelfDecl())
+ClsType = ImplParamDecl->getType();
+}
+return DynamicRecursiveASTVisitor::TraverseObjCMethodDecl(OCMD);
+  }
+
   bool VisitTypedefDecl(TypedefDecl *TD) override {
 if (Checker->RTC)
   Checker->RTC->visitTypedef(TD);
@@ -287,7 +297,7 @@ class RawPtrRefLambdaCapturesChecker
 if (!Ctor)
   return false;
 auto clsName = safeGetName(Ctor->getParent());
-if (isRefType(clsName) && CE->getNumArgs()) {
+if (Checker->isPtrType(clsName) && CE->getNumArgs()) {
   Arg = CE->getArg(0)->IgnoreParenCasts();
   continue;
 }
@@ -307,6 +317,12 @@ class RawPtrRefLambdaCapturesChecker
   Arg = CE->getArg(0)->IgnoreParenCasts();
   continue;
 }
+if (auto *Callee = CE->getDirectCallee()) {
+  if (isCtorOfSafePtr(Callee) && CE->getNumArgs() == 1) {
+Arg = CE->getArg(0)->IgnoreParenCasts();
+continue;
+  }
+}
   }
   if (auto *OpCE = dyn_cast(Arg)) {
 auto OpCode = OpCE->getOperator();
@@

[clang] [alpha.webkit.UnretainedLambdaCapturesChecker] Add the support for protectedSelf (PR #132363)

2025-03-21 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa updated 
https://github.com/llvm/llvm-project/pull/132363

>From cf415a9cf9933bc4e55d3c8da9b27551b09061fe Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Fri, 21 Mar 2025 02:32:49 -0700
Subject: [PATCH 1/2] [alpha.webkit.UnretainedLambdaCapturesChecker] Add the
 support for protectedSelf

This PR adds the support for treating capturing of "self" as safe if the lambda 
simultaneously
captures "protectedSelf", which is a RetainPtr of "self".

This PR also fixes a bug that the checker wasn't generating a warning when 
"self" is implicitly
captured. Note when "self" is implicitly captured, we use the lambda's 
getBeginLoc as a fallback
source location.

In addition, this PR also fixes a bug that the checker wasn't generating 
warnings for lambda
caotures when ARC is enabled. While ARC protects variables in the stack, it 
does not
automatically extend the lifetime of a lambda capture. So we now call 
RetainTypeChecker's
isUnretained with ignoreARC set to true.
---
 .../Checkers/WebKit/PtrTypesSemantics.cpp |  2 +-
 .../WebKit/RawPtrRefLambdaCapturesChecker.cpp | 58 +++
 .../WebKit/unretained-lambda-captures-arc.mm  |  8 +++
 .../WebKit/unretained-lambda-captures.mm  | 16 +
 4 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index b4d2353a03cd2..a161cf644b7d9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -147,7 +147,7 @@ bool isCtorOfCheckedPtr(const clang::FunctionDecl *F) {
 bool isCtorOfRetainPtr(const clang::FunctionDecl *F) {
   const std::string &FunctionName = safeGetName(F);
   return FunctionName == "RetainPtr" || FunctionName == "adoptNS" ||
- FunctionName == "adoptCF";
+ FunctionName == "adoptCF" || FunctionName == "retainPtr";
 }
 
 bool isCtorOfSafePtr(const clang::FunctionDecl *F) {
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp
index 8496a75c1b84f..e8dcf3aaf518e 100644
--- 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp
+++ 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLambdaCapturesChecker.cpp
@@ -36,6 +36,7 @@ class RawPtrRefLambdaCapturesChecker
   : Bug(this, description, "WebKit coding guidelines") {}
 
   virtual std::optional isUnsafePtr(QualType) const = 0;
+  virtual bool isPtrType(const std::string &) const = 0;
   virtual const char *ptrKind(QualType QT) const = 0;
 
   void checkASTDecl(const TranslationUnitDecl *TUD, AnalysisManager &MGR,
@@ -68,6 +69,15 @@ class RawPtrRefLambdaCapturesChecker
 return DynamicRecursiveASTVisitor::TraverseCXXMethodDecl(CXXMD);
   }
 
+  bool TraverseObjCMethodDecl(ObjCMethodDecl *OCMD) override {
+llvm::SaveAndRestore SavedDecl(ClsType);
+if (OCMD && OCMD->isInstanceMethod()) {
+  if (auto *ImplParamDecl = OCMD->getSelfDecl())
+ClsType = ImplParamDecl->getType();
+}
+return DynamicRecursiveASTVisitor::TraverseObjCMethodDecl(OCMD);
+  }
+
   bool VisitTypedefDecl(TypedefDecl *TD) override {
 if (Checker->RTC)
   Checker->RTC->visitTypedef(TD);
@@ -287,7 +297,7 @@ class RawPtrRefLambdaCapturesChecker
 if (!Ctor)
   return false;
 auto clsName = safeGetName(Ctor->getParent());
-if (isRefType(clsName) && CE->getNumArgs()) {
+if (Checker->isPtrType(clsName) && CE->getNumArgs()) {
   Arg = CE->getArg(0)->IgnoreParenCasts();
   continue;
 }
@@ -307,6 +317,12 @@ class RawPtrRefLambdaCapturesChecker
   Arg = CE->getArg(0)->IgnoreParenCasts();
   continue;
 }
+if (auto *Callee = CE->getDirectCallee()) {
+  if (isCtorOfSafePtr(Callee) && CE->getNumArgs() == 1) {
+Arg = CE->getArg(0)->IgnoreParenCasts();
+continue;
+  }
+}
   }
   if (auto *OpCE = dyn_cast(Arg)) {
 auto OpCode = OpCE->getOperator();
@@ -315,7 +331,7 @@ class RawPtrRefLambdaCapturesChecker
   if (!Callee)
 return false;
   auto clsName = safeGetName(Callee->getParent());
-  if (!isRefType(clsName) || !OpCE->getNumArgs())
+  if (!Checker->isPtrType(clsName) || !OpCE->getNumArgs())
 return false;
   Arg = OpCE->getArg(0)->IgnoreParenCasts();
   continue;
@@ -330,8 +346,15 @@ class RawPtrRefLambdaCapturesChecker
   }
   break;
 } while (Arg);
-if (auto *DRE = dyn_cast(Arg))
-  return ProtectedThisDecls.contains(DRE->getDecl());
+if (auto *DRE = dyn_cast(A

[clang] [clang-tools-extra] [lldb] [llvm] Add test to clang-doc, it can test comments in macro. Original issue is #59819. (PR #132360)

2025-03-21 Thread via cfe-commits

ZhongUncle wrote:

@ilovepi Hey, This is my test to 
https://github.com/llvm/llvm-project/issues/59819.

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


  1   2   3   4   5   >