[clang] cc8fa1e - [clang][Interp][NFC] Refactor lvalue-to-rvalue conversion code

2024-06-08 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-06-09T06:32:12+02:00
New Revision: cc8fa1e9206aa69197c891ca2f17b64340c5a6aa

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

LOG: [clang][Interp][NFC] Refactor lvalue-to-rvalue conversion code

Really perform the conversion always if the flag is set and don't make
it dependent on whether we're checking the result for initialization.

Added: 


Modified: 
clang/lib/AST/Interp/EvalEmitter.cpp
clang/lib/AST/Interp/EvaluationResult.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/EvalEmitter.cpp 
b/clang/lib/AST/Interp/EvalEmitter.cpp
index f6191d8ed6345..025b46b3d7886 100644
--- a/clang/lib/AST/Interp/EvalEmitter.cpp
+++ b/clang/lib/AST/Interp/EvalEmitter.cpp
@@ -40,7 +40,7 @@ void EvalEmitter::cleanup() { S.cleanup(); }
 EvaluationResult EvalEmitter::interpretExpr(const Expr *E,
 bool ConvertResultToRValue) {
   S.setEvalLocation(E->getExprLoc());
-  this->ConvertResultToRValue = ConvertResultToRValue;
+  this->ConvertResultToRValue = ConvertResultToRValue && !isa(E);
   this->CheckFullyInitialized = isa(E);
   EvalResult.setSource(E);
 
@@ -56,10 +56,14 @@ EvaluationResult EvalEmitter::interpretExpr(const Expr *E,
 EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD,
 bool CheckFullyInitialized) {
   this->CheckFullyInitialized = CheckFullyInitialized;
-  this->ConvertResultToRValue =
-  VD->getAnyInitializer() &&
-  (VD->getAnyInitializer()->getType()->isAnyComplexType() ||
-   VD->getAnyInitializer()->getType()->isVectorType());
+
+  if (const Expr *Init = VD->getAnyInitializer()) {
+QualType T = VD->getType();
+this->ConvertResultToRValue = !Init->isGLValue() && !T->isPointerType() &&
+  !T->isObjCObjectPointerType();
+  } else
+this->ConvertResultToRValue = false;
+
   EvalResult.setSource(VD);
 
   if (!this->visitDecl(VD) && EvalResult.empty())
@@ -138,6 +142,10 @@ template <> bool EvalEmitter::emitRet(const 
SourceInfo ) {
 return true;
 
   const Pointer  = S.Stk.pop();
+
+  if (CheckFullyInitialized && !EvalResult.checkFullyInitialized(S, Ptr))
+return false;
+
   // Implicitly convert lvalue to rvalue, if requested.
   if (ConvertResultToRValue) {
 if (std::optional V = Ptr.toRValue(Ctx)) {
@@ -146,17 +154,7 @@ template <> bool EvalEmitter::emitRet(const 
SourceInfo ) {
   return false;
 }
   } else {
-if (CheckFullyInitialized) {
-  if (!EvalResult.checkFullyInitialized(S, Ptr))
-return false;
-
-  std::optional RValueResult = Ptr.toRValue(Ctx);
-  if (!RValueResult)
-return false;
-  EvalResult.setValue(*RValueResult);
-} else {
-  EvalResult.setValue(Ptr.toAPValue());
-}
+EvalResult.setValue(Ptr.toAPValue());
   }
 
   return true;

diff  --git a/clang/lib/AST/Interp/EvaluationResult.cpp 
b/clang/lib/AST/Interp/EvaluationResult.cpp
index 29977232975fc..387e3dc88bff2 100644
--- a/clang/lib/AST/Interp/EvaluationResult.cpp
+++ b/clang/lib/AST/Interp/EvaluationResult.cpp
@@ -151,9 +151,12 @@ bool EvaluationResult::checkFullyInitialized(InterpState 
,
 
   if (const Record *R = Ptr.getRecord())
 return CheckFieldsInitialized(S, InitLoc, Ptr, R);
-  const auto *CAT =
-  cast(Ptr.getType()->getAsArrayTypeUnsafe());
-  return CheckArrayInitialized(S, InitLoc, Ptr, CAT);
+
+  if (const auto *CAT = dyn_cast_if_present(
+  Ptr.getType()->getAsArrayTypeUnsafe()))
+return CheckArrayInitialized(S, InitLoc, Ptr, CAT);
+
+  return true;
 }
 
 } // namespace interp



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


[clang-tools-extra] [clang-tidy] Ignore non-math operators in readability-math-missing-parentheses (PR #94654)

2024-06-08 Thread Bhuminjay Soni via cfe-commits

https://github.com/11happy approved this pull request.


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


[clang] [Sema][CTAD] Allow user defined conversion for copy-list-initialization (PR #94752)

2024-06-08 Thread Younan Zhang via cfe-commits


@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused-value -std=c++20 %s
+namespace std
+{
+  typedef long unsigned int size_t;
+}
+
+namespace std
+{
+  template
+class initializer_list
+{
+public:
+  typedef _E value_type;
+  typedef const _E& reference;
+  typedef const _E& const_reference;
+  typedef size_t size_type;
+  typedef const _E* iterator;
+  typedef const _E* const_iterator;
+
+private:
+  iterator _M_array;
+  size_type _M_len;
+
+
+  constexpr initializer_list(const_iterator __a, size_type __l)
+  : _M_array(__a), _M_len(__l) { }
+
+public:
+  constexpr initializer_list() noexcept
+  : _M_array(0), _M_len(0) { }
+
+
+  constexpr size_type
+  size() const noexcept { return _M_len; }
+
+
+  constexpr const_iterator
+  begin() const noexcept { return _M_array; }
+
+
+  constexpr const_iterator
+  end() const noexcept { return begin() + size(); }
+};
+
+  template
+constexpr const _Tp*
+begin(initializer_list<_Tp> __ils) noexcept
+{ return __ils.begin(); }
+
+  template
+constexpr const _Tp*
+end(initializer_list<_Tp> __ils) noexcept
+{ return __ils.end(); }
+}
+
+template
+class pair{
+private:
+T fst;
+Y snd;
+public:
+pair(T f, Y s) : fst(f), snd(s) {}
+};
+
+template
+class map {
+public:
+map(std::initializer_list>, int a = 4, int b = 5) {}
+};
+
+template
+class Contained {
+  public:
+  Contained(T, Y) {}
+};
+
+template
+class A {
+  public:
+  A(std::initializer_list >, int) {}
+};
+
+int main() {
+map mOk ={pair{5, 'a'}, {6, 'b'}, {7, 'c'}};

zyn0217 wrote:

Could you try to simplify the test case a bit? There is so much boilerplate 
that it's hard to understand the issue.

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


[clang] [Sema][CTAD] Allow user defined conversion for copy-list-initialization (PR #94752)

2024-06-08 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 commented:

Thanks for working on this. While I didn't dig into the details in 
`DeduceTemplateSpecializationFromInitializer()`, I think the test could be 
improved before proceeding. I also wish @erichkeane and @hokein could take a 
look at this because they have more expertise in CTAD. :)

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


[clang] [Sema][CTAD] Allow user defined conversion for copy-list-initialization (PR #94752)

2024-06-08 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] Fix two issues of CTAD for aggregates (PR #94889)

2024-06-08 Thread Younan Zhang via cfe-commits

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

Fixes https://github.com/llvm/llvm-project/issues/64625
Fixes https://github.com/llvm/llvm-project/issues/83368

>From 217c00f47aaa65b113d1c1cfd93a9c4e1d235c1a Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 9 Jun 2024 11:49:18 +0800
Subject: [PATCH] [Clang] Fix two issues of CTAD for aggregates

---
 clang/lib/Sema/SemaInit.cpp | 56 +++--
 clang/test/SemaTemplate/deduction-guide.cpp | 19 +++
 2 files changed, 60 insertions(+), 15 deletions(-)

diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 79bdc8e9f8783..de2ea639bbba8 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -313,6 +313,8 @@ class InitListChecker {
   InitListExpr *FullyStructuredList = nullptr;
   NoInitExpr *DummyExpr = nullptr;
   SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr;
+  SmallVectorImpl
+  *AggrDeductionCandidateParamTypesWithoutBraceElision = nullptr;
 
   NoInitExpr *getDummyInit() {
 if (!DummyExpr)
@@ -506,14 +508,19 @@ class InitListChecker {
   Sema , const InitializedEntity , InitListExpr *IL, QualType ,
   bool VerifyOnly, bool TreatUnavailableAsInvalid,
   bool InOverloadResolution = false,
-  SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr);
+  SmallVectorImpl *AggrDeductionCandidateParamTypes = nullptr,
+  SmallVectorImpl
+  *AggrDeductionCandidateParamTypesWithoutBraceElision = nullptr);
   InitListChecker(Sema , const InitializedEntity , InitListExpr *IL,
   QualType ,
-  SmallVectorImpl )
+  SmallVectorImpl ,
+  SmallVectorImpl
+  )
   : InitListChecker(S, Entity, IL, T, /*VerifyOnly=*/true,
 /*TreatUnavailableAsInvalid=*/false,
 /*InOverloadResolution=*/false,
-){};
+,
+) 
{}
 
   bool HadError() { return hadError; }
 
@@ -982,11 +989,15 @@ static bool hasAnyDesignatedInits(const InitListExpr *IL) 
{
 InitListChecker::InitListChecker(
 Sema , const InitializedEntity , InitListExpr *IL, QualType ,
 bool VerifyOnly, bool TreatUnavailableAsInvalid, bool InOverloadResolution,
-SmallVectorImpl *AggrDeductionCandidateParamTypes)
+SmallVectorImpl *AggrDeductionCandidateParamTypes,
+SmallVectorImpl
+*AggrDeductionCandidateParamTypesWithoutBraceElision)
 : SemaRef(S), VerifyOnly(VerifyOnly),
   TreatUnavailableAsInvalid(TreatUnavailableAsInvalid),
   InOverloadResolution(InOverloadResolution),
-  AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes) {
+  AggrDeductionCandidateParamTypes(AggrDeductionCandidateParamTypes),
+  AggrDeductionCandidateParamTypesWithoutBraceElision(
+  AggrDeductionCandidateParamTypesWithoutBraceElision) {
   if (!VerifyOnly || hasAnyDesignatedInits(IL)) {
 FullyStructuredList =
 createInitListExpr(T, IL->getSourceRange(), IL->getNumInits());
@@ -1448,13 +1459,17 @@ void InitListChecker::CheckSubElementType(const 
InitializedEntity ,
   //   brace elision is not considered for any aggregate element that has a
   //   dependent non-array type or an array type with a value-dependent
   //   bound
-  assert(AggrDeductionCandidateParamTypes);
-  if (!isa_and_nonnull(
+  assert(AggrDeductionCandidateParamTypes &&
+ AggrDeductionCandidateParamTypesWithoutBraceElision);
+  if (!isa_and_present(
   SemaRef.Context.getAsArrayType(ElemType))) {
 ++Index;
 AggrDeductionCandidateParamTypes->push_back(ElemType);
 return;
   }
+  // For array types with known bounds, we still want the brace version 
even
+  // though the braces can be elided.
+  AggrDeductionCandidateParamTypesWithoutBraceElision->push_back(ElemType);
 } else {
   InitializationSequence Seq(SemaRef, TmpEntity, Kind, expr,
  /*TopLevelOfInitList*/ true);
@@ -10918,22 +10933,24 @@ QualType 
Sema::DeduceTemplateSpecializationFromInitializer(
   if (!(RD->getDefinition() && RD->isAggregate()))
 return;
   QualType Ty = Context.getRecordType(RD);
-  SmallVector ElementTypes;
-
-  InitListChecker CheckInitList(*this, Entity, ListInit, Ty, ElementTypes);
-  if (!CheckInitList.HadError()) {
+  auto BuildAggregateDeductionGuide = [&](MutableArrayRef
+  ElementTypes,
+  bool BracedVersion = false) {
+if (ElementTypes.empty())
+  return;
 // C++ [over.match.class.deduct]p1.8:
 //   if e_i is of array type and x_i is a braced-init-list, T_i is an
 //   rvalue reference to the declared type of e_i and
 // C++ 

[clang-tools-extra] [llvm] [mlir] Use StringRef::starts_with (NFC) (PR #94886)

2024-06-08 Thread via cfe-commits

llvmbot wrote:



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

@llvm/pr-subscribers-mlir

Author: Kazu Hirata (kazutakahirata)


Changes



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


3 Files Affected:

- (modified) bolt/lib/Profile/BoltAddressTranslation.cpp (+1-1) 
- (modified) clang-tools-extra/clang-query/QueryParser.cpp (+2-4) 
- (modified) mlir/lib/Query/QueryParser.cpp (+2-4) 


``diff
diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp 
b/bolt/lib/Profile/BoltAddressTranslation.cpp
index cdfca2b9871ac..519f282a2351c 100644
--- a/bolt/lib/Profile/BoltAddressTranslation.cpp
+++ b/bolt/lib/Profile/BoltAddressTranslation.cpp
@@ -304,7 +304,7 @@ std::error_code BoltAddressTranslation::parse(raw_ostream 
, StringRef Buf) {
 
   StringRef Name = Buf.slice(Offset, Offset + NameSz);
   Offset = alignTo(Offset + NameSz, 4);
-  if (Name.substr(0, 4) != "BOLT")
+  if (!Name.starts_with("BOLT"))
 return make_error_code(llvm::errc::io_error);
 
   Error Err(Error::success());
diff --git a/clang-tools-extra/clang-query/QueryParser.cpp 
b/clang-tools-extra/clang-query/QueryParser.cpp
index 1d0b7d9bc6fc8..97cb264a611af 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -144,13 +144,11 @@ QueryRef QueryParser::endQuery(QueryRef Q) {
   StringRef Extra = Line;
   StringRef ExtraTrimmed = Extra.ltrim(" \t\v\f\r");
 
-  if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') ||
-  (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' &&
-   ExtraTrimmed[1] == '\n'))
+  if (ExtraTrimmed.starts_with('\n') || ExtraTrimmed.starts_with("\r\n"))
 Q->RemainingContent = Extra;
   else {
 StringRef TrailingWord = lexWord();
-if (!TrailingWord.empty() && TrailingWord.front() == '#') {
+if (TrailingWord.starts_with('#')) {
   Line = Line.drop_until([](char c) { return c == '\n'; });
   Line = Line.drop_while([](char c) { return c == '\n'; });
   return endQuery(Q);
diff --git a/mlir/lib/Query/QueryParser.cpp b/mlir/lib/Query/QueryParser.cpp
index 595055a42965f..8a034634c5b89 100644
--- a/mlir/lib/Query/QueryParser.cpp
+++ b/mlir/lib/Query/QueryParser.cpp
@@ -91,13 +91,11 @@ QueryRef QueryParser::endQuery(QueryRef queryRef) {
   llvm::StringRef extra = line;
   llvm::StringRef extraTrimmed = extra.ltrim(" \t\v\f\r");
 
-  if ((!extraTrimmed.empty() && extraTrimmed[0] == '\n') ||
-  (extraTrimmed.size() >= 2 && extraTrimmed[0] == '\r' &&
-   extraTrimmed[1] == '\n'))
+  if (extraTrimmed.starts_with('\n') || extraTrimmed.starts_with("\r\n"))
 queryRef->remainingContent = extra;
   else {
 llvm::StringRef trailingWord = lexWord();
-if (!trailingWord.empty() && trailingWord.front() == '#') {
+if (trailingWord.starts_with('#')) {
   line = line.drop_until([](char c) { return c == '\n'; });
   line = line.drop_while([](char c) { return c == '\n'; });
   return endQuery(queryRef);

``




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


[clang-tools-extra] [llvm] [mlir] Use StringRef::starts_with (NFC) (PR #94886)

2024-06-08 Thread Kazu Hirata via cfe-commits

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

None

>From b33680b77672ac4881032113e2302c02c1dd62b5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Mon, 20 May 2024 19:02:40 -0700
Subject: [PATCH] Use StringRef::starts_with (NFC)

---
 bolt/lib/Profile/BoltAddressTranslation.cpp   | 2 +-
 clang-tools-extra/clang-query/QueryParser.cpp | 6 ++
 mlir/lib/Query/QueryParser.cpp| 6 ++
 3 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp 
b/bolt/lib/Profile/BoltAddressTranslation.cpp
index cdfca2b9871ac..519f282a2351c 100644
--- a/bolt/lib/Profile/BoltAddressTranslation.cpp
+++ b/bolt/lib/Profile/BoltAddressTranslation.cpp
@@ -304,7 +304,7 @@ std::error_code BoltAddressTranslation::parse(raw_ostream 
, StringRef Buf) {
 
   StringRef Name = Buf.slice(Offset, Offset + NameSz);
   Offset = alignTo(Offset + NameSz, 4);
-  if (Name.substr(0, 4) != "BOLT")
+  if (!Name.starts_with("BOLT"))
 return make_error_code(llvm::errc::io_error);
 
   Error Err(Error::success());
diff --git a/clang-tools-extra/clang-query/QueryParser.cpp 
b/clang-tools-extra/clang-query/QueryParser.cpp
index 1d0b7d9bc6fc8..97cb264a611af 100644
--- a/clang-tools-extra/clang-query/QueryParser.cpp
+++ b/clang-tools-extra/clang-query/QueryParser.cpp
@@ -144,13 +144,11 @@ QueryRef QueryParser::endQuery(QueryRef Q) {
   StringRef Extra = Line;
   StringRef ExtraTrimmed = Extra.ltrim(" \t\v\f\r");
 
-  if ((!ExtraTrimmed.empty() && ExtraTrimmed[0] == '\n') ||
-  (ExtraTrimmed.size() >= 2 && ExtraTrimmed[0] == '\r' &&
-   ExtraTrimmed[1] == '\n'))
+  if (ExtraTrimmed.starts_with('\n') || ExtraTrimmed.starts_with("\r\n"))
 Q->RemainingContent = Extra;
   else {
 StringRef TrailingWord = lexWord();
-if (!TrailingWord.empty() && TrailingWord.front() == '#') {
+if (TrailingWord.starts_with('#')) {
   Line = Line.drop_until([](char c) { return c == '\n'; });
   Line = Line.drop_while([](char c) { return c == '\n'; });
   return endQuery(Q);
diff --git a/mlir/lib/Query/QueryParser.cpp b/mlir/lib/Query/QueryParser.cpp
index 595055a42965f..8a034634c5b89 100644
--- a/mlir/lib/Query/QueryParser.cpp
+++ b/mlir/lib/Query/QueryParser.cpp
@@ -91,13 +91,11 @@ QueryRef QueryParser::endQuery(QueryRef queryRef) {
   llvm::StringRef extra = line;
   llvm::StringRef extraTrimmed = extra.ltrim(" \t\v\f\r");
 
-  if ((!extraTrimmed.empty() && extraTrimmed[0] == '\n') ||
-  (extraTrimmed.size() >= 2 && extraTrimmed[0] == '\r' &&
-   extraTrimmed[1] == '\n'))
+  if (extraTrimmed.starts_with('\n') || extraTrimmed.starts_with("\r\n"))
 queryRef->remainingContent = extra;
   else {
 llvm::StringRef trailingWord = lexWord();
-if (!trailingWord.empty() && trailingWord.front() == '#') {
+if (trailingWord.starts_with('#')) {
   line = line.drop_until([](char c) { return c == '\n'; });
   line = line.drop_while([](char c) { return c == '\n'; });
   return endQuery(queryRef);

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


[clang] [ObjC][CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-08 Thread via cfe-commits

https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/94885

>From dc4f05c243d08bcfb5ad0d7a0c402d499a8b9f28 Mon Sep 17 00:00:00 2001
From: Rose 
Date: Sat, 8 Jun 2024 22:30:53 -0400
Subject: [PATCH] [ObjC][CodeGen] Assume a for-in loop is in bounds and cannot
 overflow

When accessing data in the buffer, we know we won't overrun the buffer, so we 
know it is inbounds. In addition, we know that the addition to increase the 
index is also NUW because the buffer's end has to be unsigned-greater-than 0, 
which becomes untrue if the bounds ever has an unsigned wrap.
---
 clang/lib/CodeGen/CGObjC.cpp | 4 ++--
 clang/test/CodeGenObjC/arc-foreach.m | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 281b2d9795f6c..80a64d8e4cdd9 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -1952,7 +1952,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 Builder.CreateLoad(StateItemsPtr, "stateitems");
 
   // Fetch the value at the current index from the buffer.
-  llvm::Value *CurrentItemPtr = Builder.CreateGEP(
+  llvm::Value *CurrentItemPtr = Builder.CreateInBoundsGEP(
   ObjCIdType, EnumStateItems, index, "currentitem.ptr");
   llvm::Value *CurrentItem =
 Builder.CreateAlignedLoad(ObjCIdType, CurrentItemPtr, getPointerAlign());
@@ -2028,7 +2028,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 
   // First we check in the local buffer.
   llvm::Value *indexPlusOne =
-  Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
+  Builder.CreateNUWAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
 
   // If we haven't overrun the buffer yet, we can continue.
   // Set the branch weights based on the simplifying assumption that this is
diff --git a/clang/test/CodeGenObjC/arc-foreach.m 
b/clang/test/CodeGenObjC/arc-foreach.m
index 71edc5161303c..9f7b60aef7a1b 100644
--- a/clang/test/CodeGenObjC/arc-foreach.m
+++ b/clang/test/CodeGenObjC/arc-foreach.m
@@ -53,7 +53,7 @@ void test0(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: store ptr [[T3]], ptr [[X]]
 
@@ -100,7 +100,7 @@ void test1(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: call ptr @llvm.objc.initWeak(ptr [[X]], ptr [[T3]])
 

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


[clang] [ObjC][CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-08 Thread via cfe-commits

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


[clang] [CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: AtariDreams (AtariDreams)


Changes

When accessing data in the buffer, we know we won't overrun the buffer, so we 
know it is inbounds. In addition, we know that the addition to increase the 
index is also NUW because the buffer's end has to be unsigned-greater-than 0, 
which becomes untrue if the bounds ever has an unsigned wrap.

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGObjC.cpp (+2-2) 
- (modified) clang/test/CodeGenObjC/arc-foreach.m (+2-2) 


``diff
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 281b2d9795f6c..80a64d8e4cdd9 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -1952,7 +1952,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 Builder.CreateLoad(StateItemsPtr, "stateitems");
 
   // Fetch the value at the current index from the buffer.
-  llvm::Value *CurrentItemPtr = Builder.CreateGEP(
+  llvm::Value *CurrentItemPtr = Builder.CreateInBoundsGEP(
   ObjCIdType, EnumStateItems, index, "currentitem.ptr");
   llvm::Value *CurrentItem =
 Builder.CreateAlignedLoad(ObjCIdType, CurrentItemPtr, getPointerAlign());
@@ -2028,7 +2028,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 
   // First we check in the local buffer.
   llvm::Value *indexPlusOne =
-  Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
+  Builder.CreateNUWAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
 
   // If we haven't overrun the buffer yet, we can continue.
   // Set the branch weights based on the simplifying assumption that this is
diff --git a/clang/test/CodeGenObjC/arc-foreach.m 
b/clang/test/CodeGenObjC/arc-foreach.m
index 71edc5161303c..9f7b60aef7a1b 100644
--- a/clang/test/CodeGenObjC/arc-foreach.m
+++ b/clang/test/CodeGenObjC/arc-foreach.m
@@ -53,7 +53,7 @@ void test0(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: store ptr [[T3]], ptr [[X]]
 
@@ -100,7 +100,7 @@ void test1(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: call ptr @llvm.objc.initWeak(ptr [[X]], ptr [[T3]])
 

``




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


[clang] [CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: AtariDreams (AtariDreams)


Changes

When accessing data in the buffer, we know we won't overrun the buffer, so we 
know it is inbounds. In addition, we know that the addition to increase the 
index is also NUW because the buffer's end has to be unsigned-greater-than 0, 
which becomes untrue if the bounds ever has an unsigned wrap.

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGObjC.cpp (+2-2) 
- (modified) clang/test/CodeGenObjC/arc-foreach.m (+2-2) 


``diff
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 281b2d9795f6c..80a64d8e4cdd9 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -1952,7 +1952,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 Builder.CreateLoad(StateItemsPtr, "stateitems");
 
   // Fetch the value at the current index from the buffer.
-  llvm::Value *CurrentItemPtr = Builder.CreateGEP(
+  llvm::Value *CurrentItemPtr = Builder.CreateInBoundsGEP(
   ObjCIdType, EnumStateItems, index, "currentitem.ptr");
   llvm::Value *CurrentItem =
 Builder.CreateAlignedLoad(ObjCIdType, CurrentItemPtr, getPointerAlign());
@@ -2028,7 +2028,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 
   // First we check in the local buffer.
   llvm::Value *indexPlusOne =
-  Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
+  Builder.CreateNUWAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
 
   // If we haven't overrun the buffer yet, we can continue.
   // Set the branch weights based on the simplifying assumption that this is
diff --git a/clang/test/CodeGenObjC/arc-foreach.m 
b/clang/test/CodeGenObjC/arc-foreach.m
index 71edc5161303c..9f7b60aef7a1b 100644
--- a/clang/test/CodeGenObjC/arc-foreach.m
+++ b/clang/test/CodeGenObjC/arc-foreach.m
@@ -53,7 +53,7 @@ void test0(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: store ptr [[T3]], ptr [[X]]
 
@@ -100,7 +100,7 @@ void test1(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: call ptr @llvm.objc.initWeak(ptr [[X]], ptr [[T3]])
 

``




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


[clang] [CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-08 Thread via cfe-commits

https://github.com/AtariDreams created 
https://github.com/llvm/llvm-project/pull/94885

When accessing data in the buffer, we know we won't overrun the buffer, so we 
know it is inbounds. In addition, we know that the addition to increase the 
index is also NUW because the buffer's end has to be unsigned-greater-than 0, 
which becomes untrue if the bounds ever has an unsigned wrap.

>From e50a348e54b90212f7061458010cfa181816f363 Mon Sep 17 00:00:00 2001
From: Rose 
Date: Sat, 8 Jun 2024 22:30:53 -0400
Subject: [PATCH] [CodeGen] Assume a for-in loop is in bounds and cannot
 overflow

When accessing data in the buffer, we know we won't overrun the buffer, so we 
know it is inbounds. In addition, we know that the addition to increase the 
index is also NUW because the buffer's end has to be unsigned-greater-than 0, 
which becomes untrue if the bounds ever has an unsigned wrap.
---
 clang/lib/CodeGen/CGObjC.cpp | 4 ++--
 clang/test/CodeGenObjC/arc-foreach.m | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 281b2d9795f6c..80a64d8e4cdd9 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -1952,7 +1952,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 Builder.CreateLoad(StateItemsPtr, "stateitems");
 
   // Fetch the value at the current index from the buffer.
-  llvm::Value *CurrentItemPtr = Builder.CreateGEP(
+  llvm::Value *CurrentItemPtr = Builder.CreateInBoundsGEP(
   ObjCIdType, EnumStateItems, index, "currentitem.ptr");
   llvm::Value *CurrentItem =
 Builder.CreateAlignedLoad(ObjCIdType, CurrentItemPtr, getPointerAlign());
@@ -2028,7 +2028,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 
   // First we check in the local buffer.
   llvm::Value *indexPlusOne =
-  Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
+  Builder.CreateNUWAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
 
   // If we haven't overrun the buffer yet, we can continue.
   // Set the branch weights based on the simplifying assumption that this is
diff --git a/clang/test/CodeGenObjC/arc-foreach.m 
b/clang/test/CodeGenObjC/arc-foreach.m
index 71edc5161303c..9f7b60aef7a1b 100644
--- a/clang/test/CodeGenObjC/arc-foreach.m
+++ b/clang/test/CodeGenObjC/arc-foreach.m
@@ -53,7 +53,7 @@ void test0(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: store ptr [[T3]], ptr [[X]]
 
@@ -100,7 +100,7 @@ void test1(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: call ptr @llvm.objc.initWeak(ptr [[X]], ptr [[T3]])
 

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


[clang] [CodeGen] Assume a for-in loop is in bounds and cannot overflow (PR #94885)

2024-06-08 Thread via cfe-commits

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


[clang] Assume a for-in loop is in bounds and cannot overflow (PR #94883)

2024-06-08 Thread via cfe-commits

https://github.com/AtariDreams updated 
https://github.com/llvm/llvm-project/pull/94883

>From e50a348e54b90212f7061458010cfa181816f363 Mon Sep 17 00:00:00 2001
From: Rose 
Date: Sat, 8 Jun 2024 22:30:53 -0400
Subject: [PATCH] [CodeGen] Assume a for-in loop is in bounds and cannot
 overflow

When accessing data in the buffer, we know we won't overrun the buffer, so we 
know it is inbounds. In addition, we know that the addition to increase the 
index is also NUW because the buffer's end has to be unsigned-greater-than 0, 
which becomes untrue if the bounds ever has an unsigned wrap.
---
 clang/lib/CodeGen/CGObjC.cpp | 4 ++--
 clang/test/CodeGenObjC/arc-foreach.m | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 281b2d9795f6c..80a64d8e4cdd9 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -1952,7 +1952,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 Builder.CreateLoad(StateItemsPtr, "stateitems");
 
   // Fetch the value at the current index from the buffer.
-  llvm::Value *CurrentItemPtr = Builder.CreateGEP(
+  llvm::Value *CurrentItemPtr = Builder.CreateInBoundsGEP(
   ObjCIdType, EnumStateItems, index, "currentitem.ptr");
   llvm::Value *CurrentItem =
 Builder.CreateAlignedLoad(ObjCIdType, CurrentItemPtr, getPointerAlign());
@@ -2028,7 +2028,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 
   // First we check in the local buffer.
   llvm::Value *indexPlusOne =
-  Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
+  Builder.CreateNUWAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
 
   // If we haven't overrun the buffer yet, we can continue.
   // Set the branch weights based on the simplifying assumption that this is
diff --git a/clang/test/CodeGenObjC/arc-foreach.m 
b/clang/test/CodeGenObjC/arc-foreach.m
index 71edc5161303c..9f7b60aef7a1b 100644
--- a/clang/test/CodeGenObjC/arc-foreach.m
+++ b/clang/test/CodeGenObjC/arc-foreach.m
@@ -53,7 +53,7 @@ void test0(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: store ptr [[T3]], ptr [[X]]
 
@@ -100,7 +100,7 @@ void test1(NSArray *array) {
 
 // CHECK-LP64:  [[T0:%.*]] = getelementptr inbounds [[STATE_T]], ptr 
[[STATE]], i32 0, i32 1
 // CHECK-LP64-NEXT: [[T1:%.*]] = load ptr, ptr [[T0]]
-// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr ptr, ptr [[T1]], i64
+// CHECK-LP64-NEXT: [[T2:%.*]] = getelementptr inbounds ptr, ptr [[T1]], i64
 // CHECK-LP64-NEXT: [[T3:%.*]] = load ptr, ptr [[T2]]
 // CHECK-LP64-NEXT: call ptr @llvm.objc.initWeak(ptr [[X]], ptr [[T3]])
 

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


[clang] Assume a for-in loop is in bounds and cannot overflow (PR #94883)

2024-06-08 Thread via cfe-commits

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


[clang] Assume a for-in loop is in bounds and cannot overflow (PR #94883)

2024-06-08 Thread via cfe-commits

https://github.com/AtariDreams created 
https://github.com/llvm/llvm-project/pull/94883

None

>From 9db997477f3a5649092b9bf385a6a1d963b4971b Mon Sep 17 00:00:00 2001
From: Rose 
Date: Sat, 8 Jun 2024 22:30:53 -0400
Subject: [PATCH] Assume a for-in loop is in bounds and cannot overflow

---
 clang/lib/CodeGen/CGObjC.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 281b2d9795f6c..80a64d8e4cdd9 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -1952,7 +1952,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 Builder.CreateLoad(StateItemsPtr, "stateitems");
 
   // Fetch the value at the current index from the buffer.
-  llvm::Value *CurrentItemPtr = Builder.CreateGEP(
+  llvm::Value *CurrentItemPtr = Builder.CreateInBoundsGEP(
   ObjCIdType, EnumStateItems, index, "currentitem.ptr");
   llvm::Value *CurrentItem =
 Builder.CreateAlignedLoad(ObjCIdType, CurrentItemPtr, getPointerAlign());
@@ -2028,7 +2028,7 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const 
ObjCForCollectionStmt ){
 
   // First we check in the local buffer.
   llvm::Value *indexPlusOne =
-  Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
+  Builder.CreateNUWAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
 
   // If we haven't overrun the buffer yet, we can continue.
   // Set the branch weights based on the simplifying assumption that this is

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


[clang] [hexagon] Add {con, de}structive interference size defn (PR #94877)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Brian Cain (androm3da)


Changes

This support was originally added in 72c373bfdc98 ([C++17] Support 
__GCC_[CON|DE]STRUCTIVE_SIZE (#89446), 2024-04-26).  We're overriding 
the values for Hexagon here.

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


1 Files Affected:

- (modified) clang/lib/Basic/Targets/Hexagon.h (+4) 


``diff
diff --git a/clang/lib/Basic/Targets/Hexagon.h 
b/clang/lib/Basic/Targets/Hexagon.h
index cdb47dbae7999..f5e7a8878f01b 100644
--- a/clang/lib/Basic/Targets/Hexagon.h
+++ b/clang/lib/Basic/Targets/Hexagon.h
@@ -139,6 +139,10 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public 
TargetInfo {
   }
 
   bool hasBitIntType() const override { return true; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(32, 32);
+  }
 };
 } // namespace targets
 } // namespace clang

``




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


[clang] [hexagon] Add {con, de}structive interference size defn (PR #94877)

2024-06-08 Thread Brian Cain via cfe-commits

https://github.com/androm3da created 
https://github.com/llvm/llvm-project/pull/94877

This support was originally added in 72c373bfdc98 ([C++17] Support 
__GCC_[CON|DE]STRUCTIVE_SIZE (#89446), 2024-04-26).  We're overriding the 
values for Hexagon here.

>From 2641525accd144331dcd1efee03a62835e1e0d65 Mon Sep 17 00:00:00 2001
From: Brian Cain 
Date: Sat, 8 Jun 2024 16:25:11 -0700
Subject: [PATCH] [hexagon] Add {con,de}structive interference size defn

This support was originally added in 72c373bfdc98 ([C++17] Support
__GCC_[CON|DE]STRUCTIVE_SIZE (#89446), 2024-04-26).  We're overriding
the values for Hexagon here.

Signed-off-by: Brian Cain 
---
 clang/lib/Basic/Targets/Hexagon.h | 4 
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/Basic/Targets/Hexagon.h 
b/clang/lib/Basic/Targets/Hexagon.h
index cdb47dbae7999..f5e7a8878f01b 100644
--- a/clang/lib/Basic/Targets/Hexagon.h
+++ b/clang/lib/Basic/Targets/Hexagon.h
@@ -139,6 +139,10 @@ class LLVM_LIBRARY_VISIBILITY HexagonTargetInfo : public 
TargetInfo {
   }
 
   bool hasBitIntType() const override { return true; }
+
+  std::pair hardwareInterferenceSizes() const override {
+return std::make_pair(32, 32);
+  }
 };
 } // namespace targets
 } // namespace clang

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-06-08 Thread Kohei Asano via cfe-commits

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


[clang] [libcxxabi] [llvm] Add support for WASI builds (PR #91051)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Luca Versari (veluca93)


Changes

This PR modifies the LLVM source code to compile (and run) in a WASI 
environment.

The question of whether having WASI support in LLVM is one that doesn't have a 
clear answer for me (although of course I can see some use cases), but since 
the patch ended up being small enough I figured I'd create a PR and see what 
the LLVM community would make of it :-)

The code compiles  runs successfully when compiled with an unmodified 
wasi-libc (I only tested running clang++ and wasm-ld).

Caveats:
- a bunch of things are not supported. Most importantly, executing binaries is 
not supported, but also memory mapping, signals, dynamic linking, set/longjump, 
and JIT.
- There are no tests. I also would not know how to go about adding tests.
- Some projects are disabled on WASI.

---

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


19 Files Affected:

- (modified) clang/CMakeLists.txt (+1-1) 
- (modified) clang/lib/Driver/Driver.cpp (+1-1) 
- (modified) libcxxabi/src/CMakeLists.txt (+2-2) 
- (modified) llvm/cmake/modules/HandleLLVMOptions.cmake (+4) 
- (modified) llvm/include/llvm/ADT/bit.h (+2-2) 
- (modified) llvm/include/llvm/Support/Memory.h (+2) 
- (modified) llvm/lib/CMakeLists.txt (+2) 
- (modified) llvm/lib/Support/CrashRecoveryContext.cpp (+30-18) 
- (modified) llvm/lib/Support/LockFileManager.cpp (+11-8) 
- (modified) llvm/lib/Support/Unix/Memory.inc (+20) 
- (modified) llvm/lib/Support/Unix/Path.inc (+41-3) 
- (modified) llvm/lib/Support/Unix/Process.inc (+14-1) 
- (modified) llvm/lib/Support/Unix/Program.inc (+16-1) 
- (modified) llvm/lib/Support/Unix/Signals.inc (+14) 
- (modified) llvm/lib/Support/Unix/Unix.h (+9-6) 
- (modified) llvm/lib/Support/Unix/Watchdog.inc (+2-2) 
- (modified) llvm/lib/Support/raw_socket_stream.cpp (+22-2) 
- (modified) llvm/lib/Transforms/CMakeLists.txt (+2) 
- (modified) llvm/tools/CMakeLists.txt (+4) 


``diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 2ac0bccb42f50..e1da8297ddd5f 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -426,7 +426,7 @@ CMAKE_DEPENDENT_OPTION(CLANG_PLUGIN_SUPPORT
 # If libstdc++ is statically linked, clang-repl needs to statically link 
libstdc++
 # itself, which is not possible in many platforms because of current 
limitations in
 # JIT stack. (more platforms need to be supported by JITLink)
-if(NOT LLVM_STATIC_LINK_CXX_STDLIB)
+if(NOT LLVM_STATIC_LINK_CXX_STDLIB AND NOT WASI)
   set(HAVE_CLANG_REPL_SUPPORT ON)
 endif()
 
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..4f117a1d3a5ca 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1577,7 +1577,7 @@ bool Driver::getCrashDiagnosticFile(StringRef 
ReproCrashFilename,
 CrashDiagDir = "/";
   path::append(CrashDiagDir, "Library/Logs/DiagnosticReports");
   int PID =
-#if LLVM_ON_UNIX
+#if LLVM_ON_UNIX && !defined(__wasi__)
   getpid();
 #else
   0;
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index c54ced4dc3ea8..f96d23b3c0315 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -36,8 +36,8 @@ else()
   )
 endif()
 
-if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA) AND NOT (APPLE OR CYGWIN)
-AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
+if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA OR WASI) AND NOT
+  (APPLE OR CYGWIN) AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
   list(APPEND LIBCXXABI_SOURCES
 cxa_thread_atexit.cpp
   )
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c5..11cc1af78b9ba 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -217,6 +217,10 @@ elseif(FUCHSIA OR UNIX)
   else()
 set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
   endif()
+elseif(WASI)
+  set(LLVM_ON_WIN32 0)
+  set(LLVM_ON_UNIX 1)
+  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Generic")
   set(LLVM_ON_WIN32 0)
   set(LLVM_ON_UNIX 0)
diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index c42b5e686bdc9..8dcf6a8bfbb0a 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -24,12 +24,12 @@
 #endif
 
 #if defined(_MSC_VER) && !defined(_DEBUG)
-#include   // for _byteswap_{ushort,ulong,uint64}
+#include  // for _byteswap_{ushort,ulong,uint64}
 #endif
 
 #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||
\
 defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) ||  
\
-defined(__OpenBSD__) || defined(__DragonFly__)
+defined(__OpenBSD__) || defined(__DragonFly__) || defined(__wasi__)
 #include 
 #elif defined(_AIX)
 #include 
diff --git a/llvm/include/llvm/Support/Memory.h 
b/llvm/include/llvm/Support/Memory.h
index 

[clang] [libcxxabi] [llvm] Add support for WASI builds (PR #91051)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-llvm-adt

Author: Luca Versari (veluca93)


Changes

This PR modifies the LLVM source code to compile (and run) in a WASI 
environment.

The question of whether having WASI support in LLVM is one that doesn't have a 
clear answer for me (although of course I can see some use cases), but since 
the patch ended up being small enough I figured I'd create a PR and see what 
the LLVM community would make of it :-)

The code compiles  runs successfully when compiled with an unmodified 
wasi-libc (I only tested running clang++ and wasm-ld).

Caveats:
- a bunch of things are not supported. Most importantly, executing binaries is 
not supported, but also memory mapping, signals, dynamic linking, set/longjump, 
and JIT.
- There are no tests. I also would not know how to go about adding tests.
- Some projects are disabled on WASI.

---

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


19 Files Affected:

- (modified) clang/CMakeLists.txt (+1-1) 
- (modified) clang/lib/Driver/Driver.cpp (+1-1) 
- (modified) libcxxabi/src/CMakeLists.txt (+2-2) 
- (modified) llvm/cmake/modules/HandleLLVMOptions.cmake (+4) 
- (modified) llvm/include/llvm/ADT/bit.h (+2-2) 
- (modified) llvm/include/llvm/Support/Memory.h (+2) 
- (modified) llvm/lib/CMakeLists.txt (+2) 
- (modified) llvm/lib/Support/CrashRecoveryContext.cpp (+30-18) 
- (modified) llvm/lib/Support/LockFileManager.cpp (+11-8) 
- (modified) llvm/lib/Support/Unix/Memory.inc (+20) 
- (modified) llvm/lib/Support/Unix/Path.inc (+41-3) 
- (modified) llvm/lib/Support/Unix/Process.inc (+14-1) 
- (modified) llvm/lib/Support/Unix/Program.inc (+16-1) 
- (modified) llvm/lib/Support/Unix/Signals.inc (+14) 
- (modified) llvm/lib/Support/Unix/Unix.h (+9-6) 
- (modified) llvm/lib/Support/Unix/Watchdog.inc (+2-2) 
- (modified) llvm/lib/Support/raw_socket_stream.cpp (+22-2) 
- (modified) llvm/lib/Transforms/CMakeLists.txt (+2) 
- (modified) llvm/tools/CMakeLists.txt (+4) 


``diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 2ac0bccb42f50..e1da8297ddd5f 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -426,7 +426,7 @@ CMAKE_DEPENDENT_OPTION(CLANG_PLUGIN_SUPPORT
 # If libstdc++ is statically linked, clang-repl needs to statically link 
libstdc++
 # itself, which is not possible in many platforms because of current 
limitations in
 # JIT stack. (more platforms need to be supported by JITLink)
-if(NOT LLVM_STATIC_LINK_CXX_STDLIB)
+if(NOT LLVM_STATIC_LINK_CXX_STDLIB AND NOT WASI)
   set(HAVE_CLANG_REPL_SUPPORT ON)
 endif()
 
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..4f117a1d3a5ca 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1577,7 +1577,7 @@ bool Driver::getCrashDiagnosticFile(StringRef 
ReproCrashFilename,
 CrashDiagDir = "/";
   path::append(CrashDiagDir, "Library/Logs/DiagnosticReports");
   int PID =
-#if LLVM_ON_UNIX
+#if LLVM_ON_UNIX && !defined(__wasi__)
   getpid();
 #else
   0;
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index c54ced4dc3ea8..f96d23b3c0315 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -36,8 +36,8 @@ else()
   )
 endif()
 
-if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA) AND NOT (APPLE OR CYGWIN)
-AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
+if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA OR WASI) AND NOT
+  (APPLE OR CYGWIN) AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
   list(APPEND LIBCXXABI_SOURCES
 cxa_thread_atexit.cpp
   )
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c5..11cc1af78b9ba 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -217,6 +217,10 @@ elseif(FUCHSIA OR UNIX)
   else()
 set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
   endif()
+elseif(WASI)
+  set(LLVM_ON_WIN32 0)
+  set(LLVM_ON_UNIX 1)
+  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Generic")
   set(LLVM_ON_WIN32 0)
   set(LLVM_ON_UNIX 0)
diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index c42b5e686bdc9..8dcf6a8bfbb0a 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -24,12 +24,12 @@
 #endif
 
 #if defined(_MSC_VER) && !defined(_DEBUG)
-#include   // for _byteswap_{ushort,ulong,uint64}
+#include  // for _byteswap_{ushort,ulong,uint64}
 #endif
 
 #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||
\
 defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) ||  
\
-defined(__OpenBSD__) || defined(__DragonFly__)
+defined(__OpenBSD__) || defined(__DragonFly__) || defined(__wasi__)
 #include 
 #elif defined(_AIX)
 #include 
diff --git a/llvm/include/llvm/Support/Memory.h 
b/llvm/include/llvm/Support/Memory.h
index 

[clang] [libcxxabi] [llvm] Add support for WASI builds (PR #91051)

2024-06-08 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-support

@llvm/pr-subscribers-clang

Author: Luca Versari (veluca93)


Changes

This PR modifies the LLVM source code to compile (and run) in a WASI 
environment.

The question of whether having WASI support in LLVM is one that doesn't have a 
clear answer for me (although of course I can see some use cases), but since 
the patch ended up being small enough I figured I'd create a PR and see what 
the LLVM community would make of it :-)

The code compiles  runs successfully when compiled with an unmodified 
wasi-libc (I only tested running clang++ and wasm-ld).

Caveats:
- a bunch of things are not supported. Most importantly, executing binaries is 
not supported, but also memory mapping, signals, dynamic linking, set/longjump, 
and JIT.
- There are no tests. I also would not know how to go about adding tests.
- Some projects are disabled on WASI.

---

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


19 Files Affected:

- (modified) clang/CMakeLists.txt (+1-1) 
- (modified) clang/lib/Driver/Driver.cpp (+1-1) 
- (modified) libcxxabi/src/CMakeLists.txt (+2-2) 
- (modified) llvm/cmake/modules/HandleLLVMOptions.cmake (+4) 
- (modified) llvm/include/llvm/ADT/bit.h (+2-2) 
- (modified) llvm/include/llvm/Support/Memory.h (+2) 
- (modified) llvm/lib/CMakeLists.txt (+2) 
- (modified) llvm/lib/Support/CrashRecoveryContext.cpp (+30-18) 
- (modified) llvm/lib/Support/LockFileManager.cpp (+11-8) 
- (modified) llvm/lib/Support/Unix/Memory.inc (+20) 
- (modified) llvm/lib/Support/Unix/Path.inc (+41-3) 
- (modified) llvm/lib/Support/Unix/Process.inc (+14-1) 
- (modified) llvm/lib/Support/Unix/Program.inc (+16-1) 
- (modified) llvm/lib/Support/Unix/Signals.inc (+14) 
- (modified) llvm/lib/Support/Unix/Unix.h (+9-6) 
- (modified) llvm/lib/Support/Unix/Watchdog.inc (+2-2) 
- (modified) llvm/lib/Support/raw_socket_stream.cpp (+22-2) 
- (modified) llvm/lib/Transforms/CMakeLists.txt (+2) 
- (modified) llvm/tools/CMakeLists.txt (+4) 


``diff
diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 2ac0bccb42f50..e1da8297ddd5f 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -426,7 +426,7 @@ CMAKE_DEPENDENT_OPTION(CLANG_PLUGIN_SUPPORT
 # If libstdc++ is statically linked, clang-repl needs to statically link 
libstdc++
 # itself, which is not possible in many platforms because of current 
limitations in
 # JIT stack. (more platforms need to be supported by JITLink)
-if(NOT LLVM_STATIC_LINK_CXX_STDLIB)
+if(NOT LLVM_STATIC_LINK_CXX_STDLIB AND NOT WASI)
   set(HAVE_CLANG_REPL_SUPPORT ON)
 endif()
 
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..4f117a1d3a5ca 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1577,7 +1577,7 @@ bool Driver::getCrashDiagnosticFile(StringRef 
ReproCrashFilename,
 CrashDiagDir = "/";
   path::append(CrashDiagDir, "Library/Logs/DiagnosticReports");
   int PID =
-#if LLVM_ON_UNIX
+#if LLVM_ON_UNIX && !defined(__wasi__)
   getpid();
 #else
   0;
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index c54ced4dc3ea8..f96d23b3c0315 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -36,8 +36,8 @@ else()
   )
 endif()
 
-if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA) AND NOT (APPLE OR CYGWIN)
-AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
+if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA OR WASI) AND NOT
+  (APPLE OR CYGWIN) AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
   list(APPEND LIBCXXABI_SOURCES
 cxa_thread_atexit.cpp
   )
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c5..11cc1af78b9ba 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -217,6 +217,10 @@ elseif(FUCHSIA OR UNIX)
   else()
 set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
   endif()
+elseif(WASI)
+  set(LLVM_ON_WIN32 0)
+  set(LLVM_ON_UNIX 1)
+  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Generic")
   set(LLVM_ON_WIN32 0)
   set(LLVM_ON_UNIX 0)
diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h
index c42b5e686bdc9..8dcf6a8bfbb0a 100644
--- a/llvm/include/llvm/ADT/bit.h
+++ b/llvm/include/llvm/ADT/bit.h
@@ -24,12 +24,12 @@
 #endif
 
 #if defined(_MSC_VER) && !defined(_DEBUG)
-#include   // for _byteswap_{ushort,ulong,uint64}
+#include  // for _byteswap_{ushort,ulong,uint64}
 #endif
 
 #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||
\
 defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) ||  
\
-defined(__OpenBSD__) || defined(__DragonFly__)
+defined(__OpenBSD__) || defined(__DragonFly__) || defined(__wasi__)
 #include 
 #elif defined(_AIX)
 #include 
diff --git a/llvm/include/llvm/Support/Memory.h 

[clang] [libcxxabi] [llvm] Add support for WASI builds (PR #91051)

2024-06-08 Thread Luca Versari via cfe-commits

https://github.com/veluca93 updated 
https://github.com/llvm/llvm-project/pull/91051

>From a573b261c878c26e74831b101287945b6c414fc9 Mon Sep 17 00:00:00 2001
From: Luca Versari 
Date: Wed, 1 May 2024 15:42:57 +0200
Subject: [PATCH 1/2] Adapt the build system for WASI.

---
 clang/CMakeLists.txt   | 2 +-
 libcxxabi/src/CMakeLists.txt   | 4 ++--
 llvm/cmake/modules/HandleLLVMOptions.cmake | 4 
 llvm/lib/CMakeLists.txt| 2 ++
 llvm/lib/Transforms/CMakeLists.txt | 2 ++
 llvm/tools/CMakeLists.txt  | 4 
 6 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 2ac0bccb42f50..e1da8297ddd5f 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -426,7 +426,7 @@ CMAKE_DEPENDENT_OPTION(CLANG_PLUGIN_SUPPORT
 # If libstdc++ is statically linked, clang-repl needs to statically link 
libstdc++
 # itself, which is not possible in many platforms because of current 
limitations in
 # JIT stack. (more platforms need to be supported by JITLink)
-if(NOT LLVM_STATIC_LINK_CXX_STDLIB)
+if(NOT LLVM_STATIC_LINK_CXX_STDLIB AND NOT WASI)
   set(HAVE_CLANG_REPL_SUPPORT ON)
 endif()
 
diff --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index c54ced4dc3ea8..f96d23b3c0315 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -36,8 +36,8 @@ else()
   )
 endif()
 
-if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA) AND NOT (APPLE OR CYGWIN)
-AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
+if (LIBCXXABI_ENABLE_THREADS AND (UNIX OR FUCHSIA OR WASI) AND NOT
+  (APPLE OR CYGWIN) AND NOT (${CMAKE_SYSTEM_NAME} MATCHES "AIX"))
   list(APPEND LIBCXXABI_SOURCES
 cxa_thread_atexit.cpp
   )
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 5ca580fbb59c5..11cc1af78b9ba 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -217,6 +217,10 @@ elseif(FUCHSIA OR UNIX)
   else()
 set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
   endif()
+elseif(WASI)
+  set(LLVM_ON_WIN32 0)
+  set(LLVM_ON_UNIX 1)
+  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
 elseif(CMAKE_SYSTEM_NAME STREQUAL "Generic")
   set(LLVM_ON_WIN32 0)
   set(LLVM_ON_UNIX 0)
diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt
index 74e2d03c07953..b32411ae0b860 100644
--- a/llvm/lib/CMakeLists.txt
+++ b/llvm/lib/CMakeLists.txt
@@ -31,7 +31,9 @@ add_subdirectory(Remarks)
 add_subdirectory(Debuginfod)
 add_subdirectory(DebugInfo)
 add_subdirectory(DWP)
+if (NOT WASI)
 add_subdirectory(ExecutionEngine)
+endif ()
 add_subdirectory(Target)
 add_subdirectory(AsmParser)
 add_subdirectory(LineEditor)
diff --git a/llvm/lib/Transforms/CMakeLists.txt 
b/llvm/lib/Transforms/CMakeLists.txt
index 84a7e34147d08..1843abf1bdaa4 100644
--- a/llvm/lib/Transforms/CMakeLists.txt
+++ b/llvm/lib/Transforms/CMakeLists.txt
@@ -5,7 +5,9 @@ add_subdirectory(InstCombine)
 add_subdirectory(Scalar)
 add_subdirectory(IPO)
 add_subdirectory(Vectorize)
+if (NOT WASI)
 add_subdirectory(Hello)
+endif ()
 add_subdirectory(ObjCARC)
 add_subdirectory(Coroutines)
 add_subdirectory(CFGuard)
diff --git a/llvm/tools/CMakeLists.txt b/llvm/tools/CMakeLists.txt
index db66dad5dc0db..acd3cde1f85c1 100644
--- a/llvm/tools/CMakeLists.txt
+++ b/llvm/tools/CMakeLists.txt
@@ -28,12 +28,14 @@ endif()
 # Add LTO, llvm-ar, llvm-config, and llvm-profdata before clang, 
ExternalProject
 # requires targets specified in DEPENDS to exist before the call to
 # ExternalProject_Add.
+if (NOT WASI)
 add_llvm_tool_subdirectory(lto)
 add_llvm_tool_subdirectory(gold)
 add_llvm_tool_subdirectory(llvm-ar)
 add_llvm_tool_subdirectory(llvm-config)
 add_llvm_tool_subdirectory(llvm-lto)
 add_llvm_tool_subdirectory(llvm-profdata)
+endif ()
 
 # Projects supported via LLVM_EXTERNAL_*_SOURCE_DIR need to be explicitly
 # specified.
@@ -43,6 +45,7 @@ add_llvm_external_project(mlir)
 # accordingly so place them afterwards
 add_llvm_external_project(clang)
 add_llvm_external_project(flang)
+if (NOT WASI)
 add_llvm_external_project(lldb)
 add_llvm_external_project(bolt)
 
@@ -54,6 +57,7 @@ add_llvm_external_project(polly)
 
 # libclc depends on clang
 add_llvm_external_project(libclc)
+endif ()
 
 # Add subprojects specified using LLVM_EXTERNAL_PROJECTS
 foreach(p ${LLVM_EXTERNAL_PROJECTS})

>From e1c9c7a0c03f82e714dca866395c7b796ea7ddc2 Mon Sep 17 00:00:00 2001
From: Luca Versari 
Date: Wed, 1 May 2024 22:20:56 +0200
Subject: [PATCH 2/2] Add support for building clang on WASI.

---
 clang/lib/Driver/Driver.cpp   |  2 +-
 llvm/include/llvm/ADT/bit.h   |  4 +-
 llvm/include/llvm/Support/Memory.h|  2 +
 llvm/lib/Support/CrashRecoveryContext.cpp | 48 ++-
 llvm/lib/Support/LockFileManager.cpp  | 19 +
 llvm/lib/Support/Unix/Memory.inc  | 20 ++
 llvm/lib/Support/Unix/Path.inc| 44 

[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits

tchaikov wrote:

@5chmidti hi Julian, thank you for your review, suggestions and approval. 
updated accordingly.

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits

tchaikov wrote:

v3:

- allocate `CFGReverseBlockReachabilityAnalysis` on stack not on heap, as it's 
small enough and can be fit in the stack.
- initialize `EvaluationOrderUndefined` in-class to be more consistent. please 
note, before this change, it's always initialized if it's going to be 
referenced.

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits

https://github.com/tchaikov updated 
https://github.com/llvm/llvm-project/pull/93623

>From e07681e21f01c56a9e2705f6380838047886598a Mon Sep 17 00:00:00 2001
From: martinboehme 
Date: Wed, 29 May 2024 07:23:35 +0800
Subject: [PATCH] [clang-tidy] Let bugprone-use-after-move ignore the moved
 variable in callee

In C++17, callee is guaranteed to be sequenced before arguments.

This eliminates false positives in bugprone-use-after-move where a variable
is used in the callee and moved from in the arguments.

We introduce one special case: If the callee is a MemberExpr with a DeclRefExpr 
as its base, we consider it to be sequenced after the arguments. This is 
because the variable referenced in the base will only actually be accessed when 
the call happens, i.e. once all of the arguments have been evaluated. This has 
no basis in the C++ standard, but it reflects actual behavior that is relevant 
to a use-after-move scenario:
```
a.bar(consumeA(std::move(a));
In this example, we end up accessing a after it has been moved from, even 
though nominally the callee a.bar is evaluated before the argument 
consumeA(std::move(a)).
```
Treating this scenario correctly has required rewriting the logic in 
bugprone-use-after-move that governs whether the use happens in a later loop 
iteration than the move. This was previously based on an unsound heuristic 
(does the use come lexically before the move?); we now use a more rigourous 
criterion based on reachability in the CFG.

Fixes #57758
Fixes #59612
---
 .../clang-tidy/bugprone/UseAfterMoveCheck.cpp | 42 +---
 .../clang-tidy/utils/ExprSequence.cpp | 68 +--
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 +-
 .../checkers/bugprone/use-after-move.cpp  | 50 +-
 4 files changed, 148 insertions(+), 17 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
index b91ad0f182295..c90c92b5f660a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -11,9 +11,11 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
 #include "clang/Analysis/CFG.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallPtrSet.h"
 
 #include "../utils/ExprSequence.h"
 #include "../utils/Matchers.h"
@@ -34,7 +36,12 @@ struct UseAfterMove {
   const DeclRefExpr *DeclRef;
 
   // Is the order in which the move and the use are evaluated undefined?
-  bool EvaluationOrderUndefined;
+  bool EvaluationOrderUndefined = false;
+
+  // Does the use happen in a later loop iteration than the move?
+  //
+  // We default to false and change it to true if required in find().
+  bool UseHappensInLaterLoopIteration = false;
 };
 
 /// Finds uses of a variable after a move (and maintains state required by the
@@ -48,7 +55,7 @@ class UseAfterMoveFinder {
   // use-after-move is found, writes information about it to 'TheUseAfterMove'.
   // Returns whether a use-after-move was found.
   bool find(Stmt *CodeBlock, const Expr *MovingCall,
-const ValueDecl *MovedVariable, UseAfterMove *TheUseAfterMove);
+const DeclRefExpr *MovedVariable, UseAfterMove *TheUseAfterMove);
 
 private:
   bool findInternal(const CFGBlock *Block, const Expr *MovingCall,
@@ -89,7 +96,7 @@ UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)
 : Context(TheContext) {}
 
 bool UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
-  const ValueDecl *MovedVariable,
+  const DeclRefExpr *MovedVariable,
   UseAfterMove *TheUseAfterMove) {
   // Generate the CFG manually instead of through an AnalysisDeclContext 
because
   // it seems the latter can't be used to generate a CFG for the body of a
@@ -110,15 +117,32 @@ bool UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr 
*MovingCall,
   BlockMap = std::make_unique(TheCFG.get(), Context);
   Visited.clear();
 
-  const CFGBlock *Block = BlockMap->blockContainingStmt(MovingCall);
-  if (!Block) {
+  const CFGBlock *MoveBlock = BlockMap->blockContainingStmt(MovingCall);
+  if (!MoveBlock) {
 // This can happen if MovingCall is in a constructor initializer, which is
 // not included in the CFG because the CFG is built only from the function
 // body.
-Block = >getEntry();
+MoveBlock = >getEntry();
   }
 
-  return findInternal(Block, MovingCall, MovedVariable, TheUseAfterMove);
+  bool Found = findInternal(MoveBlock, MovingCall, MovedVariable->getDecl(),
+TheUseAfterMove);
+
+  if (Found) {
+if (const CFGBlock *UseBlock =
+BlockMap->blockContainingStmt(TheUseAfterMove->DeclRef)) {
+  // Does the use happen in a later loop 

[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits


@@ -110,15 +117,32 @@ bool UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr 
*MovingCall,
   BlockMap = std::make_unique(TheCFG.get(), Context);
   Visited.clear();
 
-  const CFGBlock *Block = BlockMap->blockContainingStmt(MovingCall);
-  if (!Block) {
+  const CFGBlock *MoveBlock = BlockMap->blockContainingStmt(MovingCall);
+  if (!MoveBlock) {
 // This can happen if MovingCall is in a constructor initializer, which is
 // not included in the CFG because the CFG is built only from the function
 // body.
-Block = >getEntry();
+MoveBlock = >getEntry();
   }
 
-  return findInternal(Block, MovingCall, MovedVariable, TheUseAfterMove);
+  bool Found = findInternal(MoveBlock, MovingCall, MovedVariable->getDecl(),
+TheUseAfterMove);
+
+  if (Found) {
+if (const CFGBlock *UseBlock =
+BlockMap->blockContainingStmt(TheUseAfterMove->DeclRef)) {
+  // Does the use happen in a later loop iteration than the move?
+  // - If they are in the same CFG block, we know the use happened in a
+  //   later iteration if we visited that block a second time.
+  // - Otherwise, we know the use happened in a later iteration if the
+  //   move is reachable from the use.
+  auto CFA = 
std::make_unique(*TheCFG);
+  TheUseAfterMove->UseHappensInLaterLoopIteration =
+  UseBlock == MoveBlock ? Visited.contains(UseBlock)
+: CFA->isReachable(UseBlock, MoveBlock);

tchaikov wrote:

`CFGReverseBlockReachabilityAnalysis` comes with two member variables of 
`llvm::BitVector` and `llvm::DenseMap<>`, which could be potentially too large 
to put on the stack, i thought. that's why i allocated it on heap. but if you 
believe it's safe to do so. will allocate it on stack.

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Kefu Chai via cfe-commits


@@ -35,6 +37,11 @@ struct UseAfterMove {
 
   // Is the order in which the move and the use are evaluated undefined?
   bool EvaluationOrderUndefined;

tchaikov wrote:

sure. but for the reason explained at 
https://github.com/llvm/llvm-project/pull/93623#discussion_r1631614642. but 
please note, it's just for the sake of readability / consistency, not for the 
correctness.

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


[clang] [clang] Cover CWG issues about `export template` (PR #94876)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This PR covers the following Core issues:
[CWG204](https://cplusplus.github.io/CWG/issues/204.html) "Exported class 
templates"
[CWG323](https://cplusplus.github.io/CWG/issues/323.html) "Where must `export` 
appear?"
[CWG335](https://cplusplus.github.io/CWG/issues/335.html) "Allowing `export` on 
template members of nontemplate classes"
[CWG820](https://cplusplus.github.io/CWG/issues/820.html) "Deprecation of 
`export`"

I believe the list above is entirety of Core issues that are dedicated solely 
to `export template`.

I believe we have two main points of view here, which command what this PR 
should do:
1. (easy) Removal of `export template` was done as a defect report in CWG820, 
and the rest are effectively superseded by it, because we apply defect reports 
retroactively.
2. (harder) Those Core issues are testable individually, so we should test them 
for the behavior Core wanted at the time.

This PR implements the first option, making our C++ DR status page greener.
I think I can be persuaded to go with the second option, if reviewers have 
strong preference for it.

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


4 Files Affected:

- (modified) clang/test/CXX/drs/cwg2xx.cpp (+1-1) 
- (modified) clang/test/CXX/drs/cwg3xx.cpp (+2-2) 
- (modified) clang/test/CXX/drs/cwg8xx.cpp (+15-10) 
- (modified) clang/www/cxx_dr_status.html (+4-4) 


``diff
diff --git a/clang/test/CXX/drs/cwg2xx.cpp b/clang/test/CXX/drs/cwg2xx.cpp
index 99916dea9a912..926cb19596026 100644
--- a/clang/test/CXX/drs/cwg2xx.cpp
+++ b/clang/test/CXX/drs/cwg2xx.cpp
@@ -41,7 +41,7 @@ namespace cwg202 { // cwg202: 3.1
   template struct X;
 }
 
-// FIXME (export) cwg204: no
+// cwg204: sup 820
 
 namespace cwg206 { // cwg206: yes
   struct S; // #cwg206-S
diff --git a/clang/test/CXX/drs/cwg3xx.cpp b/clang/test/CXX/drs/cwg3xx.cpp
index 94227dc031c6a..a10ed95941ba4 100644
--- a/clang/test/CXX/drs/cwg3xx.cpp
+++ b/clang/test/CXX/drs/cwg3xx.cpp
@@ -377,7 +377,7 @@ namespace cwg322 { // cwg322: 2.8
   int  = a;
 }
 
-// cwg323: no
+// cwg323: sup 820
 
 namespace cwg324 { // cwg324: 3.6
   struct S { int n : 1; } s; // #cwg324-n
@@ -587,7 +587,7 @@ namespace cwg334 { // cwg334: yes
   template void f();
 }
 
-// cwg335: no
+// cwg335: sup 820
 
 namespace cwg336 { // cwg336: yes
   namespace Pre {
diff --git a/clang/test/CXX/drs/cwg8xx.cpp b/clang/test/CXX/drs/cwg8xx.cpp
index eba601300584d..c8cbdfcee3f4d 100644
--- a/clang/test/CXX/drs/cwg8xx.cpp
+++ b/clang/test/CXX/drs/cwg8xx.cpp
@@ -1,14 +1,19 @@
-// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
-// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-17 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98-17,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx20,since-cxx11 -fexceptions -fcxx-exceptions 
-pedantic-errors
 
-#if __cplusplus == 199711L
-// expected-no-diagnostics
-#endif
+namespace cwg820 { // cwg820: 2.7
+export template  struct B {};
+// cxx98-17-warning@-1 {{exported templates are unsupported}}
+// since-cxx20-error@-2 {{export declaration can only be used within a module 
purview}}
+export template void f() {}
+// 

[clang] [clang] Cover CWG issues about `export template` (PR #94876)

2024-06-08 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/94876

This PR covers the following Core issues:
[CWG204](https://cplusplus.github.io/CWG/issues/204.html) "Exported class 
templates"
[CWG323](https://cplusplus.github.io/CWG/issues/323.html) "Where must `export` 
appear?"
[CWG335](https://cplusplus.github.io/CWG/issues/335.html) "Allowing `export` on 
template members of nontemplate classes"
[CWG820](https://cplusplus.github.io/CWG/issues/820.html) "Deprecation of 
`export`"

I believe the list above is entirety of Core issues that are dedicated solely 
to `export template`.

I believe we have two main points of view here, which command what this PR 
should do:
1. (easy) Removal of `export template` was done as a defect report in CWG820, 
and the rest are effectively superseded by it, because we apply defect reports 
retroactively.
2. (harder) Those Core issues are testable individually, so we should test them 
for the behavior Core wanted at the time.

This PR implements the first option, making our C++ DR status page greener.
I think I can be persuaded to go with the second option, if reviewers have 
strong preference for it.

>From e4028ec6e70f6d86325393a8d03e407404643bc0 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 9 Jun 2024 00:59:09 +0300
Subject: [PATCH 1/2] [clang] Cover CWG issues about `export template`

---
 clang/test/CXX/drs/cwg2xx.cpp |  2 +-
 clang/test/CXX/drs/cwg3xx.cpp |  4 ++--
 clang/test/CXX/drs/cwg8xx.cpp |  7 +++
 clang/www/cxx_dr_status.html  | 20 
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/clang/test/CXX/drs/cwg2xx.cpp b/clang/test/CXX/drs/cwg2xx.cpp
index 99916dea9a912..926cb19596026 100644
--- a/clang/test/CXX/drs/cwg2xx.cpp
+++ b/clang/test/CXX/drs/cwg2xx.cpp
@@ -41,7 +41,7 @@ namespace cwg202 { // cwg202: 3.1
   template struct X;
 }
 
-// FIXME (export) cwg204: no
+// cwg204: sup 820
 
 namespace cwg206 { // cwg206: yes
   struct S; // #cwg206-S
diff --git a/clang/test/CXX/drs/cwg3xx.cpp b/clang/test/CXX/drs/cwg3xx.cpp
index 94227dc031c6a..a10ed95941ba4 100644
--- a/clang/test/CXX/drs/cwg3xx.cpp
+++ b/clang/test/CXX/drs/cwg3xx.cpp
@@ -377,7 +377,7 @@ namespace cwg322 { // cwg322: 2.8
   int  = a;
 }
 
-// cwg323: no
+// cwg323: sup 820
 
 namespace cwg324 { // cwg324: 3.6
   struct S { int n : 1; } s; // #cwg324-n
@@ -587,7 +587,7 @@ namespace cwg334 { // cwg334: yes
   template void f();
 }
 
-// cwg335: no
+// cwg335: sup 820
 
 namespace cwg336 { // cwg336: yes
   namespace Pre {
diff --git a/clang/test/CXX/drs/cwg8xx.cpp b/clang/test/CXX/drs/cwg8xx.cpp
index eba601300584d..28fa8083d8e6a 100644
--- a/clang/test/CXX/drs/cwg8xx.cpp
+++ b/clang/test/CXX/drs/cwg8xx.cpp
@@ -10,6 +10,13 @@
 // expected-no-diagnostics
 #endif
 
+namespace cwg820 { // cwg820: 2.7
+export template  struct B {};
+// expected-warning@-1 {{exported templates are unsupported}}
+export template void f() {}
+// expected-warning@-1 {{exported templates are unsupported}}
+}
+
 namespace cwg873 { // cwg873: 3.0
 #if __cplusplus >= 201103L
 template  void f(T &&);
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 43857447d83b1..3fdf6bae0a3d5 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1262,7 +1262,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/204.html;>204
 CD1
 Exported class templates
-No
+Superseded by 820
   
   
 https://cplusplus.github.io/CWG/issues/205.html;>205
@@ -1978,7 +1978,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/323.html;>323
 CD1
 Where must export appear?
-No
+Superseded by 820
   
   
 https://cplusplus.github.io/CWG/issues/324.html;>324
@@ -2050,7 +2050,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/335.html;>335
 CD1
 Allowing export on template members of nontemplate 
classes
-No
+Superseded by 820
   
   
 https://cplusplus.github.io/CWG/issues/336.html;>336
@@ -4914,7 +4914,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/820.html;>820
 CD2
 Deprecation of export
-Unknown
+Clang 2.7
   
   
 https://cplusplus.github.io/CWG/issues/822.html;>822
@@ -17186,6 +17186,18 @@ C++ defect report implementation 
status
 open
 Template argument deduction involving exception specifications
 Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2897.html;>2897
+open
+Copying potentially-overlapping union subobjects
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2898.html;>2898
+open
+Clarify implicit conversion sequence from cv T to 
T
+Not resolved
   
 
 

>From bce3e35289aa977e828f6cd76c05e594ff32596b Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sun, 9 Jun 2024 01:31:36 +0300
Subject: [PATCH 2/2] Add directives 

[clang] 2e482b2 - [clang][NFC] Update CWG issues list

2024-06-08 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-06-09T01:00:42+03:00
New Revision: 2e482b25329433a61fee2e22f4ea00775e7e7ec7

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

LOG: [clang][NFC] Update CWG issues list

Added: 


Modified: 
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 43857447d83b1..5e2ab06701703 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -17186,6 +17186,18 @@ C++ defect report implementation 
status
 open
 Template argument deduction involving exception specifications
 Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2897.html;>2897
+open
+Copying potentially-overlapping union subobjects
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2898.html;>2898
+open
+Clarify implicit conversion sequence from cv T to 
T
+Not resolved
   
 
 



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


[clang] [InstallAPI] Pick up input headers by directory traversal (PR #94508)

2024-06-08 Thread Juergen Ributzka via cfe-commits


@@ -97,6 +97,14 @@ class HeaderFile {
   Other.Excluded, Other.Extra,
   Other.Umbrella);
   }
+
+  bool operator<(const HeaderFile ) const {

ributzka wrote:

Including the umbrella header first increases the likelihood of successfully 
parsing all the headers in the framework. Extra headers always go last.

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Erich Reitz via cfe-commits


@@ -796,6 +796,44 @@ TEST_F(FormatTestComments, 
ParsesCommentsAdjacentToPPDirectives) {
 format("namespace {}\n   /* Test */#define A"));
 }
 
+TEST_F(FormatTestComments, DeIdentsCommentBeforeIfdefAfterBracelessIf) {
+  verifyFormat("void f() {\n"
+   "  if (true)\n"
+   "int i;\n"
+   "  /* comment */\n"
+   "#ifdef A\n"
+   "  int j;\n"
+   "#endif\n"
+   "}",
+   "void f() {\n"
+   "  if (true)\n"
+   "int i;\n"
+   "/* comment */\n"
+   "#ifdef A\n"
+   "  int j;\n"
+   "#endif\n"
+   "}");
+
+  verifyFormat("void f() {\n"
+   "  if (true)\n"
+   "int i;\n"
+   "  /* comment */\n"

Erich-Reitz wrote:

Okay, I don't think that is the existing behavior. Using `clang-format-18`
```
void f() {
  if (foo) 
a = 3;
/* comment */

  int b = 4; 
}
```
is formatted to
```
void f() {
  if (foo)
a = 3;
  /* comment */

  int b = 4;
}
```

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Erich Reitz via cfe-commits

https://github.com/Erich-Reitz updated 
https://github.com/llvm/llvm-project/pull/94776

>From 6c910c8b40be79e3d573f6953860f60ebd27b39f Mon Sep 17 00:00:00 2001
From: Erich Reitz 
Date: Fri, 7 Jun 2024 13:04:33 -0400
Subject: [PATCH 1/6] delay flushing comments before ifdef after braceless if;
 align with token that begins conditional

---
 clang/lib/Format/UnwrappedLineParser.cpp | 19 +++
 clang/lib/Format/UnwrappedLineParser.h   |  2 ++
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index b15a87327240b..7bc066787bf46 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -354,6 +354,7 @@ bool UnwrappedLineParser::precededByCommentOrPPDirective() 
const {
 bool UnwrappedLineParser::parseLevel(const FormatToken *OpeningBrace,
  IfStmtKind *IfKind,
  FormatToken **IfLeftBrace) {
+
   const bool InRequiresExpression =
   OpeningBrace && OpeningBrace->is(TT_RequiresExpressionLBrace);
   const bool IsPrecededByCommentOrPPDirective =
@@ -385,6 +386,7 @@ bool UnwrappedLineParser::parseLevel(const FormatToken 
*OpeningBrace,
 };
 
 switch (Kind) {
+
 case tok::comment:
   nextToken();
   addUnwrappedLine();
@@ -1419,6 +1421,7 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {
 void UnwrappedLineParser::parseStructuralElement(
 const FormatToken *OpeningBrace, IfStmtKind *IfKind,
 FormatToken **IfLeftBrace, bool *HasDoWhile, bool *HasLabel) {
+
   if (Style.Language == FormatStyle::LK_TableGen &&
   FormatTok->is(tok::pp_include)) {
 nextToken();
@@ -1696,6 +1699,7 @@ void UnwrappedLineParser::parseStructuralElement(
 
   const bool InRequiresExpression =
   OpeningBrace && OpeningBrace->is(TT_RequiresExpressionLBrace);
+
   do {
 const FormatToken *Previous = FormatTok->Previous;
 switch (FormatTok->Tok.getKind()) {
@@ -2705,6 +2709,7 @@ void UnwrappedLineParser::parseUnbracedBody(bool 
CheckEOF) {
 
   addUnwrappedLine();
   ++Line->Level;
+  ++UnBracedBodyDepth;
   parseStructuralElement();
 
   if (Tok) {
@@ -2719,11 +2724,11 @@ void UnwrappedLineParser::parseUnbracedBody(bool 
CheckEOF) {
 assert(Tok);
 ++Tok->BraceCount;
   }
-
   if (CheckEOF && eof())
 addUnwrappedLine();
 
   --Line->Level;
+  --UnBracedBodyDepth;
 }
 
 static void markOptionalBraces(FormatToken *LeftBrace) {
@@ -4736,6 +4741,7 @@ void UnwrappedLineParser::distributeComments(
   // the two lines about b form a maximal trail, so there are two sections, the
   // first one consisting of the single comment "// line about a" and the
   // second one consisting of the next two comments.
+
   if (Comments.empty())
 return;
   bool ShouldPushCommentsInCurrentLine = true;
@@ -4811,8 +4817,10 @@ void UnwrappedLineParser::readToken(int LevelDifference) 
{
(!Style.isVerilog() ||
 Keywords.isVerilogPPDirective(*Tokens->peekNextToken())) &&
FirstNonCommentOnLine) {
-  distributeComments(Comments, FormatTok);
-  Comments.clear();
+  if (!UnBracedBodyDepth) {
+distributeComments(Comments, FormatTok);
+Comments.clear();
+  }
   // If there is an unfinished unwrapped line, we flush the preprocessor
   // directives only after that unwrapped line was finished later.
   bool SwitchToPreprocessorLines = !Line->Tokens.empty();
@@ -4828,7 +4836,10 @@ void UnwrappedLineParser::readToken(int LevelDifference) 
{
   PPBranchLevel > 0) {
 Line->Level += PPBranchLevel;
   }
-  flushComments(isOnNewLine(*FormatTok));
+  if (!UnBracedBodyDepth) {
+flushComments(isOnNewLine(*FormatTok));
+  }
+
   parsePPDirective();
   PreviousWasComment = FormatTok->is(tok::comment);
   FirstNonCommentOnLine = IsFirstNonCommentOnLine(
diff --git a/clang/lib/Format/UnwrappedLineParser.h 
b/clang/lib/Format/UnwrappedLineParser.h
index d7963a4211bb9..4d87896870a3e 100644
--- a/clang/lib/Format/UnwrappedLineParser.h
+++ b/clang/lib/Format/UnwrappedLineParser.h
@@ -338,6 +338,8 @@ class UnwrappedLineParser {
   // `decltype(auto)`.
   bool IsDecltypeAutoFunction = false;
 
+  int UnBracedBodyDepth = 0;
+
   // Represents preprocessor branch type, so we can find matching
   // #if/#else/#endif directives.
   enum PPBranchKind {

>From b9d52022e1caf314cb3f24f03775c8baf5da1c4a Mon Sep 17 00:00:00 2001
From: Erich Reitz 
Date: Fri, 7 Jun 2024 13:08:13 -0400
Subject: [PATCH 2/6] whitespace formatting

---
 clang/lib/Format/UnwrappedLineParser.cpp | 7 +++
 clang/lib/Format/UnwrappedLineParser.h   | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 7bc066787bf46..b17ef33f95e98 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ 

[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-08 Thread Björn Schäpers via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Piotr Zegar (PiotrZSL)


Changes

- Removed custom smart pointers handling (were hiding issues)
- Changed 'move occurred here' note location to always point to 'std::move'

Closes #90174


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


4 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp 
(+3-34) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+2-1) 
- (modified) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/use-after-move.rst (-7) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp (+91-23) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
index b91ad0f182295..4f1ea32da20f4 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -215,26 +215,6 @@ void UseAfterMoveFinder::getUsesAndReinits(
   });
 }
 
-bool isStandardSmartPointer(const ValueDecl *VD) {
-  const Type *TheType = VD->getType().getNonReferenceType().getTypePtrOrNull();
-  if (!TheType)
-return false;
-
-  const CXXRecordDecl *RecordDecl = TheType->getAsCXXRecordDecl();
-  if (!RecordDecl)
-return false;
-
-  const IdentifierInfo *ID = RecordDecl->getIdentifier();
-  if (!ID)
-return false;
-
-  StringRef Name = ID->getName();
-  if (Name != "unique_ptr" && Name != "shared_ptr" && Name != "weak_ptr")
-return false;
-
-  return RecordDecl->getDeclContext()->isStdNamespace();
-}
-
 void UseAfterMoveFinder::getDeclRefs(
 const CFGBlock *Block, const Decl *MovedVariable,
 llvm::SmallPtrSetImpl *DeclRefs) {
@@ -248,13 +228,8 @@ void UseAfterMoveFinder::getDeclRefs(
 DeclRefs](const ArrayRef Matches) {
   for (const auto  : Matches) {
 const auto *DeclRef = Match.getNodeAs("declref");
-const auto *Operator = 
Match.getNodeAs("operator");
 if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
-  // Ignore uses of a standard smart pointer that don't dereference the
-  // pointer.
-  if (Operator || !isStandardSmartPointer(DeclRef->getDecl())) {
-DeclRefs->insert(DeclRef);
-  }
+  DeclRefs->insert(DeclRef);
 }
   }
 };
@@ -265,11 +240,6 @@ void UseAfterMoveFinder::getDeclRefs(
 
 AddDeclRefs(match(traverse(TK_AsIs, findAll(DeclRefMatcher)), 
*S->getStmt(),
   *Context));
-AddDeclRefs(match(findAll(cxxOperatorCallExpr(
-  hasAnyOverloadedOperatorName("*", "->", 
"[]"),
-  hasArgument(0, DeclRefMatcher))
-  .bind("operator")),
-  *S->getStmt(), *Context));
   }
 }
 
@@ -411,10 +381,9 @@ void UseAfterMoveCheck::registerMatchers(MatchFinder 
*Finder) {
   auto TryEmplaceMatcher =
   cxxMemberCallExpr(callee(cxxMethodDecl(hasName("try_emplace";
   auto CallMoveMatcher =
-  callExpr(argumentCountIs(1),
+  callExpr(argumentCountIs(1), hasArgument(0, declRefExpr().bind("arg")),
callee(functionDecl(hasAnyName("::std::move", "::std::forward"))
   .bind("move-decl")),
-   hasArgument(0, declRefExpr().bind("arg")),
unless(inDecltypeOrTemplateArg()),
unless(hasParent(TryEmplaceMatcher)), expr().bind("call-move"),
anyOf(hasAncestor(compoundStmt(
@@ -496,7 +465,7 @@ void UseAfterMoveCheck::check(const 
MatchFinder::MatchResult ) {
 UseAfterMoveFinder Finder(Result.Context);
 UseAfterMove Use;
 if (Finder.find(CodeBlock, MovingCall, Arg->getDecl(), ))
-  emitDiagnostic(MovingCall, Arg, Use, this, Result.Context,
+  emitDiagnostic(CallMove, Arg, Use, this, Result.Context,
  determineMoveType(MoveDecl));
   }
 }
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 277a6e75da2ac..f9b84a6df532e 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -254,7 +254,8 @@ Changes in existing checks
 
 - Improved :doc:`bugprone-use-after-move
   ` check to also handle
-  calls to ``std::forward``.
+  calls to ``std::forward``. Smart pointers are now handled like any other
+  objects allowing to detect more cases.
 
 - Improved :doc:`cppcoreguidelines-missing-std-forward
   ` check by no longer
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/use-after-move.rst 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/use-after-move.rst
index 08bb5374bab1f..faf9e4dddc12c 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/bugprone/use-after-move.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone/use-after-move.rst
@@ -195,13 +195,6 @@ Use
 Any occurrence of the 

[clang-tools-extra] [clang-tidy] Fix smart pointers handling in bugprone-use-after-move (PR #94869)

2024-06-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL created 
https://github.com/llvm/llvm-project/pull/94869

- Removed custom smart pointers handling (were hiding issues)
- Changed 'move occurred here' note location to always point to 'std::move'

Closes #90174


>From 1179f63d792da2462e1490c1b0a59cf1e6e47349 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Sat, 8 Jun 2024 19:41:51 +
Subject: [PATCH 1/3] [clang-tidy] Fix smart pointers handling in
 bugprone-use-after-move

- Removed custom smart pointers handling (were hidding issues)
- Changed 'move occurred here' note location to always point to 'std::move'
- Fixed issue when 'std::move' of 'x' on initialization list would be
  incorrectly detected as use after move.

Closes #90174
---
 .../clang-tidy/bugprone/UseAfterMoveCheck.cpp |  39 +-
 .../checkers/bugprone/use-after-move.cpp  | 114 ++
 2 files changed, 95 insertions(+), 58 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
index b91ad0f182295..593ed11d8ac43 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -215,26 +215,6 @@ void UseAfterMoveFinder::getUsesAndReinits(
   });
 }
 
-bool isStandardSmartPointer(const ValueDecl *VD) {
-  const Type *TheType = VD->getType().getNonReferenceType().getTypePtrOrNull();
-  if (!TheType)
-return false;
-
-  const CXXRecordDecl *RecordDecl = TheType->getAsCXXRecordDecl();
-  if (!RecordDecl)
-return false;
-
-  const IdentifierInfo *ID = RecordDecl->getIdentifier();
-  if (!ID)
-return false;
-
-  StringRef Name = ID->getName();
-  if (Name != "unique_ptr" && Name != "shared_ptr" && Name != "weak_ptr")
-return false;
-
-  return RecordDecl->getDeclContext()->isStdNamespace();
-}
-
 void UseAfterMoveFinder::getDeclRefs(
 const CFGBlock *Block, const Decl *MovedVariable,
 llvm::SmallPtrSetImpl *DeclRefs) {
@@ -248,13 +228,8 @@ void UseAfterMoveFinder::getDeclRefs(
 DeclRefs](const ArrayRef Matches) {
   for (const auto  : Matches) {
 const auto *DeclRef = Match.getNodeAs("declref");
-const auto *Operator = 
Match.getNodeAs("operator");
 if (DeclRef && BlockMap->blockContainingStmt(DeclRef) == Block) {
-  // Ignore uses of a standard smart pointer that don't dereference the
-  // pointer.
-  if (Operator || !isStandardSmartPointer(DeclRef->getDecl())) {
-DeclRefs->insert(DeclRef);
-  }
+  DeclRefs->insert(DeclRef);
 }
   }
 };
@@ -265,11 +240,6 @@ void UseAfterMoveFinder::getDeclRefs(
 
 AddDeclRefs(match(traverse(TK_AsIs, findAll(DeclRefMatcher)), 
*S->getStmt(),
   *Context));
-AddDeclRefs(match(findAll(cxxOperatorCallExpr(
-  hasAnyOverloadedOperatorName("*", "->", 
"[]"),
-  hasArgument(0, DeclRefMatcher))
-  .bind("operator")),
-  *S->getStmt(), *Context));
   }
 }
 
@@ -411,10 +381,9 @@ void UseAfterMoveCheck::registerMatchers(MatchFinder 
*Finder) {
   auto TryEmplaceMatcher =
   cxxMemberCallExpr(callee(cxxMethodDecl(hasName("try_emplace";
   auto CallMoveMatcher =
-  callExpr(argumentCountIs(1),
+  callExpr(argumentCountIs(1), hasArgument(0, declRefExpr().bind("arg")),
callee(functionDecl(hasAnyName("::std::move", "::std::forward"))
   .bind("move-decl")),
-   hasArgument(0, declRefExpr().bind("arg")),
unless(inDecltypeOrTemplateArg()),
unless(hasParent(TryEmplaceMatcher)), expr().bind("call-move"),
anyOf(hasAncestor(compoundStmt(
@@ -464,7 +433,7 @@ void UseAfterMoveCheck::check(const 
MatchFinder::MatchResult ) {
   const auto *MoveDecl = Result.Nodes.getNodeAs("move-decl");
 
   if (!MovingCall || !MovingCall->getExprLoc().isValid())
-MovingCall = CallMove;
+MovingCall = ContainingCtorInit ? ContainingCtorInit : CallMove;
 
   // Ignore the std::move if the variable that was passed to it isn't a local
   // variable.
@@ -496,7 +465,7 @@ void UseAfterMoveCheck::check(const 
MatchFinder::MatchResult ) {
 UseAfterMoveFinder Finder(Result.Context);
 UseAfterMove Use;
 if (Finder.find(CodeBlock, MovingCall, Arg->getDecl(), ))
-  emitDiagnostic(MovingCall, Arg, Use, this, Result.Context,
+  emitDiagnostic(CallMove, Arg, Use, this, Result.Context,
  determineMoveType(MoveDecl));
   }
 }
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
index 7d9f63479a1b4..3d06dc008d353 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
+++ 

[clang] Improve error message for invalid lambda captures (PR #94865)

2024-06-08 Thread Thorsten Schütt via cfe-commits

tschuett wrote:

Needs a test.

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits


@@ -796,6 +796,24 @@ TEST_F(FormatTestComments, 
ParsesCommentsAdjacentToPPDirectives) {
 format("namespace {}\n   /* Test */#define A"));
 }
 
+
+TEST_F(FormatTestComments, DeIdentsCommentBeforeIfdefAfterBracelessIf) {
+  EXPECT_EQ("void f() {\n"

owenca wrote:

You don't need to because the default style is `LLVM`.

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits


@@ -338,6 +338,9 @@ class UnwrappedLineParser {
   // `decltype(auto)`.
   bool IsDecltypeAutoFunction = false;
 
+  // Current nesting depth within unbraced codeblocks.

owenca wrote:

```suggestion
  // Nesting depth of unbraced body of a control statement.
```

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits


@@ -4811,8 +4813,11 @@ void UnwrappedLineParser::readToken(int LevelDifference) 
{
(!Style.isVerilog() ||
 Keywords.isVerilogPPDirective(*Tokens->peekNextToken())) &&
FirstNonCommentOnLine) {
-  distributeComments(Comments, FormatTok);
-  Comments.clear();
+
+  if (!UnbracedBodyDepth) {
+distributeComments(Comments, FormatTok);
+Comments.clear();
+  }

owenca wrote:

```suggestion
  if (UnbracedBodyDepth == 0) {
distributeComments(Comments, FormatTok);
Comments.clear();
  }

```

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits


@@ -796,6 +796,44 @@ TEST_F(FormatTestComments, 
ParsesCommentsAdjacentToPPDirectives) {
 format("namespace {}\n   /* Test */#define A"));
 }
 
+TEST_F(FormatTestComments, DeIdentsCommentBeforeIfdefAfterBracelessIf) {
+  verifyFormat("void f() {\n"
+   "  if (true)\n"
+   "int i;\n"
+   "  /* comment */\n"
+   "#ifdef A\n"
+   "  int j;\n"
+   "#endif\n"
+   "}",
+   "void f() {\n"
+   "  if (true)\n"
+   "int i;\n"
+   "/* comment */\n"
+   "#ifdef A\n"
+   "  int j;\n"
+   "#endif\n"
+   "}");
+
+  verifyFormat("void f() {\n"
+   "  if (true)\n"
+   "int i;\n"
+   "  /* comment */\n"

owenca wrote:

It doesn't look right as the comment is likely for the line above it.

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits


@@ -4828,7 +4833,10 @@ void UnwrappedLineParser::readToken(int LevelDifference) 
{
   PPBranchLevel > 0) {
 Line->Level += PPBranchLevel;
   }
-  flushComments(isOnNewLine(*FormatTok));
+
+  if (!UnbracedBodyDepth)

owenca wrote:

Ditto.

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


[clang] [clang-format] Fix bad comment indentation before ifdef after braceless if (PR #94776)

2024-06-08 Thread Owen Pan via cfe-commits

https://github.com/owenca commented:

What happens if the comment is unindented, with and without an empty line below 
it?

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


[clang] Improve error message for invalid lambda captures (PR #94865)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: CedricSWA (CedricSwa)


Changes

close issue #94764

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


2 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2) 
- (modified) clang/lib/Sema/SemaLambda.cpp (+6-1) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9f0b6f5a36389..fdf4409125c00 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8173,6 +8173,8 @@ let CategoryName = "Lambda Issue" in {
 "'&' must precede a capture when the capture default is '='">;
   def err_capture_does_not_name_variable : Error<
 "%0 in capture list does not name a variable">;
+  def err_capture_class_member_does_not_name_variable : Error<
+"class member %0 cannot appear in capture list as it is not a variable">;
   def err_capture_non_automatic_variable : Error<
 "%0 cannot be captured because it does not have automatic storage "
 "duration">;
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index e9476a0c93c5d..79c10c3bad6d7 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1246,7 +1246,12 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer ,
 
   if (auto *BD = R.getAsSingle())
 Var = BD;
-  else
+  else if (auto *FD = R.getAsSingle()) {
+Var = R.getAsSingle();
+Diag(C->Loc, diag::err_capture_class_member_does_not_name_variable)
+<< C->Id;
+continue;
+  } else
 Var = R.getAsSingle();
   if (Var && DiagnoseUseOfDecl(Var, C->Loc))
 continue;

``




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


[clang] Improve error message for invalid lambda captures (PR #94865)

2024-06-08 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] Improve error message for invalid lambda captures (PR #94865)

2024-06-08 Thread via cfe-commits

https://github.com/CedricSwa created 
https://github.com/llvm/llvm-project/pull/94865

close issue #94764

>From 012849c5410960001ca5bbcb90ea2cf4a661b840 Mon Sep 17 00:00:00 2001
From: Cedric Schwarzer 
Date: Sat, 8 Jun 2024 17:52:02 +0200
Subject: [PATCH] Improve error message for invalid lambda captures

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 ++
 clang/lib/Sema/SemaLambda.cpp| 7 ++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 9f0b6f5a36389..fdf4409125c00 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8173,6 +8173,8 @@ let CategoryName = "Lambda Issue" in {
 "'&' must precede a capture when the capture default is '='">;
   def err_capture_does_not_name_variable : Error<
 "%0 in capture list does not name a variable">;
+  def err_capture_class_member_does_not_name_variable : Error<
+"class member %0 cannot appear in capture list as it is not a variable">;
   def err_capture_non_automatic_variable : Error<
 "%0 cannot be captured because it does not have automatic storage "
 "duration">;
diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index e9476a0c93c5d..79c10c3bad6d7 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1246,7 +1246,12 @@ void 
Sema::ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer ,
 
   if (auto *BD = R.getAsSingle())
 Var = BD;
-  else
+  else if (auto *FD = R.getAsSingle()) {
+Var = R.getAsSingle();
+Diag(C->Loc, diag::err_capture_class_member_does_not_name_variable)
+<< C->Id;
+continue;
+  } else
 Var = R.getAsSingle();
   if (Var && DiagnoseUseOfDecl(Var, C->Loc))
 continue;

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


[clang-tools-extra] [clang-tidy] Ignore implicit functions in readability-implicit-bool-conversion (PR #94512)

2024-06-08 Thread Julian Schmidt via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] Ignore non-math operators in readability-math-missing-parentheses (PR #94654)

2024-06-08 Thread Julian Schmidt via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] Extend modernize-use-designated-initializers with new options (PR #94651)

2024-06-08 Thread Julian Schmidt via cfe-commits

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

LGTM

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


[clang-tools-extra] [clang-tidy] Improve bugprone-multi-level-implicit-pointer-conversion (PR #94524)

2024-06-08 Thread Julian Schmidt via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Julian Schmidt via cfe-commits


@@ -35,6 +37,11 @@ struct UseAfterMove {
 
   // Is the order in which the move and the use are evaluated undefined?
   bool EvaluationOrderUndefined;

5chmidti wrote:

While you're at it, please initialize `EvaluationOrderUndefined` to `false` as 
well.

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Julian Schmidt via cfe-commits


@@ -110,15 +117,32 @@ bool UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr 
*MovingCall,
   BlockMap = std::make_unique(TheCFG.get(), Context);
   Visited.clear();
 
-  const CFGBlock *Block = BlockMap->blockContainingStmt(MovingCall);
-  if (!Block) {
+  const CFGBlock *MoveBlock = BlockMap->blockContainingStmt(MovingCall);
+  if (!MoveBlock) {
 // This can happen if MovingCall is in a constructor initializer, which is
 // not included in the CFG because the CFG is built only from the function
 // body.
-Block = >getEntry();
+MoveBlock = >getEntry();
   }
 
-  return findInternal(Block, MovingCall, MovedVariable, TheUseAfterMove);
+  bool Found = findInternal(MoveBlock, MovingCall, MovedVariable->getDecl(),
+TheUseAfterMove);
+
+  if (Found) {
+if (const CFGBlock *UseBlock =
+BlockMap->blockContainingStmt(TheUseAfterMove->DeclRef)) {
+  // Does the use happen in a later loop iteration than the move?
+  // - If they are in the same CFG block, we know the use happened in a
+  //   later iteration if we visited that block a second time.
+  // - Otherwise, we know the use happened in a later iteration if the
+  //   move is reachable from the use.
+  auto CFA = 
std::make_unique(*TheCFG);
+  TheUseAfterMove->UseHappensInLaterLoopIteration =
+  UseBlock == MoveBlock ? Visited.contains(UseBlock)
+: CFA->isReachable(UseBlock, MoveBlock);

5chmidti wrote:

`CFA` does not need to be a unique_ptr, you can simply create a 
`CFGReverseBlockReachabilityAnalysis` on the stack.

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Julian Schmidt via cfe-commits

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

LGTM after fixing these two comments, but let's wait for others to review as 
well

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


[clang-tools-extra] [clang-tidy] In C++17, callee is guaranteed to be sequenced before arguments. (PR #93623)

2024-06-08 Thread Julian Schmidt via cfe-commits

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


[clang] fix(93512): skip alignment checks on incomplete types (PR #94542)

2024-06-08 Thread Oleksandr T. via cfe-commits

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

>From 417093b489f17b0d22701f3c3b990388997c25a0 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Thu, 6 Jun 2024 01:55:54 +0300
Subject: [PATCH] fix(93512): skip alignment checks on incomplete types

---
 clang/docs/ReleaseNotes.rst| 2 ++
 clang/lib/Sema/SemaStmt.cpp| 2 +-
 clang/test/SemaCXX/lambda-as-default-parameter.cpp | 6 ++
 3 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/lambda-as-default-parameter.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 39a9013c75a41..819fe1811ddaf 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -840,6 +840,8 @@ Bug Fixes to C++ Support
 - Fix a crash caused by improper use of ``__array_extent``. (#GH80474)
 - Fixed several bugs in capturing variables within unevaluated contexts. 
(#GH63845), (#GH67260), (#GH69307),
   (#GH88081), (#GH89496), (#GH90669) and (#GH91633).
+- Fix an assertion failure caused by parsing a lambda used as a default 
argument for the value of a
+  forward-declared class. (#GH93512).
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 57465d4a77ac2..56f69dd50f361 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3355,7 +3355,7 @@ Sema::NamedReturnInfo Sema::getNamedReturnInfo(const 
VarDecl *VD) {
 
   // Variables with higher required alignment than their type's ABI
   // alignment cannot use NRVO.
-  if (!VD->hasDependentAlignment() &&
+  if (!VD->hasDependentAlignment() && !VDType->isIncompleteType() &&
   Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
 Info.S = NamedReturnInfo::MoveEligible;
 
diff --git a/clang/test/SemaCXX/lambda-as-default-parameter.cpp 
b/clang/test/SemaCXX/lambda-as-default-parameter.cpp
new file mode 100644
index 0..1f07a7f5644b7
--- /dev/null
+++ b/clang/test/SemaCXX/lambda-as-default-parameter.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct a; // expected-note {{forward declaration of 'a'}} \
+ expected-note {{forward declaration of 'a'}}
+void b(a c = [] { return c; }); // expected-error {{initialization of 
incomplete type 'a'}} \
+   expected-error {{variable has incomplete 
type 'a'}}

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


[clang] [clang-tools-extra] [compiler-rt] [libc] [libcxx] [lld] [lldb] [llvm] [mlir] [libc][math][C23] Implemented remquof128 function (PR #94809)

2024-06-08 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff bfa937a48767a3dd10c5847034ce0b341da00a93 
619189446484702fdf66dc43009cf6606dc4a8cd -- 
clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp 
clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.h 
clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/use-internal-linkage/func.h
 
clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/use-internal-linkage/func_cpp.inc
 
clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/use-internal-linkage/func_h.inc
 
clang-tools-extra/test/clang-tidy/checkers/misc/Inputs/use-internal-linkage/var.h
 clang-tools-extra/test/clang-tidy/checkers/misc/use-internal-linkage-func.cpp 
clang-tools-extra/test/clang-tidy/checkers/misc/use-internal-linkage-var.cpp 
libc/src/math/fmodf16.h libc/src/math/generic/fmodf16.cpp 
libc/src/math/generic/remquof128.cpp libc/src/math/remquof128.h 
libc/test/src/math/performance_testing/fmodf16_perf.cpp 
libc/test/src/math/smoke/fmodf16_test.cpp 
libc/test/src/math/smoke/remquof128_test.cpp 
clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp 
clang/examples/PrintFunctionNames/PrintFunctionNames.cpp 
clang/include/clang/Sema/SemaHLSL.h clang/lib/AST/ExprConstant.cpp 
clang/lib/CodeGen/CGHLSLRuntime.cpp clang/lib/Sema/SemaHLSL.cpp 
clang/test/SemaCXX/complex-folding.cpp 
compiler-rt/lib/xray/tests/unit/function_call_trie_test.cpp 
compiler-rt/lib/xray/tests/unit/profile_collector_test.cpp 
compiler-rt/lib/xray/tests/unit/segmented_array_test.cpp 
compiler-rt/lib/xray/tests/unit/test_helpers.cpp 
compiler-rt/lib/xray/xray_fdr_logging.cpp 
compiler-rt/lib/xray/xray_function_call_trie.h 
compiler-rt/lib/xray/xray_profile_collector.cpp 
compiler-rt/lib/xray/xray_profiling.cpp 
compiler-rt/lib/xray/xray_segmented_array.h 
compiler-rt/test/dfsan/release_shadow_space.c 
compiler-rt/test/tsan/custom_mutex4.cpp compiler-rt/test/tsan/custom_mutex5.cpp 
libc/src/__support/FPUtil/FPBits.h libc/src/__support/FPUtil/generic/FMod.h 
libc/test/src/math/performance_testing/BinaryOpSingleOutputPerf.h 
libc/test/src/math/smoke/FModTest.h libcxx/include/__type_traits/promote.h 
lld/ELF/Arch/AArch64.cpp lld/ELF/InputFiles.cpp lld/ELF/Relocations.cpp 
lld/ELF/SyntheticSections.cpp lld/ELF/SyntheticSections.h lld/ELF/Writer.cpp 
lldb/include/lldb/API/SBCommandInterpreterRunOptions.h 
lldb/include/lldb/Interpreter/CommandInterpreter.h 
lldb/source/API/SBCommandInterpreterRunOptions.cpp 
lldb/source/Interpreter/CommandInterpreter.cpp 
lldb/tools/debugserver/source/JSON.cpp llvm/examples/BrainF/BrainF.cpp 
llvm/examples/BrainF/BrainFDriver.cpp llvm/include/llvm/ProfileData/InstrProf.h 
llvm/include/llvm/ProfileData/MemProf.h 
llvm/include/llvm/ProfileData/MemProfReader.h 
llvm/include/llvm/Support/GenericLoopInfoImpl.h 
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
llvm/lib/ProfileData/InstrProfReader.cpp 
llvm/lib/ProfileData/InstrProfWriter.cpp llvm/lib/ProfileData/MemProf.cpp 
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp 
llvm/lib/Transforms/Instrumentation/MemProfiler.cpp 
llvm/lib/Transforms/Scalar/Reassociate.cpp 
llvm/lib/Transforms/Utils/SimplifyCFG.cpp 
llvm/unittests/ProfileData/MemProfTest.cpp mlir/include/mlir/IR/PatternMatch.h 
mlir/lib/Dialect/Affine/IR/AffineOps.cpp 
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp 
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp mlir/lib/Dialect/SCF/IR/SCF.cpp 
mlir/lib/Dialect/SCF/Transforms/ForallToFor.cpp 
mlir/lib/Dialect/SCF/Transforms/ForallToParallel.cpp 
mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp 
mlir/unittests/Dialect/SCF/LoopLikeSCFOpsTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Interpreter/CommandInterpreter.h 
b/lldb/include/lldb/Interpreter/CommandInterpreter.h
index 48f6618ab0..8683e2a88a 100644
--- a/lldb/include/lldb/Interpreter/CommandInterpreter.h
+++ b/lldb/include/lldb/Interpreter/CommandInterpreter.h
@@ -100,8 +100,7 @@ public:
LazyBool stop_on_error, LazyBool stop_on_crash,
LazyBool echo_commands, LazyBool echo_comments,
LazyBool print_results, LazyBool print_errors,
-   LazyBool add_to_history,
-   LazyBool handle_repeats)
+   LazyBool add_to_history, LazyBool 
handle_repeats)
   : m_stop_on_continue(stop_on_continue), m_stop_on_error(stop_on_error),
 m_stop_on_crash(stop_on_crash), m_echo_commands(echo_commands),
 m_echo_comment_commands(echo_comments), m_print_results(print_results),

``




https://github.com/llvm/llvm-project/pull/94809
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[clang] Sema: Fix CXXRecordDecl::isTriviallyCopyable() for classes with all deleted special functions. (PR #94831)

2024-06-08 Thread Amirreza Ashouri via cfe-commits

AMP999 wrote:

You're currently checking whether there is at least one **deleted** member of 
**each** kind; but you should be checking whether there is at least one 
**non-deleted** member of **any** kind. A type that shows the difference is:
```
struct S {
  S(const S&) = default;
  S(S&) = delete;
  S(S&&) = delete;
  S& operator=(const S&) = default;
  S& operator=(S&) = delete;
  S& operator=(S&&) = delete;
};
static_assert(__is_trivially_copyable(S)); // should be true
```

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


[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)

2024-06-08 Thread Shilei Tian via cfe-commits


@@ -0,0 +1,9 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -fclang-abi-compat=latest -triple amdgcn %s -emit-llvm -o - 
| FileCheck %s

shiltian wrote:

Copy/paste from other tests Lol

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


[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)

2024-06-08 Thread Shilei Tian via cfe-commits


@@ -0,0 +1,21 @@
+//===-- AMDGPUTypes.def - Metadata about AMDGPU types ---*- 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 defines various AMDGPU builtin types.
+//
+//===--===//
+
+#ifndef AMDGPU_OPAQUE_TYPE
+#define AMDGPU_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) 
\
+  AMDGPU_TYPE(Name, Id, SingletonId)
+#endif
+
+AMDGPU_OPAQUE_TYPE("__buffer_rsrc_t", "__buffer_rsrc_t", AMDGPUBufferRsrc, 
AMDGPUBufferRsrcTy)

shiltian wrote:

Probably not. I checked WASM reference types and they don't have wasm prefix.

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


[clang] [Clang][AMDGPU] Add a new builtin type for buffer rsrc (PR #94830)

2024-06-08 Thread Shilei Tian via cfe-commits


@@ -2200,6 +2206,9 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const 
{
 Align = 8; 
\
 break;
 #include "clang/Basic/WebAssemblyReferenceTypes.def"
+case BuiltinType::AMDGPUBufferRsrc:
+  Width = 128;
+  Align = 128;

shiltian wrote:

Do we want to expose it as a pointer, a sizeless object, or a vector of 160 
bits?

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


[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-08 Thread Rajveer Singh Bharadwaj via cfe-commits

Rajveer100 wrote:

I have added a `FIXME` for now regarding the Obj-C part.

The function change is also done.

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


[clang] [clang] Fix-it hint for `++this` -> `++*this` when deref is modifiable (PR #94159)

2024-06-08 Thread Rajveer Singh Bharadwaj via cfe-commits

https://github.com/Rajveer100 updated 
https://github.com/llvm/llvm-project/pull/94159

>From 1a9ef88a6fec33521ecdfe9d7e6d5ebc8d0805a5 Mon Sep 17 00:00:00 2001
From: Rajveer 
Date: Sun, 2 Jun 2024 18:33:37 +0530
Subject: [PATCH] [clang] Fix-it hint for `++this` -> `++*this` when deref is
 modifiable

Resolves #93066
---
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ++
 clang/lib/Sema/SemaExpr.cpp   | 23 --
 clang/test/C/drs/dr1xx.c  |  1 +
 clang/test/Sema/debug-93066.cpp   | 31 +++
 clang/test/Sema/exprs.c   |  2 ++
 clang/test/Sema/va_arg_x86_32.c   |  1 +
 clang/test/SemaObjCXX/sel-address.mm  |  8 +
 7 files changed, 67 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/Sema/debug-93066.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 270b0a1e01307..0ad0a80c21521 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8777,6 +8777,9 @@ def err_typecheck_incomplete_type_not_modifiable_lvalue : 
Error<
 def err_typecheck_lvalue_casts_not_supported : Error<
   "assignment to cast is illegal, lvalue casts are not supported">;
 
+def note_typecheck_expression_not_modifiable_lvalue : Note<
+  "add '*' to dereference it">; 
+
 def err_typecheck_duplicate_vector_components_not_mlvalue : Error<
   "vector is not assignable (contains duplicate components)">;
 def err_block_decl_ref_not_modifiable_lvalue : Error<
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index ff9c5ead36dcf..cc6e29c186bd4 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13273,6 +13273,22 @@ enum {
   ConstUnknown,  // Keep as last element
 };
 
+static void MaybeSuggestDerefFixIt(Sema , const Expr *E, SourceLocation Loc) 
{
+  ExprResult Deref;
+  Expr *TE = const_cast(E);
+  {
+Sema::TentativeAnalysisScope Trap(S);
+Deref = S.ActOnUnaryOp(S.getCurScope(), Loc, tok::star, TE);
+  }
+  if (Deref.isUsable() &&
+  Deref.get()->isModifiableLvalue(S.Context, ) == Expr::MLV_Valid &&
+  !E->getType()->isObjCObjectPointerType()) {
+S.Diag(Loc, diag::note_typecheck_expression_not_modifiable_lvalue)
+<< E->getSourceRange()
+<< FixItHint::CreateInsertion(E->getBeginLoc(), "*");
+  }
+}
+
 /// Emit the "read-only variable not assignable" error and print notes to give
 /// more information about why the variable is not assignable, such as pointing
 /// to the declaration of a const variable, showing that a method is const, or
@@ -13367,6 +13383,7 @@ static void DiagnoseConstAssignment(Sema , const Expr 
*E,
 if (!DiagnosticEmitted) {
   S.Diag(Loc, diag::err_typecheck_assign_const)
   << ExprRange << ConstVariable << VD << VD->getType();
+  MaybeSuggestDerefFixIt(S, E, Loc);
   DiagnosticEmitted = true;
 }
 S.Diag(VD->getLocation(), diag::note_typecheck_assign_const)
@@ -13587,10 +13604,12 @@ static bool CheckForModifiableLvalue(Expr *E, 
SourceLocation Loc, Sema ) {
   SourceRange Assign;
   if (Loc != OrigLoc)
 Assign = SourceRange(OrigLoc, OrigLoc);
-  if (NeedType)
+  if (NeedType) {
 S.Diag(Loc, DiagID) << E->getType() << E->getSourceRange() << Assign;
-  else
+  } else {
 S.Diag(Loc, DiagID) << E->getSourceRange() << Assign;
+MaybeSuggestDerefFixIt(S, E, Loc);
+  }
   return true;
 }
 
diff --git a/clang/test/C/drs/dr1xx.c b/clang/test/C/drs/dr1xx.c
index 47538e44428c3..20e953b2c20ac 100644
--- a/clang/test/C/drs/dr1xx.c
+++ b/clang/test/C/drs/dr1xx.c
@@ -296,6 +296,7 @@ void dr126(void) {
*/
   *object = 12; /* ok */
   ++object; /* expected-error {{cannot assign to variable 'object' with 
const-qualified type 'const IP' (aka 'int *const')}} */
+  /* expected-note@-1 {{add '*' to dereference it}} */
 }
 
 /* WG14 DR128: yes
diff --git a/clang/test/Sema/debug-93066.cpp b/clang/test/Sema/debug-93066.cpp
new file mode 100644
index 0..8e9c382a63bbe
--- /dev/null
+++ b/clang/test/Sema/debug-93066.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
+
+struct S {
+  void f() {
+++this; // expected-error {{expression is not assignable}}
+// expected-note@-1 {{add '*' to dereference it}}
+  }
+
+  void g() const {
+++this; // expected-error {{expression is not assignable}}
+  }
+};
+
+void f(int* a, int* const b, const int* const c, __UINTPTR_TYPE__ d) {
+  (int*)d = 4; // expected-error {{assignment to cast is illegal, lvalue casts 
are not supported}}
+  // expected-note@-1 {{add '*' to dereference it}}
+
+  ++a;
+  ++b; // expected-error {{cannot assign to variable 'b' with const-qualified 
type 'int *const'}}
+  // expected-note@-1 {{add '*' to dereference it}}
+  // expected-note@* {{variable 'b' declared const here}}
+  ++c; // expected-error {{cannot assign 

[clang] Clang-Refactor (PR #94855)

2024-06-08 Thread Сергеев Игнатий via cfe-commits

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


[clang] Clang-Refactor (PR #94855)

2024-06-08 Thread via cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Clang-Refactor (PR #94855)

2024-06-08 Thread via cfe-commits
=?utf-8?b?0JjQs9C90LDRgiDQodC10YDQsw=?=,
=?utf-8?b?0JjQs9C90LDRgiDQodC10YDQsw=?Message-ID:
In-Reply-To: 


github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] Clang-Refactor (PR #94855)

2024-06-08 Thread Сергеев Игнатий via cfe-commits

https://github.com/IgnatSergeev created 
https://github.com/llvm/llvm-project/pull/94855

None

From d206a7e8fd690ce9d97a5f0278d0347d59d0c18d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=98=D0=B3=D0=BD=D0=B0=D1=82=20=D0=A1=D0=B5=D1=80=D0=B3?=
 =?UTF-8?q?=D0=B5=D0=B5=D0=B2?= 
Date: Mon, 27 May 2024 19:43:11 +
Subject: [PATCH 1/3] Merge branch '1-source-location-requirement' into
 'dev-rk'

Added source location requirement

See merge request llvm/llvm-project!6

(cherry picked from commit ff149ddaae4fc2a89879b16fc754ba5094adfc8b)

083b626e Added source location requirement
424b878c Added source location requirement
25c29ca9 Added source location argument
6e7a40da Removed test argument
e5bb6ef4 Added parse
41b4b3b2 Removed test support argument
8e40aa48 Added hasLoctionRequirement
75067db6 Fixed multiple definitions
---
 .../clang/Basic/DiagnosticRefactoringKinds.td|  2 ++
 .../Tooling/Refactoring/RefactoringActionRule.h  |  4 
 .../Refactoring/RefactoringActionRuleRequirements.h  | 11 +++
 .../Refactoring/RefactoringActionRulesInternal.h |  5 +
 .../Tooling/Refactoring/RefactoringRuleContext.h | 12 
 5 files changed, 34 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticRefactoringKinds.td 
b/clang/include/clang/Basic/DiagnosticRefactoringKinds.td
index 5446b32efbdd4..da35eae93df9a 100644
--- a/clang/include/clang/Basic/DiagnosticRefactoringKinds.td
+++ b/clang/include/clang/Basic/DiagnosticRefactoringKinds.td
@@ -28,6 +28,8 @@ def err_refactor_extract_simple_expression : Error<"the 
selected expression "
 def err_refactor_extract_prohibited_expression : Error<"the selected "
   "expression can't be extracted">;
 
+def err_refactor_no_location : Error<"refactoring action can't be initiated "
+  "without a location">;
 }
 
 } // end of Refactoring diagnostics
diff --git a/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h 
b/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
index c6a6c4f6093a3..374f19d6d8233 100644
--- a/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
+++ b/clang/include/clang/Tooling/Refactoring/RefactoringActionRule.h
@@ -56,6 +56,10 @@ class RefactoringActionRule : public 
RefactoringActionRuleBase {
   /// to be fulfilled before refactoring can be performed.
   virtual bool hasSelectionRequirement() = 0;
 
+  /// Returns true when the rule has a source location requirement that has
+  /// to be fulfilled before refactoring can be performed.
+  virtual bool hasLocationRequirement() = 0;
+
   /// Traverses each refactoring option used by the rule and invokes the
   /// \c visit callback in the consumer for each option.
   ///
diff --git 
a/clang/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h 
b/clang/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
index 1a318da3acca1..fe7f96064b81c 100644
--- 
a/clang/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
+++ 
b/clang/include/clang/Tooling/Refactoring/RefactoringActionRuleRequirements.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLING_REFACTORING_REFACTORINGACTIONRULEREQUIREMENTS_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Tooling/Refactoring/ASTSelection.h"
 #include "clang/Tooling/Refactoring/RefactoringDiagnostic.h"
 #include "clang/Tooling/Refactoring/RefactoringOption.h"
@@ -77,6 +78,16 @@ class CodeRangeASTSelectionRequirement : public 
ASTSelectionRequirement {
   evaluate(RefactoringRuleContext ) const;
 };
 
+/// A base class for any requirement that expects source code position (or the 
refactoring tool with the -location option).
+class SourceLocationRequirement : public RefactoringActionRuleRequirement {
+public:
+  Expected evaluate(RefactoringRuleContext ) const {
+if (Context.getLocation().isValid())
+  return Context.getLocation();
+return Context.createDiagnosticError(diag::err_refactor_no_location);
+  }
+};
+
 /// A base class for any requirement that requires some refactoring options.
 class RefactoringOptionsRequirement : public RefactoringActionRuleRequirement {
 public:
diff --git 
a/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h 
b/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
index 33194c401ea14..52afb012f4874 100644
--- a/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
+++ b/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h
@@ -139,6 +139,11 @@ createRefactoringActionRule(const RequirementTypes &... 
Requirements) {
  RequirementTypes...>::value;
 }
 
+bool hasLocationRequirement() override {
+  return internal::HasBaseOf::value;
+}
+
 void visitRefactoringOptions(RefactoringOptionVisitor ) override {
   internal::visitRefactoringOptions(
   Visitor, Requirements,
diff --git 

[clang] [Clang][C++23] update constexpr diagnostics for missing return statements per P2448 (PR #94123)

2024-06-08 Thread Oleksandr T. via cfe-commits

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

>From 90eeafc82ee08129c2d290e6382f42ec89680049 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 2 Jun 2024 00:07:35 +0300
Subject: [PATCH 1/3] feat(92583): [C++23] update constexpr diagnostics for
 missing return statements per P2448

---
 clang/lib/Sema/SemaDeclCXX.cpp| 34 ---
 .../CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp |  2 +-
 .../SemaCXX/constant-expression-cxx14.cpp |  2 +-
 .../constexpr-return-non-void-cxx2b.cpp   |  7 
 4 files changed, 31 insertions(+), 14 deletions(-)
 create mode 100644 clang/test/SemaCXX/constexpr-return-non-void-cxx2b.cpp

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 631fd4e354927..d4401a427282c 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1806,6 +1806,7 @@ static unsigned getRecordDiagFromTagKind(TagTypeKind Tag) 
{
 static bool CheckConstexprFunctionBody(Sema , const FunctionDecl *Dcl,
Stmt *Body,
Sema::CheckConstexprKind Kind);
+static bool CheckConstexprMissingReturn(Sema , const FunctionDecl 
*Dcl);
 
 // Check whether a function declaration satisfies the requirements of a
 // constexpr function definition or a constexpr constructor definition. If so,
@@ -2411,20 +2412,9 @@ static bool CheckConstexprFunctionBody(Sema , 
const FunctionDecl *Dcl,
 }
   } else {
 if (ReturnStmts.empty()) {
-  // C++1y doesn't require constexpr functions to contain a 'return'
-  // statement. We still do, unless the return type might be void, because
-  // otherwise if there's no return statement, the function cannot
-  // be used in a core constant expression.
-  bool OK = SemaRef.getLangOpts().CPlusPlus14 &&
-(Dcl->getReturnType()->isVoidType() ||
- Dcl->getReturnType()->isDependentType());
   switch (Kind) {
   case Sema::CheckConstexprKind::Diagnose:
-SemaRef.Diag(Dcl->getLocation(),
- OK ? diag::warn_cxx11_compat_constexpr_body_no_return
-: diag::err_constexpr_body_no_return)
-<< Dcl->isConsteval();
-if (!OK)
+if (!CheckConstexprMissingReturn(SemaRef, Dcl))
   return false;
 break;
 
@@ -2487,6 +2477,26 @@ static bool CheckConstexprFunctionBody(Sema , 
const FunctionDecl *Dcl,
   return true;
 }
 
+static bool CheckConstexprMissingReturn(Sema ,
+const FunctionDecl *Dcl) {
+  bool IsVoidOrDependentType = Dcl->getReturnType()->isVoidType() ||
+   Dcl->getReturnType()->isDependentType();
+
+  if (SemaRef.getLangOpts().CPlusPlus23 && !IsVoidOrDependentType)
+return true;
+
+  // C++1y doesn't require constexpr functions to contain a 'return'
+  // statement. We still do, unless the return type might be void, because
+  // otherwise if there's no return statement, the function cannot
+  // be used in a core constant expression.
+  bool OK = SemaRef.getLangOpts().CPlusPlus14 && IsVoidOrDependentType;
+  SemaRef.Diag(Dcl->getLocation(),
+   OK ? diag::warn_cxx11_compat_constexpr_body_no_return
+  : diag::err_constexpr_body_no_return)
+  << Dcl->isConsteval();
+  return OK;
+}
+
 bool Sema::CheckImmediateEscalatingFunctionDefinition(
 FunctionDecl *FD, const sema::FunctionScopeInfo *FSI) {
   if (!getLangOpts().CPlusPlus20 || !FD->isImmediateEscalating())
diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
index 4416c82522649..51990ee4341d2 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -212,7 +212,7 @@ constexpr int ClassDecl3() {
   return 0;
 }
 
-constexpr int NoReturn() {} // expected-error {{no return statement in 
constexpr function}}
+constexpr int NoReturn() {} // beforecxx23-error {{no return statement in 
constexpr function}}
 constexpr int MultiReturn() {
   return 0; // beforecxx14-note {{return statement}}
   return 0; // beforecxx14-warning {{multiple return statements in constexpr 
function}}
diff --git a/clang/test/SemaCXX/constant-expression-cxx14.cpp 
b/clang/test/SemaCXX/constant-expression-cxx14.cpp
index 80a7a2dd31531..70ab5dcd357c1 100644
--- a/clang/test/SemaCXX/constant-expression-cxx14.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx14.cpp
@@ -82,7 +82,7 @@ constexpr void k() {
 
 // If the return type is not 'void', no return statements => never a constant
 // expression, so still diagnose that case.
-[[noreturn]] constexpr int fn() { // expected-error {{no return statement in 
constexpr function}}
+[[noreturn]] constexpr int fn() { // cxx14_20-error {{no return statement in 
constexpr function}}
   fn();
 }
 
diff --git 

[clang] [llvm] Enable LLDB tests in Linux pre-merge CI (PR #94208)

2024-06-08 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [llvm] Enable LLDB tests in Linux pre-merge CI (PR #94208)

2024-06-08 Thread Matheus Izvekov via cfe-commits

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


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


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-08 Thread Braden Helmer via cfe-commits

https://github.com/bradenhelmer updated 
https://github.com/llvm/llvm-project/pull/94827

>From 317e4c2fe7fb0ee76f7917b64ee447ba3ed838bc Mon Sep 17 00:00:00 2001
From: Braden Helmer 
Date: Fri, 7 Jun 2024 21:38:04 -0400
Subject: [PATCH] Implement -Wmissing-include-dirs

---
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
 clang/include/clang/Basic/DiagnosticGroups.td  | 2 +-
 clang/lib/Driver/Driver.cpp| 6 ++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 773b234cd68fe..b7d50e22cc0d0 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -809,4 +809,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def warn_missing_include_dirs : Warning <
+   "the included directory %0 is missing">, InGroup;
 }
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d5ba7869ec34..9b37d4bd3205b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -506,7 +506,7 @@ def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
 def : DiagGroup<"missing-format-attribute">;
-def : DiagGroup<"missing-include-dirs">;
+def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
 def : DiagGroup<"nested-externs">;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..5bc737a43338e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,6 +1271,12 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
+  // Check for missing include directories
+  for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+if (!llvm::sys::fs::is_directory(IncludeDir))
+  Diag(diag::warn_missing_include_dirs) << IncludeDir;
+  }
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 

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


[clang] [Clang] Swap range metadata to attribute for intrinsics. (PR #94851)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Andreas Jonson (andjo403)


Changes

Continues to swap out range metadata to range attribute for calls to be able to 
deprecate range metadata on calls in the future

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


3 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+8-10) 
- (modified) clang/test/CodeGenOpenCL/builtins-amdgcn.cl (+3-4) 
- (modified) clang/test/CodeGenOpenCL/builtins-r600.cl (+3-4) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c16b69ba87567..e053e1a46cbb1 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -734,17 +734,15 @@ static llvm::Value *EmitOverflowIntrinsic(CodeGenFunction 
,
   return CGF.Builder.CreateExtractValue(Tmp, 0);
 }
 
-static Value *emitRangedBuiltin(CodeGenFunction ,
-unsigned IntrinsicID,
+static Value *emitRangedBuiltin(CodeGenFunction , unsigned IntrinsicID,
 int low, int high) {
-llvm::MDBuilder MDHelper(CGF.getLLVMContext());
-llvm::MDNode *RNode = MDHelper.createRange(APInt(32, low), APInt(32, 
high));
-Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
-llvm::Instruction *Call = CGF.Builder.CreateCall(F);
-Call->setMetadata(llvm::LLVMContext::MD_range, RNode);
-Call->setMetadata(llvm::LLVMContext::MD_noundef,
-  llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
-return Call;
+  Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
+  llvm::CallInst *Call = CGF.Builder.CreateCall(F);
+  llvm::ConstantRange CR(APInt(32, low), APInt(32, high));
+  Call->addRangeRetAttr(CR);
+  Call->setMetadata(llvm::LLVMContext::MD_noundef,
+llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
+  return Call;
 }
 
 namespace {
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index ffc190b76db98..121d1f15449e3 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -605,9 +605,9 @@ void test_s_getreg(volatile global uint *out)
 }
 
 // CHECK-LABEL: @test_get_local_id(
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.x(), !range 
[[$WI_RANGE:![0-9]*]], !noundef
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.y(), !range 
[[$WI_RANGE]], !noundef
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.z(), !range 
[[$WI_RANGE]], !noundef
+// CHECK: tail call range(i32 0, 1024){{.*}} i32 @llvm.amdgcn.workitem.id.x(), 
!noundef
+// CHECK: tail call range(i32 0, 1024){{.*}} i32 @llvm.amdgcn.workitem.id.y(), 
!noundef
+// CHECK: tail call range(i32 0, 1024{{.*}}) i32 @llvm.amdgcn.workitem.id.z(), 
!noundef
 void test_get_local_id(int d, global int *out)
 {
switch (d) {
@@ -891,6 +891,5 @@ void test_set_fpenv(unsigned long env) {
   __builtin_amdgcn_set_fpenv(env);
 }
 
-// CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { convergent mustprogress 
nocallback nofree nounwind willreturn memory(none) }
diff --git a/clang/test/CodeGenOpenCL/builtins-r600.cl 
b/clang/test/CodeGenOpenCL/builtins-r600.cl
index c6b40f079b3f2..e9d60be2ee444 100644
--- a/clang/test/CodeGenOpenCL/builtins-r600.cl
+++ b/clang/test/CodeGenOpenCL/builtins-r600.cl
@@ -39,9 +39,9 @@ void test_get_group_id(int d, global int *out)
 }
 
 // CHECK-LABEL: @test_get_local_id(
-// CHECK: tail call i32 @llvm.r600.read.tidig.x(), !range [[WI_RANGE:![0-9]*]]
-// CHECK: tail call i32 @llvm.r600.read.tidig.y(), !range [[WI_RANGE]]
-// CHECK: tail call i32 @llvm.r600.read.tidig.z(), !range [[WI_RANGE]]
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.x()
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.y()
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.z()
 void test_get_local_id(int d, global int *out)
 {
switch (d) {
@@ -52,4 +52,3 @@ void test_get_local_id(int d, global int *out)
}
 }
 
-// CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 1024}

``




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


[clang] [Clang] Swap range metadata to attribute for intrinsics. (PR #94851)

2024-06-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Andreas Jonson (andjo403)


Changes

Continues to swap out range metadata to range attribute for calls to be able to 
deprecate range metadata on calls in the future

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


3 Files Affected:

- (modified) clang/lib/CodeGen/CGBuiltin.cpp (+8-10) 
- (modified) clang/test/CodeGenOpenCL/builtins-amdgcn.cl (+3-4) 
- (modified) clang/test/CodeGenOpenCL/builtins-r600.cl (+3-4) 


``diff
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c16b69ba87567..e053e1a46cbb1 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -734,17 +734,15 @@ static llvm::Value *EmitOverflowIntrinsic(CodeGenFunction 
,
   return CGF.Builder.CreateExtractValue(Tmp, 0);
 }
 
-static Value *emitRangedBuiltin(CodeGenFunction ,
-unsigned IntrinsicID,
+static Value *emitRangedBuiltin(CodeGenFunction , unsigned IntrinsicID,
 int low, int high) {
-llvm::MDBuilder MDHelper(CGF.getLLVMContext());
-llvm::MDNode *RNode = MDHelper.createRange(APInt(32, low), APInt(32, 
high));
-Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
-llvm::Instruction *Call = CGF.Builder.CreateCall(F);
-Call->setMetadata(llvm::LLVMContext::MD_range, RNode);
-Call->setMetadata(llvm::LLVMContext::MD_noundef,
-  llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
-return Call;
+  Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
+  llvm::CallInst *Call = CGF.Builder.CreateCall(F);
+  llvm::ConstantRange CR(APInt(32, low), APInt(32, high));
+  Call->addRangeRetAttr(CR);
+  Call->setMetadata(llvm::LLVMContext::MD_noundef,
+llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
+  return Call;
 }
 
 namespace {
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index ffc190b76db98..121d1f15449e3 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -605,9 +605,9 @@ void test_s_getreg(volatile global uint *out)
 }
 
 // CHECK-LABEL: @test_get_local_id(
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.x(), !range 
[[$WI_RANGE:![0-9]*]], !noundef
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.y(), !range 
[[$WI_RANGE]], !noundef
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.z(), !range 
[[$WI_RANGE]], !noundef
+// CHECK: tail call range(i32 0, 1024){{.*}} i32 @llvm.amdgcn.workitem.id.x(), 
!noundef
+// CHECK: tail call range(i32 0, 1024){{.*}} i32 @llvm.amdgcn.workitem.id.y(), 
!noundef
+// CHECK: tail call range(i32 0, 1024{{.*}}) i32 @llvm.amdgcn.workitem.id.z(), 
!noundef
 void test_get_local_id(int d, global int *out)
 {
switch (d) {
@@ -891,6 +891,5 @@ void test_set_fpenv(unsigned long env) {
   __builtin_amdgcn_set_fpenv(env);
 }
 
-// CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { convergent mustprogress 
nocallback nofree nounwind willreturn memory(none) }
diff --git a/clang/test/CodeGenOpenCL/builtins-r600.cl 
b/clang/test/CodeGenOpenCL/builtins-r600.cl
index c6b40f079b3f2..e9d60be2ee444 100644
--- a/clang/test/CodeGenOpenCL/builtins-r600.cl
+++ b/clang/test/CodeGenOpenCL/builtins-r600.cl
@@ -39,9 +39,9 @@ void test_get_group_id(int d, global int *out)
 }
 
 // CHECK-LABEL: @test_get_local_id(
-// CHECK: tail call i32 @llvm.r600.read.tidig.x(), !range [[WI_RANGE:![0-9]*]]
-// CHECK: tail call i32 @llvm.r600.read.tidig.y(), !range [[WI_RANGE]]
-// CHECK: tail call i32 @llvm.r600.read.tidig.z(), !range [[WI_RANGE]]
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.x()
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.y()
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.z()
 void test_get_local_id(int d, global int *out)
 {
switch (d) {
@@ -52,4 +52,3 @@ void test_get_local_id(int d, global int *out)
}
 }
 
-// CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 1024}

``




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


[clang] [Clang] Swap range metadata to attribute for intrinsics. (PR #94851)

2024-06-08 Thread Andreas Jonson via cfe-commits

https://github.com/andjo403 created 
https://github.com/llvm/llvm-project/pull/94851

Continues to swap out range metadata to range attribute for calls to be able to 
deprecate range metadata on calls in the future

>From 6b4556ea373d90a780c132ab2c51ae46d40a3f49 Mon Sep 17 00:00:00 2001
From: Andreas Jonson 
Date: Sun, 26 May 2024 10:02:25 +0200
Subject: [PATCH] [Clang] swap range metadata to attribute for Intrinsics.

---
 clang/lib/CodeGen/CGBuiltin.cpp | 18 --
 clang/test/CodeGenOpenCL/builtins-amdgcn.cl |  7 +++
 clang/test/CodeGenOpenCL/builtins-r600.cl   |  7 +++
 3 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index c16b69ba87567..e053e1a46cbb1 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -734,17 +734,15 @@ static llvm::Value *EmitOverflowIntrinsic(CodeGenFunction 
,
   return CGF.Builder.CreateExtractValue(Tmp, 0);
 }
 
-static Value *emitRangedBuiltin(CodeGenFunction ,
-unsigned IntrinsicID,
+static Value *emitRangedBuiltin(CodeGenFunction , unsigned IntrinsicID,
 int low, int high) {
-llvm::MDBuilder MDHelper(CGF.getLLVMContext());
-llvm::MDNode *RNode = MDHelper.createRange(APInt(32, low), APInt(32, 
high));
-Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
-llvm::Instruction *Call = CGF.Builder.CreateCall(F);
-Call->setMetadata(llvm::LLVMContext::MD_range, RNode);
-Call->setMetadata(llvm::LLVMContext::MD_noundef,
-  llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
-return Call;
+  Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
+  llvm::CallInst *Call = CGF.Builder.CreateCall(F);
+  llvm::ConstantRange CR(APInt(32, low), APInt(32, high));
+  Call->addRangeRetAttr(CR);
+  Call->setMetadata(llvm::LLVMContext::MD_noundef,
+llvm::MDNode::get(CGF.getLLVMContext(), std::nullopt));
+  return Call;
 }
 
 namespace {
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index ffc190b76db98..121d1f15449e3 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -605,9 +605,9 @@ void test_s_getreg(volatile global uint *out)
 }
 
 // CHECK-LABEL: @test_get_local_id(
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.x(), !range 
[[$WI_RANGE:![0-9]*]], !noundef
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.y(), !range 
[[$WI_RANGE]], !noundef
-// CHECK: tail call{{.*}} i32 @llvm.amdgcn.workitem.id.z(), !range 
[[$WI_RANGE]], !noundef
+// CHECK: tail call range(i32 0, 1024){{.*}} i32 @llvm.amdgcn.workitem.id.x(), 
!noundef
+// CHECK: tail call range(i32 0, 1024){{.*}} i32 @llvm.amdgcn.workitem.id.y(), 
!noundef
+// CHECK: tail call range(i32 0, 1024{{.*}}) i32 @llvm.amdgcn.workitem.id.z(), 
!noundef
 void test_get_local_id(int d, global int *out)
 {
switch (d) {
@@ -891,6 +891,5 @@ void test_set_fpenv(unsigned long env) {
   __builtin_amdgcn_set_fpenv(env);
 }
 
-// CHECK-DAG: [[$WI_RANGE]] = !{i32 0, i32 1024}
 // CHECK-DAG: [[$WS_RANGE]] = !{i16 1, i16 1025}
 // CHECK-DAG: attributes #[[$NOUNWIND_READONLY]] = { convergent mustprogress 
nocallback nofree nounwind willreturn memory(none) }
diff --git a/clang/test/CodeGenOpenCL/builtins-r600.cl 
b/clang/test/CodeGenOpenCL/builtins-r600.cl
index c6b40f079b3f2..e9d60be2ee444 100644
--- a/clang/test/CodeGenOpenCL/builtins-r600.cl
+++ b/clang/test/CodeGenOpenCL/builtins-r600.cl
@@ -39,9 +39,9 @@ void test_get_group_id(int d, global int *out)
 }
 
 // CHECK-LABEL: @test_get_local_id(
-// CHECK: tail call i32 @llvm.r600.read.tidig.x(), !range [[WI_RANGE:![0-9]*]]
-// CHECK: tail call i32 @llvm.r600.read.tidig.y(), !range [[WI_RANGE]]
-// CHECK: tail call i32 @llvm.r600.read.tidig.z(), !range [[WI_RANGE]]
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.x()
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.y()
+// CHECK: tail call range(i32 0, 1024) i32 @llvm.r600.read.tidig.z()
 void test_get_local_id(int d, global int *out)
 {
switch (d) {
@@ -52,4 +52,3 @@ void test_get_local_id(int d, global int *out)
}
 }
 
-// CHECK-DAG: [[WI_RANGE]] = !{i32 0, i32 1024}

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


[clang-tools-extra] [clang-tidy] Ignore non-math operators in readability-math-missing-parentheses (PR #94654)

2024-06-08 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL updated 
https://github.com/llvm/llvm-project/pull/94654

>From 5d37ba1925696582d752a45ceec605c8b6277543 Mon Sep 17 00:00:00 2001
From: Piotr Zegar 
Date: Thu, 6 Jun 2024 18:17:55 +
Subject: [PATCH] [clang-tidy] Ignore non-math operators in
 readability-math-missing-parentheses

Do not emit warnings for non-math operators.

Closes #92516
---
 .../readability/MathMissingParenthesesCheck.cpp |  3 ++-
 .../readability/math-missing-parentheses.cpp| 17 +
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git 
a/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
index 65fd296094915..64ce94e3fc1db 100644
--- a/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
@@ -57,7 +57,8 @@ static void addParantheses(const BinaryOperator *BinOp,
   int Precedence1 = getPrecedence(BinOp);
   int Precedence2 = getPrecedence(ParentBinOp);
 
-  if (ParentBinOp != nullptr && Precedence1 != Precedence2) {
+  if (ParentBinOp != nullptr && Precedence1 != Precedence2 && Precedence1 > 0 
&&
+  Precedence2 > 0) {
 const clang::SourceLocation StartLoc = BinOp->getBeginLoc();
 const clang::SourceLocation EndLoc =
 clang::Lexer::getLocForEndOfToken(BinOp->getEndLoc(), 0, SM, LangOpts);
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability/math-missing-parentheses.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability/math-missing-parentheses.cpp
index a6045c079a482..4face0bb3fe68 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability/math-missing-parentheses.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability/math-missing-parentheses.cpp
@@ -140,3 +140,20 @@ void f(){
 //CHECK-MESSAGES: :[[@LINE+1]]:13: warning: '*' has higher precedence than 
'+'; add parentheses to explicitly specify the order of operations 
[readability-math-missing-parentheses]
 int v = FUN5(0 + 1);
 }
+
+namespace PR92516 {
+  void f(int i) {
+int j, k;
+for (j = i + 1, k = 0; j < 1; ++j) {}
+  }
+
+  void f2(int i) {
+int j;
+for (j = i + 1; j < 1; ++j) {}
+  }
+
+  void f3(int i) {
+int j;
+for (j = i + 1, 2; j < 1; ++j) {}
+  }
+}

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


[clang] [llvm] [APFloat] Add APFloat support for FP6 data types (PR #94735)

2024-06-08 Thread Durgadoss R via cfe-commits


@@ -68,6 +68,10 @@ enum class fltNonfiniteBehavior {
   // `fltNanEncoding` enum. We treat all NaNs as quiet, as the available
   // encodings do not distinguish between signalling and quiet NaN.
   NanOnly,
+
+  // This behavior is present in Float6E3M2FN and Float6E2M3FN types.
+  // There is no representation for Inf or NaN.
+  NoNanInf,

durga4github wrote:

@kuhar , I updated the naming to "FiniteOnly" in the latest revision. Please 
let me know if it's good to go.


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


[clang] [llvm] Enable LLDB tests in Linux pre-merge CI (PR #94208)

2024-06-08 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> How will this affect test capacity?

Evidence is anecdotal, but we're looking at about 4 more minutes on Linux CI.

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


[clang] [llvm] [APFloat] Add APFloat support for FP6 data types (PR #94735)

2024-06-08 Thread Durgadoss R via cfe-commits

https://github.com/durga4github updated 
https://github.com/llvm/llvm-project/pull/94735

>From 2ee13938a4428948ae6fdeb82de6e0c15e2dd9f8 Mon Sep 17 00:00:00 2001
From: Durgadoss R 
Date: Wed, 5 Jun 2024 19:22:31 +0530
Subject: [PATCH] [APFloat] Add APFloat support for FP6 data types

This patch adds APFloat type support for two FP6
data types, E2M3 and E3M2. The definitions for the
two formats are detailed in section 5.3.2 of the
OCP specification, which can be accessed here:
https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf

Signed-off-by: Durgadoss R 
---
 clang/lib/AST/MicrosoftMangle.cpp  |   2 +
 llvm/include/llvm/ADT/APFloat.h|  25 ++
 llvm/lib/Support/APFloat.cpp   |  87 +-
 llvm/unittests/ADT/APFloatTest.cpp | 484 +++--
 4 files changed, 563 insertions(+), 35 deletions(-)

diff --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 36d611750ca48..72c79dab6bdcc 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -899,6 +899,8 @@ void MicrosoftCXXNameMangler::mangleFloat(llvm::APFloat 
Number) {
   case APFloat::S_Float8E4M3FNUZ:
   case APFloat::S_Float8E4M3B11FNUZ:
   case APFloat::S_FloatTF32:
+  case APFloat::S_Float6E3M2FN:
+  case APFloat::S_Float6E2M3FN:
 llvm_unreachable("Tried to mangle unexpected APFloat semantics");
   }
 
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index 44a301ecc9928..35d6d88013e9e 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -189,6 +189,14 @@ struct APFloatBase {
 // improved range compared to half (16-bit) formats, at (potentially)
 // greater throughput than single precision (32-bit) formats.
 S_FloatTF32,
+// 6-bit floating point number with bit layout S1E3M2. Unlike IEEE-754
+// types, there are no infinity or NaN values. The format is detailed in
+// 
https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf
+S_Float6E3M2FN,
+// 6-bit floating point number with bit layout S1E2M3. Unlike IEEE-754
+// types, there are no infinity or NaN values. The format is detailed in
+// 
https://www.opencompute.org/documents/ocp-microscaling-formats-mx-v1-0-spec-final-pdf
+S_Float6E2M3FN,
 
 S_x87DoubleExtended,
 S_MaxSemantics = S_x87DoubleExtended,
@@ -209,6 +217,8 @@ struct APFloatBase {
   static const fltSemantics () LLVM_READNONE;
   static const fltSemantics () LLVM_READNONE;
   static const fltSemantics () LLVM_READNONE;
+  static const fltSemantics () LLVM_READNONE;
+  static const fltSemantics () LLVM_READNONE;
   static const fltSemantics () LLVM_READNONE;
 
   /// A Pseudo fltsemantic used to construct APFloats that cannot conflict with
@@ -627,6 +637,8 @@ class IEEEFloat final : public APFloatBase {
   APInt convertFloat8E4M3FNUZAPFloatToAPInt() const;
   APInt convertFloat8E4M3B11FNUZAPFloatToAPInt() const;
   APInt convertFloatTF32APFloatToAPInt() const;
+  APInt convertFloat6E3M2FNAPFloatToAPInt() const;
+  APInt convertFloat6E2M3FNAPFloatToAPInt() const;
   void initFromAPInt(const fltSemantics *Sem, const APInt );
   template  void initFromIEEEAPInt(const APInt );
   void initFromHalfAPInt(const APInt );
@@ -642,6 +654,8 @@ class IEEEFloat final : public APFloatBase {
   void initFromFloat8E4M3FNUZAPInt(const APInt );
   void initFromFloat8E4M3B11FNUZAPInt(const APInt );
   void initFromFloatTF32APInt(const APInt );
+  void initFromFloat6E3M2FNAPInt(const APInt );
+  void initFromFloat6E2M3FNAPInt(const APInt );
 
   void assign(const IEEEFloat &);
   void copySignificand(const IEEEFloat &);
@@ -1039,6 +1053,17 @@ class APFloat : public APFloatBase {
   /// \param Semantics - type float semantics
   static APFloat getAllOnesValue(const fltSemantics );
 
+  static bool hasNanOrInf(const fltSemantics ) {
+switch (SemanticsToEnum(Sem)) {
+default:
+  return true;
+// Below Semantics do not support {NaN or Inf}
+case APFloat::S_Float6E3M2FN:
+case APFloat::S_Float6E2M3FN:
+  return false;
+}
+  }
+
   /// Used to insert APFloat objects, or objects that contain APFloat objects,
   /// into FoldingSets.
   void Profile(FoldingSetNodeID ) const;
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index 283fcc153b33a..1209bf71a287d 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -68,6 +68,10 @@ enum class fltNonfiniteBehavior {
   // `fltNanEncoding` enum. We treat all NaNs as quiet, as the available
   // encodings do not distinguish between signalling and quiet NaN.
   NanOnly,
+
+  // This behavior is present in Float6E3M2FN and Float6E2M3FN types,
+  // which do not support Inf or NaN values.
+  FiniteOnly,
 };
 
 // How NaN values are represented. This is curently only used in combination
@@ -139,6 +143,10 @@ static constexpr fltSemantics semFloat8E4M3FNUZ = {
 static constexpr 

[clang] [clang] Report erroneous floating point results in _Complex math (PR #90588)

2024-06-08 Thread Timm Baeder via cfe-commits

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


[clang] 9ddc014 - [clang] Report erroneous floating point results in _Complex math (#90588)

2024-06-08 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-06-08T11:20:31+02:00
New Revision: 9ddc014f1a588608af1f08051d084c5839a41a80

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

LOG: [clang] Report erroneous floating point results in _Complex math (#90588)

Use handleFloatFloatBinOp to properly diagnose NaN results and divisions
by zero.

Fixes #84871

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/complex-folding.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index f1aa19e4409e1..86fb396fabe2d 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15209,11 +15209,21 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const 
BinaryOperator *E) {
   APFloat  = Result.getComplexFloatImag();
   if (LHSReal) {
 assert(!RHSReal && "Cannot have two real operands for a complex op!");
-ResR = A * C;
-ResI = A * D;
+ResR = A;
+ResI = A;
+// ResR = A * C;
+// ResI = A * D;
+if (!handleFloatFloatBinOp(Info, E, ResR, BO_Mul, C) ||
+!handleFloatFloatBinOp(Info, E, ResI, BO_Mul, D))
+  return false;
   } else if (RHSReal) {
-ResR = C * A;
-ResI = C * B;
+// ResR = C * A;
+// ResI = C * B;
+ResR = C;
+ResI = C;
+if (!handleFloatFloatBinOp(Info, E, ResR, BO_Mul, A) ||
+!handleFloatFloatBinOp(Info, E, ResI, BO_Mul, B))
+  return false;
   } else {
 // In the fully general case, we need to handle NaNs and infinities
 // robustly.
@@ -15289,8 +15299,13 @@ bool ComplexExprEvaluator::VisitBinaryOperator(const 
BinaryOperator *E) {
   APFloat  = Result.getComplexFloatReal();
   APFloat  = Result.getComplexFloatImag();
   if (RHSReal) {
-ResR = A / C;
-ResI = B / C;
+ResR = A;
+ResI = B;
+// ResR = A / C;
+// ResI = B / C;
+if (!handleFloatFloatBinOp(Info, E, ResR, BO_Div, C) ||
+!handleFloatFloatBinOp(Info, E, ResI, BO_Div, C))
+  return false;
   } else {
 if (LHSReal) {
   // No real optimizations we can do here, stub out with zero.

diff  --git a/clang/test/SemaCXX/complex-folding.cpp 
b/clang/test/SemaCXX/complex-folding.cpp
index 054f159e9ce0d..7bfd36f156ea6 100644
--- a/clang/test/SemaCXX/complex-folding.cpp
+++ b/clang/test/SemaCXX/complex-folding.cpp
@@ -59,41 +59,48 @@ static_assert((1.25 / (0.25 - 0.75j)) == (0.5 + 1.5j));
 
 // Test that infinities are preserved, don't turn into NaNs, and do form zeros
 // when the divisor.
+constexpr _Complex float InfC = {1.0, __builtin_inf()};
+constexpr _Complex float InfInf = __builtin_inf() + InfC;
+static_assert(__real__(InfInf) == __builtin_inf());
+static_assert(__imag__(InfInf) == __builtin_inf());
+static_assert(__builtin_isnan(__real__(InfInf * InfInf)));
+static_assert(__builtin_isinf_sign(__imag__(InfInf * InfInf)) == 1);
+
 static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * 1.0)) 
== 1);
-static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) * 
1.0)) == 1);
+static_assert(__builtin_isinf_sign(__imag__((1.0 + InfC) * 1.0)) == 1);
 static_assert(__builtin_isinf_sign(__real__(1.0 * (__builtin_inf() + 1.0j))) 
== 1);
-static_assert(__builtin_isinf_sign(__imag__(1.0 * (1.0 + __builtin_inf() * 
1.0j))) == 1);
-
+static_assert(__builtin_isinf_sign(__imag__(1.0 * (1.0 + InfC))) == 1);
 static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * (1.0 + 
1.0j))) == 1);
 static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) * (__builtin_inf() + 
1.0j))) == 1);
 static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + 1.0j) * 
(__builtin_inf() + 1.0j))) == 1);
-
-static_assert(__builtin_isinf_sign(__real__((1.0 + __builtin_inf() * 1.0j) * 
(1.0 + 1.0j))) == -1);
-static_assert(__builtin_isinf_sign(__imag__((1.0 + __builtin_inf() * 1.0j) * 
(1.0 + 1.0j))) == 1);
-static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) * (1.0 + 
__builtin_inf() * 1.0j))) == -1);
-static_assert(__builtin_isinf_sign(__imag__((1.0 + 1.0j) * (1.0 + 
__builtin_inf() * 1.0j))) == 1);
-
-static_assert(__builtin_isinf_sign(__real__((1.0 + __builtin_inf() * 1.0j) * 
(1.0 + __builtin_inf() * 1.0j))) == -1);
-static_assert(__builtin_isinf_sign(__real__((__builtin_inf() + __builtin_inf() 
* 1.0j) * (__builtin_inf() + __builtin_inf() * 1.0j))) == -1);
-
+static_assert(__builtin_isinf_sign(__real__((1.0 + InfC) * (1.0 + 1.0j))) == 
-1);
+static_assert(__builtin_isinf_sign(__imag__((1.0 + InfC) * (1.0 + 1.0j))) == 
1);
+static_assert(__builtin_isinf_sign(__real__((1.0 + 1.0j) * (1.0 + InfC))) == 
-1);

[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-08 Thread via cfe-commits


@@ -1457,7 +1457,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState ) {
   !Current.isOneOf(tok::colon, tok::comment)) {
 return ContinuationIndent;
   }
-  if (Style.isCpp() && Current.is(tok::arrow) &&
+  if (Style.isCpp() && Current.is(TT_TrailingReturnArrow) &&

c8ef wrote:

Done.

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


[clang] [clang-format] fix incorrectly indents lambda trailing return (PR #94560)

2024-06-08 Thread via cfe-commits

https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/94560

>From 624e74b3066930a5a2bb15d6c0b2ddb4f94d3b79 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Thu, 6 Jun 2024 10:44:57 +0800
Subject: [PATCH 1/3] fix incorrectly indents lambda trailing return

---
 clang/lib/Format/ContinuationIndenter.cpp |  5 +
 clang/unittests/Format/FormatTest.cpp | 25 +++
 2 files changed, 30 insertions(+)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 6b9fbfe0ebf53..630a4ebff9843 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1457,6 +1457,11 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState ) {
   !Current.isOneOf(tok::colon, tok::comment)) {
 return ContinuationIndent;
   }
+  if (Style.isCpp() && Current.is(tok::arrow) &&
+  Previous.isOneOf(tok::kw_noexcept, tok::kw_mutable, tok::kw_constexpr,
+   tok::kw_consteval, tok::kw_static)) {
+return ContinuationIndent;
+  }
   if (Current.is(TT_ProtoExtensionLSquare))
 return CurrentState.Indent;
   if (Current.isBinaryOperator() && CurrentState.UnindentOperator) {
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 4e427268fb82a..d117efc06c2a7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -22858,6 +22858,31 @@ TEST_F(FormatTest, FormatsLambdas) {
   "  //\n"
   "});");
 
+  verifyFormat("int main() {\n"
+   "  very_long_function_name_yes_it_is_really_long(\n"
+   "  [](auto n)\n"
+   "  -> std::unordered_map {\n"
+   "really_do_something();\n"
+   "  });\n"
+   "}");
+  verifyFormat("int main() {\n"
+   "  very_long_function_name_yes_it_is_really_long(\n"
+   "  [](auto n) noexcept\n"
+   "  -> std::unordered_map {\n"
+   "really_do_something();\n"
+   "  });\n"
+   "}");
+  verifyFormat("int main() {\n"
+   "  very_long_function_name_yes_it_is_really_long(\n"
+   "  [](auto n) constexpr\n"
+   "  -> std::unordered_map {\n"
+   "really_do_something();\n"
+   "  });\n"
+   "}");
+
   FormatStyle DoNotMerge = getLLVMStyle();
   DoNotMerge.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
   verifyFormat("auto c = []() {\n"

>From ec319435d82f1a815206eeb51a8e6e09c5d811fe Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Fri, 7 Jun 2024 09:18:26 +0800
Subject: [PATCH 2/3] address CR issue

---
 clang/lib/Format/ContinuationIndenter.cpp |  2 +-
 clang/unittests/Format/FormatTest.cpp | 21 -
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 630a4ebff9843..9206344490b53 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1457,7 +1457,7 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState ) {
   !Current.isOneOf(tok::colon, tok::comment)) {
 return ContinuationIndent;
   }
-  if (Style.isCpp() && Current.is(tok::arrow) &&
+  if (Style.isCpp() && Current.is(TT_TrailingReturnArrow) &&
   Previous.isOneOf(tok::kw_noexcept, tok::kw_mutable, tok::kw_constexpr,
tok::kw_consteval, tok::kw_static)) {
 return ContinuationIndent;
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index d117efc06c2a7..9759d58c718b5 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -22861,27 +22861,30 @@ TEST_F(FormatTest, FormatsLambdas) {
   verifyFormat("int main() {\n"
"  very_long_function_name_yes_it_is_really_long(\n"
"  [](auto n)\n"
-   "  -> std::unordered_map {\n"
+   "  -> std::unordered_map {\n"
"really_do_something();\n"
"  });\n"
-   "}");
+   "}",
+   getLLVMStyleWithColumns(60));
   verifyFormat("int main() {\n"
"  very_long_function_name_yes_it_is_really_long(\n"
"  [](auto n) noexcept\n"
-   "  -> std::unordered_map {\n"
+   "  -> std::unordered_map {\n"
"really_do_something();\n"
"  });\n"
-   "}");
+   "}",
+   getLLVMStyleWithColumns(60));
   verifyFormat("int main() {\n"
"  very_long_function_name_yes_it_is_really_long(\n"
"  [](auto n) constexpr\n"
-   "  -> std::unordered_map {\n"
+

[clang] [llvm] Revert changes in AddDefaultGCCPrefixes() for SystemZTriples. (PR #94729)

2024-06-08 Thread Jonas Paulsson via cfe-commits

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


[clang] [llvm] [APFloat] Add APFloat support for FP6 data types (PR #94735)

2024-06-08 Thread Durgadoss R via cfe-commits


@@ -68,6 +68,10 @@ enum class fltNonfiniteBehavior {
   // `fltNanEncoding` enum. We treat all NaNs as quiet, as the available
   // encodings do not distinguish between signalling and quiet NaN.
   NanOnly,
+
+  // This behavior is present in Float6E3M2FN and Float6E2M3FN types.
+  // There is no representation for Inf or NaN.
+  NoNanInf,

durga4github wrote:

Thank you, I will refresh with this "FiniteOnly".

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


[clang] [llvm] [clang][CodeGen] `used` globals are fake (PR #93601)

2024-06-08 Thread Alexander Richardson via cfe-commits

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

LGTM with the outstanding comments addressed.

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


[clang] [Driver] Remove a bunch of unnecessary REQUIRES constraints (PR #94055)

2024-06-08 Thread Melissa Hunter via cfe-commits

Mhunter15 wrote:

#94843 

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


[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-08 Thread Pranav Bhandarkar via cfe-commits


@@ -5229,13 +5362,288 @@ static void emitTargetOutlinedFunction(
   OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, 
true,
   OutlinedFn, OutlinedFnID);
 }
+OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(
+Function *OutlinedFn, Value *OutlinedFnID,
+EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+Value *DeviceID, Value *RTLoc, OpenMPIRBuilder::InsertPointTy AllocaIP,
+SmallVector ,
+bool HasNoWait) {
+
+  // When we arrive at this function, the target region itself has been
+  // outlined into the function OutlinedFn.
+  // So at ths point, for
+  // --
+  //   void user_code_that_offloads(...) {
+  // omp target depend(..) map(from:a) map(to:b, c)
+  //a = b + c
+  //   }
+  //
+  // --
+  //
+  // we have
+  //
+  // --
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  // ;; target region has been outlined and now we need to
+  // ;; offload to it via a target task.
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  // *a = *b + *c
+  //   }
+  //
+  // We have to now do the following
+  // (i)   Make an offloading call to outlined_device_function using the OpenMP
+  //   RTL. See 'kernel_launch_function' in the pseudo code below. This is
+  //   emitted by emitKernelLaunch
+  // (ii)  Create a task entry point function that calls kernel_launch_function
+  //   and is the entry point for the target task. See
+  //   '@.omp_target_task_proxy_func in the pseudocode below.
+  // (iii) Create a task with the task entry point created in (ii)
+  //
+  // That is we create the following
+  //
+  //   void user_code_that_offloads(...) {
+  // %.offload_baseptrs = alloca [3 x ptr], align 8
+  // %.offload_ptrs = alloca [3 x ptr], align 8
+  // %.offload_mappers = alloca [3 x ptr], align 8
+  //
+  // %structArg = alloca { ptr, ptr, ptr }, align 8
+  // %strucArg[0] = %.offload_baseptrs
+  // %strucArg[1] = %.offload_ptrs
+  // %strucArg[2] = %.offload_mappers
+  // proxy_target_task = @__kmpc_omp_task_alloc(...,
+  //   
@.omp_target_task_proxy_func)
+  // memcpy(proxy_target_task->shareds, %structArg, sizeof(structArg))
+  // dependencies_array = ...
+  // ;; if nowait not present
+  // call @__kmpc_omp_wait_deps(..., dependencies_array)
+  // call @__kmpc_omp_task_begin_if0(...)
+  // call @ @.omp_target_task_proxy_func(i32 thread_id, ptr
+  // %proxy_target_task) call @__kmpc_omp_task_complete_if0(...)
+  //   }
+  //
+  //   define internal void @.omp_target_task_proxy_func(i32 %thread.id,
+  // ptr %task) {
+  //   %structArg = alloca {ptr, ptr, ptr}
+  //   %shared_data = load (getelementptr %task, 0, 0)
+  //   mempcy(%structArg, %shared_data, sizeof(structArg))
+  //   kernel_launch_function(%thread.id, %structArg)
+  //   }
+  //
+  //   We need the proxy function because the signature of the task entry point
+  //   expected by kmpc_omp_task is always the same and will be different from
+  //   that of the kernel_launch function.
+  //
+  //   kernel_launch_function is generated by emitKernelLaunch and has the
+  //   always_inline attribute. void kernel_launch_function(thread_id,
+  //structArg)
+  //alwaysinline {
+  //   %kernel_args = alloca %struct.__tgt_kernel_arguments, align 8
+  //   offload_baseptrs = load(getelementptr structArg, 0, 0)
+  //   offload_ptrs = load(getelementptr structArg, 0, 1)
+  //   offload_mappers = load(getelementptr structArg, 0, 2)
+  //   ; setup kernel_args using offload_baseptrs, offload_ptrs and
+  //   ; offload_mappers
+  //   call i32 @__tgt_target_kernel(...,
+  // outlined_device_function,
+  // ptr %kernel_args)
+  //   }
+  //   void outlined_device_function(ptr a, ptr b, ptr c) {
+  //  *a = *b + *c
+  //   }
+  //
+  BasicBlock *TargetTaskBodyBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.body");
+  BasicBlock *TargetTaskAllocaBB =
+  splitBB(Builder, /*CreateBranch=*/true, "target.task.alloca");
+
+  InsertPointTy TargetTaskAllocaIP =
+  InsertPointTy(TargetTaskAllocaBB, TargetTaskAllocaBB->begin());
+  InsertPointTy TargetTaskBodyIP =
+  InsertPointTy(TargetTaskBodyBB, TargetTaskBodyBB->begin());
+
+  OutlineInfo OI;
+  OI.EntryBB = 

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-08 Thread Pranav Bhandarkar via cfe-commits


@@ -1762,6 +1762,26 @@ class OpenMPIRBuilder {
   EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
   Value *DeviceID, Value *RTLoc, InsertPointTy AllocaIP);
 
+  /// Generate a target-task for the target construct
+  ///
+  /// \param OutlinedFn The outlined device/target kernel function.
+  /// \param OutlinedFnID The ooulined function ID.
+  /// \param EmitTargetCallFallbackCB Call back function to generate host
+  ///fallback code.
+  /// \param Args Data structure holding information about the kernel 
arguments.
+  /// \param DeviceID Identifier for the device via the 'device' clause.
+  /// \param RTLoc Source location identifier
+  /// \param AllocaIP The insertion point to be used for alloca instructions.
+  /// \param Dependencies Vector of DependData objects holding information of
+  ///dependencies as specified by the 'depend' clause.
+  /// \param HasNoWait True if the target construct had 'nowait' on it, false
+  ///otherwise
+  InsertPointTy emitTargetTask(
+  Function *OutlinedFn, Value *OutlinedFnID,
+  EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs ,
+  Value *DeviceID, Value *RTLoc, InsertPointTy AllocaIP,
+  SmallVector , bool HasNoWait);

bhandarkar-pranav wrote:

I don't think this is safe. I capture Dependencies in a lambda so storing 
ArrayRef which doesnt manage the lifetime of the data pointer isn't safe. 

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


[clang-tools-extra] [clang-doc] Add basic e2e test (PR #93928)

2024-06-08 Thread via cfe-commits


@@ -0,0 +1,17 @@
+[
+  {
+"directory": "$test_dir/build",

PeterChou1 wrote:

I tried getting relative paths to work but it didn't seem to work

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


[clang-tools-extra] [clang-doc] Add basic e2e test (PR #93928)

2024-06-08 Thread via cfe-commits

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


[clang-tools-extra] [clang-doc] Add basic e2e test (PR #93928)

2024-06-08 Thread via cfe-commits


@@ -0,0 +1,361 @@
+// RUN: rm -rf %t && mkdir -p %t/build %t/include %t/src %t/docs
+// RUN: sed 's|$test_dir|%/t|g' 
%S/Inputs/clang-doc-project1/database_template.json > 
%t/build/compile_commands.json
+// RUN: cp %S/Inputs/clang-doc-project1/*.h  %t/include
+// RUN: cp %S/Inputs/clang-doc-project1/*.cpp %t/src
+// RUN: cd %t
+// RUN: clang-doc --format=html --executor=all-TUs --asset=%S/Inputs 
./build/compile_commands.json

PeterChou1 wrote:

I removed the copying so the commands run should be simplified I based most of 
the commands off a test case I found here 
https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/test/clang-move/move-class.cpp
its also why I used the .cpp extension for the test case 

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


[clang-tools-extra] [clang-doc] Add basic e2e test (PR #93928)

2024-06-08 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/93928

>From 219df1820de43696dd51268f1aa22c397846c0a6 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Fri, 7 Jun 2024 01:47:15 -0400
Subject: [PATCH 1/2] [clang-doc] add basic e2e test

---
 .../Inputs/clang-doc-default-stylesheet.css   | 969 ++
 .../Inputs/clang-doc-project1/Calculator.cpp  |  21 +
 .../Inputs/clang-doc-project1/Calculator.h|  46 +
 .../Inputs/clang-doc-project1/Circle.cpp  |  11 +
 .../Inputs/clang-doc-project1/Circle.h|  35 +
 .../Inputs/clang-doc-project1/Rectangle.cpp   |  12 +
 .../Inputs/clang-doc-project1/Rectangle.h |  37 +
 .../Inputs/clang-doc-project1/Shape.h |  30 +
 .../clang-doc-project1/database_template.json |  17 +
 .../test/clang-doc/Inputs/index.js|  87 ++
 .../test/clang-doc/clang-doc-project1.cpp | 361 +++
 11 files changed, 1626 insertions(+)
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-default-stylesheet.css
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Calculator.cpp
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Calculator.h
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Circle.cpp
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Circle.h
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Rectangle.cpp
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Rectangle.h
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/Shape.h
 create mode 100644 
clang-tools-extra/test/clang-doc/Inputs/clang-doc-project1/database_template.json
 create mode 100644 clang-tools-extra/test/clang-doc/Inputs/index.js
 create mode 100644 clang-tools-extra/test/clang-doc/clang-doc-project1.cpp

diff --git 
a/clang-tools-extra/test/clang-doc/Inputs/clang-doc-default-stylesheet.css 
b/clang-tools-extra/test/clang-doc/Inputs/clang-doc-default-stylesheet.css
new file mode 100644
index 0..8b335232b8048
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/Inputs/clang-doc-default-stylesheet.css
@@ -0,0 +1,969 @@
+.dark-primary-color{ background: #1976D2; }
+.default-primary-color { background: #2196F3; }
+.light-primary-color   { background: #BBDEFB; }
+.text-primary-color{ color: #FF; }
+.accent-color  { background: #00BCD4; }
+.primary-text-color{ color: #212121; }
+.secondary-text-color  { color: #727272; }
+.divider-color { border-color: #B6B6B6; }
+
+/* for layout */
+html,
+body {
+  margin: 0;
+  padding: 0;
+  height: 100%;
+  width: 100%;
+  overflow: hidden;
+  box-sizing: border-box;
+}
+
+*, *:before, *:after {
+  box-sizing: inherit;
+}
+
+body {
+  display: flex;
+  flex-direction: column;
+  min-height: 100vh;
+}
+
+header {
+  flex: 0 0 50px;
+  display: flex;
+  flex-direction: row;
+  align-items: center;
+  padding-left: 30px;
+}
+
+header ol {
+  list-style: none;
+  margin: 0;
+  padding: 0;
+}
+
+header ol li {
+  display: inline;
+}
+
+header form {
+  display: flex;
+  flex: 1;
+  justify-content: flex-end;
+  padding-right: 30px;
+}
+
+header#header-search-sidebar {
+  height: 50px;
+  margin-bottom: 25px;
+}
+
+footer {
+  flex: 0 0 16px;
+  text-align: center;
+  padding: 16px 20px;
+}
+
+main {
+  flex: 1;
+  display: flex;
+  flex-direction: row;
+  padding: 20px;
+  min-height: 0;
+}
+
+.sidebar-offcanvas-left {
+  flex: 0 1 230px;
+  overflow-y: scroll;
+  padding: 20px 0 15px 30px;
+  margin: 5px 20px 0 0;
+  visibility: visible; /* shown by Javascript after scroll position restore */
+}
+
+::-webkit-scrollbar-button{ display: none; height: 13px; border-radius: 0px; 
background-color: #AAA; }
+::-webkit-scrollbar-button:hover{ background-color: #AAA; }
+::-webkit-scrollbar-thumb{ background-color: #CCC; }
+::-webkit-scrollbar-thumb:hover{ background-color: #CCC; }
+::-webkit-scrollbar{ width: 4px; }
+/* ::-webkit-overflow-scrolling: touch; */
+
+.main-content::-webkit-scrollbar{ width: 8px; }
+
+.main-content {
+  flex: 1;
+  overflow-y: scroll;
+  padding: 10px 20px 0 20px;
+  visibility: visible; /* shown by Javascript after scroll position restore */
+}
+
+.sidebar-offcanvas-right {
+  flex: 0 1 12em;
+  overflow-y: scroll;
+  padding: 20px 15px 15px 15px;
+  margin-top: 5px;
+  margin-right: 20px;
+  visibility: visible; /* shown by Javascript after scroll position restore */
+}
+/* end for layout */
+
+body {
+  -webkit-text-size-adjust: 100%;
+  overflow-x: hidden;
+  font-family: Roboto, sans-serif;
+  font-size: 16px;
+  line-height: 1.42857143;
+  color: #11;
+  background-color: #fff;
+}
+
+/* some of this is to reset bootstrap */
+nav.navbar {
+  background-color: inherit;
+  min-height: 50px;
+  border: 0;
+}
+
+@media (max-width: 768px) {
+  .hidden-xs {
+display: none !important;
+  }
+}
+
+@media (min-width: 769px) {