[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt updated 
https://github.com/llvm/llvm-project/pull/136828

>From 8d42eca9da4afd53b9d51fda5a8d285ed2cdeb72 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Wed, 30 Apr 2025 22:26:59 -0700
Subject: [PATCH] [clang][PAC] add support for options parameter to __ptrauth

This PR adds support for an 'options' parameter for the __ptrauth
qualifier.

The initial version only exposes the authehntication modes:
 * "strip"
 * "sign-and-strip"
 * "sign-and-auth"

We also support parsing the options but not yet the implementation
 * "isa-pointer"
 * "authenticates-null-values"

The initial support for authentication mode controls exist to support
ABI changes over time, and as a byproduct support basic initial tests
for option parsing.
---
 clang/include/clang/Basic/Attr.td |   6 +-
 .../clang/Basic/DiagnosticParseKinds.td   |   4 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  19 +-
 clang/include/clang/Basic/LangOptions.h   |  11 +
 clang/lib/CodeGen/CGExprConstant.cpp  |  24 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +-
 clang/lib/Sema/SemaType.cpp   | 157 -
 clang/test/CodeGen/ptrauth-stripping.c| 327 ++
 clang/test/Parser/ptrauth-qualifier.c |   2 +-
 clang/test/Sema/ptrauth-qualifier-options.c   |  65 
 clang/test/Sema/ptrauth-qualifier.c   |  39 ++-
 .../ptrauth-qualifier-constexpr-options.cpp   |  65 
 12 files changed, 691 insertions(+), 30 deletions(-)
 create mode 100644 clang/test/CodeGen/ptrauth-stripping.c
 create mode 100644 clang/test/Sema/ptrauth-qualifier-options.c
 create mode 100644 clang/test/SemaCXX/ptrauth-qualifier-constexpr-options.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 37c80ac90182c..1941bb2d1febc 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3595,9 +3595,9 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 
 def PointerAuth : TypeAttr {
   let Spellings = [CustomKeyword<"__ptrauth">];
-  let Args = [IntArgument<"Key">,
-  BoolArgument<"AddressDiscriminated", 1>,
-  IntArgument<"ExtraDiscriminator", 1>];
+  let Args = [IntArgument<"Key">, BoolArgument<"AddressDiscriminated", 1>,
+  IntArgument<"ExtraDiscriminator", 1>,
+  StringArgument<"Options", 1>];
   let Documentation = [PtrAuthDocs];
 }
 
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 3bbdc49946dac..8e0f818714c42 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1735,8 +1735,8 @@ def warn_pragma_unroll_cuda_value_in_parens : Warning<
   "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">,
   InGroup;
 
-def err_ptrauth_qualifier_bad_arg_count : Error<
-  "'__ptrauth' qualifier must take between 1 and 3 arguments">;
+def err_ptrauth_qualifier_bad_arg_count
+: Error<"'__ptrauth' qualifier must take between 1 and 4 arguments">;
 
 def warn_cuda_attr_lambda_position : Warning<
   "nvcc does not allow '__%0__' to appear after the parameter list in 
lambdas">,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 89b2d664d66a0..0da30d0d98061 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1045,6 +1045,24 @@ def err_ptrauth_extra_discriminator_invalid : Error<
   "invalid extra discriminator flag '%0'; '__ptrauth' requires a value between 
"
   "'0' and '%1'">;
 
+// __ptrauth qualifier options string
+def note_ptrauth_evaluating_options
+: Note<"options parameter evaluated to '%0'">;
+def err_ptrauth_invalid_option : Error<"'%0' options parameter %1">;
+def err_ptrauth_unknown_authentication_option
+: Error<"unknown '%0' authentication option '%1'">;
+def err_ptrauth_repeated_authentication_option
+: Error<"repeated '%0' authentication %select{mode|option}1%select{, prior 
"
+"mode was '%3'| '%2'}1">;
+def note_ptrauth_previous_authentication_option
+: Note<"previous '%0' authentication %select{mode|option}1">;
+def err_ptrauth_unexpected_option_end
+: Error<"unexpected end of options parameter for %0">;
+def err_ptrauth_option_unexpected_token
+: Error<"unexpected character '%0' in '%1' options">;
+def err_ptrauth_option_missing_comma
+: Error<"missing comma after '%1' option in '%0' qualifier">;
+
 /// main()
 // static main() is not an error in C, just in C++.
 def warn_static_main : Warning<"'main' should not be declared static">,
@@ -1735,7 +1753,6 @@ def err_static_assert_requirement_failed : Error<
 def note_expr_evaluates_to : Note<
   "expression evaluates to '%0 %1 %2'">;
 
-
 def subst_user_defined_msg : TextSubstitution<
   "%select{the message|the expression}0 in "
   "%select{a static assertion

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Oliver Hunt (ojhunt)


Changes

[clang][PAC] add support for options parameter to __ptrauth

This PR adds support for an 'options' parameter for the __ptrauth
qualifier.

The initial version only exposes the authehntication modes:
 * "strip"
 * "sign-and-strip"
 * "sign-and-auth"

We also support parsing the options but not yet the implementation
 * "isa-pointer"
 * "authenticates-null-values"

The initial support for authentication mode controls exist to support
ABI changes over time, and as a byproduct support basic initial tests
for option parsing.


---

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


12 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+3-3) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+2-2) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+17-1) 
- (modified) clang/include/clang/Basic/LangOptions.h (+11) 
- (modified) clang/lib/CodeGen/CGExprConstant.cpp (+17-7) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaType.cpp (+150-9) 
- (added) clang/test/CodeGen/ptrauth-stripping.c (+327) 
- (modified) clang/test/Parser/ptrauth-qualifier.c (+1-1) 
- (added) clang/test/Sema/ptrauth-qualifier-options.c (+65) 
- (modified) clang/test/Sema/ptrauth-qualifier.c (+33-6) 
- (added) clang/test/SemaCXX/ptrauth-qualifier-constexpr-options.cpp (+65) 


``diff
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 37c80ac90182c..1941bb2d1febc 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3595,9 +3595,9 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 
 def PointerAuth : TypeAttr {
   let Spellings = [CustomKeyword<"__ptrauth">];
-  let Args = [IntArgument<"Key">,
-  BoolArgument<"AddressDiscriminated", 1>,
-  IntArgument<"ExtraDiscriminator", 1>];
+  let Args = [IntArgument<"Key">, BoolArgument<"AddressDiscriminated", 1>,
+  IntArgument<"ExtraDiscriminator", 1>,
+  StringArgument<"Options", 1>];
   let Documentation = [PtrAuthDocs];
 }
 
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 3bbdc49946dac..8e0f818714c42 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1735,8 +1735,8 @@ def warn_pragma_unroll_cuda_value_in_parens : Warning<
   "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">,
   InGroup;
 
-def err_ptrauth_qualifier_bad_arg_count : Error<
-  "'__ptrauth' qualifier must take between 1 and 3 arguments">;
+def err_ptrauth_qualifier_bad_arg_count
+: Error<"'__ptrauth' qualifier must take between 1 and 4 arguments">;
 
 def warn_cuda_attr_lambda_position : Warning<
   "nvcc does not allow '__%0__' to appear after the parameter list in 
lambdas">,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 89b2d664d66a0..0ae2c09b1e4fb 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1045,6 +1045,23 @@ def err_ptrauth_extra_discriminator_invalid : Error<
   "invalid extra discriminator flag '%0'; '__ptrauth' requires a value between 
"
   "'0' and '%1'">;
 
+// __ptrauth qualifier options string
+def note_ptrauth_evaluating_options
+: Note<"options parameter evaluated to '%0'">;
+def err_ptrauth_invalid_option : Error<"'%0' options parameter %1">;
+def err_ptrauth_unknown_authentication_option
+: Error<"unknown '%0' authentication option '%1'">;
+def err_ptrauth_repeated_authentication_option
+: Error<"repeated '%0' authentication %select{mode|option}1%select{, prior 
mode was '%3'| '%2'}1">;
+def note_ptrauth_previous_authentication_option
+: Note<"previous '%0' authentication %select{mode|option}1">;
+def err_ptrauth_unexpected_option_end
+: Error<"unexpected end of options parameter for %0">;
+def err_ptrauth_option_unexpected_token
+: Error<"unexpected character '%0' in '%1' options">;
+def err_ptrauth_option_missing_comma
+: Error<"missing comma after '%1' option in '%0' qualifier">;
+
 /// main()
 // static main() is not an error in C, just in C++.
 def warn_static_main : Warning<"'main' should not be declared static">,
@@ -1735,7 +1752,6 @@ def err_static_assert_requirement_failed : Error<
 def note_expr_evaluates_to : Note<
   "expression evaluates to '%0 %1 %2'">;
 
-
 def subst_user_defined_msg : TextSubstitution<
   "%select{the message|the expression}0 in "
   "%select{a static assertion|this asm operand}0">;
diff --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 491e8bee9fd5c..3944946374d30 100644
--- a/clang/include/clang/Basi

[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits


@@ -65,6 +65,17 @@ enum class PointerAuthenticationMode : unsigned {
   SignAndAuth
 };
 
+static constexpr llvm::StringLiteral PointerAuthenticationOptionStrip = 
"strip";

ojhunt wrote:

@cor3ntin @AaronBallman is there a better/more idiomatic way of doing these?

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


[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits

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


[clang] Fix crash with invalid VLA in a type trait (PR #138543)

2025-05-09 Thread Shafik Yaghmour via cfe-commits


@@ -41,3 +41,17 @@ void func(int expr) {
   int array[sizeof(Ty) ? sizeof(Ty{}) : sizeof(int)];
   int old_style_assert[expr ? Ty::one : Ty::Neg_one]; // We don't diagnose as 
a VLA until instantiation
 }
+
+namespace GH138444 {
+struct S { // expected-note {{candidate constructor (the implicit copy 
constructor) not viable: no known conversion from 'int' to 'const S &' for 1st 
argument}} \

shafik wrote:

I would have liked to see a test for the union case as well since it also 
triggered the crash. I don't see a way to trigger it w/ the enum case yet. 

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


[clang] 98d68e4 - [clang][bytecode][NFC] Remove unused function (#139355)

2025-05-09 Thread via cfe-commits

Author: Timm Baeder
Date: 2025-05-10T07:57:44+02:00
New Revision: 98d68e49f73efab7126a34fa2469a590e832afa4

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

LOG: [clang][bytecode][NFC] Remove unused function (#139355)

Added: 


Modified: 
clang/lib/AST/ByteCode/Interp.cpp
clang/lib/AST/ByteCode/Interp.h

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 9c041ad782af9..43f8d156589b6 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -942,15 +942,6 @@ bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer 
&This) {
   return false;
 }
 
-bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD) {
-  if (!MD->isPureVirtual())
-return true;
-  const SourceInfo &E = S.Current->getSource(OpPC);
-  S.FFDiag(E, diag::note_constexpr_pure_virtual_call, 1) << MD;
-  S.Note(MD->getLocation(), diag::note_declared_at);
-  return false;
-}
-
 bool CheckFloatResult(InterpState &S, CodePtr OpPC, const Floating &Result,
   APFloat::opStatus Status, FPOptions FPO) {
   // [expr.pre]p4:

diff  --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index c89e68a0c27ba..a13fd6c1f1daa 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -114,9 +114,6 @@ bool CheckCallDepth(InterpState &S, CodePtr OpPC);
 /// Checks the 'this' pointer.
 bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This);
 
-/// Checks if a method is pure virtual.
-bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD);
-
 /// Checks if all the arguments annotated as 'nonnull' are in fact not null.
 bool CheckNonNullArgs(InterpState &S, CodePtr OpPC, const Function *F,
   const CallExpr *CE, unsigned ArgSize);



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


[clang] [clang][bytecode][NFC] Remove unused function (PR #139355)

2025-05-09 Thread Timm Baeder via cfe-commits

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


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

2025-05-09 Thread via cfe-commits

Author: halbi2
Date: 2025-05-10T08:03:20+02:00
New Revision: 0b9c63dfe91309935d607f701bed90a739ad47f0

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

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

The old codepath in GetFullTypeForDeclarator was under "if (not a class type)"
so that it failed to warn for class types. Move the diagnostic outside
of the "if" so that it warns in the proper situations.

Fixes #133380

Co-authored-by: cor3ntin 

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaType.cpp
clang/test/CXX/expr/expr.const/p2-0x.cpp
clang/test/SemaCXX/deprecated.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dcf260f282ac3..1d0896f585fb4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -509,6 +509,9 @@ Improvements to Clang's diagnostics
 - Clang now prints the namespace for an attribute, if any,
   when emitting an unknown attribute diagnostic.
 
+- ``-Wvolatile`` now warns about volatile-qualified class return types
+  as well as volatile-qualified scalar return types. Fixes #GH133380
+
 - Several compatibility diagnostics that were incorrectly being grouped under
   ``-Wpre-c++20-compat`` are now part of ``-Wc++20-compat``. (#GH138775)
 
@@ -921,7 +924,8 @@ Improvements
 
 
 Additional Information
-==
+
+===
 
 A wide variety of additional information is available on the `Clang web
 page `_. The web page contains versions of the

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index a8e85c885069e..9ed2326f151a3 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5056,13 +5056,13 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
   S.Diag(DeclType.Loc, diag::err_func_returning_qualified_void) << T;
 } else
   diagnoseRedundantReturnTypeQualifiers(S, T, D, chunkIndex);
-
-// C++2a [dcl.fct]p12:
-//   A volatile-qualified return type is deprecated
-if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
-  S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
   }
 
+  // C++2a [dcl.fct]p12:
+  //   A volatile-qualified return type is deprecated
+  if (T.isVolatileQualified() && S.getLangOpts().CPlusPlus20)
+S.Diag(DeclType.Loc, diag::warn_deprecated_volatile_return) << T;
+
   // Objective-C ARC ownership qualifiers are ignored on the function
   // return type (by type canonicalization). Complain if this attribute
   // was written here.

diff  --git a/clang/test/CXX/expr/expr.const/p2-0x.cpp 
b/clang/test/CXX/expr/expr.const/p2-0x.cpp
index df5ce108aca82..c6c3381be5523 100644
--- a/clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ b/clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -356,7 +356,7 @@ namespace LValueToRValue {
   // - a non-volatile glvalue of literal type that refers to a non-volatile
   //   temporary object whose lifetime has not ended, initialized with a
   //   constant expression;
-  constexpr volatile S f() { return S(); }
+  constexpr volatile S f() { return S(); } // cxx20-warning 
{{volatile-qualified return type 'volatile S' is deprecated}}
   static_assert(f().i, ""); // expected-error {{constant expression}} 
expected-note {{read of volatile-qualified type}}
   static_assert(((volatile const S&&)(S)0).i, ""); // expected-error 
{{constant expression}} expected-note {{read of volatile-qualified type}}
 }

diff  --git a/clang/test/SemaCXX/deprecated.cpp 
b/clang/test/SemaCXX/deprecated.cpp
index a24b40d8e622a..ba7bb71b7d20b 100644
--- a/clang/test/SemaCXX/deprecated.cpp
+++ b/clang/test/SemaCXX/deprecated.cpp
@@ -231,6 +231,13 @@ namespace DeprecatedVolatile {
 a = c = a;
 b += a;
   }
+
+  volatile struct amber jurassic();
+// cxx20-warning@-1 {{volatile-qualified return type 'volatile struct 
amber' is deprecated}}
+  void trex(volatile short left_arm, volatile struct amber right_arm);
+// cxx20-warning@-1 {{volatile-qualified parameter type 'volatile short' 
is deprecated}}
+// cxx20-warning@-2 {{volatile-qualified parameter type 'volatile struct 
amber' is deprecated}}
+  void fly(volatile struct pterosaur* pteranodon);
 }
 
 namespace ArithConv {



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


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

2025-05-09 Thread via cfe-commits

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



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits


@@ -1735,8 +1735,8 @@ def warn_pragma_unroll_cuda_value_in_parens : Warning<
   "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">,
   InGroup;
 
-def err_ptrauth_qualifier_bad_arg_count : Error<
-  "'__ptrauth' qualifier must take between 1 and 3 arguments">;
+def err_ptrauth_qualifier_bad_arg_count

ojhunt wrote:

This is clang-format induced (aside from the 3 vs 4 change obviously) I can 
more the `Error<` back but it might be worth trying to work out how to stop 
clang-format from making this choice

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


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

2025-05-09 Thread via cfe-commits

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


[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits


@@ -8373,10 +8375,140 @@ static void HandlePtrAuthQualifier(ASTContext &Ctx, 
QualType &T,
IsAddressDiscriminated);
   IsInvalid |= !S.checkPointerAuthDiscriminatorArg(
   ExtraDiscriminatorArg, PointerAuthDiscArgKind::Extra, 
ExtraDiscriminator);
+  std::string LastAuthenticationMode;
+  std::optional AuthenticationMode = std::nullopt;
+  bool IsIsaPointer = false;
+  bool AuthenticatesNullValues = false;
+
+  if (AuthenticationOptionsArg && !AuthenticationOptionsArg->containsErrors()) 
{
+StringRef OptionsString;
+std::string EvaluatedString;
+bool HasEvaluatedOptionsString = false;
+const StringLiteral *OptionsStringLiteral =
+dyn_cast(AuthenticationOptionsArg);
+SourceRange AuthenticationOptionsRange =
+AuthenticationOptionsArg->getSourceRange();
+bool ReportedEvaluation = false;
+auto ReportEvaluationOfExpressionIfNeeded = [&]() {
+  if (OptionsStringLiteral || !HasEvaluatedOptionsString ||
+  ReportedEvaluation)
+return;
+  ReportedEvaluation = true;
+  S.Diag(AuthenticationOptionsRange.getBegin(),
+ diag::note_ptrauth_evaluating_options)
+  << OptionsString << AuthenticationOptionsRange;
+};
+auto DiagnoseInvalidOptionsParameter = [&](llvm::StringRef Reason) {
+  S.Diag(AuthenticationOptionsRange.getBegin(),
+ diag::err_ptrauth_invalid_option)
+  << AttrName << Reason;
+  Attr.setInvalid();
+  IsInvalid = true;
+  ReportEvaluationOfExpressionIfNeeded();
+};
+if (AuthenticationOptionsArg->isValueDependent() ||
+AuthenticationOptionsArg->isTypeDependent()) {
+  DiagnoseInvalidOptionsParameter("is dependent");
+  return;
+}
+if (OptionsStringLiteral) {
+  OptionsString = OptionsStringLiteral->getString();
+  HasEvaluatedOptionsString = true;
+} else {
+  Expr::EvalResult Eval;
+  bool Result = AuthenticationOptionsArg->EvaluateAsRValue(Eval, Ctx);
+  if (Result && Eval.Val.isLValue()) {

ojhunt wrote:

This section can be replaced once 
https://github.com/llvm/llvm-project/pull/135864 or similar is landed as it 
supports const char* constant expressions

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


[clang] b3a6d43 - [Clang] Allow parsing arbitrary order of attributes for declarations (#133107)

2025-05-09 Thread via cfe-commits

Author: Denis.G
Date: 2025-05-09T14:10:18-04:00
New Revision: b3a6d434a7051d879718ef92a4fafd1697759aed

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

LOG: [Clang] Allow parsing arbitrary order of attributes for declarations 
(#133107)

Enable parsing alignas attribute after GNU attributes, before
ParseDeclaration

This might be useful for cuda code where __shared__ and other
specificators may be mixed with align.

I'd be glad to see if there are any better places or other technique to
process this attribute without interrupting current flow of parsing.

Added: 
clang/test/SemaCUDA/cuda-attr-order.cu

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseStmt.cpp
clang/test/AST/ast-dump-template-json-win32-mangler-crash.cpp
clang/test/Parser/c2x-alignas.c
clang/test/Parser/cxx0x-attributes.cpp
clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cd452179a6555..9ca1c1c79b20a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -680,6 +680,7 @@ Bug Fixes to C++ Support
 - Improved parser recovery of invalid requirement expressions. In turn, this
   fixes crashes from follow-on processing of the invalid requirement. 
(#GH138820)
 - Fixed the handling of pack indexing types in the constraints of a member 
function redeclaration. (#GH138255)
+- Clang now correctly parses arbitrary order of ``[[]]``, ``__attribute__`` 
and ``alignas`` attributes for declarations (#GH133107)
 - Fixed a crash when forming an invalid function type in a dependent context. 
(#GH138657) (#GH115725) (#GH68852)
 
 Bug Fixes to AST Handling

diff  --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index e0b8850493b49..d2fec2b7a6462 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -3081,13 +3081,16 @@ class Parser : public CodeCompletionHandler {
 bool CouldBeBitField = false);
   Decl *ParseHLSLBuffer(SourceLocation &DeclEnd);
 
-  void MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
+  bool MaybeParseMicrosoftAttributes(ParsedAttributes &Attrs) {
+bool AttrsParsed = false;
 if ((getLangOpts().MicrosoftExt || getLangOpts().HLSL) &&
 Tok.is(tok::l_square)) {
   ParsedAttributes AttrsWithRange(AttrFactory);
   ParseMicrosoftAttributes(AttrsWithRange);
+  AttrsParsed = !AttrsWithRange.empty();
   Attrs.takeAllFrom(AttrsWithRange);
 }
+return AttrsParsed;
   }
   void ParseMicrosoftUuidAttributeArgs(ParsedAttributes &Attrs);
   void ParseMicrosoftAttributes(ParsedAttributes &Attrs);

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index ec080bf9dc97d..2aa7a5b1a0cb1 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -3096,11 +3096,24 @@ Parser::DeclGroupPtrTy 
Parser::ParseCXXClassMemberDeclaration(
   }
 
   ParsedAttributes DeclSpecAttrs(AttrFactory);
-  MaybeParseMicrosoftAttributes(DeclSpecAttrs);
-
   // Hold late-parsed attributes so we can attach a Decl to them later.
   LateParsedAttrList CommonLateParsedAttrs;
 
+  while (MaybeParseCXX11Attributes(DeclAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs) ||
+ MaybeParseMicrosoftAttributes(DeclSpecAttrs))
+;
+
+  SourceLocation DeclStart;
+  if (DeclAttrs.Range.isValid()) {
+DeclStart = DeclSpecAttrs.Range.isInvalid()
+? DeclAttrs.Range.getBegin()
+: std::min(DeclAttrs.Range.getBegin(),
+   DeclSpecAttrs.Range.getBegin());
+  } else {
+DeclStart = DeclSpecAttrs.Range.getBegin();
+  }
+
   // decl-specifier-seq:
   // Parse the common declaration-specifiers piece.
   ParsingDeclSpec DS(*this, TemplateDiags);
@@ -3128,6 +3141,9 @@ Parser::DeclGroupPtrTy 
Parser::ParseCXXClassMemberDeclaration(
   // Turn off colon protection that was set for declspec.
   X.restore();
 
+  if (DeclStart.isValid())
+DS.SetRangeStart(DeclStart);
+
   // If we had a free-standing type definition with a missing semicolon, we
   // may get this far before the problem becomes obvious.
   if (DS.hasTagDefinition() &&

diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 546e524932f5e..2794a5834dce9 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -235,6 +235,9 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
   }
 
   default: {
+if (getLangOpts().CPlusPlus && MaybeParseCXX11Attributes(CXX11Attrs, true))
+  goto Retry;
+
 bool HaveAttrs = !

[clang] [Clang] Allow parsing arbitrary order of attributes for declarations (PR #133107)

2025-05-09 Thread Aaron Ballman via cfe-commits

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -15451,6 +15819,500 @@ StmtResult 
SemaOpenMP::ActOnOpenMPInterchangeDirective(
  buildPreInits(Context, PreInits));
 }
 
+StmtResult SemaOpenMP::ActOnOpenMPFuseDirective(ArrayRef Clauses,
+Stmt *AStmt,
+SourceLocation StartLoc,
+SourceLocation EndLoc) {
+
+  ASTContext &Context = getASTContext();
+  DeclContext *CurrContext = SemaRef.CurContext;
+  Scope *CurScope = SemaRef.getCurScope();
+  CaptureVars CopyTransformer(SemaRef);
+
+  // Ensure the structured block is not empty
+  if (!AStmt) {
+return StmtError();
+  }
+
+  unsigned NumLoops = 1;
+  unsigned LoopSeqSize = 1;
+
+  // Defer transformation in dependent contexts
+  // The NumLoopNests argument is set to a placeholder 1 (even though
+  // using looprange fuse could yield up to 3 top level loop nests)
+  // because a dependent context could prevent determining its true value
+  if (CurrContext->isDependentContext()) {
+return OMPFuseDirective::Create(Context, StartLoc, EndLoc, Clauses,
+NumLoops, LoopSeqSize, AStmt, nullptr,
+nullptr);
+  }
+
+  // Validate that the potential loop sequence is transformable for fusion
+  // Also collect the HelperExprs, Loop Stmts, Inits, and Number of loops
+  SmallVector LoopHelpers;
+  SmallVector LoopStmts;
+  SmallVector> OriginalInits;
+  SmallVector> TransformsPreInits;
+  SmallVector> LoopSequencePreInits;
+  SmallVector LoopCategories;
+  if (!checkTransformableLoopSequence(OMPD_fuse, AStmt, LoopSeqSize, NumLoops,
+  LoopHelpers, LoopStmts, OriginalInits,
+  TransformsPreInits, LoopSequencePreInits,
+  LoopCategories, Context)) {
+return StmtError();
+  }
+
+  // Handle clauses, which can be any of the following: [looprange, apply]
+  const OMPLoopRangeClause *LRC =
+  OMPExecutableDirective::getSingleClause(Clauses);
+
+  // The clause arguments are invalidated if any error arises
+  // such as non-constant or non-positive arguments
+  if (LRC && (!LRC->getFirst() || !LRC->getCount()))
+return StmtError();
+
+  // Delayed semantic check of LoopRange constraint
+  // Evaluates the loop range arguments and returns the first and count values
+  auto EvaluateLoopRangeArguments = [&Context](Expr *First, Expr *Count,
+   uint64_t &FirstVal,
+   uint64_t &CountVal) {
+llvm::APSInt FirstInt = First->EvaluateKnownConstInt(Context);
+llvm::APSInt CountInt = Count->EvaluateKnownConstInt(Context);
+FirstVal = FirstInt.getZExtValue();
+CountVal = CountInt.getZExtValue();
+  };
+
+  // OpenMP [6.0, Restrictions]
+  // first + count - 1 must not evaluate to a value greater than the
+  // loop sequence length of the associated canonical loop sequence.
+  auto ValidLoopRange = [](uint64_t FirstVal, uint64_t CountVal,
+   unsigned NumLoops) -> bool {
+return FirstVal + CountVal - 1 <= NumLoops;
+  };
+  uint64_t FirstVal = 1, CountVal = 0, LastVal = LoopSeqSize;
+
+  // Validates the loop range after evaluating the semantic information
+  // and ensures that the range is valid for the given loop sequence size.
+  // Expressions are evaluated at compile time to obtain constant values.
+  if (LRC) {
+EvaluateLoopRangeArguments(LRC->getFirst(), LRC->getCount(), FirstVal,
+   CountVal);
+if (CountVal == 1)
+  SemaRef.Diag(LRC->getCountLoc(), diag::warn_omp_redundant_fusion)
+  << getOpenMPDirectiveName(OMPD_fuse);
+
+if (!ValidLoopRange(FirstVal, CountVal, LoopSeqSize)) {
+  SemaRef.Diag(LRC->getFirstLoc(), diag::err_omp_invalid_looprange)
+  << getOpenMPDirectiveName(OMPD_fuse) << (FirstVal + CountVal - 1)
+  << LoopSeqSize;
+  return StmtError();
+}
+
+LastVal = FirstVal + CountVal - 1;
+  }
+
+  // Complete fusion generates a single canonical loop nest
+  // However looprange clause generates several loop nests
+  unsigned NumLoopNests = LRC ? LoopSeqSize - CountVal + 1 : 1;
+
+  // Emit a warning for redundant loop fusion when the sequence contains only
+  // one loop.
+  if (LoopSeqSize == 1)
+SemaRef.Diag(AStmt->getBeginLoc(), diag::warn_omp_redundant_fusion)
+<< getOpenMPDirectiveName(OMPD_fuse);
+
+  assert(LoopHelpers.size() == LoopSeqSize &&
+ "Expecting loop iteration space dimensionality to match number of "
+ "affected loops");
+  assert(OriginalInits.size() == LoopSeqSize &&
+ "Expecting loop iteration space dimensionality to match number of "
+ "affected loops");
+
+  // Select the type with the largest bit width among all induction variables
+  QualType IV

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -14175,27 +14222,350 @@ bool SemaOpenMP::checkTransformableLoopNest(
 return false;
   },
   [&OriginalInits](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else
-  llvm_unreachable("Unhandled loop transformation");
-
-appendFlattenedStmtList(OriginalInits.back(), DependentPreInits);
+updatePreInits(Transform, OriginalInits);
   });
   assert(OriginalInits.back().empty() && "No preinit after innermost loop");
   OriginalInits.pop_back();
   return Result;
 }
 
+// Counts the total number of nested loops, including the outermost loop (the
+// original loop). PRECONDITION of this visitor is that it must be invoked from
+// the original loop to be analyzed. The traversal is stop for Decl's and
+// Expr's given that they may contain inner loops that must not be counted.
+//
+// Example AST structure for the code:
+//
+// int main() {
+// #pragma omp fuse
+// {
+// for (int i = 0; i < 100; i++) {<-- Outer loop
+// []() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// };
+// for(int j = 0; j < 5; ++j) {}<-- Inner loop
+// }
+// for (int r = 0; i < 100; i++) {<-- Outer loop
+// struct LocalClass {
+// void bar() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// }
+// };
+// for(int k = 0; k < 10; ++k) {}<-- Inner loop
+// {x = 5; for(k = 0; k < 10; ++k) x += k; x}; <-- NOT A LOOP
+// }
+// }
+// }
+// Result: Loop 'i' contains 2 loops, Loop 'r' also contains 2 loops
+class NestedLoopCounterVisitor : public DynamicRecursiveASTVisitor {
+private:
+  unsigned NestedLoopCount = 0;
+
+public:
+  explicit NestedLoopCounterVisitor() {}
+
+  unsigned getNestedLoopCount() const { return NestedLoopCount; }
+
+  bool VisitForStmt(ForStmt *FS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool VisitCXXForRangeStmt(CXXForRangeStmt *FRS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool TraverseStmt(Stmt *S) override {
+if (!S)
+  return true;
+
+// Skip traversal of all expressions, including special cases like
+// LambdaExpr, StmtExpr, BlockExpr, and RequiresExpr. These expressions
+// may contain inner statements (and even loops), but they are not part
+// of the syntactic body of the surrounding loop structure.
+//  Therefore must not be counted
+if (isa(S))
+  return true;
+
+// Only recurse into CompoundStmt (block {}) and loop bodies
+if (isa(S) || isa(S) || isa(S)) {
+  return DynamicRecursiveASTVisitor::TraverseStmt(S);
+}
+
+// Stop traversal of the rest of statements, that break perfect
+// loop nesting, such as control flow (IfStmt, SwitchStmt...)
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) override {
+// Stop in the case of finding a declaration, it is not important
+// in order to find nested loops (Possible CXXRecordDecl, RecordDecl,
+// FunctionDecl...)
+return true;
+  }
+};
+
+bool SemaOpenMP::analyzeLoopSequence(
+Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
+SmallVectorImpl &LoopHelpers,
+SmallVectorImpl &ForStmts,
+SmallVectorImpl> &OriginalInits,
+SmallVectorImpl> &TransformsPreInits,
+SmallVectorImpl> &LoopSequencePreInits,
+SmallVectorImpl &LoopCategories, ASTContext &Context,
+OpenMPDirectiveKind Kind) {
+
+  VarsWithInheritedDSAType TmpDSA;
+  QualType BaseInductionVarType;
+  // Helper Lambda to handle storing initialization and body statements for 
both
+  // ForStmt and CXXForRangeStmt and checks for any possible mismatch between
+  // induction variables types
+  auto storeLoopStatements = [&OriginalInits, &ForStmts, &BaseInductionVarType,
+  this, &Context](Stmt *LoopStmt) {
+if (auto *For = dyn_cast(LoopStmt)) {
+  OriginalInits.back().push_back(For->getInit());
+  ForStmts.push_back(For);
+  // Extract induction variable
+  if (auto *InitStmt = dyn_cast_or_null(For->getInit())) {
+if (auto *InitDecl = dyn_cast(InitStmt->getSingleDecl())) {
+  QualType InductionVarType = InitDecl->getType().getCanonicalType();
+
+  // Compare with first loop type
+  if (BaseInductionVarType.isNull()) {
+BaseInductionVarType = InductionVarT

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -14175,27 +14222,350 @@ bool SemaOpenMP::checkTransformableLoopNest(
 return false;
   },
   [&OriginalInits](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else
-  llvm_unreachable("Unhandled loop transformation");
-
-appendFlattenedStmtList(OriginalInits.back(), DependentPreInits);
+updatePreInits(Transform, OriginalInits);
   });
   assert(OriginalInits.back().empty() && "No preinit after innermost loop");
   OriginalInits.pop_back();
   return Result;
 }
 
+// Counts the total number of nested loops, including the outermost loop (the
+// original loop). PRECONDITION of this visitor is that it must be invoked from
+// the original loop to be analyzed. The traversal is stop for Decl's and
+// Expr's given that they may contain inner loops that must not be counted.
+//
+// Example AST structure for the code:
+//
+// int main() {
+// #pragma omp fuse
+// {
+// for (int i = 0; i < 100; i++) {<-- Outer loop
+// []() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// };
+// for(int j = 0; j < 5; ++j) {}<-- Inner loop
+// }
+// for (int r = 0; i < 100; i++) {<-- Outer loop
+// struct LocalClass {
+// void bar() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// }
+// };
+// for(int k = 0; k < 10; ++k) {}<-- Inner loop
+// {x = 5; for(k = 0; k < 10; ++k) x += k; x}; <-- NOT A LOOP
+// }
+// }
+// }
+// Result: Loop 'i' contains 2 loops, Loop 'r' also contains 2 loops
+class NestedLoopCounterVisitor : public DynamicRecursiveASTVisitor {
+private:
+  unsigned NestedLoopCount = 0;
+
+public:
+  explicit NestedLoopCounterVisitor() {}
+
+  unsigned getNestedLoopCount() const { return NestedLoopCount; }
+
+  bool VisitForStmt(ForStmt *FS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool VisitCXXForRangeStmt(CXXForRangeStmt *FRS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool TraverseStmt(Stmt *S) override {
+if (!S)
+  return true;
+
+// Skip traversal of all expressions, including special cases like
+// LambdaExpr, StmtExpr, BlockExpr, and RequiresExpr. These expressions
+// may contain inner statements (and even loops), but they are not part
+// of the syntactic body of the surrounding loop structure.
+//  Therefore must not be counted
+if (isa(S))
+  return true;
+
+// Only recurse into CompoundStmt (block {}) and loop bodies
+if (isa(S) || isa(S) || isa(S)) {
+  return DynamicRecursiveASTVisitor::TraverseStmt(S);
+}

alexey-bataev wrote:

```suggestion
if (isa(S))
  return DynamicRecursiveASTVisitor::TraverseStmt(S);
```


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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -14175,27 +14222,350 @@ bool SemaOpenMP::checkTransformableLoopNest(
 return false;
   },
   [&OriginalInits](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else
-  llvm_unreachable("Unhandled loop transformation");
-
-appendFlattenedStmtList(OriginalInits.back(), DependentPreInits);
+updatePreInits(Transform, OriginalInits);
   });
   assert(OriginalInits.back().empty() && "No preinit after innermost loop");
   OriginalInits.pop_back();
   return Result;
 }
 
+// Counts the total number of nested loops, including the outermost loop (the
+// original loop). PRECONDITION of this visitor is that it must be invoked from
+// the original loop to be analyzed. The traversal is stop for Decl's and
+// Expr's given that they may contain inner loops that must not be counted.
+//
+// Example AST structure for the code:
+//
+// int main() {
+// #pragma omp fuse
+// {
+// for (int i = 0; i < 100; i++) {<-- Outer loop
+// []() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// };
+// for(int j = 0; j < 5; ++j) {}<-- Inner loop
+// }
+// for (int r = 0; i < 100; i++) {<-- Outer loop
+// struct LocalClass {
+// void bar() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// }
+// };
+// for(int k = 0; k < 10; ++k) {}<-- Inner loop
+// {x = 5; for(k = 0; k < 10; ++k) x += k; x}; <-- NOT A LOOP
+// }
+// }
+// }
+// Result: Loop 'i' contains 2 loops, Loop 'r' also contains 2 loops
+class NestedLoopCounterVisitor : public DynamicRecursiveASTVisitor {
+private:
+  unsigned NestedLoopCount = 0;
+
+public:
+  explicit NestedLoopCounterVisitor() {}
+
+  unsigned getNestedLoopCount() const { return NestedLoopCount; }
+
+  bool VisitForStmt(ForStmt *FS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool VisitCXXForRangeStmt(CXXForRangeStmt *FRS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool TraverseStmt(Stmt *S) override {
+if (!S)
+  return true;
+
+// Skip traversal of all expressions, including special cases like
+// LambdaExpr, StmtExpr, BlockExpr, and RequiresExpr. These expressions
+// may contain inner statements (and even loops), but they are not part
+// of the syntactic body of the surrounding loop structure.
+//  Therefore must not be counted
+if (isa(S))
+  return true;
+
+// Only recurse into CompoundStmt (block {}) and loop bodies
+if (isa(S) || isa(S) || isa(S)) {
+  return DynamicRecursiveASTVisitor::TraverseStmt(S);
+}
+
+// Stop traversal of the rest of statements, that break perfect
+// loop nesting, such as control flow (IfStmt, SwitchStmt...)
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) override {
+// Stop in the case of finding a declaration, it is not important
+// in order to find nested loops (Possible CXXRecordDecl, RecordDecl,
+// FunctionDecl...)
+return true;
+  }
+};
+
+bool SemaOpenMP::analyzeLoopSequence(
+Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
+SmallVectorImpl &LoopHelpers,
+SmallVectorImpl &ForStmts,
+SmallVectorImpl> &OriginalInits,
+SmallVectorImpl> &TransformsPreInits,
+SmallVectorImpl> &LoopSequencePreInits,
+SmallVectorImpl &LoopCategories, ASTContext &Context,
+OpenMPDirectiveKind Kind) {
+
+  VarsWithInheritedDSAType TmpDSA;
+  QualType BaseInductionVarType;
+  // Helper Lambda to handle storing initialization and body statements for 
both
+  // ForStmt and CXXForRangeStmt and checks for any possible mismatch between
+  // induction variables types
+  auto storeLoopStatements = [&OriginalInits, &ForStmts, &BaseInductionVarType,
+  this, &Context](Stmt *LoopStmt) {
+if (auto *For = dyn_cast(LoopStmt)) {
+  OriginalInits.back().push_back(For->getInit());
+  ForStmts.push_back(For);
+  // Extract induction variable
+  if (auto *InitStmt = dyn_cast_or_null(For->getInit())) {
+if (auto *InitDecl = dyn_cast(InitStmt->getSingleDecl())) {
+  QualType InductionVarType = InitDecl->getType().getCanonicalType();
+
+  // Compare with first loop type
+  if (BaseInductionVarType.isNull()) {
+BaseInductionVarType = InductionVarT

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -14175,27 +14222,350 @@ bool SemaOpenMP::checkTransformableLoopNest(
 return false;
   },
   [&OriginalInits](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else
-  llvm_unreachable("Unhandled loop transformation");
-
-appendFlattenedStmtList(OriginalInits.back(), DependentPreInits);
+updatePreInits(Transform, OriginalInits);
   });
   assert(OriginalInits.back().empty() && "No preinit after innermost loop");
   OriginalInits.pop_back();
   return Result;
 }
 
+// Counts the total number of nested loops, including the outermost loop (the
+// original loop). PRECONDITION of this visitor is that it must be invoked from
+// the original loop to be analyzed. The traversal is stop for Decl's and
+// Expr's given that they may contain inner loops that must not be counted.
+//
+// Example AST structure for the code:
+//
+// int main() {
+// #pragma omp fuse
+// {
+// for (int i = 0; i < 100; i++) {<-- Outer loop
+// []() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// };
+// for(int j = 0; j < 5; ++j) {}<-- Inner loop
+// }
+// for (int r = 0; i < 100; i++) {<-- Outer loop
+// struct LocalClass {
+// void bar() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// }
+// };
+// for(int k = 0; k < 10; ++k) {}<-- Inner loop
+// {x = 5; for(k = 0; k < 10; ++k) x += k; x}; <-- NOT A LOOP
+// }
+// }
+// }
+// Result: Loop 'i' contains 2 loops, Loop 'r' also contains 2 loops
+class NestedLoopCounterVisitor : public DynamicRecursiveASTVisitor {
+private:
+  unsigned NestedLoopCount = 0;
+
+public:
+  explicit NestedLoopCounterVisitor() {}
+
+  unsigned getNestedLoopCount() const { return NestedLoopCount; }
+
+  bool VisitForStmt(ForStmt *FS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool VisitCXXForRangeStmt(CXXForRangeStmt *FRS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool TraverseStmt(Stmt *S) override {
+if (!S)
+  return true;
+
+// Skip traversal of all expressions, including special cases like
+// LambdaExpr, StmtExpr, BlockExpr, and RequiresExpr. These expressions
+// may contain inner statements (and even loops), but they are not part
+// of the syntactic body of the surrounding loop structure.
+//  Therefore must not be counted
+if (isa(S))
+  return true;
+
+// Only recurse into CompoundStmt (block {}) and loop bodies
+if (isa(S) || isa(S) || isa(S)) {
+  return DynamicRecursiveASTVisitor::TraverseStmt(S);
+}
+
+// Stop traversal of the rest of statements, that break perfect
+// loop nesting, such as control flow (IfStmt, SwitchStmt...)
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) override {
+// Stop in the case of finding a declaration, it is not important
+// in order to find nested loops (Possible CXXRecordDecl, RecordDecl,
+// FunctionDecl...)
+return true;
+  }
+};
+
+bool SemaOpenMP::analyzeLoopSequence(
+Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
+SmallVectorImpl &LoopHelpers,
+SmallVectorImpl &ForStmts,
+SmallVectorImpl> &OriginalInits,
+SmallVectorImpl> &TransformsPreInits,
+SmallVectorImpl> &LoopSequencePreInits,
+SmallVectorImpl &LoopCategories, ASTContext &Context,
+OpenMPDirectiveKind Kind) {
+
+  VarsWithInheritedDSAType TmpDSA;
+  QualType BaseInductionVarType;
+  // Helper Lambda to handle storing initialization and body statements for 
both
+  // ForStmt and CXXForRangeStmt and checks for any possible mismatch between
+  // induction variables types
+  auto storeLoopStatements = [&OriginalInits, &ForStmts, &BaseInductionVarType,
+  this, &Context](Stmt *LoopStmt) {
+if (auto *For = dyn_cast(LoopStmt)) {
+  OriginalInits.back().push_back(For->getInit());
+  ForStmts.push_back(For);
+  // Extract induction variable
+  if (auto *InitStmt = dyn_cast_or_null(For->getInit())) {
+if (auto *InitDecl = dyn_cast(InitStmt->getSingleDecl())) {
+  QualType InductionVarType = InitDecl->getType().getCanonicalType();
+
+  // Compare with first loop type
+  if (BaseInductionVarType.isNull()) {
+BaseInductionVarType = InductionVarT

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -11516,6 +11516,21 @@ def note_omp_implicit_dsa : Note<
   "implicitly determined as %0">;
 def err_omp_loop_var_dsa : Error<
   "loop iteration variable in the associated loop of 'omp %1' directive may 
not be %0, predetermined as %2">;
+def warn_omp_different_loop_ind_var_types : Warning <
+  "loop sequence following '#pragma omp %0' contains induction variables of 
differing types: %1 and %2">,

alexey-bataev wrote:

I thought that the number of iterations should be the limitation here, not the 
type of indices

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -1151,6 +1151,106 @@ class OMPFullClause final : public 
OMPNoChildClause {
   static OMPFullClause *CreateEmpty(const ASTContext &C);
 };
 
+/// This class represents the 'looprange' clause in the
+/// '#pragma omp fuse' directive
+///
+/// \code {c}
+/// #pragma omp fuse looprange(1,2)
+/// {
+///   for(int i = 0; i < 64; ++i)
+///   for(int j = 0; j < 256; j+=2)
+///   for(int k = 127; k >= 0; --k)
+/// \endcode
+class OMPLoopRangeClause final : public OMPClause {
+  friend class OMPClauseReader;
+
+  explicit OMPLoopRangeClause()
+  : OMPClause(llvm::omp::OMPC_looprange, {}, {}) {}
+
+  /// Location of '('
+  SourceLocation LParenLoc;
+
+  /// Location of 'first'
+  SourceLocation FirstLoc;
+
+  /// Location of 'count'
+  SourceLocation CountLoc;
+
+  /// Expr associated with 'first' argument
+  Expr *First = nullptr;
+
+  /// Expr associated with 'count' argument
+  Expr *Count = nullptr;
+
+  /// Set 'first'
+  void setFirst(Expr *First) { this->First = First; }
+
+  /// Set 'count'
+  void setCount(Expr *Count) { this->Count = Count; }
+
+  /// Set location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+
+  /// Set location of 'first' argument
+  void setFirstLoc(SourceLocation Loc) { FirstLoc = Loc; }
+
+  /// Set location of 'count' argument
+  void setCountLoc(SourceLocation Loc) { CountLoc = Loc; }
+
+public:
+  /// Build an AST node for a 'looprange' clause
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLocLocation of '('.
+  /// \param ModifierLoc  Modifier location.
+  /// \param
+  static OMPLoopRangeClause *
+  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation 
LParenLoc,
+ SourceLocation FirstLoc, SourceLocation CountLoc,
+ SourceLocation EndLoc, Expr *First, Expr *Count);
+
+  /// Build an empty 'looprange' node for deserialization
+  ///
+  /// \param C  Context of the AST.
+  static OMPLoopRangeClause *CreateEmpty(const ASTContext &C);
+
+  /// Returns the location of '('
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// Returns the location of 'first'
+  SourceLocation getFirstLoc() const { return FirstLoc; }
+
+  /// Returns the location of 'count'
+  SourceLocation getCountLoc() const { return CountLoc; }
+
+  /// Returns the argument 'first' or nullptr if not set
+  Expr *getFirst() const { return cast_or_null(First); }
+
+  /// Returns the argument 'count' or nullptr if not set
+  Expr *getCount() const { return cast_or_null(Count); }
+
+  child_range children() {
+return child_range(reinterpret_cast(&First),
+   reinterpret_cast(&Count) + 1);

alexey-bataev wrote:

It does not work safely, to do this safely you need to store both associated 
expressions in a single array

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -5378,6 +5379,10 @@ class CodeGenFunction : public CodeGenTypeCache {
 
   /// Set the address of a local variable.
   void setAddrOfLocalVar(const VarDecl *VD, Address Addr) {
+if (LocalDeclMap.count(VD)) {
+  llvm::errs() << "Warning: VarDecl already exists in map: ";
+  VD->dumpColor(); 
+}

alexey-bataev wrote:

Remove

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -5790,7 +5805,11 @@ class OMPReverseDirective final : public 
OMPLoopTransformationDirective {
   explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc)
   : OMPLoopTransformationDirective(OMPReverseDirectiveClass,
llvm::omp::OMPD_reverse, StartLoc,
-   EndLoc, 1) {}
+   EndLoc, 1) {
+// Reverse produces a single top-level canonical loop nest
+setNumGeneratedLoops(1);

alexey-bataev wrote:

Should be in a separate patch

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


[clang] 49c22e3 - Thread Safety Analysis: Improve comments of LockErrorKind

2025-05-09 Thread Marco Elver via cfe-commits

Author: Marco Elver
Date: 2025-05-09T20:14:30+02:00
New Revision: 49c22e3ee147326668aa0b2097f857d0b0c2a81e

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

LOG: Thread Safety Analysis: Improve comments of LockErrorKind

Move documentation inline and add missing documentation for
LEK_NotLockedAtEndOfFunction.

NFC.

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

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/ThreadSafety.h

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/ThreadSafety.h 
b/clang/include/clang/Analysis/Analyses/ThreadSafety.h
index 20b75c46593e0..65a91483562e0 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafety.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafety.h
@@ -94,16 +94,14 @@ enum AccessKind {
 
 /// This enum distinguishes between 
diff erent situations where we warn due to
 /// inconsistent locking.
-/// \enum SK_LockedSomeLoopIterations -- a mutex is locked for some but not all
-/// loop iterations.
-/// \enum SK_LockedSomePredecessors -- a mutex is locked in some but not all
-/// predecessors of a CFGBlock.
-/// \enum SK_LockedAtEndOfFunction -- a mutex is still locked at the end of a
-/// function.
 enum LockErrorKind {
+  /// A capability is locked for some but not all loop iterations.
   LEK_LockedSomeLoopIterations,
+  /// A capability is locked in some but not all predecessors of a CFGBlock.
   LEK_LockedSomePredecessors,
+  /// A capability is still locked at the end of a function.
   LEK_LockedAtEndOfFunction,
+  /// Expecting a capability to be held at the end of function.
   LEK_NotLockedAtEndOfFunction
 };
 



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


[clang] [HLSL][NFC] Test cleanup - remove function attributes (PR #139302)

2025-05-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Helena Kotas (hekota)


Changes

The function attribute numbers are not stable. They are not part of the test 
and can be removed. 

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


1 Files Affected:

- (modified) clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl 
(+3-3) 


``diff
diff --git a/clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl 
b/clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl
index f2aea4e376b03..47afba27b6ebd 100644
--- a/clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl
@@ -32,6 +32,6 @@ export float TestLoad() {
 // CHECK: %[[PTR1:.*]] = call ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1) %{{[0-9]+}}, i32 %{{[0-9]+}})
 // CHECK: %[[VALUE1:.*]] = load float, ptr %[[PTR1]]
 
-// CHECK: declare i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0), i8) #3
-// CHECK: declare i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1), i8) #3
-// CHECK: declare ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1), i32) #4
+// CHECK: declare i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0), i8)
+// CHECK: declare i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1), i8)
+// CHECK: declare ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1), i32)

``




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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -14175,27 +14222,350 @@ bool SemaOpenMP::checkTransformableLoopNest(
 return false;
   },
   [&OriginalInits](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else
-  llvm_unreachable("Unhandled loop transformation");
-
-appendFlattenedStmtList(OriginalInits.back(), DependentPreInits);
+updatePreInits(Transform, OriginalInits);
   });
   assert(OriginalInits.back().empty() && "No preinit after innermost loop");
   OriginalInits.pop_back();
   return Result;
 }
 
+// Counts the total number of nested loops, including the outermost loop (the
+// original loop). PRECONDITION of this visitor is that it must be invoked from
+// the original loop to be analyzed. The traversal is stop for Decl's and
+// Expr's given that they may contain inner loops that must not be counted.
+//
+// Example AST structure for the code:
+//
+// int main() {
+// #pragma omp fuse
+// {
+// for (int i = 0; i < 100; i++) {<-- Outer loop
+// []() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// };
+// for(int j = 0; j < 5; ++j) {}<-- Inner loop
+// }
+// for (int r = 0; i < 100; i++) {<-- Outer loop
+// struct LocalClass {
+// void bar() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// }
+// };
+// for(int k = 0; k < 10; ++k) {}<-- Inner loop
+// {x = 5; for(k = 0; k < 10; ++k) x += k; x}; <-- NOT A LOOP
+// }
+// }
+// }
+// Result: Loop 'i' contains 2 loops, Loop 'r' also contains 2 loops
+class NestedLoopCounterVisitor : public DynamicRecursiveASTVisitor {
+private:
+  unsigned NestedLoopCount = 0;
+
+public:
+  explicit NestedLoopCounterVisitor() {}
+
+  unsigned getNestedLoopCount() const { return NestedLoopCount; }
+
+  bool VisitForStmt(ForStmt *FS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool VisitCXXForRangeStmt(CXXForRangeStmt *FRS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool TraverseStmt(Stmt *S) override {
+if (!S)
+  return true;
+
+// Skip traversal of all expressions, including special cases like
+// LambdaExpr, StmtExpr, BlockExpr, and RequiresExpr. These expressions
+// may contain inner statements (and even loops), but they are not part
+// of the syntactic body of the surrounding loop structure.
+//  Therefore must not be counted
+if (isa(S))
+  return true;
+
+// Only recurse into CompoundStmt (block {}) and loop bodies
+if (isa(S) || isa(S) || isa(S)) {
+  return DynamicRecursiveASTVisitor::TraverseStmt(S);
+}
+
+// Stop traversal of the rest of statements, that break perfect
+// loop nesting, such as control flow (IfStmt, SwitchStmt...)
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) override {
+// Stop in the case of finding a declaration, it is not important
+// in order to find nested loops (Possible CXXRecordDecl, RecordDecl,
+// FunctionDecl...)
+return true;
+  }
+};
+
+bool SemaOpenMP::analyzeLoopSequence(
+Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
+SmallVectorImpl &LoopHelpers,
+SmallVectorImpl &ForStmts,
+SmallVectorImpl> &OriginalInits,
+SmallVectorImpl> &TransformsPreInits,
+SmallVectorImpl> &LoopSequencePreInits,
+SmallVectorImpl &LoopCategories, ASTContext &Context,
+OpenMPDirectiveKind Kind) {
+
+  VarsWithInheritedDSAType TmpDSA;
+  QualType BaseInductionVarType;
+  // Helper Lambda to handle storing initialization and body statements for 
both
+  // ForStmt and CXXForRangeStmt and checks for any possible mismatch between
+  // induction variables types
+  auto storeLoopStatements = [&OriginalInits, &ForStmts, &BaseInductionVarType,
+  this, &Context](Stmt *LoopStmt) {
+if (auto *For = dyn_cast(LoopStmt)) {
+  OriginalInits.back().push_back(For->getInit());
+  ForStmts.push_back(For);
+  // Extract induction variable
+  if (auto *InitStmt = dyn_cast_or_null(For->getInit())) {
+if (auto *InitDecl = dyn_cast(InitStmt->getSingleDecl())) {
+  QualType InductionVarType = InitDecl->getType().getCanonicalType();
+
+  // Compare with first loop type
+  if (BaseInductionVarType.isNull()) {
+BaseInductionVarType = InductionVarT

[clang] [HLSL][NFC] Test cleanup - remove function attributes (PR #139302)

2025-05-09 Thread Helena Kotas via cfe-commits

https://github.com/hekota created 
https://github.com/llvm/llvm-project/pull/139302

The function attribute numbers are not stable. They are not part of the test 
and can be removed. 

>From 14eda614ef4d2f3d5617dcedd935adfe97ec9c1a Mon Sep 17 00:00:00 2001
From: Helena Kotas 
Date: Fri, 9 May 2025 11:15:36 -0700
Subject: [PATCH] remove function attributes

---
 .../CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl 
b/clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl
index f2aea4e376b03..47afba27b6ebd 100644
--- a/clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/StructuredBuffers-methods-ps.hlsl
@@ -32,6 +32,6 @@ export float TestLoad() {
 // CHECK: %[[PTR1:.*]] = call ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1) %{{[0-9]+}}, i32 %{{[0-9]+}})
 // CHECK: %[[VALUE1:.*]] = load float, ptr %[[PTR1]]
 
-// CHECK: declare i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0), i8) #3
-// CHECK: declare i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1), i8) #3
-// CHECK: declare ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1), i32) #4
+// CHECK: declare i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_0t(target("dx.RawBuffer", 
float, 1, 0), i8)
+// CHECK: declare i32 
@llvm.dx.resource.updatecounter.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1), i8)
+// CHECK: declare ptr 
@llvm.dx.resource.getpointer.p0.tdx.RawBuffer_f32_1_1t(target("dx.RawBuffer", 
float, 1, 1), i32)

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


[clang] [HLSL][NFC] Test cleanup - remove function attributes (PR #139302)

2025-05-09 Thread Deric C. via cfe-commits

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


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


[clang] [clang] Function type attribute to prevent CFI instrumentation (PR #135836)

2025-05-09 Thread via cfe-commits

https://github.com/PiJoules updated 
https://github.com/llvm/llvm-project/pull/135836



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[clang] [CIR] Upstream insert op for VectorType (PR #139146)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits


@@ -1969,6 +1969,43 @@ def VecCreateOp : CIR_Op<"vec.create", [Pure]> {
   let hasVerifier = 1;
 }
 
+//===--===//
+// VecInsertOp
+//===--===//
+
+def VecInsertOp : CIR_Op<"vec.insert", [Pure,
+  TypesMatchWith<"argument type matches vector element type", "vec", "value",
+ "cast($_self).getElementType()">,
+  AllTypesMatch<["result", "vec"]>]> {
+
+  let summary = "Insert one element into a vector object";
+  let description = [{
+The `cir.vec.insert` operation replaces the element of the given vector at
+the given index with the given value.  The new vector with the inserted
+element is returned.

bcardosolopes wrote:

The description in the incubator is confusing: we don't implicitly store. 
Perhaps rewrite to something like:
```
The `cir.vec.insert` operation produces a new vector by replacing the element 
of the input vector at `index` with `value`.
```

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


[clang] [CIR] Upstream insert op for VectorType (PR #139146)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits

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


[clang] [CIR] Upstream insert op for VectorType (PR #139146)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits

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

LGTM after nits

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -1480,6 +1493,108 @@ class SemaOpenMP : public SemaBase {
   SmallVectorImpl &LoopHelpers,
   Stmt *&Body, SmallVectorImpl> &OriginalInits);
 
+  /// @brief Categories of loops encountered during semantic OpenMP loop
+  /// analysis
+  ///
+  /// This enumeration identifies the structural category of a loop or sequence
+  /// of loops analyzed in the context of OpenMP transformations and 
directives.
+  /// This categorization helps differentiate between original source loops
+  /// and the structures resulting from applying OpenMP loop transformations.
+  enum class OMPLoopCategory {
+
+/// @var OMPLoopCategory::RegularLoop
+/// Represents a standard canonical loop nest found in the
+/// original source code or an intact loop after transformations
+/// (i.e Post/Pre loops of a loopranged fusion)
+RegularLoop,
+
+/// @var OMPLoopCategory::TransformSingleLoop
+/// Represents the resulting loop structure when an OpenMP loop
+//  transformation, generates a single, top-level loop
+TransformSingleLoop,
+
+/// @var OMPLoopCategory::TransformLoopSequence
+/// Represents the resulting loop structure when an OpenMP loop
+/// transformation
+/// generates a sequence of two or more canonical loop nests
+TransformLoopSequence
+  };
+
+  /// The main recursive process of `checkTransformableLoopSequence` that
+  /// performs grammatical parsing of a canonical loop sequence. It extracts
+  /// key information, such as the number of top-level loops, loop statements,
+  /// helper expressions, and other relevant loop-related data, all in a single
+  /// execution to avoid redundant traversals. This analysis flattens inner
+  /// Loop Sequences
+  ///
+  /// \param LoopSeqStmtThe AST of the original statement.
+  /// \param LoopSeqSize[out] Number of top level canonical loops.
+  /// \param NumLoops   [out] Number of total canonical loops (nested too).
+  /// \param LoopHelpers[out] The multiple loop analyses results.
+  /// \param ForStmts   [out] The multiple Stmt of each For loop.
+  /// \param OriginalInits  [out] The raw original initialization statements
+  ///   of each belonging to a loop of the loop sequence
+  /// \param TransformPreInits [out] The multiple collection of statements and
+  ///   declarations that must have been executed/declared
+  ///   before entering the loop (each belonging to a
+  ///   particular loop transformation, nullptr otherwise)
+  /// \param LoopSequencePreInits [out] Additional general collection of loop
+  ///   transformation related statements and declarations
+  ///   not bounded to a particular loop that must be
+  ///   executed before entering the loop transformation
+  /// \param LoopCategories [out] A sequence of OMPLoopCategory values,
+  ///   one for each loop or loop transformation node
+  ///   successfully analyzed.
+  /// \param Context
+  /// \param Kind   The loop transformation directive kind.
+  /// \return Whether the original statement is both syntactically and
+  /// semantically correct according to OpenMP 6.0 canonical loop
+  /// sequence definition.
+  bool analyzeLoopSequence(
+  Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
+  SmallVectorImpl &LoopHelpers,
+  SmallVectorImpl &ForStmts,
+  SmallVectorImpl> &OriginalInits,
+  SmallVectorImpl> &TransformsPreInits,
+  SmallVectorImpl> &LoopSequencePreInits,

alexey-bataev wrote:

```suggestion
  SmallVectorImpl> &OriginalInits,
  SmallVectorImpl> &TransformsPreInits,
  SmallVectorImpl> &LoopSequencePreInits,
```


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


[clang] [clang] Function type attribute to prevent CFI instrumentation (PR #135836)

2025-05-09 Thread via cfe-commits

https://github.com/PiJoules updated 
https://github.com/llvm/llvm-project/pull/135836



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[clang] [Clang] Reland: Diagnose invalid function types in dependent contexts (PR #139246)

2025-05-09 Thread via cfe-commits

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

>From 4c87a813ed0d4b4646ab6d32374dfa1525a3711e Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Tue, 6 May 2025 20:00:18 +0200
Subject: [PATCH 1/5] [Clang] Diagnose invalid function types in dependent
 contexts

When forming an invalid function type, we were not diagnosing
it if the call was dependent.

However, we later rely on the function type to be sensible
during argument deduction.

We now diagnose anything that is not a potential function type,
to avoid constructing bogus call expressions.

Fixes #138657
Fixes #115725
Fixes #68852
---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/lib/Sema/SemaExpr.cpp  | 19 
 clang/test/SemaTemplate/fun-template-def.cpp | 51 +++-
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8f5f40d8fef7..cd452179a6555 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -680,6 +680,7 @@ Bug Fixes to C++ Support
 - Improved parser recovery of invalid requirement expressions. In turn, this
   fixes crashes from follow-on processing of the invalid requirement. 
(#GH138820)
 - Fixed the handling of pack indexing types in the constraints of a member 
function redeclaration. (#GH138255)
+- Fixed a crash when forming an invalid function type in a dependent context. 
(#GH138657) (#GH115725) (#GH68852)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index deb8d2edfc5c9..9517c73006fd0 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6550,6 +6550,15 @@ ExprResult Sema::ActOnCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
   return Call;
 }
 
+// Any type that could be used to form a callable expression
+static bool MayBeFunctionType(const ASTContext &Context, QualType T) {
+  return T == Context.BoundMemberTy || T == Context.UnknownAnyTy ||
+ T == Context.BuiltinFnTy || T == Context.OverloadTy ||
+ T->isFunctionType() || T->isFunctionReferenceType() ||
+ T->isMemberFunctionPointerType() || T->isFunctionPointerType() ||
+ T->isBlockPointerType() || T->isRecordType();
+}
+
 ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, SourceLocation 
LParenLoc,
MultiExprArg ArgExprs, SourceLocation RParenLoc,
Expr *ExecConfig, bool IsExecConfig,
@@ -6603,6 +6612,16 @@ ExprResult Sema::BuildCallExpr(Scope *Scope, Expr *Fn, 
SourceLocation LParenLoc,
 *this, dyn_cast(Fn->IgnoreParens()),
 Fn->getBeginLoc());
 
+if (!Fn->getType()->isDependentType()) {
+  // If the type of the function itself is not dependent
+  // check that it is a reasonable as a function, as type deduction
+  // later assume the CallExpr has a sensible TYPE.
+  if (!MayBeFunctionType(Context, Fn->getType()))
+return ExprError(
+Diag(LParenLoc, diag::err_typecheck_call_not_function)
+<< Fn->getType() << Fn->getSourceRange());
+}
+
 return CallExpr::Create(Context, Fn, ArgExprs, Context.DependentTy,
 VK_PRValue, RParenLoc, 
CurFPFeatureOverrides());
   }
diff --git a/clang/test/SemaTemplate/fun-template-def.cpp 
b/clang/test/SemaTemplate/fun-template-def.cpp
index de77901b5b601..716296e72bc44 100644
--- a/clang/test/SemaTemplate/fun-template-def.cpp
+++ b/clang/test/SemaTemplate/fun-template-def.cpp
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 
 // Tests that dependent expressions are always allowed, whereas non-dependent
 // are checked as usual.
@@ -32,7 +33,7 @@ T f1(T t1, U u1, int i1, T** tpp)
   i1 = t1[u1];
   i1 *= t1;
 
-  i1(u1, t1); // error
+  i1(u1, t1); // expected-error {{called object type 'int' is not a function 
or function pointer}}
   u1(i1, t1);
 
   U u2 = (T)i1;
@@ -60,3 +61,51 @@ void f3() {
   f2(0);
   f2(0); // expected-error {{no matching function for call to 'f2'}}
 }
+
+#if __cplusplus >= 202002L
+namespace GH138657 {
+template  // #gh138657-template-head
+class meta {};
+template
+class meta {}; // expected-error {{called object type 'int' is not a 
function or function point}}
+
+template
+class meta {}; // expected-error {{called object type 'int *' is not a 
function or function point}}
+
+template
+class meta {}; // expected-error {{called object type 'char *' is not a 
function or function point}}
+
+struct S {};
+template
+class meta {}; // expected-error {{template argument for non-type 
template parameter is treated as function type 'S ()'}}
+// expected-note@#gh138657-template

[clang] [openmp] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)

2025-05-09 Thread CHANDRA GHALE via cfe-commits

https://github.com/chandraghale updated 
https://github.com/llvm/llvm-project/pull/134709



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[clang] [Clang] Allow parsing arbitrary order of attributes for declarations (PR #133107)

2025-05-09 Thread Aaron Ballman via cfe-commits

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

>From c46eda67cd7434dcce5c1f29125a940dc4ff64ba Mon Sep 17 00:00:00 2001
From: Denis Gerasimov 
Date: Wed, 26 Mar 2025 18:29:38 +0300
Subject: [PATCH 1/8] [CLANG] Enable alignas after GNU attributes

---
 clang/lib/Parse/ParseStmt.cpp  |  5 +
 clang/test/SemaCUDA/cuda-attr-order.cu | 15 +++
 2 files changed, 20 insertions(+)
 create mode 100644 clang/test/SemaCUDA/cuda-attr-order.cu

diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 150b2879fc94f..33b9f63bcfa08 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -296,6 +296,11 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
 goto Retry;
   }
 
+  case tok::kw_alignas: {
+ParseAlignmentSpecifier(CXX11Attrs);
+goto Retry;
+  }
+
   case tok::kw_template: {
 SourceLocation DeclEnd;
 ParseTemplateDeclarationOrSpecialization(DeclaratorContext::Block, DeclEnd,
diff --git a/clang/test/SemaCUDA/cuda-attr-order.cu 
b/clang/test/SemaCUDA/cuda-attr-order.cu
new file mode 100644
index 0..d3bf5b014d1c6
--- /dev/null
+++ b/clang/test/SemaCUDA/cuda-attr-order.cu
@@ -0,0 +1,15 @@
+// Verify that we can parse a simple CUDA file with different attributes order.
+// RUN: %clang_cc1 "-triple" "nvptx-nvidia-cuda"  -fsyntax-only -verify %s
+// expected-no-diagnostics
+#include "Inputs/cuda.h"
+
+struct alignas(16) float4 {
+float x, y, z, w;
+};
+
+__attribute__((device)) float func() {
+__shared__ alignas(alignof(float4)) float As[4][4];  // Both combinations
+alignas(alignof(float4)) __shared__  float Bs[4][4]; // must be legal
+
+return As[0][0] + Bs[0][0];
+}

>From 517ba9e99f06c23ec675f5bf808b84273f5b409d Mon Sep 17 00:00:00 2001
From: Denis Gerasimov 
Date: Fri, 28 Mar 2025 18:27:49 +0300
Subject: [PATCH 2/8] [CLANG] Enable cxx11 attributes after gnu attributes in
 ParseCXXClassMemberDeclaration

---
 clang/lib/Parse/ParseDeclCXX.cpp   | 7 +--
 clang/test/AST/ast-dump-color.cpp  | 2 +-
 clang/test/Index/annotate-attribute.cpp| 2 +-
 clang/test/Parser/cxx0x-attributes.cpp | 6 ++
 clang/test/SemaCXX/warn-thread-safety-analysis.cpp | 8 
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index 51fe0663a8d1a..42db9ceb89a2b 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -3035,10 +3035,13 @@ Parser::DeclGroupPtrTy 
Parser::ParseCXXClassMemberDeclaration(
   }
 
   ParsedAttributes DeclSpecAttrs(AttrFactory);
-  MaybeParseMicrosoftAttributes(DeclSpecAttrs);
-
   // Hold late-parsed attributes so we can attach a Decl to them later.
   LateParsedAttrList CommonLateParsedAttrs;
+  while (MaybeParseCXX11Attributes(DeclAttrs) ||
+ MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs)) {
+  }
+
+  MaybeParseMicrosoftAttributes(DeclSpecAttrs);
 
   // decl-specifier-seq:
   // Parse the common declaration-specifiers piece.
diff --git a/clang/test/AST/ast-dump-color.cpp 
b/clang/test/AST/ast-dump-color.cpp
index 87797f6bffc5b..2bd9ab7c3c841 100644
--- a/clang/test/AST/ast-dump-color.cpp
+++ b/clang/test/AST/ast-dump-color.cpp
@@ -91,7 +91,7 @@ struct Invalid {
 //CHECK: {{^}}[[Blue]]|   `-[[RESET]][[MAGENTA]]DeclRefExpr[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:40[[RESET]]> [[Green]]'class 
Mutex':'Mutex'[[RESET]][[Cyan]] lvalue[[RESET]][[Cyan]][[RESET]] 
[[GREEN]]Var[[RESET]][[Yellow]] 0x{{[0-9a-fA-F]*}}[[RESET]][[CYAN]] 
'mu1'[[RESET]] [[Green]]'class Mutex':'Mutex'[[RESET]] 
non_odr_use_unevaluated{{$}}
 //CHECK: {{^}}[[Blue]]|-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:28:1[[RESET]], 
[[Yellow]]line:30:1[[RESET]]> [[Yellow]]line:28:8[[RESET]] struct[[CYAN]] 
Invalid[[RESET]] definition
 //CHECK: {{^}}[[Blue]]| |-[[RESET]][[GREEN]]CXXRecordDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:1[[RESET]], 
[[Yellow]]col:8[[RESET]]> [[Yellow]]col:8[[RESET]] implicit referenced 
struct[[CYAN]] Invalid[[RESET]]
-//CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:29:3[[RESET]], 
[[Yellow]]col:42[[RESET]]> [[Yellow]]col:29[[RESET]] invalid[[CYAN]] 
Invalid[[RESET]] [[Green]]'void (int)'[[RESET]]
+//CHECK: {{^}}[[Blue]]| 
|-[[RESET]][[GREEN]]CXXConstructorDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]line:29:29[[RESET]], 
[[Yellow]]col:42[[RESET]]> [[Yellow]]col:29[[RESET]] invalid[[CYAN]] 
Invalid[[RESET]] [[Green]]'void (int)'[[RESET]]
 //CHECK: {{^}}[[Blue]]| | |-[[RESET]][[GREEN]]ParmVarDecl[[RESET]][[Yellow]] 
0x{{[0-9a-fA-F]*}}[[RESET]] <[[Yellow]]col:37[[RESET]], [[Yellow]][[RESET]]> [[Yellow]]col:42[[RESET]] invalid [[Green]]'int'[[RESET]]
 //CHECK: {{^}}[[B

[clang] [HLSL][NFC] Test cleanup - remove function attributes (PR #139302)

2025-05-09 Thread Joshua Batista via cfe-commits

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


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


[clang] [llvm] [HLSL][RootSignature] Add parsing for RootFlags (PR #138055)

2025-05-09 Thread Finn Plummer via cfe-commits

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


[clang] [llvm] [OpenMP] implementation set controls elision for begin declare variant (PR #139287)

2025-05-09 Thread Kelvin Li via cfe-commits

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


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


[clang] [clang] Implement address sanitizer on AIX (1/n) (PR #129925)

2025-05-09 Thread Jake Egan via cfe-commits

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -14175,27 +14222,350 @@ bool SemaOpenMP::checkTransformableLoopNest(
 return false;
   },
   [&OriginalInits](OMPLoopBasedDirective *Transform) {
-Stmt *DependentPreInits;
-if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else if (auto *Dir = dyn_cast(Transform))
-  DependentPreInits = Dir->getPreInits();
-else
-  llvm_unreachable("Unhandled loop transformation");
-
-appendFlattenedStmtList(OriginalInits.back(), DependentPreInits);
+updatePreInits(Transform, OriginalInits);
   });
   assert(OriginalInits.back().empty() && "No preinit after innermost loop");
   OriginalInits.pop_back();
   return Result;
 }
 
+// Counts the total number of nested loops, including the outermost loop (the
+// original loop). PRECONDITION of this visitor is that it must be invoked from
+// the original loop to be analyzed. The traversal is stop for Decl's and
+// Expr's given that they may contain inner loops that must not be counted.
+//
+// Example AST structure for the code:
+//
+// int main() {
+// #pragma omp fuse
+// {
+// for (int i = 0; i < 100; i++) {<-- Outer loop
+// []() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// };
+// for(int j = 0; j < 5; ++j) {}<-- Inner loop
+// }
+// for (int r = 0; i < 100; i++) {<-- Outer loop
+// struct LocalClass {
+// void bar() {
+// for(int j = 0; j < 100; j++) {}  <-- NOT A LOOP
+// }
+// };
+// for(int k = 0; k < 10; ++k) {}<-- Inner loop
+// {x = 5; for(k = 0; k < 10; ++k) x += k; x}; <-- NOT A LOOP
+// }
+// }
+// }
+// Result: Loop 'i' contains 2 loops, Loop 'r' also contains 2 loops
+class NestedLoopCounterVisitor : public DynamicRecursiveASTVisitor {
+private:
+  unsigned NestedLoopCount = 0;
+
+public:
+  explicit NestedLoopCounterVisitor() {}
+
+  unsigned getNestedLoopCount() const { return NestedLoopCount; }
+
+  bool VisitForStmt(ForStmt *FS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool VisitCXXForRangeStmt(CXXForRangeStmt *FRS) override {
+++NestedLoopCount;
+return true;
+  }
+
+  bool TraverseStmt(Stmt *S) override {
+if (!S)
+  return true;
+
+// Skip traversal of all expressions, including special cases like
+// LambdaExpr, StmtExpr, BlockExpr, and RequiresExpr. These expressions
+// may contain inner statements (and even loops), but they are not part
+// of the syntactic body of the surrounding loop structure.
+//  Therefore must not be counted
+if (isa(S))
+  return true;
+
+// Only recurse into CompoundStmt (block {}) and loop bodies
+if (isa(S) || isa(S) || isa(S)) {
+  return DynamicRecursiveASTVisitor::TraverseStmt(S);
+}
+
+// Stop traversal of the rest of statements, that break perfect
+// loop nesting, such as control flow (IfStmt, SwitchStmt...)
+return true;
+  }
+
+  bool TraverseDecl(Decl *D) override {
+// Stop in the case of finding a declaration, it is not important
+// in order to find nested loops (Possible CXXRecordDecl, RecordDecl,
+// FunctionDecl...)
+return true;
+  }
+};
+
+bool SemaOpenMP::analyzeLoopSequence(
+Stmt *LoopSeqStmt, unsigned &LoopSeqSize, unsigned &NumLoops,
+SmallVectorImpl &LoopHelpers,
+SmallVectorImpl &ForStmts,
+SmallVectorImpl> &OriginalInits,
+SmallVectorImpl> &TransformsPreInits,
+SmallVectorImpl> &LoopSequencePreInits,
+SmallVectorImpl &LoopCategories, ASTContext &Context,
+OpenMPDirectiveKind Kind) {
+
+  VarsWithInheritedDSAType TmpDSA;
+  QualType BaseInductionVarType;
+  // Helper Lambda to handle storing initialization and body statements for 
both
+  // ForStmt and CXXForRangeStmt and checks for any possible mismatch between
+  // induction variables types
+  auto storeLoopStatements = [&OriginalInits, &ForStmts, &BaseInductionVarType,
+  this, &Context](Stmt *LoopStmt) {
+if (auto *For = dyn_cast(LoopStmt)) {
+  OriginalInits.back().push_back(For->getInit());
+  ForStmts.push_back(For);
+  // Extract induction variable
+  if (auto *InitStmt = dyn_cast_or_null(For->getInit())) {
+if (auto *InitDecl = dyn_cast(InitStmt->getSingleDecl())) {
+  QualType InductionVarType = InitDecl->getType().getCanonicalType();
+
+  // Compare with first loop type
+  if (BaseInductionVarType.isNull()) {
+BaseInductionVarType = InductionVarT

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Alexey Bataev via cfe-commits


@@ -0,0 +1,186 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -std=c++20 -fopenmp 
-fopenmp-version=60 -fsyntax-only -Wuninitialized -verify %s
+
+void func() {
+
+// expected-error@+2 {{statement after '#pragma omp fuse' must be a loop 
sequence containing canonical loops or loop-generating constructs}}
+#pragma omp fuse 
+;
+
+// expected-error@+2 {{statement after '#pragma omp fuse' must be a for 
loop}}
+#pragma omp fuse 
+{int bar = 0;}
+
+// expected-error@+4 {{statement after '#pragma omp fuse' must be a for 
loop}}
+#pragma omp fuse 
+{
+for(int i = 0; i < 10; ++i);
+int x = 2;
+}
+
+// expected-error@+2 {{statement after '#pragma omp fuse' must be a loop 
sequence containing canonical loops or loop-generating constructs}}
+#pragma omp fuse 
+#pragma omp for 
+for (int i = 0; i < 7; ++i)
+;
+
+{
+// expected-error@+2 {{expected statement}}
+#pragma omp fuse
+}
+
+// expected-warning@+1 {{extra tokens at the end of '#pragma omp fuse' are 
ignored}}
+#pragma omp fuse foo
+{
+for (int i = 0; i < 7; ++i)
+;
+for(int j = 0; j < 100; ++j);
+
+}
+
+
+// expected-error@+1 {{unexpected OpenMP clause 'final' in directive 
'#pragma omp fuse'}}
+#pragma omp fuse final(0) 
+{
+for (int i = 0; i < 7; ++i)
+;
+for(int j = 0; j < 100; ++j);
+
+}
+
+//expected-error@+4 {{loop after '#pragma omp fuse' is not in canonical 
form}}

alexey-bataev wrote:

Why do you need the second message, if there's already another one, requiring 
canonical loop form?

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


[clang] [Clang] [Sema] Improve support for `__restrict`-qualified member functions (PR #83855)

2025-05-09 Thread via cfe-commits

Sirraide wrote:

> @Sirraide, wait, did we all miss this PR? I am so sorry

This was a while ago, but I recall talking to @AaronBallman about this one 
several times, and I think our conclusion at some point was that it wasn’t 
worth supporting this divergent behaviour or sth like that but I could be wrong 
(we also had a discussion about in one of the Wednesday meetings iirc).

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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Walter J.T.V via cfe-commits


@@ -3223,6 +3223,8 @@ LValue CodeGenFunction::EmitDeclRefLValue(const 
DeclRefExpr *E) {
 
 // No other cases for now.
 } else {
+  llvm::dbgs() << "THE DAMN DECLREFEXPR HASN'T BEEN ENTERED IN 
LOCALDECLMAP\n";
+  VD->dumpColor();

eZWALT wrote:

Oops, thanks!

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


[clang] 0d51247 - [clang][Darwin] Minor args cleanup (#139142)

2025-05-09 Thread via cfe-commits

Author: Ian Anderson
Date: 2025-05-09T11:37:47-07:00
New Revision: 0d5124775cace200f6f99905989ebeb65853b16e

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

LOG: [clang][Darwin] Minor args cleanup (#139142)

I just realized that ArgList.hasArg takes multiple arguments.
Consolidate the two calls into one.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 76fa2d121db2a..fe3952ee76229 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2582,8 +2582,7 @@ void DarwinClang::AddClangSystemIncludeArgs(
 llvm::opt::ArgStringList &CC1Args) const {
   AppleMachO::AddClangSystemIncludeArgs(DriverArgs, CC1Args);
 
-  if (DriverArgs.hasArg(options::OPT_nostdinc) ||
-  DriverArgs.hasArg(options::OPT_nostdlibinc))
+  if (DriverArgs.hasArg(options::OPT_nostdinc, options::OPT_nostdlibinc))
 return;
 
   llvm::SmallString<128> Sysroot = GetEffectiveSysroot(DriverArgs);



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


[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Walter J.T.V via cfe-commits


@@ -5378,6 +5379,10 @@ class CodeGenFunction : public CodeGenTypeCache {
 
   /// Set the address of a local variable.
   void setAddrOfLocalVar(const VarDecl *VD, Address Addr) {
+if (LocalDeclMap.count(VD)) {
+  llvm::errs() << "Warning: VarDecl already exists in map: ";
+  VD->dumpColor(); 
+}

eZWALT wrote:

Oops, thanks!

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


[clang] [CIR][NFC] Remove ABI handling from CIRGen call handling (PR #139159)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits

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


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


[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits

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


[libcxx] [libcxxabi] [libunwind] [llvm] [libcxxabi][libunwind] Support for using LLVM libc (PR #134893)

2025-05-09 Thread Petr Hosek via cfe-commits

https://github.com/petrhosek updated 
https://github.com/llvm/llvm-project/pull/134893

>From 1677ee5c547018472a1f6a29282d3af3500abcd7 Mon Sep 17 00:00:00 2001
From: Petr Hosek 
Date: Fri, 2 Aug 2024 08:25:53 -0700
Subject: [PATCH 1/2] [libcxxabi][libunwind] Support for using LLVM libc

This generalizes the support added in #99287 renaming the option to
RUNTIMES_USE_LIBC and integrating the module into libc++abi and
libunwind as well.
---
 libcxx/CMakeLists.txt|  8 -
 libcxx/cmake/Modules/HandleLibC.cmake| 39 
 libcxx/include/CMakeLists.txt|  2 +-
 libcxx/src/CMakeLists.txt|  4 +--
 libcxxabi/CMakeLists.txt |  2 ++
 libcxxabi/cmake/Modules/HandleLibC.cmake | 39 
 libcxxabi/src/CMakeLists.txt | 14 
 libunwind/CMakeLists.txt |  2 ++
 libunwind/cmake/Modules/HandleLibC.cmake | 39 
 libunwind/src/CMakeLists.txt | 14 
 runtimes/cmake/Modules/HandleLibC.cmake  | 46 
 11 files changed, 147 insertions(+), 62 deletions(-)
 delete mode 100644 libcxx/cmake/Modules/HandleLibC.cmake
 create mode 100644 libcxxabi/cmake/Modules/HandleLibC.cmake
 create mode 100644 libunwind/cmake/Modules/HandleLibC.cmake
 create mode 100644 runtimes/cmake/Modules/HandleLibC.cmake

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index ebaa6e9fd0e97..d3003cbec3889 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -225,14 +225,6 @@ set(LIBCXX_ABI_DEFINES "" CACHE STRING "A semicolon 
separated list of ABI macros
 set(LIBCXX_EXTRA_SITE_DEFINES "" CACHE STRING "Extra defines to add into 
__config_site")
 option(LIBCXX_USE_COMPILER_RT "Use compiler-rt instead of libgcc" OFF)
 
-# C Library options ---
-
-set(LIBCXX_SUPPORTED_C_LIBRARIES system llvm-libc)
-set(LIBCXX_LIBC "system" CACHE STRING "Specify C library to use. Supported 
values are ${LIBCXX_SUPPORTED_C_LIBRARIES}.")
-if (NOT "${LIBCXX_LIBC}" IN_LIST LIBCXX_SUPPORTED_C_LIBRARIES)
-  message(FATAL_ERROR "Unsupported C library: '${LIBCXX_CXX_ABI}'. Supported 
values are ${LIBCXX_SUPPORTED_C_LIBRARIES}.")
-endif()
-
 # ABI Library options -
 if (MSVC)
   set(LIBCXX_DEFAULT_ABI_LIBRARY "vcruntime")
diff --git a/libcxx/cmake/Modules/HandleLibC.cmake 
b/libcxx/cmake/Modules/HandleLibC.cmake
deleted file mode 100644
index 1b0564ae6fcc6..0
--- a/libcxx/cmake/Modules/HandleLibC.cmake
+++ /dev/null
@@ -1,39 +0,0 @@
-#===
-# Define targets for linking against the selected C library
-#
-# After including this file, the following targets are defined:
-# - libcxx-libc-headers: An interface target that allows getting access to the
-#headers of the selected C library.
-# - libcxx-libc-shared: A target representing the selected shared C library.
-# - libcxx-libc-static: A target representing the selected static C library.
-#===
-
-# Link against a system-provided libc
-if (LIBCXX_LIBC STREQUAL "system")
-  add_library(libcxx-libc-headers INTERFACE)
-
-  add_library(libcxx-libc-static INTERFACE)
-  add_library(libcxx-libc-shared INTERFACE)
-
-# Link against the in-tree LLVM libc
-elseif (LIBCXX_LIBC STREQUAL "llvm-libc")
-  add_library(libcxx-libc-headers INTERFACE)
-  target_link_libraries(libcxx-libc-headers INTERFACE libc-headers)
-  if(CXX_SUPPORTS_NOSTDLIBINC_FLAG)
-target_compile_options(libcxx-libc-headers INTERFACE "-nostdlibinc")
-  endif()
-
-  add_library(libcxx-libc-static INTERFACE)
-  if (TARGET libc)
-target_link_libraries(libcxx-libc-static INTERFACE libc)
-  endif()
-  if (TARGET libm)
-target_link_libraries(libcxx-libc-static INTERFACE libm)
-  endif()
-  if (CXX_SUPPORTS_NOLIBC_FLAG)
-target_link_options(libcxx-libc-static INTERFACE "-nolibc")
-  endif()
-
-  # TODO: There's no support for building LLVM libc as a shared library yet.
-  add_library(libcxx-libc-shared INTERFACE)
-endif()
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index a021b9bb44d67..9058a72ea75ab 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -2121,7 +2121,7 @@ list(APPEND _all_includes 
"${LIBCXX_GENERATED_INCLUDE_DIR}/libcxx.imp")
 add_custom_target(generate-cxx-headers ALL DEPENDS ${_all_includes})
 
 add_library(cxx-headers INTERFACE)
-target_link_libraries(cxx-headers INTERFACE libcxx-libc-headers 
libcxx-abi-headers)
+target_link_libraries(cxx-headers INTERFACE runtimes-libc-headers 
libcxx-abi-headers)
 add_dependencies(cxx-headers generate-cxx-headers)
 # It's important that the arch directory be included first so that its header 
files
 # which interpose on the default include dir be included instea

[clang] [clang][OpenMP] Add error for large expr in collapse clause (PR #138592)

2025-05-09 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

Thank you for the fix! I've added a few more reviewers. This is a pretty 
general problem, so I think we may want additional test coverage for basically 
any of the OpenMP clauses which accept an integer argument. For example, this 
is another related issue: https://github.com/llvm/llvm-project/issues/139268 -- 
I expect they're all resolved by your fix, perhaps?

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


[clang] [HIP] change default offload archs (PR #139281)

2025-05-09 Thread Cory Bloor via cfe-commits

https://github.com/cgmb commented:

Thanks @yxsamliu! To add a bit more context, this was my original email that 
raised the topic:

> I wonder if we should consider revisiting the decision to default clang to 
> gfx906 [1]. I came across how that decision was made shortly after it was 
> implemented, and at the time I thought it was silly not to default to 
> `native`. The decision was made to change the default from gfx803 to gfx906 
> because the former wasn’t supported, but AMD dropped support for the latter 
> shortly thereafter. Using the same criteria as that previous decision, we 
> should be changing the default again to something newer.
> 
> However, the default of "some random GPU architecture that changes every few 
> releases" is just plain bad. If a user tries to run a program that was built 
> for gfx906 only because nothing else was specified, the most likely result 
> will be that the program doesn’t work on their machine. I’m not sure what the 
> current behaviour of the HIP Runtime is, but historically, running a program 
> built for a different GPU than your own would result in a crash that might 
> not even include an error message.
> 
> My workstations all have gfx906 GPUs, but this is arguably worse! It means 
> that when I work on build scripts, if I make a mistake and fail to specify 
> the target architecture somewhere, the built result will still work on my 
> machine! This hides errors in my build scripts, which then become a problem 
> when I share those scripts with others working on different hardware. Even 
> for my own work, I wouldn’t want to depend on gfx906 being the default 
> target. My scripts would all break when I update clang to some future version.
> 
> I would suggest that we should either (a) change the default GPU target to 
> `native` and make the failure to detect the user’s GPU into a hard compiler 
> error, or (b) change the default GPU target to SPIR-V so that it works on 
> every machine.
> 
> [1]: 
> https://discourse.llvm.org/t/rfc-let-clang-use-system-gpu-as-default-offload-arch-for-hip/66950/5

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


[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits

https://github.com/bcardosolopes commented:

This is also missing a end-to-end test that proves we generate switchflatop if 
we are coming all the way from source code. There are examples in the incubator 
on how to check if a pass runs (you can use print-before/after) and the IR for 
it.

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


[libcxx] [libcxxabi] [libunwind] [llvm] [libcxxabi][libunwind] Support for using LLVM libc (PR #134893)

2025-05-09 Thread Petr Hosek via cfe-commits


@@ -0,0 +1,39 @@
+#===

petrhosek wrote:

These are no longer used, removed.

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


[clang] [clang][Darwin] Minor args cleanup (PR #139142)

2025-05-09 Thread Ian Anderson via cfe-commits

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s 
cppcoreguidelines-use-enum-class %t -- -config="{CheckOptions: 
{cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true}}" --
+
+enum E {};
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum 
class' instead [cppcoreguidelines-use-enum-class]
+
+enum class EC {};
+
+struct S {
+  enum E {};

JungPhilipp wrote:

Done

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s 
cppcoreguidelines-use-enum-class %t -- -config="{CheckOptions: 
{cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true}}" --

JungPhilipp wrote:

Done

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-use-enum-class
+
+cppcoreguidelines-use-enum-class
+=

JungPhilipp wrote:

Done

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


[clang-tools-extra] Fix spelling error crtp-constructor-accessibility.rst (PR #139307)

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


[clang-tools-extra] Fix spelling error crtp-constructor-accessibility.rst (PR #139307)

2025-05-09 Thread Bart Louwers via cfe-commits

https://github.com/louwers created 
https://github.com/llvm/llvm-project/pull/139307

it's = it has, which is not correct here.



  



Rate limit · GitHub


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

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

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

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

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

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

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


  
  



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

  

  

  

  

  


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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-use-enum-class
+
+cppcoreguidelines-use-enum-class
+=
+
+Finds plain non-class ``enum`` definitions that could use ``enum class``.
+
+This check implements `Enum.3
+`_
+from the C++ Core Guidelines."
+
+Example:
+
+.. code-block:: c++
+
+  enum E {};// use "enum class E {};" instead
+  enum class E {};  // OK
+
+  struct S {
+  enum E {};// use "enum class E {};" instead
+// OK with option IgnoreUnscopedEnumsInClasses
+  };
+
+  namespace N {
+  enum E {};// use "enum class E {};" instead
+  }
+
+

JungPhilipp wrote:

Done

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -59,6 +60,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck(
 "cppcoreguidelines-avoid-capturing-lambda-coroutines");
+CheckFactories.registerCheck(
+"cppcoreguidelines-use-enum-class");

JungPhilipp wrote:

Done

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -136,6 +136,11 @@ New checks
   Finds potentially erroneous calls to ``reset`` method on smart pointers when
   the pointee type also has a ``reset`` method.
 
+- New :doc:`cppcoreguidelines-use-enum-class

JungPhilipp wrote:

Done

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -211,6 +211,7 @@ Clang-Tidy Checks
:doc:`cppcoreguidelines-rvalue-reference-param-not-moved 
`,
:doc:`cppcoreguidelines-slicing `,
:doc:`cppcoreguidelines-special-member-functions 
`,
+   :doc:`cppcoreguidelines-use-enum-class `, 
"Yes"

JungPhilipp wrote:

Done

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-use-enum-class
+
+cppcoreguidelines-use-enum-class
+=
+
+Finds plain non-class ``enum`` definitions that could use ``enum class``.
+
+This check implements `Enum.3
+`_
+from the C++ Core Guidelines."
+
+Example:
+
+.. code-block:: c++
+
+  enum E {};// use "enum class E {};" instead
+  enum class E {};  // OK
+
+  struct S {
+  enum E {};// use "enum class E {};" instead
+// OK with option IgnoreUnscopedEnumsInClasses
+  };
+
+  namespace N {
+  enum E {};// use "enum class E {};" instead
+  }
+
+
+.. option:: IgnoreUnscopedEnumsInClasses
+
+   When `true` (default is `false`), ignores unscoped ``enum`` declarations in 
classes.

JungPhilipp wrote:

Done

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -0,0 +1,13 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s 
cppcoreguidelines-use-enum-class %t -- -config="{CheckOptions: 
{cppcoreguidelines-use-enum-class.IgnoreUnscopedEnumsInClasses: true}}" --
+
+enum E {};
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: enum 'E' is unscoped, use 'enum 
class' instead [cppcoreguidelines-use-enum-class]

JungPhilipp wrote:

Done

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits


@@ -0,0 +1,31 @@
+.. title:: clang-tidy - cppcoreguidelines-use-enum-class
+
+cppcoreguidelines-use-enum-class
+=
+
+Finds plain non-class ``enum`` definitions that could use ``enum class``.

JungPhilipp wrote:

Done

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


[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits


@@ -0,0 +1,68 @@
+// RUN: cir-opt %s | FileCheck %s
+!s32i = !cir.int
+
+cir.func @FlatSwitchWithoutDefault(%arg0: !s32i) {
+  cir.switch.flat %arg0 : !s32i, ^bb2 [
+1: ^bb1
+  ]
+  ^bb1:
+cir.br ^bb2
+  ^bb2:
+cir.return
+}
+
+// CHECK: cir.switch.flat %arg0 : !s32i, ^bb2 [
+// CHECK-NEXT:  1: ^bb1
+// CHECK-NEXT: ]
+// CHECK-NEXT: ^bb1:
+// CHECK-NEXT:   cir.br ^bb2
+// CHECK-NEXT: ^bb2:
+//CHECK-NEXT:cir.return

bcardosolopes wrote:

Odd indentation compared with other check lines

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


[clang] [clang] Add support for `__ptrauth` being applied to integer types (PR #137580)

2025-05-09 Thread Oliver Hunt via cfe-commits


@@ -1031,10 +1031,12 @@ def err_ptrauth_qualifier_invalid : Error<
   "%select{return type|parameter type|property}1 may not be qualified with 
'__ptrauth'; type is %0">;
 def err_ptrauth_qualifier_cast : Error<
   "cannot cast to '__ptrauth'-qualified type %0">;
-def err_ptrauth_qualifier_nonpointer : Error<
-  "'__ptrauth' qualifier only applies to pointer types; %0 is invalid">;
-def err_ptrauth_qualifier_redundant : Error<
-  "type %0 is already %1-qualified">;
+def err_ptrauth_qualifier_invalid_target
+: Error<"'__ptrauth' qualifier only applies to pointer or pointer sized "
+"integer"
+" types; %0 is invalid">;
+def err_ptrauth_qualifier_redundant
+: Error<"type %0 is already __ptrauth-qualified">;

ojhunt wrote:

yeah I find the 80col breaks especially irksome in diagnostics, but also if we 
went to my preferred limit of 120 they'd be annoying to break :D

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


[clang-tools-extra] Add check 'modernize-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits

https://github.com/JungPhilipp updated 
https://github.com/llvm/llvm-project/pull/138282

>From 0567bc8e1168bb409ee759dd5505861a644a8ead Mon Sep 17 00:00:00 2001
From: Philipp Jung 
Date: Fri, 2 May 2025 15:22:40 +0200
Subject: [PATCH 1/6] Add check 'modernize-use-enum-class'

Warn on non-class enum definitions as suggested by the Core Guidelines:
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Renum-class
---
 .../clang-tidy/modernize/CMakeLists.txt   |  1 +
 .../modernize/ModernizeTidyModule.cpp |  2 +
 .../modernize/UseEnumClassCheck.cpp   | 34 +++
 .../clang-tidy/modernize/UseEnumClassCheck.h  | 34 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../checks/modernize/use-enum-class.rst   | 26 +
 .../checkers/modernize/use-enum-class.cpp | 58 +++
 8 files changed, 161 insertions(+)
 create mode 100644 clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.cpp
 create mode 100644 clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/modernize/use-enum-class.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-enum-class.cpp

diff --git a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
index bab1167fb15ff..ea19586b1f08c 100644
--- a/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
@@ -34,6 +34,7 @@ add_clang_library(clangTidyModernizeModule STATIC
   UseDefaultMemberInitCheck.cpp
   UseDesignatedInitializersCheck.cpp
   UseEmplaceCheck.cpp
+  UseEnumClassCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
   UseIntegerSignComparisonCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp 
b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
index fc46c72982fdc..1f77c9a94d25a 100644
--- a/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -35,6 +35,7 @@
 #include "UseDefaultMemberInitCheck.h"
 #include "UseDesignatedInitializersCheck.h"
 #include "UseEmplaceCheck.h"
+#include "UseEnumClassCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
 #include "UseIntegerSignComparisonCheck.h"
@@ -110,6 +111,7 @@ class ModernizeModule : public ClangTidyModule {
 CheckFactories.registerCheck(
 "modernize-use-default-member-init");
 CheckFactories.registerCheck("modernize-use-emplace");
+
CheckFactories.registerCheck("modernize-use-enum-class");
 
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.cpp
new file mode 100644
index 0..9fc3614aaf498
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.cpp
@@ -0,0 +1,34 @@
+//===--- UseEnumClassCheck.cpp - clang-tidy 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "UseEnumClassCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::modernize {
+
+void UseEnumClassCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  traverse(TK_AsIs,
+   enumDecl(unless(isScoped()), unless(hasParent(recordDecl()
+  .bind("unscoped_enum"),
+  this);
+}
+
+void UseEnumClassCheck::check(const MatchFinder::MatchResult &Result) {
+  const auto *UnscopedEnum = Result.Nodes.getNodeAs("unscoped_enum");
+
+  diag(UnscopedEnum->getLocation(),
+   "enum %0 is unscoped, use enum class instead")
+  << UnscopedEnum;
+  diag(UnscopedEnum->getLocation(), "insert 'class'", DiagnosticIDs::Note)
+  << FixItHint::CreateInsertion(UnscopedEnum->getLocation(), "class ");
+}
+
+} // namespace clang::tidy::modernize
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.h
new file mode 100644
index 0..9cfb2024b9cfd
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/modernize/UseEnumClassCheck.h
@@ -0,0 +1,34 @@
+//===--- UseEnumClassCheck.h - clang-tidy ---*- C++ 
-*-===//
+//
+// 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
+//
+//==

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Walter J.T.V via cfe-commits


@@ -5790,7 +5805,11 @@ class OMPReverseDirective final : public 
OMPLoopTransformationDirective {
   explicit OMPReverseDirective(SourceLocation StartLoc, SourceLocation EndLoc)
   : OMPLoopTransformationDirective(OMPReverseDirectiveClass,
llvm::omp::OMPD_reverse, StartLoc,
-   EndLoc, 1) {}
+   EndLoc, 1) {
+// Reverse produces a single top-level canonical loop nest
+setNumGeneratedLoops(1);

eZWALT wrote:

Okey do i make another pull request just for the loop corrections though?

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


[clang] [CIR] Implement folder for VecExtractOp (PR #139304)

2025-05-09 Thread Amr Hesham via cfe-commits

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


[clang] [CIR] Upstream support for FlattenCFG switch and SwitchFlatOp (PR #139154)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits


@@ -171,6 +171,232 @@ class CIRScopeOpFlattening : public 
mlir::OpRewritePattern {
   }
 };
 
+class CIRSwitchOpFlattening : public mlir::OpRewritePattern {
+public:
+  using OpRewritePattern::OpRewritePattern;
+
+  inline void rewriteYieldOp(mlir::PatternRewriter &rewriter,
+ cir::YieldOp yieldOp,
+ mlir::Block *destination) const {
+rewriter.setInsertionPoint(yieldOp);
+rewriter.replaceOpWithNewOp(yieldOp, yieldOp.getOperands(),
+   destination);
+  }
+
+  // Return the new defaultDestination block.
+  Block *condBrToRangeDestination(cir::SwitchOp op,
+  mlir::PatternRewriter &rewriter,
+  mlir::Block *rangeDestination,
+  mlir::Block *defaultDestination,
+  const APInt &lowerBound,
+  const APInt &upperBound) const {
+assert(lowerBound.sle(upperBound) && "Invalid range");
+mlir::Block *resBlock = rewriter.createBlock(defaultDestination);
+cir::IntType sIntType = cir::IntType::get(op.getContext(), 32, true);
+cir::IntType uIntType = cir::IntType::get(op.getContext(), 32, false);
+
+cir::ConstantOp rangeLength = rewriter.create(
+op.getLoc(), cir::IntAttr::get(sIntType, upperBound - lowerBound));
+
+cir::ConstantOp lowerBoundValue = rewriter.create(
+op.getLoc(), cir::IntAttr::get(sIntType, lowerBound));
+cir::BinOp diffValue =
+rewriter.create(op.getLoc(), sIntType, cir::BinOpKind::Sub,
+op.getCondition(), lowerBoundValue);
+
+// Use unsigned comparison to check if the condition is in the range.
+cir::CastOp uDiffValue = rewriter.create(
+op.getLoc(), uIntType, CastKind::integral, diffValue);
+cir::CastOp uRangeLength = rewriter.create(
+op.getLoc(), uIntType, CastKind::integral, rangeLength);
+
+cir::CmpOp cmpResult = rewriter.create(
+op.getLoc(), cir::BoolType::get(op.getContext()), cir::CmpOpKind::le,
+uDiffValue, uRangeLength);
+rewriter.create(op.getLoc(), cmpResult, rangeDestination,
+   defaultDestination);
+return resBlock;
+  }
+
+  mlir::LogicalResult
+  matchAndRewrite(cir::SwitchOp op,
+  mlir::PatternRewriter &rewriter) const override {
+llvm::SmallVector cases;
+op.collectCases(cases);
+
+// Empty switch statement: just erase it.
+if (cases.empty()) {
+  rewriter.eraseOp(op);
+  return mlir::success();
+}
+
+// Create exit block from the next node of cir.switch op.
+mlir::Block *exitBlock = rewriter.splitBlock(
+rewriter.getBlock(), op->getNextNode()->getIterator());
+
+// We lower cir.switch op in the following process:
+// 1. Inline the region from the switch op after switch op.
+// 2. Traverse each cir.case op:
+//a. Record the entry block, block arguments and condition for every
+//case. b. Inline the case region after the case op.
+// 3. Replace the empty cir.switch.op with the new cir.switchflat op by the
+//recorded block and conditions.
+
+// inline everything from switch body between the switch op and the exit
+// block.
+{
+  cir::YieldOp switchYield = nullptr;
+  // Clear switch operation.
+  for (auto &block : llvm::make_early_inc_range(op.getBody().getBlocks()))
+if (auto yieldOp = dyn_cast(block.getTerminator()))
+  switchYield = yieldOp;
+
+  assert(!op.getBody().empty());
+  mlir::Block *originalBlock = op->getBlock();
+  mlir::Block *swopBlock =
+  rewriter.splitBlock(originalBlock, op->getIterator());
+  rewriter.inlineRegionBefore(op.getBody(), exitBlock);
+
+  if (switchYield)
+rewriteYieldOp(rewriter, switchYield, exitBlock);
+
+  rewriter.setInsertionPointToEnd(originalBlock);
+  rewriter.create(op.getLoc(), swopBlock);
+}
+
+// Allocate required data structures (disconsider default case in
+// vectors).
+llvm::SmallVector caseValues;
+llvm::SmallVector caseDestinations;
+llvm::SmallVector caseOperands;
+
+llvm::SmallVector> rangeValues;
+llvm::SmallVector rangeDestinations;
+llvm::SmallVector rangeOperands;
+
+// Initialize default case as optional.
+mlir::Block *defaultDestination = exitBlock;
+mlir::ValueRange defaultOperands = exitBlock->getArguments();
+
+// Digest the case statements values and bodies.
+for (auto caseOp : cases) {
+  mlir::Region ®ion = caseOp.getCaseRegion();
+
+  // Found default case: save destination and operands.
+  switch (caseOp.getKind()) {
+  case cir::CaseOpKind::Default:
+defaultDestination = ®ion.front();
+defaultOperands = defaultDestination->getArguments();
+break;
+  case cir::CaseOpKind::Range:
+ 

[clang] [DNC] Break formatting to test clang-format (PR #124809)

2025-05-09 Thread Jacob Lambert via cfe-commits

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


[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)

2025-05-09 Thread Marco Elver via cfe-commits


@@ -235,6 +266,20 @@ class FactSet {
 return false;
   }
 
+  std::optional replaceLock(FactManager &FM, iterator It,
+std::unique_ptr Entry) {
+if (It == end())
+  return std::nullopt;
+FactID F = FM.newFact(std::move(Entry));
+*It = F;
+return F;
+  }
+
+  std::optional replaceLock(FactManager &FM, const CapabilityExpr 
&CapE,
+std::unique_ptr Entry) {
+return replaceLock(FM, findLockIter(FM, CapE), std::move(Entry));
+  }
+

melver wrote:

replaceLock without caller-iterator still saves a copy+pop_back+push_back. Not 
much, but not nothing either.

This PR should include the bare minimum use of replaceLock - I have one patch 
queued that is not part of this PR to do an unrelated substitution with 
replaceLock.

If anything I'd move replaceLock introduction before this PR, but I think we're 
just splitting hairs at that point.

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


[clang] [clang] Add support for `__ptrauth` being applied to integer types (PR #137580)

2025-05-09 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt updated 
https://github.com/llvm/llvm-project/pull/137580

>From 07b6275740646c6ac0ffd95518e7e9fa8f1e8717 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Sun, 27 Apr 2025 22:33:44 -0700
Subject: [PATCH 1/2] [clang] Add support for __ptrauth being applied to
 integer types

This adds support for the __ptrauth qualifier to be applied to
pointer sized integer types.
---
 clang/docs/PointerAuthentication.rst  |  11 +-
 clang/include/clang/AST/Type.h|  12 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  10 +-
 clang/lib/AST/ASTContext.cpp  |   3 +
 clang/lib/AST/Type.cpp|   6 +
 clang/lib/CodeGen/CGExprConstant.cpp  |   4 +
 clang/lib/CodeGen/CGExprScalar.cpp|   2 +-
 clang/lib/CodeGen/CGPointerAuth.cpp   |  17 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   2 +-
 clang/lib/Sema/SemaType.cpp   |  10 +-
 clang/lib/Sema/TreeTransform.h|  12 +-
 .../ptrauth-restricted-intptr-qualifier.c | 219 ++
 clang/test/Sema/ptrauth-qualifier.c   |   6 +-
 clang/test/SemaCXX/ptrauth-triviality.cpp |  48 
 14 files changed, 329 insertions(+), 33 deletions(-)
 create mode 100644 clang/test/CodeGen/ptrauth-restricted-intptr-qualifier.c

diff --git a/clang/docs/PointerAuthentication.rst 
b/clang/docs/PointerAuthentication.rst
index 41818d43ac687..b9341a9c3b6a8 100644
--- a/clang/docs/PointerAuthentication.rst
+++ b/clang/docs/PointerAuthentication.rst
@@ -284,13 +284,14 @@ __ptrauth Qualifier
 ^^^
 
 ``__ptrauth(key, address, discriminator)`` is an extended type
-qualifier which causes so-qualified objects to hold pointers signed using the
-specified schema rather than the default schema for such types.
+qualifier which causes so-qualified objects to hold pointers or pointer sized
+integers signed using the specified schema rather than the default schema for
+such types.
 
 In the current implementation in Clang, the qualified type must be a C pointer
-type, either to a function or to an object.  It currently cannot be an
-Objective-C pointer type, a C++ reference type, or a block pointer type; these
-restrictions may be lifted in the future.
+type, either to a function or to an object, or a pointer sized integer.  It
+currently cannot be an Objective-C pointer type, a C++ reference type, or a
+block pointer type; these restrictions may be lifted in the future.
 
 The qualifier's operands are as follows:
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 773796a55eaa1..435a9de68f774 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2560,7 +2560,9 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isFunctionProtoType() const { return getAs(); }
   bool isPointerType() const;
   bool isPointerOrReferenceType() const;
-  bool isSignableType() const;
+  bool isSignableType(const ASTContext &Ctx) const;
+  bool isSignablePointerType() const;
+  bool isSignableIntegerType(const ASTContext &Ctx) const;
   bool isAnyPointerType() const;   // Any C pointer or ObjC object pointer
   bool isCountAttributedType() const;
   bool isBlockPointerType() const;
@@ -8222,7 +8224,13 @@ inline bool Type::isAnyPointerType() const {
   return isPointerType() || isObjCObjectPointerType();
 }
 
-inline bool Type::isSignableType() const { return isPointerType(); }
+inline bool Type::isSignableType(const ASTContext &Ctx) const {
+  return isSignablePointerType() || isSignableIntegerType(Ctx);
+}
+
+inline bool Type::isSignablePointerType() const {
+  return isPointerType() || isObjCClassType() || isObjCQualifiedClassType();
+}
 
 inline bool Type::isBlockPointerType() const {
   return isa(CanonicalType);
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index e1b9ed0647bb9..034ef4ff57187 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1031,10 +1031,12 @@ def err_ptrauth_qualifier_invalid : Error<
   "%select{return type|parameter type|property}1 may not be qualified with 
'__ptrauth'; type is %0">;
 def err_ptrauth_qualifier_cast : Error<
   "cannot cast to '__ptrauth'-qualified type %0">;
-def err_ptrauth_qualifier_nonpointer : Error<
-  "'__ptrauth' qualifier only applies to pointer types; %0 is invalid">;
-def err_ptrauth_qualifier_redundant : Error<
-  "type %0 is already %1-qualified">;
+def err_ptrauth_qualifier_invalid_target
+: Error<"'__ptrauth' qualifier only applies to pointer or pointer sized "
+"integer"
+" types; %0 is invalid">;
+def err_ptrauth_qualifier_redundant
+: Error<"type %0 is already __ptrauth-qualified">;
 def err_ptrauth_arg_not_ice : Error<
   "argument to '__ptrauth' must be an integer constant expression">;
 def err_ptrauth_address_discrimination_invalid

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Walter J.T.V via cfe-commits


@@ -962,6 +962,9 @@ class OMPLoopTransformationDirective : public 
OMPLoopBasedDirective {
 
   /// Number of loops generated by this loop transformation.
   unsigned NumGeneratedLoops = 0;
+  /// Number of top level canonical loop nests generated by this loop
+  /// transformation
+  unsigned NumGeneratedLoopNests = 0;

eZWALT wrote:

Maybe the name is a bit unfortunate and could be improved, but they are 2 
completely different fields conceptually. This top level loops are the ones 
actually managed by loop Sequence constructs like fuse and the upcoming split. 
A loop sequence contains loops which may contain several inner nestes loops, 
but these should not be taken into account for performing fusion or splitting.  
This was not taken into account originally due to all transformations having a 
fixed number of generated top level nests (1). However fuse or split may 
generate several loop nests with inner nested loops.

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


[clang-tools-extra] Fix spelling error crtp-constructor-accessibility.rst (PR #139307)

2025-05-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Bart Louwers (louwers)


Changes

it's = it has, which is not correct here.

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


1 Files Affected:

- (modified) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
 (+1-1) 


``diff
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
index afd88764b5967..07d7e68fddc47 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
@@ -9,7 +9,7 @@ can be constructed outside itself and the derived class.
 The CRTP is an idiom, in which a class derives from a template class, where 
 itself is the template argument. It should be ensured that if a class is
 intended to be a base class in this idiom, it can only be instantiated if
-the derived class is it's template argument.
+the derived class is its template argument.
 
 Example:
 

``




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


[clang-tools-extra] Fix spelling error crtp-constructor-accessibility.rst (PR #139307)

2025-05-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Bart Louwers (louwers)


Changes

it's = it has, which is not correct here.

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


1 Files Affected:

- (modified) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
 (+1-1) 


``diff
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
index afd88764b5967..07d7e68fddc47 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/crtp-constructor-accessibility.rst
@@ -9,7 +9,7 @@ can be constructed outside itself and the derived class.
 The CRTP is an idiom, in which a class derives from a template class, where 
 itself is the template argument. It should be ensured that if a class is
 intended to be a base class in this idiom, it can only be instantiated if
-the derived class is it's template argument.
+the derived class is its template argument.
 
 Example:
 

``




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


[clang] [CIR] Upstream insert op for VectorType (PR #139146)

2025-05-09 Thread Amr Hesham via cfe-commits

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

>From 11de7d363ae9f06e98f15fc5c492e74a660693f8 Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Thu, 8 May 2025 22:10:39 +0200
Subject: [PATCH 1/3] [CIR] Upstream insert op for VectorType

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  37 ++
 clang/lib/CIR/CodeGen/CIRGenExpr.cpp  |  38 --
 clang/lib/CIR/CodeGen/CIRGenValue.h   |  27 
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp |  11 +-
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.h   |  10 ++
 clang/test/CIR/CodeGen/vector-ext.cpp | 123 ++
 clang/test/CIR/CodeGen/vector.cpp | 123 ++
 clang/test/CIR/IR/vector.cir  |  38 ++
 8 files changed, 397 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 7aff5edb88167..4b071680c4c1e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -1969,6 +1969,43 @@ def VecCreateOp : CIR_Op<"vec.create", [Pure]> {
   let hasVerifier = 1;
 }
 
+//===--===//
+// VecInsertOp
+//===--===//
+
+def VecInsertOp : CIR_Op<"vec.insert", [Pure,
+  TypesMatchWith<"argument type matches vector element type", "vec", "value",
+ "cast($_self).getElementType()">,
+  AllTypesMatch<["result", "vec"]>]> {
+
+  let summary = "Insert one element into a vector object";
+  let description = [{
+The `cir.vec.insert` operation replaces the element of the given vector at
+the given index with the given value.  The new vector with the inserted
+element is returned.
+
+```mlir
+%value = cir.const #cir.int<5> : !s32i
+%index = cir.const #cir.int<2> : !s32i
+%vec_tmp = cir.load %0 : !cir.ptr>, !cir.vector<4 x 
!s32i>
+%new_vec = cir.vec.insert %index, %vec_tmp[%value : !s32i] : !cir.vector<4 
x !s32i>
+```
+  }];
+
+  let arguments = (ins
+CIR_VectorType:$vec,
+AnyType:$value,
+CIR_AnyFundamentalIntType:$index
+  );
+
+  let results = (outs CIR_VectorType:$result);
+
+  let assemblyFormat = [{
+$value `,` $vec `[` $index `:` type($index) `]` attr-dict `:`
+qualified(type($vec))
+  }];
+}
+
 
//===--===//
 // VecExtractOp
 
//===--===//
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp 
b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
index 711a65215b043..fd70b0d9b667e 100644
--- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp
@@ -205,6 +205,17 @@ Address CIRGenFunction::emitPointerWithAlignment(const 
Expr *expr,
 void CIRGenFunction::emitStoreThroughLValue(RValue src, LValue dst,
 bool isInit) {
   if (!dst.isSimple()) {
+if (dst.isVectorElt()) {
+  // Read/modify/write the vector, inserting the new element
+  const mlir::Location loc = dst.getVectorPointer().getLoc();
+  const mlir::Value vector =
+  builder.createLoad(loc, dst.getVectorAddress().getPointer());
+  const mlir::Value newVector = builder.create(
+  loc, vector, src.getScalarVal(), dst.getVectorIdx());
+  builder.createStore(loc, newVector, dst.getVectorAddress().getPointer());
+  return;
+}
+
 cgm.errorNYI(dst.getPointer().getLoc(),
  "emitStoreThroughLValue: non-simple lvalue");
 return;
@@ -418,6 +429,13 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, 
SourceLocation loc) {
   if (lv.isSimple())
 return RValue::get(emitLoadOfScalar(lv, loc));
 
+  if (lv.isVectorElt()) {
+auto load =
+builder.createLoad(getLoc(loc), lv.getVectorAddress().getPointer());
+return RValue::get(builder.create(getLoc(loc), load,
+ lv.getVectorIdx()));
+  }
+
   cgm.errorNYI(loc, "emitLoadOfLValue");
   return RValue::get(nullptr);
 }
@@ -638,12 +656,6 @@ static Address emitArraySubscriptPtr(CIRGenFunction &cgf,
 
 LValue
 CIRGenFunction::emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e) {
-  if (e->getBase()->getType()->isVectorType() &&
-  !isa(e->getBase())) {
-cgm.errorNYI(e->getSourceRange(), "emitArraySubscriptExpr: VectorType");
-return LValue::makeAddr(Address::invalid(), e->getType(), 
LValueBaseInfo());
-  }
-
   if (isa(e->getBase())) {
 cgm.errorNYI(e->getSourceRange(),
  "emitArraySubscriptExpr: ExtVectorElementExpr");
@@ -666,18 +678,26 @@ CIRGenFunction::emitArraySubscriptExpr(const 
clang::ArraySubscriptExpr *e) {
   assert((e->getIdx() == e->getLHS() || e->getIdx() == e->getRHS()) &&
  "index was neither LHS nor RHS");
 
-  auto emitIdxAfterBase = [

[clang] [flang] [llvm] [openmp] [Clang][OpenMP][LoopTransformations] Add support for "#pragma omp fuse" loop transformation direcrive and "looprange" clause (PR #139293)

2025-05-09 Thread Walter J.T.V via cfe-commits


@@ -962,6 +962,9 @@ class OMPLoopTransformationDirective : public 
OMPLoopBasedDirective {
 
   /// Number of loops generated by this loop transformation.
   unsigned NumGeneratedLoops = 0;
+  /// Number of top level canonical loop nests generated by this loop
+  /// transformation
+  unsigned NumGeneratedLoopNests = 0;

eZWALT wrote:

Note that unroll is an exception, it could have 0 or 1 but it coincides 
perfectly with the original number of loops .

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


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

2025-05-09 Thread Daniel Paoliello via cfe-commits

https://github.com/dpaoliello updated 
https://github.com/llvm/llvm-project/pull/125320

>From f429ad43fa0f56240721f071607b196ad970a6a0 Mon Sep 17 00:00:00 2001
From: "Daniel Paoliello (HE/HIM)" 
Date: Fri, 31 Jan 2025 16:47:23 -0800
Subject: [PATCH] [aarch64][x86][win] Add support for MSVC's /funcoverride flag
 (Windows kernel loader replaceable functions)

---
 clang/include/clang/Basic/CodeGenOptions.h|   9 ++
 clang/include/clang/Driver/Options.td |   7 ++
 clang/lib/CodeGen/CGCall.cpp  |   4 +
 clang/lib/Driver/ToolChains/Clang.cpp |   6 +
 .../CodeGen/loader-replaceable-function.cpp   |  17 +++
 clang/test/Driver/cl-options.c|   4 +
 llvm/include/llvm/CodeGen/AsmPrinter.h|  11 ++
 llvm/include/llvm/IR/Attributes.td|   1 +
 llvm/include/llvm/IR/Mangler.h|   2 +
 llvm/lib/Analysis/InlineCost.cpp  |   4 +
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 106 ++
 .../AArch64/AArch64Arm64ECCallLowering.cpp|   5 +-
 llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp |  28 +
 llvm/lib/Target/X86/X86AsmPrinter.cpp |  37 +-
 .../win-loader-replaceable-function.ll|  40 +++
 .../X86/win-loader-replaceable-function.ll|  40 +++
 llvm/test/Transforms/Inline/attributes.ll |  12 ++
 17 files changed, 270 insertions(+), 63 deletions(-)
 create mode 100644 clang/test/CodeGen/loader-replaceable-function.cpp
 create mode 100644 llvm/test/CodeGen/AArch64/win-loader-replaceable-function.ll
 create mode 100644 llvm/test/CodeGen/X86/win-loader-replaceable-function.ll

diff --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index e716b59a119fc..278803f7bb960 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -499,6 +499,9 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// The name of a file to use with \c .secure_log_unique directives.
   std::string AsSecureLogFile;
 
+  /// A list of functions that are replacable by the loader.
+  std::vector LoaderReplaceableFunctionNames;
+
 public:
   // Define accessors/mutators for code generation options of enumeration type.
 #define CODEGENOPT(Name, Bits, Default)
@@ -571,6 +574,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
   /// Reset all of the options that are not considered when building a
   /// module.
   void resetNonModularOptions(StringRef ModuleFormat);
+
+  // Is the given function name one of the functions that can be replaced by 
the
+  // loader?
+  bool isLoaderReplaceableFunctionName(StringRef FuncName) const {
+return llvm::is_contained(LoaderReplaceableFunctionNames, FuncName);
+  }
 };
 
 }  // end namespace clang
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3cdf57d0085ee..bd8df8f6a749a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -7826,6 +7826,9 @@ def import_call_optimization : Flag<["-"], 
"import-call-optimization">,
  "by the Windows kernel to enable import call optimization">,
 MarshallingInfoFlag>;
 
+def replaceable_function: Joined<["-"], "loader-replaceable-function=">,
+  MarshallingInfoStringVector>;
+
 } // let Visibility = [CC1Option]
 
 
//===--===//
@@ -9088,6 +9091,10 @@ def _SLASH_Gregcall : CLFlag<"Gregcall">,
 def _SLASH_Gregcall4 : CLFlag<"Gregcall4">,
   HelpText<"Set __regcall4 as a default calling convention to respect 
__regcall ABI v.4">;
 
+def _SLASH_funcoverride : CLCompileJoined<"funcoverride:">,
+  HelpText<"Mark  as being replaceable by the Windows kernel 
loader">,
+  MetaVarName<"">;
+
 // GNU Driver aliases
 
 def : Separate<["-"], "Xmicrosoft-visualc-tools-root">, 
Alias<_SLASH_vctoolsdir>;
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 65970fcdc9648..aa1909443e8cd 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -2641,6 +2641,10 @@ void CodeGenModule::ConstructAttributeList(StringRef 
Name,
 GetCPUAndFeaturesAttributes(CalleeInfo.getCalleeDecl(), FuncAttrs);
   }
 
+  // Mark functions that are replaceable by the loader.
+  if (CodeGenOpts.isLoaderReplaceableFunctionName(Name))
+FuncAttrs.addAttribute("loader-replaceable");
+
   // Collect attributes from arguments and return values.
   ClangToLLVMArgMapping IRFunctionArgs(getContext(), FI);
 
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 0c09daa17d37f..a08ff044add95 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -8578,6 +8578,12 @@ void Clang::AddClangCLArgs(const ArgList &Args, 
types::ID InputType,
 }
 A->claim();
   }
+
+  for (const auto &FuncOverride :
+   Args.getAllArgValues(options::OPT__SLASH_funcoverride)) {
+CmdArg

[clang-tools-extra] Add check 'cppcoreguidelines-use-enum-class' (PR #138282)

2025-05-09 Thread Philipp Jung via cfe-commits

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


[clang] [CIR] Implement folder for VecExtractOp (PR #139304)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits


@@ -1395,6 +1395,26 @@ LogicalResult cir::VecCreateOp::verify() {
   return success();
 }
 
+//===--===//
+// VecExtractOp
+//===--===//
+
+OpFoldResult cir::VecExtractOp::fold(FoldAdaptor adaptor) {
+  const auto vectorAttr =
+  llvm::dyn_cast_if_present(adaptor.getVec());
+  if (!vectorAttr)
+return {};
+
+  const auto indexAttr =
+  llvm::dyn_cast_if_present(adaptor.getIndex());
+  if (!indexAttr)
+return {};
+
+  const mlir::ArrayAttr elements = vectorAttr.getElts();
+  const int64_t index = indexAttr.getSInt();
+  return elements[index];

bcardosolopes wrote:

If the index is out of bounds we don't want to try accessing the elements. We 
have couple options here: (a) make the verifier look at input constants and 
verify out of bounds and/or (b) return `{}` in case it's not bound. If you add 
a verifier, than the check could be a helper function used by both it and 
`::fold`.

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


[clang] [CIR] Implement foldder for VecExtractOp (PR #139304)

2025-05-09 Thread Amr Hesham via cfe-commits

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

This change adds a folder for the VecExtractOp

Issue https://github.com/llvm/llvm-project/issues/136487

>From 6a21dc2a983094f61a54755454d12c45cf074c9d Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Fri, 9 May 2025 20:32:31 +0200
Subject: [PATCH] [CIR] Implement foldder for VecExtractOp

---
 clang/include/clang/CIR/Dialect/IR/CIROps.td  |  2 ++
 clang/lib/CIR/Dialect/IR/CIRDialect.cpp   | 20 +++
 .../Dialect/Transforms/CIRCanonicalize.cpp|  5 +++--
 .../CIR/Transforms/vector-extract-fold.cir| 20 +++
 4 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CIR/Transforms/vector-extract-fold.cir

diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td 
b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index 7aff5edb88167..f7f84bb715846 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -1995,6 +1995,8 @@ def VecExtractOp : CIR_Op<"vec.extract", [Pure,
   let assemblyFormat = [{
 $vec `[` $index `:` type($index) `]` attr-dict `:` qualified(type($vec))
   }];
+
+  let hasFolder = 1;
 }
 
 #endif // CLANG_CIR_DIALECT_IR_CIROPS_TD
diff --git a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp 
b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
index b131edaf403ed..9ddb1b1dd60b2 100644
--- a/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRDialect.cpp
@@ -1395,6 +1395,26 @@ LogicalResult cir::VecCreateOp::verify() {
   return success();
 }
 
+//===--===//
+// VecExtractOp
+//===--===//
+
+OpFoldResult cir::VecExtractOp::fold(FoldAdaptor adaptor) {
+  const auto vectorAttr =
+  llvm::dyn_cast_if_present(adaptor.getVec());
+  if (!vectorAttr)
+return {};
+
+  const auto indexAttr =
+  llvm::dyn_cast_if_present(adaptor.getIndex());
+  if (!indexAttr)
+return {};
+
+  const mlir::ArrayAttr elements = vectorAttr.getElts();
+  const int64_t index = indexAttr.getSInt();
+  return elements[index];
+}
+
 
//===--===//
 // TableGen'd op method definitions
 
//===--===//
diff --git a/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp 
b/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
index 3b4c7bc613133..798bc0dab9384 100644
--- a/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/CIRCanonicalize.cpp
@@ -125,9 +125,10 @@ void CIRCanonicalizePass::runOnOperation() {
 assert(!cir::MissingFeatures::complexRealOp());
 assert(!cir::MissingFeatures::complexImagOp());
 assert(!cir::MissingFeatures::callOp());
-// CastOp and UnaryOp are here to perform a manual `fold` in
+// CastOp, UnaryOp and VecExtractOp are here to perform a manual `fold` in
 // applyOpPatternsGreedily.
-if (isa(op))
+if (isa(
+op))
   ops.push_back(op);
   });
 
diff --git a/clang/test/CIR/Transforms/vector-extract-fold.cir 
b/clang/test/CIR/Transforms/vector-extract-fold.cir
new file mode 100644
index 0..5e1d6e1ddb629
--- /dev/null
+++ b/clang/test/CIR/Transforms/vector-extract-fold.cir
@@ -0,0 +1,20 @@
+// RUN: cir-opt %s -cir-canonicalize -o - | FileCheck %s
+
+!s32i = !cir.int
+
+module {
+  cir.func @fold_extract_vector_op_test() {
+%init = cir.alloca !s32i, !cir.ptr, ["e", init]
+%const_vec = cir.const #cir.const_vector<[#cir.int<1> : !s32i, #cir.int<2> 
: !s32i, #cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.vector<4 x !s32i>
+%index = cir.const #cir.int<1> : !s32i
+%ele = cir.vec.extract %const_vec[%index : !s32i] : !cir.vector<4 x !s32i>
+cir.store %ele, %init : !s32i, !cir.ptr
+cir.return
+  }
+
+  // CHECK: %[[INIT:.*]] = cir.alloca !s32i, !cir.ptr, ["e", init]
+  // CHECK: %[[VALUE:.*]] = cir.const #cir.int<2> : !s32i
+  // CHECK: cir.store %[[VALUE]], %[[INIT]] : !s32i, !cir.ptr
+}
+
+

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


[clang] [CIR] Implement folder for VecExtractOp (PR #139304)

2025-05-09 Thread Bruno Cardoso Lopes via cfe-commits

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


[clang] a783edf - [OpenACC][CIR] 'tile' lowering for combined constructs

2025-05-09 Thread via cfe-commits

Author: erichkeane
Date: 2025-05-09T11:54:16-07:00
New Revision: a783edf3db8eaa9797e25cbece7a71370f968d3d

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

LOG: [OpenACC][CIR] 'tile' lowering for combined constructs

This clause requires that we attach it to the 'loop', and can generate
variables, so this is the first loop clause to require that we properly
set up the insertion location.  This patch does so, as a part of
lowering 'tile' correctly.

Added: 


Modified: 
clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h
clang/test/CIR/CodeGenOpenACC/combined.cpp

Removed: 




diff  --git a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h 
b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h
index 3692560b06e6f..86997dd057aa3 100644
--- a/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h
+++ b/clang/lib/CIR/CodeGen/CIRGenOpenACCClause.h
@@ -138,7 +138,8 @@ class OpenACCClauseCIREmitter final
   template , U>>
   void applyToLoopOp(const OpenACCClause &c) {
-// TODO OpenACC: we have to set the insertion scope here correctly still.
+mlir::OpBuilder::InsertionGuard guardCase(builder);
+builder.setInsertionPoint(operation.loopOp);
 OpenACCClauseCIREmitter loopEmitter{
 operation.loopOp, cgf, builder, dirKind, dirLoc};
 loopEmitter.lastDeviceTypeValues = lastDeviceTypeValues;
@@ -448,10 +449,10 @@ class OpenACCClauseCIREmitter final
 
   operation.setTileForDeviceTypes(builder.getContext(),
   lastDeviceTypeValues, values);
+} else if constexpr (isCombinedType) {
+  applyToLoopOp(clause);
 } else {
-  // TODO: When we've implemented this for everything, switch this to an
-  // unreachable. Combined constructs remain.
-  return clauseNotImplemented(clause);
+  llvm_unreachable("Unknown construct kind in VisitTileClause");
 }
   }
 

diff  --git a/clang/test/CIR/CodeGenOpenACC/combined.cpp 
b/clang/test/CIR/CodeGenOpenACC/combined.cpp
index da8347a7f89c4..50c831c286e0e 100644
--- a/clang/test/CIR/CodeGenOpenACC/combined.cpp
+++ b/clang/test/CIR/CodeGenOpenACC/combined.cpp
@@ -252,4 +252,71 @@ extern "C" void acc_combined(int N) {
   // CHECK-NEXT: acc.yield
   // CHECK-NEXT: } loc
 
+  #pragma acc parallel loop tile(1, 2, 3)
+  for(unsigned I = 0; I < N; ++I)
+for(unsigned J = 0; J < N; ++J)
+  for(unsigned K = 0; K < N; ++K);
+  // CHECK-NEXT: acc.parallel combined(loop) {
+  // CHECK: %[[ONE_CONST:.*]] = arith.constant 1 : i64
+  // CHECK-NEXT: %[[TWO_CONST:.*]] = arith.constant 2 : i64
+  // CHECK-NEXT: %[[THREE_CONST:.*]] = arith.constant 3 : i64
+  // CHECK-NEXT: acc.loop combined(parallel) tile({%[[ONE_CONST]] : i64, 
%[[TWO_CONST]] : i64, %[[THREE_CONST]] : i64}) {
+  // CHECK: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.yield
+  // CHECK-NEXT: } loc
+  #pragma acc serial loop tile(2) device_type(radeon)
+  for(unsigned I = 0; I < N; ++I)
+for(unsigned J = 0; J < N; ++J)
+  for(unsigned K = 0; K < N; ++K);
+  // CHECK-NEXT: acc.serial combined(loop) {
+  // CHECK-NEXT: %[[TWO_CONST:.*]] = arith.constant 2 : i64
+  // CHECK-NEXT: acc.loop combined(serial) tile({%[[TWO_CONST]] : i64}) {
+  // CHECK: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.yield
+  // CHECK-NEXT: } loc
+  #pragma acc kernels loop tile(2) device_type(radeon) tile (1, *)
+  for(unsigned I = 0; I < N; ++I)
+for(unsigned J = 0; J < N; ++J)
+  for(unsigned K = 0; K < N; ++K);
+  // CHECK-NEXT: acc.kernels combined(loop) {
+  // CHECK-NEXT: %[[TWO_CONST:.*]] = arith.constant 2 : i64
+  // CHECK-NEXT: %[[ONE_CONST:.*]] = arith.constant 1 : i64
+  // CHECK-NEXT: %[[STAR_CONST:.*]] = arith.constant -1 : i64
+  // CHECK-NEXT: acc.loop combined(kernels) tile({%[[TWO_CONST]] : i64}, 
{%[[ONE_CONST]] : i64, %[[STAR_CONST]] : i64} [#acc.device_type]) {
+  // CHECK: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.terminator
+  // CHECK-NEXT: } loc
+  #pragma acc parallel loop tile(*) device_type(radeon, nvidia) tile (1, 2)
+  for(unsigned I = 0; I < N; ++I)
+for(unsigned J = 0; J < N; ++J)
+  for(unsigned K = 0; K < N; ++K);
+  // CHECK-NEXT: acc.parallel combined(loop) {
+  // CHECK-NEXT: %[[STAR_CONST:.*]] = arith.constant -1 : i64
+  // CHECK-NEXT: %[[ONE_CONST:.*]] = arith.constant 1 : i64
+  // CHECK-NEXT: %[[TWO_CONST:.*]] = arith.constant 2 : i64
+  // CHECK-NEXT: acc.loop combined(parallel) tile({%[[STAR_CONST]] : i64}, 
{%[[ONE_CONST]] : i64, %[[TWO_CONST]] : i64} [#acc.device_type], 
{%[[ONE_CONST]] : i64, %[[TWO_CONST]] : i64} [#acc.device_type]) {
+  // CHECK: acc.yield
+  // CHECK-NEXT: } loc
+  // CHECK-NEXT: acc.yield
+  // CHECK-NEXT: } loc
+  #pragma acc serial loop tile(1) device_type(radeon, nvidia) tile(2, 3) 
device_type(host) tile(*, *, *)
+  for(unsigned I = 0; I

[clang-tools-extra] Add check 'cppcoreguidelines-use-enum-class' (PR #138282)

2025-05-09 Thread Baranov Victor via cfe-commits


@@ -198,7 +203,7 @@ Changes in existing checks
   diagnosing designated initializers for ``std::array`` initializations.
 
 - Improved :doc:`modernize-use-ranges
-  ` check by updating suppress 
+  ` check by updating suppress

vbvictor wrote:

Unrelated change?
I'd suggest undoing it.

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


[clang-tools-extra] Add check 'cppcoreguidelines-use-enum-class' (PR #138282)

2025-05-09 Thread via cfe-commits


@@ -117,6 +117,11 @@ Improvements to clang-tidy
 New checks
 ^^
 
+- New :doc:`cppcoreguidelines-use-enum-class

EugeneZelenko wrote:

Should be after `bugprone-unintended-char-ostream-output`.

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


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

2025-05-09 Thread Reid Kleckner via cfe-commits


@@ -138,6 +138,12 @@ let Attributes = [Const, NoThrow, 
RequiredVectorWidth<256>], Features = "avx" in
   }
 }
 
+// PRFCHW
+let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in 
{

rnk wrote:

Looks like I actually had a pending change to go back to the mmx target 
feature, so my past self shared your concern. :) 

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


[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt updated 
https://github.com/llvm/llvm-project/pull/136828

>From d53d1ad252ad5c4c9db61ad03e8a606e195156d9 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Wed, 30 Apr 2025 22:26:59 -0700
Subject: [PATCH] [clang][PAC] add support for options parameter to __ptrauth

This PR adds support for an 'options' parameter for the __ptrauth
qualifier.

The initial version only exposes the authehntication modes:
 * "strip"
 * "sign-and-strip"
 * "sign-and-auth"

We also support parsing the options but not yet the implementation
 * "isa-pointer"
 * "authenticates-null-values"

The initial support for authentication mode controls exist to support
ABI changes over time, and as a byproduct support basic initial tests
for option parsing.
---
 clang/include/clang/Basic/Attr.td |   6 +-
 .../clang/Basic/DiagnosticParseKinds.td   |   4 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  18 +-
 clang/include/clang/Basic/LangOptions.h   |  11 +
 clang/lib/CodeGen/CGExprConstant.cpp  |  24 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +-
 clang/lib/Sema/SemaType.cpp   | 160 -
 clang/test/CodeGen/ptrauth-stripping.c| 327 ++
 clang/test/Parser/ptrauth-qualifier.c |   2 +-
 clang/test/Sema/ptrauth-qualifier-options.c   |  65 
 clang/test/Sema/ptrauth-qualifier.c   |  29 +-
 .../ptrauth-qualifier-constexpr-options.cpp   |  65 
 12 files changed, 688 insertions(+), 25 deletions(-)
 create mode 100644 clang/test/CodeGen/ptrauth-stripping.c
 create mode 100644 clang/test/Sema/ptrauth-qualifier-options.c
 create mode 100644 clang/test/SemaCXX/ptrauth-qualifier-constexpr-options.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 37c80ac90182c..1941bb2d1febc 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3595,9 +3595,9 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 
 def PointerAuth : TypeAttr {
   let Spellings = [CustomKeyword<"__ptrauth">];
-  let Args = [IntArgument<"Key">,
-  BoolArgument<"AddressDiscriminated", 1>,
-  IntArgument<"ExtraDiscriminator", 1>];
+  let Args = [IntArgument<"Key">, BoolArgument<"AddressDiscriminated", 1>,
+  IntArgument<"ExtraDiscriminator", 1>,
+  StringArgument<"Options", 1>];
   let Documentation = [PtrAuthDocs];
 }
 
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 3bbdc49946dac..8e0f818714c42 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1735,8 +1735,8 @@ def warn_pragma_unroll_cuda_value_in_parens : Warning<
   "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">,
   InGroup;
 
-def err_ptrauth_qualifier_bad_arg_count : Error<
-  "'__ptrauth' qualifier must take between 1 and 3 arguments">;
+def err_ptrauth_qualifier_bad_arg_count
+: Error<"'__ptrauth' qualifier must take between 1 and 4 arguments">;
 
 def warn_cuda_attr_lambda_position : Warning<
   "nvcc does not allow '__%0__' to appear after the parameter list in 
lambdas">,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 89b2d664d66a0..0ae2c09b1e4fb 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1045,6 +1045,23 @@ def err_ptrauth_extra_discriminator_invalid : Error<
   "invalid extra discriminator flag '%0'; '__ptrauth' requires a value between 
"
   "'0' and '%1'">;
 
+// __ptrauth qualifier options string
+def note_ptrauth_evaluating_options
+: Note<"options parameter evaluated to '%0'">;
+def err_ptrauth_invalid_option : Error<"'%0' options parameter %1">;
+def err_ptrauth_unknown_authentication_option
+: Error<"unknown '%0' authentication option '%1'">;
+def err_ptrauth_repeated_authentication_option
+: Error<"repeated '%0' authentication %select{mode|option}1%select{, prior 
mode was '%3'| '%2'}1">;
+def note_ptrauth_previous_authentication_option
+: Note<"previous '%0' authentication %select{mode|option}1">;
+def err_ptrauth_unexpected_option_end
+: Error<"unexpected end of options parameter for %0">;
+def err_ptrauth_option_unexpected_token
+: Error<"unexpected character '%0' in '%1' options">;
+def err_ptrauth_option_missing_comma
+: Error<"missing comma after '%1' option in '%0' qualifier">;
+
 /// main()
 // static main() is not an error in C, just in C++.
 def warn_static_main : Warning<"'main' should not be declared static">,
@@ -1735,7 +1752,6 @@ def err_static_assert_requirement_failed : Error<
 def note_expr_evaluates_to : Note<
   "expression evaluates to '%0 %1 %2'">;
 
-
 def subst_user_defined_msg : TextSubstitution<
   "%select{the message|the expression}0 in "
   "%select{a static assertion|this asm operand

[clang] [clang][PAC] add ptrauth intptr test (PR #139338)

2025-05-09 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt created 
https://github.com/llvm/llvm-project/pull/139338

Forgot to actually add the test as part of the `__ptrauth` on intptr PR

>From db7075b4855eca0dbb5c0d6c7184c193a975f405 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Fri, 9 May 2025 16:36:51 -0700
Subject: [PATCH] [clang][PAC] add ptrauth intptr test

---
 clang/test/Sema/ptrauth-intptr-qualifier.c | 35 ++
 1 file changed, 35 insertions(+)
 create mode 100644 clang/test/Sema/ptrauth-intptr-qualifier.c

diff --git a/clang/test/Sema/ptrauth-intptr-qualifier.c 
b/clang/test/Sema/ptrauth-intptr-qualifier.c
new file mode 100644
index 0..efce95795356e
--- /dev/null
+++ b/clang/test/Sema/ptrauth-intptr-qualifier.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify 
-fptrauth-intrinsics %s
+
+char __ptrauth(0) a;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'char' is invalid}}
+unsigned char __ptrauth(0) b;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'unsigned char' is invalid}}
+short __ptrauth(0) c;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'short' is invalid}}
+unsigned short __ptrauth(0) d;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'unsigned short' is invalid}}
+int __ptrauth(0) e;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'int' is invalid}}
+unsigned int __ptrauth(0) f;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'unsigned int' is invalid}}
+__int128_t __ptrauth(0) g;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; '__int128_t' (aka '__int128') is invalid}}
+unsigned short __ptrauth(0) h;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'unsigned short' is invalid}}
+
+unsigned long long __ptrauth(0) i;
+long long __ptrauth(0) j;
+__SIZE_TYPE__ __ptrauth(0) k;
+const unsigned long long __ptrauth(0) l;
+const long long __ptrauth(0) m;
+const __SIZE_TYPE__ __ptrauth(0) n;
+
+struct S1 {
+  __SIZE_TYPE__ __ptrauth(0) f0;
+};
+
+void x(unsigned long long __ptrauth(0) f0);
+// expected-error@-1{{parameter type may not be qualified with '__ptrauth'; 
type is '__ptrauth(0,0,0) unsigned long long'}}
+
+unsigned long long __ptrauth(0) y();
+// expected-error@-1{{return type may not be qualified with '__ptrauth'; type 
is '__ptrauth(0,0,0) unsigned long long'}}

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


[clang] [clang][PAC] add ptrauth intptr test (PR #139338)

2025-05-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Oliver Hunt (ojhunt)


Changes

Forgot to actually add the test as part of the `__ptrauth` on intptr PR

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


1 Files Affected:

- (added) clang/test/Sema/ptrauth-intptr-qualifier.c (+35) 


``diff
diff --git a/clang/test/Sema/ptrauth-intptr-qualifier.c 
b/clang/test/Sema/ptrauth-intptr-qualifier.c
new file mode 100644
index 0..efce95795356e
--- /dev/null
+++ b/clang/test/Sema/ptrauth-intptr-qualifier.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios -fsyntax-only -verify 
-fptrauth-intrinsics %s
+
+char __ptrauth(0) a;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'char' is invalid}}
+unsigned char __ptrauth(0) b;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'unsigned char' is invalid}}
+short __ptrauth(0) c;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'short' is invalid}}
+unsigned short __ptrauth(0) d;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'unsigned short' is invalid}}
+int __ptrauth(0) e;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'int' is invalid}}
+unsigned int __ptrauth(0) f;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'unsigned int' is invalid}}
+__int128_t __ptrauth(0) g;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; '__int128_t' (aka '__int128') is invalid}}
+unsigned short __ptrauth(0) h;
+// expected-error@-1{{'__ptrauth' qualifier only applies to pointer or pointer 
sized integer types; 'unsigned short' is invalid}}
+
+unsigned long long __ptrauth(0) i;
+long long __ptrauth(0) j;
+__SIZE_TYPE__ __ptrauth(0) k;
+const unsigned long long __ptrauth(0) l;
+const long long __ptrauth(0) m;
+const __SIZE_TYPE__ __ptrauth(0) n;
+
+struct S1 {
+  __SIZE_TYPE__ __ptrauth(0) f0;
+};
+
+void x(unsigned long long __ptrauth(0) f0);
+// expected-error@-1{{parameter type may not be qualified with '__ptrauth'; 
type is '__ptrauth(0,0,0) unsigned long long'}}
+
+unsigned long long __ptrauth(0) y();
+// expected-error@-1{{return type may not be qualified with '__ptrauth'; type 
is '__ptrauth(0,0,0) unsigned long long'}}

``




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


[clang] [clang][unittests] Fix a leak in SearchPathTest (PR #139335)

2025-05-09 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

I checked on the bot, this fixes the leak!
Thank you!

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


[clang] [clang][PAC] add ptrauth intptr test (PR #139338)

2025-05-09 Thread Oliver Hunt via cfe-commits

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


[clang] [clang][PAC] add support for options parameter to __ptrauth (PR #136828)

2025-05-09 Thread Oliver Hunt via cfe-commits

https://github.com/ojhunt updated 
https://github.com/llvm/llvm-project/pull/136828

>From 6f161d3699cac269f74376dc02697a7242b5 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Wed, 30 Apr 2025 22:26:59 -0700
Subject: [PATCH] [clang][PAC] add support for options parameter to __ptrauth

This PR adds support for an 'options' parameter for the __ptrauth
qualifier.

The initial version only exposes the authehntication modes:
 * "strip"
 * "sign-and-strip"
 * "sign-and-auth"

We also support parsing the options but not yet the implementation
 * "isa-pointer"
 * "authenticates-null-values"

The initial support for authentication mode controls exist to support
ABI changes over time, and as a byproduct support basic initial tests
for option parsing.
---
 clang/include/clang/Basic/Attr.td |   6 +-
 .../clang/Basic/DiagnosticParseKinds.td   |   4 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  18 +-
 clang/include/clang/Basic/LangOptions.h   |  11 +
 clang/lib/CodeGen/CGExprConstant.cpp  |  24 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +-
 clang/lib/Sema/SemaType.cpp   | 159 -
 clang/test/CodeGen/ptrauth-stripping.c| 327 ++
 clang/test/Parser/ptrauth-qualifier.c |   2 +-
 clang/test/Sema/ptrauth-qualifier-options.c   |  65 
 clang/test/Sema/ptrauth-qualifier.c   |  39 ++-
 .../ptrauth-qualifier-constexpr-options.cpp   |  65 
 12 files changed, 692 insertions(+), 30 deletions(-)
 create mode 100644 clang/test/CodeGen/ptrauth-stripping.c
 create mode 100644 clang/test/Sema/ptrauth-qualifier-options.c
 create mode 100644 clang/test/SemaCXX/ptrauth-qualifier-constexpr-options.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 37c80ac90182c..1941bb2d1febc 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3595,9 +3595,9 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 
 def PointerAuth : TypeAttr {
   let Spellings = [CustomKeyword<"__ptrauth">];
-  let Args = [IntArgument<"Key">,
-  BoolArgument<"AddressDiscriminated", 1>,
-  IntArgument<"ExtraDiscriminator", 1>];
+  let Args = [IntArgument<"Key">, BoolArgument<"AddressDiscriminated", 1>,
+  IntArgument<"ExtraDiscriminator", 1>,
+  StringArgument<"Options", 1>];
   let Documentation = [PtrAuthDocs];
 }
 
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 3bbdc49946dac..8e0f818714c42 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1735,8 +1735,8 @@ def warn_pragma_unroll_cuda_value_in_parens : Warning<
   "argument to '#pragma unroll' should not be in parentheses in CUDA C/C++">,
   InGroup;
 
-def err_ptrauth_qualifier_bad_arg_count : Error<
-  "'__ptrauth' qualifier must take between 1 and 3 arguments">;
+def err_ptrauth_qualifier_bad_arg_count
+: Error<"'__ptrauth' qualifier must take between 1 and 4 arguments">;
 
 def warn_cuda_attr_lambda_position : Warning<
   "nvcc does not allow '__%0__' to appear after the parameter list in 
lambdas">,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 89b2d664d66a0..0ae2c09b1e4fb 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1045,6 +1045,23 @@ def err_ptrauth_extra_discriminator_invalid : Error<
   "invalid extra discriminator flag '%0'; '__ptrauth' requires a value between 
"
   "'0' and '%1'">;
 
+// __ptrauth qualifier options string
+def note_ptrauth_evaluating_options
+: Note<"options parameter evaluated to '%0'">;
+def err_ptrauth_invalid_option : Error<"'%0' options parameter %1">;
+def err_ptrauth_unknown_authentication_option
+: Error<"unknown '%0' authentication option '%1'">;
+def err_ptrauth_repeated_authentication_option
+: Error<"repeated '%0' authentication %select{mode|option}1%select{, prior 
mode was '%3'| '%2'}1">;
+def note_ptrauth_previous_authentication_option
+: Note<"previous '%0' authentication %select{mode|option}1">;
+def err_ptrauth_unexpected_option_end
+: Error<"unexpected end of options parameter for %0">;
+def err_ptrauth_option_unexpected_token
+: Error<"unexpected character '%0' in '%1' options">;
+def err_ptrauth_option_missing_comma
+: Error<"missing comma after '%1' option in '%0' qualifier">;
+
 /// main()
 // static main() is not an error in C, just in C++.
 def warn_static_main : Warning<"'main' should not be declared static">,
@@ -1735,7 +1752,6 @@ def err_static_assert_requirement_failed : Error<
 def note_expr_evaluates_to : Note<
   "expression evaluates to '%0 %1 %2'">;
 
-
 def subst_user_defined_msg : TextSubstitution<
   "%select{the message|the expression}0 in "
   "%select{a static assertion|this asm operan

[clang] [clang-format] Fix a bug in annotating binary operator && (PR #138633)

2025-05-09 Thread Pierre Jolivet via cfe-commits

prj- wrote:

@owenca, I actually think that this introduced a regression that was previously 
fixed in the nightly snapshot of `clang-format-21`.
With `clang-format-20`:
```
$ cat foo.cpp
template 
using invoke_result_t = typename std::result_of::type;
$ clang-format-20 foo.cpp
template 
using invoke_result_t = typename std::result_of::type;
```
With `clang-format-21` prior to 
`++20250509052510+a6385a87a2e5-1~exp1~20250509172712.2830`, e.g., 
`++2025050520%2B21aa7b8138a1-1\~exp1\~2025050702.2812`:
```
$ clang-format-21 foo.cpp
template 
using invoke_result_t = typename std::result_of::type;
```
But now, we are back to the wrong formatting of `clang-format-20`.

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


[clang] [clang][bytecode][NFC] Remove unused function (PR #139355)

2025-05-09 Thread Timm Baeder via cfe-commits

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

None

>From a7aba9984f3a01d07d8e90c64bea7d9c9fd328a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sat, 10 May 2025 07:19:37 +0200
Subject: [PATCH] [clang][bytecode][NFC] Remove unused function

---
 clang/lib/AST/ByteCode/Interp.cpp | 9 -
 clang/lib/AST/ByteCode/Interp.h   | 3 ---
 2 files changed, 12 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 9c041ad782af9..43f8d156589b6 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -942,15 +942,6 @@ bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer 
&This) {
   return false;
 }
 
-bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD) {
-  if (!MD->isPureVirtual())
-return true;
-  const SourceInfo &E = S.Current->getSource(OpPC);
-  S.FFDiag(E, diag::note_constexpr_pure_virtual_call, 1) << MD;
-  S.Note(MD->getLocation(), diag::note_declared_at);
-  return false;
-}
-
 bool CheckFloatResult(InterpState &S, CodePtr OpPC, const Floating &Result,
   APFloat::opStatus Status, FPOptions FPO) {
   // [expr.pre]p4:
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index c89e68a0c27ba..a13fd6c1f1daa 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -114,9 +114,6 @@ bool CheckCallDepth(InterpState &S, CodePtr OpPC);
 /// Checks the 'this' pointer.
 bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This);
 
-/// Checks if a method is pure virtual.
-bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD);
-
 /// Checks if all the arguments annotated as 'nonnull' are in fact not null.
 bool CheckNonNullArgs(InterpState &S, CodePtr OpPC, const Function *F,
   const CallExpr *CE, unsigned ArgSize);

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


[clang] [clang][bytecode][NFC] Remove unused function (PR #139355)

2025-05-09 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes



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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (-9) 
- (modified) clang/lib/AST/ByteCode/Interp.h (-3) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 9c041ad782af9..43f8d156589b6 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -942,15 +942,6 @@ bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer 
&This) {
   return false;
 }
 
-bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD) {
-  if (!MD->isPureVirtual())
-return true;
-  const SourceInfo &E = S.Current->getSource(OpPC);
-  S.FFDiag(E, diag::note_constexpr_pure_virtual_call, 1) << MD;
-  S.Note(MD->getLocation(), diag::note_declared_at);
-  return false;
-}
-
 bool CheckFloatResult(InterpState &S, CodePtr OpPC, const Floating &Result,
   APFloat::opStatus Status, FPOptions FPO) {
   // [expr.pre]p4:
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index c89e68a0c27ba..a13fd6c1f1daa 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -114,9 +114,6 @@ bool CheckCallDepth(InterpState &S, CodePtr OpPC);
 /// Checks the 'this' pointer.
 bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This);
 
-/// Checks if a method is pure virtual.
-bool CheckPure(InterpState &S, CodePtr OpPC, const CXXMethodDecl *MD);
-
 /// Checks if all the arguments annotated as 'nonnull' are in fact not null.
 bool CheckNonNullArgs(InterpState &S, CodePtr OpPC, const Function *F,
   const CallExpr *CE, unsigned ArgSize);

``




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


[clang-tools-extra] [clangd] Add tweak to add pure virtual overrides (PR #139348)

2025-05-09 Thread Marco Maia via cfe-commits

marcogmaia wrote:

@HighCommander4 could you please take a look here, or forward it to anyone who 
can?

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