[clang] [clang] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-12 Thread Haojian Wu via cfe-commits

hokein wrote:

Thanks, it looks like this introduces a new false positive:

```
#include 
std::optional func(int a) {
  if (a)
   return std::make_optional(nullptr); // emit a dangling.
}
```

I'm going to revert it.

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


[clang] 0683c4e - Revert "[clang] Diagnose dangling issues for the "Container" case. (#107213)"

2024-09-12 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2024-09-12T09:24:32+02:00
New Revision: 0683c4e839524c37fe4ddfa1bce1e31ba556041b

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

LOG: Revert "[clang] Diagnose dangling issues for the "Container" 
case. (#107213)"

This reverts commit e50131aa068f74daa70d4135c92020aadae3af33.

It introduces a new false positive, see comment 
https://github.com/llvm/llvm-project/pull/107213#issuecomment-2345465256

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/AttrDocs.td
clang/lib/Sema/CheckExprLifetime.cpp
clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9860b25f2e7fa6..22749e96a7e3d3 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -301,8 +301,6 @@ Improvements to Clang's diagnostics
 
 - Clang now warns for u8 character literals used in C23 with 
``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
 
-- Clang now diagnoses cases where a dangling ``GSLOwner`` object 
is constructed, e.g. ``std::vector v = {std::string()};`` 
(#GH100526).
-
 Improvements to Clang's time-trace
 --
 

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 9f72456d2da678..546e5100b79dd9 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6690,20 +6690,6 @@ When the Owner's lifetime ends, it will consider the 
Pointer to be dangling.
 P.getInt(); // P is dangling
   }
 
-If a template class is annotated with ``[[gsl::Owner]]``, and the first
-instantiated template argument is a pointer type (raw pointer, or 
``[[gsl::Pointer]]``),
-the analysis will consider the instantiated class as a container of the 
pointer.
-When constructing such an object from a GSL owner object, the analysis will
-assume that the container holds a pointer to the owner object. Consequently,
-when the owner object is destroyed, the pointer will be considered dangling.
-
-.. code-block:: c++
-
-   int f() {
- std::vector v = {std::string()}; // v holds a dangling 
pointer.
- std::optional o = std::string(); // o holds a dangling 
pointer.
-   }
-
 }];
 }
 

diff  --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index 77c73f47658fe1..f62e18543851c1 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -267,26 +267,6 @@ static bool isInStlNamespace(const Decl *D) {
   return DC->isStdNamespace();
 }
 
-// Returns true if the given Record decl is a form of `GSLOwner`
-// type, e.g. std::vector, std::optional.
-static bool isContainerOfPointer(const RecordDecl *Container) {
-  if (const auto *CTSD =
-  dyn_cast_if_present(Container)) {
-if (!CTSD->hasAttr()) // Container must be a GSL owner type.
-  return false;
-const auto &TAs = CTSD->getTemplateArgs();
-return TAs.size() > 0 && TAs[0].getKind() == TemplateArgument::Type &&
-   (isRecordWithAttr(TAs[0].getAsType()) ||
-TAs[0].getAsType()->isPointerType());
-  }
-  return false;
-}
-
-static bool isGSLOwner(QualType T) {
-  return isRecordWithAttr(T) &&
- !isContainerOfPointer(T->getAsRecordDecl());
-}
-
 static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) {
   if (auto *Conv = dyn_cast_or_null(Callee))
 if (isRecordWithAttr(Conv->getConversionType()))
@@ -295,7 +275,7 @@ static bool shouldTrackImplicitObjectArg(const 
CXXMethodDecl *Callee) {
 return false;
   if (!isRecordWithAttr(
   Callee->getFunctionObjectParameterType()) &&
-  !isGSLOwner(Callee->getFunctionObjectParameterType()))
+  !isRecordWithAttr(Callee->getFunctionObjectParameterType()))
 return false;
   if (Callee->getReturnType()->isPointerType() ||
   isRecordWithAttr(Callee->getReturnType())) {
@@ -433,7 +413,7 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 // Once we initialized a value with a non gsl-owner reference, it can no
 // longer dangle.
 if (ReturnType->isReferenceType() &&
-!isGSLOwner(ReturnType->getPointeeType())) {
+!isRecordWithAttr(ReturnType->getPointeeType())) {
   for (const IndirectLocalPathEntry &PE : llvm::reverse(Path)) {
 if (PE.Kind == IndirectLocalPathEntry::GslReferenceInit ||
 PE.Kind == IndirectLocalPathEntry::LifetimeBoundCall)
@@ -488,17 +468,12 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr())
   VisitLifetimeBoundArg(Callee->getParamDecl(I), Args[I]);
 else if (EnableGSLAnalysis && I == 0) {
-  // Perform GSL 

[clang] [clang][bytecode] Implement base casts on integral pointers (PR #108340)

2024-09-12 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/108340

Get the right offset to apply from the RecordLayout.

>From af62225a90e3dd2ebd234c391a4e05dd1d1d7df9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 12 Sep 2024 09:36:17 +0200
Subject: [PATCH] [clang][bytecode] Implement base casts on integral pointers

Get the right offset to apply from the RecordLayout.
---
 clang/lib/AST/ByteCode/Interp.h | 12 +++
 clang/lib/AST/ByteCode/Pointer.cpp  | 23 +
 clang/lib/AST/ByteCode/Pointer.h|  1 +
 clang/test/AST/ByteCode/const-base-cast.cpp | 19 +
 clang/test/CodeGenCXX/const-base-cast.cpp   |  2 +-
 5 files changed, 56 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/AST/ByteCode/const-base-cast.cpp

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 7b7c7822e4a925..3d507e2e2ba764 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -1611,6 +1611,12 @@ inline bool GetPtrDerivedPop(InterpState &S, CodePtr 
OpPC, uint32_t Off) {
 
 inline bool GetPtrBase(InterpState &S, CodePtr OpPC, uint32_t Off) {
   const Pointer &Ptr = S.Stk.peek();
+
+  if (!Ptr.isBlockPointer()) {
+S.Stk.push(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
+return true;
+  }
+
   if (!CheckNull(S, OpPC, Ptr, CSK_Base))
 return false;
   if (!CheckSubobject(S, OpPC, Ptr, CSK_Base))
@@ -1624,6 +1630,12 @@ inline bool GetPtrBase(InterpState &S, CodePtr OpPC, 
uint32_t Off) {
 
 inline bool GetPtrBasePop(InterpState &S, CodePtr OpPC, uint32_t Off) {
   const Pointer &Ptr = S.Stk.pop();
+
+  if (!Ptr.isBlockPointer()) {
+S.Stk.push(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
+return true;
+  }
+
   if (!CheckNull(S, OpPC, Ptr, CSK_Base))
 return false;
   if (!CheckSubobject(S, OpPC, Ptr, CSK_Base))
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp 
b/clang/lib/AST/ByteCode/Pointer.cpp
index 9eaf0db45c7451..282953eb991a6b 100644
--- a/clang/lib/AST/ByteCode/Pointer.cpp
+++ b/clang/lib/AST/ByteCode/Pointer.cpp
@@ -667,3 +667,26 @@ IntPointer IntPointer::atOffset(const ASTContext &ASTCtx,
   .getQuantity();
   return IntPointer{this->Desc, this->Value + FieldOffset};
 }
+
+IntPointer IntPointer::baseCast(const ASTContext &ASTCtx,
+unsigned BaseOffset) const {
+  const Record *R = Desc->ElemRecord;
+  const Descriptor *BaseDesc = nullptr;
+
+  // This iterates over bases and checks for the proper offset. That's
+  // potentially slow but this case really shouldn't happen a lot.
+  for (const Record::Base &B : R->bases()) {
+if (B.Offset == BaseOffset) {
+  BaseDesc = B.Desc;
+  break;
+}
+  }
+  assert(BaseDesc);
+
+  // Adjust the offset value based on the information from the record layout.
+  const ASTRecordLayout &Layout = ASTCtx.getASTRecordLayout(R->getDecl());
+  CharUnits BaseLayoutOffset =
+  Layout.getBaseClassOffset(cast(BaseDesc->asDecl()));
+
+  return {BaseDesc, Value + BaseLayoutOffset.getQuantity()};
+}
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index acbef437752388..ac9b9ed4091b66 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -46,6 +46,7 @@ struct IntPointer {
   uint64_t Value;
 
   IntPointer atOffset(const ASTContext &ASTCtx, unsigned Offset) const;
+  IntPointer baseCast(const ASTContext &ASTCtx, unsigned BaseOffset) const;
 };
 
 enum class Storage { Block, Int, Fn };
diff --git a/clang/test/AST/ByteCode/const-base-cast.cpp 
b/clang/test/AST/ByteCode/const-base-cast.cpp
new file mode 100644
index 00..80226b973bf977
--- /dev/null
+++ b/clang/test/AST/ByteCode/const-base-cast.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s
+
+
+/// Slightly adapted to the version from test/CodeGenCXX/.
+
+struct X { int x[12];};
+struct A : X { char x, y, z; };
+struct B { char y; };
+struct C : A,B {};
+unsigned char x = ((char*)(X*)(C*)0x1000) - (char*)0x1000;
+// CHECK: @x = {{(dso_local )?}}global i8 0
+
+unsigned char y = ((char*)(B*)(C*)0x1000) - (char*)0x1000;
+// CHECK: @y = {{(dso_local )?}}global i8 51
+
+unsigned char z = ((char*)(A*)(C*)0x1000) - (char*)0x1000;
+// CHECK: @z = {{(dso_local )?}}global i8 0
+
diff --git a/clang/test/CodeGenCXX/const-base-cast.cpp 
b/clang/test/CodeGenCXX/const-base-cast.cpp
index bb08b9d21fcfce..7f2c66e6ca0886 100644
--- a/clang/test/CodeGenCXX/const-base-cast.cpp
+++ b/clang/test/CodeGenCXX/const-base-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s
 
 // C

[clang] [clang][bytecode] Implement base casts on integral pointers (PR #108340)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

Get the right offset to apply from the RecordLayout.

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


5 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.h (+12) 
- (modified) clang/lib/AST/ByteCode/Pointer.cpp (+23) 
- (modified) clang/lib/AST/ByteCode/Pointer.h (+1) 
- (added) clang/test/AST/ByteCode/const-base-cast.cpp (+19) 
- (modified) clang/test/CodeGenCXX/const-base-cast.cpp (+1-1) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index 7b7c7822e4a925..3d507e2e2ba764 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -1611,6 +1611,12 @@ inline bool GetPtrDerivedPop(InterpState &S, CodePtr 
OpPC, uint32_t Off) {
 
 inline bool GetPtrBase(InterpState &S, CodePtr OpPC, uint32_t Off) {
   const Pointer &Ptr = S.Stk.peek();
+
+  if (!Ptr.isBlockPointer()) {
+S.Stk.push(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
+return true;
+  }
+
   if (!CheckNull(S, OpPC, Ptr, CSK_Base))
 return false;
   if (!CheckSubobject(S, OpPC, Ptr, CSK_Base))
@@ -1624,6 +1630,12 @@ inline bool GetPtrBase(InterpState &S, CodePtr OpPC, 
uint32_t Off) {
 
 inline bool GetPtrBasePop(InterpState &S, CodePtr OpPC, uint32_t Off) {
   const Pointer &Ptr = S.Stk.pop();
+
+  if (!Ptr.isBlockPointer()) {
+S.Stk.push(Ptr.asIntPointer().baseCast(S.getASTContext(), Off));
+return true;
+  }
+
   if (!CheckNull(S, OpPC, Ptr, CSK_Base))
 return false;
   if (!CheckSubobject(S, OpPC, Ptr, CSK_Base))
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp 
b/clang/lib/AST/ByteCode/Pointer.cpp
index 9eaf0db45c7451..282953eb991a6b 100644
--- a/clang/lib/AST/ByteCode/Pointer.cpp
+++ b/clang/lib/AST/ByteCode/Pointer.cpp
@@ -667,3 +667,26 @@ IntPointer IntPointer::atOffset(const ASTContext &ASTCtx,
   .getQuantity();
   return IntPointer{this->Desc, this->Value + FieldOffset};
 }
+
+IntPointer IntPointer::baseCast(const ASTContext &ASTCtx,
+unsigned BaseOffset) const {
+  const Record *R = Desc->ElemRecord;
+  const Descriptor *BaseDesc = nullptr;
+
+  // This iterates over bases and checks for the proper offset. That's
+  // potentially slow but this case really shouldn't happen a lot.
+  for (const Record::Base &B : R->bases()) {
+if (B.Offset == BaseOffset) {
+  BaseDesc = B.Desc;
+  break;
+}
+  }
+  assert(BaseDesc);
+
+  // Adjust the offset value based on the information from the record layout.
+  const ASTRecordLayout &Layout = ASTCtx.getASTRecordLayout(R->getDecl());
+  CharUnits BaseLayoutOffset =
+  Layout.getBaseClassOffset(cast(BaseDesc->asDecl()));
+
+  return {BaseDesc, Value + BaseLayoutOffset.getQuantity()};
+}
diff --git a/clang/lib/AST/ByteCode/Pointer.h b/clang/lib/AST/ByteCode/Pointer.h
index acbef437752388..ac9b9ed4091b66 100644
--- a/clang/lib/AST/ByteCode/Pointer.h
+++ b/clang/lib/AST/ByteCode/Pointer.h
@@ -46,6 +46,7 @@ struct IntPointer {
   uint64_t Value;
 
   IntPointer atOffset(const ASTContext &ASTCtx, unsigned Offset) const;
+  IntPointer baseCast(const ASTContext &ASTCtx, unsigned BaseOffset) const;
 };
 
 enum class Storage { Block, Int, Fn };
diff --git a/clang/test/AST/ByteCode/const-base-cast.cpp 
b/clang/test/AST/ByteCode/const-base-cast.cpp
new file mode 100644
index 00..80226b973bf977
--- /dev/null
+++ b/clang/test/AST/ByteCode/const-base-cast.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s
+
+
+/// Slightly adapted to the version from test/CodeGenCXX/.
+
+struct X { int x[12];};
+struct A : X { char x, y, z; };
+struct B { char y; };
+struct C : A,B {};
+unsigned char x = ((char*)(X*)(C*)0x1000) - (char*)0x1000;
+// CHECK: @x = {{(dso_local )?}}global i8 0
+
+unsigned char y = ((char*)(B*)(C*)0x1000) - (char*)0x1000;
+// CHECK: @y = {{(dso_local )?}}global i8 51
+
+unsigned char z = ((char*)(A*)(C*)0x1000) - (char*)0x1000;
+// CHECK: @z = {{(dso_local )?}}global i8 0
+
diff --git a/clang/test/CodeGenCXX/const-base-cast.cpp 
b/clang/test/CodeGenCXX/const-base-cast.cpp
index bb08b9d21fcfce..7f2c66e6ca0886 100644
--- a/clang/test/CodeGenCXX/const-base-cast.cpp
+++ b/clang/test/CodeGenCXX/const-base-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - 
-fexperimental-new-constant-interpreter | FileCheck %s
 
 // Check that the following construct, which is similar to one which occurs
 // in Firefox, is folded correctly.

``




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

[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)

2024-09-12 Thread Dmitry Polukhin via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Kyungwoo Lee 
,Dmitry
 Polukhin ,Dmitry Polukhin
 
Message-ID:
In-Reply-To: 


dmpolukhin wrote:

> this is causing a crash with precompiled headers. I can try to reduce, but 
> hopefully the problem is obvious from this assert/stack trace?

@aeubanks could you please create a reproducer or at least some instruction how 
it can be reproduced? From the stack trace it is not clear. The crash happens 
on translating GlobalDeclID but it has no clue what was wrong with the value.

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


[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)

2024-09-12 Thread Dmitry Polukhin via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Kyungwoo Lee 
,Dmitry
 Polukhin ,Dmitry Polukhin
 
Message-ID:
In-Reply-To: 



@@ -1155,6 +1155,16 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   for (unsigned I = 0; I != NumParams; ++I)
 Params.push_back(readDeclAs());
   FD->setParams(Reader.getContext(), Params);
+
+  // For the first decl add all lambdas inside for loading them later,
+  // otherwise skip them.
+  unsigned NumLambdas = Record.readInt();
+  if (FD->isFirstDecl()) {
+for (unsigned I = 0; I != NumLambdas; ++I)
+  Reader.PendingLambdas.push_back(Record.readDeclID());
+  } else {
+Record.skipInts(NumLambdas);

dmpolukhin wrote:

@ChuanqiXu9 could you please elaborate why you think it may not be paired? Code 
in ASTDeclWriter looks like this:
```
  if (D->isCanonicalDecl()) {
llvm::SmallVector Lambdas = collectLambdas(D);
Record.push_back(Lambdas.size());
for (const auto *L : Lambdas)
  Record.AddDeclRef(L);
  } else {
Record.push_back(0);
  }
```
So in the first case it writes size + following decls, in the second case it 
writes 0. I looked the implementation of skipInts for `skipInts(0)` it does 
nothing.

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


[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)

2024-09-12 Thread Chuanqi Xu via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Kyungwoo Lee 
,Dmitry
 Polukhin ,Dmitry Polukhin
 
Message-ID:
In-Reply-To: 



@@ -1155,6 +1155,16 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   for (unsigned I = 0; I != NumParams; ++I)
 Params.push_back(readDeclAs());
   FD->setParams(Reader.getContext(), Params);
+
+  // For the first decl add all lambdas inside for loading them later,
+  // otherwise skip them.
+  unsigned NumLambdas = Record.readInt();
+  if (FD->isFirstDecl()) {
+for (unsigned I = 0; I != NumLambdas; ++I)
+  Reader.PendingLambdas.push_back(Record.readDeclID());
+  } else {
+Record.skipInts(NumLambdas);

ChuanqiXu9 wrote:

Sorry, it was an oversight. I took too quickly from the above stack trace.

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


[clang-tools-extra] [clang-tidy] add default error message for performance-avoid-endl (PR #107867)

2024-09-12 Thread Danny Mösch via cfe-commits


@@ -46,14 +46,15 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult 
&Result) {
 // Handle the more common streaming '... << std::endl' case
 const CharSourceRange TokenRange =
 CharSourceRange::getTokenRange(Expression->getSourceRange());
-const StringRef SourceText = Lexer::getSourceText(
+StringRef SourceText = Lexer::getSourceText(
 TokenRange, *Result.SourceManager, Result.Context->getLangOpts());
-
-auto Diag = diag(Expression->getBeginLoc(),
- "do not use '%0' with streams; use '\\n' instead")
-<< SourceText;
-
-Diag << FixItHint::CreateReplacement(TokenRange, "'\\n'");
+if (SourceText.empty())
+  SourceText = "std::endl";
+auto Builder = diag(Expression->getBeginLoc(),
+"do not use '%0' with streams; use '\\n' instead");
+if (TokenRange.isValid())
+  Builder << SourceText

SimplyDanny wrote:

The `<< SourceText` part should always be added, shouldn't it? The tests seem 
to be fine though. 🤔 

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


[clang] [llvm] Delete the clang-format Visual Studio plugin code (PR #108342)

2024-09-12 Thread via cfe-commits

https://github.com/zmodem created 
https://github.com/llvm/llvm-project/pull/108342

This was obsoleted by Visual Studio providing built-in support for running 
clang-format in VS2017.

We haven't shipped it for years (since 
10d2195305ac49605f2b7b6a25a4076c31923191), never got it working with VS2019, 
and never even tried with VS2022.

It's time to retire the code.

>From 9153796fa6cd7f18bd7395ec667a41d0598ac7a3 Mon Sep 17 00:00:00 2001
From: Hans Wennborg 
Date: Thu, 12 Sep 2024 09:43:09 +0200
Subject: [PATCH 1/3] remove reference in build_llvm_release.bat

---
 llvm/utils/release/build_llvm_release.bat | 1 -
 1 file changed, 1 deletion(-)

diff --git a/llvm/utils/release/build_llvm_release.bat 
b/llvm/utils/release/build_llvm_release.bat
index 3508748c1d5404..dd041d7d384ec4 100755
--- a/llvm/utils/release/build_llvm_release.bat
+++ b/llvm/utils/release/build_llvm_release.bat
@@ -80,7 +80,6 @@ REM Prerequisites:
 REM
 REM   Visual Studio 2019, CMake, Ninja, GNUWin32, SWIG, Python 3,
 REM   NSIS with the strlen_8192 patch,
-REM   Visual Studio 2019 SDK and Nuget (for the clang-format plugin),
 REM   Perl (for the OpenMP run-time).
 REM
 REM

>From 1ce159849a2ab508b90a3ca200e894bcacb030a1 Mon Sep 17 00:00:00 2001
From: Hans Wennborg 
Date: Thu, 12 Sep 2024 09:43:50 +0200
Subject: [PATCH 2/3] remove the clang-format-vs dir

---
 clang/tools/clang-format-vs/.gitignore|  11 -
 clang/tools/clang-format-vs/CMakeLists.txt|  33 --
 clang/tools/clang-format-vs/ClangFormat.sln   |  22 -
 .../ClangFormat/ClangFormat.csproj| 261 --
 .../ClangFormat/ClangFormat.vsct  | 127 -
 .../ClangFormat/ClangFormatPackage.cs | 464 --
 .../ClangFormat/GlobalSuppressions.cs |  11 -
 .../clang-format-vs/ClangFormat/Guids.cs  |  12 -
 .../clang-format-vs/ClangFormat/PkgCmdID.cs   |   8 -
 .../ClangFormat/Properties/AssemblyInfo.cs|  33 --
 .../ClangFormat/Resources.Designer.cs |  63 ---
 .../ClangFormat/Resources.resx| 129 -
 .../ClangFormat/Resources/Images_32bit.bmp| Bin 5176 -> 0 bytes
 .../ClangFormat/Resources/Package.ico | Bin 1078 -> 0 bytes
 .../RunningDocTableEventsDispatcher.cs|  79 ---
 .../ClangFormat/VSPackage.resx| 140 --
 .../tools/clang-format-vs/ClangFormat/Vsix.cs |  96 
 .../clang-format-vs/ClangFormat/license.txt   | 261 --
 .../ClangFormat/packages.config   |  21 -
 clang/tools/clang-format-vs/README.txt|  51 --
 .../source.extension.vsixmanifest.in  |  19 -
 21 files changed, 1841 deletions(-)
 delete mode 100644 clang/tools/clang-format-vs/.gitignore
 delete mode 100644 clang/tools/clang-format-vs/CMakeLists.txt
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat.sln
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/ClangFormat.vsct
 delete mode 100644 
clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
 delete mode 100644 
clang/tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/Guids.cs
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/PkgCmdID.cs
 delete mode 100644 
clang/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
 delete mode 100644 
clang/tools/clang-format-vs/ClangFormat/Resources.Designer.cs
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/Resources.resx
 delete mode 100644 
clang/tools/clang-format-vs/ClangFormat/Resources/Images_32bit.bmp
 delete mode 100644 
clang/tools/clang-format-vs/ClangFormat/Resources/Package.ico
 delete mode 100644 
clang/tools/clang-format-vs/ClangFormat/RunningDocTableEventsDispatcher.cs
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/VSPackage.resx
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/Vsix.cs
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/license.txt
 delete mode 100644 clang/tools/clang-format-vs/ClangFormat/packages.config
 delete mode 100644 clang/tools/clang-format-vs/README.txt
 delete mode 100644 clang/tools/clang-format-vs/source.extension.vsixmanifest.in

diff --git a/clang/tools/clang-format-vs/.gitignore 
b/clang/tools/clang-format-vs/.gitignore
deleted file mode 100644
index 270d840cb6d1a8..00
--- a/clang/tools/clang-format-vs/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-# Visual Studio files
-.vs/
-*.user
-/packages/
-/ClangFormat/obj/
-/ClangFormat/bin/
-
-# Generated and copied files
-/ClangFormat/Key.snk
-/ClangFormat/clang-format.exe
-/ClangFormat/source.extension.vsixmanifest
diff --git a/clang/tools/clang-format-vs/CMakeLists.txt 
b/clang/tools/clang-format-vs/CMakeLists.txt
deleted file mode 100644
index 1d44a47a3137be..00
--- a/clang/tools/clang-format-vs/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-option(BUILD_CLANG_FORMAT_VS_PLUGIN "Build clang-format VS plugin" OFF)
-if (BUILD_C

[clang] [llvm] Delete the clang-format Visual Studio plugin code (PR #108342)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-platform-windows

Author: Hans (zmodem)


Changes

This was obsoleted by Visual Studio providing built-in support for running 
clang-format in VS2017.

We haven't shipped it for years (since 
10d2195305ac49605f2b7b6a25a4076c31923191), never got it working with VS2019, 
and never even tried with VS2022.

It's time to retire the code.

---

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


23 Files Affected:

- (modified) clang/tools/CMakeLists.txt (-1) 
- (removed) clang/tools/clang-format-vs/.gitignore (-11) 
- (removed) clang/tools/clang-format-vs/CMakeLists.txt (-33) 
- (removed) clang/tools/clang-format-vs/ClangFormat.sln (-22) 
- (removed) clang/tools/clang-format-vs/ClangFormat/ClangFormat.csproj (-261) 
- (removed) clang/tools/clang-format-vs/ClangFormat/ClangFormat.vsct (-127) 
- (removed) clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs 
(-464) 
- (removed) clang/tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs (-11) 
- (removed) clang/tools/clang-format-vs/ClangFormat/Guids.cs (-12) 
- (removed) clang/tools/clang-format-vs/ClangFormat/PkgCmdID.cs (-8) 
- (removed) clang/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs 
(-33) 
- (removed) clang/tools/clang-format-vs/ClangFormat/Resources.Designer.cs (-63) 
- (removed) clang/tools/clang-format-vs/ClangFormat/Resources.resx (-129) 
- (removed) clang/tools/clang-format-vs/ClangFormat/Resources/Images_32bit.bmp 
() 
- (removed) clang/tools/clang-format-vs/ClangFormat/Resources/Package.ico () 
- (removed) 
clang/tools/clang-format-vs/ClangFormat/RunningDocTableEventsDispatcher.cs 
(-79) 
- (removed) clang/tools/clang-format-vs/ClangFormat/VSPackage.resx (-140) 
- (removed) clang/tools/clang-format-vs/ClangFormat/Vsix.cs (-96) 
- (removed) clang/tools/clang-format-vs/ClangFormat/license.txt (-261) 
- (removed) clang/tools/clang-format-vs/ClangFormat/packages.config (-21) 
- (removed) clang/tools/clang-format-vs/README.txt (-51) 
- (removed) clang/tools/clang-format-vs/source.extension.vsixmanifest.in (-19) 
- (modified) llvm/utils/release/build_llvm_release.bat (-1) 


``diff
diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 4885afc1584d01..f588a3634ee6bc 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -5,7 +5,6 @@ add_clang_subdirectory(driver)
 add_clang_subdirectory(apinotes-test)
 add_clang_subdirectory(clang-diff)
 add_clang_subdirectory(clang-format)
-add_clang_subdirectory(clang-format-vs)
 add_clang_subdirectory(clang-fuzzer)
 add_clang_subdirectory(clang-import-test)
 add_clang_subdirectory(clang-linker-wrapper)
diff --git a/clang/tools/clang-format-vs/.gitignore 
b/clang/tools/clang-format-vs/.gitignore
deleted file mode 100644
index 270d840cb6d1a8..00
--- a/clang/tools/clang-format-vs/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-# Visual Studio files
-.vs/
-*.user
-/packages/
-/ClangFormat/obj/
-/ClangFormat/bin/
-
-# Generated and copied files
-/ClangFormat/Key.snk
-/ClangFormat/clang-format.exe
-/ClangFormat/source.extension.vsixmanifest
diff --git a/clang/tools/clang-format-vs/CMakeLists.txt 
b/clang/tools/clang-format-vs/CMakeLists.txt
deleted file mode 100644
index 1d44a47a3137be..00
--- a/clang/tools/clang-format-vs/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-option(BUILD_CLANG_FORMAT_VS_PLUGIN "Build clang-format VS plugin" OFF)
-if (BUILD_CLANG_FORMAT_VS_PLUGIN)
-  add_custom_target(clang_format_exe_for_vsix
-  ${CMAKE_COMMAND} -E copy_if_different
-  "${LLVM_TOOLS_BINARY_DIR}/clang-format.exe"
-  "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/clang-format.exe"
-  DEPENDS clang-format)
-
-  # Build number added to Clang version to ensure that new VSIX can be upgraded
-  string(TIMESTAMP CLANG_FORMAT_VSIX_BUILD %y%m%d%H%M UTC)
-
-  if (NOT CLANG_FORMAT_VS_VERSION)
-set(CLANG_FORMAT_VS_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}.${CLANG_FORMAT_VSIX_BUILD}")
-  endif()
-
-  configure_file("source.extension.vsixmanifest.in"
-  "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
-
-  find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_DIR})
-  if (NOT NUGET_EXE)
-message(FATAL_ERROR "Could not find nuget.exe. Download from 
https://www.nuget.org/nuget.exe";
-" and add parent directory to PATH or pass it via 
NUGET_EXE_DIR var.")
-  endif()
-
-  add_custom_target(clang_format_vsix ALL
-  COMMAND ${NUGET_EXE} restore 
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln"
-  COMMAND devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build 
Release
-  DEPENDS clang_format_exe_for_vsix 
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
-  COMMAND ${CMAKE_COMMAND} -E copy_if_different
-  "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
-  "${LLVM_TOOLS_BINARY_DIR}/Cl

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread Haojian Wu via cfe-commits

https://github.com/hokein created 
https://github.com/llvm/llvm-project/pull/108344

This relands #107213, with a fix to the "make_optional(nullptr)" false positive 
(please see the second commit in this PR).

>From d1096323a87897b917ede2c29afd42c9f2674cd7 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Thu, 12 Sep 2024 09:27:03 +0200
Subject: [PATCH 1/2] Reapply "[clang] Diagnose dangling issues for the
 "Container" case. (#107213)"

This reverts commit 0683c4e839524c37fe4ddfa1bce1e31ba556041b.
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/AttrDocs.td | 14 
 clang/lib/Sema/CheckExprLifetime.cpp  | 42 +++---
 .../Sema/warn-lifetime-analysis-nocfg.cpp | 77 +++
 4 files changed, 126 insertions(+), 9 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 22749e96a7e3d3..9860b25f2e7fa6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -301,6 +301,8 @@ Improvements to Clang's diagnostics
 
 - Clang now warns for u8 character literals used in C23 with 
``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
 
+- Clang now diagnoses cases where a dangling ``GSLOwner`` object 
is constructed, e.g. ``std::vector v = {std::string()};`` 
(#GH100526).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 546e5100b79dd9..9f72456d2da678 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6690,6 +6690,20 @@ When the Owner's lifetime ends, it will consider the 
Pointer to be dangling.
 P.getInt(); // P is dangling
   }
 
+If a template class is annotated with ``[[gsl::Owner]]``, and the first
+instantiated template argument is a pointer type (raw pointer, or 
``[[gsl::Pointer]]``),
+the analysis will consider the instantiated class as a container of the 
pointer.
+When constructing such an object from a GSL owner object, the analysis will
+assume that the container holds a pointer to the owner object. Consequently,
+when the owner object is destroyed, the pointer will be considered dangling.
+
+.. code-block:: c++
+
+   int f() {
+ std::vector v = {std::string()}; // v holds a dangling 
pointer.
+ std::optional o = std::string(); // o holds a dangling 
pointer.
+   }
+
 }];
 }
 
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index f62e18543851c1..77c73f47658fe1 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -267,6 +267,26 @@ static bool isInStlNamespace(const Decl *D) {
   return DC->isStdNamespace();
 }
 
+// Returns true if the given Record decl is a form of `GSLOwner`
+// type, e.g. std::vector, std::optional.
+static bool isContainerOfPointer(const RecordDecl *Container) {
+  if (const auto *CTSD =
+  dyn_cast_if_present(Container)) {
+if (!CTSD->hasAttr()) // Container must be a GSL owner type.
+  return false;
+const auto &TAs = CTSD->getTemplateArgs();
+return TAs.size() > 0 && TAs[0].getKind() == TemplateArgument::Type &&
+   (isRecordWithAttr(TAs[0].getAsType()) ||
+TAs[0].getAsType()->isPointerType());
+  }
+  return false;
+}
+
+static bool isGSLOwner(QualType T) {
+  return isRecordWithAttr(T) &&
+ !isContainerOfPointer(T->getAsRecordDecl());
+}
+
 static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) {
   if (auto *Conv = dyn_cast_or_null(Callee))
 if (isRecordWithAttr(Conv->getConversionType()))
@@ -275,7 +295,7 @@ static bool shouldTrackImplicitObjectArg(const 
CXXMethodDecl *Callee) {
 return false;
   if (!isRecordWithAttr(
   Callee->getFunctionObjectParameterType()) &&
-  !isRecordWithAttr(Callee->getFunctionObjectParameterType()))
+  !isGSLOwner(Callee->getFunctionObjectParameterType()))
 return false;
   if (Callee->getReturnType()->isPointerType() ||
   isRecordWithAttr(Callee->getReturnType())) {
@@ -413,7 +433,7 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 // Once we initialized a value with a non gsl-owner reference, it can no
 // longer dangle.
 if (ReturnType->isReferenceType() &&
-!isRecordWithAttr(ReturnType->getPointeeType())) {
+!isGSLOwner(ReturnType->getPointeeType())) {
   for (const IndirectLocalPathEntry &PE : llvm::reverse(Path)) {
 if (PE.Kind == IndirectLocalPathEntry::GslReferenceInit ||
 PE.Kind == IndirectLocalPathEntry::LifetimeBoundCall)
@@ -468,12 +488,17 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr())
   VisitLifetimeBoundArg(Callee->getParamDecl(I), Args[I]);
 else if (EnableGSLAnalysis && I == 0) {
+  // Perform GSL analysis for the first argument
   if (shouldTrackFirst

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)


Changes

This relands #107213, with a fix to the "make_optional(nullptr)" false 
positive (please see the second commit in this PR).

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


4 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+14) 
- (modified) clang/lib/Sema/CheckExprLifetime.cpp (+34-10) 
- (modified) clang/test/Sema/warn-lifetime-analysis-nocfg.cpp (+82) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 22749e96a7e3d3..9860b25f2e7fa6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -301,6 +301,8 @@ Improvements to Clang's diagnostics
 
 - Clang now warns for u8 character literals used in C23 with 
``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
 
+- Clang now diagnoses cases where a dangling ``GSLOwner`` object 
is constructed, e.g. ``std::vector v = {std::string()};`` 
(#GH100526).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 546e5100b79dd9..9f72456d2da678 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6690,6 +6690,20 @@ When the Owner's lifetime ends, it will consider the 
Pointer to be dangling.
 P.getInt(); // P is dangling
   }
 
+If a template class is annotated with ``[[gsl::Owner]]``, and the first
+instantiated template argument is a pointer type (raw pointer, or 
``[[gsl::Pointer]]``),
+the analysis will consider the instantiated class as a container of the 
pointer.
+When constructing such an object from a GSL owner object, the analysis will
+assume that the container holds a pointer to the owner object. Consequently,
+when the owner object is destroyed, the pointer will be considered dangling.
+
+.. code-block:: c++
+
+   int f() {
+ std::vector v = {std::string()}; // v holds a dangling 
pointer.
+ std::optional o = std::string(); // o holds a dangling 
pointer.
+   }
+
 }];
 }
 
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index f62e18543851c1..c3e203d56c9280 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -267,6 +267,27 @@ static bool isInStlNamespace(const Decl *D) {
   return DC->isStdNamespace();
 }
 
+// Returns true if the given Record decl is a form of `GSLOwner`
+// type, e.g. std::vector, std::optional.
+static bool isContainerOfPointer(const RecordDecl *Container) {
+  if (const auto *CTSD =
+  dyn_cast_if_present(Container)) {
+if (!CTSD->hasAttr()) // Container must be a GSL owner type.
+  return false;
+const auto &TAs = CTSD->getTemplateArgs();
+return TAs.size() > 0 && TAs[0].getKind() == TemplateArgument::Type &&
+   (isRecordWithAttr(TAs[0].getAsType()) ||
+TAs[0].getAsType()->isPointerType() ||
+TAs[0].getAsType()->isNullPtrType());
+  }
+  return false;
+}
+
+static bool isGSLOwner(QualType T) {
+  return isRecordWithAttr(T) &&
+ !isContainerOfPointer(T->getAsRecordDecl());
+}
+
 static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) {
   if (auto *Conv = dyn_cast_or_null(Callee))
 if (isRecordWithAttr(Conv->getConversionType()))
@@ -275,7 +296,7 @@ static bool shouldTrackImplicitObjectArg(const 
CXXMethodDecl *Callee) {
 return false;
   if (!isRecordWithAttr(
   Callee->getFunctionObjectParameterType()) &&
-  !isRecordWithAttr(Callee->getFunctionObjectParameterType()))
+  !isGSLOwner(Callee->getFunctionObjectParameterType()))
 return false;
   if (Callee->getReturnType()->isPointerType() ||
   isRecordWithAttr(Callee->getReturnType())) {
@@ -413,7 +434,7 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 // Once we initialized a value with a non gsl-owner reference, it can no
 // longer dangle.
 if (ReturnType->isReferenceType() &&
-!isRecordWithAttr(ReturnType->getPointeeType())) {
+!isGSLOwner(ReturnType->getPointeeType())) {
   for (const IndirectLocalPathEntry &PE : llvm::reverse(Path)) {
 if (PE.Kind == IndirectLocalPathEntry::GslReferenceInit ||
 PE.Kind == IndirectLocalPathEntry::LifetimeBoundCall)
@@ -468,12 +489,17 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr())
   VisitLifetimeBoundArg(Callee->getParamDecl(I), Args[I]);
 else if (EnableGSLAnalysis && I == 0) {
+  // Perform GSL analysis for the first argument
   if (shouldTrackFirstArgument(Callee)) {
 VisitGSLPointerArg(Callee, Args[0]);
-  } else if (auto *CCE = dyn_cast(Call);
- CCE &&
- CCE->getConstructor()->getParent()->hasAttr())

[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread Haojian Wu via cfe-commits

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

>From d1096323a87897b917ede2c29afd42c9f2674cd7 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Thu, 12 Sep 2024 09:27:03 +0200
Subject: [PATCH 1/2] Reapply "[clang] Diagnose dangling issues for the
 "Container" case. (#107213)"

This reverts commit 0683c4e839524c37fe4ddfa1bce1e31ba556041b.
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/AttrDocs.td | 14 
 clang/lib/Sema/CheckExprLifetime.cpp  | 42 +++---
 .../Sema/warn-lifetime-analysis-nocfg.cpp | 77 +++
 4 files changed, 126 insertions(+), 9 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 22749e96a7e3d3..9860b25f2e7fa6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -301,6 +301,8 @@ Improvements to Clang's diagnostics
 
 - Clang now warns for u8 character literals used in C23 with 
``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
 
+- Clang now diagnoses cases where a dangling ``GSLOwner`` object 
is constructed, e.g. ``std::vector v = {std::string()};`` 
(#GH100526).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 546e5100b79dd9..9f72456d2da678 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6690,6 +6690,20 @@ When the Owner's lifetime ends, it will consider the 
Pointer to be dangling.
 P.getInt(); // P is dangling
   }
 
+If a template class is annotated with ``[[gsl::Owner]]``, and the first
+instantiated template argument is a pointer type (raw pointer, or 
``[[gsl::Pointer]]``),
+the analysis will consider the instantiated class as a container of the 
pointer.
+When constructing such an object from a GSL owner object, the analysis will
+assume that the container holds a pointer to the owner object. Consequently,
+when the owner object is destroyed, the pointer will be considered dangling.
+
+.. code-block:: c++
+
+   int f() {
+ std::vector v = {std::string()}; // v holds a dangling 
pointer.
+ std::optional o = std::string(); // o holds a dangling 
pointer.
+   }
+
 }];
 }
 
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index f62e18543851c1..77c73f47658fe1 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -267,6 +267,26 @@ static bool isInStlNamespace(const Decl *D) {
   return DC->isStdNamespace();
 }
 
+// Returns true if the given Record decl is a form of `GSLOwner`
+// type, e.g. std::vector, std::optional.
+static bool isContainerOfPointer(const RecordDecl *Container) {
+  if (const auto *CTSD =
+  dyn_cast_if_present(Container)) {
+if (!CTSD->hasAttr()) // Container must be a GSL owner type.
+  return false;
+const auto &TAs = CTSD->getTemplateArgs();
+return TAs.size() > 0 && TAs[0].getKind() == TemplateArgument::Type &&
+   (isRecordWithAttr(TAs[0].getAsType()) ||
+TAs[0].getAsType()->isPointerType());
+  }
+  return false;
+}
+
+static bool isGSLOwner(QualType T) {
+  return isRecordWithAttr(T) &&
+ !isContainerOfPointer(T->getAsRecordDecl());
+}
+
 static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) {
   if (auto *Conv = dyn_cast_or_null(Callee))
 if (isRecordWithAttr(Conv->getConversionType()))
@@ -275,7 +295,7 @@ static bool shouldTrackImplicitObjectArg(const 
CXXMethodDecl *Callee) {
 return false;
   if (!isRecordWithAttr(
   Callee->getFunctionObjectParameterType()) &&
-  !isRecordWithAttr(Callee->getFunctionObjectParameterType()))
+  !isGSLOwner(Callee->getFunctionObjectParameterType()))
 return false;
   if (Callee->getReturnType()->isPointerType() ||
   isRecordWithAttr(Callee->getReturnType())) {
@@ -413,7 +433,7 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 // Once we initialized a value with a non gsl-owner reference, it can no
 // longer dangle.
 if (ReturnType->isReferenceType() &&
-!isRecordWithAttr(ReturnType->getPointeeType())) {
+!isGSLOwner(ReturnType->getPointeeType())) {
   for (const IndirectLocalPathEntry &PE : llvm::reverse(Path)) {
 if (PE.Kind == IndirectLocalPathEntry::GslReferenceInit ||
 PE.Kind == IndirectLocalPathEntry::LifetimeBoundCall)
@@ -468,12 +488,17 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr())
   VisitLifetimeBoundArg(Callee->getParamDecl(I), Args[I]);
 else if (EnableGSLAnalysis && I == 0) {
+  // Perform GSL analysis for the first argument
   if (shouldTrackFirstArgument(Callee)) {
 VisitGSLPointerArg(Callee, Args[0]);
-  } else if (auto *CCE = dyn_cast(Call);
-

[clang] [Utils] add update-verify-tests.py (PR #97369)

2024-09-12 Thread Nicolai Hähnle via cfe-commits


@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -verify %s
+// RUN: diff %s %s.expected

nhaehnle wrote:

Right, it's all a little mind-bending, but my point is that since you're trying 
to test whether the invocation of `not %{lit} %S/LitTests --update-tests` in 
`lit-plugin.test` updated the tests to look like the `.expected` file, that 
invocation of `diff` should *also* be in `lit-plugin.test`.

You can't have the correctness check for a test that modifies a file be in the 
same file that is being modified. It has to live outside.

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


[clang] [Utils] add update-verify-tests.py (PR #97369)

2024-09-12 Thread Nicolai Hähnle via cfe-commits

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

I didn't go over the core.py implementation with a comb, but this looks 
reasonable to me. Thanks!

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


[clang] 2149914 - [Clang][Parser] Build up QualifiedTemplateName for typo correction (#108148)

2024-09-12 Thread via cfe-commits

Author: Younan Zhang
Date: 2024-09-12T16:36:06+08:00
New Revision: 2149914ea10c05c17fc6e994af5cc96b6b312f1b

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

LOG: [Clang][Parser] Build up QualifiedTemplateName for typo correction 
(#108148)

Since #93433, we have switched to `QualifiedTemplateName`s in more
situations to preserve sugars in diagnostics. However, there is one
missed case in typo correction that might not meet the expectation in
`CheckDeductionGuideDeclarator()`.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplate.cpp
clang/test/Parser/cxx1z-class-template-argument-deduction.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 22749e96a7e3d3..d4db877a823ea5 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -381,6 +381,7 @@ Bug Fixes to C++ Support
 - Fixed a bug where defaulted comparison operators would remove ``const`` from 
base classes. (#GH102588)
 - Fix a crash when using ``source_location`` in the trailing return type of a 
lambda expression. (#GH67134)
 - A follow-up fix was added for (#GH61460), as the previous fix was not 
entirely correct. (#GH86361)
+- Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 513f83146fb59e..e5ea02a919f4eb 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3567,7 +3567,9 @@ bool Sema::resolveAssumedTemplateNameAsType(Scope *S, 
TemplateName &Name,
   if (Corrected && Corrected.getFoundDecl()) {
 diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest)
 << ATN->getDeclName());
-Name = TemplateName(Corrected.getCorrectionDeclAs());
+Name = Context.getQualifiedTemplateName(
+/*NNS=*/nullptr, /*TemplateKeyword=*/false,
+TemplateName(Corrected.getCorrectionDeclAs()));
 return false;
   }
 

diff  --git a/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp 
b/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
index 2dd61baac31b3c..a1594333abae73 100644
--- a/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ b/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -255,3 +255,15 @@ void f() {
   GH57495::vector.d; // expected-error {{cannot use dot operator on a type}}
 }
 }
+
+namespace GH107887 {
+
+namespace a {
+template  struct pair; // expected-note 3{{declared here}}
+}
+template  pair() -> pair;   // expected-error 2{{no template 
named 'pair'}} \
+  // expected-error {{deduction guide 
must be declared in the same scope}} \
+  // expected-error {{cannot be 
deduced}} \
+  // expected-note {{non-deducible 
template parameter 'T2'}}
+
+}



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


[clang] [Clang][Parser] Build up QualifiedTemplateName for typo correction (PR #108148)

2024-09-12 Thread Younan Zhang via cfe-commits

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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Ilya Biryukov via cfe-commits

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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Ilya Biryukov via cfe-commits


@@ -113,9 +113,11 @@ class TreeTransform {
   class ForgetPartiallySubstitutedPackRAII {
 Derived &Self;
 TemplateArgument Old;
+Sema::ArgumentPackSubstitutionIndexRAII ResetPackSubstIndex;

ilya-biryukov wrote:

Could you add a short comment mentioning that we need this because many code 
paths assume correct index corresponds to the pack being present and do not do 
any extra checking?

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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov approved this pull request.

LGTM from my side if all other tests pass.
Given that it's a small change and bugfix, I think it should be okay to land 
this without waiting for other reviewers. We could always follow up with more 
fixes if they have additional comments.

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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Ilya Biryukov via cfe-commits

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


[clang] [llvm] [SPIR-V] Add SPIR-V structurizer (PR #107408)

2024-09-12 Thread Nathan Gauër via cfe-commits

Keenuts wrote:

Thanks for looking into this.
I don't know what's causing the ""Virtual register defs don't dominate all 
uses", as some cases are located in the middle of a block and doesn't seem to 
be related to BB sorting (even though this is probably the cause)

```
127 bb.10.do.end8:
[...]
133   %96:iid(s32) = nsw G_ADD %97:iid, %98:iid
134   %97:iid(s32) = GET_ID %45:iid(s32)
[...]
139   G_BR %bb.11
```

Need to investigate this.
Also will investigate the hang you observe.

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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Younan Zhang via cfe-commits


@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s

zyn0217 wrote:

Can you move the test to a pre-existing file instead of adding a new one? e.g. 
somewhere like clang/test/SemaTemplate/pack-deduction.cpp, since this patch is 
affecting something that has been around for many years.

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


[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-12 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat commented:

I re-reviewed the commit and added two very minor remarks, otherwise LGTM.

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


[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-12 Thread Donát Nagy via cfe-commits

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


[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-12 Thread Donát Nagy via cfe-commits


@@ -327,6 +327,8 @@ Static Analyzer
 New features
 
 
+- Now CSA models `builtin_*_overflow` functions.

NagyDonat wrote:

```suggestion
- Now CSA models `__builtin_*_overflow` functions.
```

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


[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-12 Thread Donát Nagy via cfe-commits


@@ -16,21 +16,93 @@
 
 #include "clang/Basic/Builtins.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Checkers/Taint.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 
 using namespace clang;
 using namespace ento;
+using namespace taint;
 
 namespace {
 
+QualType getSufficientTypeForOverflowOp(CheckerContext &C, const QualType &T) {
+  // Calling a builtin with a non-integer type result produces compiler error.
+  assert(T->isIntegerType());
+
+  ASTContext &ACtx = C.getASTContext();
+
+  unsigned BitWidth = ACtx.getIntWidth(T);
+  return ACtx.getIntTypeForBitwidth(BitWidth * 2, T->isSignedIntegerType());

NagyDonat wrote:

What happens if `BitWidth * 2` is too large and there is no standard / 
semi-standard (like `__int128`) type to represent it? Do we get a compiler 
error at an earlier step? Does this call crash?

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


[clang] [llvm] Delete the clang-format Visual Studio plugin code (PR #108342)

2024-09-12 Thread Tobias Hieta via cfe-commits

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

LGTM. Let's remove it.

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


[clang] [clang-tools-extra] [clangd] Collect comments from function definitions into the index (PR #67802)

2024-09-12 Thread Christian Kandeler via cfe-commits

https://github.com/ckandeler updated 
https://github.com/llvm/llvm-project/pull/67802

>From dec33143e617967dee46ce4123a2e298220d73fc Mon Sep 17 00:00:00 2001
From: Christian Kandeler 
Date: Fri, 29 Sep 2023 15:01:58 +0200
Subject: [PATCH] [clangd] Collect comments from function definitions into the
 index

This is useful with projects that put their (doxygen) comments at the
implementation site, rather than the header.
---
 clang-tools-extra/clangd/index/Symbol.h   |  4 +-
 .../clangd/index/SymbolCollector.cpp  | 56 +++
 .../clangd/index/SymbolCollector.h|  3 +-
 .../clangd/unittests/SymbolCollectorTests.cpp | 52 +
 clang/lib/AST/ASTContext.cpp  | 11 +++-
 5 files changed, 113 insertions(+), 13 deletions(-)

diff --git a/clang-tools-extra/clangd/index/Symbol.h 
b/clang-tools-extra/clangd/index/Symbol.h
index 1aa5265299231b..62c47ddfc5758d 100644
--- a/clang-tools-extra/clangd/index/Symbol.h
+++ b/clang-tools-extra/clangd/index/Symbol.h
@@ -145,9 +145,11 @@ struct Symbol {
 ImplementationDetail = 1 << 2,
 /// Symbol is visible to other files (not e.g. a static helper function).
 VisibleOutsideFile = 1 << 3,
+/// Symbol has an attached documentation comment.
+HasDocComment = 1 << 4
   };
-
   SymbolFlag Flags = SymbolFlag::None;
+
   /// FIXME: also add deprecation message and fixit?
 };
 
diff --git a/clang-tools-extra/clangd/index/SymbolCollector.cpp 
b/clang-tools-extra/clangd/index/SymbolCollector.cpp
index 5c4e2150cf3123..066c7428ace555 100644
--- a/clang-tools-extra/clangd/index/SymbolCollector.cpp
+++ b/clang-tools-extra/clangd/index/SymbolCollector.cpp
@@ -635,17 +635,20 @@ bool SymbolCollector::handleDeclOccurrence(
 return true;
 
   const Symbol *BasicSymbol = Symbols.find(ID);
-  if (isPreferredDeclaration(*OriginalDecl, Roles))
+  bool SkipDocCheckInDef = false;
+  if (isPreferredDeclaration(*OriginalDecl, Roles)) {
 // If OriginalDecl is preferred, replace/create the existing canonical
 // declaration (e.g. a class forward declaration). There should be at most
 // one duplicate as we expect to see only one preferred declaration per
 // TU, because in practice they are definitions.
 BasicSymbol = addDeclaration(*OriginalDecl, std::move(ID), IsMainFileOnly);
-  else if (!BasicSymbol || DeclIsCanonical)
+SkipDocCheckInDef = true;
+  } else if (!BasicSymbol || DeclIsCanonical) {
 BasicSymbol = addDeclaration(*ND, std::move(ID), IsMainFileOnly);
+  }
 
   if (Roles & static_cast(index::SymbolRole::Definition))
-addDefinition(*OriginalDecl, *BasicSymbol);
+addDefinition(*OriginalDecl, *BasicSymbol, SkipDocCheckInDef);
 
   return true;
 }
@@ -1025,16 +1028,28 @@ const Symbol *SymbolCollector::addDeclaration(const 
NamedDecl &ND, SymbolID ID,
   *ASTCtx, *PP, CodeCompletionContext::CCC_Symbol, *CompletionAllocator,
   *CompletionTUInfo,
   /*IncludeBriefComments*/ false);
-  std::string Documentation =
-  formatDocumentation(*CCS, getDocComment(Ctx, SymbolCompletion,
-  /*CommentsFromHeaders=*/true));
+  std::string DocComment;
+  std::string Documentation;
+  bool AlreadyHasDoc = S.Flags & Symbol::HasDocComment;
+  if (!AlreadyHasDoc) {
+DocComment = getDocComment(Ctx, SymbolCompletion,
+   /*CommentsFromHeaders=*/true);
+Documentation = formatDocumentation(*CCS, DocComment);
+  }
+  const auto UpdateDoc = [&] {
+if (!AlreadyHasDoc) {
+  if (!DocComment.empty())
+S.Flags |= Symbol::HasDocComment;
+  S.Documentation = Documentation;
+}
+  };
   if (!(S.Flags & Symbol::IndexedForCodeCompletion)) {
 if (Opts.StoreAllDocumentation)
-  S.Documentation = Documentation;
+  UpdateDoc();
 Symbols.insert(S);
 return Symbols.find(S.ID);
   }
-  S.Documentation = Documentation;
+  UpdateDoc();
   std::string Signature;
   std::string SnippetSuffix;
   getSignature(*CCS, &Signature, &SnippetSuffix, SymbolCompletion.Kind,
@@ -1058,8 +1073,8 @@ const Symbol *SymbolCollector::addDeclaration(const 
NamedDecl &ND, SymbolID ID,
   return Symbols.find(S.ID);
 }
 
-void SymbolCollector::addDefinition(const NamedDecl &ND,
-const Symbol &DeclSym) {
+void SymbolCollector::addDefinition(const NamedDecl &ND, const Symbol &DeclSym,
+bool SkipDocCheck) {
   if (DeclSym.Definition)
 return;
   const auto &SM = ND.getASTContext().getSourceManager();
@@ -1074,6 +1089,27 @@ void SymbolCollector::addDefinition(const NamedDecl &ND,
   Symbol S = DeclSym;
   // FIXME: use the result to filter out symbols.
   S.Definition = *DefLoc;
+
+  std::string DocComment;
+  std::string Documentation;
+  if (!SkipDocCheck && !(S.Flags & Symbol::HasDocComment) &&
+  (llvm::isa(ND) || llvm::isa(ND))) {
+CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
+const auto *CCS = Symbol

[clang] 63dab72 - [Sema] Remove unused variable 'FromExtType' [NFC]

2024-09-12 Thread Mikael Holmen via cfe-commits

Author: Mikael Holmen
Date: 2024-09-12T11:23:13+02:00
New Revision: 63dab72fd5b96cd98bba6d041d08bb2a6f3aaa0a

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

LOG: [Sema] Remove unused variable 'FromExtType' [NFC]

Last use of the variable was removed in a29afb754fb4
 [HLSL] Allow truncation to scalar (#104844)

gcc warned about this:
  ../../clang/lib/Sema/SemaOverload.cpp:2070:15: warning: unused variable 
'FromExtType' [-Wunused-variable]
  2070 | if (auto *FromExtType = FromType->getAs()) {
   |   ^~~

Added: 


Modified: 
clang/lib/Sema/SemaOverload.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index ea72d3f003cbc4..a155bb2fd3ba2a 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2067,7 +2067,7 @@ static bool IsVectorConversion(Sema &S, QualType 
FromType, QualType ToType,
 
   // There are no conversions between extended vector types, only identity.
   if (auto *ToExtType = ToType->getAs()) {
-if (auto *FromExtType = FromType->getAs()) {
+if (FromType->getAs()) {
   // There are no conversions between extended vector types other than the
   // identity conversion.
   return false;



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


[clang] [clang-tools-extra] [clang] Extend diagnose_if to accept more detailed warning information (PR #70976)

2024-09-12 Thread Nikolas Klauser via cfe-commits


@@ -870,7 +872,8 @@ class DiagnosticsEngine : public 
RefCountedBase {
   /// \param FormatString A fixed diagnostic format string that will be hashed
   /// and mapped to a unique DiagID.
   template 
-  unsigned getCustomDiagID(Level L, const char (&FormatString)[N]) {
+  [[deprecated("Use a CustomDiagDesc instead of a Level")]] unsigned

philnik777 wrote:

I guess so. Should we maybe enable `-Werror` in the pre-commit CI to catch 
these kinds of problems?

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


[clang] [clang-tools-extra] [clang] Extend diagnose_if to accept more detailed warning information (PR #70976)

2024-09-12 Thread Nikolas Klauser via cfe-commits


@@ -200,7 +273,33 @@ class DiagnosticIDs : public RefCountedBase 
{
   // FIXME: Replace this function with a create-only facilty like
   // createCustomDiagIDFromFormatString() to enforce safe usage. At the time of
   // writing, nearly all callers of this function were invalid.
-  unsigned getCustomDiagID(Level L, StringRef FormatString);
+  unsigned getCustomDiagID(CustomDiagDesc Diag);
+
+  [[deprecated("Use a CustomDiagDesc instead of a Level")]] unsigned
+  getCustomDiagID(Level Level, StringRef Message) {
+return getCustomDiagID([&]() -> CustomDiagDesc {
+  switch (Level) {
+  case DiagnosticIDs::Level::Ignored:
+return {diag::Severity::Ignored, std::string(Message), CLASS_WARNING,

philnik777 wrote:

Yes, this is just matching the previous behaviour. I agree that it doesn't make 
a ton of sense in some cases, but this should go at some point anyways, so I 
didn't want to mess with it.

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


[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-12 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa created 
https://github.com/llvm/llvm-project/pull/108352

This PR introduces new WebKit checker to warn a member variable that is a raw 
reference or a raw pointer to an object, which is capable of creating a 
CheckedRef/CheckedPtr.

>From ac0447762c98da3cfb41a6b462034e3ab410bc33 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Thu, 12 Sep 2024 02:13:12 -0700
Subject: [PATCH] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member
 variable checker for CheckedPtr/CheckedRef

This PR introduces new WebKit checker to warn a member variable that is a raw 
reference or
a raw pointer to an object, which is capable of creating a 
CheckedRef/CheckedPtr.
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td |  4 +
 .../StaticAnalyzer/Checkers/CMakeLists.txt|  2 +-
 .../Checkers/WebKit/PtrTypesSemantics.cpp | 37 ++--
 .../Checkers/WebKit/PtrTypesSemantics.h   |  7 ++
 ...Checker.cpp => RawPtrRefMemberChecker.cpp} | 88 ---
 .../Analysis/Checkers/WebKit/mock-types.h | 48 ++
 .../Checkers/WebKit/unchecked-members.cpp | 53 +++
 .../lib/StaticAnalyzer/Checkers/BUILD.gn  |  2 +-
 8 files changed, 219 insertions(+), 22 deletions(-)
 rename clang/lib/StaticAnalyzer/Checkers/WebKit/{NoUncountedMembersChecker.cpp 
=> RawPtrRefMemberChecker.cpp} (66%)
 create mode 100644 clang/test/Analysis/Checkers/WebKit/unchecked-members.cpp

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 585246547b3dce..4759f680fb4ff7 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1771,6 +1771,10 @@ def UncountedLambdaCapturesChecker : 
Checker<"UncountedLambdaCapturesChecker">,
 
 let ParentPackage = WebKitAlpha in {
 
+def NoUncheckedPtrMemberChecker : Checker<"NoUncheckedPtrMemberChecker">,
+  HelpText<"Check for no unchecked member variables.">,
+  Documentation;
+
 def UncountedCallArgsChecker : Checker<"UncountedCallArgsChecker">,
   HelpText<"Check uncounted call arguments.">,
   Documentation;
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 414282d58f779f..6da3665ab9a4df 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -132,7 +132,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   VLASizeChecker.cpp
   ValistChecker.cpp
   VirtualCallChecker.cpp
-  WebKit/NoUncountedMembersChecker.cpp
+  WebKit/RawPtrRefMemberChecker.cpp
   WebKit/ASTUtils.cpp
   WebKit/PtrTypesSemantics.cpp
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index f48b2fd9dca71b..09298102993f99 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -53,7 +53,9 @@ hasPublicMethodInBase(const CXXBaseSpecifier *Base, const 
char *NameToMatch) {
   return hasPublicMethodInBaseClass(R, NameToMatch) ? R : nullptr;
 }
 
-std::optional isRefCountable(const CXXRecordDecl* R)
+std::optional isSmartPtrCompatible(const CXXRecordDecl *R,
+ const char *IncMethodName,
+ const char *DecMethodName)
 {
   assert(R);
 
@@ -61,8 +63,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   if (!R)
 return std::nullopt;
 
-  bool hasRef = hasPublicMethodInBaseClass(R, "ref");
-  bool hasDeref = hasPublicMethodInBaseClass(R, "deref");
+  bool hasRef = hasPublicMethodInBaseClass(R, IncMethodName);
+  bool hasDeref = hasPublicMethodInBaseClass(R, DecMethodName);
   if (hasRef && hasDeref)
 return true;
 
@@ -71,8 +73,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   bool AnyInconclusiveBase = false;
   const auto hasPublicRefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasRefInBase = clang::hasPublicMethodInBase(Base, "ref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName);
 if (!hasRefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -87,8 +89,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   Paths.clear();
   const auto hasPublicDerefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasDerefInBase = clang::hasPublicMethodInBase(Base, "deref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasDerefInBase = clang::hasPublicMethodInBase(Base, 
DecMethodName);
 if (!hasDerefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -103,11 +105,23 @@ std::optional isRefCountable(const CXX

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-12 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-static-analyzer-1

@llvm/pr-subscribers-clang

Author: Ryosuke Niwa (rniwa)


Changes

This PR introduces new WebKit checker to warn a member variable that is a raw 
reference or a raw pointer to an object, which is capable of creating a 
CheckedRef/CheckedPtr.

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


8 Files Affected:

- (modified) clang/include/clang/StaticAnalyzer/Checkers/Checkers.td (+4) 
- (modified) clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt (+1-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
(+30-7) 
- (modified) clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h (+7) 
- (renamed) clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp 
(+75-13) 
- (modified) clang/test/Analysis/Checkers/WebKit/mock-types.h (+48) 
- (added) clang/test/Analysis/Checkers/WebKit/unchecked-members.cpp (+53) 
- (modified) llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Checkers/BUILD.gn 
(+1-1) 


``diff
diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 585246547b3dce..4759f680fb4ff7 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1771,6 +1771,10 @@ def UncountedLambdaCapturesChecker : 
Checker<"UncountedLambdaCapturesChecker">,
 
 let ParentPackage = WebKitAlpha in {
 
+def NoUncheckedPtrMemberChecker : Checker<"NoUncheckedPtrMemberChecker">,
+  HelpText<"Check for no unchecked member variables.">,
+  Documentation;
+
 def UncountedCallArgsChecker : Checker<"UncountedCallArgsChecker">,
   HelpText<"Check uncounted call arguments.">,
   Documentation;
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 414282d58f779f..6da3665ab9a4df 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -132,7 +132,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   VLASizeChecker.cpp
   ValistChecker.cpp
   VirtualCallChecker.cpp
-  WebKit/NoUncountedMembersChecker.cpp
+  WebKit/RawPtrRefMemberChecker.cpp
   WebKit/ASTUtils.cpp
   WebKit/PtrTypesSemantics.cpp
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index f48b2fd9dca71b..09298102993f99 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -53,7 +53,9 @@ hasPublicMethodInBase(const CXXBaseSpecifier *Base, const 
char *NameToMatch) {
   return hasPublicMethodInBaseClass(R, NameToMatch) ? R : nullptr;
 }
 
-std::optional isRefCountable(const CXXRecordDecl* R)
+std::optional isSmartPtrCompatible(const CXXRecordDecl *R,
+ const char *IncMethodName,
+ const char *DecMethodName)
 {
   assert(R);
 
@@ -61,8 +63,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   if (!R)
 return std::nullopt;
 
-  bool hasRef = hasPublicMethodInBaseClass(R, "ref");
-  bool hasDeref = hasPublicMethodInBaseClass(R, "deref");
+  bool hasRef = hasPublicMethodInBaseClass(R, IncMethodName);
+  bool hasDeref = hasPublicMethodInBaseClass(R, DecMethodName);
   if (hasRef && hasDeref)
 return true;
 
@@ -71,8 +73,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   bool AnyInconclusiveBase = false;
   const auto hasPublicRefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasRefInBase = clang::hasPublicMethodInBase(Base, "ref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName);
 if (!hasRefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -87,8 +89,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   Paths.clear();
   const auto hasPublicDerefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasDerefInBase = clang::hasPublicMethodInBase(Base, "deref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasDerefInBase = clang::hasPublicMethodInBase(Base, 
DecMethodName);
 if (!hasDerefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -103,11 +105,23 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   return hasRef && hasDeref;
 }
 
+std::optional isRefCountable(const clang::CXXRecordDecl *R) {
+  return isSmartPtrCompatible(R, "ref", "deref");
+}
+
+std::optional isCheckedPtrCapable(const clang::CXXRecordDecl *R) {
+  return isSmartPtrCompatible(R, "incrementPtrCount", "decrementPtrCount");
+}
+
 bool isRefType(const std::string &Name) {
   retur

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-12 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa updated 
https://github.com/llvm/llvm-project/pull/108352

>From ac0447762c98da3cfb41a6b462034e3ab410bc33 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Thu, 12 Sep 2024 02:13:12 -0700
Subject: [PATCH 1/2] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce
 member variable checker for CheckedPtr/CheckedRef

This PR introduces new WebKit checker to warn a member variable that is a raw 
reference or
a raw pointer to an object, which is capable of creating a 
CheckedRef/CheckedPtr.
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td |  4 +
 .../StaticAnalyzer/Checkers/CMakeLists.txt|  2 +-
 .../Checkers/WebKit/PtrTypesSemantics.cpp | 37 ++--
 .../Checkers/WebKit/PtrTypesSemantics.h   |  7 ++
 ...Checker.cpp => RawPtrRefMemberChecker.cpp} | 88 ---
 .../Analysis/Checkers/WebKit/mock-types.h | 48 ++
 .../Checkers/WebKit/unchecked-members.cpp | 53 +++
 .../lib/StaticAnalyzer/Checkers/BUILD.gn  |  2 +-
 8 files changed, 219 insertions(+), 22 deletions(-)
 rename clang/lib/StaticAnalyzer/Checkers/WebKit/{NoUncountedMembersChecker.cpp 
=> RawPtrRefMemberChecker.cpp} (66%)
 create mode 100644 clang/test/Analysis/Checkers/WebKit/unchecked-members.cpp

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 585246547b3dce..4759f680fb4ff7 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1771,6 +1771,10 @@ def UncountedLambdaCapturesChecker : 
Checker<"UncountedLambdaCapturesChecker">,
 
 let ParentPackage = WebKitAlpha in {
 
+def NoUncheckedPtrMemberChecker : Checker<"NoUncheckedPtrMemberChecker">,
+  HelpText<"Check for no unchecked member variables.">,
+  Documentation;
+
 def UncountedCallArgsChecker : Checker<"UncountedCallArgsChecker">,
   HelpText<"Check uncounted call arguments.">,
   Documentation;
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 414282d58f779f..6da3665ab9a4df 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -132,7 +132,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   VLASizeChecker.cpp
   ValistChecker.cpp
   VirtualCallChecker.cpp
-  WebKit/NoUncountedMembersChecker.cpp
+  WebKit/RawPtrRefMemberChecker.cpp
   WebKit/ASTUtils.cpp
   WebKit/PtrTypesSemantics.cpp
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index f48b2fd9dca71b..09298102993f99 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -53,7 +53,9 @@ hasPublicMethodInBase(const CXXBaseSpecifier *Base, const 
char *NameToMatch) {
   return hasPublicMethodInBaseClass(R, NameToMatch) ? R : nullptr;
 }
 
-std::optional isRefCountable(const CXXRecordDecl* R)
+std::optional isSmartPtrCompatible(const CXXRecordDecl *R,
+ const char *IncMethodName,
+ const char *DecMethodName)
 {
   assert(R);
 
@@ -61,8 +63,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   if (!R)
 return std::nullopt;
 
-  bool hasRef = hasPublicMethodInBaseClass(R, "ref");
-  bool hasDeref = hasPublicMethodInBaseClass(R, "deref");
+  bool hasRef = hasPublicMethodInBaseClass(R, IncMethodName);
+  bool hasDeref = hasPublicMethodInBaseClass(R, DecMethodName);
   if (hasRef && hasDeref)
 return true;
 
@@ -71,8 +73,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   bool AnyInconclusiveBase = false;
   const auto hasPublicRefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasRefInBase = clang::hasPublicMethodInBase(Base, "ref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName);
 if (!hasRefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -87,8 +89,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   Paths.clear();
   const auto hasPublicDerefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasDerefInBase = clang::hasPublicMethodInBase(Base, "deref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasDerefInBase = clang::hasPublicMethodInBase(Base, 
DecMethodName);
 if (!hasDerefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -103,11 +105,23 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   return hasRef && hasDeref;
 }
 
+std::optional isRefCountable(const clang::CXXRecordDecl *R) {
+  return isSmartPtrCompatible(R, "ref", "deref");
+}
+
+st

[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)

2024-09-12 Thread KristĂłf Umann via cfe-commits

https://github.com/Szelethus commented:

Alright, I think this patch is good from a design standpoint! I'll get into the 
nitty-gritty in a bit.

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


[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)

2024-09-12 Thread KristĂłf Umann via cfe-commits


@@ -86,6 +124,19 @@ Options
this option enables.
Default is `true`.
 
+.. _option-ReportDefaultFunctions:
+
+.. option:: ReportDefaultFunctions
+
+When `true`, the check reports the default set of functions.
+Default is `true`.

Szelethus wrote:

"You can consider setting this to false if you only want to see custom 
functions matched via `CustomFunctions`"

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


[clang-tools-extra] [clang-tidy] Add user-defined functions to `bugprone-unsafe-functions` check (PR #106350)

2024-09-12 Thread KristĂłf Umann via cfe-commits

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


[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-12 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 b06954a5d02a41a38b72f7914c791428ccd95318 
5abb2493cfc67f2bd1dcdd946ed9ecbef8929d2b --extensions h,cpp -- 
clang/test/Analysis/Checkers/WebKit/unchecked-members.cpp 
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h 
clang/test/Analysis/Checkers/WebKit/mock-types.h 
clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index 0929810299..7084a09a03 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -55,8 +55,7 @@ hasPublicMethodInBase(const CXXBaseSpecifier *Base, const 
char *NameToMatch) {
 
 std::optional isSmartPtrCompatible(const CXXRecordDecl *R,
  const char *IncMethodName,
- const char *DecMethodName)
-{
+ const char *DecMethodName) {
   assert(R);
 
   R = R->getDefinition();
@@ -72,15 +71,15 @@ std::optional isSmartPtrCompatible(const 
CXXRecordDecl *R,
   Paths.setOrigin(const_cast(R));
 
   bool AnyInconclusiveBase = false;
-  const auto hasPublicRefInBase =
-  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName);
-if (!hasRefInBase) {
-  AnyInconclusiveBase = true;
-  return false;
-}
-return (*hasRefInBase) != nullptr;
-  };
+  const auto hasPublicRefInBase = [&](const CXXBaseSpecifier *Base,
+  CXXBasePath &) {
+auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName);
+if (!hasRefInBase) {
+  AnyInconclusiveBase = true;
+  return false;
+}
+return (*hasRefInBase) != nullptr;
+  };
 
   hasRef = hasRef || R->lookupInBases(hasPublicRefInBase, Paths,
   /*LookupInDependent =*/true);
@@ -88,15 +87,15 @@ std::optional isSmartPtrCompatible(const 
CXXRecordDecl *R,
 return std::nullopt;
 
   Paths.clear();
-  const auto hasPublicDerefInBase =
-  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasDerefInBase = clang::hasPublicMethodInBase(Base, 
DecMethodName);
-if (!hasDerefInBase) {
-  AnyInconclusiveBase = true;
-  return false;
-}
-return (*hasDerefInBase) != nullptr;
-  };
+  const auto hasPublicDerefInBase = [&](const CXXBaseSpecifier *Base,
+CXXBasePath &) {
+auto hasDerefInBase = clang::hasPublicMethodInBase(Base, DecMethodName);
+if (!hasDerefInBase) {
+  AnyInconclusiveBase = true;
+  return false;
+}
+return (*hasDerefInBase) != nullptr;
+  };
   hasDeref = hasDeref || R->lookupInBases(hasPublicDerefInBase, Paths,
   /*LookupInDependent =*/true);
   if (AnyInconclusiveBase)
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
index 08f9be4997..d58e54d448 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.h
@@ -42,7 +42,7 @@ std::optional isRefCountable(const 
clang::CXXRecordDecl* Class);
 
 /// \returns true if \p Class is checked-pointer compatible, false if not,
 /// std::nullopt if inconclusive.
-std::optional isCheckedPtrCapable(const clang::CXXRecordDecl* Class);
+std::optional isCheckedPtrCapable(const clang::CXXRecordDecl *Class);
 
 /// \returns true if \p Class is ref-counted, false if not.
 bool isRefCounted(const clang::CXXRecordDecl *Class);
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
index 9ea0abbee9..54d89e29a5 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/RawPtrRefMemberChecker.cpp
@@ -35,10 +35,11 @@ public:
   RawPtrRefMemberChecker(const char *description)
   : Bug(this, description, "WebKit coding guidelines") {}
 
-  virtual std::optional isPtrCompatible(const clang::CXXRecordDecl *) 
const = 0;
+  virtual std::optional
+  isPtrCompatible(const clang::CXXRecordDecl *) const = 0;
   virtual bool isPtrCls(const clang::CXXRecordDecl *) const = 0;
-  virtual const char* typeName() const = 0;
-  virtual const char* invariantName() const = 0;
+  virtual const char *typeName() const = 0;
+  virtual

[clang] [RISCV][FMV] Support target_clones (PR #85786)

2024-09-12 Thread Piyou Chen via cfe-commits

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

>From 395ce72afbf9e4b12fcbfaf9cdbda8921c9ff72a Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Tue, 23 Jul 2024 19:59:06 -0700
Subject: [PATCH 01/18] [RISCV][FMV] Support target_clones

---
 .../clang/Basic/DiagnosticFrontendKinds.td|   4 +
 clang/include/clang/Basic/TargetInfo.h|   3 +-
 clang/include/clang/Sema/SemaRISCV.h  |   1 +
 clang/lib/AST/ASTContext.cpp  |  12 +
 clang/lib/CodeGen/CodeGenFunction.cpp | 106 -
 clang/lib/CodeGen/CodeGenFunction.h   |   3 +
 clang/lib/CodeGen/CodeGenModule.cpp   |   5 +-
 clang/lib/CodeGen/Targets/RISCV.cpp   |  35 +++
 clang/lib/Sema/SemaDeclAttr.cpp   |  30 +++
 clang/lib/Sema/SemaRISCV.cpp  |  10 +
 .../attr-target-clones-riscv-invalid.c|   8 +
 clang/test/CodeGen/attr-target-clones-riscv.c | 211 ++
 .../CodeGenCXX/attr-target-clones-riscv.cpp   | 210 +
 .../test/SemaCXX/attr-target-clones-riscv.cpp |  35 +++
 14 files changed, 670 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/CodeGen/attr-target-clones-riscv-invalid.c
 create mode 100644 clang/test/CodeGen/attr-target-clones-riscv.c
 create mode 100644 clang/test/CodeGenCXX/attr-target-clones-riscv.cpp
 create mode 100644 clang/test/SemaCXX/attr-target-clones-riscv.cpp

diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 8a1462c670d68f..0c870a1f3f1442 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -378,4 +378,8 @@ def warn_missing_symbol_graph_dir : Warning<
 def err_ast_action_on_llvm_ir : Error<
   "cannot apply AST actions to LLVM IR file '%0'">,
   DefaultFatal;
+
+def err_os_unsupport_riscv_target_clones : Error<
+  "target_clones is currently only supported on Linux">;
+
 }
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index a58fb5f9792720..f31d88a354ea28 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1496,7 +1496,8 @@ class TargetInfo : public TransferrableTargetInfo,
   /// Identify whether this target supports multiversioning of functions,
   /// which requires support for cpu_supports and cpu_is functionality.
   bool supportsMultiVersioning() const {
-return getTriple().isX86() || getTriple().isAArch64();
+return getTriple().isX86() || getTriple().isAArch64() ||
+   getTriple().isRISCV();
   }
 
   /// Identify whether this target supports IFuncs.
diff --git a/clang/include/clang/Sema/SemaRISCV.h 
b/clang/include/clang/Sema/SemaRISCV.h
index d62fca8128b2a3..d7f17797283b86 100644
--- a/clang/include/clang/Sema/SemaRISCV.h
+++ b/clang/include/clang/Sema/SemaRISCV.h
@@ -43,6 +43,7 @@ class SemaRISCV : public SemaBase {
 
   void handleInterruptAttr(Decl *D, const ParsedAttr &AL);
   bool isAliasValid(unsigned BuiltinID, llvm::StringRef AliasName);
+  bool isValidFMVExtension(StringRef Ext);
 
   /// Indicate RISC-V vector builtin functions enabled or not.
   bool DeclareRVVBuiltins = false;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b201d201e1ea6a..a4d123219770bb 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -14181,6 +14181,18 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
   Target->getTargetOpts().FeaturesAsWritten.begin(),
   Target->getTargetOpts().FeaturesAsWritten.end());
   Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, 
Features);
+} else if (Target->getTriple().isRISCV()) {
+  StringRef VersionStr = TC->getFeatureStr(GD.getMultiVersionIndex());
+  std::vector Features;
+  if (VersionStr != "default") {
+ParsedTargetAttr ParsedAttr = Target->parseTargetAttr(VersionStr);
+Features.insert(Features.begin(), ParsedAttr.Features.begin(),
+ParsedAttr.Features.end());
+  }
+  Features.insert(Features.begin(),
+  Target->getTargetOpts().FeaturesAsWritten.begin(),
+  Target->getTargetOpts().FeaturesAsWritten.end());
+  Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, 
Features);
 } else {
   std::vector Features;
   StringRef VersionStr = TC->getFeatureStr(GD.getMultiVersionIndex());
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index eff8c9f5694084..d625dde684933b 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2877,12 +2877,116 @@ void CodeGenFunction::EmitMultiVersionResolver(
   case llvm::Triple::aarch64:
 EmitAArch64MultiVersionResolver(Resolver, Options);
 return;
+  case llvm::Triple::riscv32:
+  case 

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

2024-09-12 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.

LGTM!

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


[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

2024-09-12 Thread Gábor Horváth via cfe-commits

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


[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

2024-09-12 Thread Gábor Horváth via cfe-commits


@@ -300,6 +300,8 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses cases where a dangling ``GSLOwner`` object 
is constructed, e.g. ``std::vector v = {std::string()};`` 
(#GH100526).
 
+- Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and 
`[[clang::lifetimebound]]` are used together (#GH108272).

Xazax-hun wrote:

Do we fix a problem that was present in the previous release? Or is this 
something that was introduced since the branching? I think in case users of 
releases never saw these bogus warnings, there is no reason to mention this in 
the release notes. 

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


[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-12 Thread Pavel Skripkin via cfe-commits


@@ -16,21 +16,93 @@
 
 #include "clang/Basic/Builtins.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
+#include "clang/StaticAnalyzer/Checkers/Taint.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
 
 using namespace clang;
 using namespace ento;
+using namespace taint;
 
 namespace {
 
+QualType getSufficientTypeForOverflowOp(CheckerContext &C, const QualType &T) {
+  // Calling a builtin with a non-integer type result produces compiler error.
+  assert(T->isIntegerType());
+
+  ASTContext &ACtx = C.getASTContext();
+
+  unsigned BitWidth = ACtx.getIntWidth(T);
+  return ACtx.getIntTypeForBitwidth(BitWidth * 2, T->isSignedIntegerType());

pskrgag wrote:

Based on `getIntTypeForBitwith` source, it just returns `128` bit ingetegers 
and does not crash:

```cpp
  if (!QualTy && DestWidth == 128)
return Signed ? Int128Ty : UnsignedInt128Ty;
```

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


[clang] [llvm] [HLSL] Implement elementwise popcount (PR #108121)

2024-09-12 Thread Simon Pilgrim via cfe-commits


@@ -505,6 +505,27 @@ void test_builtin_elementwise_log2(int i, float f, double 
d, float4 v, int3 iv,
   // expected-error@-1 {{1st argument must be a floating point type (was 
'unsigned4' (vector of 4 'unsigned int' values))}}
 }
 
+void test_builtin_elementwise_popcount(int i, float f, double d, float4 v, 
int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_popcount(i);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of 
incompatible type 'int'}}
+
+  i = __builtin_elementwise_popcount();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 
0}}
+
+  i = __builtin_elementwise_popcount(f);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 
'float')}}
+
+  i = __builtin_elementwise_popcount(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 
2}}
+
+  u = __builtin_elementwise_popcount(d);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 
'double')}}
+
+  v = __builtin_elementwise_popcount(v);
+  // expected-error@-1 {{1st argument must be a vector of integers (was 
'float4' (vector of 4 'float' values))}}

RKSimon wrote:

please can you add tests for vector element count mismatches and implicit arg 
vs result vector extension/truncation/sign changes

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


[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.

LGTM!

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


[clang] Reland: [clang] Diagnose dangling issues for the "Container" case. #107213 (PR #108344)

2024-09-12 Thread Haojian Wu via cfe-commits

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

>From d1096323a87897b917ede2c29afd42c9f2674cd7 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Thu, 12 Sep 2024 09:27:03 +0200
Subject: [PATCH 1/2] Reapply "[clang] Diagnose dangling issues for the
 "Container" case. (#107213)"

This reverts commit 0683c4e839524c37fe4ddfa1bce1e31ba556041b.
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/AttrDocs.td | 14 
 clang/lib/Sema/CheckExprLifetime.cpp  | 42 +++---
 .../Sema/warn-lifetime-analysis-nocfg.cpp | 77 +++
 4 files changed, 126 insertions(+), 9 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 22749e96a7e3d3..9860b25f2e7fa6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -301,6 +301,8 @@ Improvements to Clang's diagnostics
 
 - Clang now warns for u8 character literals used in C23 with 
``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
 
+- Clang now diagnoses cases where a dangling ``GSLOwner`` object 
is constructed, e.g. ``std::vector v = {std::string()};`` 
(#GH100526).
+
 Improvements to Clang's time-trace
 --
 
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 546e5100b79dd9..9f72456d2da678 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -6690,6 +6690,20 @@ When the Owner's lifetime ends, it will consider the 
Pointer to be dangling.
 P.getInt(); // P is dangling
   }
 
+If a template class is annotated with ``[[gsl::Owner]]``, and the first
+instantiated template argument is a pointer type (raw pointer, or 
``[[gsl::Pointer]]``),
+the analysis will consider the instantiated class as a container of the 
pointer.
+When constructing such an object from a GSL owner object, the analysis will
+assume that the container holds a pointer to the owner object. Consequently,
+when the owner object is destroyed, the pointer will be considered dangling.
+
+.. code-block:: c++
+
+   int f() {
+ std::vector v = {std::string()}; // v holds a dangling 
pointer.
+ std::optional o = std::string(); // o holds a dangling 
pointer.
+   }
+
 }];
 }
 
diff --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index f62e18543851c1..77c73f47658fe1 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -267,6 +267,26 @@ static bool isInStlNamespace(const Decl *D) {
   return DC->isStdNamespace();
 }
 
+// Returns true if the given Record decl is a form of `GSLOwner`
+// type, e.g. std::vector, std::optional.
+static bool isContainerOfPointer(const RecordDecl *Container) {
+  if (const auto *CTSD =
+  dyn_cast_if_present(Container)) {
+if (!CTSD->hasAttr()) // Container must be a GSL owner type.
+  return false;
+const auto &TAs = CTSD->getTemplateArgs();
+return TAs.size() > 0 && TAs[0].getKind() == TemplateArgument::Type &&
+   (isRecordWithAttr(TAs[0].getAsType()) ||
+TAs[0].getAsType()->isPointerType());
+  }
+  return false;
+}
+
+static bool isGSLOwner(QualType T) {
+  return isRecordWithAttr(T) &&
+ !isContainerOfPointer(T->getAsRecordDecl());
+}
+
 static bool shouldTrackImplicitObjectArg(const CXXMethodDecl *Callee) {
   if (auto *Conv = dyn_cast_or_null(Callee))
 if (isRecordWithAttr(Conv->getConversionType()))
@@ -275,7 +295,7 @@ static bool shouldTrackImplicitObjectArg(const 
CXXMethodDecl *Callee) {
 return false;
   if (!isRecordWithAttr(
   Callee->getFunctionObjectParameterType()) &&
-  !isRecordWithAttr(Callee->getFunctionObjectParameterType()))
+  !isGSLOwner(Callee->getFunctionObjectParameterType()))
 return false;
   if (Callee->getReturnType()->isPointerType() ||
   isRecordWithAttr(Callee->getReturnType())) {
@@ -413,7 +433,7 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 // Once we initialized a value with a non gsl-owner reference, it can no
 // longer dangle.
 if (ReturnType->isReferenceType() &&
-!isRecordWithAttr(ReturnType->getPointeeType())) {
+!isGSLOwner(ReturnType->getPointeeType())) {
   for (const IndirectLocalPathEntry &PE : llvm::reverse(Path)) {
 if (PE.Kind == IndirectLocalPathEntry::GslReferenceInit ||
 PE.Kind == IndirectLocalPathEntry::LifetimeBoundCall)
@@ -468,12 +488,17 @@ static void visitFunctionCallArguments(IndirectLocalPath 
&Path, Expr *Call,
 if (CheckCoroCall || Callee->getParamDecl(I)->hasAttr())
   VisitLifetimeBoundArg(Callee->getParamDecl(I), Args[I]);
 else if (EnableGSLAnalysis && I == 0) {
+  // Perform GSL analysis for the first argument
   if (shouldTrackFirstArgument(Callee)) {
 VisitGSLPointerArg(Callee, Args[0]);
-  } else if (auto *CCE = dyn_cast(Call);
-

[clang] [clang] Detect dangling assignment for "Container" case. (PR #108205)

2024-09-12 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.

LGTM!

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


[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-12 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa updated 
https://github.com/llvm/llvm-project/pull/108352

>From ac0447762c98da3cfb41a6b462034e3ab410bc33 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Thu, 12 Sep 2024 02:13:12 -0700
Subject: [PATCH 1/3] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce
 member variable checker for CheckedPtr/CheckedRef

This PR introduces new WebKit checker to warn a member variable that is a raw 
reference or
a raw pointer to an object, which is capable of creating a 
CheckedRef/CheckedPtr.
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td |  4 +
 .../StaticAnalyzer/Checkers/CMakeLists.txt|  2 +-
 .../Checkers/WebKit/PtrTypesSemantics.cpp | 37 ++--
 .../Checkers/WebKit/PtrTypesSemantics.h   |  7 ++
 ...Checker.cpp => RawPtrRefMemberChecker.cpp} | 88 ---
 .../Analysis/Checkers/WebKit/mock-types.h | 48 ++
 .../Checkers/WebKit/unchecked-members.cpp | 53 +++
 .../lib/StaticAnalyzer/Checkers/BUILD.gn  |  2 +-
 8 files changed, 219 insertions(+), 22 deletions(-)
 rename clang/lib/StaticAnalyzer/Checkers/WebKit/{NoUncountedMembersChecker.cpp 
=> RawPtrRefMemberChecker.cpp} (66%)
 create mode 100644 clang/test/Analysis/Checkers/WebKit/unchecked-members.cpp

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 585246547b3dce..4759f680fb4ff7 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1771,6 +1771,10 @@ def UncountedLambdaCapturesChecker : 
Checker<"UncountedLambdaCapturesChecker">,
 
 let ParentPackage = WebKitAlpha in {
 
+def NoUncheckedPtrMemberChecker : Checker<"NoUncheckedPtrMemberChecker">,
+  HelpText<"Check for no unchecked member variables.">,
+  Documentation;
+
 def UncountedCallArgsChecker : Checker<"UncountedCallArgsChecker">,
   HelpText<"Check uncounted call arguments.">,
   Documentation;
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 414282d58f779f..6da3665ab9a4df 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -132,7 +132,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   VLASizeChecker.cpp
   ValistChecker.cpp
   VirtualCallChecker.cpp
-  WebKit/NoUncountedMembersChecker.cpp
+  WebKit/RawPtrRefMemberChecker.cpp
   WebKit/ASTUtils.cpp
   WebKit/PtrTypesSemantics.cpp
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index f48b2fd9dca71b..09298102993f99 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -53,7 +53,9 @@ hasPublicMethodInBase(const CXXBaseSpecifier *Base, const 
char *NameToMatch) {
   return hasPublicMethodInBaseClass(R, NameToMatch) ? R : nullptr;
 }
 
-std::optional isRefCountable(const CXXRecordDecl* R)
+std::optional isSmartPtrCompatible(const CXXRecordDecl *R,
+ const char *IncMethodName,
+ const char *DecMethodName)
 {
   assert(R);
 
@@ -61,8 +63,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   if (!R)
 return std::nullopt;
 
-  bool hasRef = hasPublicMethodInBaseClass(R, "ref");
-  bool hasDeref = hasPublicMethodInBaseClass(R, "deref");
+  bool hasRef = hasPublicMethodInBaseClass(R, IncMethodName);
+  bool hasDeref = hasPublicMethodInBaseClass(R, DecMethodName);
   if (hasRef && hasDeref)
 return true;
 
@@ -71,8 +73,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   bool AnyInconclusiveBase = false;
   const auto hasPublicRefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasRefInBase = clang::hasPublicMethodInBase(Base, "ref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName);
 if (!hasRefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -87,8 +89,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   Paths.clear();
   const auto hasPublicDerefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasDerefInBase = clang::hasPublicMethodInBase(Base, "deref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasDerefInBase = clang::hasPublicMethodInBase(Base, 
DecMethodName);
 if (!hasDerefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -103,11 +105,23 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   return hasRef && hasDeref;
 }
 
+std::optional isRefCountable(const clang::CXXRecordDecl *R) {
+  return isSmartPtrCompatible(R, "ref", "deref");
+}
+
+st

[clang] [llvm] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce member variable checker for CheckedPtr/CheckedRef (PR #108352)

2024-09-12 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa updated 
https://github.com/llvm/llvm-project/pull/108352

>From ac0447762c98da3cfb41a6b462034e3ab410bc33 Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Thu, 12 Sep 2024 02:13:12 -0700
Subject: [PATCH 1/4] [alpha.webkit.NoUncheckedPtrMemberChecker] Introduce
 member variable checker for CheckedPtr/CheckedRef

This PR introduces new WebKit checker to warn a member variable that is a raw 
reference or
a raw pointer to an object, which is capable of creating a 
CheckedRef/CheckedPtr.
---
 .../clang/StaticAnalyzer/Checkers/Checkers.td |  4 +
 .../StaticAnalyzer/Checkers/CMakeLists.txt|  2 +-
 .../Checkers/WebKit/PtrTypesSemantics.cpp | 37 ++--
 .../Checkers/WebKit/PtrTypesSemantics.h   |  7 ++
 ...Checker.cpp => RawPtrRefMemberChecker.cpp} | 88 ---
 .../Analysis/Checkers/WebKit/mock-types.h | 48 ++
 .../Checkers/WebKit/unchecked-members.cpp | 53 +++
 .../lib/StaticAnalyzer/Checkers/BUILD.gn  |  2 +-
 8 files changed, 219 insertions(+), 22 deletions(-)
 rename clang/lib/StaticAnalyzer/Checkers/WebKit/{NoUncountedMembersChecker.cpp 
=> RawPtrRefMemberChecker.cpp} (66%)
 create mode 100644 clang/test/Analysis/Checkers/WebKit/unchecked-members.cpp

diff --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 585246547b3dce..4759f680fb4ff7 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1771,6 +1771,10 @@ def UncountedLambdaCapturesChecker : 
Checker<"UncountedLambdaCapturesChecker">,
 
 let ParentPackage = WebKitAlpha in {
 
+def NoUncheckedPtrMemberChecker : Checker<"NoUncheckedPtrMemberChecker">,
+  HelpText<"Check for no unchecked member variables.">,
+  Documentation;
+
 def UncountedCallArgsChecker : Checker<"UncountedCallArgsChecker">,
   HelpText<"Check uncounted call arguments.">,
   Documentation;
diff --git a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt 
b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
index 414282d58f779f..6da3665ab9a4df 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
+++ b/clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
@@ -132,7 +132,7 @@ add_clang_library(clangStaticAnalyzerCheckers
   VLASizeChecker.cpp
   ValistChecker.cpp
   VirtualCallChecker.cpp
-  WebKit/NoUncountedMembersChecker.cpp
+  WebKit/RawPtrRefMemberChecker.cpp
   WebKit/ASTUtils.cpp
   WebKit/PtrTypesSemantics.cpp
   WebKit/RefCntblBaseVirtualDtorChecker.cpp
diff --git a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
index f48b2fd9dca71b..09298102993f99 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
@@ -53,7 +53,9 @@ hasPublicMethodInBase(const CXXBaseSpecifier *Base, const 
char *NameToMatch) {
   return hasPublicMethodInBaseClass(R, NameToMatch) ? R : nullptr;
 }
 
-std::optional isRefCountable(const CXXRecordDecl* R)
+std::optional isSmartPtrCompatible(const CXXRecordDecl *R,
+ const char *IncMethodName,
+ const char *DecMethodName)
 {
   assert(R);
 
@@ -61,8 +63,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   if (!R)
 return std::nullopt;
 
-  bool hasRef = hasPublicMethodInBaseClass(R, "ref");
-  bool hasDeref = hasPublicMethodInBaseClass(R, "deref");
+  bool hasRef = hasPublicMethodInBaseClass(R, IncMethodName);
+  bool hasDeref = hasPublicMethodInBaseClass(R, DecMethodName);
   if (hasRef && hasDeref)
 return true;
 
@@ -71,8 +73,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   bool AnyInconclusiveBase = false;
   const auto hasPublicRefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasRefInBase = clang::hasPublicMethodInBase(Base, "ref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasRefInBase = clang::hasPublicMethodInBase(Base, IncMethodName);
 if (!hasRefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -87,8 +89,8 @@ std::optional isRefCountable(const CXXRecordDecl* R)
 
   Paths.clear();
   const auto hasPublicDerefInBase =
-  [&AnyInconclusiveBase](const CXXBaseSpecifier *Base, CXXBasePath &) {
-auto hasDerefInBase = clang::hasPublicMethodInBase(Base, "deref");
+  [&](const CXXBaseSpecifier *Base, CXXBasePath &) {
+auto hasDerefInBase = clang::hasPublicMethodInBase(Base, 
DecMethodName);
 if (!hasDerefInBase) {
   AnyInconclusiveBase = true;
   return false;
@@ -103,11 +105,23 @@ std::optional isRefCountable(const CXXRecordDecl* R)
   return hasRef && hasDeref;
 }
 
+std::optional isRefCountable(const clang::CXXRecordDecl *R) {
+  return isSmartPtrCompatible(R, "ref", "deref");
+}
+
+st

[clang] [clang] Don't emit bogus dangling diagnostics when `[[gsl::Owner]]` and `[[clang::lifetimebound]]` are used together. (PR #108280)

2024-09-12 Thread Haojian Wu via cfe-commits


@@ -300,6 +300,8 @@ Improvements to Clang's diagnostics
 
 - Clang now diagnoses cases where a dangling ``GSLOwner`` object 
is constructed, e.g. ``std::vector v = {std::string()};`` 
(#GH100526).
 
+- Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and 
`[[clang::lifetimebound]]` are used together (#GH108272).

hokein wrote:

Yeah, this issue has been present in earlier releases, starting from Clang 10.

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


[clang] [llvm] [SPIR-V] Add SPIR-V structurizer (PR #107408)

2024-09-12 Thread Nathan Gauër via cfe-commits

Keenuts wrote:

Ok, so I've figured out 3 issues:

1. A bug in my sorting of merge instructions. If LHS == RHS, I returned LHS < 
RHS, that was wrong. Executed outside of GDB, it was very slow to show the 
backtrace and crash, so tests looked like it was hanging, but it was just 
crashing.
2. An existing bug in the SPIRVPreLegalizer: the GET_ID instruction insertion 
point is wrong. Seems like I found a quick fix.
3. When SPIRVGlobalRegistry is used to create OpTypeBool, it creates it not in 
the main BB, but in the current location. Meaning if you then want this type on 
a BB located before the last insertion point, you'll end-up with a "use before 
declare".

Fixing those 3 allowed me to get later in the verification process. I now have 
2 more types of issues:
- OpBranch/OpBranchConditional are not considered to be valid basic block 
terminators
- OpLoopMerge are taking BB operands, but verifier expected register operand.

I'd be tempted to fix the issue 1 (the actual iterator issue), but leave the 
rest unfixed in this PR (which is already huge).
Then, in distrinct PRs, fir 1 and 2, and then address the next ones.

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


[clang] [llvm] [SPIR-V] Add SPIR-V structurizer (PR #107408)

2024-09-12 Thread Vyacheslav Levytskyy via cfe-commits
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= 
Message-ID:
In-Reply-To: 


VyacheslavLevytskyy wrote:

That's really great, thank you.

> OpBranch/OpBranchConditional are not considered to be valid basic block 
> terminators
In lib/Target/SPIRV/SPIRVInstrInfo.td lines 625-632 we actually set 
isTerminator=1 for both of those, but let's double check then.

> ... leave the rest unfixed in this PR (which is already huge)
Sure!

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-affine

Author: VitalyR (VitalyAnkh)


Changes



---

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


130 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp (+7-7) 
- (modified) mlir/docs/Canonicalization.md (+6-6) 
- (modified) mlir/docs/Dialects/Linalg/_index.md (+1-1) 
- (modified) mlir/docs/PDLL.md (+1-1) 
- (modified) mlir/docs/Rationale/RationaleLinalgDialect.md (+1-1) 
- (modified) mlir/docs/SPIRVToLLVMDialectConversion.md (+1-1) 
- (modified) mlir/docs/Tutorials/Toy/Ch-4.md (+1-1) 
- (modified) mlir/docs/doxygen.cfg.in (+1-1) 
- (modified) mlir/include/mlir/AsmParser/AsmParser.h (+2-2) 
- (modified) mlir/include/mlir/Bytecode/BytecodeImplementation.h (+1-1) 
- (modified) mlir/include/mlir/Bytecode/BytecodeReader.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h (+1-1) 
- (modified) 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
(+1-1) 
- (modified) mlir/include/mlir/Dialect/Arith/IR/ArithBase.td (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td 
(+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/IR/AttrTypeBase.td (+1-1) 
- (modified) mlir/include/mlir/IR/OpImplementation.h (+1-1) 
- (modified) mlir/include/mlir/IR/OperationSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Threading.h (+1-1) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.h (+2-2) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (+3-3) 
- (modified) mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Nodes.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Types.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Context.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Dialect.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Operation.h (+5-5) 
- (modified) mlir/include/mlir/Tools/ParseUtilities.h (+1-1) 
- (modified) mlir/include/mlir/Tools/lsp-server-support/Protocol.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+3-3) 
- (modified) mlir/include/mlir/Transforms/Inliner.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+2-2) 
- (modified) mlir/include/mlir/Transforms/Passes.td (+3-3) 
- (modified) mlir/include/mlir/Transforms/RegionUtils.h (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRModule.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+10-10) 
- (modified) mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp (+1-1) 
- (modified) 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp 
(+4-4) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cp

[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-memref

Author: VitalyR (VitalyAnkh)


Changes



---

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


130 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp (+7-7) 
- (modified) mlir/docs/Canonicalization.md (+6-6) 
- (modified) mlir/docs/Dialects/Linalg/_index.md (+1-1) 
- (modified) mlir/docs/PDLL.md (+1-1) 
- (modified) mlir/docs/Rationale/RationaleLinalgDialect.md (+1-1) 
- (modified) mlir/docs/SPIRVToLLVMDialectConversion.md (+1-1) 
- (modified) mlir/docs/Tutorials/Toy/Ch-4.md (+1-1) 
- (modified) mlir/docs/doxygen.cfg.in (+1-1) 
- (modified) mlir/include/mlir/AsmParser/AsmParser.h (+2-2) 
- (modified) mlir/include/mlir/Bytecode/BytecodeImplementation.h (+1-1) 
- (modified) mlir/include/mlir/Bytecode/BytecodeReader.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h (+1-1) 
- (modified) 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
(+1-1) 
- (modified) mlir/include/mlir/Dialect/Arith/IR/ArithBase.td (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td 
(+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/IR/AttrTypeBase.td (+1-1) 
- (modified) mlir/include/mlir/IR/OpImplementation.h (+1-1) 
- (modified) mlir/include/mlir/IR/OperationSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Threading.h (+1-1) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.h (+2-2) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (+3-3) 
- (modified) mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Nodes.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Types.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Context.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Dialect.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Operation.h (+5-5) 
- (modified) mlir/include/mlir/Tools/ParseUtilities.h (+1-1) 
- (modified) mlir/include/mlir/Tools/lsp-server-support/Protocol.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+3-3) 
- (modified) mlir/include/mlir/Transforms/Inliner.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+2-2) 
- (modified) mlir/include/mlir/Transforms/Passes.td (+3-3) 
- (modified) mlir/include/mlir/Transforms/RegionUtils.h (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRModule.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+10-10) 
- (modified) mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp (+1-1) 
- (modified) 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp 
(+4-4) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cp

[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-llvm

Author: VitalyR (VitalyAnkh)


Changes



---

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


130 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp (+7-7) 
- (modified) mlir/docs/Canonicalization.md (+6-6) 
- (modified) mlir/docs/Dialects/Linalg/_index.md (+1-1) 
- (modified) mlir/docs/PDLL.md (+1-1) 
- (modified) mlir/docs/Rationale/RationaleLinalgDialect.md (+1-1) 
- (modified) mlir/docs/SPIRVToLLVMDialectConversion.md (+1-1) 
- (modified) mlir/docs/Tutorials/Toy/Ch-4.md (+1-1) 
- (modified) mlir/docs/doxygen.cfg.in (+1-1) 
- (modified) mlir/include/mlir/AsmParser/AsmParser.h (+2-2) 
- (modified) mlir/include/mlir/Bytecode/BytecodeImplementation.h (+1-1) 
- (modified) mlir/include/mlir/Bytecode/BytecodeReader.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h (+1-1) 
- (modified) 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
(+1-1) 
- (modified) mlir/include/mlir/Dialect/Arith/IR/ArithBase.td (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td 
(+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/IR/AttrTypeBase.td (+1-1) 
- (modified) mlir/include/mlir/IR/OpImplementation.h (+1-1) 
- (modified) mlir/include/mlir/IR/OperationSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Threading.h (+1-1) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.h (+2-2) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (+3-3) 
- (modified) mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Nodes.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Types.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Context.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Dialect.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Operation.h (+5-5) 
- (modified) mlir/include/mlir/Tools/ParseUtilities.h (+1-1) 
- (modified) mlir/include/mlir/Tools/lsp-server-support/Protocol.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+3-3) 
- (modified) mlir/include/mlir/Transforms/Inliner.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+2-2) 
- (modified) mlir/include/mlir/Transforms/Passes.td (+3-3) 
- (modified) mlir/include/mlir/Transforms/RegionUtils.h (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRModule.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+10-10) 
- (modified) mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp (+1-1) 
- (modified) 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp 
(+4-4) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cpp 

[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-tools-extra
@llvm/pr-subscribers-mlir-ods
@llvm/pr-subscribers-mlir-arith

@llvm/pr-subscribers-mlir-linalg

Author: VitalyR (VitalyAnkh)


Changes



---

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


130 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp (+7-7) 
- (modified) mlir/docs/Canonicalization.md (+6-6) 
- (modified) mlir/docs/Dialects/Linalg/_index.md (+1-1) 
- (modified) mlir/docs/PDLL.md (+1-1) 
- (modified) mlir/docs/Rationale/RationaleLinalgDialect.md (+1-1) 
- (modified) mlir/docs/SPIRVToLLVMDialectConversion.md (+1-1) 
- (modified) mlir/docs/Tutorials/Toy/Ch-4.md (+1-1) 
- (modified) mlir/docs/doxygen.cfg.in (+1-1) 
- (modified) mlir/include/mlir/AsmParser/AsmParser.h (+2-2) 
- (modified) mlir/include/mlir/Bytecode/BytecodeImplementation.h (+1-1) 
- (modified) mlir/include/mlir/Bytecode/BytecodeReader.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h (+1-1) 
- (modified) 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
(+1-1) 
- (modified) mlir/include/mlir/Dialect/Arith/IR/ArithBase.td (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td 
(+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/IR/AttrTypeBase.td (+1-1) 
- (modified) mlir/include/mlir/IR/OpImplementation.h (+1-1) 
- (modified) mlir/include/mlir/IR/OperationSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Threading.h (+1-1) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.h (+2-2) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (+3-3) 
- (modified) mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Nodes.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Types.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Context.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Dialect.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Operation.h (+5-5) 
- (modified) mlir/include/mlir/Tools/ParseUtilities.h (+1-1) 
- (modified) mlir/include/mlir/Tools/lsp-server-support/Protocol.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+3-3) 
- (modified) mlir/include/mlir/Transforms/Inliner.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+2-2) 
- (modified) mlir/include/mlir/Transforms/Passes.td (+3-3) 
- (modified) mlir/include/mlir/Transforms/RegionUtils.h (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRModule.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+10-10) 
- (modified) mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp (+1-1) 
- (modified) 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Tenso

[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-gpu

Author: VitalyR (VitalyAnkh)


Changes



---

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


130 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp (+7-7) 
- (modified) mlir/docs/Canonicalization.md (+6-6) 
- (modified) mlir/docs/Dialects/Linalg/_index.md (+1-1) 
- (modified) mlir/docs/PDLL.md (+1-1) 
- (modified) mlir/docs/Rationale/RationaleLinalgDialect.md (+1-1) 
- (modified) mlir/docs/SPIRVToLLVMDialectConversion.md (+1-1) 
- (modified) mlir/docs/Tutorials/Toy/Ch-4.md (+1-1) 
- (modified) mlir/docs/doxygen.cfg.in (+1-1) 
- (modified) mlir/include/mlir/AsmParser/AsmParser.h (+2-2) 
- (modified) mlir/include/mlir/Bytecode/BytecodeImplementation.h (+1-1) 
- (modified) mlir/include/mlir/Bytecode/BytecodeReader.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h (+1-1) 
- (modified) 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
(+1-1) 
- (modified) mlir/include/mlir/Dialect/Arith/IR/ArithBase.td (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td 
(+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/IR/AttrTypeBase.td (+1-1) 
- (modified) mlir/include/mlir/IR/OpImplementation.h (+1-1) 
- (modified) mlir/include/mlir/IR/OperationSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Threading.h (+1-1) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.h (+2-2) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (+3-3) 
- (modified) mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Nodes.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Types.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Context.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Dialect.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Operation.h (+5-5) 
- (modified) mlir/include/mlir/Tools/ParseUtilities.h (+1-1) 
- (modified) mlir/include/mlir/Tools/lsp-server-support/Protocol.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+3-3) 
- (modified) mlir/include/mlir/Transforms/Inliner.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+2-2) 
- (modified) mlir/include/mlir/Transforms/Passes.td (+3-3) 
- (modified) mlir/include/mlir/Transforms/RegionUtils.h (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRModule.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+10-10) 
- (modified) mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp (+1-1) 
- (modified) 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp 
(+4-4) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cpp (

[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-tosa

Author: VitalyR (VitalyAnkh)


Changes



---

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


130 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp (+7-7) 
- (modified) mlir/docs/Canonicalization.md (+6-6) 
- (modified) mlir/docs/Dialects/Linalg/_index.md (+1-1) 
- (modified) mlir/docs/PDLL.md (+1-1) 
- (modified) mlir/docs/Rationale/RationaleLinalgDialect.md (+1-1) 
- (modified) mlir/docs/SPIRVToLLVMDialectConversion.md (+1-1) 
- (modified) mlir/docs/Tutorials/Toy/Ch-4.md (+1-1) 
- (modified) mlir/docs/doxygen.cfg.in (+1-1) 
- (modified) mlir/include/mlir/AsmParser/AsmParser.h (+2-2) 
- (modified) mlir/include/mlir/Bytecode/BytecodeImplementation.h (+1-1) 
- (modified) mlir/include/mlir/Bytecode/BytecodeReader.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h (+1-1) 
- (modified) 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
(+1-1) 
- (modified) mlir/include/mlir/Dialect/Arith/IR/ArithBase.td (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td 
(+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/IR/AttrTypeBase.td (+1-1) 
- (modified) mlir/include/mlir/IR/OpImplementation.h (+1-1) 
- (modified) mlir/include/mlir/IR/OperationSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Threading.h (+1-1) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.h (+2-2) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (+3-3) 
- (modified) mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Nodes.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Types.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Context.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Dialect.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Operation.h (+5-5) 
- (modified) mlir/include/mlir/Tools/ParseUtilities.h (+1-1) 
- (modified) mlir/include/mlir/Tools/lsp-server-support/Protocol.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+3-3) 
- (modified) mlir/include/mlir/Transforms/Inliner.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+2-2) 
- (modified) mlir/include/mlir/Transforms/Passes.td (+3-3) 
- (modified) mlir/include/mlir/Transforms/RegionUtils.h (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRModule.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+10-10) 
- (modified) mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp (+1-1) 
- (modified) 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp 
(+4-4) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cpp 

[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-sparse

Author: VitalyR (VitalyAnkh)


Changes



---

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


130 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp (+7-7) 
- (modified) mlir/docs/Canonicalization.md (+6-6) 
- (modified) mlir/docs/Dialects/Linalg/_index.md (+1-1) 
- (modified) mlir/docs/PDLL.md (+1-1) 
- (modified) mlir/docs/Rationale/RationaleLinalgDialect.md (+1-1) 
- (modified) mlir/docs/SPIRVToLLVMDialectConversion.md (+1-1) 
- (modified) mlir/docs/Tutorials/Toy/Ch-4.md (+1-1) 
- (modified) mlir/docs/doxygen.cfg.in (+1-1) 
- (modified) mlir/include/mlir/AsmParser/AsmParser.h (+2-2) 
- (modified) mlir/include/mlir/Bytecode/BytecodeImplementation.h (+1-1) 
- (modified) mlir/include/mlir/Bytecode/BytecodeReader.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h (+1-1) 
- (modified) 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
(+1-1) 
- (modified) mlir/include/mlir/Dialect/Arith/IR/ArithBase.td (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td 
(+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/IR/AttrTypeBase.td (+1-1) 
- (modified) mlir/include/mlir/IR/OpImplementation.h (+1-1) 
- (modified) mlir/include/mlir/IR/OperationSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Threading.h (+1-1) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.h (+2-2) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (+3-3) 
- (modified) mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Nodes.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Types.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Context.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Dialect.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Operation.h (+5-5) 
- (modified) mlir/include/mlir/Tools/ParseUtilities.h (+1-1) 
- (modified) mlir/include/mlir/Tools/lsp-server-support/Protocol.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+3-3) 
- (modified) mlir/include/mlir/Transforms/Inliner.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+2-2) 
- (modified) mlir/include/mlir/Transforms/Passes.td (+3-3) 
- (modified) mlir/include/mlir/Transforms/RegionUtils.h (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRModule.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+10-10) 
- (modified) mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp (+1-1) 
- (modified) 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp 
(+4-4) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorOps.cp

[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mlir-bufferization

Author: VitalyR (VitalyAnkh)


Changes



---

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


130 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp (+7-7) 
- (modified) mlir/docs/Canonicalization.md (+6-6) 
- (modified) mlir/docs/Dialects/Linalg/_index.md (+1-1) 
- (modified) mlir/docs/PDLL.md (+1-1) 
- (modified) mlir/docs/Rationale/RationaleLinalgDialect.md (+1-1) 
- (modified) mlir/docs/SPIRVToLLVMDialectConversion.md (+1-1) 
- (modified) mlir/docs/Tutorials/Toy/Ch-4.md (+1-1) 
- (modified) mlir/docs/doxygen.cfg.in (+1-1) 
- (modified) mlir/include/mlir/AsmParser/AsmParser.h (+2-2) 
- (modified) mlir/include/mlir/Bytecode/BytecodeImplementation.h (+1-1) 
- (modified) mlir/include/mlir/Bytecode/BytecodeReader.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h (+1-1) 
- (modified) mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h (+1-1) 
- (modified) 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
(+1-1) 
- (modified) mlir/include/mlir/Dialect/Arith/IR/ArithBase.td (+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIAttrs.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/DLTI/DLTIBase.td (+3-3) 
- (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMEnums.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/Linalg/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SCF/Utils/Utils.h (+1-1) 
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td 
(+1-1) 
- (modified) 
mlir/include/mlir/Dialect/Tensor/TransformOps/TensorTransformOps.td (+1-1) 
- (modified) mlir/include/mlir/IR/AttrTypeBase.td (+1-1) 
- (modified) mlir/include/mlir/IR/OpImplementation.h (+1-1) 
- (modified) mlir/include/mlir/IR/OperationSupport.h (+1-1) 
- (modified) mlir/include/mlir/IR/Threading.h (+1-1) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.h (+2-2) 
- (modified) mlir/include/mlir/Interfaces/DataLayoutInterfaces.td (+3-3) 
- (modified) mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Nodes.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/AST/Types.h (+2-2) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Context.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Dialect.h (+1-1) 
- (modified) mlir/include/mlir/Tools/PDLL/ODS/Operation.h (+5-5) 
- (modified) mlir/include/mlir/Tools/ParseUtilities.h (+1-1) 
- (modified) mlir/include/mlir/Tools/lsp-server-support/Protocol.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/DialectConversion.h (+3-3) 
- (modified) mlir/include/mlir/Transforms/Inliner.h (+1-1) 
- (modified) mlir/include/mlir/Transforms/OneToNTypeConversion.h (+2-2) 
- (modified) mlir/include/mlir/Transforms/Passes.td (+3-3) 
- (modified) mlir/include/mlir/Transforms/RegionUtils.h (+1-1) 
- (modified) mlir/lib/Bindings/Python/IRModule.h (+1-1) 
- (modified) mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp (+1-1) 
- (modified) mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp (+1-1) 
- (modified) mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/IR/AffineOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Affine/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/DLTI/DLTI.cpp (+10-10) 
- (modified) mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp (+1-1) 
- (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp (+1-1) 
- (modified) 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp (+2-2) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-1) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SCF/Utils/Utils.cpp (+1-1) 
- (modified) mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
(+1-1) 
- (modified) mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp 
(+4-4) 
- (modified) mlir/lib/Dialect/Tensor/IR/Tenso

[clang] clang-format: Add AlignFunctionDeclarations attribute to AlignConsecutiveDeclarations (PR #108241)

2024-09-12 Thread Brad House via cfe-commits

https://github.com/bradh352 updated 
https://github.com/llvm/llvm-project/pull/108241

>From 89d238800f0287f29f95165e05530d3f5e397245 Mon Sep 17 00:00:00 2001
From: Brad House 
Date: Wed, 11 Sep 2024 10:27:50 -0400
Subject: [PATCH] Add AlignFunctionDeclarations attribute to
 AlignConsecutiveDeclarations

Enabling AlignConsecutiveDeclarations also aligns function prototypes
or declarations.  This is often unexpected as typically function
prototypes, especially in public headers, don't use any padding.

Setting AlignFunctionDeclarations to false will skip this alignment.
It is by default set to true to keep compatibility with prior
versions to not make unexpected changes.

Signed-off-by: Brad House 
---
 clang/docs/ClangFormatStyleOptions.rst | 105 +
 clang/include/clang/Format/Format.h|  15 +++
 clang/lib/Format/Format.cpp|  31 --
 clang/lib/Format/WhitespaceManager.cpp |   2 +-
 clang/unittests/Format/ConfigParseTest.cpp |  18 ++--
 clang/unittests/Format/FormatTest.cpp  |  22 -
 6 files changed, 177 insertions(+), 16 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index a427d7cd40fcdd..c862d57a19b954 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -409,6 +409,21 @@ the configuration (without a prefix: ``Auto``).
   int *p;
   int (*f)();
 
+  * ``bool AlignFunctionDeclarations`` Only for 
``AlignConsecutiveDeclarations``. Whether function declarations
+are aligned.
+
+.. code-block:: c++
+
+  true:
+  unsigned int f1(void);
+  void f2(void);
+  size_t   f3(void);
+
+  false:
+  unsigned int f1(void);
+  void f2(void);
+  size_t f3(void);
+
   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short assignment
 operators are left-padded to the same length as long ones in order to
 put all assignment operators to the right of the left hand side.
@@ -551,6 +566,21 @@ the configuration (without a prefix: ``Auto``).
   int *p;
   int (*f)();
 
+  * ``bool AlignFunctionDeclarations`` Only for 
``AlignConsecutiveDeclarations``. Whether function declarations
+are aligned.
+
+.. code-block:: c++
+
+  true:
+  unsigned int f1(void);
+  void f2(void);
+  size_t   f3(void);
+
+  false:
+  unsigned int f1(void);
+  void f2(void);
+  size_t f3(void);
+
   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short assignment
 operators are left-padded to the same length as long ones in order to
 put all assignment operators to the right of the left hand side.
@@ -693,6 +723,21 @@ the configuration (without a prefix: ``Auto``).
   int *p;
   int (*f)();
 
+  * ``bool AlignFunctionDeclarations`` Only for 
``AlignConsecutiveDeclarations``. Whether function declarations
+are aligned.
+
+.. code-block:: c++
+
+  true:
+  unsigned int f1(void);
+  void f2(void);
+  size_t   f3(void);
+
+  false:
+  unsigned int f1(void);
+  void f2(void);
+  size_t f3(void);
+
   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short assignment
 operators are left-padded to the same length as long ones in order to
 put all assignment operators to the right of the left hand side.
@@ -836,6 +881,21 @@ the configuration (without a prefix: ``Auto``).
   int *p;
   int (*f)();
 
+  * ``bool AlignFunctionDeclarations`` Only for 
``AlignConsecutiveDeclarations``. Whether function declarations
+are aligned.
+
+.. code-block:: c++
+
+  true:
+  unsigned int f1(void);
+  void f2(void);
+  size_t   f3(void);
+
+  false:
+  unsigned int f1(void);
+  void f2(void);
+  size_t f3(void);
+
   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short assignment
 operators are left-padded to the same length as long ones in order to
 put all assignment operators to the right of the left hand side.
@@ -1098,6 +1158,21 @@ the configuration (without a prefix: ``Auto``).
   int *p;
   int (*f)();
 
+  * ``bool AlignFunctionDeclarations`` Only for 
``AlignConsecutiveDeclarations``. Whether function declarations
+are aligned.
+
+.. code-block:: c++
+
+  true:
+  unsigned int f1(void);
+  void f2(void);
+  size_t   f3(void);
+
+  false:
+  unsigned int f1(void);
+  void f2(void);
+  size_t f3(void);
+
   * ``bool PadOperators`` Only for ``AlignConsecutiveAssignments``.  Whether 
short assignment
 operators are left-padded to the same length as long ones in order to
 put all assignment operators to the right of the left hand side.
@@ -1238,6 +1313,21 @@ the configuration (without a prefix: ``Auto``).
   int *p;
   int (*f)();
 
+  * 

[clang] clang-format: Add AlignFunctionDeclarations attribute to AlignConsecutiveDeclarations (PR #108241)

2024-09-12 Thread Brad House via cfe-commits

bradh352 wrote:

I just corrected the formatting...

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


[clang] [llvm] [SPIR-V] Add SPIR-V structurizer (PR #107408)

2024-09-12 Thread Vyacheslav Levytskyy via cfe-commits
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= ,
Nathan =?utf-8?q?Gauër?= 
Message-ID:
In-Reply-To: 


VyacheslavLevytskyy wrote:

> OpLoopMerge are taking BB operands, but verifier expected register operand.

Hopefully, the fix may be as simple as to change 
lib/Target/SPIRV/SPIRVInstrInfo.td line 620-621 `ID:$merge, ID:$continue` into 
`unknown:$merge, unknown:$continue` as in line 626 for OpBranch:
`def OpBranch: Op<249, (outs), (ins unknown:$label), "OpBranch $label">;`

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 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 59731eebf8f24e3e90dc77e91a08d068b529cfc5 
65c7658359b856bd736229d501def16027fd2a42 --extensions cpp,h -- 
clang-tools-extra/clang-tidy/llvmlibc/RestrictSystemLibcHeadersCheck.cpp 
mlir/include/mlir/AsmParser/AsmParser.h 
mlir/include/mlir/Bytecode/BytecodeImplementation.h 
mlir/include/mlir/Bytecode/BytecodeReader.h 
mlir/include/mlir/Conversion/TosaToLinalg/TosaToLinalg.h 
mlir/include/mlir/Conversion/VectorToGPU/VectorToGPU.h 
mlir/include/mlir/Debug/BreakpointManagers/FileLineColLocBreakpointManager.h 
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h 
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h 
mlir/include/mlir/Dialect/SCF/Transforms/Transforms.h 
mlir/include/mlir/Dialect/SCF/Utils/Utils.h 
mlir/include/mlir/IR/OpImplementation.h mlir/include/mlir/IR/OperationSupport.h 
mlir/include/mlir/IR/Threading.h 
mlir/include/mlir/Interfaces/DataLayoutInterfaces.h 
mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h 
mlir/include/mlir/Tools/PDLL/AST/Nodes.h 
mlir/include/mlir/Tools/PDLL/AST/Types.h 
mlir/include/mlir/Tools/PDLL/ODS/Context.h 
mlir/include/mlir/Tools/PDLL/ODS/Dialect.h 
mlir/include/mlir/Tools/PDLL/ODS/Operation.h 
mlir/include/mlir/Tools/ParseUtilities.h 
mlir/include/mlir/Tools/lsp-server-support/Protocol.h 
mlir/include/mlir/Transforms/DialectConversion.h 
mlir/include/mlir/Transforms/Inliner.h 
mlir/include/mlir/Transforms/OneToNTypeConversion.h 
mlir/include/mlir/Transforms/RegionUtils.h mlir/lib/Bindings/Python/IRModule.h 
mlir/lib/Conversion/GPUToNVVM/WmmaOpsToNvvm.cpp 
mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp 
mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp 
mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp 
mlir/lib/Dialect/Affine/IR/AffineOps.cpp 
mlir/lib/Dialect/Affine/Utils/Utils.cpp 
mlir/lib/Dialect/ArmSME/Transforms/VectorLegalization.cpp 
mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp 
mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp 
mlir/lib/Dialect/DLTI/DLTI.cpp 
mlir/lib/Dialect/GPU/Transforms/AllReduceLowering.cpp 
mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp 
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp 
mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp 
mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.cpp 
mlir/lib/Dialect/Linalg/Transforms/NamedOpConversions.cpp 
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp 
mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp 
mlir/lib/Dialect/MemRef/Transforms/EmulateWideInt.cpp 
mlir/lib/Dialect/SCF/Utils/Utils.cpp 
mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp 
mlir/lib/Dialect/Tensor/IR/TensorInferTypeOpInterfaceImpl.cpp 
mlir/lib/Dialect/Tensor/IR/TensorOps.cpp mlir/lib/IR/BuiltinTypes.cpp 
mlir/lib/Interfaces/DataLayoutInterfaces.cpp 
mlir/lib/Target/LLVMIR/DataLayoutImporter.cpp 
mlir/lib/Target/LLVMIR/DataLayoutImporter.h 
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp 
mlir/lib/Tools/PDLL/ODS/Context.cpp mlir/lib/Tools/PDLL/ODS/Dialect.cpp 
mlir/lib/Tools/PDLL/ODS/Operation.cpp mlir/lib/Tools/PDLL/Parser/Parser.cpp 
mlir/lib/Transforms/InlinerPass.cpp mlir/lib/Transforms/RemoveDeadValues.cpp 
mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp 
mlir/lib/Transforms/Utils/Inliner.cpp 
mlir/test/lib/Dialect/DLTI/TestDataLayoutQuery.cpp 
mlir/test/lib/IR/TestSymbolUses.cpp 
mlir/tools/mlir-vulkan-runner/VulkanRuntime.cpp 
mlir/unittests/Debug/FileLineColLocBreakpointManagerTest.cpp 
mlir/unittests/Dialect/OpenACC/OpenACCOpsTest.cpp 
mlir/unittests/IR/AttrTypeReplacerTest.cpp 
mlir/unittests/IR/InterfaceAttachmentTest.cpp 
mlir/unittests/IR/OpPropertiesTest.cpp 
mlir/unittests/Interfaces/DataLayoutInterfacesTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/mlir/include/mlir/Transforms/DialectConversion.h 
b/mlir/include/mlir/Transforms/DialectConversion.h
index 08283e3b15..8b1272ea98 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -218,12 +218,13 @@ public:
   ///
   /// The conversion functions take a non-null Type or subclass of Type and a
   /// non-null Attribute (or subclass of Attribute), and returns a
-  /// `AttributeConversionResult`. This result can either contain an 
`Attribute`,
-  /// which may be `nullptr`, representing the conversion's success,
-  /// `AttributeConversionResult::na()` (the default empty value), indicating
-  /// that the conversion function did not apply and that further conversion
-  /// functions should be checked, or `AttributeConversionResult::abort()`
-  /// indicating that the conversion process should be aborted.
+  /// `AttributeConversionResult`. This result can either contain an
+  /// `Attribute`, which may 

[libcxx] [libcxxabi] [libunwind] [llvm] [runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler (PR #108357)

2024-09-12 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo created 
https://github.com/llvm/llvm-project/pull/108357

While these flags semantically are relevant only for C++, we do add them to 
CMAKE_REQUIRED_FLAGS if they are detected. All flags in that variable are used 
both when testing compilation of C and C++ (and for detecting libraries, which 
uses the C compiler driver).

Therefore, to be sure we safely can add the flags to CMAKE_REQUIRED_FLAGS, test 
for the option with the C language.

This should fix compilation with GCC; newer versions of GCC do support the 
-nostdlib++ option, but it's only supported by the C++ compiler driver, not the 
C driver. (However, many builds of GCC also do accept the option with the C 
driver, if GCC was compiled with Ada support enabled, see [1]. That's why this 
issue isn't noticed in all configurations with GCC.)

Clang does support these options in both C and C++ driver modes.

This should fix #90332.

[1] https://github.com/llvm/llvm-project/issues/90332#issuecomment-2325099254

From 290374fd8492bb1612ad0f14c488c760fec32ab3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Tue, 3 Sep 2024 13:33:45 +0300
Subject: [PATCH] [runtimes] Probe for -nostdlib++ and -nostdinc++ with the C
 compiler

While these flags semantically are relevant only for C++, we do
add them to CMAKE_REQUIRED_FLAGS if they are detected. All flags
in that variable are used both when testing compilation of C and C++
(and for detecting libraries, which uses the C compiler driver).

Therefore, to be sure we safely can add the flags to
CMAKE_REQUIRED_FLAGS, test for the option with the C language.

This should fix compilation with GCC; newer versions of GCC do
support the -nostdlib++ option, but it's only supported by the
C++ compiler driver, not the C driver. (However, many builds of
GCC also do accept the option with the C driver, if GCC was
compiled with Ada support enabled, see [1]. That's why this
issue isn't noticed in all configurations with GCC.)

Clang does support these options in both C and C++ driver modes.

[1] https://github.com/llvm/llvm-project/issues/90332#issuecomment-2325099254
---
 libcxx/cmake/config-ix.cmake| 12 
 libcxxabi/cmake/config-ix.cmake | 12 
 libcxxabi/src/CMakeLists.txt|  4 ++--
 libunwind/cmake/config-ix.cmake | 12 
 libunwind/src/CMakeLists.txt|  2 +-
 runtimes/CMakeLists.txt | 12 
 6 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 270d80575adcfd..192bad7a7a7fc6 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -38,9 +38,13 @@ check_cxx_compiler_flag(-nolibc CXX_SUPPORTS_NOLIBC_FLAG)
 # required during compilation (which has the -nostdlib++ or -nodefaultlibs). 
libc is
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
+#
+# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
+# compilation of C and C++. Therefore test to make sure that the flags are
+# supported by the C compiler driver, before deciding to include them.
 
-check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 else()
   check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
@@ -51,7 +55,7 @@ endif()
 
 # Only link against compiler-rt manually if we use -nodefaultlibs, since
 # otherwise the compiler will do the right thing on its own.
-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (LIBCXX_USE_COMPILER_RT)
 include(HandleCompilerRT)
 find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY
@@ -81,7 +85,7 @@ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND 
C_SUPPORTS_NODEFAULTLIBS_FLAG)
   endif()
 endif()
 
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()
diff --git a/libcxxabi/cmake/config-ix.cmake b/libcxxabi/cmake/config-ix.cmake
index 10f2087c68c5e7..ab74ad79a654af 100644
--- a/libcxxabi/cmake/config-ix.cmake
+++ b/libcxxabi/cmake/config-ix.cmake
@@ -22,9 +22,13 @@ endif ()
 # required during compilation (which has the -nodefaultlibs). libc is
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
+#
+# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
+# compilation of C and C++. Therefore test to make sure that the flags are
+# supported by the C compiler dri

[libcxx] [libcxxabi] [libunwind] [llvm] [runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler (PR #108357)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxxabi

Author: Martin Storsjö (mstorsjo)


Changes

While these flags semantically are relevant only for C++, we do add them to 
CMAKE_REQUIRED_FLAGS if they are detected. All flags in that variable are used 
both when testing compilation of C and C++ (and for detecting libraries, which 
uses the C compiler driver).

Therefore, to be sure we safely can add the flags to CMAKE_REQUIRED_FLAGS, test 
for the option with the C language.

This should fix compilation with GCC; newer versions of GCC do support the 
-nostdlib++ option, but it's only supported by the C++ compiler driver, not the 
C driver. (However, many builds of GCC also do accept the option with the C 
driver, if GCC was compiled with Ada support enabled, see [1]. That's why this 
issue isn't noticed in all configurations with GCC.)

Clang does support these options in both C and C++ driver modes.

This should fix #90332.

[1] https://github.com/llvm/llvm-project/issues/90332#issuecomment-2325099254

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


6 Files Affected:

- (modified) libcxx/cmake/config-ix.cmake (+8-4) 
- (modified) libcxxabi/cmake/config-ix.cmake (+8-4) 
- (modified) libcxxabi/src/CMakeLists.txt (+2-2) 
- (modified) libunwind/cmake/config-ix.cmake (+8-4) 
- (modified) libunwind/src/CMakeLists.txt (+1-1) 
- (modified) runtimes/CMakeLists.txt (+8-4) 


``diff
diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 270d80575adcfd..192bad7a7a7fc6 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -38,9 +38,13 @@ check_cxx_compiler_flag(-nolibc CXX_SUPPORTS_NOLIBC_FLAG)
 # required during compilation (which has the -nostdlib++ or -nodefaultlibs). 
libc is
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
+#
+# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
+# compilation of C and C++. Therefore test to make sure that the flags are
+# supported by the C compiler driver, before deciding to include them.
 
-check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 else()
   check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
@@ -51,7 +55,7 @@ endif()
 
 # Only link against compiler-rt manually if we use -nodefaultlibs, since
 # otherwise the compiler will do the right thing on its own.
-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (LIBCXX_USE_COMPILER_RT)
 include(HandleCompilerRT)
 find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY
@@ -81,7 +85,7 @@ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND 
C_SUPPORTS_NODEFAULTLIBS_FLAG)
   endif()
 endif()
 
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()
diff --git a/libcxxabi/cmake/config-ix.cmake b/libcxxabi/cmake/config-ix.cmake
index 10f2087c68c5e7..ab74ad79a654af 100644
--- a/libcxxabi/cmake/config-ix.cmake
+++ b/libcxxabi/cmake/config-ix.cmake
@@ -22,9 +22,13 @@ endif ()
 # required during compilation (which has the -nodefaultlibs). libc is
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
+#
+# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
+# compilation of C and C++. Therefore test to make sure that the flags are
+# supported by the C compiler driver, before deciding to include them.
 
-check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 else()
   check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
@@ -35,7 +39,7 @@ endif()
 
 # Only link against compiler-rt manually if we use -nodefaultlibs, since
 # otherwise the compiler will do the right thing on its own.
-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (LIBCXXABI_HAS_C_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES c)
   endif ()
@@ -71,7 +75,7 @@ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND 
C_SUPPORTS_NODEFAULTLIBS_FLAG)
   endif()
 endif()
 
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (CMAKE_C_FLAGS MATCHES -

[libcxx] [libcxxabi] [libunwind] [llvm] [runtimes] Probe for -nostdlib++ and -nostdinc++ with the C compiler (PR #108357)

2024-09-12 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-libcxx

@llvm/pr-subscribers-libunwind

Author: Martin Storsjö (mstorsjo)


Changes

While these flags semantically are relevant only for C++, we do add them to 
CMAKE_REQUIRED_FLAGS if they are detected. All flags in that variable are used 
both when testing compilation of C and C++ (and for detecting libraries, which 
uses the C compiler driver).

Therefore, to be sure we safely can add the flags to CMAKE_REQUIRED_FLAGS, test 
for the option with the C language.

This should fix compilation with GCC; newer versions of GCC do support the 
-nostdlib++ option, but it's only supported by the C++ compiler driver, not the 
C driver. (However, many builds of GCC also do accept the option with the C 
driver, if GCC was compiled with Ada support enabled, see [1]. That's why this 
issue isn't noticed in all configurations with GCC.)

Clang does support these options in both C and C++ driver modes.

This should fix #90332.

[1] https://github.com/llvm/llvm-project/issues/90332#issuecomment-2325099254

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


6 Files Affected:

- (modified) libcxx/cmake/config-ix.cmake (+8-4) 
- (modified) libcxxabi/cmake/config-ix.cmake (+8-4) 
- (modified) libcxxabi/src/CMakeLists.txt (+2-2) 
- (modified) libunwind/cmake/config-ix.cmake (+8-4) 
- (modified) libunwind/src/CMakeLists.txt (+1-1) 
- (modified) runtimes/CMakeLists.txt (+8-4) 


``diff
diff --git a/libcxx/cmake/config-ix.cmake b/libcxx/cmake/config-ix.cmake
index 270d80575adcfd..192bad7a7a7fc6 100644
--- a/libcxx/cmake/config-ix.cmake
+++ b/libcxx/cmake/config-ix.cmake
@@ -38,9 +38,13 @@ check_cxx_compiler_flag(-nolibc CXX_SUPPORTS_NOLIBC_FLAG)
 # required during compilation (which has the -nostdlib++ or -nodefaultlibs). 
libc is
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
+#
+# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
+# compilation of C and C++. Therefore test to make sure that the flags are
+# supported by the C compiler driver, before deciding to include them.
 
-check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 else()
   check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
@@ -51,7 +55,7 @@ endif()
 
 # Only link against compiler-rt manually if we use -nodefaultlibs, since
 # otherwise the compiler will do the right thing on its own.
-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (LIBCXX_USE_COMPILER_RT)
 include(HandleCompilerRT)
 find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY
@@ -81,7 +85,7 @@ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND 
C_SUPPORTS_NODEFAULTLIBS_FLAG)
   endif()
 endif()
 
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
   endif ()
diff --git a/libcxxabi/cmake/config-ix.cmake b/libcxxabi/cmake/config-ix.cmake
index 10f2087c68c5e7..ab74ad79a654af 100644
--- a/libcxxabi/cmake/config-ix.cmake
+++ b/libcxxabi/cmake/config-ix.cmake
@@ -22,9 +22,13 @@ endif ()
 # required during compilation (which has the -nodefaultlibs). libc is
 # required for the link to go through. We remove sanitizers from the
 # configuration checks to avoid spurious link errors.
+#
+# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
+# compilation of C and C++. Therefore test to make sure that the flags are
+# supported by the C compiler driver, before deciding to include them.
 
-check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
+check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG)
   set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 else()
   check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
@@ -35,7 +39,7 @@ endif()
 
 # Only link against compiler-rt manually if we use -nodefaultlibs, since
 # otherwise the compiler will do the right thing on its own.
-if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (LIBCXXABI_HAS_C_LIB)
 list(APPEND CMAKE_REQUIRED_LIBRARIES c)
   endif ()
@@ -71,7 +75,7 @@ if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND 
C_SUPPORTS_NODEFAULTLIBS_FLAG)
   endif()
 endif()
 
-if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
  

[clang] [clang][C23] Support N3029 Improved Normal Enumerations (PR #103917)

2024-09-12 Thread Mariya Podchishchaeva via cfe-commits

Fznamznon wrote:

ping @AaronBallman 

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread Matthias Springer via cfe-commits


@@ -16,7 +16,7 @@ like Toy to get the information they need.
 
 MLIR provides a set of always available-hooks for certain core transformations,
 as seen in the [previous chapter](Ch-3.md), where we registered some
-canonicalizations via a hook on our operations (`getCanonicalizationPatterns`).

matthias-springer wrote:

Not sure if `canonicalization` has a plural. In practice we often say 
`canonicalizations` though.

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread Matthias Springer via cfe-commits


@@ -121,7 +121,7 @@ struct EmulateWideIntPass final
 [&typeConverter](Operation *op) { return typeConverter.isLegal(op); });
 
 RewritePatternSet patterns(ctx);
-// Add common pattenrs to support contants, functions, etc.

matthias-springer wrote:

I think think should be `constants`. Also there's a typo in `patterns`.

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread Matthias Springer via cfe-commits


@@ -14,7 +14,7 @@
   "name": "punctuation.definition.string.begin.cpp"
 },
 "1": {
-  "name": "mlir.delimeter.raw.string.cpp"

matthias-springer wrote:

I'm not sure if this is safe to change...

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread Matthias Springer via cfe-commits


@@ -316,7 +316,7 @@ static omp::DeclareReductionOp 
declareReduction(PatternRewriter &builder,
   reduction, {arith::CmpFPredicate::OLT, arith::CmpFPredicate::OLE},
   {arith::CmpFPredicate::OGT, arith::CmpFPredicate::OGE}, isMin) ||
   matchSelectReduction(
-  reduction, {LLVM::FCmpPredicate::olt, LLVM::FCmpPredicate::ole},

matthias-springer wrote:

Same here and in other places.

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread Matthias Springer via cfe-commits


@@ -239,7 +239,7 @@ std::optional 
mlir::detail::getDefaultIndexBitwidth(
 
 // Returns the endianness if specified in the given entry. If the entry is 
empty
 // the default endianness represented by an empty attribute is returned.
-Attribute mlir::detail::getDefaultEndianness(DataLayoutEntryInterface entry) {
+Attribute mlir::detail::getDefaultEndiannesss(DataLayoutEntryInterface entry) {

matthias-springer wrote:

Extra `s`?

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread Matthias Springer via cfe-commits


@@ -335,7 +335,7 @@ SPIR-V Dialect op| LLVM Dialect op
 `spirv.FOrdEqual`  | `llvm.fcmp "oeq"`
 `spirv.FOrdGreaterThan`| `llvm.fcmp "ogt"`
 `spirv.FOrdGreaterThanEqual`   | `llvm.fcmp "oge"`
-`spirv.FOrdLessThan`   | `llvm.fcmp "olt"`

matthias-springer wrote:

Not a typo.

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread Matthias Springer via cfe-commits


@@ -41,7 +41,7 @@ def Arith_CmpFPredicateAttr : I64EnumAttr<
   I64EnumAttrCase<"OEQ", 1, "oeq">,
   I64EnumAttrCase<"OGT", 2, "ogt">,
   I64EnumAttrCase<"OGE", 3, "oge">,
-  I64EnumAttrCase<"OLT", 4, "olt">,

matthias-springer wrote:

This is not a typo

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits


@@ -121,7 +121,7 @@ struct EmulateWideIntPass final
 [&typeConverter](Operation *op) { return typeConverter.isLegal(op); });
 
 RewritePatternSet patterns(ctx);
-// Add common pattenrs to support contants, functions, etc.

VitalyAnkh wrote:

You are so quick! I'm still undoing some false positives introduced by my 
grammar tools. Mark this as a draft before this is ready

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits

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


[clang-tools-extra] [mlir] [NFC][MLIR] Fix some typos (PR #108355)

2024-09-12 Thread via cfe-commits


@@ -14,7 +14,7 @@
   "name": "punctuation.definition.string.begin.cpp"
 },
 "1": {
-  "name": "mlir.delimeter.raw.string.cpp"

VitalyAnkh wrote:

But it is indeed a typo. Should we correct it?

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-09-12 Thread Alexander Kornienko via cfe-commits

alexfh wrote:

Hi @mizvekov, we started seeing crashes after this commit.

I'm working on a shareable test case, but here's the assertion failure and the 
stack trace:
```
assert.h assertion failed at llvm-project/clang/lib/AST/TemplateName.cpp:184 in 
TemplateDecl *clang::TemplateName::getAsTemplateDecl(bool) const: 
Name.getAsDeducedTemplateName
() == nullptr && "Unexpected canonical DeducedTemplateName; Did you mean to use 
" "getTemplateDeclAndDefaultArgs instead?"
@ 0x559dafb2e734  __assert_fail
@ 0x559dac2d2534  clang::TemplateName::getAsTemplateDecl()
@ 0x559dab8f5744  (anonymous 
namespace)::TemplateInstantiator::TransformTemplateName()
@ 0x559dab94e9a2  
clang::TreeTransform<>::TransformTemplateSpecializationType()
@ 0x559dab8e7f9f  clang::TreeTransform<>::TransformType()
@ 0x559dab94ad68  clang::TreeTransform<>::TransformElaboratedType()
@ 0x559dab8e80a5  clang::TreeTransform<>::TransformType()
@ 0x559dab8e7a0b  clang::TreeTransform<>::TransformType()
@ 0x559dab8e8790  clang::TreeTransform<>::TransformType()
@ 0x559dab8e8690  clang::Sema::SubstType()
@ 0x559dab6f4796  clang::Sema::CheckTemplateIdType()
@ 0x559dab94a6d1  
clang::TreeTransform<>::TransformDependentTemplateSpecializationType()
@ 0x559dab8e815f  clang::TreeTransform<>::TransformType()
@ 0x559dab8e8ebe  clang::Sema::SubstFunctionDeclType()
@ 0x559dab985787  clang::TemplateDeclInstantiator::SubstFunctionType()
@ 0x559dab98386d  clang::TemplateDeclInstantiator::VisitFunctionDecl()
@ 0x559dab9de2f3  llvm::function_ref<>::callback_fn<>()
@ 0x559daace13df  clang::Sema::runWithSufficientStackSpace()
@ 0x559dab98e1c8  clang::Sema::SubstDecl()
@ 0x559dab7d6bc1  clang::Sema::FinishTemplateArgumentDeduction()
@ 0x559dab866702  llvm::function_ref<>::callback_fn<>()
@ 0x559daace13df  clang::Sema::runWithSufficientStackSpace()
@ 0x559dab7da125  clang::Sema::DeduceTemplateArguments()
@ 0x559dab64655f  clang::Sema::AddTemplateOverloadCandidate()
@ 0x559dab65b2e4  AddOverloadedCallCandidate()
@ 0x559dab65b167  clang::Sema::AddOverloadedCallCandidates()
@ 0x559dab65b735  clang::Sema::buildOverloadedCallSet()
@ 0x559dab65bb92  clang::Sema::BuildOverloadedCallExpr()
@ 0x559dab13092c  clang::Sema::BuildCallExpr()
@ 0x559dab14af37  clang::Sema::ActOnCallExpr()
@ 0x559daa9f72b4  clang::Parser::ParsePostfixExpressionSuffix()
@ 0x559daa9f9078  clang::Parser::ParseCastExpression()
@ 0x559daa9f44b2  clang::Parser::ParseAssignmentExpression()
@ 0x559daaa4f9a0  
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes()
@ 0x559daaa4cf26  clang::Parser::ParseDeclGroup()
@ 0x559daaa4b310  clang::Parser::ParseSimpleDeclaration()
@ 0x559daaa4aa30  clang::Parser::ParseDeclaration()
@ 0x559daaa96433  
clang::Parser::ParseStatementOrDeclarationAfterAttributes()
@ 0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
@ 0x559daaa9f8f3  clang::Parser::ParseCompoundStatementBody()
@ 0x559daaa94f57  
clang::Parser::ParseStatementOrDeclarationAfterAttributes()
@ 0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
@ 0x559daaa9b8c0  clang::Parser::ParseForStatement()
@ 0x559daaa94e07  
clang::Parser::ParseStatementOrDeclarationAfterAttributes()
@ 0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
@ 0x559daaa9f8f3  clang::Parser::ParseCompoundStatementBody()
@ 0x559daaa94f57  
clang::Parser::ParseStatementOrDeclarationAfterAttributes()
@ 0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
@ 0x559daaa9b8c0  clang::Parser::ParseForStatement()
@ 0x559daaa94e07  
clang::Parser::ParseStatementOrDeclarationAfterAttributes()
@ 0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
@ 0x559daaa9f8f3  clang::Parser::ParseCompoundStatementBody()
@ 0x559daaa94f57  
clang::Parser::ParseStatementOrDeclarationAfterAttributes()
@ 0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
@ 0x559daaa9b8c0  clang::Parser::ParseForStatement()
@ 0x559daaa94e07  
clang::Parser::ParseStatementOrDeclarationAfterAttributes()
@ 0x559daaa9428e  clang::Parser::ParseStatementOrDeclaration()
@ 0x559daaa9f8f3  clang::Parser::ParseCompoundStatementBody()
@ 0x559d0c70  clang::Parser::ParseFunctionStatementBody()
@ 0x559daa9d361c  clang::Parser::ParseFunctionDefinition()
@ 0x559daaa4d89b  clang::Parser::ParseDeclGroup()
@ 0x559daa9d1ea8  clang::Parser::ParseDeclOrFunctionDefInternal()
@ 0x559daa9d13d2  clang::Parser::ParseDeclarationOrFunctionDefinition()
@ 0x559daa9d0106  clang::Parser::ParseExternalDeclaration()
@ 0x559daaa1fba7  clang::Parser::Par

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits

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

>From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 11:33:45 +
Subject: [PATCH 1/6] [clang] Do not expand pack while retaining expansion

---
 clang/lib/Sema/TreeTransform.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 0daf620b4123e4..a40673b04764da 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4361,7 +4361,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
-
+Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())
   return true;

>From 97fbf34c3edd09348fb48b4dc66f1d854516e8ef Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 11:59:58 +
Subject: [PATCH 2/6] Add comment

---
 clang/lib/Sema/TreeTransform.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a40673b04764da..0de43d2127b12f 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4361,6 +4361,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
+// Simple transform producing another pack expansion.
 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())

>From ab756525ab4a5f71ee5d3703238a1f9188a376e1 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 15:45:40 +
Subject: [PATCH 3/6] Add tests

---
 clang/test/SemaCXX/GH107560.cpp | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 clang/test/SemaCXX/GH107560.cpp

diff --git a/clang/test/SemaCXX/GH107560.cpp b/clang/test/SemaCXX/GH107560.cpp
new file mode 100644
index 00..faaa7004e06cf9
--- /dev/null
+++ b/clang/test/SemaCXX/GH107560.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+int bar(...);
+
+template  struct Int {};
+
+template 
+consteval auto foo(T... x) -> decltype(bar(T(x)...)) { return 10; }
+
+template 
+constexpr auto baz(Int(T())>... x) -> int { return 1; }
+
+static_assert(baz, Int<2>, Int<3>>(Int<10>(), Int<10>(), Int<10>()) == 
1);

>From 600a9259bf087c5f3b6e881211da69013aca018e Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 16:27:49 +
Subject: [PATCH 4/6] Move ArgumentPackSubstitutionIndexRAII to
 ForgetPartiallySubstitutedPackRAII

---
 clang/lib/Sema/TreeTransform.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 0de43d2127b12f..1538f87ac27358 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -113,9 +113,11 @@ class TreeTransform {
   class ForgetPartiallySubstitutedPackRAII {
 Derived &Self;
 TemplateArgument Old;
+Sema::ArgumentPackSubstitutionIndexRAII ResetPackSubstIndex;
 
   public:
-ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
+ForgetPartiallySubstitutedPackRAII(Derived &Self)
+: Self(Self), ResetPackSubstIndex(Self.getSema(), -1) {
   Old = Self.ForgetPartiallySubstitutedPack();
 }
 
@@ -4361,8 +4363,6 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
-// Simple transform producing another pack expansion.
-Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())
   return true;

>From 6cd618e295e984f2dd1924407fe64553549e6fcb Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 16:31:18 +
Subject: [PATCH 5/6] remove space

---
 clang/lib/Sema/TreeTransform.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1538f87ac27358..aa3e2308828bec 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4363,6 +4363,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
+
 ExprResult Out = getDerived().Tran

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits


@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s

usx95 wrote:

Done.

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


[clang] [clang] check deduction consistency when partial ordering function templates (PR #100692)

2024-09-12 Thread via cfe-commits

cor3ntin wrote:

> I tried out #94981 and -fno-relaxed-template-template-args and can confirm 
> both fix it. I'm now running into a separate LoopVectorizer crash, but I made 
> it out of the frontend :)
> 
> Using -fno-relaxed-template-template-args should be fine, in llvm-test-suite 
> we already do something similar for another benchmark by passing 
> -fdelayed-template-parsing, so I'll go ahead and open up a pull request there 
> to add the flag.
> 
> Thanks for all your help so far in finding a way around this!

It should work without any flags now, can you confirm?

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


[clang] [llvm] [SPIR-V] Add SPIR-V structurizer (PR #107408)

2024-09-12 Thread Nathan Gauër via cfe-commits

Keenuts wrote:

> > OpLoopMerge are taking BB operands, but verifier expected register operand.
> 
> Hopefully, the fix may be as simple as to change 
> lib/Target/SPIRV/SPIRVInstrInfo.td line 620-621 `ID:$merge, ID:$continue` 
> into `unknown:$merge, unknown:$continue` as in line 626 for OpBranch: `def 
> OpBranch: Op<249, (outs), (ins unknown:$label), "OpBranch $label">;`

Oh thanks!
Turns out the barrier think can also be solved with just an `isBarrier = 1` in 
this td file.

https://github.com/llvm/llvm-project/pull/107408
___
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 documentation of bugprone-pointer-arithmetic-on-polymorphic-object (PR #108324)

2024-09-12 Thread via cfe-commits

chrchr-github wrote:

Thank for addressing this.
I still wonder why using `new`/`delete` with additional UB (deleting pointer 
with offset) is necessary in the examples.
Why not simply define a function taking a pointer argument and do the 
arithmetic on that?

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


[clang] [clang][bytecode] Fix modify_global diagnostics in C++11 (PR #108358)

2024-09-12 Thread Timm Baeder via cfe-commits

https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/108358

We shouldn't emit this until C++14.

>From 82627320e5b3ec07f01d9f1761e5e871b1dc5919 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= 
Date: Thu, 12 Sep 2024 12:44:48 +0200
Subject: [PATCH] [clang][bytecode] Fix modify_global diagnostics in C++11

We shouldn't emit this until C++14.
---
 clang/lib/AST/ByteCode/Interp.cpp | 2 +-
 clang/test/AST/ByteCode/cxx11.cpp | 5 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 2fa8b40f6085ad..827a177f9bf830 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -883,7 +883,7 @@ bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer 
&Ptr,
 return diagnoseUnknownDecl(S, OpPC, D);
 
   assert(AK == AK_Assign);
-  if (S.getLangOpts().CPlusPlus11) {
+  if (S.getLangOpts().CPlusPlus14) {
 const SourceInfo &E = S.Current->getSource(OpPC);
 S.FFDiag(E, diag::note_constexpr_modify_global);
   }
diff --git a/clang/test/AST/ByteCode/cxx11.cpp 
b/clang/test/AST/ByteCode/cxx11.cpp
index 481e3da9289efa..86b58283023bc8 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -169,3 +169,8 @@ namespace FinalLtorDiags {
   A c; // both-error {{non-type template argument of type 'int *' is not a 
constant expression}} \
   // both-note {{read of non-constexpr variable 'q' is not allowed in 
a constant expression}}
 }
+
+void lambdas() {
+  int d;
+  int a9[1] = {[d = 0] = 1}; // both-error {{not an integral constant 
expression}}
+}

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


[clang] [clang][bytecode] Fix modify_global diagnostics in C++11 (PR #108358)

2024-09-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)


Changes

We shouldn't emit this until C++14.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/Interp.cpp (+1-1) 
- (modified) clang/test/AST/ByteCode/cxx11.cpp (+5) 


``diff
diff --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 2fa8b40f6085ad..827a177f9bf830 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -883,7 +883,7 @@ bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer 
&Ptr,
 return diagnoseUnknownDecl(S, OpPC, D);
 
   assert(AK == AK_Assign);
-  if (S.getLangOpts().CPlusPlus11) {
+  if (S.getLangOpts().CPlusPlus14) {
 const SourceInfo &E = S.Current->getSource(OpPC);
 S.FFDiag(E, diag::note_constexpr_modify_global);
   }
diff --git a/clang/test/AST/ByteCode/cxx11.cpp 
b/clang/test/AST/ByteCode/cxx11.cpp
index 481e3da9289efa..86b58283023bc8 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -169,3 +169,8 @@ namespace FinalLtorDiags {
   A c; // both-error {{non-type template argument of type 'int *' is not a 
constant expression}} \
   // both-note {{read of non-constexpr variable 'q' is not allowed in 
a constant expression}}
 }
+
+void lambdas() {
+  int d;
+  int a9[1] = {[d = 0] = 1}; // both-error {{not an integral constant 
expression}}
+}

``




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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread via cfe-commits

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

Can we get a changelog entry?
LGTM otherwise

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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits

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

>From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 11:33:45 +
Subject: [PATCH 1/7] [clang] Do not expand pack while retaining expansion

---
 clang/lib/Sema/TreeTransform.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 0daf620b4123e4..a40673b04764da 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4361,7 +4361,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
-
+Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())
   return true;

>From 97fbf34c3edd09348fb48b4dc66f1d854516e8ef Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 11:59:58 +
Subject: [PATCH 2/7] Add comment

---
 clang/lib/Sema/TreeTransform.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a40673b04764da..0de43d2127b12f 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4361,6 +4361,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
+// Simple transform producing another pack expansion.
 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())

>From ab756525ab4a5f71ee5d3703238a1f9188a376e1 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 15:45:40 +
Subject: [PATCH 3/7] Add tests

---
 clang/test/SemaCXX/GH107560.cpp | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 clang/test/SemaCXX/GH107560.cpp

diff --git a/clang/test/SemaCXX/GH107560.cpp b/clang/test/SemaCXX/GH107560.cpp
new file mode 100644
index 00..faaa7004e06cf9
--- /dev/null
+++ b/clang/test/SemaCXX/GH107560.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+int bar(...);
+
+template  struct Int {};
+
+template 
+consteval auto foo(T... x) -> decltype(bar(T(x)...)) { return 10; }
+
+template 
+constexpr auto baz(Int(T())>... x) -> int { return 1; }
+
+static_assert(baz, Int<2>, Int<3>>(Int<10>(), Int<10>(), Int<10>()) == 
1);

>From 600a9259bf087c5f3b6e881211da69013aca018e Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 16:27:49 +
Subject: [PATCH 4/7] Move ArgumentPackSubstitutionIndexRAII to
 ForgetPartiallySubstitutedPackRAII

---
 clang/lib/Sema/TreeTransform.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 0de43d2127b12f..1538f87ac27358 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -113,9 +113,11 @@ class TreeTransform {
   class ForgetPartiallySubstitutedPackRAII {
 Derived &Self;
 TemplateArgument Old;
+Sema::ArgumentPackSubstitutionIndexRAII ResetPackSubstIndex;
 
   public:
-ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
+ForgetPartiallySubstitutedPackRAII(Derived &Self)
+: Self(Self), ResetPackSubstIndex(Self.getSema(), -1) {
   Old = Self.ForgetPartiallySubstitutedPack();
 }
 
@@ -4361,8 +4363,6 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
-// Simple transform producing another pack expansion.
-Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())
   return true;

>From 6cd618e295e984f2dd1924407fe64553549e6fcb Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 16:31:18 +
Subject: [PATCH 5/7] remove space

---
 clang/lib/Sema/TreeTransform.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1538f87ac27358..aa3e2308828bec 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4363,6 +4363,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
+
 ExprResult Out = getDerived().Tran

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits

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

>From 5901d82ea0543074853b963f7dc9106a6fe3bcee Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 11:33:45 +
Subject: [PATCH 1/7] [clang] Do not expand pack while retaining expansion

---
 clang/lib/Sema/TreeTransform.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 0daf620b4123e4..a40673b04764da 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4361,7 +4361,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
-
+Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())
   return true;

>From 97fbf34c3edd09348fb48b4dc66f1d854516e8ef Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 11:59:58 +
Subject: [PATCH 2/7] Add comment

---
 clang/lib/Sema/TreeTransform.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index a40673b04764da..0de43d2127b12f 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4361,6 +4361,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
+// Simple transform producing another pack expansion.
 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())

>From ab756525ab4a5f71ee5d3703238a1f9188a376e1 Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 15:45:40 +
Subject: [PATCH 3/7] Add tests

---
 clang/test/SemaCXX/GH107560.cpp | 14 ++
 1 file changed, 14 insertions(+)
 create mode 100644 clang/test/SemaCXX/GH107560.cpp

diff --git a/clang/test/SemaCXX/GH107560.cpp b/clang/test/SemaCXX/GH107560.cpp
new file mode 100644
index 00..faaa7004e06cf9
--- /dev/null
+++ b/clang/test/SemaCXX/GH107560.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+int bar(...);
+
+template  struct Int {};
+
+template 
+consteval auto foo(T... x) -> decltype(bar(T(x)...)) { return 10; }
+
+template 
+constexpr auto baz(Int(T())>... x) -> int { return 1; }
+
+static_assert(baz, Int<2>, Int<3>>(Int<10>(), Int<10>(), Int<10>()) == 
1);

>From 600a9259bf087c5f3b6e881211da69013aca018e Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 16:27:49 +
Subject: [PATCH 4/7] Move ArgumentPackSubstitutionIndexRAII to
 ForgetPartiallySubstitutedPackRAII

---
 clang/lib/Sema/TreeTransform.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 0de43d2127b12f..1538f87ac27358 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -113,9 +113,11 @@ class TreeTransform {
   class ForgetPartiallySubstitutedPackRAII {
 Derived &Self;
 TemplateArgument Old;
+Sema::ArgumentPackSubstitutionIndexRAII ResetPackSubstIndex;
 
   public:
-ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
+ForgetPartiallySubstitutedPackRAII(Derived &Self)
+: Self(Self), ResetPackSubstIndex(Self.getSema(), -1) {
   Old = Self.ForgetPartiallySubstitutedPack();
 }
 
@@ -4361,8 +4363,6 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
-// Simple transform producing another pack expansion.
-Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
 ExprResult Out = getDerived().TransformExpr(Pattern);
 if (Out.isInvalid())
   return true;

>From 6cd618e295e984f2dd1924407fe64553549e6fcb Mon Sep 17 00:00:00 2001
From: Utkarsh Saxena 
Date: Wed, 11 Sep 2024 16:31:18 +
Subject: [PATCH 5/7] remove space

---
 clang/lib/Sema/TreeTransform.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 1538f87ac27358..aa3e2308828bec 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -4363,6 +4363,7 @@ bool TreeTransform::TransformExprs(Expr *const 
*Inputs,
   // forgetting the partially-substituted parameter pack.
   if (RetainExpansion) {
 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
+
 ExprResult Out = getDerived().Tran

[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits

usx95 wrote:

Thanks for the review. Landing now. For other reviewers, feel free to drop more 
comments, and I would be happy to address in a followup.

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


[clang] 849d1b8 - [clang] Do not substitute parameter pack while retaining the pack expansion (#108197)

2024-09-12 Thread via cfe-commits

Author: Utkarsh Saxena
Date: 2024-09-12T13:21:26+02:00
New Revision: 849d1b8b1f1fc16dc28b07da358515a52b79ea81

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

LOG: [clang] Do not substitute parameter pack while retaining the pack 
expansion (#108197)

(In reference to 
https://github.com/llvm/llvm-project/pull/108197/commits/5901d82ea0543074853b963f7dc9106a6fe3bcee)
Consider when `Input[I]` is a `VarDecl` with parameter pack. We would
have already expanded the pack before the code change in the loop`for
(unsigned I = 0; I != *NumExpansions; ++I) {`.

Now in `if (RetainExpansion) {`, without this change, we continue to
substitute the pack in the pattern even when we do not have meaningful
`ArgumentPackSubstitutionIndex` set.

This leads to use of an invalid pack substitution index in
`TemplateInstantiator::TransformFunctionParmPackRefExpr` in
`TransformedDecl = (*Pack)[getSema().ArgumentPackSubstitutionIndex];`

This change sets `ArgumentPackSubstitutionIndex` to `-1` while retaining
expansion to instruct `TransformFunctionParmPackRefExpr` to build
`FunctionParmPackExpr` instead of substituting the param pack.

---

There are other instances of `RetainExpansion` and IIUC, they should
also unset the `ArgumentPackSubstitutionIndex`. It would be great if
someone can verify my understanding. If this is correct then we could
instead have a `ArgumentPackSubstitutionIndexRAII` as part of
`ForgetPartiallySubstitutedPackRAII`.

EDIT: I have moved this to `ForgetPartiallySubstitutedPackRAII`.

Fixes https://github.com/llvm/llvm-project/issues/63819
Fixes https://github.com/llvm/llvm-project/issues/107560

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/TreeTransform.h
clang/test/SemaTemplate/pack-deduction.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d4db877a823ea5..c4fa017b982bbd 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -382,6 +382,9 @@ Bug Fixes to C++ Support
 - Fix a crash when using ``source_location`` in the trailing return type of a 
lambda expression. (#GH67134)
 - A follow-up fix was added for (#GH61460), as the previous fix was not 
entirely correct. (#GH86361)
 - Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887)
+- Fixed a crash when clang tries to subtitute parameter pack while retaining 
the parameter
+  pack. #GH63819, #GH107560
+
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 4bbc024587915c..ff745b3385fcd9 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -113,9 +113,13 @@ class TreeTransform {
   class ForgetPartiallySubstitutedPackRAII {
 Derived &Self;
 TemplateArgument Old;
+// Set the pack expansion index to -1 to avoid pack substitution and
+// indicate that parameter packs should be instantiated as themselves.
+Sema::ArgumentPackSubstitutionIndexRAII ResetPackSubstIndex;
 
   public:
-ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
+ForgetPartiallySubstitutedPackRAII(Derived &Self)
+: Self(Self), ResetPackSubstIndex(Self.getSema(), -1) {
   Old = Self.ForgetPartiallySubstitutedPack();
 }
 

diff  --git a/clang/test/SemaTemplate/pack-deduction.cpp 
b/clang/test/SemaTemplate/pack-deduction.cpp
index e42709820e9cff..28fb127a386441 100644
--- a/clang/test/SemaTemplate/pack-deduction.cpp
+++ b/clang/test/SemaTemplate/pack-deduction.cpp
@@ -185,3 +185,17 @@ void Run() {
   Outer::Inner<0>().Test(1,1);
 }
 }
+
+namespace GH107560 {
+int bar(...);
+
+template  struct Int {};
+
+template 
+constexpr auto foo(T... x) -> decltype(bar(T(x)...)) { return 10; }
+
+template 
+constexpr auto baz(Int(T())>... x) -> int { return 1; }
+
+static_assert(baz, Int<2>, Int<3>>(Int<10>(), Int<10>(), Int<10>()) == 
1, "");
+}



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


[clang] [clang] Do not substitute parameter pack while retaining the pack expansion (PR #108197)

2024-09-12 Thread Utkarsh Saxena via cfe-commits

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


[clang] f22a8d1 - [clang][bytecode] Fix modify_global diagnostics in C++11 (#108358)

2024-09-12 Thread via cfe-commits

Author: Timm Baeder
Date: 2024-09-12T13:25:25+02:00
New Revision: f22a8d18229fe94fe340afbf02ad9592ca199784

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

LOG: [clang][bytecode] Fix modify_global diagnostics in C++11 (#108358)

We shouldn't emit this until C++14.

Added: 


Modified: 
clang/lib/AST/ByteCode/Interp.cpp
clang/test/AST/ByteCode/cxx11.cpp

Removed: 




diff  --git a/clang/lib/AST/ByteCode/Interp.cpp 
b/clang/lib/AST/ByteCode/Interp.cpp
index 2fa8b40f6085ad..827a177f9bf830 100644
--- a/clang/lib/AST/ByteCode/Interp.cpp
+++ b/clang/lib/AST/ByteCode/Interp.cpp
@@ -883,7 +883,7 @@ bool CheckDummy(InterpState &S, CodePtr OpPC, const Pointer 
&Ptr,
 return diagnoseUnknownDecl(S, OpPC, D);
 
   assert(AK == AK_Assign);
-  if (S.getLangOpts().CPlusPlus11) {
+  if (S.getLangOpts().CPlusPlus14) {
 const SourceInfo &E = S.Current->getSource(OpPC);
 S.FFDiag(E, diag::note_constexpr_modify_global);
   }

diff  --git a/clang/test/AST/ByteCode/cxx11.cpp 
b/clang/test/AST/ByteCode/cxx11.cpp
index 481e3da9289efa..86b58283023bc8 100644
--- a/clang/test/AST/ByteCode/cxx11.cpp
+++ b/clang/test/AST/ByteCode/cxx11.cpp
@@ -169,3 +169,8 @@ namespace FinalLtorDiags {
   A c; // both-error {{non-type template argument of type 'int *' is not a 
constant expression}} \
   // both-note {{read of non-constexpr variable 'q' is not allowed in 
a constant expression}}
 }
+
+void lambdas() {
+  int d;
+  int a9[1] = {[d = 0] = 1}; // both-error {{not an integral constant 
expression}}
+}



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


[clang] [clang][bytecode] Fix modify_global diagnostics in C++11 (PR #108358)

2024-09-12 Thread Timm Baeder via cfe-commits

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


[clang] [llvm] Delete the clang-format Visual Studio plugin code (PR #108342)

2024-09-12 Thread Alexandre Ganea via cfe-commits

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


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


[clang] ddd2af3 - Delete the clang-format Visual Studio plugin code (#108342)

2024-09-12 Thread via cfe-commits

Author: Hans
Date: 2024-09-12T13:27:38+02:00
New Revision: ddd2af3c5a076f2c5f2024019067b206d1b411b4

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

LOG: Delete the clang-format Visual Studio plugin code (#108342)

This was obsoleted by Visual Studio providing built-in support for
running clang-format in VS2017.

We haven't shipped it for years (since
10d2195305ac49605f2b7b6a25a4076c31923191), never got it working with
VS2019, and never even tried with VS2022.

It's time to retire the code.

Added: 


Modified: 
clang/tools/CMakeLists.txt
llvm/utils/release/build_llvm_release.bat

Removed: 
clang/tools/clang-format-vs/.gitignore
clang/tools/clang-format-vs/CMakeLists.txt
clang/tools/clang-format-vs/ClangFormat.sln
clang/tools/clang-format-vs/ClangFormat/ClangFormat.csproj
clang/tools/clang-format-vs/ClangFormat/ClangFormat.vsct
clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
clang/tools/clang-format-vs/ClangFormat/GlobalSuppressions.cs
clang/tools/clang-format-vs/ClangFormat/Guids.cs
clang/tools/clang-format-vs/ClangFormat/PkgCmdID.cs
clang/tools/clang-format-vs/ClangFormat/Properties/AssemblyInfo.cs
clang/tools/clang-format-vs/ClangFormat/Resources.Designer.cs
clang/tools/clang-format-vs/ClangFormat/Resources.resx
clang/tools/clang-format-vs/ClangFormat/Resources/Images_32bit.bmp
clang/tools/clang-format-vs/ClangFormat/Resources/Package.ico
clang/tools/clang-format-vs/ClangFormat/RunningDocTableEventsDispatcher.cs
clang/tools/clang-format-vs/ClangFormat/VSPackage.resx
clang/tools/clang-format-vs/ClangFormat/Vsix.cs
clang/tools/clang-format-vs/ClangFormat/license.txt
clang/tools/clang-format-vs/ClangFormat/packages.config
clang/tools/clang-format-vs/README.txt
clang/tools/clang-format-vs/source.extension.vsixmanifest.in



diff  --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 4885afc1584d01..f588a3634ee6bc 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -5,7 +5,6 @@ add_clang_subdirectory(driver)
 add_clang_subdirectory(apinotes-test)
 add_clang_subdirectory(clang-
diff )
 add_clang_subdirectory(clang-format)
-add_clang_subdirectory(clang-format-vs)
 add_clang_subdirectory(clang-fuzzer)
 add_clang_subdirectory(clang-import-test)
 add_clang_subdirectory(clang-linker-wrapper)

diff  --git a/clang/tools/clang-format-vs/.gitignore 
b/clang/tools/clang-format-vs/.gitignore
deleted file mode 100644
index 270d840cb6d1a8..00
--- a/clang/tools/clang-format-vs/.gitignore
+++ /dev/null
@@ -1,11 +0,0 @@
-# Visual Studio files
-.vs/
-*.user
-/packages/
-/ClangFormat/obj/
-/ClangFormat/bin/
-
-# Generated and copied files
-/ClangFormat/Key.snk
-/ClangFormat/clang-format.exe
-/ClangFormat/source.extension.vsixmanifest

diff  --git a/clang/tools/clang-format-vs/CMakeLists.txt 
b/clang/tools/clang-format-vs/CMakeLists.txt
deleted file mode 100644
index 1d44a47a3137be..00
--- a/clang/tools/clang-format-vs/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-option(BUILD_CLANG_FORMAT_VS_PLUGIN "Build clang-format VS plugin" OFF)
-if (BUILD_CLANG_FORMAT_VS_PLUGIN)
-  add_custom_target(clang_format_exe_for_vsix
-  ${CMAKE_COMMAND} -E copy_if_
diff erent
-  "${LLVM_TOOLS_BINARY_DIR}/clang-format.exe"
-  "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/clang-format.exe"
-  DEPENDS clang-format)
-
-  # Build number added to Clang version to ensure that new VSIX can be upgraded
-  string(TIMESTAMP CLANG_FORMAT_VSIX_BUILD %y%m%d%H%M UTC)
-
-  if (NOT CLANG_FORMAT_VS_VERSION)
-set(CLANG_FORMAT_VS_VERSION 
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}.${CLANG_FORMAT_VSIX_BUILD}")
-  endif()
-
-  configure_file("source.extension.vsixmanifest.in"
-  "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest")
-
-  find_program(NUGET_EXE nuget PATHS ${NUGET_EXE_DIR})
-  if (NOT NUGET_EXE)
-message(FATAL_ERROR "Could not find nuget.exe. Download from 
https://www.nuget.org/nuget.exe";
-" and add parent directory to PATH or pass it via 
NUGET_EXE_DIR var.")
-  endif()
-
-  add_custom_target(clang_format_vsix ALL
-  COMMAND ${NUGET_EXE} restore 
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln"
-  COMMAND devenv "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat.sln" /Build 
Release
-  DEPENDS clang_format_exe_for_vsix 
"${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/source.extension.vsixmanifest"
-  COMMAND ${CMAKE_COMMAND} -E copy_if_
diff erent
-  "${CMAKE_CURRENT_SOURCE_DIR}/ClangFormat/bin/Release/ClangFormat.vsix"
-  "${LLVM_TOOLS_BINARY_DIR}/ClangFormat.vsix"
-  DEPENDS clang_format_exe_for_vsix)
-endif()

diff  --git a/clang/tools/clang-format-vs/ClangForma

[clang] [llvm] Delete the clang-format Visual Studio plugin code (PR #108342)

2024-09-12 Thread via cfe-commits

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


  1   2   3   4   5   6   >