[clang] [llvm] [LoongArch] Support LA V1.1 feature ld-seq-sa that don't generate dbar 0x700. (PR #116762)

2024-11-19 Thread via cfe-commits

https://github.com/tangaac created 
https://github.com/llvm/llvm-project/pull/116762

Two options for clang
  -mld-seq-sa: Do not generate load-load barrier instructions (dbar 
0x700)
  -mno-ld-seq-sa:  Generate load-load barrier instructions (dbar 0x700)
The default is -mno-ld-seq-sa

>From c70cfa3b2e35eadfe80e3b8388e7554f398f8645 Mon Sep 17 00:00:00 2001
From: tangaac 
Date: Fri, 1 Nov 2024 17:28:38 +0800
Subject: [PATCH] [LoongArch] Support feature ld-seq-sa that don't generate
 dbar 0x700.

---
 clang/include/clang/Driver/Options.td |4 +
 clang/lib/Basic/Targets/LoongArch.cpp |7 +-
 clang/lib/Basic/Targets/LoongArch.h   |2 +
 .../lib/Driver/ToolChains/Arch/LoongArch.cpp  |9 +
 clang/test/Driver/loongarch-march.c   |8 +-
 clang/test/Driver/loongarch-mld-seq-sa.c  |   30 +
 clang/test/Preprocessor/init-loongarch.c  |   30 +-
 .../TargetParser/LoongArchTargetParser.def|3 +-
 .../llvm/TargetParser/LoongArchTargetParser.h |4 +
 llvm/lib/Target/LoongArch/LoongArch.td|5 +
 .../LoongArchExpandAtomicPseudoInsts.cpp  |4 +-
 .../TargetParser/LoongArchTargetParser.cpp|1 +
 .../ir-instruction/atomic-cmpxchg.ll  | 1145 +
 13 files changed, 1237 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/Driver/loongarch-mld-seq-sa.c

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d7230dd7272fd6..3ebb682397a0b6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5416,6 +5416,10 @@ def mlam_bh : Flag<["-"], "mlam-bh">, 
Group,
   HelpText<"Enable amswap[_db].{b/h} and amadd[_db].{b/h}">;
 def mno_lam_bh : Flag<["-"], "mno-lam-bh">, Group,
   HelpText<"Disable amswap[_db].{b/h} and amadd[_db].{b/h}">;
+def mld_seq_sa : Flag<["-"], "mld-seq-sa">, Group,
+  HelpText<"Do not generate load-load barrier instructions (dbar 0x700)">;
+def mno_ld_seq_sa : Flag<["-"], "mno-ld-seq-sa">, 
Group,
+  HelpText<"Generate load-load barrier instructions (dbar 0x700)">;
 def mannotate_tablejump : Flag<["-"], "mannotate-tablejump">, 
Group,
   HelpText<"Enable annotate table jump instruction to correlate it with the 
jump table.">;
 def mno_annotate_tablejump : Flag<["-"], "mno-annotate-tablejump">, 
Group,
diff --git a/clang/lib/Basic/Targets/LoongArch.cpp 
b/clang/lib/Basic/Targets/LoongArch.cpp
index 07b22b35f603ce..3f2d7317532aaf 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -205,7 +205,7 @@ void LoongArchTargetInfo::getTargetDefines(const 
LangOptions &Opts,
   // TODO: As more features of the V1.1 ISA are supported, a unified "v1.1"
   // arch feature set will be used to include all sub-features belonging to
   // the V1.1 ISA version.
-  if (HasFeatureFrecipe && HasFeatureLAM_BH)
+  if (HasFeatureFrecipe && HasFeatureLAM_BH && HasFeatureLD_SEQ_SA)
 Builder.defineMacro("__loongarch_arch",
 Twine('"') + "la64v1.1" + Twine('"'));
   else
@@ -239,6 +239,9 @@ void LoongArchTargetInfo::getTargetDefines(const 
LangOptions &Opts,
   if (HasFeatureLAM_BH)
 Builder.defineMacro("__loongarch_lam_bh", Twine(1));
 
+  if (HasFeatureLD_SEQ_SA)
+Builder.defineMacro("__loongarch_ld_seq_sa", Twine(1));
+
   StringRef ABI = getABI();
   if (ABI == "lp64d" || ABI == "lp64f" || ABI == "lp64s")
 Builder.defineMacro("__loongarch_lp64");
@@ -317,6 +320,8 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   HasFeatureFrecipe = true;
 else if (Feature == "+lam-bh")
   HasFeatureLAM_BH = true;
+else if (Feature == "+ld-seq-sa")
+  HasFeatureLD_SEQ_SA = true;
   }
   return true;
 }
diff --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 3585e9f7968b4b..e5eae7a8fcf677 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -31,6 +31,7 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
   bool HasFeatureLASX;
   bool HasFeatureFrecipe;
   bool HasFeatureLAM_BH;
+  bool HasFeatureLD_SEQ_SA;
 
 public:
   LoongArchTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
@@ -41,6 +42,7 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
 HasFeatureLASX = false;
 HasFeatureFrecipe = false;
 HasFeatureLAM_BH = false;
+HasFeatureLD_SEQ_SA = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp 
b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index 987db4638fca88..67b71a3ec623e4 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -274,6 +274,15 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
 else
   Features.push_back("-lam-bh");
   }

[clang] [TargetVersion] Only enable on RISC-V and AArch64 (PR #115991)

2024-11-19 Thread Piyou Chen via cfe-commits

https://github.com/BeMg updated https://github.com/llvm/llvm-project/pull/115991

>From 28f7a2adc055ec6f30790e1e9535c71241a08e29 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Tue, 12 Nov 2024 20:56:47 -0800
Subject: [PATCH 1/7] [TargetVersion] Only enable on RISC-V and AArch64

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 ++
 clang/lib/Sema/SemaDeclAttr.cpp  | 5 +
 2 files changed, 7 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 509d45c0867590..6170c3c10b00ca 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3282,6 +3282,8 @@ def warn_unsupported_target_attribute
   "attribute string; 
'%select{target|target_clones|target_version}3' "
   "attribute ignored">,
   InGroup;
+def err_target_version_unsupported
+: Error<"target_version attribute is not supported in this target">;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported on targets missing %1;"
 " specify an appropriate -march= or -mcpu=">;
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index d05d326178e1b8..e2eaa00c666fc2 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3040,6 +3040,11 @@ bool Sema::checkTargetVersionAttr(SourceLocation 
LiteralLoc, Decl *D,
   enum FirstParam { Unsupported };
   enum SecondParam { None };
   enum ThirdParam { Target, TargetClones, TargetVersion };
+
+  if (!Context.getTargetInfo().getTriple().isRISCV() &&
+  !Context.getTargetInfo().getTriple().isAArch64())
+return Diag(LiteralLoc, diag::err_target_version_unsupported);
+
   llvm::SmallVector Features;
   if (Context.getTargetInfo().getTriple().isRISCV()) {
 llvm::SmallVector AttrStrs;

>From 5355896434206bce33ff2442189aaff4d6b605ad Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Wed, 13 Nov 2024 22:25:05 -0800
Subject: [PATCH 2/7] Add testcase

---
 clang/test/Sema/attr-target-version-unsupported.c | 4 
 1 file changed, 4 insertions(+)
 create mode 100644 clang/test/Sema/attr-target-version-unsupported.c

diff --git a/clang/test/Sema/attr-target-version-unsupported.c 
b/clang/test/Sema/attr-target-version-unsupported.c
new file mode 100644
index 00..7a868e4085f20e
--- /dev/null
+++ b/clang/test/Sema/attr-target-version-unsupported.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown  -fsyntax-only -verify %s
+
+//expected-error@+1 {{target_version attribute is not supported in this 
target}}
+int __attribute__((target_version("aes"))) foo(void) { return 3; }

>From 659b628a12e05610ff82421dd358292c53940e93 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Wed, 13 Nov 2024 22:28:30 -0800
Subject: [PATCH 3/7] in this target -> on this target

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td  | 2 +-
 clang/test/Sema/attr-target-version-unsupported.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6170c3c10b00ca..0e3e8f90e52252 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3283,7 +3283,7 @@ def warn_unsupported_target_attribute
   "attribute ignored">,
   InGroup;
 def err_target_version_unsupported
-: Error<"target_version attribute is not supported in this target">;
+: Error<"target_version attribute is not supported on this target">;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported on targets missing %1;"
 " specify an appropriate -march= or -mcpu=">;
diff --git a/clang/test/Sema/attr-target-version-unsupported.c 
b/clang/test/Sema/attr-target-version-unsupported.c
index 7a868e4085f20e..056cbd25bd90d4 100644
--- a/clang/test/Sema/attr-target-version-unsupported.c
+++ b/clang/test/Sema/attr-target-version-unsupported.c
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown  -fsyntax-only -verify %s
 
-//expected-error@+1 {{target_version attribute is not supported in this 
target}}
+//expected-error@+1 {{target_version attribute is not supported on this 
target}}
 int __attribute__((target_version("aes"))) foo(void) { return 3; }

>From 5f7a3ebe81f2dc6af7d558d012d8d05543fa7115 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Thu, 14 Nov 2024 22:34:18 -0800
Subject: [PATCH 4/7] Using the TargetSpecificAttr instead of InheritableAttr

---
 clang/include/clang/Basic/Attr.td | 2 +-
 clang/include/clang/Basic/DiagnosticSemaKinds.td  | 2 --
 clang/lib/Sema/SemaDeclAttr.cpp   | 4 
 clang/test/Sema/attr-target-version-unsupported.c | 2 +-
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index a631e81d40aa68

[clang] [Clang] Fix typo 'dereferencable' to 'dereferenceable' (PR #116761)

2024-11-19 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [clang] Improve diagnostic on [[nodiscard]] attribute (PR #112521)

2024-11-19 Thread via cfe-commits

https://github.com/Sirraide updated 
https://github.com/llvm/llvm-project/pull/112521

>From 59f7dbdd8eed456b76e93f6260bf0e361242e9fd Mon Sep 17 00:00:00 2001
From: Yihe Li 
Date: Wed, 16 Oct 2024 18:53:04 +0800
Subject: [PATCH 1/5] [clang] Improve diagnostic on [[nodiscard]] attribute

---
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/include/clang/AST/Expr.h|   8 +-
 .../clang/Basic/DiagnosticSemaKinds.td|   6 +
 clang/lib/AST/Expr.cpp|  18 +--
 clang/lib/Sema/SemaStmt.cpp   |  40 ---
 .../dcl.attr/dcl.attr.nodiscard/p2.cpp|  28 ++---
 .../dcl.attr/dcl.attr.nodiscard/p3.cpp|   2 +-
 clang/test/Sema/c2x-nodiscard.c   |   8 +-
 clang/test/SemaCXX/warn-unused-result.cpp | 111 ++
 9 files changed, 159 insertions(+), 65 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index dc5564b6db119f..5dd30569fad108 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -416,6 +416,9 @@ Improvements to Clang's diagnostics
   name was a reserved name, which we improperly allowed to suppress the
   diagnostic.
 
+- Clang now includes the return type of the function or constructor in the 
warning generated
+  when `[[nodiscard]]` is triggered by its placement on return types instead 
of function itself.
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index cbe62411d11bff..592e1ef925796f 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3181,12 +3181,14 @@ class CallExpr : public Expr {
   QualType getCallReturnType(const ASTContext &Ctx) const;
 
   /// Returns the WarnUnusedResultAttr that is either declared on the called
-  /// function, or its return type declaration.
-  const Attr *getUnusedResultAttr(const ASTContext &Ctx) const;
+  /// function, or its return type declaration, together with a NamedDecl that
+  /// refers to the declaration the attribute is attached onto.
+  std::pair
+  getUnusedResultAttr(const ASTContext &Ctx) const;
 
   /// Returns true if this call expression should warn on unused results.
   bool hasUnusedResultAttr(const ASTContext &Ctx) const {
-return getUnusedResultAttr(Ctx) != nullptr;
+return getUnusedResultAttr(Ctx).second != nullptr;
   }
 
   SourceLocation getRParenLoc() const { return RParenLoc; }
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c458a62d9be48c..d22ceb0920b2ab 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9267,6 +9267,12 @@ def warn_unused_container_subscript_expr : Warning<
 def warn_unused_call : Warning<
   "ignoring return value of function declared with %0 attribute">,
   InGroup;
+def warn_unused_return_type : Warning<
+  "ignoring %select{return value|temporary}0 of type %2 declared with %1 
attribute">,
+  InGroup;
+def warn_unused_return_type_msg : Warning<
+  "ignoring %select{return value|temporary}0 of type %2 declared with %1 
attribute: %3">,
+  InGroup;
 def warn_unused_constructor : Warning<
   "ignoring temporary created by a constructor declared with %0 attribute">,
   InGroup;
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 9ecbf121e3fc0d..bbb05ec48523f5 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1616,22 +1616,24 @@ QualType CallExpr::getCallReturnType(const ASTContext 
&Ctx) const {
   return FnType->getReturnType();
 }
 
-const Attr *CallExpr::getUnusedResultAttr(const ASTContext &Ctx) const {
+std::pair
+CallExpr::getUnusedResultAttr(const ASTContext &Ctx) const {
+  // If the callee is marked nodiscard, return that attribute
+  const Decl *D = getCalleeDecl();
+  if (const auto *A = D->getAttr())
+return {nullptr, A};
+
   // If the return type is a struct, union, or enum that is marked nodiscard,
   // then return the return type attribute.
   if (const TagDecl *TD = getCallReturnType(Ctx)->getAsTagDecl())
 if (const auto *A = TD->getAttr())
-  return A;
+  return {TD, A};
 
   for (const auto *TD = getCallReturnType(Ctx)->getAs(); TD;
TD = TD->desugar()->getAs())
 if (const auto *A = TD->getDecl()->getAttr())
-  return A;
-
-  // Otherwise, see if the callee is marked nodiscard and return that attribute
-  // instead.
-  const Decl *D = getCalleeDecl();
-  return D ? D->getAttr() : nullptr;
+  return {TD->getDecl(), A};
+  return {nullptr, nullptr};
 }
 
 SourceLocation CallExpr::getBeginLoc() const {
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 9e235a46707cd4..5895da9daaf22d 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -204,22 +204,28 @@ static bool DiagnoseUnusedComparison(Sema &S, const Expr 
*E) {
   return true;
 }
 
-s

[clang] [clang] Improve diagnostic on [[nodiscard]] attribute (PR #112521)

2024-11-19 Thread via cfe-commits

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

LGTM

Thanks for contributing!

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


[clang] [clang] Improve diagnostic on [[nodiscard]] attribute (PR #112521)

2024-11-19 Thread via cfe-commits

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


[clang] [clang-repl] Improve flags responsible for generating shared wasm binaries (PR #116735)

2024-11-19 Thread Vassil Vassilev via cfe-commits

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


[clang] [analyzer] Handle [[assume(cond)]] as __builtin_assume(cond) (PR #116462)

2024-11-19 Thread Balazs Benics via cfe-commits

steakhal wrote:

I simplified your implementation, and also identified a shortcoming of the 
`getSpecificAttr` that it didn't work with const attributes. I'll submit a fix 
for it separately to this PR.

The implementation looks pretty but there is a catch. And this is unfortunately 
a blocker issue.
Quoting https://eel.is/c++draft/dcl.attr.assume:

```c++
int divide_by_32(int x) {
  [[assume(x >= 0)]];
  return x/32;  // The instructions produced for the division
// may omit handling of negative values.
}
int f(int y) {
  [[assume(++y == 43)]];// y is not incremented
  return y; // statement may be replaced with return 42;
}
```

Because we eval the subexpressions of the assume arguments, their sideeffects 
sneaks in to the ExplodedGraph.
So after all, this approach might not work out that well.

We should have a look at what the codegen does with this attribute, or even 
with the builtin assume call - because we should do something very similar. We 
should gather the constraints and apply them, just like codegen does (I assume).
I think a suitable place to start reading would be CGStmt.cpp 
`CodeGenFunction::EmitAttributedStmt()`.

Basically, my idea now is more like: don't eval the expressions of the assume 
in the CFG, but only visit the AttributedStmt in the ExprEngine. When we would 
reach that, "do the same as codegen to get the constraints" and apply these 
constraints.

Alternatively, we could take a snapshot of the Store and Environment before we 
would evaluate any expressions of the assume attribute and "restore" those 
after we finished with the AttributedStmt. If we would do this, we would be 
careful of sinking/"merging" all the paths we ended up creating while 
evaluating this Stmt. This is a lot more complicated, so I'd definitely try the 
previous approach before even considering this.

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


[clang] 752dbd6 - [clang-repl] Improve flags responsible for generating shared wasm binaries (#116735)

2024-11-19 Thread via cfe-commits

Author: Anutosh Bhat
Date: 2024-11-19T09:07:40+01:00
New Revision: 752dbd6112affa418e33910ac08bf9921f9c270b

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

LOG: [clang-repl] Improve flags responsible for generating shared wasm binaries 
(#116735)

There are a couple changes in this PR that help getting clang-repl to
run in the browser. Using a jupyterlite instance for the example pasted
below

1) Updating flags responsible for generating shared wasm binaries that
need to be dynamically loaded Most Importantly as can be seen in the
changes `shared` and `allow-undefined` are crucial.



![image](https://github.com/user-attachments/assets/1183fd44-8951-496a-899a-e4af39a48447)

2) While exiting we encounter this.



![image](https://github.com/user-attachments/assets/9487a3f4-7200-471d-ba88-09e98ccbc47a)


Now as can be seen here 


https://github.com/llvm/llvm-project/blob/cd418030de7ae75750bc4e48d1238baf03c675e5/clang/lib/Interpreter/Interpreter.cpp#L421-L430

We call cleanUP in the destructor. Now cleanUP through
IncrementalExecutor tries to deinitialize the JIT which wasn't even
intialized as runCtors in wasm.cpp is a no-op


https://github.com/llvm/llvm-project/blob/cd418030de7ae75750bc4e48d1238baf03c675e5/clang/lib/Interpreter/IncrementalExecutor.cpp#L94-L101


https://github.com/llvm/llvm-project/blob/cd418030de7ae75750bc4e48d1238baf03c675e5/clang/lib/Interpreter/Wasm.cpp#L107-L109

Added: 


Modified: 
clang/lib/Interpreter/IncrementalExecutor.h
clang/lib/Interpreter/Interpreter.cpp
clang/lib/Interpreter/Wasm.cpp
clang/lib/Interpreter/Wasm.h

Removed: 




diff  --git a/clang/lib/Interpreter/IncrementalExecutor.h 
b/clang/lib/Interpreter/IncrementalExecutor.h
index 7954cde36588bd..dbd61f0b8b1ebb 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -56,7 +56,7 @@ class IncrementalExecutor {
   virtual llvm::Error addModule(PartialTranslationUnit &PTU);
   virtual llvm::Error removeModule(PartialTranslationUnit &PTU);
   virtual llvm::Error runCtors() const;
-  llvm::Error cleanUp();
+  virtual llvm::Error cleanUp();
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
 

diff  --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index bc96da811d44cb..73ad766e655180 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -196,7 +196,6 @@ IncrementalCompilerBuilder::CreateCpp() {
 #ifdef __EMSCRIPTEN__
   Argv.push_back("-target");
   Argv.push_back("wasm32-unknown-emscripten");
-  Argv.push_back("-pie");
   Argv.push_back("-shared");
 #endif
   Argv.insert(Argv.end(), UserArgs.begin(), UserArgs.end());

diff  --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index 1001410aa0f279..79efbaa03982d0 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -72,13 +72,13 @@ llvm::Error 
WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
   OutputFile.close();
 
   std::vector LinkerArgs = {"wasm-ld",
-  "-pie",
+  "-shared",
   "--import-memory",
   "--no-entry",
   "--export-all",
   "--experimental-pic",
-  "--no-export-dynamic",
   "--stack-first",
+  "--allow-undefined",
   OutputFileName.c_str(),
   "-o",
   OutputFileName.c_str()};
@@ -109,6 +109,12 @@ llvm::Error WasmIncrementalExecutor::runCtors() const {
   return llvm::Error::success();
 }
 
+llvm::Error WasmIncrementalExecutor::cleanUp() const {
+  // Can't call cleanUp through IncrementalExecutor as it
+  // tries to deinitialize JIT which hasn't been initialized
+  return llvm::Error::success();
+}
+
 WasmIncrementalExecutor::~WasmIncrementalExecutor() = default;
 
 } // namespace clang

diff  --git a/clang/lib/Interpreter/Wasm.h b/clang/lib/Interpreter/Wasm.h
index b1fd88024f14d7..4632613326d39b 100644
--- a/clang/lib/Interpreter/Wasm.h
+++ b/clang/lib/Interpreter/Wasm.h
@@ -28,6 +28,7 @@ class WasmIncrementalExecutor : public IncrementalExecutor {
   llvm::Error addModule(PartialTranslationUnit &PTU) override;
   llvm::Error removeModule(PartialTranslationUnit &PTU) override;
   llvm::Error runCtors() const override;
+  llvm::Error cleanUp() override;
 
   ~WasmIncrementalExecutor() override;
 };


   

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-19 Thread Utkarsh Saxena via cfe-commits


@@ -0,0 +1,220 @@
+// RUN: %clang_cc1 --std=c++20 -fsyntax-only -Wdangling -Wdangling-field 
-Wreturn-stack-address -verify %s
+
+#include "Inputs/lifetime-analysis.h"

usx95 wrote:

> > I think it would be much more readable if we would have a namespace per use 
> > case or set of use cases where everything relevant to that use case would 
> > be declared/defined and used.
> 
> +1, I think the test can be improved by having a dedicated namespace per use 
> case.

Done.
I will also incline towards not splitting it the test further.
Happy to address more suggestions to make this readable and organised.

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


[clang] [llvm] [RISCV] Support `svukte` extension (PR #115657)

2024-11-19 Thread Craig Topper via cfe-commits


@@ -330,6 +329,9 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-smctr``, ``experimental-ssctr``
   LLVM implements the `1.0-rc3 specification 
`__.
 
+``experimental-svukte``, ``experimental-svukte``

topperc wrote:

smctr and ssctr are each mentioned 1 time.

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


[clang] [llvm] [RISCV] Support `svukte` extension (PR #115657)

2024-11-19 Thread Craig Topper via cfe-commits

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


[clang] [llvm] [LoongArch] Support LA V1.1 feature ld-seq-sa that don't generate dbar 0x700. (PR #116762)

2024-11-19 Thread via cfe-commits

https://github.com/tangaac updated 
https://github.com/llvm/llvm-project/pull/116762

>From eef0e50043c45ea6ca22af266bcc833ce9bbaf0d Mon Sep 17 00:00:00 2001
From: tangaac 
Date: Fri, 1 Nov 2024 17:28:38 +0800
Subject: [PATCH] [LoongArch] Support feature ld-seq-sa that don't generate
 dbar 0x700.

---
 clang/include/clang/Driver/Options.td |4 +
 clang/lib/Basic/Targets/LoongArch.cpp |7 +-
 clang/lib/Basic/Targets/LoongArch.h   |2 +
 .../lib/Driver/ToolChains/Arch/LoongArch.cpp  |9 +
 clang/test/Driver/loongarch-march.c   |8 +-
 clang/test/Driver/loongarch-mld-seq-sa.c  |   30 +
 clang/test/Preprocessor/init-loongarch.c  |   25 +-
 .../TargetParser/LoongArchTargetParser.def|3 +-
 .../llvm/TargetParser/LoongArchTargetParser.h |4 +
 llvm/lib/Target/LoongArch/LoongArch.td|5 +
 .../LoongArchExpandAtomicPseudoInsts.cpp  |4 +-
 .../TargetParser/LoongArchTargetParser.cpp|1 +
 .../ir-instruction/atomic-cmpxchg.ll  | 1145 +
 13 files changed, 1232 insertions(+), 15 deletions(-)
 create mode 100644 clang/test/Driver/loongarch-mld-seq-sa.c

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d7230dd7272fd6..3ebb682397a0b6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5416,6 +5416,10 @@ def mlam_bh : Flag<["-"], "mlam-bh">, 
Group,
   HelpText<"Enable amswap[_db].{b/h} and amadd[_db].{b/h}">;
 def mno_lam_bh : Flag<["-"], "mno-lam-bh">, Group,
   HelpText<"Disable amswap[_db].{b/h} and amadd[_db].{b/h}">;
+def mld_seq_sa : Flag<["-"], "mld-seq-sa">, Group,
+  HelpText<"Do not generate load-load barrier instructions (dbar 0x700)">;
+def mno_ld_seq_sa : Flag<["-"], "mno-ld-seq-sa">, 
Group,
+  HelpText<"Generate load-load barrier instructions (dbar 0x700)">;
 def mannotate_tablejump : Flag<["-"], "mannotate-tablejump">, 
Group,
   HelpText<"Enable annotate table jump instruction to correlate it with the 
jump table.">;
 def mno_annotate_tablejump : Flag<["-"], "mno-annotate-tablejump">, 
Group,
diff --git a/clang/lib/Basic/Targets/LoongArch.cpp 
b/clang/lib/Basic/Targets/LoongArch.cpp
index 07b22b35f603ce..3f2d7317532aaf 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -205,7 +205,7 @@ void LoongArchTargetInfo::getTargetDefines(const 
LangOptions &Opts,
   // TODO: As more features of the V1.1 ISA are supported, a unified "v1.1"
   // arch feature set will be used to include all sub-features belonging to
   // the V1.1 ISA version.
-  if (HasFeatureFrecipe && HasFeatureLAM_BH)
+  if (HasFeatureFrecipe && HasFeatureLAM_BH && HasFeatureLD_SEQ_SA)
 Builder.defineMacro("__loongarch_arch",
 Twine('"') + "la64v1.1" + Twine('"'));
   else
@@ -239,6 +239,9 @@ void LoongArchTargetInfo::getTargetDefines(const 
LangOptions &Opts,
   if (HasFeatureLAM_BH)
 Builder.defineMacro("__loongarch_lam_bh", Twine(1));
 
+  if (HasFeatureLD_SEQ_SA)
+Builder.defineMacro("__loongarch_ld_seq_sa", Twine(1));
+
   StringRef ABI = getABI();
   if (ABI == "lp64d" || ABI == "lp64f" || ABI == "lp64s")
 Builder.defineMacro("__loongarch_lp64");
@@ -317,6 +320,8 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   HasFeatureFrecipe = true;
 else if (Feature == "+lam-bh")
   HasFeatureLAM_BH = true;
+else if (Feature == "+ld-seq-sa")
+  HasFeatureLD_SEQ_SA = true;
   }
   return true;
 }
diff --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 3585e9f7968b4b..e5eae7a8fcf677 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -31,6 +31,7 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
   bool HasFeatureLASX;
   bool HasFeatureFrecipe;
   bool HasFeatureLAM_BH;
+  bool HasFeatureLD_SEQ_SA;
 
 public:
   LoongArchTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
@@ -41,6 +42,7 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
 HasFeatureLASX = false;
 HasFeatureFrecipe = false;
 HasFeatureLAM_BH = false;
+HasFeatureLD_SEQ_SA = false;
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
diff --git a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp 
b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
index 987db4638fca88..67b71a3ec623e4 100644
--- a/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
@@ -274,6 +274,15 @@ void loongarch::getLoongArchTargetFeatures(const Driver &D,
 else
   Features.push_back("-lam-bh");
   }
+
+  // Select ld-seq-sa feature determined by -m[no-]ld-seq-sa.
+  if (const Arg *A = Args.getLastArg(options::OPT_mld_seq_sa,
+ options::OPT_mno_ld_seq_sa)) {
+if (A->getOption()

[clang] [Clang] Preserve partially substituted pack indexing type/expressions (PR #116782)

2024-11-19 Thread Younan Zhang via cfe-commits

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

Substituting into pack indexing types/expressions can still result in 
unexpanded types/expressions, such as PackIndexingType or PackIndexingExpr. To 
handle these cases correctly, we should defer the pack size checks to the next 
round of transformation, when the patterns can be fully expanded.

To that end, the `FullySubstituted` flag is now necessary for computing the 
dependencies of `PackIndexingExprs`. Conveniently, this flag can also represent 
the prior `ExpandsToEmpty` status with an additional emptiness check. 
Therefore, I converted all stored flags to use FullySubstituted.

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

>From 5c0d947576b692c32febf89703033715b0c51cda Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Tue, 19 Nov 2024 18:33:34 +0800
Subject: [PATCH] [Clang] Preserve partially substituted pack indexing
 type/expressions

---
 clang/include/clang/AST/ExprCXX.h  | 14 +
 clang/include/clang/AST/Type.h | 12 
 clang/include/clang/AST/TypeProperties.td  |  6 ++--
 clang/include/clang/Sema/Sema.h|  2 +-
 clang/lib/AST/ASTContext.cpp   |  8 ++---
 clang/lib/AST/ComputeDependence.cpp|  3 +-
 clang/lib/AST/ExprCXX.cpp  |  6 ++--
 clang/lib/AST/Type.cpp |  8 ++---
 clang/lib/Sema/SemaTemplateVariadic.cpp| 16 +-
 clang/lib/Sema/TreeTransform.h | 13 +
 clang/lib/Serialization/ASTReaderStmt.cpp  |  2 +-
 clang/lib/Serialization/ASTWriterStmt.cpp  |  2 +-
 clang/test/SemaCXX/cxx2c-pack-indexing.cpp | 34 ++
 13 files changed, 84 insertions(+), 42 deletions(-)

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 696a574833dad2..1a24b8857674ca 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4390,17 +4390,17 @@ class PackIndexingExpr final
   unsigned TransformedExpressions : 31;
 
   LLVM_PREFERRED_TYPE(bool)
-  unsigned ExpandedToEmptyPack : 1;
+  unsigned FullySubstituted : 1;
 
   PackIndexingExpr(QualType Type, SourceLocation EllipsisLoc,
SourceLocation RSquareLoc, Expr *PackIdExpr, Expr 
*IndexExpr,
ArrayRef SubstitutedExprs = {},
-   bool ExpandedToEmptyPack = false)
+   bool FullySubstituted = false)
   : Expr(PackIndexingExprClass, Type, VK_LValue, OK_Ordinary),
 EllipsisLoc(EllipsisLoc), RSquareLoc(RSquareLoc),
 SubExprs{PackIdExpr, IndexExpr},
 TransformedExpressions(SubstitutedExprs.size()),
-ExpandedToEmptyPack(ExpandedToEmptyPack) {
+FullySubstituted(FullySubstituted) {
 
 auto *Exprs = getTrailingObjects();
 std::uninitialized_copy(SubstitutedExprs.begin(), SubstitutedExprs.end(),
@@ -4424,12 +4424,16 @@ class PackIndexingExpr final
   SourceLocation RSquareLoc, Expr *PackIdExpr,
   Expr *IndexExpr, std::optional 
Index,
   ArrayRef SubstitutedExprs = {},
-  bool ExpandedToEmptyPack = false);
+  bool FullySubstituted = false);
   static PackIndexingExpr *CreateDeserialized(ASTContext &Context,
   unsigned NumTransformedExprs);
 
+  bool isFullySubstituted() const { return FullySubstituted; }
+
   /// Determine if the expression was expanded to empty.
-  bool expandsToEmptyPack() const { return ExpandedToEmptyPack; }
+  bool expandsToEmptyPack() const {
+return isFullySubstituted() && TransformedExpressions == 0;
+  }
 
   /// Determine the location of the 'sizeof' keyword.
   SourceLocation getEllipsisLoc() const { return EllipsisLoc; }
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1ed5c22361ca68..90a52b1dcbf624 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -5922,12 +5922,12 @@ class PackIndexingType final
   unsigned Size : 31;
 
   LLVM_PREFERRED_TYPE(bool)
-  unsigned ExpandsToEmptyPack : 1;
+  unsigned FullySubstituted : 1;
 
 protected:
   friend class ASTContext; // ASTContext creates these.
   PackIndexingType(const ASTContext &Context, QualType Canonical,
-   QualType Pattern, Expr *IndexExpr, bool ExpandsToEmptyPack,
+   QualType Pattern, Expr *IndexExpr, bool FullySubstituted,
ArrayRef Expansions = {});
 
 public:
@@ -5951,7 +5951,9 @@ class PackIndexingType final
 
   bool hasSelectedType() const { return getSelectedIndex() != std::nullopt; }
 
-  bool expandsToEmptyPack() const { return ExpandsToEmptyPack; }
+  bool isFullySubstituted() const { return FullySubstituted; }
+
+  bool expandsToEmptyPack() const { return isFullySubstituted() && Size == 0; }
 
   ArrayRef getExpansions() const {

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116784)

2024-11-19 Thread Oliver Hunt via cfe-commits

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

Very simply extends the bitfield sema checks for assignment to fields with a 
preferred type specified to consider the preferred type if the decl storage 
type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different storage 
requirements we may not warn in all possible cases, but that's a scenario for 
which the warnings are much more complex and confusing.

>From d800f5371739670a415b7bfc6f7d1643cd8750a1 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Tue, 19 Nov 2024 11:55:11 +0100
Subject: [PATCH] [Clang] Consider preferred_type in bitfield warnings
 (#116760)

Very simply extends the bitfield sema checks for assignment to fields
with a preferred type specified to consider the preferred type if the
decl storage type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different
storage requirements we may not warn in all possible cases, but that's
a scenario for which the warnings are much more complex and confusing.
---
 .../clang/Basic/DiagnosticSemaKinds.td|   9 +-
 clang/lib/Sema/SemaChecking.cpp   |  29 +-
 .../Sema/bitfield-preferred-type-sizing.c | 108 +
 .../bitfield-preferred-type-sizing.cpp| 413 ++
 4 files changed, 552 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Sema/bitfield-preferred-type-sizing.c
 create mode 100644 clang/test/SemaCXX/bitfield-preferred-type-sizing.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..226b52f58d88d9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6404,20 +6404,23 @@ def warn_bitfield_width_exceeds_type_width: Warning<
 def err_bitfield_too_wide : Error<
   "%select{bit-field %1|anonymous bit-field}0 is too wide (%2 bits)">;
 def warn_bitfield_too_small_for_enum : Warning<
-  "bit-field %0 is not wide enough to store all enumerators of %1">,
+  "bit-field %0 is not wide enough to store all enumerators of 
%select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_widen_bitfield : Note<
   "widen this field to %0 bits to store all values of %1">;
 def warn_unsigned_bitfield_assigned_signed_enum : Warning<
-  "assigning value of signed enum type %1 to unsigned bit-field %0; "
+  "assigning value of %select{|preferred }1signed enum type %2 to unsigned 
bit-field %0; "
   "negative enumerators of enum %1 will be converted to positive values">,
   InGroup, DefaultIgnore;
 def warn_signed_bitfield_enum_conversion : Warning<
   "signed bit-field %0 needs an extra bit to represent the largest positive "
-  "enumerators of %1">,
+  "enumerators of %select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_change_bitfield_sign : Note<
   "consider making the bitfield type %select{unsigned|signed}0">;
+def note_bitfield_preferred_type : Note<
+  "preferred type for bitfield %0 specified here"
+>;
 
 def warn_missing_braces : Warning<
   "suggest braces around initialization of subobject">,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2d4a7cd287b70d..3d5d6f3285b12d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10488,7 +10488,14 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
 // The RHS is not constant.  If the RHS has an enum type, make sure the
 // bitfield is wide enough to hold all the values of the enum without
 // truncation.
-if (const auto *EnumTy = OriginalInit->getType()->getAs()) {
+const auto *EnumTy = OriginalInit->getType()->getAs();
+const PreferredTypeAttr *PTAttr = nullptr;
+if (!EnumTy) {
+  PTAttr = Bitfield->getAttr();
+  if (PTAttr)
+EnumTy = PTAttr->getType()->getAs();
+}
+if (EnumTy) {
   EnumDecl *ED = EnumTy->getDecl();
   bool SignedBitfield = BitfieldType->isSignedIntegerType();
 
@@ -10509,14 +10516,21 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
  ED->getNumPositiveBits() == FieldWidth) {
 DiagID = diag::warn_signed_bitfield_enum_conversion;
   }
-
+  unsigned PreferredTypeDiagIndex = PTAttr != nullptr;
   if (DiagID) {
-S.Diag(InitLoc, DiagID) << Bitfield << ED;
+S.Diag(InitLoc, DiagID) << Bitfield << PreferredTypeDiagIndex << ED;
 TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo();
 SourceRange TypeRange =
 TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange();
 S.Diag(Bitfield->getTypeSpecStartLoc(), 
diag::note_change_bitfield_sign)
 << SignedEnum << TypeRange;
+if (PTAttr) {
+  assert(PreferredTypeDiagIndex == 1);
+  S.Diag(PTAttr->getLocation(), diag::note_bitfield_preferred_type)

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116784)

2024-11-19 Thread Oliver Hunt via cfe-commits

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


[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2024-11-19 Thread Oliver Hunt via cfe-commits

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

Very simply extends the bitfield sema checks for assignment to fields with a 
preferred type specified to consider the preferred type if the decl storage 
type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different storage 
requirements we may not warn in all possible cases, but that's a scenario for 
which the warnings are much more complex and confusing.

>From d800f5371739670a415b7bfc6f7d1643cd8750a1 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Tue, 19 Nov 2024 11:55:11 +0100
Subject: [PATCH] [Clang] Consider preferred_type in bitfield warnings
 (#116760)

Very simply extends the bitfield sema checks for assignment to fields
with a preferred type specified to consider the preferred type if the
decl storage type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different
storage requirements we may not warn in all possible cases, but that's
a scenario for which the warnings are much more complex and confusing.
---
 .../clang/Basic/DiagnosticSemaKinds.td|   9 +-
 clang/lib/Sema/SemaChecking.cpp   |  29 +-
 .../Sema/bitfield-preferred-type-sizing.c | 108 +
 .../bitfield-preferred-type-sizing.cpp| 413 ++
 4 files changed, 552 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Sema/bitfield-preferred-type-sizing.c
 create mode 100644 clang/test/SemaCXX/bitfield-preferred-type-sizing.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..226b52f58d88d9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6404,20 +6404,23 @@ def warn_bitfield_width_exceeds_type_width: Warning<
 def err_bitfield_too_wide : Error<
   "%select{bit-field %1|anonymous bit-field}0 is too wide (%2 bits)">;
 def warn_bitfield_too_small_for_enum : Warning<
-  "bit-field %0 is not wide enough to store all enumerators of %1">,
+  "bit-field %0 is not wide enough to store all enumerators of 
%select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_widen_bitfield : Note<
   "widen this field to %0 bits to store all values of %1">;
 def warn_unsigned_bitfield_assigned_signed_enum : Warning<
-  "assigning value of signed enum type %1 to unsigned bit-field %0; "
+  "assigning value of %select{|preferred }1signed enum type %2 to unsigned 
bit-field %0; "
   "negative enumerators of enum %1 will be converted to positive values">,
   InGroup, DefaultIgnore;
 def warn_signed_bitfield_enum_conversion : Warning<
   "signed bit-field %0 needs an extra bit to represent the largest positive "
-  "enumerators of %1">,
+  "enumerators of %select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_change_bitfield_sign : Note<
   "consider making the bitfield type %select{unsigned|signed}0">;
+def note_bitfield_preferred_type : Note<
+  "preferred type for bitfield %0 specified here"
+>;
 
 def warn_missing_braces : Warning<
   "suggest braces around initialization of subobject">,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2d4a7cd287b70d..3d5d6f3285b12d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10488,7 +10488,14 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
 // The RHS is not constant.  If the RHS has an enum type, make sure the
 // bitfield is wide enough to hold all the values of the enum without
 // truncation.
-if (const auto *EnumTy = OriginalInit->getType()->getAs()) {
+const auto *EnumTy = OriginalInit->getType()->getAs();
+const PreferredTypeAttr *PTAttr = nullptr;
+if (!EnumTy) {
+  PTAttr = Bitfield->getAttr();
+  if (PTAttr)
+EnumTy = PTAttr->getType()->getAs();
+}
+if (EnumTy) {
   EnumDecl *ED = EnumTy->getDecl();
   bool SignedBitfield = BitfieldType->isSignedIntegerType();
 
@@ -10509,14 +10516,21 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
  ED->getNumPositiveBits() == FieldWidth) {
 DiagID = diag::warn_signed_bitfield_enum_conversion;
   }
-
+  unsigned PreferredTypeDiagIndex = PTAttr != nullptr;
   if (DiagID) {
-S.Diag(InitLoc, DiagID) << Bitfield << ED;
+S.Diag(InitLoc, DiagID) << Bitfield << PreferredTypeDiagIndex << ED;
 TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo();
 SourceRange TypeRange =
 TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange();
 S.Diag(Bitfield->getTypeSpecStartLoc(), 
diag::note_change_bitfield_sign)
 << SignedEnum << TypeRange;
+if (PTAttr) {
+  assert(PreferredTypeDiagIndex == 1);
+  S.Diag(PTAttr->getLocation(), diag::note_bitfield_preferred_type)

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2024-11-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Oliver Hunt (ojhunt)


Changes

Very simply extends the bitfield sema checks for assignment to fields with a 
preferred type specified to consider the preferred type if the decl storage 
type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different storage 
requirements we may not warn in all possible cases, but that's a scenario for 
which the warnings are much more complex and confusing.

---

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


4 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+6-3) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+25-4) 
- (added) clang/test/Sema/bitfield-preferred-type-sizing.c (+108) 
- (added) clang/test/SemaCXX/bitfield-preferred-type-sizing.cpp (+413) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..226b52f58d88d9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6404,20 +6404,23 @@ def warn_bitfield_width_exceeds_type_width: Warning<
 def err_bitfield_too_wide : Error<
   "%select{bit-field %1|anonymous bit-field}0 is too wide (%2 bits)">;
 def warn_bitfield_too_small_for_enum : Warning<
-  "bit-field %0 is not wide enough to store all enumerators of %1">,
+  "bit-field %0 is not wide enough to store all enumerators of 
%select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_widen_bitfield : Note<
   "widen this field to %0 bits to store all values of %1">;
 def warn_unsigned_bitfield_assigned_signed_enum : Warning<
-  "assigning value of signed enum type %1 to unsigned bit-field %0; "
+  "assigning value of %select{|preferred }1signed enum type %2 to unsigned 
bit-field %0; "
   "negative enumerators of enum %1 will be converted to positive values">,
   InGroup, DefaultIgnore;
 def warn_signed_bitfield_enum_conversion : Warning<
   "signed bit-field %0 needs an extra bit to represent the largest positive "
-  "enumerators of %1">,
+  "enumerators of %select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_change_bitfield_sign : Note<
   "consider making the bitfield type %select{unsigned|signed}0">;
+def note_bitfield_preferred_type : Note<
+  "preferred type for bitfield %0 specified here"
+>;
 
 def warn_missing_braces : Warning<
   "suggest braces around initialization of subobject">,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2d4a7cd287b70d..3d5d6f3285b12d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10488,7 +10488,14 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
 // The RHS is not constant.  If the RHS has an enum type, make sure the
 // bitfield is wide enough to hold all the values of the enum without
 // truncation.
-if (const auto *EnumTy = OriginalInit->getType()->getAs()) {
+const auto *EnumTy = OriginalInit->getType()->getAs();
+const PreferredTypeAttr *PTAttr = nullptr;
+if (!EnumTy) {
+  PTAttr = Bitfield->getAttr();
+  if (PTAttr)
+EnumTy = PTAttr->getType()->getAs();
+}
+if (EnumTy) {
   EnumDecl *ED = EnumTy->getDecl();
   bool SignedBitfield = BitfieldType->isSignedIntegerType();
 
@@ -10509,14 +10516,21 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
  ED->getNumPositiveBits() == FieldWidth) {
 DiagID = diag::warn_signed_bitfield_enum_conversion;
   }
-
+  unsigned PreferredTypeDiagIndex = PTAttr != nullptr;
   if (DiagID) {
-S.Diag(InitLoc, DiagID) << Bitfield << ED;
+S.Diag(InitLoc, DiagID) << Bitfield << PreferredTypeDiagIndex << ED;
 TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo();
 SourceRange TypeRange =
 TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange();
 S.Diag(Bitfield->getTypeSpecStartLoc(), 
diag::note_change_bitfield_sign)
 << SignedEnum << TypeRange;
+if (PTAttr) {
+  assert(PreferredTypeDiagIndex == 1);
+  S.Diag(PTAttr->getLocation(), diag::note_bitfield_preferred_type)
+  << ED;
+} else {
+  assert(PreferredTypeDiagIndex == 0);
+}
   }
 
   // Compute the required bitwidth. If the enum has negative values, we 
need
@@ -10530,9 +10544,16 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
   if (BitsNeeded > FieldWidth) {
 Expr *WidthExpr = Bitfield->getBitWidth();
 S.Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
-<< Bitfield << ED;
+<< Bitfield << PreferredTypeDiagIndex << ED;
 S.Diag(WidthExpr->getExprLoc(), diag::note_widen_bitfield)
 << Bi

[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116785)

2024-11-19 Thread Oliver Hunt via cfe-commits

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

>From 5f260726253e78a00d2dff02c22837ce02b49075 Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Tue, 19 Nov 2024 11:55:11 +0100
Subject: [PATCH] [Clang] Consider preferred_type in bitfield warnings
 (#116760)

Very simply extends the bitfield sema checks for assignment to fields
with a preferred type specified to consider the preferred type if the
decl storage type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different
storage requirements we may not warn in all possible cases, but that's
a scenario for which the warnings are much more complex and confusing.
---
 .../clang/Basic/DiagnosticSemaKinds.td|   9 +-
 clang/lib/Sema/SemaChecking.cpp   |  23 +-
 .../Sema/bitfield-preferred-type-sizing.c | 108 +
 .../bitfield-preferred-type-sizing.cpp| 413 ++
 4 files changed, 546 insertions(+), 7 deletions(-)
 create mode 100644 clang/test/Sema/bitfield-preferred-type-sizing.c
 create mode 100644 clang/test/SemaCXX/bitfield-preferred-type-sizing.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..226b52f58d88d9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6404,20 +6404,23 @@ def warn_bitfield_width_exceeds_type_width: Warning<
 def err_bitfield_too_wide : Error<
   "%select{bit-field %1|anonymous bit-field}0 is too wide (%2 bits)">;
 def warn_bitfield_too_small_for_enum : Warning<
-  "bit-field %0 is not wide enough to store all enumerators of %1">,
+  "bit-field %0 is not wide enough to store all enumerators of 
%select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_widen_bitfield : Note<
   "widen this field to %0 bits to store all values of %1">;
 def warn_unsigned_bitfield_assigned_signed_enum : Warning<
-  "assigning value of signed enum type %1 to unsigned bit-field %0; "
+  "assigning value of %select{|preferred }1signed enum type %2 to unsigned 
bit-field %0; "
   "negative enumerators of enum %1 will be converted to positive values">,
   InGroup, DefaultIgnore;
 def warn_signed_bitfield_enum_conversion : Warning<
   "signed bit-field %0 needs an extra bit to represent the largest positive "
-  "enumerators of %1">,
+  "enumerators of %select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_change_bitfield_sign : Note<
   "consider making the bitfield type %select{unsigned|signed}0">;
+def note_bitfield_preferred_type : Note<
+  "preferred type for bitfield %0 specified here"
+>;
 
 def warn_missing_braces : Warning<
   "suggest braces around initialization of subobject">,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2d4a7cd287b70d..254284e950c7e5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10488,7 +10488,14 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
 // The RHS is not constant.  If the RHS has an enum type, make sure the
 // bitfield is wide enough to hold all the values of the enum without
 // truncation.
-if (const auto *EnumTy = OriginalInit->getType()->getAs()) {
+const auto *EnumTy = OriginalInit->getType()->getAs();
+const PreferredTypeAttr *PTAttr = nullptr;
+if (!EnumTy) {
+  PTAttr = Bitfield->getAttr();
+  if (PTAttr)
+EnumTy = PTAttr->getType()->getAs();
+}
+if (EnumTy) {
   EnumDecl *ED = EnumTy->getDecl();
   bool SignedBitfield = BitfieldType->isSignedIntegerType();
 
@@ -10509,14 +10516,18 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
  ED->getNumPositiveBits() == FieldWidth) {
 DiagID = diag::warn_signed_bitfield_enum_conversion;
   }
-
+  unsigned PreferredTypeDiagIndex = PTAttr != nullptr;
   if (DiagID) {
-S.Diag(InitLoc, DiagID) << Bitfield << ED;
+S.Diag(InitLoc, DiagID) << Bitfield << PreferredTypeDiagIndex << ED;
 TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo();
 SourceRange TypeRange =
 TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange();
 S.Diag(Bitfield->getTypeSpecStartLoc(), 
diag::note_change_bitfield_sign)
 << SignedEnum << TypeRange;
+if (PTAttr) {
+  S.Diag(PTAttr->getLocation(), diag::note_bitfield_preferred_type)
+  << ED;
+}
   }
 
   // Compute the required bitwidth. If the enum has negative values, we 
need
@@ -10530,9 +10541,13 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
   if (BitsNeeded > FieldWidth) {
 Expr *WidthExpr = Bitfield->getBitWidth();
 S.Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
-<< Bitfield << ED;
+<< Bitfield << Preferre

[clang] [Clang] Preserve partially substituted pack indexing type/expressions (PR #116782)

2024-11-19 Thread Younan Zhang via cfe-commits

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


[clang] [llvm] [LoongArch] Support LA V1.1 feature that div.w[u] and mod.w[u] instructions with inputs not signed-extended. (PR #116764)

2024-11-19 Thread via cfe-commits


@@ -118,6 +118,12 @@ def FeatureLAM_BH
 "Support amswap[_db].{b/h} and amadd[_db].{b/h} 
instructions.">;
 def HasLAM_BH : Predicate<"Subtarget->hasLAM_BH()">;
 
+// Assume div.w[u] and mod.w[u] can handle inputs that are not sign-extended.
+def FeatureDiv32
+: SubtargetFeature<"div32", "HasDiv32", "true",
+"Support div.w[u] and mod.w[u] can handle inputs that 
are not sign-extended">;

heiher wrote:

Clang is not the only LLVM frontend, and the 3A5000 is still not outdated, so I 
recommend setting the `div32` feature to `false` by default.

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


[clang] [llvm] [LoongArch] Support LA V1.1 feature that div.w[u] and mod.w[u] instructions with inputs not signed-extended. (PR #116764)

2024-11-19 Thread via cfe-commits


@@ -121,7 +121,7 @@ define i32 @sdiv_i32(i32 %a, i32 %b) {
 ; LA64:   # %bb.0: # %entry
 ; LA64-NEXT:addi.w $a1, $a1, 0
 ; LA64-NEXT:addi.w $a0, $a0, 0
-; LA64-NEXT:div.d $a0, $a0, $a1
+; LA64-NEXT:div.w $a0, $a0, $a1

heiher wrote:

These cases are allowed when `div32` is enabled, as it eliminates unnecessary 
sign-extend instructions.

https://github.com/llvm/llvm-project/blob/7e85cb8a8a9de57ed10635b843662148a87b17e5/llvm/lib/Target/LoongArch/LoongArchOptWInstrs.cpp#L142-L146

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


[clang] [Driver] Remove ignored Flag form of -fauto-profile/-fprofile-sample-use (PR #113528)

2024-11-19 Thread Haohai Wen via cfe-commits

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


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


[clang] 91c1699 - [clang] [NFC] Merge conditions (#116612)

2024-11-19 Thread via cfe-commits

Author: Boaz Brickner
Date: 2024-11-19T09:57:00+01:00
New Revision: 91c1699943a7f41c337d44b965c63bb6fc96de16

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

LOG: [clang] [NFC] Merge conditions (#116612)

Added: 


Modified: 
clang/lib/Sema/CheckExprLifetime.cpp

Removed: 




diff  --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index a1a402b4a2b530..2dbd9862802e7a 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -1095,9 +1095,7 @@ static bool pathOnlyHandlesGslPointer(const 
IndirectLocalPath &Path) {
 }
 
 static bool isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) {
-  if (!CMD)
-return false;
-  return isNormalAssignmentOperator(CMD) && CMD->param_size() == 1 &&
+  return CMD && isNormalAssignmentOperator(CMD) && CMD->param_size() == 1 &&
  CMD->getParamDecl(0)->hasAttr();
 }
 



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


[clang] [clang] [NFC] Merge conditions (PR #116612)

2024-11-19 Thread Boaz Brickner via cfe-commits

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


[clang] [analyzer][Solver] Early return if sym is concrete on assuming (PR #115579)

2024-11-19 Thread Balazs Benics via cfe-commits

steakhal wrote:

> > I'm not sure I see why. The logs I linked in the revert only showed a 
> > single test failure. The new test we added in this PR. This suggests close 
> > correlations. Maybe the content of the "constraints" map in the State is 
> > dumped in a non-deterministic order? And we just happened to step on it now.
> 
> Yes it's the testcase touched by this PR that failed (not other random 
> testcase inside the repo).
> 
> I mean that clang behaves randomly.
> 
> The randomness might not be introduced by this PR but by some earlier commit 
> point.
> 
> I'm working on it.

Be aware of that llvm DenseMap and sets are basically open-address hashtables, 
and the hash function is seeded by the address of some known function (IDK 
which). This means that these tables depend on where clang is loaded in memory. 
Consequently, address-space layout randomization could affect the 
reproducibility of some issues and lead to flaky cases.

The constraints are backed by llvm::Immutable map and set. which is some 
AVL-tree if I recall. I'm not sure how the "ordering" is implemented there but 
if they are in terms of comparing pointer addresses then we might have a 
problem.

When dumping the constraints, I think we just iterate the AVL-tree from begin 
to end, which will prefer "less-then" elements, but if those depend on where 
the process is loaded then the whole iteration order is RT dependent.
Could you please check if we sort before dumping the constraints?

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


[clang] [analyzer][Solver] Early return if sym is concrete on assuming (PR #115579)

2024-11-19 Thread Balazs Benics via cfe-commits

steakhal wrote:

> > @danix800 Could you please have a look at the failed test, such that we 
> > could reapply this PR? I reverted this soon after I realized the broken 
> > test is from this PR.
> 
> The test randomly fails for unknown reason, on VS2019~2022, after 
> [1c154bd](https://github.com/llvm/llvm-project/commit/1c154bd755153b5c6ada4bbed58facf23f6abffc)
>  (seems totally irrelevant to this randomness). Not sure if it's a compiler 
> bug.

I'm not sure I see why. The logs I linked in the revert only showed a single 
test failure. The new test we added in this PR. This suggests close 
correlations. Maybe the content of the "constraints" map in the State is dumped 
in a non-deterministic order? And we just happened to step on it now.

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


[clang] [Clang] Consider preferred_type in bitfield warnings (#116760) (PR #116784)

2024-11-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Oliver Hunt (ojhunt)


Changes

Very simply extends the bitfield sema checks for assignment to fields with a 
preferred type specified to consider the preferred type if the decl storage 
type is not explicitly an enum type.

This does mean that if the preferred and explicit types have different storage 
requirements we may not warn in all possible cases, but that's a scenario for 
which the warnings are much more complex and confusing.

---

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


4 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+6-3) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+25-4) 
- (added) clang/test/Sema/bitfield-preferred-type-sizing.c (+108) 
- (added) clang/test/SemaCXX/bitfield-preferred-type-sizing.cpp (+413) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..226b52f58d88d9 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6404,20 +6404,23 @@ def warn_bitfield_width_exceeds_type_width: Warning<
 def err_bitfield_too_wide : Error<
   "%select{bit-field %1|anonymous bit-field}0 is too wide (%2 bits)">;
 def warn_bitfield_too_small_for_enum : Warning<
-  "bit-field %0 is not wide enough to store all enumerators of %1">,
+  "bit-field %0 is not wide enough to store all enumerators of 
%select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_widen_bitfield : Note<
   "widen this field to %0 bits to store all values of %1">;
 def warn_unsigned_bitfield_assigned_signed_enum : Warning<
-  "assigning value of signed enum type %1 to unsigned bit-field %0; "
+  "assigning value of %select{|preferred }1signed enum type %2 to unsigned 
bit-field %0; "
   "negative enumerators of enum %1 will be converted to positive values">,
   InGroup, DefaultIgnore;
 def warn_signed_bitfield_enum_conversion : Warning<
   "signed bit-field %0 needs an extra bit to represent the largest positive "
-  "enumerators of %1">,
+  "enumerators of %select{|preferred type }1%2">,
   InGroup, DefaultIgnore;
 def note_change_bitfield_sign : Note<
   "consider making the bitfield type %select{unsigned|signed}0">;
+def note_bitfield_preferred_type : Note<
+  "preferred type for bitfield %0 specified here"
+>;
 
 def warn_missing_braces : Warning<
   "suggest braces around initialization of subobject">,
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 2d4a7cd287b70d..3d5d6f3285b12d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -10488,7 +10488,14 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
 // The RHS is not constant.  If the RHS has an enum type, make sure the
 // bitfield is wide enough to hold all the values of the enum without
 // truncation.
-if (const auto *EnumTy = OriginalInit->getType()->getAs()) {
+const auto *EnumTy = OriginalInit->getType()->getAs();
+const PreferredTypeAttr *PTAttr = nullptr;
+if (!EnumTy) {
+  PTAttr = Bitfield->getAttr();
+  if (PTAttr)
+EnumTy = PTAttr->getType()->getAs();
+}
+if (EnumTy) {
   EnumDecl *ED = EnumTy->getDecl();
   bool SignedBitfield = BitfieldType->isSignedIntegerType();
 
@@ -10509,14 +10516,21 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
  ED->getNumPositiveBits() == FieldWidth) {
 DiagID = diag::warn_signed_bitfield_enum_conversion;
   }
-
+  unsigned PreferredTypeDiagIndex = PTAttr != nullptr;
   if (DiagID) {
-S.Diag(InitLoc, DiagID) << Bitfield << ED;
+S.Diag(InitLoc, DiagID) << Bitfield << PreferredTypeDiagIndex << ED;
 TypeSourceInfo *TSI = Bitfield->getTypeSourceInfo();
 SourceRange TypeRange =
 TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange();
 S.Diag(Bitfield->getTypeSpecStartLoc(), 
diag::note_change_bitfield_sign)
 << SignedEnum << TypeRange;
+if (PTAttr) {
+  assert(PreferredTypeDiagIndex == 1);
+  S.Diag(PTAttr->getLocation(), diag::note_bitfield_preferred_type)
+  << ED;
+} else {
+  assert(PreferredTypeDiagIndex == 0);
+}
   }
 
   // Compute the required bitwidth. If the enum has negative values, we 
need
@@ -10530,9 +10544,16 @@ static bool AnalyzeBitFieldAssignment(Sema &S, 
FieldDecl *Bitfield, Expr *Init,
   if (BitsNeeded > FieldWidth) {
 Expr *WidthExpr = Bitfield->getBitWidth();
 S.Diag(InitLoc, diag::warn_bitfield_too_small_for_enum)
-<< Bitfield << ED;
+<< Bitfield << PreferredTypeDiagIndex << ED;
 S.Diag(WidthExpr->getExprLoc(), diag::note_widen_bitfield)
 << Bi

[clang] [clang] Generate note on declaration for nodiscard-related attributes (PR #112289)

2024-11-19 Thread Yihe Li via cfe-commits

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


[clang] [NFC][Clang][AArch64]Refactor implementation of Neon vectors MFloat8… (PR #114804)

2024-11-19 Thread Paul Walker via cfe-commits

paulwalker-arm wrote:

Thanks @CarolineConcatto this is structurally more what I had in mind.  The 
non-fp8 neon types make use of general vector support within clang but the fp8 
based types are completely target specific and so I'd rather keep their spread 
within common code to a minimum.  NeonEmitter being target specific means we 
have no such worries and can freely embed fp8 type support within it as you're 
now doing.

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


[libclc] [libclc] Move several integer functions to CLC library (PR #116786)

2024-11-19 Thread Fraser Cormack via cfe-commits

https://github.com/frasercrmck created 
https://github.com/llvm/llvm-project/pull/116786

This commit moves over the OpenCL clz, hadd, mad24, mad_hi, mul24, mul_hi, 
popcount, rhadd, and upsample builtins to the CLC library. There are no changes 
to any target's CLC libraries.

The OpenCL mad_hi builtin wasn't previously publicly available from the CLC 
libraries, as it was hash-defined to mul_hi in the header files. That issue has 
been fixed, and mad_hi is now exposed.

The custom AMD implementation/workaround for popcount has been removed as it 
was only valid for clang < 7.

There are still three integer functions which haven't been moved over. The 
OpenCL add_sat, sub_sat, and mad_sat builtins require saturating conversion 
builtins which haven't yet been ported.

>From 3f05aee5651a8364d4f3ba45bfc8024ff5beec8c Mon Sep 17 00:00:00 2001
From: Fraser Cormack 
Date: Mon, 18 Nov 2024 17:29:42 +
Subject: [PATCH] [libclc] Move several integer functions to CLC library

This commit moves over the OpenCL clz, hadd, mad24, mad_hi, mul24,
mul_hi, popcount, rhadd, and upsample builtins to the CLC library. There
are no changes to any target's CLC libraries.

The OpenCL mad_hi builtin wasn't previously publicly available from the
CLC libraries, as it was hash-defined to mul_hi in the header files.
That issue has been fixed, and mad_hi is now exposed.

The custom AMD implementation/workaround for popcount has been removed
as it was only valid for clang < 7.

There are still two integer functions which haven't been moved over. The
OpenCL add_sat, sub_sat, and mad_sat builtins require saturating
conversion builtins which haven't yet been ported.
---
 libclc/amdgcn/lib/SOURCES |   1 -
 libclc/amdgcn/lib/integer/popcount.cl |   6 -
 libclc/amdgcn/lib/integer/popcount.inc|  17 ---
 libclc/clc/include/clc/integer/binary_decl.h  |   2 +
 libclc/clc/include/clc/integer/clc_clz.h  |  21 +++
 libclc/clc/include/clc/integer/clc_hadd.h |  21 +++
 libclc/clc/include/clc/integer/clc_mad24.h|  21 +++
 libclc/clc/include/clc/integer/clc_mad_hi.h   |   8 ++
 libclc/clc/include/clc/integer/clc_mul24.h|  21 +++
 libclc/clc/include/clc/integer/clc_mul_hi.h   |  21 +++
 libclc/clc/include/clc/integer/clc_popcount.h |  19 +++
 libclc/clc/include/clc/integer/clc_rhadd.h|  21 +++
 libclc/clc/include/clc/integer/clc_upsample.h |  38 +
 .../include/clc/integer/definitions.h |   7 +-
 libclc/clc/include/clc/integer/gentype24.inc  | 134 ++
 libclc/clc/include/clc/integer/ternary_decl.h |   2 +
 libclc/clc/include/clc/integer/unary_decl.h   |   1 +
 .../clc/include/clc/integer/unary_intrin.inc  |  26 
 libclc/clc/lib/generic/SOURCES|   7 +
 libclc/clc/lib/generic/integer/clc_clz.cl |  44 ++
 libclc/clc/lib/generic/integer/clc_hadd.cl|   4 +
 libclc/clc/lib/generic/integer/clc_hadd.inc   |   8 ++
 libclc/clc/lib/generic/integer/clc_mad24.cl   |   5 +
 libclc/clc/lib/generic/integer/clc_mad24.inc  |   5 +
 libclc/clc/lib/generic/integer/clc_mul24.cl   |   4 +
 .../lib/generic/integer/clc_mul24.inc}|   4 +-
 libclc/clc/lib/generic/integer/clc_mul_hi.cl  | 113 +++
 libclc/clc/lib/generic/integer/clc_rhadd.cl   |   4 +
 libclc/clc/lib/generic/integer/clc_rhadd.inc  |   8 ++
 .../clc/lib/generic/integer/clc_upsample.cl   |  45 ++
 libclc/generic/include/clc/integer/clz.h  |   6 +-
 libclc/generic/include/clc/integer/clz.inc|   1 -
 libclc/generic/include/clc/integer/hadd.h |   6 +-
 libclc/generic/include/clc/integer/hadd.inc   |   1 -
 libclc/generic/include/clc/integer/mad24.h|   9 +-
 libclc/generic/include/clc/integer/mad24.inc  |   1 -
 libclc/generic/include/clc/integer/mad_hi.h   |   7 +-
 libclc/generic/include/clc/integer/mul24.h|   9 +-
 libclc/generic/include/clc/integer/mul24.inc  |   1 -
 libclc/generic/include/clc/integer/mul_hi.h   |   6 +-
 libclc/generic/include/clc/integer/mul_hi.inc |   1 -
 libclc/generic/include/clc/integer/popcount.h |   9 +-
 libclc/generic/include/clc/integer/rhadd.h|   6 +-
 libclc/generic/include/clc/integer/rhadd.inc  |   1 -
 libclc/generic/include/clc/integer/upsample.h |  33 +++--
 libclc/generic/include/integer/popcount.h |   3 -
 .../generic/include/integer/unary_intrin.inc  |  20 ---
 libclc/generic/lib/SOURCES|   1 +
 libclc/generic/lib/integer/binary_def.inc |   8 ++
 libclc/generic/lib/integer/clz.cl |  44 +-
 libclc/generic/lib/integer/hadd.cl|   5 +-
 libclc/generic/lib/integer/hadd.inc   |   6 -
 libclc/generic/lib/integer/mad24.cl   |   7 +-
 libclc/generic/lib/integer/mad24.inc  |   3 -
 libclc/generic/lib/integer/mad_hi.cl  |   7 +
 libclc/generic/lib/integer/mul24.cl   |   7 +-
 libclc/generic/lib/integer/mul_hi.cl  | 110 +-
 libclc/generic/lib/integer/popcount.cl|   7 +-
 libclc/generic/lib/integer/rhadd

[clang-tools-extra] b3e2b1a - [clang-tidy][NFC] fix typo in ExceptionAnalyzer; `replace count()>0` with `contains` (#116635)

2024-11-19 Thread via cfe-commits

Author: Congcong Cai
Date: 2024-11-19T18:11:41+08:00
New Revision: b3e2b1a7eb258a7c9c55691d08342eface083499

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

LOG: [clang-tidy][NFC] fix typo in ExceptionAnalyzer; `replace count()>0` with 
`contains` (#116635)

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
index 620a57194acb8e..3d1f63fcf33a5a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -20,7 +20,7 @@ namespace {
 
 AST_MATCHER_P(FunctionDecl, isEnabled, llvm::StringSet<>,
   FunctionsThatShouldNotThrow) {
-  return FunctionsThatShouldNotThrow.count(Node.getNameAsString()) > 0;
+  return FunctionsThatShouldNotThrow.contains(Node.getNameAsString());
 }
 
 AST_MATCHER(FunctionDecl, isExplicitThrow) {

diff  --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index 9bfb7e2677533a..68f3ecf6bdaa81 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -418,7 +418,7 @@ ExceptionAnalyzer::ExceptionInfo::filterIgnoredExceptions(
   if (TD->getDeclName().isIdentifier()) {
 if ((IgnoreBadAlloc &&
  (TD->getName() == "bad_alloc" && TD->isInStdNamespace())) ||
-(IgnoredTypes.count(TD->getName()) > 0))
+(IgnoredTypes.contains(TD->getName(
   TypesToDelete.push_back(T);
   }
 }
@@ -449,7 +449,8 @@ void 
ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() {
 ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
 const FunctionDecl *Func, const ExceptionInfo::Throwables &Caught,
 llvm::SmallSet &CallStack) {
-  if (!Func || CallStack.count(Func) || (!CallStack.empty() && 
!canThrow(Func)))
+  if (!Func || CallStack.contains(Func) ||
+  (!CallStack.empty() && !canThrow(Func)))
 return ExceptionInfo::createNonThrowing();
 
   if (const Stmt *Body = Func->getBody()) {
@@ -507,7 +508,7 @@ ExceptionAnalyzer::ExceptionInfo 
ExceptionAnalyzer::throwsException(
 for (unsigned I = 0; I < Try->getNumHandlers(); ++I) {
   const CXXCatchStmt *Catch = Try->getHandler(I);
 
-  // Everything is catched through 'catch(...)'.
+  // Everything is caught through 'catch(...)'.
   if (!Catch->getExceptionDecl()) {
 ExceptionInfo Rethrown = throwsException(
 Catch->getHandlerBlock(), Uncaught.getExceptionTypes(), CallStack);

diff  --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
index 0a8cf8668d3ca9..6c2d693d64b50e 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
@@ -101,8 +101,8 @@ class ExceptionAnalyzer {
 /// Recalculate the 'Behaviour' for example after filtering.
 void reevaluateBehaviour();
 
-/// Keep track if the entity related to this 'ExceptionInfo' can in 
princple
-/// throw, if it's unknown or if it won't throw.
+/// Keep track if the entity related to this 'ExceptionInfo' can in
+/// principle throw, if it's unknown or if it won't throw.
 State Behaviour;
 
 /// Keep track if the entity contains any unknown elements to keep track



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


[clang] [ARM] Fix NaN behaviour for MVE compare intrinsics (PR #116371)

2024-11-19 Thread Oliver Stannard via cfe-commits

https://github.com/ostannard updated 
https://github.com/llvm/llvm-project/pull/116371

>From 6bfe667f87da2551e7080af3caede272378e1e4d Mon Sep 17 00:00:00 2001
From: Oliver Stannard 
Date: Thu, 14 Nov 2024 18:16:12 +
Subject: [PATCH 1/2] [ARM] Fix NaN behaviour for MVE compare intrinsics

The MVE intrinsics are defined as having the same behaviour as the
instructions which they correspond to. In particular, the vcmpleq and
vcmpltq intrinsics correspond to the VCMP instruction with the LE or LT
condition. However, these instructions with these two conditions do not
match the normal IEEE754 behaviour for NaNs, they return true if either
operand is a NaN, instead of false. Therefore we need to generate `fcmp`
IR instructions with the `ule` and `ult` conditions, instead of `ole`
and `olt`.

This differs from AdvSIMD, where only instructions with the EQ, GE and
GT conditions are available, and the intrinsics for the others are
defined by swapping the condition and operand order, so the results
match the IEEE754 behaviour for NaNs.
---
 clang/include/clang/Basic/arm_mve.td  |  4 +--
 clang/include/clang/Basic/arm_mve_defs.td |  2 ++
 .../test/CodeGen/arm-mve-intrinsics/compare.c | 32 +--
 3 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 1debb94a0a7b81..93abbc47c54dd5 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -753,8 +753,8 @@ let params = T.Float in {
   defm: compare<"ne", fcmp_ne>;
   defm: compare<"gt", fcmp_gt>;
   defm: compare<"ge", fcmp_ge>;
-  defm: compare<"lt", fcmp_lt>;
-  defm: compare<"le", fcmp_le>;
+  defm: compare<"lt", fcmp_ult>;
+  defm: compare<"le", fcmp_ule>;
 }
 
 let params = T.Signed in {
diff --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index 1a090c08cc8531..9c725c890e7e4d 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -118,6 +118,8 @@ def fcmp_gt: IRBuilder<"CreateFCmpOGT">;
 def fcmp_ge: IRBuilder<"CreateFCmpOGE">;
 def fcmp_lt: IRBuilder<"CreateFCmpOLT">;
 def fcmp_le: IRBuilder<"CreateFCmpOLE">;
+def fcmp_ult: IRBuilder<"CreateFCmpULT">;
+def fcmp_ule: IRBuilder<"CreateFCmpULE">;
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
 def select: IRBuilder<"CreateSelect">;
 def fneg: IRBuilder<"CreateFNeg">;
diff --git a/clang/test/CodeGen/arm-mve-intrinsics/compare.c 
b/clang/test/CodeGen/arm-mve-intrinsics/compare.c
index 8f190990a65869..8886cf5c100581 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/compare.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/compare.c
@@ -2376,7 +2376,7 @@ mve_pred16_t test_vcmphiq_m_n_u32(uint32x4_t a, uint32_t 
b, mve_pred16_t p)
 
 // CHECK-LABEL: @test_vcmpleq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = fcmp ole <8 x half> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[TMP0:%.*]] = fcmp ule <8 x half> [[A:%.*]], [[B:%.*]]
 // CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.arm.mve.pred.v2i.v8i1(<8 x i1> 
[[TMP0]])
 // CHECK-NEXT:[[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
 // CHECK-NEXT:ret i16 [[TMP2]]
@@ -2392,7 +2392,7 @@ mve_pred16_t test_vcmpleq_f16(float16x8_t a, float16x8_t 
b)
 
 // CHECK-LABEL: @test_vcmpleq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = fcmp ole <4 x float> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[TMP0:%.*]] = fcmp ule <4 x float> [[A:%.*]], [[B:%.*]]
 // CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1> 
[[TMP0]])
 // CHECK-NEXT:[[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
 // CHECK-NEXT:ret i16 [[TMP2]]
@@ -2458,7 +2458,7 @@ mve_pred16_t test_vcmpleq_s32(int32x4_t a, int32x4_t b)
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <8 x half> poison, 
half [[B:%.*]], i64 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <8 x half> 
[[DOTSPLATINSERT]], <8 x half> poison, <8 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP0:%.*]] = fcmp ole <8 x half> [[A:%.*]], [[DOTSPLAT]]
+// CHECK-NEXT:[[TMP0:%.*]] = fcmp ule <8 x half> [[A:%.*]], [[DOTSPLAT]]
 // CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.arm.mve.pred.v2i.v8i1(<8 x i1> 
[[TMP0]])
 // CHECK-NEXT:[[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
 // CHECK-NEXT:ret i16 [[TMP2]]
@@ -2476,7 +2476,7 @@ mve_pred16_t test_vcmpleq_n_f16(float16x8_t a, float16_t 
b)
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <4 x float> poison, 
float [[B:%.*]], i64 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <4 x float> 
[[DOTSPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP0:%.*]] = fcmp ole <4 x float> [[A:%.*]], [[DOTSPLAT]]
+// CHECK-NEXT:[[TMP0:%.*]] = fcmp ule <4 x float> [[A:%.*]], [[DOTSPLAT]]
 // CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1> 
[[TMP0]])
 // CHECK-NEXT:[[TMP2:%.*]] = tru

[clang] [ARM] Fix NaN behaviour for MVE compare intrinsics (PR #116371)

2024-11-19 Thread Oliver Stannard via cfe-commits


@@ -118,6 +118,8 @@ def fcmp_gt: IRBuilder<"CreateFCmpOGT">;
 def fcmp_ge: IRBuilder<"CreateFCmpOGE">;
 def fcmp_lt: IRBuilder<"CreateFCmpOLT">;
 def fcmp_le: IRBuilder<"CreateFCmpOLE">;

ostannard wrote:

Done

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


[clang] [clang-repl] Use default visibility for symbols while building CompilerInstance against emscripten (PR #116779)

2024-11-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Anutosh Bhat (anutosh491)


Changes

When running clang-repl in the browser we end up having something like the 
following 
`
"" -cc1 -triple wasm32-unknown-emscripten .. -main-file-name "<<< 
inputs >>>"  -fvisibility=hidden  -o "<<< inputs 
>>>.o" -x c++ "<<< inputs >>>"
`


Due to the default introduced through this commit 
(https://github.com/llvm/llvm-project/commit/e3d71e14d756d78f9e2538f2e530aa7c051541cd#diff-b5496baaf5c83e1ffa1a26d0815843b8d3224aba84366cbb6aeecf703808c803R2083)


That being said, when we generated the shared libraries to be loaded on top of 
the main module while running clang-repl in the browser, we have to surpass the 
above through `--export-all`
https://github.com/llvm/llvm-project/blob/b3e2b1a7eb258a7c9c55691d08342eface083499/clang/lib/Interpreter/Wasm.cpp#L78

This is because obviously `incr_module_XX.wasm` might want to access symbols 
out of file from `incr_module_XX-1.wasm` to `incr_mdoule_0.wasm`

But this also exports some problematic things like `__dso_handle` that causes 
conflicts across modules.

![image](https://github.com/user-attachments/assets/007cb2a8-e732-4e7a-9950-ff54785e62a6)

A better way to deal with this is to pass `-fvisibility=default` to the 
`CompilerInstance`.

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


2 Files Affected:

- (modified) clang/lib/Interpreter/Interpreter.cpp (+1) 
- (modified) clang/lib/Interpreter/Wasm.cpp (-1) 


``diff
diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 73ad766e655180..999271aae7491d 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -197,6 +197,7 @@ IncrementalCompilerBuilder::CreateCpp() {
   Argv.push_back("-target");
   Argv.push_back("wasm32-unknown-emscripten");
   Argv.push_back("-shared");
+  Argv.push_back("-fvisibility=default")
 #endif
   Argv.insert(Argv.end(), UserArgs.begin(), UserArgs.end());
 
diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index 79efbaa03982d0..6d4cc478dd6a85 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -75,7 +75,6 @@ llvm::Error 
WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
   "-shared",
   "--import-memory",
   "--no-entry",
-  "--export-all",
   "--experimental-pic",
   "--stack-first",
   "--allow-undefined",

``




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


[clang-tools-extra] [clang-tidy] Improved readability redundant casting with enums (PR #111424)

2024-11-19 Thread Piotr Zegar via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin
Message-ID:
In-Reply-To: 


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

Please implement this change under separate option like: 
`AllowEnumsBeRecognizedAs Aliases` or something similar.
Implicit conversion between enums and underlying type is not always welcome by 
developers.

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


[clang] [flang] [clang][driver] When -fveclib=ArmPL flag is in use, always link against libamath (PR #116432)

2024-11-19 Thread Paul Walker via cfe-commits


@@ -490,6 +490,16 @@ void tools::AddLinkerInputs(const ToolChain &TC, const 
InputInfoList &Inputs,
 else
   A.renderAsInput(Args, CmdArgs);
   }
+  if (const Arg *A = Args.getLastArg(options::OPT_fveclib)) {
+if (A->getNumValues() == 1) {
+  StringRef V = A->getValue();
+  if (V == "ArmPL") {
+CmdArgs.push_back(Args.MakeArgString("-lamath"));
+CmdArgs.push_back(Args.MakeArgString("-lm"));

paulwalker-arm wrote:

> Flang already has a hack for a different veclib implementation on darwin

The difference with the one instance of doing this is that Accelerate is a core 
part of that environment, much like libm is a core part of the linux 
environment.  libamath is not core to any environment.  I recommend seeking 
advice from the wider clang community before landing this work.

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


[clang] [analyzer][Solver] Early return if sym is concrete on assuming (PR #115579)

2024-11-19 Thread Ding Fei via cfe-commits

danix800 wrote:

> I'm not sure I see why. The logs I linked in the revert only showed a single 
> test failure. The new test we added in this PR. This suggests close 
> correlations. Maybe the content of the "constraints" map in the State is 
> dumped in a non-deterministic order? And we just happened to step on it now.

Yes it's the testcase touched by this PR that failed (not other random testcase 
inside the repo).

I mean that clang behaves randomly.

The randomness might not be introduced by this PR but by some earlier commit 
point.

I'm working on it.

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


[clang] [lld] [llvm] [X86][MC,LLD][NFC] Rename R_X86_64_REX2_GOTPCRELX (PR #116737)

2024-11-19 Thread Shengchen Kan via cfe-commits

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

LGTM

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


[clang-tools-extra] [clang-tidy][NFC] fix typo in ExceptionAnalyzer; `replace count()>0` with `contains` (PR #116635)

2024-11-19 Thread Congcong Cai via cfe-commits


@@ -449,7 +449,8 @@ void 
ExceptionAnalyzer::ExceptionInfo::reevaluateBehaviour() {
 ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::throwsException(
 const FunctionDecl *Func, const ExceptionInfo::Throwables &Caught,
 llvm::SmallSet &CallStack) {
-  if (!Func || CallStack.count(Func) || (!CallStack.empty() && 
!canThrow(Func)))

HerrCai0907 wrote:

After change (`count` to `contains`), it is more than 80 characters. 😆 

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


[clang-tools-extra] [clang-tidy][NFC] fix typo in ExceptionAnalyzer; `replace count()>0` with `contains` (PR #116635)

2024-11-19 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy] Create a check for signed and unsigned integers comparison (PR #113144)

2024-11-19 Thread via cfe-commits

qt-tatiana wrote:

Ping :)

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


[clang] 51ad290 - [Clang] Improve diagnostic on `[[nodiscard]]` attribute (#112521)

2024-11-19 Thread via cfe-commits

Author: Yihe Li
Date: 2024-11-19T11:04:53+01:00
New Revision: 51ad2901ca54a01a72db71622b116eb27ea6dcf2

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

LOG: [Clang] Improve diagnostic on `[[nodiscard]]` attribute (#112521)

A follow-up to #112289.

When diagnosing an unused return value, if the diagnostic
is triggered by an attribute attached to a type, the type name
is now included in the diagnostic.

-

Co-authored-by: Sirraide 

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Expr.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/Expr.cpp
clang/lib/Sema/SemaStmt.cpp
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp
clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp
clang/test/Sema/c2x-nodiscard.c
clang/test/SemaCXX/warn-unused-result.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4d6275fbc9810c..4514f9f591ffa4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -539,6 +539,22 @@ Improvements to Clang's diagnostics
 
 - Clang now omits shadow warnings for enum constants in separate class scopes 
(#GH62588).
 
+- When diagnosing an unused return value of a type declared ``[[nodiscard]]``, 
the type
+  itself is now included in the diagnostic.
+
+- Clang will now prefer the ``[[nodiscard]]`` declaration on function 
declarations over ``[[nodiscard]]``
+  declaration on the return type of a function. Previously, when both have a 
``[[nodiscard]]`` declaration attached,
+  the one on the return type would be preferred. This may affect the generated 
warning message:
+
+  .. code-block:: c++
+
+struct [[nodiscard("Reason 1")]] S {};
+[[nodiscard("Reason 2")]] S getS();
+void use()
+{
+  getS(); // Now diagnoses "Reason 2", previously diagnoses "Reason 1"
+}
+
 Improvements to Clang's time-trace
 --
 

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 466c65a9685ad3..708c8656decbe0 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3181,12 +3181,14 @@ class CallExpr : public Expr {
   QualType getCallReturnType(const ASTContext &Ctx) const;
 
   /// Returns the WarnUnusedResultAttr that is either declared on the called
-  /// function, or its return type declaration.
-  const Attr *getUnusedResultAttr(const ASTContext &Ctx) const;
+  /// function, or its return type declaration, together with a NamedDecl that
+  /// refers to the declaration the attribute is attached onto.
+  std::pair
+  getUnusedResultAttr(const ASTContext &Ctx) const;
 
   /// Returns true if this call expression should warn on unused results.
   bool hasUnusedResultAttr(const ASTContext &Ctx) const {
-return getUnusedResultAttr(Ctx) != nullptr;
+return getUnusedResultAttr(Ctx).second != nullptr;
   }
 
   SourceLocation getRParenLoc() const { return RParenLoc; }

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ad2a932ca463ec..dfb90501ce72d7 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9300,11 +9300,11 @@ def warn_unused_container_subscript_expr : Warning<
 def warn_unused_call : Warning<
   "ignoring return value of function declared with %0 attribute">,
   InGroup;
-def warn_unused_constructor : Warning<
-  "ignoring temporary created by a constructor declared with %0 attribute">,
+def warn_unused_return_type : Warning<
+  "ignoring %select{return value|temporary}0 of type %2 declared with %1 
attribute%select{|: %4}3">,
   InGroup;
-def warn_unused_constructor_msg : Warning<
-  "ignoring temporary created by a constructor declared with %0 attribute: 
%1">,
+def warn_unused_constructor : Warning<
+  "ignoring temporary created by a constructor declared with %0 
attribute%select{|: %2}1">,
   InGroup;
 def warn_side_effects_unevaluated_context : Warning<
   "expression with side effects has no effect in an unevaluated context">,
@@ -9313,10 +9313,7 @@ def warn_side_effects_typeid : Warning<
   "expression with side effects will be evaluated despite being used as an "
   "operand to 'typeid'">, InGroup;
 def warn_unused_result : Warning<
-  "ignoring return value of function declared with %0 attribute">,
-  InGroup;
-def warn_unused_result_msg : Warning<
-  "ignoring return value of function declared with %0 attribute: %1">,
+  "ignoring return value of function declared with %0 attribute%select{|: 
%2}1">,
   InGroup;
 def warn_unused_result_typedef_unsupported_spelling : Warning<
   "'[[%select{nodiscard|gnu::warn_unused_result}0]]' attribute ignored when "

diff  -

[clang-tools-extra] [clang-tidy] Improved readability redundant casting with enums (PR #111424)

2024-11-19 Thread Piotr Zegar via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin
Message-ID:
In-Reply-To: 



@@ -221,3 +221,16 @@ void testRedundantDependentNTTPCasting() {
   // CHECK-MESSAGES: :[[@LINE-4]]:25: note: source type originates from 
referencing this non-type template parameter
   // CHECK-FIXES: {{^}}  T a = V;
 }
+
+enum E1 : char {};
+enum class E2 : char {};
+
+void testEnum(E1 e1, E2 e2){
+  char a = static_cast(e1);

PiotrZSL wrote:

That isn't a redundant cast. Such casts should be done in explicit way. In C++ 
is even better to use:
std::to_underlying since C++23 or std::underlying_type now.

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


[clang] [clang-repl] Use default visibility for symbols while building CompilerInstance against emscripten (PR #116779)

2024-11-19 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 7e85cb8a8a9de57ed10635b843662148a87b17e5 
616ebd6b6487eeaa302e6d33de3a371e6c9843f5 --extensions cpp -- 
clang/lib/Interpreter/Interpreter.cpp clang/lib/Interpreter/Wasm.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index 999271aae7..8b91f55c7e 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -199,7 +199,7 @@ IncrementalCompilerBuilder::CreateCpp() {
   Argv.push_back("-shared");
   Argv.push_back("-fvisibility=default")
 #endif
-  Argv.insert(Argv.end(), UserArgs.begin(), UserArgs.end());
+  Argv.insert(Argv.end(), UserArgs.begin(), UserArgs.end());
 
   std::string TT = TargetTriple ? *TargetTriple : 
llvm::sys::getProcessTriple();
   return IncrementalCompilerBuilder::create(TT, Argv);

``




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


[clang-tools-extra] [clang-tidy] Improved readability redundant casting with enums (PR #111424)

2024-11-19 Thread Piotr Zegar via cfe-commits
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin
Message-ID:
In-Reply-To: 


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


[clang] b2ec416 - [ARM] Fix NaN behaviour for MVE compare intrinsics (#116371)

2024-11-19 Thread via cfe-commits

Author: Oliver Stannard
Date: 2024-11-19T10:23:14Z
New Revision: b2ec416aa5bcd89c4bc295163d60e5a2ecb99212

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

LOG: [ARM] Fix NaN behaviour for MVE compare intrinsics (#116371)

The MVE intrinsics are defined as having the same behaviour as the
instructions which they correspond to. In particular, the vcmpleq and
vcmpltq intrinsics correspond to the VCMP instruction with the LE or LT
condition. However, these instructions with these two conditions do not
match the normal IEEE754 behaviour for NaNs, they return true if either
operand is a NaN, instead of false. Therefore we need to generate `fcmp`
IR instructions with the `ule` and `ult` conditions, instead of `ole`
and `olt`.

This differs from AdvSIMD, where only instructions with the EQ, GE and
GT conditions are available, and the intrinsics for the others are
defined by swapping the condition and operand order, so the results
match the IEEE754 behaviour for NaNs.

Added: 


Modified: 
clang/include/clang/Basic/arm_mve.td
clang/include/clang/Basic/arm_mve_defs.td
clang/test/CodeGen/arm-mve-intrinsics/compare.c

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 1debb94a0a7b81..93abbc47c54dd5 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -753,8 +753,8 @@ let params = T.Float in {
   defm: compare<"ne", fcmp_ne>;
   defm: compare<"gt", fcmp_gt>;
   defm: compare<"ge", fcmp_ge>;
-  defm: compare<"lt", fcmp_lt>;
-  defm: compare<"le", fcmp_le>;
+  defm: compare<"lt", fcmp_ult>;
+  defm: compare<"le", fcmp_ule>;
 }
 
 let params = T.Signed in {

diff  --git a/clang/include/clang/Basic/arm_mve_defs.td 
b/clang/include/clang/Basic/arm_mve_defs.td
index 1a090c08cc8531..634b4e9c2c9c8a 100644
--- a/clang/include/clang/Basic/arm_mve_defs.td
+++ b/clang/include/clang/Basic/arm_mve_defs.td
@@ -116,8 +116,8 @@ def fcmp_eq: IRBuilder<"CreateFCmpOEQ">;
 def fcmp_ne: IRBuilder<"CreateFCmpUNE">; // not O: it must return true on NaNs
 def fcmp_gt: IRBuilder<"CreateFCmpOGT">;
 def fcmp_ge: IRBuilder<"CreateFCmpOGE">;
-def fcmp_lt: IRBuilder<"CreateFCmpOLT">;
-def fcmp_le: IRBuilder<"CreateFCmpOLE">;
+def fcmp_ult: IRBuilder<"CreateFCmpULT">;
+def fcmp_ule: IRBuilder<"CreateFCmpULE">;
 def splat: CGHelperFn<"ARMMVEVectorSplat">;
 def select: IRBuilder<"CreateSelect">;
 def fneg: IRBuilder<"CreateFNeg">;

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/compare.c 
b/clang/test/CodeGen/arm-mve-intrinsics/compare.c
index 8f190990a65869..8886cf5c100581 100644
--- a/clang/test/CodeGen/arm-mve-intrinsics/compare.c
+++ b/clang/test/CodeGen/arm-mve-intrinsics/compare.c
@@ -2376,7 +2376,7 @@ mve_pred16_t test_vcmphiq_m_n_u32(uint32x4_t a, uint32_t 
b, mve_pred16_t p)
 
 // CHECK-LABEL: @test_vcmpleq_f16(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = fcmp ole <8 x half> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[TMP0:%.*]] = fcmp ule <8 x half> [[A:%.*]], [[B:%.*]]
 // CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.arm.mve.pred.v2i.v8i1(<8 x i1> 
[[TMP0]])
 // CHECK-NEXT:[[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
 // CHECK-NEXT:ret i16 [[TMP2]]
@@ -2392,7 +2392,7 @@ mve_pred16_t test_vcmpleq_f16(float16x8_t a, float16x8_t 
b)
 
 // CHECK-LABEL: @test_vcmpleq_f32(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = fcmp ole <4 x float> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:[[TMP0:%.*]] = fcmp ule <4 x float> [[A:%.*]], [[B:%.*]]
 // CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1> 
[[TMP0]])
 // CHECK-NEXT:[[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
 // CHECK-NEXT:ret i16 [[TMP2]]
@@ -2458,7 +2458,7 @@ mve_pred16_t test_vcmpleq_s32(int32x4_t a, int32x4_t b)
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <8 x half> poison, 
half [[B:%.*]], i64 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <8 x half> 
[[DOTSPLATINSERT]], <8 x half> poison, <8 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP0:%.*]] = fcmp ole <8 x half> [[A:%.*]], [[DOTSPLAT]]
+// CHECK-NEXT:[[TMP0:%.*]] = fcmp ule <8 x half> [[A:%.*]], [[DOTSPLAT]]
 // CHECK-NEXT:[[TMP1:%.*]] = call i32 @llvm.arm.mve.pred.v2i.v8i1(<8 x i1> 
[[TMP0]])
 // CHECK-NEXT:[[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
 // CHECK-NEXT:ret i16 [[TMP2]]
@@ -2476,7 +2476,7 @@ mve_pred16_t test_vcmpleq_n_f16(float16x8_t a, float16_t 
b)
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[DOTSPLATINSERT:%.*]] = insertelement <4 x float> poison, 
float [[B:%.*]], i64 0
 // CHECK-NEXT:[[DOTSPLAT:%.*]] = shufflevector <4 x float> 
[[DOTSPLATINSERT]], <4 x float> poison, <4 x i32> zeroinitializer
-// CHECK-NEXT:[[TMP0:%.*]] = fcmp ole <4 x float> [[A:%.*]], 

[clang] [ARM] Fix NaN behaviour for MVE compare intrinsics (PR #116371)

2024-11-19 Thread Oliver Stannard via cfe-commits

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


[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-19 Thread Haojian Wu via cfe-commits

https://github.com/hokein updated 
https://github.com/llvm/llvm-project/pull/114044

>From ac8f934144cfa657ae7ba0c8797fe058aa0a9c53 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Fri, 1 Nov 2024 16:51:03 +0100
Subject: [PATCH 1/5] [clang] Fix the post-filtering heuristics for GSLPointer
 case.

---
 clang/docs/ReleaseNotes.rst   |   2 +
 clang/lib/Sema/CheckExprLifetime.cpp  | 113 ++
 .../Sema/warn-lifetime-analysis-nocfg.cpp |  48 +++-
 3 files changed, 139 insertions(+), 24 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ba582160cf9920..67a30eaaffa9a3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -533,6 +533,8 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables 
(#GH90073).
 
+- Fix false positives when `[[gsl::Owner/Pointer]]` and 
`[[clang::lifetimebound]]` are used together.
+
 - Improved diagnostic message for ``__builtin_bit_cast`` size mismatch 
(#GH115870).
 
 Improvements to Clang's time-trace
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index a1a402b4a2b530..d1e8cc9f9b075c 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -1093,6 +1093,87 @@ static bool pathOnlyHandlesGslPointer(const 
IndirectLocalPath &Path) {
   }
   return false;
 }
+// Result of analyzing the Path for GSLPointer.
+enum AnalysisResult {
+  // Path does not correspond to a GSLPointer.
+  NotGSLPointer,
+
+  // A relevant case was identified.
+  Report,
+  // Stop the entire traversal.
+  Abandon,
+  // Skip this step and continue traversing inner AST nodes.
+  Skip,
+};
+// Analyze cases where a GSLPointer is initialized or assigned from a
+// temporary owner object.
+static AnalysisResult analyzePathForGSLPointer(const IndirectLocalPath &Path,
+   Local L) {
+  if (!pathOnlyHandlesGslPointer(Path))
+return NotGSLPointer;
+
+  // At this point, Path represents a series of operations involving a
+  // GSLPointer, either in the process of initialization or assignment.
+
+  // Note: A LifetimeBoundCall can appear interleaved in this sequence.
+  // For example:
+  //const std::string& Ref(const std::string& a [[clang::lifetimebound]]);
+  //string_view abc = Ref(std::string());
+  // The "Path" is [GSLPointerInit, LifetimeboundCall], where "L" is the
+  // temporary "std::string()" object. We need to check if the function with 
the
+  // lifetimebound attribute returns a "owner" type.
+  if (Path.back().Kind == IndirectLocalPathEntry::LifetimeBoundCall) {
+// The lifetimebound applies to the implicit object parameter of a method.
+if (const auto *Method = llvm::dyn_cast(Path.back().D)) {
+  if (Method->getReturnType()->isReferenceType() &&
+  isRecordWithAttr(
+  Method->getReturnType()->getPointeeType()))
+return Report;
+  return Abandon;
+}
+// The lifetimebound applies to a function parameter.
+const auto *PD = llvm::dyn_cast(Path.back().D);
+if (const auto *FD = llvm::dyn_cast(PD->getDeclContext())) {
+  if (isa(FD)) {
+// Constructor case: the parameter is annotated with lifetimebound
+//   e.g., GSLPointer(const S& s [[clang::lifetimebound]])
+// We still respect this case even the type S is not an owner.
+return Report;
+  }
+  // For regular functions, check if the return type has an Owner 
attribute.
+  //   e.g., const GSLOwner& func(const Foo& foo [[clang::lifetimebound]])
+  if (FD->getReturnType()->isReferenceType() &&
+  isRecordWithAttr(FD->getReturnType()->getPointeeType()))
+return Report;
+}
+return Abandon;
+  }
+
+  if (isa(L)) {
+// We do not want to follow the references when returning a pointer
+// originating from a local owner to avoid the following false positive:
+//   int &p = *localUniquePtr;
+//   someContainer.add(std::move(localUniquePtr));
+//   return p;
+if (!pathContainsInit(Path) && isRecordWithAttr(L->getType()))
+  return Report;
+return Abandon;
+  }
+
+  // The GSLPointer is from a temporary object.
+  auto *MTE = dyn_cast(L);
+
+  bool IsGslPtrValueFromGslTempOwner =
+  MTE && !MTE->getExtendingDecl() &&
+  isRecordWithAttr(MTE->getType());
+  // Skipping a chain of initializing gsl::Pointer annotated objects.
+  // We are looking only for the final source to find out if it was
+  // a local or temporary owner or the address of a local
+  // variable/param.
+  if (!IsGslPtrValueFromGslTempOwner)
+return Skip;
+  return Report;
+}
 
 static bool isAssignmentOperatorLifetimeBound(CXXMethodDecl *CMD) {
   if (!CMD)
@@ -1131,27 +1212,17 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
 
 auto *MTE = dyn_cast(L);
 
-bool IsGslPtrValueFromGslTempOwner = false;
-if (pat

[clang] [clang] Improve diagnostic on [[nodiscard]] attribute (PR #112521)

2024-11-19 Thread via cfe-commits

github-actions[bot] wrote:



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


[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-19 Thread Haojian Wu via cfe-commits

hokein wrote:

> Just discover a new false positive:
> 
> ```
> namespace std {
> template 
> class [[gsl::Pointer]] Iterator2 {
>  public:
>   using reference = T&;
>   Iterator2() {}
>   reference operator*() const;
> };
> }
> 
> template 
> class AnySpan {
>  public:
>   AnySpan() {}
>   std::Iterator2 begin() const [[clang::lifetimebound]];
> };
> 
> AnySpan MakeAnySpan();
> void s() {
>   const int& t2 = *AnySpan().begin();  // false positive, warning.
> }
> ```

Fix it in the latest commit 
https://github.com/llvm/llvm-project/pull/114044/commits/85e08706d4b9cfd6d419e486cdf1034c1dc1a45d,
 it would be nice to take another look at the patch, @Xazax-hun, @usx95.

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


[clang] [Clang] add single quotes around __builtin_bit_cast (PR #116120)

2024-11-19 Thread via cfe-commits


@@ -12366,7 +12366,7 @@ def err_preserve_enum_value_not_const: Error<
   "__builtin_preserve_enum_value argument %0 not a constant">;
 

Sirraide wrote:

It would probably be nice if someone did a general cleanup pass on all the 
diagnostics TD files, because I just saw a bunch more up here that aren’t 
quoted, but that sounds like a lot of work...

~~Maybe we can tag that as a good first issue?~~ ;Þ

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


[clang] 6aa80f0 - [Clang] [NFC] Add single quotes around __builtin_bit_cast (#116120)

2024-11-19 Thread via cfe-commits

Author: Oleksandr T.
Date: 2024-11-19T10:16:47+01:00
New Revision: 6aa80f00574826a0c2f2972a659517a9bf1efece

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

LOG: [Clang] [NFC] Add single quotes around __builtin_bit_cast (#116120)

Fixes #116118

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/test/SemaCXX/builtin-bit-cast.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 3caf471d3037f9..ad2a932ca463ec 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12366,7 +12366,7 @@ def err_preserve_enum_value_not_const: Error<
   "__builtin_preserve_enum_value argument %0 not a constant">;
 
 def err_bit_cast_non_trivially_copyable : Error<
-  "__builtin_bit_cast %select{source|destination}0 type must be trivially 
copyable">;
+  "'__builtin_bit_cast' %select{source|destination}0 type must be trivially 
copyable">;
 def err_bit_cast_type_size_mismatch : Error<
   "size of '__builtin_bit_cast' source type %0 does not match destination type 
%1 (%2 vs %3 bytes)">;
 

diff  --git a/clang/test/SemaCXX/builtin-bit-cast.cpp 
b/clang/test/SemaCXX/builtin-bit-cast.cpp
index d7f24c7939b558..8717371b941b0d 100644
--- a/clang/test/SemaCXX/builtin-bit-cast.cpp
+++ b/clang/test/SemaCXX/builtin-bit-cast.cpp
@@ -32,10 +32,10 @@ struct not_trivially_copyable {
   virtual void foo() {}
 };
 
-// expected-error@+1{{__builtin_bit_cast source type must be trivially 
copyable}}
+// expected-error@+1{{'__builtin_bit_cast' source type must be trivially 
copyable}}
 constexpr unsigned long ul = __builtin_bit_cast(unsigned long, 
not_trivially_copyable{});
 
-// expected-error@+1 {{__builtin_bit_cast destination type must be trivially 
copyable}}
+// expected-error@+1 {{'__builtin_bit_cast' destination type must be trivially 
copyable}}
 constexpr long us = __builtin_bit_cast(unsigned long &, 0L);
 
 namespace PR42936 {



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


[clang] [Clang] add single quotes around __builtin_bit_cast (PR #116120)

2024-11-19 Thread via cfe-commits

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


[clang] [clang] constexpr built-in reduce mul function. (PR #116626)

2024-11-19 Thread Mariya Podchishchaeva via cfe-commits

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

LGTM, thanks!

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


[clang] [Clang] Prevent Null Pointer Dereference in in sema::​isNormalAssignmentOperator() (PR #115880)

2024-11-19 Thread via cfe-commits


@@ -482,8 +482,8 @@ static bool isNormalAssignmentOperator(const FunctionDecl 
*FD) {
 if (RetT->isLValueReferenceType()) {
   ASTContext &Ctx = FD->getASTContext();
   QualType LHST;
-  auto *MD = dyn_cast(FD);
-  if (MD && MD->isCXXInstanceMember())
+  auto *MD = cast(FD);
+  if (MD->isCXXInstanceMember())
 LHST = 
Ctx.getLValueReferenceType(MD->getFunctionObjectParameterType());
   else
 LHST = MD->getParamDecl(0)->getType();

Sirraide wrote:

```suggestion
  else
LHST = FD->getParamDecl(0)->getType();
```
I’m pretty sure this is a typo and is actually supposed to be this. I don’t 
think a `cast` instead of `dyn_cast` is right here because this is also a valid 
assignment operator, but it isn’t a `CXXMethodDecl`:
```c++
struct S {};
void operator|=(S, S) {}
```

@cor3ntin’s question as to whether this handles explicit object parameters 
correctly is also something we should investigate, but that seems like a 
separate issue.

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


[clang] 4818dd3 - [HLSL] Rename resource's "h" member to "__handle". NFC (#116696)

2024-11-19 Thread via cfe-commits

Author: Justin Bogner
Date: 2024-11-19T01:26:52-08:00
New Revision: 4818dd33d84fcf41c08419a9960cadd473d536a9

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

LOG: [HLSL] Rename resource's "h" member to "__handle". NFC (#116696)

This makes it clearer that the handle is an implementation detail by
using a name that's reserved.

Added: 


Modified: 
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
clang/test/AST/HLSL/RWBuffer-AST.hlsl
clang/test/AST/HLSL/RWStructuredBuffer-AST.hlsl
clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
clang/test/AST/HLSL/StructuredBuffer-AST.hlsl
clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl
clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl

Removed: 




diff  --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index cac15b974a276e..9c430be16f1aa3 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -139,7 +139,7 @@ struct BuiltinTypeDeclBuilder {
 Attr *ResourceAttr = HLSLResourceAttr::CreateImplicit(Ctx, RK);
 if (CreateHLSLAttributedResourceType(S, Ctx.HLSLResourceTy, Attrs,
  AttributedResTy))
-  addMemberVariable("h", AttributedResTy, {ResourceAttr}, Access);
+  addMemberVariable("__handle", AttributedResTy, {ResourceAttr}, Access);
 return *this;
   }
 

diff  --git a/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl 
b/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
index 5a13ca7735f999..e0199d0371fb5d 100644
--- a/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
@@ -30,7 +30,7 @@ AppendStructuredBuffer Buffer;
 // CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit class AppendStructuredBuffer definition
 
 // CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
-// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit h '__hlsl_resource_t
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit __handle '__hlsl_resource_t
 // CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
 // CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
@@ -43,7 +43,7 @@ AppendStructuredBuffer Buffer;
 // CHECK: TemplateArgument type 'int'
 // CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
 // CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
-// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit h '__hlsl_resource_t
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit __handle '__hlsl_resource_t
 // CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
 // CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(int)]]

diff  --git a/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl 
b/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
index b75f3fcb959cfc..32cd9c02af1ab0 100644
--- a/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
@@ -30,7 +30,7 @@ ConsumeStructuredBuffer Buffer;
 // CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit class ConsumeStructuredBuffer definition
 
 // CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
-// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit h '__hlsl_resource_t
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit __handle '__hlsl_resource_t
 // CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
 // CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
@@ -44,7 +44,7 @@ ConsumeStructuredBuffer Buffer;
 // CHECK: TemplateArgument type 'int'
 // CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
 // CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
-// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit h '__hlsl_resource_t
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit __handle '__hlsl_resource_t
 // CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
 // CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(int)]]

diff  --git a/clang/test/AST/HLSL/RWBuffer-AST.hlsl 
b/clang/test/AST/HLSL/RWBuffer-AST.hlsl
index ebddd72ddb1e0e..769e4b5ff8aadc 100644
--- a/clang/test/AST/HLSL/RWBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/RWBuffer-AST.hlsl
@@ -29,7 +29,7 @@ RWBuffer Buffer;
 // CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit class RWBuffer definition
 
 // CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
-// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit h '__hlsl_resource_t
+

[clang] [Clang] Prevent Null Pointer Dereference in in sema::​isNormalAssignmentOperator() (PR #115880)

2024-11-19 Thread via cfe-commits

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


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


[clang] [HLSL] Rename resource's "h" member to "__handle". NFC (PR #116696)

2024-11-19 Thread Justin Bogner via cfe-commits

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


[clang] [HLSL] Fix resource kind for RasterizerOrderedStructuredBuffer (PR #116700)

2024-11-19 Thread Justin Bogner via cfe-commits


@@ -480,8 +480,8 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
 
   onCompletion(Decl, [this](CXXRecordDecl *Decl) {
 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV,
-ResourceKind::TypedBuffer,
-/*IsROV=*/false, /*RawBuffer=*/false)
+ResourceKind::TypedBuffer, /*IsROV=*/false,
+/*RawBuffer=*/false)

bogner wrote:

`clang-format` was complaining about the line I actually changed and I noticed 
that all of these looked funny. Seems like there's a "comment at the beginning 
of a line" heuristic that stops clang-format from messing with these, but if 
you collapse them to a single line and then run clang-format it does something 
pretty reasonable.

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


[clang] [HLSL] Fix resource kind for RasterizerOrderedStructuredBuffer (PR #116700)

2024-11-19 Thread Justin Bogner via cfe-commits


@@ -547,9 +543,8 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
  .addSimpleTemplateParams(*SemaPtr, {"element_type"})
  .Record;
   onCompletion(Decl, [this](CXXRecordDecl *Decl) {
-setupBufferType(Decl, *SemaPtr, ResourceClass::UAV,
-ResourceKind::TypedBuffer, /*IsROV=*/true,
-/*RawBuffer=*/true)
+setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, 
ResourceKind::RawBuffer,
+/*IsROV=*/true, /*RawBuffer=*/true)

bogner wrote:

`ResourceKind` won't be specified here in the future (See #104862), which will 
remove the redundancy. This change doesn't actually do much as is, but the 
inconsistency was confusing.

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


[clang] 4bd982d - [HLSL] Fix resource kind for RasterizerOrderedStructuredBuffer (#116700)

2024-11-19 Thread via cfe-commits

Author: Justin Bogner
Date: 2024-11-19T01:32:37-08:00
New Revision: 4bd982d528ac2b2cb73d9fe6e534db84cfc16aaf

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

LOG: [HLSL] Fix resource kind for RasterizerOrderedStructuredBuffer (#116700)

This is a kind of StructuredBuffer, so it should be "Raw" and not
"Typed".

Added: 


Modified: 
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl

Removed: 




diff  --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index 9c430be16f1aa3..9b1885374921a6 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -480,8 +480,8 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
 
   onCompletion(Decl, [this](CXXRecordDecl *Decl) {
 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV,
-ResourceKind::TypedBuffer,
-/*IsROV=*/false, /*RawBuffer=*/false)
+ResourceKind::TypedBuffer, /*IsROV=*/false,
+/*RawBuffer=*/false)
 .addArraySubscriptOperators()
 .completeDefinition();
   });
@@ -503,8 +503,7 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
  .Record;
   onCompletion(Decl, [this](CXXRecordDecl *Decl) {
 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, 
ResourceKind::RawBuffer,
-/*IsROV=*/false,
-/*RawBuffer=*/true)
+/*IsROV=*/false, /*RawBuffer=*/true)
 .addArraySubscriptOperators()
 .completeDefinition();
   });
@@ -514,8 +513,7 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
  .Record;
   onCompletion(Decl, [this](CXXRecordDecl *Decl) {
 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, 
ResourceKind::RawBuffer,
-/*IsROV=*/false,
-/*RawBuffer=*/true)
+/*IsROV=*/false, /*RawBuffer=*/true)
 .addArraySubscriptOperators()
 .completeDefinition();
   });
@@ -526,8 +524,7 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
   .Record;
   onCompletion(Decl, [this](CXXRecordDecl *Decl) {
 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, 
ResourceKind::RawBuffer,
-/*IsROV=*/false,
-/*RawBuffer=*/true)
+/*IsROV=*/false, /*RawBuffer=*/true)
 .completeDefinition();
   });
 
@@ -537,8 +534,7 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
   .Record;
   onCompletion(Decl, [this](CXXRecordDecl *Decl) {
 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, 
ResourceKind::RawBuffer,
-/*IsROV=*/false,
-/*RawBuffer=*/true)
+/*IsROV=*/false, /*RawBuffer=*/true)
 .completeDefinition();
   });
 
@@ -547,9 +543,8 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
  .addSimpleTemplateParams(*SemaPtr, {"element_type"})
  .Record;
   onCompletion(Decl, [this](CXXRecordDecl *Decl) {
-setupBufferType(Decl, *SemaPtr, ResourceClass::UAV,
-ResourceKind::TypedBuffer, /*IsROV=*/true,
-/*RawBuffer=*/true)
+setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, 
ResourceKind::RawBuffer,
+/*IsROV=*/true, /*RawBuffer=*/true)
 .addArraySubscriptOperators()
 .completeDefinition();
   });

diff  --git a/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl 
b/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
index f71affe898c231..488a1449d37400 100644
--- a/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
@@ -35,7 +35,7 @@ RasterizerOrderedStructuredBuffer Buffer;
 // CHECK-SAME{LITERAL}: [[hlsl::is_rov]]
 // CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
-// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
TypedBuffer
+// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
RawBuffer
 
 // CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'element_type &const (unsigned int) const'
 // CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  
Idx 'unsigned int'
@@ -63,4 +63,4 @@ RasterizerOrderedStructuredBuffer Buffer;
 // CHECK-SAME{LITERAL}: [[hlsl::is_rov]]
 // CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(int)]]
-// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
TypedBuffer
+// CHECK-NEXT: HLSLResou

[clang] [Clang] avoid adding consteval condition as the last statement to preserve valid CFG (PR #116513)

2024-11-19 Thread Oleksandr T. via cfe-commits

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

>From 69689f6ba5ac1715cc1df6cf08b79bb4b8bbe107 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 17 Nov 2024 01:34:42 +0200
Subject: [PATCH] [Clang] avoid adding consteval condition as the last
 statement to preserve valid CFG

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Analysis/CFG.cpp | 5 -
 clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp | 6 ++
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8830a5658c7da..d81085d011b866 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -535,6 +535,8 @@ Improvements to Clang's diagnostics
 
 - Improved diagnostic message for ``__builtin_bit_cast`` size mismatch 
(#GH115870).
 
+- Clang now diagnoses missing return value in functions containing ``if 
consteval`` (#GH116485).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index f678ac6f2ff36a..7a6bd8b6f8d070 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -3177,11 +3177,14 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
 if (!I->isConsteval())
   KnownVal = tryEvaluateBool(I->getCond());
 
-// Add the successors.  If we know that specific branches are
+// Add the successors. If we know that specific branches are
 // unreachable, inform addSuccessor() of that knowledge.
 addSuccessor(Block, ThenBlock, /* IsReachable = */ !KnownVal.isFalse());
 addSuccessor(Block, ElseBlock, /* IsReachable = */ !KnownVal.isTrue());
 
+if (I->isConsteval())
+  return Block;
+
 // Add the condition as the last statement in the new block.  This may
 // create new blocks as the condition may contain control-flow.  Any newly
 // created blocks will be pointed to be "Block".
diff --git a/clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp 
b/clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp
index 25d1f8df7f7166..3d993f000e8dda 100644
--- a/clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp
+++ b/clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp
@@ -5,3 +5,9 @@ static_assert(__is_same(decltype([] constexpr -> int { }( )), 
int)); // expected
 
 consteval int g() { } // expected-warning {{non-void function does not return 
a value}}
 static_assert(__is_same(decltype([] consteval -> int { }( )), int)); // 
expected-warning {{non-void lambda does not return a value}}
+
+namespace GH116485 {
+int h() {
+if consteval { }
+} // expected-warning {{non-void function does not return a value}}
+}

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


[clang] [Clang] skip warnings for constructors marked with the [[noreturn]] attribute (PR #115558)

2024-11-19 Thread Oleksandr T. via cfe-commits

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

>From f63263a1aa4873a63918649ea92352eb5cfe66eb Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 9 Nov 2024 00:41:13 +0200
Subject: [PATCH] [Clang] skip warnings for constructors marked with the
 [[noreturn]] attribute

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/lib/Analysis/CFG.cpp| 15 ++-
 .../CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp | 12 
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c3424e0e6f34c9..11d0e35d12a786 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -527,6 +527,8 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables 
(#GH90073).
 
+- Clang now omits warnings for constructors marked with the ``[[noreturn]]`` 
attribute (#GH63009).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index f678ac6f2ff36a..4d83f04c23060a 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -4889,16 +4889,21 @@ CFGBlock 
*CFGBuilder::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E,
   return Visit(E->getSubExpr(), asc);
 }
 
-CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
+CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E,
   AddStmtChoice asc) {
   // If the constructor takes objects as arguments by value, we need to 
properly
   // construct these objects. Construction contexts we find here aren't for the
   // constructor C, they're for its arguments only.
-  findConstructionContextsForArguments(C);
+  findConstructionContextsForArguments(E);
 
-  autoCreateBlock();
-  appendConstructor(Block, C);
-  return VisitChildren(C);
+  CXXConstructorDecl *C = E->getConstructor();
+  if (C && C->isNoReturn())
+Block = createNoReturnBlock();
+  else
+autoCreateBlock();
+
+  appendConstructor(Block, E);
+  return VisitChildren(E);
 }
 
 CFGBlock *CFGBuilder::VisitImplicitCastExpr(ImplicitCastExpr *E,
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
index 56920ea8e8cf20..a96224dd03e360 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
@@ -49,3 +49,15 @@ void check() {
   test_type(g);
   test_type(h); // expected-note {{instantiation}}
 }
+
+namespace GH63009 {
+struct S {
+  [[noreturn]] S() { throw int {}; }
+};
+
+int test_no_return_constructor() { S(); } // ok
+
+int main() {
+  test_no_return_constructor();
+}
+}

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


[clang] Reland [Clang] skip default argument instantiation for non-defining friend declarations to meet [dcl.fct.default] p4 (PR #115487)

2024-11-19 Thread Oleksandr T. via cfe-commits

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

>From 5e24d212f797b5fa1b6da1526c807046373d3c21 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Fri, 8 Nov 2024 16:13:17 +0200
Subject: [PATCH 1/2] [Clang] skip default argument instantiation for
 non-defining friend declarations to meet [dcl.fct.default] p4

---
 clang/docs/ReleaseNotes.rst   |  2 +
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  4 ++
 clang/test/CXX/temp/temp.res/p4.cpp   | 43 +++
 3 files changed, 49 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d0c43ff11f7bae..e8cf6fc50a1290 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -636,6 +636,8 @@ Bug Fixes to C++ Support
   an implicitly instantiated class template specialization. (#GH51051)
 - Fixed an assertion failure caused by invalid enum forward declarations. 
(#GH112208)
 - Name independent data members were not correctly initialized from default 
member initializers. (#GH114069)
+- Fixed an assertion failure caused by invalid default argument substitutions 
in non-defining
+  friend declarations. (#GH113324).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 5a001843e2ba46..200519c71c57ab 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4694,6 +4694,10 @@ bool Sema::InstantiateDefaultArgument(SourceLocation 
CallLoc, FunctionDecl *FD,
   ParmVarDecl *Param) {
   assert(Param->hasUninstantiatedDefaultArg());
 
+  if (FD->getFriendObjectKind() != Decl::FOK_None &&
+  !FD->getTemplateInstantiationPattern())
+return true;
+
   // Instantiate the expression.
   //
   // FIXME: Pass in a correct Pattern argument, otherwise
diff --git a/clang/test/CXX/temp/temp.res/p4.cpp 
b/clang/test/CXX/temp/temp.res/p4.cpp
index f54d8649f5da88..cf6c45b4c351c5 100644
--- a/clang/test/CXX/temp/temp.res/p4.cpp
+++ b/clang/test/CXX/temp/temp.res/p4.cpp
@@ -185,3 +185,46 @@ template struct S {
   friend void X::f(T::type);
 };
 }
+
+namespace GH113324 {
+template  struct S1 {
+  friend void f1(S1, int = 0); // expected-error {{friend declaration 
specifying a default argument must be a definition}}
+  friend void f2(S1 a, S1 = decltype(a){}); // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+};
+
+template  using alias = int;
+template  struct S2 {
+  // FIXME: We miss diagnosing the default argument instantiation failure
+  // (forming reference to void)
+  friend void f3(S2, int a = alias(1)); // expected-error {{friend 
declaration specifying a default argument must be a definition}}
+};
+
+struct S3 {
+  friend void f4(S3, int = 42) { }
+};
+
+template  using __enable_if_t = int;
+template  struct S4 {
+  static const int value = v;
+};
+struct S5 {
+  template <__enable_if_t::value, int> = 0>
+  S5(const char *);
+};
+struct S6 {
+  template 
+  friend void f5(int, S6, a, b, S5 = "") { }
+};
+
+void test() {
+  f1(S1<>{});
+  f2(S1<>{});
+  f3(S2());
+
+  S3 s3;
+  f4(s3);
+
+  S6 s6;
+  auto result = f5(0, s6, [] {}, [] {}); // expected-error {{variable has 
incomplete type 'void}}
+}
+} // namespace GH113324

>From 3ad3b6c5f35730be32f4f6ba2dc8d19f53be0442 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Fri, 8 Nov 2024 16:53:39 +0200
Subject: [PATCH 2/2] update comments

---
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 200519c71c57ab..0bbab95001ad8e 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4694,6 +4694,13 @@ bool Sema::InstantiateDefaultArgument(SourceLocation 
CallLoc, FunctionDecl *FD,
   ParmVarDecl *Param) {
   assert(Param->hasUninstantiatedDefaultArg());
 
+  // FIXME: We don't track member specialization info for non-defining
+  // friend declarations, so we will not be able to later find the function
+  // pattern. As a workaround, don't instantiate the default argument in this
+  // case. This is correct per wording and only an error recovery issue, as per
+  // [dcl.fct.default]p4:
+  //   if a friend declaration D specifies a default argument expression,
+  //   that declaration shall be a definition.
   if (FD->getFriendObjectKind() != Decl::FOK_None &&
   !FD->getTemplateInstantiationPattern())
 return true;

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


[clang] [Clang] Fix name lookup for dependent bases (PR #114978)

2024-11-19 Thread Vladislav Belov via cfe-commits

https://github.com/vbe-sc updated 
https://github.com/llvm/llvm-project/pull/114978

>From d17588af72f845b758a03637c84752dde733200c Mon Sep 17 00:00:00 2001
From: vb-sc 
Date: Tue, 5 Nov 2024 15:46:57 +0300
Subject: [PATCH] [clang] Fix name lookup for dependent bases

---
 clang/docs/ReleaseNotes.rst  |  3 ++
 clang/lib/AST/CXXInheritance.cpp | 18 
 clang/test/CXX/drs/cwg5xx.cpp| 48 ++--
 clang/www/cxx_dr_status.html |  2 +-
 4 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8830a5658c7da..b9f06f2047539a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -268,6 +268,9 @@ Resolutions to C++ Defect Reports
   by default.
   (`CWG2521: User-defined literals and reserved identifiers 
`_).
 
+- Clang now make correct name lookup when dependent base class is the current 
instantiation.
+  (`CWG591: When a dependent base class is the current instantiation 
`_).
+
 C Language Changes
 --
 
diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index eb265a872c1259..6d71cb206aa188 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -135,7 +135,7 @@ bool CXXRecordDecl::forallBases(ForallBasesCallback 
BaseMatches) const {
 return false;
 
   CXXRecordDecl *Base =
-cast_or_null(Ty->getDecl()->getDefinition());
+  cast_if_present(Ty->getDecl()->getDefinition());
   if (!Base ||
   (Base->isDependentContext() &&
!Base->isCurrentInstantiation(Record))) {
@@ -170,13 +170,21 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
 QualType BaseType =
 Context.getCanonicalType(BaseSpec.getType()).getUnqualifiedType();
 
+bool isCurrentInstantiation = isa(BaseType);
+if (!isCurrentInstantiation) {
+  if (auto *BaseRecord = cast_if_present(
+  BaseSpec.getType()->getAsRecordDecl()))
+isCurrentInstantiation = BaseRecord->isDependentContext() &&
+ BaseRecord->isCurrentInstantiation(Record);
+}
 // C++ [temp.dep]p3:
 //   In the definition of a class template or a member of a class template,
 //   if a base class of the class template depends on a template-parameter,
 //   the base class scope is not examined during unqualified name lookup
 //   either at the point of definition of the class template or member or
 //   during an instantiation of the class tem- plate or member.
-if (!LookupInDependent && BaseType->isDependentType())
+if (!LookupInDependent &&
+(BaseType->isDependentType() && !isCurrentInstantiation))
   continue;
 
 // Determine whether we need to visit this base class at all,
@@ -244,9 +252,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
 return FoundPath;
   }
 } else if (VisitBase) {
-  CXXRecordDecl *BaseRecord;
+  CXXRecordDecl *BaseRecord = nullptr;
   if (LookupInDependent) {
-BaseRecord = nullptr;
 const TemplateSpecializationType *TST =
 BaseSpec.getType()->getAs();
 if (!TST) {
@@ -265,8 +272,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
 BaseRecord = nullptr;
 }
   } else {
-BaseRecord = cast(
-BaseSpec.getType()->castAs()->getDecl());
+BaseRecord = 
cast(BaseSpec.getType()->getAsRecordDecl());
   }
   if (BaseRecord &&
   lookupInBases(Context, BaseRecord, BaseMatches, LookupInDependent)) {
diff --git a/clang/test/CXX/drs/cwg5xx.cpp b/clang/test/CXX/drs/cwg5xx.cpp
index ed0c7159dfc889..0d53a9d07d76de 100644
--- a/clang/test/CXX/drs/cwg5xx.cpp
+++ b/clang/test/CXX/drs/cwg5xx.cpp
@@ -1178,17 +1178,61 @@ namespace cwg590 { // cwg590: yes
   template typename A::B::C A::B::C::f(A::B::C) {}
 }
 
-namespace cwg591 { // cwg591: no
+namespace cwg591 { // cwg591: yes
   template struct A {
 typedef int M;
 struct B {
   typedef void M;
   struct C;
+  struct D;
+};
+  };
+
+  template struct G {
+struct B {
+  typedef int M;
+  struct C {
+typedef void M;
+struct D;
+  };
+};
+  };
+
+  template struct H {
+template struct B {
+  typedef int M;
+  template struct C {
+typedef void M;
+struct D;
+struct P;
+  };
 };
   };
 
   template struct A::B::C : A {
-// FIXME: Should find member of non-dependent base class A.
+M m;
+  };
+
+  template struct G::B::C::D : B {
+M m;
+  };
+
+  template
+  template
+  template
+  struct H::B::C::D : B {
+M m;
+  };
+
+  template struct A::B::D : A {
+M m;
+// expected-error@-1 {{field has incomplete type 'M' (aka 'void'}}
+  };
+
+  template
+  template
+  template
+  struct H::B::C:

[clang] [Clang] eliminate shadowing warnings for parameters using deducing this (PR #114813)

2024-11-19 Thread Oleksandr T. via cfe-commits

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

>From 91ff2b4226110ea35c78f0f1b6ff89b4bec2c788 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Mon, 4 Nov 2024 17:38:46 +0200
Subject: [PATCH 1/3] [Clang] eliminate shadowing warnings for parameters using
 deducing this

---
 clang/docs/ReleaseNotes.rst  |  2 ++
 clang/lib/Sema/SemaDecl.cpp  |  7 +--
 clang/test/SemaCXX/cxx2b-warn-shadow.cpp | 10 ++
 3 files changed, 17 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/SemaCXX/cxx2b-warn-shadow.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1372e49dfac03c..af8288ee8a8296 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -464,6 +464,8 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables 
(#GH90073).
 
+- Clang now omits shadowing warnings for parameter names using deducing this 
(#GH95707).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 1aa3e8edfe1b13..38b07b15eb3eb2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8236,11 +8236,14 @@ void Sema::CheckShadow(NamedDecl *D, NamedDecl 
*ShadowedDecl,
   DeclContext *NewDC = D->getDeclContext();
 
   if (FieldDecl *FD = dyn_cast(ShadowedDecl)) {
-// Fields are not shadowed by variables in C++ static methods.
-if (CXXMethodDecl *MD = dyn_cast(NewDC))
+if (CXXMethodDecl *MD = dyn_cast(NewDC)) {
+  // Fields are not shadowed by variables in C++ static methods.
   if (MD->isStatic())
 return;
 
+  if (!MD->getParent()->isLambda() && MD->isExplicitObjectMemberFunction())
+return;
+}
 // Fields shadowed by constructor parameters are a special case. Usually
 // the constructor initializes the field with the parameter.
 if (isa(NewDC))
diff --git a/clang/test/SemaCXX/cxx2b-warn-shadow.cpp 
b/clang/test/SemaCXX/cxx2b-warn-shadow.cpp
new file mode 100644
index 00..0cf47f3848979c
--- /dev/null
+++ b/clang/test/SemaCXX/cxx2b-warn-shadow.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++2b -Wshadow-all %s
+
+namespace GH95707 {
+struct Foo {
+  int a; // expected-note {{previous declaration is here}}
+
+  void f1(this auto &self, int a) { self.a = a; }
+  void f2(int a) { } // expected-warning {{declaration shadows a field of 
'GH95707::Foo'}}
+};
+} // namespace GH95707

>From 849515a74f1c82845b0baa100729aa80bf236f66 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Tue, 5 Nov 2024 15:33:14 +0200
Subject: [PATCH 2/3] update tests/release notes

---
 clang/docs/ReleaseNotes.rst  | 2 +-
 clang/test/SemaCXX/cxx2b-warn-shadow.cpp | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index af8288ee8a8296..5ecde32bb70429 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -464,7 +464,7 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables 
(#GH90073).
 
-- Clang now omits shadowing warnings for parameter names using deducing this 
(#GH95707).
+- Clang now omits shadowing warnings for parameter names in explicit object 
member functions (#GH95707).
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/test/SemaCXX/cxx2b-warn-shadow.cpp 
b/clang/test/SemaCXX/cxx2b-warn-shadow.cpp
index 0cf47f3848979c..19db49a4566fa7 100644
--- a/clang/test/SemaCXX/cxx2b-warn-shadow.cpp
+++ b/clang/test/SemaCXX/cxx2b-warn-shadow.cpp
@@ -6,5 +6,8 @@ struct Foo {
 
   void f1(this auto &self, int a) { self.a = a; }
   void f2(int a) { } // expected-warning {{declaration shadows a field of 
'GH95707::Foo'}}
+  void f3() {
+[&](this auto &self, int x) { }; // expected-warning {{expression result 
unused}}
+  }
 };
 } // namespace GH95707

>From 2a2cb900b090d4bb2f1e66c3e027cd947d8053c4 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Wed, 6 Nov 2024 12:18:00 +0200
Subject: [PATCH 3/3] remove unnesessary warning

---
 clang/test/SemaCXX/cxx2b-warn-shadow.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/SemaCXX/cxx2b-warn-shadow.cpp 
b/clang/test/SemaCXX/cxx2b-warn-shadow.cpp
index 19db49a4566fa7..e6615e969910e2 100644
--- a/clang/test/SemaCXX/cxx2b-warn-shadow.cpp
+++ b/clang/test/SemaCXX/cxx2b-warn-shadow.cpp
@@ -7,7 +7,7 @@ struct Foo {
   void f1(this auto &self, int a) { self.a = a; }
   void f2(int a) { } // expected-warning {{declaration shadows a field of 
'GH95707::Foo'}}
   void f3() {
-[&](this auto &self, int x) { }; // expected-warning {{expression result 
unused}}
+(void)[&](this auto &self, int x) { };
   }
 };
 } // namespace GH95707

___
cfe-commits mailin

[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-19 Thread Oleksandr T. via cfe-commits

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

>From d95d0fdb22ae2ad162f89cb211f313cea6c6474a Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 2 Nov 2024 23:54:35 +0200
Subject: [PATCH] [Clang] enhance error recovery with RecoveryExpr for trailing
 commas in call arguments

---
 clang/lib/Parse/ParseExpr.cpp|  3 +++
 clang/test/AST/ast-dump-recovery.cpp | 17 -
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index 4570a18bc0d5e5..5fccd2ae106015 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -3705,6 +3705,9 @@ bool Parser::ParseExpressionList(SmallVectorImpl 
&Exprs,
 Token Comma = Tok;
 ConsumeToken();
 checkPotentialAngleBracketDelimiter(Comma);
+
+if (Tok.is(tok::r_paren))
+  break;
   }
   if (SawError) {
 // Ensure typos get diagnosed when errors were encountered while parsing 
the
diff --git a/clang/test/AST/ast-dump-recovery.cpp 
b/clang/test/AST/ast-dump-recovery.cpp
index a88dff471d9f04..1876f4ace32a5a 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -9,7 +9,7 @@ int some_func(int *);
 // CHECK-NEXT:`-IntegerLiteral {{.*}} 123
 // DISABLED-NOT: -RecoveryExpr {{.*}} contains-errors
 int invalid_call = some_func(123);
-void test_invalid_call(int s) {
+void test_invalid_call_1(int s) {
   // CHECK:  CallExpr {{.*}} '' contains-errors
   // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} 'some_func'
   // CHECK-NEXT: |-RecoveryExpr {{.*}} 
@@ -32,6 +32,21 @@ void test_invalid_call(int s) {
   int var = some_func(undef1);
 }
 
+int some_func2(int a, int b);
+void test_invalid_call_2() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  some_func2(1, );
+}
+
+void test_invalid_call_3() {
+  // CHECK:   `-RecoveryExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} '' 
lvalue (ADL) = 'some_func2'
+  // CHECK-NEXT: `-IntegerLiteral {{.*}} 'int' 1
+  some_func2(1);
+}
+
 int ambig_func(double);
 int ambig_func(float);
 

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


[clang] [Clang] Fix name lookup for dependent bases (PR #114978)

2024-11-19 Thread Vladislav Belov via cfe-commits

vbe-sc wrote:

> Can you add a release note

I added a release note as you asked

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


[clang-tools-extra] [clangd] Let DefineOutline tweak handle member function templates (PR #112345)

2024-11-19 Thread Nathan Ridge via cfe-commits


@@ -130,23 +129,40 @@ getFunctionSourceAfterReplacements(const FunctionDecl *FD,
 return QualifiedFunc.takeError();
 
   std::string TemplatePrefix;
+  auto AddToTemplatePrefixIfApplicable = [&](const Decl *D, bool append) {
+const TemplateParameterList *Params = D->getDescribedTemplateParams();
+if (!Params)
+  return;
+for (Decl *P : *Params) {
+  if (auto *TTP = dyn_cast(P))
+TTP->removeDefaultArgument();
+  else if (auto *NTTP = dyn_cast(P))
+NTTP->removeDefaultArgument();
+  else if (auto *TTPD = dyn_cast(P))
+TTPD->removeDefaultArgument();
+}
+std::string S;
+llvm::raw_string_ostream Stream(S);
+Params->print(Stream, FD->getASTContext());
+if (!S.empty())
+  *S.rbegin() = '\n'; // Replace space with newline
+if (append)
+  TemplatePrefix.append(S);
+else
+  TemplatePrefix.insert(0, S);
+  };
   if (auto *MD = llvm::dyn_cast(FD)) {
 for (const CXXRecordDecl *Parent = MD->getParent(); Parent;
  Parent =
  llvm::dyn_cast_or_null(Parent->getParent())) 
{
-  if (const TemplateParameterList *Params =
-  Parent->getDescribedTemplateParams()) {
-std::string S;
-llvm::raw_string_ostream Stream(S);
-Params->print(Stream, FD->getASTContext());
-if (!S.empty())
-  *S.rbegin() = '\n'; // Replace space with newline
-TemplatePrefix.insert(0, S);
-  }
+  AddToTemplatePrefixIfApplicable(Parent, false);
 }
   }
 
+  AddToTemplatePrefixIfApplicable(FD, true);

HighCommander4 wrote:

suggestion: remove the `append` parameter, always prepend, and call this before 
the loop over parents?

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


[clang] [Clang][Parser] Make 'T...[N]' within a function parameter a valid pack expansion prior to C++2c (PR #116332)

2024-11-19 Thread via cfe-commits

Sirraide wrote:

> I am not sure we want to keep supporting the old syntax, even in older 
> language modes (notably, it isn't supported by other compilers and is at best 
> missleading),

I think we should just remove it (maybe make it an error that can be downgraded 
to a warning for now and then a hard error in the next release? not sure that’s 
even necessary tho), because, candidly, it just seems categorically useless 
(and every other compiler seems to agree considering that they don’t support it 
to begin with).

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


[clang-tools-extra] 8a6a76b - [clangd] Let DefineOutline tweak handle member function templates (#112345)

2024-11-19 Thread via cfe-commits

Author: Christian Kandeler
Date: 2024-11-19T12:47:15+01:00
New Revision: 8a6a76b1e122536858531a8612cbbe6869803393

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

LOG: [clangd] Let DefineOutline tweak handle member function templates (#112345)

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
index 591a8b245260ea..2a96b305bd7a25 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
@@ -109,14 +109,13 @@ findContextForNS(llvm::StringRef TargetNS, const 
DeclContext *CurContext) {
 // afterwards it can be shared with define-inline code action.
 llvm::Expected
 getFunctionSourceAfterReplacements(const FunctionDecl *FD,
-   const tooling::Replacements &Replacements) {
+   const tooling::Replacements &Replacements,
+   bool TargetFileIsHeader) {
   const auto &SM = FD->getASTContext().getSourceManager();
   auto OrigFuncRange = toHalfOpenFileRange(
   SM, FD->getASTContext().getLangOpts(), FD->getSourceRange());
   if (!OrigFuncRange)
 return error("Couldn't get range for function.");
-  assert(!FD->getDescribedFunctionTemplate() &&
- "Define out-of-line doesn't apply to function templates.");
 
   // Get new begin and end positions for the qualified function definition.
   unsigned FuncBegin = SM.getFileOffset(OrigFuncRange->getBegin());
@@ -129,24 +128,38 @@ getFunctionSourceAfterReplacements(const FunctionDecl *FD,
   if (!QualifiedFunc)
 return QualifiedFunc.takeError();
 
+  auto Source = QualifiedFunc->substr(FuncBegin, FuncEnd - FuncBegin + 1);
   std::string TemplatePrefix;
+  auto AddToTemplatePrefixIfApplicable = [&](const Decl *D) {
+const TemplateParameterList *Params = D->getDescribedTemplateParams();
+if (!Params)
+  return;
+for (Decl *P : *Params) {
+  if (auto *TTP = dyn_cast(P))
+TTP->removeDefaultArgument();
+  else if (auto *NTTP = dyn_cast(P))
+NTTP->removeDefaultArgument();
+  else if (auto *TTPD = dyn_cast(P))
+TTPD->removeDefaultArgument();
+}
+std::string S;
+llvm::raw_string_ostream Stream(S);
+Params->print(Stream, FD->getASTContext());
+if (!S.empty())
+  *S.rbegin() = '\n'; // Replace space with newline
+TemplatePrefix.insert(0, S);
+  };
+  AddToTemplatePrefixIfApplicable(FD);
   if (auto *MD = llvm::dyn_cast(FD)) {
 for (const CXXRecordDecl *Parent = MD->getParent(); Parent;
  Parent =
  llvm::dyn_cast_or_null(Parent->getParent())) 
{
-  if (const TemplateParameterList *Params =
-  Parent->getDescribedTemplateParams()) {
-std::string S;
-llvm::raw_string_ostream Stream(S);
-Params->print(Stream, FD->getASTContext());
-if (!S.empty())
-  *S.rbegin() = '\n'; // Replace space with newline
-TemplatePrefix.insert(0, S);
-  }
+  AddToTemplatePrefixIfApplicable(Parent);
 }
   }
 
-  auto Source = QualifiedFunc->substr(FuncBegin, FuncEnd - FuncBegin + 1);
+  if (TargetFileIsHeader)
+Source.insert(0, "inline ");
   if (!TemplatePrefix.empty())
 Source.insert(0, TemplatePrefix);
   return Source;
@@ -202,7 +215,8 @@ deleteTokensWithKind(const syntax::TokenBuffer &TokBuf, 
tok::TokenKind Kind,
 llvm::Expected
 getFunctionSourceCode(const FunctionDecl *FD, const DeclContext *TargetContext,
   const syntax::TokenBuffer &TokBuf,
-  const HeuristicResolver *Resolver) {
+  const HeuristicResolver *Resolver,
+  bool TargetFileIsHeader) {
   auto &AST = FD->getASTContext();
   auto &SM = AST.getSourceManager();
 
@@ -337,7 +351,8 @@ getFunctionSourceCode(const FunctionDecl *FD, const 
DeclContext *TargetContext,
 
   if (Errors)
 return std::move(Errors);
-  return getFunctionSourceAfterReplacements(FD, DeclarationCleanups);
+  return getFunctionSourceAfterReplacements(FD, DeclarationCleanups,
+TargetFileIsHeader);
 }
 
 struct InsertionPoint {
@@ -419,15 +434,15 @@ class DefineOutline : public Tweak {
 Source->isOutOfLine())
   return false;
 
-// Bail out if this is a function template or specialization, as their
+// Bail out if this is a function template specialization, as their
 // definitions need to be visible in all including translation units.
-if (Source->getDescribedFunctionTempla

[clang] [Clang] skip warnings for constructors marked with the [[noreturn]] attribute (PR #115558)

2024-11-19 Thread Aaron Ballman via cfe-commits


@@ -49,3 +49,15 @@ void check() {
   test_type(g);
   test_type(h); // expected-note {{instantiation}}
 }
+
+namespace GH63009 {
+struct S {
+  [[noreturn]] S() { throw int {}; }
+};
+
+int test_no_return_constructor() { S(); } // ok

AaronBallman wrote:

Can you also add a test case (in a different test file under SemaCXX) for:
```
struct S {
  [[noreturn]] S();
};

int foo();
int func() {
  S s;
  foo(); // Unreachable warning
} // No "does not return a value" warning
```

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


[clang] [flang] [clang][driver] When -fveclib=ArmPL flag is in use, always link against libamath (PR #116432)

2024-11-19 Thread David Truby via cfe-commits


@@ -490,6 +490,16 @@ void tools::AddLinkerInputs(const ToolChain &TC, const 
InputInfoList &Inputs,
 else
   A.renderAsInput(Args, CmdArgs);
   }
+  if (const Arg *A = Args.getLastArg(options::OPT_fveclib)) {
+if (A->getNumValues() == 1) {
+  StringRef V = A->getValue();
+  if (V == "ArmPL") {
+CmdArgs.push_back(Args.MakeArgString("-lamath"));
+CmdArgs.push_back(Args.MakeArgString("-lm"));

DavidTruby wrote:

MinGW here doesn't really mean MinGW (I realise this is quite confusing). It 
more specifically  means "using glibc, ld.bfd and libstdc++". This isn't 
supported on AArch64 at all, and is mostly being phased out on X86 too I 
believe. Only the "new style" mingw-w64 is supported on AArch64 (using libucrt 
and link.exe).

There's no Cygwin on AArch64 either.
I suppose more specifically I should have said that this function will never be 
called on Windows _on Arm_ 🙂

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


[clang] [amdgpu-arch] Replace use of HSA with reading sysfs directly (PR #116651)

2024-11-19 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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)
...
[3741/4107] Linking CXX executable bin/llvm-jitlink-executor
[3742/4107] Linking CXX static library lib/libLLVMPowerPCDisassembler.a
[3743/4107] Linking CXX static library lib/libLLVMPowerPCDesc.a
[3744/4107] Linking CXX static library lib/libLLVMIRReader.a
[3745/4107] Linking CXX executable bin/llvm-stress
[3746/4107] Linking CXX executable bin/llvm-bcanalyzer
[3747/4107] Linking CXX executable bin/llvm-dis
[3748/4107] Linking CXX executable bin/llvm-diff
[3749/4107] Building CXX object 
tools/clang/tools/amdgpu-arch/CMakeFiles/amdgpu-arch.dir/AMDGPUArch.cpp.o
[3750/4107] Building CXX object 
tools/clang/tools/amdgpu-arch/CMakeFiles/amdgpu-arch.dir/AMDGPUArchByKFD.cpp.o
FAILED: 
tools/clang/tools/amdgpu-arch/CMakeFiles/amdgpu-arch.dir/AMDGPUArchByKFD.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm_build0/bin/clang++
 -DGTEST_HAS_RTTI=0 -DLLVM_BUILD_STATIC -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/tools/amdgpu-arch
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/tools/amdgpu-arch
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/tools/amdgpu-arch/CMakeFiles/amdgpu-arch.dir/AMDGPUArchByKFD.cpp.o 
-MF 
tools/clang/tools/amdgpu-arch/CMakeFiles/amdgpu-arch.dir/AMDGPUArchByKFD.cpp.o.d
 -o 
tools/clang/tools/amdgpu-arch/CMakeFiles/amdgpu-arch.dir/AMDGPUArchByKFD.cpp.o 
-c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/tools/amdgpu-arch/AMDGPUArchByKFD.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/tools/amdgpu-arch/AMDGPUArchByKFD.cpp:58:9:
 error: ignoring return value of function declared with 'nodiscard' attribute 
[-Werror,-Wunused-result]
   58 | Line.drop_while([](char C) { return std::isspace(C); });
  | ^~~ ~~
1 error generated.
[3751/4107] Building CXX object 
lib/MC/MCParser/CMakeFiles/LLVMMCParser.dir/AsmParser.cpp.o
ninja: build stopped: subcommand failed.

How to reproduce locally: 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild

@@@STEP_FAILURE@@@
@@@BUILD_STEP test compiler-rt debug@@@
ninja: Entering directory `build_default'
[1/239] Linking CXX static library lib/libLLVMMCParser.a
[2/239] Linking CXX static library lib/libLLVMPowerPCAsmParser.a
[3/239] Linking CXX static library lib/libLLVMObject.a
[4/239] Linking CXX static library lib/libLLVMLibDriver.a
[5/239] Linking CXX static library lib/libLLVMDlltoolDriver.a
[6/239] Linking CXX static library lib/libLLVMObjCopy.a
[7/239] Linking CXX static library lib/libLLVMDebugInfoDWARF.a
[8/239] Linking CXX static library lib/libLLVMJITLink.a
[9/239] Linking CXX static library lib/libLLVMRuntimeDyld.a
[10/239] Linking CXX static library lib/libLLVMObjectYAML.a
[11/239] Linking CXX static library lib/libLLVMXRay.a
[12/239] Linking CXX static library lib/libLLVMDebugInfoPDB.a
[13/239] Linking CXX static library lib/libLLVMTextAPIBinaryReader.a
[14/239] Linking CXX static library lib/libLLVMSymbolize.a
[15/239] Linking 

[clang] [Clang] enhance error recovery with RecoveryExpr for trailing commas in call arguments (PR #114684)

2024-11-19 Thread Haojian Wu via cfe-commits

https://github.com/hokein commented:

Thanks, this is nice.

Can you also add a release note? 

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-19 Thread Utkarsh Saxena via cfe-commits




usx95 wrote:

The contents are moved from `clang/test/Sema/warn-lifetime-analysis-nocfg.cpp`. 
AFAIK, I don't think git supports branching from a file.

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


[clang] Clarify use of contractions in diagnostic messages (PR #116803)

2024-11-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Aaron Ballman (AaronBallman)


Changes

This dissuades contributors from using contractions when writing diagnostic 
wording for Clang. Contractions should be avoided because of the potential for 
visual confusion with single quoting syntactic constructs and because they can 
be harder to understand for non-native English speakers.

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


1 Files Affected:

- (modified) clang/docs/InternalsManual.rst (+4) 


``diff
diff --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index f189cb4e6a2ac3..39d389b816f129 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -160,6 +160,10 @@ wording a diagnostic.
   named in a diagnostic message. e.g., prefer wording like ``'this' pointer
   cannot be null in well-defined C++ code`` over wording like ``this pointer
   cannot be null in well-defined C++ code``.
+* Prefer diagnostic wording without contractions whenever possible. The single
+  quote in a contraction can be visually distracting due to its use with
+  syntactic constructs and contractions can be harder to understand for non-
+  native English speakers.
 
 The Format String
 ^

``




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


[clang] Clarify use of contractions in diagnostic messages (PR #116803)

2024-11-19 Thread Aaron Ballman via cfe-commits

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

This dissuades contributors from using contractions when writing diagnostic 
wording for Clang. Contractions should be avoided because of the potential for 
visual confusion with single quoting syntactic constructs and because they can 
be harder to understand for non-native English speakers.

>From 4a2673ab46fb77a554fd66d39c7faad2cce030d2 Mon Sep 17 00:00:00 2001
From: Aaron Ballman 
Date: Tue, 19 Nov 2024 08:49:22 -0500
Subject: [PATCH] Clarify use of contractions in diagnostic messages

This dissuades contributors from using contractions when writing
diagnostic wording for Clang. Contractions should be avoided because of
the potential for visual confusion with single quoting syntactic
constructs and because they can be harder to understand for non-native
English speakers.
---
 clang/docs/InternalsManual.rst | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index f189cb4e6a2ac3..39d389b816f129 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -160,6 +160,10 @@ wording a diagnostic.
   named in a diagnostic message. e.g., prefer wording like ``'this' pointer
   cannot be null in well-defined C++ code`` over wording like ``this pointer
   cannot be null in well-defined C++ code``.
+* Prefer diagnostic wording without contractions whenever possible. The single
+  quote in a contraction can be visually distracting due to its use with
+  syntactic constructs and contractions can be harder to understand for non-
+  native English speakers.
 
 The Format String
 ^

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-19 Thread Haojian Wu via cfe-commits


@@ -1412,17 +1438,34 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
 return false;
   };
 
+  bool HasReferenceBinding = Init->isGLValue();
   llvm::SmallVector Path;
-  if (LK == LK_Assignment &&
-  shouldRunGSLAssignmentAnalysis(SemaRef, *AEntity)) {
-Path.push_back(
-{isAssignmentOperatorLifetimeBound(AEntity->AssignmentOperator)
- ? IndirectLocalPathEntry::LifetimeBoundCall
- : IndirectLocalPathEntry::GslPointerAssignment,
- Init});
+  switch (LK) {
+  case LK_Assignment: {
+if (shouldRunGSLAssignmentAnalysis(SemaRef, *AEntity))
+  Path.push_back(
+  {isAssignmentOperatorLifetimeBound(AEntity->AssignmentOperator)
+   ? IndirectLocalPathEntry::LifetimeBoundCall
+   : IndirectLocalPathEntry::GslPointerAssignment,
+   Init});
+break;
+  }
+  case LK_LifetimeCapture: {
+Path.push_back({IndirectLocalPathEntry::LifetimeCapture, Init});
+if (isRecordWithAttr(Init->getType()))
+  HasReferenceBinding = false;
+// Skip the top MTE if it is a temporary object of the pointer-like type
+// itself.
+if (auto *MTE = dyn_cast(Init);
+MTE && isPointerLikeType(Init->getType()))
+  Init = MTE->getSubExpr();

hokein wrote:

I know that this code originated from my patch that added assignment support 
for "container." That patch has some issues: although it passed the 
unit tests, it failed to diagnose cases in real STL headers.

I'm not sure I fully understand the implementation here (my initial idea was to 
leverage the existing code paths for `lifetimebound` and `gsl::Pointer`, so the 
need for `IndirectLocalPathEntry::LifetimeCapture` isn’t clear). I experimented 
this patch, and made some tweaks to simplify the logic, and here’s the diff I 
came up with:

```cpp
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -1212,9 +1212,9 @@ checkExprLifetimeImpl(Sema &SemaRef, const 
InitializedEntity *InitEntity,
   // and the capturing entity does too, so don't warn.
   if (!MTE)
 return false;
-  assert(shouldLifetimeExtendThroughPath(Path) ==
- PathLifetimeKind::NoExtend &&
- "No lifetime extension in function calls");
+  // assert(shouldLifetimeExtendThroughPath(Path) ==
+  //PathLifetimeKind::NoExtend &&
+  //"No lifetime extension in function calls");
   if (CapEntity->Entity)
 SemaRef.Diag(DiagLoc, diag::warn_dangling_reference_captured)
 << CapEntity->Entity << DiagRange;
@@ -1451,14 +1451,8 @@ checkExprLifetimeImpl(Sema &SemaRef, const 
InitializedEntity *InitEntity,
 break;
   }
   case LK_LifetimeCapture: {
-Path.push_back({IndirectLocalPathEntry::LifetimeCapture, Init});
-if (isRecordWithAttr(Init->getType()))
-  HasReferenceBinding = false;
-// Skip the top MTE if it is a temporary object of the pointer-like type
-// itself.
-if (auto *MTE = dyn_cast(Init);
-MTE && isPointerLikeType(Init->getType()))
-  Init = MTE->getSubExpr();
+if (isPointerLikeType(Init->getType()))
+  Path.push_back({IndirectLocalPathEntry::GslPointerInit, Init});
 break;
   }
   default:
```

The tests passed, and it also fixes the known false positives:

```
error: 'expected-warning' diagnostics expected but not seen: 
  File 
/workspace/llvm-project/clang/test/Sema/warn-lifetime-analysis-capture-by.cpp 
Line 313: captured
  File 
/workspace/llvm-project/clang/test/Sema/warn-lifetime-analysis-capture-by.cpp 
Line 314: captured
  File 
/workspace/llvm-project/clang/test/Sema/warn-lifetime-analysis-capture-by.cpp 
Line 318: captured
```

Would you mind taking it further?

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


[clang] [Clang] skip warnings for constructors marked with the [[noreturn]] attribute (PR #115558)

2024-11-19 Thread Aaron Ballman via cfe-commits


@@ -49,3 +49,15 @@ void check() {
   test_type(g);
   test_type(h); // expected-note {{instantiation}}
 }
+
+namespace GH63009 {
+struct S {
+  [[noreturn]] S() { throw int {}; }
+};
+
+int test_no_return_constructor() { S(); } // ok

AaronBallman wrote:

Also, since we're here, can you add a test to ensure that destructors also work 
as expected? That can be done in a separate PR if you'd like.

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-19 Thread Helmut Januschka via cfe-commits

hjanuschka wrote:

@EugeneZelenko your comments have been resolved, but i am unable to mark them 
due to force push

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


[clang] [Clang] skip warnings for constructors marked with the [[noreturn]] attribute (PR #115558)

2024-11-19 Thread Oleksandr T. via cfe-commits

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

>From f63263a1aa4873a63918649ea92352eb5cfe66eb Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sat, 9 Nov 2024 00:41:13 +0200
Subject: [PATCH] [Clang] skip warnings for constructors marked with the
 [[noreturn]] attribute

---
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/lib/Analysis/CFG.cpp| 15 ++-
 .../CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp | 12 
 3 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c3424e0e6f34c9..11d0e35d12a786 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -527,6 +527,8 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses ``[[deprecated]]`` attribute usage on local variables 
(#GH90073).
 
+- Clang now omits warnings for constructors marked with the ``[[noreturn]]`` 
attribute (#GH63009).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index f678ac6f2ff36a..4d83f04c23060a 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -4889,16 +4889,21 @@ CFGBlock 
*CFGBuilder::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E,
   return Visit(E->getSubExpr(), asc);
 }
 
-CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *C,
+CFGBlock *CFGBuilder::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E,
   AddStmtChoice asc) {
   // If the constructor takes objects as arguments by value, we need to 
properly
   // construct these objects. Construction contexts we find here aren't for the
   // constructor C, they're for its arguments only.
-  findConstructionContextsForArguments(C);
+  findConstructionContextsForArguments(E);
 
-  autoCreateBlock();
-  appendConstructor(Block, C);
-  return VisitChildren(C);
+  CXXConstructorDecl *C = E->getConstructor();
+  if (C && C->isNoReturn())
+Block = createNoReturnBlock();
+  else
+autoCreateBlock();
+
+  appendConstructor(Block, E);
+  return VisitChildren(E);
 }
 
 CFGBlock *CFGBuilder::VisitImplicitCastExpr(ImplicitCastExpr *E,
diff --git a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp 
b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
index 56920ea8e8cf20..a96224dd03e360 100644
--- a/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.noreturn/p1.cpp
@@ -49,3 +49,15 @@ void check() {
   test_type(g);
   test_type(h); // expected-note {{instantiation}}
 }
+
+namespace GH63009 {
+struct S {
+  [[noreturn]] S() { throw int {}; }
+};
+
+int test_no_return_constructor() { S(); } // ok
+
+int main() {
+  test_no_return_constructor();
+}
+}

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


[clang] [flang] [flang] Add UNSIGNED (PR #113504)

2024-11-19 Thread via cfe-commits


@@ -213,6 +213,22 @@ def fir_IntegerType : FIR_Type<"Integer", "int"> {
   }];
 }
 
+def fir_UnsignedType : FIR_Type<"Unsigned", "unsigned"> {

jeanPerier wrote:

Removing both the type and predicate, I got no failures (I had to help make by 
deleting some of the tablegen generated `.cpp.inc` that still referred to the 
type though, but fresh build should not hit that issue). I am however OK with 
adding this type for consistency with fir_IntegerType.

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-19 Thread Boaz Brickner via cfe-commits




bricknerb wrote:

I'm not familiar either with such a feature, but it seems it's possible to 
achieve, though not in a super straight forward way: For example: 
https://stackoverflow.com/questions/16937359/git-copy-file-preserving-history

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


[clang] [compiler-rt] [llvm] [SystemZ] Add support for half (fp16) (PR #109164)

2024-11-19 Thread Ulrich Weigand via cfe-commits


@@ -6285,6 +6465,16 @@ SDValue SystemZTargetLowering::LowerOperation(SDValue Op,
 return lowerAddrSpaceCast(Op, DAG);
   case ISD::ROTL:
 return lowerShift(Op, DAG, SystemZISD::VROTL_BY_SCALAR);
+  case ISD::FP_EXTEND:
+//case ISD::STRICT_FP_EXTEND:

uweigand wrote:

We should support the strict variants here as well.

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


[clang] [clang] Fix the post-filtering heuristic for GSLPointer. (PR #114044)

2024-11-19 Thread Haojian Wu via cfe-commits

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


[clang] [HLSL] Fix placement of `const` for resource operator[] (PR #116698)

2024-11-19 Thread Justin Bogner via cfe-commits

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


[clang] [clang] Implement -fstrict-bool (PR #116732)

2024-11-19 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

If we're going to document that values other than 0 and 1 are "allowed", I 
think the documentation needs to explicitly state how values other than 0 and 1 
are handled.

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


[clang] [HLSL] Add ByteAddressBuffer definition to HLSLExternalSemaSource #113477 (PR #116699)

2024-11-19 Thread via cfe-commits

https://github.com/joaosaffran updated 
https://github.com/llvm/llvm-project/pull/116699

>From c3b3c87db9b6a47bea9ed69575d4a9a728d1b154 Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Sat, 9 Nov 2024 01:34:16 +
Subject: [PATCH 1/6] adding definition

---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 10 +
 .../test/AST/HLSL/ByteAddressBuffer-AST.hlsl  | 41 +++
 2 files changed, 51 insertions(+)
 create mode 100644 clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl

diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index 6eb24c578f602c..d4d800a311e52d 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -531,6 +531,16 @@ void 
HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
 .addArraySubscriptOperators()
 .completeDefinition();
   });
+
+  Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ByteAddressBuffer")
+ .Record;
+  onCompletion(Decl, [this](CXXRecordDecl *Decl) {
+setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, 
ResourceKind::RawBuffer,
+/*IsROV=*/true,
+/*RawBuffer=*/true)
+.addArraySubscriptOperators()
+.completeDefinition();
+  });
 }
 
 void HLSLExternalSemaSource::onCompletion(CXXRecordDecl *Record,
diff --git a/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl 
b/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl
new file mode 100644
index 00..013974369d033a
--- /dev/null
+++ b/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY %s | FileCheck -check-prefix=EMPTY %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump %s 
| FileCheck %s
+
+
+// EMPTY: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit  class ByteAddressBuffer
+// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+
+// There should be no more occurrences of ByteAddressBuffer
+// EMPTY-NOT: {{[^[:alnum:]]}}ByteAddressBuffer
+
+#ifndef EMPTY
+
+ByteAddressBuffer Buffer;
+
+#endif
+
+// CHECK: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit referenced  class ByteAddressBuffer 
definition
+
+
+// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  
implicit h '__hlsl_resource_t
+// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
+// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
+// CHECK-SAME{LITERAL}: [[hlsl::contained_type(char8_t)]]
+// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
RawBuffer
+
+// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'char8_t &const (unsigned int) const'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  
Idx 'unsigned int'
+// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 'char8_t' lvalue 
.e 0x{{[0-9A-Fa-f]+}}
+// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <> 'const 
hlsl::ByteAddressBuffer' lvalue implicit this
+// CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
always_inline
+
+// CHECK-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  operator[] 'char8_t &(unsigned int)'
+// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  
Idx 'unsigned int'
+// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <>
+// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <> 'char8_t' lvalue 
.e 0x{{[0-9A-Fa-f]+}}
+// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <> 
'hlsl::ByteAddressBuffer' lvalue implicit this
+// CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
always_inline

>From 9d773dbf0d94fbfcd324c0803bb0b9b34f08564b Mon Sep 17 00:00:00 2001
From: Joao Saffran 
Date: Mon, 18 Nov 2024 21:11:47 +
Subject: [PATCH 2/6] adding tests

---
 clang/test/AST/HLSL/ByteAddressBuffer-AST.ll| 13 +
 .../CodeGenHLSL/builtins/ByteAddressBuffer.hlsl |  8 
 2 files changed, 21 insertions(+)
 create mode 100644 clang/test/AST/HLSL/ByteAddressBuffer-AST.ll
 create mode 100644 clang/test/CodeGenHLSL/builtins/ByteAddressBuffer.hlsl

diff --git a/clang/test/AST/HLSL/ByteAddressBuffer-AST.ll 
b/clang/test/AST/HLSL/ByteAddressBuffer-AST.ll
new file mode 100644
index 00..7df06100d69fe5
--- /dev/null
+++ b/clang/test/AST/HLSL/ByteAddressBuffer-AST.ll
@@ -0,0 +1,13 @@
+; ModuleID = 
'/workspace/llvm-project/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl'
+source_filename = 
"/workspace/llvm-project/clang/test/AST/HLSL/ByteAddressBuffer-AST.hlsl"
+target datalayout = 
"e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
+target triple = "dxilv1.0-pc-shadermodel6.0-library"
+
+!llvm.module.flags = !{!0, !1}
+!dx.valver = !{!2}
+!llvm.ident = !{!3}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 4, !"dx.disable_optimizations", i32 1}
+!2 = !{i32 1, i32 8}
+!3 = !{!"clang versi

[clang] [analyzer] Avoid creating LazyCompoundVal when possible (PR #116840)

2024-11-19 Thread Balazs Benics via cfe-commits

steakhal wrote:

Btw expect more patches about fixing LCVs and overall PostInitializer events 
and bindings.
Basically, how we model the member initializers and copies. Stay tuned for 
those, but before that this one is a preparation patch, so I'm excited to see 
your comments.

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


[clang] 2186a00 - [HLSL] Fix placement of `const` for resource operator[] (#116698)

2024-11-19 Thread via cfe-commits

Author: Justin Bogner
Date: 2024-11-19T10:33:54-08:00
New Revision: 2186a008c98e8bb6738fe9120441d6bd15c272f3

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

LOG: [HLSL] Fix placement of `const` for resource operator[] (#116698)

We had an incorrect AST here - We want `const T &`, not `T &const`.

Added: 


Modified: 
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
clang/test/AST/HLSL/RWBuffer-AST.hlsl
clang/test/AST/HLSL/RWStructuredBuffer-AST.hlsl
clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
clang/test/AST/HLSL/StructuredBuffer-AST.hlsl

Removed: 




diff  --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index 9b1885374921a6..a14e7d50a6043f 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -212,11 +212,11 @@ struct BuiltinTypeDeclBuilder {
 
 // Subscript operators return references to elements, const makes the
 // reference and method const so that the underlying data is not mutable.
-ReturnTy = AST.getLValueReferenceType(ReturnTy);
 if (IsConst) {
   ExtInfo.TypeQuals.addConst();
   ReturnTy.addConst();
 }
+ReturnTy = AST.getLValueReferenceType(ReturnTy);
 
 QualType MethodTy =
 AST.getFunctionType(ReturnTy, {AST.UnsignedIntTy}, ExtInfo);

diff  --git a/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl 
b/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
index e0199d0371fb5d..8c951e98292114 100644
--- a/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
@@ -36,7 +36,7 @@ AppendStructuredBuffer Buffer;
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
 // CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
RawBuffer
 
-// CHECK-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'element_type &const (unsigned int) const'
+// CHECK-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'const element_type &(unsigned int) const'
 // CHECK-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'element_type &(unsigned int)'
 
 // CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <> 
 class AppendStructuredBuffer definition

diff  --git a/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl 
b/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
index 32cd9c02af1ab0..86e3d387883dcc 100644
--- a/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
@@ -36,7 +36,7 @@ ConsumeStructuredBuffer Buffer;
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
 // CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
RawBuffer
 
-// CHECK-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'element_type &const (unsigned int) const'
+// CHECK-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'const element_type &(unsigned int) const'
 // CHECK-NOT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'element_type &(unsigned int)'
 
 // CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <> 
 class ConsumeStructuredBuffer definition

diff  --git a/clang/test/AST/HLSL/RWBuffer-AST.hlsl 
b/clang/test/AST/HLSL/RWBuffer-AST.hlsl
index 769e4b5ff8aadc..f2eba75481fd55 100644
--- a/clang/test/AST/HLSL/RWBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/RWBuffer-AST.hlsl
@@ -34,7 +34,7 @@ RWBuffer Buffer;
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
 // CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
TypedBuffer
 
-// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'element_type &const (unsigned int) const'
+// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'const element_type &(unsigned int) const'
 // CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  
Idx 'unsigned int'
 // CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <>
 // CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <>

diff  --git a/clang/test/AST/HLSL/RWStructuredBuffer-AST.hlsl 
b/clang/test/AST/HLSL/RWStructuredBuffer-AST.hlsl
index 4e0f71bc0747e5..cc10b41b7c2b0d 100644
--- a/clang/test/AST/HLSL/RWStructuredBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/RWStructuredBuffer-AST.hlsl
@@ -36,7 +36,7 @@ RWStructuredBuffer Buffer;
 // CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
 // CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <> Implicit 
RawBuffer
 
-// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'element_type &const (unsigned int) const'
+// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <>  
operator[] 'const element_type &(unsigned int) const'
 // CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <>  
Idx 'unsigned int'
 // CHECK-NEXT: Comp

[clang] [ObjC] Name lookup in methods shouldn't allow shadowing types (PR #116683)

2024-11-19 Thread Akira Hatanaka via cfe-commits

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


[clang] [HLSL] Add implicit resource element type concepts to AST (PR #116413)

2024-11-19 Thread Chris B via cfe-commits


@@ -323,19 +325,114 @@ struct TemplateParameterListBuilder {
 return *this;
   }
 
-  BuiltinTypeDeclBuilder &finalizeTemplateArgs() {
+  // The concept specialization expression (CSE) constructed in
+  // constructConceptSpecializationExpr is constructed so that it
+  // matches the CSE that is constructed when parsing the below C++ code:
+  //
+  // template
+  // concept is_typed_resource_element_compatible = sizeof(T) <= 16;

llvm-beanz wrote:

Sure, it needs to be a vector or a scalar 
(https://github.com/llvm/wg-hlsl/blob/main/proposals/0011-resource-element-type-validation.md?plain=1#L31).

I guess I maybe don't understand why we're breaking this into so many separate 
changes where the intermediate steps aren't fully testable.

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


[clang] [clang] Add support for `__declspec(no_init_all)` (PR #116847)

2024-11-19 Thread Daniel Paoliello via cfe-commits

dpaoliello wrote:

> If we're going to treat `/d1initall` as an alias for 
> `-ftrivial-auto-var-init`, can we just treat `__declspec(no_init_all)` as an 
> alias for `__attribute__((uninitialized))`?

`uninitialized` currently only applied to local variable declarations, whereas 
`__declspec(no_init_all)` is for types and functions.

I think allowing `uninitialized` to be applied to types and functions would be 
confusing:
* Does `uninitialized` on a non-trivial type suppress the normal automatic 
initialization? If not, then does this need a warning/error?
* How is a user supposed to interpret `uninitialized` on a function? There's no 
obvious connection that it's referring to the local variables in the function, 
let alone those that are not automatically initialized.

This is why I wanted to avoid adding a Clang spelling: it feels like it would 
need a bunch of naming discussions and design work.



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


[clang] [llvm] [aarch64][clang][llvm] Allow AArch64 TLB maintenance instructions to be enabled via -march (PR #116707)

2024-11-19 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

In assembly, you can override the current architecture with a `.arch` directive.

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


[clang] [clang][UBSan] Make sure that the implicit-conversion group is compatible with minimal runtime (PR #114865)

2024-11-19 Thread Axel Lundberg via cfe-commits

Zonotora wrote:

@vitalybuka This is connected to 
https://github.com/llvm/llvm-project/pull/75481 that was merged a couple of 
months ago..

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


[clang] [llvm] [HLSL] Implement WaveActiveAnyTrue intrinsic (PR #115902)

2024-11-19 Thread Greg Roth via cfe-commits

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

Thanks for the fixups!

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


[clang] [llvm] [HLSL] Implement WaveActiveAnyTrue intrinsic (PR #115902)

2024-11-19 Thread Farzon Lotfi via cfe-commits


@@ -2206,6 +2206,15 @@ float4 trunc(float4);
 // Wave* builtins
 
//===--===//
 
+/// \brief Returns true if the expression is true in any active lane in the
+/// current wave.
+///
+/// \param Val The boolean expression to evaluate.
+/// \return True if the expression is true in any lane.
+_HLSL_AVAILABILITY(shadermodel, 6.0)

farzonl wrote:

So this is correct.  And I can see the other wave intrinsics do this, but our 
default availability is 6.0. Is the thinking to do this that do the bookkeeping 
now so that it makes it easier to support pre 6.0 shader models i.e. FXC 
shaders at some point?

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


[clang] [llvm] [mlir] [LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (PR #116856)

2024-11-19 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Paul Walker (paulwalker-arm)


Changes

This brings the printing of scalable vector constant splats inline with their 
fixed length counterparts.

---

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


145 Files Affected:

- (modified) clang/test/CodeGen/AArch64/sve-vector-bitwise-ops.c (+18-18) 
- (modified) clang/test/CodeGenCXX/aarch64-sve-vector-conditional-op.cpp (+4-4) 
- (modified) llvm/lib/IR/AsmWriter.cpp (+18) 
- (modified) llvm/test/Assembler/constant-splat.ll (+2-2) 
- (modified) llvm/test/Bitcode/vscale-shuffle.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/replace-with-veclib-armpl.ll (+35-35) 
- (modified) llvm/test/CodeGen/AArch64/replace-with-veclib-sleef-scalable.ll 
(+34-34) 
- (modified) llvm/test/CodeGen/RISCV/rvv/strided-load-store.ll (+24-24) 
- (modified) 
llvm/test/Instrumentation/AddressSanitizer/asan-masked-load-store.ll (+2-2) 
- (modified) llvm/test/Transforms/AggressiveInstCombine/vector-or-load.ll 
(+1-1) 
- (modified) llvm/test/Transforms/Attributor/nofpclass.ll (+1-1) 
- (modified) llvm/test/Transforms/ConstantHoisting/AArch64/large-immediate.ll 
(+7-13) 
- (modified) llvm/test/Transforms/ConstraintElimination/geps-ptrvector.ll 
(+1-1) 
- (modified) llvm/test/Transforms/CorrelatedValuePropagation/vectors.ll (+1-1) 
- (modified) 
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-abs-srshl.ll (+13-13) 
- (modified) 
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-fmul-idempotency.ll 
(+32-21) 
- (modified) 
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-fmul_u-idempotency.ll 
(+32-21) 
- (modified) llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-insr.ll 
(+2-2) 
- (modified) 
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-mul-idempotency.ll 
(+32-21) 
- (modified) 
llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-mul_u-idempotency.ll 
(+32-21) 
- (modified) llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-sdiv.ll 
(+3-3) 
- (modified) llvm/test/Transforms/InstCombine/add.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/div.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/exp2-to-ldexp.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/fdiv.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/fmul.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/fneg.ll (+3-3) 
- (modified) llvm/test/Transforms/InstCombine/getelementptr.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/icmp-vec.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/known-bits.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/load-store-forward.ll (+10-10) 
- (modified) llvm/test/Transforms/InstCombine/pow-to-ldexp.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/pr83931.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/scalable-const-fp-splat.ll (+6-3) 
- (modified) llvm/test/Transforms/InstCombine/scalable-select.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/select-masked_gather.ll (+4-4) 
- (modified) llvm/test/Transforms/InstCombine/select.ll (+5-5) 
- (modified) llvm/test/Transforms/InstCombine/shift.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/sub.ll (+2-2) 
- (modified) llvm/test/Transforms/InstCombine/udiv-simplify.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/vec_shuffle-inseltpoison.ll 
(+1-1) 
- (modified) llvm/test/Transforms/InstCombine/vec_shuffle.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/vscale_cmp.ll (+1-1) 
- (modified) llvm/test/Transforms/InstCombine/zext-ctlz-trunc-to-ctlz-add.ll 
(+2-2) 
- (modified) 
llvm/test/Transforms/InstSimplify/ConstProp/extractelement-vscale.ll (+15-9) 
- (modified) llvm/test/Transforms/InstSimplify/ConstProp/vscale-inseltpoison.ll 
(+6-6) 
- (modified) 
llvm/test/Transforms/InstSimplify/ConstProp/vscale-shufflevector-inseltpoison.ll
 (+11-8) 
- (modified) 
llvm/test/Transforms/InstSimplify/ConstProp/vscale-shufflevector.ll (+11-8) 
- (modified) llvm/test/Transforms/InstSimplify/ConstProp/vscale.ll (+6-6) 
- (modified) llvm/test/Transforms/InstSimplify/cmp-vec-fast-path.ll (+26-26) 
- (modified) llvm/test/Transforms/InstSimplify/fp-nan.ll (+10-10) 
- (modified) llvm/test/Transforms/InstSimplify/gep.ll (+1-1) 
- (modified) llvm/test/Transforms/InstSimplify/vscale-inseltpoison.ll (+3-3) 
- (modified) llvm/test/Transforms/InstSimplify/vscale.ll (+3-3) 
- (modified) 
llvm/test/Transforms/InterleavedAccess/AArch64/scalable-deinterleave-intrinsics.ll
 (+22-22) 
- (modified) 
llvm/test/Transforms/InterleavedAccess/AArch64/sve-deinterleave4.ll (+7-7) 
- (modified) llvm/test/Transforms/InterleavedAccess/AArch64/sve-interleave4.ll 
(+5-5) 
- (modified) 
llvm/test/Transforms/InterleavedAccess/AArch64/sve-interleaved-accesses.ll 
(+2-2) 
- (modified) llvm/test/Transforms/LoopIdiom/RISCV/byte-compare-index.ll 
(+56-56) 
- (modified) llvm/test/Transforms/LoopVectorize/AArch64/clamped-trip-count.

  1   2   3   4   5   >