[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2023-04-04 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

I rebased the patch and regenerated the clang tests. I haven't regenerated the 
llvm tests. @jhuber6 @jdoerfert Please help regenerate the llvm tests. Several 
of the failing clang tests were regenerated earlier, they can perhaps be 
regenerated after the llvm tests are regenerated.

Here are the test results. check-openmp on amdgpu passes.

  Failed Tests (13):
Clang :: AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
Clang :: AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
Clang :: AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
Clang :: AST/ast-dump-openmp-teams-distribute-parallel-for.c
Clang :: CodeGen/PowerPC/ppc64le-varargs-f128.c
Clang :: Headers/amdgcn-openmp-device-math-complex.c
Clang :: Headers/amdgcn-openmp-device-math-complex.cpp
Clang :: Headers/amdgcn_openmp_device_math.c
Clang :: Headers/openmp_device_math_isnan.cpp
Clang :: OpenMP/nvptx_lambda_pointer_capturing.cpp
Clang :: OpenMP/parallel_copyin_combined_codegen.c
Clang :: OpenMP/target_globals_codegen.cpp
Clang :: OpenMP/unroll_codegen_parallel_for_factor.cpp
  
  Failed Tests (14):
LLVM :: Transforms/OpenMP/custom_state_machines.ll
LLVM :: Transforms/OpenMP/custom_state_machines_remarks.ll
LLVM :: Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
LLVM :: Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
LLVM :: Transforms/OpenMP/is_spmd_exec_mode_fold.ll
LLVM :: Transforms/OpenMP/nested_parallelism.ll
LLVM :: Transforms/OpenMP/parallel_level_fold.ll
LLVM :: Transforms/OpenMP/spmdization.ll
LLVM :: Transforms/OpenMP/spmdization_assumes.ll
LLVM :: Transforms/OpenMP/spmdization_constant_prop.ll
LLVM :: Transforms/OpenMP/spmdization_guarding.ll
LLVM :: Transforms/OpenMP/spmdization_guarding_two_reaching_kernels.ll
LLVM :: Transforms/OpenMP/spmdization_no_guarding_two_reaching_kernels.ll
LLVM :: Transforms/OpenMP/spmdization_remarks.ll


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102107/new/

https://reviews.llvm.org/D102107

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


[clang] 745a957 - [clang][dataflow] Add `create()` methods to `Environment` and `DataflowAnalysisContext`.

2023-04-04 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-04-04T07:13:44Z
New Revision: 745a957f9dc562477cbe587fb3fa8305713b51b3

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

LOG: [clang][dataflow] Add `create()` methods to `Environment` and 
`DataflowAnalysisContext`.

These methods provide a less verbose way of allocating `StorageLocation`s and
`Value`s than the existing `takeOwnership(make_unique(...))` pattern.

In addition, because allocation of `StorageLocation`s and `Value`s now happens
within the `DataflowAnalysisContext`, the `create()` open up the possibility
of using `BumpPtrAllocator` to allocate these objects if it turns out this
helps performance.

Reviewed By: ymandel, xazax.hun, gribozavr2

Differential Revision: https://reviews.llvm.org/D147302

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Removed: 




diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
index a044f477ce1b..31bd9809a72a 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -86,14 +86,51 @@ class DataflowAnalysisContext {
   /*Logger=*/nullptr});
   ~DataflowAnalysisContext();
 
+  /// Creates a `T` (some subclass of `StorageLocation`), forwarding `args` to
+  /// the constructor, and returns a reference to it.
+  ///
+  /// The `DataflowAnalysisContext` takes ownership of the created object. The
+  /// object will be destroyed when the `DataflowAnalysisContext` is destroyed.
+  template 
+  std::enable_if_t::value, T &>
+  create(Args &&...args) {
+// Note: If allocation of individual `StorageLocation`s turns out to be
+// costly, consider creating specializations of `create` for commonly
+// used `StorageLocation` subclasses and make them use a 
`BumpPtrAllocator`.
+return *cast(
+Locs.emplace_back(std::make_unique(std::forward(args)...))
+.get());
+  }
+
+  /// Creates a `T` (some subclass of `Value`), forwarding `args` to the
+  /// constructor, and returns a reference to it.
+  ///
+  /// The `DataflowAnalysisContext` takes ownership of the created object. The
+  /// object will be destroyed when the `DataflowAnalysisContext` is destroyed.
+  template 
+  std::enable_if_t::value, T &>
+  create(Args &&...args) {
+// Note: If allocation of individual `Value`s turns out to be costly,
+// consider creating specializations of `create` for commonly used
+// `Value` subclasses and make them use a `BumpPtrAllocator`.
+return *cast(
+Vals.emplace_back(std::make_unique(std::forward(args)...))
+.get());
+  }
+
   /// Takes ownership of `Loc` and returns a reference to it.
   ///
+  /// This function is deprecated. Instead of
+  /// `takeOwnership(std::make_unique(args))`, prefer
+  /// `create(args)`.
+  ///
   /// Requirements:
   ///
   ///  `Loc` must not be null.
   template 
-  std::enable_if_t::value, T &>
-  takeOwnership(std::unique_ptr Loc) {
+  LLVM_DEPRECATED("use create instead", "")
+  std::enable_if_t::value,
+   T &> takeOwnership(std::unique_ptr Loc) {
 assert(Loc != nullptr);
 Locs.push_back(std::move(Loc));
 return *cast(Locs.back().get());
@@ -101,12 +138,17 @@ class DataflowAnalysisContext {
 
   /// Takes ownership of `Val` and returns a reference to it.
   ///
+  /// This function is deprecated. Instead of
+  /// `takeOwnership(std::make_unique(args))`, prefer
+  /// `create(args)`.
+  ///
   /// Requirements:
   ///
   ///  `Val` must not be null.
   template 
-  std::enable_if_t::value, T &>
-  takeOwnership(std::unique_ptr Val) {
+  LLVM_DEPRECATED("use create instead", "")
+  std::enable_if_t::value, T &> takeOwnership(
+  std::unique_ptr Val) {
 assert(Val != nullptr);
 Vals.push_back(std::move(Val));
 return *cast(Vals.back().get());
@@ -170,9 +212,9 @@ class DataflowAnalysisContext {
   }
 
   /// Creates an atomic boolean value.
-  AtomicBoolValue &createAtomicBoolValue() {
-return takeOwnership(std::make_unique());
-  }
+  LLVM_DEPRECATED("use create instead",
+  "create")
+  AtomicBoolValue &createAtomicBoolValue() { return create(); 
}
 
   /// Creates a Top value for booleans. Each instance i

[PATCH] D147302: [clang][dataflow] Add `create()` methods to `Environment` and `DataflowAnalysisContext`.

2023-04-04 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
mboehme marked an inline comment as done.
Closed by commit rG745a957f9dc5: [clang][dataflow] Add `create()` 
methods to `Environment` and… (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147302/new/

https://reviews.llvm.org/D147302

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -312,8 +312,7 @@
 
   if (Member->getType()->isReferenceType()) {
 auto &MemberLoc = ThisLoc.getChild(*Member);
-Env.setValue(MemberLoc, Env.takeOwnership(std::make_unique(
-*InitStmtLoc)));
+Env.setValue(MemberLoc, Env.create(*InitStmtLoc));
   } else {
 auto &MemberLoc = ThisLoc.getChild(*Member);
 Env.setValue(MemberLoc, *InitStmtVal);
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -237,7 +237,7 @@
   Env.setStorageLocation(*S, *DeclLoc);
 } else {
   auto &Loc = Env.createStorageLocation(*S);
-  auto &Val = Env.takeOwnership(std::make_unique(*DeclLoc));
+  auto &Val = Env.create(*DeclLoc);
   Env.setStorageLocation(*S, Loc);
   Env.setValue(Loc, Val);
 }
@@ -276,8 +276,7 @@
   // FIXME: reuse the ReferenceValue instead of creating a new one.
   if (auto *InitExprLoc =
   Env.getStorageLocation(*InitExpr, SkipPast::Reference)) {
-auto &Val =
-Env.takeOwnership(std::make_unique(*InitExprLoc));
+auto &Val = Env.create(*InitExprLoc);
 Env.setValue(Loc, Val);
   }
 } else if (auto *InitExprVal = Env.getValue(*InitExpr, SkipPast::None)) {
@@ -423,8 +422,8 @@
 
   auto &Loc = Env.createStorageLocation(*S);
   Env.setStorageLocation(*S, Loc);
-  Env.setValue(Loc, Env.takeOwnership(std::make_unique(
-SubExprVal->getPointeeLoc(;
+  Env.setValue(Loc,
+   Env.create(SubExprVal->getPointeeLoc()));
   break;
 }
 case UO_AddrOf: {
@@ -437,8 +436,7 @@
 break;
 
   auto &PointerLoc = Env.createStorageLocation(*S);
-  auto &PointerVal =
-  Env.takeOwnership(std::make_unique(*PointeeLoc));
+  auto &PointerVal = Env.create(*PointeeLoc);
   Env.setStorageLocation(*S, PointerLoc);
   Env.setValue(PointerLoc, PointerVal);
   break;
@@ -468,8 +466,7 @@
 
 auto &Loc = Env.createStorageLocation(*S);
 Env.setStorageLocation(*S, Loc);
-Env.setValue(Loc, Env.takeOwnership(
-  std::make_unique(*ThisPointeeLoc)));
+Env.setValue(Loc, Env.create(*ThisPointeeLoc));
   }
 
   void VisitReturnStmt(const ReturnStmt *S) {
@@ -523,8 +520,7 @@
 } else {
   auto &Loc = Env.createStorageLocation(*S);
   Env.setStorageLocation(*S, Loc);
-  Env.setValue(Loc, Env.takeOwnership(
-std::make_unique(*VarDeclLoc)));
+  Env.setValue(Loc, Env.create(*VarDeclLoc));
 }
 return;
   }
@@ -558,8 +554,7 @@
 } else {
   auto &Loc = Env.createStorageLocation(*S);
   Env.setStorageLocation(*S, Loc);
-  Env.setValue(
-  Loc, Env.takeOwnership(std::make_unique(MemberLoc)));
+  Env.setValue(Loc, Env.create(MemberLoc));
 }
   }
 
Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -221,9 +221,9 @@
 /// Creates a symbolic value for an `optional` value using `HasValueVal` as the
 /// symbolic value of its "has_value" property.
 StructValue &createOptionalValue(Environment &Env, BoolValue &HasValueVal) {
-  auto OptionalVal = std::make_unique();
-  setHasValue(*OptionalVal, HasValueVal);
-  return Env.takeOwnership(std::move(OptionalVal));
+  auto &OptionalVal = Env.create();
+  setHasValue(OptionalVal, HasValueVal);
+  return OptionalVal;
 }
 
 /// Returns the symbolic value that represents the "has_value" property of the
@@ -312,8 +

[clang-tools-extra] 3afe3db - [clang-tidy] Fix readability-static-accessed-through-instance check for anonymous structs

2023-04-04 Thread Piotr Zegar via cfe-commits

Author: AMS21
Date: 2023-04-04T07:20:25Z
New Revision: 3afe3dbfa0157608aa1d058f6be28e0060aaf9c6

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

LOG: [clang-tidy] Fix readability-static-accessed-through-instance check for 
anonymous structs

Previously we would provide a fixit which looked like
this `unnamed struct at ...::f()` but which is obviously
not valid C/C++.

Since there is no real nice way to accesses a static function
from an anonymous struct anyways we simply ignore all
anonymous structs.

Fixes llvm#61736

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D147411

Added: 


Modified: 

clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
index 4bb14850d602..619374cddbcf 100644
--- 
a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -59,7 +59,7 @@ void StaticAccessedThroughInstanceCheck::check(
   if (isa(BaseExpr))
 return;
 
-  QualType BaseType =
+  const QualType BaseType =
   BaseExpr->getType()->isPointerType()
   ? BaseExpr->getType()->getPointeeType().getUnqualifiedType()
   : BaseExpr->getType().getUnqualifiedType();
@@ -75,6 +75,11 @@ void StaticAccessedThroughInstanceCheck::check(
   std::string BaseTypeName =
   BaseType.getAsString(PrintingPolicyWithSuppressedTag);
 
+  // Ignore anonymous structs/classes which will not have an identifier
+  const RecordDecl *RecDecl = BaseType->getAsCXXRecordDecl();
+  if (!RecDecl || RecDecl->getIdentifier() == nullptr)
+return;
+
   // Do not warn for CUDA built-in variables.
   if (StringRef(BaseTypeName).startswith("__cuda_builtin_"))
 return;

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 13a06efcf563..573609be539a 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -255,8 +255,9 @@ Changes in existing checks
   be unnecessarily emitted for template dependent ``if constexpr``.
 
 - Improved :doc:`readability-static-accessed-through-instance
-  ` check to 
-  support unscoped enumerations through instances.
+  ` check to
+  support unscoped enumerations through instances and fixed usage of anonymous
+  structs or classes.
 
 - Fixed a false positive in :doc:`cppcoreguidelines-slicing
   ` check when warning would be

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
index 6d4a03421913..9e8930084a65 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
@@ -306,3 +306,60 @@ unsigned int x4 = gridDim.x;
 // CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
 
 } // namespace Bugzilla_48758
+
+// https://github.com/llvm/llvm-project/issues/61736
+namespace llvm_issue_61736
+{
+
+struct {
+  static void f() {}
+} AnonStruct, *AnonStructPointer;
+
+class {
+  public:
+  static void f() {}
+} AnonClass, *AnonClassPointer;
+
+void testAnonymousStructAndClass() {
+  AnonStruct.f();
+  AnonStructPointer->f();
+
+  AnonClass.f();
+  AnonClassPointer->f();
+}
+
+struct Embedded {
+  struct {
+static void f() {}
+  } static EmbeddedStruct, *EmbeddedStructPointer;
+
+  class {
+public:
+  static void f() {}
+  } static EmbeddedClass, *EmbeddedClassPointer;
+};
+
+void testEmbeddedAnonymousStructAndClass() {
+  Embedded::EmbeddedStruct.f();
+  Embedded::EmbeddedStructPointer->f();
+
+  Embedded::EmbeddedClass.f();
+  Embedded::EmbeddedClassPointer->f();
+
+  Embedded E;
+  E.EmbeddedStruct.f();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through 
instance [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  llvm_issue_61736::Embedded::EmbeddedStruct.f();{{$}}
+  E.EmbeddedStructPointer->f();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through 
instance [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  
llvm_issue_61736::Embedded::EmbeddedStructPointer->f();{{$}}
+
+  E.EmbeddedClass.f();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through 
instance [readabi

[clang-tools-extra] 25956d5 - [clang-tidy] Allow bugprone-unchecked-optional-access to handle calls to `std::forward`

2023-04-04 Thread Piotr Zegar via cfe-commits

Author: AMS21
Date: 2023-04-04T07:20:25Z
New Revision: 25956d55d02489964428ab5f55e609ff16c6632d

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

LOG: [clang-tidy] Allow bugprone-unchecked-optional-access to handle calls to 
`std::forward`

The check now understands that calling `std::forward`
will not modify the underlying optional value.

This fixes llvm#59705

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D147383

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 573609be539a..8e57424ae815 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -175,6 +175,10 @@ Changes in existing checks
   ` check.
   Global options of the same name should be used instead.
 
+- Improved :doc:`bugprone-unchecked-optional-access
+  ` check to properly 
handle calls
+  to ``std::forward``.
+
 - Improved :doc:`bugprone-use-after-move
   ` check to also cover constructor
   initializers.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
index 6c79dad93e90..c1e731f41171 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
@@ -110,3 +110,50 @@ class C4 {
   }
   int foo_;
 };
+
+// llvm#59705
+namespace std
+{
+  template 
+  constexpr T&& forward(T& type) noexcept {
+return static_cast(type);
+  }
+
+  template 
+  constexpr T&& forward(T&& type) noexcept {
+return static_cast(type);
+  }
+}
+
+void std_forward_copy(absl::optional opt) {
+  std::forward>(opt).value();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: unchecked access to optional
+}
+
+void std_forward_copy_safe(absl::optional opt) {
+  if (!opt) return;
+
+  std::forward>(opt).value();
+}
+
+void std_forward_copy(absl::optional& opt) {
+  std::forward>(opt).value();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: unchecked access to optional
+}
+
+void std_forward_lvalue_ref_safe(absl::optional& opt) {
+  if (!opt) return;
+
+  std::forward>(opt).value();
+}
+
+void std_forward_copy(absl::optional&& opt) {
+  std::forward>(opt).value();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: unchecked access to optional
+}
+
+void std_forward_rvalue_ref_safe(absl::optional&& opt) {
+  if (!opt) return;
+
+  std::forward>(opt).value();
+}

diff  --git 
a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp 
b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
index a91ec5d6ad9c..1512023383a6 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -96,7 +96,6 @@ auto hasAnyOptionalType() {
   recordType(hasDeclaration(anyOf(nulloptTypeDecl(), optionalClass());
 }
 
-
 auto inPlaceClass() {
   return recordDecl(
   hasAnyName("std::in_place_t", "absl::in_place_t", "base::in_place_t"));
@@ -149,6 +148,11 @@ auto isStdSwapCall() {
   hasArgument(1, hasOptionalType()));
 }
 
+auto isStdForwardCall() {
+  return callExpr(callee(functionDecl(hasName("std::forward"))),
+  argumentCountIs(1), hasArgument(0, hasOptionalType()));
+}
+
 constexpr llvm::StringLiteral ValueOrCallID = "ValueOrCall";
 
 auto isValueOrStringEmptyCall() {
@@ -571,6 +575,31 @@ void transferStdSwapCall(const CallExpr *E, const 
MatchFinder::MatchResult &,
   transferSwap(*E->getArg(0), SkipPast::Reference, *E->getArg(1), State.Env);
 }
 
+void transferStdForwardCall(const CallExpr *E, const MatchFinder::MatchResult 
&,
+LatticeTransferState &State) {
+  assert(E->getNumArgs() == 1);
+
+  StorageLocation *LocRet = State.Env.getStorageLocation(*E, SkipPast::None);
+  if (LocRet != nullptr)
+return;
+
+  StorageLocation *LocArg =
+  State.Env.getStorageLocation(*E->getArg(0), SkipPast::Reference);
+
+  if (LocArg == nullptr)
+return;
+
+  Value *ValArg = State.Env.getValue(*LocArg);
+  if (ValArg == nullptr)
+ValArg = &createOptionalValue(State.Env, State.Env.makeAtomicBoolValue());
+
+  // Create a new storage location
+  LocRet = &State.Env.createStorageLocation(*E);
+  State.Env.setStorageLocation(*E, *LocRet);
+
+  State.Env.setValue(*LocRet, *ValArg);
+}
+
 BoolValue &evaluateEquality(Environment &Env, BoolValue &

[PATCH] D147411: [clang-tidy] Fix readability-static-accessed-through-instance check for anonymous structs

2023-04-04 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3afe3dbfa015: [clang-tidy] Fix 
readability-static-accessed-through-instance check for… (authored by AMS21, 
committed by PiotrZSL).

Changed prior to commit:
  https://reviews.llvm.org/D147411?vs=510537&id=510713#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147411/new/

https://reviews.llvm.org/D147411

Files:
  
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/static-accessed-through-instance.cpp
@@ -306,3 +306,60 @@
 // CHECK-MESSAGES-NOT: :[[@LINE-1]]:10: warning: static member
 
 } // namespace Bugzilla_48758
+
+// https://github.com/llvm/llvm-project/issues/61736
+namespace llvm_issue_61736
+{
+
+struct {
+  static void f() {}
+} AnonStruct, *AnonStructPointer;
+
+class {
+  public:
+  static void f() {}
+} AnonClass, *AnonClassPointer;
+
+void testAnonymousStructAndClass() {
+  AnonStruct.f();
+  AnonStructPointer->f();
+
+  AnonClass.f();
+  AnonClassPointer->f();
+}
+
+struct Embedded {
+  struct {
+static void f() {}
+  } static EmbeddedStruct, *EmbeddedStructPointer;
+
+  class {
+public:
+  static void f() {}
+  } static EmbeddedClass, *EmbeddedClassPointer;
+};
+
+void testEmbeddedAnonymousStructAndClass() {
+  Embedded::EmbeddedStruct.f();
+  Embedded::EmbeddedStructPointer->f();
+
+  Embedded::EmbeddedClass.f();
+  Embedded::EmbeddedClassPointer->f();
+
+  Embedded E;
+  E.EmbeddedStruct.f();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through instance [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  llvm_issue_61736::Embedded::EmbeddedStruct.f();{{$}}
+  E.EmbeddedStructPointer->f();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through instance [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  llvm_issue_61736::Embedded::EmbeddedStructPointer->f();{{$}}
+
+  E.EmbeddedClass.f();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through instance [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  llvm_issue_61736::Embedded::EmbeddedClass.f();{{$}}
+  E.EmbeddedClassPointer->f();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through instance [readability-static-accessed-through-instance]
+  // CHECK-FIXES: {{^}}  llvm_issue_61736::Embedded::EmbeddedClassPointer->f();{{$}}
+}
+
+} // namespace llvm_issue_61736
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -255,8 +255,9 @@
   be unnecessarily emitted for template dependent ``if constexpr``.
 
 - Improved :doc:`readability-static-accessed-through-instance
-  ` check to 
-  support unscoped enumerations through instances.
+  ` check to
+  support unscoped enumerations through instances and fixed usage of anonymous
+  structs or classes.
 
 - Fixed a false positive in :doc:`cppcoreguidelines-slicing
   ` check when warning would be
Index: clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -59,7 +59,7 @@
   if (isa(BaseExpr))
 return;
 
-  QualType BaseType =
+  const QualType BaseType =
   BaseExpr->getType()->isPointerType()
   ? BaseExpr->getType()->getPointeeType().getUnqualifiedType()
   : BaseExpr->getType().getUnqualifiedType();
@@ -75,6 +75,11 @@
   std::string BaseTypeName =
   BaseType.getAsString(PrintingPolicyWithSuppressedTag);
 
+  // Ignore anonymous structs/classes which will not have an identifier
+  const RecordDecl *RecDecl = BaseType->getAsCXXRecordDecl();
+  if (!RecDecl || RecDecl->getIdentifier() == nullptr)
+return;
+
   // Do not warn for CUDA built-in variables.
   if (StringRef(BaseTypeName).startswith("__cuda_builtin_"))
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] e588ef8 - [clang-tidy] Small refactor for ExceptionAnalyzer

2023-04-04 Thread Piotr Zegar via cfe-commits

Author: AMS21
Date: 2023-04-04T07:20:26Z
New Revision: e588ef8a7a531380836e17242c2c2276559df0b9

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

LOG: [clang-tidy] Small refactor for ExceptionAnalyzer

- Use llvm::DenseMap<> with pre-allocation instead of std::map<> for 
FunctionCache
- Avoid double lookup for FunctionCache
- Use try_emplace instead of insert
- Simplify definition of State enum

Reviewed By: PiotrZSL

Differential Revision: https://reviews.llvm.org/D147376

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index c8d165e83045..c862303706cc 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -537,7 +537,8 @@ ExceptionAnalyzer::analyzeImpl(const FunctionDecl *Func) {
   ExceptionInfo ExceptionList;
 
   // Check if the function has already been analyzed and reuse that result.
-  if (FunctionCache.count(Func) == 0) {
+  const auto CacheEntry = FunctionCache.find(Func);
+  if (CacheEntry == FunctionCache.end()) {
 llvm::SmallSet CallStack;
 ExceptionList = throwsException(Func, CallStack);
 
@@ -545,9 +546,9 @@ ExceptionAnalyzer::analyzeImpl(const FunctionDecl *Func) {
 // because it is best to keep as much information as possible.
 // The results here might be relevant to 
diff erent analysis passes
 // with 
diff erent needs as well.
-FunctionCache.insert(std::make_pair(Func, ExceptionList));
+FunctionCache.try_emplace(Func, ExceptionList);
   } else
-ExceptionList = FunctionCache[Func];
+ExceptionList = CacheEntry->getSecond();
 
   return ExceptionList;
 }
@@ -579,8 +580,7 @@ ExceptionAnalyzer::analyze(const FunctionDecl *Func) {
   return analyzeDispatch(Func);
 }
 
-ExceptionAnalyzer::ExceptionInfo
-ExceptionAnalyzer::analyze(const Stmt *Stmt) {
+ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::analyze(const Stmt *Stmt) {
   return analyzeDispatch(Stmt);
 }
 

diff  --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h 
b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
index fd65284d570a..a40149ac98d8 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
@@ -21,11 +21,11 @@ namespace clang::tidy::utils {
 /// custom exception types.
 class ExceptionAnalyzer {
 public:
-  enum class State : std::int8_t {
-Throwing = 0,///< The function can definitely throw given an AST.
-NotThrowing = 1, ///< This function can not throw, given an AST.
-Unknown = 2, ///< This can happen for extern functions without 
available
- ///< definition.
+  enum class State {
+Throwing,///< The function can definitely throw given an AST.
+NotThrowing, ///< This function can not throw, given an AST.
+Unknown, ///< This can happen for extern functions without available
+ ///< definition.
   };
 
   /// Bundle the gathered information about an entity like a function regarding
@@ -144,7 +144,7 @@ class ExceptionAnalyzer {
 
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
-  std::map FunctionCache;
+  llvm::DenseMap FunctionCache{32u};
 };
 
 } // namespace clang::tidy::utils



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


[PATCH] D147383: [clang-tidy] Allow bugprone-unchecked-optional-access to handle calls to `std::forward`

2023-04-04 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG25956d55d024: [clang-tidy] Allow 
bugprone-unchecked-optional-access to handle calls to `std… (authored by AMS21, 
committed by PiotrZSL).

Changed prior to commit:
  https://reviews.llvm.org/D147383?vs=510698&id=510714#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147383/new/

https://reviews.llvm.org/D147383

Files:
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -96,7 +96,6 @@
   recordType(hasDeclaration(anyOf(nulloptTypeDecl(), optionalClass());
 }
 
-
 auto inPlaceClass() {
   return recordDecl(
   hasAnyName("std::in_place_t", "absl::in_place_t", "base::in_place_t"));
@@ -149,6 +148,11 @@
   hasArgument(1, hasOptionalType()));
 }
 
+auto isStdForwardCall() {
+  return callExpr(callee(functionDecl(hasName("std::forward"))),
+  argumentCountIs(1), hasArgument(0, hasOptionalType()));
+}
+
 constexpr llvm::StringLiteral ValueOrCallID = "ValueOrCall";
 
 auto isValueOrStringEmptyCall() {
@@ -571,6 +575,31 @@
   transferSwap(*E->getArg(0), SkipPast::Reference, *E->getArg(1), State.Env);
 }
 
+void transferStdForwardCall(const CallExpr *E, const MatchFinder::MatchResult &,
+LatticeTransferState &State) {
+  assert(E->getNumArgs() == 1);
+
+  StorageLocation *LocRet = State.Env.getStorageLocation(*E, SkipPast::None);
+  if (LocRet != nullptr)
+return;
+
+  StorageLocation *LocArg =
+  State.Env.getStorageLocation(*E->getArg(0), SkipPast::Reference);
+
+  if (LocArg == nullptr)
+return;
+
+  Value *ValArg = State.Env.getValue(*LocArg);
+  if (ValArg == nullptr)
+ValArg = &createOptionalValue(State.Env, State.Env.makeAtomicBoolValue());
+
+  // Create a new storage location
+  LocRet = &State.Env.createStorageLocation(*E);
+  State.Env.setStorageLocation(*E, *LocRet);
+
+  State.Env.setValue(*LocRet, *ValArg);
+}
+
 BoolValue &evaluateEquality(Environment &Env, BoolValue &EqVal, BoolValue &LHS,
 BoolValue &RHS) {
   // Logically, an optional object is composed of two values - a `has_value`
@@ -686,7 +715,6 @@
   .CaseOfCFGStmt(isOptionalValueOrConversionConstructor(),
transferValueOrConversionConstructor)
 
-
   // optional::operator=
   .CaseOfCFGStmt(
   isOptionalValueOrConversionAssignment(),
@@ -745,6 +773,9 @@
   // std::swap
   .CaseOfCFGStmt(isStdSwapCall(), transferStdSwapCall)
 
+  // std::forward
+  .CaseOfCFGStmt(isStdForwardCall(), transferStdForwardCall)
+
   // opt.value_or("").empty()
   .CaseOfCFGStmt(isValueOrStringEmptyCall(),
transferValueOrStringEmptyCall)
@@ -845,10 +876,12 @@
 return ComparisonResult::Unknown;
   bool MustNonEmpty1 = isNonEmptyOptional(Val1, Env1);
   bool MustNonEmpty2 = isNonEmptyOptional(Val2, Env2);
-  if (MustNonEmpty1 && MustNonEmpty2) return ComparisonResult::Same;
+  if (MustNonEmpty1 && MustNonEmpty2)
+return ComparisonResult::Same;
   // If exactly one is true, then they're different, no reason to check whether
   // they're definitely empty.
-  if (MustNonEmpty1 || MustNonEmpty2) return ComparisonResult::Different;
+  if (MustNonEmpty1 || MustNonEmpty2)
+return ComparisonResult::Different;
   // Check if they're both definitely empty.
   return (isEmptyOptional(Val1, Env1) && isEmptyOptional(Val2, Env2))
  ? ComparisonResult::Same
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/unchecked-optional-access.cpp
@@ -110,3 +110,50 @@
   }
   int foo_;
 };
+
+// llvm#59705
+namespace std
+{
+  template 
+  constexpr T&& forward(T& type) noexcept {
+return static_cast(type);
+  }
+
+  template 
+  constexpr T&& forward(T&& type) noexcept {
+return static_cast(type);
+  }
+}
+
+void std_forward_copy(absl::optional opt) {
+  std::forward>(opt).value();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: unchecked access to optional
+}
+
+void std_forward_copy_safe(absl::optional opt) {
+  if (!opt) return;
+
+  std::forward>(opt).value();
+}
+
+void std_forward_copy(absl::optional& opt) {
+  std::forward>(opt).value();
+  //

[PATCH] D147376: [clang-tidy] Small refactor for ExceptionAnalyzer

2023-04-04 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe588ef8a7a53: [clang-tidy] Small refactor for 
ExceptionAnalyzer (authored by AMS21, committed by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147376/new/

https://reviews.llvm.org/D147376

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h


Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
@@ -21,11 +21,11 @@
 /// custom exception types.
 class ExceptionAnalyzer {
 public:
-  enum class State : std::int8_t {
-Throwing = 0,///< The function can definitely throw given an AST.
-NotThrowing = 1, ///< This function can not throw, given an AST.
-Unknown = 2, ///< This can happen for extern functions without 
available
- ///< definition.
+  enum class State {
+Throwing,///< The function can definitely throw given an AST.
+NotThrowing, ///< This function can not throw, given an AST.
+Unknown, ///< This can happen for extern functions without available
+ ///< definition.
   };
 
   /// Bundle the gathered information about an entity like a function regarding
@@ -144,7 +144,7 @@
 
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
-  std::map FunctionCache;
+  llvm::DenseMap FunctionCache{32u};
 };
 
 } // namespace clang::tidy::utils
Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -537,7 +537,8 @@
   ExceptionInfo ExceptionList;
 
   // Check if the function has already been analyzed and reuse that result.
-  if (FunctionCache.count(Func) == 0) {
+  const auto CacheEntry = FunctionCache.find(Func);
+  if (CacheEntry == FunctionCache.end()) {
 llvm::SmallSet CallStack;
 ExceptionList = throwsException(Func, CallStack);
 
@@ -545,9 +546,9 @@
 // because it is best to keep as much information as possible.
 // The results here might be relevant to different analysis passes
 // with different needs as well.
-FunctionCache.insert(std::make_pair(Func, ExceptionList));
+FunctionCache.try_emplace(Func, ExceptionList);
   } else
-ExceptionList = FunctionCache[Func];
+ExceptionList = CacheEntry->getSecond();
 
   return ExceptionList;
 }
@@ -579,8 +580,7 @@
   return analyzeDispatch(Func);
 }
 
-ExceptionAnalyzer::ExceptionInfo
-ExceptionAnalyzer::analyze(const Stmt *Stmt) {
+ExceptionAnalyzer::ExceptionInfo ExceptionAnalyzer::analyze(const Stmt *Stmt) {
   return analyzeDispatch(Stmt);
 }
 


Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.h
@@ -21,11 +21,11 @@
 /// custom exception types.
 class ExceptionAnalyzer {
 public:
-  enum class State : std::int8_t {
-Throwing = 0,///< The function can definitely throw given an AST.
-NotThrowing = 1, ///< This function can not throw, given an AST.
-Unknown = 2, ///< This can happen for extern functions without available
- ///< definition.
+  enum class State {
+Throwing,///< The function can definitely throw given an AST.
+NotThrowing, ///< This function can not throw, given an AST.
+Unknown, ///< This can happen for extern functions without available
+ ///< definition.
   };
 
   /// Bundle the gathered information about an entity like a function regarding
@@ -144,7 +144,7 @@
 
   bool IgnoreBadAlloc = true;
   llvm::StringSet<> IgnoredExceptions;
-  std::map FunctionCache;
+  llvm::DenseMap FunctionCache{32u};
 };
 
 } // namespace clang::tidy::utils
Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -537,7 +537,8 @@
   ExceptionInfo ExceptionList;
 
   // Check if the function has already been analyzed and reuse that result.
-  if (FunctionCache.count(Func) == 0) {
+  const auto CacheEntry = FunctionCache.find(Func);
+  if (CacheEntry == FunctionCache.end()) {
 llvm::SmallSet CallStack;
 ExceptionList = throwsException(Func, CallStack);
 
@@ -545,9 +546,9 @@
 // because it is best to keep as much information as possible.
 // The results here might be relevant to different analysis passes
 // with different needs as well.
-FunctionCac

[PATCH] D144943: [clang][Interp] Implement bitcasts (WIP)

2023-04-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144943/new/

https://reviews.llvm.org/D144943

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


[PATCH] D146030: [clang][Interp] Handle LambdaExprs

2023-04-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146030/new/

https://reviews.llvm.org/D146030

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


[PATCH] D144457: [clang][Interp] Handle global composite temporaries

2023-04-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144457/new/

https://reviews.llvm.org/D144457

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


[PATCH] D144164: [clang][Interp] Handle PtrMemOps

2023-04-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144164/new/

https://reviews.llvm.org/D144164

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


[PATCH] D143334: [clang][Interp] Fix diagnosing uninitialized ctor record arrays

2023-04-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143334/new/

https://reviews.llvm.org/D143334

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


[PATCH] D147461: [Headers] Add some intrinsic function descriptions to immintrin.h

2023-04-04 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for working on it!




Comment at: clang/lib/Headers/immintrin.h:294
+/// \param __p
+///Pointer to a 16-bit location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.

memory location



Comment at: clang/lib/Headers/immintrin.h:294
+/// \param __p
+///Pointer to a 16-bit location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.

pengfei wrote:
> memory location
Nit: I saw others prefer to `A pointer`



Comment at: clang/lib/Headers/immintrin.h:309
+/// \param __p
+///Pointer to a 32-bit location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.

ditto.



Comment at: clang/lib/Headers/immintrin.h:324
+/// \param __p
+///Pointer to a 64-bit location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.

ditto.



Comment at: clang/lib/Headers/immintrin.h:414
+/// \param __V
+///Value to use for the lower 32 bits of the FS base register.
 static __inline__ void __attribute__((__always_inline__, __nodebug__, 
__target__("fsgsbase")))

Nit: I saw others prefer to `A 32-bit integer value`.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147461/new/

https://reviews.llvm.org/D147461

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


[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D147073#4240793 , @zequanwu wrote:

> In D147073#4240017 , @hans wrote:
>
>> I'm not familiar with this code. I suppose the question is whether it's 
>> reasonable for this code to expect that the source locations are always 
>> valid or not?
>
> Yes.
>
> For `0 ? T{} : T{};`, the both branches have valid start location but 
> invalid end location. See comments at 
> https://github.com/llvm/llvm-project/issues/45481#issuecomment-1487267814.
>
> For the `std::strong_ordering`, I found that `DeclRefExpr` in the 
> ConditionalOperator's true branch has invalid start and end locations. It 
> might because it's inside a `PseudoObjectExpr`. Maybe we should simply just 
> skip visiting `PseudoObjectExpr`, I see that its begin and end location are 
> the same. I'm not familiar with that expression, so, I just handled it by 
> adding checks for validating begin and end locations.

Right, I'm just wondering if it's reasonable that this code should have to 
handle such situations. (It seems it can't handle it perfectly anyway, since 
the coverage won't be completely correct.) Maybe Aaron can comment on what the 
expectations are for these locations.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147073/new/

https://reviews.llvm.org/D147073

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


[PATCH] D147395: [Clangd] Make the type hint length limit configurable

2023-04-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/Config.h:151
+// Limit the length of type names in inlay hints.
+size_t TypeNameLimit = 32;
   } InlayHints;

zhangyi1357 wrote:
> hokein wrote:
> > I would extend it a bit more -- 0 means no limit. 
> > 
> > Can you also add a unittest in `TEST(TypeHints, LongTypeName)` in 
> > `InlayHintTests.cpp`? 
> > 0 means no limit.
> This is quite a good idea. I've done it.
> 
> For unittest, there is already `TEST(TypeHints, LongTypeName)` in 
> `InlayHintTests.cpp`. Do you mean add more tests in the same `TEST` or 
> another `TEST` with TypeNameLimit configured?
> 
I mean adding one more test in the same `TEST(TypeHints, LongTypeName)`.

This test verifies the the long type name is shown when the limit is set to 0, 
something like

```
TEST(TypeHints, LongTypeName) {
  assertTypeHints(R"cpp(
template 
struct A {};
struct MultipleWords {};
A foo();
// Omit type hint past a certain length (currently 32)
auto var = foo();
  )cpp");

Config cfg; 
 ... // set the limit to 0

   assertTypeHints(R"cpp(
template 
struct A {};
struct MultipleWords {};
A foo();
// Omit type hint past a certain length (currently 32)
auto var = foo();
  )cpp", ExpectedHint...);
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147395/new/

https://reviews.llvm.org/D147395

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


[clang] c107231 - [clang][dataflow] Fix -Wdeprecated-declarations after D147302 (NFC)

2023-04-04 Thread Jie Fu via cfe-commits

Author: Jie Fu
Date: 2023-04-04T16:17:25+08:00
New Revision: c107231cde99c0b8cdda5c5befe6354750ca03f2

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

LOG: [clang][dataflow] Fix -Wdeprecated-declarations after D147302 (NFC)

Replace:
 1. createAtomicBoolValue() --> create()
 2. createTopBoolValue()--> create()

/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:386:19:
 error: 'createAtomicBoolValue' is deprecated: use create 
instead [-Werror,-Wdeprecated-declarations]
return DACtx->createAtomicBoolValue();
  ^
  create
/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:215:3:
 note: 'createAtomicBoolValue' has been explicitly marked deprecated here
  LLVM_DEPRECATED("use create instead",
  ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/Compiler.h:143:50: note: 
expanded from macro 'LLVM_DEPRECATED'
 ^
In file included from 
/Users/jiefu/llvm-project/clang/lib/Analysis/FlowSensitive/Transfer.cpp:14:
In file included from 
/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/Transfer.h:19:
/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h:391:19:
 error: 'createTopBoolValue' is deprecated: use create instead 
[-Werror,-Wdeprecated-declarations]
return DACtx->createTopBoolValue();
  ^~
  create
/Users/jiefu/llvm-project/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:227:3:
 note: 'createTopBoolValue' has been explicitly marked deprecated here
  LLVM_DEPRECATED("use create instead", "create")
  ^
/Users/jiefu/llvm-project/llvm/include/llvm/Support/Compiler.h:143:50: note: 
expanded from macro 'LLVM_DEPRECATED'
 ^
2 errors generated.

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index ce11fc1c2b2d7..97ea6a573cffd 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -383,12 +383,12 @@ class Environment {
 
   /// Returns an atomic boolean value.
   BoolValue &makeAtomicBoolValue() const {
-return DACtx->createAtomicBoolValue();
+return DACtx->create();
   }
 
   /// Returns a unique instance of boolean Top.
   BoolValue &makeTopBoolValue() const {
-return DACtx->createTopBoolValue();
+return DACtx->create();
   }
 
   /// Returns a boolean value that represents the conjunction of `LHS` and

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 5a49ef195c0b1..4d8a42c1390c2 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -157,7 +157,7 @@ BoolValue 
&DataflowAnalysisContext::getOrCreateIff(BoolValue &LHS,
 }
 
 AtomicBoolValue &DataflowAnalysisContext::makeFlowConditionToken() {
-  return createAtomicBoolValue();
+  return create();
 }
 
 void DataflowAnalysisContext::addFlowConditionConstraint(
@@ -378,8 +378,8 @@ DataflowAnalysisContext::getControlFlowContext(const 
FunctionDecl *F) {
 
 DataflowAnalysisContext::DataflowAnalysisContext(std::unique_ptr S,
  Options Opts)
-: S(std::move(S)), TrueVal(createAtomicBoolValue()),
-  FalseVal(createAtomicBoolValue()), Opts(Opts) {
+: S(std::move(S)), TrueVal(create()),
+  FalseVal(create()), Opts(Opts) {
   assert(this->S != nullptr);
   // If the -dataflow-log command-line flag was set, synthesize a logger.
   // This is ugly but provides a uniform method for ad-hoc debugging dataflow-

diff  --git 
a/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
index 0efb341cc06e7..52b2d5c7a33a3 100644
--- a/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/DataflowAnalysisContextTest.cpp
@@ -27,35 +27,35 @@ class DataflowAnalysisContextTest : public ::testing::Test {
 
 TEST_F(DataflowAnalysisContextTest,
CreateAtomicBoolValueReturnsDistinctValues) {
-  auto &X = Context.createAtomicBoolValue();
-  auto &Y = Context.

[PATCH] D147497: [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of __builtin_neon_vfmsh_f16.

2023-04-04 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147497/new/

https://reviews.llvm.org/D147497

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


[PATCH] D147497: [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of __builtin_neon_vfmsh_f16.

2023-04-04 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.

Sounds OK to me


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147497/new/

https://reviews.llvm.org/D147497

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


[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-04-04 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

Did another quick look. And I feel the title and the summary of the page is not 
consistent with the patch itself. I think it is better to split this to make 
the change to focus on the entities with internal linkage. I don't know what's 
wrong with the module linkage things. Maybe we can file an issue ahead in next 
time.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11181
+  "%select{declaration|definition|default argument|"
+  "explicit specialization|partial specialization}0 of %1 is private to module 
"
+  "'%2'">;

The 'private'  here makes me to think about module private fragment while it is 
not true. I prefer to refactor it to something like "it is not exported".



Comment at: clang/include/clang/Sema/Sema.h:2356
+  /// Determine whether the module M is part of the current named module.
+  bool isPartOfCurrentNamedModule(const Module *M) const {
+if (!M || M->isGlobalModule())

While I am not a native speaker, I feel `isSameModuleWithCurrentTU` may be a 
better name.



Comment at: clang/lib/Sema/SemaLookup.cpp:1782
   assert(DeclModule && "hidden decl has no owning module");
 
+  // If the owning module is visible, the decl is potentially acceptable.

It looks better to me if we can insert codes here



Comment at: clang/lib/Sema/SemaLookup.cpp:3912-3936
+  if (Visible) {
+if (!FM)
+  break;
+assert (D->hasLinkage() && "an imported func with no linkage?");
+// Unless the module is a defining one for the
+bool Ovr = true;
+for (unsigned I = 0; I < CodeSynthesisContexts.size(); ++I) {

What's the intention for the change? And why is the current behavior bad 
without this?



Comment at: clang/lib/Sema/SemaLookup.cpp:4517
 /// declarations are visible, false otherwise.
 static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC) {
   TypoCorrection::decl_iterator DI = TC.begin(), DE = TC.end();

What if we don't touch the typo part? I am still confusing.



Comment at: clang/lib/Sema/SemaLookup.cpp:5821-5832
+  } else if (Decl->hasLinkage() &&
+ Decl->getFormalLinkage() == Linkage::ModuleLinkage) {
+Diag(UseLoc, diag::err_module_private_use)
+<< (int)MIK << Decl << Modules[0]->getFullModuleName();
+Diag(Decl->getBeginLoc(), diag::note_suggest_export)
+<< (int)MIK
+<< FixItHint::CreateInsertion(Decl->getBeginLoc(), "export");

I feel like this can be another change. I'm a little bit confused since I feel 
the patch did multiple things at the same time again..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145965/new/

https://reviews.llvm.org/D145965

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


[clang] ee71cbd - [clang][Interp] Ignore more non-VarDecl declarations

2023-04-04 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-04-04T10:41:46+02:00
New Revision: ee71cbddb77f8da9285657cac248b431928143b9

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

LOG: [clang][Interp] Ignore more non-VarDecl declarations

They are harmless and handled by other means, but we used to return
false from visitDeclStmt.

Differential Revision: https://reviews.llvm.org/D145861

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/test/AST/Interp/literals.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp 
b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index 6faa3f9a47a9b..2c53900111d9b 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -224,7 +224,7 @@ bool ByteCodeStmtGen::visitCompoundStmt(
 template 
 bool ByteCodeStmtGen::visitDeclStmt(const DeclStmt *DS) {
   for (auto *D : DS->decls()) {
-if (isa(D))
+if (isa(D))
   continue;
 
 const auto *VD = dyn_cast(D);

diff  --git a/clang/test/AST/Interp/literals.cpp 
b/clang/test/AST/Interp/literals.cpp
index 5883c1879b925..f31a49088dc6c 100644
--- a/clang/test/AST/Interp/literals.cpp
+++ b/clang/test/AST/Interp/literals.cpp
@@ -766,3 +766,16 @@ namespace TypeTraits {
   static_assert(S3{}.foo(), "");
   static_assert(!S3{}.foo(), "");
 }
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+  static_assert(true, "");
+  struct F { int a; };
+  enum E { b };
+  using A = int;
+  typedef int Z;
+
+  return F{12}.a;
+}
+static_assert(ignoredDecls() == 12, "");
+#endif



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


[PATCH] D145861: [clang][Interp] Ignore more non-VarDecl declarations

2023-04-04 Thread Timm Bäder via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGee71cbddb77f: [clang][Interp] Ignore more non-VarDecl 
declarations (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D145861?vs=505092&id=510721#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145861/new/

https://reviews.llvm.org/D145861

Files:
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -766,3 +766,16 @@
   static_assert(S3{}.foo(), "");
   static_assert(!S3{}.foo(), "");
 }
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+  static_assert(true, "");
+  struct F { int a; };
+  enum E { b };
+  using A = int;
+  typedef int Z;
+
+  return F{12}.a;
+}
+static_assert(ignoredDecls() == 12, "");
+#endif
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -224,7 +224,7 @@
 template 
 bool ByteCodeStmtGen::visitDeclStmt(const DeclStmt *DS) {
   for (auto *D : DS->decls()) {
-if (isa(D))
+if (isa(D))
   continue;
 
 const auto *VD = dyn_cast(D);


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -766,3 +766,16 @@
   static_assert(S3{}.foo(), "");
   static_assert(!S3{}.foo(), "");
 }
+
+#if __cplusplus >= 201402L
+constexpr int ignoredDecls() {
+  static_assert(true, "");
+  struct F { int a; };
+  enum E { b };
+  using A = int;
+  typedef int Z;
+
+  return F{12}.a;
+}
+static_assert(ignoredDecls() == 12, "");
+#endif
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -224,7 +224,7 @@
 template 
 bool ByteCodeStmtGen::visitDeclStmt(const DeclStmt *DS) {
   for (auto *D : DS->decls()) {
-if (isa(D))
+if (isa(D))
   continue;
 
 const auto *VD = dyn_cast(D);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145965: [C++20][Modules] Fix incorrect visibilities in implementation units.

2023-04-04 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Sema/SemaLookup.cpp:3912-3936
+  if (Visible) {
+if (!FM)
+  break;
+assert (D->hasLinkage() && "an imported func with no linkage?");
+// Unless the module is a defining one for the
+bool Ovr = true;
+for (unsigned I = 0; I < CodeSynthesisContexts.size(); ++I) {

ChuanqiXu wrote:
> What's the intention for the change? And why is the current behavior bad 
> without this?
> What's the intention for the change? And why is the current behavior bad 
> without this?





Comment at: clang/lib/Sema/SemaLookup.cpp:3912-3936
+  if (Visible) {
+if (!FM)
+  break;
+assert (D->hasLinkage() && "an imported func with no linkage?");
+// Unless the module is a defining one for the
+bool Ovr = true;
+for (unsigned I = 0; I < CodeSynthesisContexts.size(); ++I) {

ChuanqiXu wrote:
> ChuanqiXu wrote:
> > What's the intention for the change? And why is the current behavior bad 
> > without this?
> > What's the intention for the change? And why is the current behavior bad 
> > without this?
> 
> 
Oh, I understand why I feel the code is not good since the decl with internal 
linkage or module linkage shouldn't be visible. So even if there are problems, 
we should handle them elsewhere.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145965/new/

https://reviews.llvm.org/D145965

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


[clang] 626b7e5 - [clang][Interp][NFC] Remove Integral.h include from PrimType.h

2023-04-04 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-04-04T10:44:56+02:00
New Revision: 626b7e5dd249f569203e024141c1a2a0f618df9c

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

LOG: [clang][Interp][NFC] Remove Integral.h include from PrimType.h

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/PrimType.h
clang/lib/AST/Interp/Program.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index af5b4678b070..46a926bfb5f0 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -224,9 +224,9 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
   llvm::function_ref Indirect);
 
   /// Emits an APSInt constant.
-  bool emitConst(const APSInt &Value, const Expr *E);
-  bool emitConst(const APInt &Value, const Expr *E) {
-return emitConst(static_cast(Value), E);
+  bool emitConst(const llvm::APSInt &Value, const Expr *E);
+  bool emitConst(const llvm::APInt &Value, const Expr *E) {
+return emitConst(static_cast(Value), E);
   }
 
   /// Emits an integer constant.

diff  --git a/clang/lib/AST/Interp/PrimType.h b/clang/lib/AST/Interp/PrimType.h
index 91311cf7030a..30bec3f2a17c 100644
--- a/clang/lib/AST/Interp/PrimType.h
+++ b/clang/lib/AST/Interp/PrimType.h
@@ -13,7 +13,6 @@
 #ifndef LLVM_CLANG_AST_INTERP_TYPE_H
 #define LLVM_CLANG_AST_INTERP_TYPE_H
 
-#include "Integral.h"
 #include 
 #include 
 #include 
@@ -25,6 +24,7 @@ class Pointer;
 class Boolean;
 class Floating;
 class FunctionPointer;
+template  class Integral;
 
 /// Enumeration of the primitive types of the VM.
 enum PrimType : unsigned {

diff  --git a/clang/lib/AST/Interp/Program.cpp 
b/clang/lib/AST/Interp/Program.cpp
index 106c59463e2b..f6f378dd49f1 100644
--- a/clang/lib/AST/Interp/Program.cpp
+++ b/clang/lib/AST/Interp/Program.cpp
@@ -10,6 +10,7 @@
 #include "ByteCodeStmtGen.h"
 #include "Context.h"
 #include "Function.h"
+#include "Integral.h"
 #include "Opcode.h"
 #include "PrimType.h"
 #include "clang/AST/Decl.h"



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


[PATCH] D146242: [ARM] Fixing ABI mismatch for packed structs and fields

2023-04-04 Thread Oliver Stannard via Phabricator via cfe-commits
olista01 accepted this revision.
olista01 added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146242/new/

https://reviews.llvm.org/D146242

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


[PATCH] D147481: [M68k] Add basic Clang supports for M68881/2

2023-04-04 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/Driver/m68k-macros.cpp:2
 // Check macro definitions
 // RUN: %clang -target m68k-unknown-linux -m68000 -dM -E %s | FileCheck 
--check-prefix=CHECK-MX %s
+// RUN: %clang -target m68k-unknown-linux -m68000 -mhard-float -dM -E %s | 
FileCheck --check-prefix=CHECK-MX881 %s

Add a CHECK-NOMX881 prefix and check that __HAVE_68881__  isn't defined?



Comment at: clang/test/Driver/m68k-macros.cpp:24
+
+// RUN: %clang -target m68k-unknown-linux -m68020 -dM -E %s | FileCheck 
--check-prefixes=CHECK-MX20,CHECK-MX881 %s
 // CHECK-MX20: #define __mc68000 1

Add soft-float checks without CHECK-MX881 so we can check for 020-060 targets 
without FPU (68LC040 etc.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147481/new/

https://reviews.llvm.org/D147481

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


[PATCH] D147520: Fix a time-trace issue of incorrect header hierarchy when a header contains a template function for its last symbol.

2023-04-04 Thread Ying Yi via Phabricator via cfe-commits
MaggieYi created this revision.
MaggieYi added reviewers: Whitney, jamieschmeiser, MaskRay, rnk, aras-p, 
anton-afanasyev.
Herald added a subscriber: hiraditya.
Herald added a project: All.
MaggieYi requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

`HandleEndOfFile` is invoked when the lexer hits the end of the current file. 
This either returns the EOF token or pops a level off the include stack and
keeps going. If it keeps going, clang parses from one header to another header. 
This results in incorrect header hierarchy in the time trace.

This patch corrects this, as reported by #56554

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147520

Files:
  clang/lib/Sema/Sema.cpp
  clang/test/Driver/Inputs/header5.h
  clang/test/Driver/Inputs/header6.h
  clang/test/Driver/check-time-trace-header-hierarchy.cpp
  clang/test/Driver/check-time-trace-header-hierarchy.py
  llvm/include/llvm/Support/TimeProfiler.h
  llvm/lib/Support/TimeProfiler.cpp

Index: llvm/lib/Support/TimeProfiler.cpp
===
--- llvm/lib/Support/TimeProfiler.cpp
+++ llvm/lib/Support/TimeProfiler.cpp
@@ -107,7 +107,7 @@
Detail());
   }
 
-  void end() {
+  void element_end() {
 assert(!Stack.empty() && "Must call begin() first");
 TimeTraceProfilerEntry &E = Stack.back();
 E.End = ClockType::now();
@@ -143,6 +143,33 @@
 Stack.pop_back();
   }
 
+  void end(bool IsSource = false) {
+bool TopElementIsSource = Stack.back().Name == "Source";
+// If time trace profiler is ended by exiting a file (IsSource=true), we
+// expect the top of Stack is time section entry with name "Source".
+// If IsSource is false, the last time section should not be "Source". In
+// these two cases, only pop the top element of the Stack.
+if ((IsSource && TopElementIsSource) ||
+(!IsSource && !TopElementIsSource)) {
+  element_end();
+  return;
+}
+
+// If the last time section entry is "Source" but time trace profiler is not
+// ended by exiting a file (IsSource=false), we don't need to do anything
+// since the time section entry has been popped out when exiting the
+// previous 'Source' time section entry.
+if (!IsSource && TopElementIsSource)
+  return;
+
+// If the last time section entry is not "Source" but time trace profiler is
+// ended by exiting a file (IsSource=true), we will pop time sections from
+// the top of Stack until the 'Source' time section.
+while (Stack.back().Name != "Source")
+  element_end();
+element_end();
+  }
+
   // Write events from this TimeTraceProfilerInstance and
   // ThreadTimeTraceProfilerInstances.
   void write(raw_pwrite_stream &OS) {
@@ -353,7 +380,7 @@
 TimeTraceProfilerInstance->begin(std::string(Name), Detail);
 }
 
-void llvm::timeTraceProfilerEnd() {
+void llvm::timeTraceProfilerEnd(bool IsSource) {
   if (TimeTraceProfilerInstance != nullptr)
-TimeTraceProfilerInstance->end();
+TimeTraceProfilerInstance->end(IsSource);
 }
Index: llvm/include/llvm/Support/TimeProfiler.h
===
--- llvm/include/llvm/Support/TimeProfiler.h
+++ llvm/include/llvm/Support/TimeProfiler.h
@@ -124,8 +124,10 @@
 void timeTraceProfilerBegin(StringRef Name,
 llvm::function_ref Detail);
 
-/// Manually end the last time section.
-void timeTraceProfilerEnd();
+/// Manually end the last time section, with the given \p IsSource.
+/// Pass true to \p IsSource if the name of the last time section is
+/// "Source". By default, \p IsSource is false.
+void timeTraceProfilerEnd(bool IsSource = false);
 
 /// The TimeTraceScope is a helper class to call the begin and end functions
 /// of the time trace profiler.  When the object is constructed, it begins
Index: clang/test/Driver/check-time-trace-header-hierarchy.py
===
--- /dev/null
+++ clang/test/Driver/check-time-trace-header-hierarchy.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python
+
+import json, sys, time
+
+def is_inside(range1, range2):
+a = range1["ts"]; b = a + range1["dur"]
+c = range2["ts"]; d = c + range2["dur"]
+return (c <= a <= d) and (c <= b <= d)
+
+def is_before(range1, range2):
+b = range1["ts"] + range1["dur"]; c = range2["ts"]
+return b <= c
+
+log_contents = json.loads(sys.stdin.read())
+events = log_contents["traceEvents"]
+
+count = 0;
+header5 = header6 = parsetemplate = parseclass = None
+for event in events:
+if event["name"] == "Source" and "header5.h" in event["args"]["detail"]:
+header5 = event
+count += 1
+elif event["name"] == "Source" and "header6.h" in event["args"]["detail"]:
+header6 = event
+count += 1
+elif event["n

[PATCH] D147449: [include-cleaner] Only ignore builtins without a header

2023-04-04 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks. I was surprised to see that some standard library symbols are treated 
as builtin symbols.

I think the current approach is better (e.g. clangd's hover on 
`__builtin_popcount()` will not give some arbitrary header providers).




Comment at: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp:169
+ND->getASTContext().BuiltinInfo.getHeaderName(ID);
+// FIXME: Use the header mapping for builtins with a known header.
+if (!BuiltinHeader)

I think it would be clearer if we move this FIXME after the following if 
branch. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147449/new/

https://reviews.llvm.org/D147449

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


[clang-tools-extra] 3402b77 - [include-cleaner] Only ignore builtins without a header

2023-04-04 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2023-04-04T13:28:56+02:00
New Revision: 3402b77db3ee83f0c576988631afa12cfba61285

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

LOG: [include-cleaner] Only ignore builtins without a header

Certain standard library functions (e.g. std::move) are also implemented
as builtins. This patch moves filtering logic to the symbol->header
mapping phase to rather generate these references without any providers
only when we don't have a mapping.
That way we can also map them to header names mentioned in the builtin
mappings.

Differential Revision: https://reviews.llvm.org/D147449

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
clang-tools-extra/include-cleaner/lib/WalkAST.cpp
clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp 
b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
index e273d429cd8c3..1b705e1d52c2d 100644
--- a/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ b/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -10,18 +10,21 @@
 #include "TypesInternal.h"
 #include "clang-include-cleaner/Record.h"
 #include "clang-include-cleaner/Types.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
-#include 
+#include 
 #include 
 
 namespace clang::include_cleaner {
@@ -106,37 +109,68 @@ 
hintedHeadersForStdHeaders(llvm::ArrayRef Headers,
   return Results;
 }
 
-// Special-case the ambiguous standard library symbols (e.g. std::move) which
-// are not supported by the tooling stdlib lib.
-llvm::SmallVector>
-headersForSpecialSymbol(const Symbol &S, const SourceManager &SM,
-const PragmaIncludes *PI) {
-  if (S.kind() != Symbol::Declaration || !S.declaration().isInStdNamespace())
+// Symbol to header mapping for std::move and std::remove, based on number of
+// parameters.
+std::optional
+headerForAmbiguousStdSymbol(const NamedDecl *ND) {
+  if (!ND->isInStdNamespace())
 return {};
-
-  const auto *FD = S.declaration().getAsFunction();
+  const auto *FD = ND->getAsFunction();
   if (!FD)
-return {};
-
-  llvm::StringRef FName = symbolName(S);
-  llvm::SmallVector Headers;
+return std::nullopt;
+  llvm::StringRef FName = symbolName(*ND);
   if (FName == "move") {
 if (FD->getNumParams() == 1)
   // move(T&& t)
-  Headers.push_back(*tooling::stdlib::Header::named(""));
+  return tooling::stdlib::Header::named("");
 if (FD->getNumParams() == 3)
   // move(InputIt first, InputIt last, OutputIt dest);
-  Headers.push_back(*tooling::stdlib::Header::named(""));
+  return tooling::stdlib::Header::named("");
   } else if (FName == "remove") {
 if (FD->getNumParams() == 1)
   // remove(const char*);
-  Headers.push_back(*tooling::stdlib::Header::named(""));
+  return tooling::stdlib::Header::named("");
 if (FD->getNumParams() == 3)
   // remove(ForwardIt first, ForwardIt last, const T& value);
-  Headers.push_back(*tooling::stdlib::Header::named(""));
+  return tooling::stdlib::Header::named("");
   }
-  return applyHints(hintedHeadersForStdHeaders(Headers, SM, PI),
-Hints::CompleteSymbol);
+  return std::nullopt;
+}
+
+// Special-case symbols without proper locations, like the ambiguous standard
+// library symbols (e.g. std::move) or builtin declarations.
+std::optional>>
+headersForSpecialSymbol(const Symbol &S, const SourceManager &SM,
+const PragmaIncludes *PI) {
+  // Our special casing logic only deals with decls, so bail out early for
+  // macros.
+  if (S.kind() != Symbol::Declaration)
+return std::nullopt;
+  const auto *ND = llvm::cast(&S.declaration());
+  // We map based on names, so again bail out early if there are no names.
+  if (!ND)
+return std::nullopt;
+  auto *II = ND->getIdentifier();
+  if (!II)
+return std::nullopt;
+
+  // Check first for symbols that are part of our stdlib mapping. As we have
+  // header names for those.
+  if (auto Header = headerForAmbiguousStdSymbol(ND)) {
+return applyHints(hintedHeadersForStdHeaders({*Header}, SM, PI),
+  Hints::CompleteSymbol);
+  }
+
+  // Now check for b

[PATCH] D147449: [include-cleaner] Only ignore builtins without a header

2023-04-04 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3402b77db3ee: [include-cleaner] Only ignore builtins without 
a header (authored by kadircet).

Changed prior to commit:
  https://reviews.llvm.org/D147449?vs=510516&id=510746#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147449/new/

https://reviews.llvm.org/D147449

Files:
  clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
  clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -327,11 +327,5 @@
   testWalk("enum class E : int {};", "enum class ^E : int ;");
 }
 
-TEST(WalkAST, BuiltinSymbols) {
-  testWalk(R"cpp(
-extern "C" int __builtin_popcount(unsigned int) noexcept;
-  )cpp", "int x = ^__builtin_popcount(1);");
-}
-
 } // namespace
 } // namespace clang::include_cleaner
Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -93,12 +93,14 @@
   void $bar^bar($private^Private $p^p) {
 $foo^foo();
 std::$vector^vector $vconstructor^$v^v;
+$builtin^__builtin_popcount(1);
+std::$move^move(3);
   }
   )cpp");
   Inputs.Code = Code.code();
   Inputs.ExtraFiles["header.h"] = guard(R"cpp(
   void foo();
-  namespace std { class vector {}; }
+  namespace std { class vector {}; int&& move(int&&); }
   )cpp");
   Inputs.ExtraFiles["private.h"] = guard(R"cpp(
 // IWYU pragma: private, include "path/public.h"
@@ -112,6 +114,7 @@
   auto PublicFile = Header("\"path/public.h\"");
   auto MainFile = Header(SM.getFileEntryForID(SM.getMainFileID()));
   auto VectorSTL = Header(*tooling::stdlib::Header::named(""));
+  auto UtilitySTL = Header(*tooling::stdlib::Header::named(""));
   EXPECT_THAT(
   offsetToProviders(AST, SM),
   UnorderedElementsAre(
@@ -122,8 +125,9 @@
   Pair(Code.point("foo"), UnorderedElementsAre(HeaderFile)),
   Pair(Code.point("vector"), UnorderedElementsAre(VectorSTL)),
   Pair(Code.point("vconstructor"), UnorderedElementsAre(VectorSTL)),
-  Pair(Code.point("v"), UnorderedElementsAre(MainFile))
-  ));
+  Pair(Code.point("v"), UnorderedElementsAre(MainFile)),
+  Pair(Code.point("builtin"), testing::IsEmpty()),
+  Pair(Code.point("move"), UnorderedElementsAre(UtilitySTL;
 }
 
 TEST_F(WalkUsedTest, MultipleProviders) {
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -35,9 +35,6 @@
   RefType RT = RefType::Explicit) {
 if (!ND || Loc.isInvalid())
   return;
-// Don't report builtin symbols.
-if (const auto *II = ND->getIdentifier(); II && II->getBuiltinID() > 0)
-  return;
 Callback(Loc, *cast(ND->getCanonicalDecl()), RT);
   }
 
Index: clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
===
--- clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
+++ clang-tools-extra/include-cleaner/lib/FindHeaders.cpp
@@ -10,18 +10,21 @@
 #include "TypesInternal.h"
 #include "clang-include-cleaner/Record.h"
 #include "clang-include-cleaner/Types.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/FileEntry.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Tooling/Inclusions/StandardLibrary.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
-#include 
+#include 
 #include 
 
 namespace clang::include_cleaner {
@@ -106,37 +109,68 @@
   return Results;
 }
 
-// Special-case the ambiguous standard library symbols (e.g. std::move) which
-// are not supported by the tooling stdlib lib.
-llvm::SmallVector>
-headersForSpecialSymbol(const Symbol &S, const SourceManager &SM,
-const PragmaIncludes *PI) {
-  if (S.kind() != Symbol::Declaration || !S.declaration().isInStdNamespace())
+// Symbol to header mapping for std::move and std::remove, based on number of
+// parameters.
+std::optional
+headerForAmbiguousStdSymbol(const NamedDecl *ND) {
+  if (!ND->isInStdNamespa

[PATCH] D147520: Fix a time-trace issue of incorrect header hierarchy when a header contains a template function for its last symbol.

2023-04-04 Thread Ying Yi via Phabricator via cfe-commits
MaggieYi added a comment.

A simple test to reproduce the issue:

  % cat main.cpp
  #include "1.h"
  #include "2.h"
  int foo();
  
  % cat 1.h
  template  auto Zero() -> T { return T{}; }
  
  %cat 2.h
  struct Bla {};

Compile the code with `-ftime-trace-granularity=0 -ftime-trace` to show the 
issue:

  prospero-clang -ftime-trace-granularity=0 -ftime-trace main.cpp -c -o main.o 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147520/new/

https://reviews.llvm.org/D147520

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


[PATCH] D147520: Fix a time-trace issue of incorrect header hierarchy when a header contains a template function for its last symbol.

2023-04-04 Thread Ying Yi via Phabricator via cfe-commits
MaggieYi added a comment.

Analysis the issue using the above simple example:

When clang parses the first line (`#include "1.h"`) in the `main.cpp`, a time 
section entry is created and put on the top of the time-trace stack. Assuming 
this time section entry is named `Source-1.h`, which has its name `Source` and 
detail `1.h`. Then, clang parses the template function `Zero` defined in the 
`1.h` header file. Clang will create a `TimeTraceScope` variable in which its 
name is `ParseTemplate` and its detail is `Zero`. A new time section entry 
named `ParseTemplate-Zero` is created and put on the top of the time-trace 
stack. `ParseTemplate-Zero` has its name `ParseTemplate` and detail `Zero`. 
Now, the top element of the time-trace stack is `ParseTemplate-Zero` and 
`Source-1.h` is under `ParseTemplate-Zero`.

Please note: since `ParseTemplate-Zero` is `TimeTraceScope` type variable. It 
should be popped out from the time-trace stack once the destructor of 
`TimeTraceScope` is called.

Since the template `Zero` is the last symbol defined in the `1.h` header, the 
`LexEndOfFile` is called, then `LexedFileChanged` is called. `LexedFileChanged` 
is invoked when the lexer hits the end of the current file. This either returns 
the EOF token or pops a level off the include stack and keeps going. In our 
case, it keeps going and notifies the client that we are in a new header file: 
`2.h`. The function of `timeTraceProfilerEnd` is called to pop the top element 
out from the time-trace stack and calculate the corresponding compilation time. 
`Source-1.h` is expected to pop out from the time-trace stack. However, since 
`ParseTemplate-Zero` is still alive and is on the top of the time-trace stack. 
`ParseTemplate-Zero` is popped out from the time trace stack instead of 
`Source-1.h`, which is wrong. Until now, the top of the time-trace stack is 
`Source-1.h`.

After that, a time section entry named `Source-2.h` is created and put on the 
top of the time-trace stack. Now, the top element of the time-trace stack is 
`Source-2.h`, and then `Source-1.h` is under `Source-2.h`. This results in 
incorrect header hierarchy in the time trace: the `2.h` shows up as an 
inclusion under `1.h`.

Currently, two available time profiling APIs cannot deal with this special 
case. I have modified `timeTraceProfilerEnd()` to handle the header file 
specially.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147520/new/

https://reviews.llvm.org/D147520

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


[PATCH] D147495: [Clang][Attributes] Add MeaningfulToClassTemplateDefinition to unavailable attribute

2023-04-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though please add a release note about the fix. I don't *think* this 
qualifies as a potentially breaking change, though it does theoretically have 
the ability to cause code which previously compiled to no longer compile. At 
least, my search over sourcegraph didn't come up with any results 
(https://sourcegraph.com/search?q=context:global+lang:C%2B%2B+-file:.*test.*+template+%3Ctypename%7Cclass+.*%3E+__attribute__%5C%28%5C%28unavailable&patternType=regexp&sm=1&groupBy=repo).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147495/new/

https://reviews.llvm.org/D147495

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


[PATCH] D147307: [clang] Do not require GNUInlineAttr for inline builtins

2023-04-04 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 510752.
serge-sans-paille retitled this revision from "[clang] Consider artificial 
always inline builtin as inline builtins" to "[clang] Do not require 
GNUInlineAttr for inline builtins".
serge-sans-paille added a comment.

DO not require gnu inline, period.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147307/new/

https://reviews.llvm.org/D147307

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGen/memcpy-inline-builtin.c
  clang/test/CodeGen/pr9614.c

Index: clang/test/CodeGen/pr9614.c
===
--- clang/test/CodeGen/pr9614.c
+++ clang/test/CodeGen/pr9614.c
@@ -32,7 +32,7 @@
 
 // CHECK-LABEL: define{{.*}} void @f()
 // CHECK: call void @foo()
-// CHECK: call i32 @abs(i32 noundef 0)
+// CHECK: call i32 @abs(i32 noundef %0)
 // CHECK: call ptr @strrchr(
 // CHECK: call void @llvm.prefetch.p0(
 // CHECK: call ptr @memchr(
Index: clang/test/CodeGen/memcpy-inline-builtin.c
===
--- clang/test/CodeGen/memcpy-inline-builtin.c
+++ clang/test/CodeGen/memcpy-inline-builtin.c
@@ -3,18 +3,27 @@
 // RUN: %clang_cc1 -triple x86_64 -S -emit-llvm -o - %s | FileCheck %s
 //
 // Verifies that clang detects memcpy inline version and uses it instead of the builtin.
+// Checks alternate version with the `artificial` attribute.
 
 typedef unsigned long size_t;
 
 // Clang requires these attributes for a function to be redefined.
 #define AVAILABLE_EXTERNALLY extern inline __attribute__((always_inline)) __attribute__((gnu_inline))
 
+#define AVAILABLE_EXTERNALLY_ALTERNATE extern inline __attribute__((__always_inline__)) __attribute__((__artificial__))
+
 // Clang recognizes an inline builtin and renames it to prevent conflict with builtins.
 AVAILABLE_EXTERNALLY void *memcpy(void *a, const void *b, size_t c) {
   asm("# memcpy.inline marker");
   return __builtin_memcpy(a, b, c);
 }
 
+// Clang recognizes an inline builtin and renames it to prevent conflict with builtins.
+AVAILABLE_EXTERNALLY_ALTERNATE void *memmove(void *a, const void *b, size_t c) {
+  asm("# memmove.inline marker");
+  return __builtin_memmove(a, b, c);
+}
+
 // CHECK-LABEL: @foo(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[A_ADDR_I:%.*]] = alloca ptr, align 8
@@ -43,6 +52,34 @@
   return memcpy(a, b, c);
 }
 
+// CHECK-LABEL: @foo_alt(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR_I:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[B_ADDR_I:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[C_ADDR_I:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:store ptr [[A:%.*]], ptr [[A_ADDR]], align 8
+// CHECK-NEXT:store ptr [[B:%.*]], ptr [[B_ADDR]], align 8
+// CHECK-NEXT:store i64 [[C:%.*]], ptr [[C_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[A_ADDR]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = load ptr, ptr [[B_ADDR]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = load i64, ptr [[C_ADDR]], align 8
+// CHECK-NEXT:store ptr [[TMP0]], ptr [[A_ADDR_I]], align 8
+// CHECK-NEXT:store ptr [[TMP1]], ptr [[B_ADDR_I]], align 8
+// CHECK-NEXT:store i64 [[TMP2]], ptr [[C_ADDR_I]], align 8
+// CHECK-NEXT:call void asm sideeffect "# memmove.inline marker", "~{dirflag},~{fpsr},~{flags}"() #[[ATTR3]], !srcloc !3
+// CHECK-NEXT:[[TMP3:%.*]] = load ptr, ptr [[A_ADDR_I]], align 8
+// CHECK-NEXT:[[TMP4:%.*]] = load ptr, ptr [[B_ADDR_I]], align 8
+// CHECK-NEXT:[[TMP5:%.*]] = load i64, ptr [[C_ADDR_I]], align 8
+// CHECK-NEXT:call void @llvm.memmove.p0.p0.i64(ptr align 1 [[TMP3]], ptr align 1 [[TMP4]], i64 [[TMP5]], i1 false)
+// CHECK-NEXT:ret ptr [[TMP3]]
+//
+void *foo_alt(void *a, const void *b, size_t c) {
+  return memmove(a, b, c);
+}
+
 // CHECK-LABEL: @bar(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[A_ADDR:%.*]] = alloca ptr, align 8
@@ -68,3 +105,29 @@
   void *(*cpy)(void *, const void *, size_t) = c > 10 ? memcpy : foo;
   cpy(a, b, c);
 }
+
+// CHECK-LABEL: @bar_alt(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:[[CPY:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[A:%.*]], ptr [[A_ADDR]], align 8
+// CHECK-NEXT:store ptr [[B:%.*]], ptr [[B_ADDR]], align 8
+// CHECK-NEXT:store i64 [[C:%.*]], ptr [[C_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i64, ptr [[C_ADDR]], align 8
+// CHECK-NEXT:[[CMP:%.*]] = icmp ugt i64 [[TMP0]], 10
+// CHECK-NEXT:[[TMP1:%.*]] = zext i1 [[CMP]] to i64
+// CHECK-NEXT:[[COND:%.*]] = select i1 [[CMP]], ptr @memmove, ptr @foo_alt
+// CHECK-NEXT:store ptr [[COND]], ptr [[CPY]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = load ptr, p

[PATCH] D147073: [Coverage] Handle invalid end location of an expression/statement.

2023-04-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D147073#4242566 , @hans wrote:

> In D147073#4240793 , @zequanwu 
> wrote:
>
>> In D147073#4240017 , @hans wrote:
>>
>>> I'm not familiar with this code. I suppose the question is whether it's 
>>> reasonable for this code to expect that the source locations are always 
>>> valid or not?
>>
>> Yes.
>>
>> For `0 ? T{} : T{};`, the both branches have valid start location but 
>> invalid end location. See comments at 
>> https://github.com/llvm/llvm-project/issues/45481#issuecomment-1487267814.
>>
>> For the `std::strong_ordering`, I found that `DeclRefExpr` in the 
>> ConditionalOperator's true branch has invalid start and end locations. It 
>> might because it's inside a `PseudoObjectExpr`. Maybe we should simply just 
>> skip visiting `PseudoObjectExpr`, I see that its begin and end location are 
>> the same. I'm not familiar with that expression, so, I just handled it by 
>> adding checks for validating begin and end locations.
>
> Right, I'm just wondering if it's reasonable that this code should have to 
> handle such situations. (It seems it can't handle it perfectly anyway, since 
> the coverage won't be completely correct.) Maybe Aaron can comment on what 
> the expectations are for these locations.

`PseudoObjectExpr` is a strange little beast in that it's an abstract object in 
the AST. It gets used when there's is a particular syntax that is modelled 
directly by the language as a series of expressions (e.g., writing `foo->x = 
12;` in the source, but due to some language feature like 
`__declspec(property)`, the semantics are `foo->setX(12);` as a member function 
call instead). So it has multiple source locations that are of interest and you 
have to know what information you're after -- the syntactic location or one of 
the semantic locations. I'm not super familiar with the code coverage 
machinery, but it looks like it's walking over the semantic expressions rather 
than the syntactic one, and that seems a bit fishy to me because I'd assume 
that coverage is intended to describe what the user actually wrote in their 
source. So I don't think I'd skip the `PseudoObjectExpr`, but you might need to 
handle it differently in `CounterCoverageMappingBuilder` by adding a 
`VisitPseudoObjectExpr()` method and not walking over *all* of the children, 
but only the syntactic form of the expression.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147073/new/

https://reviews.llvm.org/D147073

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


[PATCH] D141307: Add -f[no-]loop-versioning option

2023-04-04 Thread Mats Petersson via Phabricator via cfe-commits
Leporacanthicus updated this revision to Diff 510756.
Leporacanthicus added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141307/new/

https://reviews.llvm.org/D141307

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/version-loops.f90

Index: flang/test/Driver/version-loops.f90
===
--- /dev/null
+++ flang/test/Driver/version-loops.f90
@@ -0,0 +1,54 @@
+! Test that flang-new forwards the -f{no-,}version-loops-for-stride 
+! options corredly to flang-new -fc1 for different variants of optimisation
+! and explicit flags.
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O3 \
+! RUN:   | FileCheck %s
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O2 \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O2
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O2 -fversion-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O2-with
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O4 \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O4
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -Ofast \
+! RUN:   | FileCheck %s --check-prefix=CHECK-Ofast
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -Ofast -fno-version-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-Ofast-no
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O3 -fno-version-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O3-no
+  
+! CHECK: "-fversion-loops-for-stride"
+! CHECK: "-O3"
+
+! CHECK-O2-NOT: "-fversion-loops-for-stride"
+! CHECK-O2: "-O2"  
+
+! CHECK-O2-with: "-fversion-loops-for-stride"
+! CHECK-O2-with: "-O2"  
+  
+! CHECK-O4: "-fversion-loops-for-stride"
+! CHECK-O4: "-O3"
+
+! CHECK-Ofast: "-ffast-math"
+! CHECK-Ofast: "-fversion-loops-for-stride"
+! CHECK-Ofast: "-O3"
+
+! CHECK-Ofast-no: "-ffast-math"
+! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride"
+! CHECK-Ofast-no: "-O3"
+
+! CHECK-O3-no-NOT: "-fversion-loops-for-stride"
+! CHECK-O3-no: "-O3"
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -15,6 +15,8 @@
 ! RUN: -fassociative-math \
 ! RUN: -freciprocal-math \
 ! RUN: -fpass-plugin=Bye%pluginext \
+! RUN: -fversion-loops-for-stride \
+! RUN: -mllvm -print-before-all\
 ! RUN: -mllvm -print-before-all \
 ! RUN: -save-temps=obj \
 ! RUN: -P \
@@ -34,5 +36,6 @@
 ! CHECK: "-freciprocal-math"
 ! CHECK: "-fconvert=little-endian"
 ! CHECK: "-fpass-plugin=Bye
+! CHECK: "-fversion-loops-for-stride"  
 ! CHECK: "-mllvm" "-print-before-all"
 ! CHECK: "-save-temps=obj"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -48,6 +48,8 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
+! HELP-NEXT: -fno-version-loops-for-stride
+! HELP-NEXT:Do not create unit-strided loops (default)
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
@@ -55,6 +57,8 @@
 ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names
+! HELP-NEXT: -fversion-loops-for-stride
+! HELP-NEXT:Create unit-strided versions of loops
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -gline-tables-only Emit debug line number tables only
 ! HELP-NEXT: -g Generate source-level debug information
@@ -143,6 +147,8 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
+! HELP-FC1-NEX

[clang] d3aed4f - MachO use generic code to detect atomic support.

2023-04-04 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2023-04-04T13:44:45+01:00
New Revision: d3aed4f401fa35ea986d3967c529f4d2b24e2bb6

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

LOG: MachO use generic code to detect atomic support.

The default code can detect what width of atomic instructions are supported
based on the targeted architecture profile, version etc so there's no need to
hard-code 64 on Darwin targets (especially as it's wrong in most M-class
cases).

Added: 
clang/test/CodeGen/atomic-arm.c

Modified: 
clang/lib/Basic/Targets/ARM.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 5e0e8f5c476af..a0ffbcf78001e 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -1406,11 +1406,6 @@ DarwinARMTargetInfo::DarwinARMTargetInfo(const 
llvm::Triple &Triple,
  const TargetOptions &Opts)
 : DarwinTargetInfo(Triple, Opts) {
   HasAlignMac68kSupport = true;
-  // iOS always has 64-bit atomic instructions.
-  // FIXME: This should be based off of the target features in
-  // ARMleTargetInfo.
-  MaxAtomicInlineWidth = 64;
-
   if (Triple.isWatchABI()) {
 // Darwin on iOS uses a variant of the ARM C++ ABI.
 TheCXXABI.set(TargetCXXABI::WatchOS);

diff  --git a/clang/test/CodeGen/atomic-arm.c b/clang/test/CodeGen/atomic-arm.c
new file mode 100644
index 0..6952b4d0099b5
--- /dev/null
+++ b/clang/test/CodeGen/atomic-arm.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -triple thumbv6m-apple-unknown-macho %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-V6M
+// RUN: %clang_cc1 -triple thumbv7m-apple-unknown-macho %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-V7M
+// RUN: %clang_cc1 -triple thumbv7-apple-ios13.0 %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-HOSTED
+// RUN: %clang_cc1 -triple thumbv7k-apple-watchos5.0 %s -emit-llvm -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-HOSTED
+
+
+// CHECK-V6M: @always1 = global i32 0
+// CHECK-V6M: @always4 = global i32 0
+// CHECK-V6M: @always8 = global i32 0
+
+// CHECK-V7M: @always1 = global i32 1
+// CHECK-V7M: @always4 = global i32 1
+// CHECK-V7M: @always8 = global i32 0
+
+// CHECK-HOSTED: @always1 = global i32 1
+// CHECK-HOSTED: @always4 = global i32 1
+// CHECK-HOSTED: @always8 = global i32 1
+
+int always1 = __atomic_always_lock_free(1, 0);
+int always4 = __atomic_always_lock_free(4, 0);
+int always8 = __atomic_always_lock_free(8, 0);
+
+int lock_free_1() {
+  // CHECK-LABEL: @lock_free_1
+  // CHECK-V6M:   [[RES:%.*]] = call arm_aapcscc zeroext i1 
@__atomic_is_lock_free(i32 noundef 1, ptr noundef null)
+  // CHECK-V6M:   [[RES32:%.*]] = zext i1 [[RES]] to i32
+  // CHECK-V6M:   ret i32 [[RES32]]
+
+  // CHECK-V7M: ret i32 1
+  // CHECK-HOSTED: ret i32 1
+  return __c11_atomic_is_lock_free(1);
+}
+
+int lock_free_4() {
+  // CHECK-LABEL: @lock_free_4
+  // CHECK-V6M:   [[RES:%.*]] = call arm_aapcscc zeroext i1 
@__atomic_is_lock_free(i32 noundef 4, ptr noundef null)
+  // CHECK-V6M:   [[RES32:%.*]] = zext i1 [[RES]] to i32
+  // CHECK-V6M:   ret i32 [[RES32]]
+
+  // CHECK-V7M: ret i32 1
+  // CHECK-HOSTED: ret i32 1
+  return __c11_atomic_is_lock_free(4);
+}
+
+int lock_free_8() {
+  // CHECK-LABEL: @lock_free_8
+  // CHECK-V6M:   [[RES:%.*]] = call arm_aapcscc zeroext i1 
@__atomic_is_lock_free(i32 noundef 8, ptr noundef null)
+  // CHECK-V6M:   [[RES32:%.*]] = zext i1 [[RES]] to i32
+  // CHECK-V6M:   ret i32 [[RES32]]
+
+  // CHECK-V7M:   [[RES:%.*]] = call arm_aapcscc zeroext i1 
@__atomic_is_lock_free(i32 noundef 8, ptr noundef null)
+  // CHECK-V7M:   [[RES32:%.*]] = zext i1 [[RES]] to i32
+  // CHECK-V7M:   ret i32 [[RES32]]
+
+  // CHECK-HOSTED: ret i32 1
+  return __c11_atomic_is_lock_free(8);
+}



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


[PATCH] D144190: [AIX][clang] Storage Locations for Constant Pointers

2023-04-04 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added a comment.

Ping for review. Thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144190/new/

https://reviews.llvm.org/D144190

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


[PATCH] D147525: [X86] Add AMX_COMPLEX to Graniterapids

2023-04-04 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
FreddyYe requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch also rename __AMXCOMPLEX__ to __AMX_COMPLEX__


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147525

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Headers/immintrin.h
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp


Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -208,7 +208,7 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
+FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI | 
FeatureAMX_COMPLEX;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1054,7 +1054,8 @@
 
   // Graniterapids
   list GNRAdditionalFeatures = [FeatureAMXFP16,
-  FeaturePREFETCHI];
+  FeaturePREFETCHI,
+  FeatureAMXCOMPLEX];
   list GNRFeatures =
 !listconcat(SPRFeatures, GNRAdditionalFeatures);
 
Index: clang/test/Preprocessor/x86_target_features.c
===
--- clang/test/Preprocessor/x86_target_features.c
+++ clang/test/Preprocessor/x86_target_features.c
@@ -562,14 +562,14 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-complex -x 
c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=AMX-COMPLEX %s
 
-// AMX-COMPLEX: #define __AMXCOMPLEX__ 1
+// AMX-COMPLEX: #define __AMX_COMPLEX__ 1
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mno-amx-complex 
-x c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-COMPLEX %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-complex 
-mno-amx-tile \
 // RUN: -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-COMPLEX %s
 
-// NO-AMX-COMPLEX-NOT: #define __AMXCOMPLEX__ 1
+// NO-AMX-COMPLEX-NOT: #define __AMX_COMPLEX__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavxvnni -x c -E -dM 
-o - %s | FileCheck -match-full-lines --check-prefix=AVXVNNI %s
 
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1798,6 +1798,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M32
 // CHECK_GNR_M32: #define __AES__ 1
 // CHECK_GNR_M32: #define __AMX_BF16__ 1
+// CHECK_GNR_M32: #define __AMX_COMPLEX__ 1
 // CHECK_GNR_M32: #define __AMX_FP16__ 1
 // CHECK_GNR_M32: #define __AMX_INT8__ 1
 // CHECK_GNR_M32: #define __AMX_TILE__ 1
@@ -1872,6 +1873,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M64
 // CHECK_GNR_M64: #define __AES__ 1
 // CHECK_GNR_M64: #define __AMX_BF16__ 1
+// CHECK_GNR_M64: #define __AMX_COMPLEX__ 1
 // CHECK_GNR_M64: #define __AMX_FP16__ 1
 // CHECK_GNR_M64: #define __AMX_INT8__ 1
 // CHECK_GNR_M64: #define __AMX_TILE__ 1
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -539,7 +539,7 @@
 #endif
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
-defined(__AMXCOMPLEX__)
+defined(__AMX_COMPLEX__)
 #include 
 #endif
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -802,7 +802,7 @@
   if (HasAMXFP16)
 Builder.defineMacro("__AMX_FP16__");
   if (HasAMXCOMPLEX)
-Builder.defineMacro("__AMXCOMPLEX__");
+Builder.defineMacro("__AMX_COMPLEX__");
   if (HasCMPCCXADD)
 Builder.defineMacro("__CMPCCXADD__");
   if (HasRAOINT)


Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -208,7 +208,7 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | Feature

[clang] c7161e7 - [python] Expose clang_Location_isInSystemHeader

2023-04-04 Thread Aaron Ballman via cfe-commits

Author: Artur Ryt
Date: 2023-04-04T09:21:04-04:00
New Revision: c7161e73ca0afdf9cc016ce4e9f1e23a6a140b51

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

LOG: [python] Expose clang_Location_isInSystemHeader

Add is_in_system_header property for Location class.

Corresponding unit test was also added.

Differential Revision: https://reviews.llvm.org/D147414

Added: 


Modified: 
clang/bindings/python/clang/cindex.py
clang/bindings/python/tests/cindex/test_location.py
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index 5d13b7bff1498..6d33650a71671 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -286,6 +286,11 @@ def offset(self):
 """Get the file offset represented by this source location."""
 return self._get_instantiation()[3]
 
+@property
+def is_in_system_header(self):
+"""Returns true if the given source location is in a system header."""
+return conf.lib.clang_Location_isInSystemHeader(self)
+
 def __eq__(self, other):
 return conf.lib.clang_equalLocations(self, other)
 
@@ -4131,6 +4136,10 @@ def cursor(self):
[Cursor],
c_longlong),
 
+  ("clang_Location_isInSystemHeader",
+   [SourceLocation],
+   bool),
+
   ("clang_Type_getAlignOf",
[Type],
c_longlong),

diff  --git a/clang/bindings/python/tests/cindex/test_location.py 
b/clang/bindings/python/tests/cindex/test_location.py
index fbe9770d7ebc5..0d2c69db883cc 100644
--- a/clang/bindings/python/tests/cindex/test_location.py
+++ b/clang/bindings/python/tests/cindex/test_location.py
@@ -7,6 +7,7 @@
 from clang.cindex import File
 from clang.cindex import SourceLocation
 from clang.cindex import SourceRange
+from clang.cindex import TranslationUnit
 from .util import get_cursor
 from .util import get_tu
 
@@ -103,3 +104,17 @@ def test_extent(self):
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 self.assertNotEqual(range1, range3)
+
+def test_is_system_location(self):
+header = os.path.normpath('./fake/fake.h')
+tu = TranslationUnit.from_source('fake.c', 
[f'-isystem{os.path.dirname(header)}'], unsaved_files = [
+('fake.c', """
+#include 
+int one;
+"""),
+(header, "int two();")
+])
+one = get_cursor(tu, 'one')
+two = get_cursor(tu, 'two')
+self.assertFalse(one.location.is_in_system_header)
+self.assertTrue(two.location.is_in_system_header)

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 100be1b5e893c..e39c8606ffd38 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -451,6 +451,12 @@ Static Analyzer
 Sanitizers
 --
 
+Python Binding Changes
+--
+The following methods have been added:
+
+- ``clang_Location_isInSystemHeader`` exposed via the ``is_in_system_header``
+  property of the `Location` class.
 
 Additional Information
 ==



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


[PATCH] D147414: [python] Expose clang_Location_isInSystemHeader

2023-04-04 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc7161e73ca0a: [python] Expose 
clang_Location_isInSystemHeader (authored by R2RT, committed by aaron.ballman).

Changed prior to commit:
  https://reviews.llvm.org/D147414?vs=510542&id=510771#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147414/new/

https://reviews.llvm.org/D147414

Files:
  clang/bindings/python/clang/cindex.py
  clang/bindings/python/tests/cindex/test_location.py
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -451,6 +451,12 @@
 Sanitizers
 --
 
+Python Binding Changes
+--
+The following methods have been added:
+
+- ``clang_Location_isInSystemHeader`` exposed via the ``is_in_system_header``
+  property of the `Location` class.
 
 Additional Information
 ==
Index: clang/bindings/python/tests/cindex/test_location.py
===
--- clang/bindings/python/tests/cindex/test_location.py
+++ clang/bindings/python/tests/cindex/test_location.py
@@ -7,6 +7,7 @@
 from clang.cindex import File
 from clang.cindex import SourceLocation
 from clang.cindex import SourceRange
+from clang.cindex import TranslationUnit
 from .util import get_cursor
 from .util import get_tu
 
@@ -103,3 +104,17 @@
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 self.assertNotEqual(range1, range3)
+
+def test_is_system_location(self):
+header = os.path.normpath('./fake/fake.h')
+tu = TranslationUnit.from_source('fake.c', 
[f'-isystem{os.path.dirname(header)}'], unsaved_files = [
+('fake.c', """
+#include 
+int one;
+"""),
+(header, "int two();")
+])
+one = get_cursor(tu, 'one')
+two = get_cursor(tu, 'two')
+self.assertFalse(one.location.is_in_system_header)
+self.assertTrue(two.location.is_in_system_header)
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -286,6 +286,11 @@
 """Get the file offset represented by this source location."""
 return self._get_instantiation()[3]
 
+@property
+def is_in_system_header(self):
+"""Returns true if the given source location is in a system header."""
+return conf.lib.clang_Location_isInSystemHeader(self)
+
 def __eq__(self, other):
 return conf.lib.clang_equalLocations(self, other)
 
@@ -4131,6 +4136,10 @@
[Cursor],
c_longlong),
 
+  ("clang_Location_isInSystemHeader",
+   [SourceLocation],
+   bool),
+
   ("clang_Type_getAlignOf",
[Type],
c_longlong),


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -451,6 +451,12 @@
 Sanitizers
 --
 
+Python Binding Changes
+--
+The following methods have been added:
+
+- ``clang_Location_isInSystemHeader`` exposed via the ``is_in_system_header``
+  property of the `Location` class.
 
 Additional Information
 ==
Index: clang/bindings/python/tests/cindex/test_location.py
===
--- clang/bindings/python/tests/cindex/test_location.py
+++ clang/bindings/python/tests/cindex/test_location.py
@@ -7,6 +7,7 @@
 from clang.cindex import File
 from clang.cindex import SourceLocation
 from clang.cindex import SourceRange
+from clang.cindex import TranslationUnit
 from .util import get_cursor
 from .util import get_tu
 
@@ -103,3 +104,17 @@
 location3 = SourceLocation.from_position(tu, file, 1, 6)
 range3 = SourceRange.from_locations(location1, location3)
 self.assertNotEqual(range1, range3)
+
+def test_is_system_location(self):
+header = os.path.normpath('./fake/fake.h')
+tu = TranslationUnit.from_source('fake.c', [f'-isystem{os.path.dirname(header)}'], unsaved_files = [
+('fake.c', """
+#include 
+int one;
+"""),
+(header, "int two();")
+])
+one = get_cursor(tu, 'one')
+two = get_cursor(tu, 'two')
+self.assertFalse(one.location.is_in_system_header)
+self.assertTrue(two.location.is_in_system_header)
Index: clang/bindings/python/clang/cindex.py
===
--- clang/bindings/python/clang/cindex.py
+++ clang/bindings/python/clang/cindex.py
@@ -286,6 +286,11 @@
 """Get the file offset represented by this source location."""
 return self._get_ins

[PATCH] D147525: [X86] Add AMX_COMPLEX to Graniterapids

2023-04-04 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 510772.
FreddyYe added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147525/new/

https://reviews.llvm.org/D147525

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Headers/immintrin.h
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/lib/TargetParser/X86TargetParser.cpp.f

Index: llvm/lib/TargetParser/X86TargetParser.cpp.f
===
--- llvm/lib/TargetParser/X86TargetParser.cpp.f
+++ llvm/lib/TargetParser/X86TargetParser.cpp.f
@@ -208,7 +208,8 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
+FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI |
+FeatureAMX_COMPLEX;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
@@ -302,145 +303,165 @@
 FeaturesZNVER3 | FeatureAVX512F | FeatureAVX512CD | FeatureAVX512DQ |
 FeatureAVX512BW | FeatureAVX512VL | FeatureAVX512IFMA | FeatureAVX512VBMI |
 FeatureAVX512VBMI2 | FeatureAVX512VNNI | FeatureAVX512BITALG |
-FeatureAVX512VPOPCNTDQ | FeatureAVX512BF16 | FeatureGFNI |
-FeatureSHSTK;
+FeatureAVX512VPOPCNTDQ | FeatureAVX512BF16 | FeatureGFNI | FeatureSHSTK;
 
 constexpr ProcInfo Processors[] = {
-  // Empty processor. Include X87 and CMPXCHG8 for backwards compatibility.
-  { {""}, CK_None, ~0U, FeatureX87 | FeatureCMPXCHG8B },
-  // i386-generation processors.
-  { {"i386"}, CK_i386, ~0U, FeatureX87 },
-  // i486-generation processors.
-  { {"i486"}, CK_i486, ~0U, FeatureX87 },
-  { {"winchip-c6"}, CK_WinChipC6, ~0U, FeaturesPentiumMMX },
-  { {"winchip2"}, CK_WinChip2, ~0U, FeaturesPentiumMMX | Feature3DNOW },
-  { {"c3"}, CK_C3, ~0U, FeaturesPentiumMMX | Feature3DNOW },
-  // i586-generation processors, P5 microarchitecture based.
-  { {"i586"}, CK_i586, ~0U, FeatureX87 | FeatureCMPXCHG8B },
-  { {"pentium"}, CK_Pentium, ~0U, FeatureX87 | FeatureCMPXCHG8B },
-  { {"pentium-mmx"}, CK_PentiumMMX, ~0U, FeaturesPentiumMMX },
-  // i686-generation processors, P6 / Pentium M microarchitecture based.
-  { {"pentiumpro"}, CK_PentiumPro, ~0U, FeatureX87 | FeatureCMPXCHG8B },
-  { {"i686"}, CK_i686, ~0U, FeatureX87 | FeatureCMPXCHG8B },
-  { {"pentium2"}, CK_Pentium2, ~0U, FeaturesPentium2 },
-  { {"pentium3"}, CK_Pentium3, ~0U, FeaturesPentium3 },
-  { {"pentium3m"}, CK_Pentium3, ~0U, FeaturesPentium3 },
-  { {"pentium-m"}, CK_PentiumM, ~0U, FeaturesPentium4 },
-  { {"c3-2"}, CK_C3_2, ~0U, FeaturesPentium3 },
-  { {"yonah"}, CK_Yonah, ~0U, FeaturesPrescott },
-  // Netburst microarchitecture based processors.
-  { {"pentium4"}, CK_Pentium4, ~0U, FeaturesPentium4 },
-  { {"pentium4m"}, CK_Pentium4, ~0U, FeaturesPentium4 },
-  { {"prescott"}, CK_Prescott, ~0U, FeaturesPrescott },
-  { {"nocona"}, CK_Nocona, ~0U, FeaturesNocona },
-  // Core microarchitecture based processors.
-  { {"core2"}, CK_Core2, FEATURE_SSSE3, FeaturesCore2 },
-  { {"penryn"}, CK_Penryn, ~0U, FeaturesPenryn },
-  // Atom processors
-  { {"bonnell"}, CK_Bonnell, FEATURE_SSSE3, FeaturesBonnell },
-  { {"atom"}, CK_Bonnell, FEATURE_SSSE3, FeaturesBonnell },
-  { {"silvermont"}, CK_Silvermont, FEATURE_SSE4_2, FeaturesSilvermont },
-  { {"slm"}, CK_Silvermont, FEATURE_SSE4_2, FeaturesSilvermont },
-  { {"goldmont"}, CK_Goldmont, FEATURE_SSE4_2, FeaturesGoldmont },
-  { {"goldmont-plus"}, CK_GoldmontPlus, FEATURE_SSE4_2, FeaturesGoldmontPlus },
-  { {"tremont"}, CK_Tremont, FEATURE_SSE4_2, FeaturesTremont },
-  // Nehalem microarchitecture based processors.
-  { {"nehalem"}, CK_Nehalem, FEATURE_SSE4_2, FeaturesNehalem },
-  { {"corei7"}, CK_Nehalem, FEATURE_SSE4_2, FeaturesNehalem },
-  // Westmere microarchitecture based processors.
-  { {"westmere"}, CK_Westmere, FEATURE_PCLMUL, FeaturesWestmere },
-  // Sandy Bridge microarchitecture based processors.
-  { {"sandybridge"}, CK_SandyBridge, FEATURE_AVX, FeaturesSandyBridge },
-  { {"corei7-avx"}, CK_SandyBridge, FEATURE_AVX, FeaturesSandyBridge },
-  // Ivy Bridge microarchitecture based processors.
-  { {"ivybridge"}, CK_IvyBridge, FEATURE_AVX, FeaturesIvyBridge },
-  { {"core-avx-i"}, CK_IvyBridge, FEATURE_AVX, FeaturesIvyBridge },
-  // Haswell microarchitecture based processors.
-  { {"haswell"}, CK_Haswell, FEATURE_AVX2, FeaturesHaswell },
-  { {"core-avx2"}, CK_Haswell, FEATURE_AVX2, FeaturesHaswell },
-  // Broadwell microarchitecture based processors.
-  { {"broadwell"}, CK_Broadwell, FEATURE_AVX2, FeaturesBroadwell },
-  // Skylake client microarchitecture based processors.
-  { {"skylake"}, CK_SkylakeClient, FEATURE_AVX2, FeaturesSkylakeClient },
-  // Skylake server microarchitecture based processors.
-  { {"skylake-

[clang] a82170f - [Headers] Add some intrinsic function descriptions to immintrin.h.

2023-04-04 Thread Paul Robinson via cfe-commits

Author: Paul Robinson
Date: 2023-04-04T06:26:05-07:00
New Revision: a82170fa41ca9756b0f67d0ed015adef325e8921

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

LOG: [Headers] Add some intrinsic function descriptions to immintrin.h.

Differential Revision: https://reviews.llvm.org/D147461

Added: 


Modified: 
clang/lib/Headers/immintrin.h

Removed: 




diff  --git a/clang/lib/Headers/immintrin.h b/clang/lib/Headers/immintrin.h
index 8e109af0f5817..d382ec88f30f7 100644
--- a/clang/lib/Headers/immintrin.h
+++ b/clang/lib/Headers/immintrin.h
@@ -284,18 +284,45 @@ _rdpid_u32(void) {
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
 defined(__RDRND__)
+/// Returns a 16-bit hardware-generated random value.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDRAND  instruction.
+///
+/// \param __p
+///A pointer to a 16-bit memory location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.
 static __inline__ int __attribute__((__always_inline__, __nodebug__, 
__target__("rdrnd")))
 _rdrand16_step(unsigned short *__p)
 {
   return (int)__builtin_ia32_rdrand16_step(__p);
 }
 
+/// Returns a 32-bit hardware-generated random value.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDRAND  instruction.
+///
+/// \param __p
+///A pointer to a 32-bit memory location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.
 static __inline__ int __attribute__((__always_inline__, __nodebug__, 
__target__("rdrnd")))
 _rdrand32_step(unsigned int *__p)
 {
   return (int)__builtin_ia32_rdrand32_step(__p);
 }
 
+/// Returns a 64-bit hardware-generated random value.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDRAND  instruction.
+///
+/// \param __p
+///A pointer to a 64-bit memory location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.
 #ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, 
__target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
@@ -325,48 +352,108 @@ _rdrand64_step(unsigned long long *__p)
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
 defined(__FSGSBASE__)
 #ifdef __x86_64__
+/// Reads the FS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDFSBASE  instruction.
+///
+/// \returns The lower 32 bits of the FS base register.
 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, 
__target__("fsgsbase")))
 _readfsbase_u32(void)
 {
   return __builtin_ia32_rdfsbase32();
 }
 
+/// Reads the FS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDFSBASE  instruction.
+///
+/// \returns The contents of the FS base register.
 static __inline__ unsigned long long __attribute__((__always_inline__, 
__nodebug__, __target__("fsgsbase")))
 _readfsbase_u64(void)
 {
   return __builtin_ia32_rdfsbase64();
 }
 
+/// Reads the GS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDGSBASE  instruction.
+///
+/// \returns The lower 32 bits of the GS base register.
 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, 
__target__("fsgsbase")))
 _readgsbase_u32(void)
 {
   return __builtin_ia32_rdgsbase32();
 }
 
+/// Reads the GS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDGSBASE  instruction.
+///
+/// \returns The contents of the GS base register.
 static __inline__ unsigned long long __attribute__((__always_inline__, 
__nodebug__, __target__("fsgsbase")))
 _readgsbase_u64(void)
 {
   return __builtin_ia32_rdgsbase64();
 }
 
+/// Modifies the FS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  WRFSBASE  instruction.
+///
+/// \param __V
+///Value to use for the lower 32 bits of the FS base register.
 static __inline__ void __attribute__((__always_inline__, __nodebug__, 
__target__("fsgsbase")))
 _writefsbase_u32(unsigned int __V)
 {
   __builtin_ia32_wrfsbase32(__V);
 }
 
+/// Modifies the FS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  WRFSBASE  instruction.
+///
+/// \param __V
+///Value to use for the FS base register.
 static __inline__ void __attribute__((__always_inline__, __nodebug__, 
__target__("fsgsbase")))
 _writefsbase_u64(unsigned long long __V)
 {
   __builtin_ia32_wrfsbase64(__V);
 }
 
+/// Modifies the GS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  WRGSBASE  instruction.
+///
+/// \param __V
+///Value to use for the lower 32 bits of the GS base registe

[PATCH] D147461: [Headers] Add some intrinsic function descriptions to immintrin.h

2023-04-04 Thread Paul Robinson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa82170fa41ca: [Headers] Add some intrinsic function 
descriptions to immintrin.h. (authored by probinson).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D147461?vs=510568&id=510778#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147461/new/

https://reviews.llvm.org/D147461

Files:
  clang/lib/Headers/immintrin.h

Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -284,18 +284,45 @@
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  \
 defined(__RDRND__)
+/// Returns a 16-bit hardware-generated random value.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDRAND  instruction.
+///
+/// \param __p
+///A pointer to a 16-bit memory location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand16_step(unsigned short *__p)
 {
   return (int)__builtin_ia32_rdrand16_step(__p);
 }
 
+/// Returns a 32-bit hardware-generated random value.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDRAND  instruction.
+///
+/// \param __p
+///A pointer to a 32-bit memory location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand32_step(unsigned int *__p)
 {
   return (int)__builtin_ia32_rdrand32_step(__p);
 }
 
+/// Returns a 64-bit hardware-generated random value.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDRAND  instruction.
+///
+/// \param __p
+///A pointer to a 64-bit memory location to place the random value.
+/// \returns 1 if the value was successfully generated, 0 otherwise.
 #ifdef __x86_64__
 static __inline__ int __attribute__((__always_inline__, __nodebug__, __target__("rdrnd")))
 _rdrand64_step(unsigned long long *__p)
@@ -325,48 +352,108 @@
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  \
 defined(__FSGSBASE__)
 #ifdef __x86_64__
+/// Reads the FS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDFSBASE  instruction.
+///
+/// \returns The lower 32 bits of the FS base register.
 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
 _readfsbase_u32(void)
 {
   return __builtin_ia32_rdfsbase32();
 }
 
+/// Reads the FS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDFSBASE  instruction.
+///
+/// \returns The contents of the FS base register.
 static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
 _readfsbase_u64(void)
 {
   return __builtin_ia32_rdfsbase64();
 }
 
+/// Reads the GS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDGSBASE  instruction.
+///
+/// \returns The lower 32 bits of the GS base register.
 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
 _readgsbase_u32(void)
 {
   return __builtin_ia32_rdgsbase32();
 }
 
+/// Reads the GS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  RDGSBASE  instruction.
+///
+/// \returns The contents of the GS base register.
 static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
 _readgsbase_u64(void)
 {
   return __builtin_ia32_rdgsbase64();
 }
 
+/// Modifies the FS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  WRFSBASE  instruction.
+///
+/// \param __V
+///Value to use for the lower 32 bits of the FS base register.
 static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
 _writefsbase_u32(unsigned int __V)
 {
   __builtin_ia32_wrfsbase32(__V);
 }
 
+/// Modifies the FS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  WRFSBASE  instruction.
+///
+/// \param __V
+///Value to use for the FS base register.
 static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
 _writefsbase_u64(unsigned long long __V)
 {
   __builtin_ia32_wrfsbase64(__V);
 }
 
+/// Modifies the GS base register.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  WRGSBASE  instruction.
+///
+/// \param __V
+///Value to use for the lower 32 bits of the GS base register.
 static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("fsgsbase")))
 _writegsbase_u32(unsig

[PATCH] D143479: [Clang] Emit error when caller cannot meet target feature requirement from always-inlining callee

2023-04-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added subscribers: FreddyYe, craig.topper.
erichkeane added a comment.

Hi-
We've actually seen some regressions internally thanks to this patch, which 
boil down to:

https://godbolt.org/z/WEer4M6ha

  // compiled with -march=skylake
  __attribute__((always_inline)) inline void foo(){}
  
  __attribute__((target("arch=core-avx2")))
  void bar() {
  foo();
  }

I believe @craig.topper and I spent a long time on these things, but I'm now 
questioning what `arch=` is supposed to do in this case.  We're compiling `bar` 
as if it is an avx2 function, so it cannot call `foo`, which has additional 
features. However, they were not 'disabled'.  A part of me thinks that the 
`arch=...` should mean "has at least these features", and the bug is thus in 
the code that sets the features list.

What does everyone think?  attn: @FreddyYe


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143479/new/

https://reviews.llvm.org/D143479

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


[PATCH] D147530: [clang] Add test for CWG191

2023-04-04 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : CWG191 and CWG1200 are resolved by defining 
unqualified lookup in terms of every enclosing scope.
Wording: If no declarations are found, the results of the unqualified search 
are the results of an unqualified search in the parent scope of S, if any, from 
P. ([basic.lookup.unqual]/2)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147530

Files:
  clang/test/CXX/drs/dr1xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1183,7 +1183,7 @@
 https://wg21.link/cwg191";>191
 CD6
 Name lookup does not handle complex nesting
-Unknown
+Yes
   
   
 https://wg21.link/cwg192";>192
Index: clang/test/CXX/drs/dr1xx.cpp
===
--- clang/test/CXX/drs/dr1xx.cpp
+++ clang/test/CXX/drs/dr1xx.cpp
@@ -999,6 +999,36 @@
 
 // dr190 FIXME: add codegen test for tbaa
 
+int dr191_j;
+namespace dr191 { // dr191: yes
+  namespace example1 {
+struct outer {
+  static int i;
+  struct inner {
+void f() {
+  struct local {
+void g() {
+  i = 5;
+}
+  };
+}
+  };
+};
+  }
+
+  namespace example2 {
+struct S {
+  void f() {
+struct local2 {
+  void g() {
+dr191_j = 5;
+  }
+};
+  }
+};
+  }
+}
+
 // dr193 FIXME: add codegen test
 
 namespace dr194 { // dr194: yes


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1183,7 +1183,7 @@
 https://wg21.link/cwg191";>191
 CD6
 Name lookup does not handle complex nesting
-Unknown
+Yes
   
   
 https://wg21.link/cwg192";>192
Index: clang/test/CXX/drs/dr1xx.cpp
===
--- clang/test/CXX/drs/dr1xx.cpp
+++ clang/test/CXX/drs/dr1xx.cpp
@@ -999,6 +999,36 @@
 
 // dr190 FIXME: add codegen test for tbaa
 
+int dr191_j;
+namespace dr191 { // dr191: yes
+  namespace example1 {
+struct outer {
+  static int i;
+  struct inner {
+void f() {
+  struct local {
+void g() {
+  i = 5;
+}
+  };
+}
+  };
+};
+  }
+
+  namespace example2 {
+struct S {
+  void f() {
+struct local2 {
+  void g() {
+dr191_j = 5;
+  }
+};
+  }
+};
+  }
+}
+
 // dr193 FIXME: add codegen test
 
 namespace dr194 { // dr194: yes
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146329: [Clang] Fix defaulted equality operator so that it does not attempt to compare unnamed bit-fields

2023-04-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D146329#4242215 , @shafik wrote:

> In D146329#4207522 , @royjacobson 
> wrote:
>
>> In D146329#4203174 , @shafik wrote:
>>
>>> I would have loved to test the case from 
>>> https://github.com/llvm/llvm-project/issues/61335 directly but I think in 
>>> order to do it nicely I need `__builtin_memset` to be usable in a constant 
>>> expression context. I will add this to my todo list. I am open to other 
>>> alternatives for testing this.
>>
>> I managed to generate relatively readable LLVM IR for this: 
>> https://godbolt.org/z/z1YzoEcr3 (the generated equality operators are 
>> obviously not correct yet), I think matching against that is testing the 
>> issue pretty well.
>>
>> (The trick to making it readable was turning on optimization, though. Not 
>> sure if we usually do that)
>
> I think in general we can't rely on optimizations in test like this but wdyt 
> @erichkeane

We should not have opt enabled in our lit tests, thats correct.  However, the 
non-optimized version of that godbolt link has reasonably readable IR that we 
can test.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146329/new/

https://reviews.llvm.org/D146329

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


[PATCH] D147525: [X86] Add AMX_COMPLEX to Graniterapids

2023-04-04 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 510783.
FreddyYe added a comment.

Remove redundant file.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147525/new/

https://reviews.llvm.org/D147525

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Headers/immintrin.h
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp


Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -208,7 +208,8 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
+FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI |
+FeatureAMX_COMPLEX;
 
 // Intel Atom processors.
 // Bonnell has feature parity with Core2 and adds MOVBE.
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1054,7 +1054,8 @@
 
   // Graniterapids
   list GNRAdditionalFeatures = [FeatureAMXFP16,
-  FeaturePREFETCHI];
+  FeaturePREFETCHI,
+  FeatureAMXCOMPLEX];
   list GNRFeatures =
 !listconcat(SPRFeatures, GNRAdditionalFeatures);
 
Index: clang/test/Preprocessor/x86_target_features.c
===
--- clang/test/Preprocessor/x86_target_features.c
+++ clang/test/Preprocessor/x86_target_features.c
@@ -562,14 +562,14 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-complex -x 
c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=AMX-COMPLEX %s
 
-// AMX-COMPLEX: #define __AMXCOMPLEX__ 1
+// AMX-COMPLEX: #define __AMX_COMPLEX__ 1
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mno-amx-complex 
-x c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-COMPLEX %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=x86-64 -mamx-complex 
-mno-amx-tile \
 // RUN: -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-COMPLEX %s
 
-// NO-AMX-COMPLEX-NOT: #define __AMXCOMPLEX__ 1
+// NO-AMX-COMPLEX-NOT: #define __AMX_COMPLEX__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavxvnni -x c -E -dM 
-o - %s | FileCheck -match-full-lines --check-prefix=AVXVNNI %s
 
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1798,6 +1798,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M32
 // CHECK_GNR_M32: #define __AES__ 1
 // CHECK_GNR_M32: #define __AMX_BF16__ 1
+// CHECK_GNR_M32: #define __AMX_COMPLEX__ 1
 // CHECK_GNR_M32: #define __AMX_FP16__ 1
 // CHECK_GNR_M32: #define __AMX_INT8__ 1
 // CHECK_GNR_M32: #define __AMX_TILE__ 1
@@ -1872,6 +1873,7 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_GNR_M64
 // CHECK_GNR_M64: #define __AES__ 1
 // CHECK_GNR_M64: #define __AMX_BF16__ 1
+// CHECK_GNR_M64: #define __AMX_COMPLEX__ 1
 // CHECK_GNR_M64: #define __AMX_FP16__ 1
 // CHECK_GNR_M64: #define __AMX_INT8__ 1
 // CHECK_GNR_M64: #define __AMX_TILE__ 1
Index: clang/lib/Headers/immintrin.h
===
--- clang/lib/Headers/immintrin.h
+++ clang/lib/Headers/immintrin.h
@@ -539,7 +539,7 @@
 #endif
 
 #if !(defined(_MSC_VER) || defined(__SCE__)) || __has_feature(modules) ||  
\
-defined(__AMXCOMPLEX__)
+defined(__AMX_COMPLEX__)
 #include 
 #endif
 
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -802,7 +802,7 @@
   if (HasAMXFP16)
 Builder.defineMacro("__AMX_FP16__");
   if (HasAMXCOMPLEX)
-Builder.defineMacro("__AMXCOMPLEX__");
+Builder.defineMacro("__AMX_COMPLEX__");
   if (HasCMPCCXADD)
 Builder.defineMacro("__CMPCCXADD__");
   if (HasRAOINT)


Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -208,7 +208,8 @@
 FeatureSERIALIZE | FeatureSHSTK | FeatureTSXLDTRK | FeatureUINTR |
 FeatureWAITPKG;
 constexpr FeatureBitset FeaturesGraniteRapids =
-FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI;
+FeaturesSapphireRapids | FeatureAMX_FP16 | FeaturePREFETCHI |
+FeatureAMX_COMPLEX;
 
 // Intel Atom processors

[PATCH] D143479: [Clang] Emit error when caller cannot meet target feature requirement from always-inlining callee

2023-04-04 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D143479#4243090 , @erichkeane 
wrote:

> Hi-
> We've actually seen some regressions internally thanks to this patch, which 
> boil down to:
>
> https://godbolt.org/z/WEer4M6ha
>
>   // compiled with -march=skylake
>   __attribute__((always_inline)) inline void foo(){}
>   
>   __attribute__((target("arch=core-avx2")))
>   void bar() {
>   foo();
>   }
>
> I believe @craig.topper and I spent a long time on these things, but I'm now 
> questioning what `arch=` is supposed to do in this case.  We're compiling 
> `bar` as if it is an avx2 function, so it cannot call `foo`, which has 
> additional features. However, they were not 'disabled'.  A part of me thinks 
> that the `arch=...` should mean "has at least these features", and the bug is 
> thus in the code that sets the features list.
>
> What does everyone think?  attn: @FreddyYe

Based on GCC's behavior: https://godbolt.org/z/fxWzPTT9P  I suspect our 
behavior is consistent/correct now, and the 'regressions' are to be expected, 
since GCC diagnoses the same things we do (just nicer, albeit, less 
informative).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143479/new/

https://reviews.llvm.org/D143479

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


[PATCH] D147525: [X86] Add AMX_COMPLEX to Graniterapids

2023-04-04 Thread Kan Shengchen via Phabricator via cfe-commits
skan accepted this revision.
skan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147525/new/

https://reviews.llvm.org/D147525

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Due not resetting that, clang still thinks that it is in immediate
function context even if it is already entered non-consteval function.
It caused consteval functions reaching codegen in some cases.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,23 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void g() {
+f();
+  }
+  consteval static void f() {};
+};
+
+consteval void a() {
+  Test::g();
+}
+
+void b() {
+  Test::g();
+}
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15174,6 +15174,7 @@
 PushExpressionEvaluationContext(
 FD->isConsteval() ? 
ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
+ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
 
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix assertion hit when template consteval function appears in nested
+  consteval/constexpr call chain.
+  (`#61142 `_)
 
 
 Bug Fixes to Compiler Builtins


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,23 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void g() {
+f();
+  }
+  consteval static void f() {};
+};
+
+consteval void a() {
+  Test::g();
+}
+
+void b() {
+  Test::g();
+}
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15174,6 +15174,7 @@
 PushExpressionEvaluationContext(
 FD->isConsteval() ? ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
+ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
 
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix assertion hit when template consteval function appears in nested
+  consteval/constexpr call chain.
+  (`#61142 `_)
 
 
 Bug Fixes to Compiler Builtins
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-04-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:2357-2361
+if (SubobjectDecl) {
+  Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << 
SubobjectDecl;
+  Info.Note(SubobjectDecl->getLocation(),
+diag::note_constexpr_subobject_declared_here);
+}

hazohelet wrote:
> aaron.ballman wrote:
> > Hmm, this breaks one of the contracts of our constexpr evaluation engine, 
> > doesn't it? My understanding is that if constexpr evaluation fails, we will 
> > have emitted a note diagnostic for why it failed. But if the caller doesn't 
> > pass a nonnull `SubobjectDecl`, we'll return `false` but we won't issue a 
> > diagnostic.
> > 
> > I'm surprised no tests lost notes as a result of this change, that suggests 
> > we're missing test coverage for the cases where nullptr is passed in 
> > explicitly to this function.
> Yeah, I was looking into when `SubobjectDecl` can be null here. I `assert`ed 
> the non-nullness of `SubobjectDecl` before and found that there exists two 
> lines of code 
> (https://github.com/llvm/llvm-project/blob/22a3f974d35da89247c0396594f2e4cd592742eb/clang/test/SemaCXX/attr-weak.cpp#L49
>  and 
> https://github.com/llvm/llvm-project/blob/abf4a8cb15d4faf04ee0da14e37d7349d3bde9a1/clang/test/CodeGenCXX/weak-external.cpp#L97)
>  in the test codes that nulls here.
> It seems they are doing the same thing, doing comparison against a pointer to 
> a `[[gnu::weak]]` member. A simple reproducing code is here: 
> https://godbolt.org/z/qn997n85n
> As you can see from the compiler explorer, there's no note emitted here 
> before the patch.
> I inserted some `printf` into the code before this patch  and confirmed 
> `Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << true << Type` 
> was actually called when compiling the reproducing code and that somehow it 
> is ignored. FWIW, `SubobjectLoc.isValid()` was `false` here.
> It seems they are doing the same thing, doing comparison against a pointer to 
> a [[gnu::weak]] member. A simple reproducing code is here: 
> https://godbolt.org/z/qn997n85n
> As you can see from the compiler explorer, there's no note emitted here 
> before the patch.

I see a note generated there:
```
:4:41: note: comparison against pointer to weak member 
'Weak::weak_method' can only be performed at runtime
constexpr bool val = &Weak::weak_method != nullptr;
^
```
The situations I'm concerned about are the changes to ExprConstant.cpp:2270 or 
line 2399 and so on.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146358/new/

https://reviews.llvm.org/D146358

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


[PATCH] D147530: [clang] Add test for CWG191

2023-04-04 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill updated this revision to Diff 510793.
Endill edited the summary of this revision.
Endill added a comment.

Mark CWG1200 as "na" and enable newer standard versions in RUN lines


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147530/new/

https://reviews.llvm.org/D147530

Files:
  clang/test/CXX/drs/dr12xx.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1183,7 +1183,7 @@
 https://wg21.link/cwg191";>191
 CD6
 Name lookup does not handle complex nesting
-Unknown
+Yes
   
   
 https://wg21.link/cwg192";>192
@@ -7007,7 +7007,7 @@
 https://wg21.link/cwg1200";>1200
 CD6
 Lookup rules for template parameters
-Unknown
+N/A
   
   
 https://wg21.link/cwg1201";>1201
Index: clang/test/CXX/drs/dr1xx.cpp
===
--- clang/test/CXX/drs/dr1xx.cpp
+++ clang/test/CXX/drs/dr1xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify 
-fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr100 { // dr100: yes
   template struct A {}; // expected-note 0-1{{declared 
here}}
@@ -999,6 +1000,36 @@
 
 // dr190 FIXME: add codegen test for tbaa
 
+int dr191_j;
+namespace dr191 { // dr191: yes
+  namespace example1 {
+struct outer {
+  static int i;
+  struct inner {
+void f() {
+  struct local {
+void g() {
+  i = 5;
+}
+  };
+}
+  };
+};
+  }
+
+  namespace example2 {
+struct S {
+  void f() {
+struct local2 {
+  void g() {
+dr191_j = 5;
+  }
+};
+  }
+};
+  }
+}
+
 // dr193 FIXME: add codegen test
 
 namespace dr194 { // dr194: yes
Index: clang/test/CXX/drs/dr12xx.cpp
===
--- clang/test/CXX/drs/dr12xx.cpp
+++ clang/test/CXX/drs/dr12xx.cpp
@@ -1,7 +1,11 @@
 // RUN: %clang_cc1 -std=c++98 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++11 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
-// RUN: %clang_cc1 -std=c++1z %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+
+// dr1200: na
 
 namespace dr1213 { // dr1213: 7
 #if __cplusplus >= 201103L


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1183,7 +1183,7 @@
 https://wg21.link/cwg191";>191
 CD6
 Name lookup does not handle complex nesting
-Unknown
+Yes
   
   
 https://wg21.link/cwg192";>192
@@ -7007,7 +7007,7 @@
 https://wg21.link/cwg1200";>1200
 CD6
 Lookup rules for template parameters
-Unknown
+N/A
   
   
 https://wg21.link/cwg1201";>1201
Index: clang/test/CXX/drs/dr1xx.cpp
===
--- clang/test/CXX/drs/dr1xx.cpp
+++ clang/test/CXX/drs/dr1xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b -triple x86_64-unknown-unknown %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 namespace dr100 { // dr100: yes
   template struct A {}; // expected-note 0-1{{declared here}}
@@ -999,6 +1000,36 @@
 
 // dr190 FIXME: add codegen test for tbaa
 
+int dr191_j;
+namespace dr191 { // dr191: yes
+  namespace example1 {
+struct outer {
+  static int i;
+  struct inner {
+void f() {
+  struct local {
+void g() {
+  i = 5;
+}
+  };
+}
+  };
+};
+  }
+
+  namespace example2 {
+struct S {
+  void f() {
+struct local2 {
+  void g()

[PATCH] D147395: [Clangd] Make the type hint length limit configurable

2023-04-04 Thread Yi Zhang via Phabricator via cfe-commits
zhangyi1357 updated this revision to Diff 510795.
zhangyi1357 added a comment.

- [Clangd] Add unittest for TypeNameLimit config


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147395/new/

https://reviews.llvm.org/D147395

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -77,6 +77,7 @@
   C.InlayHints.Parameters = false;
   C.InlayHints.DeducedTypes = false;
   C.InlayHints.Designators = false;
+  C.InlayHints.TypeNameLimit = 1;
   return C;
 }
 
@@ -1324,6 +1325,21 @@
 // Omit type hint past a certain length (currently 32)
 auto var = foo();
   )cpp");
+
+  Config Cfg;
+  Cfg.InlayHints.TypeNameLimit = 0;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+
+  assertTypeHints(
+  R"cpp(
+template 
+struct A {};
+struct MultipleWords {};
+A foo();
+// Should have type hint with TypeNameLimit = 0
+auto $var[[var]] = foo();
+  )cpp",
+  ExpectedHint{": A", "var"});
 }
 
 TEST(TypeHints, DefaultTemplateArgs) {
Index: clang-tools-extra/clangd/InlayHints.cpp
===
--- clang-tools-extra/clangd/InlayHints.cpp
+++ clang-tools-extra/clangd/InlayHints.cpp
@@ -688,7 +688,8 @@
   return;
 
 std::string TypeName = T.getAsString(Policy);
-if (TypeName.length() < TypeNameLimit)
+if (Cfg.InlayHints.TypeNameLimit == 0 ||
+TypeName.length() < Cfg.InlayHints.TypeNameLimit)
   addInlayHint(R, HintSide::Right, InlayHintKind::Type, Prefix, TypeName,
/*Suffix=*/"");
   }
@@ -714,8 +715,6 @@
   // the policies are initialized for more details.)
   PrintingPolicy TypeHintPolicy;
   PrintingPolicy StructuredBindingPolicy;
-
-  static const size_t TypeNameLimit = 32;
 };
 
 } // namespace
Index: clang-tools-extra/clangd/ConfigYAML.cpp
===
--- clang-tools-extra/clangd/ConfigYAML.cpp
+++ clang-tools-extra/clangd/ConfigYAML.cpp
@@ -254,6 +254,10 @@
   if (auto Value = boolValue(N, "Designators"))
 F.Designators = *Value;
 });
+Dict.handle("TypeNameLimit", [&](Node &N) {
+  if (auto Value = uint32Value(N, "TypeNameLimit"))
+F.TypeNameLimit = *Value;
+});
 Dict.parse(N);
   }
 
@@ -375,6 +379,17 @@
 return std::nullopt;
   }
 
+  std::optional> uint32Value(Node &N, llvm::StringRef Desc) {
+if (auto Scalar = scalarValue(N, Desc)) {
+  unsigned long long Num;
+  if (!llvm::getAsUnsignedInteger(**Scalar, 0, Num)) {
+return Located(Num, Scalar->Range);
+  }
+}
+warning(Desc + " invalid number", N);
+return std::nullopt;
+  }
+
   // Try to parse a list of single scalar values, or just a single value.
   std::optional>> scalarValues(Node &N) {
 std::vector> Result;
Index: clang-tools-extra/clangd/ConfigFragment.h
===
--- clang-tools-extra/clangd/ConfigFragment.h
+++ clang-tools-extra/clangd/ConfigFragment.h
@@ -322,6 +322,8 @@
 std::optional> DeducedTypes;
 /// Show designators in aggregate initialization.
 std::optional> Designators;
+/// Limit the length of type name hints. (0 means no limit)
+std::optional> TypeNameLimit;
   };
   InlayHintsBlock InlayHints;
 };
Index: clang-tools-extra/clangd/ConfigCompile.cpp
===
--- clang-tools-extra/clangd/ConfigCompile.cpp
+++ clang-tools-extra/clangd/ConfigCompile.cpp
@@ -611,6 +611,11 @@
   Out.Apply.push_back([Value(**F.Designators)](const Params &, Config &C) {
 C.InlayHints.Designators = Value;
   });
+if (F.TypeNameLimit)
+  Out.Apply.push_back(
+  [Value(**F.TypeNameLimit)](const Params &, Config &C) {
+C.InlayHints.TypeNameLimit = Value;
+  });
   }
 
   constexpr static llvm::SourceMgr::DiagKind Error = llvm::SourceMgr::DK_Error;
Index: clang-tools-extra/clangd/Config.h
===
--- clang-tools-extra/clangd/Config.h
+++ clang-tools-extra/clangd/Config.h
@@ -147,6 +147,8 @@
 bool Parameters = true;
 bool DeducedTypes = true;
 bool Designators = true;
+// Limit the length of type names in inlay hints. (0 means no limit)
+uint32_t TypeNameLimit = 32;
   } InlayHints;
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/lis

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Thanks, for working on this
Congrats on finding the underlying issue, it must not have been easy!




Comment at: clang/lib/Sema/SemaDecl.cpp:15177
   : ExprEvalContexts.back().Context);
+ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
 

I think it might be worth adding a comment there to explain why this is 
necessary.
I think i convinced myself this make sense and is almost certainly the correct 
fix but it would, I think, benefit from some more explanation for future 
reference.





Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:138
+
+} // namespace GH61142


Just to make sure, did you check that this fixes the other examples in the 
issue? I was afraid i reduced too much


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2023-04-04 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 510797.
jhuber6 added a comment.
Herald added subscribers: kbarton, nemanjai.

Fixed the Clang tests. Haven't touched the LLVM ones because this breaks 
SPMDzation and state machine rewrites completely in those tests. Someone who 
knows what this patch changes should look into what needs to be updated to make 
those tests match whatever form SPDMzation expects now. Also for some bizarre 
reason this patch breaks adding `alwaysinline` on `kmpc_parallel_51`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102107/new/

https://reviews.llvm.org/D102107

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/OpenMP/amdgpu_target_with_aligned_attribute.c
  clang/test/OpenMP/bug54082.c
  clang/test/OpenMP/bug60602.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/debug_threadprivate_copyin.c
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_constexpr_codegen.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/irbuilder_safelen.cpp
  clang/test/OpenMP/irbuilder_safelen_order_concurrent.cpp
  clang/test/OpenMP/irbuilder_simd_aligned.cpp
  clang/test/OpenMP/irbuilder_simdlen.cpp
  clang/test/OpenMP/irbuilder_simdlen_safelen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/nested_loop_codegen.cpp
  clang/test/OpenMP/nvptx_SPMD_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codege

[PATCH] D147534: [clang][Interp] Make sure we have a variable scope for initializers

2023-04-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  Otherwise, we run into an assertion when trying to use the current
  variable scope while creating temporaries for constructor initializers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147534

Files:
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/test/AST/Interp/records.cpp


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -252,6 +252,26 @@
 constexpr S s;
 static_assert(s.m() == 1, "");
 
+namespace InitializerTemporaries {
+  class Bar {
+  private:
+int a;
+
+  public:
+constexpr Bar() : a(10) {}
+constexpr int getA() const { return a; }
+  };
+
+  class Foo {
+  public:
+int a;
+
+constexpr Foo() : a(Bar().getA()) {}
+  };
+  constexpr Foo F;
+  static_assert(F.a == 10, "");
+}
+
 #if __cplusplus >= 201703L
 namespace BaseInit {
   class _A {public: int a;};
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -94,6 +94,9 @@
   // Classify the return type.
   ReturnType = this->classify(F->getReturnType());
 
+  // Scope needed for the initializers.
+  BlockScope Scope(this);
+
   // Constructor. Set up field initializers.
   if (const auto Ctor = dyn_cast(F)) {
 const RecordDecl *RD = Ctor->getParent();


Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -252,6 +252,26 @@
 constexpr S s;
 static_assert(s.m() == 1, "");
 
+namespace InitializerTemporaries {
+  class Bar {
+  private:
+int a;
+
+  public:
+constexpr Bar() : a(10) {}
+constexpr int getA() const { return a; }
+  };
+
+  class Foo {
+  public:
+int a;
+
+constexpr Foo() : a(Bar().getA()) {}
+  };
+  constexpr Foo F;
+  static_assert(F.a == 10, "");
+}
+
 #if __cplusplus >= 201703L
 namespace BaseInit {
   class _A {public: int a;};
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -94,6 +94,9 @@
   // Classify the return type.
   ReturnType = this->classify(F->getReturnType());
 
+  // Scope needed for the initializers.
+  BlockScope Scope(this);
+
   // Constructor. Set up field initializers.
   if (const auto Ctor = dyn_cast(F)) {
 const RecordDecl *RD = Ctor->getParent();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147535: [clang][Interp] Don't create global variables more than once

2023-04-04 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, tahonermann, shafik, erichkeane.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  just because we're being told to evaluate it twice. This sometimes
  happens when a variable is evaluated again during codegen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147535

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1564,7 +1564,11 @@
   std::optional VarT = classify(VD->getType());
 
   if (shouldBeGloballyIndexed(VD)) {
-std::optional GlobalIndex = P.getOrCreateGlobal(VD, Init);
+// We've already seen and initialized this global.
+if (P.getGlobal(VD))
+  return true;
+
+std::optional GlobalIndex = P.createGlobal(VD, Init);
 
 if (!GlobalIndex)
   return this->bail(VD);


Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1564,7 +1564,11 @@
   std::optional VarT = classify(VD->getType());
 
   if (shouldBeGloballyIndexed(VD)) {
-std::optional GlobalIndex = P.getOrCreateGlobal(VD, Init);
+// We've already seen and initialized this global.
+if (P.getGlobal(VD))
+  return true;
+
+std::optional GlobalIndex = P.createGlobal(VD, Init);
 
 if (!GlobalIndex)
   return this->bail(VD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 74cc438 - [clang-format] Add option for having one port per line in Verilog

2023-04-04 Thread via cfe-commits

Author: sstwcw
Date: 2023-04-04T14:51:22Z
New Revision: 74cc4389f37d753bf07f1b4a4a4c5e09433d9231

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

LOG: [clang-format] Add option for having one port per line in Verilog

We added the option `VerilogBreakBetweenInstancePorts` to put ports on
separate lines in module instantiations.  We made it default to true
because style guides mostly recommend it that way for example:

https://github.com/lowRISC/style-guides/blob/master/VerilogCodingStyle.md#module-instantiation

Reviewed By: HazardyKnusperkeks

Differential Revision: https://reviews.llvm.org/D147327

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTestVerilog.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4078019f82bad..527bdff5f5b56 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5302,6 +5302,22 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+.. _VerilogBreakBetweenInstancePorts:
+
+**VerilogBreakBetweenInstancePorts** (``Boolean``) :versionbadge:`clang-format 
17` :ref:`¶ `
+  For Verilog, put each port on its own line in module instantiations.
+
+  .. code-block:: c++
+
+ true:
+ ffnand ff1(.q(),
+.qbar(out1),
+.clear(in1),
+.preset(in2));
+
+ false:
+ ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
+
 .. _WhitespaceSensitiveMacros:
 
 **WhitespaceSensitiveMacros** (``List of Strings``) 
:versionbadge:`clang-format 11` :ref:`¶ `

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 85daa50b5bac8..755621ec53d63 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4219,6 +4219,20 @@ struct FormatStyle {
   /// \version 3.7
   UseTabStyle UseTab;
 
+  /// For Verilog, put each port on its own line in module instantiations.
+  /// \code
+  ///true:
+  ///ffnand ff1(.q(),
+  ///   .qbar(out1),
+  ///   .clear(in1),
+  ///   .preset(in2));
+  ///
+  ///false:
+  ///ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));
+  /// \endcode
+  /// \version 17
+  bool VerilogBreakBetweenInstancePorts;
+
   /// A vector of macros which are whitespace-sensitive and should not
   /// be touched.
   ///
@@ -4388,6 +4402,8 @@ struct FormatStyle {
StatementAttributeLikeMacros == R.StatementAttributeLikeMacros &&
StatementMacros == R.StatementMacros && TabWidth == R.TabWidth &&
TypenameMacros == R.TypenameMacros && UseTab == R.UseTab &&
+   VerilogBreakBetweenInstancePorts ==
+   R.VerilogBreakBetweenInstancePorts &&
WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
   }
 

diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 97c4867fcb449..248d3684d01f2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1038,6 +1038,8 @@ template <> struct MappingTraits {
 IO.mapOptional("TabWidth", Style.TabWidth);
 IO.mapOptional("TypenameMacros", Style.TypenameMacros);
 IO.mapOptional("UseTab", Style.UseTab);
+IO.mapOptional("VerilogBreakBetweenInstancePorts",
+   Style.VerilogBreakBetweenInstancePorts);
 IO.mapOptional("WhitespaceSensitiveMacros",
Style.WhitespaceSensitiveMacros);
 IO.mapOptional("Macros", Style.Macros);
@@ -1462,6 +1464,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.StatementMacros.push_back("QT_REQUIRE_VERSION");
   LLVMStyle.TabWidth = 8;
   LLVMStyle.UseTab = FormatStyle::UT_Never;
+  LLVMStyle.VerilogBreakBetweenInstancePorts = true;
   LLVMStyle.WhitespaceSensitiveMacros.push_back("BOOST_PP_STRINGIZE");
   LLVMStyle.WhitespaceSensitiveMacros.push_back("CF_SWIFT_NAME");
   LLVMStyle.WhitespaceSensitiveMacros.push_back("NS_SWIFT_NAME");

diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 59d4a871f7eca..dc136428082e0 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -152,6 +152,9 @@ namespace format {
* In 'logic [1:0] x[1:0]', only the first '['. This way we can have space   
\
* before the first bracket but not the second. */   
\
   TYPE(VerilogDimensionedTypeName) 
\
+  /* list of port connection

[PATCH] D147327: [clang-format] Add option for having one port per line in Verilog

2023-04-04 Thread sstwcw via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74cc4389f37d: [clang-format] Add option for having one port 
per line in Verilog (authored by sstwcw).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147327/new/

https://reviews.llvm.org/D147327

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTestVerilog.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1645,6 +1645,18 @@
   EXPECT_TOKEN_PRECEDENCE(Tokens[1], prec::Assignment);
   EXPECT_TOKEN(Tokens[3], tok::lessequal, TT_BinaryOperator);
   EXPECT_TOKEN_PRECEDENCE(Tokens[3], prec::Relational);
+
+  // Port lists in module instantiation.
+  Tokens = Annotate("module_x instance_1(port_1), instance_2(port_2);");
+  ASSERT_EQ(Tokens.size(), 12u);
+  EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_VerilogInstancePortLParen);
+  EXPECT_TOKEN(Tokens[7], tok::l_paren, TT_VerilogInstancePortLParen);
+  Tokens = Annotate("module_x #(parameter) instance_1(port_1), "
+"instance_2(port_2);");
+  ASSERT_EQ(Tokens.size(), 16u);
+  EXPECT_TOKEN(Tokens[2], tok::l_paren, TT_VerilogInstancePortLParen);
+  EXPECT_TOKEN(Tokens[6], tok::l_paren, TT_VerilogInstancePortLParen);
+  EXPECT_TOKEN(Tokens[11], tok::l_paren, TT_VerilogInstancePortLParen);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandConstructors) {
Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -673,6 +673,77 @@
"  x = x;");
 }
 
+TEST_F(FormatTestVerilog, Instantiation) {
+  // Without ports.
+  verifyFormat("ffnand ff1;");
+  // With named ports.
+  verifyFormat("ffnand ff1(.qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  // With wildcard.
+  verifyFormat("ffnand ff1(.qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2),\n"
+   "   .*);");
+  verifyFormat("ffnand ff1(.*,\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  // With unconnected ports.
+  verifyFormat("ffnand ff1(.q(),\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  verifyFormat("ffnand ff1(.q(),\n"
+   "   .qbar(),\n"
+   "   .clear(),\n"
+   "   .preset());");
+  verifyFormat("ffnand ff1(,\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  // With positional ports.
+  verifyFormat("ffnand ff1(out1,\n"
+   "   in1,\n"
+   "   in2);");
+  verifyFormat("ffnand ff1(,\n"
+   "   out1,\n"
+   "   in1,\n"
+   "   in2);");
+  // Multiple instantiations.
+  verifyFormat("ffnand ff1(.q(),\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2)),\n"
+   "   ff1(.q(),\n"
+   "   .qbar(out1),\n"
+   "   .clear(in1),\n"
+   "   .preset(in2));");
+  verifyFormat("ffnand //\n"
+   "ff1(.q(),\n"
+   ".qbar(out1),\n"
+   ".clear(in1),\n"
+   ".preset(in2)),\n"
+   "ff1(.q(),\n"
+   ".qbar(out1),\n"
+   ".clear(in1),\n"
+   ".preset(in2));");
+  // With breaking between instance ports disabled.
+  auto Style = getDefaultStyle();
+  Style.VerilogBreakBetweenInstancePorts = false;
+  verifyFormat("ffnand ff1;", Style);
+  verifyFormat("ffnand ff1(.qbar(out1), .clear(in1), .preset(in2), .*);",
+   Style);
+  verifyFormat("ffnand ff1(out1, in1, in2);", Style);
+  verifyFormat("ffnand ff1(.q(), .qbar(out1), .clear(in1), .preset(in2)),\n"
+   "   ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));",
+   Style);
+  verifyFormat("ffnand //\n"
+   "ff1(.q(), .qbar(out1), .clear(in1), .preset(in2)),\n"
+   "ff1(.q(), .qbar(out1), .clear(in1), .preset(in2));",
+   Style);
+}
+
 T

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 510807.
Fznamznon added a comment.

Add a comment, rebase, fix format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,23 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void g() {
+f();
+  }
+  consteval static void f() {};
+};
+
+consteval void a() {
+  Test::g();
+}
+
+void b() {
+  Test::g();
+}
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15175,6 +15175,16 @@
 FD->isConsteval() ? 
ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
 
+  // Each ExpressionEvaluationContextRecord also keeps track on whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when the new
+  // function is entered, we need to reset this tracking, since entered 
function
+  // might be not an immediate one and therefore everything inside of it needs
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix assertion hit when template consteval function appears in nested
+  consteval/constexpr call chain.
+  (`#61142 `_)
 
 
 Bug Fixes to Compiler Builtins


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,23 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void g() {
+f();
+  }
+  consteval static void f() {};
+};
+
+consteval void a() {
+  Test::g();
+}
+
+void b() {
+  Test::g();
+}
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15175,6 +15175,16 @@
 FD->isConsteval() ? ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
 
+  // Each ExpressionEvaluationContextRecord also keeps track on whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when the new
+  // function is entered, we need to reset this tracking, since entered function
+  // might be not an immediate one and therefore everything inside of it needs
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix assertion hit when template consteval function appears in nested
+  consteval/constexpr call chain.
+  (`#61142 `_)
 
 
 Bug Fixes to Compiler Builtins
___
cfe-commits mailing list
cfe-commits@l

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:15177
   : ExprEvalContexts.back().Context);
+ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
 

cor3ntin wrote:
> I think it might be worth adding a comment there to explain why this is 
> necessary.
> I think i convinced myself this make sense and is almost certainly the 
> correct fix but it would, I think, benefit from some more explanation for 
> future reference.
> 
> 
Sure, done. Hope it turned out helpful.



Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:138
+
+} // namespace GH61142

cor3ntin wrote:
> 
> Just to make sure, did you check that this fixes the other examples in the 
> issue? I was afraid i reduced too much
Yes, it helps to fix them. I checked even the original big one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Anubhab Ghosh via Phabricator via cfe-commits
argentite created this revision.
Herald added subscribers: mattd, carlosgalvezp, yaxunl.
Herald added a project: All.
argentite updated this revision to Diff 507049.
argentite added a comment.
argentite updated this revision to Diff 510808.
argentite edited the summary of this revision.
argentite added reviewers: v.g.vassilev, sgraenitz, lhames.
argentite published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Use full name of CUDA library


argentite added a comment.

Clear LinkModules on every interpreter iteration


CUDA support can be enabled in clang-repl with --cuda flag.
Device code linking is not yet supported. inline must be used with all
__device__ functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146389

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/lib/Interpreter/Offload.cpp
  clang/lib/Interpreter/Offload.h
  clang/tools/clang-repl/ClangRepl.cpp

Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -23,6 +23,9 @@
 #include "llvm/Support/TargetSelect.h" // llvm::Initialize*
 #include 
 
+static llvm::cl::opt CudaEnabled("cuda", llvm::cl::Hidden);
+static llvm::cl::opt OffloadArch("offload-arch", llvm::cl::Hidden);
+
 static llvm::cl::list
 ClangArgs("Xcc",
   llvm::cl::desc("Argument to pass to the CompilerInvocation"),
@@ -90,9 +93,29 @@
 return 0;
   }
 
+  std::unique_ptr DeviceCI;
+  if (CudaEnabled) {
+// initialize NVPTX backend
+LLVMInitializeNVPTXTargetInfo();
+LLVMInitializeNVPTXTarget();
+LLVMInitializeNVPTXTargetMC();
+LLVMInitializeNVPTXAsmPrinter();
+
+auto DeviceArgv = ClangArgv;
+
+DeviceCI = ExitOnErr(
+clang::IncrementalCudaCompilerBuilder::createDevice(DeviceArgv));
+  }
+
   // FIXME: Investigate if we could use runToolOnCodeWithArgs from tooling. It
   // can replace the boilerplate code for creation of the compiler instance.
-  auto CI = ExitOnErr(clang::IncrementalCompilerBuilder::create(ClangArgv));
+  std::unique_ptr CI;
+  if (CudaEnabled) {
+CI = ExitOnErr(clang::IncrementalCudaCompilerBuilder::createHost(
+ClangArgv, "/tmp/clang-repl.fatbin"));
+  } else {
+CI = ExitOnErr(clang::IncrementalCompilerBuilder::createCpp(ClangArgv));
+  }
 
   // Set an error handler, so that any LLVM backend diagnostics go through our
   // error handler.
@@ -102,7 +125,19 @@
   // Load any requested plugins.
   CI->LoadRequestedPlugins();
 
-  auto Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
+  std::unique_ptr Interp;
+  if (CudaEnabled) {
+if (OffloadArch.empty()) {
+  OffloadArch = "sm_35";
+}
+Interp = ExitOnErr(clang::Interpreter::createWithCUDA(
+std::move(CI), std::move(DeviceCI), OffloadArch,
+"/tmp/clang-repl.fatbin"));
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else
+Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
+
   for (const std::string &input : OptInputs) {
 if (auto Err = Interp->ParseAndExecute(input))
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
Index: clang/lib/Interpreter/Offload.h
===
--- /dev/null
+++ clang/lib/Interpreter/Offload.h
@@ -0,0 +1,47 @@
+//===--- Offload.h - CUDA Offloading *- 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 implements classes required for offloading to CUDA devices.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_INTERPRETER_OFFLOAD_H
+#define LLVM_CLANG_LIB_INTERPRETER_OFFLOAD_H
+
+#include "IncrementalParser.h"
+
+namespace clang {
+
+class DeviceCodeInlinerAction;
+
+class IncrementalCUDADeviceParser : public IncrementalParser {
+public:
+  IncrementalCUDADeviceParser(std::unique_ptr Instance,
+  llvm::LLVMContext &LLVMCtx, llvm::StringRef Arch,
+  llvm::StringRef FatbinFile, llvm::Error &Err);
+
+  llvm::Expected
+  Parse(llvm::StringRef Input) override;
+
+  // Generate PTX for the last PTU
+  llvm::Expected GeneratePTX();
+
+  // Write last PTX to the fatbinary file
+  llvm::Error WriteFatbinary() const;
+
+  ~IncrementalCUDADeviceParser();
+
+protected:
+  int SMVersion;
+  

[clang] 8ec36e6 - [clang][modules] Handle explicit modules when checking for .Private -> _Private

2023-04-04 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2023-04-04T08:12:10-07:00
New Revision: 8ec36e6956cb03d80f3fee8e593808c43a8a1ec3

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

LOG: [clang][modules] Handle explicit modules when checking for .Private -> 
_Private

While we eventually want to remove the mapping from .Private to _Private
modules, until we do, ensure that it behaves the same for explicit
modules.

rdar://107449872

Differential Revision: https://reviews.llvm.org/D147477

Added: 
clang/test/Modules/implicit-private-with-submodule-explicit.m

Modified: 
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 691f779b5966c..51fe77630bf7a 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -2026,8 +2026,12 @@ CompilerInstance::loadModule(SourceLocation ImportLoc,
   PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
   PrivPath.push_back(std::make_pair(&II, Path[0].second));
 
+  std::string FileName;
+  // If there is a modulemap module or prebuilt module, load it.
   if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, ImportLoc, 
true,
- !IsInclusionDirective))
+ !IsInclusionDirective) ||
+  selectModuleSource(nullptr, PrivateModule, FileName, BuiltModules,
+ PP->getHeaderSearchInfo()) != MS_ModuleNotFound)
 Sub = loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
   if (Sub) {
 MapPrivateSubModToTopLevel = true;

diff  --git a/clang/test/Modules/implicit-private-with-submodule-explicit.m 
b/clang/test/Modules/implicit-private-with-submodule-explicit.m
new file mode 100644
index 0..a2e9950ec3181
--- /dev/null
+++ b/clang/test/Modules/implicit-private-with-submodule-explicit.m
@@ -0,0 +1,31 @@
+// Checks that the use of .Private to refer to _Private modules works with an
+// explicit module.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module 
-fmodule-name=A %t/module.modulemap -o %t/A.pcm
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module 
-fmodule-name=A_Private %t/module.modulemap -o %t/A_Private.pcm
+
+// Check lazily-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules 
-fmodule-file=A=%t/A.pcm -fmodule-file=A_Private=%t/A_Private.pcm -fsyntax-only 
%t/tu.m
+
+// Check eagerly-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules 
-fmodule-file=%t/A.pcm -fmodule-file=%t/A_Private.pcm -fsyntax-only %t/tu.m
+
+//--- module.modulemap
+module A { header "a.h" }
+module A_Private { header "priv.h" }
+
+//--- a.h
+
+//--- priv.h
+void priv(void);
+
+//--- tu.m
+@import A.Private; // expected-warning{{no submodule named 'Private' in module 
'A'; using top level 'A_Private'}}
+// expected-note@*:* {{defined here}}
+
+void tu(void) {
+  priv();
+}
\ No newline at end of file



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


[PATCH] D147477: [clang][modules] Handle explicit modules when checking for .Private -> _Private

2023-04-04 Thread Ben Langmuir via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ec36e6956cb: [clang][modules] Handle explicit modules when 
checking for .Private -> _Private (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147477/new/

https://reviews.llvm.org/D147477

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/Modules/implicit-private-with-submodule-explicit.m


Index: clang/test/Modules/implicit-private-with-submodule-explicit.m
===
--- /dev/null
+++ clang/test/Modules/implicit-private-with-submodule-explicit.m
@@ -0,0 +1,31 @@
+// Checks that the use of .Private to refer to _Private modules works with an
+// explicit module.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module 
-fmodule-name=A %t/module.modulemap -o %t/A.pcm
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module 
-fmodule-name=A_Private %t/module.modulemap -o %t/A_Private.pcm
+
+// Check lazily-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules 
-fmodule-file=A=%t/A.pcm -fmodule-file=A_Private=%t/A_Private.pcm -fsyntax-only 
%t/tu.m
+
+// Check eagerly-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules 
-fmodule-file=%t/A.pcm -fmodule-file=%t/A_Private.pcm -fsyntax-only %t/tu.m
+
+//--- module.modulemap
+module A { header "a.h" }
+module A_Private { header "priv.h" }
+
+//--- a.h
+
+//--- priv.h
+void priv(void);
+
+//--- tu.m
+@import A.Private; // expected-warning{{no submodule named 'Private' in module 
'A'; using top level 'A_Private'}}
+// expected-note@*:* {{defined here}}
+
+void tu(void) {
+  priv();
+}
\ No newline at end of file
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -2026,8 +2026,12 @@
   PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
   PrivPath.push_back(std::make_pair(&II, Path[0].second));
 
+  std::string FileName;
+  // If there is a modulemap module or prebuilt module, load it.
   if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, ImportLoc, 
true,
- !IsInclusionDirective))
+ !IsInclusionDirective) ||
+  selectModuleSource(nullptr, PrivateModule, FileName, BuiltModules,
+ PP->getHeaderSearchInfo()) != MS_ModuleNotFound)
 Sub = loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
   if (Sub) {
 MapPrivateSubModToTopLevel = true;


Index: clang/test/Modules/implicit-private-with-submodule-explicit.m
===
--- /dev/null
+++ clang/test/Modules/implicit-private-with-submodule-explicit.m
@@ -0,0 +1,31 @@
+// Checks that the use of .Private to refer to _Private modules works with an
+// explicit module.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module -fmodule-name=A %t/module.modulemap -o %t/A.pcm
+// RUN: %clang_cc1 -x objective-c -fmodules -fno-implicit-modules -emit-module -fmodule-name=A_Private %t/module.modulemap -o %t/A_Private.pcm
+
+// Check lazily-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules -fmodule-file=A=%t/A.pcm -fmodule-file=A_Private=%t/A_Private.pcm -fsyntax-only %t/tu.m
+
+// Check eagerly-loaded module
+// RUN: %clang_cc1 -x objective-c -verify -fmodules -fno-implicit-modules -fmodule-file=%t/A.pcm -fmodule-file=%t/A_Private.pcm -fsyntax-only %t/tu.m
+
+//--- module.modulemap
+module A { header "a.h" }
+module A_Private { header "priv.h" }
+
+//--- a.h
+
+//--- priv.h
+void priv(void);
+
+//--- tu.m
+@import A.Private; // expected-warning{{no submodule named 'Private' in module 'A'; using top level 'A_Private'}}
+// expected-note@*:* {{defined here}}
+
+void tu(void) {
+  priv();
+}
\ No newline at end of file
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -2026,8 +2026,12 @@
   PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
   PrivPath.push_back(std::make_pair(&II, Path[0].second));
 
+  std::string FileName;
+  // If there is a modulemap module or prebuilt module, load it.
   if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, ImportLoc, true,
- !IsInclusionDirective))
+ !IsInclusionDirective) ||
+

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

I reworked the comment a bit otherwise LGTM.




Comment at: clang/lib/Sema/SemaDecl.cpp:15178-15185
+  // Each ExpressionEvaluationContextRecord also keeps track on whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when the new
+  // function is entered, we need to reset this tracking, since entered 
function
+  // might be not an immediate one and therefore everything inside of it needs




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

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


[PATCH] D141700: AMDGPU: Move enqueued block handling into clang

2023-04-04 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl added a comment.

Overall looks good.




Comment at: llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp:299
+
+  Attrs.mRuntimeHandle = getEnqueuedBlockSymbolName(TM, Func);
 }

Do we really need/want to update code object v2?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141700/new/

https://reviews.llvm.org/D141700

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


[PATCH] D141700: AMDGPU: Move enqueued block handling into clang

2023-04-04 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp:299
+
+  Attrs.mRuntimeHandle = getEnqueuedBlockSymbolName(TM, Func);
 }

kzhuravl wrote:
> Do we really need/want to update code object v2?
as long as the code is here yes. Not updating it would mean maintaining two 
paths in the implementation. This is just changing the internal representation 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141700/new/

https://reviews.llvm.org/D141700

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


[PATCH] D144003: [clang][analyzer] Improve bug reports of StdLibraryFunctionsChecker.

2023-04-04 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 510816.
balazske marked 3 inline comments as done.
balazske added a comment.

I decided to add back `DescriptionKind` and make possible to use a message like
"should not be NULL". Now all generated strings in functions `describe` and
`describeArgumentValue` start with "should be" or "is" to make this consistent.
The messages are now in form "is ... but should be ..." which sounds at some 
times
too trivial but acceptable as generated message.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144003/new/

https://reviews.llvm.org/D144003

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-notes.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints-tracking-notes.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.c
  clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream-stdlibraryfunctionargs.c

Index: clang/test/Analysis/stream-stdlibraryfunctionargs.c
===
--- clang/test/Analysis/stream-stdlibraryfunctionargs.c
+++ clang/test/Analysis/stream-stdlibraryfunctionargs.c
@@ -42,7 +42,7 @@
 
 void test_fread(void) {
   FILE *fp = tmpfile();
-  size_t ret = fread(buf, size, n, fp); // stdargs-warning{{The 4th argument to 'fread' should not be NULL}}
+  size_t ret = fread(buf, size, n, fp); // stdargs-warning{{The 4th argument to 'fread' is NULL but should not be NULL}}
   clang_analyzer_eval(fp != NULL); // any-warning{{TRUE}}
   clang_analyzer_eval(ret <= n); // any-warning{{TRUE}}
   clang_analyzer_eval(ret == n); // any-warning{{TRUE}} any-warning{{FALSE}}
@@ -52,7 +52,7 @@
 
 void test_fwrite(void) {
   FILE *fp = tmpfile();
-  size_t ret = fwrite(buf, size, n, fp); // stdargs-warning{{The 4th argument to 'fwrite' should not be NULL}}
+  size_t ret = fwrite(buf, size, n, fp); // stdargs-warning{{The 4th argument to 'fwrite' is NULL but should not be NULL}}
   clang_analyzer_eval(fp != NULL); // any-warning{{TRUE}}
   clang_analyzer_eval(ret <= n); // any-warning{{TRUE}}
   clang_analyzer_eval(ret == n); // any-warning{{TRUE}} any-warning{{FALSE}}
Index: clang/test/Analysis/stream-note.c
===
--- clang/test/Analysis/stream-note.c
+++ clang/test/Analysis/stream-note.c
@@ -88,8 +88,8 @@
 fclose(F);
 return;
   }
-  fclose(F); // stdargs-warning {{The 1st argument to 'fclose' should not be NULL}}
- // stdargs-note@-1 {{The 1st argument to 'fclose' should not be NULL}}
+  fclose(F); // stdargs-warning {{The 1st argument to 'fclose' is NULL but should not be NULL}}
+ // stdargs-note@-1 {{The 1st argument to 'fclose' is NULL but should not be NULL}}
 }
 
 void check_eof_notes_feof_after_feof(void) {
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.cpp
@@ -14,5 +14,5 @@
 
 void test_arg_constraint_on_fun_with_default_param() {
   __defaultparam(nullptr); // \
-  // expected-warning{{The 1st argument to '__defaultparam' should not be NULL}}
+  // expected-warning{{The 1st argument to '__defaultparam' is NULL but should not be NULL}}
 }
Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -30,9 +30,9 @@
 
 void test_alnum_concrete(int v) {
   int ret = isalnum(256); // \
-  // report-warning{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}} \
-  // bugpath-warning{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}} \
-  // bugpath-note{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}}
+  // report-warning{{The 1st argument to 'isalnum' is 256 but should be an unsigned char value or EOF}} \
+  // bugpath-warning{{The 1st argument to 'isalnum' is 256 but should be an unsigned char value or EOF}} \
+  // bugpath-note{{The 1st argument to 'isalnum' is 256 but should be an unsigned char value or EOF}}
   (void)ret;
 }
 
@@ -55,9 +55,9 @@
 // bugpath-note{{Taking true branch}}
 
 int ret = isalnum(x); // \
-// report-warning{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}} \
-// bugpath-warning{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}} \
-// bugpath-note{{The 1st argument to 'isalnum' should be an unsigned char value or EOF}}
+// report-warning{{The 1st ar

[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-04-04 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a reviewer: ChuanqiXu.
ChuanqiXu added a comment.

Add me as a reviewer to add this to my stack.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D41416/new/

https://reviews.llvm.org/D41416

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


[PATCH] D41416: [modules] [pch] Do not deserialize all lazy template specializations when looking for one.

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/lib/Serialization/ASTWriterDecl.cpp:288
+  }
+  for (auto &SpecInfo : LazySpecializations) {
+Record.push_back(SpecInfo.DeclID);

We should not store the lazy specialization information as an array of items 
because that makes the search slow. Instead we should use the `OnDiskHashTable` 
approach which we use already to store the identifier data.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D41416/new/

https://reviews.llvm.org/D41416

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


[clang] 0109f8d - [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of __builtin_neon_vfmsh_f16.

2023-04-04 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-04-04T09:01:24-07:00
New Revision: 0109f8d1e3bf64e4b23db6e2f284185207e46541

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

LOG: [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of 
__builtin_neon_vfmsh_f16.

Addresses the FIXME and removes the only in tree use of
llvm::ConstantFP::getZeroValueForNegation for an FP type.

Reviewed By: dmgreen, SjoerdMeijer

Differential Revision: https://reviews.llvm.org/D147497

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f399b0770143..1d79d9a14635 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -10965,14 +10965,12 @@ Value 
*CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
 {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), Ops[0]});
   case NEON::BI__builtin_neon_vfmsh_f16: {
-// FIXME: This should be an fneg instruction:
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(HalfTy);
-Value* Sub = Builder.CreateFSub(Zero, EmitScalarExpr(E->getArg(1)), 
"vsubh");
+Value* Neg = Builder.CreateFNeg(EmitScalarExpr(E->getArg(1)), "vsubh");
 
 // NEON intrinsic puts accumulator first, unlike the LLVM fma.
 return emitCallMaybeConstrainedFPBuiltin(
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
-{Sub, EmitScalarExpr(E->getArg(2)), Ops[0]});
+{Neg, EmitScalarExpr(E->getArg(2)), Ops[0]});
   }
   case NEON::BI__builtin_neon_vaddd_s64:
   case NEON::BI__builtin_neon_vaddd_u64:

diff  --git a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c 
b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
index 198c4523d651..536713402b5d 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
@@ -290,8 +290,7 @@ float16_t test_vfmah_f16(float16_t a, float16_t b, 
float16_t c) {
 }
 
 // COMMON-LABEL: test_vfmsh_f16
-// UNCONSTRAINED:  [[SUB:%.*]] = fsub half 0xH8000, %b
-// CONSTRAINED:[[SUB:%.*]] = call half 
@llvm.experimental.constrained.fsub.f16(half 0xH8000, half %b, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
+// COMMONIR:  [[SUB:%.*]] = fneg half %b
 // UNCONSTRAINED:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half 
%c, half %a)
 // CONSTRAINED:[[ADD:%.*]] = call half 
@llvm.experimental.constrained.fma.f16(half [[SUB]], half %c, half %a, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
 // COMMONIR:   ret half [[ADD]]

diff  --git a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c 
b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
index b374ba1ab097..d745a7789326 100644
--- a/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
+++ b/clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
@@ -652,7 +652,7 @@ float16_t test_vfmah_f16(float16_t a, float16_t b, 
float16_t c) {
 }
 
 // CHECK-LABEL: test_vfmsh_f16
-// CHECK:  [[SUB:%.*]] = fsub half 0xH8000, %b
+// CHECK:  [[SUB:%.*]] = fneg half %b
 // CHECK:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half 
%a)
 // CHECK:  ret half [[ADD]]
 float16_t test_vfmsh_f16(float16_t a, float16_t b, float16_t c) {



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


[PATCH] D147497: [AArch64] Use fneg instead of fsub -0.0, X Cin IR expansion of __builtin_neon_vfmsh_f16.

2023-04-04 Thread Craig Topper via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0109f8d1e3bf: [AArch64] Use fneg instead of fsub -0.0, X Cin 
IR expansion of… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147497/new/

https://reviews.llvm.org/D147497

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c


Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
@@ -652,7 +652,7 @@
 }
 
 // CHECK-LABEL: test_vfmsh_f16
-// CHECK:  [[SUB:%.*]] = fsub half 0xH8000, %b
+// CHECK:  [[SUB:%.*]] = fneg half %b
 // CHECK:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half 
%a)
 // CHECK:  ret half [[ADD]]
 float16_t test_vfmsh_f16(float16_t a, float16_t b, float16_t c) {
Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
@@ -290,8 +290,7 @@
 }
 
 // COMMON-LABEL: test_vfmsh_f16
-// UNCONSTRAINED:  [[SUB:%.*]] = fsub half 0xH8000, %b
-// CONSTRAINED:[[SUB:%.*]] = call half 
@llvm.experimental.constrained.fsub.f16(half 0xH8000, half %b, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
+// COMMONIR:  [[SUB:%.*]] = fneg half %b
 // UNCONSTRAINED:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half 
%c, half %a)
 // CONSTRAINED:[[ADD:%.*]] = call half 
@llvm.experimental.constrained.fma.f16(half [[SUB]], half %c, half %a, metadata 
!"round.tonearest", metadata !"fpexcept.strict")
 // COMMONIR:   ret half [[ADD]]
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10965,14 +10965,12 @@
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
 {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), Ops[0]});
   case NEON::BI__builtin_neon_vfmsh_f16: {
-// FIXME: This should be an fneg instruction:
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(HalfTy);
-Value* Sub = Builder.CreateFSub(Zero, EmitScalarExpr(E->getArg(1)), 
"vsubh");
+Value* Neg = Builder.CreateFNeg(EmitScalarExpr(E->getArg(1)), "vsubh");
 
 // NEON intrinsic puts accumulator first, unlike the LLVM fma.
 return emitCallMaybeConstrainedFPBuiltin(
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
-{Sub, EmitScalarExpr(E->getArg(2)), Ops[0]});
+{Neg, EmitScalarExpr(E->getArg(2)), Ops[0]});
   }
   case NEON::BI__builtin_neon_vaddd_s64:
   case NEON::BI__builtin_neon_vaddd_u64:


Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics.c
@@ -652,7 +652,7 @@
 }
 
 // CHECK-LABEL: test_vfmsh_f16
-// CHECK:  [[SUB:%.*]] = fsub half 0xH8000, %b
+// CHECK:  [[SUB:%.*]] = fneg half %b
 // CHECK:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half %a)
 // CHECK:  ret half [[ADD]]
 float16_t test_vfmsh_f16(float16_t a, float16_t b, float16_t c) {
Index: clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-fp16-intrinsics-constrained.c
@@ -290,8 +290,7 @@
 }
 
 // COMMON-LABEL: test_vfmsh_f16
-// UNCONSTRAINED:  [[SUB:%.*]] = fsub half 0xH8000, %b
-// CONSTRAINED:[[SUB:%.*]] = call half @llvm.experimental.constrained.fsub.f16(half 0xH8000, half %b, metadata !"round.tonearest", metadata !"fpexcept.strict")
+// COMMONIR:  [[SUB:%.*]] = fneg half %b
 // UNCONSTRAINED:  [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half %a)
 // CONSTRAINED:[[ADD:%.*]] = call half @llvm.experimental.constrained.fma.f16(half [[SUB]], half %c, half %a, metadata !"round.tonearest", metadata !"fpexcept.strict")
 // COMMONIR:   ret half [[ADD]]
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -10965,14 +10965,12 @@
 *this, Intrinsic::fma, Intrinsic::experimental_constrained_fma, HalfTy,
 {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), Ops[0]});
   case NEON::BI__builtin_neon_vfmsh_f16: {
-// FIXME: This should be an

[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

Thanks for working on this!




Comment at: clang/lib/Interpreter/Offload.cpp:1
+//===-- Offload.cpp - CUDA Offloading ---*- C++ 
-*-===//
+//

How about `DeviceOffload.cpp`?



Comment at: clang/tools/clang-repl/ClangRepl.cpp:135
+std::move(CI), std::move(DeviceCI), OffloadArch,
+"/tmp/clang-repl.fatbin"));
+

To cover the case where platforms have no `/tmp` we could use 
`fs::createTemporaryFile`. However, some platforms have read-only file systems. 
What do we do there?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:273-274
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix assertion hit when template consteval function appears in nested
+  consteval/constexpr call chain.





Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:120
+
+namespace GH61142 {
+

Would it make sense to add some CHECK lines to check the actual codegen is 
sensible?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:15186
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+

I am a bit concerned that we are updating `InImmediateFunctionContext` outside 
of `PushExpressionEvaluationContext`. So we are now spreading the logic outside 
of where it was originally contained.

I am wondering if instead inside of `PushExpressionEvaluationContext` we could 
set `InImmediateFunctionContext` like so:

```
ExprEvalContexts.back().InImmediateFunctionContext =
  ExprEvalContexts[ExprEvalContexts.size() - 2]
  .isImmediateFunctionContext() || NewContext == 
ImmediateFunctionContext;
```

or something along those lines.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:15186
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+

shafik wrote:
> I am a bit concerned that we are updating `InImmediateFunctionContext` 
> outside of `PushExpressionEvaluationContext`. So we are now spreading the 
> logic outside of where it was originally contained.
> 
> I am wondering if instead inside of `PushExpressionEvaluationContext` we 
> could set `InImmediateFunctionContext` like so:
> 
> ```
> ExprEvalContexts.back().InImmediateFunctionContext =
>   ExprEvalContexts[ExprEvalContexts.size() - 2]
>   .isImmediateFunctionContext() || NewContext == 
> ImmediateFunctionContext;
> ```
> 
> or something along those lines.
Here `isImmediateFunctionContext()` will be true, we want it to be false

If we wanted to do somelink like what you are suggesting, we'd need something 
like a new `EnteringFunctionDefinitionContext` boolean parameter to  
PushExpressionEvaluationContext. so that
InImmediateFunctionContext is only set to the outer context value when 
`EnteringFunctionDefinitionContext`would be false

Given that we should only get in that situation from `ActOnStartOfFunctionDef`, 
I'm not sure that would be a better design


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

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


[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 510843.
Fznamznon added a comment.

Fix grammar, add checks to the test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/cxx20-consteval-crash.cpp


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,27 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void bar() {
+foo();
+  }
+  consteval static void foo() {};
+};
+
+consteval void a() {
+  Test::bar();
+}
+
+void b() {
+  Test::bar();
+}
+
+// Make sure consteval function is not emitted.
+// CHECK-NOT: call {{.*}}foo{{.*}}()
+// CHECK-NOT: define {{.*}}foo{{.*}}()
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15175,6 +15175,15 @@
 FD->isConsteval() ? 
ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
 
+  // Each ExpressionEvaluationContextRecord also keeps track of whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when a new
+  // function is entered, we need to reset this tracking, since the entered
+  // function might be not an immediate function.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix the assertion hit when a template consteval function appears in a nested
+  consteval/constexpr call chain.
+  (`#61142 `_)
 
 
 Bug Fixes to Compiler Builtins


Index: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
===
--- clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
+++ clang/test/CodeGenCXX/cxx20-consteval-crash.cpp
@@ -116,3 +116,27 @@
 }
 
 } // namespace GH60166
+
+namespace GH61142 {
+
+template 
+struct Test {
+  constexpr static void bar() {
+foo();
+  }
+  consteval static void foo() {};
+};
+
+consteval void a() {
+  Test::bar();
+}
+
+void b() {
+  Test::bar();
+}
+
+// Make sure consteval function is not emitted.
+// CHECK-NOT: call {{.*}}foo{{.*}}()
+// CHECK-NOT: define {{.*}}foo{{.*}}()
+
+} // namespace GH61142
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15175,6 +15175,15 @@
 FD->isConsteval() ? ExpressionEvaluationContext::ImmediateFunctionContext
   : ExprEvalContexts.back().Context);
 
+  // Each ExpressionEvaluationContextRecord also keeps track of whether the
+  // context is nested in an immediate function context, so smaller contexts
+  // that appear inside immediate functions (like variable initializers) are
+  // considered to be inside an immediate function context even though by
+  // themselves they are not immediate function contexts. But when a new
+  // function is entered, we need to reset this tracking, since the entered
+  // function might be not an immediate function.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+
   // Check for defining attributes before the check for redefinition.
   if (const auto *Attr = FD->getAttr()) {
 Diag(Attr->getLocation(), diag::err_alias_is_definition) << FD << 0;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -271,6 +271,9 @@
   (`#60887 `_)
 - Fix incorrect merging of lambdas across modules.
   (`#60985 `_)
+- Fix the assertion hit when a template consteval function appears in a nested
+  consteval/constexpr call chain.
+  (`#61142 

[PATCH] D147531: [clang] Reset track of immediate function context when entering new function

2023-04-04 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon marked 2 inline comments as done.
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:15186
+  // different handling.
+  ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval();
+

cor3ntin wrote:
> shafik wrote:
> > I am a bit concerned that we are updating `InImmediateFunctionContext` 
> > outside of `PushExpressionEvaluationContext`. So we are now spreading the 
> > logic outside of where it was originally contained.
> > 
> > I am wondering if instead inside of `PushExpressionEvaluationContext` we 
> > could set `InImmediateFunctionContext` like so:
> > 
> > ```
> > ExprEvalContexts.back().InImmediateFunctionContext =
> >   ExprEvalContexts[ExprEvalContexts.size() - 2]
> >   .isImmediateFunctionContext() || NewContext == 
> > ImmediateFunctionContext;
> > ```
> > 
> > or something along those lines.
> Here `isImmediateFunctionContext()` will be true, we want it to be false
> 
> If we wanted to do somelink like what you are suggesting, we'd need something 
> like a new `EnteringFunctionDefinitionContext` boolean parameter to  
> PushExpressionEvaluationContext. so that
> InImmediateFunctionContext is only set to the outer context value when 
> `EnteringFunctionDefinitionContext`would be false
> 
> Given that we should only get in that situation from 
> `ActOnStartOfFunctionDef`, I'm not sure that would be a better design
Thanks, @cor3ntin .
This is the exact reason why I implemented the fix this way.



Comment at: clang/test/CodeGenCXX/cxx20-consteval-crash.cpp:120
+
+namespace GH61142 {
+

aaron.ballman wrote:
> Would it make sense to add some CHECK lines to check the actual codegen is 
> sensible?
Well, the assertion was due to consteval function reaching codegen, so I added 
checks that it doesn't appear in the IR in any way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147531/new/

https://reviews.llvm.org/D147531

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


[clang] 32b53cf - [ExtractAPI] Remove extra attributes in property declaration fragments

2023-04-04 Thread Zixu Wang via cfe-commits

Author: Usman Akinyemi
Date: 2023-04-04T10:00:34-07:00
New Revision: 32b53cf9d0c8c0e01ce5b0e7d5c717202a98cdf5

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

LOG: [ExtractAPI] Remove extra attributes in property declaration fragments

Use `getPropertyAttributesAsWritten` instead of `getPropertyAttributes`
to get property attributes actually specified in the source code.
Resolves issue #61478.

https://reviews.llvm.org/D146759

Reviewed By: zixuw, dang

Differential Revision: https://reviews.llvm.org/D146759

Added: 


Modified: 
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/test/ExtractAPI/objc_category.m
clang/test/ExtractAPI/objc_id_protocol.m
clang/test/ExtractAPI/objc_interface.m
clang/test/ExtractAPI/objc_property.m

Removed: 




diff  --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp 
b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index 912e58a0c6e82..da75a701b405e 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -638,7 +638,7 @@ DeclarationFragments 
DeclarationFragmentsBuilder::getFragmentsForObjCProperty(
   // Build the Objective-C property keyword.
   Fragments.append("@property", DeclarationFragments::FragmentKind::Keyword);
 
-  const auto Attributes = Property->getPropertyAttributes();
+  const auto Attributes = Property->getPropertyAttributesAsWritten();
   // Build the attributes if there is any associated with the property.
   if (Attributes != ObjCPropertyAttribute::kind_noattr) {
 // No leading comma for the first attribute.

diff  --git a/clang/test/ExtractAPI/objc_category.m 
b/clang/test/ExtractAPI/objc_category.m
index 185016dfe848c..3323d75f40392 100644
--- a/clang/test/ExtractAPI/objc_category.m
+++ b/clang/test/ExtractAPI/objc_category.m
@@ -282,39 +282,7 @@ + (void)ClassMethod;
 },
 {
   "kind": "text",
-  "spelling": " ("
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
-{
-  "kind": "text",
-  "spelling": ") "
+  "spelling": " "
 },
 {
   "kind": "typeIdentifier",

diff  --git a/clang/test/ExtractAPI/objc_id_protocol.m 
b/clang/test/ExtractAPI/objc_id_protocol.m
index 551e908ae4fdd..02f4cde772d48 100644
--- a/clang/test/ExtractAPI/objc_id_protocol.m
+++ b/clang/test/ExtractAPI/objc_id_protocol.m
@@ -122,14 +122,6 @@ @interface MyInterface
   "kind": "text",
   "spelling": " ("
 },
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
 {
   "kind": "keyword",
   "spelling": "copy"
@@ -206,30 +198,6 @@ @interface MyInterface
   "kind": "text",
   "spelling": " ("
 },
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
 {
   "kind": "keyword",
   "spelling": "readwrite"

diff  --git a/clang/test/ExtractAPI/objc_interface.m 
b/clang/test/ExtractAPI/objc_interface.m
index 159e97a193a13..3f53546866513 100644
--- a/clang/test/ExtractAPI/objc_interface.m
+++ b/clang/test/ExtractAPI/objc_interface.m
@@ -432,14 +432,6 @@ - (char)getIvar;
   "kind": "text",
   "spelling": " ("
 },
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
 {
   "kind": "keyword",
   "spelling": "readonly"

diff  --git a/clang/test/ExtractAPI/objc_property.m 
b/clang/test/ExtractAPI/objc_property.m
index f09a5ad724238..9c69a1156bffd 100644
--- a/clang/test/ExtractAPI/objc_property.m
+++ b/clang/test/ExtractAPI/objc_property.m
@@ -161,38 +161,6 @@ @interface Interfa

[PATCH] D146759: [ExtractAPI] Remove extra attributes in property declaration fragments

2023-04-04 Thread Zixu Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG32b53cf9d0c8: [ExtractAPI] Remove extra attributes in 
property declaration fragments (authored by Unique_Usman, committed by zixuw).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146759/new/

https://reviews.llvm.org/D146759

Files:
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/test/ExtractAPI/objc_category.m
  clang/test/ExtractAPI/objc_id_protocol.m
  clang/test/ExtractAPI/objc_interface.m
  clang/test/ExtractAPI/objc_property.m

Index: clang/test/ExtractAPI/objc_property.m
===
--- clang/test/ExtractAPI/objc_property.m
+++ clang/test/ExtractAPI/objc_property.m
@@ -161,38 +161,6 @@
   "kind": "keyword",
   "spelling": "class"
 },
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
 {
   "kind": "text",
   "spelling": ") "
@@ -255,39 +223,7 @@
 },
 {
   "kind": "text",
-  "spelling": " ("
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
-{
-  "kind": "text",
-  "spelling": ") "
+  "spelling": " "
 },
 {
   "kind": "typeIdentifier",
@@ -353,38 +289,6 @@
   "kind": "keyword",
   "spelling": "class"
 },
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
 {
   "kind": "text",
   "spelling": ") "
@@ -447,39 +351,7 @@
 },
 {
   "kind": "text",
-  "spelling": " ("
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
-{
-  "kind": "text",
-  "spelling": ") "
+  "spelling": " "
 },
 {
   "kind": "typeIdentifier",
@@ -595,38 +467,6 @@
   "kind": "keyword",
   "spelling": "class"
 },
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "atomic"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "assign"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "unsafe_unretained"
-},
-{
-  "kind": "text",
-  "spelling": ", "
-},
-{
-  "kind": "keyword",
-  "spelling": "readwrite"
-},
 {
   "kind

[PATCH] D145441: [AMDGPU] Define data layout entries for buffers

2023-04-04 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 updated this revision to Diff 510848.
krzysz00 added a comment.

Rebase data layout changes


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145441/new/

https://reviews.llvm.org/D145441

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
  llvm/docs/AMDGPUUsage.rst
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.h
  llvm/lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/buffer-atomic-fadd.v2f16-rtn.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-non-integral-address-spaces.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.atomic.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.dim.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.2darraymsaa.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.load.3d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.d.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.a16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.sample.g16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-llvm.amdgcn.image.store.2d.d16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.image.atomic.dim.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.add.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.atomic.fadd.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.i8.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.raw.tbuffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.add.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.cmpswap.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd-with-ret.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.atomic.fadd.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.format.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f16.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.format.f32.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.struct.tbuffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.load.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.image.sample.1d.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.raw.buffer.load.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.load.ll
  
llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-amdgcn.struct.buffer.store.ll
  llvm/test/CodeGen/AMDGPU/addrspacecast-captured.ll
  llvm/test/CodeGen/AMDGPU/annotate-kernel-features-hsa.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f32-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.f64.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-no-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-atomic-fadd.v2f16-rtn.ll
  llvm/test/CodeGen/AMDGPU/buffer-intrinsics-mmo-offsets.ll
  llvm/te

[PATCH] D146399: [AIX][Clang][K] Create `-K` Option for AIX.

2023-04-04 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

@francii, what happens when `-K` is used on a pure-compile (`-c`) invocation? 
Do we get an "unused" message? Should we be testing that?
I think we should be testing the diagnostic for the "wrong target" usage as 
well?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146399/new/

https://reviews.llvm.org/D146399

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2023-04-04 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

In D102107#4243260 , @jhuber6 wrote:

> Fixed the Clang tests. Haven't touched the LLVM ones because this breaks 
> SPMDzation and state machine rewrites completely in those tests. Someone who 
> knows what this patch changes should look into what needs to be updated to 
> make those tests match whatever form SPDMzation expects now. Also for some 
> bizarre reason this patch breaks adding `alwaysinline` on `kmpc_parallel_51`.

I hadn't looked into whether OpenMPOpt was working ok, so did not realize this 
breakage. @jdoerfert If you get a chance, please look into this problem ^^.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102107/new/

https://reviews.llvm.org/D102107

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:27
+static llvm::cl::opt CudaEnabled("cuda", llvm::cl::Hidden);
+static llvm::cl::opt OffloadArch("offload-arch", 
llvm::cl::Hidden);
+

Where will clang-repl find CUDA headers? Generally speaking `--cuda-path` is 
essential for CUDA compilation as it's fairly common for users to have more 
than one CUDA SDK versions installed, or to have them installed in a 
non-default location.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:137
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else

Is there any doc describing the big picture approach to CUDA REPL 
implementation and how all the pieces tie together?

From the patch I see that we will compile GPU side of the code to PTX, pack it 
into fatbinary, but it's not clear now do we get from there to actually 
launching the kernels. Loading libcudart.so here also does not appear to be 
tied to anything else. I do not see any direct API calls, and the host-side 
compilation appears to be done w.o passing the GPU binary to it, which would 
normally trigger generation of the glue code to register the kernels with CUDA 
runtime. I may be missing something, too.

I assume the gaps will be filled in in future patches, but I'm still curious 
about the overall plan.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a subscriber: SimeonEhrig.
v.g.vassilev added inline comments.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:137
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else

tra wrote:
> Is there any doc describing the big picture approach to CUDA REPL 
> implementation and how all the pieces tie together?
> 
> From the patch I see that we will compile GPU side of the code to PTX, pack 
> it into fatbinary, but it's not clear now do we get from there to actually 
> launching the kernels. Loading libcudart.so here also does not appear to be 
> tied to anything else. I do not see any direct API calls, and the host-side 
> compilation appears to be done w.o passing the GPU binary to it, which would 
> normally trigger generation of the glue code to register the kernels with 
> CUDA runtime. I may be missing something, too.
> 
> I assume the gaps will be filled in in future patches, but I'm still curious 
> about the overall plan.
> 
> 
Hi @tra, thanks for asking. Our reference implementation was done in Cling a 
while ago by @SimeonEhrig. One of his talks which I think describes well the 
big picture could be found here: 
https://compiler-research.org/meetings/#caas_04Mar2021


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

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


[PATCH] D147549: [clang] Add test for CWG255

2023-04-04 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : CWG255 (partially resolved by N3778 is 
resolved by generally specifying the restriction to usual deallocation 
functions.
Wording: In any case, any declarations other than of usual deallocation 
functions ([basic.stc.dynamic.deallocation]) are discarded. ([expr.delete]/9)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147549

Files:
  clang/test/CXX/drs/dr2xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1568,7 +1568,7 @@
 https://wg21.link/cwg255";>255
 CD6
 Placement deallocation functions and lookup ambiguity
-Unknown
+Yes
   
   
 https://wg21.link/cwg256";>256
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
@@ -692,6 +693,14 @@
   A::type n; // expected-note {{instantiation of}}
 }
 
+namespace dr255 { // dr255: yes
+struct S {
+  void operator delete(void *){};
+  void operator delete(void *, int){};
+};
+void f(S *p) { delete p; }
+} // namespace dr255
+
 // dr256: dup 624
 
 namespace dr257 { // dr257: yes


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -1568,7 +1568,7 @@
 https://wg21.link/cwg255";>255
 CD6
 Placement deallocation functions and lookup ambiguity
-Unknown
+Yes
   
   
 https://wg21.link/cwg256";>256
Index: clang/test/CXX/drs/dr2xx.cpp
===
--- clang/test/CXX/drs/dr2xx.cpp
+++ clang/test/CXX/drs/dr2xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // PR13819 -- __SIZE_TYPE__ is incompatible.
 typedef __SIZE_TYPE__ size_t; // expected-error 0-1 {{extension}}
@@ -692,6 +693,14 @@
   A::type n; // expected-note {{instantiation of}}
 }
 
+namespace dr255 { // dr255: yes
+struct S {
+  void operator delete(void *){};
+  void operator delete(void *, int){};
+};
+void f(S *p) { delete p; }
+} // namespace dr255
+
 // dr256: dup 624
 
 namespace dr257 { // dr257: yes
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D146897: [clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

2023-04-04 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15656
   case BO_XorAssign:
-DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
 CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S);
 break;

This is the same thing, but for `this->x += this->x`. I think we should also 
suppress those warnings for compound assignment, except when one of the 
operands is an implicit member access and one is an explicit member access 
(`this->x += x;` should still warn if the latter `x` is also interpreted as 
`this->x`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146897/new/

https://reviews.llvm.org/D146897

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> Initial interactive CUDA support for clang-repl

What should a user expect to be supported, functionality wise? I assume it 
should cover parsing and compilation. I'm not so sure about the execution. 
Should it be expected to actually launch kernels, or will that come in a future 
patch?




Comment at: clang/tools/clang-repl/ClangRepl.cpp:137
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else

v.g.vassilev wrote:
> tra wrote:
> > Is there any doc describing the big picture approach to CUDA REPL 
> > implementation and how all the pieces tie together?
> > 
> > From the patch I see that we will compile GPU side of the code to PTX, pack 
> > it into fatbinary, but it's not clear now do we get from there to actually 
> > launching the kernels. Loading libcudart.so here also does not appear to be 
> > tied to anything else. I do not see any direct API calls, and the host-side 
> > compilation appears to be done w.o passing the GPU binary to it, which 
> > would normally trigger generation of the glue code to register the kernels 
> > with CUDA runtime. I may be missing something, too.
> > 
> > I assume the gaps will be filled in in future patches, but I'm still 
> > curious about the overall plan.
> > 
> > 
> Hi @tra, thanks for asking. Our reference implementation was done in Cling a 
> while ago by @SimeonEhrig. One of his talks which I think describes well the 
> big picture could be found here: 
> https://compiler-research.org/meetings/#caas_04Mar2021
Cling does ring the bell. The slides from the link above do look OK.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added inline comments.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:137
+
+ExitOnErr(Interp->LoadDynamicLibrary("libcudart.so"));
+  } else

tra wrote:
> v.g.vassilev wrote:
> > tra wrote:
> > > Is there any doc describing the big picture approach to CUDA REPL 
> > > implementation and how all the pieces tie together?
> > > 
> > > From the patch I see that we will compile GPU side of the code to PTX, 
> > > pack it into fatbinary, but it's not clear now do we get from there to 
> > > actually launching the kernels. Loading libcudart.so here also does not 
> > > appear to be tied to anything else. I do not see any direct API calls, 
> > > and the host-side compilation appears to be done w.o passing the GPU 
> > > binary to it, which would normally trigger generation of the glue code to 
> > > register the kernels with CUDA runtime. I may be missing something, too.
> > > 
> > > I assume the gaps will be filled in in future patches, but I'm still 
> > > curious about the overall plan.
> > > 
> > > 
> > Hi @tra, thanks for asking. Our reference implementation was done in Cling 
> > a while ago by @SimeonEhrig. One of his talks which I think describes well 
> > the big picture could be found here: 
> > https://compiler-research.org/meetings/#caas_04Mar2021
> Cling does ring the bell. The slides from the link above do look OK.
> 
There is also a video.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

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


[PATCH] D147175: [clang] Add __is_trivially_equality_comparable

2023-04-04 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

In D147175#4240572 , @aaron.ballman 
wrote:

> Hmmm, is this effectively `std::has_unique_object_representations` (ensuring 
> that all bits of the object representation contribute to the value)?

These two traits are indeed very similar. The main difference is that 
`has_unique_object_representations` requires that the type is trivially 
copyable, and `__is_trivially_equality_comparable` requires a defaulted 
equality comparison operator.




Comment at: clang/lib/AST/Type.cpp:2640
+
+  return false;
+}

aaron.ballman wrote:
> I think this might be missing cases, like complex integers, scoped 
> enumerations, vector types?, pointer types, atomic versions of these types...
I think this should be covered by the switch to using 
`hasUniqueObjectRepresentation`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147175/new/

https://reviews.llvm.org/D147175

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


[PATCH] D147175: [clang] Add __is_trivially_equality_comparable

2023-04-04 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 510865.
philnik marked 5 inline comments as done.
philnik added a comment.

Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147175/new/

https://reviews.llvm.org/D147175

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp
  libcxx/include/__algorithm/equal.h
  libcxx/include/__string/constexpr_c_functions.h
  libcxx/include/__type_traits/is_equality_comparable.h
  libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp

Index: libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
===
--- libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
+++ libcxx/test/libcxx/type_traits/is_trivially_comparable.compile.pass.cpp
@@ -13,32 +13,32 @@
 enum Enum : int {};
 enum class EnumClass : int {};
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
 struct S {
   char c;
@@ -51,8 +51,8 @@
 struct VirtualBase : virtual S {};
 struct NonVirtualBase : S, S2 {};
 
-static_assert(!std::__is_trivially_equality_comparable::value, "");
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
 
 // This is trivially_equality_comparable, but we can't detect it currently
-static_assert(!std::__is_trivially_equality_comparable::value, "");
+static_assert(!std::__libcpp_is_trivially_equality_comparable::value, "");
Index: libcxx/include/__type_traits/is_equality_comparable.h
===
--- libcxx/include/__type_traits/is_equality_comparable.h
+++ libcxx/include/__type_traits/is_equality_comparable.h
@@ -43,14 +43,14 @@
 //   always compared.
 
 template 
-struct __is_trivially_equality_comparable
+struct __libcpp_is_trivially_equality_comparable
 : integral_constant::value && i

[PATCH] D147551: [clang-tidy] Fix init-list handling in readability-implicit-bool-conversion

2023-04-04 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Adds support for explicit casts using initListExpr,
for example: int{boolValue} constructions.

Fixes: #47000


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147551

Files:
  clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
@@ -471,3 +471,10 @@
 }
 
 } // namespace ignore_1bit_bitfields
+
+namespace PR47000 {
+  int to_int(bool x) { return int{x}; }
+
+  using IntType = int;
+  int to_int2(bool x) { return IntType{x}; }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -237,6 +237,10 @@
   behavior of using `i` as the prefix for enum tags, set the 
`EnumConstantPrefix`
   option to `i` instead of using `EnumConstantHungarianPrefix`.
 
+- Fixed a false positive in :doc:`readability-implicit-bool-conversion
+  ` check warning would
+  be unnecessarily emitted for explicit cast using direct list initialization.
+
 - Added support to optionally ignore user-defined literals in
   
:doc:`readability-magic-numbers`.
 
Index: clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -262,7 +262,10 @@
   expr(anyOf(allOf(isMacroExpansion(), unless(isNULLMacroExpansion())),
  has(ignoringImplicit(
  memberExpr(hasDeclaration(fieldDecl(hasBitWidth(1)),
- hasParent(explicitCastExpr(;
+ hasParent(explicitCastExpr()),
+ expr(hasType(qualType().bind("type")),
+  hasParent(initListExpr(hasParent(explicitCastExpr(
+  hasType(qualType(equalsBoundNode("type"));
   auto ImplicitCastFromBool = implicitCastExpr(
   anyOf(hasCastKind(CK_IntegralCast), hasCastKind(CK_IntegralToFloating),
 // Prior to C++11 cast from bool literal to pointer was allowed.
@@ -290,7 +293,7 @@
unless(ExceptionCases), unless(has(BoolXor)),
// Retrieve also parent statement, to check if we need
// additional parens in replacement.
-   anyOf(hasParent(stmt().bind("parentStmt")), anything()),
+   optionally(hasParent(stmt().bind("parentStmt"))),
unless(isInTemplateInstantiation()),
unless(hasAncestor(functionTemplateDecl(
.bind("implicitCastToBool")),


Index: clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/implicit-bool-conversion.cpp
@@ -471,3 +471,10 @@
 }
 
 } // namespace ignore_1bit_bitfields
+
+namespace PR47000 {
+  int to_int(bool x) { return int{x}; }
+
+  using IntType = int;
+  int to_int2(bool x) { return IntType{x}; }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -237,6 +237,10 @@
   behavior of using `i` as the prefix for enum tags, set the `EnumConstantPrefix`
   option to `i` instead of using `EnumConstantHungarianPrefix`.
 
+- Fixed a false positive in :doc:`readability-implicit-bool-conversion
+  ` check warning would
+  be unnecessarily emitted for explicit cast using direct list initialization.
+
 - Added support to optionally ignore user-defined literals in
   :doc:`readability-magic-numbers`.
 
Index: clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -262,7 +262,10 @@
   expr(anyOf(allOf(isMacroExpansi

[PATCH] D147554: [clang] Mark CWG562 as N/A

2023-04-04 Thread Vlad Serebrennikov via Phabricator via cfe-commits
Endill created this revision.
Endill added a reviewer: clang-language-wg.
Herald added a project: All.
Endill requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

P1787 : CWG562 is resolved by defining lookup as 
occurring from a program point.
Wording: A single search in a scope S for a name N from a program point P finds 
all declarations that precede P to which any name that is the same as N 
([basic.pre]) is bound in S. ([basic.lookup]/2)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147554

Files:
  clang/test/CXX/drs/dr5xx.cpp
  clang/www/cxx_dr_status.html


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3413,7 +3413,7 @@
 https://wg21.link/cwg562";>562
 CD6
 qualified-ids in non-expression contexts
-Unknown
+N/A
   
   
 https://wg21.link/cwg563";>563
Index: clang/test/CXX/drs/dr5xx.cpp
===
--- clang/test/CXX/drs/dr5xx.cpp
+++ clang/test/CXX/drs/dr5xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions 
-pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
@@ -643,6 +644,8 @@
   }
 }
 
+// dr562: na
+
 namespace dr564 { // dr564: yes
   extern "C++" void f(int);
   void f(int); // ok


Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -3413,7 +3413,7 @@
 https://wg21.link/cwg562";>562
 CD6
 qualified-ids in non-expression contexts
-Unknown
+N/A
   
   
 https://wg21.link/cwg563";>563
Index: clang/test/CXX/drs/dr5xx.cpp
===
--- clang/test/CXX/drs/dr5xx.cpp
+++ clang/test/CXX/drs/dr5xx.cpp
@@ -3,6 +3,7 @@
 // RUN: %clang_cc1 -std=c++14 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 // RUN: %clang_cc1 -std=c++20 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2b %s -verify -fexceptions -fcxx-exceptions -pedantic-errors
 
 // FIXME: This is included to avoid a diagnostic with no source location
 // pointing at the implicit operator new. We can't match such a diagnostic
@@ -643,6 +644,8 @@
   }
 }
 
+// dr562: na
+
 namespace dr564 { // dr564: yes
   extern "C++" void f(int);
   void f(int); // ok
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147530: [clang] Add test for CWG191

2023-04-04 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147530/new/

https://reviews.llvm.org/D147530

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


[PATCH] D146897: [clang:diagnostics] Turning off warn_self_assignment_overloaded for user-defined compound assignments

2023-04-04 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:15656
   case BO_XorAssign:
-DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false);
 CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S);
 break;

rsmith wrote:
> This is the same thing, but for `this->x += this->x`. I think we should also 
> suppress those warnings for compound assignment, except when one of the 
> operands is an implicit member access and one is an explicit member access 
> (`this->x += x;` should still warn if the latter `x` is also interpreted as 
> `this->x`).
For case like this:

```
class Vector {
public:
Vector& operator+=(const Vector &v) { return *this; }
Vector& operator-=(const Vector &v) { return *this; }
};

class A {
public:
  A(){}
  Vector x;
  void foo() {
 this->x -= this->x;
 this->x -= x;
 this->x += this->x;
 this->x += x;
  }
};
```
clang will report 2 warning:

```
:14:14: warning: assigning field to itself [-Wself-assign-field]
 this->x -= this->x;
 ^
:15:14: warning: assigning field to itself [-Wself-assign-field]
 this->x -= x;
```

Do you mean we should make it report warning on this->x -= x; and this->x += x; 
?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146897/new/

https://reviews.llvm.org/D146897

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


[PATCH] D147556: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-04 Thread Jon Phillips via Phabricator via cfe-commits
jp4a50 created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
jp4a50 requested review of this revision.

The option allows users to specify how many columns to use to indent
the contents of braced init lists.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147556

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4855,6 +4855,191 @@
"[5] = ee};");
 }
 
+TEST_F(FormatTest, BracedInitializerIndentWidth) {
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.BinPackArguments = true;
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
+  Style.BracedInitializerIndentWidth = 6;
+
+  // Non-initializing braces are unaffected by BracedInitializerIndentWidth.
+  verifyFormat("enum class {\n"
+   "  One,\n"
+   "  Two,\n"
+   "};\n",
+   Style);
+  verifyFormat("class Foo {\n"
+   "  Foo() {}\n"
+   "  void bar();\n"
+   "};\n",
+   Style);
+  verifyFormat("void foo() {\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  verifyFormat("auto foo = [&] {\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  verifyFormat("{\n"
+   "  auto bar = baz;\n"
+   "  return baz;\n"
+   "};\n",
+   Style);
+  // Non-brace initialization is unaffected by BracedInitializerIndentWidth.
+  verifyFormat("SomeClass clazz(\n"
+   "\"xx\", \"yy\",\n"
+   "\"zz\");\n",
+   Style);
+
+  // The following types of initialization are all affected by
+  // BracedInitializerIndentWidth. Aggregate initialization.
+  verifyFormat("int LongVariable[2] = {\n"
+   "  1000, 2000};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "  \"\", \"\",\n"
+   "  \"\"};\n",
+   Style);
+  // Designated initializers.
+  verifyFormat("int LongVariable[1] = {\n"
+   "  [0] = 1000, [1] = 2000};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "  .foo = \"x\",\n"
+   "  .bar = \"y\",\n"
+   "  .baz = \"z\"};\n",
+   Style);
+  // List initialization.
+  verifyFormat("SomeStruct s{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("new SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  // Member initializer.
+  verifyFormat("class SomeClass {\n"
+   "  SomeStruct s{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "  };\n"
+   "};\n",
+   Style);
+  // Constructor member initializer.
+  verifyFormat("SomeClass::SomeClass : strct{\n"
+   " \"x\",\n"
+   " \"y\",\n"
+   " \"z\",\n"
+   "   } {}\n",
+   Style);
+  // Copy initialization.
+  verifyFormat("SomeStruct s = SomeStruct{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "};\n",
+   Style);
+  // Copy list initialization.
+  verifyFormat("SomeStruct s = {\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"

[PATCH] D147556: [clang-format] Add BracedInitializerIndentWidth option.

2023-04-04 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Um, was this a mistake? What is with D146101 ?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147556/new/

https://reviews.llvm.org/D147556

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


[PATCH] D146389: [clang-repl][CUDA] Initial interactive CUDA support for clang-repl

2023-04-04 Thread Simeon Ehrig via Phabricator via cfe-commits
SimeonEhrig added inline comments.



Comment at: clang/tools/clang-repl/ClangRepl.cpp:135
+std::move(CI), std::move(DeviceCI), OffloadArch,
+"/tmp/clang-repl.fatbin"));
+

v.g.vassilev wrote:
> To cover the case where platforms have no `/tmp` we could use 
> `fs::createTemporaryFile`. However, some platforms have read-only file 
> systems. What do we do there?
Actual, we can avoid temporary files completely. The reason, why the fatbinary 
code is written to a file is the following code in the code generator of the 
CUDA runtime functions:

https://github.com/llvm/llvm-project/blob/d9d840cdaf51a9795930750d1b91d614a3849137/clang/lib/CodeGen/CGCUDANV.cpp#L722-L732

In the past, I avoided to change the code, because this was an extra Clang 
patch for Cling.

Maybe we can use the llvm virtualFileSystem: 
https://llvm.org/doxygen/classllvm_1_1vfs_1_1InMemoryFileSystem.html
But this is just an idea. I have no experience, if this is working for us.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146389/new/

https://reviews.llvm.org/D146389

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


  1   2   >