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

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

https://github.com/danix800 updated 
https://github.com/llvm/llvm-project/pull/115579

>From 19b47c6ad25453c6be74bfd4cbdb7bc7eeed401c Mon Sep 17 00:00:00 2001
From: dingfei 
Date: Sat, 9 Nov 2024 10:28:59 +0800
Subject: [PATCH 1/4] [StaticAnalyzer] early return if sym is concrete on
 assuming

This could deduce some complex syms derived from simple ones whose
values could be constrainted to be concrete during execution, thus
reducing some overconstrainted states.

This commit also fix 'unix.StdCLibraryFunctions' crash due to these
overconstrainted states being added to the graph, which is marked as
sink node (PosteriorlyOverconstrained). The 'assume' API is used in
non-dual style so the checker should protectively test whether these
newly added nodes are actually impossible.
---
 .../Checkers/StdLibraryFunctionsChecker.cpp   |  2 ++
 .../StaticAnalyzer/Core/ConstraintManager.cpp |  2 +-
 .../Core/RangedConstraintManager.cpp  |  9 -
 .../solver-sym-simplification-on-assumption.c | 31 +
 ...ions-bufsize-nocrash-with-correct-solver.c | 33 +++
 ...simplification-fixpoint-two-iterations.cpp |  6 ++--
 6 files changed, 78 insertions(+), 5 deletions(-)
 create mode 100644 
clang/test/Analysis/solver-sym-simplification-on-assumption.c
 create mode 100644 
clang/test/Analysis/std-c-library-functions-bufsize-nocrash-with-correct-solver.c

diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 4f30b2a0e7e7da..5faaf9cf274531 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1354,6 +1354,8 @@ void StdLibraryFunctionsChecker::checkPreCall(const 
CallEvent &Call,
 if (BR.isInteresting(ArgSVal))
   OS << Msg;
   }));
+  if (NewNode->isSink())
+break;
 }
   }
 }
diff --git a/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp
index c0b3f346b654df..2b77167fab86f2 100644
--- a/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp
@@ -74,7 +74,7 @@ ConstraintManager::assumeDualImpl(ProgramStateRef &State,
   // it might happen that a Checker uncoditionally uses one of them if the
   // other is a nullptr. This may also happen with the non-dual and
   // adjacent `assume(true)` and `assume(false)` calls. By implementing
-  // assume in therms of assumeDual, we can keep our API contract there as
+  // assume in terms of assumeDual, we can keep our API contract there as
   // well.
   return ProgramStatePair(StInfeasible, StInfeasible);
 }
diff --git a/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
index 4bbe933be2129e..cc2280faa6f730 100644
--- a/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
@@ -23,7 +23,14 @@ RangedConstraintManager::~RangedConstraintManager() {}
 ProgramStateRef RangedConstraintManager::assumeSym(ProgramStateRef State,
SymbolRef Sym,
bool Assumption) {
-  Sym = simplify(State, Sym);
+  SVal SimplifiedVal = simplifyToSVal(State, Sym);
+  if (SimplifiedVal.isConstant()) {
+bool Feasible = SimplifiedVal.isZeroConstant() ? !Assumption : Assumption;
+return Feasible ? State : nullptr;
+  }
+
+  if (SymbolRef SimplifiedSym = SimplifiedVal.getAsSymbol())
+Sym = SimplifiedSym;
 
   // Handle SymbolData.
   if (isa(Sym))
diff --git a/clang/test/Analysis/solver-sym-simplification-on-assumption.c 
b/clang/test/Analysis/solver-sym-simplification-on-assumption.c
new file mode 100644
index 00..941c584c598c52
--- /dev/null
+++ b/clang/test/Analysis/solver-sym-simplification-on-assumption.c
@@ -0,0 +1,31 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -verify
+
+void clang_analyzer_eval(int);
+
+void test_derived_sym_simplification_on_assume(int s0, int s1) {
+  int elem = s0 + s1 + 1;
+  if (elem-- == 0) // elem = s0 + s1
+return;
+
+  if (elem-- == 0) // elem = s0 + s1 - 1
+return;
+
+  if (s0 < 1) // s0: [1, 2147483647]
+return;
+  if (s1 < 1) // s0: [1, 2147483647]
+return;
+
+  if (elem-- == 0) // elem = s0 + s1 - 2
+return;
+
+  if (s0 > 1) // s0: [-2147483648, 0] U [1, 2147483647] => s0 = 0
+return;
+
+  if (s1 > 1) // s1: [-2147483648, 0] U [1, 2147483647] => s1 = 0
+return;
+
+  // elem = s0 + s1 - 2 should be 0
+  clang_analyzer_eval(elem); // expected-warning{{FALSE}}
+}
diff --git 
a/clang/test/Analysis/std-c-library-functions-bufsize-nocrash-with-correct-solver.c
 
b/clang/test/Analysis/std-c-library-functions-bufsize-nocrash-with-corre

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

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


@@ -0,0 +1,37 @@
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -verify

danix800 wrote:

Thanks for reminding of this! Fixed!

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] 44b33f5 - Filter test based on backend support. (#116244)

2024-11-14 Thread via cfe-commits

Author: Daniel Kiss
Date: 2024-11-14T17:34:00+01:00
New Revision: 44b33f5d3b7ec1f29235acee34938d52bb987619

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

LOG: Filter test based on backend support. (#116244)

ifunc support for Windows on AArch64 needs AArch64 support in the
backend so restrict the test to it's availability.

Added: 


Modified: 
clang/test/CodeGen/ifunc-win.c

Removed: 




diff  --git a/clang/test/CodeGen/ifunc-win.c b/clang/test/CodeGen/ifunc-win.c
index 7c9d6f6516c70f..deda51757e43be 100644
--- a/clang/test/CodeGen/ifunc-win.c
+++ b/clang/test/CodeGen/ifunc-win.c
@@ -3,6 +3,8 @@
 // RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=thread -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
 // RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=address -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
 
+// REQUIRES: aarch64-registered-target
+
 int foo(int) __attribute__ ((ifunc("foo_ifunc")));
 
 static int f1(int i) {



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


[clang] Filter test based on backend support. (PR #116244)

2024-11-14 Thread Daniel Kiss via cfe-commits

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


[clang] Filter test based on backend support. (PR #116244)

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

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

LGTM, it would be good to land this ASAP so the bots get back to green.

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


[clang] [llvm] [AArch64][SVE] Change the immediate argument in svextq (PR #115340)

2024-11-14 Thread via cfe-commits

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


[clang] [llvm] [AArch64][SVE] Change the immediate argument in svextq (PR #115340)

2024-11-14 Thread via cfe-commits

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


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

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


@@ -1110,12 +1117,13 @@ static bool shouldRunGSLAssignmentAnalysis(const Sema 
&SemaRef,
isAssignmentOperatorLifetimeBound(Entity.AssignmentOperator)));
 }
 
-static void checkExprLifetimeImpl(Sema &SemaRef,
-  const InitializedEntity *InitEntity,
-  const InitializedEntity *ExtendingEntity,
-  LifetimeKind LK,
-  const AssignedEntity *AEntity, Expr *Init) {
+static void
+checkExprLifetimeImpl(Sema &SemaRef, const InitializedEntity *InitEntity,
+  const InitializedEntity *ExtendingEntity, LifetimeKind 
LK,
+  const AssignedEntity *AEntity,
+  const CapturingEntity *CapEntity, Expr *Init) {
   assert((AEntity && LK == LK_Assignment) ||
+ (CapEntity && LK == LK_LifetimeCapture) ||

usx95 wrote:

The third one has a `!=`. Simplified into 3 asserts.

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] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

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


@@ -3229,6 +3231,52 @@ void Sema::CheckArgAlignment(SourceLocation Loc, 
NamedDecl *FDecl,
 << ParamName << (FDecl != nullptr) << FDecl;
 }
 
+void Sema::checkLifetimeCaptureBy(FunctionDecl *FD, bool IsMemberFunction,
+  const Expr *ThisArg,
+  ArrayRef Args) {
+  auto GetArgAt = [&](int Idx) -> Expr * {
+if (Idx == LifetimeCaptureByAttr::GLOBAL ||
+Idx == LifetimeCaptureByAttr::UNKNOWN)
+  return nullptr;
+if (IsMemberFunction && Idx == 0)
+  return const_cast(ThisArg);
+return const_cast(Args[Idx - int(IsMemberFunction)]);
+  };
+  for (unsigned I = 0; I < FD->getNumParams(); ++I) {
+auto *CapturedByAttr =
+FD->getParamDecl(I)->getAttr();
+if (!CapturedByAttr)
+  continue;
+for (int CapturingParamIdx : CapturedByAttr->params()) {
+  Expr *Capturing = GetArgAt(CapturingParamIdx);
+  Expr *Captured = GetArgAt(I + IsMemberFunction);
+  CapturingEntity CE{Capturing};
+  // Ensure that 'Captured' outlives the 'Capturing' entity.
+  checkExprLifetime(*this, CE, Captured);
+}
+  }
+  // Check when the 'this' object is captured.
+  if (IsMemberFunction) {
+TypeSourceInfo *TSI = FD->getTypeSourceInfo();
+if (!TSI)
+  return;
+AttributedTypeLoc ATL;

usx95 wrote:

You could combine the two loop variables into one
```cpp
for (AttributedTypeLoc ATL =
 TSI->getTypeLoc().getAsAdjusted();
 ATL; ATL = ATL.getModifiedLoc().getAsAdjusted()) {
...
}
```
But I would keep it simpler by using two loop variables for readability. Since 
they are different types, both cannot be part of for expression.

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-tools-extra] Extend bugprone-use-after-move check to handle std::optional::reset() and std::any::reset() (PR #114255)

2024-11-14 Thread via cfe-commits

higher-performance wrote:

Thanks! Could we merge this?

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


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

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

https://github.com/usx95 updated 
https://github.com/llvm/llvm-project/pull/115921

>From 2cef37ecdb81452a8f5882dfe765167c1e45b7b6 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 13 Nov 2024 10:24:33 +
Subject: [PATCH 1/5] Implement semantics for lifetime analysis

---
 clang/include/clang/Basic/DiagnosticGroups.td |   2 +
 .../clang/Basic/DiagnosticSemaKinds.td|   7 +-
 clang/include/clang/Sema/Sema.h   |   3 +
 clang/lib/Sema/CheckExprLifetime.cpp  |  66 ---
 clang/lib/Sema/CheckExprLifetime.h|  13 +++
 clang/lib/Sema/SemaChecking.cpp   |  47 +++-
 .../Sema/warn-lifetime-analysis-nocfg.cpp | 105 ++
 clang/test/SemaCXX/attr-lifetimebound.cpp |   4 +-
 8 files changed, 228 insertions(+), 19 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 72eada50a56cc9..df9bf94b5d0398 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -453,6 +453,7 @@ def ShiftOpParentheses: DiagGroup<"shift-op-parentheses">;
 def OverloadedShiftOpParentheses: DiagGroup<"overloaded-shift-op-parentheses">;
 def DanglingAssignment: DiagGroup<"dangling-assignment">;
 def DanglingAssignmentGsl : DiagGroup<"dangling-assignment-gsl">;
+def DanglingCapture : DiagGroup<"dangling-capture">;
 def DanglingElse: DiagGroup<"dangling-else">;
 def DanglingField : DiagGroup<"dangling-field">;
 def DanglingInitializerList : DiagGroup<"dangling-initializer-list">;
@@ -462,6 +463,7 @@ def ReturnStackAddress : DiagGroup<"return-stack-address">;
 def : DiagGroup<"return-local-addr", [ReturnStackAddress]>;
 def Dangling : DiagGroup<"dangling", [DanglingAssignment,
   DanglingAssignmentGsl,
+  DanglingCapture,
   DanglingField,
   DanglingInitializerList,
   DanglingGsl,
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 2f5d672e2f0035..58745d450ed63f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10132,10 +10132,10 @@ def err_lifetimebound_ctor_dtor : Error<
   "%select{constructor|destructor}0">;
 def err_lifetimebound_parameter_void_return_type : Error<
   "'lifetimebound' attribute cannot be applied to a parameter of a function "
-  "that returns void">;
+  "that returns void; did you mean 'lifetime_capture_by(X)'">;
 def err_lifetimebound_implicit_object_parameter_void_return_type : Error<
   "'lifetimebound' attribute cannot be applied to an implicit object "
-  "parameter of a function that returns void">;
+  "parameter of a function that returns void; did you mean 
'lifetime_capture_by(X)'">;
 
 // CHECK: returning address/reference of stack memory
 def warn_ret_stack_addr_ref : Warning<
@@ -10230,6 +10230,9 @@ def warn_dangling_pointer_assignment : Warning<
"object backing %select{|the pointer }0%1 "
"will be destroyed at the end of the full-expression">,
InGroup;
+def warn_dangling_reference_captured : Warning<
+   "object captured by '%0' will be destroyed at the end of the 
full-expression">,
+   InGroup;
 
 // For non-floating point, expressions of the form x == x or x != x
 // should result in a warning, since these always evaluate to a constant.
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index d6f3508a5243f3..6ea6c67447b6f0 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2323,6 +2323,9 @@ class Sema final : public SemaBase {
   bool BuiltinVectorMath(CallExpr *TheCall, QualType &Res, bool FPOnly = 
false);
   bool BuiltinVectorToScalarMath(CallExpr *TheCall);
 
+  void checkLifetimeCaptureBy(FunctionDecl *FDecl, bool IsMemberFunction,
+  const Expr *ThisArg, ArrayRef 
Args);
+
   /// Handles the checks for format strings, non-POD arguments to vararg
   /// functions, NULL arguments passed to non-NULL parameters, diagnose_if
   /// attributes and AArch64 SME attributes.
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index a1a402b4a2b530..81e26f48fb8851 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -45,10 +45,14 @@ enum LifetimeKind {
   /// a default member initializer), the program is ill-formed.
   LK_MemInitializer,
 
-  /// The lifetime of a temporary bound to this entity probably ends too soon,
+  /// The lifetime of a temporary bound to this entity may end too soon,
   /// because the entity is a pointer and we assign the address of a temporary
   /// object to it.
   LK_Assignment,
+
+  /// The lifetime of a temporary bound to this entity may end too soon,
+  /// because the enti

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

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

https://github.com/usx95 edited 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] Remove Linux search paths on Windows (PR #113628)

2024-11-14 Thread David Salinas via cfe-commits


@@ -0,0 +1,9 @@
+// REQUIRES: system-linux

david-salinas wrote:

agreed.  Will change to use target.

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


[clang] [clang][CIR] Fix missing dependency of MLIRCIR (PR #116221)

2024-11-14 Thread Shoaib Meenai via cfe-commits

smeenai wrote:

Do you need me to merge this for you? Could you also fix the message about 
private email addresses above?

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


[clang] [libcxx] [libcxxabi] [Fuchsia][cmake] Allow using FatLTO when building runtimes (PR #112277)

2024-11-14 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/112277

>From 1dafa521d5a1e10e3f79f63a661b2e14acff5a4a Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 14 Oct 2024 15:06:38 -0700
Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 libcxx/CMakeLists.txt|  4 
 libcxx/src/CMakeLists.txt| 10 ++
 libcxxabi/src/CMakeLists.txt | 10 ++
 3 files changed, 24 insertions(+)

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index f1942e963ccc31..5a68237f7336c5 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -102,6 +102,10 @@ option(LIBCXX_ENABLE_WIDE_CHARACTERS
support the C functionality for wide characters. When wide characters are
not supported, several parts of the library will be disabled, notably the
wide character specializations of std::basic_string." ON)
+ option(LIBCXX_ENABLE_FATLTO
+   "Whether to compile libc++ with FatLTO enabled." ON)
+ option(LIBCXX_ENABLE_LTO
+   "Whether to compile libc++ with LTO enabled." ON)
 
 # To use time zone support in libc++ the platform needs to have the IANA
 # database installed. Libc++ will fail to build if this is enabled on a
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index b187677ff2db52..670db758f53173 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -173,6 +173,16 @@ if (APPLE AND LLVM_USE_SANITIZER)
   endif()
 endif()
 
+
+if(LIBCXX_ENABLE_LTO)
+  list(APPEND LIBCXX_COMPILE_FLAGS "-flto")
+  list(APPEND LIBCXX_LINK_FLAGS "-flto")
+endif()
+if(LIBCXX_ENABLE_FATLTO)
+  list(APPEND LIBCXX_COMPILE_FLAGS "-ffat-lto-objects")
+  list(APPEND LIBCXX_LINK_FLAGS "-ffat-lto-objects")
+endif()
+
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 480e528b819bb9..822ede39c6a525 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -143,6 +143,15 @@ if ( APPLE )
   endif()
 endif()
 
+if(LIBCXX_ENABLE_LTO)
+  list(APPEND LIBCXXABI_COMPILE_FLAGS "-flto")
+  list(APPEND LIBCXXABI_LINK_FLAGS "-flto")
+endif()
+if(LIBCXX_ENABLE_FATLTO)
+  list(APPEND LIBCXXABI_COMPILE_FLAGS "-ffat-lto-objects")
+  list(APPEND LIBCXXABI_LINK_FLAGS "-ffat-lto-objects")
+endif()
+
 split_list(LIBCXXABI_COMPILE_FLAGS)
 split_list(LIBCXXABI_LINK_FLAGS)
 
@@ -154,6 +163,7 @@ endif()
 
 include(WarningFlags)
 
+
 # Build the shared library.
 add_library(cxxabi_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBCXXABI_SOURCES} 
${LIBCXXABI_HEADERS})
 cxx_add_warning_flags(cxxabi_shared_objects ${LIBCXXABI_ENABLE_WERROR} 
${LIBCXXABI_ENABLE_PEDANTIC})

>From 38851d29d9eaf5e3c597be3f9f57179f308ba335 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 14 Oct 2024 15:27:36 -0700
Subject: [PATCH 2/4] Remove newline from diff

Created using spr 1.3.4
---
 libcxxabi/src/CMakeLists.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 1a1e57aa0077b4..783f17583c62e0 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -163,7 +163,6 @@ endif()
 
 include(WarningFlags)
 
-
 # Build the shared library.
 add_library(cxxabi_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBCXXABI_SOURCES} 
${LIBCXXABI_HEADERS})
 cxx_add_warning_flags(cxxabi_shared_objects ${LIBCXXABI_ENABLE_WERROR} 
${LIBCXXABI_ENABLE_PEDANTIC})

>From 535f2f2c17a3c80aa12c0106a468a8f2127241fc Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Wed, 16 Oct 2024 11:20:51 -0700
Subject: [PATCH 3/4] Avoid unecessary changes to libc++ cmake

Created using spr 1.3.4
---
 clang/cmake/caches/Fuchsia-stage2.cmake |  8 
 libcxx/CMakeLists.txt   |  4 
 libcxx/src/CMakeLists.txt   | 10 --
 libcxxabi/src/CMakeLists.txt|  9 -
 4 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5af98c7b3b3fba..e62f29ecbe6f45 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -192,6 +192,10 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
+# Enable FatLTO for Linux and baremetal runtimes
+set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "")
+set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endif()
@@ -274,6 +278,10 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE 
B

[clang] [libcxx] [libcxxabi] [Fuchsia][cmake] Allow using FatLTO when building runtimes (PR #112277)

2024-11-14 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi updated 
https://github.com/llvm/llvm-project/pull/112277

>From 1dafa521d5a1e10e3f79f63a661b2e14acff5a4a Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 14 Oct 2024 15:06:38 -0700
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 libcxx/CMakeLists.txt|  4 
 libcxx/src/CMakeLists.txt| 10 ++
 libcxxabi/src/CMakeLists.txt | 10 ++
 3 files changed, 24 insertions(+)

diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index f1942e963ccc31..5a68237f7336c5 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -102,6 +102,10 @@ option(LIBCXX_ENABLE_WIDE_CHARACTERS
support the C functionality for wide characters. When wide characters are
not supported, several parts of the library will be disabled, notably the
wide character specializations of std::basic_string." ON)
+ option(LIBCXX_ENABLE_FATLTO
+   "Whether to compile libc++ with FatLTO enabled." ON)
+ option(LIBCXX_ENABLE_LTO
+   "Whether to compile libc++ with LTO enabled." ON)
 
 # To use time zone support in libc++ the platform needs to have the IANA
 # database installed. Libc++ will fail to build if this is enabled on a
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index b187677ff2db52..670db758f53173 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -173,6 +173,16 @@ if (APPLE AND LLVM_USE_SANITIZER)
   endif()
 endif()
 
+
+if(LIBCXX_ENABLE_LTO)
+  list(APPEND LIBCXX_COMPILE_FLAGS "-flto")
+  list(APPEND LIBCXX_LINK_FLAGS "-flto")
+endif()
+if(LIBCXX_ENABLE_FATLTO)
+  list(APPEND LIBCXX_COMPILE_FLAGS "-ffat-lto-objects")
+  list(APPEND LIBCXX_LINK_FLAGS "-ffat-lto-objects")
+endif()
+
 split_list(LIBCXX_COMPILE_FLAGS)
 split_list(LIBCXX_LINK_FLAGS)
 
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 480e528b819bb9..822ede39c6a525 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -143,6 +143,15 @@ if ( APPLE )
   endif()
 endif()
 
+if(LIBCXX_ENABLE_LTO)
+  list(APPEND LIBCXXABI_COMPILE_FLAGS "-flto")
+  list(APPEND LIBCXXABI_LINK_FLAGS "-flto")
+endif()
+if(LIBCXX_ENABLE_FATLTO)
+  list(APPEND LIBCXXABI_COMPILE_FLAGS "-ffat-lto-objects")
+  list(APPEND LIBCXXABI_LINK_FLAGS "-ffat-lto-objects")
+endif()
+
 split_list(LIBCXXABI_COMPILE_FLAGS)
 split_list(LIBCXXABI_LINK_FLAGS)
 
@@ -154,6 +163,7 @@ endif()
 
 include(WarningFlags)
 
+
 # Build the shared library.
 add_library(cxxabi_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBCXXABI_SOURCES} 
${LIBCXXABI_HEADERS})
 cxx_add_warning_flags(cxxabi_shared_objects ${LIBCXXABI_ENABLE_WERROR} 
${LIBCXXABI_ENABLE_PEDANTIC})

>From 38851d29d9eaf5e3c597be3f9f57179f308ba335 Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Mon, 14 Oct 2024 15:27:36 -0700
Subject: [PATCH 2/3] Remove newline from diff

Created using spr 1.3.4
---
 libcxxabi/src/CMakeLists.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 1a1e57aa0077b4..783f17583c62e0 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -163,7 +163,6 @@ endif()
 
 include(WarningFlags)
 
-
 # Build the shared library.
 add_library(cxxabi_shared_objects OBJECT EXCLUDE_FROM_ALL ${LIBCXXABI_SOURCES} 
${LIBCXXABI_HEADERS})
 cxx_add_warning_flags(cxxabi_shared_objects ${LIBCXXABI_ENABLE_WERROR} 
${LIBCXXABI_ENABLE_PEDANTIC})

>From 535f2f2c17a3c80aa12c0106a468a8f2127241fc Mon Sep 17 00:00:00 2001
From: Paul Kirth 
Date: Wed, 16 Oct 2024 11:20:51 -0700
Subject: [PATCH 3/3] Avoid unecessary changes to libc++ cmake

Created using spr 1.3.4
---
 clang/cmake/caches/Fuchsia-stage2.cmake |  8 
 libcxx/CMakeLists.txt   |  4 
 libcxx/src/CMakeLists.txt   | 10 --
 libcxxabi/src/CMakeLists.txt|  9 -
 4 files changed, 8 insertions(+), 23 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5af98c7b3b3fba..e62f29ecbe6f45 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -192,6 +192,10 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
+# Enable FatLTO for Linux and baremetal runtimes
+set(RUNTIMES_${target}_LLVM_ENABLE_LTO ON CACHE BOOL "")
+set(RUNTIMES_${target}_LLVM_ENABLE_FATLTO ON CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endif()
@@ -274,6 +278,10 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}+asan+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE 
B

[clang] Remove Linux search paths on Windows (PR #113628)

2024-11-14 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,9 @@
+// REQUIRES: system-windows

arsenm wrote:

I don't need .cl, as in OpenCL. I mean cl as in clang-cl, the MSVC compatible 
driver 

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


[clang] [clang] Extend clang's to define *LONG_LONG*_ macros for bionic (PR #115406)

2024-11-14 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/115406

>From eda669f73765a957cc47d3d684a6443ed2f75edf Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 1/6] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 56dffe568486cc..9879fe81faa651 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,11 +111,12 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension.  It's too 
bad
-   that we don't have something like #pragma poison that could be used to
-   deprecate a macro - the code should just use LLONG_MAX and friends.
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
+   defines them. It's too bad that we don't have something like #pragma poison
+   that could be used to deprecate a macro - the code should just use LLONG_MAX
+   and friends.
  */
-#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
+#if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 
 #undef   LONG_LONG_MIN
 #undef   LONG_LONG_MAX

>From b727c41e93ee0fa5f3cc2addf4f1b67ffedc8879 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 2/6] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 9879fe81faa651..82e07f5a494951 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,10 +111,17 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
+<<< HEAD
 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
defines them. It's too bad that we don't have something like #pragma poison
that could be used to deprecate a macro - the code should just use LLONG_MAX
and friends.
+===
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
+   bionic also defines them. It's too bad that we don't have something like
+   #pragma poison that could be used to deprecate a macro - the code should 
just
+   use LLONG_MAX and friends.
+>>> 16ef50bd1f66 (Extend clang's  to define *LONG_LONG*_ macros 
for bionic)
  */
 #if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 

>From 2cb4ee5d644f42b54f93e8e07fe61b93dc6de2f1 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 3/6] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 82e07f5a494951..bc3dfb1d6d0d1c 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,17 +111,10 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-<<< HEAD
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
-   defines them. It's too bad that we don't have something like #pragma poison
-   that could be used to deprecate a macro - the code should just use LLONG_MAX
-   and friends.
-===
 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
bionic also defines them. It's too bad that we don't have something like
#pragma poison that could be used to deprecate a macro - the code should 
just
use LLONG_MAX and friends.
->>> 16ef50bd1f66 (Extend clang's  to define *LONG_LONG*_ macros 
for bionic)
  */
 #if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 

>From a69cebad4e9f0b24bb4fa704157888c4604a71b2 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 4/6] Extend clang's  to define *LONG_LONG*_ macros
 for Android's bionic

---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/test/Headers/limits.cpp | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3fc275b528d215..3d75dbe36c05b3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -319,6 +319,7 @@ C23 Feature Support
 
 - Clang now supports `N3029 
`_ Improved Normal 
Enumerations.
 - Clang now officially supports `N3030 
`_ Enhancements to 
Enumerations. Clang already supported it as an extension, so there were no 
changes to compiler behavior.
+- Extend clang's  to define *LONG_LONG*_ macros for Android's bionic.
 
 Non-comprehensive list of changes in this release
 -

[clang] [clang] Extend clang's to define *LONG_LONG*_ macros for bionic (PR #115406)

2024-11-14 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/115406

>From eda669f73765a957cc47d3d684a6443ed2f75edf Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 1/7] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 56dffe568486cc..9879fe81faa651 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,11 +111,12 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension.  It's too 
bad
-   that we don't have something like #pragma poison that could be used to
-   deprecate a macro - the code should just use LLONG_MAX and friends.
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
+   defines them. It's too bad that we don't have something like #pragma poison
+   that could be used to deprecate a macro - the code should just use LLONG_MAX
+   and friends.
  */
-#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
+#if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 
 #undef   LONG_LONG_MIN
 #undef   LONG_LONG_MAX

>From b727c41e93ee0fa5f3cc2addf4f1b67ffedc8879 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 2/7] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 9879fe81faa651..82e07f5a494951 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,10 +111,17 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
+<<< HEAD
 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
defines them. It's too bad that we don't have something like #pragma poison
that could be used to deprecate a macro - the code should just use LLONG_MAX
and friends.
+===
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
+   bionic also defines them. It's too bad that we don't have something like
+   #pragma poison that could be used to deprecate a macro - the code should 
just
+   use LLONG_MAX and friends.
+>>> 16ef50bd1f66 (Extend clang's  to define *LONG_LONG*_ macros 
for bionic)
  */
 #if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 

>From 2cb4ee5d644f42b54f93e8e07fe61b93dc6de2f1 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 3/7] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 82e07f5a494951..bc3dfb1d6d0d1c 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,17 +111,10 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-<<< HEAD
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
-   defines them. It's too bad that we don't have something like #pragma poison
-   that could be used to deprecate a macro - the code should just use LLONG_MAX
-   and friends.
-===
 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
bionic also defines them. It's too bad that we don't have something like
#pragma poison that could be used to deprecate a macro - the code should 
just
use LLONG_MAX and friends.
->>> 16ef50bd1f66 (Extend clang's  to define *LONG_LONG*_ macros 
for bionic)
  */
 #if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 

>From a69cebad4e9f0b24bb4fa704157888c4604a71b2 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 4/7] Extend clang's  to define *LONG_LONG*_ macros
 for Android's bionic

---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/test/Headers/limits.cpp | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3fc275b528d215..3d75dbe36c05b3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -319,6 +319,7 @@ C23 Feature Support
 
 - Clang now supports `N3029 
`_ Improved Normal 
Enumerations.
 - Clang now officially supports `N3030 
`_ Enhancements to 
Enumerations. Clang already supported it as an extension, so there were no 
changes to compiler behavior.
+- Extend clang's  to define *LONG_LONG*_ macros for Android's bionic.
 
 Non-comprehensive list of changes in this release
 -

[clang] [Webkit Checkers] Treat const member variables as a safe origin (PR #115594)

2024-11-14 Thread Rashmi Mudduluru via cfe-commits

https://github.com/t-rasmud approved this pull request.

LGTM!

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


[clang] 6be567b - [Webkit Checkers] Treat const member variables as a safe origin (#115594)

2024-11-14 Thread via cfe-commits

Author: Ryosuke Niwa
Date: 2024-11-14T21:11:08-08:00
New Revision: 6be567bfc22e0d165a4b927beab3933be7ef98e6

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

LOG: [Webkit Checkers] Treat const member variables as a safe origin (#115594)

Treat const Ref, RefPtr, CheckedRef, CheckedPtr member variables as safe
pointer origin in WebKit's local variable and call arguments checkers.

Added: 
clang/test/Analysis/Checkers/WebKit/call-args-checked-const-member.cpp
clang/test/Analysis/Checkers/WebKit/call-args-counted-const-member.cpp
clang/test/Analysis/Checkers/WebKit/local-vars-checked-const-member.cpp
clang/test/Analysis/Checkers/WebKit/local-vars-counted-const-member.cpp

Modified: 
clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefLocalVarsChecker.cpp
clang/test/Analysis/Checkers/WebKit/mock-types.h

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
index 9d34dfd3cea636..b3cd594a0f3529 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
@@ -142,9 +142,31 @@ bool isASafeCallArg(const Expr *E) {
 return true;
 }
   }
+  if (isConstOwnerPtrMemberExpr(E))
+return true;
 
   // TODO: checker for method calls on non-refcounted objects
   return isa(E);
 }
 
+bool isConstOwnerPtrMemberExpr(const clang::Expr *E) {
+  if (auto *MCE = dyn_cast(E)) {
+if (auto *Callee = MCE->getDirectCallee()) {
+  auto Name = safeGetName(Callee);
+  if (Name == "get" || Name == "ptr") {
+auto *ThisArg = MCE->getImplicitObjectArgument();
+E = ThisArg;
+  }
+}
+  }
+  auto *ME = dyn_cast(E);
+  if (!ME)
+return false;
+  auto *D = ME->getMemberDecl();
+  if (!D)
+return false;
+  auto T = D->getType();
+  return isOwnerPtrType(T) && T.isConstQualified();
+}
+
 } // namespace clang

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
index e972924e0c523d..ddbef0fba04489 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.h
@@ -64,6 +64,9 @@ bool tryToFindPtrOrigin(
 /// \returns Whether \p E is a safe call arugment.
 bool isASafeCallArg(const clang::Expr *E);
 
+/// \returns true if E is a MemberExpr accessing a const smart pointer type.
+bool isConstOwnerPtrMemberExpr(const clang::Expr *E);
+
 /// \returns name of AST node or empty string.
 template  std::string safeGetName(const T *ASTNode) {
   const auto *const ND = llvm::dyn_cast_or_null(ASTNode);

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 94419cfd9e73eb..797f3e1f3fba5a 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -145,25 +145,37 @@ bool isCtorOfSafePtr(const clang::FunctionDecl *F) {
   return isCtorOfRefCounted(F) || isCtorOfCheckedPtr(F);
 }
 
-bool isSafePtrType(const clang::QualType T) {
+template 
+static bool isPtrOfType(const clang::QualType T, Predicate Pred) {
   QualType type = T;
   while (!type.isNull()) {
 if (auto *elaboratedT = type->getAs()) {
   type = elaboratedT->desugar();
   continue;
 }
-if (auto *specialT = type->getAs()) {
-  if (auto *decl = specialT->getTemplateName().getAsTemplateDecl()) {
-auto name = decl->getNameAsString();
-return isRefType(name) || isCheckedPtr(name);
-  }
+auto *SpecialT = type->getAs();
+if (!SpecialT)
   return false;
-}
-return false;
+auto *Decl = SpecialT->getTemplateName().getAsTemplateDecl();
+if (!Decl)
+  return false;
+return Pred(Decl->getNameAsString());
   }
   return false;
 }
 
+bool isSafePtrType(const clang::QualType T) {
+  return isPtrOfType(
+  T, [](auto Name) { return isRefType(Name) || isCheckedPtr(Name); });
+}
+
+bool isOwnerPtrType(const clang::QualType T) {
+  return isPtrOfType(T, [](auto Name) {
+return isRefType(Name) || isCheckedPtr(Name) || Name == "unique_ptr" ||
+   Name == "UniqueRef" || Name == "LazyUniqueRef";
+  });
+}
+
 std::optional isUncounted(const QualType T) {
   if (auto *Subst = dyn_cast(T)) {
 if (auto *Decl = Subst->getAssociatedDecl()) {

diff  --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h 
b/clang/lib/StaticAnalyzer

[clang] [Webkit Checkers] Treat const member variables as a safe origin (PR #115594)

2024-11-14 Thread Ryosuke Niwa via cfe-commits

rniwa wrote:

Thanks for the review!

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


[clang] [clang][CIR] Fix missing dependency of MLIRCIR (PR #116221)

2024-11-14 Thread via cfe-commits

github-actions[bot] wrote:



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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

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

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


[clang] 56e56c9 - [clang][CIR] Fix missing dependency of MLIRCIR (#116221)

2024-11-14 Thread via cfe-commits

Author: Luohao Wang
Date: 2024-11-14T22:21:07-08:00
New Revision: 56e56c9e6673cc17f4bc7cdb3a5dbffc1557b446

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

LOG: [clang][CIR] Fix missing dependency of MLIRCIR (#116221)

Building `MLIRCIR` will report an error `CIROpsDialect.h.inc` not found.
This is because `MLIRCIR` hasn't declared its dependence on the tablegen
target `MLIRCIROpsIncGen`. This patch fixes the issue.

Added: 


Modified: 
clang/lib/CIR/Dialect/IR/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/CIR/Dialect/IR/CMakeLists.txt 
b/clang/lib/CIR/Dialect/IR/CMakeLists.txt
index 1518e8c760609c..75cee3f8711307 100644
--- a/clang/lib/CIR/Dialect/IR/CMakeLists.txt
+++ b/clang/lib/CIR/Dialect/IR/CMakeLists.txt
@@ -3,6 +3,9 @@ add_clang_library(MLIRCIR
   CIRDialect.cpp
   CIRTypes.cpp
 
+  DEPENDS
+  MLIRCIROpsIncGen
+
   LINK_LIBS PUBLIC
   MLIRIR
   )



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


[clang] [clang][CIR] Fix missing dependency of MLIRCIR (PR #116221)

2024-11-14 Thread Shoaib Meenai via cfe-commits

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


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

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


@@ -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);

BeMg wrote:

Great idea. This patch now uses the TargetSpecificAttr to enable target_version 
for AArch64 and RISC-V.

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


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

2024-11-14 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/4] [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/4] 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/4] 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/4] 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] [Driver] Remove unused includes (NFC) (PR #116316)

2024-11-14 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/116316

Identified with misc-include-cleaner.


>From 9f56ac1466659fbce81c098214e819afb19df7be Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Thu, 14 Nov 2024 08:46:55 -0800
Subject: [PATCH] [Driver] Remove unused includes (NFC)

Identified with misc-include-cleaner.
---
 clang/lib/Driver/Compilation.cpp | 3 ---
 clang/lib/Driver/Distro.cpp  | 1 -
 clang/lib/Driver/Driver.cpp  | 1 -
 clang/lib/Driver/DriverOptions.cpp   | 2 --
 clang/lib/Driver/Job.cpp | 2 --
 clang/lib/Driver/Multilib.cpp| 4 
 clang/lib/Driver/MultilibBuilder.cpp | 1 -
 clang/lib/Driver/OffloadBundler.cpp  | 1 -
 clang/lib/Driver/SanitizerArgs.cpp   | 3 ---
 clang/lib/Driver/ToolChain.cpp   | 2 --
 clang/lib/Driver/Types.cpp   | 3 ---
 clang/lib/Driver/XRayArgs.cpp| 3 ---
 12 files changed, 26 deletions(-)

diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index ad077d5bbfa69a..4d4080507175c2 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -10,13 +10,10 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Driver.h"
-#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Job.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/ToolChain.h"
 #include "clang/Driver/Util.h"
-#include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptSpecifier.h"
 #include "llvm/Option/Option.h"
diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index 3d1bce027f664d..3cc79535de8dab 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -8,7 +8,6 @@
 
 #include "clang/Driver/Distro.h"
 #include "clang/Basic/LLVM.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/ErrorOr.h"
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 93e85f7dffe35a..a0f4329e36136b 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -56,7 +56,6 @@
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Compilation.h"
-#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Job.h"
 #include "clang/Driver/Options.h"
diff --git a/clang/lib/Driver/DriverOptions.cpp 
b/clang/lib/Driver/DriverOptions.cpp
index b25801a8f3f494..053e7f1c6404fe 100644
--- a/clang/lib/Driver/DriverOptions.cpp
+++ b/clang/lib/Driver/DriverOptions.cpp
@@ -7,9 +7,7 @@
 
//===--===//
 
 #include "clang/Driver/Options.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/Option/OptTable.h"
-#include "llvm/Option/Option.h"
 #include 
 
 using namespace clang::driver;
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index fe2f7242b04a51..ae2f1cd1f56c99 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -9,7 +9,6 @@
 #include "clang/Driver/Job.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Driver.h"
-#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
@@ -26,7 +25,6 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/raw_ostream.h"
-#include 
 #include 
 #include 
 #include 
diff --git a/clang/lib/Driver/Multilib.cpp b/clang/lib/Driver/Multilib.cpp
index c56417c6f6d0b0..0207e0f2eb2ded 100644
--- a/clang/lib/Driver/Multilib.cpp
+++ b/clang/lib/Driver/Multilib.cpp
@@ -8,15 +8,11 @@
 
 #include "clang/Driver/Multilib.h"
 #include "clang/Basic/LLVM.h"
-#include "clang/Basic/Version.h"
 #include "clang/Driver/Driver.h"
 #include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Compiler.h"
-#include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorHandling.h"
-#include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/VersionTuple.h"
 #include "llvm/Support/YAMLParser.h"
diff --git a/clang/lib/Driver/MultilibBuilder.cpp 
b/clang/lib/Driver/MultilibBuilder.cpp
index 4b365a164c4586..4fbe9d9047bde5 100644
--- a/clang/lib/Driver/MultilibBuilder.cpp
+++ b/clang/lib/Driver/MultilibBuilder.cpp
@@ -8,7 +8,6 @@
 
 #include "clang/Driver/MultilibBuilder.h"
 #include "ToolChains/CommonArgs.h"
-#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
diff --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 687a38333e1287..87d7303d938c90 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -17,7 +17,6 @@
 #include "clang/Driver/OffloadBund

[clang] [llvm] [Clang][Darwin] Introduce `SubFrameworks` as a SDK default location (PR #115048)

2024-11-14 Thread Jake Petroules via cfe-commits


@@ -346,6 +346,7 @@ void InitHeaderSearch::AddDefaultIncludePaths(
 AddPath("/System/DriverKit/System/Library/Frameworks", System, true);

jakepetroules wrote:

Should we include SubFrameworks for DriverKit too, for consistency? Also, why's 
there an explicit /System/DriverKit here, didn't we generalize support for the 
system prefix?

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


[clang] [Webkit Checkers] Treat const member variables as a safe origin (PR #115594)

2024-11-14 Thread Ryosuke Niwa via cfe-commits

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


[clang] [llvm] AMDGPU: Add gfx950 subtarget definitions (PR #116307)

2024-11-14 Thread Shilei Tian via cfe-commits

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


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


[clang] 4e60075 - [Clang] [Tests] Refactor most unit tests to use DynamicRecursiveASTVisitor (#115132)

2024-11-14 Thread via cfe-commits

Author: Sirraide
Date: 2024-11-15T06:17:20+01:00
New Revision: 4e600751d2f7e8e7b85a71b7128b68444bdde91b

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

LOG: [Clang] [Tests] Refactor most unit tests to use DynamicRecursiveASTVisitor 
(#115132)

This pr refactors most tests that use RAV to use DRAV instead; this also
has the nice effect of testing both the RAV and DRAV implementations at
the same time w/o having to duplicate all of our AST visitor tests.

Some tests rely on features that DRAV doesn’t support (mainly post-order
traversal), so those haven’t been migrated. At the same time,
`TestVisitor` is now a DRAV, so I’ve had to introduce a new
`CTRPTestVisitor` for any tests that need to use RAV directly.

Added: 
clang/unittests/Tooling/CRTPTestVisitor.h

Modified: 
clang/unittests/AST/EvaluateAsRValueTest.cpp
clang/unittests/Analysis/CloneDetectionTest.cpp
clang/unittests/Frontend/FrontendActionTest.cpp
clang/unittests/Tooling/ASTSelectionTest.cpp
clang/unittests/Tooling/CastExprTest.cpp
clang/unittests/Tooling/CommentHandlerTest.cpp
clang/unittests/Tooling/ExecutionTest.cpp
clang/unittests/Tooling/LexicallyOrderedRecursiveASTVisitorTest.cpp
clang/unittests/Tooling/LookupTest.cpp
clang/unittests/Tooling/QualTypeNamesTest.cpp
clang/unittests/Tooling/RecursiveASTVisitorTestDeclVisitor.cpp
clang/unittests/Tooling/RecursiveASTVisitorTestPostOrderVisitor.cpp
clang/unittests/Tooling/RecursiveASTVisitorTestTypeLocVisitor.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/Attr.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/BitfieldInitializer.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/CXXMemberCall.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/CXXMethodDecl.cpp

clang/unittests/Tooling/RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/CallbacksCommon.h
clang/unittests/Tooling/RecursiveASTVisitorTests/Class.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/Concept.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/ConstructExpr.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/DeductionGuide.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/ImplicitCtor.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/ImplicitCtorInitializer.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPostOrder.cpp

clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPostOrderNoQueue.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp

clang/unittests/Tooling/RecursiveASTVisitorTests/InitListExprPreOrderNoQueue.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/IntegerLiteral.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaDefaultCapture.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaTemplateParams.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/MemberPointerTypeLoc.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/ParenExpr.cpp

clang/unittests/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/TraversalScope.cpp
clang/unittests/Tooling/RefactoringTest.cpp
clang/unittests/Tooling/SourceCodeTest.cpp
clang/unittests/Tooling/TestVisitor.h

Removed: 




diff  --git a/clang/unittests/AST/EvaluateAsRValueTest.cpp 
b/clang/unittests/AST/EvaluateAsRValueTest.cpp
index f6261b827671bc..1e17330863f264 100644
--- a/clang/unittests/AST/EvaluateAsRValueTest.cpp
+++ b/clang/unittests/AST/EvaluateAsRValueTest.cpp
@@ -13,7 +13,7 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/RecursiveASTVisitor.h"
+#include "clang/AST/DynamicRecursiveASTVisitor.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
 #include 
@@ -28,8 +28,8 @@ typedef std::map VarInfoMap;
 
 /// \brief Records information on variable initializers to a map.
 class EvaluateConstantInitializersVisitor
-: public clang::RecursiveASTVisitor {
- public:
+: public clang::DynamicRecursiveASTVisitor {
+public:
   explicit EvaluateConstantInitializersVisitor(VarInfoMap &VarInfo)
   : VarInfo(VarInfo) {}
 
@@ -38,7 +38,7 @@ class EvaluateConstantInitializersVisitor
   ///
   /// For each VarDecl with an initializer this also records in VarInfo
   /// whether the initializer could be evaluated as a constant.
-  bool VisitVarD

[clang] [Clang] [Tests] Refactor most unit tests to use DRAV instead (PR #115132)

2024-11-14 Thread via cfe-commits

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


[clang-tools-extra] 9ae21b0 - [clangd] fix extract-to-function for overloaded operators (#81640)

2024-11-14 Thread via cfe-commits

Author: Julian Schmidt
Date: 2024-11-15T01:05:20-05:00
New Revision: 9ae21b073ab48b376687ecd7fbae12e08b4ae86e

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

LOG: [clangd] fix extract-to-function for overloaded operators (#81640)

When selecting code that contains the use of overloaded operators,
the SelectionTree will attribute the operator to the operator
declaration, not to the `CXXOperatorCallExpr`. To allow
extract-to-function to work with these operators, make unselected
`CXXOperatorCallExpr`s valid root statements, just like `DeclStmt`s.

Partially fixes clangd/clangd#1254

-

Co-authored-by: Nathan Ridge 

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 0302839c58252e..cd07cbf73635c2 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -56,6 +56,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -70,7 +71,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/raw_os_ostream.h"
 #include 
 
 namespace clang {
@@ -95,8 +95,8 @@ enum FunctionDeclKind {
   OutOfLineDefinition
 };
 
-// A RootStmt is a statement that's fully selected including all it's children
-// and it's parent is unselected.
+// A RootStmt is a statement that's fully selected including all its children
+// and its parent is unselected.
 // Check if a node is a root statement.
 bool isRootStmt(const Node *N) {
   if (!N->ASTNode.get())
@@ -104,9 +104,12 @@ bool isRootStmt(const Node *N) {
   // Root statement cannot be partially selected.
   if (N->Selected == SelectionTree::Partial)
 return false;
-  // Only DeclStmt can be an unselected RootStmt since VarDecls claim the 
entire
-  // selection range in selectionTree.
-  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get())
+  // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
+  // selection range in selectionTree. Additionally, a CXXOperatorCallExpr of a
+  // binary operation can be unselected because its children claim the entire
+  // selection range in the selection tree (e.g. <<).
+  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get() 
&&
+  !N->ASTNode.get())
 return false;
   return true;
 }
@@ -913,8 +916,8 @@ Expected ExtractFunction::apply(const 
Selection &Inputs) {
 
   tooling::Replacements OtherEdit(
   createForwardDeclaration(*ExtractedFunc, SM));
-  if (auto PathAndEdit = Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc),
- OtherEdit))
+  if (auto PathAndEdit =
+  Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc), OtherEdit))
 MultiFileEffect->ApplyEdits.try_emplace(PathAndEdit->first,
 PathAndEdit->second);
   else

diff  --git 
a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
index dec63d454d52c6..eff4d0f43595c5 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -190,6 +190,18 @@ F (extracted();)
 }]]
   )cpp";
   EXPECT_EQ(apply(CompoundFailInput), "unavailable");
+
+  ExtraArgs.push_back("-std=c++14");
+  // FIXME: Expressions are currently not extracted
+  EXPECT_EQ(apply(R"cpp(
+void call() { [[1+1]]; }
+)cpp"),
+"unavailable");
+  // FIXME: Single expression statements are currently not extracted
+  EXPECT_EQ(apply(R"cpp(
+void call() { [[1+1;]] }
+)cpp"),
+"unavailable");
 }
 
 TEST_F(ExtractFunctionTest, DifferentHeaderSourceTest) {
@@ -571,6 +583,53 @@ int getNum(bool Superstitious, int Min, int Max) {
   EXPECT_EQ(apply(Before), After);
 }
 
+TEST_F(ExtractFunctionTest, OverloadedOperators) {
+  Context = File;
+  std::string Before = R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+   

[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-14 Thread Phoebe Wang via cfe-commits


@@ -381,6 +389,8 @@ constexpr ProcInfo Processors[] = {
   { {"emeraldrapids"}, CK_Emeraldrapids, FEATURE_AVX512FP16, 
FeaturesSapphireRapids, 'n', false },
   // Clearwaterforest microarchitecture based processors.
   { {"clearwaterforest"}, CK_Lunarlake, FEATURE_AVX2, 
FeaturesClearwaterforest, 'p', false },
+  // Diamond Rapids microarchitecture based processors.
+  { {"diamondrapids"}, CK_DiamondRapids, FEATURE_AVX10_2_512, 
FeaturesDiamondRapids, 'z', false },

phoebewang wrote:

ditto.

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


[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-14 Thread Phoebe Wang via cfe-commits


@@ -121,6 +121,7 @@ enum CPUKind {
   CK_GraniterapidsD,
   CK_Emeraldrapids,
   CK_Clearwaterforest,
+  CK_DiamondRapids,

phoebewang wrote:

CK_Diamondrapids?

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


[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-14 Thread Phoebe Wang via cfe-commits


@@ -1155,6 +1155,34 @@ def ProcessorFeatures {
   list GNRDFeatures =
 !listconcat(GNRFeatures, GNRDAdditionalFeatures);
 
+  // Diamond Rapids
+  list DMRAdditionalFeatures = [FeatureAVX10_2_512,
+  FeatureAMXCOMPLEX,

phoebewang wrote:

`FeatureAMXCOMPLEX` alreay inherited from `GNRDFeatures`.

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


[clang] [clang] Extend clang's to define *LONG_LONG*_ macros for bionic (PR #115406)

2024-11-14 Thread via cfe-commits

https://github.com/enh-google approved this pull request.


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


[clang] [clang] Extend clang's to define *LONG_LONG*_ macros for bionic (PR #115406)

2024-11-14 Thread via cfe-commits

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


[clang] 1cd981a - [OpenACC] Implement private/firstprivate for combined constructs

2024-11-14 Thread via cfe-commits

Author: erichkeane
Date: 2024-11-14T09:57:39-08:00
New Revision: 1cd981a5f3c89058edd61cdeb1efa3232b1f71e6

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

LOG: [OpenACC] Implement private/firstprivate for combined constructs

This is another pair of clauses where the work is already done from
previous constructs, so this just has to allow them and include tests
for them. This patch adds testing, does a few little cleanup bits on the
clause checking, and enables these.

Added: 
clang/test/SemaOpenACC/combined-construct-firstprivate-clause.c
clang/test/SemaOpenACC/combined-construct-firstprivate-clause.cpp
clang/test/SemaOpenACC/combined-construct-private-clause.c
clang/test/SemaOpenACC/combined-construct-private-clause.cpp
clang/test/SemaOpenACC/combined-construct-private-firstprivate-ast.cpp

Modified: 
clang/lib/Sema/SemaOpenACC.cpp
clang/test/AST/ast-print-openacc-combined-construct.cpp
clang/test/SemaOpenACC/combined-construct-auto_seq_independent-clauses.c
clang/test/SemaOpenACC/combined-construct-default-clause.c
clang/test/SemaOpenACC/compute-construct-default-clause.c

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenACC.cpp b/clang/lib/Sema/SemaOpenACC.cpp
index 70a0a122d82497..3554ecd7c80e81 100644
--- a/clang/lib/Sema/SemaOpenACC.cpp
+++ b/clang/lib/Sema/SemaOpenACC.cpp
@@ -598,6 +598,7 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitDefaultClause(
 
 OpenACCClause *SemaOpenACCClauseVisitor::VisitTileClause(
 SemaOpenACC::OpenACCParsedClause &Clause) {
+  // TODO OpenACC: Remove this when we get combined construct impl for this.
   if (Clause.getDirectiveKind() != OpenACCDirectiveKind::Loop)
 return isNotImplemented();
 
@@ -699,6 +700,8 @@ OpenACCClause 
*SemaOpenACCClauseVisitor::VisitNumGangsClause(
   // Restrictions only properly implemented on 'compute' constructs, and
   // 'compute' constructs are the only construct that can do anything with
   // this yet, so skip/treat as unimplemented in this case.
+  // TODO OpenACC:  Remove this check when we have combined constructs for this
+  // clause.
   if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
 return isNotImplemented();
 
@@ -754,6 +757,7 @@ OpenACCClause 
*SemaOpenACCClauseVisitor::VisitNumWorkersClause(
   // Restrictions only properly implemented on 'compute' constructs, and
   // 'compute' constructs are the only construct that can do anything with
   // this yet, so skip/treat as unimplemented in this case.
+  // TODO: OpenACC: Remove when we get combined constructs.
   if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
 return isNotImplemented();
 
@@ -775,6 +779,7 @@ OpenACCClause 
*SemaOpenACCClauseVisitor::VisitVectorLengthClause(
   // Restrictions only properly implemented on 'compute' constructs, and
   // 'compute' constructs are the only construct that can do anything with
   // this yet, so skip/treat as unimplemented in this case.
+  // TODO: OpenACC: Remove when we get combined constructs.
   if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
 return isNotImplemented();
 
@@ -815,14 +820,6 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitAsyncClause(
 
 OpenACCClause *SemaOpenACCClauseVisitor::VisitPrivateClause(
 SemaOpenACC::OpenACCParsedClause &Clause) {
-  // Restrictions only properly implemented on 'compute' and 'loop'
-  // constructs, and 'compute'/'loop' constructs are the only construct that
-  // can do anything with this yet, so skip/treat as unimplemented in this
-  // case.
-  if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
-  Clause.getDirectiveKind() != OpenACCDirectiveKind::Loop)
-return isNotImplemented();
-
   // ActOnVar ensured that everything is a valid variable reference, so there
   // really isn't anything to do here. GCC does some duplicate-finding, though
   // it isn't apparent in the standard where this is justified.
@@ -834,12 +831,6 @@ OpenACCClause 
*SemaOpenACCClauseVisitor::VisitPrivateClause(
 
 OpenACCClause *SemaOpenACCClauseVisitor::VisitFirstPrivateClause(
 SemaOpenACC::OpenACCParsedClause &Clause) {
-  // Restrictions only properly implemented on 'compute' constructs, and
-  // 'compute' constructs are the only construct that can do anything with
-  // this yet, so skip/treat as unimplemented in this case.
-  if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
-return isNotImplemented();
-
   // ActOnVar ensured that everything is a valid variable reference, so there
   // really isn't anything to do here. GCC does some duplicate-finding, though
   // it isn't apparent in the standard where this is justified.
@@ -1412,6 +1403,7 @@ OpenACCClause 
*SemaOpenACCClauseVisitor::VisitReductionClause(
   // Restrictions

[clang] [llvm] Reland "[LLVM] Add IRNormalizer Pass" (PR #113780)

2024-11-14 Thread Justin Fargnoli via cfe-commits

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


[clang] [clang][CIR] Fix missing dependency of MLIRCIR (PR #116221)

2024-11-14 Thread Shoaib Meenai via cfe-commits

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

LGTM

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


[clang] [HLSL] Implement SV_GroupID semantic (PR #115911)

2024-11-14 Thread Damyan Pepper via cfe-commits

https://github.com/damyanp commented:

This LGTM, but I think we should try and get reviews from @tex3d and 
@llvm-beanz before completing this PR.

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


[clang] [clang] Extend clang's to define *LONG_LONG*_ macros for bionic (PR #115406)

2024-11-14 Thread via cfe-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/115406

>From eda669f73765a957cc47d3d684a6443ed2f75edf Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 1/7] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 56dffe568486cc..9879fe81faa651 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,11 +111,12 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension.  It's too 
bad
-   that we don't have something like #pragma poison that could be used to
-   deprecate a macro - the code should just use LLONG_MAX and friends.
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
+   defines them. It's too bad that we don't have something like #pragma poison
+   that could be used to deprecate a macro - the code should just use LLONG_MAX
+   and friends.
  */
-#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
+#if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 
 #undef   LONG_LONG_MIN
 #undef   LONG_LONG_MAX

>From b727c41e93ee0fa5f3cc2addf4f1b67ffedc8879 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 2/7] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 9879fe81faa651..82e07f5a494951 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,10 +111,17 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
+<<< HEAD
 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
defines them. It's too bad that we don't have something like #pragma poison
that could be used to deprecate a macro - the code should just use LLONG_MAX
and friends.
+===
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
+   bionic also defines them. It's too bad that we don't have something like
+   #pragma poison that could be used to deprecate a macro - the code should 
just
+   use LLONG_MAX and friends.
+>>> 16ef50bd1f66 (Extend clang's  to define *LONG_LONG*_ macros 
for bionic)
  */
 #if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 

>From 2cb4ee5d644f42b54f93e8e07fe61b93dc6de2f1 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 3/7] Extend clang's  to define *LONG_LONG*_ macros
 for bionic

---
 clang/lib/Headers/limits.h | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 82e07f5a494951..bc3dfb1d6d0d1c 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,17 +111,10 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-<<< HEAD
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Bionic also
-   defines them. It's too bad that we don't have something like #pragma poison
-   that could be used to deprecate a macro - the code should just use LLONG_MAX
-   and friends.
-===
 /* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
bionic also defines them. It's too bad that we don't have something like
#pragma poison that could be used to deprecate a macro - the code should 
just
use LLONG_MAX and friends.
->>> 16ef50bd1f66 (Extend clang's  to define *LONG_LONG*_ macros 
for bionic)
  */
 #if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : 
!defined(__STRICT_ANSI__)) || defined(__BIONIC__)
 

>From a69cebad4e9f0b24bb4fa704157888c4604a71b2 Mon Sep 17 00:00:00 2001
From: Zijun 
Date: Fri, 8 Nov 2024 01:04:21 +
Subject: [PATCH 4/7] Extend clang's  to define *LONG_LONG*_ macros
 for Android's bionic

---
 clang/docs/ReleaseNotes.rst   | 1 +
 clang/test/Headers/limits.cpp | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3fc275b528d215..3d75dbe36c05b3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -319,6 +319,7 @@ C23 Feature Support
 
 - Clang now supports `N3029 
`_ Improved Normal 
Enumerations.
 - Clang now officially supports `N3030 
`_ Enhancements to 
Enumerations. Clang already supported it as an extension, so there were no 
changes to compiler behavior.
+- Extend clang's  to define *LONG_LONG*_ macros for Android's bionic.
 
 Non-comprehensive list of changes in this release
 -

[clang] Filter test based on backend support. (PR #116244)

2024-11-14 Thread Daniel Kiss via cfe-commits

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


[clang] [clang][CodeGen] `sret` args should always point to the `alloca` AS, so use that (PR #114062)

2024-11-14 Thread Alex Voicu via cfe-commits

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


[libunwind] [libunwind][Haiku] Improve support (PR #115462)

2024-11-14 Thread Fangrui Song via cfe-commits


@@ -2917,7 +2980,8 @@ template  int UnwindCursor::step(bool stage2) {
 
   // Use unwinding info to modify register set as if function returned.
   int result;
-#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
+#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) ||   
\
+(defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64))

MaskRay wrote:

Why is `_LIBUNWIND_TARGET_X86_64` check needed?

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


[clang] Respect the [[clang::unsafe_buffer_usage]] attribute for field and constructor initializers (PR #91991)

2024-11-14 Thread Zequan Wu via cfe-commits

ZequanWu wrote:

It's actually an existing crash not caused by this one.

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


[clang] [clang][Analysis][NFC] Let isConfigurationValue take Expr (PR #116266)

2024-11-14 Thread Aaron Puchert via cfe-commits

https://github.com/aaronpuchert created 
https://github.com/llvm/llvm-project/pull/116266

The only non-`Expr` Terminator is `ObjCForCollectionStmt`, but that is arguably 
just a modelling issue, and we return false for every non-`Expr` anyway. 
Letting the caller cast to `Expr` removes lots of `dyn_cast`s.

>From b58bf4d9b7f0757f2208b6c77eff6aeeca07efa4 Mon Sep 17 00:00:00 2001
From: Aaron Puchert 
Date: Thu, 14 Nov 2024 18:30:55 +0100
Subject: [PATCH] [clang][Analysis][NFC] Let isConfigurationValue take Expr

The only non-Expr Terminator is ObjCForCollectionStmt, but that is
arguably just a modelling issue, and we return false for every non-Expr
anyway. Letting the caller cast to Expr removes lots of dyn_casts.
---
 clang/lib/Analysis/ReachableCode.cpp | 46 +---
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/clang/lib/Analysis/ReachableCode.cpp 
b/clang/lib/Analysis/ReachableCode.cpp
index acbe1470b38991..f5f7e924b8c37e 100644
--- a/clang/lib/Analysis/ReachableCode.cpp
+++ b/clang/lib/Analysis/ReachableCode.cpp
@@ -186,45 +186,39 @@ static bool isConfigurationValue(const ValueDecl *D, 
Preprocessor &PP);
 /// "sometimes unreachable" code.  Such code is usually not interesting
 /// to report as unreachable, and may mask truly unreachable code within
 /// those blocks.
-static bool isConfigurationValue(const Stmt *S,
- Preprocessor &PP,
+static bool isConfigurationValue(const Expr *E, Preprocessor &PP,
  SourceRange *SilenceableCondVal = nullptr,
  bool IncludeIntegers = true,
  bool WrappedInParens = false) {
-  if (!S)
+  if (!E)
 return false;
 
-  if (const auto *Ex = dyn_cast(S))
-S = Ex->IgnoreImplicit();
-
-  if (const auto *Ex = dyn_cast(S))
-S = Ex->IgnoreCasts();
+  E = E->IgnoreImplicit();
+  E = E->IgnoreCasts();
 
   // Special case looking for the sigil '()' around an integer literal.
-  if (const ParenExpr *PE = dyn_cast(S))
+  if (const ParenExpr *PE = dyn_cast(E))
 if (!PE->getBeginLoc().isMacroID())
   return isConfigurationValue(PE->getSubExpr(), PP, SilenceableCondVal,
   IncludeIntegers, true);
 
-  if (const Expr *Ex = dyn_cast(S))
-S = Ex->IgnoreCasts();
+  E = E->IgnoreCasts();
 
   bool IgnoreYES_NO = false;
 
-  switch (S->getStmtClass()) {
+  switch (E->getStmtClass()) {
 case Stmt::CallExprClass: {
   const FunctionDecl *Callee =
-dyn_cast_or_null(cast(S)->getCalleeDecl());
+dyn_cast_or_null(cast(E)->getCalleeDecl());
   return Callee ? Callee->isConstexpr() : false;
 }
 case Stmt::DeclRefExprClass:
-  return isConfigurationValue(cast(S)->getDecl(), PP);
+  return isConfigurationValue(cast(E)->getDecl(), PP);
 case Stmt::ObjCBoolLiteralExprClass:
   IgnoreYES_NO = true;
   [[fallthrough]];
 case Stmt::CXXBoolLiteralExprClass:
 case Stmt::IntegerLiteralClass: {
-  const Expr *E = cast(S);
   if (IncludeIntegers) {
 if (SilenceableCondVal && !SilenceableCondVal->getBegin().isValid())
   *SilenceableCondVal = E->getSourceRange();
@@ -234,11 +228,11 @@ static bool isConfigurationValue(const Stmt *S,
   return false;
 }
 case Stmt::MemberExprClass:
-  return isConfigurationValue(cast(S)->getMemberDecl(), PP);
+  return isConfigurationValue(cast(E)->getMemberDecl(), PP);
 case Stmt::UnaryExprOrTypeTraitExprClass:
   return true;
 case Stmt::BinaryOperatorClass: {
-  const BinaryOperator *B = cast(S);
+  const BinaryOperator *B = cast(E);
   // Only include raw integers (not enums) as configuration
   // values if they are used in a logical or comparison operator
   // (not arithmetic).
@@ -249,7 +243,7 @@ static bool isConfigurationValue(const Stmt *S,
   IncludeIntegers);
 }
 case Stmt::UnaryOperatorClass: {
-  const UnaryOperator *UO = cast(S);
+  const UnaryOperator *UO = cast(E);
   if (UO->getOpcode() != UO_LNot && UO->getOpcode() != UO_Minus)
 return false;
   bool SilenceableCondValNotSet =
@@ -299,8 +293,8 @@ static bool shouldTreatSuccessorsAsReachable(const CFGBlock 
*B,
 if (isa(Term))
   return true;
 // Specially handle '||' and '&&'.
-if (isa(Term)) {
-  return isConfigurationValue(Term, PP);
+if (const auto *BO = dyn_cast(Term)) {
+  return isConfigurationValue(BO, PP);
 }
 // Do not treat constexpr if statement successors as unreachable in 
warnings
 // since the point of these statements is to determine branches at compile
@@ -310,8 +304,10 @@ static bool shouldTreatSuccessorsAsReachable(const 
CFGBlock *B,
   return true;
   }
 
-  const Stmt *Cond = B->getTerminatorCondition(/* stripParens */ false);
-  return isConfigurationValue(Cond, PP);
+  if (const Expr *Cond = dyn_cast_or_null(
+  B->g

[clang] 7d20ea9 - [clang] Extend clang's to define *LONG_LONG*_ macros for bionic (#115406)

2024-11-14 Thread via cfe-commits

Author: ZijunZhaoCCK
Date: 2024-11-14T10:39:08-08:00
New Revision: 7d20ea9d32954e8e5becab8495fa509a3f67b710

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

LOG: [clang] Extend clang's  to define *LONG_LONG*_ macros for bionic 
(#115406)

*LONG_LONG*_ macros are not GNU-only extensions any more. Bionic also
defines them.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Headers/limits.h
clang/test/Headers/limits.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index eecfd585c1c03d..681728d36952c1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -271,6 +271,8 @@ Resolutions to C++ Defect Reports
 C Language Changes
 --
 
+- Extend clang's  to define ``LONG_LONG_*`` macros for Android's 
bionic.
+
 C2y Feature Support
 ^^^
 

diff  --git a/clang/lib/Headers/limits.h b/clang/lib/Headers/limits.h
index 56dffe568486cc..d08227fe4d3d48 100644
--- a/clang/lib/Headers/limits.h
+++ b/clang/lib/Headers/limits.h
@@ -111,11 +111,14 @@
 #define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
 #endif
 
-/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension.  It's too 
bad
-   that we don't have something like #pragma poison that could be used to
-   deprecate a macro - the code should just use LLONG_MAX and friends.
+/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
+   bionic also defines them. It's too bad that we don't have something like
+   #pragma poison that could be used to deprecate a macro - the code should 
just
+   use LLONG_MAX and friends.
  */
-#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
+#if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) 
\
+  : !defined(__STRICT_ANSI__)) ||  
\
+defined(__BIONIC__)
 
 #undef   LONG_LONG_MIN
 #undef   LONG_LONG_MAX

diff  --git a/clang/test/Headers/limits.cpp b/clang/test/Headers/limits.cpp
index da7a64901831d5..132e5bc24a0c92 100644
--- a/clang/test/Headers/limits.cpp
+++ b/clang/test/Headers/limits.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -std=c17 -ffreestanding -fsyntax-only -verify -x c %s
 // RUN: %clang_cc1 -std=c2x -ffreestanding -fsyntax-only -verify -x c %s
 
+// Specifically test arm64 linux platforms.
+// RUN: %clang_cc1 -triple arm64-linux -ffreestanding -fsyntax-only -verify -x 
c %s
+
 // Specifically test 16-bit int platforms.
 // RUN: %clang_cc1 -triple=avr -ffreestanding -fsyntax-only -verify -x c %s
 // RUN: %clang_cc1 -triple=avr -std=c++11 -ffreestanding -fsyntax-only -verify 
%s



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


[clang] b96c24b - [analyzer] Allow copying empty structs (1/4) (#115916)

2024-11-14 Thread via cfe-commits

Author: Balazs Benics
Date: 2024-11-14T14:31:32+01:00
New Revision: b96c24b8613036749e7ba28f0c7a837115ae9f91

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

LOG: [analyzer] Allow copying empty structs (1/4) (#115916)

We represent copies of structs by LazyCompoundVals, that is basically a
snapshot of the Store and Region that your copy would refer to.

This snapshot is actually not taken for empty structs (structs that have
no non-static data members), because the users won't be able to access
any fields anyways, so why bother.
However, when it comes to taint propagation, it would be nice if
instances of empty structs would behave similar to non-empty structs.
For this, we need an identity for which taint can bind, so Unknown -
that was used in the past wouldn't work.

Consequently, copying the value of an empty struct should behave the
same way as a non-empty struct, thus be represented by a
LazyCompoundVal.

Split from #114835

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
clang/test/Analysis/ctor-trivial-copy.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp 
b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index 6bad9a93a30169..f46282a73fbe40 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -2336,20 +2336,16 @@ NonLoc 
RegionStoreManager::createLazyBinding(RegionBindingsConstRef B,
   return svalBuilder.makeLazyCompoundVal(StoreRef(B.asStore(), *this), R);
 }
 
-static bool isRecordEmpty(const RecordDecl *RD) {
-  if (!RD->field_empty())
-return false;
-  if (const CXXRecordDecl *CRD = dyn_cast(RD))
-return CRD->getNumBases() == 0;
-  return true;
-}
-
 SVal RegionStoreManager::getBindingForStruct(RegionBindingsConstRef B,
  const TypedValueRegion *R) {
   const RecordDecl *RD = R->getValueType()->castAs()->getDecl();
-  if (!RD->getDefinition() || isRecordEmpty(RD))
+  if (!RD->getDefinition())
 return UnknownVal();
 
+  // We also create a LCV for copying empty structs because then the store
+  // behavior doesn't depend on the struct layout.
+  // This way even an empty struct can carry taint, no matter if creduce drops
+  // the last field member or not.
   return createLazyBinding(B, R);
 }
 

diff  --git a/clang/test/Analysis/ctor-trivial-copy.cpp 
b/clang/test/Analysis/ctor-trivial-copy.cpp
index 5ed188aa8f1eae..a1209c24136e20 100644
--- a/clang/test/Analysis/ctor-trivial-copy.cpp
+++ b/clang/test/Analysis/ctor-trivial-copy.cpp
@@ -1,8 +1,12 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config c++-inlining=constructors -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection 
-analyzer-config c++-inlining=constructors -verify %s \
+// RUN:   2>&1 | FileCheck %s
 
 
-template
-void clang_analyzer_dump(T&);
+void clang_analyzer_printState();
+template void clang_analyzer_dump_lref(T&);
+template void clang_analyzer_dump_val(T);
+template  T conjure();
+template  void nop(const Ts &... args) {}
 
 struct aggr {
   int x;
@@ -15,20 +19,103 @@ struct empty {
 void test_copy_return() {
   aggr s1 = {1, 2};
   aggr const& cr1 = aggr(s1);
-  clang_analyzer_dump(cr1); // expected-warning-re 
{{&lifetime_extended_object{aggr, cr1, S{{[0-9]+}}} }}
+  clang_analyzer_dump_lref(cr1); // expected-warning-re 
{{&lifetime_extended_object{aggr, cr1, S{{[0-9]+}}} }}
 
   empty s2;
   empty const& cr2 = empty{s2};
-  clang_analyzer_dump(cr2); // expected-warning-re 
{{&lifetime_extended_object{empty, cr2, S{{[0-9]+}}} }}
+  clang_analyzer_dump_lref(cr2); // expected-warning-re 
{{&lifetime_extended_object{empty, cr2, S{{[0-9]+}}} }}
 }
 
 void test_assign_return() {
   aggr s1 = {1, 2};
   aggr d1;
-  clang_analyzer_dump(d1 = s1); // expected-warning {{&d1 }}
+  clang_analyzer_dump_lref(d1 = s1); // expected-warning {{&d1 }}
 
   empty s2;
   empty d2;
-  clang_analyzer_dump(d2 = s2); // expected-warning {{&d2 }} was Unknown
+  clang_analyzer_dump_lref(d2 = s2); // expected-warning {{&d2 }} was Unknown
 }
 
+
+namespace trivial_struct_copy {
+
+void _01_empty_structs() {
+  clang_analyzer_dump_val(conjure()); // expected-warning 
{{lazyCompoundVal}}
+  empty Empty = conjure();
+  empty Empty2 = Empty;
+  empty Empty3 = Empty2;
+  // All of these should refer to the exact same LCV, because all of
+  // these trivial copies refer to the original conjured value.
+  // There were Unknown before:
+  clang_analyzer_dump_val(Empty);  // expected-warning {{lazyCompoundVal}}
+  clang_analyzer_dump_val(Empty2); // expected-warning {{lazyCompoundVal}}
+  clang_analyzer_dump_val(Empty3); // expected-warning {{lazyCompoundVal}}
+
+  // Notice that we don't have 

[clang] [clang] Instantiate attributes on LabelDecls (PR #115924)

2024-11-14 Thread Eric Astor via cfe-commits

https://github.com/ericastor updated 
https://github.com/llvm/llvm-project/pull/115924

>From da2e66a6a2636bf1a1ab2e25afdbd29095b6db3f Mon Sep 17 00:00:00 2001
From: Eric Astor 
Date: Tue, 12 Nov 2024 17:37:42 +
Subject: [PATCH 1/6] [clang] Instantiate attributes on other decl types

Start propagating attributes on (e.g.) labels inside of templated functions to 
their instances.
---
 clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 16 +---
 clang/test/SemaCXX/attr-mode-tmpl.cpp  |  4 ++--
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 5a001843e2ba46..bfc5913dbafd0f 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -990,6 +990,7 @@ Decl *
 TemplateDeclInstantiator::VisitLabelDecl(LabelDecl *D) {
   LabelDecl *Inst = LabelDecl::Create(SemaRef.Context, Owner, D->getLocation(),
   D->getIdentifier());
+  SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope);
   Owner->addDecl(Inst);
   return Inst;
 }
@@ -1009,6 +1010,7 @@ 
TemplateDeclInstantiator::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
  D->getQualifierLoc(),
  D->getTargetNameLoc(),
  D->getNamespace());
+  SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope);
   Owner->addDecl(Inst);
   return Inst;
 }
@@ -1095,15 +1097,21 @@ Decl 
*TemplateDeclInstantiator::InstantiateTypedefNameDecl(TypedefNameDecl *D,
 
 Decl *TemplateDeclInstantiator::VisitTypedefDecl(TypedefDecl *D) {
   Decl *Typedef = InstantiateTypedefNameDecl(D, /*IsTypeAlias=*/false);
-  if (Typedef)
+  if (Typedef) {
+SemaRef.InstantiateAttrs(TemplateArgs, D, Typedef, LateAttrs,
+ StartingScope);
 Owner->addDecl(Typedef);
+  }
   return Typedef;
 }
 
 Decl *TemplateDeclInstantiator::VisitTypeAliasDecl(TypeAliasDecl *D) {
   Decl *Typedef = InstantiateTypedefNameDecl(D, /*IsTypeAlias=*/true);
-  if (Typedef)
+  if (Typedef) {
+SemaRef.InstantiateAttrs(TemplateArgs, D, Typedef, LateAttrs,
+ StartingScope);
 Owner->addDecl(Typedef);
+  }
   return Typedef;
 }
 
@@ -1160,8 +1168,10 @@ Decl 
*TemplateDeclInstantiator::InstantiateTypeAliasTemplateDecl(
 Decl *
 TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) 
{
   Decl *Inst = InstantiateTypeAliasTemplateDecl(D);
-  if (Inst)
+  if (Inst) {
+SemaRef.InstantiateAttrs(TemplateArgs, D, Inst, LateAttrs, StartingScope);
 Owner->addDecl(Inst);
+  }
 
   return Inst;
 }
diff --git a/clang/test/SemaCXX/attr-mode-tmpl.cpp 
b/clang/test/SemaCXX/attr-mode-tmpl.cpp
index f665b1ba491237..58266f947051c5 100644
--- a/clang/test/SemaCXX/attr-mode-tmpl.cpp
+++ b/clang/test/SemaCXX/attr-mode-tmpl.cpp
@@ -9,7 +9,7 @@ void CheckEnumerations() {
   // Check that non-vector 'mode' attribute is OK with enumeration types.
   typedef T __attribute__((mode(QI))) T1;
   typedef T T2 __attribute__((mode(HI)));
-  typedef T __attribute__((mode(V8SI))) T3; // expected-error{{mode 'V8SI' is 
not supported for enumeration types}}
+  typedef T __attribute__((mode(V8SI))) T3; // expected-error2{{mode 'V8SI' is 
not supported for enumeration types}}
   // expected-warning@-1{{specifying vector types with the 'mode' attribute is 
deprecated}}
 
   typedef enum __attribute__((mode(HI))) { A4, B4 } T4;
@@ -62,7 +62,7 @@ struct TemplatedStruct {
 
   // Check typedefs.
   typedef T __attribute__((mode(DI)))   T1;
-  typedef T __attribute__((mode(V8DI))) T2;   // expected-error{{mode 'V8DI' 
is not supported for enumeration types}}
+  typedef T __attribute__((mode(V8DI))) T2;   // expected-error2{{mode 'V8DI' 
is not supported for enumeration types}}
   // 
expected-warning@-1{{deprecated}}
 
   // Check parameters.

>From eb4b3a2d1e25b9fc63048e5f2d71d62a3cbd2bde Mon Sep 17 00:00:00 2001
From: Eric Astor 
Date: Thu, 14 Nov 2024 19:24:45 +
Subject: [PATCH 2/6] Include attributes on LabelStmts (forwarding from decls)
 in AST dumps

We apply this to add a test of the new label attribute instantiation support.
---
 clang/examples/Attribute/Attribute.cpp | 6 +++---
 clang/include/clang/AST/ASTNodeTraverser.h | 5 +
 clang/test/Frontend/plugin-attribute.cpp   | 8 
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/clang/examples/Attribute/Attribute.cpp 
b/clang/examples/Attribute/Attribute.cpp
index 3b90724ad22205..59446a15a6925d 100644
--- a/clang/examples/Attribute/Attribute.cpp
+++ b/clang/examples/Attribute/Attribute.cpp
@@ -41,9 +41,9 @@ struct ExampleAttrInfo : public ParsedAttrInfo {
   bool diagAppertainsToDecl(Sema &S, const ParsedAttr &Attr,
 const Decl *D) const override {
 // This 

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

2024-11-14 Thread Finn Plummer via cfe-commits


@@ -853,6 +853,15 @@ def CreateHandleFromBinding : DXILOp<217, 
createHandleFromBinding> {
   let stages = [Stages];
 }
 
+def WaveActiveAnyTrue : DXILOp<113, waveAnyTrue> {
+  let Doc = "returns true if the expression is true in any of the active lanes 
in the current wave";
+  let LLVMIntrinsic = int_dx_wave_any;
+  let arguments = [Int1Ty];
+  let result = Int1Ty;
+  let stages = [Stages];
+  let attributes = [Attributes];

inbelic wrote:

```suggestion
```
There is no attribute specified for `WaveAnyTrue` in `hctdb.py`. As discussed, 
there are many others with incorrectly added attributes, which will be 
cleaned-up in https://github.com/llvm/llvm-project/issues/115912

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-14 Thread Finn Plummer via cfe-commits


@@ -94,6 +94,7 @@ def int_dx_umad : DefaultAttrsIntrinsic<[llvm_anyint_ty], 
[LLVMMatchType<0>, LLV
 def int_dx_normalize : DefaultAttrsIntrinsic<[LLVMMatchType<0>], 
[llvm_anyfloat_ty], [IntrNoMem]>;
 def int_dx_rsqrt  : DefaultAttrsIntrinsic<[llvm_anyfloat_ty], 
[LLVMMatchType<0>], [IntrNoMem]>;
 def int_dx_wave_active_countbits : DefaultAttrsIntrinsic<[llvm_i32_ty], 
[llvm_i1_ty], [IntrConvergent, IntrNoMem]>;
+def int_dx_wave_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i1_ty], 
[IntrConvergent]>;

inbelic wrote:

```suggestion
def int_dx_wave_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i1_ty], 
[IntrConvergent, IntrNoMem]>;
```

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-14 Thread Finn Plummer via cfe-commits


@@ -19120,6 +19120,15 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
 /*ReturnType=*/Op0->getType(), CGM.getHLSLRuntime().getStepIntrinsic(),
 ArrayRef{Op0, Op1}, nullptr, "hlsl.step");
   }
+  case Builtin::BI__builtin_hlsl_wave_active_any_true: {
+Value *Op = EmitScalarExpr(E->getArg(0));
+llvm::Type *Ty = Op->getType();
+assert(Ty->isIntegerTy(1) && "wave_active_any_true operand must be a 
bool");

inbelic wrote:

```suggestion
assert(Ty->isIntegerTy(1) && "Intrinsic WaveActiveAnyTrue operand must be a 
bool");
```

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-14 Thread Finn Plummer via cfe-commits


@@ -86,6 +86,7 @@ let TargetPrefix = "spv" in {
   def int_spv_dot4add_i8packed : DefaultAttrsIntrinsic<[llvm_i32_ty], 
[llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
   def int_spv_dot4add_u8packed : DefaultAttrsIntrinsic<[llvm_i32_ty], 
[llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
   def int_spv_wave_active_countbits : DefaultAttrsIntrinsic<[llvm_i32_ty], 
[llvm_i1_ty], [IntrConvergent, IntrNoMem]>;
+  def int_spv_wave_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i1_ty], 
[IntrConvergent]>;

inbelic wrote:

```suggestion
  def int_spv_wave_any : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_i1_ty], 
[IntrConvergent, IntrNoMem]>;
```

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-14 Thread Finn Plummer via cfe-commits


@@ -676,7 +679,6 @@ void RequirementHandler::initAvailableCapabilitiesForOpenCL(
 addAvailableCaps({Capability::SubgroupDispatch, Capability::PipeStorage});
   if (ST.isAtLeastSPIRVVer(VersionTuple(1, 3)))
 addAvailableCaps({Capability::GroupNonUniform,

inbelic wrote:

I guess we could move the rest of these while we are here

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-14 Thread Finn Plummer via cfe-commits

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

LGTM., just some minor fix-ups

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] AMDGPU: Add gfx950 subtarget definitions (PR #116307)

2024-11-14 Thread Matt Arsenault via cfe-commits

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


[clang] [llvm] AMDGPU: Add gfx950 subtarget definitions (PR #116307)

2024-11-14 Thread Matt Arsenault via cfe-commits

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


[clang] [llvm] AMDGPU: Add gfx950 subtarget definitions (PR #116307)

2024-11-14 Thread Matt Arsenault via cfe-commits

https://github.com/arsenm edited 
https://github.com/llvm/llvm-project/pull/116307
___
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 #112600)

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

llvm-ci wrote:

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

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: AST/HLSL/AppendStructuredBuffer-AST.hlsl' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-cc1 -internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/20/include 
-nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
 | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=EMPTY 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-check-prefix=EMPTY 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -cc1 
-internal-isystem 
/Users/buildbot/buildbot-root/aarch64-darwin/build/lib/clang/20/include 
-nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl:15:16:
 error: EMPTY-NEXT: expected string not found in input
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <> 
 class depth 0 index 0 element_type
   ^
:39:98: note: scanning from here
| |-ClassTemplateDecl 0x133853fa0 <>  implicit 
AppendStructuredBuffer
   
  ^
:40:7: note: possible intended match here
| | |-TemplateTypeParmDecl 0x133853f00 <>  
typename depth 0 index 0 element_type
  ^

Input file: 
Check file: 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl

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

Input was:
<<
   1: TranslationUnitDecl 0x13382c608 
<>  
   2: |-NamespaceDecl 0x13382cf28 <>  implicit hlsl 
   3: | |-TypeAliasTemplateDecl 0x13382d280 
<>  implicit vector 
   4: | | |-TemplateTypeParmDecl 0x13382cfb0 
<>  class depth 0 index 0 element 
   5: | | | `-TemplateArgument type 'float' 

   6: | | | `-BuiltinType 0x13382c810 'float' 

   7: | | |-NonTypeTemplateParmDecl 
0x13382d0b0 <>  'int' depth 0 index 1 element_count 

   8: | | | `-TemplateArgument expr '4' 
   9: | | | `-IntegerLiteral 0x13382d108 
<> 'int' 4 
  10: | | `-TypeAliasDecl 0x13382d220 
<>  implicit vector 'vector' 
  11: | | `-DependentSizedExtVectorType 
0x13382d1d0 'vector' dependent  
  12: | | |-TemplateTypeParmType 0x13382d030 
'element' dependent depth 0 index 0 
  13: | | | `-TemplateTypeParm 0x13382cfb0 
'element' 
  14: | | `-DeclRefExpr 0x13382d170 <> 'int' lvalue NonTypeTemplateParm 0x13382d0b0 'element_count' 'int' 
  15: | |-ClassTemplateDecl 0x1338521a8 
<>  implicit RWBuffer 
  16: | | |-TemplateTypeParmDecl 0x13382d538 
<>  typename depth 0 index 0 element_type 
  17: | | |-ConceptSpecializationExpr 
0x133852148 <> 'bool' Concept 0x13382d3f0 
'__is_typed_resource_element_compatible' 
  18: | | | 
|-ImplicitConceptSpecializationDecl 0x133852080 <>  

  19: | | | | `-TemplateArgument type 
'type-parameter-0-0' 
  20: | | | | `-TemplateTypeParmType 
0x133852050 'type-parameter-0-0' dependent depth 0 index 0 
  21: | | | | `-TemplateTypeParm 0x133852000 
'' 
  22: | | | `-TemplateArgument type 
'element_t

[clang] [llvm] AMDGPU: Add gfx950 subtarget definitions (PR #116307)

2024-11-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)


Changes

AMDGPU: Copy correct predicates for SDWA reals

There are a lot of messes in the special case
predicate handling. Currently broad let blocks
override specific predicates with more general
cases. For instructions with SDWA, the HasSDWA
predicate was overriding the SubtargetPredicate
for the instruction.

This fixes enough to properly disallow new instructions
that support SDWA on older targets.

AMDGPU: Add gfx950 subtarget definitions

Mostly a stub, but adds some baseline tests and
tests for removed instructions.

---

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


47 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/Cuda.h (+1) 
- (modified) clang/lib/Basic/Cuda.cpp (+1) 
- (modified) clang/lib/Basic/Targets/NVPTX.cpp (+1) 
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+1) 
- (modified) clang/test/CodeGenOpenCL/amdgpu-features.cl (+2) 
- (modified) clang/test/Driver/amdgpu-macros.cl (+1) 
- (modified) clang/test/Driver/amdgpu-mcpu.cl (+2) 
- (modified) clang/test/Misc/target-invalid-cpu-note/amdgcn.c (+1) 
- (modified) clang/test/Misc/target-invalid-cpu-note/nvptx.c (+1) 
- (modified) llvm/docs/AMDGPUUsage.rst (+8-1) 
- (modified) llvm/include/llvm/BinaryFormat/ELF.h (+1-1) 
- (modified) llvm/include/llvm/TargetParser/TargetParser.h (+13-12) 
- (modified) llvm/lib/Object/ELFObjectFile.cpp (+2) 
- (modified) llvm/lib/ObjectYAML/ELFYAML.cpp (+1) 
- (modified) llvm/lib/Target/AMDGPU/AMDGPU.td (+20-2) 
- (modified) llvm/lib/Target/AMDGPU/GCNProcessors.td (+4) 
- (modified) llvm/lib/Target/AMDGPU/GCNSubtarget.h (+1) 
- (modified) llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp (+2) 
- (modified) llvm/lib/Target/AMDGPU/VOP1Instructions.td (+2-2) 
- (modified) llvm/lib/Target/AMDGPU/VOP2Instructions.td (+14-12) 
- (modified) llvm/lib/Target/AMDGPU/VOPCInstructions.td (+1-1) 
- (modified) llvm/lib/Target/AMDGPU/VOPInstructions.td (+6-6) 
- (modified) llvm/lib/TargetParser/TargetParser.cpp (+9-2) 
- (modified) llvm/test/CodeGen/AMDGPU/bf16-conversions.ll (+232-113) 
- (modified) llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll (+6) 
- (modified) llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll (+2) 
- (modified) llvm/test/CodeGen/AMDGPU/elf-header-flags-sramecc.ll (+8) 
- (modified) llvm/test/CodeGen/AMDGPU/fmaximum3.ll (+437-157) 
- (modified) llvm/test/CodeGen/AMDGPU/fminimum3.ll (+437-157) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.amdgcn.cvt.fp8.ll (+2) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.maximum.f16.ll (+586-638) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.maximum.f32.ll (+527-586) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.maximum.f64.ll (+755-814) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.minimum.f16.ll (+586-637) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.minimum.f32.ll (+527-586) 
- (modified) llvm/test/CodeGen/AMDGPU/llvm.minimum.f64.ll (+755-814) 
- (modified) llvm/test/MC/AMDGPU/flat-scratch-gfx940.s (+1) 
- (modified) llvm/test/MC/AMDGPU/gfx940_asm_features.s (+1) 
- (added) llvm/test/MC/AMDGPU/gfx950-unsupported.s (+179) 
- (added) llvm/test/MC/AMDGPU/gfx950_invalid_encoding.txt (+13) 
- (modified) llvm/test/MC/Disassembler/AMDGPU/gfx940_features.txt (+1) 
- (modified) llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml (+7) 
- (modified) llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll (+5) 
- (modified) llvm/test/tools/llvm-readobj/ELF/AMDGPU/elf-headers.test (+9) 
- (modified) llvm/tools/llvm-readobj/ELFDumper.cpp (+1) 
- (modified) offload/DeviceRTL/CMakeLists.txt (+1-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 681728d36952c1..5caedd0b6d3cfd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -710,6 +710,8 @@ Target Specific Changes
 AMDGPU Support
 ^^
 
+* Initial support for gfx950
+
 X86 Support
 ^^^
 
diff --git a/clang/include/clang/Basic/Cuda.h b/clang/include/clang/Basic/Cuda.h
index 721e8981af6ffc..c2a4addf488df1 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -107,6 +107,7 @@ enum class OffloadArch {
   GFX940,
   GFX941,
   GFX942,
+  GFX950,
   GFX10_1_GENERIC,
   GFX1010,
   GFX1011,
diff --git a/clang/lib/Basic/Cuda.cpp b/clang/lib/Basic/Cuda.cpp
index 59c932468cd891..d56609a2a8f24a 100644
--- a/clang/lib/Basic/Cuda.cpp
+++ b/clang/lib/Basic/Cuda.cpp
@@ -125,6 +125,7 @@ static const OffloadArchToStringMap arch_names[] = {
 GFX(940),  // gfx940
 GFX(941),  // gfx941
 GFX(942),  // gfx942
+GFX(950),  // gfx950
 {OffloadArch::GFX10_1_GENERIC, "gfx10-1-generic", "compute_amdgcn"},
 GFX(1010), // gfx1010
 GFX(1011), // gfx1011
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp 
b/clang/lib/Basic/Targets/NVPTX.cpp
index 0897032c4b8546..dbc3fec3657610 100644
--- a

[clang] [llvm] AMDGPU: Copy correct predicates for SDWA reals (PR #116307)

2024-11-14 Thread Matt Arsenault via cfe-commits

arsenm wrote:

* **#116309** https://app.graphite.dev/github/pr/llvm/llvm-project/116309?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#116308** https://app.graphite.dev/github/pr/llvm/llvm-project/116308?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/>
* **#116307** https://app.graphite.dev/github/pr/llvm/llvm-project/116307?utm_source=stack-comment-icon";
 target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" 
width="10px" height="10px"/> 👈 https://app.graphite.dev/github/pr/llvm/llvm-project/116307?utm_source=stack-comment-view-in-graphite";
 target="_blank">(View in Graphite)
* `main`



This stack of pull requests is managed by https://graphite.dev?utm-source=stack-comment";>Graphite. Learn 
more about https://stacking.dev/?utm_source=stack-comment";>stacking.


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


[clang] [HLSL] Add empty struct test cases to `__builtin_hlsl_is_typed_resource_element_compatible` test file (PR #115045)

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

bogner wrote:

When you change what a PR does, please remember to update the title and 
description. This went in saying it's about adding some test cases but it 
actually changes much more than that.

https://github.com/llvm/llvm-project/pull/115045
___
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-14 Thread Helmut Januschka via cfe-commits

https://github.com/hjanuschka updated 
https://github.com/llvm/llvm-project/pull/116033

>From caddb82d73d49b59dff71547d8ab986039895696 Mon Sep 17 00:00:00 2001
From: Helmut Januschka 
Date: Wed, 13 Nov 2024 12:52:36 +0100
Subject: [PATCH] [clang-tidy] Enhance modernize-use-starts-ends-with with
 substr detection

Enhances the modernize-use-starts-ends-with check to detect substr-based
patterns that can be replaced with starts_with() (C++20). This improves code
readability and efficiency by avoiding temporary string creation.

New patterns detected:
  str.substr(0, n) == "foo"   -> str.starts_with("foo")
  "foo" == str.substr(0, n)   -> str.starts_with("foo")
  str.substr(0, n) != "foo"   -> !str.starts_with("foo")
  str.substr(0, strlen("foo")) == "foo" -> str.starts_with("foo")
  str.substr(0, prefix.size()) == "foo" -> str.starts_with("foo")

The enhancement:
- Integrates with existing starts_with patterns
- Handles substr with zero first argument
- Supports length via literals, strlen(), and size()/length()
- Validates string literal length matches
- Handles both == and != operators

Part of modernize-use-starts-ends-with check.
---
 .../modernize/UseStartsEndsWithCheck.cpp  | 185 --
 .../modernize/UseStartsEndsWithCheck.h|   4 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   7 +
 .../checks/modernize/use-starts-ends-with.rst |  45 +++--
 .../clang-tidy/checkers/Inputs/Headers/string |   5 +-
 .../modernize/use-starts-ends-with.cpp|  42 +++-
 6 files changed, 257 insertions(+), 31 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index 1231f954298adc..e7da45198df6c1 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -22,28 +22,46 @@ struct NotLengthExprForStringNode {
   NotLengthExprForStringNode(std::string ID, DynTypedNode Node,
  ASTContext *Context)
   : ID(std::move(ID)), Node(std::move(Node)), Context(Context) {}
+  
   bool operator()(const internal::BoundNodesMap &Nodes) const {
-// Match a string literal and an integer size or strlen() call.
 if (const auto *StringLiteralNode = Nodes.getNodeAs(ID)) {
+  // Match direct integer literals
   if (const auto *IntegerLiteralSizeNode = Node.get()) {
 return StringLiteralNode->getLength() !=
IntegerLiteralSizeNode->getValue().getZExtValue();
   }
 
-  if (const auto *StrlenNode = Node.get()) {
-if (StrlenNode->getDirectCallee()->getName() != "strlen" ||
-StrlenNode->getNumArgs() != 1) {
-  return true;
+  // Match strlen() calls
+  if (const auto *CallNode = Node.get()) {
+if (const auto *FD = CallNode->getDirectCallee()) {
+  if (FD->getName() == "strlen" && CallNode->getNumArgs() == 1) {
+if (const auto *StrArg = 
CallNode->getArg(0)->IgnoreParenImpCasts()) {
+  // Handle both string literals and string variables in strlen
+  if (const auto *StrLit = dyn_cast(StrArg)) {
+return StrLit->getLength() != StringLiteralNode->getLength();
+  } else if (const auto *StrVar = dyn_cast(StrArg)) {
+return !utils::areStatementsIdentical(StrVar, 
StringLiteralNode, *Context);
+  }
+}
+  }
 }
-
-if (const auto *StrlenArgNode = dyn_cast(
-StrlenNode->getArg(0)->IgnoreParenImpCasts())) {
-  return StrlenArgNode->getLength() != StringLiteralNode->getLength();
+  }
+  
+  // Match size()/length() member calls
+  if (const auto *MemberCall = Node.get()) {
+if (const auto *Method = MemberCall->getMethodDecl()) {
+  StringRef Name = Method->getName();
+  if (Method->isConst() && Method->getNumParams() == 0 &&
+  (Name == "size" || Name == "length")) {
+// For string literals used in comparison, allow size/length calls
+// on any string variable
+return false;
+  }
 }
   }
 }
 
-// Match a string variable and a call to length() or size().
+// Match member function calls on string variables
 if (const auto *ExprNode = Nodes.getNodeAs(ID)) {
   if (const auto *MemberCallNode = Node.get()) {
 const CXXMethodDecl *MethodDeclNode = MemberCallNode->getMethodDecl();
@@ -53,8 +71,8 @@ struct NotLengthExprForStringNode {
   return true;
 }
 
-if (const auto *OnNode =
-dyn_cast(MemberCallNode->getImplicitObjectArgument())) {
+if (const auto *OnNode = dyn_cast(
+MemberCallNode->getImplicitObjectArgument())) {
   return !utils::areStatementsIdentical(OnNode->IgnoreParenImpCasts(),
 

[clang] [MSP430] Default to unsigned char (PR #115964)

2024-11-14 Thread Anton Korobeynikov via cfe-commits

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


[clang] 7b7ae72 - [MSP430] Default to unsigned char (#115964)

2024-11-14 Thread via cfe-commits

Author: Alexander Richardson
Date: 2024-11-14T12:49:02-08:00
New Revision: 7b7ae72b5863c4090bf06d1f10cd676823e02fb1

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

LOG: [MSP430] Default to unsigned char (#115964)

This matches the ABI document at https://www.ti.com/lit/pdf/slaa534 as well as 
the GCC implementation.

Partially fixes https://github.com/llvm/llvm-project/issues/115957

Added: 
clang/test/Driver/msp430-char.c

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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 8ca2d2006d6fb0..3133b8f5762389 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1341,6 +1341,7 @@ static bool isSignedCharDefault(const llvm::Triple 
&Triple) {
 return false;
 
   case llvm::Triple::hexagon:
+  case llvm::Triple::msp430:
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64le:
   case llvm::Triple::riscv32:

diff  --git a/clang/test/Driver/msp430-char.c b/clang/test/Driver/msp430-char.c
new file mode 100644
index 00..67954e3e2a1be5
--- /dev/null
+++ b/clang/test/Driver/msp430-char.c
@@ -0,0 +1,4 @@
+/// Check that char is unsigned by default.
+// RUN: %clang -### %s --target=msp430 -c 2>&1 | FileCheck %s
+// CHECK: "-cc1" "-triple" "msp430"
+// CHECK-SAME: "-fno-signed-char"



___
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-14 Thread Helmut Januschka via cfe-commits

https://github.com/hjanuschka updated 
https://github.com/llvm/llvm-project/pull/116033

>From e549c1a93f242608af2c51a8777b4bb8ab60c228 Mon Sep 17 00:00:00 2001
From: Helmut Januschka 
Date: Wed, 13 Nov 2024 12:52:36 +0100
Subject: [PATCH] [clang-tidy] Enhance modernize-use-starts-ends-with with
 substr detection

Enhances the modernize-use-starts-ends-with check to detect substr-based
patterns that can be replaced with starts_with() (C++20). This improves code
readability and efficiency by avoiding temporary string creation.

New patterns detected:
  str.substr(0, n) == "foo"   -> str.starts_with("foo")
  "foo" == str.substr(0, n)   -> str.starts_with("foo")
  str.substr(0, n) != "foo"   -> !str.starts_with("foo")
  str.substr(0, strlen("foo")) == "foo" -> str.starts_with("foo")
  str.substr(0, prefix.size()) == "foo" -> str.starts_with("foo")

The enhancement:
- Integrates with existing starts_with patterns
- Handles substr with zero first argument
- Supports length via literals, strlen(), and size()/length()
- Validates string literal length matches
- Handles both == and != operators

Part of modernize-use-starts-ends-with check.
---
 .../modernize/UseStartsEndsWithCheck.cpp  | 185 --
 .../modernize/UseStartsEndsWithCheck.h|   4 +
 .../checks/modernize/use-starts-ends-with.rst |  45 +++--
 .../clang-tidy/checkers/Inputs/Headers/string |   5 +-
 .../modernize/use-starts-ends-with.cpp|  42 +++-
 5 files changed, 250 insertions(+), 31 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index 1231f954298adc..e7da45198df6c1 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -22,28 +22,46 @@ struct NotLengthExprForStringNode {
   NotLengthExprForStringNode(std::string ID, DynTypedNode Node,
  ASTContext *Context)
   : ID(std::move(ID)), Node(std::move(Node)), Context(Context) {}
+  
   bool operator()(const internal::BoundNodesMap &Nodes) const {
-// Match a string literal and an integer size or strlen() call.
 if (const auto *StringLiteralNode = Nodes.getNodeAs(ID)) {
+  // Match direct integer literals
   if (const auto *IntegerLiteralSizeNode = Node.get()) {
 return StringLiteralNode->getLength() !=
IntegerLiteralSizeNode->getValue().getZExtValue();
   }
 
-  if (const auto *StrlenNode = Node.get()) {
-if (StrlenNode->getDirectCallee()->getName() != "strlen" ||
-StrlenNode->getNumArgs() != 1) {
-  return true;
+  // Match strlen() calls
+  if (const auto *CallNode = Node.get()) {
+if (const auto *FD = CallNode->getDirectCallee()) {
+  if (FD->getName() == "strlen" && CallNode->getNumArgs() == 1) {
+if (const auto *StrArg = 
CallNode->getArg(0)->IgnoreParenImpCasts()) {
+  // Handle both string literals and string variables in strlen
+  if (const auto *StrLit = dyn_cast(StrArg)) {
+return StrLit->getLength() != StringLiteralNode->getLength();
+  } else if (const auto *StrVar = dyn_cast(StrArg)) {
+return !utils::areStatementsIdentical(StrVar, 
StringLiteralNode, *Context);
+  }
+}
+  }
 }
-
-if (const auto *StrlenArgNode = dyn_cast(
-StrlenNode->getArg(0)->IgnoreParenImpCasts())) {
-  return StrlenArgNode->getLength() != StringLiteralNode->getLength();
+  }
+  
+  // Match size()/length() member calls
+  if (const auto *MemberCall = Node.get()) {
+if (const auto *Method = MemberCall->getMethodDecl()) {
+  StringRef Name = Method->getName();
+  if (Method->isConst() && Method->getNumParams() == 0 &&
+  (Name == "size" || Name == "length")) {
+// For string literals used in comparison, allow size/length calls
+// on any string variable
+return false;
+  }
 }
   }
 }
 
-// Match a string variable and a call to length() or size().
+// Match member function calls on string variables
 if (const auto *ExprNode = Nodes.getNodeAs(ID)) {
   if (const auto *MemberCallNode = Node.get()) {
 const CXXMethodDecl *MethodDeclNode = MemberCallNode->getMethodDecl();
@@ -53,8 +71,8 @@ struct NotLengthExprForStringNode {
   return true;
 }
 
-if (const auto *OnNode =
-dyn_cast(MemberCallNode->getImplicitObjectArgument())) {
+if (const auto *OnNode = dyn_cast(
+MemberCallNode->getImplicitObjectArgument())) {
   return !utils::areStatementsIdentical(OnNode->IgnoreParenImpCasts(),
 
ExprNode->IgnoreParenImpCasts(),
 

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

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

https://github.com/hjanuschka edited 
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-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

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


@@ -7,26 +7,39 @@ Checks for common roundabout ways to express ``starts_with`` 
and ``ends_with``
 and suggests replacing with the simpler method when it is available. Notably, 
 this will work with ``std::string`` and ``std::string_view``.
 
-.. code-block:: c++
+The check handles the following expressions:
 
-  std::string s = "...";
-  if (s.find("prefix") == 0) { /* do something */ }
-  if (s.rfind("prefix", 0) == 0) { /* do something */ }
-  if (s.compare(0, strlen("prefix"), "prefix") == 0) { /* do something */ }
-  if (s.compare(s.size() - strlen("suffix"), strlen("suffix"), "suffix") == 0) 
{
-/* do something */
-  }
-  if (s.rfind("suffix") == (s.length() - 6)) {
-/* do something */
-  }
-
-becomes
+ 
===

hjanuschka wrote:

to what column? it is right now excatly at 80

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-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

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

https://github.com/hjanuschka edited 
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-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-14 Thread via cfe-commits


@@ -147,6 +147,13 @@ New check aliases
 Changes in existing checks
 ^^
 
+- Improved :doc:`modernize-use-starts-ends-with

EugeneZelenko wrote:

Please append text to existing `modernize-use-starts-ends-with` entry.

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-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-14 Thread via cfe-commits


@@ -173,7 +240,101 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   this);
 }
 
+void UseStartsEndsWithCheck::handleSubstrMatch(const MatchFinder::MatchResult 
&Result) {
+  const auto *SubstrCall = 
Result.Nodes.getNodeAs("substr_fun");
+  const auto *PositiveComparison = 
Result.Nodes.getNodeAs("positiveComparison");
+  const auto *NegativeComparison = 
Result.Nodes.getNodeAs("negativeComparison");
+  
+  if (!SubstrCall || (!PositiveComparison && !NegativeComparison))
+return;
+
+  const bool Negated = NegativeComparison != nullptr;
+  const auto *Comparison = Negated ? NegativeComparison : PositiveComparison;
+  
+  if (SubstrCall->getBeginLoc().isMacroID())
+return;
+
+  const auto *Str = Result.Nodes.getNodeAs("str");
+  const auto *Literal = Result.Nodes.getNodeAs("literal");
+  const auto *Length = Result.Nodes.getNodeAs("length");
+
+  if (!Str || !Literal || !Length)
+return;
+
+  // Special handling for strlen and size/length member calls
+  const bool IsValidLength = [&]() {
+if (const auto *LengthInt = dyn_cast(Length)) {
+  return LengthInt->getValue().getZExtValue() == Literal->getLength();
+}
+
+if (const auto *Call = dyn_cast(Length)) {
+  if (const auto *FD = Call->getDirectCallee()) {
+if (FD->getName() == "strlen" && Call->getNumArgs() == 1) {
+  if (const auto *StrArg = dyn_cast(
+  Call->getArg(0)->IgnoreParenImpCasts())) {
+return StrArg->getLength() == Literal->getLength();
+  }
+}
+  }
+}
+
+if (const auto *MemberCall = dyn_cast(Length)) {
+  if (const auto *Method = MemberCall->getMethodDecl()) {
+StringRef Name = Method->getName();

EugeneZelenko wrote:

```suggestion
const StringRef Name = Method->getName();
```

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-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-14 Thread via cfe-commits


@@ -7,26 +7,39 @@ Checks for common roundabout ways to express ``starts_with`` 
and ``ends_with``
 and suggests replacing with the simpler method when it is available. Notably, 
 this will work with ``std::string`` and ``std::string_view``.
 
-.. code-block:: c++
+The check handles the following expressions:
 
-  std::string s = "...";
-  if (s.find("prefix") == 0) { /* do something */ }
-  if (s.rfind("prefix", 0) == 0) { /* do something */ }
-  if (s.compare(0, strlen("prefix"), "prefix") == 0) { /* do something */ }
-  if (s.compare(s.size() - strlen("suffix"), strlen("suffix"), "suffix") == 0) 
{
-/* do something */
-  }
-  if (s.rfind("suffix") == (s.length() - 6)) {
-/* do something */
-  }
-
-becomes
+ 
===

EugeneZelenko wrote:

Should fix texts in second column.

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] Match against all plugins when parsing microsoft attributes (PR #86426)

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

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


[clang] Match against all plugins when parsing microsoft attributes (PR #86426)

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

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

I'm really sorry for not realizing this was held up on me -- mea culpa!

This LGTM with a caveat: Clang has ignored Microsoft style attributes for a 
*long* time, so it's entirely possible that we don't correctly implement their 
parsing in all cases.

https://github.com/llvm/llvm-project/pull/86426
___
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-14 Thread Helmut Januschka via cfe-commits

https://github.com/hjanuschka edited 
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] [MSP430] Default to unsigned char (PR #115964)

2024-11-14 Thread Anton Korobeynikov via cfe-commits

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

Thanks!

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


[clang] Match against all plugins when parsing microsoft attributes (PR #86426)

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


@@ -0,0 +1,61 @@
+//===- Attribute.cpp 
--===//

AaronBallman wrote:

```suggestion
//===- MicrosoftAttributes.cpp ===//
```

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


[clang] Match against all plugins when parsing microsoft attributes (PR #86426)

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

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


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

2024-11-14 Thread Joshua Batista via cfe-commits

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


[clang] c1f6cb7 - Revert "[HLSL] Add implicit resource element type concepts to AST" (#116305)

2024-11-14 Thread via cfe-commits

Author: Joshua Batista
Date: 2024-11-14T17:10:58-08:00
New Revision: c1f6cb74634509d0e4204dadd46566185fa33e2b

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

LOG: Revert "[HLSL] Add implicit resource element type concepts to AST" 
(#116305)

Reverts llvm/llvm-project#112600

Added: 


Modified: 
clang/lib/Sema/HLSLExternalSemaSource.cpp
clang/test/AST/HLSL/RWBuffer-AST.hlsl
clang/test/AST/HLSL/StructuredBuffer-AST.hlsl
clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
clang/test/SemaHLSL/BuiltIns/StructuredBuffers.hlsl

Removed: 
clang/test/AST/HLSL/is_typed_resource_element_compatible_concept.hlsl



diff  --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index d90a7d3c697a04..cac15b974a276e 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -289,9 +289,8 @@ struct BuiltinTypeDeclBuilder {
   }
 
   TemplateParameterListBuilder addTemplateArgumentList(Sema &S);
-  BuiltinTypeDeclBuilder &
-  addSimpleTemplateParams(Sema &S, ArrayRef Names, ConceptDecl *CD);
-  BuiltinTypeDeclBuilder &addConceptSpecializationExpr(Sema &S);
+  BuiltinTypeDeclBuilder &addSimpleTemplateParams(Sema &S,
+  ArrayRef Names);
 };
 
 struct TemplateParameterListBuilder {
@@ -313,129 +312,30 @@ struct TemplateParameterListBuilder {
 S.Context, Builder.Record->getDeclContext(), SourceLocation(),
 SourceLocation(), /* TemplateDepth */ 0, Position,
 &S.Context.Idents.get(Name, tok::TokenKind::identifier),
-/* Typename */ true,
-/* ParameterPack */ false,
-/* HasTypeConstraint*/ false);
+/* Typename */ false,
+/* ParameterPack */ false);
 if (!DefaultValue.isNull())
   Decl->setDefaultArgument(
   S.Context, S.getTrivialTemplateArgumentLoc(DefaultValue, QualType(),
  SourceLocation()));
+
 Params.emplace_back(Decl);
 return *this;
   }
 
-  /*
-  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;
-
-  template requires
-  is_typed_resource_element_compatible
-  struct RWBuffer {
-  element_type Val;
-  };
-
-  int fn() {
-  RWBuffer Buf;
-  }
-
-  When dumping the AST and filtering for "RWBuffer", the resulting AST
-  structure is what we're trying to construct below, specifically the
-  CSE portion.
-  */
-  ConceptSpecializationExpr *
-  constructConceptSpecializationExpr(Sema &S, ConceptDecl *CD) {
-ASTContext &Context = S.getASTContext();
-SourceLocation Loc = Builder.Record->getBeginLoc();
-DeclarationNameInfo DNI(CD->getDeclName(), Loc);
-NestedNameSpecifierLoc NNSLoc;
-DeclContext *DC = Builder.Record->getDeclContext();
-TemplateArgumentListInfo TALI(Loc, Loc);
-
-// Assume that the concept decl has just one template parameter
-// This parameter should have been added when CD was constructed
-// in getTypedBufferConceptDecl
-assert(CD->getTemplateParameters()->size() == 1 &&
-   "unexpected concept decl parameter count");
-TemplateTypeParmDecl *ConceptTTPD = dyn_cast(
-CD->getTemplateParameters()->getParam(0));
-
-// this TemplateTypeParmDecl is the template for the resource, and is
-// used to construct a template argumentthat will be used
-// to construct the ImplicitConceptSpecializationDecl
-TemplateTypeParmDecl *T = TemplateTypeParmDecl::Create(
-Context,  // AST context
-Builder.Record->getDeclContext(), // DeclContext
-SourceLocation(), SourceLocation(),
-/*depth=*/0,// Depth in the template parameter list
-/*position=*/0, // Position in the template parameter list
-/*id=*/nullptr, // Identifier for 'T'
-/*Typename=*/true,  // Indicates this is a 'typename' or 
'class'
-/*ParameterPack=*/false,// Not a parameter pack
-/*HasTypeConstraint=*/false // Has no type constraint
-);
-
-T->setDeclContext(DC);
-
-QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
-
-// this is the 2nd template argument node, on which
-// the concept constraint is actually being applied: 'element_type'
-TemplateArgument ConceptTA = TemplateArgument(ConceptTType);
-
-QualType CSETType = Context.getTypeDeclType(T);
-
-// this is the 1st template argument node, which represents
-// the abstract type that a concept would refer to: 'T'
- 

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

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-cmake-x86_64-avx512-linux` running on `avx512-intel64` while building 
`clang` at step 7 "ninja check 1".

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


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

```
Step 7 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'Clang :: AST/HLSL/ConsumeStructuredBuffer-AST.hlsl' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang
 -cc1 -internal-isystem 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/lib/clang/20/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
 | 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck
 -check-prefix=EMPTY 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
+ 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/clang
 -cc1 -internal-isystem 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/lib/clang/20/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
+ 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/stage1/bin/FileCheck
 -check-prefix=EMPTY 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl:15:16:
 error: EMPTY-NEXT: expected string not found in input
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <> 
 class depth 0 index 0 element_type
   ^
:43:97: note: scanning from here
| |-ClassTemplateDecl 0xa161520 <>  implicit 
ConsumeStructuredBuffer

^
:44:7: note: possible intended match here
| | |-TemplateTypeParmDecl 0xa161480 <>  typename 
depth 0 index 0 element_type
  ^

Input file: 
Check file: 
/localdisk2/buildbot/llvm-worker/clang-cmake-x86_64-avx512-linux/llvm/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl

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

Input was:
<<
   .
   .
   .
  38: | | `-FinalAttr 0xa15ed58 <> Implicit final 
  39: | |-ClassTemplateDecl 0xa161130 <>  
implicit AppendStructuredBuffer 
  40: | | |-TemplateTypeParmDecl 0xa161090 <>  typename depth 0 index 0 element_type 
  41: | | `-CXXRecordDecl 0xa160f90 <>  
implicit  class AppendStructuredBuffer 
  42: | | `-FinalAttr 0xa161038 <> Implicit final 
  43: | |-ClassTemplateDecl 0xa161520 <>  
implicit ConsumeStructuredBuffer 
next:15'0   
  X error: no match found
  44: | | |-TemplateTypeParmDecl 0xa161480 <>  typename depth 0 index 0 element_type 
next:15'0 
~~~
next:15'1   ?   
  possible intended match
  45: | | `-CXXRecordDecl 0xa161380 <>  
implicit  class ConsumeStructuredBuffer 
next:15'0 
~~~
  46: | | `-FinalAttr 0xa161428 <> Implicit final 
next:15'0 ~~
  47: | `-ClassTemplateDecl 0xa161910 <>  
implicit RasterizerOrderedStructuredBuffer 
next:15'0 
~~~
  48: | |-TemplateTypeParmDecl 0xa161870 <>  typename depth 0 index 0 element_type 
next:15'0 
~
  49: | `-CXXRecordDecl 0xa161770 <>  
implicit  class RasterizerOrderedStructuredBuffer 
next:15'0 
~~~
   .
   .
...

```



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

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

2024-11-14 Thread Joshua Batista via cfe-commits

https://github.com/bob80905 created 
https://github.com/llvm/llvm-project/pull/116305

Reverts llvm/llvm-project#112600

>From 110599f1ada1999c5c33c41928cec0ea6e438992 Mon Sep 17 00:00:00 2001
From: Joshua Batista 
Date: Thu, 14 Nov 2024 17:08:30 -0800
Subject: [PATCH] Revert "[HLSL] Add implicit resource element type concepts to
 AST (#112600)"

This reverts commit 478c24b5f86911d14256bad71c85ed0ff061070a.
---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 217 +-
 clang/test/AST/HLSL/RWBuffer-AST.hlsl |  20 +-
 clang/test/AST/HLSL/StructuredBuffer-AST.hlsl |   4 +-
 ...d_resource_element_compatible_concept.hlsl |  10 -
 clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl   |  15 +-
 .../SemaHLSL/BuiltIns/StructuredBuffers.hlsl  |   4 +-
 6 files changed, 20 insertions(+), 250 deletions(-)
 delete mode 100644 
clang/test/AST/HLSL/is_typed_resource_element_compatible_concept.hlsl

diff --git a/clang/lib/Sema/HLSLExternalSemaSource.cpp 
b/clang/lib/Sema/HLSLExternalSemaSource.cpp
index d90a7d3c697a04..cac15b974a276e 100644
--- a/clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ b/clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -289,9 +289,8 @@ struct BuiltinTypeDeclBuilder {
   }
 
   TemplateParameterListBuilder addTemplateArgumentList(Sema &S);
-  BuiltinTypeDeclBuilder &
-  addSimpleTemplateParams(Sema &S, ArrayRef Names, ConceptDecl *CD);
-  BuiltinTypeDeclBuilder &addConceptSpecializationExpr(Sema &S);
+  BuiltinTypeDeclBuilder &addSimpleTemplateParams(Sema &S,
+  ArrayRef Names);
 };
 
 struct TemplateParameterListBuilder {
@@ -313,129 +312,30 @@ struct TemplateParameterListBuilder {
 S.Context, Builder.Record->getDeclContext(), SourceLocation(),
 SourceLocation(), /* TemplateDepth */ 0, Position,
 &S.Context.Idents.get(Name, tok::TokenKind::identifier),
-/* Typename */ true,
-/* ParameterPack */ false,
-/* HasTypeConstraint*/ false);
+/* Typename */ false,
+/* ParameterPack */ false);
 if (!DefaultValue.isNull())
   Decl->setDefaultArgument(
   S.Context, S.getTrivialTemplateArgumentLoc(DefaultValue, QualType(),
  SourceLocation()));
+
 Params.emplace_back(Decl);
 return *this;
   }
 
-  /*
-  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;
-
-  template requires
-  is_typed_resource_element_compatible
-  struct RWBuffer {
-  element_type Val;
-  };
-
-  int fn() {
-  RWBuffer Buf;
-  }
-
-  When dumping the AST and filtering for "RWBuffer", the resulting AST
-  structure is what we're trying to construct below, specifically the
-  CSE portion.
-  */
-  ConceptSpecializationExpr *
-  constructConceptSpecializationExpr(Sema &S, ConceptDecl *CD) {
-ASTContext &Context = S.getASTContext();
-SourceLocation Loc = Builder.Record->getBeginLoc();
-DeclarationNameInfo DNI(CD->getDeclName(), Loc);
-NestedNameSpecifierLoc NNSLoc;
-DeclContext *DC = Builder.Record->getDeclContext();
-TemplateArgumentListInfo TALI(Loc, Loc);
-
-// Assume that the concept decl has just one template parameter
-// This parameter should have been added when CD was constructed
-// in getTypedBufferConceptDecl
-assert(CD->getTemplateParameters()->size() == 1 &&
-   "unexpected concept decl parameter count");
-TemplateTypeParmDecl *ConceptTTPD = dyn_cast(
-CD->getTemplateParameters()->getParam(0));
-
-// this TemplateTypeParmDecl is the template for the resource, and is
-// used to construct a template argumentthat will be used
-// to construct the ImplicitConceptSpecializationDecl
-TemplateTypeParmDecl *T = TemplateTypeParmDecl::Create(
-Context,  // AST context
-Builder.Record->getDeclContext(), // DeclContext
-SourceLocation(), SourceLocation(),
-/*depth=*/0,// Depth in the template parameter list
-/*position=*/0, // Position in the template parameter list
-/*id=*/nullptr, // Identifier for 'T'
-/*Typename=*/true,  // Indicates this is a 'typename' or 
'class'
-/*ParameterPack=*/false,// Not a parameter pack
-/*HasTypeConstraint=*/false // Has no type constraint
-);
-
-T->setDeclContext(DC);
-
-QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
-
-// this is the 2nd template argument node, on which
-// the concept constraint is actually being applied: 'element_type'
-TemplateArgument ConceptTA = TemplateArgument(ConceptTType);
-
-QualType CSETType = Context.getTypeDeclType(T);
-
-// this is the 1st template argument node, which represents
-/

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

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-sles-build-only` running on `rocm-worker-hw-04-sles` while 
building `clang` at step 6 "Add check check-clang".

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


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

```
Step 6 (Add check check-clang) failure: test (failure)
 TEST 'Clang :: 
AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang -cc1 
-internal-isystem 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/lib/clang/20/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
 | 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-check-prefix=EMPTY 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
+ 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-check-prefix=EMPTY 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-cc1 -internal-isystem 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/lib/clang/20/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl:15:16:
 error: EMPTY-NEXT: expected string not found in input
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <> 
 class depth 0 index 0 element_type
   ^
:47:107: note: scanning from here
| `-ClassTemplateDecl 0xc81a9b0 <>  implicit 
RasterizerOrderedStructuredBuffer

  ^
:48:5: note: possible intended match here
| |-TemplateTypeParmDecl 0xc81a910 <>  typename 
depth 0 index 0 element_type
^

Input file: 
Check file: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl

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

Input was:
<<
   .
   .
   .
  42: | | `-FinalAttr 0xc81a0d8 <> Implicit final 
  43: | |-ClassTemplateDecl 0xc81a5c0 <>  
implicit ConsumeStructuredBuffer 
  44: | | |-TemplateTypeParmDecl 0xc81a520 <>  typename depth 0 index 0 element_type 
  45: | | `-CXXRecordDecl 0xc81a420 <>  
implicit  class ConsumeStructuredBuffer 
  46: | | `-FinalAttr 0xc81a4c8 <> Implicit final 
  47: | `-ClassTemplateDecl 0xc81a9b0 <>  
implicit RasterizerOrderedStructuredBuffer 
next:15'0   
X error: no match found
  48: | |-TemplateTypeParmDecl 0xc81a910 <>  typename depth 0 index 0 element_type 
next:15'0 
~
next:15'1 ? 
possible intended match
  49: | `-CXXRecordDecl 0xc81a810 <>  
implicit  class RasterizerOrderedStructuredBuffer 
next:15'0 
~~~
  50: | `-FinalAttr 0xc81a8b8 <> Implicit final 
next:15'0 
  51: |-ConceptDecl 0xc7ef030 <>  
__is_typed_resource_element_compatible 
next:15'0 
~~~
  52: | |-TemplateTypeParmDecl 0xc7eef18 <>  referenced typename depth 0 index 0 element_type 
next:15'0 

  53: | `-BinaryOperator 0xc7ef010 <> 'bool' lvalue '<=' 
next:15'0 ~
   .
   .
...

```



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

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-ve-ninja` running on 
`hpce-ve-main` while building `clang` at step 4 "annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/ve-linux.py ...' (failure)
...
[295/301] Linking CXX executable tools/clang/unittests/Driver/ClangDriverTests
[296/301] Linking CXX executable tools/clang/unittests/CodeGen/ClangCodeGenTests
[297/301] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests
[298/301] Linking CXX executable tools/clang/unittests/Frontend/FrontendTests
[299/301] Linking CXX executable 
tools/clang/unittests/Interpreter/ExceptionTests/ClangReplInterpreterExceptionTests
[300/301] Linking CXX executable 
tools/clang/unittests/Interpreter/ClangReplInterpreterTests
[300/301] Running the Clang regression tests
-- Testing: 21335 tests, 48 workers --
llvm-lit: 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using clang: 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang
Testing: 
FAIL: Clang :: AST/HLSL/ConsumeStructuredBuffer-AST.hlsl (192 of 21335)
 TEST 'Clang :: AST/HLSL/ConsumeStructuredBuffer-AST.hlsl' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang -cc1 
-internal-isystem 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/lib/clang/20/include 
-nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
 | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck 
-check-prefix=EMPTY 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
+ /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/clang -cc1 
-internal-isystem 
/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/lib/clang/20/include 
-nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
+ /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck 
-check-prefix=EMPTY 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl:15:16:
 error: EMPTY-NEXT: expected string not found in input
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <> 
 class depth 0 index 0 element_type
   ^
:43:97: note: scanning from here
| |-ClassTemplateDecl 0x8330f40 <>  implicit 
ConsumeStructuredBuffer

^
:44:7: note: possible intended match here
| | |-TemplateTypeParmDecl 0x8330ea0 <>  typename 
depth 0 index 0 element_type
  ^

Input file: 
Check file: 
/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl

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

Input was:
<<
   .
   .
   .
  38: | | `-FinalAttr 0x832e778 <> Implicit final 
  39: | |-ClassTemplateDecl 0x8330b50 <>  
implicit AppendStructuredBuffer 
  40: | | |-TemplateTypeParmDecl 0x8330ab0 <>  typename depth 0 index 0 element_type 
  41: | | `-CXXRecordDecl 0x83309b0 <>  
implicit  class AppendStructuredBuffer 
  42: | | `-FinalAttr 0x8330a58 <> Implicit final 
  43: | |-ClassTemplateDecl 0x8330f40 <>  
implicit ConsumeStructuredBuffer 
next:15'0   
  X error: no match found
  44: | | |-TemplateTypeParmDecl 0x8330ea0 <>  typename depth 0 index 0 element_type 
next:15'0 
~~~
next:15'1   ?   
  possible intended match
Step 8 (check-llvm) failure: check-llvm (failure)
...
[295/301] Linking CXX executable tools/clang/unittests/Driver/ClangDriverTests
[296/301] Linking CXX executable tools/clang/unittests/CodeGen/ClangCodeGenTests
[297/301] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests
[298/301] Linking CXX executable tools/clang/unittests/Frontend/FrontendTests
[299/301] Linking CXX executable 
tools/clang/unittests/Interpreter/ExceptionTests/ClangReplInterpreterExceptionTests
[300/301] Linking CXX executable 
tools/clang/unittests/Interpreter/Cl

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

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-a-1` while building `clang` at step 4 
"annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[1345/1347] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests
[1346/1347] Running the Clang regression tests
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using clang: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/clang
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/subst.py:126:
 note: Did not find clang-repl in 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin:/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/ld.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using lld-link: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/lld-link
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using ld64.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/ld64.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:506:
 note: using wasm-ld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/wasm-ld
-- Testing: 21511 tests, 60 workers --
Testing: 
FAIL: Clang :: AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl (152 of 
21511)
 TEST 'Clang :: 
AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl' FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/clang -cc1 
-internal-isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/lib/clang/20/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
 | 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/FileCheck 
-check-prefix=EMPTY 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/FileCheck 
-check-prefix=EMPTY 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/bin/clang 
-cc1 -internal-isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-zmj85sc8/lib/clang/20/include
 -nostdsysteminc -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump 
-DEMPTY 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl:15:16:
 error: EMPTY-NEXT: expected string not found in input
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <> 
 class depth 0 index 0 element_type
   ^
:47:112: note: scanning from here
| `-ClassTemplateDecl 0x55d7f80dc0a0 <>  implicit 
RasterizerOrderedStructuredBuffer

   ^
:48:5: note: possible intended match here
| |-TemplateTypeParmDecl 0x55d7f80dc000 <>  
typename depth 0 index 0 element_type
^

Input file: 
Check file: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl

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

Input was:
<<
   .
   .
   .
  42: | | `-FinalAttr 0x55d7f80db7c8 <> Implicit final 
  43: | |-ClassTemplateDecl 0x55d7f80dbcb0 <>  implicit ConsumeStructuredBuffer 
  44: | | |-TemplateTypeParmDecl 0x55d7f80dbc10 <> 
 typename depth 0 index 0 element_type 
  45: | | `-CXXRecordDecl 0x55d7f80dbb10 <>  implicit  class ConsumeStructuredBuffer 
  46: | | `-FinalAttr 0x55d7f80dbbb8 <> Implicit final 
  47: | `-ClassTemplateDecl 0x55d7f80dc0a0 <>  implicit RasterizerOrderedStructuredBuffer 
next:15'0   
 X error: no match found
  48: | |-TemplateTypeParmDecl 0x55d

[clang] [clang][CIR] Fix missing dependency of MLIRCIR (PR #116221)

2024-11-14 Thread Bruno Cardoso Lopes via cfe-commits

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


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


[clang] [Clang][NFC] Refactor `Targets.h` to make it publicly accessible (PR #116090)

2024-11-14 Thread via cfe-commits

https://github.com/seven-mile updated 
https://github.com/llvm/llvm-project/pull/116090

>From 6d769704bd7001e17aee988d9ff12439505abbf4 Mon Sep 17 00:00:00 2001
From: seven-mile 
Date: Wed, 13 Nov 2024 18:10:58 +
Subject: [PATCH] [Clang][NFC] Refactor target info allocation to make it
 publicly accessible

---
 clang/include/clang/Basic/TargetInfo.h |  5 
 clang/lib/Basic/TargetDefines.h| 39 ++
 clang/lib/Basic/Targets.h  | 27 +-
 3 files changed, 45 insertions(+), 26 deletions(-)
 create mode 100644 clang/lib/Basic/TargetDefines.h

diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 2b3552854e1f9b..d4fa4203afbbe9 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1864,6 +1864,11 @@ class TargetInfo : public TransferrableTargetInfo,
   void CheckFixedPointBits() const;
 };
 
+namespace targets {
+std::unique_ptr
+AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts);
+} // namespace targets
+
 }  // end namespace clang
 
 #endif
diff --git a/clang/lib/Basic/TargetDefines.h b/clang/lib/Basic/TargetDefines.h
new file mode 100644
index 00..96fc4fe70fa9d2
--- /dev/null
+++ b/clang/lib/Basic/TargetDefines.h
@@ -0,0 +1,39 @@
+//===--- TargetDefines.h - Target define helpers *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file declares a series of helper functions for defining target-specific
+// macros.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_BASIC_TARGETDEFINES_H
+#define LLVM_CLANG_LIB_BASIC_TARGETDEFINES_H
+
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/MacroBuilder.h"
+#include "llvm/ADT/StringRef.h"
+
+namespace clang {
+namespace targets {
+/// Define a macro name and standard variants.  For example if MacroName is
+/// "unix", then this will define "__unix", "__unix__", and "unix" when in GNU
+/// mode.
+LLVM_LIBRARY_VISIBILITY
+void DefineStd(clang::MacroBuilder &Builder, llvm::StringRef MacroName,
+   const clang::LangOptions &Opts);
+
+LLVM_LIBRARY_VISIBILITY
+void defineCPUMacros(clang::MacroBuilder &Builder, llvm::StringRef CPUName,
+ bool Tuning = true);
+
+LLVM_LIBRARY_VISIBILITY
+void addCygMingDefines(const clang::LangOptions &Opts,
+   clang::MacroBuilder &Builder);
+} // namespace targets
+} // namespace clang
+#endif // LLVM_CLANG_LIB_BASIC_TARGETDEFINES_H
diff --git a/clang/lib/Basic/Targets.h b/clang/lib/Basic/Targets.h
index b4d2486b5d2b13..e1458384fa1c8b 100644
--- a/clang/lib/Basic/Targets.h
+++ b/clang/lib/Basic/Targets.h
@@ -15,32 +15,7 @@
 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_H
 #define LLVM_CLANG_LIB_BASIC_TARGETS_H
 
-#include "clang/Basic/LangOptions.h"
-#include "clang/Basic/MacroBuilder.h"
+#include "TargetDefines.h"
 #include "clang/Basic/TargetInfo.h"
-#include "llvm/ADT/StringRef.h"
 
-namespace clang {
-namespace targets {
-
-LLVM_LIBRARY_VISIBILITY
-std::unique_ptr
-AllocateTarget(const llvm::Triple &Triple, const clang::TargetOptions &Opts);
-
-/// DefineStd - Define a macro name and standard variants.  For example if
-/// MacroName is "unix", then this will define "__unix", "__unix__", and "unix"
-/// when in GNU mode.
-LLVM_LIBRARY_VISIBILITY
-void DefineStd(clang::MacroBuilder &Builder, llvm::StringRef MacroName,
-   const clang::LangOptions &Opts);
-
-LLVM_LIBRARY_VISIBILITY
-void defineCPUMacros(clang::MacroBuilder &Builder, llvm::StringRef CPUName,
- bool Tuning = true);
-
-LLVM_LIBRARY_VISIBILITY
-void addCygMingDefines(const clang::LangOptions &Opts,
-   clang::MacroBuilder &Builder);
-} // namespace targets
-} // namespace clang
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_H

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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

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

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

Thanks. +1 to taking this targeted fix without waiting for a larger refactor.

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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

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


@@ -104,9 +104,12 @@ bool isRootStmt(const Node *N) {
   // Root statement cannot be partially selected.
   if (N->Selected == SelectionTree::Partial)
 return false;
-  // Only DeclStmt can be an unselected RootStmt since VarDecls claim the 
entire
-  // selection range in selectionTree.
-  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get())
+  // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
+  // selection range in selectionTree. Additionally, a CXXOperatorCallExpr of a
+  // binary operation can be unselected because it's children claim the entire
+  // selection range in the selection tree (e.g. <<).
+  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get() 
&&

HighCommander4 wrote:

I guess the difference is that a `DeclStmt` can have a **single** `VarDecl` 
child which could be completely selected, leaving the `DeclStmt` unselected. 
There is no analogous situation for a `CXXOperatorCallExpr` which has multiple 
children.

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


[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-14 Thread Freddy Ye via cfe-commits


@@ -1139,6 +1139,28 @@ def ProcessorFeatures {
   list GNRDFeatures =
 !listconcat(GNRFeatures, GNRDAdditionalFeatures);
 
+  // Diamondrapids

FreddyLeaf wrote:

[52e63a0](https://github.com/llvm/llvm-project/pull/113881/commits/52e63a0f4b48ad106471343f2f48976bd9b84661)

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


[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-14 Thread Freddy Ye via cfe-commits


@@ -600,6 +601,19 @@ static const char 
*getIntelProcessorTypeAndSubtype(unsigned Family,
   break;
 }
 break;
+  case 19:
+switch (Model) {
+// Diamondrapids:
+case 0x01:
+  CPU = "diamondrapids";
+  *Type = INTEL_COREI7;
+  *Subtype = INTEL_COREI7_DIAMONDRAPIDS;
+  break;
+
+default: // Unknown family 0x13 CPU.

FreddyLeaf wrote:

[52e63a0](https://github.com/llvm/llvm-project/pull/113881/commits/52e63a0f4b48ad106471343f2f48976bd9b84661)

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


[clang] [clang][CIR] Fix missing dependency of MLIRCIR (PR #116221)

2024-11-14 Thread Luohao Wang via cfe-commits

Luohaothu wrote:

> Do you need me to merge this for you? Could you also fix the message about 
> private email addresses above?

Thanks. I'll fix it later today.

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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

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

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

>From 04687eb4fcc3cc424580c0a0df8044a8b17286f8 Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Tue, 13 Feb 2024 18:59:16 +0100
Subject: [PATCH 1/6] [clangd] fix extract-to-function for overloaded operators

When selecting code that contains the use of overloaded operators,
the SelectionTree will attribute the operator to the operator
declaration, not to the `CXXOperatorCallExpr`. To allow
extract-to-function to work with these operators, make unselected
`CXXOperatorCallExpr`s valid root statements, just like `DeclStmt`s.

Partially fixes clangd/clangd#1254
---
 .../refactor/tweaks/ExtractFunction.cpp   | 15 +++---
 .../unittests/tweaks/ExtractFunctionTests.cpp | 47 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 ++
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 0302839c58252e..aae480175b33f6 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -56,6 +56,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -70,7 +71,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/raw_os_ostream.h"
 #include 
 
 namespace clang {
@@ -104,9 +104,12 @@ bool isRootStmt(const Node *N) {
   // Root statement cannot be partially selected.
   if (N->Selected == SelectionTree::Partial)
 return false;
-  // Only DeclStmt can be an unselected RootStmt since VarDecls claim the 
entire
-  // selection range in selectionTree.
-  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get())
+  // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
+  // selection range in selectionTree. Additionally, an CXXOperatorCallExpr of 
a
+  // binary operation can be unselected because it's children claim the entire
+  // selection range in the selection tree (e.g. <<).
+  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get() 
&&
+  !N->ASTNode.get())
 return false;
   return true;
 }
@@ -913,8 +916,8 @@ Expected ExtractFunction::apply(const 
Selection &Inputs) {
 
   tooling::Replacements OtherEdit(
   createForwardDeclaration(*ExtractedFunc, SM));
-  if (auto PathAndEdit = Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc),
- OtherEdit))
+  if (auto PathAndEdit =
+  Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc), OtherEdit))
 MultiFileEffect->ApplyEdits.try_emplace(PathAndEdit->first,
 PathAndEdit->second);
   else
diff --git a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
index dec63d454d52c6..8e347b516c6ffe 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -571,6 +571,53 @@ int getNum(bool Superstitious, int Min, int Max) {
   EXPECT_EQ(apply(Before), After);
 }
 
+TEST_F(ExtractFunctionTest, OverloadedOperators) {
+  Context = File;
+  std::string Before = R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+  int main() {
+[[foo(1, 2);
+foo(3, 4);
+stream << 42;
+stream + 42;
+stream | 42;
+foo(1, 2);
+foo(3, 4);]]
+  })cpp";
+  std::string After =
+  R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+  void extracted() {
+foo(1, 2);
+foo(3, 4);
+stream << 42;
+stream + 42;
+stream | 42;
+foo(1, 2);
+foo(3, 4);
+}
+int main() {
+extracted();
+  })cpp";
+  EXPECT_EQ(apply(Before), After);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 442fb7180555ea..157263737149c6 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -78,6 +78,9

[clang] [clang] Handle trivial_abi attribute for Microsoft ABI. (PR #88857)

2024-11-14 Thread Tobias Hieta via cfe-commits

tru wrote:

Yeah. It's still on my list to update the patch to be recursive - but it's been 
a pretty busy period and I haven't gotten around to it yet. 

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


[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

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

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

>From 04687eb4fcc3cc424580c0a0df8044a8b17286f8 Mon Sep 17 00:00:00 2001
From: Julian Schmidt 
Date: Tue, 13 Feb 2024 18:59:16 +0100
Subject: [PATCH 1/5] [clangd] fix extract-to-function for overloaded operators

When selecting code that contains the use of overloaded operators,
the SelectionTree will attribute the operator to the operator
declaration, not to the `CXXOperatorCallExpr`. To allow
extract-to-function to work with these operators, make unselected
`CXXOperatorCallExpr`s valid root statements, just like `DeclStmt`s.

Partially fixes clangd/clangd#1254
---
 .../refactor/tweaks/ExtractFunction.cpp   | 15 +++---
 .../unittests/tweaks/ExtractFunctionTests.cpp | 47 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 ++
 3 files changed, 59 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
index 0302839c58252e..aae480175b33f6 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -56,6 +56,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
@@ -70,7 +71,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
-#include "llvm/Support/raw_os_ostream.h"
 #include 
 
 namespace clang {
@@ -104,9 +104,12 @@ bool isRootStmt(const Node *N) {
   // Root statement cannot be partially selected.
   if (N->Selected == SelectionTree::Partial)
 return false;
-  // Only DeclStmt can be an unselected RootStmt since VarDecls claim the 
entire
-  // selection range in selectionTree.
-  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get())
+  // A DeclStmt can be an unselected RootStmt since VarDecls claim the entire
+  // selection range in selectionTree. Additionally, an CXXOperatorCallExpr of 
a
+  // binary operation can be unselected because it's children claim the entire
+  // selection range in the selection tree (e.g. <<).
+  if (N->Selected == SelectionTree::Unselected && !N->ASTNode.get() 
&&
+  !N->ASTNode.get())
 return false;
   return true;
 }
@@ -913,8 +916,8 @@ Expected ExtractFunction::apply(const 
Selection &Inputs) {
 
   tooling::Replacements OtherEdit(
   createForwardDeclaration(*ExtractedFunc, SM));
-  if (auto PathAndEdit = Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc),
- OtherEdit))
+  if (auto PathAndEdit =
+  Tweak::Effect::fileEdit(SM, SM.getFileID(*FwdLoc), OtherEdit))
 MultiFileEffect->ApplyEdits.try_emplace(PathAndEdit->first,
 PathAndEdit->second);
   else
diff --git a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
index dec63d454d52c6..8e347b516c6ffe 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -571,6 +571,53 @@ int getNum(bool Superstitious, int Min, int Max) {
   EXPECT_EQ(apply(Before), After);
 }
 
+TEST_F(ExtractFunctionTest, OverloadedOperators) {
+  Context = File;
+  std::string Before = R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+  int main() {
+[[foo(1, 2);
+foo(3, 4);
+stream << 42;
+stream + 42;
+stream | 42;
+foo(1, 2);
+foo(3, 4);]]
+  })cpp";
+  std::string After =
+  R"cpp(struct A {
+int operator+(int x) { return x; }
+  };
+  A &operator<<(A &, int);
+  A &operator|(A &, int);
+
+  A stream{};
+
+  void foo(int, int);
+
+  void extracted() {
+foo(1, 2);
+foo(3, 4);
+stream << 42;
+stream + 42;
+stream | 42;
+foo(1, 2);
+foo(3, 4);
+}
+int main() {
+extracted();
+  })cpp";
+  EXPECT_EQ(apply(Before), After);
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 442fb7180555ea..157263737149c6 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -78,6 +78,9

[clang-tools-extra] [clangd] fix extract-to-function for overloaded operators (PR #81640)

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

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


  1   2   3   4   >