[clang-tools-extra] [clang-tidy] support static analyzer checker configuration in `--verify-config` (PR #109523)

2024-09-21 Thread via cfe-commits


@@ -98,6 +98,10 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Improved :program:`clang-tidy`'s `--verify-config` flag by adding support for

EugeneZelenko wrote:

I think will be good idea to put this entry before `run-clang-tidy.py` one as 
about main application.

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


[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread Rainer Orth via cfe-commits

rorth wrote:

No, that doesn't exist.  The failure will occur on any non-x86 build configure 
with `-DLLVM_TARGETS_TO_BUILD=`.

AFAICS the tests just need
```
// REQUIRES: x86-registered-target
```

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


[clang] [C++20][Modules] Restore inliness of constexpr/consteval functions defined in-class (PR #109470)

2024-09-21 Thread via cfe-commits


@@ -9760,8 +9760,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   if (getLangOpts().CPlusPlus) {
 // The rules for implicit inlines changed in C++20 for methods and friends
 // with an in-class definition (when such a definition is not attached to
-// the global module).  User-specified 'inline' overrides this (set when
-// the function decl is created above).
+// the global module). This does not affect declarations, that are already
+// inline, for example due being declared `inline` or `consteval`

cor3ntin wrote:

```suggestion
// the global module). This does not affect declarations that are already
// inline (whether explicitly or implicitly by being declared constexpr, 
etc)
```

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


[clang] [C++20][Modules] Restore inliness of constexpr/consteval functions defined in-class (PR #109470)

2024-09-21 Thread via cfe-commits

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


[clang] [C++20][Modules] Restore inliness of constexpr/consteval functions defined in-class (PR #109470)

2024-09-21 Thread via cfe-commits

https://github.com/cor3ntin commented:

I think this looks reasonable but I'd like @iains or @ChuanqiXu9 to review too.
Can you add a changelog entry?

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


[clang] [clang] fix the unexpected control flow in ParseTentative.cpp (PR #109298)

2024-09-21 Thread via cfe-commits

cor3ntin wrote:

> @cor3ntin See the discussion on #95917. This is likely effectively dead code, 
> but nobody is certain enough of that to delete it outright...

The original issue seems to suggest the code path can be used on invalid code 
such as 

struct X {
};
void foo() {
  X;
}
```

(ie a bogus template-name that is not annotated)
We might test that - and see that the errors make a bit of sense/don't regress

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


[clang] f5f61c8 - Updated and renamed README.txt to README.md (#106198)

2024-09-21 Thread via cfe-commits

Author: Tarık Çelik
Date: 2024-09-21T09:58:42+02:00
New Revision: f5f61c802e9bb9504082f9e0f41926f5d2ab7115

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

LOG: Updated and renamed README.txt to README.md (#106198)

Co-authored-by: Tarık Çelik 

Added: 
clang/README.md

Modified: 


Removed: 
clang/README.txt



diff  --git a/clang/README.md b/clang/README.md
new file mode 100644
index 00..b98182d8a3f684
--- /dev/null
+++ b/clang/README.md
@@ -0,0 +1,25 @@
+# C language Family Front-end
+
+Welcome to Clang. 
+
+This is a compiler front-end for the C family of languages (C, C++ and 
Objective-C) which is built as part of the LLVM compiler infrastructure project.
+
+Unlike many other compiler frontends, Clang is useful for a number of things 
beyond just compiling code: we intend for Clang to be host to a number of 
diff erent   source-level tools. One example of this is the Clang 
Static Analyzer.
+
+If you're interested in more (including how to build Clang) it is best to read 
the relevant websites. Here are some pointers:
+
+* Information on Clang:  http://clang.llvm.org/
+
+* Building and using Clang:http://clang.llvm.org/get_started.html
+
+* Clang Static Analyzer:http://clang-analyzer.llvm.org/
+
+* Information on the LLVM project:http://llvm.org/
+
+* If you have questions or comments about Clang, a great place to disucss them 
is on the Clang forums:
+  
+  [Clang Frontend - LLVM Discussion 
Forums](https://discourse.llvm.org/c/clang/)
+
+* If you find a bug in Clang, please file it in the LLVM bug tracker:
+  
+https://github.com/llvm/llvm-project/issues

diff  --git a/clang/README.txt b/clang/README.txt
deleted file mode 100644
index 477f720b193fbd..00
--- a/clang/README.txt
+++ /dev/null
@@ -1,26 +0,0 @@
-//===--===//
-// C Language Family Front-end
-//===--===//
-
-Welcome to Clang.  This is a compiler front-end for the C family of languages
-(C, C++, Objective-C, and Objective-C++) which is built as part of the LLVM
-compiler infrastructure project.
-
-Unlike many other compiler frontends, Clang is useful for a number of things
-beyond just compiling code: we intend for Clang to be host to a number of
-
diff erent source-level tools.  One example of this is the Clang Static 
Analyzer.
-
-If you're interested in more (including how to build Clang) it is best to read
-the relevant web sites.  Here are some pointers:
-
-Information on Clang: http://clang.llvm.org/
-Building and using Clang: http://clang.llvm.org/get_started.html
-Clang Static Analyzer:http://clang-analyzer.llvm.org/
-Information on the LLVM project:  http://llvm.org/
-
-If you have questions or comments about Clang, a great place to discuss them is
-on the Clang forums:
-  https://discourse.llvm.org/c/clang/
-
-If you find a bug in Clang, please file it in the LLVM bug tracker:
-  https://github.com/llvm/llvm-project/issues



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


[clang] [C++20][Modules] Restore inliness of constexpr/consteval functions defined in-class (PR #109470)

2024-09-21 Thread via cfe-commits

https://github.com/tomasz-kaminski-sonarsource updated 
https://github.com/llvm/llvm-project/pull/109470

>From 6ff9964b7180cc9279c2742b14f69cc966a027a1 Mon Sep 17 00:00:00 2001
From: Tomasz Kaminski 
Date: Fri, 20 Sep 2024 17:21:33 +0200
Subject: [PATCH 1/2] [C++20][Modules] Restore inliness of constexpr/consteval
 functions defined in-class

This correct issue, when the functions declared as `constexpr` are `consteval`,
are not considered to be inline (`isInlined()` is false) when defined inside 
class
attached to named module:
```c++
export module mod;

struct Clazz {
  constexpr void f1() { } // non-inline
  constexpr void f2();
  friend constexpr void f3() {} // non-inline
};

constexpr void Clazz::f3() {} // inline
```

This conflicts with [decl.constexpr] p1:
> A function or static data member declared with the constexpr or consteval
  specifier on its first declaration is implicitly an inline function or
  variable ([dcl.inline]).
  If any declaration of a function or function template has a constexpr or
  consteval specifier, then all its declarations shall contain the same
  specifier/)

This regression was introduced by 
https://github.com/llvm/llvm-project/commit/97af17c5,
where the inline of such function was accidentally removed
The corresponding wording in [class.friend] and p6 [class.mfct] p1 uses "if" 
and not "if and only if",
thus does not imply that these are only cases where such functions are inline.
---
 clang/lib/Sema/SemaDecl.cpp   | 14 +++
 .../test/CXX/class/class.friend/p7-cxx20.cpp  | 38 ---
 clang/test/CXX/class/class.mfct/p1-cxx20.cpp  | 30 +--
 3 files changed, 67 insertions(+), 15 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index de8805e15bc750..0ea99c43037e5e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9760,8 +9760,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   if (getLangOpts().CPlusPlus) {
 // The rules for implicit inlines changed in C++20 for methods and friends
 // with an in-class definition (when such a definition is not attached to
-// the global module).  User-specified 'inline' overrides this (set when
-// the function decl is created above).
+// the global module). This does not affect declarations, that are already
+// inline, for example due being declared `inline` or `consteval`
 // FIXME: We need a better way to separate C++ standard and clang modules.
 bool ImplicitInlineCXX20 = !getLangOpts().CPlusPlusModules ||
NewFD->isConstexpr() || NewFD->isConsteval() ||
@@ -9772,14 +9772,14 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
 bool isVirtual = D.getDeclSpec().isVirtualSpecified();
 bool hasExplicit = D.getDeclSpec().hasExplicitSpecifier();
 isFriend = D.getDeclSpec().isFriendSpecified();
-if (isFriend && !isInline && D.isFunctionDefinition()) {
+if (ImplicitInlineCXX20 && isFriend && D.isFunctionDefinition()) {
   // Pre-C++20 [class.friend]p5
   //   A function can be defined in a friend declaration of a
   //   class . . . . Such a function is implicitly inline.
   // Post C++20 [class.friend]p7
   //   Such a function is implicitly an inline function if it is attached
   //   to the global module.
-  NewFD->setImplicitlyInline(ImplicitInlineCXX20);
+  NewFD->setImplicitlyInline();
 }
 
 // If this is a method defined in an __interface, and is not a constructor
@@ -10083,15 +10083,15 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator 
&D, DeclContext *DC,
   break;
 }
 
-if (isa(NewFD) && DC == CurContext &&
-D.isFunctionDefinition() && !isInline) {
+if (ImplicitInlineCXX20 && isa(NewFD) && DC == CurContext &&
+D.isFunctionDefinition()) {
   // Pre C++20 [class.mfct]p2:
   //   A member function may be defined (8.4) in its class definition, in
   //   which case it is an inline member function (7.1.2)
   // Post C++20 [class.mfct]p1:
   //   If a member function is attached to the global module and is defined
   //   in its class definition, it is inline.
-  NewFD->setImplicitlyInline(ImplicitInlineCXX20);
+  NewFD->setImplicitlyInline();
 }
 
 if (!isFriend && SC != SC_None) {
diff --git a/clang/test/CXX/class/class.friend/p7-cxx20.cpp 
b/clang/test/CXX/class/class.friend/p7-cxx20.cpp
index 8843d55910ea2d..0ce77b353c2499 100644
--- a/clang/test/CXX/class/class.friend/p7-cxx20.cpp
+++ b/clang/test/CXX/class/class.friend/p7-cxx20.cpp
@@ -46,14 +46,42 @@ module;
 export module M;
 
 class Z {
-  friend void z(){};
+  friend void z1(){};
 };
+
+class Inline {
+  friend inline void z2(){};
+};
+
+class Constexpr {
+  friend constexpr void z3(){};
+};
+
+class Consteval {
+  friend consteval void z4(){};
+};
+
 // CHECK-MOD: |-CXXRecordDecl {{.*}} <.{{/|?}}header.h:2:1, line:

[clang] [llvm] [clang][wasm] Replace the target integer sub saturate intrinsics with the equivalent generic `__builtin_elementwise_sub_sat` intrinsics (PR #109405)

2024-09-21 Thread Simon Pilgrim via cfe-commits

https://github.com/RKSimon updated 
https://github.com/llvm/llvm-project/pull/109405

>From 657f1c0369a2befecdca26235f231bfd9ab55e9b Mon Sep 17 00:00:00 2001
From: Simon Pilgrim 
Date: Fri, 20 Sep 2024 12:36:27 +0100
Subject: [PATCH 1/2] [clang][wasm] Replace the target integer sub saturate
 intrinsics with the equivalent generic `__builtin_elementwise_sub_sat`
 intrinsics

Remove the Intrinsic::wasm_sub_sat_signed/wasm_sub_sat_unsigned entries and 
just use sub_sat_s/sub_sat_u directly
---
 .../clang/Basic/BuiltinsWebAssembly.def   |  5 
 clang/lib/CodeGen/CGBuiltin.cpp   | 22 --
 clang/lib/Headers/wasm_simd128.h  |  8 ++---
 clang/test/CodeGen/builtins-wasm.c| 30 +--
 llvm/include/llvm/IR/IntrinsicsWebAssembly.td |  8 -
 .../WebAssembly/WebAssemblyISelLowering.cpp   |  4 +--
 .../WebAssembly/WebAssemblyInstrSIMD.td   |  6 ++--
 .../CodeGen/WebAssembly/simd-intrinsics.ll| 16 +-
 8 files changed, 17 insertions(+), 82 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 90441a5d500120..ab480369b3820e 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -68,11 +68,6 @@ TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, 
"LLid", "nc", "nontrappi
 // SIMD builtins
 TARGET_BUILTIN(__builtin_wasm_swizzle_i8x16, "V16ScV16ScV16Sc", "nc", 
"simd128")
 
-TARGET_BUILTIN(__builtin_wasm_sub_sat_s_i8x16, "V16ScV16ScV16Sc", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_sub_sat_u_i8x16, "V16UcV16UcV16Uc", "nc", 
"simd128")
-TARGET_BUILTIN(__builtin_wasm_sub_sat_s_i16x8, "V8sV8sV8s", "nc", "simd128")
-TARGET_BUILTIN(__builtin_wasm_sub_sat_u_i16x8, "V8UsV8UsV8Us", "nc", "simd128")
-
 TARGET_BUILTIN(__builtin_wasm_abs_i8x16, "V16ScV16Sc", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_abs_i16x8, "V8sV8s", "nc", "simd128")
 TARGET_BUILTIN(__builtin_wasm_abs_i32x4, "V4iV4i", "nc", "simd128")
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 3d1138b7773853..78b432474ba3b7 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -21443,28 +21443,6 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_swizzle);
 return Builder.CreateCall(Callee, {Src, Indices});
   }
-  case WebAssembly::BI__builtin_wasm_sub_sat_s_i8x16:
-  case WebAssembly::BI__builtin_wasm_sub_sat_u_i8x16:
-  case WebAssembly::BI__builtin_wasm_sub_sat_s_i16x8:
-  case WebAssembly::BI__builtin_wasm_sub_sat_u_i16x8: {
-unsigned IntNo;
-switch (BuiltinID) {
-case WebAssembly::BI__builtin_wasm_sub_sat_s_i8x16:
-case WebAssembly::BI__builtin_wasm_sub_sat_s_i16x8:
-  IntNo = Intrinsic::wasm_sub_sat_signed;
-  break;
-case WebAssembly::BI__builtin_wasm_sub_sat_u_i8x16:
-case WebAssembly::BI__builtin_wasm_sub_sat_u_i16x8:
-  IntNo = Intrinsic::wasm_sub_sat_unsigned;
-  break;
-default:
-  llvm_unreachable("unexpected builtin ID");
-}
-Value *LHS = EmitScalarExpr(E->getArg(0));
-Value *RHS = EmitScalarExpr(E->getArg(1));
-Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
-return Builder.CreateCall(Callee, {LHS, RHS});
-  }
   case WebAssembly::BI__builtin_wasm_abs_i8x16:
   case WebAssembly::BI__builtin_wasm_abs_i16x8:
   case WebAssembly::BI__builtin_wasm_abs_i32x4:
diff --git a/clang/lib/Headers/wasm_simd128.h b/clang/lib/Headers/wasm_simd128.h
index b1bef7097800b9..08e39bf1a79b4f 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -997,12 +997,12 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i8x16_sub(v128_t __a,
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_sub_sat(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_sat_s_i8x16((__i8x16)__a, (__i8x16)__b);
+  return (v128_t)__builtin_elementwise_sub_sat((__i8x16)__a, (__i8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_u8x16_sub_sat(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_sat_u_i8x16((__u8x16)__a, (__u8x16)__b);
+  return (v128_t)__builtin_elementwise_sub_sat((__u8x16)__a, (__u8x16)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i8x16_min(v128_t __a,
@@ -1083,12 +1083,12 @@ static __inline__ v128_t __DEFAULT_FN_ATTRS 
wasm_i16x8_sub(v128_t __a,
 
 static __inline__ v128_t __DEFAULT_FN_ATTRS wasm_i16x8_sub_sat(v128_t __a,
v128_t __b) {
-  return (v128_t)__builtin_wasm_sub_sat_s_i16x8((__i16x8)__a, (__i16x8)__b);
+  return (v128_t)__builtin_elementwise_sub_sat((__i16x8)__a, (__i16x8)__b);
 }
 
 static __inline__ v128_t __DEFAULT_FN_A

[clang-tools-extra] [modularize] Avoid repeated hash lookups (NFC) (PR #109508)

2024-09-21 Thread Nikita Popov via cfe-commits


@@ -508,13 +508,11 @@ class EntityMap : public std::map> {
   // Sort contents.
   llvm::sort(H->second);
 
-  // Check whether we've seen this header before.
-  auto KnownH = AllHeaderContents.find(H->first);
-  if (KnownH == AllHeaderContents.end()) {
-// We haven't seen this header before; record its contents.
-AllHeaderContents.insert(*H);
+  // Record this header and its contents if we haven't seen it before.
+  auto [KnownH, Inserted] =
+  AllHeaderContents.try_emplace(H->first, H->second);

nikic wrote:

```suggestion
  AllHeaderContents.insert(*H);
```
Maybe?

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


[clang] [CLANG][AArch64] Add the modal 8 bit floating-point scalar type (PR #97277)

2024-09-21 Thread via cfe-commits

https://github.com/CarolineConcatto updated 
https://github.com/llvm/llvm-project/pull/97277

>From edf2f6c977d06627f7a752a0128ffcb04c082c38 Mon Sep 17 00:00:00 2001
From: Caroline Concatto 
Date: Mon, 24 Jun 2024 09:59:24 +
Subject: [PATCH] [CLANG][AArch64] Add the  modal 8 bit floating-point scalar
 type

ARM ACLE PR#323[1] adds new modal types for 8-bit floating point intrinsic.

>From the PR#323:
```
ACLE defines the `__mfp8` type, which can be used for the E5M2 and E4M3
8-bit floating-point formats. It is a storage and interchange only type
with no arithmetic operations other than intrinsic calls.


The type should be an opaque type and its format in undefined in Clang.
Only defined in the backend by a status/format register, for AArch64 the FPMR.

This patch is an attempt to the add the MFloat8_t scalar type.
It has a parser and codegen for the new scalar type.

The patch it is lowering to and 8bit unsigned as it has no format.
But maybe we should add another opaque type.

[1]  https://github.com/ARM-software/acle/pull/323
---
 clang/include/clang/AST/Type.h|  7 ++
 .../clang/Basic/AArch64SVEACLETypes.def   |  9 ++
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/include/clang/Basic/Specifiers.h|  1 +
 clang/include/clang/Basic/TargetInfo.h|  4 +
 clang/include/clang/Basic/TokenKinds.def  |  1 +
 clang/include/clang/Sema/DeclSpec.h   |  2 +
 .../include/clang/Serialization/ASTBitCodes.h |  2 +-
 clang/lib/AST/ASTContext.cpp  | 13 ++-
 clang/lib/AST/ItaniumMangle.cpp   |  6 ++
 clang/lib/AST/Type.cpp| 25 -
 clang/lib/Basic/TargetInfo.cpp|  1 +
 clang/lib/Basic/Targets/AArch64.cpp   |  6 ++
 clang/lib/Basic/Targets/AArch64.h |  3 +
 clang/lib/CodeGen/CGDebugInfo.cpp |  7 ++
 clang/lib/CodeGen/CodeGenTypes.cpp|  6 +-
 clang/lib/Parse/ParseDecl.cpp |  7 ++
 clang/lib/Parse/ParseExpr.cpp |  1 +
 clang/lib/Parse/ParseExprCXX.cpp  |  4 +
 clang/lib/Parse/ParseTentative.cpp|  2 +
 clang/lib/Sema/DeclSpec.cpp   |  3 +
 clang/lib/Sema/SemaCast.cpp   |  8 ++
 clang/lib/Sema/SemaExpr.cpp   |  6 ++
 clang/lib/Sema/SemaTemplateVariadic.cpp   |  1 +
 clang/lib/Sema/SemaType.cpp   |  6 +-
 clang/test/AST/arm-mfp8.cpp   | 94 +++
 clang/test/CodeGen/arm-mfp8.c | 26 +
 clang/test/Modules/no-external-type-id.cppm   |  2 +-
 clang/test/Sema/arm-mfp8.c| 11 +++
 clang/test/Sema/arm-mfp8.cpp  | 35 +++
 30 files changed, 293 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/AST/arm-mfp8.cpp
 create mode 100644 clang/test/CodeGen/arm-mfp8.c
 create mode 100644 clang/test/Sema/arm-mfp8.c
 create mode 100644 clang/test/Sema/arm-mfp8.cpp

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index dc87b84153e74a..195d471bb155fb 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2644,6 +2644,8 @@ class alignas(TypeAlignment) Type : public 
ExtQualsTypeCommonBase {
   bool isQueueT() const;// OpenCL queue_t
   bool isReserveIDT() const;// OpenCL reserve_id_t
 
+  bool isArmMFloat8Type() const; // AARCH64_OPAQUE_TYPE
+
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
   bool is##Id##Type() const;
 #include "clang/Basic/OpenCLExtensionTypes.def"
@@ -8312,6 +8314,11 @@ inline bool Type::isBitIntType() const {
   return isa(CanonicalType);
 }
 
+// AARCH64_OPAQUE_TYPE
+inline bool Type::isArmMFloat8Type() const {
+  return isSpecificBuiltinType(BuiltinType::ArmMFloat8);
+}
+
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
   inline bool Type::is##Id##Type() const { \
 return isSpecificBuiltinType(BuiltinType::Id); \
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def 
b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 55ed9c36f6c5cd..53644905b789b7 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -97,6 +97,12 @@
   SVE_TYPE(Name, Id, SingletonId)
 #endif
 
+#ifndef AARCH64_OPAQUE_TYPE
+#define AARCH64_OPAQUE_TYPE(Name, MangledName, Id, SingletonId, NumEls, \
+ElBits, NF) \
+  SVE_TYPE(Name, Id, SingletonId)
+#endif
+
 //===- Vector point types ---===//
 
 SVE_VECTOR_TYPE_INT("__SVInt8_t",  "__SVInt8_t",  SveInt8,  SveInt8Ty, 16,  8, 
1, true)
@@ -181,6 +187,8 @@ SVE_PREDICATE_TYPE_ALL("__clang_svboolx4_t", "svboolx4_t", 
SveBoolx4, SveBoolx4T
 
 SVE_OPAQUE_TYPE("__SVCount_t", "__SVCount_t", SveCount, SveCountTy)
 
+AARCH64_OPAQUE_TYPE("__MFloat8_t", "__MFloat8_t", ArmMFloat8, ArmMFloat8Ty, 1, 
8, 1)
+
 #undef SVE_VECTOR_TYPE
 #undef SVE_VECTOR_TYPE_BFLOAT
 #undef SVE_VECTOR_

[clang] [clang-format] Fix regression with BlockIndent of Braced Initializers (PR #108717)

2024-09-21 Thread Owen Pan via cfe-commits


@@ -9395,6 +9398,9 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
   "fooo(new FOO::BA(\n"
   "XXXZ()));",
   Style);
+  verifyFormat("aaa const aa{\n"
+   "a(aaa, )};",
+   Style);

owenca wrote:

Ditto.

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


[clang] [clang-format] Fix regression with BlockIndent of Braced Initializers (PR #108717)

2024-09-21 Thread Owen Pan via cfe-commits


@@ -9336,6 +9336,9 @@ TEST_F(FormatTest, AlignsAfterOpenBracket) {
"ccc(a, //\n"
"b));",
Style);
+  verifyFormat("aaa const aa{\n"
+   "a(aaa, )};",
+   Style);

owenca wrote:

This test seems irrelevant and IMO ought to be deleted.

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


[clang] [clang-format] Fix regression with BlockIndent of Braced Initializers (PR #108717)

2024-09-21 Thread Owen Pan via cfe-commits


@@ -348,6 +348,13 @@ bool ContinuationIndenter::canBreak(const LineState 
&State) {
 }
   }
 
+  // Don't allow breaking before a closing right brace of a block-indented
+  // braced list initializer if there was not already a break.

owenca wrote:

```suggestion
  // Don't allow breaking before a closing brace of a block-indented braced list
  // initializer if there isn't already a break.
```

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


[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread Rainer Orth via cfe-commits

rorth wrote:

Seems so, yes.  Could also be an endianess thing.  I know nothing about this 
test, though.

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


[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread Timm Baeder via cfe-commits

tbaederr wrote:

But if that was the entire problem, the one in `test/SemaCXX/` would've failed 
before or not?

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


[clang] [libclang/python] Fix evaluation of the unsigned enumeration values, #108766 (PR #108769)

2024-09-21 Thread Vlad Serebrennikov via cfe-commits


@@ -1952,6 +1952,8 @@ def enum_value(self):
 underlying_type = self.type
 if underlying_type.kind == TypeKind.ENUM:
 underlying_type = underlying_type.get_declaration().enum_type
+if underlying_type.kind == TypeKind.ELABORATED:

Endilll wrote:

Hm, this seems to be a regression in Clang 16, not too long ago: 
https://godbolt.org/z/bEno8Pdhb

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


[clang] [BoundsSafety][NFC] Specify taking address of a variable referred to by '__counted_by' is forbidden (PR #106147)

2024-09-21 Thread Henrik G. Olsson via cfe-commits


@@ -759,7 +759,24 @@ relationship must hold even after any of these related 
variables are updated. To
 this end, the model requires that assignments to ``buf`` and ``count`` must be
 side by side, with no side effects between them. This prevents ``buf`` and
 ``count`` from temporarily falling out of sync due to updates happening at a
-distance.
+distance. In addition, taking address of ``count`` is not allowed in order to 
+prevent the programmers from updating the ``count`` through the pointer, which
+will evade the necessary checks to make ``count`` and ``buf`` in sync.
+
+.. code-block:: c
+
+   struct counted_buf {
+  int *__counted_by(count) buf;
+  size_t count;
+   };
+
+   void foo(struct counted_buf *p) {
+  int *pointer_to_count = &p->count; // error: variable referred to by
+  // '__counted_by' cannot be pointed to by any other variable; exception 
is
+  // when the pointer is passed as a compatible argument to a function.

hnrklssn wrote:

I think we should define what a compatible argument is

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


[clang] [BoundsSafety][NFC] Specify taking address of a variable referred to by '__counted_by' is forbidden (PR #106147)

2024-09-21 Thread Henrik G. Olsson via cfe-commits

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


[clang] [BoundsSafety][NFC] Specify taking address of a variable referred to by '__counted_by' is forbidden (PR #106147)

2024-09-21 Thread Henrik G. Olsson via cfe-commits

https://github.com/hnrklssn commented:

Overall looks good, just a small clarification

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


[clang] [Clang][Sema] Refactor collection of multi-level template argument lists (PR #106585)

2024-09-21 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

This change broke building Qt.

A small standalone reproducer: https://martin.st/temp/qtgui-preproc2.cpp
To inspect:
```
$ clang -target armv7-w64-mingw32 -w -c qtgui-preproc2.cpp -o out.o -std=gnu++17
$ llvm-nm out.o | grep 
_ZN19QWindowSystemHelperIN22QWindowSystemInterface20AsynchronousDeliveryEE11handleEventIN29QWindowSystemInterfacePrivate10LeaveEventEJP7QWindowEEEbDpT0_
 U 
_ZN19QWindowSystemHelperIN22QWindowSystemInterface20AsynchronousDeliveryEE11handleEventIN29QWindowSystemInterfacePrivate10LeaveEventEJP7QWindowEEEbDpT0_
```
This symbol is undefined, and linking later fails as this is undefined (but 
this object file should define it).
With Clang from before this commit, we get this result instead:
```
$ llvm-nm out.o | grep 
_ZN19QWindowSystemHelperIN22QWindowSystemInterface20AsynchronousDeliveryEE11handleEventIN29QWindowSystemInterfacePrivate10LeaveEventEJP7QWindowEEEbDpT0_
 T 
_ZN19QWindowSystemHelperIN22QWindowSystemInterface20AsynchronousDeliveryEE11handleEventIN29QWindowSystemInterfacePrivate10LeaveEventEJP7QWindowEEEbDpT0_
```

A fullblown reproducer on Linux is also this:
```
$ git clone https://github.com/qt/qtbase
$ cd qtbase
$ git checkout v6.8.0-beta4
$ mkdir build
$ cd build
$ cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang 
-DCMAKE_CXX_COMPILER=clang++ -DINPUT_opengl=no
$ ninja
[1/342] Linking CXX shared library lib/libQt6Gui.so.6.8.0
FAILED: lib/libQt6Gui.so.6.8.0
[...]
/usr/bin/ld: src/gui/CMakeFiles/Gui.dir/kernel/qwindowsysteminterface.cpp.o: in 
function `QWindowSystemInterface::handleEnterLeaveEvent(QWindow*, QWindow*, 
QPointF const&, QPointF const&)':
qwindowsysteminterface.cpp:(.text+0x4f6): undefined reference to `bool 
QWindowSystemHelper::handleEvent(QWindow*)'
```

I'll go ahead and revert this change to unbreak things.

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


[clang] 1818ca5 - Revert "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585)"

2024-09-21 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2024-09-21T23:24:49+03:00
New Revision: 1818ca5c4ae87ed222a18177caa7c8dde6c67efa

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

LOG: Revert "[Clang][Sema] Refactor collection of multi-level template argument 
lists (#106585)"

This reverts commit cdd71d61664b63ae57bdba9ee0d891f78ef79c07 (and
30adb43c897a45c18d7dd163fb4ff40c915fc488).

This change broke compiling Qt, see
https://github.com/llvm/llvm-project/pull/106585#issuecomment-2365309463
for details.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/DeclTemplate.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateDeductionGuide.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

Removed: 
clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 97b79e6c5ca928..00d254b70277d4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -409,9 +409,6 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure in debug mode, and potential crashes in release 
mode, when
   diagnosing a failed cast caused indirectly by a failed implicit conversion 
to the type of the constructor parameter.
 - Fixed an assertion failure by adjusting integral to boolean vector 
conversions (#GH108326)
-- Clang now uses the correct set of template argument lists when comparing the 
constraints of
-  out-of-line definitions and member templates explicitly specialized for a 
given implicit instantiation of
-  a class template. (#GH102320)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 05739f39d2a496..687715a22e9fd3 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -781,11 +781,15 @@ class RedeclarableTemplateDecl : public TemplateDecl,
  EntryType *Entry, void *InsertPos);
 
   struct CommonBase {
-CommonBase() {}
+CommonBase() : InstantiatedFromMember(nullptr, false) {}
 
 /// The template from which this was most
 /// directly instantiated (or null).
-RedeclarableTemplateDecl *InstantiatedFromMember = nullptr;
+///
+/// The boolean value indicates whether this template
+/// was explicitly specialized.
+llvm::PointerIntPair
+  InstantiatedFromMember;
 
 /// If non-null, points to an array of specializations (including
 /// partial specializations) known only by their external declaration IDs.
@@ -805,19 +809,14 @@ class RedeclarableTemplateDecl : public TemplateDecl,
   };
 
   /// Pointer to the common data shared by all declarations of this
-  /// template, and a flag indicating if the template is a member
-  /// specialization.
-  mutable llvm::PointerIntPair Common;
-
-  CommonBase *getCommonPtrInternal() const { return Common.getPointer(); }
+  /// template.
+  mutable CommonBase *Common = nullptr;
 
   /// Retrieves the "common" pointer shared by all (re-)declarations of
   /// the same template. Calling this routine may implicitly allocate memory
   /// for the common pointer.
   CommonBase *getCommonPtr() const;
 
-  void setCommonPtr(CommonBase *C) const { Common.setPointer(C); }
-
   virtual CommonBase *newCommon(ASTContext &C) const = 0;
 
   // Construct a template decl with name, parameters, and templated element.
@@ -858,12 +857,15 @@ class RedeclarableTemplateDecl : public TemplateDecl,
   /// template<> template
   /// struct X::Inner { /* ... */ };
   /// \endcode
-  bool isMemberSpecialization() const { return Common.getInt(); }
+  bool isMemberSpecialization() const {
+return getCommonPtr()->InstantiatedFromMember.getInt();
+  }
 
   /// Note that this member template is a specialization.
   void setMemberSpecialization() {
-assert(!isMemberSpecialization() && "already a member specialization");
-Common.setInt(true);
+assert(getCommonPtr()->InstantiatedFromMember.getPointer() &&
+   "Only member templates can be member template specializations");
+getCommonPtr()->InstantiatedFromMember.setInt(true);
   }
 
   /// Retrieve the member template from which this template was
@@ -903,12 +905,12 @@ class RedeclarableTemplateDecl : public TemplateDecl,
   /// void X::f(T, U);
   /// \endcode
   RedeclarableTemplate

[libclc] [llvm] [libclc] Refactor build system to allow in-tree builds (PR #87622)

2024-09-21 Thread Aaron Puchert via cfe-commits


@@ -167,12 +181,14 @@ install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc 
DESTINATION "${CMAKE_INSTAL
 install( DIRECTORY generic/include/clc DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}" )
 
 if( ENABLE_RUNTIME_SUBNORMAL )
-  add_library( subnormal_use_default STATIC
-generic/lib/subnormal_use_default.ll )
-  add_library( subnormal_disable STATIC
-generic/lib/subnormal_disable.ll )
-  install( TARGETS subnormal_use_default subnormal_disable ARCHIVE
-DESTINATION "${CMAKE_INSTALL_DATADIR}/clc" )
+  foreach( file subnormal_use_default subnormal_disable )
+link_bc(
+   TARGET ${file}
+   INPUTS ${PROJECT_SOURCE_DIR}/generic/lib/${file}.ll
+)
+install( FILES $ ARCHIVE

aaronpuchert wrote:

This causes an installation error for me with 
`-DENABLE_RUNTIME_SUBNORMAL:BOOL=ON`:
```
CMake Error at cmake_install.cmake:54 (file):
  file INSTALL cannot find
  "[...]/ARCHIVE": No such file or directory.
```
According to the 
[documentation](https://cmake.org/cmake/help/latest/command/install.html), 
`ARCHIVE` is a valid option for `install(TARGETS ...)`, but not for 
`install(FILES ...)`.

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


[clang-tools-extra] [modularize] Avoid repeated hash lookups (NFC) (PR #109508)

2024-09-21 Thread Kazu Hirata via cfe-commits

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


[clang-tools-extra] da38e1d - [modularize] Avoid repeated hash lookups (NFC) (#109508)

2024-09-21 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-09-21T14:01:16-07:00
New Revision: da38e1d5a962b45fd95034fc0a00f26526ec3c70

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

LOG: [modularize] Avoid repeated hash lookups (NFC) (#109508)

Co-authored-by: Nikita Popov 

Added: 


Modified: 
clang-tools-extra/modularize/Modularize.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index f3e7dfc20b027d..2c00c76c855336 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -508,13 +508,10 @@ class EntityMap : public std::map> {
   // Sort contents.
   llvm::sort(H->second);
 
-  // Check whether we've seen this header before.
-  auto KnownH = AllHeaderContents.find(H->first);
-  if (KnownH == AllHeaderContents.end()) {
-// We haven't seen this header before; record its contents.
-AllHeaderContents.insert(*H);
+  // Record this header and its contents if we haven't seen it before.
+  auto [KnownH, Inserted] = AllHeaderContents.insert(*H);
+  if (Inserted)
 continue;
-  }
 
   // If the header contents are the same, we're done.
   if (H->second == KnownH->second)



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


[clang-tools-extra] [modularize] Avoid repeated hash lookups (NFC) (PR #109508)

2024-09-21 Thread Nikita Popov via cfe-commits

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


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


[clang-tools-extra] issue-63565: community requested small QoL fix for more configurabili… (PR #108005)

2024-09-21 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> `FlagConfigProvider` is pushed in the vector after `.clangd` config in 
> [CLangdMain.cpp](https://github.com/llvm/llvm-project/blob/a4586bd2d4fa7d6c0100893496a9383fd581e2e9/clang-tools-extra/clangd/tool/ClangdMain.cpp#L926)
>  Then 
> [ConfigProvider.cpp](https://github.com/llvm/llvm-project/blob/5ac97d397c2088c3ac0a113506e57ab9b1e69ac8/clang-tools-extra/clangd/ConfigProvider.cpp#L154)
>  just iterates over it, which means that `FlagConfigProvider` is evaluated 
> **after** `.clangd` and will override it!

Thanks for catching that; I was under the mistaken impression that it was the 
other way around!

I think it would be a nicer user experience if the config file took precedence 
over compile flags... but since that's not the case today for existing flags 
(like `--background-index`), I think it's appropriate for this patch to remain 
consistent with the existing behaviour.

In other words, I think what the current version of the patch is doing is fine.

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


[clang-tools-extra] issue-63565: community requested small QoL fix for more configurabili… (PR #108005)

2024-09-21 Thread Nathan Ridge via cfe-commits


@@ -230,6 +230,10 @@ class Parser {
   if (auto AllScopes = boolValue(N, "AllScopes"))
 F.AllScopes = *AllScopes;
 });
+Dict.handle("ArgumentLists", [&](Node &N) {
+  if (auto ArgumentLists = scalarValue(N, "ArgumentLists"))

HighCommander4 wrote:

(this comment remains to be addressed)

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


[clang-tools-extra] issue-63565: community requested small QoL fix for more configurabili… (PR #108005)

2024-09-21 Thread Nathan Ridge via cfe-commits

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

Thanks, this is looking pretty good. My only remaining request is to please 
split the formatting changes out. I know it's the fault of the code not being 
clang-format clean, and I'm happy to merge them in a separate PR, but it 
confuses things when "git blame" says that the last commit that touched some 
unrelated test / code line is this one about `ArgumentLists`.

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


[clang-tools-extra] issue-63565: community requested small QoL fix for more configurabili… (PR #108005)

2024-09-21 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 925b220ee424f8489bc8d7b1a247f2c5f3edde5d 
49ca6ddee1003aaf58f076da5c2ee6767acbf939 --extensions h,cpp -- 
clang-tools-extra/clangd/ClangdServer.cpp 
clang-tools-extra/clangd/CodeComplete.cpp 
clang-tools-extra/clangd/CodeComplete.h clang-tools-extra/clangd/Config.h 
clang-tools-extra/clangd/ConfigCompile.cpp 
clang-tools-extra/clangd/ConfigFragment.h 
clang-tools-extra/clangd/ConfigYAML.cpp 
clang-tools-extra/clangd/tool/ClangdMain.cpp 
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang-tools-extra/clangd/ClangdServer.cpp 
b/clang-tools-extra/clangd/ClangdServer.cpp
index 547f988b87..9b38be04e7 100644
--- a/clang-tools-extra/clangd/ClangdServer.cpp
+++ b/clang-tools-extra/clangd/ClangdServer.cpp
@@ -64,7 +64,7 @@ namespace {
 // Tracks number of times a tweak has been offered.
 static constexpr trace::Metric TweakAvailable(
 "tweak_available", trace::Metric::Counter, "tweak_id");
-
+
 // Update the FileIndex with new ASTs and plumb the diagnostics responses.
 struct UpdateIndexCallbacks : public ParsingCallbacks {
   UpdateIndexCallbacks(FileIndex *FIndex,

``




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


[clang-tools-extra] issue-63565: community requested small QoL fix for more configurabili… (PR #108005)

2024-09-21 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] issue-63565: community requested small QoL fix for more configurabili… (PR #108005)

2024-09-21 Thread Nathan Ridge via cfe-commits

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


[clang] bbca451 - [CMake] Preserve clang-prebolt

2024-09-21 Thread via cfe-commits

Author: Amir Ayupov
Date: 2024-09-21T20:56:21-07:00
New Revision: bbca451be01fb02d05c2d0586b061fd5611d80ba

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

LOG: [CMake] Preserve clang-prebolt

In Clang-BOLT step, preserve pre-BOLT Clang binary (as well as clang++
symlink).

Also modify the default set of BOLT flags:
- drop ICF (can mess with unwinders),
- switch from hfsort+ to cdsort (aliases),
- enable CDSplit,
- update debug sections.

Reviewers: maksfb

Reviewed By: maksfb

Pull Request: https://github.com/llvm/llvm-project/pull/109351

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c6496167d3828b..94ce5968beb75e 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -899,6 +899,7 @@ if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
 -instrument --instrumentation-file-append-pid
 --instrumentation-file=${BOLT_FDATA}
   COMMENT "Instrumenting clang binary with BOLT"
+  USES_TERMINAL
   VERBATIM
 )
 add_custom_target(clang-bolt-training-deps DEPENDS clang-instrumented)
@@ -907,20 +908,19 @@ if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
   endif()
 
   # Optimize original (pre-bolt) Clang using the collected profile
-  set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt)
   add_custom_target(clang-bolt
-DEPENDS ${CLANG_OPTIMIZED}
-  )
-  add_custom_command(OUTPUT ${CLANG_OPTIMIZED}
 DEPENDS clang-bolt-profile
-COMMAND llvm-bolt ${CLANG_PATH}
-  -o ${CLANG_OPTIMIZED}
+COMMAND ${CMAKE_COMMAND} -E rename $ 
${CLANG_PATH}-prebolt
+COMMAND ${CMAKE_COMMAND} -E create_symlink ${CLANG_PATH}-prebolt 
${CLANG_PATH}++-prebolt
+COMMAND llvm-bolt ${CLANG_PATH}-prebolt
+  -o $
   -data ${BOLT_FDATA}
-  -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions
-  -split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack
+  -reorder-blocks=ext-tsp -reorder-functions=cdsort -split-functions
+  -split-all-cold -split-eh -dyno-stats -use-gnu-stack
+  -split-strategy=cdsplit -update-debug-sections
   ${BOLT_NO_LBR}
-COMMAND ${CMAKE_COMMAND} -E rename ${CLANG_OPTIMIZED} $
 COMMENT "Optimizing Clang with BOLT"
+USES_TERMINAL
 VERBATIM
   )
 endif()



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


[clang] [llvm] [CMake] Preserve clang-prebolt (PR #109351)

2024-09-21 Thread Amir Ayupov via cfe-commits

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


[clang] [llvm] [CMake] Preserve clang-prebolt (PR #109351)

2024-09-21 Thread Amir Ayupov via cfe-commits

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


[clang-tools-extra] [modularize] Avoid repeated hash lookups (NFC) (PR #109508)

2024-09-21 Thread Kazu Hirata via cfe-commits

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

>From d50b829fd1277736b7e65886879fcfe9a45714f2 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Fri, 20 Sep 2024 13:31:12 -0700
Subject: [PATCH 1/2] [modularize] Avoid repeated hash lookups (NFC)

---
 clang-tools-extra/modularize/Modularize.cpp | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index f3e7dfc20b027d..92e4792526d6f3 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -508,13 +508,11 @@ class EntityMap : public std::map> {
   // Sort contents.
   llvm::sort(H->second);
 
-  // Check whether we've seen this header before.
-  auto KnownH = AllHeaderContents.find(H->first);
-  if (KnownH == AllHeaderContents.end()) {
-// We haven't seen this header before; record its contents.
-AllHeaderContents.insert(*H);
+  // Record this header and its contents if we haven't seen it before.
+  auto [KnownH, Inserted] =
+  AllHeaderContents.try_emplace(H->first, H->second);
+  if (Inserted)
 continue;
-  }
 
   // If the header contents are the same, we're done.
   if (H->second == KnownH->second)

>From 39dea55ef4af49f1d855d78a70a5b5f535e44405 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 21 Sep 2024 09:12:57 -0700
Subject: [PATCH 2/2] Update clang-tools-extra/modularize/Modularize.cpp

Co-authored-by: Nikita Popov 
---
 clang-tools-extra/modularize/Modularize.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 92e4792526d6f3..9dda405a392bec 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -510,7 +510,7 @@ class EntityMap : public std::map> {
 
   // Record this header and its contents if we haven't seen it before.
   auto [KnownH, Inserted] =
-  AllHeaderContents.try_emplace(H->first, H->second);
+  AllHeaderContents.insert(*H);
   if (Inserted)
 continue;
 

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


[clang-tools-extra] [modularize] Avoid repeated hash lookups (NFC) (PR #109508)

2024-09-21 Thread Kazu Hirata via cfe-commits

kazutakahirata wrote:

Revised the patch.  Please take a look.  Thanks!

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


[clang] [Clang] Remove __is_nullptr from the list of type traits (PR #109533)

2024-09-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nikolas Klauser (philnik777)


Changes

Support for `__is_nullptr` was removed in #99038, but I forgot to 
remove it from the list of type traits, resulting in Clang crashing when one 
tries to use it.


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


1 Files Affected:

- (modified) clang/include/clang/Basic/TokenKinds.def (-1) 


``diff
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 00e150dbd7a3a7..c5c3838407cf48 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -542,7 +542,6 @@ TYPE_TRAIT_1(__is_trivially_relocatable, 
IsTriviallyRelocatable, KEYCXX)
 TYPE_TRAIT_1(__is_trivially_equality_comparable, 
IsTriviallyEqualityComparable, KEYCXX)
 TYPE_TRAIT_1(__is_bounded_array, IsBoundedArray, KEYCXX)
 TYPE_TRAIT_1(__is_unbounded_array, IsUnboundedArray, KEYCXX)
-TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX)
 TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
 TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)

``




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


[clang-tools-extra] [modularize] Avoid repeated hash lookups (NFC) (PR #109508)

2024-09-21 Thread Kazu Hirata via cfe-commits

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

>From d50b829fd1277736b7e65886879fcfe9a45714f2 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Fri, 20 Sep 2024 13:31:12 -0700
Subject: [PATCH 1/3] [modularize] Avoid repeated hash lookups (NFC)

---
 clang-tools-extra/modularize/Modularize.cpp | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index f3e7dfc20b027d..92e4792526d6f3 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -508,13 +508,11 @@ class EntityMap : public std::map> {
   // Sort contents.
   llvm::sort(H->second);
 
-  // Check whether we've seen this header before.
-  auto KnownH = AllHeaderContents.find(H->first);
-  if (KnownH == AllHeaderContents.end()) {
-// We haven't seen this header before; record its contents.
-AllHeaderContents.insert(*H);
+  // Record this header and its contents if we haven't seen it before.
+  auto [KnownH, Inserted] =
+  AllHeaderContents.try_emplace(H->first, H->second);
+  if (Inserted)
 continue;
-  }
 
   // If the header contents are the same, we're done.
   if (H->second == KnownH->second)

>From 39dea55ef4af49f1d855d78a70a5b5f535e44405 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 21 Sep 2024 09:12:57 -0700
Subject: [PATCH 2/3] Update clang-tools-extra/modularize/Modularize.cpp

Co-authored-by: Nikita Popov 
---
 clang-tools-extra/modularize/Modularize.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 92e4792526d6f3..9dda405a392bec 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -510,7 +510,7 @@ class EntityMap : public std::map> {
 
   // Record this header and its contents if we haven't seen it before.
   auto [KnownH, Inserted] =
-  AllHeaderContents.try_emplace(H->first, H->second);
+  AllHeaderContents.insert(*H);
   if (Inserted)
 continue;
 

>From 92292648faf08168d951e762ec191d1b21df2ce5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sat, 21 Sep 2024 09:18:17 -0700
Subject: [PATCH 3/3] Fix formatting.

---
 clang-tools-extra/modularize/Modularize.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 9dda405a392bec..2c00c76c855336 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -509,8 +509,7 @@ class EntityMap : public std::map> {
   llvm::sort(H->second);
 
   // Record this header and its contents if we haven't seen it before.
-  auto [KnownH, Inserted] =
-  AllHeaderContents.insert(*H);
+  auto [KnownH, Inserted] = AllHeaderContents.insert(*H);
   if (Inserted)
 continue;
 

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


[clang] [Clang] Remove __is_nullptr from the list of type traits (PR #109533)

2024-09-21 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 created 
https://github.com/llvm/llvm-project/pull/109533

Support for `__is_nullptr` was removed in #99038, but I forgot to remove it 
from the list of type traits, resulting in Clang crashing when one tries to use 
it.


>From db8690cdbc2a218692d8fc83398beecf8853bae2 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Sat, 21 Sep 2024 18:11:12 +0200
Subject: [PATCH] [Clang] Remove __is_nullptr from the list of type traits

---
 clang/include/clang/Basic/TokenKinds.def | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 00e150dbd7a3a7..c5c3838407cf48 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -542,7 +542,6 @@ TYPE_TRAIT_1(__is_trivially_relocatable, 
IsTriviallyRelocatable, KEYCXX)
 TYPE_TRAIT_1(__is_trivially_equality_comparable, 
IsTriviallyEqualityComparable, KEYCXX)
 TYPE_TRAIT_1(__is_bounded_array, IsBoundedArray, KEYCXX)
 TYPE_TRAIT_1(__is_unbounded_array, IsUnboundedArray, KEYCXX)
-TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX)
 TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
 TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)

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


[clang-tools-extra] [modularize] Avoid repeated hash lookups (NFC) (PR #109508)

2024-09-21 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 0cab475d1126305dc1bbb2ba269e40d704dfb90f 
39dea55ef4af49f1d855d78a70a5b5f535e44405 --extensions cpp -- 
clang-tools-extra/modularize/Modularize.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang-tools-extra/modularize/Modularize.cpp 
b/clang-tools-extra/modularize/Modularize.cpp
index 9dda405a39..2c00c76c85 100644
--- a/clang-tools-extra/modularize/Modularize.cpp
+++ b/clang-tools-extra/modularize/Modularize.cpp
@@ -509,8 +509,7 @@ public:
   llvm::sort(H->second);
 
   // Record this header and its contents if we haven't seen it before.
-  auto [KnownH, Inserted] =
-  AllHeaderContents.insert(*H);
+  auto [KnownH, Inserted] = AllHeaderContents.insert(*H);
   if (Inserted)
 continue;
 

``




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


[clang] d296902 - [Clang] Remove __is_nullptr from the list of type traits

2024-09-21 Thread Nikolas Klauser via cfe-commits

Author: Nikolas Klauser
Date: 2024-09-21T18:38:15+02:00
New Revision: d2969022640a94b26b7324241e13d67080554d9f

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

LOG: [Clang] Remove __is_nullptr from the list of type traits

Added: 


Modified: 
clang/include/clang/Basic/TokenKinds.def

Removed: 




diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 00e150dbd7a3a7..c5c3838407cf48 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -542,7 +542,6 @@ TYPE_TRAIT_1(__is_trivially_relocatable, 
IsTriviallyRelocatable, KEYCXX)
 TYPE_TRAIT_1(__is_trivially_equality_comparable, 
IsTriviallyEqualityComparable, KEYCXX)
 TYPE_TRAIT_1(__is_bounded_array, IsBoundedArray, KEYCXX)
 TYPE_TRAIT_1(__is_unbounded_array, IsUnboundedArray, KEYCXX)
-TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX)
 TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
 TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)



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


[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)

2024-09-21 Thread Fangrui Song via cfe-commits

MaskRay wrote:

I understand the intention to generalize naming, but I feel that there is 
significance chance that the over-generalization may not work with the 
alternative CFI schemes, and this change could turn out to be needed when the 
other schemes go with different IR constructs.

I feel that we should make such renaming at this time.

BTW: when kcfi was proposed, I felt that it was not a good name because the 
strategy could only cover a very limited subset of LTO-based `-fsanitize=cfi`. 
kcfi is just like a brand name.

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


[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)

2024-09-21 Thread Fangrui Song via cfe-commits

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

.

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


[clang] [llvm] [SPARC] Align i128 to 16 bytes in SPARC datalayouts (PR #106951)

2024-09-21 Thread via cfe-commits

https://github.com/koachan updated 
https://github.com/llvm/llvm-project/pull/106951

>From 3eb96009b0b483553c2255893d26e59b8c4f6574 Mon Sep 17 00:00:00 2001
From: Koakuma 
Date: Mon, 2 Sep 2024 12:01:04 +0700
Subject: [PATCH 1/3] [SPARC] Align i128 to 16 bytes in SPARC datalayouts

Align i128s to 16 bytes, following the example at 
https://reviews.llvm.org/D86310.

clang already does this, but do it in backend code too for the benefit of other
frontends (see e.g https://github.com/llvm/llvm-project/issues/102783).
---
 clang/lib/Basic/Targets/Sparc.h  |  6 ++---
 clang/test/CodeGen/target-data.c |  4 +--
 llvm/lib/Target/Sparc/SparcTargetMachine.cpp |  4 +++
 llvm/test/CodeGen/SPARC/data-align.ll| 27 
 4 files changed, 36 insertions(+), 5 deletions(-)
 create mode 100644 llvm/test/CodeGen/SPARC/data-align.ll

diff --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h
index 3357bee33e1ac7..ee0d3e2b4329eb 100644
--- a/clang/lib/Basic/Targets/Sparc.h
+++ b/clang/lib/Basic/Targets/Sparc.h
@@ -151,7 +151,7 @@ class LLVM_LIBRARY_VISIBILITY SparcV8TargetInfo : public 
SparcTargetInfo {
 public:
   SparcV8TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : SparcTargetInfo(Triple, Opts) {
-resetDataLayout("E-m:e-p:32:32-i64:64-f128:64-n32-S64");
+resetDataLayout("E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64");
 // NetBSD / OpenBSD use long (same as llvm default); everyone else uses 
int.
 switch (getTriple().getOS()) {
 default:
@@ -188,7 +188,7 @@ class LLVM_LIBRARY_VISIBILITY SparcV8elTargetInfo : public 
SparcV8TargetInfo {
 public:
   SparcV8elTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : SparcV8TargetInfo(Triple, Opts) {
-resetDataLayout("e-m:e-p:32:32-i64:64-f128:64-n32-S64");
+resetDataLayout("e-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64");
   }
 };
 
@@ -198,7 +198,7 @@ class LLVM_LIBRARY_VISIBILITY SparcV9TargetInfo : public 
SparcTargetInfo {
   SparcV9TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : SparcTargetInfo(Triple, Opts) {
 // FIXME: Support Sparc quad-precision long double?
-resetDataLayout("E-m:e-i64:64-n32:64-S128");
+resetDataLayout("E-m:e-i64:64-i128:128-n32:64-S128");
 // This is an LP64 platform.
 LongWidth = LongAlign = PointerWidth = PointerAlign = 64;
 
diff --git a/clang/test/CodeGen/target-data.c b/clang/test/CodeGen/target-data.c
index 41cbd5a0219d5e..8548aa00cfe877 100644
--- a/clang/test/CodeGen/target-data.c
+++ b/clang/test/CodeGen/target-data.c
@@ -28,11 +28,11 @@
 
 // RUN: %clang_cc1 -triple sparc-sun-solaris -emit-llvm -o - %s | \
 // RUN: FileCheck %s --check-prefix=SPARC-V8
-// SPARC-V8: target datalayout = "E-m:e-p:32:32-i64:64-f128:64-n32-S64"
+// SPARC-V8: target datalayout = 
"E-m:e-p:32:32-i64:64-i128:128-f128:64-n32-S64"
 
 // RUN: %clang_cc1 -triple sparcv9-sun-solaris -emit-llvm -o - %s | \
 // RUN: FileCheck %s --check-prefix=SPARC-V9
-// SPARC-V9: target datalayout = "E-m:e-i64:64-n32:64-S128"
+// SPARC-V9: target datalayout = "E-m:e-i64:64-i128:128-n32:64-S128"
 
 // RUN: %clang_cc1 -triple mipsel-linux-gnu -o - -emit-llvm %s | \
 // RUN: FileCheck %s -check-prefix=MIPS-32EL
diff --git a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp 
b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
index fec2d3a35ae6d2..50a96368bbdca9 100644
--- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
+++ b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp
@@ -48,6 +48,10 @@ static std::string computeDataLayout(const Triple &T, bool 
is64Bit) {
   // Alignments for 64 bit integers.
   Ret += "-i64:64";
 
+  // Alignments for 128 bit integers.
+  // This is not specified in the ABI document but is the de facto standard.
+  Ret += "-i128:128";
+
   // On SparcV9 128 floats are aligned to 128 bits, on others only to 64.
   // On SparcV9 registers can hold 64 or 32 bits, on others only 32.
   if (is64Bit)
diff --git a/llvm/test/CodeGen/SPARC/data-align.ll 
b/llvm/test/CodeGen/SPARC/data-align.ll
new file mode 100644
index 00..d4a39524da44f6
--- /dev/null
+++ b/llvm/test/CodeGen/SPARC/data-align.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s -march=sparc | FileCheck %s
+; RUN: llc < %s -march=sparcel | FileCheck %s
+; RUN: llc < %s -march=sparcv9 | FileCheck %s
+
+; CHECK:  .Li8:
+; CHECK-DAG: .size .Li8, 1
+@i8 = private constant i8 42
+
+; CHECK:  .p2align 1
+; CHECK-NEXT: .Li16:
+; CHECK-DAG:  .size .Li16, 2
+@i16 = private constant i16 42
+
+; CHECK:  .p2align 2
+; CHECK-NEXT: .Li32:
+; CHECK-DAG:  .size .Li32, 4
+@i32 = private constant i32 42
+
+; CHECK:  .p2align 3
+; CHECK-NEXT: .Li64:
+; CHECK-DAG:  .size .Li64, 8
+@i64 = private constant i64 42
+
+; CHECK:  .p2align 4
+; CHECK-NEXT: .Li128:
+; CHECK-DAG:  .size .Li128, 16
+@i128 = private constant i128 42

>From 4b40325439810ff7786be100577207693b372f7b Mon Sep 17 00:00:00 2001
From: Koakuma 
Date: Wed, 4 Sep 2024 2

[clang] [clang][bytecode] Create dummy pointers for ObjCStringLiterals (PR #109520)

2024-09-21 Thread Timm Baeder via cfe-commits

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


[clang] [lld] [llvm] Stablefunctest2 (PR #109522)

2024-09-21 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 8527861179ac7771bae09e2fcb0eece4b589d747 
e5ace714e5424afd855c678344bce0aca13ba2ac --extensions cpp,inc,h -- 
llvm/include/llvm/CGData/StableFunctionMap.h 
llvm/include/llvm/CGData/StableFunctionMapRecord.h 
llvm/include/llvm/Transforms/IPO/GlobalMergeFunctions.h 
llvm/lib/CGData/StableFunctionMap.cpp 
llvm/lib/CGData/StableFunctionMapRecord.cpp 
llvm/lib/Transforms/IPO/GlobalMergeFunctions.cpp 
llvm/unittests/CGData/StableFunctionMapRecordTest.cpp 
llvm/unittests/CGData/StableFunctionMapTest.cpp 
clang/lib/CodeGen/BackendUtil.cpp lld/MachO/Driver.cpp lld/MachO/InputSection.h 
lld/MachO/LTO.cpp llvm/include/llvm/CGData/CodeGenData.h 
llvm/include/llvm/CGData/CodeGenData.inc 
llvm/include/llvm/CGData/CodeGenDataReader.h 
llvm/include/llvm/CGData/CodeGenDataWriter.h 
llvm/include/llvm/IR/StructuralHash.h llvm/include/llvm/InitializePasses.h 
llvm/include/llvm/LTO/LTOBackend.h llvm/include/llvm/LinkAllPasses.h 
llvm/include/llvm/Passes/CodeGenPassBuilder.h 
llvm/include/llvm/Transforms/IPO.h llvm/lib/CGData/CodeGenData.cpp 
llvm/lib/CGData/CodeGenDataReader.cpp llvm/lib/CGData/CodeGenDataWriter.cpp 
llvm/lib/IR/StructuralHash.cpp llvm/lib/LTO/LTO.cpp llvm/lib/LTO/LTOBackend.cpp 
llvm/tools/llvm-cgdata/llvm-cgdata.cpp llvm/unittests/IR/StructuralHashTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/include/llvm/CGData/StableFunctionMap.h 
b/llvm/include/llvm/CGData/StableFunctionMap.h
index 9bf7183daa..8773637314 100644
--- a/llvm/include/llvm/CGData/StableFunctionMap.h
+++ b/llvm/include/llvm/CGData/StableFunctionMap.h
@@ -26,7 +26,6 @@
 
 namespace llvm {
 
-
 using IndexPairHash = std::pair;
 using IndexOperandHashVecType = SmallVector;
 
diff --git a/llvm/include/llvm/CGData/StableFunctionMapRecord.h 
b/llvm/include/llvm/CGData/StableFunctionMapRecord.h
index 0a38e2df73..29cabd7b51 100644
--- a/llvm/include/llvm/CGData/StableFunctionMapRecord.h
+++ b/llvm/include/llvm/CGData/StableFunctionMapRecord.h
@@ -27,7 +27,7 @@ struct StableFunctionMapRecord {
 FunctionMap = std::make_unique();
   }
   StableFunctionMapRecord(std::unique_ptr FunctionMap)
-  : FunctionMap(std::move(FunctionMap)){};
+  : FunctionMap(std::move(FunctionMap)) {};
 
   /// Serialize the stable function map to a raw_ostream.
   void serialize(raw_ostream &OS) const;

``




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


[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread Timm Baeder via cfe-commits

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


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


[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread Younan Zhang via cfe-commits

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

>From 1deb74f00b518eb595dbe49be3234a05c3753c6f Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 21 Sep 2024 12:48:27 +0800
Subject: [PATCH 1/2] [Clang][Sema] Retain the expanding index for unevaluated
 type constraints

---
 clang/include/clang/Sema/Sema.h   |   1 +
 clang/lib/Sema/SemaTemplate.cpp   |   6 +-
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 +-
 clang/lib/Sema/SemaType.cpp   |   8 +-
 .../SemaCXX/fold_lambda_with_variadics.cpp|  54 
 5 files changed, 177 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b86861ce7e8cfa..f711fe952d35e9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11252,6 +11252,7 @@ class Sema final : public SemaBase {
 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc);
 
   bool AttachTypeConstraint(AutoTypeLoc TL,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 16f4542d785715..bdfb0f4c95afb8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1134,7 +1134,8 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
   SS.isSet() ? SS.getWithLocInContext(Context) : NestedNameSpecifierLoc(),
   ConceptName, CD, /*FoundDecl=*/USD ? cast(USD) : CD,
   TypeConstr->LAngleLoc.isValid() ? &TemplateArgs : nullptr,
-  ConstrainedParameter, EllipsisLoc);
+  ConstrainedParameter, Context.getTypeDeclType(ConstrainedParameter),
+  EllipsisLoc);
 }
 
 template 
@@ -1191,6 +1192,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 ConceptDecl *NamedConcept, NamedDecl 
*FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc) {
   // C++2a [temp.param]p4:
   // [...] If Q is of the form C, then let E' be
@@ -1199,7 +1201,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context,
*TemplateArgs) : 
nullptr;
 
-  QualType ParamAsArgument(ConstrainedParameter->getTypeForDecl(), 0);
+  QualType ParamAsArgument = ConstrainedType;
 
   ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint(
   *this, NS, NameInfo, NamedConcept, FoundDecl,
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 7481c700019dc8..d62ac5c1de3cc9 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1646,6 +1646,21 @@ namespace {
SubstTemplateTypeParmPackTypeLoc TL,
bool SuppressObjCLifetime);
 
+QualType
+TransformSubstTemplateTypeParmType(TypeLocBuilder &TLB,
+   SubstTemplateTypeParmTypeLoc TL) {
+  if (SemaRef.CodeSynthesisContexts.back().Kind !=
+  Sema::CodeSynthesisContext::ConstraintSubstitution)
+return inherited::TransformSubstTemplateTypeParmType(TLB, TL);
+
+  auto PackIndex = TL.getTypePtr()->getPackIndex();
+  std::optional SubstIndex;
+  if (SemaRef.ArgumentPackSubstitutionIndex == -1 && PackIndex)
+SubstIndex.emplace(SemaRef, *PackIndex);
+
+  return inherited::TransformSubstTemplateTypeParmType(TLB, TL);
+}
+
 CXXRecordDecl::LambdaDependencyKind
 ComputeLambdaDependency(LambdaScopeInfo *LSI) {
   if (auto TypeAlias = getEnclosingTypeAliasTemplateDecl(getSema());
@@ -3056,6 +3071,46 @@ namespace {
 
 } // namespace
 
+namespace {
+
+struct ExpandPackedTypeConstraints
+: TreeTransform {
+
+  using inherited = TreeTransform;
+
+  ExpandPackedTypeConstraints(Sema &SemaRef) : inherited(SemaRef) {}
+
+  using inherited::TransformTemplateTypeParmType;
+
+  QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
+ TemplateTypeParmTypeLoc TL, bool) {
+const TemplateTypeParmType *T = TL.getTypePtr();
+if (!T->isParameterPack()) {
+  TemplateTypeParmTypeLoc NewTL =
+  TLB.push(TL.getType());
+  NewTL.setNameLoc(TL.getNameLoc());
+  return TL.getType();
+}
+
+assert(SemaRef.ArgumentPackSubstitutionIndex != -1);
+
+QualType Result = SemaRef.Context.getSubstTemplateTypePar

[clang] [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (PR #109278)

2024-09-21 Thread Rainer Orth via cfe-commits

rorth wrote:

Good, that considerably simplifies non-native testing:
- The original patch ignored the issue because I had no idea how to handle it.
- The first version of this one used the hack of checking `uname -v`.  While 
this works, it's still wrong since this checks the host distro, not the target 
one.
- It occured to me that one could use the vendor component of the target triple 
for this purpose.  Right now, only `SUSE` is used here, but it could be 
extended to Debian, Gentoo and others if need be.  AFAICS, the vendor field is 
usually just ignored.

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


[clang] 39e3050 - [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (#109278)

2024-09-21 Thread via cfe-commits

Author: Rainer Orth
Date: 2024-09-21T19:53:35+02:00
New Revision: 39e30508a7f6ec5477b11611946a491af5ebdeda

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

LOG: [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (#109278)

While working on supporting PR #109101 on Linux/sparc64, I was reminded
that `clang -m32` still defaults to generating V8 code, although the
64-bit kernel requires a V9 CPU.

This patch corrects that.

Tested on `sparc64-unknown-linux-gnu`, `x86_64-pc-linux-gnu`,
`sparcv9-sun-solaris2.11`, and `amd64-pc-solaris2.11`.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Driver/ToolChains/Arch/Sparc.cpp
clang/test/Preprocessor/predefined-arch-macros.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f4535db7356194..97b79e6c5ca928 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -39,6 +39,11 @@ code bases.
 
 - The ``le32`` and ``le64`` targets have been removed.
 
+- ``clang -m32`` defaults to ``-mcpu=v9`` on SPARC Linux now.  Distros
+  still supporting SPARC V8 CPUs need to specify ``-mcpu=v8`` with a
+  `config file
+  `_.
+  
 - The ``clang-rename`` tool has been removed.
 
 C/C++ Language Potentially Breaking Changes

diff  --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp 
b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index f7f0a265fef68b..55fbc8b30698b9 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -125,7 +125,8 @@ std::string sparc::getSparcTargetCPU(const Driver &D, const 
ArgList &Args,
 return std::string(CPUName);
   }
 
-  if (Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris())
+  if (Triple.getArch() == llvm::Triple::sparc &&
+  (Triple.isOSSolaris() || Triple.isOSLinux()))
 return "v9";
   return "";
 }

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index a149c69ee0cdb2..35801e758cc58a 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -4137,7 +4137,8 @@
 // CHECK_SPARC: #define __sparc__ 1
 // CHECK_SPARC-NOT: #define __sparcv9 1
 // CHECK_SPARC-NOT: #define __sparcv9__ 1
-// CHECK_SPARC: #define __sparcv8 1
+// CHECK_SPARC: #define __sparc_v9__ 1
+// CHECK_SPARC-NOT: #define __sparcv8 1
 // CHECK_SPARC-NOT: #define __sparcv9 1
 // CHECK_SPARC-NOT: #define __sparcv9__ 1
 



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


[clang] [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (PR #109278)

2024-09-21 Thread Rainer Orth via cfe-commits

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


[clang] [clang][bytecode] Don't call checkLiteralType() in visitInitializer() (PR #109530)

2024-09-21 Thread Timm Baeder via cfe-commits

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


[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread Rainer Orth via cfe-commits

rorth wrote:

This patch broke the [Solaris/sparcv9 
buildbot](https://lab.llvm.org/buildbot/#/builders/13/builds/2437).  The two 
affected tests use `-triple x86_64-linux-gnu` without requiring x86 support.

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


[clang] f86050d - [clang][bytecode] Don't call checkLiteralType() in visitInitializer() (#109530)

2024-09-21 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-21T20:01:21+02:00
New Revision: f86050de738385ecc27e7ce827f72296be8def36

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

LOG: [clang][bytecode] Don't call checkLiteralType() in visitInitializer() 
(#109530)

We were calling checkLiteralType() too many time and rejecting some
things we shouldn't. Add The calls manually when handling
MaterializeTemporaryExprs. Maybe we should call it in other places as
well, but adding more calls is easier than removing them from a generic
code path.

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/lib/AST/ByteCode/Interp.cpp
clang/lib/AST/ByteCode/Interp.h
clang/test/AST/ByteCode/cxx17.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 31aa400937e36a..68c3cdff712fb2 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2529,6 +2529,8 @@ bool Compiler::VisitMaterializeTemporaryExpr(
   return this->emitGetPtrGlobal(*GlobalIndex, E);
 }
 
+if (!this->checkLiteralType(SubExpr))
+  return false;
 // Non-primitive values.
 if (!this->emitGetPtrGlobal(*GlobalIndex, E))
   return false;
@@ -2549,6 +2551,10 @@ bool Compiler::VisitMaterializeTemporaryExpr(
   return false;
 return this->emitGetPtrLocal(LocalIndex, E);
   } else {
+
+if (!this->checkLiteralType(SubExpr))
+  return false;
+
 const Expr *Inner = E->getSubExpr()->skipRValueSubobjectAdjustments();
 if (std::optional LocalIndex =
 allocateLocal(Inner, E->getExtendingDecl())) {
@@ -3570,9 +3576,6 @@ template 
 bool Compiler::visitInitializer(const Expr *E) {
   assert(!classify(E->getType()));
 
-  if (!this->checkLiteralType(E))
-return false;
-
   OptionScope Scope(this, /*NewDiscardResult=*/false,
  /*NewInitializing=*/true);
   return this->Visit(E);

diff  --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index ede52de1c5e7b2..0587ffd67eba51 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1012,6 +1012,37 @@ void diagnoseEnumValue(InterpState &S, CodePtr OpPC, 
const EnumDecl *ED,
   }
 }
 
+bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T) {
+  assert(T);
+  assert(!S.getLangOpts().CPlusPlus23);
+
+  // C++1y: A constant initializer for an object o [...] may also invoke
+  // constexpr constructors for o and its subobjects even if those objects
+  // are of non-literal class types.
+  //
+  // C++11 missed this detail for aggregates, so classes like this:
+  //   struct foo_t { union { int i; volatile int j; } u; };
+  // are not (obviously) initializable like so:
+  //   __attribute__((__require_constant_initialization__))
+  //   static const foo_t x = {{0}};
+  // because "i" is a subobject with non-literal initialization (due to the
+  // volatile member of the union). See:
+  //   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677
+  // Therefore, we use the C++1y behavior.
+
+  if (S.Current->getFunction() && S.Current->getFunction()->isConstructor() &&
+  S.Current->getThis().getDeclDesc()->asDecl() == S.EvaluatingDecl) {
+return true;
+  }
+
+  const Expr *E = S.Current->getExpr(OpPC);
+  if (S.getLangOpts().CPlusPlus11)
+S.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType();
+  else
+S.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
+  return false;
+}
+
 bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func,
  uint32_t VarArgSize) {
   if (Func->hasThisPointer()) {

diff  --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 92bed32d56f4d5..4aceb83eee0e71 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -158,6 +158,7 @@ bool CallBI(InterpState &S, CodePtr OpPC, const Function 
*Func,
 const CallExpr *CE, uint32_t BuiltinID);
 bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t ArgSize,
  const CallExpr *CE);
+bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T);
 
 enum class ShiftDir { Left, Right };
 
@@ -2946,39 +2947,6 @@ static inline bool IsConstantContext(InterpState &S, 
CodePtr OpPC) {
   return true;
 }
 
-inline bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T) {
-  assert(T);
-  assert(!S.getLangOpts().CPlusPlus23);
-
-  // C++1y: A constant initializer for an object o [...] may also invoke
-  // constexpr constructors for o and its subobjects even if those objects
-  // are of non-literal class types.
-  //
-  // C++11 missed this detail for aggregates, so classes like this:
-  //   struct foo_t { union { int i; volatile int j; } u; };
-  // a

[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Is x86-solaris11-sparcv9 the right triple to use to reproduce issues for that 
builder?

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


[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/109518

Fixes #101754

>From f09bb393dc173ba47af49ecf4da6ecfcf969adb1 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 21 Sep 2024 12:48:27 +0800
Subject: [PATCH] [Clang][Sema] Retain the expanding index for unevaluated type
 constraints

---
 clang/include/clang/Sema/Sema.h   |   1 +
 clang/lib/Sema/SemaTemplate.cpp   |   6 +-
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 +-
 clang/lib/Sema/SemaType.cpp   |   8 +-
 .../SemaCXX/fold_lambda_with_variadics.cpp|  54 
 5 files changed, 177 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b86861ce7e8cfa..f711fe952d35e9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11252,6 +11252,7 @@ class Sema final : public SemaBase {
 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc);
 
   bool AttachTypeConstraint(AutoTypeLoc TL,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 16f4542d785715..bdfb0f4c95afb8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1134,7 +1134,8 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
   SS.isSet() ? SS.getWithLocInContext(Context) : NestedNameSpecifierLoc(),
   ConceptName, CD, /*FoundDecl=*/USD ? cast(USD) : CD,
   TypeConstr->LAngleLoc.isValid() ? &TemplateArgs : nullptr,
-  ConstrainedParameter, EllipsisLoc);
+  ConstrainedParameter, Context.getTypeDeclType(ConstrainedParameter),
+  EllipsisLoc);
 }
 
 template 
@@ -1191,6 +1192,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 ConceptDecl *NamedConcept, NamedDecl 
*FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc) {
   // C++2a [temp.param]p4:
   // [...] If Q is of the form C, then let E' be
@@ -1199,7 +1201,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context,
*TemplateArgs) : 
nullptr;
 
-  QualType ParamAsArgument(ConstrainedParameter->getTypeForDecl(), 0);
+  QualType ParamAsArgument = ConstrainedType;
 
   ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint(
   *this, NS, NameInfo, NamedConcept, FoundDecl,
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 7481c700019dc8..a6100310587fa7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1646,6 +1646,21 @@ namespace {
SubstTemplateTypeParmPackTypeLoc TL,
bool SuppressObjCLifetime);
 
+QualType
+TransformSubstTemplateTypeParmType(TypeLocBuilder &TLB,
+   SubstTemplateTypeParmTypeLoc TL) {
+  if (SemaRef.CodeSynthesisContexts.back().Kind !=
+  Sema::CodeSynthesisContext::ConstraintSubstitution)
+return inherited::TransformSubstTemplateTypeParmType(TLB, TL);
+
+  auto PackIndex = TL.getTypePtr()->getPackIndex();
+  std::optional SubstIndex;
+  if (SemaRef.ArgumentPackSubstitutionIndex == -1 && PackIndex)
+SubstIndex.emplace(SemaRef, *PackIndex);
+
+  return inherited::TransformSubstTemplateTypeParmType(TLB, TL);
+}
+
 CXXRecordDecl::LambdaDependencyKind
 ComputeLambdaDependency(LambdaScopeInfo *LSI) {
   if (auto TypeAlias = getEnclosingTypeAliasTemplateDecl(getSema());
@@ -3056,6 +3071,46 @@ namespace {
 
 } // namespace
 
+namespace {
+
+struct ExpandPackedTypeConstraints
+: TreeTransform {
+
+  using inherited = TreeTransform;
+
+  ExpandPackedTypeConstraints(Sema &SemaRef) : inherited(SemaRef) {}
+
+  using inherited::TransformTemplateTypeParmType;
+
+  QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
+ TemplateTypeParmTypeLoc TL, bool) {
+const TemplateTypeParmType *T = TL.getTypePtr();
+if (!T->isParameterPack()) {
+  TemplateTypeParmTypeLoc NewTL =
+  TLB.push(TL.getType());
+  NewTL.setNameLoc(TL.getNameLoc());
+  return TL.getType();
+}
+
+assert(SemaRef.ArgumentPackSubstitutionIndex != -1);
+
+QualType Result = SemaRef.Context.getSubstTemp

[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff c28e268c32a6840d08e3a4dbc9eeb8a0f564d6c0 
f09bb393dc173ba47af49ecf4da6ecfcf969adb1 --extensions cpp,h -- 
clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaTemplate.cpp 
clang/lib/Sema/SemaTemplateInstantiate.cpp clang/lib/Sema/SemaType.cpp 
clang/test/SemaCXX/fold_lambda_with_variadics.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index a610031058..d62ac5c1de 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3144,7 +3144,7 @@ bool Sema::SubstTypeConstraint(
   InstArgs.setLAngleLoc(TemplArgInfo->LAngleLoc);
   InstArgs.setRAngleLoc(TemplArgInfo->RAngleLoc);
   if (ExpandPackedTypeConstraints(*this).SubstTemplateArguments(
-  TemplArgInfo->arguments(), InstArgs))
+  TemplArgInfo->arguments(), InstArgs))
 return true;
 
   // The type of the original parameter.

``




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


[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread Younan Zhang via cfe-commits

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

>From 1deb74f00b518eb595dbe49be3234a05c3753c6f Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 21 Sep 2024 12:48:27 +0800
Subject: [PATCH] [Clang][Sema] Retain the expanding index for unevaluated type
 constraints

---
 clang/include/clang/Sema/Sema.h   |   1 +
 clang/lib/Sema/SemaTemplate.cpp   |   6 +-
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 +-
 clang/lib/Sema/SemaType.cpp   |   8 +-
 .../SemaCXX/fold_lambda_with_variadics.cpp|  54 
 5 files changed, 177 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b86861ce7e8cfa..f711fe952d35e9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11252,6 +11252,7 @@ class Sema final : public SemaBase {
 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc);
 
   bool AttachTypeConstraint(AutoTypeLoc TL,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 16f4542d785715..bdfb0f4c95afb8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1134,7 +1134,8 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
   SS.isSet() ? SS.getWithLocInContext(Context) : NestedNameSpecifierLoc(),
   ConceptName, CD, /*FoundDecl=*/USD ? cast(USD) : CD,
   TypeConstr->LAngleLoc.isValid() ? &TemplateArgs : nullptr,
-  ConstrainedParameter, EllipsisLoc);
+  ConstrainedParameter, Context.getTypeDeclType(ConstrainedParameter),
+  EllipsisLoc);
 }
 
 template 
@@ -1191,6 +1192,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 ConceptDecl *NamedConcept, NamedDecl 
*FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc) {
   // C++2a [temp.param]p4:
   // [...] If Q is of the form C, then let E' be
@@ -1199,7 +1201,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context,
*TemplateArgs) : 
nullptr;
 
-  QualType ParamAsArgument(ConstrainedParameter->getTypeForDecl(), 0);
+  QualType ParamAsArgument = ConstrainedType;
 
   ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint(
   *this, NS, NameInfo, NamedConcept, FoundDecl,
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 7481c700019dc8..d62ac5c1de3cc9 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1646,6 +1646,21 @@ namespace {
SubstTemplateTypeParmPackTypeLoc TL,
bool SuppressObjCLifetime);
 
+QualType
+TransformSubstTemplateTypeParmType(TypeLocBuilder &TLB,
+   SubstTemplateTypeParmTypeLoc TL) {
+  if (SemaRef.CodeSynthesisContexts.back().Kind !=
+  Sema::CodeSynthesisContext::ConstraintSubstitution)
+return inherited::TransformSubstTemplateTypeParmType(TLB, TL);
+
+  auto PackIndex = TL.getTypePtr()->getPackIndex();
+  std::optional SubstIndex;
+  if (SemaRef.ArgumentPackSubstitutionIndex == -1 && PackIndex)
+SubstIndex.emplace(SemaRef, *PackIndex);
+
+  return inherited::TransformSubstTemplateTypeParmType(TLB, TL);
+}
+
 CXXRecordDecl::LambdaDependencyKind
 ComputeLambdaDependency(LambdaScopeInfo *LSI) {
   if (auto TypeAlias = getEnclosingTypeAliasTemplateDecl(getSema());
@@ -3056,6 +3071,46 @@ namespace {
 
 } // namespace
 
+namespace {
+
+struct ExpandPackedTypeConstraints
+: TreeTransform {
+
+  using inherited = TreeTransform;
+
+  ExpandPackedTypeConstraints(Sema &SemaRef) : inherited(SemaRef) {}
+
+  using inherited::TransformTemplateTypeParmType;
+
+  QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
+ TemplateTypeParmTypeLoc TL, bool) {
+const TemplateTypeParmType *T = TL.getTypePtr();
+if (!T->isParameterPack()) {
+  TemplateTypeParmTypeLoc NewTL =
+  TLB.push(TL.getType());
+  NewTL.setNameLoc(TL.getNameLoc());
+  return TL.getType();
+}
+
+assert(SemaRef.ArgumentPackSubstitutionIndex != -1);
+
+QualType Result = SemaRef.Context.getSubstTemplateTypeParmTyp

[clang-tools-extra] [clang-tidy] support static analyzer checker configuration in `--verify-config` (PR #109523)

2024-09-21 Thread via cfe-commits

llvmbot wrote:




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

Author: Julian Schmidt (5chmidti)


Changes

Previously the configuration options for the Clang Static Analyzer
checkers were not recognized for the verification of the configuration
with `--verify-config`.
Add all available configuration options of CSA checkers as possible
configuration options in a clang-tidy config.


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


3 Files Affected:

- (modified) clang-tools-extra/clang-tidy/ClangTidy.cpp (+12) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp 
(+8) 


``diff
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 1cd7cdd10bc25f..62f9d19b2a362f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -672,6 +672,18 @@ getAllChecksAndOptions(bool 
AllowEnablingAnalyzerAlphaCheckers) {
 Buffer.append(AnalyzerCheck);
 Result.Names.insert(Buffer);
   }
+  for (std::string OptionName : {
+#define GET_CHECKER_OPTIONS
+#define CHECKER_OPTION(TYPE, CHECKER, OPTION_NAME, DESCRIPTION, DEFAULT,   
\
+   RELEASE, HIDDEN)
\
+  Twine(AnalyzerCheckNamePrefix).concat(CHECKER ":" OPTION_NAME).str(),
+
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER_OPTION
+#undef GET_CHECKER_OPTIONS
+   }) {
+Result.Options.insert(OptionName);
+  }
 #endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
 
   Context.setOptionsCollector(&Result.Options);
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 8d0c093b312dd5..877db81a1ca235 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,6 +98,10 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Improved :program:`clang-tidy`'s `--verify-config` flag by adding support for
+  the configuration options of the `Clang Static Analyzer Checks
+  `_.
+
 New checks
 ^^
 
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
index 3659285986482a..93f6f9fc156a45 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
@@ -30,3 +30,11 @@
 // CHECK-VERIFY-BLOCK-BAD: command-line option '-config': warning: check glob 
'bugprone-arguments-*' doesn't match any known check [-verify-config]
 // CHECK-VERIFY-BLOCK-BAD: command-line option '-config': warning: unknown 
check 'bugprone-assert-side-effects'; did you mean 
'bugprone-assert-side-effect' [-verify-config]
 
+// RUN: echo -e 'Checks: 
"-*,clang-analyzer-optin.cplusplus.UninitializedObject"\nCheckOptions:\n 
clang-analyzer-optin.cplusplus.UninitializedObject:Pedantic: true' > 
%T/MyClangTidyConfigCSA
+// RUN: clang-tidy --verify-config --config-file=%T/MyClangTidyConfigCSA 2>&1 
| FileCheck %s -check-prefix=CHECK-VERIFY-CSA-OK 
-implicit-check-not='{{warnings|error}}'
+// CHECK-VERIFY-CSA-OK: No config errors detected.
+
+// RUN: echo -e 'Checks: 
"-*,clang-analyzer-optin.cplusplus.UninitializedObject"\nCheckOptions:\n 
clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic: true' > 
%T/MyClangTidyConfigCSABad
+// RUN: not clang-tidy --verify-config 
--config-file=%T/MyClangTidyConfigCSABad 2>&1 | FileCheck %s 
-check-prefix=CHECK-VERIFY-CSA-BAD -implicit-check-not='{{warnings|error}}'
+// CHECK-VERIFY-CSA-BAD: command-line option '-config': warning: unknown check 
option 'clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic'; did you 
mean 'clang-analyzer-optin.cplusplus.UninitializedObject:Pedantic' 
[-verify-config]
+

``




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


[clang-tools-extra] [clang-tidy] support static analyzer checker configuration in `--verify-config` (PR #109523)

2024-09-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Julian Schmidt (5chmidti)


Changes

Previously the configuration options for the Clang Static Analyzer
checkers were not recognized for the verification of the configuration
with `--verify-config`.
Add all available configuration options of CSA checkers as possible
configuration options in a clang-tidy config.


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


3 Files Affected:

- (modified) clang-tools-extra/clang-tidy/ClangTidy.cpp (+12) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp 
(+8) 


``diff
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 1cd7cdd10bc25f..62f9d19b2a362f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -672,6 +672,18 @@ getAllChecksAndOptions(bool 
AllowEnablingAnalyzerAlphaCheckers) {
 Buffer.append(AnalyzerCheck);
 Result.Names.insert(Buffer);
   }
+  for (std::string OptionName : {
+#define GET_CHECKER_OPTIONS
+#define CHECKER_OPTION(TYPE, CHECKER, OPTION_NAME, DESCRIPTION, DEFAULT,   
\
+   RELEASE, HIDDEN)
\
+  Twine(AnalyzerCheckNamePrefix).concat(CHECKER ":" OPTION_NAME).str(),
+
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER_OPTION
+#undef GET_CHECKER_OPTIONS
+   }) {
+Result.Options.insert(OptionName);
+  }
 #endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
 
   Context.setOptionsCollector(&Result.Options);
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 8d0c093b312dd5..877db81a1ca235 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,6 +98,10 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Improved :program:`clang-tidy`'s `--verify-config` flag by adding support for
+  the configuration options of the `Clang Static Analyzer Checks
+  `_.
+
 New checks
 ^^
 
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
index 3659285986482a..93f6f9fc156a45 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
@@ -30,3 +30,11 @@
 // CHECK-VERIFY-BLOCK-BAD: command-line option '-config': warning: check glob 
'bugprone-arguments-*' doesn't match any known check [-verify-config]
 // CHECK-VERIFY-BLOCK-BAD: command-line option '-config': warning: unknown 
check 'bugprone-assert-side-effects'; did you mean 
'bugprone-assert-side-effect' [-verify-config]
 
+// RUN: echo -e 'Checks: 
"-*,clang-analyzer-optin.cplusplus.UninitializedObject"\nCheckOptions:\n 
clang-analyzer-optin.cplusplus.UninitializedObject:Pedantic: true' > 
%T/MyClangTidyConfigCSA
+// RUN: clang-tidy --verify-config --config-file=%T/MyClangTidyConfigCSA 2>&1 
| FileCheck %s -check-prefix=CHECK-VERIFY-CSA-OK 
-implicit-check-not='{{warnings|error}}'
+// CHECK-VERIFY-CSA-OK: No config errors detected.
+
+// RUN: echo -e 'Checks: 
"-*,clang-analyzer-optin.cplusplus.UninitializedObject"\nCheckOptions:\n 
clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic: true' > 
%T/MyClangTidyConfigCSABad
+// RUN: not clang-tidy --verify-config 
--config-file=%T/MyClangTidyConfigCSABad 2>&1 | FileCheck %s 
-check-prefix=CHECK-VERIFY-CSA-BAD -implicit-check-not='{{warnings|error}}'
+// CHECK-VERIFY-CSA-BAD: command-line option '-config': warning: unknown check 
option 'clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic'; did you 
mean 'clang-analyzer-optin.cplusplus.UninitializedObject:Pedantic' 
[-verify-config]
+

``




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


[clang-tools-extra] [clang-tidy] support static analyzer checker configuration in `--verify-config` (PR #109523)

2024-09-21 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti created 
https://github.com/llvm/llvm-project/pull/109523

Previously the configuration options for the Clang Static Analyzer
checkers were not recognized for the verification of the configuration
with `--verify-config`.
Add all available configuration options of CSA checkers as possible
configuration options in a clang-tidy config.


>From 8364d6def042734fe1efc1396646d160f3355a52 Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Fri, 20 Sep 2024 01:52:31 +0200
Subject: [PATCH] [clang-tidy] support static analyzer checker configuration in
 `--verify-config`

Previously the configuration options for the Clang Static Analyzer
checkers were not recognized for the verification of the configuration
with `--verify-config`.
Add all available configuration options of CSA checkers as possible
configuration options in a clang-tidy config.
---
 clang-tools-extra/clang-tidy/ClangTidy.cpp   | 12 
 clang-tools-extra/docs/ReleaseNotes.rst  |  4 
 .../test/clang-tidy/infrastructure/verify-config.cpp |  8 
 3 files changed, 24 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp 
b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 1cd7cdd10bc25f..62f9d19b2a362f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -672,6 +672,18 @@ getAllChecksAndOptions(bool 
AllowEnablingAnalyzerAlphaCheckers) {
 Buffer.append(AnalyzerCheck);
 Result.Names.insert(Buffer);
   }
+  for (std::string OptionName : {
+#define GET_CHECKER_OPTIONS
+#define CHECKER_OPTION(TYPE, CHECKER, OPTION_NAME, DESCRIPTION, DEFAULT,   
\
+   RELEASE, HIDDEN)
\
+  Twine(AnalyzerCheckNamePrefix).concat(CHECKER ":" OPTION_NAME).str(),
+
+#include "clang/StaticAnalyzer/Checkers/Checkers.inc"
+#undef CHECKER_OPTION
+#undef GET_CHECKER_OPTIONS
+   }) {
+Result.Options.insert(OptionName);
+  }
 #endif // CLANG_TIDY_ENABLE_STATIC_ANALYZER
 
   Context.setOptionsCollector(&Result.Options);
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 8d0c093b312dd5..877db81a1ca235 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,6 +98,10 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Improved :program:`clang-tidy`'s `--verify-config` flag by adding support for
+  the configuration options of the `Clang Static Analyzer Checks
+  `_.
+
 New checks
 ^^
 
diff --git a/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp 
b/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
index 3659285986482a..93f6f9fc156a45 100644
--- a/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
+++ b/clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
@@ -30,3 +30,11 @@
 // CHECK-VERIFY-BLOCK-BAD: command-line option '-config': warning: check glob 
'bugprone-arguments-*' doesn't match any known check [-verify-config]
 // CHECK-VERIFY-BLOCK-BAD: command-line option '-config': warning: unknown 
check 'bugprone-assert-side-effects'; did you mean 
'bugprone-assert-side-effect' [-verify-config]
 
+// RUN: echo -e 'Checks: 
"-*,clang-analyzer-optin.cplusplus.UninitializedObject"\nCheckOptions:\n 
clang-analyzer-optin.cplusplus.UninitializedObject:Pedantic: true' > 
%T/MyClangTidyConfigCSA
+// RUN: clang-tidy --verify-config --config-file=%T/MyClangTidyConfigCSA 2>&1 
| FileCheck %s -check-prefix=CHECK-VERIFY-CSA-OK 
-implicit-check-not='{{warnings|error}}'
+// CHECK-VERIFY-CSA-OK: No config errors detected.
+
+// RUN: echo -e 'Checks: 
"-*,clang-analyzer-optin.cplusplus.UninitializedObject"\nCheckOptions:\n 
clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic: true' > 
%T/MyClangTidyConfigCSABad
+// RUN: not clang-tidy --verify-config 
--config-file=%T/MyClangTidyConfigCSABad 2>&1 | FileCheck %s 
-check-prefix=CHECK-VERIFY-CSA-BAD -implicit-check-not='{{warnings|error}}'
+// CHECK-VERIFY-CSA-BAD: command-line option '-config': warning: unknown check 
option 'clang-analyzer-optin.cplusplus.UninitializedObject.Pedantic'; did you 
mean 'clang-analyzer-optin.cplusplus.UninitializedObject:Pedantic' 
[-verify-config]
+

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


[clang] f5a65d8 - [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (#108949)

2024-09-21 Thread via cfe-commits

Author: yronglin
Date: 2024-09-21T17:05:24+08:00
New Revision: f5a65d8752f26245744ae3e1365cc3ac283c2638

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

LOG: [clang][bytecode] Implement arithmetic, bitwise and compound assignment 
operator (#108949)

Implement `+`, `-`, `*`, `/` , `%`, `&`, `|`, `^`, `<<`, `>>` and
compound assignment operator.

-

Signed-off-by: yronglin 

Added: 


Modified: 
clang/lib/AST/ByteCode/Compiler.cpp
clang/test/AST/ByteCode/constexpr-vectors.cpp
clang/test/AST/ByteCode/vectors.cpp
clang/test/SemaCXX/constexpr-vectors.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 161b6a9bb36ec7..31aa400937e36a 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1267,12 +1267,8 @@ bool Compiler::VisitVectorBinOp(const 
BinaryOperator *E) {
   assert(E->getLHS()->getType()->isVectorType());
   assert(E->getRHS()->getType()->isVectorType());
 
-  // FIXME: Current only support comparison binary operator, add support for
-  // other binary operator.
-  if (!E->isComparisonOp() && !E->isLogicalOp())
-return this->emitInvalid(E);
   // Prepare storage for result.
-  if (!Initializing) {
+  if (!Initializing && !E->isCompoundAssignmentOp()) {
 unsigned LocalIndex = allocateTemporary(E);
 if (!this->emitGetPtrLocal(LocalIndex, E))
   return false;
@@ -1281,6 +1277,9 @@ bool Compiler::VisitVectorBinOp(const 
BinaryOperator *E) {
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
   const auto *VecTy = E->getType()->getAs();
+  auto Op = E->isCompoundAssignmentOp()
+? BinaryOperator::getOpForCompoundAssignment(E->getOpcode())
+: E->getOpcode();
 
   // The LHS and RHS of a comparison operator must have the same type. So we
   // just use LHS vector element type here.
@@ -1301,6 +1300,17 @@ bool Compiler::VisitVectorBinOp(const 
BinaryOperator *E) {
   if (!this->emitSetLocal(PT_Ptr, RHSOffset, E))
 return false;
 
+  if (E->isCompoundAssignmentOp() && !this->emitGetLocal(PT_Ptr, LHSOffset, E))
+return false;
+
+  // BitAdd/BitOr/BitXor/Shl/Shr doesn't support bool type, we need perform the
+  // integer promotion.
+  bool NeedIntPromot = ElemT == PT_Bool && (E->isBitwiseOp() || 
E->isShiftOp());
+  QualType PromotTy =
+  Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
+  PrimType PromotT = classifyPrim(PromotTy);
+  PrimType OpT = NeedIntPromot ? PromotT : ElemT;
+
   auto getElem = [=](unsigned Offset, unsigned Index) {
 if (!this->emitGetLocal(PT_Ptr, Offset, E))
   return false;
@@ -1311,16 +1321,63 @@ bool Compiler::VisitVectorBinOp(const 
BinaryOperator *E) {
 return false;
   if (!this->emitPrimCast(PT_Bool, ResultElemT, VecTy->getElementType(), 
E))
 return false;
+} else if (NeedIntPromot) {
+  if (!this->emitPrimCast(ElemT, PromotT, PromotTy, E))
+return false;
 }
 return true;
   };
 
+#define EMIT_ARITH_OP(OP)  
\
+  {
\
+if (ElemT == PT_Float) {   
\
+  if (!this->emit##OP##f(getFPOptions(E), E))  
\
+return false;  
\
+} else {   
\
+  if (!this->emit##OP(ElemT, E))   
\
+return false;  
\
+}  
\
+break; 
\
+  }
+
   for (unsigned I = 0; I != VecTy->getNumElements(); ++I) {
 if (!getElem(LHSOffset, I))
   return false;
 if (!getElem(RHSOffset, I))
   return false;
-switch (E->getOpcode()) {
+switch (Op) {
+case BO_Add:
+  EMIT_ARITH_OP(Add)
+case BO_Sub:
+  EMIT_ARITH_OP(Sub)
+case BO_Mul:
+  EMIT_ARITH_OP(Mul)
+case BO_Div:
+  EMIT_ARITH_OP(Div)
+case BO_Rem:
+  if (!this->emitRem(ElemT, E))
+return false;
+  break;
+case BO_And:
+  if (!this->emitBitAnd(OpT, E))
+return false;
+  break;
+case BO_Or:
+  if (!this->emitBitOr(OpT, E))
+return false;
+  break;
+case BO_Xor:
+  if (!this->emitBitXor(OpT, E))
+return false;
+  break;
+case BO_Shl:
+  if (!this->emitShl(OpT, ElemT, E))
+return false;
+  break;
+case BO_Shr:
+  if (!this->e

[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread via cfe-commits

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


[clang] [clang][bytecode] Create dummy pointers for ObjCStringLiterals (PR #109520)

2024-09-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 10 (Add check check-offload) failure: 1200 seconds without output running 
[b'ninja', b'-j 32', b'check-offload'], attempting to kill
...
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug47654.cpp 
(866 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug53727.cpp 
(867 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug50022.cpp 
(868 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/test_libc.cpp 
(869 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu :: offloading/bug49021.cpp (870 
of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/wtime.c (871 
of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu :: 
offloading/std_complex_arithmetic.cpp (872 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: 
offloading/complex_reduction.cpp (873 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: offloading/bug49021.cpp 
(874 of 879)
PASS: libomptarget :: x86_64-unknown-linux-gnu-LTO :: 
offloading/std_complex_arithmetic.cpp (875 of 879)
command timed out: 1200 seconds without output running [b'ninja', b'-j 32', 
b'check-offload'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1236.179502

```



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


[clang-tools-extra] [clang-tidy] modernize-use-nullptr matches "NULL" in templates (PR #109169)

2024-09-21 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti approved this pull request.


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


[clang] [flang] [llvm] [mlir] Make MMIWP not have ownership over MMI + Make MMI Only Use an External MCContext (PR #105541)

2024-09-21 Thread Matin Raayai via cfe-commits

matinraayai wrote:

@aeubanks @arsenm after looking into this in more detail, I realized that the 
`getContext` method of `MMI` is heavily used in the `AsmPrinter` to create 
symbols. Also not having it makes it harder for the `MMI` to create machine 
functions using `getOrCreateMachineFunction`. 

Hence I don't think it's a good idea to remove the `MCContext` reference from 
`MMI`. 

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


[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread Younan Zhang via cfe-commits

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


[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

(This continues the effort of #86265, fixing another piece of issue in 
constraint evaluation on variadic lambdas.)

We need the depth of the primary template parameters for constraint 
substitution. To that end, we avoided substituting type constraints by copying 
the constraint expression when instantiating a template. This, however, has 
left an issue in that for lambda's parameters, they can reference outer 
template packs that would be expanded in the process of an instantiation, where 
these parameters would make their way into the constraint evaluation, wherein 
we have no other way to expand them later in evaluation. For example,

```cpp
template  void foo() {
   bar([](C auto value) {}...);
}
```

The lambda references a pack `Ts` that should be expanded when instantiating 
`foo()`. The `Ts` along with the constraint expression would not be transformed 
until constraint evaluation, and at that point, we would have no chance to 
expand `Ts` anyhow.

This patch takes an approach that transforms `Ts` from an unexpanded 
TemplateTypeParmType into a SubstTemplateTypeParmType with the current pack 
substitution index, such that we could use that to expand the type during 
evaluation. 

Fixes #101754

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


6 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Sema/Sema.h (+1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+4-2) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+124-3) 
- (modified) clang/lib/Sema/SemaType.cpp (+6-2) 
- (modified) clang/test/SemaCXX/fold_lambda_with_variadics.cpp (+54) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f4535db7356194..c069bb0b4fa597 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -407,6 +407,8 @@ Bug Fixes to C++ Support
 - Clang now uses the correct set of template argument lists when comparing the 
constraints of
   out-of-line definitions and member templates explicitly specialized for a 
given implicit instantiation of
   a class template. (#GH102320)
+- Fixed an issue in constraint evaluation, where type constraints on the 
lambda expression
+  containing outer unexpanded parameters were not correctly expanded. 
(#GH101754)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b86861ce7e8cfa..f711fe952d35e9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11252,6 +11252,7 @@ class Sema final : public SemaBase {
 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc);
 
   bool AttachTypeConstraint(AutoTypeLoc TL,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 16f4542d785715..bdfb0f4c95afb8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1134,7 +1134,8 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
   SS.isSet() ? SS.getWithLocInContext(Context) : NestedNameSpecifierLoc(),
   ConceptName, CD, /*FoundDecl=*/USD ? cast(USD) : CD,
   TypeConstr->LAngleLoc.isValid() ? &TemplateArgs : nullptr,
-  ConstrainedParameter, EllipsisLoc);
+  ConstrainedParameter, Context.getTypeDeclType(ConstrainedParameter),
+  EllipsisLoc);
 }
 
 template 
@@ -1191,6 +1192,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 ConceptDecl *NamedConcept, NamedDecl 
*FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc) {
   // C++2a [temp.param]p4:
   // [...] If Q is of the form C, then let E' be
@@ -1199,7 +1201,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context,
*TemplateArgs) : 
nullptr;
 
-  QualType ParamAsArgument(ConstrainedParameter->getTypeForDecl(), 0);
+  QualType ParamAsArgument = ConstrainedType;
 
   ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint(
   *this, NS, NameInfo, NamedConcept, FoundDecl,
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 7481c700019dc8..34635ef3860803 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInst

[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread Younan Zhang via cfe-commits

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


[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread Younan Zhang via cfe-commits

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


[clang] [Clang][Sema] Retain the expanding index for unevaluated type constraints (PR #109518)

2024-09-21 Thread Younan Zhang via cfe-commits

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

>From 1deb74f00b518eb595dbe49be3234a05c3753c6f Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sat, 21 Sep 2024 12:48:27 +0800
Subject: [PATCH 1/3] [Clang][Sema] Retain the expanding index for unevaluated
 type constraints

---
 clang/include/clang/Sema/Sema.h   |   1 +
 clang/lib/Sema/SemaTemplate.cpp   |   6 +-
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 115 +-
 clang/lib/Sema/SemaType.cpp   |   8 +-
 .../SemaCXX/fold_lambda_with_variadics.cpp|  54 
 5 files changed, 177 insertions(+), 7 deletions(-)

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b86861ce7e8cfa..f711fe952d35e9 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11252,6 +11252,7 @@ class Sema final : public SemaBase {
 ConceptDecl *NamedConcept, NamedDecl *FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc);
 
   bool AttachTypeConstraint(AutoTypeLoc TL,
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 16f4542d785715..bdfb0f4c95afb8 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1134,7 +1134,8 @@ bool Sema::BuildTypeConstraint(const CXXScopeSpec &SS,
   SS.isSet() ? SS.getWithLocInContext(Context) : NestedNameSpecifierLoc(),
   ConceptName, CD, /*FoundDecl=*/USD ? cast(USD) : CD,
   TypeConstr->LAngleLoc.isValid() ? &TemplateArgs : nullptr,
-  ConstrainedParameter, EllipsisLoc);
+  ConstrainedParameter, Context.getTypeDeclType(ConstrainedParameter),
+  EllipsisLoc);
 }
 
 template 
@@ -1191,6 +1192,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 ConceptDecl *NamedConcept, NamedDecl 
*FoundDecl,
 const TemplateArgumentListInfo *TemplateArgs,
 TemplateTypeParmDecl *ConstrainedParameter,
+QualType ConstrainedType,
 SourceLocation EllipsisLoc) {
   // C++2a [temp.param]p4:
   // [...] If Q is of the form C, then let E' be
@@ -1199,7 +1201,7 @@ bool Sema::AttachTypeConstraint(NestedNameSpecifierLoc NS,
 TemplateArgs ? ASTTemplateArgumentListInfo::Create(Context,
*TemplateArgs) : 
nullptr;
 
-  QualType ParamAsArgument(ConstrainedParameter->getTypeForDecl(), 0);
+  QualType ParamAsArgument = ConstrainedType;
 
   ExprResult ImmediatelyDeclaredConstraint = formImmediatelyDeclaredConstraint(
   *this, NS, NameInfo, NamedConcept, FoundDecl,
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 7481c700019dc8..d62ac5c1de3cc9 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1646,6 +1646,21 @@ namespace {
SubstTemplateTypeParmPackTypeLoc TL,
bool SuppressObjCLifetime);
 
+QualType
+TransformSubstTemplateTypeParmType(TypeLocBuilder &TLB,
+   SubstTemplateTypeParmTypeLoc TL) {
+  if (SemaRef.CodeSynthesisContexts.back().Kind !=
+  Sema::CodeSynthesisContext::ConstraintSubstitution)
+return inherited::TransformSubstTemplateTypeParmType(TLB, TL);
+
+  auto PackIndex = TL.getTypePtr()->getPackIndex();
+  std::optional SubstIndex;
+  if (SemaRef.ArgumentPackSubstitutionIndex == -1 && PackIndex)
+SubstIndex.emplace(SemaRef, *PackIndex);
+
+  return inherited::TransformSubstTemplateTypeParmType(TLB, TL);
+}
+
 CXXRecordDecl::LambdaDependencyKind
 ComputeLambdaDependency(LambdaScopeInfo *LSI) {
   if (auto TypeAlias = getEnclosingTypeAliasTemplateDecl(getSema());
@@ -3056,6 +3071,46 @@ namespace {
 
 } // namespace
 
+namespace {
+
+struct ExpandPackedTypeConstraints
+: TreeTransform {
+
+  using inherited = TreeTransform;
+
+  ExpandPackedTypeConstraints(Sema &SemaRef) : inherited(SemaRef) {}
+
+  using inherited::TransformTemplateTypeParmType;
+
+  QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB,
+ TemplateTypeParmTypeLoc TL, bool) {
+const TemplateTypeParmType *T = TL.getTypePtr();
+if (!T->isParameterPack()) {
+  TemplateTypeParmTypeLoc NewTL =
+  TLB.push(TL.getType());
+  NewTL.setNameLoc(TL.getNameLoc());
+  return TL.getType();
+}
+
+assert(SemaRef.ArgumentPackSubstitutionIndex != -1);
+
+QualType Result = SemaRef.Context.getSubstTemplateTypePar

[clang] [clang-offload-bundler] Avoid repeated hash lookups (NFC) (PR #109507)

2024-09-21 Thread Nikita Popov via cfe-commits

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


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


[clang] 5b4c80f - [clang][bytecode] Create dummy pointers for ObjCStringLiterals (#109520)

2024-09-21 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-21T10:33:02+02:00
New Revision: 5b4c80f1234f176c19bdbe687861e7f076ec189a

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

LOG: [clang][bytecode] Create dummy pointers for ObjCStringLiterals (#109520)

We need to have the final APValue point to the ObjCStringLiteral
expression, not the StringLiteral itself.

Added: 
clang/test/AST/ByteCode/codegen.m

Modified: 
clang/lib/AST/ByteCode/Compiler.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7e0775a51aee61..161b6a9bb36ec7 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2134,7 +2134,9 @@ bool Compiler::VisitStringLiteral(const 
StringLiteral *E) {
 
 template 
 bool Compiler::VisitObjCStringLiteral(const ObjCStringLiteral *E) {
-  return this->delegate(E->getString());
+  if (std::optional I = P.getOrCreateDummy(E))
+return this->emitGetPtrGlobal(*I, E);
+  return false;
 }
 
 template 

diff  --git a/clang/test/AST/ByteCode/codegen.m 
b/clang/test/AST/ByteCode/codegen.m
new file mode 100644
index 00..08c3d9a70b36d7
--- /dev/null
+++ b/clang/test/AST/ByteCode/codegen.m
@@ -0,0 +1,12 @@
+// REQUIRES: x86-registered-target
+
+/// See test/CodeGenObjC/constant-strings.m
+/// Test that we let the APValue we create for ObjCStringLiterals point to the 
right expression.
+
+// RUN: %clang_cc1 -triple x86_64-macho -emit-llvm -o %t %s 
-fexperimental-new-constant-interpreter
+// RUN: FileCheck --check-prefix=CHECK-NEXT < %t %s
+
+// Check that we set alignment 1 on the string.
+//
+// CHECK-NEXT: @.str = {{.*}}constant [13 x i8] c"Hello World!\00", section 
"__TEXT,__cstring,cstring_literals", align 1
+id a = @"Hello World!";



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


[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/108949

>From 3601f708847f70485fae640c5b5d96fed965e7c3 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Tue, 17 Sep 2024 17:39:47 +0800
Subject: [PATCH 1/5] [clang][bytecode] Implement arithmetic, bitwise and
 compound assignment operator

Signed-off-by: yronglin 
---
 clang/lib/AST/ByteCode/Compiler.cpp   | 121 +++-
 clang/test/AST/ByteCode/constexpr-vectors.cpp | 519 +-
 clang/test/SemaCXX/constexpr-vectors.cpp  |   1 +
 3 files changed, 611 insertions(+), 30 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7e0775a51aee61..e7a6df58e6f1a6 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -1267,12 +1267,8 @@ bool Compiler::VisitVectorBinOp(const 
BinaryOperator *E) {
   assert(E->getLHS()->getType()->isVectorType());
   assert(E->getRHS()->getType()->isVectorType());
 
-  // FIXME: Current only support comparison binary operator, add support for
-  // other binary operator.
-  if (!E->isComparisonOp() && !E->isLogicalOp())
-return this->emitInvalid(E);
   // Prepare storage for result.
-  if (!Initializing) {
+  if (!Initializing || E->isCompoundAssignmentOp()) {
 unsigned LocalIndex = allocateTemporary(E);
 if (!this->emitGetPtrLocal(LocalIndex, E))
   return false;
@@ -1281,26 +1277,67 @@ bool Compiler::VisitVectorBinOp(const 
BinaryOperator *E) {
   const Expr *LHS = E->getLHS();
   const Expr *RHS = E->getRHS();
   const auto *VecTy = E->getType()->getAs();
+  auto Op = E->isCompoundAssignmentOp()
+? BinaryOperator::getOpForCompoundAssignment(E->getOpcode())
+: E->getOpcode();
 
   // The LHS and RHS of a comparison operator must have the same type. So we
   // just use LHS vector element type here.
   PrimType ElemT = this->classifyVectorElementType(LHS->getType());
   PrimType ResultElemT = this->classifyVectorElementType(E->getType());
 
-  // Evaluate LHS and save value to LHSOffset.
+  // Allocate a local pointer for LHS and RHS.
   unsigned LHSOffset = this->allocateLocalPrimitive(LHS, PT_Ptr, true, false);
+  unsigned RHSOffset = this->allocateLocalPrimitive(RHS, PT_Ptr, true, false);
+
+  // C++17 onwards require that we evaluate the RHS of the compound
+  // assignment op first.
+  if (E->isCompoundAssignmentOp()) {
+// Evaluate RHS and save value to RHSOffset.
+if (!this->visit(RHS))
+  return false;
+if (!this->emitSetLocal(PT_Ptr, RHSOffset, E))
+  return false;
+
+// Evaluate LHS and save value to LHSOffset.
+if (!this->visit(LHS))
+  return false;
+if (!this->emitSetLocal(PT_Ptr, LHSOffset, E))
+  return false;
+  } else {
+// Evaluate LHS and save value to LHSOffset.
+if (!this->visit(LHS))
+  return false;
+if (!this->emitSetLocal(PT_Ptr, LHSOffset, E))
+  return false;
+
+// Evaluate RHS and save value to RHSOffset.
+if (!this->visit(RHS))
+  return false;
+if (!this->emitSetLocal(PT_Ptr, RHSOffset, E))
+  return false;
+  }
+
+  // Evaluate LHS and save value to LHSOffset.
   if (!this->visit(LHS))
 return false;
   if (!this->emitSetLocal(PT_Ptr, LHSOffset, E))
 return false;
 
   // Evaluate RHS and save value to RHSOffset.
-  unsigned RHSOffset = this->allocateLocalPrimitive(RHS, PT_Ptr, true, false);
   if (!this->visit(RHS))
 return false;
   if (!this->emitSetLocal(PT_Ptr, RHSOffset, E))
 return false;
 
+  // BitAdd/BitOr/BitXor/Shl/Shr doesn't support bool type, we need perform the
+  // integer promotion.
+  bool NeedIntPromot = ElemT == PT_Bool && (E->isBitwiseOp() || 
E->isShiftOp());
+  QualType PromotTy =
+  Ctx.getASTContext().getPromotedIntegerType(Ctx.getASTContext().BoolTy);
+  PrimType PromotT = classifyPrim(PromotTy);
+  PrimType OpT = NeedIntPromot ? PromotT : ElemT;
+
   auto getElem = [=](unsigned Offset, unsigned Index) {
 if (!this->emitGetLocal(PT_Ptr, Offset, E))
   return false;
@@ -1311,16 +1348,63 @@ bool Compiler::VisitVectorBinOp(const 
BinaryOperator *E) {
 return false;
   if (!this->emitPrimCast(PT_Bool, ResultElemT, VecTy->getElementType(), 
E))
 return false;
+} else if (NeedIntPromot) {
+  if (!this->emitPrimCast(ElemT, PromotT, PromotTy, E))
+return false;
 }
 return true;
   };
 
+#define EMIT_ARITH_OP(OP)  
\
+  {
\
+if (ElemT == PT_Float) {   
\
+  if (!this->emit##OP##f(getFPOptions(E), E))  
\
+return false;  
\
+} else {   
\
+  if (!this->emit##OP(ElemT, E)) 

[clang] [clang][bytecode] Fix reporting non-constant variables in C (PR #109516)

2024-09-21 Thread Timm Baeder via cfe-commits

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


[clang] Updated and renamed README.txt to README.md (PR #106198)

2024-09-21 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang] [clang][bytecode] Create dummy pointers for ObjCStringLiterals (PR #109520)

2024-09-21 Thread Timm Baeder via cfe-commits

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

We need to have the final APValue point to the ObjCStringLiteral expression, 
not the StringLiteral itself.

>From ca2960bcb2307c415547ef12fa3628aec4d4d702 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sat, 21 Sep 2024 09:56:44 +0200
Subject: [PATCH] [clang][bytecode] Create dummy pointers for
 ObjCStringLiterals

We need to have the final APValue point to the ObjCStringLiteral
expression, not the StringLiteral itself.
---
 clang/lib/AST/ByteCode/Compiler.cpp |  4 +++-
 clang/test/AST/ByteCode/codegen.m   | 12 
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/AST/ByteCode/codegen.m

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7e0775a51aee61..161b6a9bb36ec7 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2134,7 +2134,9 @@ bool Compiler::VisitStringLiteral(const 
StringLiteral *E) {
 
 template 
 bool Compiler::VisitObjCStringLiteral(const ObjCStringLiteral *E) {
-  return this->delegate(E->getString());
+  if (std::optional I = P.getOrCreateDummy(E))
+return this->emitGetPtrGlobal(*I, E);
+  return false;
 }
 
 template 
diff --git a/clang/test/AST/ByteCode/codegen.m 
b/clang/test/AST/ByteCode/codegen.m
new file mode 100644
index 00..08c3d9a70b36d7
--- /dev/null
+++ b/clang/test/AST/ByteCode/codegen.m
@@ -0,0 +1,12 @@
+// REQUIRES: x86-registered-target
+
+/// See test/CodeGenObjC/constant-strings.m
+/// Test that we let the APValue we create for ObjCStringLiterals point to the 
right expression.
+
+// RUN: %clang_cc1 -triple x86_64-macho -emit-llvm -o %t %s 
-fexperimental-new-constant-interpreter
+// RUN: FileCheck --check-prefix=CHECK-NEXT < %t %s
+
+// Check that we set alignment 1 on the string.
+//
+// CHECK-NEXT: @.str = {{.*}}constant [13 x i8] c"Hello World!\00", section 
"__TEXT,__cstring,cstring_literals", align 1
+id a = @"Hello World!";

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


[clang] [clang][bytecode] Create dummy pointers for ObjCStringLiterals (PR #109520)

2024-09-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

We need to have the final APValue point to the ObjCStringLiteral expression, 
not the StringLiteral itself.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+3-1) 
- (added) clang/test/AST/ByteCode/codegen.m (+12) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7e0775a51aee61..161b6a9bb36ec7 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2134,7 +2134,9 @@ bool Compiler::VisitStringLiteral(const 
StringLiteral *E) {
 
 template 
 bool Compiler::VisitObjCStringLiteral(const ObjCStringLiteral *E) {
-  return this->delegate(E->getString());
+  if (std::optional I = P.getOrCreateDummy(E))
+return this->emitGetPtrGlobal(*I, E);
+  return false;
 }
 
 template 
diff --git a/clang/test/AST/ByteCode/codegen.m 
b/clang/test/AST/ByteCode/codegen.m
new file mode 100644
index 00..08c3d9a70b36d7
--- /dev/null
+++ b/clang/test/AST/ByteCode/codegen.m
@@ -0,0 +1,12 @@
+// REQUIRES: x86-registered-target
+
+/// See test/CodeGenObjC/constant-strings.m
+/// Test that we let the APValue we create for ObjCStringLiterals point to the 
right expression.
+
+// RUN: %clang_cc1 -triple x86_64-macho -emit-llvm -o %t %s 
-fexperimental-new-constant-interpreter
+// RUN: FileCheck --check-prefix=CHECK-NEXT < %t %s
+
+// Check that we set alignment 1 on the string.
+//
+// CHECK-NEXT: @.str = {{.*}}constant [13 x i8] c"Hello World!\00", section 
"__TEXT,__cstring,cstring_literals", align 1
+id a = @"Hello World!";

``




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


[clang] c57b9f5 - [clang][bytecode] Fix reporting non-constant variables in C (#109516)

2024-09-21 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-21T09:58:56+02:00
New Revision: c57b9f5a138d9a7ce0744e4fdb85ff31dc5f2cac

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

LOG: [clang][bytecode] Fix reporting non-constant variables in C (#109516)

We need to call FFDiag() to get the usual "invalid subexpression"
diagnostic.

Added: 


Modified: 
clang/lib/AST/ByteCode/Interp.cpp
clang/test/Sema/annotate-type.c

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 65b4c0a9cb7660..ede52de1c5e7b2 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -90,10 +90,12 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr 
OpPC,
 
 static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
  const ValueDecl *VD) {
-  if (!S.getLangOpts().CPlusPlus)
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  if (!S.getLangOpts().CPlusPlus) {
+S.FFDiag(Loc);
 return;
+  }
 
-  const SourceInfo &Loc = S.Current->getSource(OpPC);
   if (const auto *VarD = dyn_cast(VD);
   VarD && VarD->getType().isConstQualified() &&
   !VarD->getAnyInitializer()) {

diff  --git a/clang/test/Sema/annotate-type.c b/clang/test/Sema/annotate-type.c
index 901cef7ffa8b3a..bf1632d302e554 100644
--- a/clang/test/Sema/annotate-type.c
+++ b/clang/test/Sema/annotate-type.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify 
-fexperimental-new-constant-interpreter
 
 const char *some_function();
 



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


[clang] Updated and renamed README.txt to README.md (PR #106198)

2024-09-21 Thread via cfe-commits

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


[clang] [clang][bytecode] Diagnose weak reads in final load (PR #109515)

2024-09-21 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[179/183] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64-with-call.o
[180/183] Generating Msan-aarch64-with-call-Test
[181/183] Generating MSAN_INST_TEST_OBJECTS.msan_test.cpp.aarch64.o
[182/183] Generating Msan-aarch64-Test
[182/183] Running compiler_rt regression tests
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276:
 warning: input 
'/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/interception/Unit'
 contained no tests
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/discovery.py:276:
 warning: input 
'/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/Unit'
 contained no tests
llvm-lit: 
/home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 5738 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: libFuzzer-aarch64-static-libcxx-Linux :: reduce_inputs.test (5698 of 5738)
 TEST 'libFuzzer-aarch64-static-libcxx-Linux :: 
reduce_inputs.test' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: rm -rf 
/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
+ rm -rf 
/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
RUN: at line 4: mkdir -p 
/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
+ mkdir -p 
/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp/C
RUN: at line 5: /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang 
   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer  
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta  
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowSimpleTest.cpp
 -o 
/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowSimpleTest
+ /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowSimpleTest.cpp
 -o 
/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowSimpleTest
RUN: at line 6: /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang 
   -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer  
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta  
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowTest.cpp
 -o 
/home/b/sanitizer-aarch64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/AARCH64StaticLibcxxLinuxConfig/Output/reduce_inputs.test.tmp-ShrinkControlFlowTest
+ /home/b/sanitizer-aarch64-linux/build/build_default/./bin/clang 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
--driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/lib/fuzzer 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta 
/home/b/sanitizer-aarch64-linux/build/llvm-project/compiler-rt/test/fuzzer/ShrinkControlFlowTest.cpp
 -o 
/home/b/sanit

[clang] [C++20][Modules] Restore inliness of constexpr/consteval functions defined in-class (PR #109470)

2024-09-21 Thread via cfe-commits


@@ -9760,8 +9760,8 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
   if (getLangOpts().CPlusPlus) {
 // The rules for implicit inlines changed in C++20 for methods and friends
 // with an in-class definition (when such a definition is not attached to
-// the global module).  User-specified 'inline' overrides this (set when
-// the function decl is created above).
+// the global module). This does not affect declarations, that are already
+// inline, for example due being declared `inline` or `consteval`

tomasz-kaminski-sonarsource wrote:

Updated the comment and added entry in bug fixes changes.

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


[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread via cfe-commits

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


[clang] [clang][bytecode] Implement arithmetic, bitwise and compound assignment operator (PR #108949)

2024-09-21 Thread via cfe-commits


@@ -10,11 +10,229 @@ using FourI128VecSize __attribute__((vector_size(64))) = 
__int128;
 
 using FourCharsExtVec __attribute__((ext_vector_type(4))) = char;
 using FourIntsExtVec __attribute__((ext_vector_type(4))) = int;
+using FourLongLongsExtVec __attribute__((ext_vector_type(4))) = long long;
+using FourFloatsExtVec __attribute__((ext_vector_type(4))) = float;
+using FourDoublesExtVec __attribute__((ext_vector_type(4))) = double;
 using FourI128ExtVec __attribute__((ext_vector_type(4))) = __int128;
 
+
+// Next a series of tests to make sure these operations are usable in
+// constexpr functions. Template instantiations don't emit Winvalid-constexpr,
+// so we have to do these as macros.
+#define MathShiftOps(Type)\
+  constexpr auto MathShiftOps##Type(Type a, Type b) { \
+a = a + b;\
+a = a - b;\
+a = a * b;\
+a = a / b;\
+b = a + 1;\
+b = a - 1;\
+b = a * 1;\
+b = a / 1;\
+a += a;   \
+a -= a;   \
+a *= a;   \
+a /= a;   \
+b += a;   \
+b -= a;   \
+b *= a;   \
+b /= a;   \
+b = (a += a); \
+b = (a -= a); \
+b = (a *= a); \
+b = (a /= a); \
+b = (b += a); \
+b = (b -= a); \
+b = (b *= a); \
+b = (b /= a); \
+a < b;\
+a > b;\
+a <= b;   \
+a >= b;   \
+a == b;   \
+a != b;   \
+a &&b;\
+a || b;   \
+auto c = (a, b);  \
+return c; \
+  }
+
+// Ops specific to Integers.
+#define MathShiftOpsInts(Type)\
+  constexpr auto MathShiftopsInts##Type(Type a, Type b) { \
+a = a << b;   \
+a = a >> b;   \
+a = a << 3;   \
+a = a >> 3;   \
+a = 3 << b;   \
+a = 3 >> b;   \
+a <<= b;  \
+a >>= b;  \
+a <<= 3;  \
+a >>= 3;  \
+b = (a <<= b);\
+b = (a >>= b);\
+b = (a <<= 3);\
+b = (a >>= 3);\
+a = a % b;\
+a &b; \
+a | b;\
+a ^ b;\
+return a; \
+  }
+
+MathShiftOps(FourCharsVecSize);
+MathShiftOps(FourIntsVecSize);
+MathShiftOps(FourLongLongsVecSize);
+MathShiftOps(FourFloatsVecSize);
+MathShiftOps(FourDoublesVecSize);
+MathShiftOps(FourCharsExtVec);
+MathShiftOps(FourIntsExtVec);
+MathShiftOps(FourLongLongsExtVec);
+MathShiftOps(FourFloatsExtVec);
+MathShiftOps(FourDoublesExtVec);
+
+MathShiftOpsInts(FourCharsVecSize);
+MathShiftOpsInts(FourIntsVecSize);
+MathShiftOpsInts(FourLongLongsVecSize);
+MathShiftOpsInts(FourCharsExtVec);
+MathShiftOpsInts(FourIntsExtVec);
+MathShiftOpsInts(FourLongLongsExtVec);

yronglin wrote:

Sure, added more int128 tests, it's works well in my local.

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


[clang-tools-extra] [clangd] Implement simple folding of preprocessor branches (PR #80592)

2024-09-21 Thread Ruihua Dong via cfe-commits

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


[clang] [clang][bytecode] Fix reporting non-constant variables in C (PR #109516)

2024-09-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

We need to call FFDiag() to get the usual "invalid subexpression" diagnostic.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+4-2) 
- (modified) clang/test/Sema/annotate-type.c (+1) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 17cf3ccdeb6a94..d8e9fa838abaa8 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -90,10 +90,12 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr 
OpPC,
 
 static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
  const ValueDecl *VD) {
-  if (!S.getLangOpts().CPlusPlus)
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  if (!S.getLangOpts().CPlusPlus) {
+S.FFDiag(Loc);
 return;
+  }
 
-  const SourceInfo &Loc = S.Current->getSource(OpPC);
   if (const auto *VarD = dyn_cast(VD);
   VarD && VarD->getType().isConstQualified() &&
   !VarD->getAnyInitializer()) {
diff --git a/clang/test/Sema/annotate-type.c b/clang/test/Sema/annotate-type.c
index 901cef7ffa8b3a..bf1632d302e554 100644
--- a/clang/test/Sema/annotate-type.c
+++ b/clang/test/Sema/annotate-type.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify 
-fexperimental-new-constant-interpreter
 
 const char *some_function();
 

``




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


[clang] [clang][bytecode] Fix reporting non-constant variables in C (PR #109516)

2024-09-21 Thread Timm Baeder via cfe-commits

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

We need to call FFDiag() to get the usual "invalid subexpression" diagnostic.

>From 568f6ecc3540fca57d2a7abaae99c9f07c737714 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sat, 21 Sep 2024 09:02:49 +0200
Subject: [PATCH] [clang][bytecode] Fix reporting non-constant variables in C

We need to call FFDiag() to get the usual "invalid subexpression"
diagnostic.
---
 clang/lib/AST/ByteCode/Interp.cpp | 6 --
 clang/test/Sema/annotate-type.c   | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 17cf3ccdeb6a94..d8e9fa838abaa8 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -90,10 +90,12 @@ static bool diagnoseUnknownDecl(InterpState &S, CodePtr 
OpPC,
 
 static void diagnoseNonConstVariable(InterpState &S, CodePtr OpPC,
  const ValueDecl *VD) {
-  if (!S.getLangOpts().CPlusPlus)
+  const SourceInfo &Loc = S.Current->getSource(OpPC);
+  if (!S.getLangOpts().CPlusPlus) {
+S.FFDiag(Loc);
 return;
+  }
 
-  const SourceInfo &Loc = S.Current->getSource(OpPC);
   if (const auto *VarD = dyn_cast(VD);
   VarD && VarD->getType().isConstQualified() &&
   !VarD->getAnyInitializer()) {
diff --git a/clang/test/Sema/annotate-type.c b/clang/test/Sema/annotate-type.c
index 901cef7ffa8b3a..bf1632d302e554 100644
--- a/clang/test/Sema/annotate-type.c
+++ b/clang/test/Sema/annotate-type.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -fsyntax-only -verify 
-fexperimental-new-constant-interpreter
 
 const char *some_function();
 

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


[clang] 97aa8cc - [clang][bytecode] Diagnose weak reads in final load (#109515)

2024-09-21 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-21T09:10:31+02:00
New Revision: 97aa8cc94d94e8f0adc85489f7832ba7c0a9b577

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

LOG: [clang][bytecode] Diagnose weak reads in final load (#109515)

They aren't allowed here either.

Added: 


Modified: 
clang/lib/AST/ByteCode/Interp.cpp
clang/test/CodeGenCXX/weak-init.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 17cf3ccdeb6a94..65b4c0a9cb7660 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -620,6 +620,8 @@ bool CheckFinalLoad(InterpState &S, CodePtr OpPC, const 
Pointer &Ptr) {
 return false;
   if (!CheckTemporary(S, OpPC, Ptr, AK_Read))
 return false;
+  if (!CheckWeak(S, OpPC, Ptr))
+return false;
   if (!CheckMutable(S, OpPC, Ptr))
 return false;
   return true;

diff  --git a/clang/test/CodeGenCXX/weak-init.cpp 
b/clang/test/CodeGenCXX/weak-init.cpp
index 634021f38f854c..d9b17d9ca74f87 100644
--- a/clang/test/CodeGenCXX/weak-init.cpp
+++ b/clang/test/CodeGenCXX/weak-init.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s
 
 extern const int W __attribute__((weak)) = 99;
 const int S = 77;



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


[clang] [clang][bytecode] Diagnose weak reads in final load (PR #109515)

2024-09-21 Thread Timm Baeder via cfe-commits

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


[clang-tools-extra] fc5de0a - [clang-tools-extra] Use {} instead of std::nullopt to initialize empty ArrayRef (#109400)

2024-09-21 Thread via cfe-commits

Author: Jay Foad
Date: 2024-09-21T10:57:26+01:00
New Revision: fc5de0af33b7fb9b9f745e70dcd351f2de4211cb

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

LOG: [clang-tools-extra] Use {} instead of std::nullopt to initialize empty 
ArrayRef (#109400)

Follow up to #109133.

Added: 


Modified: 
clang-tools-extra/clang-query/Query.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
clang-tools-extra/unittests/clang-tidy/IncludeInserterTest.cpp
clang-tools-extra/unittests/clang-tidy/NamespaceAliaserTest.cpp
clang-tools-extra/unittests/clang-tidy/ReadabilityModuleTest.cpp
clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
clang-tools-extra/unittests/clang-tidy/UsingInserterTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-query/Query.cpp 
b/clang-tools-extra/clang-query/Query.cpp
index 93f4104d39db8c..282d136aff721a 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -146,7 +146,7 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession 
&QS) const {
 TD.emitDiagnostic(
 FullSourceLoc(R.getBegin(), AST->getSourceManager()),
 DiagnosticsEngine::Note, "\"" + BI->first + "\" binds here",
-CharSourceRange::getTokenRange(R), std::nullopt);
+CharSourceRange::getTokenRange(R), {});
   }
 }
 if (QS.PrintOutput) {

diff  --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h 
b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
index 078054c5194c54..e511eb6e49e8df 100644
--- a/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
+++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyTest.h
@@ -86,7 +86,7 @@ template 
 std::string
 runCheckOnCode(StringRef Code, std::vector *Errors = nullptr,
const Twine &Filename = "input.cc",
-   ArrayRef ExtraArgs = std::nullopt,
+   ArrayRef ExtraArgs = {},
const ClangTidyOptions &ExtraOptions = ClangTidyOptions(),
std::map PathsToContent =
std::map()) {

diff  --git a/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
index 8da1051a860a8c..d400cf6fe2d576 100644
--- a/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
@@ -49,7 +49,7 @@ TEST(IncludeCleanerCheckTest, BasicUnusedIncludes) {
   std::vector Errors;
   EXPECT_EQ(PostCode,
 runCheckOnCode(
-PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
 {{"bar.h", "#pragma once"}, {"vector", "#pragma once"}}));
 }
 
@@ -78,7 +78,7 @@ TEST(IncludeCleanerCheckTest, SuppressUnusedIncludes) {
   EXPECT_EQ(
   PostCode,
   runCheckOnCode(
-  PreCode, &Errors, "file.cpp", std::nullopt, Opts,
+  PreCode, &Errors, "file.cpp", {}, Opts,
   {{"bar.h", "#pragma once"},
{"vector", "#pragma once"},
{"list", "#pragma once"},
@@ -103,14 +103,13 @@ int BazResult = baz();
 )";
 
   std::vector Errors;
-  EXPECT_EQ(PostCode,
-runCheckOnCode(
-PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
-{{"bar.h", R"(#pragma once
+  EXPECT_EQ(PostCode, runCheckOnCode(
+  PreCode, &Errors, "file.cpp", {}, ClangTidyOptions(),
+  {{"bar.h", R"(#pragma once
   #include "baz.h"
   int bar();
)"},
- {"baz.h", R"(#pragma once
+   {"baz.h", R"(#pragma once
   int baz();
)"}}));
 }
@@ -124,8 +123,8 @@ int BarResult2 = $diag2^bar();)");
 
   {
 std::vector Errors;
-runCheckOnCode(Code.code(), &Errors, "file.cpp",
-std::nullopt, ClangTidyOptions(),
+runCheckOnCode(Code.code(), &Errors, "file.cpp", {},
+ClangTidyOptions(),
 {{"baz.h", R"(#pragma once
   #include "bar.h"
)"},
@@ -141,8 +140,8 @@ int BarResult2 = $diag2^bar();)");
 std::vector Errors;
 ClangTidyOptions Opts;
 Opts.CheckOptions.insert({"DeduplicateFindings", "false"});
-runCheckOnCode(Code.code(), &Errors, "file.cpp",
-std::nullopt, Opts,
+runCh

[clang-tools-extra] [clang-tools-extra] Use {} instead of std::nullopt to initialize empty ArrayRef (PR #109400)

2024-09-21 Thread Jay Foad via cfe-commits

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


[clang] [clang][bytecode] Don't call checkLiteralType() in visitInitializer() (PR #109530)

2024-09-21 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

We were calling checkLiteralType() too many time and rejecting some things we 
shouldn't. Add The calls manually when handling MaterializeTemporaryExprs. 
Maybe we should call it in other places as well, but adding more calls is 
easier than removing them from a generic code path.

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


4 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+6-3) 
- (modified) clang/lib/AST/ByteCode/Interp.cpp (+31) 
- (modified) clang/lib/AST/ByteCode/Interp.h (+1-33) 
- (modified) clang/test/AST/ByteCode/cxx17.cpp (+12) 


``diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7e0775a51aee61..fe35ca9eb27675 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2459,6 +2459,8 @@ bool Compiler::VisitMaterializeTemporaryExpr(
   return this->emitGetPtrGlobal(*GlobalIndex, E);
 }
 
+if (!this->checkLiteralType(SubExpr))
+  return false;
 // Non-primitive values.
 if (!this->emitGetPtrGlobal(*GlobalIndex, E))
   return false;
@@ -2479,6 +2481,10 @@ bool Compiler::VisitMaterializeTemporaryExpr(
   return false;
 return this->emitGetPtrLocal(LocalIndex, E);
   } else {
+
+if (!this->checkLiteralType(SubExpr))
+  return false;
+
 const Expr *Inner = E->getSubExpr()->skipRValueSubobjectAdjustments();
 if (std::optional LocalIndex =
 allocateLocal(Inner, E->getExtendingDecl())) {
@@ -3500,9 +3506,6 @@ template 
 bool Compiler::visitInitializer(const Expr *E) {
   assert(!classify(E->getType()));
 
-  if (!this->checkLiteralType(E))
-return false;
-
   OptionScope Scope(this, /*NewDiscardResult=*/false,
  /*NewInitializing=*/true);
   return this->Visit(E);
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 17cf3ccdeb6a94..0c6806ebe02e6d 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1008,6 +1008,37 @@ void diagnoseEnumValue(InterpState &S, CodePtr OpPC, 
const EnumDecl *ED,
   }
 }
 
+bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T) {
+  assert(T);
+  assert(!S.getLangOpts().CPlusPlus23);
+
+  // C++1y: A constant initializer for an object o [...] may also invoke
+  // constexpr constructors for o and its subobjects even if those objects
+  // are of non-literal class types.
+  //
+  // C++11 missed this detail for aggregates, so classes like this:
+  //   struct foo_t { union { int i; volatile int j; } u; };
+  // are not (obviously) initializable like so:
+  //   __attribute__((__require_constant_initialization__))
+  //   static const foo_t x = {{0}};
+  // because "i" is a subobject with non-literal initialization (due to the
+  // volatile member of the union). See:
+  //   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677
+  // Therefore, we use the C++1y behavior.
+
+  if (S.Current->getFunction() && S.Current->getFunction()->isConstructor() &&
+  S.Current->getThis().getDeclDesc()->asDecl() == S.EvaluatingDecl) {
+return true;
+  }
+
+  const Expr *E = S.Current->getExpr(OpPC);
+  if (S.getLangOpts().CPlusPlus11)
+S.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType();
+  else
+S.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
+  return false;
+}
+
 bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func,
  uint32_t VarArgSize) {
   if (Func->hasThisPointer()) {
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 92bed32d56f4d5..4aceb83eee0e71 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -158,6 +158,7 @@ bool CallBI(InterpState &S, CodePtr OpPC, const Function 
*Func,
 const CallExpr *CE, uint32_t BuiltinID);
 bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t ArgSize,
  const CallExpr *CE);
+bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T);
 
 enum class ShiftDir { Left, Right };
 
@@ -2946,39 +2947,6 @@ static inline bool IsConstantContext(InterpState &S, 
CodePtr OpPC) {
   return true;
 }
 
-inline bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T) {
-  assert(T);
-  assert(!S.getLangOpts().CPlusPlus23);
-
-  // C++1y: A constant initializer for an object o [...] may also invoke
-  // constexpr constructors for o and its subobjects even if those objects
-  // are of non-literal class types.
-  //
-  // C++11 missed this detail for aggregates, so classes like this:
-  //   struct foo_t { union { int i; volatile int j; } u; };
-  // are not (obviously) initializable like so:
-  //   __attribute__((__require_constant_initialization__))
-  //   static const foo_t x = {{0}};
-  // because "i" is a subobject with non-literal initialization (due to the
-  // volatile member of the 

[clang] [libclang/python] Fix evaluation of the unsigned enumeration values, #108766 (PR #108769)

2024-09-21 Thread Dmitry Fursov via cfe-commits

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


[clang] [clang][bytecode] Don't call checkLiteralType() in visitInitializer() (PR #109530)

2024-09-21 Thread Timm Baeder via cfe-commits

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

We were calling checkLiteralType() too many time and rejecting some things we 
shouldn't. Add The calls manually when handling MaterializeTemporaryExprs. 
Maybe we should call it in other places as well, but adding more calls is 
easier than removing them from a generic code path.

>From e2af94d18fb2496dab65ede49662b70106253a14 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Sat, 21 Sep 2024 15:45:05 +0200
Subject: [PATCH] [clang][bytecode] Don't call checkLiteralType() in
 visitInitializer()

We were calling checkLiteralType() too many time and rejecting
some things we shouldn't. Add The calls manually when handling
MaterializeTemporaryExprs. Maybe we should call it in other places as
well, but adding more calls is easier than removing them from a generic
code path.
---
 clang/lib/AST/ByteCode/Compiler.cpp |  9 +---
 clang/lib/AST/ByteCode/Interp.cpp   | 31 ++
 clang/lib/AST/ByteCode/Interp.h | 34 +
 clang/test/AST/ByteCode/cxx17.cpp   | 12 ++
 4 files changed, 50 insertions(+), 36 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index 7e0775a51aee61..fe35ca9eb27675 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -2459,6 +2459,8 @@ bool Compiler::VisitMaterializeTemporaryExpr(
   return this->emitGetPtrGlobal(*GlobalIndex, E);
 }
 
+if (!this->checkLiteralType(SubExpr))
+  return false;
 // Non-primitive values.
 if (!this->emitGetPtrGlobal(*GlobalIndex, E))
   return false;
@@ -2479,6 +2481,10 @@ bool Compiler::VisitMaterializeTemporaryExpr(
   return false;
 return this->emitGetPtrLocal(LocalIndex, E);
   } else {
+
+if (!this->checkLiteralType(SubExpr))
+  return false;
+
 const Expr *Inner = E->getSubExpr()->skipRValueSubobjectAdjustments();
 if (std::optional LocalIndex =
 allocateLocal(Inner, E->getExtendingDecl())) {
@@ -3500,9 +3506,6 @@ template 
 bool Compiler::visitInitializer(const Expr *E) {
   assert(!classify(E->getType()));
 
-  if (!this->checkLiteralType(E))
-return false;
-
   OptionScope Scope(this, /*NewDiscardResult=*/false,
  /*NewInitializing=*/true);
   return this->Visit(E);
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 17cf3ccdeb6a94..0c6806ebe02e6d 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -1008,6 +1008,37 @@ void diagnoseEnumValue(InterpState &S, CodePtr OpPC, 
const EnumDecl *ED,
   }
 }
 
+bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T) {
+  assert(T);
+  assert(!S.getLangOpts().CPlusPlus23);
+
+  // C++1y: A constant initializer for an object o [...] may also invoke
+  // constexpr constructors for o and its subobjects even if those objects
+  // are of non-literal class types.
+  //
+  // C++11 missed this detail for aggregates, so classes like this:
+  //   struct foo_t { union { int i; volatile int j; } u; };
+  // are not (obviously) initializable like so:
+  //   __attribute__((__require_constant_initialization__))
+  //   static const foo_t x = {{0}};
+  // because "i" is a subobject with non-literal initialization (due to the
+  // volatile member of the union). See:
+  //   http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677
+  // Therefore, we use the C++1y behavior.
+
+  if (S.Current->getFunction() && S.Current->getFunction()->isConstructor() &&
+  S.Current->getThis().getDeclDesc()->asDecl() == S.EvaluatingDecl) {
+return true;
+  }
+
+  const Expr *E = S.Current->getExpr(OpPC);
+  if (S.getLangOpts().CPlusPlus11)
+S.FFDiag(E, diag::note_constexpr_nonliteral) << E->getType();
+  else
+S.FFDiag(E, diag::note_invalid_subexpr_in_const_expr);
+  return false;
+}
+
 bool CallVar(InterpState &S, CodePtr OpPC, const Function *Func,
  uint32_t VarArgSize) {
   if (Func->hasThisPointer()) {
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 92bed32d56f4d5..4aceb83eee0e71 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -158,6 +158,7 @@ bool CallBI(InterpState &S, CodePtr OpPC, const Function 
*Func,
 const CallExpr *CE, uint32_t BuiltinID);
 bool CallPtr(InterpState &S, CodePtr OpPC, uint32_t ArgSize,
  const CallExpr *CE);
+bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T);
 
 enum class ShiftDir { Left, Right };
 
@@ -2946,39 +2947,6 @@ static inline bool IsConstantContext(InterpState &S, 
CodePtr OpPC) {
   return true;
 }
 
-inline bool CheckLiteralType(InterpState &S, CodePtr OpPC, const Type *T) {
-  assert(T);
-  assert(!S.getLangOpts().CPlusPlus23);
-
-  // C++1y: A constant initializer for an object o [...] may also invoke
-  // constexpr 

[clang] [libclang/python] Fix evaluation of the unsigned enumeration values, #108766 (PR #108769)

2024-09-21 Thread Dmitry Fursov via cfe-commits


@@ -1952,6 +1952,8 @@ def enum_value(self):
 underlying_type = self.type
 if underlying_type.kind == TypeKind.ENUM:
 underlying_type = underlying_type.get_declaration().enum_type
+if underlying_type.kind == TypeKind.ELABORATED:

fursov wrote:

My educated guess:

the call chain looks like this: enum_type (cindex.py) -> 
clang_getEnumDeclIntegerType (clang/tools/libclang/CXType.cpp) -> 
getIntegerType (clang/include/clang/AST/Decl.h)

Let's use this example:

`using TUintType = uint8_t;

enum class ETUintType : TUintType
{
A = 0xff,
B = 0x20
};
`

>From what I can see, e.g. from ast dumper (clang/lib/AST/TextNodeDumper.cpp, 
>TextNodeDumper::VisitEnumDecl), first it dumps scoped class, then name 
>(ETUintType), then it uses function dumpType() to print the type: first, the 
>one that has been provided by getIntegerType(), but then it is desugared.

EnumDecl 0x5580b1f62490  line:5:12 class ETUintType 
'TUintType':'unsigned char'

This leads me to the conclusion, that getIntegerType() on the AST parser on 
purpose returns whatever type that enum is defined against without resolving to 
the target canonical type.

But I would like to hear the opinion from experts.

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


[clang] [clang-offload-bundler] Avoid repeated hash lookups (NFC) (PR #109507)

2024-09-21 Thread Kazu Hirata via cfe-commits

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


[clang] 8d0336c - [clang-offload-bundler] Avoid repeated hash lookups (NFC) (#109507)

2024-09-21 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-09-21T09:10:49-07:00
New Revision: 8d0336c14be9d1f99e5c2b5791d8f4df35725ff2

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

LOG: [clang-offload-bundler] Avoid repeated hash lookups (NFC) (#109507)

Added: 


Modified: 
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Removed: 




diff  --git a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp 
b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
index e336417586f70b..0189fe5d56ab2a 100644
--- a/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ b/clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -349,11 +349,10 @@ int main(int argc, const char **argv) {
   // Standardize target names to include env field
   std::vector StandardizedTargetNames;
   for (StringRef Target : TargetNames) {
-if (ParsedTargets.contains(Target)) {
+if (!ParsedTargets.insert(Target).second) {
   reportError(createStringError(errc::invalid_argument,
 "Duplicate targets are not allowed"));
 }
-ParsedTargets.insert(Target);
 
 auto OffloadInfo = OffloadTargetInfo(Target, BundlerConfig);
 bool KindIsValid = OffloadInfo.isOffloadKindValid();



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