[clang] [llvm] [Clang][AArch64] Add support for SHF_AARCH64_PURECODE ELF section flag (2/3) (PR #125688)

2025-02-04 Thread via cfe-commits
=?utf-8?q?Csanád_Hajdú?= 
Message-ID:
In-Reply-To: 


llvmbot wrote:




@llvm/pr-subscribers-llvm-binary-utilities

Author: Csanád Hajdú (Il-Capitano)


Changes

Add support for the new SHF_AARCH64_PURECODE ELF section flag: 
https://github.com/ARM-software/abi-aa/pull/304

The general implementation follows the existing one for ARM targets. Simlarly 
to ARM targets, generating object files with the `SHF_AARCH64_PURECODE` flag 
set is enabled by the `-mexecute-only`/`-mpure-code` driver flag.

Depends on https://github.com/llvm/llvm-project/pull/125687. The changes in 
that PR are included here as well for now, but will be removed once that gets 
merged.

---

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


23 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (+2-2) 
- (modified) clang/lib/Driver/ToolChains/Arch/AArch64.cpp (+11) 
- (added) clang/test/CodeGen/aarch64-execute-only.c (+24) 
- (added) clang/test/Driver/aarch64-execute-only.c (+6) 
- (modified) clang/test/Driver/fsanitize.c (+7-1) 
- (modified) llvm/include/llvm/BinaryFormat/ELF.h (+4-1) 
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+8-5) 
- (modified) llvm/lib/MC/MCParser/ELFAsmParser.cpp (+5-2) 
- (modified) llvm/lib/MC/MCSectionELF.cpp (+3) 
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+3) 
- (modified) llvm/lib/Target/AArch64/AArch64Features.td (+5) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp (+26) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetObjectFile.h (+6) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+16-1) 
- (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h (+2) 
- (modified) llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp (+18) 
- (added) llvm/test/CodeGen/AArch64/execute-only-section.ll (+21) 
- (added) llvm/test/MC/ELF/AArch64/execute-only-populated-text-section.s (+27) 
- (added) llvm/test/MC/ELF/AArch64/execute-only-section.s (+43) 
- (added) llvm/test/MC/ELF/AArch64/execute-only-text-section-data.s (+27) 
- (modified) llvm/test/MC/ELF/section-flags-unknown.s (+3) 
- (modified) llvm/test/Transforms/Inline/AArch64/inline-target-attr.ll (+25) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+8) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0ab923fcdd5838c..028d74c9711d1f0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4677,9 +4677,9 @@ def mno_long_calls : Flag<["-"], "mno-long-calls">, 
Group,
   HelpText<"Restore the default behaviour of not generating long calls">;
 } // let Flags = [TargetSpecific]
 def mexecute_only : Flag<["-"], "mexecute-only">, Group,
-  HelpText<"Disallow generation of data access to code sections (ARM only)">;
+  HelpText<"Disallow generation of data access to code sections (AArch64/ARM 
only)">;
 def mno_execute_only : Flag<["-"], "mno-execute-only">, 
Group,
-  HelpText<"Allow generation of data access to code sections (ARM only)">;
+  HelpText<"Allow generation of data access to code sections (AArch64/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">,
   HelpText<"Thread pointer access method. "
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 1e2ac4e501bafd1..1248fea50f9de2b 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -332,6 +332,17 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
   } else if (Triple.isOSOpenBSD())
 Features.push_back("+strict-align");
 
+  // Generate execute-only output (no data access to code sections).
+  // This only makes sense for the compiler, not for the assembler.
+  if (!ForAS) {
+if (Arg *A = Args.getLastArg(options::OPT_mexecute_only,
+ options::OPT_mno_execute_only)) {
+  if (A->getOption().matches(options::OPT_mexecute_only)) {
+Features.push_back("+execute-only");
+  }
+}
+  }
+
   if (Args.hasArg(options::OPT_ffixed_x1))
 Features.push_back("+reserve-x1");
 
diff --git a/clang/test/CodeGen/aarch64-execute-only.c 
b/clang/test/CodeGen/aarch64-execute-only.c
new file mode 100644
index 000..d885e954166f674
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-execute-only.c
@@ -0,0 +1,24 @@
+// RUN: %clang -target aarch64 -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY
+
+// RUN: %clang -target aarch64 -### -mexecute-only %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-EXECUTE-ONLY
+
+// RUN: %clang -target aarch64 -### -mexecute-only -mno-execute-only %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-EXECUTE-ONLY
+
+
+// -mpure-code flag for 

[clang] [Clang] allow restrict qualifier for array types with pointer types as element types (PR #120896)

2025-02-04 Thread Oleksandr T. via cfe-commits


@@ -1596,12 +1596,14 @@ QualType Sema::BuildQualifiedType(QualType T, 
SourceLocation Loc,
 QualType ProblemTy;
 
 if (T->isAnyPointerType() || T->isReferenceType() ||
-T->isMemberPointerType()) {
+T->isMemberPointerType() || T->isArrayType()) {
   QualType EltTy;
   if (T->isObjCObjectPointerType())
 EltTy = T;
   else if (const MemberPointerType *PTy = T->getAs())
 EltTy = PTy->getPointeeType();
+  else if (T->isArrayType())
+EltTy = BuildQualifiedType(Context.getBaseElementType(T), Loc, Qs);

a-tarasyuk wrote:

@efriedma-quic Whoops :). I had considered removing recursion but was not 
certain that was the main point. I've removed recursion. Could you check the 
latest changes? thanks

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

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


@@ -1190,6 +1190,11 @@ void Sema::ActOnPragmaAttributePop(SourceLocation 
PragmaLoc,
 void Sema::AddPragmaAttributes(Scope *S, Decl *D) {
   if (PragmaAttributeStack.empty())
 return;
+
+  if (ParmVarDecl *P = dyn_cast(D))

AaronBallman wrote:

```suggestion
  if (const auto *P = dyn_cast(D))
```

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

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


@@ -1190,6 +1190,11 @@ void Sema::ActOnPragmaAttributePop(SourceLocation 
PragmaLoc,
 void Sema::AddPragmaAttributes(Scope *S, Decl *D) {
   if (PragmaAttributeStack.empty())
 return;
+
+  if (ParmVarDecl *P = dyn_cast(D))
+if (P->getIdentifier() == nullptr && P->getType()->isVoidType())

AaronBallman wrote:

```suggestion
if (P->getType()->isVoidType())
```
I don't think we need to look at the identifier; a `void` parameter has to be 
unnamed anyway.

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


[clang] [llvm] [AMDGPU][True16][MC][CodeGen] true16 for v_alignbyte_b32 (PR #119750)

2025-02-04 Thread Ivan Kosarev via cfe-commits

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

LGTM.

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


[clang] [llvm] [analyzer] Consolidate array bound checkers (PR #125534)

2025-02-04 Thread Donát Nagy via cfe-commits

NagyDonat wrote:

I evaluated a sample of 10 random ArrayBoundV2 results from FFMPEG and I found 
the following:
- [Unjustified assumption of third 
iteration](https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=ffmpeg_n4.3.1_edonnag_llvm-main_1883de3&newcheck=ffmpeg_n4.3.1_edonnag_llvm-main_f8aa6f1&diff-type=New&report-id=6936068&report-hash=4849805b289670414ad1c51975c2eeac&report-filepath=ffmpeg%2Flibavfilter%2Faf_amultiply.c)
 because my recent "[don't assume third 
iteration](https://github.com/llvm/llvm-project/pull/119388)" change doesn't 
handle the case when there is a short-circuiting operator in the loop condition.
  - IIRC this covers several (5-10??) false positives in this particular 
project, but should be significantly less common elsewhere (FFMPEG has an 
unusually high concentration of 2-element arrays).
  - Eliminating these would be a technically complex task, but has no 
fundamental obstacles. However they're rare enough that I'm not sure if they're 
worth the effort. 
- [Non-realistic 
overflow](https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=ffmpeg_n4.3.1_edonnag_llvm-main_1883de3&newcheck=ffmpeg_n4.3.1_edonnag_llvm-main_f8aa6f1&diff-type=New&report-id=6936379&report-hash=10c43369fbbd8b9359afdebd019643ee&report-filepath=ffmpeg%2Flibavcodec%2Fansi.c)
 where the analyzer assumes that the code was able to read $\approx 2^{31}$ 
arguments from the input (which can't happen, but the analyzer cannot deduce 
this precondition of the analyzed function).
- [Correlated if 
conditions](https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=ffmpeg_n4.3.1_edonnag_llvm-main_1883de3&newcheck=ffmpeg_n4.3.1_edonnag_llvm-main_f8aa6f1&diff-type=New&page=2&report-id=6936490&report-hash=7765e71a226bf336d525811ccb01c476&report-filepath=ffmpeg%2Flibavcodec%2Fhevc_cabac.c):
 assuming that the `av_clip` call in line 1103 returns 
`-s->ps.sps->qp_bd_offset` and then assuming that this result is `> 51` 
produces an array underflow. I suspect that this can't happen (e.g. I'd guess 
that `s->ps.sps->qp_bd_offset` is always nonnegative), but I don't think that 
Z3 crosscheck would be helpful.
- [A classical "assuming skipped loop" 
error](https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=ffmpeg_n4.3.1_edonnag_llvm-main_1883de3&newcheck=ffmpeg_n4.3.1_edonnag_llvm-main_f8aa6f1&diff-type=New&page=2&report-id=6936516&report-hash=51d11525a3b6b456f1076aed8b790e61&report-filepath=ffmpeg%2Flibavcodec%2Fhevcpred_template.c)
 which would be silenced by [the new `assume-one-iteration` 
option](https://github.com/llvm/llvm-project/pull/125494) or a well-placed 
assertion. (Enabling that option would silence 34 of the 187 ArrayBoundV2 
errors on this project.)
- [Technically justified, but unwanted assumption of a third 
iteration](https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=ffmpeg_n4.3.1_edonnag_llvm-main_1883de3&newcheck=ffmpeg_n4.3.1_edonnag_llvm-main_f8aa6f1&diff-type=New&page=3&report-id=6936484&report-hash=f8cf2f54adb6af9636d26f5275b959fc&report-filepath=ffmpeg%2Flibavcodec%2Fhapdec.c):
 first there is an `if` where the analyzer can assume `ctx->texture_count != 2` 
so later when the analyzer assumes that `ctx->texture_count >= 2` (i.e. it may 
enter the second iteration of the loop), it gets "enough fuel" to also enter 
the third iteration (which is an overflow error). This is a correlated 
assumption error (similar to the "correlated if" issue), so solving it is 
blocked by fundamental theoretical obstacles.
- [Yet another "assuming skipped loop" 
issue](https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=ffmpeg_n4.3.1_edonnag_llvm-main_1883de3&newcheck=ffmpeg_n4.3.1_edonnag_llvm-main_f8aa6f1&diff-type=New&page=3&report-id=6936513&report-hash=30e1c1cefaad9086c13fdb53692a0ff4&report-filepath=ffmpeg%2Flibavcodec%2Fhevcpred_template.c),
 very similar (but somewhat more complex) than the previous one.
- [Technically a true 
positive](https://codechecker-demo.eastus.cloudapp.azure.com/Default/report-detail?run=ffmpeg_n4.3.1_edonnag_llvm-main_1883de3&newcheck=ffmpeg_n4.3.1_edonnag_llvm-main_f8aa6f1&diff-type=New&page=5&report-id=6936917&report-hash=715cc85d94e2fcebde8b49ec355401f9&report-filepath=ffmpeg%2Ffftools%2Fffmpeg_opt.c)
 where the analyzer assumes that the second element of `static const char 
*opt_name_reinit_filters[] = {"reinit_filter", NULL};` may be non-`NULL` when 
the analyzed function is executed. (For a programmer it's obvious that this is 
a constant, but the analyzer cannot deduce this. The programmer could resolve 
this by adding an extra `const` qualifier.)
- The remaining three issues in my random sample are all duplicates of this one 
-- they appear as separate reports because the error is within a **macro that's 
expanded in several locations and apparently produces 80 (!) ArrayBoundV2 
reports** (which correspond to other analogous arrays i

[clang] [llvm] [AMDGPU][True16][MC][CodeGen] true16 for v_alignbyte_b32 (PR #119750)

2025-02-04 Thread Ivan Kosarev via cfe-commits


@@ -1690,7 +1715,7 @@ defm V_FMA_F32 : 
VOP3_Realtriple_gfx11_gfx12<0x213>;
 defm V_FMA_F64 : VOP3_Real_Base_gfx11_gfx12<0x214>;
 defm V_LERP_U8 : VOP3_Realtriple_gfx11_gfx12<0x215>;
 defm V_ALIGNBIT_B32: VOP3_Realtriple_gfx11_gfx12<0x216>;
-defm V_ALIGNBYTE_B32   : VOP3_Realtriple_gfx11_gfx12<0x217>;
+defm V_ALIGNBYTE_B32   : VOP3_Realtriple_t16_and_fake16_gfx11_gfx12<0x217, 
"v_alignbyte_b32">;

kosarev wrote:

Nit: you can do `string asmName = !tolower(NAME)` in the multiclass.

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

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

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

LGTM, thank you for the fix!

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

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


@@ -10329,6 +10329,13 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   }
 }
 
+if (FTIHasSingleVoidParameter(FTI)) {
+  ParmVarDecl *Param = cast(FTI.Params[0].Param);

AaronBallman wrote:

```suggestion
  const auto *Param = cast(FTI.Params[0].Param);
```

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


[clang] [Clang] Do not try to transform invalid bindings (PR #125658)

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

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


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


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

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


@@ -179,8 +181,40 @@ bool CoreEngine::ExecuteWorkList(const LocationContext *L, 
unsigned MaxSteps,
   return WList->hasWork();
 }
 
-void CoreEngine::dispatchWorkItem(ExplodedNode* Pred, ProgramPoint Loc,
-  const WorkListUnit& WU) {
+static std::string timeTraceScopeName(const ProgramPoint &Loc) {
+  if (llvm::timeTraceProfilerEnabled()) {
+return llvm::formatv("Loc {0}",
+ ProgramPoint::getProgramPointKindName(Loc.getKind()))
+.str();
+  }
+  return "";
+}
+
+static llvm::TimeTraceMetadata timeTraceMetadata(const ExplodedNode *Pred,
+ const ProgramPoint &Loc) {
+  // If time-trace profiler is not enabled, this function is never called.
+  assert(llvm::timeTraceProfilerEnabled());
+  std::string str;

necto wrote:

Sorry for overlooking these
4cc3be9658c4 [NFC] Uppercase some variable names

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


[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-02-04 Thread Kevin P. Neal via cfe-commits

kpneal wrote:

> To handle the case where a block isn't owned by a function, we need the 
> attribute at the call site. I don't know the specifics of how that case 
> arises, but if we remove the attribute from the call site, we would have to 
> do something to add it again when the block gets detached from the function 
> (possibly during cloning?).

And then remove it again when reinserting the BB into a function body? That 
sounds like a complication, said complication may be missed by someone in the 
future who isn't focused on FP, and I haven't yet heard a reason we need all of 
this.

@spavloff -- Why do we need to change how we handle the strictfp attribute? 
What's the benefit?

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


[clang] [llvm] [IR] Don't set strictfp on irrelevant calls (PR #122735)

2025-02-04 Thread Kevin P. Neal via cfe-commits


@@ -66,6 +66,12 @@ bool IntrinsicInst::mayLowerToFunctionCall(Intrinsic::ID 
IID) {
   }
 }
 
+bool IntrinsicInst::canAccessFPEnvironment(LLVMContext &C, Intrinsic::ID IID) {
+  AttributeList Attrs = Intrinsic::getAttributes(C, IID);
+  MemoryEffects ME = Attrs.getMemoryEffects();
+  return ME.onlyAccessesInaccessibleMem();

kpneal wrote:

Wouldn't a large fraction of existing functions that may or may not have any 
floating point in them qualify as doesAccessInaccessibleMem()? It seems like if 
we're going to model the FP environment like "memory" then we need an FP 
environment modeling flag proper.

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

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


@@ -1190,6 +1190,11 @@ void Sema::ActOnPragmaAttributePop(SourceLocation 
PragmaLoc,
 void Sema::AddPragmaAttributes(Scope *S, Decl *D) {
   if (PragmaAttributeStack.empty())
 return;
+
+  if (ParmVarDecl *P = dyn_cast(D))
+if (P->getIdentifier() == nullptr && P->getType()->isVoidType())

erichkeane wrote:

is the identifier-check necessary?  Identifier on a void parameter is invalid.

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


[clang-tools-extra] [SystemZ][z/OS] Open text files in text mode (PR #125570)

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

llvm-ci wrote:

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

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Analysis/live-stmts.cpp' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-cc1 -internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include 
-nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -w 
-analyzer-checker=debug.DumpLiveExprs 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp
 2>&1   | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/21/include 
-nostdsysteminc -analyze -analyzer-constraints=range -setup-static-analyzer -w 
-analyzer-checker=debug.DumpLiveExprs 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp:239:16:
 error: CHECK-EMPTY: is not on the line after the previous 
match
// CHECK-EMPTY:
   ^
:180:1: note: 'next' match was here

^
:177:1: note: previous match ended here

^
:178:1: note: non-matching line after 
previous match is here
ImplicitCastExpr 0x11e03d178 '_Bool' 
^

Input file: 
Check file: 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Analysis/live-stmts.cpp

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

Input was:
<<
   1:  
   2: [ B0 (live expressions at block 
exit) ] 
check:21  ^~~
   3:  
empty:22  ^
   4:  
empty:23  ^
   5: [ B1 (live expressions at block 
exit) ] 
check:24  ^~~
   6:  
empty:25  ^
   7:  
empty:26  ^
   8: [ B2 (live expressions at block 
exit) ] 
check:27  ^~~
   9:  
empty:28  ^
  10: DeclRefExpr 0x11d0938e0 'int' 
lvalue ParmVar 0x11d076c70 'y' 'int' 
next:29   
^~
  11:  
empty:30  ^
  12: DeclRefExpr 0x11d093900 'int' 
lvalue ParmVar 0x11d076cf0 'z' 'int' 
...

```



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


[clang] [llvm] [analyzer] Consolidate array bound checkers (PR #125534)

2025-02-04 Thread Donát Nagy via cfe-commits

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

2025-02-04 Thread Oleksandr T. via cfe-commits

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

>From bd731e4be65fc9c1746aa6a8f63d206eb54bb2be Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 29 Jan 2025 15:17:06 +0200
Subject: [PATCH 01/10] [Clang] disallow attributes on void parameters

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Parse/ParseDecl.cpp  | 7 +++
 clang/test/Parser/cxx0x-attributes.cpp | 9 +
 3 files changed, 18 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7fafe2807bd3883..0c87e52007d5463 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -100,6 +100,8 @@ Removed Compiler Flags
 Attribute Changes in Clang
 --
 
+- Clang now disallows the use of attributes on void parameters. (#GH108819)
+
 Improvements to Clang's diagnostics
 ---
 
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index f136d5007e8a5f0..0b88dd4449b1e28 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7986,6 +7986,13 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
+if (ParmDeclarator.getIdentifier() == nullptr &&
+ParmDeclarator.getDeclarationAttributes().size() &&
+ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) {
+  SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range;
+  Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << 
AttrRange;
+}
+
 if (Tok.is(tok::kw_requires)) {
   // User tried to define a requires clause in a parameter declaration,
   // which is surely not a function declaration.
diff --git a/clang/test/Parser/cxx0x-attributes.cpp 
b/clang/test/Parser/cxx0x-attributes.cpp
index fad3010c98b9c28..13fcdd142fa841f 100644
--- a/clang/test/Parser/cxx0x-attributes.cpp
+++ b/clang/test/Parser/cxx0x-attributes.cpp
@@ -453,3 +453,12 @@ namespace P2361 {
 }
 
 alignas(int) struct AlignAsAttribute {}; // expected-error {{misplaced 
attributes; expected attributes here}}
+
+namespace GH108819 {
+void a([[maybe_unused]] void) {} // expected-error {{an 
attribute list cannot appear here}} \
+ // expected-warning {{use of 
the 'maybe_unused' attribute is a C++17 extension}}
+void b([[deprecated]] void) {}   // expected-error {{an 
attribute list cannot appear here}} \
+ // expected-warning {{use of 
the 'deprecated' attribute is a C++14 extension}}
+void c([[clang::lifetimebound]] void) {} // expected-error {{an 
attribute list cannot appear here}}
+void d([[clang::annotate("a", "b", 1)]] void) {} // expected-error {{an 
attribute list cannot appear here}}
+}

>From 063f76730ebfd289f5340d0d8477a43a5ea965c2 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 29 Jan 2025 15:54:48 +0200
Subject: [PATCH 02/10] remove unnecessary name check

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

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 0b88dd4449b1e28..934c16c95915203 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7986,8 +7986,7 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
-if (ParmDeclarator.getIdentifier() == nullptr &&
-ParmDeclarator.getDeclarationAttributes().size() &&
+if (ParmDeclarator.getDeclarationAttributes().size() &&
 ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) {
   SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range;
   Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << 
AttrRange;

>From 3f3431513ad59111794953d27e64608b3ce2e6e1 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 29 Jan 2025 16:07:18 +0200
Subject: [PATCH 03/10] use empty instead of size

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

diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 934c16c95915203..963b59565953d45 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -7986,7 +7986,7 @@ void Parser::ParseParameterDeclarationClause(
 if (getLangOpts().HLSL)
   MaybeParseHLSLAnnotations(DS.getAttributes());
 
-if (ParmDeclarator.getDeclarationAttributes().size() &&
+if (!ParmDeclarator.getDeclarationAttributes().empty() &&
 ParmDeclarator.getDeclSpec().getTypeSpecType() == DeclSpec::TST_void) {
   SourceRange AttrRange = ParmDeclarator.getDeclarationAttributes().Range;
   Diag(AttrRange.getBegin(), diag::err_attributes_not_allowed) << 
AttrRange;

>From 9919006df9ec32023b2bf179b72f9ebaf977bd08

[clang] [clang] handle fp options in __builtin_convertvector (PR #125522)

2025-02-04 Thread Jakub Ficek via cfe-commits


@@ -5439,3 +5441,21 @@ OpenACCAsteriskSizeExpr *
 OpenACCAsteriskSizeExpr::CreateEmpty(const ASTContext &C) {
   return new (C) OpenACCAsteriskSizeExpr({}, C.IntTy);
 }
+
+ConvertVectorExpr *ConvertVectorExpr::CreateEmpty(const ASTContext &C,
+  bool hasFPFeatures) {
+  void *Mem = C.Allocate(totalSizeToAlloc(hasFPFeatures),
+ alignof(ConvertVectorExpr));
+  return new (Mem) ConvertVectorExpr(hasFPFeatures, EmptyShell());
+}
+
+ConvertVectorExpr *ConvertVectorExpr::Create(
+const ASTContext &C, Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType,
+ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc,
+SourceLocation RParenLoc, FPOptionsOverride FPFeatures) {
+  bool HasFPFeatures = FPFeatures.requiresTrailingStorage();

ficol wrote:

All exprs that implement FPOptionsOverride do this check this way e.g.:
https://github.com/llvm/llvm-project/blob/fc40a0fddd830aa1fdfaafa1618acc5c2d0ee5fa/clang/lib/AST/Expr.cpp#L4961-L4968

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


[clang] [Clang] disallow attributes on void parameters (PR #124920)

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


@@ -3832,6 +3832,9 @@ def warn_type_attribute_wrong_type : Warning<
   "'%0' only applies to %select{function|pointer|"
   "Objective-C object or block pointer}1 types; type here is %2">,
   InGroup;
+def warn_attribute_on_void_param: Warning<
+  "attribute %0 cannot be applied to a 'void' parameter">,

erichkeane wrote:

disregard, in the C++ grammar it is a special case in as a parameter.

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


[clang] [clang] print correct context for diagnostics suppressed by deduction (PR #125453)

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


@@ -1909,7 +1909,19 @@ class Sema final : public SemaBase {
   /// '\#pragma clang attribute push' directives to the given declaration.
   void AddPragmaAttributes(Scope *S, Decl *D);
 
-  void PrintPragmaAttributeInstantiationPoint();
+  using DiagFuncRef =
+  llvm::function_ref;
+  auto getDefaultDiagFunc() {
+return [this](SourceLocation Loc, PartialDiagnostic PD) {
+  DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));

erichkeane wrote:

ah!  Thanks for the clarifiation.  Can we get a comment to that effect?

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


[clang] [clang] print correct context for diagnostics suppressed by deduction (PR #125453)

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


@@ -1909,7 +1909,19 @@ class Sema final : public SemaBase {
   /// '\#pragma clang attribute push' directives to the given declaration.
   void AddPragmaAttributes(Scope *S, Decl *D);
 
-  void PrintPragmaAttributeInstantiationPoint();
+  using DiagFuncRef =
+  llvm::function_ref;
+  auto getDefaultDiagFunc() {
+return [this](SourceLocation Loc, PartialDiagnostic PD) {

erichkeane wrote:

`PartialDiagnostic`, or `PDiag` don't actually have a location.  
`PartialDiagnostic` is only the diag-ID, plus up to the full-list (meaning, 
doesn't have to be the full list) of `<<` arguments.  `PartialDiagnosticAt` is 
a `std::pair` for cases where you already know the location, exactly the use 
here.

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


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

2025-02-04 Thread Kinuko Yasuda via cfe-commits

kinu wrote:

Would the alternative that is discussed here mean we want to forward some 
attributes only when they are applicable, something like 
`clang::forwad_lifetimebound`?

Regardless, I think it'd be also good to agree on the use cases we want to 
support in a concrete code snippet (that should also answer to @Xazax-hun 's 
question).  There could also be a question of whether we really should try to 
support variadic templates in the current lifetime-bound too, because we're 
aware that the current semantic itself has a limitation.


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


[clang] [Clang][P1061] Consolidate ResolvedUnpexandedPackExpr into FunctionParmPackExpr (PR #125394)

2025-02-04 Thread via cfe-commits

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


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


[clang] [Clang][P1061] Consolidate ResolvedUnpexandedPackExpr into FunctionParmPackExpr (PR #125394)

2025-02-04 Thread via cfe-commits

cor3ntin wrote:

@ricejasonf Can i merge this for you?

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


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

2025-02-04 Thread Ilya Biryukov via cfe-commits

ilya-biryukov wrote:

> mean we want to forward some attributes only when they are applicable

yes, something like that. And it gets a little tricky, because it's not that we 
want to forward only attributes from one decl to another, it's many decls 
(forwarding function itself and its parameters) to many decls (function we're 
forwarding too and its parameters). If we start talking about 
`lifetime_capture_by()`, things get even more tricky because the attribute 
itself is parametrized by the the "target" and we should somehow be able to 
connect that "target" to something else in the context we are forwarding to.

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


[clang] [analyzer] Add option assume-one-iteration (PR #125494)

2025-02-04 Thread Donát Nagy via cfe-commits


@@ -294,6 +294,16 @@ ANALYZER_OPTION(
 bool, ShouldUnrollLoops, "unroll-loops",
 "Whether the analysis should try to unroll loops with known bounds.", 
false)
 
+ANALYZER_OPTION(
+bool, ShouldAssumeOneIteration, "assume-one-iteration",
+"Whether the analyzer should always assume at least one iteration in "

NagyDonat wrote:

> How about the naive "assume-at-least-one-iteration"?

I felt that it's a bit too long, but if you prefer it (and other reviewers 
aren't opposed), then I can accept it.

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


[clang] Thread Safety Analysis: Support warning on obtaining address of guarded variables (PR #123063)

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

melver wrote:

FWIW, the Linux kernel integration (draft, WIP) currently lives here: 
https://github.com/google/kernel-sanitizers/tree/cap-analysis
It currently enables -Wthread-safety-addressof if available. Thus far, I have 
not found any false positives due to -Wthread-safety-addressof in the 2 
subsystems I converted over (more to follow).

And I want to re-iterate that without -Wthread-safety-addressof, the feature's 
coverage is significantly reduced, and I predict it to be one of the first 
complaints in later review.

Kindly take another look.

cc @bvanassche

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


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

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


@@ -365,13 +388,22 @@ namespace {
 
 void runChecker(CheckerManager::CheckBindFunc checkFn,
 NodeBuilder &Bldr, ExplodedNode *Pred) {
+  llvm::TimeTraceScope TimeScope(checkerScopeName("Bind", 
checkFn.Checker));
   const ProgramPoint &L = PP.withTag(checkFn.Checker);
   CheckerContext C(Bldr, Eng, Pred, L);
 
   checkFn(Loc, Val, S, C);
 }
   };
 
+  llvm::TimeTraceMetadata getTimeTraceBindMetadata(SVal val) {
+assert(llvm::timeTraceProfilerEnabled());
+std::string name;

necto wrote:

Sorry for overlooking these
4cc3be9658c4 [NFC] Uppercase some variable names


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


[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

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


@@ -35,6 +36,54 @@ using namespace llvm;
 namespace cir {
 namespace direct {
 
+class CIRAttrToValue : public CirAttrVisitor {
+public:
+  mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
+  mlir::Attribute attr,
+  mlir::ConversionPatternRewriter &rewriter,
+  const mlir::TypeConverter *converter,
+  mlir::DataLayout const &dataLayout) {
+return visit(attr, parentOp, rewriter, converter, dataLayout);
+  }
+
+  mlir::Value visitCirIntAttr(cir::IntAttr intAttr, mlir::Operation *parentOp,
+  mlir::ConversionPatternRewriter &rewriter,

erichkeane wrote:

Instead of all the arguments, typically with the visitors, we have them become 
members of the visitor itself.  So this would be:

```
mlir::Value visitCirIntAttr(cir::IntAttr intAttr) {
  Location Loc parentOp->getLoc();
return rewriter.create(
loc, converter->convertType(intAttr.getType()), intAttr.getValue());
}
```

still, but they would be members instead.


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


[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

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


@@ -35,6 +36,54 @@ using namespace llvm;
 namespace cir {
 namespace direct {
 
+class CIRAttrToValue : public CirAttrVisitor {
+public:
+  mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
+  mlir::Attribute attr,
+  mlir::ConversionPatternRewriter &rewriter,
+  const mlir::TypeConverter *converter,
+  mlir::DataLayout const &dataLayout) {
+return visit(attr, parentOp, rewriter, converter, dataLayout);
+  }
+
+  mlir::Value visitCirIntAttr(cir::IntAttr intAttr, mlir::Operation *parentOp,
+  mlir::ConversionPatternRewriter &rewriter,
+  const mlir::TypeConverter *converter,
+  mlir::DataLayout const &dataLayout) {
+auto loc = parentOp->getLoc();

erichkeane wrote:

```suggestion
Location loc = parentOp->getLoc();
```

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


[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

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


@@ -84,6 +138,19 @@ mlir::LogicalResult 
CIRToLLVMGlobalOpLowering::matchAndRewrite(
   SmallVector attributes;
 
   if (init.has_value()) {
+auto setupRegionInitializedLLVMGlobalOp = [&]() {

erichkeane wrote:

I think I'd prefer this get extracted to a function in an anonymous namespace 
(or a static function).  It does quite a lot of work for a lambda.

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


[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

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


@@ -0,0 +1,51 @@
+#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+#define LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+
+#include "clang/CIR/Dialect/IR/CIRAttrs.h"
+
+namespace cir {
+
+template  class CirAttrVisitor {
+public:
+  // FIXME: Create a TableGen list to automatically handle new attributes
+  template 
+  RetTy visit(mlir::Attribute attr, Args &&...args) {
+if (const auto intAttr = mlir::dyn_cast(attr))
+  return static_cast(this)->visitCirIntAttr(
+  intAttr, std::forward(args)...);
+if (const auto fltAttr = mlir::dyn_cast(attr))
+  return static_cast(this)->visitCirFPAttr(
+  fltAttr, std::forward(args)...);
+if (const auto ptrAttr = mlir::dyn_cast(attr))
+  return static_cast(this)->visitCirConstPtrAttr(
+  ptrAttr, std::forward(args)...);
+llvm_unreachable("unhandled attribute type");
+  }
+
+  // If the implementation chooses not to implement a certain visit
+  // method, fall back to the parent.
+  template 
+  RetTy visitCirIntAttr(cir::IntAttr attr, Args &&...args) {
+return static_cast(this)->visitCirAttr(

erichkeane wrote:

These will cause a stack overflow, as they end up calling themselves. 

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


[clang] [Clang][Sema] Fix wrong initialization kind when handling initializing structured bindings from an array with direct-list-initialization (PR #124793)

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

https://github.com/zwuis updated 
https://github.com/llvm/llvm-project/pull/124793

>From 16596add29b63ee0282e026dec7b1d5946863113 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Wed, 29 Jan 2025 00:38:15 +0800
Subject: [PATCH 1/4] Fix wrong initialization kind

---
 clang/lib/Sema/SemaInit.cpp|  5 +++--
 clang/test/SemaCXX/cxx1z-decomposition.cpp | 21 ++---
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index b95cbbf4222056..5552fce55f1310 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4861,8 +4861,9 @@ static void TryListInitialization(Sema &S,
 S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) 
&&
 "Deduced to other type?");
 TryArrayCopy(S,
- InitializationKind::CreateCopy(Kind.getLocation(),
-InitList->getLBraceLoc()),
+ InitializationKind::CreateDirect(Kind.getLocation(),
+  InitList->getLBraceLoc(),
+  
InitList->getRBraceLoc()),
  Entity, SubInit[0], DestType, Sequence,
  TreatUnavailableAsInvalid);
 if (Sequence)
diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index a8914fe4e9cd82..b3d98e44990f61 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -200,38 +200,37 @@ namespace lambdas {
 
 namespace by_value_array_copy {
   struct explicit_copy {
-explicit_copy() = default; // expected-note 2{{candidate constructor not 
viable: requires 0 arguments, but 1 was provided}}
-explicit explicit_copy(const explicit_copy&) = default; // expected-note 
2{{explicit constructor is not a candidate}}
+explicit_copy() = default; // expected-note {{candidate constructor not 
viable: requires 0 arguments, but 1 was provided}}
+explicit explicit_copy(const explicit_copy&) = default; // expected-note 
{{explicit constructor is not a candidate}}
   };
 
   constexpr int direct_initialization_for_elements() {
 explicit_copy ec_arr[2];
 auto [a1, b1](ec_arr);
+auto [a2, b2]{ec_arr};
 
 int arr[3]{1, 2, 3};
-auto [a2, b2, c2](arr);
+auto [a3, b3, c3](arr);
+auto [a4, b4, c4]{arr}; // GH31813
 arr[0]--;
-return a2 + b2 + c2 + arr[0];
+return a3 + b3 + c3 + a4 + b4 + c4 + arr[0];
   }
-  static_assert(direct_initialization_for_elements() == 6);
+  static_assert(direct_initialization_for_elements() == 12);
 
   constexpr int copy_initialization_for_elements() {
 int arr[2]{4, 5};
 auto [a1, b1] = arr;
-auto [a2, b2]{arr}; // GH31813
 arr[0] = 0;
-return a1 + b1 + a2 + b2 + arr[0];
+return a1 + b1 + arr[0];
   }
-  static_assert(copy_initialization_for_elements() == 18);
+  static_assert(copy_initialization_for_elements() == 9);
 
   void copy_initialization_for_elements_with_explicit_copy_ctor() {
 explicit_copy ec_arr[2];
 auto [a1, b1] = ec_arr; // expected-error {{no matching constructor for 
initialization of 'explicit_copy[2]'}}
-auto [a2, b2]{ec_arr}; // expected-error {{no matching constructor for 
initialization of 'explicit_copy[2]'}}
 
 // Test prvalue
 using T = explicit_copy[2];
-auto [a3, b3] = T{};
-auto [a4, b4]{T{}};
+auto [a2, b2] = T{};
   }
 } // namespace by_value_array_copy

>From ad033c917db457ebe68b4556a482e9ba56b4746d Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Wed, 29 Jan 2025 10:28:21 +0800
Subject: [PATCH 2/4] Make tests more clear

---
 clang/test/SemaCXX/cxx1z-decomposition.cpp | 39 ++
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index b3d98e44990f61..95c64bc3b8bff6 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -204,33 +204,28 @@ namespace by_value_array_copy {
 explicit explicit_copy(const explicit_copy&) = default; // expected-note 
{{explicit constructor is not a candidate}}
   };
 
-  constexpr int direct_initialization_for_elements() {
-explicit_copy ec_arr[2];
-auto [a1, b1](ec_arr);
-auto [a2, b2]{ec_arr};
-
-int arr[3]{1, 2, 3};
-auto [a3, b3, c3](arr);
-auto [a4, b4, c4]{arr}; // GH31813
-arr[0]--;
-return a3 + b3 + c3 + a4 + b4 + c4 + arr[0];
-  }
-  static_assert(direct_initialization_for_elements() == 12);
+  constexpr int simple_array_elements() {
+int arr[2]{1, 2};
+
+auto [a1, a2] = arr;
+auto [b1, b2](arr);
+auto [c1, c2]{arr}; // GH31813
 
-  constexpr int copy_initialization_for_elements() {
-int arr[2]{4, 5};
-auto [a1, b1] = arr;
 arr[0] = 0;
-return a1 + b1 + arr[0];
+  

[clang] [Clang][Sema] Fix wrong initialization kind when handling initializing structured bindings from an array with direct-list-initialization (PR #124793)

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

https://github.com/zwuis updated 
https://github.com/llvm/llvm-project/pull/124793

>From 16596add29b63ee0282e026dec7b1d5946863113 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Wed, 29 Jan 2025 00:38:15 +0800
Subject: [PATCH 1/4] Fix wrong initialization kind

---
 clang/lib/Sema/SemaInit.cpp|  5 +++--
 clang/test/SemaCXX/cxx1z-decomposition.cpp | 21 ++---
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index b95cbbf4222056..5552fce55f1310 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -4861,8 +4861,9 @@ static void TryListInitialization(Sema &S,
 S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) 
&&
 "Deduced to other type?");
 TryArrayCopy(S,
- InitializationKind::CreateCopy(Kind.getLocation(),
-InitList->getLBraceLoc()),
+ InitializationKind::CreateDirect(Kind.getLocation(),
+  InitList->getLBraceLoc(),
+  
InitList->getRBraceLoc()),
  Entity, SubInit[0], DestType, Sequence,
  TreatUnavailableAsInvalid);
 if (Sequence)
diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index a8914fe4e9cd82..b3d98e44990f61 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -200,38 +200,37 @@ namespace lambdas {
 
 namespace by_value_array_copy {
   struct explicit_copy {
-explicit_copy() = default; // expected-note 2{{candidate constructor not 
viable: requires 0 arguments, but 1 was provided}}
-explicit explicit_copy(const explicit_copy&) = default; // expected-note 
2{{explicit constructor is not a candidate}}
+explicit_copy() = default; // expected-note {{candidate constructor not 
viable: requires 0 arguments, but 1 was provided}}
+explicit explicit_copy(const explicit_copy&) = default; // expected-note 
{{explicit constructor is not a candidate}}
   };
 
   constexpr int direct_initialization_for_elements() {
 explicit_copy ec_arr[2];
 auto [a1, b1](ec_arr);
+auto [a2, b2]{ec_arr};
 
 int arr[3]{1, 2, 3};
-auto [a2, b2, c2](arr);
+auto [a3, b3, c3](arr);
+auto [a4, b4, c4]{arr}; // GH31813
 arr[0]--;
-return a2 + b2 + c2 + arr[0];
+return a3 + b3 + c3 + a4 + b4 + c4 + arr[0];
   }
-  static_assert(direct_initialization_for_elements() == 6);
+  static_assert(direct_initialization_for_elements() == 12);
 
   constexpr int copy_initialization_for_elements() {
 int arr[2]{4, 5};
 auto [a1, b1] = arr;
-auto [a2, b2]{arr}; // GH31813
 arr[0] = 0;
-return a1 + b1 + a2 + b2 + arr[0];
+return a1 + b1 + arr[0];
   }
-  static_assert(copy_initialization_for_elements() == 18);
+  static_assert(copy_initialization_for_elements() == 9);
 
   void copy_initialization_for_elements_with_explicit_copy_ctor() {
 explicit_copy ec_arr[2];
 auto [a1, b1] = ec_arr; // expected-error {{no matching constructor for 
initialization of 'explicit_copy[2]'}}
-auto [a2, b2]{ec_arr}; // expected-error {{no matching constructor for 
initialization of 'explicit_copy[2]'}}
 
 // Test prvalue
 using T = explicit_copy[2];
-auto [a3, b3] = T{};
-auto [a4, b4]{T{}};
+auto [a2, b2] = T{};
   }
 } // namespace by_value_array_copy

>From ad033c917db457ebe68b4556a482e9ba56b4746d Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Wed, 29 Jan 2025 10:28:21 +0800
Subject: [PATCH 2/4] Make tests more clear

---
 clang/test/SemaCXX/cxx1z-decomposition.cpp | 39 ++
 1 file changed, 17 insertions(+), 22 deletions(-)

diff --git a/clang/test/SemaCXX/cxx1z-decomposition.cpp 
b/clang/test/SemaCXX/cxx1z-decomposition.cpp
index b3d98e44990f61..95c64bc3b8bff6 100644
--- a/clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ b/clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -204,33 +204,28 @@ namespace by_value_array_copy {
 explicit explicit_copy(const explicit_copy&) = default; // expected-note 
{{explicit constructor is not a candidate}}
   };
 
-  constexpr int direct_initialization_for_elements() {
-explicit_copy ec_arr[2];
-auto [a1, b1](ec_arr);
-auto [a2, b2]{ec_arr};
-
-int arr[3]{1, 2, 3};
-auto [a3, b3, c3](arr);
-auto [a4, b4, c4]{arr}; // GH31813
-arr[0]--;
-return a3 + b3 + c3 + a4 + b4 + c4 + arr[0];
-  }
-  static_assert(direct_initialization_for_elements() == 12);
+  constexpr int simple_array_elements() {
+int arr[2]{1, 2};
+
+auto [a1, a2] = arr;
+auto [b1, b2](arr);
+auto [c1, c2]{arr}; // GH31813
 
-  constexpr int copy_initialization_for_elements() {
-int arr[2]{4, 5};
-auto [a1, b1] = arr;
 arr[0] = 0;
-return a1 + b1 + arr[0];
+  

[clang] [libclang] Migrate away from PointerUnion::dyn_cast (NFC) (PR #125631)

2025-02-04 Thread Nikita Popov via cfe-commits

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


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


[clang] [Win/X86] Make _m_prefetch[w] builtins to avoid winnt.h conflicts (PR #115099)

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

zmodem wrote:

The build is still broken (e.g. 
https://lab.llvm.org/buildbot/#/builders/63/builds/3861). I'll back it out.

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


[clang] [clang][Sema] Add diagnostic note for reference of function-like macros requiring without parentheses (PR #123495)

2025-02-04 Thread via cfe-commits

StarOne01 wrote:

I did find what was wrong

When we try to correct typos, we seem to do it by looking over all the 
identifiers in the Context which includes the **typo itself!**

```cpp
// clang/lib/Sema/SemaLookup.cpp
for (const auto &I : Context.Idents)
Consumer->FoundName(I.getKey());
```
as the typo and the correction (the typo too) are identical, **a correction is 
added**. 

- This always happen if a typo is encountered.

To avoid this, i tried to check for identical identifiers, but in some cases 
identical identifiers are a necessary correction too for example when:  

- a unqualified identifier without the nested namespace.
- a member call without it's obj, etc...

because of this ambiguity, the ` *out` is always defined and non-empty when a 
typo is encountered, which is our problem here.

i'm stuck, any help with fixing it would be appreciated!

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


[clang] [llvm] [clangd] Add support for the c2000 architecture (PR #125663)

2025-02-04 Thread via cfe-commits

https://github.com/student433 created 
https://github.com/llvm/llvm-project/pull/125663

Fixes #114979, adding support for the cl2000 compiler to the clang frontend to 
get clangd working as discussed in 
https://discourse.llvm.org/t/ti-c2000-target-not-supported-in-clangd-lsp/83015

>From 5906c0f4090e2e9b790401c34ba70eedcbb7f8ae Mon Sep 17 00:00:00 2001
From: Aditya Grewal 
Date: Tue, 4 Feb 2025 10:59:32 +0100
Subject: [PATCH] [clangd] Add support for the c2000 architecture

---
 clang/include/clang/Driver/Driver.h|   6 +-
 clang/include/clang/Driver/Options.h   |   1 +
 clang/include/clang/Driver/Options.td  |  74 -
 clang/lib/Basic/CMakeLists.txt |   1 +
 clang/lib/Basic/Targets.cpp|   4 +
 clang/lib/Basic/Targets/C2000.cpp  | 356 +
 clang/lib/Basic/Targets/C2000.h| 100 ++
 clang/lib/Driver/CMakeLists.txt|   1 +
 clang/lib/Driver/Driver.cpp|  13 +
 clang/lib/Driver/ToolChain.cpp |   1 +
 clang/lib/Driver/ToolChains/Arch/C2000.cpp |  85 +
 clang/lib/Driver/ToolChains/Arch/C2000.h   |  22 ++
 clang/lib/Driver/ToolChains/CommonArgs.cpp |   5 +
 llvm/include/llvm/TargetParser/Triple.h|   1 +
 llvm/lib/TargetParser/Triple.cpp   |   7 +
 15 files changed, 666 insertions(+), 11 deletions(-)
 create mode 100644 clang/lib/Basic/Targets/C2000.cpp
 create mode 100644 clang/lib/Basic/Targets/C2000.h
 create mode 100644 clang/lib/Driver/ToolChains/Arch/C2000.cpp
 create mode 100644 clang/lib/Driver/ToolChains/Arch/C2000.h

diff --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index f4a52cc529b79cd..55da823598f9b1b 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -107,7 +107,8 @@ class Driver {
 CPPMode,
 CLMode,
 FlangMode,
-DXCMode
+DXCMode,
+C2000Mode
   } Mode;
 
   enum SaveTempsMode {
@@ -253,6 +254,9 @@ class Driver {
   /// Whether the driver should follow dxc.exe like behavior.
   bool IsDXCMode() const { return Mode == DXCMode; }
 
+  // Whether the driver should follow cl2000.exe like behaviour.
+  bool IsC2000Mode() const { return Mode == C2000Mode; }
+
   /// Only print tool bindings, don't build any jobs.
   LLVM_PREFERRED_TYPE(bool)
   unsigned CCCPrintBindings : 1;
diff --git a/clang/include/clang/Driver/Options.h 
b/clang/include/clang/Driver/Options.h
index 0797410e9940e22..1613810a5bf741c 100644
--- a/clang/include/clang/Driver/Options.h
+++ b/clang/include/clang/Driver/Options.h
@@ -39,6 +39,7 @@ enum ClangVisibility {
   FlangOption = (1 << 4),
   FC1Option = (1 << 5),
   DXCOption = (1 << 6),
+  CL2000Option = (1 << 7)
 };
 
 enum ID {
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d38dd2b4e3cf09f..44ce3c3413b09be 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -97,6 +97,10 @@ def FC1Option : OptionVisibility;
 // are made available when the driver is running in DXC compatibility mode.
 def DXCOption : OptionVisibility;
 
+// CL2000Option - This is a cl2000.exe compatibility option. Options with this 
flag
+// are made available when the driver is running in cl2000 compatibility mode.
+def CL2000Option : OptionVisibility;
+
 /
 // Docs
 
@@ -201,6 +205,9 @@ def hlsl_Group : OptionGroup<"">, 
Group,
DocName<"HLSL options">,
Visibility<[ClangOption]>;
 
+def cl2000_group : OptionGroup<"">,
+Visibility<[CL2000Option]>;
+
 // Feature groups - these take command line options that correspond directly to
 // target specific features and can be translated directly from command line
 // options.
@@ -672,7 +679,7 @@ class InternalDriverOpt : Group,
   Flags<[NoXarchOption, HelpHidden]>;
 def driver_mode : Joined<["--"], "driver-mode=">, Group,
   Flags<[NoXarchOption, HelpHidden]>,
-  Visibility<[ClangOption, FlangOption, CLOption, DXCOption]>,
+  Visibility<[ClangOption, FlangOption, CLOption, DXCOption, CL2000Option]>,
   HelpText<"Set the driver mode to either 'gcc', 'g++', 'cpp', 'cl' or 
'flang'">;
 def rsp_quoting : Joined<["--"], "rsp-quoting=">, Group,
   Flags<[NoXarchOption, HelpHidden]>,
@@ -843,7 +850,7 @@ def C : Flag<["-"], "C">, Visibility<[ClangOption, 
CC1Option]>,
 HelpText<"Include comments in preprocessed output">,
 MarshallingInfoFlag>;
 def D : JoinedOrSeparate<["-"], "D">, Group,
-Visibility<[ClangOption, CC1Option, FlangOption, FC1Option, DXCOption]>,
+Visibility<[ClangOption, CC1Option, FlangOption, FC1Option, DXCOption, 
CL2000Option]>,
 MetaVarName<"=">,
 HelpText<"Define  to  (or 1 if  omitted)">;
 def E : Flag<["-"], "E">, Flags<[NoXarchOption]>,
@@ -929,7 +936,7 @@ def ObjCXX : Flag<["-"], "ObjC++">, Flags<[NoXarchOption]>,
 def ObjC : Flag<["-"], "ObjC">, Flags<[NoXarchOption]>,
   HelpText<"Treat source input files as Objective-C inputs"

[clang] [analyzer] Remove some false negatives in StackAddrEscapeChecker (PR #125638)

2025-02-04 Thread via cfe-commits

llvmbot wrote:




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

Author: Michael Flanders (Flandini)


Changes

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

Previously, when the StackAddrEscapeChecker checked return values, it did not 
scan into the structure of the return SVal. Now it does, and we can catch some 
more false negatives that were already mocked out in the tests in addition to 
those mentioned in https://github.com/llvm/llvm-project/issues/123459.

The warning message at the moment for these newly caught leaks is not great. I 
think they would be better if they had a better trace of why and how the region 
leaks. If y'all are happy with these changes, I would try to improve these 
warnings and work on normalizing this SVal checking on the `checkEndFunction` 
side of the checker also.

Two of the stack address leak test cases now have two warnings, one warning 
from return expression checking and another from` checkEndFunction` 
`iterBindings` checking. For these two cases, I prefer the warnings from the 
return expression checking, but I couldn't figure out a way to drop the 
`checkEndFunction` without breaking other `checkEndFunction` warnings that we 
do want. Thoughts here?

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


3 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp 
(+135-53) 
- (modified) clang/test/Analysis/stack-addr-ps.cpp (+55-20) 
- (modified) clang/test/Analysis/stackaddrleak.cpp (+2-2) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
index f4de3b500499c48..86f0949994cf6b9 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -54,8 +54,8 @@ class StackAddrEscapeChecker
   CheckerContext &C) const;
   void checkAsyncExecutedBlockCaptures(const BlockDataRegion &B,
CheckerContext &C) const;
-  void EmitStackError(CheckerContext &C, const MemRegion *R,
-  const Expr *RetE) const;
+  void EmitReturnLeakError(CheckerContext &C, const MemRegion *LeakedRegion,
+   const Expr *RetE) const;
   bool isSemaphoreCaptured(const BlockDecl &B) const;
   static SourceRange genName(raw_ostream &os, const MemRegion *R,
  ASTContext &Ctx);
@@ -147,9 +147,22 @@ StackAddrEscapeChecker::getCapturedStackRegions(const 
BlockDataRegion &B,
   return Regions;
 }
 
-void StackAddrEscapeChecker::EmitStackError(CheckerContext &C,
-const MemRegion *R,
-const Expr *RetE) const {
+static void EmitReturnedAsPartOfError(llvm::raw_ostream &OS, SVal ReturnedVal,
+  const MemRegion *LeakedRegion) {
+  if (const MemRegion *ReturnedRegion = ReturnedVal.getAsRegion()) {
+if (isa(ReturnedRegion)) {
+  OS << " is captured by a returned block";
+  return;
+}
+  }
+
+  // Generic message
+  OS << " returned to caller";
+}
+
+void StackAddrEscapeChecker::EmitReturnLeakError(CheckerContext &C,
+ const MemRegion *R,
+ const Expr *RetE) const {
   ExplodedNode *N = C.generateNonFatalErrorNode();
   if (!N)
 return;
@@ -157,11 +170,15 @@ void 
StackAddrEscapeChecker::EmitStackError(CheckerContext &C,
 BT_returnstack = std::make_unique(
 CheckNames[CK_StackAddrEscapeChecker],
 "Return of address to stack-allocated memory");
+
   // Generate a report for this bug.
   SmallString<128> buf;
   llvm::raw_svector_ostream os(buf);
+
+  // Error message formatting
   SourceRange range = genName(os, R, C.getASTContext());
-  os << " returned to caller";
+  EmitReturnedAsPartOfError(os, C.getSVal(RetE), R);
+
   auto report =
   std::make_unique(*BT_returnstack, os.str(), N);
   report->addRange(RetE->getSourceRange());
@@ -209,30 +226,6 @@ void 
StackAddrEscapeChecker::checkAsyncExecutedBlockCaptures(
   }
 }
 
-void StackAddrEscapeChecker::checkReturnedBlockCaptures(
-const BlockDataRegion &B, CheckerContext &C) const {
-  for (const MemRegion *Region : getCapturedStackRegions(B, C)) {
-if (isNotInCurrentFrame(Region, C))
-  continue;
-ExplodedNode *N = C.generateNonFatalErrorNode();
-if (!N)
-  continue;
-if (!BT_capturedstackret)
-  BT_capturedstackret = std::make_unique(
-  CheckNames[CK_StackAddrEscapeChecker],
-  "Address of stack-allocated memory is captured");
-SmallString<128> Buf;
-llvm::raw_svector_ostream Out(Buf);
-SourceRange Range = genName(Out, Region, C.getASTContext());
-Out << " is captured by a returned block";
-auto Report = 
std::make_unique(*BT_capturedstackret,
- 

[clang] [Clang][Sema] Fix wrong initialization kind when handling initializing structured bindings from an array with direct-list-initialization (PR #124793)

2025-02-04 Thread via cfe-commits

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


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


[clang] [analyzer] Remove some false negatives in StackAddrEscapeChecker (PR #125638)

2025-02-04 Thread Balazs Benics via cfe-commits

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


[clang] [llvm] [clangd] Add support for the c2000 architecture (PR #125663)

2025-02-04 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write 
permissions for the repository. In which case you can instead tag reviewers by 
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a 
review by "ping"ing the PR by adding a comment “Ping”. The common courtesy 
"ping" rate is once a week. Please remember that you are asking for valuable 
time from other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


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

2025-02-04 Thread Oliver Stöneberg via cfe-commits

firewave wrote:

> It should be relatively easy to add, but I don't want to extend the scope of 
> this PR.

Thanks for the explanation. Yes, please don't extend the scope of the change.

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


[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)

2025-02-04 Thread Sinkevich Artem via cfe-commits

https://github.com/ArtSin updated 
https://github.com/llvm/llvm-project/pull/123963

>From 462b70cfc9f9ad3cafc0dbf595ce758181ecb2a5 Mon Sep 17 00:00:00 2001
From: Artem Sinkevich 
Date: Tue, 4 Feb 2025 16:27:51 +0400
Subject: [PATCH] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID

Add support for expanding `%b` in `LLVM_PROFILE_FILE` to the binary ID
(build ID). It can be used with `%m` to avoid its signature collisions.

This is supported on all platforms where writing binary IDs into profiles
is implemented, as the `__llvm_write_binary_ids` function is used.

Fixes #51560.
---
 clang/docs/SourceBasedCodeCoverage.rst|  5 ++
 clang/docs/UsersManual.rst|  5 +-
 compiler-rt/lib/profile/InstrProfilingFile.c  | 58 +--
 .../test/profile/Linux/binary-id-path.c   | 40 +
 4 files changed, 101 insertions(+), 7 deletions(-)
 create mode 100644 compiler-rt/test/profile/Linux/binary-id-path.c

diff --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 73910e134a5891..49bce3b72b45aa 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -94,6 +94,11 @@ directory structure will be created.  Additionally, the 
following special
   not specified (i.e the pattern is "%m"), it's assumed that ``N = 1``. The
   merge pool specifier can only occur once per filename pattern.
 
+* "%b" expands out to the binary ID (build ID). It can be used with "%Nm" to
+  avoid binary signature collisions. To use it, the program should be compiled
+  with the build ID linker option (``--build-id`` for GNU ld or LLD). Linux,
+  Windows and AIX are supported.
+
 * "%c" expands out to nothing, but enables a mode in which profile counter
   updates are continuously synced to a file. This means that if the
   instrumented program crashes, or is killed by a signal, perfect coverage
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 260e84910c6f78..bc0ce3f3ccad07 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2880,7 +2880,8 @@ instrumentation:
environment variable to specify an alternate file. If non-default file name
is specified by both the environment variable and the command line option,
the environment variable takes precedence. The file name pattern specified
-   can include different modifiers: ``%p``, ``%h``, ``%m``, ``%t``, and ``%c``.
+   can include different modifiers: ``%p``, ``%h``, ``%m``, ``%b``, ``%t``, and
+   ``%c``.
 
Any instance of ``%p`` in that file name will be replaced by the process
ID, so that you can easily distinguish the profile output from multiple
@@ -2917,7 +2918,7 @@ instrumentation:
  $ LLVM_PROFILE_FILE="code-%m.profraw" ./code
 
See `this `_ 
section
-   about the ``%t``, and ``%c`` modifiers.
+   about the ``%b``, ``%t``, and ``%c`` modifiers.
 
 3. Combine profiles from multiple runs and convert the "raw" profile format to
the input expected by clang. Use the ``merge`` command of the
diff --git a/compiler-rt/lib/profile/InstrProfilingFile.c 
b/compiler-rt/lib/profile/InstrProfilingFile.c
index bad4cc71801ec4..343063fd6b754f 100644
--- a/compiler-rt/lib/profile/InstrProfilingFile.c
+++ b/compiler-rt/lib/profile/InstrProfilingFile.c
@@ -77,6 +77,7 @@ typedef struct lprofFilename {
   char Hostname[COMPILER_RT_MAX_HOSTLEN];
   unsigned NumPids;
   unsigned NumHosts;
+  unsigned NumBinaryIds;
   /* When in-process merging is enabled, this parameter specifies
* the total number of profile data files shared by all the processes
* spawned from the same binary. By default the value is 1. If merging
@@ -88,8 +89,8 @@ typedef struct lprofFilename {
   ProfileNameSpecifier PNS;
 } lprofFilename;
 
-static lprofFilename lprofCurFilename = {0,   0, 0, {0}, NULL,
- {0}, 0, 0, 0,   PNS_unknown};
+static lprofFilename lprofCurFilename = {0, 0, 0, {0}, NULL,   {0},
+ 0, 0, 0, 0,   PNS_unknown};
 
 static int ProfileMergeRequested = 0;
 static int getProfileFileSizeForMerging(FILE *ProfileFile,
@@ -790,7 +791,7 @@ static int checkBounds(int Idx, int Strlen) {
  * lprofcurFilename structure. */
 static int parseFilenamePattern(const char *FilenamePat,
 unsigned CopyFilenamePat) {
-  int NumPids = 0, NumHosts = 0, I;
+  int NumPids = 0, NumHosts = 0, NumBinaryIds = 0, I;
   char *PidChars = &lprofCurFilename.PidChars[0];
   char *Hostname = &lprofCurFilename.Hostname[0];
   int MergingEnabled = 0;
@@ -855,6 +856,16 @@ static int parseFilenamePattern(const char *FilenamePat,
 FilenamePat);
   return -1;
 }
+  } else if (FilenamePat[I] == 'b') {
+if (!NumBinaryIds++) {
+  /* Check if binary ID does not exist or if its size is 0. */
+  if (__llvm_write_binary_ids(NULL) <= 0) {
+PROF_WARN("Unable 

[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)

2025-02-04 Thread Sinkevich Artem via cfe-commits


@@ -0,0 +1,37 @@
+// REQUIRES: linux
+// RUN: split-file %s %t.dir
+// RUN: %clang_profgen -Wl,--build-id=sha1 -o %t.dir/foo %t.dir/foo.c
+// RUN: %clang_profgen -Wl,--build-id=sha1 -o %t.dir/bar %t.dir/bar.c
+
+// Check that foo and bar have the same signatures.
+// RUN: rm -rf %t.profdir
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.profraw %run %t.dir/foo
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.profraw %run %t.dir/bar 2>&1 | 
FileCheck %s --check-prefix=MERGE-ERROR
+
+// Check that foo and bar have different binary IDs.
+// RUN: rm -rf %t.profdir %t.profdata
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%b.profraw %run %t.dir/foo
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%b.profraw %run %t.dir/bar
+// RUN: llvm-profdata merge -o %t.profdata %t.profdir
+// RUN: llvm-profdata show %t.profdata | FileCheck %s --check-prefix=BINARY-ID

ArtSin wrote:

Added check for 2 binary IDs in merged profdata

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


[clang] [compiler-rt] [profile] Add `%b` `LLVM_PROFILE_FILE` option for binary ID (PR #123963)

2025-02-04 Thread Sinkevich Artem via cfe-commits


@@ -855,6 +856,15 @@ static int parseFilenamePattern(const char *FilenamePat,
 FilenamePat);
   return -1;
 }
+  } else if (FilenamePat[I] == 'b') {
+if (!NumBinaryIds++) {
+  if (__llvm_write_binary_ids(NULL) <= 0) {

ArtSin wrote:

Done

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


[clang] [llvm] [AMDGPU][True16][MC][CodeGen] true16 for v_alignbyte_b32 (PR #125706)

2025-02-04 Thread Brox Chen via cfe-commits

https://github.com/broxigarchen created 
https://github.com/llvm/llvm-project/pull/125706

Support true16 format for v_alignbyte_b32 in MC and CodeGen

>From 1e63e17cfe20f809045e7209a870b24bd15b5a91 Mon Sep 17 00:00:00 2001
From: guochen2 
Date: Thu, 12 Dec 2024 13:33:14 -0500
Subject: [PATCH 1/5] True16 for v_alignbyte_b32 in MC

---
 clang/lib/CodeGen/CGBuiltin.cpp   |  8 
 llvm/include/llvm/IR/IntrinsicsAMDGPU.td  |  2 +-
 llvm/lib/Target/AMDGPU/VOP3Instructions.td|  8 +++-
 llvm/test/MC/AMDGPU/gfx11_asm_vop3.s  | 11 +++--
 llvm/test/MC/AMDGPU/gfx11_asm_vop3_dpp16.s| 42 +--
 llvm/test/MC/AMDGPU/gfx11_asm_vop3_dpp8.s | 17 ++--
 llvm/test/MC/AMDGPU/gfx12_asm_vop3.s  |  3 ++
 llvm/test/MC/AMDGPU/gfx12_asm_vop3_dpp16.s|  3 ++
 llvm/test/MC/AMDGPU/gfx12_asm_vop3_dpp8.s |  3 ++
 .../Disassembler/AMDGPU/gfx11_dasm_vop3.txt   | 16 ++-
 .../AMDGPU/gfx11_dasm_vop3_dpp16.txt  | 31 +++---
 .../AMDGPU/gfx11_dasm_vop3_dpp8.txt   | 16 ++-
 .../Disassembler/AMDGPU/gfx12_dasm_vop3.txt   | 16 ++-
 .../AMDGPU/gfx12_dasm_vop3_dpp16.txt  | 36 +---
 .../AMDGPU/gfx12_dasm_vop3_dpp8.txt   | 21 --
 15 files changed, 190 insertions(+), 43 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 11fa295dad9524..8a02eeb64fd22a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19912,6 +19912,14 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   llvm::AtomicOrdering AO = llvm::AtomicOrdering::SequentiallyConsistent;
   llvm::SyncScope::ID SSID;
   switch (BuiltinID) {
+  case AMDGPU::BI__builtin_amdgcn_alignbyte: {
+llvm::Value *Src0 = EmitScalarExpr(E->getArg(0));
+llvm::Value *Src1 = EmitScalarExpr(E->getArg(1));
+llvm::Value *Src2 = EmitScalarExpr(E->getArg(2));
+llvm::Function *F =
+CGM.getIntrinsic(Intrinsic::amdgcn_alignbyte, Src2->getType());
+return Builder.CreateCall(F, {Src0, Src1, Src2});
+  }
   case AMDGPU::BI__builtin_amdgcn_div_scale:
   case AMDGPU::BI__builtin_amdgcn_div_scalef: {
 // Translate from the intrinsics's struct return to the builtin's out
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index eb7bde69994913..59a7480103a4f4 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -2353,7 +2353,7 @@ def int_amdgcn_writelane :
 >;
 
 def int_amdgcn_alignbyte : ClangBuiltin<"__builtin_amdgcn_alignbyte">,
-  DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+  DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, 
llvm_anyint_ty],
   [IntrNoMem, IntrSpeculatable]
 >;
 
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td 
b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index ce73e0ca361d9b..f567c528b76df7 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -212,7 +212,11 @@ defm V_BFE_U32 : VOP3Inst <"v_bfe_u32", 
VOP3_Profile, AMDGP
 defm V_BFE_I32 : VOP3Inst <"v_bfe_i32", VOP3_Profile, 
AMDGPUbfe_i32>;
 defm V_BFI_B32 : VOP3Inst <"v_bfi_b32", VOP3_Profile, 
AMDGPUbfi>;
 defm V_ALIGNBIT_B32 : VOP3Inst <"v_alignbit_b32", 
VOP3_Profile, fshr>;
-defm V_ALIGNBYTE_B32 : VOP3Inst <"v_alignbyte_b32", 
VOP3_Profile, int_amdgcn_alignbyte>;
+defm V_ALIGNBYTE_B32 : VOP3Inst_t16_with_profiles <"v_alignbyte_b32",
+   
VOP3_Profile,
+   
VOP3_Profile_True16,
+   
VOP3_Profile_Fake16,
+   int_amdgcn_alignbyte>;
 
 // XXX - No FPException seems suspect but manual doesn't say it does
 let mayRaiseFPException = 0 in {
@@ -1690,7 +1694,7 @@ defm V_FMA_F32 : 
VOP3_Realtriple_gfx11_gfx12<0x213>;
 defm V_FMA_F64 : VOP3_Real_Base_gfx11_gfx12<0x214>;
 defm V_LERP_U8 : VOP3_Realtriple_gfx11_gfx12<0x215>;
 defm V_ALIGNBIT_B32: VOP3_Realtriple_gfx11_gfx12<0x216>;
-defm V_ALIGNBYTE_B32   : VOP3_Realtriple_gfx11_gfx12<0x217>;
+defm V_ALIGNBYTE_B32   : VOP3_Realtriple_t16_and_fake16_gfx11_gfx12<0x217, 
"v_alignbyte_b32">;
 defm V_MULLIT_F32  : VOP3_Realtriple_gfx11_gfx12<0x218>;
 defm V_MIN3_F32: VOP3_Realtriple_gfx11<0x219>;
 defm V_MIN3_I32: VOP3_Realtriple_gfx11_gfx12<0x21a>;
diff --git a/llvm/test/MC/AMDGPU/gfx11_asm_vop3.s 
b/llvm/test/MC/AMDGPU/gfx11_asm_vop3.s
index e55fbfc6e18c8c..857a1359b00d99 100644
--- a/llvm/test/MC/AMDGPU/gfx11_asm_vop3.s
+++ b/llvm/test/MC/AMDGPU/gfx11_asm_vop3.s
@@ -461,11 +461,11 @@ v_alignbyte_b32 v5, s1, v255, s3
 v_alignbyte_b32 v5, s105, s105, s105
 // GFX11: v_alignbyte_b32 v5, s105, s105, s105; encoding: 
[0x05,0x00,0x17,0xd6,0x69,0xd2,0xa4,0x01]
 
-v_alignbyte

[clang] [llvm] [AMDGPU][True16][MC][CodeGen] true16 for v_alignbyte_b32 (PR #125706)

2025-02-04 Thread Brox Chen via cfe-commits

broxigarchen wrote:

Hi @Sisyph @kosarev @arsenm The previous PR of this patch 
https://github.com/llvm/llvm-project/pull/119750 is stucked and the new commit 
is not able be displayed.

Closed and reopen it here.

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


[clang] [llvm] [AMDGPU][True16][MC][CodeGen] true16 for v_alignbyte_b32 (PR #125706)

2025-02-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: Brox Chen (broxigarchen)


Changes

Support true16 format for v_alignbyte_b32 in MC and CodeGen

---

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


14 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/VOP3Instructions.td (+26-1) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.alignbyte.ll (+116-2) 
- (modified) llvm/test/MC/AMDGPU/gfx11_asm_vop3.s (+7-4) 
- (modified) llvm/test/MC/AMDGPU/gfx11_asm_vop3_dpp16.s (+30-12) 
- (modified) llvm/test/MC/AMDGPU/gfx11_asm_vop3_dpp8.s (+13-4) 
- (modified) llvm/test/MC/AMDGPU/gfx12_asm_vop3.s (+3) 
- (modified) llvm/test/MC/AMDGPU/gfx12_asm_vop3_dpp16.s (+3) 
- (modified) llvm/test/MC/AMDGPU/gfx12_asm_vop3_dpp8.s (+3) 
- (modified) llvm/test/MC/Disassembler/AMDGPU/gfx11_dasm_vop3.txt (+14-2) 
- (modified) llvm/test/MC/Disassembler/AMDGPU/gfx11_dasm_vop3_dpp16.txt (+26-5) 
- (modified) llvm/test/MC/Disassembler/AMDGPU/gfx11_dasm_vop3_dpp8.txt (+14-2) 
- (modified) llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vop3.txt (+14-2) 
- (modified) llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vop3_dpp16.txt (+30-6) 
- (modified) llvm/test/MC/Disassembler/AMDGPU/gfx12_dasm_vop3_dpp8.txt (+18-3) 


``diff
diff --git a/llvm/lib/Target/AMDGPU/VOP3Instructions.td 
b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
index ce73e0ca361d9b..afafc2ecccfafe 100644
--- a/llvm/lib/Target/AMDGPU/VOP3Instructions.td
+++ b/llvm/lib/Target/AMDGPU/VOP3Instructions.td
@@ -212,7 +212,13 @@ defm V_BFE_U32 : VOP3Inst <"v_bfe_u32", 
VOP3_Profile, AMDGP
 defm V_BFE_I32 : VOP3Inst <"v_bfe_i32", VOP3_Profile, 
AMDGPUbfe_i32>;
 defm V_BFI_B32 : VOP3Inst <"v_bfi_b32", VOP3_Profile, 
AMDGPUbfi>;
 defm V_ALIGNBIT_B32 : VOP3Inst <"v_alignbit_b32", 
VOP3_Profile, fshr>;
+
+let True16Predicate = NotHasTrue16BitInsts in
 defm V_ALIGNBYTE_B32 : VOP3Inst <"v_alignbyte_b32", 
VOP3_Profile, int_amdgcn_alignbyte>;
+let True16Predicate = UseRealTrue16Insts in
+defm V_ALIGNBYTE_B32_t16 : VOP3Inst <"v_alignbyte_b32_t16", 
VOP3_Profile_True16>;
+let True16Predicate = UseFakeTrue16Insts in 
+defm V_ALIGNBYTE_B32_fake16 : VOP3Inst <"v_alignbyte_b32_fake16", 
VOP3_Profile_Fake16>;
 
 // XXX - No FPException seems suspect but manual doesn't say it does
 let mayRaiseFPException = 0 in {
@@ -250,6 +256,25 @@ let SchedRW = [WriteDoubleAdd], FPDPRounding = 1 in {
 } // End SchedRW = [WriteDoubleAdd], FPDPRounding = 1
 } // End isReMaterializable = 1
 
+let True16Predicate = UseFakeTrue16Insts in
+def : GCNPat <
+(i32 (int_amdgcn_alignbyte (i32 (VOP3OpSelMods i32:$src0, 
i32:$src0_modifiers)),
+   (i32 (VOP3OpSelMods i32:$src1, 
i32:$src1_modifiers)),
+   (i32 (VOP3OpSelMods i32:$src2, 
i32:$src2_modifiers,
+(V_ALIGNBYTE_B32_fake16_e64 i32:$src0_modifiers, VSrc_b32:$src0,
+i32:$src1_modifiers, VSrc_b32:$src1,
+i32:$src2_modifiers, VGPR_32:$src2)
+>;
+
+let True16Predicate = UseRealTrue16Insts in
+def : GCNPat <
+(i32 (int_amdgcn_alignbyte (i32 (VOP3OpSelMods i32:$src0, 
i32:$src0_modifiers)),
+   (i32 (VOP3OpSelMods i32:$src1, 
i32:$src1_modifiers)),
+   (i32 (VOP3OpSelMods i32:$src2, 
i32:$src2_modifiers,
+(V_ALIGNBYTE_B32_t16_e64 i32:$src0_modifiers, VSrc_b32:$src0,
+ i32:$src1_modifiers, VSrc_b32:$src1,
+ i32:$src2_modifiers, (i16 (EXTRACT_SUBREG 
VGPR_32:$src2, lo16)))
+>;
 
 let mayRaiseFPException = 0 in { // Seems suspicious but manual doesn't say it 
does.
   let SchedRW = [WriteFloatFMA, WriteSALU] in
@@ -1690,7 +1715,7 @@ defm V_FMA_F32 : 
VOP3_Realtriple_gfx11_gfx12<0x213>;
 defm V_FMA_F64 : VOP3_Real_Base_gfx11_gfx12<0x214>;
 defm V_LERP_U8 : VOP3_Realtriple_gfx11_gfx12<0x215>;
 defm V_ALIGNBIT_B32: VOP3_Realtriple_gfx11_gfx12<0x216>;
-defm V_ALIGNBYTE_B32   : VOP3_Realtriple_gfx11_gfx12<0x217>;
+defm V_ALIGNBYTE_B32   : VOP3_Realtriple_t16_and_fake16_gfx11_gfx12<0x217, 
"v_alignbyte_b32">;
 defm V_MULLIT_F32  : VOP3_Realtriple_gfx11_gfx12<0x218>;
 defm V_MIN3_F32: VOP3_Realtriple_gfx11<0x219>;
 defm V_MIN3_I32: VOP3_Realtriple_gfx11_gfx12<0x21a>;
diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.alignbyte.ll 
b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.alignbyte.ll
index 8b16fef915a79d..07421afde7622d 100644
--- a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.alignbyte.ll
+++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.alignbyte.ll
@@ -1,14 +1,128 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
 ; RUN: llc -mtriple=amdgcn -verify-machineinstrs < %s | FileCheck 
-check-prefix=GCN %s
+; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=+real-true16 
-verify-machineinstrs < %s | FileCheck -check-prefixes=GFX11-TRUE16 %s
+; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -mattr=

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

2025-02-04 Thread via cfe-commits

higher-performance wrote:

w.r.t. ABI, I think the end state here would conceptually be most likely be 
similar to `__attribute__((diagnose_if(...)))`. Does that affect ABI?

w.r.t. False positives due to annotating the entire pack -- that's a great 
point. I think it's avoided by the `noexcept` approach. Any thoughts on that?

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


[clang] Pass -offload-lto instead of -lto for cuda/hip kernels (PR #125243)

2025-02-04 Thread Omar Ahmed via cfe-commits


@@ -498,12 +498,16 @@ Expected clang(ArrayRef InputFiles, 
const ArgList &Args) {
   };
 
   // Forward all of the `--offload-opt` and similar options to the device.
-  CmdArgs.push_back("-flto");
   for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
 CmdArgs.append(
 {"-Xlinker",
  Args.MakeArgString("--plugin-opt=" + StringRef(Arg->getValue()))});
 
+  if (Triple.isNVPTX() || Triple.isAMDGPU())
+CmdArgs.push_back("-foffload-lto");
+  else
+CmdArgs.push_back("-flto");

omarahmed wrote:

I managed to get similar behaviour from this small example: 
https://godbolt.org/z/xaTfGrajd

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


[clang] [clang] fix P3310 overload resolution flag propagation (PR #125372)

2025-02-04 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

> well

Thanks, I won't be able to for the next few hours. If it's not trivial to fix, 
please go ahead and revert.

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


[clang] Pass -offload-lto instead of -lto for cuda/hip kernels (PR #125243)

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


@@ -498,12 +498,16 @@ Expected clang(ArrayRef InputFiles, 
const ArgList &Args) {
   };
 
   // Forward all of the `--offload-opt` and similar options to the device.
-  CmdArgs.push_back("-flto");
   for (auto &Arg : Args.filtered(OPT_offload_opt_eq_minus, OPT_mllvm))
 CmdArgs.append(
 {"-Xlinker",
  Args.MakeArgString("--plugin-opt=" + StringRef(Arg->getValue()))});
 
+  if (Triple.isNVPTX() || Triple.isAMDGPU())
+CmdArgs.push_back("-foffload-lto");
+  else
+CmdArgs.push_back("-flto");

jhuber6 wrote:

Clang 19 is in release and can't be modified, does it happen with 20 or main? 
Also this example uses the `ptx_kernel` CC which I think was only introduced 
after the 19 release. It works for my installation on `main`. I'm going to 
guess  you're just using an older version of `clang` or your fork is missing 
something.

```console
> clang test.ll --target=nvptx64-nvidia-cuda -march=sm_50 -O2 -flto
> llvm-readelf -h a.out
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 33 07 00 00 00 00 00 00 00
  Class: ELF64
  Data:  2's complement, little endian
  Version:   1
  OS/ABI:NVIDIA - CUDA
  ABI Version:   7
  Type:  EXEC (Executable file)
  Machine:   NVIDIA CUDA architecture
  Version:   0x7E
  Entry point address:   0x0
  Start of program headers:  1888 (bytes into file)
  Start of section headers:  1248 (bytes into file)
  Flags: 0x320532, sm_50
  Size of this header:   64 (bytes)
  Size of program headers:   56 (bytes)
  Number of program headers: 3
  Size of section headers:   64 (bytes)
  Number of section headers: 10
  Section header string table index: 1
```

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


[clang] Fix broken clang codegen test (avx-cxx-record.cpp) (PR #125787)

2025-02-04 Thread Pranav Kant via cfe-commits

https://github.com/pranavk created 
https://github.com/llvm/llvm-project/pull/125787

Fixes e8a486ea97895a18e1bba75431d37d9758886084

>From eaa2581b6b81aa616296f09b859024b3d22fe3c8 Mon Sep 17 00:00:00 2001
From: Pranav Kant 
Date: Tue, 4 Feb 2025 23:35:44 +
Subject: [PATCH] Fix broken clang codegen test

Fixes e8a486ea97895a18e1bba75431d37d9758886084
---
 clang/test/CodeGen/X86/avx-cxx-record.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/test/CodeGen/X86/avx-cxx-record.cpp 
b/clang/test/CodeGen/X86/avx-cxx-record.cpp
index d8863ca4e45f9e..bcd9c361fda901 100644
--- a/clang/test/CodeGen/X86/avx-cxx-record.cpp
+++ b/clang/test/CodeGen/X86/avx-cxx-record.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang %s -S --target=x86_64-unknown-linux-gnu -emit-llvm -O2 
-march=x86-64-v3 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -O2 
-target-cpu x86-64-v3 -o - | FileCheck %s
 
 using UInt64x2 = unsigned long long __attribute__((__vector_size__(16), 
may_alias));
 
@@ -11,7 +11,7 @@ struct XMM2 : XMM1<0>, XMM1<1> {
 };
 
 // CHECK: define{{.*}} @_Z3foov({{.*}} [[ARG:%.*]]){{.*}}
-// CHECK-NEXT: entry:
+// CHECK: entry:
 // CHECK-NEXT: store {{.*}}, ptr [[ARG]]{{.*}}
 // CHECK-NEXT: [[TMP1:%.*]] = getelementptr {{.*}}, ptr [[ARG]]{{.*}}
 // CHECK-NEXT: store {{.*}}, ptr [[TMP1]]{{.*}}

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


[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits

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


[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits


@@ -359,18 +359,21 @@ class OpLowerer {
 return lowerToBindAndAnnotateHandle(F);
   }
 
-  Error replaceSplitDoubleCallUsages(CallInst *Intrin, CallInst *Op) {
+  Error replaceExtractElementTypeOfCallUsages(CallInst *Intrin, CallInst *Op) {
 for (Use &U : make_early_inc_range(Intrin->uses())) {
   if (auto *EVI = dyn_cast(U.getUser())) {
 
 if (EVI->getNumIndices() != 1)
-  return createStringError(std::errc::invalid_argument,
-   "Splitdouble has only 2 elements");
+  return createStringError(

Icohedron wrote:

To be as generic as possible, I could replace the entire function so that it 
reads:
```c++
  Error replaceExtractElementTypeOfCallUsages(CallInst *Intrin, CallInst *Op) {
for (Use &U : make_early_inc_range(Intrin->uses())) {
  U.set(Op);
}
Intrin->eraseFromParent();
return Error::success();
  }
```
This function would just replace all uses of the intrinsic with one to match 
the new named struct op return type. The function name would need to be 
changed, or it could be inlined into `replaceFunctionWithNamedStructOp`, since 
that is the only user of `replaceExtractElementTypeOfCallUsages`.

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


[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits

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


[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits

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


[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits


@@ -359,18 +359,21 @@ class OpLowerer {
 return lowerToBindAndAnnotateHandle(F);
   }
 
-  Error replaceSplitDoubleCallUsages(CallInst *Intrin, CallInst *Op) {
+  Error replaceExtractElementTypeOfCallUsages(CallInst *Intrin, CallInst *Op) {
 for (Use &U : make_early_inc_range(Intrin->uses())) {
   if (auto *EVI = dyn_cast(U.getUser())) {
 
 if (EVI->getNumIndices() != 1)
-  return createStringError(std::errc::invalid_argument,
-   "Splitdouble has only 2 elements");
+  return createStringError(

Icohedron wrote:

The new `replaceFunctionWithNamedStructOp` would look like this

```c++
  [[nodiscard]] bool replaceFunctionWithNamedStructOp(Function &F,
  dxil::OpCode DXILOp,
  Type *NewRetTy) {
bool IsVectorArgExpansion = isVectorArgExpansion(F);
return replaceFunction(F, [&](CallInst *CI) -> Error {
  SmallVector Args;
  OpBuilder.getIRB().SetInsertPoint(CI);
  if (IsVectorArgExpansion) {
SmallVector NewArgs = argVectorFlatten(CI, OpBuilder.getIRB());
Args.append(NewArgs.begin(), NewArgs.end());
  } else
Args.append(CI->arg_begin(), CI->arg_end());

  Expected OpCall =
  OpBuilder.tryCreateOp(DXILOp, Args, CI->getName(), NewRetTy);
  if (Error E = OpCall.takeError())
return E;

  for (Use &U : make_early_inc_range(CI->uses())) {
U.set(*OpCall);
  }
  CI->eraseFromParent();

  return Error::success();
});
  }
```

It works. All aggregate operations (`extractvalue`, `insertvalue`) get replaced 
correctly.
The only issue is if a function returns the result directly:
```c++
define noundef { i32, i1 } @test_UAddc2(i32 noundef %a, i32 noundef %b) {
; CHECK-LABEL: define noundef %dx.types.i32c @test_UAddc2(
; CHECK-SAME: i32 noundef [[A:%.*]], i32 noundef [[B:%.*]]) {
; CHECK-NEXT:[[UAddc:%.*]] = call %dx.types.i32c 
@dx.op.binaryWithCarryOrBorrow.i32(i32 44, i32 [[A]], i32 [[B]])
; CHECK-NEXT:ret %dx.types.i32c [[Result]]
; 
  %uaddc = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b)
  ret { i32, i1 } %uaddc
}
```
It results in an error that reads:
```
opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library 
/home/icohedron/workspace/feature-uaddc/llvm/test/CodeGen/DirectX/UAddc.ll
Function return type does not match operand type of return inst!
  ret %dx.types.i32c %uaddc1
 { i32, i1 }in function test_UAddc2
LLVM ERROR: Broken function found, compilation aborted!
...
```


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


[clang] [llvm] [X86] Extend kCFI with a 3-bit arity indicator (PR #121070)

2025-02-04 Thread Phoebe Wang via cfe-commits

phoebewang wrote:

> @lvwr @maurer @rcvalle A gentle reminder to please review this PR.

@scottconstable You don't need explicit approvals from all reviewers. Let's 
wait for 24 hours and land it if no objections.

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


[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits

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


[clang] [CIR] Lowering to LLVM for global pointers (PR #125619)

2025-02-04 Thread Andy Kaylor via cfe-commits

https://github.com/andykaylor updated 
https://github.com/llvm/llvm-project/pull/125619

>From dc7f71d511d2e13e527e0c8cd242a3ece82bcdfd Mon Sep 17 00:00:00 2001
From: Andy Kaylor 
Date: Mon, 3 Feb 2025 13:20:51 -0800
Subject: [PATCH 1/2] [CIR] Lowering to LLVM for global pointers

Add support for lowering global variables of any pointer type to LLVM IR.
---
 .../clang/CIR/Dialect/IR/CIRAttrVisitor.h | 51 +++
 clang/include/clang/CIR/MissingFeatures.h |  3 +
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp | 84 +++
 clang/test/CIR/Lowering/global-var-simple.cpp | 21 +
 4 files changed, 159 insertions(+)
 create mode 100644 clang/include/clang/CIR/Dialect/IR/CIRAttrVisitor.h

diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrVisitor.h 
b/clang/include/clang/CIR/Dialect/IR/CIRAttrVisitor.h
new file mode 100644
index 00..4babccc48038e6
--- /dev/null
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrVisitor.h
@@ -0,0 +1,51 @@
+#ifndef LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+#define LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
+
+#include "clang/CIR/Dialect/IR/CIRAttrs.h"
+
+namespace cir {
+
+template  class CirAttrVisitor {
+public:
+  // FIXME: Create a TableGen list to automatically handle new attributes
+  template 
+  RetTy visit(mlir::Attribute attr, Args &&...args) {
+if (const auto intAttr = mlir::dyn_cast(attr))
+  return static_cast(this)->visitCirIntAttr(
+  intAttr, std::forward(args)...);
+if (const auto fltAttr = mlir::dyn_cast(attr))
+  return static_cast(this)->visitCirFPAttr(
+  fltAttr, std::forward(args)...);
+if (const auto ptrAttr = mlir::dyn_cast(attr))
+  return static_cast(this)->visitCirConstPtrAttr(
+  ptrAttr, std::forward(args)...);
+llvm_unreachable("unhandled attribute type");
+  }
+
+  // If the implementation chooses not to implement a certain visit
+  // method, fall back to the parent.
+  template 
+  RetTy visitCirIntAttr(cir::IntAttr attr, Args &&...args) {
+return static_cast(this)->visitCirAttr(
+attr, std::forward(args)...);
+  }
+  template 
+  RetTy visitCirFPAttr(cir::FPAttr attr, Args &&...args) {
+return static_cast(this)->visitCirAttr(
+attr, std::forward(args)...);
+  }
+  template 
+  RetTy visitCirConstPtrAttr(cir::ConstPtrAttr attr, Args &&...args) {
+return static_cast(this)->visitCirAttr(
+attr, std::forward(args)...);
+  }
+
+  template 
+  RetTy visitCirAttr(mlir::Attribute attr, Args &&...args) {
+return RetTy();
+  }
+};
+
+} // namespace cir
+
+#endif // LLVM_CLANG_CIR_DIALECT_IR_CIRATTRVISITOR_H
diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index 3c018aeea65014..d4fcd52e7e6e3b 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -27,6 +27,9 @@ struct MissingFeatures {
   // Address space related
   static bool addressSpace() { return false; }
 
+  // This isn't needed until we add support for bools.
+  static bool convertTypeForMemory() { return false; }
+
   // Unhandled global/linkage information.
   static bool opGlobalDSOLocal() { return false; }
   static bool opGlobalThreadLocal() { return false; }
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp 
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index af8ca7d0b89e68..66f6ee328e55e5 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -24,6 +24,7 @@
 #include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"
 #include "mlir/Target/LLVMIR/Export.h"
 #include "mlir/Transforms/DialectConversion.h"
+#include "clang/CIR/Dialect/IR/CIRAttrVisitor.h"
 #include "clang/CIR/Dialect/IR/CIRDialect.h"
 #include "clang/CIR/MissingFeatures.h"
 #include "llvm/IR/Module.h"
@@ -35,6 +36,54 @@ using namespace llvm;
 namespace cir {
 namespace direct {
 
+class CIRAttrToValue : public CirAttrVisitor {
+public:
+  mlir::Value lowerCirAttrAsValue(mlir::Operation *parentOp,
+  mlir::Attribute attr,
+  mlir::ConversionPatternRewriter &rewriter,
+  const mlir::TypeConverter *converter,
+  mlir::DataLayout const &dataLayout) {
+return visit(attr, parentOp, rewriter, converter, dataLayout);
+  }
+
+  mlir::Value visitCirIntAttr(cir::IntAttr intAttr, mlir::Operation *parentOp,
+  mlir::ConversionPatternRewriter &rewriter,
+  const mlir::TypeConverter *converter,
+  mlir::DataLayout const &dataLayout) {
+auto loc = parentOp->getLoc();
+return rewriter.create(
+loc, converter->convertType(intAttr.getType()), intAttr.getValue());
+  }
+
+  mlir::Value visitCirFPAttr(cir::FPAttr fltAttr, mlir::Operation *parentOp,
+ mlir::Conv

[clang] [Clang] allow restrict qualifier for array types with pointer types as element types (PR #120896)

2025-02-04 Thread Eli Friedman via cfe-commits


@@ -1593,34 +1593,31 @@ QualType Sema::BuildQualifiedType(QualType T, 
SourceLocation Loc,
   // object or incomplete types shall not be restrict-qualified."
   if (Qs.hasRestrict()) {
 unsigned DiagID = 0;
-QualType ProblemTy;
-
-if (T->isAnyPointerType() || T->isReferenceType() ||
-T->isMemberPointerType()) {
-  QualType EltTy;
-  if (T->isObjCObjectPointerType())
-EltTy = T;
-  else if (const MemberPointerType *PTy = T->getAs())
+QualType EltTy = Context.getBaseElementType(T);
+
+if (EltTy->isAnyPointerType() || EltTy->isReferenceType() ||
+EltTy->isMemberPointerType() || EltTy->isArrayType()) {

efriedma-quic wrote:

Drop the isArrayType() here; should be impossible for EltTy to be an array here.

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


[clang] [Clang] allow restrict qualifier for array types with pointer types as element types (PR #120896)

2025-02-04 Thread Eli Friedman via cfe-commits


@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c2y -fsyntax-only -verify -pedantic %s
+
+typedef int (*T1)[2];
+restrict T1 t1;
+static_assert(_Generic(typeof (t1), int (*restrict)[2] : 1, default : 0));
+
+typedef int *T2[2];
+restrict T2 t2;
+static_assert(_Generic(typeof (t2), int *restrict[2] : 1, default : 0));
+
+typedef int *T3[2][2];
+restrict T3 t3;
+static_assert(_Generic(typeof (t3), int *restrict[2][2] : 1, default : 0));

efriedma-quic wrote:

Maybe also add a check that we handle this correctly in function types:

```
static_assert(_Generic(void(T3 restrict), void(int *restrict(*)[2]):1, 
default:0));
```

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


[clang] [Clang] Permit both `gnu` and `clang` prefixes on attributes (PR #125796)

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

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/125796

>From 77ee45f25f03614dbb63369922e9722a79ec8518 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Tue, 4 Feb 2025 20:03:33 -0600
Subject: [PATCH] [Clang] Permit both `gnu` and `clang` prefixes on attributes

Summary:
Some attributes have gnu extensions that share names with clang
attributes. If these imply the same thing, we can specially declare this
to be an alternate but equivalent spelling.

Discussions welcome on whether or not we want to bind ourselves to GNU
behavior, since theoretically it's possible for GNU to silently change
the semantics away from our implementation, but I'm not an expert.

Fixes: https://github.com/llvm/llvm-project/issues/125760
---
 clang/include/clang/Basic/Attr.td | 9 -
 clang/test/SemaCXX/attr-no-sanitize.cpp   | 4 ++--
 clang/utils/TableGen/ClangAttrEmitter.cpp | 8 
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 2a3a29bd2ee1cf..4384a98d63eb3d 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -380,6 +380,13 @@ class Clang
   bit AllowInC = allowInC;
 }
 
+// This spelling combines the spellings of GCC and Clang for cases where the
+// spellings are equivalent for compile compatibility.
+class ClangGCC
+: Spelling {
+  bit AllowInC = allowInC;
+}
+
 // HLSL Annotation spellings
 class HLSLAnnotation : Spelling;
 
@@ -3677,7 +3684,7 @@ def X86ForceAlignArgPointer : InheritableAttr, 
TargetSpecificAttr
 }
 
 def NoSanitize : InheritableAttr {
-  let Spellings = [Clang<"no_sanitize">];
+  let Spellings = [ClangGCC<"no_sanitize">];
   let Args = [VariadicStringArgument<"Sanitizers">];
   let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
   let Documentation = [NoSanitizeDocs];
diff --git a/clang/test/SemaCXX/attr-no-sanitize.cpp 
b/clang/test/SemaCXX/attr-no-sanitize.cpp
index 8951f616ce0f05..cd60e71963ac30 100644
--- a/clang/test/SemaCXX/attr-no-sanitize.cpp
+++ b/clang/test/SemaCXX/attr-no-sanitize.cpp
@@ -21,8 +21,8 @@ int f3() __attribute__((no_sanitize("address")));
 
 // DUMP-LABEL: FunctionDecl {{.*}} f4
 // DUMP: NoSanitizeAttr {{.*}} hwaddress
-// PRINT: {{\[\[}}clang::no_sanitize("hwaddress")]] int f4()
-[[clang::no_sanitize("hwaddress")]] int f4();
+// PRINT: {{\[\[}}gnu::no_sanitize("hwaddress")]] int f4()
+[[gnu::no_sanitize("hwaddress")]] int f4();
 
 // DUMP-LABEL: FunctionDecl {{.*}} f5
 // DUMP: NoSanitizeAttr {{.*}} address thread hwaddress
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index de12c7062666a4..af7478b7986f92 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -108,6 +108,14 @@ GetFlattenedSpellings(const Record &Attr) {
   Ret.emplace_back("CXX11", Name, "clang", false, *Spelling);
   if (Spelling->getValueAsBit("AllowInC"))
 Ret.emplace_back("C23", Name, "clang", false, *Spelling);
+} else if (Variety == "ClangGCC") {
+  Ret.emplace_back("GNU", Name, "", false, *Spelling);
+  Ret.emplace_back("CXX11", Name, "clang", false, *Spelling);
+  Ret.emplace_back("CXX11", Name, "gnu", false, *Spelling);
+  if (Spelling->getValueAsBit("AllowInC")) {
+Ret.emplace_back("C23", Name, "clang", false, *Spelling);
+Ret.emplace_back("C23", Name, "gnu", false, *Spelling);
+  }
 } else {
   Ret.push_back(FlattenedSpelling(*Spelling));
 }

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


[clang] Reapply "[AMDGPU] Use the AMDGPUToolChain when targeting C/C++ directly" (PR #125744)

2025-02-04 Thread Matt Arsenault via cfe-commits

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


[clang] [clang] C++20 Modules: document how to perform automated reductions (PR #124997)

2025-02-04 Thread Chuanqi Xu via cfe-commits

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

I like the idea. There are a lot of people suffering not able to send issue 
reports for modules.

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


[clang] [Clang] Permit both `gnu` and `clang` prefixes on attributes (PR #125796)

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

https://github.com/jhuber6 created 
https://github.com/llvm/llvm-project/pull/125796

Summary:
Some attributes have gnu extensions that share names with clang
attributes. If these imply the same thing, we can specially declare this
to be an alternate but equivalent spelling.

Discussions welcome on whether or not we want to bind ourselves to GNU
behavior, since theoretically it's possible for GNU to silently change
the semantics away from our implementation, but I'm not an expert.

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


>From c3b70b93e40474ca66b7ddae28e4c69d33d1 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Tue, 4 Feb 2025 20:03:33 -0600
Subject: [PATCH] [Clang] Permit both `gnu` and `clang` prefixes on attributes

Summary:
Some attributes have gnu extensions that share names with clang
attributes. If these imply the same thing, we can specially declare this
to be an alternate but equivalent spelling.

Discussions welcome on whether or not we want to bind ourselves to GNU
behavior, since theoretically it's possible for GNU to silently change
the semantics away from our implementation, but I'm not an expert.

Fixes: https://github.com/llvm/llvm-project/issues/125760
---
 clang/include/clang/Basic/Attr.td | 10 +-
 clang/test/SemaCXX/attr-no-sanitize.cpp   |  4 ++--
 clang/utils/TableGen/ClangAttrEmitter.cpp |  8 
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 2a3a29bd2ee1cf..bf746c2da51299 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -380,6 +380,14 @@ class Clang
   bit AllowInC = allowInC;
 }
 
+// The Clang spelling implies GNU, CXX11<"clang", name>, and optionally,
+// C23<"clang", name>. This spelling should be used for any Clang-specific
+// attributes.
+class ClangGCC
+: Spelling {
+  bit AllowInC = allowInC;
+}
+
 // HLSL Annotation spellings
 class HLSLAnnotation : Spelling;
 
@@ -3677,7 +3685,7 @@ def X86ForceAlignArgPointer : InheritableAttr, 
TargetSpecificAttr
 }
 
 def NoSanitize : InheritableAttr {
-  let Spellings = [Clang<"no_sanitize">];
+  let Spellings = [ClangGCC<"no_sanitize">];
   let Args = [VariadicStringArgument<"Sanitizers">];
   let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
   let Documentation = [NoSanitizeDocs];
diff --git a/clang/test/SemaCXX/attr-no-sanitize.cpp 
b/clang/test/SemaCXX/attr-no-sanitize.cpp
index 8951f616ce0f05..cd60e71963ac30 100644
--- a/clang/test/SemaCXX/attr-no-sanitize.cpp
+++ b/clang/test/SemaCXX/attr-no-sanitize.cpp
@@ -21,8 +21,8 @@ int f3() __attribute__((no_sanitize("address")));
 
 // DUMP-LABEL: FunctionDecl {{.*}} f4
 // DUMP: NoSanitizeAttr {{.*}} hwaddress
-// PRINT: {{\[\[}}clang::no_sanitize("hwaddress")]] int f4()
-[[clang::no_sanitize("hwaddress")]] int f4();
+// PRINT: {{\[\[}}gnu::no_sanitize("hwaddress")]] int f4()
+[[gnu::no_sanitize("hwaddress")]] int f4();
 
 // DUMP-LABEL: FunctionDecl {{.*}} f5
 // DUMP: NoSanitizeAttr {{.*}} address thread hwaddress
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index de12c7062666a4..af7478b7986f92 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -108,6 +108,14 @@ GetFlattenedSpellings(const Record &Attr) {
   Ret.emplace_back("CXX11", Name, "clang", false, *Spelling);
   if (Spelling->getValueAsBit("AllowInC"))
 Ret.emplace_back("C23", Name, "clang", false, *Spelling);
+} else if (Variety == "ClangGCC") {
+  Ret.emplace_back("GNU", Name, "", false, *Spelling);
+  Ret.emplace_back("CXX11", Name, "clang", false, *Spelling);
+  Ret.emplace_back("CXX11", Name, "gnu", false, *Spelling);
+  if (Spelling->getValueAsBit("AllowInC")) {
+Ret.emplace_back("C23", Name, "clang", false, *Spelling);
+Ret.emplace_back("C23", Name, "gnu", false, *Spelling);
+  }
 } else {
   Ret.push_back(FlattenedSpelling(*Spelling));
 }

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


[clang] [Clang] Permit both `gnu` and `clang` prefixes on attributes (PR #125796)

2025-02-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Joseph Huber (jhuber6)


Changes

Summary:
Some attributes have gnu extensions that share names with clang
attributes. If these imply the same thing, we can specially declare this
to be an alternate but equivalent spelling.

Discussions welcome on whether or not we want to bind ourselves to GNU
behavior, since theoretically it's possible for GNU to silently change
the semantics away from our implementation, but I'm not an expert.

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


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


3 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+9-1) 
- (modified) clang/test/SemaCXX/attr-no-sanitize.cpp (+2-2) 
- (modified) clang/utils/TableGen/ClangAttrEmitter.cpp (+8) 


``diff
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 2a3a29bd2ee1cf..bf746c2da51299 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -380,6 +380,14 @@ class Clang
   bit AllowInC = allowInC;
 }
 
+// The Clang spelling implies GNU, CXX11<"clang", name>, and optionally,
+// C23<"clang", name>. This spelling should be used for any Clang-specific
+// attributes.
+class ClangGCC
+: Spelling {
+  bit AllowInC = allowInC;
+}
+
 // HLSL Annotation spellings
 class HLSLAnnotation : Spelling;
 
@@ -3677,7 +3685,7 @@ def X86ForceAlignArgPointer : InheritableAttr, 
TargetSpecificAttr
 }
 
 def NoSanitize : InheritableAttr {
-  let Spellings = [Clang<"no_sanitize">];
+  let Spellings = [ClangGCC<"no_sanitize">];
   let Args = [VariadicStringArgument<"Sanitizers">];
   let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
   let Documentation = [NoSanitizeDocs];
diff --git a/clang/test/SemaCXX/attr-no-sanitize.cpp 
b/clang/test/SemaCXX/attr-no-sanitize.cpp
index 8951f616ce0f05..cd60e71963ac30 100644
--- a/clang/test/SemaCXX/attr-no-sanitize.cpp
+++ b/clang/test/SemaCXX/attr-no-sanitize.cpp
@@ -21,8 +21,8 @@ int f3() __attribute__((no_sanitize("address")));
 
 // DUMP-LABEL: FunctionDecl {{.*}} f4
 // DUMP: NoSanitizeAttr {{.*}} hwaddress
-// PRINT: {{\[\[}}clang::no_sanitize("hwaddress")]] int f4()
-[[clang::no_sanitize("hwaddress")]] int f4();
+// PRINT: {{\[\[}}gnu::no_sanitize("hwaddress")]] int f4()
+[[gnu::no_sanitize("hwaddress")]] int f4();
 
 // DUMP-LABEL: FunctionDecl {{.*}} f5
 // DUMP: NoSanitizeAttr {{.*}} address thread hwaddress
diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index de12c7062666a4..af7478b7986f92 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -108,6 +108,14 @@ GetFlattenedSpellings(const Record &Attr) {
   Ret.emplace_back("CXX11", Name, "clang", false, *Spelling);
   if (Spelling->getValueAsBit("AllowInC"))
 Ret.emplace_back("C23", Name, "clang", false, *Spelling);
+} else if (Variety == "ClangGCC") {
+  Ret.emplace_back("GNU", Name, "", false, *Spelling);
+  Ret.emplace_back("CXX11", Name, "clang", false, *Spelling);
+  Ret.emplace_back("CXX11", Name, "gnu", false, *Spelling);
+  if (Spelling->getValueAsBit("AllowInC")) {
+Ret.emplace_back("C23", Name, "clang", false, *Spelling);
+Ret.emplace_back("C23", Name, "gnu", false, *Spelling);
+  }
 } else {
   Ret.push_back(FlattenedSpelling(*Spelling));
 }

``




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


[clang] [clang module] Current Working Directory Pruning (PR #124786)

2025-02-04 Thread Qiongsi Wu via cfe-commits

https://github.com/qiongsiwu updated 
https://github.com/llvm/llvm-project/pull/124786

>From 7060564de1bb6062639f4b4839fa17958f212755 Mon Sep 17 00:00:00 2001
From: Qiongsi Wu 
Date: Mon, 27 Jan 2025 16:44:30 -0800
Subject: [PATCH 1/5] Initial implementation of clang modules current working
 directory pruning.

---
 .../DependencyScanningService.h   |   5 +-
 .../DependencyScanning/ModuleDepCollector.cpp |  92 -
 .../ClangScanDeps/modules-context-hash-cwd.c  | 123 ++
 clang/test/ClangScanDeps/working-dir.m|   2 +-
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |   2 +
 5 files changed, 219 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/ClangScanDeps/modules-context-hash-cwd.c

diff --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
index 4a343f2872d8d97..9ad8e68c33eb106 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
@@ -63,7 +63,10 @@ enum class ScanningOptimizations {
   /// Canonicalize -D and -U options.
   Macros = 8,
 
-  DSS_LAST_BITMASK_ENUM(Macros),
+  /// Ignore the compiler's working directory if it is safe.
+  IgnoreCWD = 0x10,
+
+  DSS_LAST_BITMASK_ENUM(IgnoreCWD),
   Default = All
 };
 
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 2e97cac0796ceea..714efb86fa37960 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -397,9 +397,92 @@ void 
ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation &CI) {
   }
 }
 
+static bool isSafeToIgnoreCWD(const CowCompilerInvocation &CI) {
+  // Check if the command line input uses relative paths.
+  // It is not safe to ignore the current working directory if any of the
+  // command line inputs use relative paths.
+#define IF_RELATIVE_RETURN_FALSE(PATH) 
\
+  do { 
\
+if (!PATH.empty() && !llvm::sys::path::is_absolute(PATH))  
\
+  return false;
\
+  } while (0)
+
+#define IF_ANY_RELATIVE_RETURN_FALSE(PATHS)
\
+  do { 
\
+if (std::any_of(PATHS.begin(), PATHS.end(), [](const auto &P) {
\
+  return !P.empty() && !llvm::sys::path::is_absolute(P);   
\
+}))
\
+  return false;
\
+  } while (0)
+
+  // Header search paths.
+  const auto &HeaderSearchOpts = CI.getHeaderSearchOpts();
+  IF_RELATIVE_RETURN_FALSE(HeaderSearchOpts.Sysroot);
+  for (auto &Entry : HeaderSearchOpts.UserEntries)
+if (Entry.IgnoreSysRoot)
+  IF_RELATIVE_RETURN_FALSE(Entry.Path);
+  IF_RELATIVE_RETURN_FALSE(HeaderSearchOpts.ResourceDir);
+  IF_RELATIVE_RETURN_FALSE(HeaderSearchOpts.ModuleCachePath);
+  IF_RELATIVE_RETURN_FALSE(HeaderSearchOpts.ModuleUserBuildPath);
+  for (auto I = HeaderSearchOpts.PrebuiltModuleFiles.begin(),
+E = HeaderSearchOpts.PrebuiltModuleFiles.end();
+   I != E;) {
+auto Current = I++;
+IF_RELATIVE_RETURN_FALSE(Current->second);
+  }
+  IF_ANY_RELATIVE_RETURN_FALSE(HeaderSearchOpts.PrebuiltModulePaths);
+  IF_ANY_RELATIVE_RETURN_FALSE(HeaderSearchOpts.VFSOverlayFiles);
+
+  // Preprocessor options.
+  const auto &PPOpts = CI.getPreprocessorOpts();
+  IF_ANY_RELATIVE_RETURN_FALSE(PPOpts.MacroIncludes);
+  IF_ANY_RELATIVE_RETURN_FALSE(PPOpts.Includes);
+  IF_RELATIVE_RETURN_FALSE(PPOpts.ImplicitPCHInclude);
+
+  // Frontend options.
+  const auto &FrontendOpts = CI.getFrontendOpts();
+  for (const FrontendInputFile &Input : FrontendOpts.Inputs) {
+if (Input.isBuffer())
+  continue; // FIXME: Can this happen when parsing command-line?
+
+IF_RELATIVE_RETURN_FALSE(Input.getFile());
+  }
+  IF_RELATIVE_RETURN_FALSE(FrontendOpts.CodeCompletionAt.FileName);
+  IF_ANY_RELATIVE_RETURN_FALSE(FrontendOpts.ModuleMapFiles);
+  IF_ANY_RELATIVE_RETURN_FALSE(FrontendOpts.ModuleFiles);
+  IF_ANY_RELATIVE_RETURN_FALSE(FrontendOpts.ModulesEmbedFiles);
+  IF_ANY_RELATIVE_RETURN_FALSE(FrontendOpts.ASTMergeFiles);
+  IF_RELATIVE_RETURN_FALSE(FrontendOpts.OverrideRecordLayoutsFile);
+  IF_RELATIVE_RETURN_FALSE(FrontendOpts.StatsFile);
+
+  // Filesystem options.
+  const auto &FileSystemOpts = CI.getFileSystemOpts();
+  IF_RELATIVE_RETURN_FALSE(FileSystemOpts.WorkingDir);
+
+  // Codegen options.
+  const auto &CodeGenOpts = CI.getCodeGenOpts();
+  IF_RELATIVE_RETURN_FALSE(CodeGenOpts.Debug

[clang] [clang module] Current Working Directory Pruning (PR #124786)

2025-02-04 Thread Qiongsi Wu via cfe-commits


@@ -397,9 +397,91 @@ void 
ModuleDepCollector::applyDiscoveredDependencies(CompilerInvocation &CI) {
   }
 }
 
+static bool isSafeToIgnoreCWD(const CowCompilerInvocation &CI) {
+  // Check if the command line input uses relative paths.
+  // It is not safe to ignore the current working directory if any of the
+  // command line inputs use relative paths.
+#define IF_RELATIVE_RETURN_FALSE(PATH) 
\
+  do { 
\
+if (!PATH.empty() && !llvm::sys::path::is_absolute(PATH))  
\
+  return false;
\
+  } while (0)
+
+#define IF_ANY_RELATIVE_RETURN_FALSE(PATHS)
\
+  do { 
\
+if (std::any_of(PATHS.begin(), PATHS.end(), [](const auto &P) {
\

qiongsiwu wrote:

Fixed! Thanks! 

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


[clang] [clang module] Current Working Directory Pruning (PR #124786)

2025-02-04 Thread Qiongsi Wu via cfe-commits


@@ -63,7 +63,10 @@ enum class ScanningOptimizations {
   /// Canonicalize -D and -U options.
   Macros = 8,
 
-  DSS_LAST_BITMASK_ENUM(Macros),
+  /// Ignore the compiler's working directory if it is safe.
+  IgnoreCWD = 0x10,

qiongsiwu wrote:

Fixed! Thanks! 

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


[clang] 4055be5 - Fix broken clang codegen test (avx-cxx-record.cpp) (#125787)

2025-02-04 Thread via cfe-commits

Author: Pranav Kant
Date: 2025-02-04T16:12:12-08:00
New Revision: 4055be55b8814b31256ca3c8840bc73bbe5e3d0f

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

LOG: Fix broken clang codegen test (avx-cxx-record.cpp) (#125787)

Fixes e8a486ea97895a18e1bba75431d37d9758886084

Added: 


Modified: 
clang/test/CodeGen/X86/avx-cxx-record.cpp

Removed: 




diff  --git a/clang/test/CodeGen/X86/avx-cxx-record.cpp 
b/clang/test/CodeGen/X86/avx-cxx-record.cpp
index d8863ca4e45f9e5..bcd9c361fda901f 100644
--- a/clang/test/CodeGen/X86/avx-cxx-record.cpp
+++ b/clang/test/CodeGen/X86/avx-cxx-record.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang %s -S --target=x86_64-unknown-linux-gnu -emit-llvm -O2 
-march=x86-64-v3 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -O2 
-target-cpu x86-64-v3 -o - | FileCheck %s
 
 using UInt64x2 = unsigned long long __attribute__((__vector_size__(16), 
may_alias));
 
@@ -11,7 +11,7 @@ struct XMM2 : XMM1<0>, XMM1<1> {
 };
 
 // CHECK: define{{.*}} @_Z3foov({{.*}} [[ARG:%.*]]){{.*}}
-// CHECK-NEXT: entry:
+// CHECK: entry:
 // CHECK-NEXT: store {{.*}}, ptr [[ARG]]{{.*}}
 // CHECK-NEXT: [[TMP1:%.*]] = getelementptr {{.*}}, ptr [[ARG]]{{.*}}
 // CHECK-NEXT: store {{.*}}, ptr [[TMP1]]{{.*}}



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


[clang] [clang] Return larger CXX records in memory (PR #120670)

2025-02-04 Thread Pranav Kant via cfe-commits

pranavk wrote:

I fixed this in #125787

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


[clang] Fix broken clang codegen test (avx-cxx-record.cpp) (PR #125787)

2025-02-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Pranav Kant (pranavk)


Changes

Fixes e8a486ea97895a18e1bba75431d37d9758886084

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


1 Files Affected:

- (modified) clang/test/CodeGen/X86/avx-cxx-record.cpp (+2-2) 


``diff
diff --git a/clang/test/CodeGen/X86/avx-cxx-record.cpp 
b/clang/test/CodeGen/X86/avx-cxx-record.cpp
index d8863ca4e45f9e5..bcd9c361fda901f 100644
--- a/clang/test/CodeGen/X86/avx-cxx-record.cpp
+++ b/clang/test/CodeGen/X86/avx-cxx-record.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang %s -S --target=x86_64-unknown-linux-gnu -emit-llvm -O2 
-march=x86-64-v3 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -O2 
-target-cpu x86-64-v3 -o - | FileCheck %s
 
 using UInt64x2 = unsigned long long __attribute__((__vector_size__(16), 
may_alias));
 
@@ -11,7 +11,7 @@ struct XMM2 : XMM1<0>, XMM1<1> {
 };
 
 // CHECK: define{{.*}} @_Z3foov({{.*}} [[ARG:%.*]]){{.*}}
-// CHECK-NEXT: entry:
+// CHECK: entry:
 // CHECK-NEXT: store {{.*}}, ptr [[ARG]]{{.*}}
 // CHECK-NEXT: [[TMP1:%.*]] = getelementptr {{.*}}, ptr [[ARG]]{{.*}}
 // CHECK-NEXT: store {{.*}}, ptr [[TMP1]]{{.*}}

``




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


[clang] Fix broken clang codegen test (avx-cxx-record.cpp) (PR #125787)

2025-02-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Pranav Kant (pranavk)


Changes

Fixes e8a486ea97895a18e1bba75431d37d9758886084

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


1 Files Affected:

- (modified) clang/test/CodeGen/X86/avx-cxx-record.cpp (+2-2) 


``diff
diff --git a/clang/test/CodeGen/X86/avx-cxx-record.cpp 
b/clang/test/CodeGen/X86/avx-cxx-record.cpp
index d8863ca4e45f9e..bcd9c361fda901 100644
--- a/clang/test/CodeGen/X86/avx-cxx-record.cpp
+++ b/clang/test/CodeGen/X86/avx-cxx-record.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang %s -S --target=x86_64-unknown-linux-gnu -emit-llvm -O2 
-march=x86-64-v3 -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -emit-llvm -O2 
-target-cpu x86-64-v3 -o - | FileCheck %s
 
 using UInt64x2 = unsigned long long __attribute__((__vector_size__(16), 
may_alias));
 
@@ -11,7 +11,7 @@ struct XMM2 : XMM1<0>, XMM1<1> {
 };
 
 // CHECK: define{{.*}} @_Z3foov({{.*}} [[ARG:%.*]]){{.*}}
-// CHECK-NEXT: entry:
+// CHECK: entry:
 // CHECK-NEXT: store {{.*}}, ptr [[ARG]]{{.*}}
 // CHECK-NEXT: [[TMP1:%.*]] = getelementptr {{.*}}, ptr [[ARG]]{{.*}}
 // CHECK-NEXT: store {{.*}}, ptr [[TMP1]]{{.*}}

``




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


[clang] Fix broken clang codegen test (avx-cxx-record.cpp) (PR #125787)

2025-02-04 Thread Pranav Kant via cfe-commits

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


[clang] [clang][OpenMP] OpenMP 6.0 updates to restrictions with order/concurrent (PR #125621)

2025-02-04 Thread David Pagan via cfe-commits

https://github.com/ddpagan updated 
https://github.com/llvm/llvm-project/pull/125621

>From deffda7ca37661781f1bae565ac8ae4a8fbba674 Mon Sep 17 00:00:00 2001
From: Dave Pagan 
Date: Fri, 31 Jan 2025 16:12:08 -0600
Subject: [PATCH 1/3] [clang][OpenMP] OpenMP 6.0 updates to restrictions with
 order/concurrent

>From OpenMP 6.0 features list
- OpenMP directives in concurrent loop regions
- atomics constructs on concurrent loop regions
- Lift nesting restriction on concurrent loop

Testing
- Updated test/OpenMP/for_order_messages.cpp
- check-all
---
 clang/include/clang/Basic/OpenMPKinds.h  |  8 +++
 clang/lib/Basic/OpenMPKinds.cpp  |  6 +
 clang/lib/Sema/SemaOpenMP.cpp| 30 +---
 clang/test/OpenMP/for_order_messages.cpp | 12 ++
 4 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Basic/OpenMPKinds.h 
b/clang/include/clang/Basic/OpenMPKinds.h
index 3e5da2a6abc017..e80bce34a97e03 100644
--- a/clang/include/clang/Basic/OpenMPKinds.h
+++ b/clang/include/clang/Basic/OpenMPKinds.h
@@ -399,6 +399,14 @@ bool isOpenMPInformationalDirective(OpenMPDirectiveKind 
DKind);
 /// \return true - if the above condition is met for this directive
 /// otherwise - false.
 bool isOpenMPCapturingDirective(OpenMPDirectiveKind DKind);
+
+/// Checks if the specified directive is an order concurrent nestable
+/// directive that can be nested within region corresponding to construct
+/// on which order clause was specified with concurrent as ordering argument.
+/// \param DKind Specified directive.
+/// \return true - if the above condition is met for this directive
+/// otherwise - false.
+bool isOpenMPOrderConcurrentNestableDirective(OpenMPDirectiveKind DKind);
 }
 
 template <>
diff --git a/clang/lib/Basic/OpenMPKinds.cpp b/clang/lib/Basic/OpenMPKinds.cpp
index 62a13f01481b28..8398eabceb82fe 100644
--- a/clang/lib/Basic/OpenMPKinds.cpp
+++ b/clang/lib/Basic/OpenMPKinds.cpp
@@ -765,6 +765,12 @@ bool clang::isOpenMPCapturingDirective(OpenMPDirectiveKind 
DKind) {
   return false;
 }
 
+bool clang::isOpenMPOrderConcurrentNestableDirective(OpenMPDirectiveKind 
DKind) {
+  return DKind == OMPD_atomic || DKind == OMPD_loop ||
+ DKind == OMPD_simd || DKind == OMPD_parallel ||
+ isOpenMPLoopTransformationDirective(DKind);
+}
+
 void clang::getOpenMPCaptureRegions(
 SmallVectorImpl &CaptureRegions,
 OpenMPDirectiveKind DKind) {
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index b83b2b12f4a230..3bba93c9560041 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4788,13 +4788,26 @@ static bool checkNestingOfRegions(Sema &SemaRef, const 
DSAStackTy *Stack,
   getLeafOrCompositeConstructs(ParentRegion, LeafOrComposite);
   OpenMPDirectiveKind EnclosingConstruct = ParentLOC.back();
 
-  if (SemaRef.LangOpts.OpenMP >= 51 && Stack->isParentOrderConcurrent() &&
-  CurrentRegion != OMPD_simd && CurrentRegion != OMPD_loop &&
-  CurrentRegion != OMPD_parallel &&
-  !isOpenMPCombinedParallelADirective(CurrentRegion)) {
-SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order)
-<< getOpenMPDirectiveName(CurrentRegion);
-return true;
+  if (Stack->isParentOrderConcurrent()) {
+bool InvalidOrderNesting = false; 
+if ((SemaRef.LangOpts.OpenMP == 51 || SemaRef.LangOpts.OpenMP == 52) &&
+CurrentRegion != OMPD_simd &&
+CurrentRegion != OMPD_loop && CurrentRegion != OMPD_parallel &&
+!isOpenMPCombinedParallelADirective(CurrentRegion)) {
+  InvalidOrderNesting = true;
+} else if (SemaRef.LangOpts.OpenMP >= 60 &&
+!isOpenMPOrderConcurrentNestableDirective(CurrentRegion)) {
+  // OpenMP 6.0 [12.3 order Clause, Restrictions]
+  // Only regions that correspond to order-concurrent-nestable constructs
+  // or order-concurrent-nestable routines may be strictly nested regions
+  // of regions that correspond to constructs on which the order clause is
+  // specified with concurrent as the ordering argument.
+  InvalidOrderNesting = true;
+}
+if (InvalidOrderNesting) {
+  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region_order)
+  << getOpenMPDirectiveName(CurrentRegion);
+}
   }
   if (isOpenMPSimdDirective(ParentRegion) &&
   ((SemaRef.LangOpts.OpenMP <= 45 && CurrentRegion != OMPD_ordered) ||
@@ -7114,7 +7127,8 @@ ExprResult SemaOpenMP::ActOnOpenMPCall(ExprResult Call, 
Scope *Scope,
   if (!CalleeFnDecl)
 return Call;
 
-  if (getLangOpts().OpenMP >= 51 && CalleeFnDecl->getIdentifier() &&
+  if (getLangOpts().OpenMP >= 51 && getLangOpts().OpenMP < 60 &&
+  CalleeFnDecl->getIdentifier() &&
   CalleeFnDecl->getName().starts_with_insensitive("omp_")) {
 // checking for any calls inside an Order region
 if (Scope && Scope->isOpenMPOrderClauseScope())
diff --git a/clang/test/OpenMP/for_order_messages.cpp 
b/clang/test/OpenMP/for_order_messages

[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits

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


[clang] [lldb] Reland: [clang] fix P3310 overload resolution flag propagation (PR #125791)

2025-02-04 Thread Matheus Izvekov via cfe-commits


@@ -280,7 +280,8 @@ std::optional 
CxxModuleHandler::tryInstantiateStdTemplate(Decl *d) {
   new_class_template->getDeclContext(),
   new_class_template->getTemplatedDecl()->getLocation(),
   new_class_template->getLocation(), new_class_template, imported_args,
-  nullptr);
+  td->hasMatchedPackOnParmToNonPackOnArg(),
+  /*PrevDecl=*/nullptr);

mizvekov wrote:

@DavidSpickett @Michael137 this is the only change for this relanding of the 
patch.

As far as I understood reading this code, this is basically importing a 
template instantiation into a different context, so this is much like what we 
would do at the AST Importer, ie just forward the new bool from the original 
specialization into this new one.

Also as I understand, this implementation whitelists only a few template names 
from the STL, none of which have template template parameter to begin with, so 
this new flag will always be false here and this is pretty much untestable.

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


[clang] [llvm] [mlir] [IR][ModRef] Introduce `errno` memory location (PR #120783)

2025-02-04 Thread Eli Friedman via cfe-commits


@@ -82,7 +82,7 @@ define void @test_store(ptr %p) {
 
 @G = external global ptr
 define i8 @test_store_capture(ptr %p) {
-; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind 
willreturn memory(readwrite, argmem: read, inaccessiblemem: none)
+; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind 
willreturn memory(readwrite, argmem: read, inaccessiblemem: none, errnomem: 
none)

efriedma-quic wrote:

This is still wrong in the latest patch?

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


[clang] 7a52b93 - [DependencyScanning] Add ability to scan TU with a buffer input (#125111)

2025-02-04 Thread via cfe-commits

Author: Steven Wu
Date: 2025-02-04T16:37:29-08:00
New Revision: 7a52b93837123488cd86151f82655979e1397453

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

LOG: [DependencyScanning] Add ability to scan TU with a buffer input (#125111)

Update Dependency scanner so it can scan the dependency of a TU with
a provided buffer rather than relying on the on disk file system to
provide the input file.

Added: 
clang/test/ClangScanDeps/tu-buffer.c

Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp
clang/tools/clang-scan-deps/Opts.td

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index ddb078dc16e3cd..bcc9ea17e2588f 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -128,14 +128,17 @@ class DependencyScanningTool {
   /// \param LookupModuleOutput This function is called to fill in
   ///   "-fmodule-file=", "-o" and other output
   ///   arguments for dependencies.
+  /// \param TUBuffer Optional memory buffer for translation unit input. If
+  /// TUBuffer is nullopt, the input should be included in the
+  /// Commandline already.
   ///
   /// \returns a \c StringError with the diagnostic output if clang errors
   /// occurred, \c TranslationUnitDeps otherwise.
-  llvm::Expected
-  getTranslationUnitDependencies(const std::vector &CommandLine,
- StringRef CWD,
- const llvm::DenseSet &AlreadySeen,
- LookupModuleOutputCallback 
LookupModuleOutput);
+  llvm::Expected getTranslationUnitDependencies(
+  const std::vector &CommandLine, StringRef CWD,
+  const llvm::DenseSet &AlreadySeen,
+  LookupModuleOutputCallback LookupModuleOutput,
+  std::optional TUBuffer = std::nullopt);
 
   /// Given a compilation context specified via the Clang driver command-line,
   /// gather modular dependencies of module with the given name, and return the

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
index da6e0401411a34..ee7582b8510208 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
@@ -17,6 +17,7 @@
 #include "clang/Tooling/DependencyScanning/ModuleDepCollector.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBufferRef.h"
 #include 
 #include 
 
@@ -83,9 +84,21 @@ class DependencyScanningWorker {
llvm::IntrusiveRefCntPtr FS);
 
   /// Run the dependency scanning tool for a given clang driver command-line,
-  /// and report the discovered dependencies to the provided consumer. If \p
-  /// ModuleName isn't empty, this function reports the dependencies of module
-  /// \p ModuleName.
+  /// and report the discovered dependencies to the provided consumer. If
+  /// TUBuffer is not nullopt, it is used as TU input for the dependency
+  /// scanning. Otherwise, the input should be included as part of the
+  /// command-line.
+  ///
+  /// \returns false if clang errors occurred (with diagnostics reported to
+  /// \c DiagConsumer), true otherwise.
+  bool computeDependencies(
+  StringRef WorkingDirectory, const std::vector &CommandLine,
+  DependencyConsumer &DepConsumer, DependencyActionController &Controller,
+  DiagnosticConsumer &DiagConsumer,
+  std::optional TUBuffer = std::nullopt);
+
+  /// Run the dependency scanning tool for a given clang driver command-line
+  /// for a specific module.
   ///
   /// \returns false if clang errors occurred (with diagnostics reported to
   /// \c DiagConsumer), true otherwise.
@@ -94,13 +107,28 @@ class DependencyScanningWorker {
DependencyConsumer &DepConsumer,
DependencyActionController &Controller,
DiagnosticConsumer &DiagConsumer,
-   std::optional ModuleName = std::nullopt);
+   StringRef ModuleName);
+
+  /// Run the dependency scanning tool for a given clang driver command-l

[clang] [DependencyScanning] Add ability to scan TU with a buffer input (PR #125111)

2025-02-04 Thread Steven Wu via cfe-commits

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


[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits

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


[clang] [llvm] [aarch64][x86][win] Add compiler support for MSVC's /funcoverride flag (Windows kernel loader replaceable functions) (PR #125320)

2025-02-04 Thread Eli Friedman via cfe-commits


@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -loader-replaceable-function=override_me -emit-llvm 
-std=c11 -o - %s | FileCheck %s
+
+// CHECK: define dso_local void @override_me() #0
+void override_me() {}
+
+// CHECK: define dso_local void @dont_override_me() #1
+void dont_override_me() {}

efriedma-quic wrote:

Please add a C++ testcase showing the interaction with mangling

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


[clang] [llvm] [aarch64][x86][win] Add compiler support for MSVC's /funcoverride flag (Windows kernel loader replaceable functions) (PR #125320)

2025-02-04 Thread Eli Friedman via cfe-commits


@@ -4661,3 +4661,110 @@ AsmPrinter::getCodeViewJumpTableInfo(int JTI, const 
MachineInstr *BranchInstr,
   return std::make_tuple(Base, 0, BranchLabel,
  codeview::JumpTableEntrySize::Int32);
 }
+
+void AsmPrinter::emitCOFFReplaceableFunctionData(Module &M) {
+  const Triple &TT = TM.getTargetTriple();
+  assert(TT.isOSBinFormatCOFF());
+
+  bool IsTargetArm64EC = TT.isWindowsArm64EC();
+  SmallVector Buf;
+  SmallVector FuncOverrideDefaultSymbols;
+  bool SwitchedToDirectiveSection = false;
+  for (const auto &F : M.functions()) {
+if (F.hasFnAttribute("loader-replaceable")) {
+  if (!SwitchedToDirectiveSection) {
+OutStreamer->switchSection(
+OutContext.getObjectFileInfo()->getDrectveSection());
+SwitchedToDirectiveSection = true;
+  }
+
+  auto Name = F.getName();
+
+  // For hybrid-patchable targets, strip the prefix so that we can mark
+  // the real function as replaceable.
+  if (IsTargetArm64EC && Name.ends_with(HybridPatchableTargetSuffix)) {
+Name = Name.substr(0, Name.size() - 
HybridPatchableTargetSuffix.size());
+  }
+
+  llvm::Twine FuncOverrideName = Name + "_$fo$";

efriedma-quic wrote:

Sticking a Twine in a local variable is a bad idea; you end up with references 
to dead temporaries because a Twine often contains a reference to another 
Twine, or some other temporary value.  (Not sure if that actually happens here, 
but we discourage the practice in general to avoid issues.)

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


[clang] [llvm] [aarch64][x86][win] Add compiler support for MSVC's /funcoverride flag (Windows kernel loader replaceable functions) (PR #125320)

2025-02-04 Thread Eli Friedman via cfe-commits


@@ -4661,3 +4661,110 @@ AsmPrinter::getCodeViewJumpTableInfo(int JTI, const 
MachineInstr *BranchInstr,
   return std::make_tuple(Base, 0, BranchLabel,
  codeview::JumpTableEntrySize::Int32);
 }
+
+void AsmPrinter::emitCOFFReplaceableFunctionData(Module &M) {
+  const Triple &TT = TM.getTargetTriple();
+  assert(TT.isOSBinFormatCOFF());
+
+  bool IsTargetArm64EC = TT.isWindowsArm64EC();
+  SmallVector Buf;
+  SmallVector FuncOverrideDefaultSymbols;
+  bool SwitchedToDirectiveSection = false;
+  for (const auto &F : M.functions()) {
+if (F.hasFnAttribute("loader-replaceable")) {
+  if (!SwitchedToDirectiveSection) {
+OutStreamer->switchSection(
+OutContext.getObjectFileInfo()->getDrectveSection());
+SwitchedToDirectiveSection = true;
+  }
+
+  auto Name = F.getName();

efriedma-quic wrote:

Don't use `auto` for easily nameable types like "StringRef".

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


[clang] [llvm] [aarch64][x86][win] Add compiler support for MSVC's /funcoverride flag (Windows kernel loader replaceable functions) (PR #125320)

2025-02-04 Thread Eli Friedman via cfe-commits


@@ -561,6 +564,16 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// Reset all of the options that are not considered when building a
   /// module.
   void resetNonModularOptions(StringRef ModuleFormat);
+
+  // Is the given function name one of the functions that can be replaced by 
the
+  // loader?
+  bool isLoaderReplaceableFunctionName(StringRef FuncName) const {
+return std::any_of(LoaderReplaceableFunctionNames.begin(),

efriedma-quic wrote:

llvm::is_contained

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


[clang] [lldb] Reland: [clang] fix P3310 overload resolution flag propagation (PR #125791)

2025-02-04 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Matheus Izvekov (mizvekov)


Changes

Class templates might be only instantiated when they are required to be 
complete, but checking the template args against the primary template is 
immediate.

This result is cached so that later when the class is instantiated, checking 
against the primary template is not repeated.

The 'MatchedPackOnParmToNonPackOnArg' flag is also produced upon checking 
against the primary template, so it needs to be cached in the specialziation as 
well.

This fixes a bug which has not been in any release, so there are no release 
notes.

Fixes #125290

---

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


16 Files Affected:

- (modified) clang/include/clang/AST/DeclTemplate.h (+14-2) 
- (modified) clang/include/clang/Sema/Sema.h (+2-2) 
- (modified) clang/lib/AST/ASTImporter.cpp (+3-3) 
- (modified) clang/lib/AST/DeclTemplate.cpp (+24-23) 
- (modified) clang/lib/AST/JSONNodeDumper.cpp (+5) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+4-1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+5-3) 
- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (-2) 
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaType.cpp (+2-1) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+1) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+1) 
- (modified) clang/test/AST/ast-dump-templates.cpp (+6045-2) 
- (modified) clang/test/AST/gen_ast_dump_json_test.py (+17-4) 
- (modified) clang/test/SemaTemplate/cwg2398.cpp (+17) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/CxxModuleHandler.cpp 
(+2-1) 


``diff
diff --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 9ecff2c898acd5..03c43765206b18 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -1841,15 +1841,23 @@ class ClassTemplateSpecializationDecl : public 
CXXRecordDecl,
   LLVM_PREFERRED_TYPE(TemplateSpecializationKind)
   unsigned SpecializationKind : 3;
 
+  /// Indicate that we have matched a parameter pack with a non pack
+  /// argument, when the opposite match is also allowed (strict pack match).
+  /// This needs to be cached as deduction is performed during declaration,
+  /// and we need the information to be preserved so that it is consistent
+  /// during instantiation.
+  bool MatchedPackOnParmToNonPackOnArg : 1;
+
 protected:
   ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,
   DeclContext *DC, SourceLocation StartLoc,
   SourceLocation IdLoc,
   ClassTemplateDecl *SpecializedTemplate,
   ArrayRef Args,
+  bool MatchedPackOnParmToNonPackOnArg,
   ClassTemplateSpecializationDecl *PrevDecl);
 
-  explicit ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
+  ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
 
 public:
   friend class ASTDeclReader;
@@ -1859,7 +1867,7 @@ class ClassTemplateSpecializationDecl : public 
CXXRecordDecl,
   Create(ASTContext &Context, TagKind TK, DeclContext *DC,
  SourceLocation StartLoc, SourceLocation IdLoc,
  ClassTemplateDecl *SpecializedTemplate,
- ArrayRef Args,
+ ArrayRef Args, bool MatchedPackOnParmToNonPackOnArg,
  ClassTemplateSpecializationDecl *PrevDecl);
   static ClassTemplateSpecializationDecl *CreateDeserialized(ASTContext &C,
  GlobalDeclID ID);
@@ -1930,6 +1938,10 @@ class ClassTemplateSpecializationDecl : public 
CXXRecordDecl,
 SpecializationKind = TSK;
   }
 
+  bool hasMatchedPackOnParmToNonPackOnArg() const {
+return MatchedPackOnParmToNonPackOnArg;
+  }
+
   /// Get the point of instantiation (if any), or null if none.
   SourceLocation getPointOfInstantiation() const {
 return PointOfInstantiation;
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 472a0e25adc975..79bf6c04ee4969 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13493,8 +13493,8 @@ class Sema final : public SemaBase {
   bool InstantiateClassTemplateSpecialization(
   SourceLocation PointOfInstantiation,
   ClassTemplateSpecializationDecl *ClassTemplateSpec,
-  TemplateSpecializationKind TSK, bool Complain = true,
-  bool PrimaryHasMatchedPackOnParmToNonPackOnArg = false);
+  TemplateSpecializationKind TSK, bool Complain,
+  bool PrimaryHasMatchedPackOnParmToNonPackOnArg);
 
   /// Instantiates the definitions of all of the member
   /// of the given class, which is an instantiation of a class template
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
inde

[clang] 6422882 - [flang] Add support for -fimplicit-none-ext option (#125248)

2025-02-04 Thread via cfe-commits

Author: Eugene Epshteyn
Date: 2025-02-04T20:50:01-05:00
New Revision: 642288247d0eb59069797f15cdd0f51b41d558c6

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

LOG: [flang] Add support for -fimplicit-none-ext option (#125248)

When -fimplicit-none-ext is passed, flang behaves as if "implicit
none(external)" was specified for all relevant constructs in Fortran
source file.

Note: implicit17.f90 was based on implicit07.f90 with `implicit
none(external)` removed and `-fimplicit-none-ext` added.

Added: 
flang/test/Semantics/implicit17.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Common/Fortran-features.h
flang/lib/Common/Fortran-features.cpp
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Semantics/resolve-names.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0ab923fcdd5838..c0749c418b7bce 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6876,6 +6876,7 @@ defm backslash : OptInFC1FFlag<"backslash", "Specify that 
backslash in string in
 defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym 
of .NEQV.">;
 defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable 
logical abbreviations">;
 defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing 
allowed unless overridden by IMPLICIT statements">;
+defm implicit_none_ext : OptInFC1FFlag<"implicit-none-ext", "No implicit 
externals allowed">;
 defm underscoring : OptInFC1FFlag<"underscoring", "Appends one trailing 
underscore to external names">;
 defm ppc_native_vec_elem_order: BoolOptionWithoutMarshalling<"f", 
"ppc-native-vector-element-order",
   PosFlag,

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 1ae865f379110b..e4019c43496874 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -42,6 +42,7 @@ void Flang::addFortranDialectOptions(const ArgList &Args,
 options::OPT_fopenacc,
 options::OPT_finput_charset_EQ,
 options::OPT_fimplicit_none,
+options::OPT_fimplicit_none_ext,
 options::OPT_fno_implicit_none,
 options::OPT_fbackslash,
 options::OPT_fno_backslash,

diff  --git a/flang/include/flang/Common/Fortran-features.h 
b/flang/include/flang/Common/Fortran-features.h
index 96c4de74cd6a8d..e2a420ae826bc7 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/include/flang/Common/Fortran-features.h
@@ -34,13 +34,13 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
 EquivalenceSameNonSequence, AdditionalIntrinsics, AnonymousParents,
 OldLabelDoEndStatements, LogicalIntegerAssignment, EmptySourceFile,
 ProgramReturn, ImplicitNoneTypeNever, ImplicitNoneTypeAlways,
-ForwardRefImplicitNone, OpenAccessAppend, BOZAsDefaultInteger,
-DistinguishableSpecifics, DefaultSave, PointerInSeqType, 
NonCharacterFormat,
-SaveMainProgram, SaveBigMainProgramVariables,
-DistinctArrayConstructorLengths, PPCVector, RelaxedIntentInChecking,
-ForwardRefImplicitNoneData, NullActualForAllocatable,
-ActualIntegerConvertedToSmallerKind, HollerithOrCharacterAsBOZ,
-BindingAsProcedure, StatementFunctionExtensions,
+ImplicitNoneExternal, ForwardRefImplicitNone, OpenAccessAppend,
+BOZAsDefaultInteger, DistinguishableSpecifics, DefaultSave,
+PointerInSeqType, NonCharacterFormat, SaveMainProgram,
+SaveBigMainProgramVariables, DistinctArrayConstructorLengths, PPCVector,
+RelaxedIntentInChecking, ForwardRefImplicitNoneData,
+NullActualForAllocatable, ActualIntegerConvertedToSmallerKind,
+HollerithOrCharacterAsBOZ, BindingAsProcedure, StatementFunctionExtensions,
 UseGenericIntrinsicWhenSpecificDoesntMatch, DataStmtExtensions,
 RedundantContiguous, RedundantAttribute, InitBlankCommon,
 EmptyBindCDerivedType, MiscSourceExtensions, AllocateToOtherLength,

diff  --git a/flang/lib/Common/Fortran-features.cpp 
b/flang/lib/Common/Fortran-features.cpp
index bbf16a4f7ac672..e2601e1af3a2f6 100644
--- a/flang/lib/Common/Fortran-features.cpp
+++ b/flang/lib/Common/Fortran-features.cpp
@@ -22,6 +22,7 @@ LanguageFeatureControl::LanguageFeatureControl() {
   disable_.set(LanguageFeature::CudaUnified);
   disable_.set(LanguageFeature::ImplicitNoneTypeNever);
   disable_.set(LanguageFeature::ImplicitNoneTypeAlways);
+  disable_.set(LanguageFeature::ImplicitNoneExternal);
   disable_.set(LanguageFeature::DefaultSave);
   disab

[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)

2025-02-04 Thread Eugene Epshteyn via cfe-commits

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


[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)

2025-02-04 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang] [llvm] [HLSL] [DXIL] Implement the `AddUint64` HLSL function and the `UAddc` DXIL op (PR #125319)

2025-02-04 Thread Deric Cheung via cfe-commits

https://github.com/Icohedron updated 
https://github.com/llvm/llvm-project/pull/125319

>From 1e194fdf6dc731276cd867501708b348e3bbc97c Mon Sep 17 00:00:00 2001
From: Icohedron 
Date: Mon, 27 Jan 2025 11:18:09 -0800
Subject: [PATCH 1/5] Implement AddUint64 HLSL codegen and sema

---
 clang/include/clang/Basic/Builtins.td |  6 ++
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +-
 clang/lib/CodeGen/CGBuiltin.cpp   | 45 
 clang/lib/Headers/hlsl/hlsl_intrinsics.h  | 21 ++
 clang/lib/Sema/SemaHLSL.cpp   | 49 +
 .../test/CodeGenHLSL/builtins/AddUint64.hlsl  | 71 +++
 .../SemaHLSL/BuiltIns/AddUint64-errors.hlsl   | 46 
 7 files changed, 239 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGenHLSL/builtins/AddUint64.hlsl
 create mode 100644 clang/test/SemaHLSL/BuiltIns/AddUint64-errors.hlsl

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 60c360d4a9e075..ffa60bf98aea06 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4753,6 +4753,12 @@ def GetDeviceSideMangledName : LangBuiltin<"CUDA_LANG"> {
 }
 
 // HLSL
+def HLSLAddUint64: LangBuiltin<"HLSL_LANG"> {
+  let Spellings = ["__builtin_hlsl_adduint64"];
+  let Attributes = [NoThrow, Const];
+  let Prototype = "void(...)";
+}
+
 def HLSLResourceGetPointer : LangBuiltin<"HLSL_LANG"> {
   let Spellings = ["__builtin_hlsl_resource_getpointer"];
   let Attributes = [NoThrow];
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 774e5484cfa0e7..2d7d306a207417 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10623,7 +10623,7 @@ def err_second_argument_to_cwsc_not_pointer : Error<
   "second argument to __builtin_call_with_static_chain must be of pointer 
type">;
 
 def err_vector_incorrect_num_elements : Error<
-  "%select{too many|too few}0 elements in vector 
%select{initialization|operand}3 (expected %1 elements, have %2)">;
+  "%select{too many|too few|incorrect number of}0 elements in vector 
%select{initialization|operand}3 (expected %1 elements, have %2)">;
 def err_altivec_empty_initializer : Error<"expected initializer">;
 
 def err_invalid_neon_type_code : Error<
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 26bdc5e36e..3a2c74f39afa78 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19105,6 +19105,51 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
 return nullptr;
 
   switch (BuiltinID) {
+  case Builtin::BI__builtin_hlsl_adduint64: {
+Value *OpA = EmitScalarExpr(E->getArg(0));
+Value *OpB = EmitScalarExpr(E->getArg(1));
+assert(E->getArg(0)->getType()->hasIntegerRepresentation() &&
+   E->getArg(1)->getType()->hasIntegerRepresentation() &&
+   "AddUint64 operands must have an integer representation");
+assert(((E->getArg(0)->getType()->castAs()->getNumElements() ==
+ 2 &&
+ E->getArg(1)->getType()->castAs()->getNumElements() ==
+ 2) ||
+(E->getArg(0)->getType()->castAs()->getNumElements() ==
+ 4 &&
+ E->getArg(1)->getType()->castAs()->getNumElements() ==
+ 4)) &&
+   "input vectors must have 2 or 4 elements each");
+
+llvm::Value *Result = PoisonValue::get(OpA->getType());
+uint64_t NumElements =
+E->getArg(0)->getType()->castAs()->getNumElements();
+for (uint64_t i = 0; i < NumElements / 2; ++i) {
+
+  // Obtain low and high words of inputs A and B
+  llvm::Value *LowA = Builder.CreateExtractElement(OpA, 2 * i + 0);
+  llvm::Value *HighA = Builder.CreateExtractElement(OpA, 2 * i + 1);
+  llvm::Value *LowB = Builder.CreateExtractElement(OpB, 2 * i + 0);
+  llvm::Value *HighB = Builder.CreateExtractElement(OpB, 2 * i + 1);
+
+  // Use an uadd_with_overflow to compute the sum of low words and obtain a
+  // carry value
+  llvm::Value *Carry;
+  llvm::Value *LowSum = EmitOverflowIntrinsic(
+  *this, llvm::Intrinsic::uadd_with_overflow, LowA, LowB, Carry);
+  llvm::Value *ZExtCarry = Builder.CreateZExt(Carry, HighA->getType());
+
+  // Sum the high words and the carry
+  llvm::Value *HighSum = Builder.CreateAdd(HighA, HighB);
+  llvm::Value *HighSumPlusCarry = Builder.CreateAdd(HighSum, ZExtCarry);
+
+  // Insert the low and high word sums into the result vector
+  Result = Builder.CreateInsertElement(Result, LowSum, 2 * i + 0);
+  Result = Builder.CreateInsertElement(Result, HighSumPlusCarry, 2 * i + 1,
+   "hlsl.AddUint64");
+}
+return Result;
+  }
   case Builtin::BI__builtin_hlsl_resource_getpointer: {
 Value *HandleOp = EmitScalarE

[clang] Reapply "[AMDGPU] Use the AMDGPUToolChain when targeting C/C++ directly (#99687)" (PR #125744)

2025-02-04 Thread Matt Arsenault via cfe-commits

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


[clang] [clang][Sema] Emit warnings on incorrect AVR interrupt/signal handlers (PR #125328)

2025-02-04 Thread Jianjian Guan via cfe-commits

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

LGTM

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


[clang] Thread Safety Analysis: Support warning on obtaining address of guarded variables (PR #123063)

2025-02-04 Thread Nick Desaulniers via cfe-commits

nickdesaulniers wrote:

Can any of the members in the structs be reorganized to put the mutex member 
declaration BEFORE the members they guard? Probably not always, but perhaps 
that's possible for most structures?

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


[clang] Patch series to reapply #118734 and substantially improve it (PR #120534)

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

rnk wrote:

> But one specific question: would you prefer me to land as a series of commits 
> or a single squashed commit for the entire PR? I'm happy either way. My mild 
> preference is to prefer the series of commits, but open to suggestions here.

I would land it as the six-patch stack in this case. I ended up using that to 
review, since mainly the first patch is the interesting one and the 
target-specific migration ones are more mechanical and more incremental.

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


[clang] [Clang] Make `-Xarch_` handling generic for all toolchains (PR #125421)

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

jhuber6 wrote:

> > Right now if someone passes -Xarch_foo --offload-arch=gfx1030 and foo 
> > doesn't match it's not passed and it will print something like this. I 
> > figured that's good enough.
> 
> This part SGTM, too.
> 
> However, I don't think I've seen the answer what happens when we do pass 
> --offload arch to cc1.
> 
> E.g. a user may accidentally paste an argument in the wrong place and instead 
> of intended `--offload-arch=sm_52 --offload-arch=sm_80 -Xarch_sm52 
> --some-option-for_sm52` passes `--offload-arch=sm_52 -Xarch_sm52 
> --offload-arch=sm_80 --some-option-for_sm52` ?

`--offload-arch=` isn't an accepted `-cc1` argument so it won't be forwarded at 
all.

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


[clang] [llvm] [clangd] Add support for the c2000 architecture (PR #125663)

2025-02-04 Thread James Nagurne via cfe-commits

DragonDisciple wrote:

General comments:

- Please do not use tabs for spacing. This is what causes the unexpected 
whitespace gaps in the diff.
- There is a utility, clang-format-diff.py, which will assist in appeasing the 
code formatting check. However, I noticed running it myself that it changes 
some entire lists that should likely stay the way they are, so be careful!
  - My usual command line is something like: git diff -U0 --no-color --relative 
HEAD~1..HEAD | /path/to/clang-format-diff.py -p1 -i -binary 
/path/to/clang-format(.exe)
- Is there no desire to catch and support C2000 built-in functions? Those will 
show up in clangd as undefined symbols and will be errors in c99 or later, and 
in all C++ modes.
- Options
  - The options parser for clang and for the TI compilers are obviously very 
different. Some options interact with others for the purposes of ease-of-use 
and error checking, which is something that the clang options parser won't 
understand. I'll do my best to be diligent in case I have to point this out
  - There are many more options than the ones currently captured. Is it 
important we get as many as we can? Otherwise this will be a PR that is 
tailor-fit to a single use-case.

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


[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)

2025-02-04 Thread Aidan Goldfarb via cfe-commits

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


  1   2   3   4   5   6   >