[PATCH] D142181: [OptTable] Store llvm::cl::Option into a DenseMap instead of a StringMap

2023-01-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@nikic : I thought I fixed that with e8a163dc03e6913360beb305620104ba129c081c 
 ... is it 
included in your build?


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

https://reviews.llvm.org/D142181

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


[PATCH] D142181: [OptTable] Store llvm::cl::Option into a DenseMap instead of a StringMap

2023-01-21 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D142181#4070868 , 
@serge-sans-paille wrote:

> @nikic : I thought I fixed that with e8a163dc03e6913360beb305620104ba129c081c 
>  ... is 
> it included in your build?

Oh yeah, I missed that fix. Sorry for the noise.


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

https://reviews.llvm.org/D142181

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


[PATCH] D142077: [Clang][SemaCXX][Coroutines] Fix misleading diagnostics with -Wunsequenced

2023-01-21 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:15186
+  if (ChildExpr == CSE->getOperand())
+// Do not recurse over a CoroutineSuspendExpr's operand.
+// The operand is also a subexpression of getCommonExpr(), and

Out of curiosity, since `getCommonExpr()` is itself a subexpression of 
`getReadyExpr()`, `getSuspendExpr()`, and `getResumeExpr()` (which are also 
children of the `CoroutineSuspendExpr`), shouldn't `getCommonExpr()` be skipped 
for the same reason?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142077

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


[PATCH] D142077: [Clang][SemaCXX][Coroutines] Fix misleading diagnostics with -Wunsequenced

2023-01-21 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang/test/SemaCXX/warn-unsequenced-coro.cpp:7
+
+namespace std {
+

Consider including `"Inputs/std-coroutine.h"` instead, as in e.g. [this 
test](https://searchfox.org/llvm/rev/1495210914997bcd0ca6937be0ae3cd6809b5ef5/clang/test/SemaCXX/coreturn.cpp#2)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142077

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


[clang] 3665da3 - Re-commit "[clang][Interp] Unify visiting variable declarations"

2023-01-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-21T10:23:53+01:00
New Revision: 3665da3d0091ab765d54ce643bd82d353c040631

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

LOG: Re-commit "[clang][Interp] Unify visiting variable declarations"

We often visit the same variable multiple times, e.g. once when checking
its initializer and later when compiling the function. Unify both of
those in visitVarDecl() and do the returning of the value in
visitDecl().

This time, use a VariableScope instead of a DeclScope for local
variables. This way, we don't emit Destroy ops for the local variables
immediately after creating them.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index f4bf162a1454c..4bab2897b03b3 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -802,6 +802,13 @@ unsigned 
ByteCodeExprGen::allocateLocalPrimitive(DeclTy &&Src,
   PrimType Ty,
   bool IsConst,
   bool IsExtended) {
+  // Make sure we don't accidentally register the same decl twice.
+  if (const auto *VD =
+  dyn_cast_if_present(Src.dyn_cast())) {
+assert(!P.getGlobal(VD));
+assert(Locals.find(VD) == Locals.end());
+  }
+
   // FIXME: There are cases where Src.is() is wrong, e.g.
   //   (int){12} in C. Consider using Expr::isTemporaryObject() instead
   //   or isa().
@@ -817,8 +824,14 @@ unsigned 
ByteCodeExprGen::allocateLocalPrimitive(DeclTy &&Src,
 template 
 std::optional
 ByteCodeExprGen::allocateLocal(DeclTy &&Src, bool IsExtended) {
-  QualType Ty;
+  // Make sure we don't accidentally register the same decl twice.
+  if (const auto *VD =
+  dyn_cast_if_present(Src.dyn_cast())) {
+assert(!P.getGlobal(VD));
+assert(Locals.find(VD) == Locals.end());
+  }
 
+  QualType Ty;
   const ValueDecl *Key = nullptr;
   const Expr *Init = nullptr;
   bool IsTemporary = false;
@@ -1128,41 +1141,86 @@ bool ByteCodeExprGen::visitExpr(const Expr 
*Exp) {
 return this->emitRetValue(Exp);
 }
 
+/// Toplevel visitDecl().
+/// We get here from evaluateAsInitializer().
+/// We need to evaluate the initializer and return its value.
 template 
 bool ByteCodeExprGen::visitDecl(const VarDecl *VD) {
+  std::optional VarT = classify(VD->getType());
+
+  // Create and initialize the variable.
+  if (!this->visitVarDecl(VD))
+return false;
+
+  // Get a pointer to the variable
+  if (shouldBeGloballyIndexed(VD)) {
+auto GlobalIndex = P.getGlobal(VD);
+assert(GlobalIndex); // visitVarDecl() didn't return false.
+if (!this->emitGetPtrGlobal(*GlobalIndex, VD))
+  return false;
+  } else {
+auto Local = Locals.find(VD);
+assert(Local != Locals.end()); // Same here.
+if (!this->emitGetPtrLocal(Local->second.Offset, VD))
+  return false;
+  }
+
+  // Return the value
+  if (VarT) {
+if (!this->emitLoadPop(*VarT, VD))
+  return false;
+
+return this->emitRet(*VarT, VD);
+  }
+
+  return this->emitRetValue(VD);
+}
+
+template 
+bool ByteCodeExprGen::visitVarDecl(const VarDecl *VD) {
   const Expr *Init = VD->getInit();
+  std::optional VarT = classify(VD->getType());
+
+  if (shouldBeGloballyIndexed(VD)) {
+std::optional GlobalIndex = P.getOrCreateGlobal(VD, Init);
+
+if (!GlobalIndex)
+  return this->bail(VD);
+
+assert(Init);
+{
+  DeclScope LocalScope(this, VD);
 
-  if (std::optional I = P.createGlobal(VD, Init)) {
-if (std::optional T = classify(VD->getType())) {
-  {
-// Primitive declarations - compute the value and set it.
-DeclScope LocalScope(this, VD);
-if (!visit(Init))
+  if (VarT) {
+if (!this->visit(Init))
   return false;
+return this->emitInitGlobal(*VarT, *GlobalIndex, VD);
   }
+  return this->visitGlobalInitializer(Init, *GlobalIndex);
+}
+  } else {
+VariableScope LocalScope(this);
+if (VarT) {
+  unsigned Offset = this->allocateLocalPrimitive(
+  VD, *VarT, VD->getType().isConstQualified());
+  if (Init) {
+// Compile the initializer in its own scope.
+ExprScope Scope(this);
+if (!this->visit(Init))
+  return false;
 
-  // If the declaration is global, save the value for later use.
-  if (!th

[PATCH] D142277: [clang][Interp] Clear metadata when destroying locals

2023-01-21 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.

I've had problems with 5b54cf1a2892767fe949826a32d7820732028a38 
 because 
we were emitting a `Destroy` op for a local variable before we were done using 
that local variable. This moves the local's `Block` to a `DeadBlock` but leaves 
the metadata (a `InlineDescriptor` in the case of local variables) 
uninitialized, so we ran into failed builds on the msan builders.

This patch simply zeroes the metadata after calling destroying the local 
variable. The only difference is that we will now run into an assertion because 
the `Descriptor*` is `nullptr`, etc.

The added code could be in a `#ifndef _NDEBUG` block, and that would be better 
for performance of course, but... that wouldn't have helped in the case of the 
failing msan builders anyway I think.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142277

Files:
  clang/lib/AST/Interp/EvalEmitter.cpp
  clang/lib/AST/Interp/EvalEmitter.h
  clang/lib/AST/Interp/InterpFrame.cpp


Index: clang/lib/AST/Interp/InterpFrame.cpp
===
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -75,6 +75,10 @@
 void InterpFrame::destroy(unsigned Idx) {
   for (auto &Local : Func->getScope(Idx).locals()) {
 S.deallocate(reinterpret_cast(localBlock(Local.Offset)));
+// Just make sure we're runnnig into some kind of error when a
+// local variable is used after being destroyed.
+InlineDescriptor *ID = localInlineDesc(Local.Offset);
+std::memset(ID, 0, sizeof(InlineDescriptor));
   }
 }
 
Index: clang/lib/AST/Interp/EvalEmitter.h
===
--- clang/lib/AST/Interp/EvalEmitter.h
+++ clang/lib/AST/Interp/EvalEmitter.h
@@ -92,6 +92,8 @@
   /// Temporaries which require storage.
   llvm::DenseMap> Locals;
 
+  InlineDescriptor *localInlineDesc(unsigned LocalIndex);
+
   // The emitter always tracks the current instruction and sets OpPC to a token
   // value which is mapped to the location of the opcode being evaluated.
   CodePtr OpPC;
Index: clang/lib/AST/Interp/EvalEmitter.cpp
===
--- clang/lib/AST/Interp/EvalEmitter.cpp
+++ clang/lib/AST/Interp/EvalEmitter.cpp
@@ -49,25 +49,33 @@
 
 EvalEmitter::LabelTy EvalEmitter::getLabel() { return NextLabel++; }
 
+InlineDescriptor *EvalEmitter::localInlineDesc(unsigned LocalIndex) {
+  auto It = Locals.find(LocalIndex);
+  assert(It != Locals.end() && "Missing local variable");
+  Block *B = reinterpret_cast(It->second.get());
+  return reinterpret_cast(B->rawData());
+}
+
 Scope::Local EvalEmitter::createLocal(Descriptor *D) {
   // Allocate memory for a local.
   auto Memory = std::make_unique(sizeof(Block) + D->getAllocSize());
   auto *B = new (Memory.get()) Block(D, /*isStatic=*/false);
   B->invokeCtor();
 
-  // Initialize local variable inline descriptor.
-  InlineDescriptor &Desc = *reinterpret_cast(B->rawData());
-  Desc.Desc = D;
-  Desc.Offset = sizeof(InlineDescriptor);
-  Desc.IsActive = true;
-  Desc.IsBase = false;
-  Desc.IsMutable = false;
-  Desc.IsConst = false;
-  Desc.IsInitialized = false;
-
   // Register the local.
   unsigned Off = Locals.size();
   Locals.insert({Off, std::move(Memory)});
+
+  // Initialize local variable inline descriptor.
+  InlineDescriptor *Desc = localInlineDesc(Off);
+  Desc->Desc = D;
+  Desc->Offset = sizeof(InlineDescriptor);
+  Desc->IsActive = true;
+  Desc->IsBase = false;
+  Desc->IsMutable = false;
+  Desc->IsConst = false;
+  Desc->IsInitialized = false;
+
   return {Off, D};
 }
 
@@ -240,8 +248,8 @@
   assert(It != Locals.end() && "Missing local variable");
   auto *B = reinterpret_cast(It->second.get());
   *reinterpret_cast(B->data()) = S.Stk.pop();
-  InlineDescriptor &Desc = *reinterpret_cast(B->rawData());
-  Desc.IsInitialized = true;
+  InlineDescriptor *Desc = localInlineDesc(I);
+  Desc->IsInitialized = true;
 
   return true;
 }
@@ -254,6 +262,10 @@
 auto It = Locals.find(Local.Offset);
 assert(It != Locals.end() && "Missing local variable");
 S.deallocate(reinterpret_cast(It->second.get()));
+// Just make sure we're runnnig into some kind of error when a
+// local variable is used after being destroyed.
+InlineDescriptor *ID = localInlineDesc(I);
+std::memset(ID, 0, sizeof(InlineDescriptor));
   }
 
   return true;


Index: clang/lib/AST/Interp/InterpFrame.cpp
===
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -75,6 +75,10 @@
 void InterpFrame::destroy(unsigned Idx) {
   for (au

[PATCH] D142026: Optimize OptTable::findNearest implementation and usage

2023-01-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.



> Plausibly caused by this change -- I'm thinking that `MaximumDistance` is 
> initialized to `UINT_MAX - 1`, but then we cast that to a signed integer and 
> compare that, so it wraps to a large negative number.

@nikic : I thought I fixed that with e8a163dc03e6913360beb305620104ba129c081c 
 ... is it 
included in your build?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142026

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


[PATCH] D142181: [OptTable] Store llvm::cl::Option into a DenseMap instead of a StringMap

2023-01-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D142181#4070881 , @nikic wrote:

> In D142181#4070868 , 
> @serge-sans-paille wrote:
>
>> @nikic : I thought I fixed that with 
>> e8a163dc03e6913360beb305620104ba129c081c 
>>  ... is 
>> it included in your build?
>
> Oh yeah, I missed that fix. Sorry for the noise.

^^! Answered in the wrong thread, so I dupliaded that message to 
https://reviews.llvm.org/D142026 where it belongs :-)


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

https://reviews.llvm.org/D142181

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


[PATCH] D142277: [clang][Interp] Clear metadata when destroying locals

2023-01-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 491060.

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

https://reviews.llvm.org/D142277

Files:
  clang/lib/AST/Interp/EvalEmitter.cpp
  clang/lib/AST/Interp/InterpFrame.cpp


Index: clang/lib/AST/Interp/InterpFrame.cpp
===
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -75,6 +75,10 @@
 void InterpFrame::destroy(unsigned Idx) {
   for (auto &Local : Func->getScope(Idx).locals()) {
 S.deallocate(reinterpret_cast(localBlock(Local.Offset)));
+// Just make sure we're runnnig into some kind of error when a
+// local variable is used after being destroyed.
+InlineDescriptor *ID = localInlineDesc(Local.Offset);
+std::memset(ID, 0, sizeof(InlineDescriptor));
   }
 }
 
Index: clang/lib/AST/Interp/EvalEmitter.cpp
===
--- clang/lib/AST/Interp/EvalEmitter.cpp
+++ clang/lib/AST/Interp/EvalEmitter.cpp
@@ -253,7 +253,12 @@
   for (auto &Local : Descriptors[I]) {
 auto It = Locals.find(Local.Offset);
 assert(It != Locals.end() && "Missing local variable");
-S.deallocate(reinterpret_cast(It->second.get()));
+Block *B = reinterpret_cast(It->second.get());
+S.deallocate(B);
+// Just make sure we're runnnig into some kind of error when a
+// local variable is used after being destroyed.
+InlineDescriptor &ID = *reinterpret_cast(B->rawData());
+std::memset(&ID, 0, sizeof(InlineDescriptor));
   }
 
   return true;


Index: clang/lib/AST/Interp/InterpFrame.cpp
===
--- clang/lib/AST/Interp/InterpFrame.cpp
+++ clang/lib/AST/Interp/InterpFrame.cpp
@@ -75,6 +75,10 @@
 void InterpFrame::destroy(unsigned Idx) {
   for (auto &Local : Func->getScope(Idx).locals()) {
 S.deallocate(reinterpret_cast(localBlock(Local.Offset)));
+// Just make sure we're runnnig into some kind of error when a
+// local variable is used after being destroyed.
+InlineDescriptor *ID = localInlineDesc(Local.Offset);
+std::memset(ID, 0, sizeof(InlineDescriptor));
   }
 }
 
Index: clang/lib/AST/Interp/EvalEmitter.cpp
===
--- clang/lib/AST/Interp/EvalEmitter.cpp
+++ clang/lib/AST/Interp/EvalEmitter.cpp
@@ -253,7 +253,12 @@
   for (auto &Local : Descriptors[I]) {
 auto It = Locals.find(Local.Offset);
 assert(It != Locals.end() && "Missing local variable");
-S.deallocate(reinterpret_cast(It->second.get()));
+Block *B = reinterpret_cast(It->second.get());
+S.deallocate(B);
+// Just make sure we're runnnig into some kind of error when a
+// local variable is used after being destroyed.
+InlineDescriptor &ID = *reinterpret_cast(B->rawData());
+std::memset(&ID, 0, sizeof(InlineDescriptor));
   }
 
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134475: Add C++11 attribute msvc::constexpr

2023-01-21 Thread Richard Dzenis via Phabricator via cfe-commits
RIscRIpt added a comment.

I asked MSFT 

 to comment, let's see if they can share the spec for this attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134475

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


[PATCH] D141754: [5/15][Clang][RISCV][NFC] Remove extra attribute Policy::IntrinsicWithoutMU by reusing HasTailPolicy and HasMaskPolicy

2023-01-21 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141754

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


[clang] ff70e22 - [C++20][Modules] Handle defaulted and deleted functions in header units.

2023-01-21 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2023-01-21T12:55:52Z
New Revision: ff70e22f08d9a289c707ef192d7d4c5968e54b51

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

LOG: [C++20][Modules] Handle defaulted and deleted functions in header units.

Address part of https://github.com/llvm/llvm-project/issues/60079.

Deleted and Defaulted functions are implicitly inline, but that state
is not set at the point that we perform the diagnostic checks for externally-
visible non-inline functions; check the function body type explicitly in the
diagnostic.

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

Added: 


Modified: 
clang/lib/Sema/SemaDecl.cpp
clang/test/CXX/module/module.import/p6.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 3ae3e33a6704..e2b921bfe78f 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -15254,9 +15254,15 @@ Decl *Sema::ActOnStartOfFunctionDef(Scope 
*FnBodyScope, Decl *D,
   }
 
   // C++ [module.import/6] external definitions are not permitted in header
-  // units.
+  // units.  Deleted and Defaulted functions are implicitly inline (but the
+  // inline state is not set at this point, so check the BodyKind explicitly).
+  // FIXME: Consider an alternate location for the test where the inlined()
+  // state is complete.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
-  FD->getFormalLinkage() == Linkage::ExternalLinkage && !FD->isInlined()) {
+  FD->getFormalLinkage() == Linkage::ExternalLinkage &&
+  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
+  BodyKind != FnBodyKind::Default && !FD->isInlined()) {
+assert(FD->isThisDeclarationADefinition());
 Diag(FD->getLocation(), diag::err_extern_def_in_header_unit);
 FD->setInvalidDecl();
   }

diff  --git a/clang/test/CXX/module/module.import/p6.cpp 
b/clang/test/CXX/module/module.import/p6.cpp
index 7d8632786d9e..4360d3e67385 100644
--- a/clang/test/CXX/module/module.import/p6.cpp
+++ b/clang/test/CXX/module/module.import/p6.cpp
@@ -28,3 +28,11 @@ class A {
 static const int value = 43; 
 };
 
+void deleted_fn_ok (void) = delete;
+
+struct S {
+   ~S() noexcept(false) = default;
+private:
+  S(S&);
+};
+S::S(S&) = default;



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


[PATCH] D141908: [C++20][Modules] Handle defaulted and deleted functions in header units.

2023-01-21 Thread Iain Sandoe 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 rGff70e22f08d9: [C++20][Modules] Handle defaulted and deleted 
functions in header units. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141908

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/module/module.import/p6.cpp


Index: clang/test/CXX/module/module.import/p6.cpp
===
--- clang/test/CXX/module/module.import/p6.cpp
+++ clang/test/CXX/module/module.import/p6.cpp
@@ -28,3 +28,11 @@
 static const int value = 43; 
 };
 
+void deleted_fn_ok (void) = delete;
+
+struct S {
+   ~S() noexcept(false) = default;
+private:
+  S(S&);
+};
+S::S(S&) = default;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15254,9 +15254,15 @@
   }
 
   // C++ [module.import/6] external definitions are not permitted in header
-  // units.
+  // units.  Deleted and Defaulted functions are implicitly inline (but the
+  // inline state is not set at this point, so check the BodyKind explicitly).
+  // FIXME: Consider an alternate location for the test where the inlined()
+  // state is complete.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
-  FD->getFormalLinkage() == Linkage::ExternalLinkage && !FD->isInlined()) {
+  FD->getFormalLinkage() == Linkage::ExternalLinkage &&
+  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
+  BodyKind != FnBodyKind::Default && !FD->isInlined()) {
+assert(FD->isThisDeclarationADefinition());
 Diag(FD->getLocation(), diag::err_extern_def_in_header_unit);
 FD->setInvalidDecl();
   }


Index: clang/test/CXX/module/module.import/p6.cpp
===
--- clang/test/CXX/module/module.import/p6.cpp
+++ clang/test/CXX/module/module.import/p6.cpp
@@ -28,3 +28,11 @@
 static const int value = 43; 
 };
 
+void deleted_fn_ok (void) = delete;
+
+struct S {
+   ~S() noexcept(false) = default;
+private:
+  S(S&);
+};
+S::S(S&) = default;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -15254,9 +15254,15 @@
   }
 
   // C++ [module.import/6] external definitions are not permitted in header
-  // units.
+  // units.  Deleted and Defaulted functions are implicitly inline (but the
+  // inline state is not set at this point, so check the BodyKind explicitly).
+  // FIXME: Consider an alternate location for the test where the inlined()
+  // state is complete.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
-  FD->getFormalLinkage() == Linkage::ExternalLinkage && !FD->isInlined()) {
+  FD->getFormalLinkage() == Linkage::ExternalLinkage &&
+  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
+  BodyKind != FnBodyKind::Default && !FD->isInlined()) {
+assert(FD->isThisDeclarationADefinition());
 Diag(FD->getLocation(), diag::err_extern_def_in_header_unit);
 FD->setInvalidDecl();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142123: [clang-tidy] Add check to suggest use of #pragma once

2023-01-21 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Can you just elaborate on what the registry is used for? Is the plan to support 
potentially dynamically loading `HeaderGuardStyle` classes.
If thats the case, Then I'd argue we don't need the `HeaderGuardBase` check 
class, We can just create a `HeaderGuardCheck` class that creates an instance 
of the `HeaderGuardStyle` based on the configuration options.
Then to maintain backwards compatibility the `llvm-header-guard` could be an 
alias with the default style option set to `llvm` for example.


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

https://reviews.llvm.org/D142123

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


[PATCH] D142123: [clang-tidy] Add check to suggest use of #pragma once

2023-01-21 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Also this goes for all your PRs, can you please upload them in future with full 
context `git diff -U99` should do it. Makes revewing changes easier and 
removes those `Context not available` message on phab


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

https://reviews.llvm.org/D142123

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


[PATCH] D141232: [OpenMP] Modernize the kernel launching interface and APIs

2023-01-21 Thread Johannes Doerfert 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 rG16a385ba21a9: [OpenMP] Modernize the kernel launching 
interface and APIs (authored by jdoerfert).
Herald added projects: clang, OpenMP.
Herald added subscribers: openmp-commits, cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D141232?vs=490669&id=491085#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141232

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  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_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/interop_irbuilder.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_data_map_codegen_hold.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_has_device_addr_codegen.cpp
  clang/test/OpenMP/target_has_device_addr_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_map_member_expr_codegen.cpp
  clang/test/OpenMP/target_offload_mandatory_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_order_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_s

[clang] a93cb93 - [clang/driver] Make sure that `-gno-modules` by itself doesn't enable debug info

2023-01-21 Thread Argyrios Kyrtzidis via cfe-commits

Author: Argyrios Kyrtzidis
Date: 2023-01-21T11:33:30-08:00
New Revision: a93cb9302c1ac03f71d3a85de9405dc97c1bbc99

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

LOG: [clang/driver] Make sure that `-gno-modules` by itself doesn't enable 
debug info

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 12425e18406f0..40fb986fd6798 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3291,7 +3291,7 @@ def gdwarf_aranges : Flag<["-"], "gdwarf-aranges">, 
Group;
 def gmodules : Flag <["-"], "gmodules">, Group,
   HelpText<"Generate debug info with external references to clang modules"
" or precompiled headers">;
-def gno_modules : Flag <["-"], "gno-modules">, Group;
+def gno_modules : Flag <["-"], "gno-modules">, Group;
 def gz_EQ : Joined<["-"], "gz=">, Group,
 HelpText<"DWARF debug sections compression type">;
 def gz : Flag<["-"], "gz">, Alias, AliasArgs<["zlib"]>, 
Group;

diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index b2198ebd0a207..dedd96c82da96 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -303,6 +303,8 @@
 // RUN: %clang -### -gmodules -gno-modules %s 2>&1 \
 // RUN:| FileCheck -check-prefix=NOGEXTREFS %s
 //
+// RUN: %clang -### -gno-modules %s 2>&1 | FileCheck -check-prefix=GNOMOD %s
+//
 // NOG_PS: "-cc1"
 // NOG_PS-NOT: "-dwarf-version=
 // NOG_PS: "-generate-arange-section"
@@ -411,6 +413,8 @@
 // GEXTREFS: "-dwarf-ext-refs" "-fmodule-format=obj"
 // GEXTREFS: "-debug-info-kind={{standalone|constructor}}"
 // NOGEXTREFS-NOT: -dwarf-ext-refs
+//
+// GNOMOD-NOT: -debug-info-kind=
 
 // RUN: not %clang -cc1 -debug-info-kind=watkind 2>&1 | FileCheck 
-check-prefix=BADSTRING1 %s
 // BADSTRING1: error: invalid value 'watkind' in '-debug-info-kind=watkind'



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


[PATCH] D142123: [clang-tidy] Add check to suggest use of #pragma once

2023-01-21 Thread Kyle Edwards via Phabricator via cfe-commits
KyleFromKitware added a comment.

In D142123#4071099 , @njames93 wrote:

> Can you just elaborate on what the registry is used for? Is the plan to 
> support potentially dynamically loading `HeaderGuardStyle` classes.

Yes.

> If thats the case, Then I'd argue we don't need the `HeaderGuardBase` check 
> class, We can just create a `HeaderGuardCheck` class that creates an instance 
> of the `HeaderGuardStyle` based on the configuration options.

Yes, that was my plan, sorry for not making that explicit. `HeaderGuardStyle` 
is supposed to be analogous to `HeaderGuardBase` and `MacroHeaderGuardStyle` is 
supposed to be analogous to `HeaderGuardCheck` from D142121 
.

> Then to maintain backwards compatibility the `llvm-header-guard` could be an 
> alias with the default style option set to `llvm` for example.

Sounds good. What should the default for regular `header-guard` be then?

> Also this goes for all your PRs, can you please upload them in future with 
> full context `git diff -U99` should do it. Makes revewing changes easier 
> and removes those `Context not available` message on phab

Will do.


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

https://reviews.llvm.org/D142123

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


[PATCH] D141232: [OpenMP] Modernize the kernel launching interface and APIs

2023-01-21 Thread Ron Lieberman via Phabricator via cfe-commits
ronlieb added a comment.

hi, breaks our amdgpu buildbot, please fix ASAP , or revert and fix.  thx
3 patches:  https://lab.llvm.org/buildbot/#/builders/193/builds/25299

i reverted locally and verified this patch as the  cause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141232

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


[PATCH] D142196: [clang][Lex] Add back PPCallbacks::FileNotFound

2023-01-21 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 491095.
Hahnfeld added a comment.

Add unit test.


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

https://reviews.llvm.org/D142196

Files:
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Lex/PPDirectives.cpp
  clang/unittests/Lex/PPCallbacksTest.cpp

Index: clang/unittests/Lex/PPCallbacksTest.cpp
===
--- clang/unittests/Lex/PPCallbacksTest.cpp
+++ clang/unittests/Lex/PPCallbacksTest.cpp
@@ -444,6 +444,50 @@
   ASSERT_EQ("\"tri\?\?-graph.h\"", GetSourceString(Range));
 }
 
+TEST_F(PPCallbacksTest, FileNotFoundSkipped) {
+  const char *SourceText = "#include \"skipped.h\"\n";
+
+  std::unique_ptr SourceBuf =
+  llvm::MemoryBuffer::getMemBuffer(SourceText);
+  SourceMgr.setMainFileID(SourceMgr.createFileID(std::move(SourceBuf)));
+
+  HeaderSearch HeaderInfo(std::make_shared(), SourceMgr,
+  Diags, LangOpts, Target.get());
+  TrivialModuleLoader ModLoader;
+
+  DiagnosticConsumer *DiagConsumer = new DiagnosticConsumer;
+  DiagnosticsEngine FileNotFoundDiags(DiagID, DiagOpts.get(), DiagConsumer);
+  Preprocessor PP(std::make_shared(), FileNotFoundDiags,
+  LangOpts, SourceMgr, HeaderInfo, ModLoader,
+  /*IILookup=*/nullptr,
+  /*OwnsHeaderSearch=*/false);
+  PP.Initialize(*Target);
+
+  class FileNotFoundCallbacks : public PPCallbacks {
+  public:
+unsigned int NumCalls = 0;
+bool FileNotFound(StringRef FileName) override {
+  NumCalls++;
+  return FileName == "skipped.h";
+}
+  };
+
+  auto *Callbacks = new FileNotFoundCallbacks;
+  PP.addPPCallbacks(std::unique_ptr(Callbacks));
+
+  // Lex source text.
+  PP.EnterMainSourceFile();
+  while (true) {
+Token Tok;
+PP.Lex(Tok);
+if (Tok.is(tok::eof))
+  break;
+  }
+
+  ASSERT_EQ(1u, Callbacks->NumCalls);
+  ASSERT_EQ(0u, DiagConsumer->getNumErrors());
+}
+
 TEST_F(PPCallbacksTest, OpenCLExtensionPragmaEnabled) {
   const char* Source =
 "#pragma OPENCL EXTENSION cl_khr_fp64 : enable\n";
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2000,6 +2000,10 @@
   if (File)
 return File;
 
+  // Give the clients a chance to silently skip this include.
+  if (Callbacks && Callbacks->FileNotFound(Filename))
+return std::nullopt;
+
   if (SuppressIncludeNotFoundError)
 return std::nullopt;
 
Index: clang/include/clang/Lex/PPCallbacks.h
===
--- clang/include/clang/Lex/PPCallbacks.h
+++ clang/include/clang/Lex/PPCallbacks.h
@@ -83,6 +83,16 @@
const Token &FilenameTok,
SrcMgr::CharacteristicKind FileType) {}
 
+  /// Callback invoked whenever an inclusion directive results in a
+  /// file-not-found error.
+  ///
+  /// \param FileName The name of the file being included, as written in the
+  /// source code.
+  ///
+  /// \returns true to indicate that the preprocessor should skip this file
+  /// and not issue any diagnostic.
+  virtual bool FileNotFound(StringRef FileName) { return false; }
+
   /// Callback invoked whenever an inclusion directive of
   /// any kind (\c \#include, \c \#import, etc.) has been processed, regardless
   /// of whether the inclusion will actually result in an inclusion.
@@ -451,6 +461,14 @@
 Second->FileSkipped(SkippedFile, FilenameTok, FileType);
   }
 
+  bool FileNotFound(StringRef FileName) override {
+bool Skip = First->FileNotFound(FileName);
+// Make sure to invoke the second callback, no matter if the first already
+// returned true to skip the file.
+Skip |= Second->FileNotFound(FileName);
+return Skip;
+  }
+
   void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
   StringRef FileName, bool IsAngled,
   CharSourceRange FilenameRange,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 366fc10 - [OpenMP][FIX] Remove version check lines in clang test

2023-01-21 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2023-01-21T13:25:24-08:00
New Revision: 366fc10f065dee6fdf94bcaddaecb048dab902e8

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

LOG: [OpenMP][FIX] Remove version check lines in clang test

We really need a way to make the check line script deal with these
automatically.

Added: 


Modified: 
clang/test/OpenMP/target_data_map_codegen_hold.cpp

Removed: 




diff  --git a/clang/test/OpenMP/target_data_map_codegen_hold.cpp 
b/clang/test/OpenMP/target_data_map_codegen_hold.cpp
index f267833232fe..5f4e50eaf0e3 100644
--- a/clang/test/OpenMP/target_data_map_codegen_hold.cpp
+++ b/clang/test/OpenMP/target_data_map_codegen_hold.cpp
@@ -522,13 +522,3 @@ void foo(int arg) {
 // CHECK-I386: attributes #0 = { mustprogress noinline nounwind optnone 
"min-legal-vector-width"="0" "no-trapping-math"="true" 
"stack-protector-buffer-size"="8" "target-features"="+cx8,+x87" }
 // CHECK-I386: attributes #1 = { nounwind }
 // CHECK-I386: attributes #2 = { nocallback nofree nounwind willreturn 
memory(argmem: readwrite) }
-//.
-// CHECK-PPC64LE: !0 = !{i32 1, !"wchar_size", i32 4}
-// CHECK-PPC64LE: !1 = !{i32 7, !"openmp", i32 50}
-// CHECK-PPC64LE: !2 = !{!"clang version 16.0.0"}
-//.
-// CHECK-I386: !0 = !{i32 1, !"NumRegisterParameters", i32 0}
-// CHECK-I386: !1 = !{i32 1, !"wchar_size", i32 4}
-// CHECK-I386: !2 = !{i32 7, !"openmp", i32 50}
-// CHECK-I386: !3 = !{!"clang version 16.0.0"}
-//.



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


[PATCH] D141775: [Clang] Export CanPassInRegisters as a type trait

2023-01-21 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 491102.
royjacobson added a comment.

fix the test after diag change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141775

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp

Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3055,6 +3055,36 @@
 
 } // namespace is_trivially_relocatable
 
+namespace can_pass_in_regs {
+
+struct A { };
+
+struct B {
+  ~B();
+};
+
+struct C; // expected-note {{forward declaration}}
+
+union D {
+  int x;
+};
+
+static_assert(__can_pass_in_regs(A), "");
+static_assert(__can_pass_in_regs(A), "");
+static_assert(!__can_pass_in_regs(B), "");
+static_assert(__can_pass_in_regs(D), "");
+
+void test_errors() {
+  (void)__can_pass_in_regs(const A); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(A&); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(A&&); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(const A&); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(C); // expected-error {{incomplete type}}
+  (void)__can_pass_in_regs(int); // expected-error {{not an unqualified class type}}
+  (void)__can_pass_in_regs(int&); // expected-error {{not an unqualified class type}}
+}
+}
+
 struct S {};
 template  using remove_const_t = __remove_const(T);
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4883,6 +4883,7 @@
   case UTT_IsLiteral:
   // By analogy, is_trivially_relocatable imposes the same constraints.
   case UTT_IsTriviallyRelocatable:
+  case UTT_CanPassInRegs:
   // Per the GCC type traits documentation, T shall be a complete type, cv void,
   // or an array of unknown bound. But GCC actually imposes the same constraints
   // as above.
@@ -5371,6 +5372,11 @@
 return T.isTriviallyRelocatableType(C);
   case UTT_IsReferenceable:
 return T.isReferenceable();
+  case UTT_CanPassInRegs:
+if (CXXRecordDecl *RD = T->getAsCXXRecordDecl(); RD && !T.hasQualifiers())
+  return RD->canPassInRegisters();
+Self.Diag(KeyLoc, diag::err_builtin_pass_in_regs_non_class) << T;
+return false;
   }
 }
 
Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -523,6 +523,7 @@
 TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX)
 TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
+TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 
 // Embarcadero Expression Traits
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11786,4 +11786,7 @@
   InGroup, DefaultIgnore;
 def err_loongarch_builtin_requires_la32 : Error<
   "this builtin requires target: loongarch32">;
+
+def err_builtin_pass_in_regs_non_class : Error<
+  "argument %0 is not an unqualified class type">;
 } // end of sema component.
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1398,6 +1398,10 @@
 * ``__array_extent(type, dim)`` (Embarcadero):
   The ``dim``'th array bound in the type ``type``, or ``0`` if
   ``dim >= __array_rank(type)``.
+* ``__can_pass_in_regs`` (C++)
+  Returns whether a class can be passed in registers under the current
+  ABI. This type can only be applied to unqualified class types.
+  This is not a portable type trait.
 * ``__has_nothrow_assign`` (GNU, Microsoft, Embarcadero):
   Deprecated, use ``__is_nothrow_assignable`` instead.
 * ``__has_nothrow_move_assign`` (GNU, Microsoft):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

> What happens with code like this
>
>   void foo(bar&& B) {
> std::move(B);
>   }

I raised https://github.com/isocpp/CppCoreGuidelines/issues/2026


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D141232: [OpenMP] Modernize the kernel launching interface and APIs

2023-01-21 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D141232#4071310 , @ronlieb wrote:

> hi, breaks our amdgpu buildbot, please fix ASAP , or revert and fix.  thx
> 3 patches:  https://lab.llvm.org/buildbot/#/builders/193/builds/25299
>
> i reverted locally and verified this patch as the  cause.

Fixed by 3820d0eaaf4ecb557cbb260e34bf5a9eeb51e0e7 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141232

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


[clang] 915602e - [OpenMP][FIX] Add default clause to switch

2023-01-21 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2023-01-21T19:50:22-08:00
New Revision: 915602e096f2bb4abb53e00f07b90ee821a49963

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

LOG: [OpenMP][FIX] Add default clause to switch

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 4ba2c4b59991..6bc30ad0302e 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6458,98 +6458,7 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, 
OpenMPClauseKind Kind,
  IsPostfixUpdate, IsFailOnly, Loc);
 break;
   }
-  case OMPC_if:
-  case OMPC_final:
-  case OMPC_num_threads:
-  case OMPC_private:
-  case OMPC_firstprivate:
-  case OMPC_lastprivate:
-  case OMPC_reduction:
-  case OMPC_task_reduction:
-  case OMPC_in_reduction:
-  case OMPC_safelen:
-  case OMPC_simdlen:
-  case OMPC_sizes:
-  case OMPC_full:
-  case OMPC_partial:
-  case OMPC_allocator:
-  case OMPC_allocate:
-  case OMPC_collapse:
-  case OMPC_default:
-  case OMPC_seq_cst:
-  case OMPC_acq_rel:
-  case OMPC_acquire:
-  case OMPC_release:
-  case OMPC_relaxed:
-  case OMPC_shared:
-  case OMPC_linear:
-  case OMPC_aligned:
-  case OMPC_copyin:
-  case OMPC_copyprivate:
-  case OMPC_flush:
-  case OMPC_depobj:
-  case OMPC_proc_bind:
-  case OMPC_schedule:
-  case OMPC_ordered:
-  case OMPC_nowait:
-  case OMPC_untied:
-  case OMPC_threadprivate:
-  case OMPC_depend:
-  case OMPC_mergeable:
-  case OMPC_device:
-  case OMPC_threads:
-  case OMPC_simd:
-  case OMPC_map:
-  case OMPC_num_teams:
-  case OMPC_thread_limit:
-  case OMPC_priority:
-  case OMPC_grainsize:
-  case OMPC_nogroup:
-  case OMPC_num_tasks:
-  case OMPC_hint:
-  case OMPC_dist_schedule:
-  case OMPC_defaultmap:
-  case OMPC_uniform:
-  case OMPC_to:
-  case OMPC_from:
-  case OMPC_use_device_ptr:
-  case OMPC_use_device_addr:
-  case OMPC_is_device_ptr:
-  case OMPC_has_device_addr:
-  case OMPC_unified_address:
-  case OMPC_unified_shared_memory:
-  case OMPC_reverse_offload:
-  case OMPC_dynamic_allocators:
-  case OMPC_atomic_default_mem_order:
-  case OMPC_at:
-  case OMPC_severity:
-  case OMPC_message:
-  case OMPC_device_type:
-  case OMPC_match:
-  case OMPC_nontemporal:
-  case OMPC_order:
-  case OMPC_destroy:
-  case OMPC_detach:
-  case OMPC_inclusive:
-  case OMPC_exclusive:
-  case OMPC_uses_allocators:
-  case OMPC_affinity:
-  case OMPC_init:
-  case OMPC_inbranch:
-  case OMPC_notinbranch:
-  case OMPC_link:
-  case OMPC_indirect:
-  case OMPC_use:
-  case OMPC_novariants:
-  case OMPC_nocontext:
-  case OMPC_filter:
-  case OMPC_when:
-  case OMPC_adjust_args:
-  case OMPC_append_args:
-  case OMPC_memory_order:
-  case OMPC_bind:
-  case OMPC_align:
-  case OMPC_cancellation_construct_type:
+  default:
 llvm_unreachable("Clause is not allowed in 'omp atomic'.");
   }
 }



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


[PATCH] D142296: [clang-format] Fix a bug in parsing C++20 import statements

2023-01-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142296

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12810,6 +12810,7 @@
   // But 'import' might also be a regular C++ namespace.
   verifyFormat("import::SomeFunction(aaa,\n"
" a);");
+  verifyFormat("import::Bar foo(val ? 2 : 1);");
 }
 
 
//===--===//
@@ -24654,6 +24655,8 @@
   verifyFormat("import", Style);
   verifyFormat("module", Style);
   verifyFormat("export", Style);
+
+  verifyFormat("import = val ? 2 : 1;");
 }
 
 TEST_F(FormatTest, CoroutineForCoawait) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -41,7 +41,7 @@
 
   // Returns the token that would be returned by the next call to
   // getNextToken().
-  virtual FormatToken *peekNextToken() = 0;
+  virtual FormatToken *peekNextToken(bool SkipComment = false) = 0;
 
   // Returns whether we are at the end of the file.
   // This can be different from whether getNextToken() returned an eof token
@@ -169,10 +169,10 @@
 return PreviousTokenSource->getPreviousToken();
   }
 
-  FormatToken *peekNextToken() override {
+  FormatToken *peekNextToken(bool SkipComment) override {
 if (eof())
   return &FakeEOF;
-return PreviousTokenSource->peekNextToken();
+return PreviousTokenSource->peekNextToken(SkipComment);
   }
 
   bool isEOF() override { return PreviousTokenSource->isEOF(); }
@@ -288,8 +288,11 @@
 return Position > 0 ? Tokens[Position - 1] : nullptr;
   }
 
-  FormatToken *peekNextToken() override {
+  FormatToken *peekNextToken(bool SkipComment) override {
 int Next = Position + 1;
+if (SkipComment)
+  while (Tokens[Next]->is(tok::comment))
+++Next;
 LLVM_DEBUG({
   llvm::dbgs() << "Peeking ";
   dbgToken(Next);
@@ -1727,8 +1730,13 @@
 return;
   }
   if (Style.isCpp()) {
-parseModuleImport();
-return;
+if (auto Token = Tokens->peekNextToken(/*SkipComment=*/true);
+Token->Tok.getIdentifierInfo() ||
+Token->TokenText.startswith("\"") ||
+Token->isOneOf(tok::less, tok::colon)) {
+  parseModuleImport();
+  return;
+}
   }
 }
 if (Style.isCpp() &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12810,6 +12810,7 @@
   // But 'import' might also be a regular C++ namespace.
   verifyFormat("import::SomeFunction(aaa,\n"
" a);");
+  verifyFormat("import::Bar foo(val ? 2 : 1);");
 }
 
 //===--===//
@@ -24654,6 +24655,8 @@
   verifyFormat("import", Style);
   verifyFormat("module", Style);
   verifyFormat("export", Style);
+
+  verifyFormat("import = val ? 2 : 1;");
 }
 
 TEST_F(FormatTest, CoroutineForCoawait) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -41,7 +41,7 @@
 
   // Returns the token that would be returned by the next call to
   // getNextToken().
-  virtual FormatToken *peekNextToken() = 0;
+  virtual FormatToken *peekNextToken(bool SkipComment = false) = 0;
 
   // Returns whether we are at the end of the file.
   // This can be different from whether getNextToken() returned an eof token
@@ -169,10 +169,10 @@
 return PreviousTokenSource->getPreviousToken();
   }
 
-  FormatToken *peekNextToken() override {
+  FormatToken *peekNextToken(bool SkipComment) override {
 if (eof())
   return &FakeEOF;
-return PreviousTokenSource->peekNextToken();
+return PreviousTokenSource->peekNextToken(SkipComment);
   }
 
   bool isEOF() override { return PreviousTokenSource->isEOF(); }
@@ -288,8 +288,11 @@
 return Position > 0 ? Tokens[Position - 1] : nullptr;
   }
 
-  FormatToken *peekNextToken() override {
+  FormatToken *peekNextToken(bool 

[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D141654#4053551 , 
@HazardyKnusperkeks wrote:

> In D141654#4053470 , @rymiel wrote:
>
>> This also made me wonder, is there an actual policy on deprecated options? 
>> As in, when they are actually removed. Is there even prior precedent for 
>> doing this? (I wouldn't know because I'm a very recent user)
>
> I think the first one was D108752  and the 
> documentation can handle that since D127578 
> .
> Removing an option is not different than changing the type of an option, 
> users of `libformat` have to adapt, and users of `clang-format` don't notice 
> (if everything is done right), because the parsing for the removed options is 
> still there, see lines 1068 and following of `Format.cpp` in this change.

+1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141654

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


[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

2023-01-21 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D141654#4053470 , @rymiel wrote:

> This also made me wonder, is there an actual policy on deprecated options? As 
> in, when they are actually removed.

We deprecate options only as a cleanup (as in this patch) or when adding new 
options (as in D108752 ) and should keep 
maintain backward compatibility. (Also see the original idea from 
@MyDeveloperDay in https://reviews.llvm.org/D19031#1745767.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141654

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


[PATCH] D142297: [Clang][OpenMP] Find the type `omp_allocator_handle_t` from identifier table

2023-01-21 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, ABataev.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP.

In Clang, in order to determine the type of `omp_allocator_handle_t`, Clang
checks the type of those predefined allocators. The first one it checks is
`omp_null_allocator`. If the language is C, and the system is 64-bit, what Clang
gets is a `int`, instead of an enum of size 8, given the fact how we define
`omp_allocator_handle_t` in `omp.h`.  If the allocator is captured by a region,
let's say a parallel region, the allocator will be privatized. Because Clang 
deems
`omp_allocator_handle_t` as an `int`, it will first cast the value returned by
the runtime library (for `libomp` it is a `void *`) to `int`, and then in the
outlined function, it casts back to `omp_allocator_handle_t`. This two casts
completely shaves the first 32-bit of the pointer value returned from `libomp`,
and when the private "new" pointer is fed to another runtime function
`__kmpc_allocate()`, it causes segment fault. That is the root cause of PR54082.
I have no idea why `-fno-pic` could hide this bug.

In this patch, we detect `omp_allocator_handle_t` using roughly the same method
as `omp_event_handle_t`, by looking it up into the identifier table.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142297

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_uses_allocators.c
  openmp/runtime/test/parallel/bug54082.c

Index: openmp/runtime/test/parallel/bug54082.c
===
--- /dev/null
+++ openmp/runtime/test/parallel/bug54082.c
@@ -0,0 +1,54 @@
+// This test is adapted from test_parallel_for_allocate.c in SOLLVE V&V.
+// https://github.com/SOLLVE/sollve_vv/blob/master/tests/5.0/parallel_for/test_parallel_for_allocate.c
+// RUN: %libomp-compile-and-run
+#include 
+
+#include 
+#include 
+
+#define N 1024
+
+int main(int argc, char *argv[]) {
+  int errors = 0;
+  int *x;
+  int result[N][N];
+  int successful_alloc = 0;
+
+  omp_memspace_handle_t x_memspace = omp_default_mem_space;
+  omp_alloctrait_t x_traits[1] = {omp_atk_alignment, 64};
+  omp_allocator_handle_t x_alloc = omp_init_allocator(x_memspace, 1, x_traits);
+
+  for (int i = 0; i < N; i++) {
+for (int j = 0; j < N; j++) {
+  result[i][j] = -1;
+}
+  }
+
+#pragma omp parallel for allocate(x_alloc: x) private(x) shared(result)
+  for (int i = 0; i < N; i++) {
+x = (int *)malloc(N * sizeof(int));
+if (x != NULL) {
+#pragma omp simd simdlen(16) aligned(x : 64)
+  for (int j = 0; j < N; j++) {
+x[j] = j * i;
+  }
+  for (int j = 0; j < N; j++) {
+result[i][j] = x[j];
+  }
+  free(x);
+  successful_alloc++;
+}
+  }
+
+  errors += successful_alloc < 1;
+
+  for (int i = 0; i < N; i++) {
+for (int j = 0; j < N; j++) {
+  errors += result[i][j] != i * j;
+}
+  }
+
+  omp_destroy_allocator(x_alloc);
+
+  return errors;
+}
Index: clang/test/OpenMP/target_uses_allocators.c
===
--- clang/test/OpenMP/target_uses_allocators.c
+++ clang/test/OpenMP/target_uses_allocators.c
@@ -6,7 +6,7 @@
 #ifndef HEADER
 #define HEADER
 
-enum omp_allocator_handle_t {
+typedef enum omp_allocator_handle_t {
   omp_null_allocator = 0,
   omp_default_mem_alloc = 1,
   omp_large_cap_mem_alloc = 2,
@@ -17,7 +17,7 @@
   omp_pteam_mem_alloc = 7,
   omp_thread_mem_alloc = 8,
   KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
-};
+} omp_allocator_handle_t;
 
 // CHECK: define {{.*}}[[FIE:@.+]]()
 void fie(void) {
@@ -105,4 +105,4 @@
 // CHECK-NEXT: %.x..void.addr = call ptr @__kmpc_alloc(i32 %[[#R0]], i64 4, ptr inttoptr (i64 8 to ptr))
 // CHECK-NEXT: %[[#R1:]] = load i32, ptr %x.addr, align 4
 // CHECK-NEXT: store i32 %[[#R1]], ptr %.x..void.addr, align 4
-// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr inttoptr (i64 8 to ptr))
\ No newline at end of file
+// CHECK-NEXT: call void @__kmpc_free(i32 %[[#R0]], ptr %.x..void.addr, ptr inttoptr (i64 8 to ptr))
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -3280,13 +3280,15 @@
   Allocator->containsUnexpandedParameterPack())
 return OMPAllocateDeclAttr::OMPUserDefinedMemAlloc;
   auto AllocatorKindRes = OMPAllocateDeclAttr::OMPUserDefinedMemAlloc;
+  llvm::FoldingSetNodeID AEId;
   const Expr *AE = Allocator->IgnoreParenImpCasts();
+  AE->IgnoreImpCasts()->Profile(AEId, S.getASTContext(), /*Canonical=*/true);
   for (int I = 0; I < OMPAllocateDeclAttr::OMPUserDefinedMemAlloc; ++I) {
 auto AllocatorKind = static_cast(I);
 const Expr *DefAllocator = Stack->getAllocato

[PATCH] D142046: [BPF][clang] Ignore stack protector options for BPF target

2023-01-21 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi, our internal release build buildbot seems to have issues with this test. It 
seems you are expected the following function declaration in the emitted IR:

  define dso_local void @_Z5test1PKc(ptr noundef %msg) #0 !dbg !19 {

But in a release build, it becomes:

  define dso_local void @_Z5test1PKc(ptr noundef %0) #0 !dbg !19 {

Note that %msg became %0. Can you fix the test so that it works in release 
builds as well?

Godbolt link: https://godbolt.org/z/E5zbM4chc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142046

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 491124.
ccotter added a comment.

- Fix windows, fix crash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,245 @@
+// RUN: %check_clang_tidy -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:35: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = [&o]() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = [&o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [&o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = [&o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:25: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  auto never_moves_with_auto_param = [](Obj&& o1, auto& v) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+// Negati

[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 491125.
ccotter added a comment.

- Fix windows, fix crash


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,244 @@
+// RUN: %check_clang_tidy -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:35: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = [&o]() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = [&o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [&o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = [&o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:25: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  auto never_moves_with_auto_param = [](Obj&& o1, auto& v) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+// Negati

[PATCH] D141892: Implement modernize-use-constraints

2023-01-21 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 491127.
ccotter added a comment.

- Add fno-delayed-template-parsing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141892

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints-first-greatergreater.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
@@ -0,0 +1,693 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-constraints %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template  struct enable_if { };
+
+template  struct enable_if { typedef T type; };
+
+template 
+using enable_if_t = typename enable_if::type;
+
+} // namespace std
+// NOLINTEND
+
+template 
+struct ConsumeVariadic;
+
+struct Obj {
+};
+
+namespace enable_if_in_return_type {
+
+
+// Section 1: enable_if in return type of function
+
+
+
+// General tests
+
+
+template 
+typename std::enable_if::type basic() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t basic_t() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic_t() requires T::some_value {{{$}}
+
+template 
+auto basic_trailing() -> typename std::enable_if::type {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:26: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}auto basic_trailing() -> Obj requires T::some_value {{{$}}
+
+template 
+typename std::enable_if::type existing_constraint() requires (T::another_value) {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}typename std::enable_if::type existing_constraint() requires (T::another_value) {{{$}}
+
+template 
+typename std::enable_if::type decl_without_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def() {
+  return Obj{};
+}
+// FIXME - Support definitions with separate decls
+
+template 
+std::enable_if_t no_dependent_type(U) {
+  return Obj{};
+}
+// FIXME - Support non-dependent enable_ifs. Low priority though...
+
+template 
+typename std::enable_if::type* pointer_of_enable_if() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t* pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+const std::enable_if_t* const_pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}const int* const_pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t const * const_pointer_of_enable_if_t2() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int const * const_pointer_of_enable_if_t2() requires T::some_value {{{$}}
+
+
+template 
+std::enable_if_t& reference_of_enable_if_t() {
+  static int x; return x;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int& reference_of_en

[clang] 183d075 - [BPF][Clang] Fix func argument pattern in bpf-stack-protector test

2023-01-21 Thread Yonghong Song via cfe-commits

Author: Yonghong Song
Date: 2023-01-21T22:33:15-08:00
New Revision: 183d075055c591dedead7ece972f1bdea611aa3b

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

LOG: [BPF][Clang] Fix func argument pattern in bpf-stack-protector test

Commit 56b038f887f3("[BPF][clang] Ignore stack protector options for BPF
target") added a test for its corresponding functionality.
Douglas Yung found that the test will fail with the release build
buildbot due to different func argument patterns (from %msg
to %0). This patch fixed the issue by using pattern [0-9a-z]+
which allows both %msg and %0.

Added: 


Modified: 
clang/test/CodeGen/bpf-stack-protector.c

Removed: 




diff  --git a/clang/test/CodeGen/bpf-stack-protector.c 
b/clang/test/CodeGen/bpf-stack-protector.c
index a005bb96ff1ed..c17af890eac23 100644
--- a/clang/test/CodeGen/bpf-stack-protector.c
+++ b/clang/test/CodeGen/bpf-stack-protector.c
@@ -24,7 +24,7 @@ char *strcpy(char *s1, const char *s2);
 //  STRONG: warning: ignoring '-fstack-protector-strong'
 // COMMON-SAME: option as it is not currently supported for target 'bpf'
 
-// COMMON: define {{.*}}void @test1(ptr noundef %msg) #[[A:.*]] {
+// COMMON: define {{.*}}void @test1(ptr noundef %{{[0-9a-z]+}}) #[[A:.*]] {
 void test1(const char *msg) {
   char a[strlen(msg) + 1];
   strcpy(a, msg);



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


[PATCH] D142046: [BPF][clang] Ignore stack protector options for BPF target

2023-01-21 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@dyung I just pushed the fix to the 'main' branch 
(https://github.com/llvm/llvm-project/commit/183d075055c591dedead7ece972f1bdea611aa3b).
 Please check it out. Thanks for reporting!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142046

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


[clang] b07399f - [clang][Interp][NFC] Forward-declare Boolean in PrimTypes.h

2023-01-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-22T08:33:39+01:00
New Revision: b07399f0fa177fc9b673a5c32fce94233e8f5643

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

LOG: [clang][Interp][NFC] Forward-declare Boolean in PrimTypes.h

We don't need the full header file here.

Added: 


Modified: 
clang/lib/AST/Interp/Descriptor.cpp
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/InterpFrame.cpp
clang/lib/AST/Interp/PrimType.cpp
clang/lib/AST/Interp/PrimType.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index 58158cd49ceb..09e0b650eb67 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Descriptor.h"
+#include "Boolean.h"
 #include "Pointer.h"
 #include "PrimType.h"
 #include "Record.h"

diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 338c35cb1835..ed3accd98a90 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_AST_INTERP_INTERP_H
 #define LLVM_CLANG_AST_INTERP_INTERP_H
 
+#include "Boolean.h"
 #include "Function.h"
 #include "InterpFrame.h"
 #include "InterpStack.h"

diff  --git a/clang/lib/AST/Interp/InterpFrame.cpp 
b/clang/lib/AST/Interp/InterpFrame.cpp
index f6437771ccbe..30068e12aa9d 100644
--- a/clang/lib/AST/Interp/InterpFrame.cpp
+++ b/clang/lib/AST/Interp/InterpFrame.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "InterpFrame.h"
+#include "Boolean.h"
 #include "Function.h"
 #include "InterpStack.h"
 #include "InterpState.h"

diff  --git a/clang/lib/AST/Interp/PrimType.cpp 
b/clang/lib/AST/Interp/PrimType.cpp
index 0c6d11844ffc..eda90e1c36c2 100644
--- a/clang/lib/AST/Interp/PrimType.cpp
+++ b/clang/lib/AST/Interp/PrimType.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "PrimType.h"
+#include "Boolean.h"
 #include "Pointer.h"
 
 using namespace clang;

diff  --git a/clang/lib/AST/Interp/PrimType.h b/clang/lib/AST/Interp/PrimType.h
index 3a77c66c7437..c8f2a600fb3c 100644
--- a/clang/lib/AST/Interp/PrimType.h
+++ b/clang/lib/AST/Interp/PrimType.h
@@ -13,16 +13,16 @@
 #ifndef LLVM_CLANG_AST_INTERP_TYPE_H
 #define LLVM_CLANG_AST_INTERP_TYPE_H
 
+#include "Integral.h"
 #include 
 #include 
 #include 
-#include "Boolean.h"
-#include "Integral.h"
 
 namespace clang {
 namespace interp {
 
 class Pointer;
+class Boolean;
 
 /// Enumeration of the primitive types of the VM.
 enum PrimType : unsigned {



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


[clang] 680993e - [clang][Interp][NFC] Fix header comment file name

2023-01-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-22T08:33:39+01:00
New Revision: 680993e90ba3201e46f3272ddb9a617a567194d3

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

LOG: [clang][Interp][NFC] Fix header comment file name

Added: 


Modified: 
clang/lib/AST/Interp/PrimType.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/PrimType.cpp 
b/clang/lib/AST/Interp/PrimType.cpp
index bd0f73df2ead2..0c6d11844ffca 100644
--- a/clang/lib/AST/Interp/PrimType.cpp
+++ b/clang/lib/AST/Interp/PrimType.cpp
@@ -1,4 +1,4 @@
-//===--- Type.cpp - Types for the constexpr VM --*- C++ 
-*-===//
+//===--- PrimType.cpp - Types for the constexpr VM --*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.



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


[clang] 8e7c1b9 - [clang][Interp][NFCI] Make InitMap::isInitialized() const

2023-01-21 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-01-22T08:33:40+01:00
New Revision: 8e7c1b9a3d5f08046261ca0b7e5d319a4c4c9b25

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

LOG: [clang][Interp][NFCI] Make InitMap::isInitialized() const

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index 09e0b650eb67..70294af7dea7 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -280,6 +280,11 @@ InitMap::T *InitMap::data() {
   return reinterpret_cast(Start);
 }
 
+const InitMap::T *InitMap::data() const {
+  auto *Start = reinterpret_cast(this) + align(sizeof(InitMap));
+  return reinterpret_cast(Start);
+}
+
 bool InitMap::initialize(unsigned I) {
   unsigned Bucket = I / PER_FIELD;
   T Mask = T(1) << (I % PER_FIELD);
@@ -290,7 +295,7 @@ bool InitMap::initialize(unsigned I) {
   return UninitFields == 0;
 }
 
-bool InitMap::isInitialized(unsigned I) {
+bool InitMap::isInitialized(unsigned I) const {
   unsigned Bucket = I / PER_FIELD;
   return data()[Bucket] & (T(1) << (I % PER_FIELD));
 }

diff  --git a/clang/lib/AST/Interp/Descriptor.h 
b/clang/lib/AST/Interp/Descriptor.h
index ae39d38d8184..730d66b0cb64 100644
--- a/clang/lib/AST/Interp/Descriptor.h
+++ b/clang/lib/AST/Interp/Descriptor.h
@@ -205,13 +205,14 @@ struct InitMap final {
 
   /// Returns a pointer to storage.
   T *data();
+  const T *data() const;
 
 public:
   /// Initializes an element. Returns true when object if fully initialized.
   bool initialize(unsigned I);
 
   /// Checks if an element was initialized.
-  bool isInitialized(unsigned I);
+  bool isInitialized(unsigned I) const;
 
   /// Allocates a map holding N elements.
   static InitMap *allocate(unsigned N);



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


[PATCH] D141581: [clang] Make clangBasic and clangDriver depend on LLVMTargetParser.

2023-01-21 Thread Sam James via Phabricator via cfe-commits
thesamesam added a comment.

This is currently holding back further testing on our end which is concerning 
me a bit, especially as we approach the branch point. Could you revert this 
please if a fix isn't imminent? Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

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