[clang] Reapply "[Clang] Fix dependent local class instantiation bugs" (PR #135914)

2025-04-15 Thread Younan Zhang via cfe-commits

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


[clang] Users/mizvekov/dependent elab keyword fixes (PR #135916)

2025-04-15 Thread via cfe-commits

llvmbot wrote:




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

Author: Matheus Izvekov (mizvekov)


Changes

This patches makes the rules for canonicalization of the elaborated keyword 
uniform
between DependentNameType and DependentTemplateSpecializationType.

`class` and `struct` keywords are functionally equivalent,
so relying on their equivalence was IFNDR.
This changes it so we treat them as equivalent,
as at least that disallows overloading, which is diagnosable.

This patch also considers a few drive by fixes to preservation
of the presence / absence of the typename keyword, and improves
a few assertions in that area.

Also improves preservation of sugar on initializer_list deduction
in order to avoid a few changes in diagnostics.

---

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


14 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4) 
- (modified) clang/include/clang/AST/Type.h (+12) 
- (modified) clang/lib/AST/ASTContext.cpp (+38-11) 
- (modified) clang/lib/AST/Type.cpp (+11) 
- (modified) clang/lib/AST/TypeLoc.cpp (+27-17) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+3-3) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+36-24) 
- (modified) clang/lib/Sema/SemaInit.cpp (+4-3) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+10-8) 
- (modified) clang/test/Analysis/anonymous-decls.cpp (+2-2) 
- (modified) clang/test/CXX/drs/cwg23xx.cpp (+2-2) 
- (modified) clang/test/SemaTemplate/dependent-template-recover.cpp (+2-2) 
- (modified) clang/test/SemaTemplate/elaborated-type-specifier.cpp (+60-3) 
- (modified) clang/test/SemaTemplate/typename-specifier-3.cpp (+18) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 84ad253c1ec4f..2dfd573dcf4e2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -476,6 +476,10 @@ Bug Fixes to C++ Support
 - Fixes matching of nested template template parameters. (#GH130362)
 - Correctly diagnoses template template paramters which have a pack parameter
   not in the last position.
+- Disallow overloading on struct vs class on dependent types, which is IFNDR, 
as
+  this makes the problem diagnosable.
+- Improved preservation of the presence or abscence of typename specifier when
+  printing types in diagnostics.
 - Clang now correctly parses ``if constexpr`` expressions in immediate 
function context. (#GH123524)
 - Fixed an assertion failure affecting code that uses C++23 "deducing this". 
(#GH130272)
 - Clang now properly instantiates destructors for initialized members within 
non-delegating constructors. (#GH93251)
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 5bf036e3347eb..d5537cb70aef6 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2838,6 +2838,18 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   /// immediately following this class.
   template  const T *getAs() const;
 
+  /// Look through sugar for an instance of TemplateSpecializationType which
+  /// is not a type alias.
+  const TemplateSpecializationType *
+  getAsNonAliasTemplateSpecializationType() const;
+
+  const TemplateSpecializationType *
+  castAsNonAliasTemplateSpecializationType() const {
+auto TST = getAsNonAliasTemplateSpecializationType();
+assert(TST && "not a TemplateSpecializationType");
+return TST;
+  }
+
   /// Member-template getAsAdjusted. Look through specific kinds
   /// of sugar (parens, attributes, etc) for an instance of \.
   /// This is used when you need to walk over sugar nodes that represent some
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c6ffe7bbf5257..bf24704e48eaa 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5747,6 +5747,30 @@ ASTContext::getMacroQualifiedType(QualType UnderlyingTy,
   return QualType(newType, 0);
 }
 
+static ElaboratedTypeKeyword
+getCanonicalElaboratedTypeKeyword(ElaboratedTypeKeyword Keyword) {
+  switch (Keyword) {
+  // These are just themselves.
+  case ElaboratedTypeKeyword::None:
+  case ElaboratedTypeKeyword::Struct:
+  case ElaboratedTypeKeyword::Union:
+  case ElaboratedTypeKeyword::Enum:
+  case ElaboratedTypeKeyword::Interface:
+return Keyword;
+
+  // These are equivalent.
+  case ElaboratedTypeKeyword::Typename:
+return ElaboratedTypeKeyword::None;
+
+  // These are functionally equivalent, so relying on their equivalence is
+  // IFNDR. By making them equivalent, we disallow overloading, which at least
+  // can produce a diagnostic.
+  case ElaboratedTypeKeyword::Class:
+return ElaboratedTypeKeyword::Struct;
+  }
+  llvm_unreachable("unexpected keyword kind");
+}
+
 QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
   NestedNameSpecifier *NNS,
   const IdentifierInfo *Name) const {
@@ -5758,10 +

[clang] Users/mizvekov/dependent elab keyword fixes (PR #135916)

2025-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

This patches makes the rules for canonicalization of the elaborated keyword 
uniform
between DependentNameType and DependentTemplateSpecializationType.

`class` and `struct` keywords are functionally equivalent,
so relying on their equivalence was IFNDR.
This changes it so we treat them as equivalent,
as at least that disallows overloading, which is diagnosable.

This patch also considers a few drive by fixes to preservation
of the presence / absence of the typename keyword, and improves
a few assertions in that area.

Also improves preservation of sugar on initializer_list deduction
in order to avoid a few changes in diagnostics.

---

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


14 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4) 
- (modified) clang/include/clang/AST/Type.h (+12) 
- (modified) clang/lib/AST/ASTContext.cpp (+38-11) 
- (modified) clang/lib/AST/Type.cpp (+11) 
- (modified) clang/lib/AST/TypeLoc.cpp (+27-17) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+3-3) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+36-24) 
- (modified) clang/lib/Sema/SemaInit.cpp (+4-3) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+10-8) 
- (modified) clang/test/Analysis/anonymous-decls.cpp (+2-2) 
- (modified) clang/test/CXX/drs/cwg23xx.cpp (+2-2) 
- (modified) clang/test/SemaTemplate/dependent-template-recover.cpp (+2-2) 
- (modified) clang/test/SemaTemplate/elaborated-type-specifier.cpp (+60-3) 
- (modified) clang/test/SemaTemplate/typename-specifier-3.cpp (+18) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 84ad253c1ec4f..2dfd573dcf4e2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -476,6 +476,10 @@ Bug Fixes to C++ Support
 - Fixes matching of nested template template parameters. (#GH130362)
 - Correctly diagnoses template template paramters which have a pack parameter
   not in the last position.
+- Disallow overloading on struct vs class on dependent types, which is IFNDR, 
as
+  this makes the problem diagnosable.
+- Improved preservation of the presence or abscence of typename specifier when
+  printing types in diagnostics.
 - Clang now correctly parses ``if constexpr`` expressions in immediate 
function context. (#GH123524)
 - Fixed an assertion failure affecting code that uses C++23 "deducing this". 
(#GH130272)
 - Clang now properly instantiates destructors for initialized members within 
non-delegating constructors. (#GH93251)
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 5bf036e3347eb..d5537cb70aef6 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2838,6 +2838,18 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   /// immediately following this class.
   template  const T *getAs() const;
 
+  /// Look through sugar for an instance of TemplateSpecializationType which
+  /// is not a type alias.
+  const TemplateSpecializationType *
+  getAsNonAliasTemplateSpecializationType() const;
+
+  const TemplateSpecializationType *
+  castAsNonAliasTemplateSpecializationType() const {
+auto TST = getAsNonAliasTemplateSpecializationType();
+assert(TST && "not a TemplateSpecializationType");
+return TST;
+  }
+
   /// Member-template getAsAdjusted. Look through specific kinds
   /// of sugar (parens, attributes, etc) for an instance of \.
   /// This is used when you need to walk over sugar nodes that represent some
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index c6ffe7bbf5257..bf24704e48eaa 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5747,6 +5747,30 @@ ASTContext::getMacroQualifiedType(QualType UnderlyingTy,
   return QualType(newType, 0);
 }
 
+static ElaboratedTypeKeyword
+getCanonicalElaboratedTypeKeyword(ElaboratedTypeKeyword Keyword) {
+  switch (Keyword) {
+  // These are just themselves.
+  case ElaboratedTypeKeyword::None:
+  case ElaboratedTypeKeyword::Struct:
+  case ElaboratedTypeKeyword::Union:
+  case ElaboratedTypeKeyword::Enum:
+  case ElaboratedTypeKeyword::Interface:
+return Keyword;
+
+  // These are equivalent.
+  case ElaboratedTypeKeyword::Typename:
+return ElaboratedTypeKeyword::None;
+
+  // These are functionally equivalent, so relying on their equivalence is
+  // IFNDR. By making them equivalent, we disallow overloading, which at least
+  // can produce a diagnostic.
+  case ElaboratedTypeKeyword::Class:
+return ElaboratedTypeKeyword::Struct;
+  }
+  llvm_unreachable("unexpected keyword kind");
+}
+
 QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
   NestedNameSpecifier *NNS,
   const IdentifierInfo *Name) const {
@@ -5758,10 +5782,13 @@ QualTyp

[clang] [llvm] [RISCV] Fix xmipscmov extension name (PR #135647)

2025-04-15 Thread Pengcheng Wang via cfe-commits

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


[clang] [llvm] [VectorCombine] Shrink loads used in shufflevector rebroadcasts (PR #128938)

2025-04-15 Thread Leon Clark via cfe-commits


@@ -47,21 +47,12 @@ define <8 x i32> @concat_extract_subvectors_poison(<8 x 
i32> %x) {
 ; broadcast loads are free on AVX (and blends are much cheap than general 
2-operand shuffles)
 
 define  <4 x double> @blend_broadcasts_v4f64(ptr %p0, ptr %p1)  {
-; SSE-LABEL: define <4 x double> @blend_broadcasts_v4f64(
-; SSE-SAME: ptr [[P0:%.*]], ptr [[P1:%.*]]) #[[ATTR0]] {
-; SSE-NEXT:[[LD0:%.*]] = load <4 x double>, ptr [[P0]], align 32
-; SSE-NEXT:[[LD1:%.*]] = load <4 x double>, ptr [[P1]], align 32
-; SSE-NEXT:[[BLEND:%.*]] = shufflevector <4 x double> [[LD0]], <4 x 
double> [[LD1]], <4 x i32> 
-; SSE-NEXT:ret <4 x double> [[BLEND]]
-;
-; AVX-LABEL: define <4 x double> @blend_broadcasts_v4f64(
-; AVX-SAME: ptr [[P0:%.*]], ptr [[P1:%.*]]) #[[ATTR0]] {
-; AVX-NEXT:[[LD0:%.*]] = load <4 x double>, ptr [[P0]], align 32
-; AVX-NEXT:[[LD1:%.*]] = load <4 x double>, ptr [[P1]], align 32
-; AVX-NEXT:[[BCST0:%.*]] = shufflevector <4 x double> [[LD0]], <4 x 
double> undef, <4 x i32> zeroinitializer
-; AVX-NEXT:[[BCST1:%.*]] = shufflevector <4 x double> [[LD1]], <4 x 
double> undef, <4 x i32> zeroinitializer
-; AVX-NEXT:[[BLEND:%.*]] = shufflevector <4 x double> [[BCST0]], <4 x 
double> [[BCST1]], <4 x i32> 
-; AVX-NEXT:ret <4 x double> [[BLEND]]
+; CHECK-LABEL: define <4 x double> @blend_broadcasts_v4f64(
+; CHECK-SAME: ptr [[P0:%.*]], ptr [[P1:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT:[[TMP1:%.*]] = load <1 x double>, ptr [[P0]], align 32
+; CHECK-NEXT:[[TMP2:%.*]] = load <1 x double>, ptr [[P1]], align 32
+; CHECK-NEXT:[[BLEND:%.*]] = shufflevector <1 x double> [[TMP1]], <1 x 
double> [[TMP2]], <4 x i32> 
+; CHECK-NEXT:ret <4 x double> [[BLEND]]
 ;

PeddleSpam wrote:

I've created #135753 to fix this regression.

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


[clang] [SYCL] Basic code generation for SYCL kernel caller offload entry point functions. (PR #133030)

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


@@ -732,6 +732,16 @@ 
CodeGenTypes::arrangeBuiltinFunctionDeclaration(CanQualType resultType,
  RequiredArgs::All);
 }
 
+const CGFunctionInfo &
+CodeGenTypes::arrangeSYCLKernelCallerDeclaration(QualType resultType,
+ const FunctionArgList &args) {
+  auto argTypes = getArgTypesForDeclaration(Context, args);

AaronBallman wrote:

IMO, the coding standard says to spell out the type here. However, I think you 
should spell out of the type not because a rule told you to but because a 
reviewer asked for it (that alone should suffice). But as a matter of 
practicality: should that be `const auto &` instead? Does the type have a move 
constructor? These sort of questions come up for reviewers and we shouldn't 
have to chase down types we can't see.

FWIW, another option is to get rid of `argTypes` entirely and nest the function 
call instead. The local variable isn't really giving much value to begin with.

> I don't consider it in scope for this PR.

This is new code, it's in scope for this PR to adjust the way you express it.

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


[clang] Fix filename parsing in clang-format-diff.py for paths with spaces (PR #135779)

2025-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Selim Keles (selimkeles)


Changes

Summary: This PR resolves an issue in clang-format-diff.py where filenames 
containing spaces were not correctly extracted from Git diffs. Due to the 
previous regex implementation, filenames were being truncated, causing the 
script to fail when processing diffs with such filenames.

**Details:**

- Adjusted the regex pattern to correctly capture the filename, including 
spaces.
- Ensured compatibility across Linux and Windows environments (tested on WSL 
and Windows).

**Steps to Reproduce:**

Modify a file with spaces in its name, stage the changes, and generate a diff.

Run git diff --cached -U0 --no-color | python3 clang-format-diff.py -p1.

Before the fix, filenames with spaces are incorrectly extracted or cause errors.

 After the fix, filenames with spaces are correctly recognized, and formatting 
differences are processed properly.

**Impact:**

Users relying on clang-format-diff.py in their automated workflows and 
pre-commit hooks will now be able to format files without filename parsing 
issues.

_No changes are made to formatting behavior—only improved filename handling in 
diffs._

_**Maintainer Mentions:**_ Tagging @mydeveloperday and @owenca 
for review since they maintain clang-format and also @owenca reviewed 
my 
[issue](https://github.com/llvm/llvm-project/issues/135619#issuecomment-2804148179)
 earlier.

_**Note: Also attached the patch file**_ 
[clang-format-space-fix.patch](https://github.com/user-attachments/files/19757014/clang-format-space-fix.patch)


Would love any feedback or suggestions for further refinements! 🚀

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


1 Files Affected:

- (modified) clang/tools/clang-format/clang-format-diff.py (+2-2) 


``diff
diff --git a/clang/tools/clang-format/clang-format-diff.py 
b/clang/tools/clang-format/clang-format-diff.py
index c82b41e8bd031..e1d635fc85ffb 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -102,9 +102,9 @@ def main():
 filename = None
 lines_by_file = {}
 for line in sys.stdin:
-match = re.search(r"^\+\+\+\ (.*?/){%s}(\S*)" % args.p, line)
+match = re.search(r"^\+\+\+\s+(?:.*?/){%s}(.+)$" % args.p, line)
 if match:
-filename = match.group(2)
+filename = match.group(1).strip()
 if filename is None:
 continue
 

``




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


[clang] Fix filename parsing in clang-format-diff.py for paths with spaces (PR #135779)

2025-04-15 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/135779
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [ARM] Adding diagnostics for mcmodel=tiny when used in invalid targets (PR #125643)

2025-04-15 Thread via cfe-commits

ShashwathiNavada wrote:

@hstk30-hw I have been waiting for approval from @cor3ntin, the PR has been 
open for over 2 months now, can we go ahead and merge this if it's alright?

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


[clang] [libclang/C++] Fix clang_File_isEqual for in-memory files (PR #135773)

2025-04-15 Thread Jannick Kremer via cfe-commits

https://github.com/DeinAlptraum updated 
https://github.com/llvm/llvm-project/pull/135773

>From 62dcfb1cb9bd0918bd471fddc1ffd849c2d604ac Mon Sep 17 00:00:00 2001
From: Jannick Kremer 
Date: Tue, 15 Apr 2025 19:17:43 +0900
Subject: [PATCH 1/2] [libclang/C++] Fix clang_File_isEqual for in-memory files

Add tests for clang_File_isEqual (on-disk and in-memory)
---
 clang/unittests/libclang/LibclangTest.cpp | 49 +++
 1 file changed, 49 insertions(+)

diff --git a/clang/unittests/libclang/LibclangTest.cpp 
b/clang/unittests/libclang/LibclangTest.cpp
index 6de4d02bf74f4..b2a87d240e56e 100644
--- a/clang/unittests/libclang/LibclangTest.cpp
+++ b/clang/unittests/libclang/LibclangTest.cpp
@@ -1410,3 +1410,52 @@ TEST_F(LibclangRewriteTest, RewriteRemove) {
   ASSERT_EQ(clang_CXRewriter_overwriteChangedFiles(Rew), 0);
   EXPECT_EQ(getFileContent(Filename), "int () { return 0; }");
 }
+
+TEST_F(LibclangParseTest, FileEqual) {
+  std::string AInc = "a.inc", BInc = "b.inc", Main = "main.cpp";
+  WriteFile(Main, "int a[] = {\n"
+  "#include \"a.inc\"\n"
+  "};\n"
+  "int b[] = {\n"
+  "#include \"b.inc\"\n"
+  "};");
+  WriteFile(AInc, "1,2,3");
+  WriteFile(BInc, "1,2,3");
+
+  ClangTU = clang_parseTranslationUnit(Index, Main.c_str(), nullptr, 0, 
nullptr,
+   0, TUFlags);
+
+  CXFile AFile = clang_getFile(ClangTU, AInc.c_str()),
+ AFile2 = clang_getFile(ClangTU, AInc.c_str()),
+ BFile = clang_getFile(ClangTU, BInc.c_str()),
+ MainFile = clang_getFile(ClangTU, Main.c_str());
+
+  ASSERT_FALSE(clang_File_isEqual(MainFile, AFile));
+  ASSERT_FALSE(clang_File_isEqual(AFile, BFile));
+  ASSERT_TRUE(clang_File_isEqual(AFile, AFile2));
+}
+
+TEST_F(LibclangParseTest, FileEqualInMemory) {
+  std::string AInc = "a.inc", BInc = "b.inc", Main = "main.cpp";
+  MapUnsavedFile(Main, "int a[] = {\n"
+   "#include \"a.inc\"\n"
+   "};\n"
+   "int b[] = {\n"
+   "#include \"b.inc\"\n"
+   "};");
+  MapUnsavedFile(AInc, "1,2,3");
+  MapUnsavedFile(BInc, "1,2,3");
+
+  ClangTU = clang_parseTranslationUnit(Index, UnsavedFiles[0].Filename, 
nullptr,
+   0, &UnsavedFiles.front(),
+   UnsavedFiles.size(), TUFlags);
+
+  CXFile AFile = clang_getFile(ClangTU, UnsavedFiles[1].Filename),
+ AFile2 = clang_getFile(ClangTU, UnsavedFiles[1].Filename),
+ BFile = clang_getFile(ClangTU, UnsavedFiles[2].Filename),
+ MainFile = clang_getFile(ClangTU, UnsavedFiles[0].Filename);
+
+  ASSERT_FALSE(clang_File_isEqual(MainFile, AFile));
+  ASSERT_FALSE(clang_File_isEqual(AFile, BFile));
+  ASSERT_TRUE(clang_File_isEqual(AFile, AFile2));
+}

>From a98d0ff8a25f394abdea96fb79168e09185fb2d8 Mon Sep 17 00:00:00 2001
From: Jannick Kremer 
Date: Tue, 15 Apr 2025 19:44:10 +0900
Subject: [PATCH 2/2] Add actual fix and release note

---
 clang/docs/ReleaseNotes.rst | 2 ++
 clang/tools/libclang/CIndex.cpp | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5b702b56038f7..08cb4a1144d72 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -557,6 +557,8 @@ clang-format
 
 libclang
 
+- Fixed a bug in ``clang_File_isEqual`` that sometimes led to different 
+  in-memory files to be considered as equal.
 - Added ``clang_visitCXXMethods``, which allows visiting the methods
   of a class.
 
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index c8db6c92bb4d4..2910483152b17 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -5170,7 +5170,7 @@ int clang_File_isEqual(CXFile file1, CXFile file2) {
 
   FileEntryRef FEnt1 = *cxfile::getFileEntryRef(file1);
   FileEntryRef FEnt2 = *cxfile::getFileEntryRef(file2);
-  return FEnt1.getUniqueID() == FEnt2.getUniqueID();
+  return FEnt1 == FEnt2;
 }
 
 CXString clang_File_tryGetRealPathName(CXFile SFile) {

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread via cfe-commits

https://github.com/CarolineConcatto commented:

Hi Jonathan, 
I notice some things that needs to be fixesd

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


[clang] [clang][AST] Handle implicit first argument in CallExpr::getBeginLoc() (PR #135757)

2025-04-15 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 updated 
https://github.com/llvm/llvm-project/pull/135757

>From a1569727c432ba67a96de07c899b562fcf349d1e Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Tue, 15 Apr 2025 03:40:37 -0400
Subject: [PATCH] [clang][AST] Handle implicit first argument in
 CallExpr::getBeginLoc()

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/AST/Expr.cpp | 7 +--
 clang/test/SemaCXX/cxx2b-deducing-this.cpp | 7 +++
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 97de736c4bad3..060a99cfdcc7c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -398,6 +398,8 @@ Bug Fixes in This Version
 
 #if 1 ? 1 : 9
 #endif
+- Fixed a clang 20 regression where diagnostics attached to some calls to 
member functions
+  using C++23 "deducing this" did not have a diagnostic location (#GH135522)
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 5fab2c73f214b..59c0e47c7c195 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1652,8 +1652,11 @@ SourceLocation CallExpr::getBeginLoc() const {
   if (!isTypeDependent()) {
 if (const auto *Method =
 dyn_cast_if_present(getCalleeDecl());
-Method && Method->isExplicitObjectMemberFunction())
-  return getArg(0)->getBeginLoc();
+Method && Method->isExplicitObjectMemberFunction()) {
+  if (auto FirstArgLoc = getArg(0)->getBeginLoc(); FirstArgLoc.isValid()) {
+return FirstArgLoc;
+  }
+}
   }
 
   SourceLocation begin = getCallee()->getBeginLoc();
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp 
b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 6f17ce7275456..7e392213710a4 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1134,3 +1134,10 @@ struct S {
 static_assert((S{} << 11) == a);
 // expected-error@-1 {{use of undeclared identifier 'a'}}
 }
+
+namespace GH135522 {
+struct S {
+  auto f(this auto) -> S;
+  bool g() { return f(); } // expected-error {{no viable conversion from 
returned value of type 'S' to function return type 'bool'}}
+};
+}

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


[clang] Silence -Wcast-function-type warnings on idiomatic Windows code (PR #135660)

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

AaronBallman wrote:

> LGTM. Or should I say, "Thanks, I hate it".
> 
> Do you know how likely it is WG14 come up with a good solution for "arbitrary 
> function pointer" ?

The last we heard on this topic was 
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2230.htm which was discussed 
in Brno in 2018 and the following is from my notes: We had consensus that the 
overall idea of a generic function pointer type is a good one. We took a straw 
poll to determine whether this should be a core language feature: F:14/O:0/A:5, 
which is strong consensus for a language feature rather than library option.

So we need an updated paper (the author of that paper retired from the 
committee).

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


[clang] [llvm] [LLVM] Add intrinsics for v_cvt_pk_norm_{i16, u16}_f16 (PR #135631)

2025-04-15 Thread Acim Maravic via cfe-commits

Acim-Maravic wrote:

> Check code formatting job is failing in a weird way. I can't work out what 
> the issue is.

I have checked locally, and it seems that the whole AMDGPURegisterBankInfo.cpp 
is not clang-formatted... But my change did not introduce any new formatting 
issues... How should I procced? 

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


[clang] [clang][ast]: Add DynamicAllocLValue and TypeInfoLValue support to APValue::dump(). (PR #135178)

2025-04-15 Thread via cfe-commits

YLChenZ wrote:

@tbaederr I don't have access to merge pr. It should require some help to merge.

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


[clang] 9a6c001 - [clang][ast]: Add DynamicAllocLValue and TypeInfoLValue support to APValue::dump(). (#135178)

2025-04-15 Thread via cfe-commits

Author: YLChenZ
Date: 2025-04-15T14:16:09+02:00
New Revision: 9a6c001b125d7d37b8f2c8b96461768c797c4e3f

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

LOG: [clang][ast]: Add DynamicAllocLValue and TypeInfoLValue support to 
APValue::dump(). (#135178)

Closes #134996.
The crash about `TypeInfoLValue` is https://godbolt.org/z/73WY31s55. 
After the patch:
```cpp
//test.cpp
#include 
constexpr const std::type_info* val = &typeid(int);
```
```
lambda@ubuntu22:~/test$ clang++ -std=c++20 -Xclang -ast-dump -fsyntax-only 
test.cpp
LValue Base=TypeInfoLValue typeid(int), Null=0, Offset=0, HasPath=1, 
PathLength=0, Path=()
```

```cpp
//DAtest.cpp
constexpr int *m = new int(42);
```
```
lambda@ubuntu22:~/test$ clang++ -std=c++20 -Xclang -ast-dump -fsyntax-only 
DAtest.cpp
LValue Base=DynamicAllocLValue 'int', Null=0, Offset=0, HasPath=1, 
PathLength=0, Path=()
```

Added: 


Modified: 
clang/lib/AST/TextNodeDumper.cpp
clang/test/AST/ast-dump-APValue-lvalue.cpp

Removed: 




diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index b90f32389c897..c8b459ee78e6b 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -738,6 +738,14 @@ void TextNodeDumper::Visit(const APValue &Value, QualType 
Ty) {
 else if (const auto *BE = B.dyn_cast()) {
   OS << BE->getStmtClassName() << ' ';
   dumpPointer(BE);
+} else if (const auto BTI = B.dyn_cast()) {
+  OS << "TypeInfoLValue ";
+  ColorScope Color(OS, ShowColors, TypeColor);
+  BTI.print(OS, PrintPolicy);
+} else if (B.is()) {
+  OS << "DynamicAllocLValue";
+  auto BDA = B.getDynamicAllocType();
+  dumpType(BDA);
 } else {
   const auto *VDB = B.get();
   OS << VDB->getDeclKindName() << "Decl";

diff  --git a/clang/test/AST/ast-dump-APValue-lvalue.cpp 
b/clang/test/AST/ast-dump-APValue-lvalue.cpp
index 224caddb3eabe..333f7aa419377 100644
--- a/clang/test/AST/ast-dump-APValue-lvalue.cpp
+++ b/clang/test/AST/ast-dump-APValue-lvalue.cpp
@@ -23,6 +23,10 @@ struct F {
 };
 F f;
 
+namespace std {
+  class type_info;
+}
+
 void Test(int (&arr)[10]) {
   constexpr int *pi = &i;
   // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} pi 'int 
*const' constexpr cinit
@@ -45,6 +49,10 @@ void Test(int (&arr)[10]) {
   // CHECK-NEXT:  |   |-value: LValue Base=VarDecl {{.*}}, Null=0, Offset=2, 
HasPath=1, PathLength=2, Path=({{.*}}, 2)
 
   constexpr const int *n = nullptr;
-  // CHECK:`-VarDecl {{.*}}  col:{{.*}} n 'const 
int *const' constexpr cinit
-  // CHECK-NEXT:  |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, 
PathLength=0, Path=()
+  // CHECK:  | `-VarDecl {{.*}}  col:{{.*}} n 'const 
int *const' constexpr cinit
+  // CHECK-NEXT:  |   |-value: LValue Base=null, Null=1, Offset=0, HasPath=1, 
PathLength=0, Path=()
+
+  constexpr const std::type_info* pti = &typeid(int);
+  // CHECK:`-VarDecl {{.*}}  col:{{.*}} pti 'const 
std::type_info *const' constexpr cinit
+  // CHECK-NEXT:  |-value: LValue Base=TypeInfoLValue typeid(int), Null=0, 
Offset=0, HasPath=1, PathLength=0, Path=()
 }



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


[clang] Disable -fdollars-in-identifiers by default (PR #135407)

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

https://github.com/AaronBallman updated 
https://github.com/llvm/llvm-project/pull/135407

>From c7e0132617ab01c12b393876b39381171996b793 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Fri, 11 Apr 2025 13:03:07 -0400
Subject: [PATCH 1/4] Disable -fdollars-in-identifiers by default

Clang used to enable -fdollars-in-identifiers by default for
compatibility with GCC. However, this is no longer a conforming
extension after WG21 P2558R2 and WG14 N2701.

So this disables the dialect by default, which is a potentially
breaking change for users.

Note: some inline assembly constructs may use dollars in identifiers.
We cannot enable the dialect mode automatically based on the user
passing -fasm-blocks because that flag is implied by -fms-extensions
which is enabled by default on Windows, and thus would mean we'd be
enabling a non-conforming language extension by default on that
platform.

Users impacted by the change should explicitly add
-fdollars-in-identifiers to their build scripts.

Partially addresses #128939
---
 clang/docs/ReleaseNotes.rst |  5 +
 clang/include/clang/Basic/LangOptions.def   |  2 +-
 clang/include/clang/Driver/Options.td   |  2 +-
 clang/test/AST/ByteCode/codegen.m   |  2 +-
 clang/test/C/drs/dr0xx.c| 12 ++--
 clang/test/CodeGen/ms-inline-asm.c  |  2 +-
 clang/test/CodeGenObjC/extern-void-class-decl.m |  2 +-
 clang/test/Lexer/dollar-idents.c|  2 +-
 clang/test/Lexer/gh128939.cpp   | 17 +
 clang/test/Preprocessor/c90.c   |  2 +-
 10 files changed, 35 insertions(+), 13 deletions(-)
 create mode 100644 clang/test/Lexer/gh128939.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9c45965dc4d82..fe51de6fd5b7c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -48,6 +48,11 @@ C/C++ Language Potentially Breaking Changes
   ensure they are not caught by these optimizations.  It is also possible to 
use
   ``-fwrapv-pointer`` or   ``-fno-delete-null-pointer-checks`` to make pointer 
arithmetic
   on null pointers well-defined. (#GH130734, #GH130742, #GH130952)
+- Use of the dollar sign (``$``) in an identifier is no longer a conforming
+  extension in either C or C++, so ``-fdollars-in-identifiers`` is no longer
+  enabled by default. Use of the dollar sign in an identifier will now be
+  diagnosed as an error unless ``-fdollars-in-identifiers`` is explicitly
+  enabled.
 
 C++ Specific Potentially Breaking Changes
 -
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 3879cc7942877..f08e179a38067 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -119,7 +119,7 @@ LANGOPT(WChar , 1, 0, "wchar_t keyword")
 LANGOPT(Char8 , 1, 0, "char8_t keyword")
 LANGOPT(IEEE128   , 1, 0, "__ieee128 keyword")
 LANGOPT(DeclSpecKeyword   , 1, 0, "__declspec keyword")
-BENIGN_LANGOPT(DollarIdents   , 1, 1, "'$' in identifiers")
+BENIGN_LANGOPT(DollarIdents   , 1, 0, "'$' in identifiers")
 BENIGN_LANGOPT(AsmPreprocessor, 1, 0, "preprocessor in asm mode")
 LANGOPT(GNUMode   , 1, 1, "GNU extensions")
 LANGOPT(GNUKeywords   , 1, 1, "GNU keywords")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c1020b234b136..38eb332f40d27 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2088,7 +2088,7 @@ def fno_discard_value_names : Flag<["-"], 
"fno-discard-value-names">,
   Group, Visibility<[ClangOption, DXCOption]>,
   HelpText<"Do not discard value names in LLVM IR">;
 defm dollars_in_identifiers : BoolFOption<"dollars-in-identifiers",
-  LangOpts<"DollarIdents">, Default,
+  LangOpts<"DollarIdents">, DefaultFalse,
   PosFlag,
   NegFlag,
   BothFlags<[], [ClangOption, CC1Option], " '$' in identifiers">>;
diff --git a/clang/test/AST/ByteCode/codegen.m 
b/clang/test/AST/ByteCode/codegen.m
index 6139596c6337a..a7b3a100165eb 100644
--- a/clang/test/AST/ByteCode/codegen.m
+++ b/clang/test/AST/ByteCode/codegen.m
@@ -3,7 +3,7 @@
 /// See test/CodeGenObjC/constant-strings.m
 /// Test that we let the APValue we create for ObjCStringLiterals point to the 
right expression.
 
-// RUN: %clang_cc1 -triple x86_64-macho -emit-llvm -o %t %s 
-fexperimental-new-constant-interpreter
+// RUN: %clang_cc1 -triple x86_64-macho -fdollars-in-identifiers  -emit-llvm 
-o %t %s -fexperimental-new-constant-interpreter
 // RUN: FileCheck --check-prefix=CHECK-NEXT < %t %s
 
 // Check that we set alignment 1 on the string.
diff --git a/clang/test/C/drs/dr0xx.c b/clang/test/C/drs/dr0xx.c
index 5fe023deaece9..ffcd63b0cc9a7 100644
--- a/clang/test/C/drs/dr0xx.c
+++ b/clang/test/C/drs/dr0xx.c
@@ -1,9 +1,9 @@
-/* RUN: %clang_cc1 -std=c89 -fsyntax-only -verify=expe

[clang] Silence -Wcast-function-type warnings on idiomatic Windows code (PR #135660)

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


@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -triple x86_64-windows -fsyntax-only 
-Wcast-function-type -Wno-cast-function-type-strict -verify=windows
+// RUN: %clang_cc1 %s -triple x86_64-windows -fsyntax-only 
-Wcast-function-type -Wno-cast-function-type-strict -x c++ -verify=windows
+// RUN: %clang_cc1 %s -triple x86_64-pc-linux -fsyntax-only 
-Wcast-function-type -Wno-cast-function-type-strict -verify=linux
+// RUN: %clang_cc1 %s -triple x86_64-pc-linux -fsyntax-only 
-Wcast-function-type -Wno-cast-function-type-strict -x c++ 
-verify=linux,linux-cpp
+// RUN: %clang_cc1 %s -triple x86_64-windows -fsyntax-only 
-Wcast-function-type -Wcast-function-type-strict -x c++ -verify=strict
+// windows-no-diagnostics
+
+// On Windows targets, this is expected to compile fine, and on non-Windows
+// targets, this should diagnose the mismatch. This is to allow for idiomatic
+// use of GetProcAddress, similar to what we do for dlsym. On non-Windows
+// targets, this should be diagnosed.
+typedef int (*FARPROC1)();
+typedef unsigned long long (*FARPROC2)();
+
+FARPROC1 GetProcAddress1(void);
+FARPROC2 GetProcAddress2(void);
+
+typedef int (*test1_type)(int);
+typedef float(*test2_type)();
+
+void test(void) {
+  // This does not diagnose on Linux in C mode because FARPROC1 has a matching
+  // return type to test1_type, but FARPROC1 has no prototype and so checking
+  // is disabled for further compatibility issues. In C++ mode, all functions
+  // have a prototype and so the check happens.
+  test1_type t1 = (test1_type)GetProcAddress1(); // linux-cpp-warning {{cast 
from 'FARPROC1' (aka 'int (*)()') to 'test1_type' (aka 'int (*)(int)') converts 
to incompatible function type}} \

AaronBallman wrote:

I went ahead and made the change (personally, I prefer line splicing over @-1 
@-2 just because it makes future changes somewhat easier, but I don't feel that 
strongly in such a small file).

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


[clang] Fix filename parsing in clang-format-diff.py for paths with spaces (PR #135779)

2025-04-15 Thread Selim Keles via cfe-commits

https://github.com/selimkeles created 
https://github.com/llvm/llvm-project/pull/135779

Summary: This PR resolves an issue in clang-format-diff.py where filenames 
containing spaces were not correctly extracted from Git diffs. Due to the 
previous regex implementation, filenames were being truncated, causing the 
script to fail when processing diffs with such filenames.

**Details:**

- Adjusted the regex pattern to correctly capture the filename, including 
spaces.
- Ensured compatibility across Linux and Windows environments (tested on WSL 
and Windows).

**Steps to Reproduce:**

Modify a file with spaces in its name, stage the changes, and generate a diff.

Run git diff --cached -U0 --no-color | python3 clang-format-diff.py -p1.

Before the fix, filenames with spaces are incorrectly extracted or cause errors.

 After the fix, filenames with spaces are correctly recognized, and formatting 
differences are processed properly.

**Impact:**

Users relying on clang-format-diff.py in their automated workflows and 
pre-commit hooks will now be able to format files without filename parsing 
issues.

_No changes are made to formatting behavior—only improved filename handling in 
diffs._

_**Maintainer Mentions:**_ Tagging @mydeveloperday and @owenca for review since 
they maintain clang-format and also @owenca reviewed my 
[issue](https://github.com/llvm/llvm-project/issues/135619#issuecomment-2804148179)
 earlier.

_**Note: Also attached the patch file**_ 
[clang-format-space-fix.patch](https://github.com/user-attachments/files/19757014/clang-format-space-fix.patch)


Would love any feedback or suggestions for further refinements! 🚀

>From 606802b8703fa3c1affcc3e52afc22bc3422dcad Mon Sep 17 00:00:00 2001
From: "selim.keles" 
Date: Tue, 15 Apr 2025 14:24:08 +0300
Subject: [PATCH] Fix filename parsing in clang-format-diff.py for files or
 paths with spaces

---
 clang/tools/clang-format/clang-format-diff.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/tools/clang-format/clang-format-diff.py 
b/clang/tools/clang-format/clang-format-diff.py
index c82b41e8bd031..e1d635fc85ffb 100755
--- a/clang/tools/clang-format/clang-format-diff.py
+++ b/clang/tools/clang-format/clang-format-diff.py
@@ -102,9 +102,9 @@ def main():
 filename = None
 lines_by_file = {}
 for line in sys.stdin:
-match = re.search(r"^\+\+\+\ (.*?/){%s}(\S*)" % args.p, line)
+match = re.search(r"^\+\+\+\s+(?:.*?/){%s}(.+)$" % args.p, line)
 if match:
-filename = match.group(2)
+filename = match.group(1).strip()
 if filename is None:
 continue
 

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


[clang] Disable -fdollars-in-identifiers by default (PR #135407)

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


@@ -4036,6 +4036,7 @@ LangOptions getFormattingLangOpts(const FormatStyle 
&Style) {
   LangOpts.MicrosoftExt = 1;// To get kw___try, kw___finally.
   LangOpts.DeclSpecKeyword = 1; // To get __declspec.
   LangOpts.C99 = 1; // To get kw_restrict for non-underscore-prefixed restrict.
+  LangOpts.DollarIdents = 1; // For $identifier$ testing.

AaronBallman wrote:

Good call!

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


[clang] Disable -fdollars-in-identifiers by default (PR #135407)

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

AaronBallman wrote:

> > If we're going to do this, I think we need better diagnostics. Just 
> > straight disabling this is going to give very confusing diagnostics to 
> > anyone actually using dollar-signs in identifiers.
> > Some ideas:
> > ```
> > * We can give a warning if we see a "$" adjacent to an identifier without 
> > any whitespace separating it.
> > 
> > * Outside the preprocessor, we can parse a "$" adjacent to an identifier as 
> > part of the identifier, with some sort of diagnostic, since it's guaranteed 
> > to be an error anyway.
> > ```
> 
> My concern here is with regressing performance of the lexer; testing those 
> conditions when lexing _any_ identifier seems like we'd be spending a lot of 
> time trying to catch a very uncommon issue.
> 
> I think this is reasonable as follow-up work, but I don't think it should 
> hold up this PR because this is fixing a conformance issue. (FWIW, I think 
> the behavior you get currently is something we could live with even if that 
> follow-up work never happened.)

Are you okay with me punting on this work and landing the changes as-os 
@efriedma-quic ?

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


[clang] [Clang][MicrosoftMangle] Implement mangling for ConstantMatrixType (PR #134930)

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

rnk wrote:

We do a similar mangling for our extended vector types, so I would start by 
copying the clang/test/CodeGenCXX/mangle-ms-vector-types.cpp file to 
mangle-ms-matrix.cpp, and add a second RUN line that pipes the result to 
`llvm-cxxfilt` and uses a second FileCheck invocation to validate that the 
right names come back. Hopefully that is enough info to get started. :)

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


[clang] [NFC][analyzer] Document configuration options (PR #135169)

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

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


[clang] [llvm] [Clang][llvm] Implement fp8 FMOP4A intrinsics (PR #130127)

2025-04-15 Thread via cfe-commits


@@ -3107,6 +3107,38 @@ let TargetPrefix = "aarch64" in {
 }
   }
 
+  class SME_FP8_OuterProduct_Intrinsic_Single_Single
+  : DefaultAttrsIntrinsic<[],
+  [llvm_i32_ty,
+  llvm_nxv16i8_ty,
+  llvm_nxv16i8_ty],
+  [ImmArg>, IntrInaccessibleMemOnly, IntrHasSideEffects]>;

CarolineConcatto wrote:

Do we need IntrHasSideEffects for the FP8?

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread via cfe-commits


@@ -3107,6 +3107,23 @@ let TargetPrefix = "aarch64" in {
 }
   }
 
+  class SME_OuterProduct_TMOP_Intrinsic
+ : DefaultAttrsIntrinsic<[],
+ [llvm_i32_ty,
+  llvm_anyvector_ty,
+  LLVMMatchType<0>,
+  LLVMMatchType<0>,
+  llvm_nxv16i8_ty,
+  llvm_i32_ty],
+ [ImmArg>, ImmArg>,
+  IntrInaccessibleMemOnly]>;
+
+  def int_aarch64_sme_tmopa : SME_OuterProduct_TMOP_Intrinsic;

CarolineConcatto wrote:

Ok, it looks like I am wrong about the properties for the ZA instructions:
https://github.com/llvm/llvm-project/pull/132058
According to the changes in the patch above Za should have 
IntrInaccessibleMemOnly.

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


[clang] [llvm] [Clang][llvm] Implement fp8 FMOP4A intrinsics (PR #130127)

2025-04-15 Thread via cfe-commits

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


[clang] [clang][ast]: Add DynamicAllocLValue and TypeInfoLValue support to APValue::dump(). (PR #135178)

2025-04-15 Thread Timm Baeder via cfe-commits

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread Jonathan Thackray via cfe-commits


@@ -0,0 +1,138 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc -force-streaming -verify-machineinstrs < %s | FileCheck %s
+
+target triple = "aarch64-linux"
+
+define void @tmopa_za32_s8( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_s8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:stmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.stmopa.nxv16i8(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_u8( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_u8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:utmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.utmopa.nxv16i8(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_u8_s8( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_u8_s8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ustmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.ustmopa.nxv16i8(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_s8_u8( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_s8_u8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:sutmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.sutmopa.nxv16i8(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_s16( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_s16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:stmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.stmopa.nxv8i16(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_u16( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_u16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:utmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.utmopa.nxv8i16(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_f16( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.nxv8f16(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 
0)
+  ret void
+}
+
+define void @tmopa_za32_bf16( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_bf16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:bftmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.nxv8bf16(i32 0,  
%zn1,  %zn2,  %zm,  
%zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_f32( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.s, { z0.s, z1.s }, z2.s, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.nxv4f32(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, 
i32 0)
+  ret void
+}
+
+define void @tmopa_za16_f16( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za16_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch6

[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread Jonathan Thackray via cfe-commits


@@ -1078,26 +1072,32 @@ let Predicates = [HasSME2p2] in {
 
 } // [HasSME2p2]
 
+let Predicates = [HasSME_TMOP] in {
+  defm FTMOPA_M2ZZZI_HtoS  : sme_tmopa_32b<0b11000, ZZ_h_mul_r, ZPR16, 
nxv8f16,  "ftmopa", int_aarch64_sme_tmopa>;

jthackray wrote:

Thanks, done.

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


[clang] [llvm] [WIP] Clang ABI Types (PR #133080)

2025-04-15 Thread via cfe-commits

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


[clang] [ARM, AArch64] Fix passing of structures with aligned base classes (PR #135564)

2025-04-15 Thread Harald van Dijk via cfe-commits

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


[clang] [llvm] [WIP] Clang ABI Types (PR #133080)

2025-04-15 Thread via cfe-commits

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


[clang] [clang] [CodeGen] fix crash when Ty isDependentType in CodeGenFunction::EmitAutoVarAlloca (PR #135643)

2025-04-15 Thread via cfe-commits

MacroModel wrote:

When I rewrote the project all in header+cpp and wrote all the cppm all in 
header's mode, the bug no longer existed.

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread Jonathan Thackray via cfe-commits


@@ -0,0 +1,138 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc -force-streaming -verify-machineinstrs < %s | FileCheck %s
+
+target triple = "aarch64-linux"
+
+define void @tmopa_za32_s8( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_s8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:stmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.stmopa.nxv16i8(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_u8( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_u8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:utmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.utmopa.nxv16i8(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_u8_s8( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_u8_s8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ustmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.ustmopa.nxv16i8(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_s8_u8( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_s8_u8:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:sutmopa za0.s, { z0.b, z1.b }, z2.b, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.sutmopa.nxv16i8(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_s16( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_s16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:stmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.stmopa.nxv8i16(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_u16( %zn1,  %zn2, 
 %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_u16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:utmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.utmopa.nxv8i16(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_f16( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.nxv8f16(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, i32 
0)
+  ret void
+}
+
+define void @tmopa_za32_bf16( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_bf16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:bftmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.nxv8bf16(i32 0,  
%zn1,  %zn2,  %zm,  
%zk, i32 0)
+  ret void
+}
+
+define void @tmopa_za32_f32( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za32_f32:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.s, { z0.s, z1.s }, z2.s, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch64.sme.tmopa.nxv4f32(i32 0,  %zn1, 
 %zn2,  %zm,  %zk, 
i32 0)
+  ret void
+}
+
+define void @tmopa_za16_f16( %zn1,  
%zn2,  %zm,  %zk) #0 {
+; CHECK-LABEL: tmopa_za16_f16:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:mov z28.d, z3.d
+; CHECK-NEXT:// kill: def $z1 killed $z1 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:// kill: def $z0 killed $z0 killed $z0_z1 def $z0_z1
+; CHECK-NEXT:ftmopa za0.s, { z0.h, z1.h }, z2.h, z28[0]
+; CHECK-NEXT:ret
+  call void @llvm.aarch6

[clang] [ARM, AArch64] Fix passing of structures with aligned base classes (PR #135564)

2025-04-15 Thread Harald van Dijk via cfe-commits


@@ -1302,6 +1302,7 @@ ItaniumRecordLayoutBuilder::LayoutBase(const 
BaseSubobjectInfo *Base) {
 setSize(std::max(getSize(), Offset + Layout.getSize()));
 
   // Remember max struct/class alignment.
+  UnadjustedAlignment = std::max(UnadjustedAlignment, PreferredBaseAlign);

hvdijk wrote:

>From what I can see from the Clang code, for non-HFAs/HVAs, yes, the alignment 
>of the composite type is used rather than the natural alignment, however for 
>HFAs/HVAs, the alignment of the element type is used without regard to the 
>alignment of the composite type. However, this does not seem like it makes any 
>difference because Darwin doesn't have that rule that 16-byte-aligned types 
>are allocated to even-numbered registers anyway, 
>https://godbolt.org/z/qhbYo9c8M

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


[clang] [ARM, AArch64] Fix passing of structures with aligned base classes (PR #135564)

2025-04-15 Thread Harald van Dijk via cfe-commits

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


[libclc] [libclc] Set OpenCL version to 3.0 (PR #135733)

2025-04-15 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

I don't think we want to unconditionally do this - we probably want a mechanism 
whereby targets can opt for a specific version. We should definitely add this 
capability, though.

Targets may even want to compile libclc for multiple different versions? That 
might introduce extra complexity (we'd need "an extra loop", more compilation 
time, new naming/versioning schemes for the build artifacts).

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


[clang] [llvm] [LLVM] Add intrinsics for v_cvt_pk_norm_{i16, u16}_f16 (PR #135631)

2025-04-15 Thread David Stuttard via cfe-commits

dstutt wrote:

Check code formatting job is failing in a weird way. I can't work out what the 
issue is.

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


[clang] [llvm] [WIP] Clang ABI Types (PR #133080)

2025-04-15 Thread via cfe-commits

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


[clang] [NFC][analyzer] Document configuration options (PR #135169)

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


@@ -0,0 +1,242 @@
+#!/usr/bin/env python3
+# A tool to automatically generate documentation for the config options of the
+# clang static analyzer by reading `AnalyzerOptions.def`.
+
+import argparse
+from collections import namedtuple
+from enum import Enum, auto
+import re
+import sys
+import textwrap
+
+
+# The following code implements a trivial parser for the narrow subset of C++
+# which is used in AnalyzerOptions.def. This supports the following features:
+# - ignores preprocessor directives, even if they are continued with \ at EOL
+# - ignores comments: both /* ... */ and // ...
+# - parses string literals (even if they contain \" escapes)
+# - concatenates adjacent string literals
+# - parses numbers even if they contain ' as a thousands separator
+# - recognizes MACRO(arg1, arg2, ..., argN) calls
+
+
+class TT(Enum):
+"Token type enum."
+number = auto()
+ident = auto()
+string = auto()
+punct = auto()
+
+
+TOKENS = [
+(re.compile(r"-?[0-9']+"), TT.number),
+(re.compile(r"\w+"), TT.ident),
+(re.compile(r'"([^\\"]|\\.)*"'), TT.string),
+(re.compile(r"[(),]"), TT.punct),
+(re.compile(r"/\*((?!\*/).)*\*/", re.S), None),  # C-style comment
+(re.compile(r"//.*\n"), None),  # C++ style oneline comment
+(re.compile(r"#.*(\\\n.*)*(?", which is
+# OK for a terse command line printout, but should be prettified for web
+# documentation.
+# Moreover, the option ctu-invocation-list shows some example file content
+# which is formatted as a preformatted block.
+paragraphs = [desc]
+extra = ""
+if m := re.search(r"(^|\s)Value:", desc):
+paragraphs = [desc[: m.start()], "Accepted values:" + desc[m.end() :]]
+elif m := re.search(r"\s*Example file.content:", desc):
+paragraphs = [desc[: m.start()]]
+extra = "Example file content::\n\n  " + desc[m.end() :] + "\n\n"
+
+wrapped = [textwrap.fill(p, width=80) for p in paragraphs if p.strip()]
+
+return "\n\n".join(wrapped + [""]) + extra
+
+
+def default_to_rst(tok):
+if tok.kind == TT.string:
+if tok.code == '""':
+return "(empty string)"
+return tok.code
+if tok.kind == TT.ident:
+return tok.code
+if tok.kind == TT.number:
+return tok.code.replace("'", "")
+raise ValueError(f"unexpected token as default value: {tok.kind.name}")
+
+
+def defaults_to_rst_paragraph(defaults):
+strs = [default_to_rst(d) for d in defaults]
+
+if len(strs) == 1:
+return f"Default value: {strs[0]}\n\n"
+if len(strs) == 2:
+return (
+f"Default value: {strs[0]} (in shallow mode) / {strs[1]} (in deep 
mode)\n\n"
+)
+raise ValueError("unexpected count of default values: %d" % len(defaults))
+
+
+def macro_call_to_rst_paragraphs(macro_call):
+if len(macro_call.args) != MACRO_NAMES_ARGCOUNTS[macro_call.name]:
+return ""
+
+try:
+_, _, cmdflag, desc, *defaults = macro_call.args
+
+return (
+cmdflag_to_rst_title(cmdflag)
++ desc_to_rst_paragraphs(desc)
++ defaults_to_rst_paragraph(defaults)
+)
+except ValueError as ve:
+print(ve.args[0], file=sys.stderr)
+return ""

NagyDonat wrote:

Yep, I implemented some "fail gracefully" printouts for the situations where 
the script runs into an unexpected situation, but I wouldn't say that these are 
supported features of the script. As this code is only intended for one very 
specific non-user-facing role, I think even removing the error handling is more 
reasonable than writing tests for it.

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


[clang] [NFC][analyzer] Document configuration options (PR #135169)

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


@@ -0,0 +1,102 @@
+
+Configuring the Analyzer
+
+
+The clang static analyzer supports two kinds of options:
+
+1. Global **analyzer options** influence the behavior of the analyzer engine.
+   They are documented on this page, in the section :ref:`List of analyzer
+   options`.
+2. The **checker options** belong to individual checkers (e.g.
+   ``core.BitwiseShift:Pedantic`` and ``unix.Stream:Pedantic`` are completely
+   separate options) and customize the behavior of that particular checker.
+   These are documented within the documentation of each individual checker at
+   :doc:`../checkers`.
+
+Assigning values to options
+===
+
+With the compiler frontend
+--
+
+All options can be configured by using the ``-analyzer-config`` flag of ``clang
+-cc1`` (the so-called *compiler frontend* part of clang). The values of the
+options are specified with the syntax ``-analyzer-config
+OPT=VAL,OPT2=VAL2,...`` which supports specifying multiple options, but
+separate flags like ``-analyzer-config OPT=VAL -analyzer-config OPT2=VAL2`` are
+also accepted (with equivalent behavior). Analyzer options and checker options
+can be freely intermixed here because it's easy to recognize that checker
+option names are always prefixed with ``some.groups.NameOfChecker:``.
+
+With the clang driver
+-
+
+In a conventional workflow ``clang -cc1`` (which is a low-level internal
+interface) is invoked indirectly by the clang *driver* (i.e. plain ``clang``
+without the ``-cc1`` flag), which acts as an "even more frontend" wrapper layer
+around the ``clang -cc1`` *compiler frontend*. In this situation **each**
+command line argument intended for the *compiler frontend* must be prefixed
+with ``-Xclang``.

NagyDonat wrote:

OK, I'll add a disclaimer and perhaps document `-Xanalyzer` if that works as 
well.

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


[clang] Silence -Wcast-function-type warnings on idiomatic Windows code (PR #135660)

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


@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 %s -triple x86_64-windows -fsyntax-only 
-Wcast-function-type -Wno-cast-function-type-strict -verify=windows
+// RUN: %clang_cc1 %s -triple x86_64-windows -fsyntax-only 
-Wcast-function-type -Wno-cast-function-type-strict -x c++ -verify=windows
+// RUN: %clang_cc1 %s -triple x86_64-pc-linux -fsyntax-only 
-Wcast-function-type -Wno-cast-function-type-strict -verify=linux
+// RUN: %clang_cc1 %s -triple x86_64-pc-linux -fsyntax-only 
-Wcast-function-type -Wno-cast-function-type-strict -x c++ 
-verify=linux,linux-cpp
+// RUN: %clang_cc1 %s -triple x86_64-windows -fsyntax-only 
-Wcast-function-type -Wcast-function-type-strict -x c++ -verify=strict
+// windows-no-diagnostics
+
+// On Windows targets, this is expected to compile fine, and on non-Windows
+// targets, this should diagnose the mismatch. This is to allow for idiomatic
+// use of GetProcAddress, similar to what we do for dlsym. On non-Windows
+// targets, this should be diagnosed.
+typedef int (*FARPROC1)();
+typedef unsigned long long (*FARPROC2)();
+
+FARPROC1 GetProcAddress1(void);
+FARPROC2 GetProcAddress2(void);
+
+typedef int (*test1_type)(int);
+typedef float(*test2_type)();
+
+void test(void) {
+  // This does not diagnose on Linux in C mode because FARPROC1 has a matching
+  // return type to test1_type, but FARPROC1 has no prototype and so checking
+  // is disabled for further compatibility issues. In C++ mode, all functions
+  // have a prototype and so the check happens.
+  test1_type t1 = (test1_type)GetProcAddress1(); // linux-cpp-warning {{cast 
from 'FARPROC1' (aka 'int (*)()') to 'test1_type' (aka 'int (*)(int)') converts 
to incompatible function type}} \

rnk wrote:

I do like @+1 syntax for readability, but that's a nice-to-have.

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


[clang] [clang][ast]: Add DynamicAllocLValue and TypeInfoLValue support to APValue::dump(). (PR #135178)

2025-04-15 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Can you merge this or do you need to someone else to do it for you?

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread Jonathan Thackray via cfe-commits


@@ -0,0 +1,138 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 4
+; RUN: llc -force-streaming -verify-machineinstrs < %s | FileCheck %s
+
+target triple = "aarch64-linux"
+
+define void @tmopa_za32_s8( %zn1,  %zn2, 
 %zm,  %zk) #0 {

jthackray wrote:

I think I've added enough test coverage now. Let me know if you spot anything 
I've missed.

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


[clang] [clang] Mark some language options as benign. (PR #131569)

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

erichkeane wrote:

> I think this looks fine but I'd like @Bigcheese @erichkeane @AaronBallman to 
> look at it too.

This looks fine as far as I can tell.  Though, I'm not sure I have sufficient 
knowledge to be comfortable enough with the implications to approve this. 
@Bigcheese and @ChuanqiXu9 might be the most knowledgeable.

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


[clang] 535eaa4 - [clang][test] Improve unit tests for Fixed point AST matchers. (#134398)

2025-04-15 Thread via cfe-commits

Author: earnol
Date: 2025-04-15T09:32:45-04:00
New Revision: 535eaa4f3be5dda5cf3aa13348aac8d9a27d20f0

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

LOG: [clang][test] Improve unit tests for Fixed point AST matchers. (#134398)

We have AST matchers for fixed point float numbers since commits
789215dc0db174c9fdd273436fdd60d8289a9fc0 and
ff9120636e9c890b4db735d252d16b92091dde55. However in those commits the
unit tests were not added. Amending the test suit by adding missing
tests.

Co-authored-by: Vladislav Aranov 

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTest.h

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 20f70863a05b3..529c6228bfa19 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -1564,6 +1564,9 @@ class FixedPointLiteral : public Expr, public 
APIntStorage {
   /// Returns an empty fixed-point literal.
   static FixedPointLiteral *Create(const ASTContext &C, EmptyShell Empty);
 
+  /// Returns an internal integer representation of the literal.
+  llvm::APInt getValue() const { return APIntStorage::getValue(); }
+
   SourceLocation getBeginLoc() const LLVM_READONLY { return Loc; }
   SourceLocation getEndLoc() const LLVM_READONLY { return Loc; }
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 55a925bf86909..c1130ff70cf5c 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1733,9 +1733,10 @@ class ForEachDescendantMatcher : public 
MatcherInterface {
 template 
 class ValueEqualsMatcher : public SingleNodeMatcherInterface {
   static_assert(std::is_base_of::value ||
-std::is_base_of::value ||
-std::is_base_of::value ||
-std::is_base_of::value,
+std::is_base_of::value ||
+std::is_base_of::value ||
+std::is_base_of::value ||
+std::is_base_of::value,
 "the node must have a getValue method");
 
 public:

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 680e21840b7d3..07450a0c59ec6 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1017,6 +1017,67 @@ TEST_P(ASTMatchersTest, FloatLiteral) {
   notMatches("double i = 5.0;", floatLiteral(equals(llvm::APFloat(6.0);
 }
 
+TEST_P(ASTMatchersTest, FixedPointLiterals) {
+  StatementMatcher HasFixedPointLiteral = fixedPointLiteral();
+  EXPECT_TRUE(matchesWithFixedpoint("_Fract i = 0.25r;", 
HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Fract i = 0.25hr;", HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Fract i = 0.25uhr;", HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Fract i = 0.25ur;", HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Fract i = 0.25lr;", HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Fract i = 0.25ulr;", HasFixedPointLiteral));
+  EXPECT_TRUE(matchesWithFixedpoint("_Accum i = 1.25k;", 
HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Accum i = 1.25hk;", HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Accum i = 1.25uhk;", HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Accum i = 1.25uk;", HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Accum i = 1.25lk;", HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Accum i = 1.25ulk;", HasFixedPointLiteral));
+  EXPECT_TRUE(matchesWithFixedpoint("_Accum decexp1 = 1.575e1k;",
+HasFixedPointLiteral));
+  EXPECT_TRUE(
+  matchesWithFixedpoint("_Accum hex = 0x1.25fp2k;", HasFixedPointLiteral));
+  EXPECT_TRUE(matchesWithFixedpoint("_Sat long _Fract i = 0.25r;",
+HasFixedPointLiteral));
+  EXPECT_TRUE(matchesWithFixedpoint("_Sat short _Accum i = 256.0k;",
+HasFixedPointLiteral));
+  EXPECT_TRUE(matchesWithFixedpoint(
+  "_Accum i = 256.0k;",
+  fixedPointLiteral(equals(llvm::APInt(32, 0x80, true);
+  EXPECT_TRUE(matchesWithFixedpoint(
+  "_Fract i = 0.25ulr;",
+  fixedPointLiteral(equals(llvm::APInt(32, 0x4000, false);
+  EXPECT_TRUE(matchesWithFixedpoint(
+  "_Fract i = 0.5hr;",
+  fixedPointLit

[clang] [CodeGen] Fix new-delete-type-mismatch in ~CodeGenTypes() (PR #135787)

2025-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: mikit (m1kit)


Changes

It is undefined behavior to use `delete` expression on something which was not 
created with corresponding `new` expression. Switching to explicit global 
`operator delete()` call to match with `operator new()` call at 
`CGFunctionInfo::create()`.

This issue is raised by Chromium ClusterFuzz, with ASan enabled. 
https://crbug.com/410141973

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


1 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+1-1) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index b94c11802a268..dec3b087b107f 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -41,7 +41,7 @@ CodeGenTypes::CodeGenTypes(CodeGenModule &cgm)
 CodeGenTypes::~CodeGenTypes() {
   for (llvm::FoldingSet::iterator
I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )
-delete &*I++;
+operator delete(&*I++);
 }
 
 CGCXXABI &CodeGenTypes::getCXXABI() const { return getCGM().getCXXABI(); }

``




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


[clang] [CodeGen] Fix new-delete-type-mismatch in ~CodeGenTypes() (PR #135787)

2025-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: mikit (m1kit)


Changes

It is undefined behavior to use `delete` expression on something which was not 
created with corresponding `new` expression. Switching to explicit global 
`operator delete()` call to match with `operator new()` call at 
`CGFunctionInfo::create()`.

This issue is raised by Chromium ClusterFuzz, with ASan enabled. 
https://crbug.com/410141973

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


1 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenTypes.cpp (+1-1) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index b94c11802a268..dec3b087b107f 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -41,7 +41,7 @@ CodeGenTypes::CodeGenTypes(CodeGenModule &cgm)
 CodeGenTypes::~CodeGenTypes() {
   for (llvm::FoldingSet::iterator
I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )
-delete &*I++;
+operator delete(&*I++);
 }
 
 CGCXXABI &CodeGenTypes::getCXXABI() const { return getCGM().getCXXABI(); }

``




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


[clang] [clang][test] Improve unit tests for Fixed point AST matchers. (PR #134398)

2025-04-15 Thread via cfe-commits

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


[clang] [ARM, AArch64] Fix passing of structures with aligned base classes (PR #135564)

2025-04-15 Thread Harald van Dijk via cfe-commits

hvdijk wrote:

Updated to use `BaseAlign`. Knowing that it does not affect Apple and Microsoft 
calling conventions, is it okay to merge then?

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


[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

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

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

>From 6f0a3ba5852134d8bd04679438866e6f373f494a Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 15 Apr 2025 12:12:19 +0800
Subject: [PATCH 1/6] [Clang] Add support for GCC bound member functions
 extension

---
 clang/include/clang/AST/OperationKinds.def|  4 ++
 clang/include/clang/Basic/DiagnosticGroups.td | 32 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  4 ++
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  1 +
 clang/lib/AST/Expr.cpp|  5 ++
 clang/lib/AST/ExprConstant.cpp|  2 +
 clang/lib/CIR/CodeGen/CIRGenExpr.cpp  |  1 +
 clang/lib/CodeGen/CGExpr.cpp  |  1 +
 clang/lib/CodeGen/CGExprAgg.cpp   |  2 +
 clang/lib/CodeGen/CGExprComplex.cpp   |  1 +
 clang/lib/CodeGen/CGExprConstant.cpp  |  1 +
 clang/lib/CodeGen/CGExprScalar.cpp|  1 +
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 24 ++-
 clang/lib/Edit/RewriteObjCFoundationAPI.cpp   |  1 +
 clang/lib/Sema/SemaCast.cpp   | 63 +++
 .../StaticAnalyzer/Core/BasicValueFactory.cpp |  3 +-
 clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp |  3 +-
 17 files changed, 129 insertions(+), 20 deletions(-)

diff --git a/clang/include/clang/AST/OperationKinds.def 
b/clang/include/clang/AST/OperationKinds.def
index 790dd572a7c99..489d89a697dc3 100644
--- a/clang/include/clang/AST/OperationKinds.def
+++ b/clang/include/clang/AST/OperationKinds.def
@@ -152,6 +152,10 @@ CAST_OPERATION(MemberPointerToBoolean)
 /// many ABIs do not guarantee this on all possible intermediate types).
 CAST_OPERATION(ReinterpretMemberPointer)
 
+/// CK_BoundPointerToMemberFunctionToFunctionPointer - Convert a bound
+/// member function pointer to a function pointer.  This is a GNU extension.
+CAST_OPERATION(BoundMemberFunctionToFunctionPointer)
+
 /// CK_UserDefinedConversion - Conversion using a user defined type
 /// conversion function.
 ///struct A { operator int(); }; int i = int(A());
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index d97bbfee2e4d5..8e5a4cba87c95 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -795,6 +795,7 @@ def DuplicateDeclSpecifier : 
DiagGroup<"duplicate-decl-specifier">;
 def CompareDistinctPointerType : DiagGroup<"compare-distinct-pointer-types">;
 def GNUUnionCast : DiagGroup<"gnu-union-cast">;
 def GNUVariableSizedTypeNotAtEnd : 
DiagGroup<"gnu-variable-sized-type-not-at-end">;
+def GNUPMFCast : DiagGroup<"pmf-conversions">;
 def Varargs : DiagGroup<"varargs">;
 def XorUsedAsPow : DiagGroup<"xor-used-as-pow">;
 
@@ -1294,22 +1295,21 @@ def C2y : DiagGroup<"c2y-extensions">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;
 
 // A warning group for warnings about GCC extensions.
-def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUAnonymousStruct,
-GNUAutoType, GNUBinaryLiteral, GNUCaseRange,
-GNUComplexInteger, GNUCompoundLiteralInitializer,
-GNUConditionalOmittedOperand, GNUDesignator,
-GNUEmptyStruct,
-VLAExtension, GNUFlexibleArrayInitializer,
-GNUFlexibleArrayUnionMember, GNUFoldingConstant,
-GNUImaginaryConstant, GNUIncludeNext,
-GNULabelsAsValue, GNULineMarker, 
GNUNullPointerArithmetic,
-GNUOffsetofExtensions, GNUPointerArith,
-RedeclaredClassMember, GNURedeclaredEnum,
-GNUStatementExpression, GNUStaticFloatInit,
-GNUStringLiteralOperatorTemplate, GNUUnionCast,
-GNUVariableSizedTypeNotAtEnd, ZeroLengthArray,
-GNUZeroLineDirective,
-GNUZeroVariadicMacroArguments]>;
+def GNU
+: DiagGroup<
+  "gnu", [GNUAlignofExpression, GNUAnonymousStruct, GNUAutoType,
+  GNUBinaryLiteral, GNUCaseRange, GNUComplexInteger,
+  GNUCompoundLiteralInitializer, GNUConditionalOmittedOperand,
+  GNUDesignator, GNUEmptyStruct, VLAExtension,
+  GNUFlexibleArrayInitializer, GNUFlexibleArrayUnionMember,
+  GNUFoldingConstant, GNUImaginaryConstant, GNUIncludeNext,
+  GNULabelsAsValue, GNULineMarker, GNUNullPointerArithmetic,
+  GNUOffsetofExtensions, GNUPointerArith, 
RedeclaredClassMember,
+  GNURedeclaredEnum, GNUStatementExpression, 
GNUStaticFloatInit,
+  GNUStringLiteralOperatorTemplate, GNUUnionCast,
+  GNUVariableSizedTypeNotAtEnd, ZeroLengthArray,
+  GNUZeroLineDirective, GNUZeroVariadicMacr

[clang] [CodeGen] Fix new-delete-type-mismatch in ~CodeGenTypes() (PR #135787)

2025-04-15 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/135787
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ARM, AArch64] Fix passing of structures with aligned base classes (PR #135564)

2025-04-15 Thread Harald van Dijk via cfe-commits

https://github.com/hvdijk updated 
https://github.com/llvm/llvm-project/pull/135564

>From 146ac68a2838c0b51551abd11b3404152bcbfc75 Mon Sep 17 00:00:00 2001
From: Harald van Dijk 
Date: Sun, 13 Apr 2025 21:47:54 +0100
Subject: [PATCH] [ARM, AArch64] Fix passing of structures with aligned base
 classes

RecordLayout::UnadjustedAlignment was documented as "Maximum of the
alignments of the record members in characters", but
RecordLayout::getUnadjustedAlignment(), which just returns
UnadjustedAlignment, was documented as getting "the record alignment in
characters, before alignment adjustement." These are not the same thing:
the former excludes alignment of base classes, the latter takes it into
account. ItaniumRecordLayoutBuilder::LayoutBase was setting it according
to the former, but the AAPCS calling convention handling, currently the
only user, relies on it being set according to the latter.

Fixes #135551.
---
 clang/include/clang/AST/RecordLayout.h  |  7 +--
 clang/lib/AST/RecordLayoutBuilder.cpp   |  1 +
 clang/test/CodeGen/aapcs64-align.cpp| 57 +
 clang/test/CodeGen/arm-vfp16-arguments2.cpp |  2 +-
 4 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/clang/include/clang/AST/RecordLayout.h 
b/clang/include/clang/AST/RecordLayout.h
index dd18f9c49f84f..6cf08e76396e2 100644
--- a/clang/include/clang/AST/RecordLayout.h
+++ b/clang/include/clang/AST/RecordLayout.h
@@ -75,8 +75,9 @@ class ASTRecordLayout {
   // performance or backwards compatibility preserving (e.g. AIX-ABI).
   CharUnits PreferredAlignment;
 
-  // UnadjustedAlignment - Maximum of the alignments of the record members in
-  // characters.
+  // UnadjustedAlignment - Alignment of record in characters before alignment
+  // adjustments. Maximum of the alignments of the record members and base
+  // classes in characters.
   CharUnits UnadjustedAlignment;
 
   /// RequiredAlignment - The required alignment of the object.  In the MS-ABI
@@ -186,7 +187,7 @@ class ASTRecordLayout {
   CharUnits getPreferredAlignment() const { return PreferredAlignment; }
 
   /// getUnadjustedAlignment - Get the record alignment in characters, before
-  /// alignment adjustement.
+  /// alignment adjustment.
   CharUnits getUnadjustedAlignment() const { return UnadjustedAlignment; }
 
   /// getSize - Get the record size in characters.
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp 
b/clang/lib/AST/RecordLayoutBuilder.cpp
index ea353f88a8aec..dd932f6179f88 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1302,6 +1302,7 @@ ItaniumRecordLayoutBuilder::LayoutBase(const 
BaseSubobjectInfo *Base) {
 setSize(std::max(getSize(), Offset + Layout.getSize()));
 
   // Remember max struct/class alignment.
+  UnadjustedAlignment = std::max(UnadjustedAlignment, BaseAlign);
   UpdateAlignment(BaseAlign, UnpackedAlignTo, PreferredBaseAlign);
 
   return Offset;
diff --git a/clang/test/CodeGen/aapcs64-align.cpp 
b/clang/test/CodeGen/aapcs64-align.cpp
index e69faf231936c..f9be94b8ec58e 100644
--- a/clang/test/CodeGen/aapcs64-align.cpp
+++ b/clang/test/CodeGen/aapcs64-align.cpp
@@ -67,6 +67,21 @@ void g3() {
 // CHECK: declare void @f3(i64 noundef, i128)
 // CHECK: declare void @f3m(i64 noundef, i64 noundef, i64 noundef, i64 
noundef, i64 noundef, i128)
 
+// Increased natural alignment through a base class.
+struct SB16 : S16 {};
+
+void f4(long, SB16);
+void f4m(long, long, long, long, long, SB16);
+void g4() {
+  SB16 s = {6, 7};
+  f4(1, s);
+  f4m(1, 2, 3, 4, 5, s);
+}
+// CHECK: define{{.*}} void @g4
+// CHECK: call void @f4(i64 noundef 1, i128 129127208515966861318)
+// CHECK: call void @f4m(i64 noundef 1, i64 noundef 2, i64 noundef 3, i64 
noundef 4, i64 noundef 5, i128 129127208515966861318)
+// CHECK: declare void @f4(i64 noundef, i128)
+// CHECK: declare void @f4m(i64 noundef, i64 noundef, i64 noundef, i64 
noundef, i64 noundef, i128)
 
 // Packed structure.
 struct  __attribute__((packed)) P {
@@ -74,18 +89,18 @@ struct  __attribute__((packed)) P {
   long u;
 };
 
-void f4(int, P);
-void f4m(int, int, int, int, int, P);
-void g4() {
+void f5(int, P);
+void f5m(int, int, int, int, int, P);
+void g5() {
   P s = {6, 7};
-  f4(1, s);
-  f4m(1, 2, 3, 4, 5, s);
+  f5(1, s);
+  f5m(1, 2, 3, 4, 5, s);
 }
-// CHECK: define{{.*}} void @g4()
-// CHECK: call void @f4(i32 noundef 1, [2 x i64] [i64 30064771078, i64 0])
-// CHECK: void @f4m(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 
4, i32 noundef 5, [2 x i64] [i64 30064771078, i64 0])
-// CHECK: declare void @f4(i32 noundef, [2 x i64])
-// CHECK: declare void @f4m(i32 noundef, i32 noundef, i32 noundef, i32 
noundef, i32 noundef, [2 x i64])
+// CHECK: define{{.*}} void @g5()
+// CHECK: call void @f5(i32 noundef 1, [2 x i64] [i64 30064771078, i64 0])
+// CHECK: void @f5m(i32 noundef 1, i32 noundef 2, i32 noundef 3, i32 noundef 
4, i32 noundef 5, [2 x i64] [i64 30064771078, i64 0])
+// CHECK: declare void @f5(i32

[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

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

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

>From 6f0a3ba5852134d8bd04679438866e6f373f494a Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 15 Apr 2025 12:12:19 +0800
Subject: [PATCH 1/7] [Clang] Add support for GCC bound member functions
 extension

---
 clang/include/clang/AST/OperationKinds.def|  4 ++
 clang/include/clang/Basic/DiagnosticGroups.td | 32 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  4 ++
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  1 +
 clang/lib/AST/Expr.cpp|  5 ++
 clang/lib/AST/ExprConstant.cpp|  2 +
 clang/lib/CIR/CodeGen/CIRGenExpr.cpp  |  1 +
 clang/lib/CodeGen/CGExpr.cpp  |  1 +
 clang/lib/CodeGen/CGExprAgg.cpp   |  2 +
 clang/lib/CodeGen/CGExprComplex.cpp   |  1 +
 clang/lib/CodeGen/CGExprConstant.cpp  |  1 +
 clang/lib/CodeGen/CGExprScalar.cpp|  1 +
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 24 ++-
 clang/lib/Edit/RewriteObjCFoundationAPI.cpp   |  1 +
 clang/lib/Sema/SemaCast.cpp   | 63 +++
 .../StaticAnalyzer/Core/BasicValueFactory.cpp |  3 +-
 clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp |  3 +-
 17 files changed, 129 insertions(+), 20 deletions(-)

diff --git a/clang/include/clang/AST/OperationKinds.def 
b/clang/include/clang/AST/OperationKinds.def
index 790dd572a7c99..489d89a697dc3 100644
--- a/clang/include/clang/AST/OperationKinds.def
+++ b/clang/include/clang/AST/OperationKinds.def
@@ -152,6 +152,10 @@ CAST_OPERATION(MemberPointerToBoolean)
 /// many ABIs do not guarantee this on all possible intermediate types).
 CAST_OPERATION(ReinterpretMemberPointer)
 
+/// CK_BoundPointerToMemberFunctionToFunctionPointer - Convert a bound
+/// member function pointer to a function pointer.  This is a GNU extension.
+CAST_OPERATION(BoundMemberFunctionToFunctionPointer)
+
 /// CK_UserDefinedConversion - Conversion using a user defined type
 /// conversion function.
 ///struct A { operator int(); }; int i = int(A());
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index d97bbfee2e4d5..8e5a4cba87c95 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -795,6 +795,7 @@ def DuplicateDeclSpecifier : 
DiagGroup<"duplicate-decl-specifier">;
 def CompareDistinctPointerType : DiagGroup<"compare-distinct-pointer-types">;
 def GNUUnionCast : DiagGroup<"gnu-union-cast">;
 def GNUVariableSizedTypeNotAtEnd : 
DiagGroup<"gnu-variable-sized-type-not-at-end">;
+def GNUPMFCast : DiagGroup<"pmf-conversions">;
 def Varargs : DiagGroup<"varargs">;
 def XorUsedAsPow : DiagGroup<"xor-used-as-pow">;
 
@@ -1294,22 +1295,21 @@ def C2y : DiagGroup<"c2y-extensions">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;
 
 // A warning group for warnings about GCC extensions.
-def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUAnonymousStruct,
-GNUAutoType, GNUBinaryLiteral, GNUCaseRange,
-GNUComplexInteger, GNUCompoundLiteralInitializer,
-GNUConditionalOmittedOperand, GNUDesignator,
-GNUEmptyStruct,
-VLAExtension, GNUFlexibleArrayInitializer,
-GNUFlexibleArrayUnionMember, GNUFoldingConstant,
-GNUImaginaryConstant, GNUIncludeNext,
-GNULabelsAsValue, GNULineMarker, 
GNUNullPointerArithmetic,
-GNUOffsetofExtensions, GNUPointerArith,
-RedeclaredClassMember, GNURedeclaredEnum,
-GNUStatementExpression, GNUStaticFloatInit,
-GNUStringLiteralOperatorTemplate, GNUUnionCast,
-GNUVariableSizedTypeNotAtEnd, ZeroLengthArray,
-GNUZeroLineDirective,
-GNUZeroVariadicMacroArguments]>;
+def GNU
+: DiagGroup<
+  "gnu", [GNUAlignofExpression, GNUAnonymousStruct, GNUAutoType,
+  GNUBinaryLiteral, GNUCaseRange, GNUComplexInteger,
+  GNUCompoundLiteralInitializer, GNUConditionalOmittedOperand,
+  GNUDesignator, GNUEmptyStruct, VLAExtension,
+  GNUFlexibleArrayInitializer, GNUFlexibleArrayUnionMember,
+  GNUFoldingConstant, GNUImaginaryConstant, GNUIncludeNext,
+  GNULabelsAsValue, GNULineMarker, GNUNullPointerArithmetic,
+  GNUOffsetofExtensions, GNUPointerArith, 
RedeclaredClassMember,
+  GNURedeclaredEnum, GNUStatementExpression, 
GNUStaticFloatInit,
+  GNUStringLiteralOperatorTemplate, GNUUnionCast,
+  GNUVariableSizedTypeNotAtEnd, ZeroLengthArray,
+  GNUZeroLineDirective, GNUZeroVariadicMacr

[libclc] 5529024 - [libclc] Add ctz built-in implementation to clc and generic (#135309)

2025-04-15 Thread via cfe-commits

Author: Wenju He
Date: 2025-04-15T15:23:25+01:00
New Revision: 552902455c7a3958930d4607ac8b85fd39d7c8a3

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

LOG: [libclc] Add ctz built-in implementation to clc and generic (#135309)

Added: 
libclc/clc/include/clc/integer/clc_ctz.h
libclc/clc/lib/generic/integer/clc_ctz.cl
libclc/generic/include/clc/integer/ctz.h
libclc/generic/lib/integer/ctz.cl

Modified: 
libclc/clc/lib/generic/SOURCES
libclc/generic/include/clc/clc.h
libclc/generic/lib/SOURCES

Removed: 




diff  --git a/libclc/clc/include/clc/integer/clc_ctz.h 
b/libclc/clc/include/clc/integer/clc_ctz.h
new file mode 100644
index 0..1e6365100827b
--- /dev/null
+++ b/libclc/clc/include/clc/integer/clc_ctz.h
@@ -0,0 +1,20 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef __CLC_INTEGER_CLC_CTZ_H__
+#define __CLC_INTEGER_CLC_CTZ_H__
+
+#define __CLC_FUNCTION __clc_ctz
+#define __CLC_BODY 
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endif // __CLC_INTEGER_CLC_CTZ_H__

diff  --git a/libclc/clc/lib/generic/SOURCES b/libclc/clc/lib/generic/SOURCES
index 4503a20ad9848..1e73627c3a270 100644
--- a/libclc/clc/lib/generic/SOURCES
+++ b/libclc/clc/lib/generic/SOURCES
@@ -7,6 +7,7 @@ integer/clc_abs.cl
 integer/clc_abs_
diff .cl
 integer/clc_add_sat.cl
 integer/clc_clz.cl
+integer/clc_ctz.cl
 integer/clc_hadd.cl
 integer/clc_mad24.cl
 integer/clc_mad_sat.cl

diff  --git a/libclc/clc/lib/generic/integer/clc_ctz.cl 
b/libclc/clc/lib/generic/integer/clc_ctz.cl
new file mode 100644
index 0..50fda4a214b24
--- /dev/null
+++ b/libclc/clc/lib/generic/integer/clc_ctz.cl
@@ -0,0 +1,48 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include 
+#include 
+#include 
+
+_CLC_OVERLOAD _CLC_DEF char __clc_ctz(char x) {
+  return __clc_ctz(__clc_as_uchar(x));
+}
+
+_CLC_OVERLOAD _CLC_DEF uchar __clc_ctz(uchar x) { return __builtin_ctzg(x, 8); 
}
+
+_CLC_OVERLOAD _CLC_DEF short __clc_ctz(short x) {
+  return __clc_ctz(__clc_as_ushort(x));
+}
+
+_CLC_OVERLOAD _CLC_DEF ushort __clc_ctz(ushort x) {
+  return __builtin_ctzg(x, 16);
+}
+
+_CLC_OVERLOAD _CLC_DEF int __clc_ctz(int x) {
+  return __clc_ctz(__clc_as_uint(x));
+}
+
+_CLC_OVERLOAD _CLC_DEF uint __clc_ctz(uint x) { return __builtin_ctzg(x, 32); }
+
+_CLC_OVERLOAD _CLC_DEF long __clc_ctz(long x) {
+  return __clc_ctz(__clc_as_ulong(x));
+}
+
+_CLC_OVERLOAD _CLC_DEF ulong __clc_ctz(ulong x) {
+  return __builtin_ctzg(x, 64);
+}
+
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, char, __clc_ctz, char)
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, uchar, __clc_ctz, uchar)
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, short, __clc_ctz, short)
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, ushort, __clc_ctz, ushort)
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, int, __clc_ctz, int)
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, uint, __clc_ctz, uint)
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, long, __clc_ctz, long)
+_CLC_UNARY_VECTORIZE(_CLC_OVERLOAD _CLC_DEF, ulong, __clc_ctz, ulong)

diff  --git a/libclc/generic/include/clc/clc.h 
b/libclc/generic/include/clc/clc.h
index 8223b529f09f9..b1e851184d7e1 100644
--- a/libclc/generic/include/clc/clc.h
+++ b/libclc/generic/include/clc/clc.h
@@ -153,6 +153,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

diff  --git a/libclc/generic/include/clc/integer/ctz.h 
b/libclc/generic/include/clc/integer/ctz.h
new file mode 100644
index 0..7c6da17a39d56
--- /dev/null
+++ b/libclc/generic/include/clc/integer/ctz.h
@@ -0,0 +1,19 @@
+//===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+
+#define __CLC_FUNCTION ctz
+#define __CLC_BODY 
+
+#include 
+
+#undef __CLC_BODY
+#undef __CLC_FUNCTION
+
+#endi

[libclc] [libclc] add ctz built-in implementation to clc and generic (PR #135309)

2025-04-15 Thread Fraser Cormack via cfe-commits

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread via cfe-commits

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


[clang] Allow some attributes on declarations after definitions (PR #135791)

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

https://github.com/AaronBallman created 
https://github.com/llvm/llvm-project/pull/135791

The deprecated, maybe_unused, and nodiscard standard attributes may all be 
applied to a redeclaration after a definition has already appeared. We were 
previously dropping the attribute in that case, now we retain the attribute 
after the redeclaration.

Note: someday we may want to tablegen this as part of information from Attr.td. 
We may also want to relax the restriction here so that the syntax used does not 
matter. This is an intentionally conservative fix.

Fixes #135481

>From fa878e011da7a04ff53ce706b8a9a4f16f82fc18 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Tue, 15 Apr 2025 10:36:48 -0400
Subject: [PATCH] Allow some attributes on declarations after definitions

The deprecated, maybe_unused, and nodiscard standard attributes may all
be applied to a redeclaration after a definition has already appeared.
We were previously dropping the attribute in that case, now we retain
the attribute after the redeclaration.

Note: someday we may want to tablegen this as part of information from
Attr.td. We may also want to relax the restriction here so that the
syntax used does not matter. This is an intentionally conservative fix.

Fixes #135481
---
 clang/docs/ReleaseNotes.rst   |  5 +++
 clang/lib/Sema/SemaDecl.cpp   | 15 +++
 .../Sema/attr-decl-after-definition-std.c | 41 +++
 3 files changed, 61 insertions(+)
 create mode 100644 clang/test/Sema/attr-decl-after-definition-std.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6d1daaa84caaa..0575880fa634e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -427,6 +427,11 @@ Bug Fixes to Attribute Support
 - No longer crashing on ``__attribute__((align_value(N)))`` during template
   instantiation when the function parameter type is not a pointer or reference.
   (#GH26612)
+- Now allowing the ``[[deprecated]]``, ``[[maybe_unused]]``, and
+  ``[[nodiscard]]`` to be applied to a redeclaration after a definition in both
+  C and C++ mode for the standard spellings (other spellings, such as
+  ``__attribute__((unused))`` are still ignored after the definition, though
+  this behavior may be relaxed in the future). (#GH135481)
 
 Bug Fixes to C++ Support
 
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e9805c345b6af..240ce5391af81 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2996,6 +2996,21 @@ static void checkNewAttributesAfterDef(Sema &S, Decl 
*New, const Decl *Old) {
   // msvc will allow a subsequent definition to add an uuid to a class
   ++I;
   continue;
+} else if (isa(
+   NewAttribute) &&
+   NewAttribute->isStandardAttributeSyntax()) {
+  // C++14 [dcl.attr.deprecated]p3: A name or entity declared without the
+  // deprecated attribute can later be re-declared with the attribute and
+  // vice-versa.
+  // C++17 [dcl.attr.unused]p4: A name or entity declared without the
+  // maybe_unused attribute can later be redeclared with the attribute and
+  // vice versa.
+  // C++20 [dcl.attr.nodiscard]p2: A name or entity declared without the
+  // nodiscard attribute can later be redeclared with the attribute and
+  // vice-versa.
+  // C23 6.7.13.3p3, 6.7.13.4p3. and 6.7.13.5p5 give the same allowances.
+  ++I;
+  continue;
 } else if (const AlignedAttr *AA = dyn_cast(NewAttribute)) {
   if (AA->isAlignas()) {
 // C++11 [dcl.align]p6:
diff --git a/clang/test/Sema/attr-decl-after-definition-std.c 
b/clang/test/Sema/attr-decl-after-definition-std.c
new file mode 100644
index 0..bab52b4dd97ad
--- /dev/null
+++ b/clang/test/Sema/attr-decl-after-definition-std.c
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -fsyntax-only -Wignored-attributes -verify -std=c23 %s
+// RUN: %clang_cc1 -fsyntax-only -Wignored-attributes -verify -x c++ %s
+// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
+
+inline int frob(int x) { return x; }
+
+[[deprecated]] int frob(int); // expected-note 2 {{'frob' has been explicitly 
marked deprecated here}}
+
+void use1() {
+  // Using this should give a deprecation warning, but not a nodiscard 
warning.
+  frob(0); // expected-warning {{'frob' is deprecated}}
+}
+
+[[nodiscard]] int frob(int);
+
+void use2() {
+  // This should give both warnings.
+  frob(0); // expected-warning {{'frob' is deprecated}} \
+  expected-warning {{ignoring return value of function declared 
with 'nodiscard' attribute}}
+}
+
+[[maybe_unused]] int frob(int);
+
+// Currently, this is only allowed for the standard spelling of the attributes.
+void blob() {}   // expected-note {{previous 
definition is here}}
+__attribute__((deprecated)) void blob(); // expected-warning {{attribute 
declaration must precede de

[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

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

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


[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

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


@@ -10382,6 +10383,7 @@ class Sema final : public SemaBase {
   /// Add a C++ function template specialization as a candidate
   /// in the candidate set, using template argument deduction to produce
   /// an appropriate function template specialization.
+

erichkeane wrote:

Pretty sure we don't want this :) 

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


[clang] [Clang][RFC] Bypass TAD during overload resolution if a perfect match exists (PR #133426)

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


@@ -407,6 +407,18 @@ class Sema;
  Third == ICK_Identity;
 }
 
+bool isPerfect(const ASTContext &C) const {

erichkeane wrote:

Still would like comments on these functions that say what 'perfect' means here.

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


[clang] Allow some attributes on declarations after definitions (PR #135791)

2025-04-15 Thread via cfe-commits

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


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


[clang] [Clang] Allow simpler visibility annotations when targeting win32 and mingw (PR #133699)

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


@@ -4185,6 +4185,14 @@ def DLLExport : InheritableAttr, 
TargetSpecificAttr {
   let Documentation = [DLLExportDocs];
 }
 
+def DLLExportOnDecl : InheritableAttr, 
TargetSpecificAttr {

erichkeane wrote:

Hmm... I'm not a huge fan of this TBH.  An attribute for the sole purpose of 
diagnostics is a little novel and not particularly in keeping with our 
"represent the AST" nature of attributes.  Is there really no way we can figure 
this out later?

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


[clang] [Clang] Add support for GCC bound member functions extension (PR #135649)

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

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

>From 445c08bcb007f157f6c66c5fabb01c2aa88b3a89 Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Tue, 15 Apr 2025 22:58:44 +0800
Subject: [PATCH] [Clang] Add support for GCC bound member functions extension

---
 clang/include/clang/AST/OperationKinds.def|   4 +
 clang/include/clang/Basic/DiagnosticGroups.td |  32 +++---
 .../clang/Basic/DiagnosticSemaKinds.td|   4 +
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |   1 +
 clang/lib/AST/Expr.cpp|   7 ++
 clang/lib/AST/ExprConstant.cpp|   2 +
 clang/lib/CIR/CodeGen/CIRGenExpr.cpp  |   1 +
 clang/lib/CodeGen/CGExpr.cpp  |   1 +
 clang/lib/CodeGen/CGExprAgg.cpp   |   2 +
 clang/lib/CodeGen/CGExprComplex.cpp   |   1 +
 clang/lib/CodeGen/CGExprConstant.cpp  |   1 +
 clang/lib/CodeGen/CGExprScalar.cpp|  32 ++
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  22 +++-
 clang/lib/Edit/RewriteObjCFoundationAPI.cpp   |   1 +
 clang/lib/Sema/SemaCast.cpp   |  31 --
 clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp |   3 +-
 clang/test/CodeGenCXX/pmf-conversions.cpp | 105 ++
 clang/test/SemaCXX/pmf-conversions.cpp|  50 +
 18 files changed, 271 insertions(+), 29 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/pmf-conversions.cpp
 create mode 100644 clang/test/SemaCXX/pmf-conversions.cpp

diff --git a/clang/include/clang/AST/OperationKinds.def 
b/clang/include/clang/AST/OperationKinds.def
index 790dd572a7c99..489d89a697dc3 100644
--- a/clang/include/clang/AST/OperationKinds.def
+++ b/clang/include/clang/AST/OperationKinds.def
@@ -152,6 +152,10 @@ CAST_OPERATION(MemberPointerToBoolean)
 /// many ABIs do not guarantee this on all possible intermediate types).
 CAST_OPERATION(ReinterpretMemberPointer)
 
+/// CK_BoundPointerToMemberFunctionToFunctionPointer - Convert a bound
+/// member function pointer to a function pointer.  This is a GNU extension.
+CAST_OPERATION(BoundMemberFunctionToFunctionPointer)
+
 /// CK_UserDefinedConversion - Conversion using a user defined type
 /// conversion function.
 ///struct A { operator int(); }; int i = int(A());
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index d97bbfee2e4d5..8e5a4cba87c95 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -795,6 +795,7 @@ def DuplicateDeclSpecifier : 
DiagGroup<"duplicate-decl-specifier">;
 def CompareDistinctPointerType : DiagGroup<"compare-distinct-pointer-types">;
 def GNUUnionCast : DiagGroup<"gnu-union-cast">;
 def GNUVariableSizedTypeNotAtEnd : 
DiagGroup<"gnu-variable-sized-type-not-at-end">;
+def GNUPMFCast : DiagGroup<"pmf-conversions">;
 def Varargs : DiagGroup<"varargs">;
 def XorUsedAsPow : DiagGroup<"xor-used-as-pow">;
 
@@ -1294,22 +1295,21 @@ def C2y : DiagGroup<"c2y-extensions">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;
 
 // A warning group for warnings about GCC extensions.
-def GNU : DiagGroup<"gnu", [GNUAlignofExpression, GNUAnonymousStruct,
-GNUAutoType, GNUBinaryLiteral, GNUCaseRange,
-GNUComplexInteger, GNUCompoundLiteralInitializer,
-GNUConditionalOmittedOperand, GNUDesignator,
-GNUEmptyStruct,
-VLAExtension, GNUFlexibleArrayInitializer,
-GNUFlexibleArrayUnionMember, GNUFoldingConstant,
-GNUImaginaryConstant, GNUIncludeNext,
-GNULabelsAsValue, GNULineMarker, 
GNUNullPointerArithmetic,
-GNUOffsetofExtensions, GNUPointerArith,
-RedeclaredClassMember, GNURedeclaredEnum,
-GNUStatementExpression, GNUStaticFloatInit,
-GNUStringLiteralOperatorTemplate, GNUUnionCast,
-GNUVariableSizedTypeNotAtEnd, ZeroLengthArray,
-GNUZeroLineDirective,
-GNUZeroVariadicMacroArguments]>;
+def GNU
+: DiagGroup<
+  "gnu", [GNUAlignofExpression, GNUAnonymousStruct, GNUAutoType,
+  GNUBinaryLiteral, GNUCaseRange, GNUComplexInteger,
+  GNUCompoundLiteralInitializer, GNUConditionalOmittedOperand,
+  GNUDesignator, GNUEmptyStruct, VLAExtension,
+  GNUFlexibleArrayInitializer, GNUFlexibleArrayUnionMember,
+  GNUFoldingConstant, GNUImaginaryConstant, GNUIncludeNext,
+  GNULabelsAsValue, GNULineMarker, GNUNullPointerArithmetic,
+  GNUOffsetofExtensions, GNUPointerArith, 
RedeclaredClassMember,
+  GNURedeclaredEnum, GNUStatementExpression, 
GNUStaticFloatInit

[clang] [Clang] Allow simpler visibility annotations when targeting win32 and mingw (PR #133699)

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

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


[clang] [libclang/C++] Fix clang_File_isEqual for in-memory files (PR #135773)

2025-04-15 Thread Jannick Kremer via cfe-commits

DeinAlptraum wrote:

@AaronBallman this is the fix PR for the bug we discussed at 
https://github.com/llvm/llvm-project/pull/130383#discussion_r2014205462

The first test is for completeness' sake, the second one (with in-memory files) 
fails without the fix

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


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

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


@@ -0,0 +1,35 @@
+// Regression test for https://github.com/llvm/llvm-project/issues/59819
+
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md 
--check-prefix=MD-MYCLASS-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS
+
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MYCLASS-LINE
+// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html 
--check-prefix=HTML-MYCLASS
+
+#define DECLARE_METHODS   \
+/**  \
+ * @brief Declare a method to calculate the sum of two numbers\
+ */   \
+int Add(int a, int b) {   \
+return a + b; \
+}
+
+// MD-MYCLASS: ### Add
+// MD-MYCLASS: *public int Add(int a, int b)*
+// MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers
+
+// HTML-MYCLASS: public int Add(int a, int b)
+// HTML-MYCLASS: brief
+// HTML-MYCLASS:  Declare a method to calculate the sum of two numbers
+
+
+class MyClass {
+public:
+// MD-MYCLASS-LINE: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp#[[@LINE+2]]*
+// HTML-MYCLASS-LINE: Defined at line [[@LINE+1]] of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}macro.cpp

ilovepi wrote:

The line number seems to not be where you expect in the test. Does this pass 
for you locally?

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread Jonathan Thackray via cfe-commits


@@ -3107,6 +3107,26 @@ let TargetPrefix = "aarch64" in {
 }
   }
 
+  class SME_OuterProduct_TMOP_Intrinsic
+ : DefaultAttrsIntrinsic<[],
+ [llvm_i32_ty,
+  llvm_anyvector_ty,
+  LLVMMatchType<0>,
+  LLVMMatchType<0>,
+  llvm_nxv16i8_ty,
+  llvm_i32_ty],
+ [ImmArg>, ImmArg>,
+  IntrInaccessibleMemOnly]>;
+
+  def int_aarch64_sme_za16_ftmopa : SME_OuterProduct_TMOP_Intrinsic;
+  def int_aarch64_sme_za16_bftmopa : SME_OuterProduct_TMOP_Intrinsic;

jthackray wrote:

Sure, now adjusted. (My original patch used `int_aarch64_sme_za16_tmopa` where 
they could be deduced by type. I'll change it back to this. The LLVM IR name 
won't have 'bf' in the name, and will become plain 
`@llvm.aarch64.sme.tmopa.za16.nxv8bf16`).

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


[clang] [llvm] [AArch64][clang][llvm] Add structured sparsity outer product (TMOP) intrinsics (PR #135145)

2025-04-15 Thread Jonathan Thackray via cfe-commits


@@ -3107,6 +3107,26 @@ let TargetPrefix = "aarch64" in {
 }
   }
 
+  class SME_OuterProduct_TMOP_Intrinsic
+ : DefaultAttrsIntrinsic<[],
+ [llvm_i32_ty,
+  llvm_anyvector_ty,
+  LLVMMatchType<0>,
+  LLVMMatchType<0>,
+  llvm_nxv16i8_ty,
+  llvm_i32_ty],
+ [ImmArg>, ImmArg>,
+  IntrInaccessibleMemOnly]>;
+
+  def int_aarch64_sme_za16_ftmopa : SME_OuterProduct_TMOP_Intrinsic;

jthackray wrote:

Sure, done 😀 

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


[clang] Silence -Wcast-function-type warnings on idiomatic Windows code (PR #135660)

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

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


[clang] [Clang] [Driver] add a Cygwin ToolChain (PR #135691)

2025-04-15 Thread via cfe-commits

jeremyd2019 wrote:

I don't have rights to push/merge. (I seem to remember being asked to mention 
this in the past)

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


[clang] [Clang] [Driver] use __cxa_atexit by default on Cygwin. (PR #135701)

2025-04-15 Thread via cfe-commits

jeremyd2019 wrote:

I don't have rights to push/merge. (I seem to remember being asked to mention 
this in the past)

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


[libclc] [libclc] Set OpenCL C version for each target (PR #135733)

2025-04-15 Thread Wenju He via cfe-commits

wenju-he wrote:

> Targets may even want to compile libclc for multiple different versions? That 
> might introduce extra complexity (we'd need "an extra loop", more compilation 
> time, new naming/versioning schemes for the build artifacts).

An application may compile using different -cl-std version, but IIUC such usage 
is incompatible with a target which supports a specific OpenCL version. So 
compiling for the target's supported OpenCL version might be enough.

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


[clang] [clang-format] Fix a bug in BWACS_MultiLine (PR #135906)

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

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/135906

>From c4ccaf91a0f2c3f3ea8e45eb75d36c1464b6c3b8 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 15 Apr 2025 21:21:28 -0700
Subject: [PATCH] [clang-format] Fix a bug in BWACS_MultiLine

Fix #51940
---
 clang/lib/Format/TokenAnnotator.cpp | 15 ++-
 clang/lib/Format/UnwrappedLineFormatter.cpp | 45 -
 clang/lib/Format/UnwrappedLineParser.cpp| 11 -
 clang/unittests/Format/FormatTest.cpp   | 11 +
 4 files changed, 41 insertions(+), 41 deletions(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index ef5f07e2c62ee..144983f675828 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4153,8 +4153,18 @@ void 
TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) const {
  ChildSize + Current->SpacesRequiredBefore;
 }
 
-if (Current->is(TT_CtorInitializerColon))
+if (Current->is(TT_ControlStatementLBrace)) {
+  if (Style.ColumnLimit > 0 &&
+  Style.BraceWrapping.AfterControlStatement ==
+  FormatStyle::BWACS_MultiLine &&
+  Line.Level * Style.IndentWidth + Line.Last->TotalLength >
+  Style.ColumnLimit) {
+Current->CanBreakBefore = true;
+Current->MustBreakBefore = true;
+  }
+} else if (Current->is(TT_CtorInitializerColon)) {
   InFunctionDecl = false;
+}
 
 // FIXME: Only calculate this if CanBreakBefore is true once static
 // initializers etc. are sorted out.
@@ -5586,12 +5596,13 @@ static bool isAllmanLambdaBrace(const FormatToken &Tok) 
{
 
 bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
  const FormatToken &Right) const {
-  const FormatToken &Left = *Right.Previous;
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0 &&
   (!Style.RemoveEmptyLinesInUnwrappedLines || &Right == Line.First)) {
 return true;
   }
 
+  const FormatToken &Left = *Right.Previous;
+
   if (Style.BreakFunctionDefinitionParameters && Line.MightBeFunctionDecl &&
   Line.mightBeFunctionDefinition() && Left.MightBeFunctionDeclParen &&
   Left.ParameterCount > 0) {
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 617d46ad281d5..6806ab18312ea 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -424,43 +424,14 @@ class LineJoiner {
  : 0;
 }
 // Try to merge a control statement block with left brace wrapped.
-if (NextLine.First->is(tok::l_brace)) {
-  if ((TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
-   tok::kw_for, tok::kw_switch, tok::kw_try,
-   tok::kw_do, TT_ForEachMacro) ||
-   (TheLine->First->is(tok::r_brace) && TheLine->First->Next &&
-TheLine->First->Next->isOneOf(tok::kw_else, tok::kw_catch))) &&
-  Style.BraceWrapping.AfterControlStatement ==
-  FormatStyle::BWACS_MultiLine) {
-// If possible, merge the next line's wrapped left brace with the
-// current line. Otherwise, leave it on the next line, as this is a
-// multi-line control statement.
-return (Style.ColumnLimit == 0 || TheLine->Level * Style.IndentWidth +
-  TheLine->Last->TotalLength <=
-  Style.ColumnLimit)
-   ? 1
-   : 0;
-  }
-  if (TheLine->First->isOneOf(tok::kw_if, tok::kw_else, tok::kw_while,
-  tok::kw_for, TT_ForEachMacro)) {
-return (Style.BraceWrapping.AfterControlStatement ==
-FormatStyle::BWACS_Always)
-   ? tryMergeSimpleBlock(I, E, Limit)
-   : 0;
-  }
-  if (TheLine->First->isOneOf(tok::kw_else, tok::kw_catch) &&
-  Style.BraceWrapping.AfterControlStatement ==
-  FormatStyle::BWACS_MultiLine) {
-// This case if different from the upper BWACS_MultiLine processing
-// in that a preceding r_brace is not on the same line as else/catch
-// most likely because of BeforeElse/BeforeCatch set to true.
-// If the line length doesn't fit ColumnLimit, leave l_brace on the
-// next line to respect the BWACS_MultiLine.
-return (Style.ColumnLimit == 0 ||
-TheLine->Last->TotalLength <= Style.ColumnLimit)
-   ? 1
-   : 0;
-  }
+if (NextLine.First->is(TT_ControlStatementLBrace)) {
+  // If possible, merge the next line's wrapped left brace with the
+  // current line. Otherwise, leave it on the next line, as this is a
+  // multi-line control statement.
+  return Style.BraceWra

[clang] 2a02404 - [clang] fix a crash in error recovery in expressions resolving to templates (#135893)

2025-04-15 Thread via cfe-commits

Author: Matheus Izvekov
Date: 2025-04-16T02:09:32-03:00
New Revision: 2a024046217a1acae4806328ac77bd88648c2bab

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

LOG: [clang] fix a crash in error recovery in expressions resolving to 
templates (#135893)

We were using AssumedTemplate incorrectly for error recovery.

Fixes #135621

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaTemplate/recovery-crash.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee69af5632f6e..84ad253c1ec4f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -402,6 +402,7 @@ Bug Fixes in This Version
   when using the ``INTn_C`` macros. (#GH85995)
 - Fixed an assertion failure in the expansion of builtin macros like 
``__has_embed()`` with line breaks before the
   closing paren. (#GH133574)
+- Fixed a crash in error recovery for expressions resolving to templates. 
(#GH135621)
 - Clang no longer accepts invalid integer constants which are too large to fit
   into any (standard or extended) integer type when the constant is 
unevaluated.
   Merely forming the token is sufficient to render the program invalid. Code
@@ -544,7 +545,7 @@ Arm and AArch64 Support
 ^^^
 - For ARM targets, cc1as now considers the FPU's features for the selected CPU 
or Architecture.
 - The ``+nosimd`` attribute is now fully supported for ARM. Previously, this 
had no effect when being used with
-  ARM targets, however this will now disable NEON instructions being 
generated. The ``simd`` option is 
+  ARM targets, however this will now disable NEON instructions being 
generated. The ``simd`` option is
   also now printed when the ``--print-supported-extensions`` option is used.
 
 -  Support for __ptrauth type qualifier has been added.

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 62e48062cf241..53620003c9655 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -4401,7 +4401,8 @@ TemplateSpecializationType::TemplateSpecializationType(
   T.getKind() == TemplateName::SubstTemplateTemplateParmPack ||
   T.getKind() == TemplateName::UsingTemplate ||
   T.getKind() == TemplateName::QualifiedTemplate ||
-  T.getKind() == TemplateName::DeducedTemplate) &&
+  T.getKind() == TemplateName::DeducedTemplate ||
+  T.getKind() == TemplateName::AssumedTemplate) &&
  "Unexpected template name for TemplateSpecializationType");
 
   auto *TemplateArgs =

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 3ac7d61546ceb..c65b4eadf9c67 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2,11 +2,15 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
 const bool IsTypeAliasTemplateDecl = isa(Temp);
 
 NestedNameSpecifier *NNS = ULE->getQualifierLoc().getNestedNameSpecifier();
-TemplateName TN(dyn_cast(Temp));
-if (TN.isNull())
+// FIXME: AssumedTemplate is not very appropriate for error recovery here,
+// as it models only the unqualified-id case, where this case can clearly 
be
+// qualified. Thus we can't just qualify an assumed template.
+TemplateName TN;
+if (auto *TD = dyn_cast(Temp))
+  TN = Context.getQualifiedTemplateName(NNS, ULE->hasTemplateKeyword(),
+TemplateName(TD));
+else
   TN = Context.getAssumedTemplateName(NameInfo.getName());
-TN = Context.getQualifiedTemplateName(NNS,
-  /*TemplateKeyword=*/true, TN);
 
 Diag(NameInfo.getLoc(), diag::err_template_kw_refers_to_type_template)
 << TN << ULE->getSourceRange() << IsTypeAliasTemplateDecl;

diff  --git a/clang/test/SemaTemplate/recovery-crash.cpp 
b/clang/test/SemaTemplate/recovery-crash.cpp
index ac8053da101ab..9b106f1f21fc5 100644
--- a/clang/test/SemaTemplate/recovery-crash.cpp
+++ b/clang/test/SemaTemplate/recovery-crash.cpp
@@ -67,3 +67,14 @@ namespace test1 {
   // expected-note@#defined-here {{defined here}}
   void NonTemplateClass::UndeclaredMethod() {}
 }
+
+namespace GH135621 {
+  template  struct S {};
+  // expected-note@-1 {{class template declared here}}
+  template  void f() {
+S::template S;
+// expected-error@-1 {{'S' is expected to be a non-type template, but 
instantiated to a class template}}
+  }
+  template void f();
+  // expected-note@-1 {{requested here}}
+} // namespace GH135621



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


[clang] [clang] fix a crash in error recovery in expressions resolving to templates (PR #135893)

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

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


[clang] [clang][NFC] Refactor CodeGen's hasBooleanRepresentation (PR #134159)

2025-04-15 Thread Michele Scandale via cfe-commits

michele-scandale wrote:

Given that there are already similar functions in the `Type` class -- e.g. 
`has{Signed,Unsigned,}IntegerRepresentation`, `hasFloatingRepresentation` -- it 
seems a bit inconsistent the definition of `hasBooleanRepresentation`. I would 
expect that "vector of booleans" to have `hasBooleanRepresentation` returning 
`true`, and I would expect `_Atomic()` to 
have `hasBooleanRepresentation` returning `false`.
Any thoughts?

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


[clang] [clang][bytecode] Explicitly mark constexpr-unknown variables as such (PR #135806)

2025-04-15 Thread via cfe-commits

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


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


[clang] [clang] fix a crash in error recovery in expressions resolving to templates (PR #135893)

2025-04-15 Thread Younan Zhang via cfe-commits

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


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


[clang] [NFC][Clang] Introduce type aliases to replace use of auto in clang/lib/CodeGen/CGCall.cpp. (PR #135861)

2025-04-15 Thread Tom Honermann via cfe-commits

https://github.com/tahonermann updated 
https://github.com/llvm/llvm-project/pull/135861

>From f413b7eeb673812fb66b1465c885a34fe21d1fc6 Mon Sep 17 00:00:00 2001
From: Tom Honermann 
Date: Tue, 15 Apr 2025 14:25:06 -0700
Subject: [PATCH 1/2] [NFC][Clang] Introduce type aliases to replace use of
 auto in clang/lib/CodeGen/CGCall.cpp.

CGCall.cpp declares several functions with a return type that is an explicitly
spelled out specialization of SmallVector. Previously, `auto` was used in
several places to avoid repeating the long type name; a use that Clang
maintainers find unjustified. This change introduces type aliases and replaces
the existing uses of `auto` with the corresponding alias name.
---
 clang/lib/CodeGen/CGCall.cpp | 73 ++--
 1 file changed, 36 insertions(+), 37 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index b25cdf9523ae1..b5995023a213a 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -199,15 +199,17 @@ static void appendParameterTypes(const CodeGenTypes &CGT,
   prefix.size());
 }
 
+using SmallExtParameterInfoList =
+SmallVector;
+
 /// Arrange the LLVM function layout for a value of the given function
 /// type, on top of any implicit parameters already stored.
 static const CGFunctionInfo &
 arrangeLLVMFunctionInfo(CodeGenTypes &CGT, bool instanceMethod,
 SmallVectorImpl &prefix,
 CanQual FTP) {
-  SmallVector paramInfos;
+  SmallExtParameterInfoList paramInfos;
   RequiredArgs Required = RequiredArgs::forPrototypePlus(FTP, prefix.size());
-  // FIXME: Kill copy.
   appendParameterTypes(CGT, prefix, paramInfos, FTP);
   CanQualType resultType = FTP->getReturnType().getUnqualifiedType();
 
@@ -217,11 +219,13 @@ arrangeLLVMFunctionInfo(CodeGenTypes &CGT, bool 
instanceMethod,
  FTP->getExtInfo(), paramInfos, Required);
 }
 
+using SmallCanQualTypeList = SmallVector;
+
 /// Arrange the argument and result information for a value of the
 /// given freestanding function type.
 const CGFunctionInfo &
 CodeGenTypes::arrangeFreeFunctionType(CanQual FTP) {
-  SmallVector argTypes;
+  SmallCanQualTypeList argTypes;
   return ::arrangeLLVMFunctionInfo(*this, /*instanceMethod=*/false, argTypes,
FTP);
 }
@@ -319,7 +323,7 @@ const CGFunctionInfo &
 CodeGenTypes::arrangeCXXMethodType(const CXXRecordDecl *RD,
const FunctionProtoType *FTP,
const CXXMethodDecl *MD) {
-  SmallVector argTypes;
+  SmallCanQualTypeList argTypes;
 
   // Add the 'this' pointer.
   argTypes.push_back(DeriveThisType(RD, MD));
@@ -375,8 +379,8 @@ const CGFunctionInfo &
 CodeGenTypes::arrangeCXXStructorDeclaration(GlobalDecl GD) {
   auto *MD = cast(GD.getDecl());
 
-  SmallVector argTypes;
-  SmallVector paramInfos;
+  SmallCanQualTypeList argTypes;
+  SmallExtParameterInfoList paramInfos;
 
   const CXXRecordDecl *ThisType = getCXXABI().getThisArgumentTypeForMethod(GD);
   argTypes.push_back(DeriveThisType(ThisType, MD));
@@ -421,26 +425,26 @@ CodeGenTypes::arrangeCXXStructorDeclaration(GlobalDecl 
GD) {
  argTypes, extInfo, paramInfos, required);
 }
 
-static SmallVector
-getArgTypesForCall(ASTContext &ctx, const CallArgList &args) {
-  SmallVector argTypes;
+static SmallCanQualTypeList getArgTypesForCall(ASTContext &ctx,
+   const CallArgList &args) {
+  SmallCanQualTypeList argTypes;
   for (auto &arg : args)
 argTypes.push_back(ctx.getCanonicalParamType(arg.Ty));
   return argTypes;
 }
 
-static SmallVector
+static SmallCanQualTypeList
 getArgTypesForDeclaration(ASTContext &ctx, const FunctionArgList &args) {
-  SmallVector argTypes;
+  SmallCanQualTypeList argTypes;
   for (auto &arg : args)
 argTypes.push_back(ctx.getCanonicalParamType(arg->getType()));
   return argTypes;
 }
 
-static llvm::SmallVector
-getExtParameterInfosForCall(const FunctionProtoType *proto,
-unsigned prefixArgs, unsigned totalArgs) {
-  llvm::SmallVector result;
+static SmallExtParameterInfoList
+getExtParameterInfosForCall(const FunctionProtoType *proto, unsigned 
prefixArgs,
+unsigned totalArgs) {
+  SmallExtParameterInfoList result;
   if (proto->hasExtParameterInfos()) {
 addExtParameterInfosForCall(result, proto, prefixArgs, totalArgs);
   }
@@ -462,8 +466,7 @@ CodeGenTypes::arrangeCXXConstructorCall(const CallArgList 
&args,
 unsigned ExtraPrefixArgs,
 unsigned ExtraSuffixArgs,
 bool PassProtoArgs) {
-  // FIXME: Kill copy.
-  SmallVector ArgTypes;
+  SmallCanQualTypeList ArgTypes;
   for (const auto &Arg : args)
 ArgTypes.push_back(Context.getCanonicalParam

[clang] [NFC][Clang] Introduce type aliases to replace use of auto in clang/lib/CodeGen/CGCall.cpp. (PR #135861)

2025-04-15 Thread Tom Honermann via cfe-commits


@@ -199,15 +199,17 @@ static void appendParameterTypes(const CodeGenTypes &CGT,
   prefix.size());
 }
 
+using SmallExtParameterInfoList =

tahonermann wrote:

Done; I dropped the `Small` prefix.

With regard to the in-place size of 16, I'm guessing that was a spur of the 
moment pick that "felt right" way back when. I did look for other aliases of 
`SmallVector` for these types and that in-place size and didn't find any. There 
is a case of `SmallVector` elsewhere in the file, so it wasn't 
a blind default everywhere.

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


[clang] 517605c - [alpha.webkit.UnretainedCallArgsChecker] Add the support for RetainPtrArc (#135532)

2025-04-15 Thread via cfe-commits

Author: Ryosuke Niwa
Date: 2025-04-15T20:00:51-07:00
New Revision: 517605c20e6014543e91d45524a17c443aa11bd4

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

LOG: [alpha.webkit.UnretainedCallArgsChecker] Add the support for RetainPtrArc 
(#135532)

WebKit uses #define to rename RetainPtr to RetainPtrArc so add the
support for it.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
clang/test/Analysis/Checkers/WebKit/objc-mock-types.h
clang/test/Analysis/Checkers/WebKit/unretained-call-args-arc.mm
clang/test/Analysis/Checkers/WebKit/unretained-call-args.mm

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 134afcd124526..811888e119449 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -119,7 +119,9 @@ bool isRefType(const std::string &Name) {
  Name == "RefPtr" || Name == "RefPtrAllowingPartiallyDestroyed";
 }
 
-bool isRetainPtr(const std::string &Name) { return Name == "RetainPtr"; }
+bool isRetainPtr(const std::string &Name) {
+  return Name == "RetainPtr" || Name == "RetainPtrArc";
+}
 
 bool isCheckedPtr(const std::string &Name) {
   return Name == "CheckedPtr" || Name == "CheckedRef";
@@ -157,7 +159,8 @@ bool isCtorOfCheckedPtr(const clang::FunctionDecl *F) {
 bool isCtorOfRetainPtr(const clang::FunctionDecl *F) {
   const std::string &FunctionName = safeGetName(F);
   return FunctionName == "RetainPtr" || FunctionName == "adoptNS" ||
- FunctionName == "adoptCF" || FunctionName == "retainPtr";
+ FunctionName == "adoptCF" || FunctionName == "retainPtr" ||
+ FunctionName == "RetainPtrArc" || FunctionName == "adoptNSArc";
 }
 
 bool isCtorOfSafePtr(const clang::FunctionDecl *F) {
@@ -190,7 +193,7 @@ bool isRefOrCheckedPtrType(const clang::QualType T) {
 }
 
 bool isRetainPtrType(const clang::QualType T) {
-  return isPtrOfType(T, [](auto Name) { return Name == "RetainPtr"; });
+  return isPtrOfType(T, [](auto Name) { return isRetainPtr(Name); });
 }
 
 bool isOwnerPtrType(const clang::QualType T) {
@@ -374,7 +377,7 @@ std::optional isGetterOfSafePtr(const CXXMethodDecl 
*M) {
  method == "impl"))
   return true;
 
-if (className == "RetainPtr" && method == "get")
+if (isRetainPtr(className) && method == "get")
   return true;
 
 // Ref -> T conversion
@@ -395,7 +398,7 @@ std::optional isGetterOfSafePtr(const CXXMethodDecl 
*M) {
   }
 }
 
-if (className == "RetainPtr") {
+if (isRetainPtr(className)) {
   if (auto *maybeRefToRawOperator = dyn_cast(M)) {
 auto QT = maybeRefToRawOperator->getConversionType();
 auto *T = QT.getTypePtrOrNull();
@@ -429,7 +432,7 @@ bool isCheckedPtr(const CXXRecordDecl *R) {
 bool isRetainPtr(const CXXRecordDecl *R) {
   assert(R);
   if (auto *TmplR = R->getTemplateInstantiationPattern())
-return safeGetName(TmplR) == "RetainPtr";
+return isRetainPtr(safeGetName(TmplR));
   return false;
 }
 

diff  --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
index d372c5d1ba626..d3eee11311d91 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RetainPtrCtorAdoptChecker.cpp
@@ -71,7 +71,7 @@ class RetainPtrCtorAdoptChecker
   }
 
   bool TraverseClassTemplateDecl(ClassTemplateDecl *CTD) {
-if (safeGetName(CTD) == "RetainPtr")
+if (isRetainPtr(safeGetName(CTD)))
   return true; // Skip the contents of RetainPtr.
 return Base::TraverseClassTemplateDecl(CTD);
   }
@@ -193,7 +193,7 @@ class RetainPtrCtorAdoptChecker
 if (!Cls)
   return;
 
-if (safeGetName(Cls) != "RetainPtr" || !CE->getNumArgs())
+if (!isRetainPtr(safeGetName(Cls)) || !CE->getNumArgs())
   return;
 
 // Ignore RetainPtr construction inside adoptNS, adoptCF, and retainPtr.
@@ -322,12 +322,12 @@ class RetainPtrCtorAdoptChecker
   if (auto *CD = dyn_cast(MD)) {
 auto QT = CD->getConversionType().getCanonicalType();
 auto *ResultType = QT.getTypePtrOrNull();
-if (safeGetName(Cls) == "RetainPtr" && ResultType &&
+if (isRetainPtr(safeGetName(Cls)) && ResultType &&
 (ResultType->isPointerType() || ResultType->isReferenceType() 
||
  ResultType->isObjCObjectPointerType()))
   return IsOwnedResult::NotOwned;
   }
-  i

[clang] [alpha.webkit.UnretainedCallArgsChecker] Add the support for RetainPtrArc (PR #135532)

2025-04-15 Thread Ryosuke Niwa via cfe-commits

rniwa wrote:

Thanks for the review!

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


[clang] [alpha.webkit.UnretainedCallArgsChecker] Add the support for RetainPtrArc (PR #135532)

2025-04-15 Thread Ryosuke Niwa via cfe-commits

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


[libclc] [libclc] Set OpenCL version to 3.0 (PR #135733)

2025-04-15 Thread Wenju He via cfe-commits


@@ -411,6 +411,16 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
 file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
 
+# OpenCL 3.0 extensions
+string(CONCAT CL_3_0_EXTENSIONS
+  "-cl-ext="
+  "+cl_khr_fp64,"
+  "+cl_khr_fp16,"
+  "+__opencl_c_3d_image_writes,"
+  "+__opencl_c_images,"
+  "+cl_khr_3d_image_writes")
+list( APPEND build_flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} )

wenju-he wrote:

I've reverted OpenCL extensions change in this PR in 
https://github.com/llvm/llvm-project/pull/135733/commits/4facfec781e39a247aba639ea8e080aa79153a12
I find that target should define its supported extension via 
setSupportedOpenCLOpts API.

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


[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)

2025-04-15 Thread via cfe-commits


@@ -10170,6 +10170,8 @@ def warn_format_bool_as_character : Warning<
   "using '%0' format specifier, but argument has boolean value">,
   InGroup;
 def note_format_string_defined : Note<"format string is defined here">;
+def note_format_string_evaluated_to : Note<
+  "format string was constant-evaluated">;

apple-fcloutier wrote:

The point is taken. Would you like to suggest an alternate wording?

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


[libclc] [libclc] Set OpenCL version to 3.0 (PR #135733)

2025-04-15 Thread Wenju He via cfe-commits

https://github.com/wenju-he updated 
https://github.com/llvm/llvm-project/pull/135733

>From 64d7bfdceb5a0a6fbf34bb15cd7d6cbeb9214881 Mon Sep 17 00:00:00 2001
From: Wenju He 
Date: Mon, 14 Apr 2025 19:20:25 -0700
Subject: [PATCH 1/2] [libclc] Set OpenCL version to 3.0

This PR is cherry-pick of https://github.com/intel/llvm/commit/cba338e5fb1c
This allows adding OpenCL 2.0 built-ins, e.g. ctz, and OpenCL 3.0
extension built-ins, including generic address space variants.

llvm-diff shows this PR has no change in amdgcn--amdhsa.bc.
---
 libclc/CMakeLists.txt | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index dbbc29261d3b5..278ae5d777a84 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -411,6 +411,16 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
 file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
 
+# OpenCL 3.0 extensions
+string(CONCAT CL_3_0_EXTENSIONS
+  "-cl-ext="
+  "+cl_khr_fp64,"
+  "+cl_khr_fp16,"
+  "+__opencl_c_3d_image_writes,"
+  "+__opencl_c_images,"
+  "+cl_khr_3d_image_writes")
+list( APPEND build_flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} )
+
 string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE )
 
 list( APPEND build_flags

>From 4facfec781e39a247aba639ea8e080aa79153a12 Mon Sep 17 00:00:00 2001
From: Wenju He 
Date: Tue, 15 Apr 2025 20:56:40 -0700
Subject: [PATCH 2/2] set opencl_c_version per target, remove CL_3_0_EXTENSIONS

---
 libclc/CMakeLists.txt | 32 +---
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt
index 278ae5d777a84..e3093af57e728 100644
--- a/libclc/CMakeLists.txt
+++ b/libclc/CMakeLists.txt
@@ -387,7 +387,11 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 
 message( STATUS "  device: ${d} ( ${${d}_aliases} )" )
 
-if ( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
+# 1.2 is Clang's default OpenCL C language standard to compile for.
+set( opencl_lang_std "CL1.2" )
+
+if ( ${DARCH} STREQUAL spirv )
+  set( opencl_lang_std "CL3.0" )
   set( build_flags -O0 -finline-hint-functions -DCLC_SPIRV )
   set( opt_flags )
   set( spvflags --spirv-max-version=1.1 )
@@ -395,13 +399,27 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
   if( ARCH STREQUAL spirv64 )
 set( MACRO_ARCH SPIRV64 )
   endif()
-elseif( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
+elseif( ${DARCH} STREQUAL clspv )
+  # Refer to https://github.com/google/clspv for OpenCL version.
+  set( opencl_lang_std "CL3.0" )
   set( build_flags "-Wno-unknown-assumption" -DCLC_CLSPV )
   set( opt_flags -O3 )
   set( MACRO_ARCH CLSPV32 )
   if( ARCH STREQUAL clspv64 )
 set( MACRO_ARCH CLSPV64 )
   endif()
+elseif( ${DARCH} STREQUAL nvptx )
+  # Refer to https://www.khronos.org/opencl/ for OpenCL version in NV 
implementation.
+  set( opencl_lang_std "CL3.0" )
+  set( build_flags )
+  set( opt_flags -O3 )
+  set( MACRO_ARCH ${ARCH} )
+elseif( ${DARCH} STREQUAL amdgcn OR ${DARCH} STREQUAL amdgcn-amdhsa OR 
${DARCH} STREQUAL r600 )
+  # Refer to https://github.com/ROCm/clr/tree/develop/opencl for OpenCL 
version.
+  set( opencl_lang_std "CL2.0" )
+  set( build_flags )
+  set( opt_flags -O3 )
+  set( MACRO_ARCH ${ARCH} )
 else()
   set( build_flags )
   set( opt_flags -O3 )
@@ -411,15 +429,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
 set( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR}/${arch_suffix}" )
 file( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
 
-# OpenCL 3.0 extensions
-string(CONCAT CL_3_0_EXTENSIONS
-  "-cl-ext="
-  "+cl_khr_fp64,"
-  "+cl_khr_fp16,"
-  "+__opencl_c_3d_image_writes,"
-  "+__opencl_c_images,"
-  "+cl_khr_3d_image_writes")
-list( APPEND build_flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} )
+list( APPEND build_flags -cl-std=${opencl_lang_std} )
 
 string( TOUPPER "CLC_${MACRO_ARCH}" CLC_TARGET_DEFINE )
 

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


[clang] [clang-format] Fix a crash in EnumTrailingComma (PR #135903)

2025-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fix #135819

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


2 Files Affected:

- (modified) clang/lib/Format/Format.cpp (+11-6) 
- (modified) clang/unittests/Format/FormatTest.cpp (+11) 


``diff
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index c601967a8715c..b8d55871ab932 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2427,19 +2427,23 @@ class EnumTrailingCommaEditor : public TokenAnalyzer {
 private:
   void editEnumTrailingComma(SmallVectorImpl &Lines,
  tooling::Replacements &Result) {
+bool InEnumBraces = false;
+const FormatToken *BeforeRBrace = nullptr;
 const auto &SourceMgr = Env.getSourceManager();
 for (auto *Line : Lines) {
   if (!Line->Children.empty())
 editEnumTrailingComma(Line->Children, Result);
-  if (!Line->Affected)
-continue;
   for (const auto *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (Token->isNot(TT_EnumRBrace))
+if (Token->isNot(TT_EnumRBrace)) {
+  if (Token->is(TT_EnumLBrace))
+InEnumBraces = true;
+  else if (InEnumBraces && Line->Affected && 
Token->isNot(tok::comment))
+BeforeRBrace = Token;
   continue;
-const auto *BeforeRBrace = Token->getPreviousNonComment();
-assert(BeforeRBrace);
-if (BeforeRBrace->is(TT_EnumLBrace)) // Empty braces.
+}
+InEnumBraces = false;
+if (!BeforeRBrace) // Empty braces or Line not affected.
   continue;
 if (BeforeRBrace->is(tok::comma)) {
   if (Style.EnumTrailingComma == FormatStyle::ETC_Remove)
@@ -2448,6 +2452,7 @@ class EnumTrailingCommaEditor : public TokenAnalyzer {
   cantFail(Result.add(tooling::Replacement(
   SourceMgr, BeforeRBrace->Tok.getEndLoc(), 0, ",")));
 }
+BeforeRBrace = nullptr;
   }
 }
   }
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index b62d49e17c83f..be0343efb4b83 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -27962,6 +27962,7 @@ TEST_F(FormatTest, EnumTrailingComma) {
   verifyFormat(Code);
 
   auto Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortEnumsOnASingleLine);
   Style.EnumTrailingComma = FormatStyle::ETC_Insert;
   verifyFormat("enum : int { /**/ };\n"
"enum {\n"
@@ -27972,6 +27973,16 @@ TEST_F(FormatTest, EnumTrailingComma) {
"enum Color { red, green, blue, /**/ };",
Code, Style);
 
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum class MyEnum_E {\n"
+   "  MY_ENUM = 0U,\n"
+   "};",
+   "enum class MyEnum_E {\n"
+   "  MY_ENUM = 0U\n"
+   "};",
+   Style);
+  Style.AllowShortEnumsOnASingleLine = true;
+
   Style.EnumTrailingComma = FormatStyle::ETC_Remove;
   verifyFormat("enum : int { /**/ };\n"
"enum {\n"

``




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


[clang] [clang-format] Fix a crash in EnumTrailingComma (PR #135903)

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

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

Fix #135819

>From 8f79ecf3e3f32b6b735a478eb1d3a48b7a6fa640 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 15 Apr 2025 21:02:28 -0700
Subject: [PATCH] [clang-format] Fix a crash in EnumTrailingComma

Fix #135819
---
 clang/lib/Format/Format.cpp   | 17 +++--
 clang/unittests/Format/FormatTest.cpp | 11 +++
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index c601967a8715c..b8d55871ab932 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2427,19 +2427,23 @@ class EnumTrailingCommaEditor : public TokenAnalyzer {
 private:
   void editEnumTrailingComma(SmallVectorImpl &Lines,
  tooling::Replacements &Result) {
+bool InEnumBraces = false;
+const FormatToken *BeforeRBrace = nullptr;
 const auto &SourceMgr = Env.getSourceManager();
 for (auto *Line : Lines) {
   if (!Line->Children.empty())
 editEnumTrailingComma(Line->Children, Result);
-  if (!Line->Affected)
-continue;
   for (const auto *Token = Line->First; Token && !Token->Finalized;
Token = Token->Next) {
-if (Token->isNot(TT_EnumRBrace))
+if (Token->isNot(TT_EnumRBrace)) {
+  if (Token->is(TT_EnumLBrace))
+InEnumBraces = true;
+  else if (InEnumBraces && Line->Affected && 
Token->isNot(tok::comment))
+BeforeRBrace = Token;
   continue;
-const auto *BeforeRBrace = Token->getPreviousNonComment();
-assert(BeforeRBrace);
-if (BeforeRBrace->is(TT_EnumLBrace)) // Empty braces.
+}
+InEnumBraces = false;
+if (!BeforeRBrace) // Empty braces or Line not affected.
   continue;
 if (BeforeRBrace->is(tok::comma)) {
   if (Style.EnumTrailingComma == FormatStyle::ETC_Remove)
@@ -2448,6 +2452,7 @@ class EnumTrailingCommaEditor : public TokenAnalyzer {
   cantFail(Result.add(tooling::Replacement(
   SourceMgr, BeforeRBrace->Tok.getEndLoc(), 0, ",")));
 }
+BeforeRBrace = nullptr;
   }
 }
   }
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index b62d49e17c83f..be0343efb4b83 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -27962,6 +27962,7 @@ TEST_F(FormatTest, EnumTrailingComma) {
   verifyFormat(Code);
 
   auto Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortEnumsOnASingleLine);
   Style.EnumTrailingComma = FormatStyle::ETC_Insert;
   verifyFormat("enum : int { /**/ };\n"
"enum {\n"
@@ -27972,6 +27973,16 @@ TEST_F(FormatTest, EnumTrailingComma) {
"enum Color { red, green, blue, /**/ };",
Code, Style);
 
+  Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum class MyEnum_E {\n"
+   "  MY_ENUM = 0U,\n"
+   "};",
+   "enum class MyEnum_E {\n"
+   "  MY_ENUM = 0U\n"
+   "};",
+   Style);
+  Style.AllowShortEnumsOnASingleLine = true;
+
   Style.EnumTrailingComma = FormatStyle::ETC_Remove;
   verifyFormat("enum : int { /**/ };\n"
"enum {\n"

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


[clang] [clang] Constant-evaluate format strings as last resort (PR #135864)

2025-04-15 Thread Hubert Tong via cfe-commits


@@ -10170,6 +10170,8 @@ def warn_format_bool_as_character : Warning<
   "using '%0' format specifier, but argument has boolean value">,
   InGroup;
 def note_format_string_defined : Note<"format string is defined here">;
+def note_format_string_evaluated_to : Note<
+  "format string was constant-evaluated">;

hubert-reinterpretcast wrote:

> The point is taken. Would you like to suggest an alternate wording?

"format string was evaluated, for diagnostic purposes, to"?

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


[clang] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)

2025-04-15 Thread via cfe-commits

https://github.com/irymarchyk updated 
https://github.com/llvm/llvm-project/pull/134337

>From df25a8bbfd827085265c51a44bedbf38deebbab4 Mon Sep 17 00:00:00 2001
From: Ivan Rymarchyk <>
Date: Sat, 29 Mar 2025 13:54:32 -0700
Subject: [PATCH 1/8] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add
 new AllowShortFunctionsOnASingleLineOptions for granular setup
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The current clang-format configuration option AllowShortFunctionsOnASingleLine 
uses a single enum (ShortFunctionStyle) to control when short function 
definitions can be merged onto a single line. This enum provides predefined 
combinations of conditions (e.g., None, Empty only, Inline only, Inline 
including Empty, All).

This approach has limitations:

1. **Lack of Granularity:** Users cannot specify arbitrary combinations of 
conditions. For example, a user might want to allow merging for both empty 
functions and short top-level functions, but not for short functions defined 
within classes. This is not possible with the current enum options except by 
choosing All, which might merge more than desired.

2. **Inflexibility:** Adding new conditions for merging (e.g., distinguishing 
between member functions and constructors, handling lambdas specifically) would 
require adding many new combined enum values, leading to a combinatorial 
explosion and making the configuration complex.

3. **Implicit Behavior:** Some options imply others (e.g., Inline implies 
Empty), which might not always be intuitive or desired.

The goal is to replace this single-choice enum with a more flexible mechanism 
allowing users to specify a set of conditions that must be met for a short 
function to be merged onto a single line.

**Proposed Solution**

1. Introduce a new configuration option: AllowShortFunctionsOnSingleLineOptions.

2. This option will accept a list of strings, where each string represents a 
specific condition allowing merging.

3. **Backward Compatibility:**

- If AllowShortFunctionsOnSingleLineOptions is present in the 
configuration, it takes precedence.

- If AllowShortFunctionsOnSingleLineOptions is not present, but the old 
AllowShortFunctionsOnASingleLine is present, the old option should be parsed 
and mapped to the corresponding new semantics for compatibility.
---
 clang/docs/ClangFormatStyleOptions.rst  |  64 +++
 clang/include/clang/Format/Format.h |  70 
 clang/lib/Format/Format.cpp |  52 +
 clang/lib/Format/TokenAnnotator.cpp |   7 +-
 clang/lib/Format/UnwrappedLineFormatter.cpp |   9 +-
 clang/unittests/Format/ConfigParseTest.cpp  |   6 ++
 clang/unittests/Format/FormatTest.cpp   | 111 
 7 files changed, 310 insertions(+), 9 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 9ecac68ae72bf..167701cf6585d 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1959,6 +1959,70 @@ the configuration (without a prefix: ``Auto``).
   };
   void f() { bar(); }
 
+  * ``SFS_Custom`` (in configuration: ``Custom``)
+Configure merge behavior using AllowShortFunctionsOnASingleLineOptions
+
+
+
+.. _AllowShortFunctionsOnASingleLineOptions:
+
+**AllowShortFunctionsOnASingleLineOptions** (``ShortFunctionMergeFlags``) 
:versionbadge:`clang-format 21` :ref:`¶ 
`
+  Precise control over merging short functions
+
+  If ``AllowShortFunctionsOnASingleLine`` is set to ``Custom``, use this to
+  specify behavior in different situations.
+
+  .. code-block:: yaml
+
+# Example of usage:
+AllowShortFunctionsOnASingleLine: Custom
+AllowShortFunctionsOnASingleLineOptions:
+  Empty: false
+  Inline: true
+  All: false
+
+  Nested configuration flags:
+
+  Precise control over merging short functions
+
+  .. code-block:: c++
+
+# Should be declared this way:
+AllowShortFunctionsOnASingleLine: Custom
+AllowShortFunctionsOnASingleLineOptions:
+  Empty: false
+  Inline: true
+  All: false
+
+  * ``bool Empty`` Only merge empty functions.
+
+.. code-block:: c++
+
+  void f() {}
+  void f2() {
+bar2();
+  }
+
+  * ``bool Inline`` Only merge functions defined inside a class.
+
+.. code-block:: c++
+
+  class Foo {
+void f() { foo(); }
+  };
+  void f() {
+foo();
+  }
+  void f() {}
+
+  * ``bool All`` Merge all functions fitting on a single line.
+
+.. code-block:: c++
+
+  class Foo {
+void f() { foo(); }
+  };
+  void f() { bar(); }
 
 
 .. _AllowShortIfStatementsOnASingleLine:
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index fec47a248abb4..96b1ecab04e63 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -871,6 +871,8 @@ struct FormatStyle {
 /

[clang] [clang-format]: Add `Custom` to `ShortFunctionStyle`; add new AllowShortFunctionsOnASingleLineOptions for granular setup (PR #134337)

2025-04-15 Thread via cfe-commits


@@ -5687,11 +5687,9 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine 
&Line,
 if (Right.is(tok::r_brace) && Left.is(tok::l_brace) &&
 !Left.Children.empty()) {
   // Support AllowShortFunctionsOnASingleLine for JavaScript.
-  return Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_None ||
- Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Empty 
||
- (Left.NestingLevel == 0 && Line.Level == 0 &&
-  Style.AllowShortFunctionsOnASingleLine &
-  FormatStyle::SFS_InlineOnly);
+  return !(Left.NestingLevel == 0 && Line.Level == 0
+   ? Style.AllowShortFunctionsOnASingleLine.Other
+   : Style.AllowShortFunctionsOnASingleLine.Inline);

irymarchyk wrote:

Thanks for explanation! I think I finally understood what Other mean. 
I've added your example to unit test.

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


[clang-tools-extra] [clangd] Add `HeaderInsertion` yaml config option (PR #128503)

2025-04-15 Thread kadir çetinkaya via cfe-commits


@@ -341,6 +341,14 @@ struct Fragment {
 ///   Delimiters: empty pair of delimiters "()" or "<>"
 ///   FullPlaceholders: full name of both type and parameter
 std::optional> ArgumentLists;
+/// Add #include directives when accepting code completions. Config
+/// equivalent of the CLI option '--header-insertion'
+/// Valid values are enum Config::HeaderInsertionPolicy values:
+///   "IWYU": Include what you use. Insert the owning header for top-level
+/// symbols, unless the header is already directly included or the
+/// symbol is forward-declared
+///   "NeverInsert": Never insert headers

kadircet wrote:

looks like there's a slight discrepancy here; value is documented as 
`NeverInsert` here, but config-compiler expects `Never`. Can you amend one of 
those?

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


[clang-tools-extra] [clangd] Add `HeaderInsertion` yaml config option (PR #128503)

2025-04-15 Thread via cfe-commits


@@ -341,6 +341,14 @@ struct Fragment {
 ///   Delimiters: empty pair of delimiters "()" or "<>"
 ///   FullPlaceholders: full name of both type and parameter
 std::optional> ArgumentLists;
+/// Add #include directives when accepting code completions. Config
+/// equivalent of the CLI option '--header-insertion'
+/// Valid values are enum Config::HeaderInsertionPolicy values:
+///   "IWYU": Include what you use. Insert the owning header for top-level
+/// symbols, unless the header is already directly included or the
+/// symbol is forward-declared
+///   "NeverInsert": Never insert headers

MythreyaK wrote:

Whoops, my mistake! Do I make a new PR or push a new amend-ed commit to the 
existing branch? 

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


[clang-tools-extra] [clangd] Add `HeaderInsertion` yaml config option (PR #128503)

2025-04-15 Thread via cfe-commits


@@ -341,6 +341,14 @@ struct Fragment {
 ///   Delimiters: empty pair of delimiters "()" or "<>"
 ///   FullPlaceholders: full name of both type and parameter
 std::optional> ArgumentLists;
+/// Add #include directives when accepting code completions. Config
+/// equivalent of the CLI option '--header-insertion'
+/// Valid values are enum Config::HeaderInsertionPolicy values:
+///   "IWYU": Include what you use. Insert the owning header for top-level
+/// symbols, unless the header is already directly included or the
+/// symbol is forward-declared
+///   "NeverInsert": Never insert headers

MythreyaK wrote:

Me neither :D

Will create a new PR with the proposed fix

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


[clang] [Lex] Use llvm::make_second_range (NFC) (PR #135902)

2025-04-15 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata updated 
https://github.com/llvm/llvm-project/pull/135902

>From 48a5e79784e0cc9a4084878712d36864bcd17cde Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Tue, 15 Apr 2025 09:40:23 -0700
Subject: [PATCH] [Lex] Use llvm::make_second_range (NFC)

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

diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 9283a0f4fce55..2665580e5afce 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1932,8 +1932,7 @@ void 
HeaderSearch::collectAllModules(SmallVectorImpl &Modules) {
   }
 
   // Populate the list of modules.
-  llvm::transform(ModMap.modules(), std::back_inserter(Modules),
-  [](const auto &NameAndMod) { return NameAndMod.second; });
+  llvm::append_range(Modules, llvm::make_second_range(ModMap.modules()));
 }
 
 void HeaderSearch::loadTopLevelSystemModules() {

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


[clang-tools-extra] [clangd][docs] Fix incorrect docstring for header-insertion "Never" (PR #135921)

2025-04-15 Thread via cfe-commits

https://github.com/MythreyaK created 
https://github.com/llvm/llvm-project/pull/135921

Docstring fix for changes introduced in PR #128503 



>From 31b695950ffe45f613d28a1b0856ccec2bac873c Mon Sep 17 00:00:00 2001
From: Mythreya 
Date: Tue, 15 Apr 2025 23:37:33 -0700
Subject: [PATCH] [clangd][docs] Fix incorrect docstring for header-insertion
 "Never"

Docstring fix for changes introduced in PR #128503.
---
 clang-tools-extra/clangd/ConfigFragment.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index f05ed4d1acdfc..2363b483ab96d 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -347,7 +347,7 @@ struct Fragment {
 ///   "IWYU": Include what you use. Insert the owning header for top-level
 /// symbols, unless the header is already directly included or the
 /// symbol is forward-declared
-///   "NeverInsert": Never insert headers
+///   "Never": Never insert headers
 std::optional> HeaderInsertion;
   };
   CompletionBlock Completion;

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


[clang] [Clang][Sema] Fix -Whigher-precision-for-complex-division (PR #131477)

2025-04-15 Thread Mészáros Gergely via cfe-commits

https://github.com/Maetveis updated 
https://github.com/llvm/llvm-project/pull/131477

From d3da72bf61ae8268a25e5331acefe895c783905a Mon Sep 17 00:00:00 2001
From: Gergely Meszaros 
Date: Sat, 15 Mar 2025 22:37:07 +0100
Subject: [PATCH 1/3] [Clang][Sema] Fix -Whigher-precision-for-complex-division

- Fix false positive when divisor is a real number
- Fix false negative when divident is real, but divisor is complex
- Fix false negative when due to promotion the division is performed
  in higher precision than the divident.
- Fix false negative in divide and assign (`a /= b`)

Fixes: #131127
---
 clang/docs/ReleaseNotes.rst   | 11 +++
 clang/lib/Sema/SemaExpr.cpp   | 78 
 .../complex-div-warn-higher-precision.cpp | 93 +++
 3 files changed, 144 insertions(+), 38 deletions(-)
 create mode 100644 clang/test/Sema/complex-div-warn-higher-precision.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 46d2debec3621..ae04ff52cdfdc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -349,6 +349,17 @@ Improvements to Clang's diagnostics
 - Now correctly diagnose a tentative definition of an array with static
   storage duration in pedantic mode in C. (#GH50661)
 
+- ``-Whigher-precisision-for-complex-divison`` no longer incorrectly warns 
when the divisor is real
+  in complex division. (#GH131127)
+
+- ``-Whigher-precisision-for-complex-divison`` now correctly warns when:
+
+  - The dividend is real, but the divisor is complex.
+  - When the complex division happens in a higher precision type than the 
dividend due to arithmetic promotion.
+  - When using the divide and assign operator (``/=``)
+  
+  Fixes #GH131127
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c25daaa022f49..1ac84d7e95323 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10591,6 +10591,45 @@ static void checkArithmeticNull(Sema &S, ExprResult 
&LHS, ExprResult &RHS,
   << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 }
 
+static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy,
+ SourceLocation OpLoc) {
+  // If the divisor is real, then this is real/real or complex/real division.
+  // Either way there can be no precision loss.
+  auto *CT = DivisorTy->getAs();
+  if (!CT)
+return;
+
+  QualType ElementType = CT->getElementType();
+  bool IsComplexRangePromoted = S.getLangOpts().getComplexRange() ==
+LangOptions::ComplexRangeKind::CX_Promoted;
+  if (!ElementType->isFloatingType() || !IsComplexRangePromoted)
+return;
+
+  ASTContext &Ctx = S.getASTContext();
+  QualType HigherElementType = Ctx.GetHigherPrecisionFPType(ElementType);
+  const llvm::fltSemantics &ElementTypeSemantics =
+  Ctx.getFloatTypeSemantics(ElementType);
+  const llvm::fltSemantics &HigherElementTypeSemantics =
+  Ctx.getFloatTypeSemantics(HigherElementType);
+
+  if ((llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
+   llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) ||
+  (HigherElementType == Ctx.LongDoubleTy &&
+   !Ctx.getTargetInfo().hasLongDoubleType())) {
+// Retain the location of the first use of higher precision type.
+if (!S.LocationOfExcessPrecisionNotSatisfied.isValid())
+  S.LocationOfExcessPrecisionNotSatisfied = OpLoc;
+for (auto &[Type, Num] : S.ExcessPrecisionNotSatisfied) {
+  if (Type == HigherElementType) {
+Num++;
+return;
+  }
+}
+S.ExcessPrecisionNotSatisfied.push_back(std::make_pair(
+HigherElementType, S.ExcessPrecisionNotSatisfied.size()));
+  }
+}
+
 static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
   SourceLocation Loc) {
   const auto *LUE = dyn_cast(LHS);
@@ -10685,6 +10724,7 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult 
&LHS, ExprResult &RHS,
   if (compType.isNull() || !compType->isArithmeticType())
 return InvalidOperands(Loc, LHS, RHS);
   if (IsDiv) {
+DetectPrecisionLossInComplexDivision(*this, RHS.get()->getType(), Loc);
 DiagnoseBadDivideOrRemainderValues(*this, LHS, RHS, Loc, IsDiv);
 DiagnoseDivisionSizeofPointerOrArray(*this, LHS.get(), RHS.get(), Loc);
   }
@@ -15336,39 +15376,6 @@ static void DiagnoseBinOpPrecedence(Sema &Self, 
BinaryOperatorKind Opc,
 DiagnoseShiftCompare(Self, OpLoc, LHSExpr, RHSExpr);
 }
 
-static void DetectPrecisionLossInComplexDivision(Sema &S, SourceLocation OpLoc,
- Expr *Operand) {
-  if (auto *CT = Operand->getType()->getAs()) {
-QualType ElementType = CT->getElementType();
-bool IsComplexRangePromoted = S.getLangOpts().getComplexRange() ==
- 

[clang] f3c7744 - [Clang][Sema] Fix -Whigher-precision-for-complex-division (#131477)

2025-04-15 Thread via cfe-commits

Author: Mészáros Gergely
Date: 2025-04-16T08:02:42+02:00
New Revision: f3c77445791b510858561cb424ffa1cd7513250b

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

LOG: [Clang][Sema] Fix -Whigher-precision-for-complex-division (#131477)

- Fix false positive when divisor is a real number.
- Fix false negative when divident is real, but divisor is complex.
- Fix false negative when due to promotion the division is performed in
higher precision than the divident.
- Fix false negative in divide and assign (`a /= b`).

Fixes: #131127

-

Co-authored-by: Zahira Ammarguellat 

Added: 
clang/test/Sema/complex-div-warn-higher-precision.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 84ad253c1ec4f..5af4c08f64cd8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -371,6 +371,14 @@ Improvements to Clang's diagnostics
 
 - An error is now emitted when a ``musttail`` call is made to a function 
marked with the ``not_tail_called`` attribute. (#GH133509).
 
+- ``-Whigher-precisision-for-complex-divison`` warns when:
+
+  -The divisor is complex.
+  -When the complex division happens in a higher precision type due to 
arithmetic promotion.
+  -When using the divide and assign operator (``/=``).
+
+  Fixes #GH131127
+
 Improvements to Clang's time-trace
 --
 

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index c65b4eadf9c67..6830bb5c01c7d 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -10602,6 +10602,45 @@ static void checkArithmeticNull(Sema &S, ExprResult 
&LHS, ExprResult &RHS,
   << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 }
 
+static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy,
+ SourceLocation OpLoc) {
+  // If the divisor is real, then this is real/real or complex/real division.
+  // Either way there can be no precision loss.
+  auto *CT = DivisorTy->getAs();
+  if (!CT)
+return;
+
+  QualType ElementType = CT->getElementType();
+  bool IsComplexRangePromoted = S.getLangOpts().getComplexRange() ==
+LangOptions::ComplexRangeKind::CX_Promoted;
+  if (!ElementType->isFloatingType() || !IsComplexRangePromoted)
+return;
+
+  ASTContext &Ctx = S.getASTContext();
+  QualType HigherElementType = Ctx.GetHigherPrecisionFPType(ElementType);
+  const llvm::fltSemantics &ElementTypeSemantics =
+  Ctx.getFloatTypeSemantics(ElementType);
+  const llvm::fltSemantics &HigherElementTypeSemantics =
+  Ctx.getFloatTypeSemantics(HigherElementType);
+
+  if ((llvm::APFloat::semanticsMaxExponent(ElementTypeSemantics) * 2 + 1 >
+   llvm::APFloat::semanticsMaxExponent(HigherElementTypeSemantics)) ||
+  (HigherElementType == Ctx.LongDoubleTy &&
+   !Ctx.getTargetInfo().hasLongDoubleType())) {
+// Retain the location of the first use of higher precision type.
+if (!S.LocationOfExcessPrecisionNotSatisfied.isValid())
+  S.LocationOfExcessPrecisionNotSatisfied = OpLoc;
+for (auto &[Type, Num] : S.ExcessPrecisionNotSatisfied) {
+  if (Type == HigherElementType) {
+Num++;
+return;
+  }
+}
+S.ExcessPrecisionNotSatisfied.push_back(std::make_pair(
+HigherElementType, S.ExcessPrecisionNotSatisfied.size()));
+  }
+}
+
 static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
   SourceLocation Loc) {
   const auto *LUE = dyn_cast(LHS);
@@ -10696,6 +10735,7 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult 
&LHS, ExprResult &RHS,
   if (compType.isNull() || !compType->isArithmeticType())
 return InvalidOperands(Loc, LHS, RHS);
   if (IsDiv) {
+DetectPrecisionLossInComplexDivision(*this, RHS.get()->getType(), Loc);
 DiagnoseBadDivideOrRemainderValues(*this, LHS, RHS, Loc, IsDiv);
 DiagnoseDivisionSizeofPointerOrArray(*this, LHS.get(), RHS.get(), Loc);
   }
@@ -15347,39 +15387,6 @@ static void DiagnoseBinOpPrecedence(Sema &Self, 
BinaryOperatorKind Opc,
 DiagnoseShiftCompare(Self, OpLoc, LHSExpr, RHSExpr);
 }
 
-static void DetectPrecisionLossInComplexDivision(Sema &S, SourceLocation OpLoc,
- Expr *Operand) {
-  if (auto *CT = Operand->getType()->getAs()) {
-QualType ElementType = CT->getElementType();
-bool IsComplexRangePromoted = S.getLangOpts().getComplexRange() ==
-  LangOptions::ComplexRangeKind::CX_Promoted;
-if (ElementType->isFloatingType() && IsComplexRangePromoted) {
-  AS

[clang] [Clang][Sema] Fix -Whigher-precision-for-complex-division (PR #131477)

2025-04-15 Thread Mészáros Gergely via cfe-commits

https://github.com/Maetveis closed 
https://github.com/llvm/llvm-project/pull/131477
___
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   7   >