[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits

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


[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits

https://github.com/cor3ntin commented:

I'm pretty happy with the direction this is going in.
I'd like to see the specific test in 
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2398, the ones we 
exchanged by mails and some tests with constraints

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


[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits


@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema , NamedDecl *A,

cor3ntin wrote:

This definitely needs a comment. The name should probably be along the lines of 
"SynthesizeTemplateArgumentWithDefaultArg" 

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


[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits


@@ -1133,8 +1133,8 @@ C++17 implementation status
 
 
   Matching template template parameters to compatible arguments
-  https://wg21.link/p0522r0;>P0522R0
-  Partial (10)
+  https://wg21.link/p0522r0;>P0522R0 (DR)
+  Clang 4 (10)

cor3ntin wrote:

```suggestion
  Clang 19(10)
```
Even if we previously had an some implementation it was well hidden :)
I think there is value in keeping the note. But the note might change as we 
want to keep a way to disable the new behavior.

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


[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits


@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema , NamedDecl *A,
+  TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+auto *T = cast(A);
+// FIXME: DefaultArgument can't represent a pack.
+if (T->isParameterPack())
+  return A;
+auto *R = TemplateTypeParmDecl::Create(
+S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(),
+T->getDepth(), T->getIndex(), T->getIdentifier(),
+T->wasDeclaredWithTypename(), /*ParameterPack=*/false,
+T->hasTypeConstraint());
+R->setDefaultArgument(
+S.Context.getTrivialTypeSourceInfo(Default.getAsType()));
+if (R->hasTypeConstraint()) {
+  auto *C = R->getTypeConstraint();
+  R->setTypeConstraint(C->getConceptReference(),
+   C->getImmediatelyDeclaredConstraint());
+}
+return R;
+  }
+  case Decl::NonTypeTemplateParm: {
+auto *T = cast(A);
+// FIXME: DefaultArgument can't represent a pack.
+if (T->isParameterPack())
+  return A;
+auto *R = NonTypeTemplateParmDecl::Create(
+S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(),
+T->getDepth(), T->getIndex(), T->getIdentifier(), T->getType(),
+/*ParameterPack=*/false, T->getTypeSourceInfo());
+R->setDefaultArgument(Default.getAsExpr());
+if (auto *PTC = T->getPlaceholderTypeConstraint())
+  R->setPlaceholderTypeConstraint(PTC);
+return R;
+  }
+  case Decl::TemplateTemplateParm: {

cor3ntin wrote:

I don't see how the `TemplateTemplateParm` case is ever used, right?


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


[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits


@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema , NamedDecl *A,
+  TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+auto *T = cast(A);
+// FIXME: DefaultArgument can't represent a pack.
+if (T->isParameterPack())
+  return A;
+auto *R = TemplateTypeParmDecl::Create(
+S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(),
+T->getDepth(), T->getIndex(), T->getIdentifier(),
+T->wasDeclaredWithTypename(), /*ParameterPack=*/false,
+T->hasTypeConstraint());
+R->setDefaultArgument(
+S.Context.getTrivialTypeSourceInfo(Default.getAsType()));
+if (R->hasTypeConstraint()) {
+  auto *C = R->getTypeConstraint();
+  R->setTypeConstraint(C->getConceptReference(),
+   C->getImmediatelyDeclaredConstraint());

cor3ntin wrote:

We probably want tests for constrainted declarations

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


[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits


@@ -519,13 +571,45 @@ DeduceTemplateArguments(Sema , TemplateParameterList 
*TemplateParams,
 return TemplateDeductionResult::Success;
   }
 
-  if (TemplateTemplateParmDecl *TempParam
-= dyn_cast(ParamDecl)) {
+  if (auto *TempParam = dyn_cast(ParamDecl)) {
 // If we're not deducing at this depth, there's nothing to deduce.
 if (TempParam->getDepth() != Info.getDeducedDepth())
   return TemplateDeductionResult::Success;
 
-DeducedTemplateArgument 
NewDeduced(S.Context.getCanonicalTemplateName(Arg));
+auto NewDeduced = DeducedTemplateArgument(Arg);
+// Provisional resolution for CWG2398: If Arg is also a template template
+// param, and it names a template specialization, then we deduce a
+// synthesized template template parameter based on A, but using the TS's
+// arguments as defaults.
+if (auto *TempArg = dyn_cast_or_null(
+Arg.getAsTemplateDecl())) {
+  assert(Arg.getKind() == TemplateName::Template);
+  assert(!TempArg->isExpandedParameterPack());
+
+  TemplateParameterList *As = TempArg->getTemplateParameters();
+  if (DefaultArguments.size() != 0) {
+assert(DefaultArguments.size() <= As->size());
+SmallVector Params(As->size());
+for (unsigned I = 0; I < DefaultArguments.size(); ++I)
+  Params[I] =
+  DeduceTemplateArguments(S, As->getParam(I), DefaultArguments[I]);
+for (unsigned I = DefaultArguments.size(); I < As->size(); ++I)
+  Params[I] = As->getParam(I);
+// FIXME: We could unique these, and also the parameters, but we don't
+// expect programs to contain a large enough amount of these deductions
+// for that to be worthwhile.

cor3ntin wrote:

Double checking: These parameters are only used for deduction, so not unique 
them would not affect type identity?

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


[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits


@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema , NamedDecl *A,
+  TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+auto *T = cast(A);
+// FIXME: DefaultArgument can't represent a pack.
+if (T->isParameterPack())

cor3ntin wrote:

Should we assert here?

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


[clang] [clang] deprecate frelaxed-template-template-args, make it on by default (PR #89807)

2024-04-24 Thread via cfe-commits


@@ -8343,58 +8343,52 @@ bool 
Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param,
   // C++1z [temp.arg.template]p3: (DR 150)
   //   A template-argument matches a template template-parameter P when P
   //   is at least as specialized as the template-argument A.
-  // FIXME: We should enable RelaxedTemplateTemplateArgs by default as it is a
-  //  defect report resolution from C++17 and shouldn't be introduced by
-  //  concepts.
-  if (getLangOpts().RelaxedTemplateTemplateArgs) {

cor3ntin wrote:

I also wonder if, at least for the time being, we should leave C++03 alone 
(despite the paper being a DR)

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


[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)

2024-04-24 Thread Wentao Zhang via cfe-commits

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


[clang] [llvm] [ARM] Armv8-R does not require fp64 or neon. (PR #88287)

2024-04-24 Thread David Green via cfe-commits

davemgreen wrote:

I'm not sure I would make this change, mostly due to it potentially causing a 
break for existing users and making performance worse, but can see the 
reasoning. I am willing to defer to others if they have an opinion.

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


[clang] [clang][Sema] Preserve the initializer of invalid VarDecls (PR #88645)

2024-04-24 Thread Nathan Ridge via cfe-commits

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

>From c24e79da57fc69d2f353a5533a3cc26313301a71 Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Sun, 14 Apr 2024 02:41:48 -0400
Subject: [PATCH] [clang][Sema] Preserve the initializer of invalid VarDecls

Fixes https://github.com/clangd/clangd/issues/1821
---
 clang/lib/Sema/JumpDiagnostics.cpp   |  3 ++-
 clang/lib/Sema/SemaDecl.cpp  | 16 +---
 clang/test/AST/ast-dump-recovery.cpp |  8 
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/JumpDiagnostics.cpp 
b/clang/lib/Sema/JumpDiagnostics.cpp
index ec3892e92f3c3b..27d5284fdb67e7 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -179,7 +179,8 @@ static ScopePair GetDiagForGotoScopeDecl(Sema , const 
Decl *D) {
 }
 
 const Expr *Init = VD->getInit();
-if (S.Context.getLangOpts().CPlusPlus && VD->hasLocalStorage() && Init) {
+if (S.Context.getLangOpts().CPlusPlus && VD->hasLocalStorage() && Init &&
+!Init->containsErrors()) {
   // C++11 [stmt.dcl]p3:
   //   A program that jumps from a point where a variable with automatic
   //   storage duration is not in scope to a point where it is in scope
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 9fdd8eb236d1ee..e6eaa98bda98e5 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -13435,15 +13435,16 @@ void Sema::checkNonTrivialCUnion(QualType QT, 
SourceLocation Loc,
 void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
   // If there is no declaration, there was an error parsing it.  Just ignore
   // the initializer.
-  if (!RealDecl || RealDecl->isInvalidDecl()) {
+  if (!RealDecl) {
 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null(RealDecl));
 return;
   }
 
-  if (CXXMethodDecl *Method = dyn_cast(RealDecl)) {
+  if (auto *Method = dyn_cast(RealDecl);
+  Method && !Method->isInvalidDecl()) {
 // Pure-specifiers are handled in ActOnPureSpecifier.
 Diag(Method->getLocation(), diag::err_member_function_initialization)
-  << Method->getDeclName() << Init->getSourceRange();
+<< Method->getDeclName() << Init->getSourceRange();
 Method->setInvalidDecl();
 return;
   }
@@ -13456,6 +13457,15 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 return;
   }
 
+  if (VDecl->isInvalidDecl()) {
+CorrectDelayedTyposInExpr(Init, VDecl);
+ExprResult Recovery =
+CreateRecoveryExpr(Init->getBeginLoc(), Init->getEndLoc(), {Init});
+if (Expr *E = Recovery.get())
+  VDecl->setInit(E);
+return;
+  }
+
   // WebAssembly tables can't be used to initialise a variable.
   if (Init && !Init->getType().isNull() &&
   Init->getType()->isWebAssemblyTableType()) {
diff --git a/clang/test/AST/ast-dump-recovery.cpp 
b/clang/test/AST/ast-dump-recovery.cpp
index cfb013585ad744..77527743fe8577 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -413,6 +413,14 @@ void RecoveryExprForInvalidDecls(Unknown InvalidDecl) {
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
 }
 
+void InitializerOfInvalidDecl() {
+  int ValidDecl;
+  Unkown InvalidDecl = ValidDecl;
+  // CHECK:  VarDecl {{.*}} invalid InvalidDecl
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} '' contains-errors
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'int' lvalue Var {{.*}} 'ValidDecl'
+}
+
 void RecoverToAnInvalidDecl() {
   Unknown* foo; // invalid decl
   goo; // the typo was correct to the invalid foo.

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


[clang] [clang][Sema] Improve error recovery for id-expressions referencing invalid decls (PR #81662)

2024-04-24 Thread Nathan Ridge via cfe-commits

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

>From 480cabcfeb42542746026bba753b4170e08bb8ae Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Tue, 13 Feb 2024 12:26:17 -0500
Subject: [PATCH] [clang][Sema] Improve error recovery for id-expressions
 referencing invalid decls

Passing AcceptInvalidDecl=true to BuildDeclarationNameExpr() allows
the RecoveryExpr that's constructed to retain a DeclRefExpr pointing
to the invalid decl as a child, preserving information about the
reference for use by tools such as clangd.

Fixes https://github.com/clangd/clangd/issues/1820
---
 clang/lib/Sema/SemaExpr.cpp  | 6 +-
 clang/test/AST/ast-dump-recovery.cpp | 6 ++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2a0e86c37f1bfc..ee999646a3a218 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2928,7 +2928,7 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec ,
 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
   }
 
-  return BuildDeclarationNameExpr(SS, R, ADL);
+  return BuildDeclarationNameExpr(SS, R, ADL, /*AcceptInvalidDecl=*/true);
 }
 
 /// BuildQualifiedDeclarationNameExpr - Build a C++ qualified
@@ -3453,6 +3453,10 @@ ExprResult Sema::BuildDeclarationNameExpr(const 
CXXScopeSpec ,
NeedsADL, R.isOverloadedResult(),
R.begin(), R.end());
 
+  if (R.isSingleResult() && R.getFoundDecl()->isInvalidDecl()) {
+return CreateRecoveryExpr(ULE->getBeginLoc(), ULE->getEndLoc(), {ULE});
+  }
+
   return ULE;
 }
 
diff --git a/clang/test/AST/ast-dump-recovery.cpp 
b/clang/test/AST/ast-dump-recovery.cpp
index cfb013585ad744..f628fa913da1e6 100644
--- a/clang/test/AST/ast-dump-recovery.cpp
+++ b/clang/test/AST/ast-dump-recovery.cpp
@@ -402,6 +402,7 @@ void returnInitListFromVoid() {
   // CHECK-NEXT:   `-IntegerLiteral {{.*}} 'int' 8
 }
 
+void FuncTakingUnknown(Unknown);
 void RecoveryExprForInvalidDecls(Unknown InvalidDecl) {
   InvalidDecl + 1;
   // CHECK:  BinaryOperator {{.*}}
@@ -411,6 +412,11 @@ void RecoveryExprForInvalidDecls(Unknown InvalidDecl) {
   InvalidDecl();
   // CHECK:  CallExpr {{.*}}
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
+  FuncTakingUnknown(InvalidDecl);
+  // CHECK:  CallExpr {{.*}} ''
+  // CHECK-NEXT: |-UnresolvedLookupExpr {{.*}} ''
+  // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
+  // CHECK-NEXT:   `-DeclRefExpr {{.*}} 'InvalidDecl' 'int'
 }
 
 void RecoverToAnInvalidDecl() {

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


[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)

2024-04-24 Thread Wentao Zhang via cfe-commits

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


[clang] [Driver] Restore compiler-rt arch suffix for PS and Windows (PR #89775)

2024-04-24 Thread Tobias Hieta via cfe-commits

tru wrote:

I agree that if downstream want to change stuff, they need to engage. We can't 
guess what microsoft wants to do (or sony) unless we have a discussion about 
it. This is also documented in the developer policy. If there are missed 
release notes, they need to be added of course.

That said - if I understand your problem correctly @pogo59 you are building 
clang yourself, but you are using the asan libraries from MSVC? I am not sure 
that would ever be a supported configuration if the compiler isn't built from 
the same source as the runtime libraries. If you would have built 
compiler-rt/asan yourself it should have been found and used correctly.

I think it might make sense to make a RFC (again I guess) to remove the old 
paths and have a grace period where there is a cmake option to force the old 
layout. This would harmonize so that we have just one layout and remove the 
biggest problem (in my mind) which is the fallback that can load the wrong 
runtime library if you are unlucky.

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


[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)

2024-04-24 Thread Nathan Ridge via cfe-commits


@@ -474,6 +477,17 @@ void DeclPrinter::VisitDeclContext(DeclContext *DC, bool 
Indent) {
   for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = 
DC->decls_end();
D != DEnd; ++D) {
 
+// Print enum members and public struct fields when
+// PrintTagTypeContents=true. Only applicable when TerseOutput=true since
+// otherwise all members are printed.
+if (Policy.TerseOutput) {
+  assert(Policy.PrintTagTypeContents);
+  if (!(isa(*D) ||
+(isa(*D) &&
+ dyn_cast(*D)->getAccess() == AS_public)))

HighCommander4 wrote:

The patch does seem to work for me on C files, but adding a test to exercise 
the code in C mode is definitely a good idea. Thanks!

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


[clang] 805d563 - [clang] Mark ill-formed partial specialization as invalid (#89536)

2024-04-24 Thread via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-04-24T10:45:38+04:00
New Revision: 805d5637a0d50caa073f435b55940c1338aae0fc

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

LOG: [clang] Mark ill-formed partial specialization as invalid (#89536)

Fixes #89374
Solution suggested by @cor3ntin

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/test/SemaCXX/template-specialization.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3db558a1c11a3f..64526ed6d06f55 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -415,6 +415,9 @@ Bug Fixes in This Version
   operator.
   Fixes (#GH83267).
 
+- Fix crash on ill-formed partial specialization with CRTP.
+  Fixes (#GH89374).
+
 - Clang now correctly generates overloads for bit-precise integer types for
   builtin operators in C++. Fixes #GH82998.
 

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 4bda31ba67c02d..bbcb7c33a98579 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -9460,6 +9460,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
   Diag(TemplateNameLoc, diag::err_partial_spec_fully_specialized)
 << ClassTemplate->getDeclName();
   isPartialSpecialization = false;
+  Invalid = true;
 }
   }
 
@@ -9675,6 +9676,7 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
   if (SkipBody && SkipBody->ShouldSkip)
 return SkipBody->Previous;
 
+  Specialization->setInvalidDecl(Invalid);
   return Specialization;
 }
 

diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 0b6375001f5326..c3815bca038554 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -1914,6 +1914,9 @@ static TemplateDeductionResult 
DeduceTemplateArgumentsByTypeMatch(
   if (!S.isCompleteType(Info.getLocation(), A))
 return Result;
 
+  if (getCanonicalRD(A)->isInvalidDecl())
+return Result;
+
   // Reset the incorrectly deduced argument from above.
   Deduced = DeducedOrig;
 

diff  --git a/clang/test/SemaCXX/template-specialization.cpp 
b/clang/test/SemaCXX/template-specialization.cpp
index 7b26ff9f5c5ba4..eabb84f2e13d3e 100644
--- a/clang/test/SemaCXX/template-specialization.cpp
+++ b/clang/test/SemaCXX/template-specialization.cpp
@@ -52,3 +52,31 @@ void instantiate() {
 }
 
 }
+
+namespace GH89374 {
+
+struct A {};
+
+template 
+struct MatrixBase { // #GH89374-MatrixBase
+  template 
+  Derived =(const MatrixBase &); // 
#GH89374-copy-assignment
+};
+
+template 
+struct solve_retval;
+
+template 
+struct solve_retval : MatrixBase > {};
+// expected-error@-1 {{partial specialization of 'solve_retval' does not use 
any of its template parameters}}
+
+void ApproximateChebyshev() {
+  MatrixBase c;
+  c = solve_retval();
+  // expected-error@-1 {{no viable overloaded '='}}
+  //   expected-note@#GH89374-copy-assignment {{candidate template ignored: 
could not match 'MatrixBase' against 'solve_retval'}}
+  //   expected-note@#GH89374-MatrixBase {{candidate function (the implicit 
copy assignment operator) not viable: no known conversion from 
'solve_retval' to 'const MatrixBase' for 1st argument}}
+  //   expected-note@#GH89374-MatrixBase {{candidate function (the implicit 
move assignment operator) not viable: no known conversion from 
'solve_retval' to 'MatrixBase' for 1st argument}}
+}
+
+} // namespace GH89374



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


[clang] [clang] Mark ill-formed partial specialization as invalid (PR #89536)

2024-04-24 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)

2024-04-24 Thread Yeting Kuo via cfe-commits

https://github.com/yetingk updated 
https://github.com/llvm/llvm-project/pull/89727

>From a43014cf3daa1b0fd9092bfe41da979205ba64aa Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 23 Apr 2024 02:16:04 -0700
Subject: [PATCH 1/3] [RISCV] Teach .option arch to support experimental
 extensions.

Previously .option arch denied extenions are not belongs to RISC-V features. But
experimental features have experimental- prefix, so .option arch can not
serve for experimental extension.
This patch uses the features of extensions to identify extension
existance.
---
 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 7 ---
 llvm/test/MC/RISCV/option-arch.s   | 9 -
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 3f4a73ad89bf8a..80ff70f1095f4c 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2824,8 +2824,9 @@ bool RISCVAsmParser::parseDirectiveOption() {
 break;
   }
 
-  auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch);
-  if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch ||
+  std::string & = RISCVISAInfo::getTargetFeatureForExtension(Arch);
+  auto Ext = llvm::lower_bound(RISCVFeatureKV, Feature);
+  if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Feature ||
   !RISCVISAInfo::isSupportedExtension(Arch)) {
 if (isDigit(Arch.back()))
   return Error(
@@ -2834,7 +2835,7 @@ bool RISCVAsmParser::parseDirectiveOption() {
 return Error(Loc, "unknown extension feature");
   }
 
-  Args.emplace_back(Type, Ext->Key);
+  Args.emplace_back(Type, Arch.str());
 
   if (Type == RISCVOptionArchArgType::Plus) {
 FeatureBitset OldFeatureBits = STI->getFeatureBits();
diff --git a/llvm/test/MC/RISCV/option-arch.s b/llvm/test/MC/RISCV/option-arch.s
index 6ee133c7159a27..40675f9e4b434b 100644
--- a/llvm/test/MC/RISCV/option-arch.s
+++ b/llvm/test/MC/RISCV/option-arch.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple riscv32 -show-encoding < %s \
 # RUN:   | FileCheck -check-prefixes=CHECK %s
 # RUN: llvm-mc -triple riscv32 -filetype=obj < %s \
-# RUN:   | llvm-objdump  --triple=riscv32 --mattr=+c,+m,+a,+f,+zba -d -M 
no-aliases - \
+# RUN:   | llvm-objdump  --triple=riscv32 
--mattr=+c,+m,+a,+f,+zba,+experimental-zicfiss -d -M no-aliases - \
 # RUN:   | FileCheck -check-prefixes=CHECK-INST %s
 
 # Test '.option arch, +' and '.option arch, -' directive
@@ -78,6 +78,13 @@ lr.w t0, (t1)
 # CHECK: encoding: [0xb3,0x22,0x73,0x20]
 sh1add t0, t1, t2
 
+# Test experimental extension
+# CHECK: .option arch, +zicfiss
+.option arch, +zicfiss
+# CHECK-INST: sspopchk ra
+# CHECK: encoding: [0x73,0xc0,0xc0,0xcd]
+sspopchk ra
+
 # Test '.option arch, ' directive
 # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
 .option arch, rv32i2p1_m2p0_a2p1_c2p0

>From 471abce617a9d18ef91370303eef90bab228d9d3 Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 23 Apr 2024 21:55:12 -0700
Subject: [PATCH 2/3] Make this pr obey menable-experimental-extensions.

---
 clang/lib/Driver/ToolChains/Clang.cpp  | 5 +
 clang/test/Driver/riscv-option-arch.s  | 5 +
 llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 6 ++
 3 files changed, 16 insertions(+)
 create mode 100644 clang/test/Driver/riscv-option-arch.s

diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5894a48e0e378b..8b0f523763486f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -8449,6 +8449,11 @@ void ClangAs::AddRISCVTargetArgs(const ArgList ,
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back("-riscv-add-build-attributes");
   }
+
+  if (!Args.hasArg(options::OPT_menable_experimental_extensions)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-riscv-disable-experimental-ext");
+  }
 }
 
 void ClangAs::ConstructJob(Compilation , const JobAction ,
diff --git a/clang/test/Driver/riscv-option-arch.s 
b/clang/test/Driver/riscv-option-arch.s
new file mode 100644
index 00..8ce84dd8ffe79d
--- /dev/null
+++ b/clang/test/Driver/riscv-option-arch.s
@@ -0,0 +1,5 @@
+# RUN: %clang --target=riscv64 -menable-experimental-extensions -c -o 
/dev/null %s
+# RUN: ! %clang --target=riscv64 -c -o /dev/null %s 2>&1 | FileCheck 
-check-prefixes=CHECK-ERR %s
+
+.option arch, +zicfiss
+# CHECK-ERR: Unexpected experimental extensions.
diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 80ff70f1095f4c..6225e0707015fe 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -51,6 +51,9 @@ STATISTIC(RISCVNumInstrsCompressed,
 
 static cl::opt 

[clang] [llvm] [RISCV] Teach .option arch to support experimental extensions. (PR #89727)

2024-04-24 Thread Yeting Kuo via cfe-commits


@@ -2824,8 +2827,12 @@ bool RISCVAsmParser::parseDirectiveOption() {
 break;
   }
 
-  auto Ext = llvm::lower_bound(RISCVFeatureKV, Arch);
-  if (Ext == std::end(RISCVFeatureKV) || StringRef(Ext->Key) != Arch ||
+  std::string & = RISCVISAInfo::getTargetFeatureForExtension(Arch);

yetingk wrote:

Done.

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


[clang] [clang][RISCV] Remove LMUL=8 scalar input for some vector crypto instructions (PR #89867)

2024-04-24 Thread Craig Topper via cfe-commits

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

LGTM

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


[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)

2024-04-24 Thread Wentao Zhang via cfe-commits

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


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-24 Thread Heejin Ahn via cfe-commits

https://github.com/aheejin updated 
https://github.com/llvm/llvm-project/pull/80923

>From d6fd48794112d6c140024d7cd55b5fe5e55e Mon Sep 17 00:00:00 2001
From: Heejin Ahn 
Date: Tue, 6 Feb 2024 00:31:59 +
Subject: [PATCH 1/5] [WebAssembly] Add more features to generic CPU config

This enables nontrapping-fptoint, multivlaue, reference-types, and
bulk-memory in `-mcpu=generic` configuration. These proposals have been
standardized and supported in all major browsers for several years at
this point: 
https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md
---
 clang/docs/ReleaseNotes.rst|  4 
 clang/lib/Basic/Targets/WebAssembly.cpp| 18 --
 clang/test/Preprocessor/wasm-target-features.c |  8 
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 802c44b6c86080..5a07dcca106876 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -259,6 +259,10 @@ AIX Support
 WebAssembly Support
 ^^^
 
+The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue,
+reference-types, and bulk-memory.These proposals are standardized and available
+in all major engines.
+
 AVR Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index f1c925d90cb649..38fe4013090f40 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -147,19 +147,25 @@ void 
WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap ,
 bool WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) const {
-  if (CPU == "bleeding-edge") {
-Features["nontrapping-fptoint"] = true;
+  auto addGenericFeatures = [&]() {
 Features["sign-ext"] = true;
+Features["mutable-globals"] = true;
+Features["nontrapping-fptoint"] = true;
 Features["bulk-memory"] = true;
+Features["reference-types"] = true;
+Features["multivalue"] = true;
+  };
+  auto addBleedingEdgeFeatures = [&]() {
 Features["atomics"] = true;
-Features["mutable-globals"] = true;
 Features["tail-call"] = true;
-Features["reference-types"] = true;
 Features["multimemory"] = true;
 setSIMDLevel(Features, SIMD128, true);
+  };
+  if (CPU == "bleeding-edge") {
+addGenericFeatures();
+addBleedingEdgeFeatures();
   } else if (CPU == "generic") {
-Features["sign-ext"] = true;
-Features["mutable-globals"] = true;
+addGenericFeatures();
   }
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
diff --git a/clang/test/Preprocessor/wasm-target-features.c 
b/clang/test/Preprocessor/wasm-target-features.c
index eccd432aa8eee6..5834e6d183bc9c 100644
--- a/clang/test/Preprocessor/wasm-target-features.c
+++ b/clang/test/Preprocessor/wasm-target-features.c
@@ -155,15 +155,15 @@
 //
 // GENERIC-DAG:#define __wasm_sign_ext__ 1{{$}}
 // GENERIC-DAG:#define __wasm_mutable_globals__ 1{{$}}
-// GENERIC-NOT:#define __wasm_nontrapping_fptoint__ 1{{$}}
-// GENERIC-NOT:#define __wasm_bulk_memory__ 1{{$}}
+// GENERIC-DAG:#define __wasm_nontrapping_fptoint__ 1{{$}}
+// GENERIC-DAG:#define __wasm_bulk_memory__ 1{{$}}
+// GENERIC-DAG:#define __wasm_multivalue__ 1{{$}}
+// GENERIC-DAG:#define __wasm_reference_types__ 1{{$}}
 // GENERIC-NOT:#define __wasm_simd128__ 1{{$}}
 // GENERIC-NOT:#define __wasm_atomics__ 1{{$}}
 // GENERIC-NOT:#define __wasm_tail_call__ 1{{$}}
 // GENERIC-NOT:#define __wasm_multimemory__ 1{{$}}
 // GENERIC-NOT:#define __wasm_exception_handling__ 1{{$}}
-// GENERIC-NOT:#define __wasm_multivalue__ 1{{$}}
-// GENERIC-NOT:#define __wasm_reference_types__ 1{{$}}
 // GENERIC-NOT:#define __wasm_extended_const__ 1{{$}}
 
 // RUN: %clang -E -dM %s -o - 2>&1 \

>From 01ac8bd38aaa86e62b00709790a36e050528f853 Mon Sep 17 00:00:00 2001
From: Heejin Ahn 
Date: Fri, 23 Feb 2024 00:31:41 +
Subject: [PATCH 2/5] Mention that ABI is not turned on

---
 clang/docs/ReleaseNotes.rst | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5a07dcca106876..ec85d8882c1861 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -261,7 +261,8 @@ WebAssembly Support
 
 The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue,
 reference-types, and bulk-memory.These proposals are standardized and available
-in all major engines.
+in all major engines. Enabling multivalue here only enables the language 
feature
+but does not turn on the multivalue ABI.
 
 AVR Support
 ^^^

>From de6aa6aa0891bb11ae7402d2cbccbcd82cd4fc77 Mon Sep 17 00:00:00 2001
From: Heejin Ahn 
Date: Tue, 23 Apr 2024 13:21:15 +
Subject: [PATCH 3/5] Enable only multivalue and reference types

---
 clang/docs/ReleaseNotes.rst|  8 
 

[clang] [Clang][AArch64] Extend diagnostics when warning non/streaming about … (PR #88380)

2024-04-24 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm approved this pull request.


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


[clang] [llvm] [InstCombine] Swap out range metadata to range attribute for cttz/ctlz/ctpop (PR #88776)

2024-04-24 Thread Nikita Popov via cfe-commits

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

LGTM

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


[clang] [clang-tools-extra] [clangd] Show struct fields and enum members in hovers (PR #89557)

2024-04-24 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> > 3. Regarding the implementation approach, is it fine to add a flag to 
> > `PrintingPolicy` (which is a clang utility class used in a variety of 
> > places) for a clangd-specific use case like this? I did it this way because 
> > the alternative seemed to involve duplicating a bunch of code related to 
> > decl-printing, but I'm happy to explore alternatives if this is an issue.
> 
> I feel like "print only public fields" is too specific for clangd use case, 
> and probably won't generalize to other callers at all. But I definitely agree 
> with all the concerns around duplicating code. Looks like we have some 
> `PrintingCallbacks`, maybe we can have something like `SummarizeTagDecl`, 
> which enables customizing what to put into the body, when printing a TagDecl 
> in terse mode?

Thanks for the suggestion! Using `PrintingCallbacks` here sounds like a 
promising idea.

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


[clang] [MC/DC][Coverage] Workaround for `##` conditions (PR #89573)

2024-04-24 Thread NAKAMURA Takumi via cfe-commits

chapuni wrote:

@whentojump Thanks. Would you like to take this over? Then I will close this.

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


[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)

2024-04-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Wentao Zhang (whentojump)


Changes

The problematic program is as follows:

```shell
#define pre_a 0
#define PRE(x) pre_##x

void f(void) {
PRE(a)  0;
}

int main(void) { return 0; }
```

in which after token concatenation (`##`), there's another nested macro `pre_a`.

Currently only the outer expansion region will be produced. ([compiler explorer 
link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:29,endLineNumber:8,positionColumn:29,positionLineNumber:8,selectionStartColumn:29,selectionStartLineNumber:8,startColumn:29,startLineNumber:8),source:'%23define+pre_a+0%0A%23define+PRE(x)+pre_%23%23x%0A%0Avoid+f(void)+%7B%0APRE(a)+%26%26+0%3B%0A%7D%0A%0Aint+main(void)+%7B+return+0%3B+%7D'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:51.69491525423727,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:cclang_assertions_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:___c,libs:!(),options:'-fprofile-instr-generate+-fcoverage-mapping+-fcoverage-mcdc+-Xclang+-dump-coverage-mapping+',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(assertions+trunk)+(Editor+%231)',t:'0')),k:34.5741843594503,l:'4',m:28.903654485049834,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:2,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(assertions+trunk)+(Compiler+%232)',t:'0')),header:(),l:'4',m:71.09634551495017,n:'0',o:'',s:0,t:'0')),k:48.30508474576271,l:'3',n:'0',o:'',t:'0')),l:'2',m:100,n:'0',o:'',t:'0')),version:4))

```text
f:
  File 0, 4:14 - 6:2 = #0
  Decision,File 0, 5:5 - 5:16 = M:0, C:2
  Expansion,File 0, 5:5 - 5:8 = #0 (Expanded file = 1)
  File 0, 5:15 - 5:16 = #1
  Branch,File 0, 5:15 - 5:16 = 0, 0 [2,0,0] 
  File 1, 2:16 - 2:23 = #0
  File 2, 1:15 - 1:16 = #0
  File 2, 1:15 - 1:16 = #0
  Branch,File 2, 1:15 - 1:16 = 0, 0 [1,2,0] 
```

The inner expansion region isn't produced because:

1. In the range-based for loop quoted below, each sloc is processed and 
possibly emit a corresponding expansion region.
2. For our sloc in question, its direct parent returned by 
`getIncludeOrExpansionLoc()` is a `scratch space`, because that's how 
`##` is processed.


https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/clang/lib/CodeGen/CoverageMappingGen.cpp#L518-L520

3. This `scratch space` cannot be found in the FileID mapping so 
`ParentFileID` will be assigned an `std::nullopt`


https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/clang/lib/CodeGen/CoverageMappingGen.cpp#L521-L526

4. As a result this iteration of for loop finishes early and no expansion 
region is added for the sloc.

This problem gets worse with MC/DC: as the example shows, there's a branch from 
File 2 but File 2 itself is missing. This will trigger assertion failures.

The fix is more or less a workaround and takes a similar approach as #89573.

Depends on #89573.
This and #89573 together fix #87000.

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


4 Files Affected:

- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+29-2) 
- (modified) clang/test/CoverageMapping/builtinmacro.c (+1-1) 
- (modified) clang/test/CoverageMapping/macros.c (+5-3) 
- (added) clang/test/CoverageMapping/mcdc-scratch-space.c (+65) 


``diff
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 733686d4946b3c..9268ac5b4c61a3 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -298,6 +298,22 @@ class CoverageMappingBuilder {
: SM.getIncludeLoc(SM.getFileID(Loc));
   }
 
+  /// Find out where the current file is included or macro is expanded. If the
+  /// found expansion is a , keep looking.
+  SourceLocation getIncludeOrNonScratchExpansionLoc(SourceLocation Loc) {
+if (Loc.isMacroID()) {
+  Loc = SM.getImmediateExpansionRange(Loc).getBegin();
+  while (Loc.isMacroID() &&
+ SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc))) {
+auto ExpansionRange = SM.getImmediateExpansionRange(Loc);
+Loc = ExpansionRange.getBegin();
+  }
+} else {
+  Loc = SM.getIncludeLoc(SM.getFileID(Loc));
+}
+return Loc;
+  }
+
   /// Return true if \c Loc is a location in a built-in macro.
   bool isInBuiltin(SourceLocation Loc) {
 return SM.getBufferName(SM.getSpellingLoc(Loc)) == "";
@@ -339,8 +355,18 @@ class CoverageMappingBuilder {
 
 

[clang] [Coverage][Expansion] handle nested macros in scratch space (PR #89869)

2024-04-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Wentao Zhang (whentojump)


Changes

The problematic program is as follows:

```shell
#define pre_a 0
#define PRE(x) pre_##x

void f(void) {
PRE(a)  0;
}

int main(void) { return 0; }
```

in which after token concatenation (`##`), there's another nested macro `pre_a`.

Currently only the outer expansion region will be produced. ([compiler explorer 
link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:29,endLineNumber:8,positionColumn:29,positionLineNumber:8,selectionStartColumn:29,selectionStartLineNumber:8,startColumn:29,startLineNumber:8),source:'%23define+pre_a+0%0A%23define+PRE(x)+pre_%23%23x%0A%0Avoid+f(void)+%7B%0APRE(a)+%26%26+0%3B%0A%7D%0A%0Aint+main(void)+%7B+return+0%3B+%7D'),l:'5',n:'0',o:'C+source+%231',t:'0')),k:51.69491525423727,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:cclang_assertions_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'0',intel:'0',libraryCode:'1',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:2,lang:___c,libs:!(),options:'-fprofile-instr-generate+-fcoverage-mapping+-fcoverage-mcdc+-Xclang+-dump-coverage-mapping+',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(assertions+trunk)+(Editor+%231)',t:'0')),k:34.5741843594503,l:'4',m:28.903654485049834,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:2,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(assertions+trunk)+(Compiler+%232)',t:'0')),header:(),l:'4',m:71.09634551495017,n:'0',o:'',s:0,t:'0')),k:48.30508474576271,l:'3',n:'0',o:'',t:'0')),l:'2',m:100,n:'0',o:'',t:'0')),version:4))

```text
f:
  File 0, 4:14 - 6:2 = #0
  Decision,File 0, 5:5 - 5:16 = M:0, C:2
  Expansion,File 0, 5:5 - 5:8 = #0 (Expanded file = 1)
  File 0, 5:15 - 5:16 = #1
  Branch,File 0, 5:15 - 5:16 = 0, 0 [2,0,0] 
  File 1, 2:16 - 2:23 = #0
  File 2, 1:15 - 1:16 = #0
  File 2, 1:15 - 1:16 = #0
  Branch,File 2, 1:15 - 1:16 = 0, 0 [1,2,0] 
```

The inner expansion region isn't produced because:

1. In the range-based for loop quoted below, each sloc is processed and 
possibly emit a corresponding expansion region.
2. For our sloc in question, its direct parent returned by 
`getIncludeOrExpansionLoc()` is a `scratch space`, because that's how 
`##` is processed.


https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/clang/lib/CodeGen/CoverageMappingGen.cpp#L518-L520

3. This `scratch space` cannot be found in the FileID mapping so 
`ParentFileID` will be assigned an `std::nullopt`


https://github.com/llvm/llvm-project/blob/88b6186af3908c55b357858eb348b5143f21c289/clang/lib/CodeGen/CoverageMappingGen.cpp#L521-L526

4. As a result this iteration of for loop finishes early and no expansion 
region is added for the sloc.

This problem gets worse with MC/DC: as the example shows, there's a branch from 
File 2 but File 2 itself is missing. This will trigger assertion failures.

The fix is more or less a workaround and takes a similar approach as #89573.

Depends on #89573.
This and #89573 together fix #87000.

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


4 Files Affected:

- (modified) clang/lib/CodeGen/CoverageMappingGen.cpp (+29-2) 
- (modified) clang/test/CoverageMapping/builtinmacro.c (+1-1) 
- (modified) clang/test/CoverageMapping/macros.c (+5-3) 
- (added) clang/test/CoverageMapping/mcdc-scratch-space.c (+65) 


``diff
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 733686d4946b3c..9268ac5b4c61a3 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -298,6 +298,22 @@ class CoverageMappingBuilder {
: SM.getIncludeLoc(SM.getFileID(Loc));
   }
 
+  /// Find out where the current file is included or macro is expanded. If the
+  /// found expansion is a , keep looking.
+  SourceLocation getIncludeOrNonScratchExpansionLoc(SourceLocation Loc) {
+if (Loc.isMacroID()) {
+  Loc = SM.getImmediateExpansionRange(Loc).getBegin();
+  while (Loc.isMacroID() &&
+ SM.isWrittenInScratchSpace(SM.getSpellingLoc(Loc))) {
+auto ExpansionRange = SM.getImmediateExpansionRange(Loc);
+Loc = ExpansionRange.getBegin();
+  }
+} else {
+  Loc = SM.getIncludeLoc(SM.getFileID(Loc));
+}
+return Loc;
+  }
+
   /// Return true if \c Loc is a location in a built-in macro.
   bool isInBuiltin(SourceLocation Loc) {
 return SM.getBufferName(SM.getSpellingLoc(Loc)) == "";
@@ -339,8 +355,18 @@ class CoverageMappingBuilder {
 
 llvm::SmallSet 

[clang] [clang][Sema] Preserve the initializer of invalid VarDecls (PR #88645)

2024-04-24 Thread Nathan Ridge via cfe-commits


@@ -13435,16 +13435,18 @@ void Sema::checkNonTrivialCUnion(QualType QT, 
SourceLocation Loc,
 void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
   // If there is no declaration, there was an error parsing it.  Just ignore
   // the initializer.
-  if (!RealDecl || RealDecl->isInvalidDecl()) {
+  if (!RealDecl) {
 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null(RealDecl));
 return;
   }
 
   if (CXXMethodDecl *Method = dyn_cast(RealDecl)) {

HighCommander4 wrote:

Note, I believe in this formulation it needs to be:

```
if (auto *Method = dyn_cast(RealDecl); Method && 
!Method->isInvalidDecl())
```

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


[clang] [clang][Sema] Preserve the initializer of invalid VarDecls (PR #88645)

2024-04-24 Thread Nathan Ridge via cfe-commits

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


[clang] [clang][Sema] Improve error recovery for id-expressions referencing invalid decls (PR #81662)

2024-04-24 Thread Nathan Ridge via cfe-commits


@@ -3453,6 +3453,10 @@ ExprResult Sema::BuildDeclarationNameExpr(const 
CXXScopeSpec ,
NeedsADL, R.isOverloadedResult(),
R.begin(), R.end());
 
+  if (ULE && R.isSingleResult() && R.getFoundDecl()->isInvalidDecl()) {

HighCommander4 wrote:

Done, thanks

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


[clang] [clang][Sema] Improve error recovery for id-expressions referencing invalid decls (PR #81662)

2024-04-24 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

(OpenMP failure still remains to be fixed.)

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


[clang] [clang-repl] Fix the process return code if diagnostics occurred. (PR #89879)

2024-04-24 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev created 
https://github.com/llvm/llvm-project/pull/89879

Should fix the failure seen in the pre-merge infrastructure of #89804.

>From 066029973ac937f3a810bd4aefaed8c8f6e0af51 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Wed, 24 Apr 2024 06:30:55 +
Subject: [PATCH] [clang-repl] Fix the process return code if diagnostics
 occurred.

---
 clang/test/Interpreter/fail.cpp  | 11 ---
 clang/tools/clang-repl/ClangRepl.cpp | 16 +++-
 2 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/clang/test/Interpreter/fail.cpp b/clang/test/Interpreter/fail.cpp
index 4e301f37548f1f..b9035aca3cb7b1 100644
--- a/clang/test/Interpreter/fail.cpp
+++ b/clang/test/Interpreter/fail.cpp
@@ -1,12 +1,9 @@
-// FIXME: There're some inconsistencies between interactive and non-interactive
-// modes. For example, when clang-repl runs in the interactive mode, issues an
-// error, and then successfully recovers if we decide it's a success then for
-// the non-interactive mode the exit code should be a failure.
-// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
-// RUN: cat %s | not clang-repl | FileCheck %s
-BOOM!
+// RUN: not clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
+BOOM! // expected-error {{intended to fail the -verify test}}
 extern "C" int printf(const char *, ...);
 int i = 42;
 auto r1 = printf("i = %d\n", i);
diff --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index aecf61b97fc719..bdc740c33a8f72 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -215,12 +215,15 @@ int main(int argc, const char **argv) {
   } else
 Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
 
+  bool HasError = false;
+
   for (const std::string  : OptInputs) {
-if (auto Err = Interp->ParseAndExecute(input))
+if (auto Err = Interp->ParseAndExecute(input)) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+  HasError = true;
+}
   }
 
-  bool HasError = false;
 
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
@@ -241,18 +244,13 @@ int main(int argc, const char **argv) {
 break;
   }
   if (Input == R"(%undo)") {
-if (auto Err = Interp->Undo()) {
+if (auto Err = Interp->Undo())
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-  HasError = true;
-}
   } else if (Input.rfind("%lib ", 0) == 0) {
-if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) {
+if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5))
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-  HasError = true;
-}
   } else if (auto Err = Interp->ParseAndExecute(Input)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-HasError = true;
   }
 
   Input = "";

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


[clang] [llvm] [ARM] Armv8-R does not require fp64 or neon. (PR #88287)

2024-04-24 Thread Chris Copeland via cfe-commits

chrisnc wrote:

@davemgreen which change? Specifying `-mcpu=cortex-r52` will behave the same 
way as before. The original manual for the R52 provided for a no-neon sp-only 
variant, and they exist in the wild, and this lets "architecture-generic" 
builds automatically support both.

One example where this comes up is in the Rust project, which recently gained 
armv8r support, but due to the over-spec'ing of the base armv8r in LLVM, it 
requires `-feature` additions in the default target feature list to build the 
`core` crate in a way that will support lesser r52's by default. Then, when 
users specify cortex-r52 as their target cpu, they are still left with the 
`-feature` additions overriding what the r52 should enable by default. 
https://github.com/rust-lang/rust/pull/123159 This change will allow the 
feature flags and target CPUs to interact in a more predictable way as compared 
to other Cortex-R and -M CPUs.

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


[clang] [clang-repl] Fix the process return code if diagnostics occurred. (PR #89879)

2024-04-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vassil Vassilev (vgvassilev)


Changes

Should fix the failure seen in the pre-merge infrastructure of #89804.

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


2 Files Affected:

- (modified) clang/test/Interpreter/fail.cpp (+4-7) 
- (modified) clang/tools/clang-repl/ClangRepl.cpp (+7-9) 


``diff
diff --git a/clang/test/Interpreter/fail.cpp b/clang/test/Interpreter/fail.cpp
index 4e301f37548f1f..b9035aca3cb7b1 100644
--- a/clang/test/Interpreter/fail.cpp
+++ b/clang/test/Interpreter/fail.cpp
@@ -1,12 +1,9 @@
-// FIXME: There're some inconsistencies between interactive and non-interactive
-// modes. For example, when clang-repl runs in the interactive mode, issues an
-// error, and then successfully recovers if we decide it's a success then for
-// the non-interactive mode the exit code should be a failure.
-// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
-// RUN: cat %s | not clang-repl | FileCheck %s
-BOOM!
+// RUN: not clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
+BOOM! // expected-error {{intended to fail the -verify test}}
 extern "C" int printf(const char *, ...);
 int i = 42;
 auto r1 = printf("i = %d\n", i);
diff --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index aecf61b97fc719..bdc740c33a8f72 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -215,12 +215,15 @@ int main(int argc, const char **argv) {
   } else
 Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
 
+  bool HasError = false;
+
   for (const std::string  : OptInputs) {
-if (auto Err = Interp->ParseAndExecute(input))
+if (auto Err = Interp->ParseAndExecute(input)) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+  HasError = true;
+}
   }
 
-  bool HasError = false;
 
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
@@ -241,18 +244,13 @@ int main(int argc, const char **argv) {
 break;
   }
   if (Input == R"(%undo)") {
-if (auto Err = Interp->Undo()) {
+if (auto Err = Interp->Undo())
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-  HasError = true;
-}
   } else if (Input.rfind("%lib ", 0) == 0) {
-if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) {
+if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5))
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-  HasError = true;
-}
   } else if (auto Err = Interp->ParseAndExecute(Input)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-HasError = true;
   }
 
   Input = "";

``




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


[clang] [clang-repl] Fix the process return code if diagnostics occurred. (PR #89879)

2024-04-24 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev updated 
https://github.com/llvm/llvm-project/pull/89879

>From d6b3d2a7b93399f8e895118e9f43378a2efa21f1 Mon Sep 17 00:00:00 2001
From: Vassil Vassilev 
Date: Wed, 24 Apr 2024 06:30:55 +
Subject: [PATCH] [clang-repl] Fix the process return code if diagnostics
 occurred.

---
 clang/test/Interpreter/fail.cpp  | 11 ---
 clang/tools/clang-repl/ClangRepl.cpp | 17 +++--
 2 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/clang/test/Interpreter/fail.cpp b/clang/test/Interpreter/fail.cpp
index 4e301f37548f1f..b9035aca3cb7b1 100644
--- a/clang/test/Interpreter/fail.cpp
+++ b/clang/test/Interpreter/fail.cpp
@@ -1,12 +1,9 @@
-// FIXME: There're some inconsistencies between interactive and non-interactive
-// modes. For example, when clang-repl runs in the interactive mode, issues an
-// error, and then successfully recovers if we decide it's a success then for
-// the non-interactive mode the exit code should be a failure.
-// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
 // REQUIRES: host-supports-jit
 // UNSUPPORTED: system-aix
-// RUN: cat %s | not clang-repl | FileCheck %s
-BOOM!
+// RUN: not clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
+// RUN: cat %s | clang-repl | FileCheck %s
+// RUN: cat %s | not clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
+BOOM! // expected-error {{intended to fail the -verify test}}
 extern "C" int printf(const char *, ...);
 int i = 42;
 auto r1 = printf("i = %d\n", i);
diff --git a/clang/tools/clang-repl/ClangRepl.cpp 
b/clang/tools/clang-repl/ClangRepl.cpp
index aecf61b97fc719..9cfc70462893dd 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -215,13 +215,15 @@ int main(int argc, const char **argv) {
   } else
 Interp = ExitOnErr(clang::Interpreter::create(std::move(CI)));
 
+  bool HasError = false;
+
   for (const std::string  : OptInputs) {
-if (auto Err = Interp->ParseAndExecute(input))
+if (auto Err = Interp->ParseAndExecute(input)) {
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
+  HasError = true;
+}
   }
 
-  bool HasError = false;
-
   if (OptInputs.empty()) {
 llvm::LineEditor LE("clang-repl");
 std::string Input;
@@ -241,18 +243,13 @@ int main(int argc, const char **argv) {
 break;
   }
   if (Input == R"(%undo)") {
-if (auto Err = Interp->Undo()) {
+if (auto Err = Interp->Undo())
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-  HasError = true;
-}
   } else if (Input.rfind("%lib ", 0) == 0) {
-if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5)) {
+if (auto Err = Interp->LoadDynamicLibrary(Input.data() + 5))
   llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-  HasError = true;
-}
   } else if (auto Err = Interp->ParseAndExecute(Input)) {
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
-HasError = true;
   }
 
   Input = "";

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


[clang] [NFC] Move DeclID from serialization/ASTBitCodes.h to AST/DeclID.h (PR #89873)

2024-04-24 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/89873

>From d83b9cda6c7d943e90c324fa2c1c7e7ffaf88e1c Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Wed, 24 Apr 2024 13:35:01 +0800
Subject: [PATCH] [NFC] Move DeclID from serialization/ASTBitCodes.h to
 AST/DeclID.h

Previously, the DeclID is defined in serialization/ASTBitCodes.h under
clang::serialization namespace. However, actually the DeclID is not
purely used in serialization part. The DeclID is already widely used in
AST and all around the clang project via classes like `LazyPtrDecl` or
calling `ExternalASTSource::getExernalDecl()`. All such uses are via the
raw underlying type of `DeclID` as `uint32_t`. This is not pretty good.

This patch moves the DeclID class family to a new header `AST/DeclID.h`
so that the whole project can use the wrapped class `DeclID`,
`GlobalDeclID` and `LocalDeclID` instead of the raw underlying type.
This can improve the readability and the type safety.
---
 clang/include/clang/AST/ASTContext.h  |   4 +-
 clang/include/clang/AST/DeclBase.h|   4 +-
 clang/include/clang/AST/DeclID.h  | 177 ++
 clang/include/clang/AST/DeclTemplate.h|   2 +-
 clang/include/clang/AST/ExternalASTSource.h   |   4 +-
 clang/include/clang/Frontend/ASTUnit.h|   2 +-
 .../clang/Frontend/MultiplexConsumer.h|   2 +-
 .../clang/Sema/MultiplexExternalSemaSource.h  |   2 +-
 .../include/clang/Serialization/ASTBitCodes.h | 161 +---
 .../ASTDeserializationListener.h  |   2 +-
 clang/include/clang/Serialization/ASTReader.h | 126 ++---
 .../clang/Serialization/ASTRecordReader.h |   6 +-
 clang/include/clang/Serialization/ASTWriter.h |  22 +--
 .../include/clang/Serialization/ModuleFile.h  |   8 +-
 clang/lib/AST/ASTContext.cpp  |   3 +-
 clang/lib/AST/Decl.cpp|  46 ++---
 clang/lib/AST/DeclBase.cpp|   4 +-
 clang/lib/AST/DeclCXX.cpp |  63 +++
 clang/lib/AST/DeclFriend.cpp  |   2 +-
 clang/lib/AST/DeclObjC.cpp|  24 +--
 clang/lib/AST/DeclOpenMP.cpp  |  18 +-
 clang/lib/AST/DeclTemplate.cpp|  41 ++--
 clang/lib/AST/ExternalASTSource.cpp   |   2 +-
 clang/lib/Frontend/ASTUnit.cpp|   4 +-
 clang/lib/Frontend/FrontendAction.cpp |   6 +-
 clang/lib/Frontend/MultiplexConsumer.cpp  |   3 +-
 .../lib/Sema/MultiplexExternalSemaSource.cpp  |   2 +-
 clang/lib/Serialization/ASTReader.cpp |  16 +-
 clang/lib/Serialization/ASTReaderDecl.cpp |  18 +-
 clang/lib/Serialization/ASTWriter.cpp |   4 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |   4 +-
 31 files changed, 384 insertions(+), 398 deletions(-)
 create mode 100644 clang/include/clang/AST/DeclID.h

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index d5ed20ff50157d..ecec9bfcf30079 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -455,7 +455,7 @@ class ASTContext : public RefCountedBase {
   /// initialization of another module).
   struct PerModuleInitializers {
 llvm::SmallVector Initializers;
-llvm::SmallVector LazyInitializers;
+llvm::SmallVector LazyInitializers;
 
 void resolve(ASTContext );
   };
@@ -1059,7 +1059,7 @@ class ASTContext : public RefCountedBase {
   /// or an ImportDecl nominating another module that has initializers.
   void addModuleInitializer(Module *M, Decl *Init);
 
-  void addLazyModuleInitializers(Module *M, ArrayRef IDs);
+  void addLazyModuleInitializers(Module *M, ArrayRef IDs);
 
   /// Get the initializations to perform when importing a module, if any.
   ArrayRef getModuleInitializers(Module *M);
diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index d8cafc3d81526e..474e51c1df6d68 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -15,6 +15,7 @@
 
 #include "clang/AST/ASTDumperUtils.h"
 #include "clang/AST/AttrIterator.h"
+#include "clang/AST/DeclID.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/SelectorLocationsKind.h"
 #include "clang/Basic/IdentifierTable.h"
@@ -239,9 +240,6 @@ class alignas(8) Decl {
 ModulePrivate
   };
 
-  /// An ID number that refers to a declaration in an AST file.
-  using DeclID = uint32_t;
-
 protected:
   /// The next declaration within the same lexical
   /// DeclContext. These pointers form the linked list that is
diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h
new file mode 100644
index 00..e2c6dd65e86bc3
--- /dev/null
+++ b/clang/include/clang/AST/DeclID.h
@@ -0,0 +1,177 @@
+//===--- DeclID.h - ID number for deserialized declarations  *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See 

[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)

2024-04-24 Thread Kishan Parmar via cfe-commits

https://github.com/Long5hot updated 
https://github.com/llvm/llvm-project/pull/77732

>From b5746d24130b9595762d85f4da7169d7b7a801f0 Mon Sep 17 00:00:00 2001
From: Kishan Parmar 
Date: Wed, 24 Apr 2024 18:01:23 +0530
Subject: [PATCH] [clang][PowerPC] Add flag to enable compatibility with GNU
 for complex arguments

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

https://godbolt.org/z/1bsW1sKMs

newFlag : -fcomplex-ppc-gnu-abi

GNU uses GPRs for complex parameters and return values storing for 
PowerPC-32bit,
which can be enabled which above flag.
Intent of this patch is to make clang compatible with GNU libraries of complex.

Following up with this patch : https://reviews.llvm.org/D146942
---
 clang/include/clang/Basic/CodeGenOptions.def  |   2 +
 clang/include/clang/Basic/CodeGenOptions.h|   6 +
 clang/include/clang/Driver/Options.td |   4 +
 clang/lib/CodeGen/Targets/PPC.cpp |  87 +++-
 clang/lib/Driver/ToolChains/Clang.cpp |   9 +
 clang/lib/Frontend/CompilerInvocation.cpp |   8 +
 .../CodeGen/PowerPC/ppc32-complex-gnu-abi.c   | 415 ++
 .../ppc32-complex-soft-float-gnu-abi.c| 310 +
 .../test/Driver/ppc32-fcomplex-ppc-gnu-abi.c  |  15 +
 9 files changed, 850 insertions(+), 6 deletions(-)
 create mode 100644 clang/test/CodeGen/PowerPC/ppc32-complex-gnu-abi.c
 create mode 100644 
clang/test/CodeGen/PowerPC/ppc32-complex-soft-float-gnu-abi.c
 create mode 100644 clang/test/Driver/ppc32-fcomplex-ppc-gnu-abi.c

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 340b08dd7e2a33..f4845e9e424c67 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -225,6 +225,8 @@ CODEGENOPT(MCDCCoverage , 1, 0) ///< Enable MC/DC code 
coverage criteria.
 
   /// If -fpcc-struct-return or -freg-struct-return is specified.
 ENUM_CODEGENOPT(StructReturnConvention, StructReturnConventionKind, 2, 
SRCK_Default)
+  /// If -fcomplex-ppc-gnu-abi is specified on ppc32.
+ENUM_CODEGENOPT(ComplexInRegABI, ComplexArgumentConventionKind, 2, 
CMPLX_OnStack)
 
 CODEGENOPT(RelaxAll  , 1, 0) ///< Relax all machine code instructions.
 CODEGENOPT(RelaxedAliasing   , 1, 0) ///< Set when -fno-strict-aliasing is 
enabled.
diff --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 9469a424045bb0..1c9424f65623dd 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -78,6 +78,12 @@ class CodeGenOptions : public CodeGenOptionsBase {
 SRCK_InRegs// Small structs in registers (-freg-struct-return).
   };
 
+  enum ComplexArgumentConventionKind {
+CMPLX_OnStack,
+CMPLX_InGPR, // If -fcomplex-ppc-gnu-abi is specified on ppc32
+CMPLX_InFPR
+  };
+
   enum ProfileInstrKind {
 ProfileNone,   // Profile instrumentation is turned off.
 ProfileClangInstr, // Clang instrumentation to generate execution counts
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 922bda721dc780..605440ed1c596d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2601,6 +2601,10 @@ def ffp_contract : Joined<["-"], "ffp-contract=">, 
Group,
   HelpText<"Form fused FP ops (e.g. FMAs)">,
   Values<"fast,on,off,fast-honor-pragmas">;
 
+def fcomplex_ppc_gnu_abi : Flag<["-"], "fcomplex-ppc-gnu-abi">, 
Group, Visibility<[ClangOption, CC1Option]>,
+  DocBrief<"Follow the GNU ABI, pass Complex values in GPRs instead of the 
stack for PowerPC-32">,
+  HelpText<"Pass Complex values in GPR instead of stack for PowerPC-32">;
+
 defm strict_float_cast_overflow : BoolFOption<"strict-float-cast-overflow",
   CodeGenOpts<"StrictFloatCastOverflow">, DefaultTrue,
   NegFlaghttps://reviews.llvm.org/D146942 and the related LLVM pull
+  // request: #77732
+
+  if (TypeSize == 64) {
+ElemTy = llvm::Type::getInt64Ty(getVMContext());
+RegsNeeded = 1;
+  } else {
+ElemTy = llvm::Type::getInt32Ty(getVMContext());
+RegsNeeded = TypeSize >> 5;
+  }
+  return ABIArgInfo::getDirect(llvm::ArrayType::get(ElemTy, RegsNeeded));
+}
+
+ABIArgInfo PPC32_SVR4_ABIInfo::classifyArgumentType(QualType Ty,
+int ) const {
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+
+  if ((getCodeGenOpts().getComplexInRegABI() != CodeGenOptions::CMPLX_InGPR) ||
+  !ArgGPRsLeft ||
+  (!Ty->isAnyComplexType() && Ty->isFloatingType() && !IsSoftFloatABI))
+return DefaultABIInfo::classifyArgumentType(Ty);
+
+  assert(ArgGPRsLeft >= 0 && "Arg GPR must be large or equal than zero");
+  ASTContext  = getContext();
+  uint64_t TypeSize = Context.getTypeSize(Ty);
+
+  // For complex type or any other primitive types.
+  if (bool IsComplex = Ty->isAnyComplexType() || !isAggregateTypeForABI(Ty)) {
+// If gr is even set gr = gr + 1 for 

[clang] 2bcbe40 - [clang][ExtractAPI] Fix handling of anonymous TagDecls (#87772)

2024-04-24 Thread via cfe-commits

Author: Daniel Grumberg
Date: 2024-04-24T13:53:29+01:00
New Revision: 2bcbe40f8a1c6cc9a256711261d8aa8fde50f7b3

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

LOG: [clang][ExtractAPI] Fix handling of anonymous TagDecls (#87772)

This changes the handling of anonymous TagDecls to the following rules:
- If the TagDecl is embedded in the declaration for some VarDecl (this
is the only possibility for RecordDecls), then pretend the child decls
belong to the VarDecl
- If it's an EnumDecl proceed as we did previously, i.e., embed it in
the enclosing DeclContext.

Additionally this fixes a few issues with declaration fragments not
consistently including "{ ... }" for anonymous TagDecls. To make testing
these additions easier this patch fixes some text declaration fragments
merging issues and updates tests accordingly.

rdar://121436298

Added: 


Modified: 
clang/include/clang/ExtractAPI/API.h
clang/include/clang/ExtractAPI/APIRecords.inc
clang/include/clang/ExtractAPI/DeclarationFragments.h
clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
clang/lib/ExtractAPI/API.cpp
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
clang/test/ExtractAPI/anonymous_record_no_typedef.c
clang/test/ExtractAPI/enum.c
clang/test/ExtractAPI/function_noexcepts.cpp
clang/test/ExtractAPI/methods.cpp
clang/test/ExtractAPI/objc_block.m
clang/test/ExtractAPI/typedef_anonymous_record.c
clang/test/ExtractAPI/typedef_struct_enum.c

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index 92cacf65c7d64e..d323e1668a72b1 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -208,20 +208,20 @@ struct APIRecord {
 RK_ClassTemplate,
 RK_ClassTemplateSpecialization,
 RK_ClassTemplatePartialSpecialization,
-RK_LastRecordContext,
-RK_GlobalFunction,
-RK_GlobalFunctionTemplate,
-RK_GlobalFunctionTemplateSpecialization,
+RK_StructField,
+RK_UnionField,
+RK_CXXField,
+RK_StaticField,
+RK_CXXFieldTemplate,
 RK_GlobalVariable,
 RK_GlobalVariableTemplate,
 RK_GlobalVariableTemplateSpecialization,
 RK_GlobalVariableTemplatePartialSpecialization,
+RK_LastRecordContext,
+RK_GlobalFunction,
+RK_GlobalFunctionTemplate,
+RK_GlobalFunctionTemplateSpecialization,
 RK_EnumConstant,
-RK_StructField,
-RK_UnionField,
-RK_StaticField,
-RK_CXXField,
-RK_CXXFieldTemplate,
 RK_Concept,
 RK_CXXStaticMethod,
 RK_CXXInstanceMethod,
@@ -321,6 +321,10 @@ class RecordContext {
 
   RecordContext(APIRecord::RecordKind Kind) : Kind(Kind) {}
 
+  /// Append \p Other children chain into ours and empty out Other's record
+  /// chain.
+  void stealRecordChain(RecordContext );
+
   APIRecord::RecordKind getKind() const { return Kind; }
 
   struct record_iterator {
@@ -370,6 +374,7 @@ class RecordContext {
   APIRecord::RecordKind Kind;
   mutable APIRecord *First = nullptr;
   mutable APIRecord *Last = nullptr;
+  bool IsWellFormed() const;
 
 protected:
   friend class APISet;
@@ -475,7 +480,7 @@ struct GlobalFunctionTemplateSpecializationRecord : 
GlobalFunctionRecord {
 };
 
 /// This holds information associated with global functions.
-struct GlobalVariableRecord : APIRecord {
+struct GlobalVariableRecord : APIRecord, RecordContext {
   GlobalVariableRecord(StringRef USR, StringRef Name, SymbolReference Parent,
PresumedLoc Loc, AvailabilityInfo Availability,
LinkageInfo Linkage, const DocComment ,
@@ -483,23 +488,28 @@ struct GlobalVariableRecord : APIRecord {
DeclarationFragments SubHeading, bool 
IsFromSystemHeader)
   : APIRecord(RK_GlobalVariable, USR, Name, Parent, Loc,
   std::move(Availability), Linkage, Comment, Declaration,
-  SubHeading, IsFromSystemHeader) {}
+  SubHeading, IsFromSystemHeader),
+RecordContext(RK_GlobalVariable) {}
 
   GlobalVariableRecord(RecordKind Kind, StringRef USR, StringRef Name,
-   SymbolReference Parent,
-
-   PresumedLoc Loc, AvailabilityInfo Availability,
-   LinkageInfo Linkage, const DocComment ,
+   SymbolReference Parent, PresumedLoc Loc,
+   AvailabilityInfo Availability, LinkageInfo Linkage,
+   const DocComment ,
DeclarationFragments Declaration,
DeclarationFragments SubHeading, bool 
IsFromSystemHeader)
   : APIRecord(Kind, USR, Name, Parent, Loc, std::move(Availability),
  

[clang] [clang][ExtractAPI] Fix handling of anonymous TagDecls (PR #87772)

2024-04-24 Thread Daniel Grumberg via cfe-commits

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


[clang] [CMake][Release] Add stage2-package target (PR #89517)

2024-04-24 Thread Tobias Hieta via cfe-commits

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


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


[clang] [Driver] Restore compiler-rt arch suffix for PS and Windows (PR #89775)

2024-04-24 Thread Tobias Hieta via cfe-commits

tru wrote:

And I think it's better to revert it all instead of implementing this 
half-revert in this PR in that case and then we should discuss how to move 
forward.

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


[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-24 Thread David Truby via cfe-commits

https://github.com/DavidTruby updated 
https://github.com/llvm/llvm-project/pull/89938

>From 88db34e906f6eb104f8d84fa9ad4f0aa49607c68 Mon Sep 17 00:00:00 2001
From: David Truby 
Date: Wed, 24 Apr 2024 14:35:23 +
Subject: [PATCH 1/2] [flang] Generate main only when a Fortran program
 statement is present

This patch changes the behaviour for flang to only create and link to a
`main` entry point when the Fortran code has a program statement in it.

This means that flang-new can be used to link even when the program is
a mixed C/Fortran code with `main` present in C and no entry point
present in Fortran.
---
 clang/include/clang/Driver/Options.td |   6 -
 clang/lib/Driver/ToolChains/CommonArgs.cpp| 110 +-
 clang/lib/Driver/ToolChains/Flang.cpp |   9 --
 flang/docs/FlangDriver.md |  32 +
 .../Builder/Runtime/EnvironmentDefaults.h |   3 +-
 .../flang/Optimizer/Builder/Runtime/Main.h|  28 +
 flang/lib/Lower/Bridge.cpp|   5 +-
 flang/lib/Optimizer/Builder/CMakeLists.txt|   1 +
 .../Builder/Runtime/EnvironmentDefaults.cpp   |   7 +-
 flang/lib/Optimizer/Builder/Runtime/Main.cpp  |  62 ++
 flang/runtime/CMakeLists.txt  |   1 -
 flang/runtime/FortranMain/CMakeLists.txt  |  23 
 flang/runtime/FortranMain/Fortran_main.c  |  23 
 flang/test/CMakeLists.txt |   1 -
 flang/test/Driver/driver-help-hidden.f90  |   1 -
 flang/test/Driver/driver-help.f90 |   1 -
 flang/test/Driver/dynamic-linker.f90  |   2 -
 flang/test/Driver/emit-mlir.f90   |  10 ++
 flang/test/Driver/linker-flags.f90|   8 --
 .../test/Driver/msvc-dependent-lib-flags.f90  |   4 -
 flang/test/Driver/no-duplicate-main.f90   |   2 -
 flang/tools/flang-driver/CMakeLists.txt   |   1 -
 lld/COFF/MinGW.cpp|   1 -
 23 files changed, 114 insertions(+), 227 deletions(-)
 create mode 100644 flang/include/flang/Optimizer/Builder/Runtime/Main.h
 create mode 100644 flang/lib/Optimizer/Builder/Runtime/Main.cpp
 delete mode 100644 flang/runtime/FortranMain/CMakeLists.txt
 delete mode 100644 flang/runtime/FortranMain/Fortran_main.c

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 922bda721dc780..4b852b297a6b99 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6582,12 +6582,6 @@ def J : JoinedOrSeparate<["-"], "J">,
   Group,
   Alias;
 
-let Visibility = [FlangOption] in {
-def no_fortran_main : Flag<["-"], "fno-fortran-main">,
-  Visibility<[FlangOption]>, Group,
-  HelpText<"Do not include Fortran_main.a (provided by Flang) when linking">;
-} // let Visibility = [ FlangOption ]
-
 
//===--===//
 // FC1 Options
 
//===--===//
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b65b96db16bd79..fec11c7e716fdf 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1191,118 +1191,10 @@ bool tools::addOpenMPRuntime(const Compilation , 
ArgStringList ,
   return true;
 }
 
-/// Determines if --whole-archive is active in the list of arguments.
-static bool isWholeArchivePresent(const ArgList ) {
-  bool WholeArchiveActive = false;
-  for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA)) {
-if (Arg) {
-  for (StringRef ArgValue : Arg->getValues()) {
-if (ArgValue == "--whole-archive")
-  WholeArchiveActive = true;
-if (ArgValue == "--no-whole-archive")
-  WholeArchiveActive = false;
-  }
-}
-  }
-
-  return WholeArchiveActive;
-}
-
-/// Determine if driver is invoked to create a shared object library (-static)
-static bool isSharedLinkage(const ArgList ) {
-  return Args.hasArg(options::OPT_shared);
-}
-
-/// Determine if driver is invoked to create a static object library (-shared)
-static bool isStaticLinkage(const ArgList ) {
-  return Args.hasArg(options::OPT_static);
-}
-
-/// Add Fortran runtime libs for MSVC
-static void addFortranRuntimeLibsMSVC(const ArgList ,
-  llvm::opt::ArgStringList ) {
-  unsigned RTOptionID = options::OPT__SLASH_MT;
-  if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
-RTOptionID = llvm::StringSwitch(rtl->getValue())
- .Case("static", options::OPT__SLASH_MT)
- .Case("static_dbg", options::OPT__SLASH_MTd)
- .Case("dll", options::OPT__SLASH_MD)
- .Case("dll_dbg", options::OPT__SLASH_MDd)
- .Default(options::OPT__SLASH_MT);
-  }
-  switch (RTOptionID) {
-  case options::OPT__SLASH_MT:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static.lib");
-break;
-  case 

[clang] [clang][Lex] Reformat suspicious condition (PR #89923)

2024-04-24 Thread Troy Butler via cfe-commits

https://github.com/Troy-Butler created 
https://github.com/llvm/llvm-project/pull/89923

Addresses issue #89805.

Assignment + comparison performed in conditional statement. Resolved by 
parenthesizing comparison operation.

>From cde48906d4b9a08dc436ab94f183c124ee336e5a Mon Sep 17 00:00:00 2001
From: Troy-Butler 
Date: Wed, 24 Apr 2024 09:23:29 -0400
Subject: [PATCH] [clang][Lex] Reformat suspicious condition

Signed-off-by: Troy-Butler 
---
 clang/lib/Lex/Pragma.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index 499813f8ab7df0..ced407355e0015 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -1444,7 +1444,7 @@ struct PragmaWarningHandler : public PragmaHandler {
  .Case("once", PPCallbacks::PWS_Once)
  .Case("suppress", PPCallbacks::PWS_Suppress)
  .Default(-1);
-  if ((SpecifierValid = SpecifierInt != -1))
+  if (SpecifierValid = (SpecifierInt != -1))
 Specifier =
 static_cast(SpecifierInt);
 

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


[clang] [clang][Lex] Reformat suspicious condition (PR #89923)

2024-04-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Troy Butler (Troy-Butler)


Changes

Addresses issue #89805.

Assignment + comparison performed in conditional statement. Resolved by 
parenthesizing comparison operation.

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


1 Files Affected:

- (modified) clang/lib/Lex/Pragma.cpp (+1-1) 


``diff
diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp
index 499813f8ab7df0..ced407355e0015 100644
--- a/clang/lib/Lex/Pragma.cpp
+++ b/clang/lib/Lex/Pragma.cpp
@@ -1444,7 +1444,7 @@ struct PragmaWarningHandler : public PragmaHandler {
  .Case("once", PPCallbacks::PWS_Once)
  .Case("suppress", PPCallbacks::PWS_Suppress)
  .Default(-1);
-  if ((SpecifierValid = SpecifierInt != -1))
+  if (SpecifierValid = (SpecifierInt != -1))
 Specifier =
 static_cast(SpecifierInt);
 

``




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


[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-24 Thread via cfe-commits

github-actions[bot] wrote:



:white_check_mark: With the latest revision this PR passed the C/C++ code 
formatter.

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


[clang] 62549db - [AMDGPU] Correctly determine the toolchain linker (#89803)

2024-04-24 Thread via cfe-commits

Author: Joseph Huber
Date: 2024-04-24T06:46:31-05:00
New Revision: 62549dbbf286823e400e07cff5ae219e48c175d2

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

LOG: [AMDGPU] Correctly determine the toolchain linker (#89803)

Summary:
The AMDGPU toolchain simply took the short name to get the link job
instead of using the common utilities that respect options like
`-fuse-ld`. Any linker that isn't `ld.lld` will fail, however we should
be able to override it.

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/test/Driver/amdgpu-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index 4e6362a0f40632..07965b487ea79b 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -617,8 +617,7 @@ void amdgpu::Linker::ConstructJob(Compilation , const 
JobAction ,
   const InputInfoList ,
   const ArgList ,
   const char *LinkingOutput) const {
-
-  std::string Linker = getToolChain().GetProgramPath(getShortName());
+  std::string Linker = getToolChain().GetLinkerPath();
   ArgStringList CmdArgs;
   CmdArgs.push_back("--no-undefined");
   CmdArgs.push_back("-shared");

diff  --git a/clang/test/Driver/amdgpu-toolchain.c 
b/clang/test/Driver/amdgpu-toolchain.c
index 4300e7e9f66705..d21ce857f3c57a 100644
--- a/clang/test/Driver/amdgpu-toolchain.c
+++ b/clang/test/Driver/amdgpu-toolchain.c
@@ -24,3 +24,9 @@
 // RUN:   -L. -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=MCPU %s
 // LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
 // MCPU: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906"
+
+// We do not suppor the BFD linker, but we should be able to override the
+// default even if it will error during linking.
+// RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
+// RUN:   -fuse-ld=bfd %s 2>&1 | FileCheck -check-prefixes=LD %s
+// LD: ld.bfd"



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


[clang] [AMDGPU] Correctly determine the toolchain linker (PR #89803)

2024-04-24 Thread Joseph Huber via cfe-commits

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


[clang] [NFC][analyzer] Initialize pointer field in StreamOperationEvaluator (PR #89837)

2024-04-24 Thread Balázs Kéri via cfe-commits

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

Probably add [clang] tag to the title.

https://github.com/llvm/llvm-project/pull/89837
___
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 new check bugprone-tagged-union-member-count (PR #89925)

2024-04-24 Thread via cfe-commits

https://github.com/tigbr created https://github.com/llvm/llvm-project/pull/89925

This patch introduces a new check to find mismatches between the number of data 
members in a union and the number enum values present in variant-like 
structures.

Variant-like types can look something like this:

```c++
struct variant {
enum {
tag1,
tag2,
} kind;
union {
int i;
char c;
  } data;
};
```

The kind data member of the variant is supposed to tell which data member of 
the union is valid, however if there are fewer enum values than union members, 
then it is likely a mistake.

The opposite is not that obvious, because it might be fine to have more enum 
values than union data members, but for the time being I am curious how many 
real bugs can be caught if we give a warning regardless.

This patch also contains a heuristic where we try to guess whether the last 
enum constant is actually supposed to be a tag value for the variant or whether 
it is just holding how many enum constants have been created.

I am still collecting data on how many bugs this check can catch on open source 
software and I will update the pull-request with the results.

>From 0dff511a0f63480dea527b6e823dcf230755f312 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20T=C3=B3thv=C3=A1ri?= 
Date: Sun, 3 Mar 2024 22:30:32 +0100
Subject: [PATCH] [clang-tidy] Add new check bugprone-tagged-union-member-count

This patch introduces a new check to find mismatches between the number
of data members in a union and the number enum values present in
variant-like structures.

Variant-like types can look something like this:

```c++
struct variant {
enum {
tag1,
tag2,
} kind;
union {
int i;
char c;
  } data;
};
```

The kind data member of the variant is supposed to tell which data
member of the union is valid, however if there are fewer enum values
than union members, then it is likely a mistake.

The opposite is not that obvious, because it might be fine to have more
enum values than union data members, but for the time being I am curious
how many real bugs can be caught if we give a warning regardless.

This patch also contains a heuristic where we try to guess whether the
last enum constant is actually supposed to be a tag value for the
variant or whether it is just holding how many enum constants have been
created.

I am still collecting data on how many bugs this check can catch on open
source software and I will update the pull-request with the results.
---
 .../bugprone/BugproneTidyModule.cpp   |   3 +
 .../clang-tidy/bugprone/CMakeLists.txt|   1 +
 .../bugprone/TaggedUnionMemberCountCheck.cpp  | 125 
 .../bugprone/TaggedUnionMemberCountCheck.h|  31 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../bugprone/tagged-union-member-count.rst|  66 +++
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../bugprone/tagged-union-member-count.cpp| 181 ++
 8 files changed, 414 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 2931325d8b5798..d9e094e11bdf09 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -76,6 +76,7 @@
 #include "SuspiciousStringviewDataUsageCheck.h"
 #include "SwappedArgumentsCheck.h"
 #include "SwitchMissingDefaultCaseCheck.h"
+#include "TaggedUnionMemberCountCheck.h"
 #include "TerminatingContinueCheck.h"
 #include "ThrowKeywordMissingCheck.h"
 #include "TooSmallLoopVariableCheck.h"
@@ -223,6 +224,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-suspicious-stringview-data-usage");
 CheckFactories.registerCheck(
 "bugprone-swapped-arguments");
+CheckFactories.registerCheck(
+"bugprone-tagged-union-member-count");
 CheckFactories.registerCheck(
 "bugprone-terminating-continue");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 081ba67efe1538..5e7fa08aece02e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -71,6 +71,7 @@ add_clang_library(clangTidyBugproneModule
   SuspiciousSemicolonCheck.cpp
   SuspiciousStringCompareCheck.cpp
   SwappedArgumentsCheck.cpp
+  TaggedUnionMemberCountCheck.cpp
   TerminatingContinueCheck.cpp
   

[clang-tools-extra] [clang-tidy] Add new check bugprone-tagged-union-member-count (PR #89925)

2024-04-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: None (tigbr)


Changes

This patch introduces a new check to find mismatches between the number of data 
members in a union and the number enum values present in variant-like 
structures.

Variant-like types can look something like this:

```c++
struct variant {
enum {
tag1,
tag2,
} kind;
union {
int i;
char c;
  } data;
};
```

The kind data member of the variant is supposed to tell which data member of 
the union is valid, however if there are fewer enum values than union members, 
then it is likely a mistake.

The opposite is not that obvious, because it might be fine to have more enum 
values than union data members, but for the time being I am curious how many 
real bugs can be caught if we give a warning regardless.

This patch also contains a heuristic where we try to guess whether the last 
enum constant is actually supposed to be a tag value for the variant or whether 
it is just holding how many enum constants have been created.

I am still collecting data on how many bugs this check can catch on open source 
software and I will update the pull-request with the results.

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


8 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp (+3) 
- (modified) clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt (+1) 
- (added) clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp 
(+125) 
- (added) clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.h 
(+31) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+6) 
- (added) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/tagged-union-member-count.rst 
(+66) 
- (modified) clang-tools-extra/docs/clang-tidy/checks/list.rst (+1) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/tagged-union-member-count.cpp
 (+181) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 2931325d8b5798..d9e094e11bdf09 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -76,6 +76,7 @@
 #include "SuspiciousStringviewDataUsageCheck.h"
 #include "SwappedArgumentsCheck.h"
 #include "SwitchMissingDefaultCaseCheck.h"
+#include "TaggedUnionMemberCountCheck.h"
 #include "TerminatingContinueCheck.h"
 #include "ThrowKeywordMissingCheck.h"
 #include "TooSmallLoopVariableCheck.h"
@@ -223,6 +224,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-suspicious-stringview-data-usage");
 CheckFactories.registerCheck(
 "bugprone-swapped-arguments");
+CheckFactories.registerCheck(
+"bugprone-tagged-union-member-count");
 CheckFactories.registerCheck(
 "bugprone-terminating-continue");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 081ba67efe1538..5e7fa08aece02e 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -71,6 +71,7 @@ add_clang_library(clangTidyBugproneModule
   SuspiciousSemicolonCheck.cpp
   SuspiciousStringCompareCheck.cpp
   SwappedArgumentsCheck.cpp
+  TaggedUnionMemberCountCheck.cpp
   TerminatingContinueCheck.cpp
   ThrowKeywordMissingCheck.cpp
   TooSmallLoopVariableCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
new file mode 100644
index 00..6a7b5a92902c86
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
@@ -0,0 +1,125 @@
+//===--- TaggedUnionMemberCountCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TaggedUnionMemberCountCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+#include "clang/AST/PrettyPrinter.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Casting.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void TaggedUnionMemberCountCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  recordDecl(
+  allOf(isStruct(),
+has(fieldDecl(hasType(recordDecl(isUnion()).bind("union",
+has(fieldDecl(hasType(enumDecl().bind("tags"))
+  .bind("root"),
+  this);
+}
+
+static bool hasMultipleUnionsOrEnums(const 

[clang] [CMake] Change GCC_INSTALL_PREFIX from warning to fatal error (PR #85891)

2024-04-24 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> I disagree, `--gcc-install-dir` is sure an improvement over 
> `--gcc-toolchain`, but they're both weaker than the compile time option 
> `GCC_INSTALL_PREFIX` because of runtimes.
> 
> You're looking to remove `GCC_INSTALL_PREFIX`, then give a clear alternative 
> that's equivalent. The current error message about config files is misleading 
> since it potentially runtimes will use an undesired gcc version when they're 
> built, which is rather opaque.
> 
> A different point: `flang-new` does not accept `--gcc-install-dir`. Is that 
> an oversight?

Should've been added in https://github.com/llvm/llvm-project/pull/87360. I 
agree overall that this change made made runtime builds unnecessarily complex.

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


[clang] [clang-tools-extra] Add ``ignoringParenImpCasts`` in arguments of hasArgument (PR #89553)

2024-04-24 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 21ef187654c819fd097171afcc6c9855dccdb36d 
82bf13532bb3980fbe55c56c2977c5dcbb654c80 -- 
clang-tools-extra/clang-tidy/abseil/RedundantStrcatCallsCheck.cpp 
clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp 
clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp 
clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp 
clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp 
clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp 
clang-tools-extra/clang-tidy/bugprone/UndefinedMemoryManipulationCheck.cpp 
clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp 
clang-tools-extra/clang-tidy/cert/CommandProcessorCheck.cpp 
clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
 
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
 clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp 
clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp 
clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
clang/include/clang/ASTMatchers/ASTMatchers.h
``





View the diff from clang-format here.


``diff
diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index 2a9726f32f..e348fe8f13 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -87,10 +87,12 @@ void 
MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
   cxxConstructExpr(
   hasType(getSmartPointerTypeMatcher()), argumentCountIs(1),
   hasArgument(
-  0, 
ignoringParenImpCasts(cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
-equalsBoundNode(PointerType),
-CanCallCtor, unless(IsPlacement)))
- .bind(NewExpression)),
+  0,
+  ignoringParenImpCasts(
+  
cxxNewExpr(hasType(pointsTo(qualType(hasCanonicalType(
+ equalsBoundNode(PointerType),
+ CanCallCtor, unless(IsPlacement)))
+  .bind(NewExpression)),
   unless(isInTemplateInstantiation()))
   .bind(ConstructorCall),
   this);

``




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


[clang] [Clang][Sema] Revisit the fix for the lambda within a type alias template decl (PR #89934)

2024-04-24 Thread Younan Zhang via cfe-commits

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

Previously commited as https://github.com/llvm/llvm-project/issues/82310.

In the last patch, we used template depths to tell if such alias decls contain 
lambdas, which is wrong because the lambda can also appear as a part of the 
default argument, and that would make `getTemplateInstantiationArgs` provide 
extra template arguments in undesired contexts. This leads to issue #89853.

Moreover, our approach for https://github.com/llvm/llvm-project/issues/82104 
was sadly wrong. We tried to teach DeduceReturnType to consider alias template 
arguments. Still, giving these arguments in the context where they should have 
been substituted in a TransformCallExpr call is never correct.

This patch addresses such problems by using a `RecursiveASTVisitor` to check if 
the lambda is contained by an alias `Decl`, as well as twiddling the lambda 
dependencies - we should also build a dependent lambda expression if the 
surrounding alias template arguments were dependent.

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

>From 670c4a42234da65f082e9828f4c8125d3527093c Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Wed, 24 Apr 2024 20:54:58 +0800
Subject: [PATCH] [Clang][Sema] Rehash the lambda within a type alias template
 decl

Fixes https://github.com/llvm/llvm-project/issues/89853
---
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 66 +--
 .../alias-template-with-lambdas.cpp   | 25 ++-
 2 files changed, 56 insertions(+), 35 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 98d5c7cb3a8a80..c9aa0525d3875c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -20,6 +20,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprConcepts.h"
 #include "clang/AST/PrettyDeclStackTrace.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
 #include "clang/AST/TypeVisitor.h"
@@ -87,12 +88,17 @@ struct Response {
 // than lambda classes.
 const FunctionDecl *
 getPrimaryTemplateOfGenericLambda(const FunctionDecl *LambdaCallOperator) {
+  if (!isLambdaCallOperator(LambdaCallOperator))
+return LambdaCallOperator;
   while (true) {
 if (auto *FTD = dyn_cast_if_present(
 LambdaCallOperator->getDescribedTemplate());
 FTD && FTD->getInstantiatedFromMemberTemplate()) {
   LambdaCallOperator =
   FTD->getInstantiatedFromMemberTemplate()->getTemplatedDecl();
+} else if (LambdaCallOperator->getPrimaryTemplate()) {
+  LambdaCallOperator =
+  LambdaCallOperator->getPrimaryTemplate()->getTemplatedDecl();
 } else if (auto *Prev = cast(LambdaCallOperator)
 ->getInstantiatedFromMemberFunction())
   LambdaCallOperator = Prev;
@@ -138,22 +144,26 @@ getEnclosingTypeAliasTemplateDecl(Sema ) {
 // Check if we are currently inside of a lambda expression that is
 // surrounded by a using alias declaration. e.g.
 //   template  using type = decltype([](auto) { ^ }());
-// By checking if:
-//  1. The lambda expression and the using alias declaration share the
-//  same declaration context.
-//  2. They have the same template depth.
 // We have to do so since a TypeAliasTemplateDecl (or a TypeAliasDecl) is never
 // a DeclContext, nor does it have an associated specialization Decl from which
 // we could collect these template arguments.
 bool isLambdaEnclosedByTypeAliasDecl(
-const FunctionDecl *PrimaryLambdaCallOperator,
+const FunctionDecl *LambdaCallOperator,
 const TypeAliasTemplateDecl *PrimaryTypeAliasDecl) {
-  return cast(PrimaryLambdaCallOperator->getDeclContext())
- ->getTemplateDepth() ==
- PrimaryTypeAliasDecl->getTemplateDepth() &&
- getLambdaAwareParentOfDeclContext(
- const_cast(PrimaryLambdaCallOperator)) ==
- PrimaryTypeAliasDecl->getDeclContext();
+  struct Visitor : RecursiveASTVisitor {
+Visitor(const FunctionDecl *CallOperator) : CallOperator(CallOperator) {}
+bool VisitLambdaExpr(const LambdaExpr *LE) {
+  auto *G = getPrimaryTemplateOfGenericLambda(LE->getCallOperator());
+  return G != CallOperator;
+}
+const FunctionDecl *CallOperator;
+  };
+  QualType Underlying =
+  PrimaryTypeAliasDecl->getTemplatedDecl()->getUnderlyingType();
+  if (auto *DT = dyn_cast(Underlying.getTypePtr()))
+return !Visitor(getPrimaryTemplateOfGenericLambda(LambdaCallOperator))
+.TraverseStmt(DT->getUnderlyingExpr());
+  return false;
 }
 
 // Add template arguments from a variable template instantiation.
@@ -283,23 +293,8 @@ Response HandleFunction(Sema , const FunctionDecl 
*Function,
 
 // If this function is a generic lambda specialization, we are done.
 if (!ForConstraintInstantiation &&
-

[clang] [Clang][Sema] Revisit the fix for the lambda within a type alias template decl (PR #89934)

2024-04-24 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits

yronglin wrote:

Thank you working on this. I'd very like this feature! I've a question, do we 
have any further plans to support GNU extension attributes(e.g. 
`__attribute__((aligned))`)? Although it is not included in the paper.

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


[clang] [Clang][Sema] Revisit the fix for the lambda within a type alias template decl (PR #89934)

2024-04-24 Thread Younan Zhang via cfe-commits

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


[clang] [Clang][Sema] Revisit the fix for the lambda within a type alias template decl (PR #89934)

2024-04-24 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

I didn't add a release note because the previous patch has not been released 
yet.

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


[clang] [C++23] [CLANG] Adding C++23 constexpr math functions: fmin and frexp. (PR #88978)

2024-04-24 Thread Zahira Ammarguellat via cfe-commits


@@ -2922,7 +2922,7 @@ static bool handleFloatFloatBinOp(EvalInfo , const 
BinaryOperator *E,
   //   If during the evaluation of an expression, the result is not
   //   mathematically defined [...], the behavior is undefined.
   // FIXME: C++ rules require us to not conform to IEEE 754 here.
-  if (LHS.isNaN()) {
+  if (!Info.getLangOpts().CPlusPlus23 && LHS.isNaN()) {

zahiraam wrote:

> There's an open CWG issue 
> ([CWG2168](https://cplusplus.github.io/CWG/issues/2168.html)) about this.

That's referring to INFINITY though. This is more specifically about NAN.

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


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits


@@ -317,7 +317,7 @@ void Declarator::setDecompositionBindings(
   new DecompositionDeclarator::Binding[Bindings.size()];

cor3ntin wrote:

Note I'm not super fan of the hidden vector implementation here.
It forces Binding to be default constructible.

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


[clang] [llvm] [coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (PR #89751)

2024-04-24 Thread via cfe-commits

https://github.com/zmodem updated 
https://github.com/llvm/llvm-project/pull/89751

>From 33b07efe6d68cb4d17e96349b552ef5e5901d8c6 Mon Sep 17 00:00:00 2001
From: Hans Wennborg 
Date: Tue, 26 Mar 2024 15:04:35 +0100
Subject: [PATCH 1/4] stuff

---
 clang/lib/CodeGen/CGCoroutine.cpp |   5 +-
 clang/test/CodeGenCoroutines/coro-await.cpp   |   3 +-
 .../coro-symmetric-transfer-01.cpp|   4 +-
 .../coro-symmetric-transfer-02.cpp|   6 +-
 llvm/docs/Coroutines.rst  |  19 +-
 llvm/docs/LangRef.rst |   2 +-
 llvm/include/llvm/IR/Intrinsics.td|   2 +-
 llvm/lib/Transforms/Coroutines/CoroInstr.h|   4 +-
 llvm/lib/Transforms/Coroutines/CoroInternal.h |   3 +-
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  | 234 +-
 llvm/lib/Transforms/Coroutines/Coroutines.cpp |   2 +-
 .../Coro/coro-split-musttail.ll   |  63 -
 .../Coro/coro-split-musttail1.ll  |  97 
 .../Coro/coro-split-musttail10.ll |  55 
 .../Coro/coro-split-musttail11.ll |  55 
 .../Coro/coro-split-musttail12.ll |  85 ---
 .../Coro/coro-split-musttail13.ll |  76 --
 .../Coro/coro-split-musttail2.ll  |  68 -
 .../Coro/coro-split-musttail3.ll  |  91 ---
 .../Coro/coro-split-musttail4.ll  |  66 -
 .../Coro/coro-split-musttail5.ll  |  63 -
 .../Coro/coro-split-musttail6.ll  | 112 -
 .../Coro/coro-split-musttail7.ll  | 115 -
 .../coro-await-suspend-lower-invoke.ll|   5 +-
 .../Coroutines/coro-await-suspend-lower.ll|   5 +-
 .../Coroutines/coro-preserve-final.ll | 131 --
 ...-split-musttail-chain-pgo-counter-promo.ll |   9 +-
 .../Coroutines/coro-split-musttail.ll |  17 +-
 .../Coroutines/coro-split-musttail1.ll|  32 ++-
 .../Coroutines/coro-split-musttail10.ll   |  13 +-
 .../Coroutines/coro-split-musttail11.ll   |  55 
 .../Coroutines/coro-split-musttail2.ll|  12 +-
 .../Coroutines/coro-split-musttail3.ll|  33 ++-
 .../Coroutines/coro-split-musttail4.ll|   5 +-
 .../Coroutines/coro-split-musttail5.ll|   5 +-
 .../Coroutines/coro-split-musttail6.ll|   9 +-
 .../Coroutines/coro-split-musttail7.ll|  15 +-
 37 files changed, 157 insertions(+), 1419 deletions(-)
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail1.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail10.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail11.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail12.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail13.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail2.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail3.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail4.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail5.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail6.ll
 delete mode 100644 
llvm/test/Instrumentation/InstrProfiling/Coro/coro-split-musttail7.ll
 delete mode 100644 llvm/test/Transforms/Coroutines/coro-preserve-final.ll
 delete mode 100644 llvm/test/Transforms/Coroutines/coro-split-musttail11.ll

diff --git a/clang/lib/CodeGen/CGCoroutine.cpp 
b/clang/lib/CodeGen/CGCoroutine.cpp
index 93ca711f716fce..e976734898b9b8 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -307,10 +307,7 @@ static LValueOrRValue 
emitSuspendExpression(CodeGenFunction , CGCoroData 
 break;
   }
   case CoroutineSuspendExpr::SuspendReturnType::SuspendHandle: {
-assert(SuspendRet->getType()->isPointerTy());
-
-auto ResumeIntrinsic = CGF.CGM.getIntrinsic(llvm::Intrinsic::coro_resume);
-Builder.CreateCall(ResumeIntrinsic, SuspendRet);
+assert(SuspendRet->getType()->isVoidTy());
 break;
   }
   }
diff --git a/clang/test/CodeGenCoroutines/coro-await.cpp 
b/clang/test/CodeGenCoroutines/coro-await.cpp
index 75851d8805bb6e..7caaa6351844b2 100644
--- a/clang/test/CodeGenCoroutines/coro-await.cpp
+++ b/clang/test/CodeGenCoroutines/coro-await.cpp
@@ -370,8 +370,7 @@ extern "C" void TestTailcall() {
   // ---
   // Call coro.await.suspend
   // ---
-  // CHECK-NEXT: %[[RESUMED:.+]] = call ptr 
@llvm.coro.await.suspend.handle(ptr %[[AWAITABLE]], ptr %[[FRAME]], ptr 
@__await_suspend_wrapper_TestTailcall_await)
-  // CHECK-NEXT: call void @llvm.coro.resume(ptr %[[RESUMED]])
+  // CHECK-NEXT: call 

[clang] [llvm] [coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (PR #89751)

2024-04-24 Thread via cfe-commits


@@ -1523,24 +1442,16 @@ struct SwitchCoroutineSplitter {
 
 createResumeEntryBlock(F, Shape);
 auto *ResumeClone =
-createClone(F, ".resume", Shape, CoroCloner::Kind::SwitchResume);
+createClone(F, ".resume", Shape, CoroCloner::Kind::SwitchResume, TTI);
 auto *DestroyClone =
-createClone(F, ".destroy", Shape, CoroCloner::Kind::SwitchUnwind);
+createClone(F, ".destroy", Shape, CoroCloner::Kind::SwitchUnwind, TTI);
 auto *CleanupClone =
-createClone(F, ".cleanup", Shape, CoroCloner::Kind::SwitchCleanup);
+createClone(F, ".cleanup", Shape, CoroCloner::Kind::SwitchCleanup, 
TTI);
 
 postSplitCleanup(*ResumeClone);
 postSplitCleanup(*DestroyClone);
 postSplitCleanup(*CleanupClone);
 
-// Adding musttail call to support symmetric transfer.
-// Skip targets which don't support tail call.
-//
-// FIXME: Could we support symmetric transfer effectively without musttail

zmodem wrote:

Done.

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


[clang] [llvm] [coro] Lower `llvm.coro.await.suspend.handle` to resume with tail call (PR #89751)

2024-04-24 Thread via cfe-commits

zmodem wrote:

> The higher level idea looks fine.

Thanks!

> A detail is that, in this patch, we must not mark 
> `llvm.coro.await.suspend.handle` as nounwind. Previously, 
> `llvm.coro.await.suspend.handle` may be marked as nounwind if the 
> `await_suspend` is noexcept. But we can't do it in this patch since 
> `llvm.coro.await.suspend.handle` will include `resume` calls, which 
> technically is not nounwind.

Done.

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


[clang] [Driver] Restore compiler-rt arch suffix for PS and Windows (PR #89775)

2024-04-24 Thread Tobias Hieta via cfe-commits

tru wrote:

Honestly - I think going back to *one* style of runtime path is to be preferred 
now. But I don't think it's fair to say that it doesn't solve any problems, 
because we switched to it so that we could ship more platforms in one toolchain 
package without having to add cfg files and similar things to point it to the 
right path. There was some kind of collision we ran into when we where using 
the old path.

I do think the current status quo is confusing and bad, so I rather we go back 
to the old layout if that's what people prefer and I'll have to work around 
that in that case. But it sounds like this needs a RFC.

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


[clang] [CMake][Release] Refactor cache file and use two stages for non-PGO builds (PR #89812)

2024-04-24 Thread Tobias Hieta via cfe-commits

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

I find changes to the multi-stage build caches a bit confusing to review 
without being able to see the cache that's generated. But I trust that you have 
tested this and it works as expected, In that case you can merge this.

https://github.com/llvm/llvm-project/pull/89812
___
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 check to suggest replacement of nested std::min or std::max with initializer lists (PR #85572)

2024-04-24 Thread Piotr Zegar via cfe-commits

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

LGTM

https://github.com/llvm/llvm-project/pull/85572
___
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 new check bugprone-tagged-union-member-count (PR #89925)

2024-04-24 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [HLSL] Support packoffset attribute in AST (PR #89836)

2024-04-24 Thread Xiang Li via cfe-commits

https://github.com/python3kgae updated 
https://github.com/llvm/llvm-project/pull/89836

>From 4d8c72688656fe3b2ce8817087d8cf7352b5876b Mon Sep 17 00:00:00 2001
From: Xiang Li 
Date: Tue, 23 Apr 2024 17:49:02 -0400
Subject: [PATCH 1/2] [HLSL] Support packoffset attribute in AST

Add HLSLPackOffsetAttr to save packoffset in AST.

Since we have to parse the attribute manually in ParseHLSLAnnotations,
we could create the ParsedAttribute with a integer offset parameter instead of 
string.
This approach avoids parsing the string if the offset is saved as a string in 
HLSLPackOffsetAttr.
---
 clang/include/clang/Basic/Attr.td |  7 ++
 clang/include/clang/Basic/AttrDocs.td | 18 +
 .../clang/Basic/DiagnosticParseKinds.td   |  2 +
 .../clang/Basic/DiagnosticSemaKinds.td|  3 +
 clang/lib/Parse/ParseHLSL.cpp | 80 +++
 clang/lib/Sema/SemaDeclAttr.cpp   | 44 ++
 clang/lib/Sema/SemaHLSL.cpp   | 48 +++
 clang/test/AST/HLSL/packoffset.hlsl   | 16 
 clang/test/SemaHLSL/packoffset-invalid.hlsl   | 55 +
 9 files changed, 273 insertions(+)
 create mode 100644 clang/test/AST/HLSL/packoffset.hlsl
 create mode 100644 clang/test/SemaHLSL/packoffset-invalid.hlsl

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..d3d006ed9633f4 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4372,6 +4372,13 @@ def HLSLResourceBinding: InheritableAttr {
   let Documentation = [HLSLResourceBindingDocs];
 }
 
+def HLSLPackOffset: HLSLAnnotationAttr {
+  let Spellings = [HLSLAnnotation<"packoffset">];
+  let LangOpts = [HLSL];
+  let Args = [IntArgument<"Offset">];
+  let Documentation = [HLSLPackOffsetDocs];
+}
+
 def HLSLSV_DispatchThreadID: HLSLAnnotationAttr {
   let Spellings = [HLSLAnnotation<"SV_DispatchThreadID">];
   let Subjects = SubjectList<[ParmVar, Field]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index a0bbe5861c5722..6bc7813bd43cb4 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7398,6 +7398,24 @@ The full documentation is available here: 
https://docs.microsoft.com/en-us/windo
   }];
 }
 
+def HLSLPackOffsetDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The packoffset attribute is used to change the layout of a cbuffer.
+Attribute spelling in HLSL is: ``packoffset(c[Subcomponent[.component]])``.
+A subcomponent is a register number, which is an integer. A component is in 
the form of [.xyzw].
+
+Here're packoffset examples with and without component:
+.. code-block:: c++
+  cbuffer A {
+float3 a : packoffset(c0.y);
+float4 b : packoffset(c4);
+  }
+
+The full documentation is available here: 
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-variable-packoffset
+  }];
+}
+
 def HLSLSV_DispatchThreadIDDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..81433ee79d48b2 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1745,5 +1745,7 @@ def err_hlsl_separate_attr_arg_and_number : Error<"wrong 
argument format for hls
 def ext_hlsl_access_specifiers : ExtWarn<
   "access specifiers are a clang HLSL extension">,
   InGroup;
+def err_hlsl_unsupported_component : Error<"invalid component '%0' used; 
expected 'x', 'y', 'z', or 'w'">;
+def err_hlsl_packoffset_invalid_reg : Error<"invalid resource class specifier 
'%0' for packoffset, expected 'c'">;
 
 } // end of Parser diagnostics
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 63e951daec7477..bde9617c9820a8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12167,6 +12167,9 @@ def err_hlsl_init_priority_unsupported : Error<
 def err_hlsl_unsupported_register_type : Error<"invalid resource class 
specifier '%0' used; expected 'b', 's', 't', or 'u'">;
 def err_hlsl_unsupported_register_number : Error<"register number should be an 
integer">;
 def err_hlsl_expected_space : Error<"invalid space specifier '%0' used; 
expected 'space' followed by an integer, like space1">;
+def err_hlsl_packoffset_mix : Error<"cannot mix packoffset elements with 
nonpackoffset elements in a cbuffer">;
+def err_hlsl_packoffset_overlap : Error<"packoffset overlap between %0, %1">;
+def err_hlsl_packoffset_cross_reg_boundary : Error<"packoffset cannot cross 
register boundary">;
 def err_hlsl_pointers_unsupported : Error<
   "%select{pointers|references}0 are unsupported in HLSL">;
 
diff --git a/clang/lib/Parse/ParseHLSL.cpp 

[clang] [clang][NFC] Reformat suspicious condition (PR #89923)

2024-04-24 Thread via cfe-commits

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


[clang] [clang][NFC] Reformat suspicious condition (PR #89923)

2024-04-24 Thread via cfe-commits

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

Thanks for your contribution.
Will you need me to merge that for you?

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


[clang] [clang][dataflow] Don't propagate result objects in nested declarations. (PR #89903)

2024-04-24 Thread via cfe-commits

https://github.com/martinboehme created 
https://github.com/llvm/llvm-project/pull/89903

Trying to do so can cause crashes -- see newly added test and the comments in
the fix.


>From 0ed905fc227bc58f3ae8f5ead856bba7e8376e3c Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Wed, 24 Apr 2024 09:41:18 +
Subject: [PATCH] [clang][dataflow] Don't propagate result objects in nested
 declarations.

Trying to do so can cause crashes -- see newly added test and the comments in
the fix.
---
 .../FlowSensitive/DataflowEnvironment.cpp | 12 ++
 .../Analysis/FlowSensitive/TransferTest.cpp   | 22 +++
 2 files changed, 34 insertions(+)

diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 3cb656adcbdc0c..aec8ee6a4a07fc 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -333,6 +333,18 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 }
   }
 
+  bool TraverseDecl(Decl *D) {
+// Don't traverse nested record or function declarations.
+// - We won't be analyzing code contained in these anyway
+// - We don't model fields that are used only in these nested declaration,
+//   so trying to propagate a result object to initializers of such fields
+//   would cause an error.
+if (isa(D) || isa(D))
+  return true;
+
+return RecursiveASTVisitor::TraverseDecl(D);
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 215e208615ac23..5c7c39e52612ec 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3309,6 +3309,28 @@ TEST(TransferTest, 
ResultObjectLocationPropagatesThroughConditionalOperator) {
   });
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitNestedRecordDecl) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // nested record and function declarations, but we don't model fields used
+  // only in these.
+  std::string Code = R"(
+struct S1 {};
+struct S2 { S1 s1; };
+void target() {
+  struct Nested {
+void f() {
+  S2 s2 = { S1() };
+}
+  };
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> ,
+ ASTContext ) {});
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {

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


[clang] [clang][dataflow] Don't propagate result objects in nested declarations. (PR #89903)

2024-04-24 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-analysis

Author: None (martinboehme)


Changes

Trying to do so can cause crashes -- see newly added test and the comments in
the fix.


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


2 Files Affected:

- (modified) clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp (+12) 
- (modified) clang/unittests/Analysis/FlowSensitive/TransferTest.cpp (+22) 


``diff
diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 3cb656adcbdc0c..aec8ee6a4a07fc 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -333,6 +333,18 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 }
   }
 
+  bool TraverseDecl(Decl *D) {
+// Don't traverse nested record or function declarations.
+// - We won't be analyzing code contained in these anyway
+// - We don't model fields that are used only in these nested declaration,
+//   so trying to propagate a result object to initializers of such fields
+//   would cause an error.
+if (isa(D) || isa(D))
+  return true;
+
+return RecursiveASTVisitor::TraverseDecl(D);
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 215e208615ac23..5c7c39e52612ec 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3309,6 +3309,28 @@ TEST(TransferTest, 
ResultObjectLocationPropagatesThroughConditionalOperator) {
   });
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitNestedRecordDecl) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // nested record and function declarations, but we don't model fields used
+  // only in these.
+  std::string Code = R"(
+struct S1 {};
+struct S2 { S1 s1; };
+void target() {
+  struct Nested {
+void f() {
+  S2 s2 = { S1() };
+}
+  };
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> ,
+ ASTContext ) {});
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {

``




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


[clang] [clang] CTAD: implement the missing IsDeducible constraint for alias templates (PR #89358)

2024-04-24 Thread via cfe-commits

cor3ntin wrote:

> Ah, I see. I haven't tried that, but one downside I can see is that it will 
> make diagnostics for CTAD worse, we need to spell the type trait name in 
> error messages when the __is_deducible trait fails.

I think we should have a custom diag for that anyway
"is not deducible from" is better than " `__is_deducible<>` is false"


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


[clang-tools-extra] [clang-tidy] check `std::string_view` and custom string-like classes in `readability-string-compare` (PR #88636)

2024-04-24 Thread Vadim D. via cfe-commits

https://github.com/vvd170501 updated 
https://github.com/llvm/llvm-project/pull/88636

>From ab87ad179f385934e2ec17517b47da33d29eb256 Mon Sep 17 00:00:00 2001
From: Vadim Dudkin 
Date: Sat, 13 Apr 2024 23:36:12 +0300
Subject: [PATCH] readability-string-compare: check std::string_view, allow
 custom string-like classes

---
 .../readability/StringCompareCheck.cpp| 27 --
 .../readability/StringCompareCheck.h  | 10 -
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 +++
 .../checks/readability/string-compare.rst | 37 ++-
 .../clang-tidy/checkers/Inputs/Headers/string | 10 +
 .../string-compare-custom-string-classes.cpp  | 35 ++
 .../checkers/readability/string-compare.cpp   | 23 
 7 files changed, 139 insertions(+), 8 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/readability/string-compare-custom-string-classes.cpp

diff --git a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp
index 3b5d89c8c64719..7c0bbef3ca0878 100644
--- a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp
@@ -7,12 +7,15 @@
 
//===--===//
 
 #include "StringCompareCheck.h"
-#include "../utils/FixItHintUtils.h"
+#include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/FixIt.h"
+#include "llvm/ADT/StringRef.h"
 
 using namespace clang::ast_matchers;
+namespace optutils = clang::tidy::utils::options;
 
 namespace clang::tidy::readability {
 
@@ -20,11 +23,27 @@ static const StringRef CompareMessage = "do not use 
'compare' to test equality "
 "of strings; use the string equality "
 "operator instead";
 
+static const StringRef DefaultStringLikeClasses = "::std::basic_string;"
+  "::std::basic_string_view";
+
+StringCompareCheck::StringCompareCheck(StringRef Name,
+   ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  StringLikeClasses(optutils::parseStringList(
+  Options.get("StringLikeClasses", DefaultStringLikeClasses))) {}
+
+void StringCompareCheck::storeOptions(ClangTidyOptions::OptionMap ) {
+  Options.store(Opts, "StringLikeClasses",
+optutils::serializeStringList(StringLikeClasses));
+}
+
 void StringCompareCheck::registerMatchers(MatchFinder *Finder) {
+  if (StringLikeClasses.empty()) {
+return;
+  }
   const auto StrCompare = cxxMemberCallExpr(
-  callee(cxxMethodDecl(hasName("compare"),
-   ofClass(classTemplateSpecializationDecl(
-   hasName("::std::basic_string"),
+  callee(cxxMethodDecl(hasName("compare"), 
ofClass(cxxRecordDecl(hasAnyName(
+   StringLikeClasses),
   hasArgument(0, expr().bind("str2")), argumentCountIs(1),
   callee(memberExpr().bind("str1")));
 
diff --git a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.h 
b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.h
index 812736d806b71d..150090901a6e97 100644
--- a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_STRINGCOMPARECHECK_H
 
 #include "../ClangTidyCheck.h"
+#include 
 
 namespace clang::tidy::readability {
 
@@ -20,13 +21,18 @@ namespace clang::tidy::readability {
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/readability/string-compare.html
 class StringCompareCheck : public ClangTidyCheck {
 public:
-  StringCompareCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  StringCompareCheck(StringRef Name, ClangTidyContext *Context);
+
   bool isLanguageVersionSupported(const LangOptions ) const override {
 return LangOpts.CPlusPlus;
   }
+
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult ) override;
+  void storeOptions(ClangTidyOptions::OptionMap ) override;
+
+private:
+  const std::vector StringLikeClasses;
 };
 
 } // namespace clang::tidy::readability
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 5b1feffb89ea06..aa8b4a63b60946 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -314,6 +314,11 @@ Changes in existing checks
   check by resolving fix-it overlaps in template code by disregarding implicit
   instances.
 
+- Improved 

[clang] [clang][modules] Allow module maps with textual headers to be non-affecting (PR #89441)

2024-04-24 Thread Sam McCall via cfe-commits


@@ -1574,6 +1574,7 @@ bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor 
,
 }
   }
 
+  FileInfo.IsLocallyIncluded = true;

sam-mccall wrote:

I'd consider placing this at the end of HandleHeaderIncludeOrImport rather than 
here:

- it looks like there are cases where this function returns true and we don't 
enter the file textually (or at least, it's not *obvious* that there are no 
such cases)
- having a load-bearing side-effect of a "should we do X" query seems 
unexpected and liable to break during refactoring or in edge cases

Concretely I don't see a case where this doesn't work though, up to you.

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


[clang] [clang][modules] Allow module maps with textual headers to be non-affecting (PR #89441)

2024-04-24 Thread Sam McCall via cfe-commits


@@ -2057,9 +2065,12 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch 
) {
 // it as a header file (in which case HFI will be null) or if it hasn't
 // changed since it was loaded. Also skip it if it's for a modular header
 // from a different module; in that case, we rely on the module(s)
-// containing the header to provide this information.
+// containing the header to provide this information. Also skip it if it's
+// for any header not from this module that has not been included; in that
+// case, we don't need the information at all.
 const HeaderFileInfo *HFI = HS.getExistingLocalFileInfo(*File);
-if (!HFI || (HFI->isModuleHeader && !HFI->isCompilingModuleHeader))
+if (!HFI || (!HFI->isCompilingModuleHeader &&

sam-mccall wrote:

nit: this seems hard to follow, consider splitting up as:

```
if (!HFI)
  continue; // we're not relying on this file at all
if (HFI->isModuleHeader && !HFI->isCompilingModuleHeader)
  continue; // will import HFI from its module
if (!HFI->isCompilingModuleHeader && !PP->alreadyIncluded(*File))
  continue; // unused header needs no description
```

and possibly pulling out as `static shouldDescribeHeader(HFI)` or so?

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


[clang] [clang][modules] Allow module maps with textual headers to be non-affecting (PR #89441)

2024-04-24 Thread Sam McCall via cfe-commits

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


[clang] [clang][modules] Allow module maps with textual headers to be non-affecting (PR #89441)

2024-04-24 Thread Sam McCall via cfe-commits

https://github.com/sam-mccall approved this pull request.

Thanks, LGTM

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


[clang] eaa2eac - [AMDGPU] Fix linker test on platforms without BFD

2024-04-24 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2024-04-24T07:03:51-05:00
New Revision: eaa2eac8ec73a0473655f2da73f347906d14b00f

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

LOG: [AMDGPU] Fix linker test on platforms without BFD

Added: 


Modified: 
clang/test/Driver/amdgpu-toolchain.c

Removed: 




diff  --git a/clang/test/Driver/amdgpu-toolchain.c 
b/clang/test/Driver/amdgpu-toolchain.c
index d21ce857f3c57a..faaff05004f6de 100644
--- a/clang/test/Driver/amdgpu-toolchain.c
+++ b/clang/test/Driver/amdgpu-toolchain.c
@@ -25,8 +25,6 @@
 // LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
 // MCPU: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906"
 
-// We do not suppor the BFD linker, but we should be able to override the
-// default even if it will error during linking.
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
-// RUN:   -fuse-ld=bfd %s 2>&1 | FileCheck -check-prefixes=LD %s
-// LD: ld.bfd"
+// RUN:   -fuse-ld=ld %s 2>&1 | FileCheck -check-prefixes=LD %s
+// LD: ld.lld"



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


[clang] [libcxx] [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (PR #89446)

2024-04-24 Thread Aaron Ballman via cfe-commits


@@ -89,6 +89,19 @@ sections with improvements to Clang's support for those 
languages.
 C++ Language Changes
 
 
+C++17 Feature Support
+^
+- Clang now exposes ``__GCC_DESTRUCTIVE_SIZE`` and ``__GCC_CONSTRUCTIVE_SIZE``
+  predefined macros to support standard library implementations of
+  ``std::hardware_destructive_interference_size`` and
+  ``std::hardware_constructive_interference_size``, respectively. These macros
+  are predefined in all C and C++ language modes. These macros can be
+  overridden on the command line with ``-D``, if desired. The values the macros

AaronBallman wrote:

> There should to be a user-facing way to set this, in order to pin it to a 
> particular value. If not -D, then e.g. copy GCC's `--param 
> hardware_destructive_interference_size=N` command-line.

`-D` is my preference, mostly because `--param` is not something we already 
support for options. I could put something into the extensions documentation to 
mention this?

> How do they know that this constant is not ABI-stable, unlike the entire rest 
> of the library?

I would assume that anyone using this interface is aware of the fact that it's 
tightly coupled with the CPU tuning used by the program and I would hope that 
folks are compiling with sanitizers enabled so they'd catch ABI issues more 
broadly than just this one narrow case. At the same time, defense in depth is 
not a bad thing.

> That may not be ideal, but it's a relatively simple solution that seems 
> likely to be good enough. I think Clang could quite reasonably do the same 
> thing.

I'll take a run at implementing that; it feels a bit user hostile because there 
are benign uses within a header file and the macro is exposed in C while the 
STL interface isn't, but it does provide *some* measure of protection.

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


[clang] [libcxx] [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (PR #89446)

2024-04-24 Thread via cfe-commits

cor3ntin wrote:

For the record, I am fairly opposed to a warning on normal use of a standard 
function.

I'm not very concerned about users using different target flags across TUs 
because this is already a massive foot gun and I do not buy that we are making 
things materially worse.

Instead, by having opinionated on-by-default warnings we encourage users to not 
care or proactively distrust our warnings. Users will use that functions in 
headers as a lot of people like to put most of their implementation in headers.

Don't get me wrong, I think diagnosing actual ODR-violation is a worthwhile 
goal, and as @AaronBallman mentioned
there are ways to do that (modules, asan, build system warning on inconsistent 
flags), but from within a single TU
we don't have a way to detect actual ODR issues, so we would end up forcing our 
opinions on users, which I'm not sure is marginally better than not 
implementing the feature at all.

I don't think this feature warrants deviating from our policy that on-by 
default warnings should be actionable and have a low false-positive rate, nor 
the complexity to actually produce the warning.

If we get users reporting issue with that feature, then we can always emit a 
deprecation warning.



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


[clang] [clang][PowerPC] Add flag to enable compatibility with GNU for complex arguments (PR #77732)

2024-04-24 Thread Kishan Parmar via cfe-commits


@@ -0,0 +1,350 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+
+// RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -fcomplex-ppc-gnu-abi \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-GNU-DEF
+// RUN: %clang_cc1 -msoft-float  -mfloat-abi soft -triple 
powerpc-unknown-linux-gnu -fcomplex-ppc-gnu-abi \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-GNU-SOFT-FLOAT
+
+// CHECK-GNU-DEF-LABEL: define dso_local [4 x i32] @_cdouble
+// CHECK-GNU-DEF-SAME: ([4 x i32] noundef [[X_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-GNU-DEF-NEXT:  entry:
+// CHECK-GNU-DEF-NEXT:[[RETVAL:%.*]] = alloca { double, double }, align 8
+// CHECK-GNU-DEF-NEXT:[[X:%.*]] = alloca { double, double }, align 8
+// CHECK-GNU-DEF-NEXT:store [4 x i32] [[X_COERCE]], ptr [[X]], align 8
+// CHECK-GNU-DEF-NEXT:[[X_REALP:%.*]] = getelementptr inbounds { double, 
double }, ptr [[X]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[X_REAL:%.*]] = load double, ptr [[X_REALP]], align 
8
+// CHECK-GNU-DEF-NEXT:[[X_IMAGP:%.*]] = getelementptr inbounds { double, 
double }, ptr [[X]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:[[X_IMAG:%.*]] = load double, ptr [[X_IMAGP]], align 
8
+// CHECK-GNU-DEF-NEXT:[[RETVAL_REALP:%.*]] = getelementptr inbounds { 
double, double }, ptr [[RETVAL]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[RETVAL_IMAGP:%.*]] = getelementptr inbounds { 
double, double }, ptr [[RETVAL]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:store double [[X_REAL]], ptr [[RETVAL_REALP]], align 
8
+// CHECK-GNU-DEF-NEXT:store double [[X_IMAG]], ptr [[RETVAL_IMAGP]], align 
8
+// CHECK-GNU-DEF-NEXT:[[TMP0:%.*]] = load [4 x i32], ptr [[RETVAL]], align 
8
+// CHECK-GNU-DEF-NEXT:ret [4 x i32] [[TMP0]]
+//
+// CHECK-GNU-SOFT-FLOAT-LABEL: define dso_local [4 x i32] @_cdouble
+// CHECK-GNU-SOFT-FLOAT-SAME: ([4 x i32] noundef [[X_COERCE:%.*]]) 
#[[ATTR0:[0-9]+]] {
+// CHECK-GNU-SOFT-FLOAT-NEXT:  entry:
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[RETVAL:%.*]] = alloca { double, double }, 
align 8
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X:%.*]] = alloca { double, double }, align 8
+// CHECK-GNU-SOFT-FLOAT-NEXT:store [4 x i32] [[X_COERCE]], ptr [[X]], 
align 8
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X_REALP:%.*]] = getelementptr inbounds { 
double, double }, ptr [[X]], i32 0, i32 0
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X_REAL:%.*]] = load double, ptr 
[[X_REALP]], align 8
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X_IMAGP:%.*]] = getelementptr inbounds { 
double, double }, ptr [[X]], i32 0, i32 1
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[X_IMAG:%.*]] = load double, ptr 
[[X_IMAGP]], align 8
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[RETVAL_REALP:%.*]] = getelementptr inbounds 
{ double, double }, ptr [[RETVAL]], i32 0, i32 0
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[RETVAL_IMAGP:%.*]] = getelementptr inbounds 
{ double, double }, ptr [[RETVAL]], i32 0, i32 1
+// CHECK-GNU-SOFT-FLOAT-NEXT:store double [[X_REAL]], ptr 
[[RETVAL_REALP]], align 8
+// CHECK-GNU-SOFT-FLOAT-NEXT:store double [[X_IMAG]], ptr 
[[RETVAL_IMAGP]], align 8
+// CHECK-GNU-SOFT-FLOAT-NEXT:[[TMP0:%.*]] = load [4 x i32], ptr 
[[RETVAL]], align 8
+// CHECK-GNU-SOFT-FLOAT-NEXT:ret [4 x i32] [[TMP0]]
+//
+_Complex double _cdouble(_Complex double x) {
+  return x;
+}
+
+// CHECK-GNU-DEF-LABEL: define dso_local [8 x i32] @_cldouble
+// CHECK-GNU-DEF-SAME: (float noundef [[F:%.*]], [8 x i32] noundef 
[[X_COERCE:%.*]]) #[[ATTR0]] {
+// CHECK-GNU-DEF-NEXT:  entry:
+// CHECK-GNU-DEF-NEXT:[[RETVAL:%.*]] = alloca { ppc_fp128, ppc_fp128 }, 
align 16
+// CHECK-GNU-DEF-NEXT:[[X:%.*]] = alloca { ppc_fp128, ppc_fp128 }, align 16
+// CHECK-GNU-DEF-NEXT:[[F_ADDR:%.*]] = alloca float, align 4
+// CHECK-GNU-DEF-NEXT:store [8 x i32] [[X_COERCE]], ptr [[X]], align 16
+// CHECK-GNU-DEF-NEXT:store float [[F]], ptr [[F_ADDR]], align 4
+// CHECK-GNU-DEF-NEXT:[[X_REALP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[X_REAL:%.*]] = load ppc_fp128, ptr [[X_REALP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[X_IMAGP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[X]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:[[X_IMAG:%.*]] = load ppc_fp128, ptr [[X_IMAGP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[RETVAL_REALP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 0
+// CHECK-GNU-DEF-NEXT:[[RETVAL_IMAGP:%.*]] = getelementptr inbounds { 
ppc_fp128, ppc_fp128 }, ptr [[RETVAL]], i32 0, i32 1
+// CHECK-GNU-DEF-NEXT:store ppc_fp128 [[X_REAL]], ptr [[RETVAL_REALP]], 
align 16
+// CHECK-GNU-DEF-NEXT:store ppc_fp128 [[X_IMAG]], ptr [[RETVAL_IMAGP]], 
align 16
+// CHECK-GNU-DEF-NEXT:[[TMP0:%.*]] = load [8 x i32], ptr [[RETVAL]], align 
16
+// CHECK-GNU-DEF-NEXT:ret [8 x i32] [[TMP0]]
+//
+// CHECK-GNU-SOFT-FLOAT-LABEL: define dso_local [8 x i32] @_cldouble
+// 

[clang] [clang][dataflow] Don't propagate result objects in nested declarations. (PR #89903)

2024-04-24 Thread via cfe-commits

https://github.com/martinboehme updated 
https://github.com/llvm/llvm-project/pull/89903

>From 0ed905fc227bc58f3ae8f5ead856bba7e8376e3c Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Wed, 24 Apr 2024 09:41:18 +
Subject: [PATCH 1/2] [clang][dataflow] Don't propagate result objects in
 nested declarations.

Trying to do so can cause crashes -- see newly added test and the comments in
the fix.
---
 .../FlowSensitive/DataflowEnvironment.cpp | 12 ++
 .../Analysis/FlowSensitive/TransferTest.cpp   | 22 +++
 2 files changed, 34 insertions(+)

diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 3cb656adcbdc0c..aec8ee6a4a07fc 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -333,6 +333,18 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 }
   }
 
+  bool TraverseDecl(Decl *D) {
+// Don't traverse nested record or function declarations.
+// - We won't be analyzing code contained in these anyway
+// - We don't model fields that are used only in these nested declaration,
+//   so trying to propagate a result object to initializers of such fields
+//   would cause an error.
+if (isa(D) || isa(D))
+  return true;
+
+return RecursiveASTVisitor::TraverseDecl(D);
+  }
+
   bool TraverseBindingDecl(BindingDecl *BD) {
 // `RecursiveASTVisitor` doesn't traverse holding variables for
 // `BindingDecl`s by itself, so we need to tell it to.
diff --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index 215e208615ac23..5c7c39e52612ec 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3309,6 +3309,28 @@ TEST(TransferTest, 
ResultObjectLocationPropagatesThroughConditionalOperator) {
   });
 }
 
+TEST(TransferTest, ResultObjectLocationDontVisitNestedRecordDecl) {
+  // This is a crash repro.
+  // We used to crash because when propagating result objects, we would visit
+  // nested record and function declarations, but we don't model fields used
+  // only in these.
+  std::string Code = R"(
+struct S1 {};
+struct S2 { S1 s1; };
+void target() {
+  struct Nested {
+void f() {
+  S2 s2 = { S1() };
+}
+  };
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> ,
+ ASTContext ) {});
+}
+
 TEST(TransferTest, StaticCast) {
   std::string Code = R"(
 void target(int Foo) {

>From 21dead242d19077052d495b03d641854109ddcbb Mon Sep 17 00:00:00 2001
From: Martin Braenne 
Date: Wed, 24 Apr 2024 13:07:13 +
Subject: [PATCH 2/2] fixup! [clang][dataflow] Don't propagate result objects
 in nested declarations.

---
 clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index aec8ee6a4a07fc..636d2302093983 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -339,7 +339,7 @@ class ResultObjectVisitor : public 
RecursiveASTVisitor {
 // - We don't model fields that are used only in these nested declaration,
 //   so trying to propagate a result object to initializers of such fields
 //   would cause an error.
-if (isa(D) || isa(D))
+if (isa_and_nonnull(D) || isa_and_nonnull(D))
   return true;
 
 return RecursiveASTVisitor::TraverseDecl(D);

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


[clang] [Clang][Sema] Revisit the fix for the lambda within a type alias template decl (PR #89934)

2024-04-24 Thread Younan Zhang via cfe-commits

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


[clang] [clang][SPIR-V] Add support for AMDGCN flavoured SPIRV (PR #89796)

2024-04-24 Thread Yaxun Liu via cfe-commits


@@ -54,3 +56,289 @@ void SPIRV64TargetInfo::getTargetDefines(const LangOptions 
,
   BaseSPIRVTargetInfo::getTargetDefines(Opts, Builder);
   DefineStd(Builder, "SPIRV64", Opts);
 }
+
+static constexpr Builtin::Info BuiltinInfo[] = {
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+  {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   
\
+  {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES},
+#include "clang/Basic/BuiltinsAMDGPU.def"
+};
+
+namespace {
+const char *AMDGPUGCCRegNames[] = {

yxsamliu wrote:

we could create a common base class for amdgpu target info and spirv64 amdgcn 
target info and not duplicate stuff. we can define a static member for reg 
names.

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


[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-24 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-lld
@llvm/pr-subscribers-lld-coff

@llvm/pr-subscribers-flang-fir-hlfir

Author: David Truby (DavidTruby)


Changes

This patch changes the behaviour for flang to only create and link to a
`main` entry point when the Fortran code has a program statement in it.

This means that flang-new can be used to link even when the program is
a mixed C/Fortran code with `main` present in C and no entry point
present in Fortran.


---

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


23 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (-6) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-109) 
- (modified) clang/lib/Driver/ToolChains/Flang.cpp (-9) 
- (modified) flang/docs/FlangDriver.md (+3-29) 
- (modified) 
flang/include/flang/Optimizer/Builder/Runtime/EnvironmentDefaults.h (+2-1) 
- (added) flang/include/flang/Optimizer/Builder/Runtime/Main.h (+28) 
- (modified) flang/lib/Lower/Bridge.cpp (+4-1) 
- (modified) flang/lib/Optimizer/Builder/CMakeLists.txt (+1) 
- (modified) flang/lib/Optimizer/Builder/Runtime/EnvironmentDefaults.cpp (+3-4) 
- (added) flang/lib/Optimizer/Builder/Runtime/Main.cpp (+62) 
- (modified) flang/runtime/CMakeLists.txt (-1) 
- (removed) flang/runtime/FortranMain/CMakeLists.txt (-23) 
- (removed) flang/runtime/FortranMain/Fortran_main.c (-23) 
- (modified) flang/test/CMakeLists.txt (-1) 
- (modified) flang/test/Driver/driver-help-hidden.f90 (-1) 
- (modified) flang/test/Driver/driver-help.f90 (-1) 
- (modified) flang/test/Driver/dynamic-linker.f90 (-2) 
- (modified) flang/test/Driver/emit-mlir.f90 (+10) 
- (modified) flang/test/Driver/linker-flags.f90 (-8) 
- (modified) flang/test/Driver/msvc-dependent-lib-flags.f90 (-4) 
- (modified) flang/test/Driver/no-duplicate-main.f90 (-2) 
- (modified) flang/tools/flang-driver/CMakeLists.txt (-1) 
- (modified) lld/COFF/MinGW.cpp (-1) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 922bda721dc780..4b852b297a6b99 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6582,12 +6582,6 @@ def J : JoinedOrSeparate<["-"], "J">,
   Group,
   Alias;
 
-let Visibility = [FlangOption] in {
-def no_fortran_main : Flag<["-"], "fno-fortran-main">,
-  Visibility<[FlangOption]>, Group,
-  HelpText<"Do not include Fortran_main.a (provided by Flang) when linking">;
-} // let Visibility = [ FlangOption ]
-
 
//===--===//
 // FC1 Options
 
//===--===//
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b65b96db16bd79..fec11c7e716fdf 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1191,118 +1191,10 @@ bool tools::addOpenMPRuntime(const Compilation , 
ArgStringList ,
   return true;
 }
 
-/// Determines if --whole-archive is active in the list of arguments.
-static bool isWholeArchivePresent(const ArgList ) {
-  bool WholeArchiveActive = false;
-  for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA)) {
-if (Arg) {
-  for (StringRef ArgValue : Arg->getValues()) {
-if (ArgValue == "--whole-archive")
-  WholeArchiveActive = true;
-if (ArgValue == "--no-whole-archive")
-  WholeArchiveActive = false;
-  }
-}
-  }
-
-  return WholeArchiveActive;
-}
-
-/// Determine if driver is invoked to create a shared object library (-static)
-static bool isSharedLinkage(const ArgList ) {
-  return Args.hasArg(options::OPT_shared);
-}
-
-/// Determine if driver is invoked to create a static object library (-shared)
-static bool isStaticLinkage(const ArgList ) {
-  return Args.hasArg(options::OPT_static);
-}
-
-/// Add Fortran runtime libs for MSVC
-static void addFortranRuntimeLibsMSVC(const ArgList ,
-  llvm::opt::ArgStringList ) {
-  unsigned RTOptionID = options::OPT__SLASH_MT;
-  if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
-RTOptionID = llvm::StringSwitch(rtl->getValue())
- .Case("static", options::OPT__SLASH_MT)
- .Case("static_dbg", options::OPT__SLASH_MTd)
- .Case("dll", options::OPT__SLASH_MD)
- .Case("dll_dbg", options::OPT__SLASH_MDd)
- .Default(options::OPT__SLASH_MT);
-  }
-  switch (RTOptionID) {
-  case options::OPT__SLASH_MT:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static.lib");
-break;
-  case options::OPT__SLASH_MTd:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static_dbg.lib");
-break;
-  case options::OPT__SLASH_MD:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.dynamic.lib");
-break;
-  case options::OPT__SLASH_MDd:
-

[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: David Truby (DavidTruby)


Changes

This patch changes the behaviour for flang to only create and link to a
`main` entry point when the Fortran code has a program statement in it.

This means that flang-new can be used to link even when the program is
a mixed C/Fortran code with `main` present in C and no entry point
present in Fortran.


---

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


23 Files Affected:

- (modified) clang/include/clang/Driver/Options.td (-6) 
- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-109) 
- (modified) clang/lib/Driver/ToolChains/Flang.cpp (-9) 
- (modified) flang/docs/FlangDriver.md (+3-29) 
- (modified) 
flang/include/flang/Optimizer/Builder/Runtime/EnvironmentDefaults.h (+2-1) 
- (added) flang/include/flang/Optimizer/Builder/Runtime/Main.h (+28) 
- (modified) flang/lib/Lower/Bridge.cpp (+4-1) 
- (modified) flang/lib/Optimizer/Builder/CMakeLists.txt (+1) 
- (modified) flang/lib/Optimizer/Builder/Runtime/EnvironmentDefaults.cpp (+3-4) 
- (added) flang/lib/Optimizer/Builder/Runtime/Main.cpp (+62) 
- (modified) flang/runtime/CMakeLists.txt (-1) 
- (removed) flang/runtime/FortranMain/CMakeLists.txt (-23) 
- (removed) flang/runtime/FortranMain/Fortran_main.c (-23) 
- (modified) flang/test/CMakeLists.txt (-1) 
- (modified) flang/test/Driver/driver-help-hidden.f90 (-1) 
- (modified) flang/test/Driver/driver-help.f90 (-1) 
- (modified) flang/test/Driver/dynamic-linker.f90 (-2) 
- (modified) flang/test/Driver/emit-mlir.f90 (+10) 
- (modified) flang/test/Driver/linker-flags.f90 (-8) 
- (modified) flang/test/Driver/msvc-dependent-lib-flags.f90 (-4) 
- (modified) flang/test/Driver/no-duplicate-main.f90 (-2) 
- (modified) flang/tools/flang-driver/CMakeLists.txt (-1) 
- (modified) lld/COFF/MinGW.cpp (-1) 


``diff
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 922bda721dc780..4b852b297a6b99 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6582,12 +6582,6 @@ def J : JoinedOrSeparate<["-"], "J">,
   Group,
   Alias;
 
-let Visibility = [FlangOption] in {
-def no_fortran_main : Flag<["-"], "fno-fortran-main">,
-  Visibility<[FlangOption]>, Group,
-  HelpText<"Do not include Fortran_main.a (provided by Flang) when linking">;
-} // let Visibility = [ FlangOption ]
-
 
//===--===//
 // FC1 Options
 
//===--===//
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index b65b96db16bd79..fec11c7e716fdf 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1191,118 +1191,10 @@ bool tools::addOpenMPRuntime(const Compilation , 
ArgStringList ,
   return true;
 }
 
-/// Determines if --whole-archive is active in the list of arguments.
-static bool isWholeArchivePresent(const ArgList ) {
-  bool WholeArchiveActive = false;
-  for (auto *Arg : Args.filtered(options::OPT_Wl_COMMA)) {
-if (Arg) {
-  for (StringRef ArgValue : Arg->getValues()) {
-if (ArgValue == "--whole-archive")
-  WholeArchiveActive = true;
-if (ArgValue == "--no-whole-archive")
-  WholeArchiveActive = false;
-  }
-}
-  }
-
-  return WholeArchiveActive;
-}
-
-/// Determine if driver is invoked to create a shared object library (-static)
-static bool isSharedLinkage(const ArgList ) {
-  return Args.hasArg(options::OPT_shared);
-}
-
-/// Determine if driver is invoked to create a static object library (-shared)
-static bool isStaticLinkage(const ArgList ) {
-  return Args.hasArg(options::OPT_static);
-}
-
-/// Add Fortran runtime libs for MSVC
-static void addFortranRuntimeLibsMSVC(const ArgList ,
-  llvm::opt::ArgStringList ) {
-  unsigned RTOptionID = options::OPT__SLASH_MT;
-  if (auto *rtl = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
-RTOptionID = llvm::StringSwitch(rtl->getValue())
- .Case("static", options::OPT__SLASH_MT)
- .Case("static_dbg", options::OPT__SLASH_MTd)
- .Case("dll", options::OPT__SLASH_MD)
- .Case("dll_dbg", options::OPT__SLASH_MDd)
- .Default(options::OPT__SLASH_MT);
-  }
-  switch (RTOptionID) {
-  case options::OPT__SLASH_MT:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static.lib");
-break;
-  case options::OPT__SLASH_MTd:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.static_dbg.lib");
-break;
-  case options::OPT__SLASH_MD:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.dynamic.lib");
-break;
-  case options::OPT__SLASH_MDd:
-CmdArgs.push_back("/WHOLEARCHIVE:Fortran_main.dynamic_dbg.lib");
-

[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-24 Thread David Truby via cfe-commits

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


[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits

https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/89906

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused. There 
maybe something more clever to do here but that can be explored as a separate 
PR.

>From e87546f2bc0c7d213b6c1f2b414e0ce5335b3e47 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Wed, 24 Apr 2024 11:53:28 +0200
Subject: [PATCH] [Clang] Implement C++26 Attributes for Structured Bindings
 (P0609R3)

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused.
There maybe something more clever to do here but that can be explored
as a separate PR.
---
 clang/docs/LanguageExtensions.rst |  1 +
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/include/clang/Basic/Attr.td |  2 +-
 .../clang/Basic/DiagnosticParseKinds.td   | 10 +
 clang/include/clang/Sema/DeclSpec.h   | 10 +++--
 clang/include/clang/Sema/ParsedAttr.h |  1 +
 clang/lib/Frontend/InitPreprocessor.cpp   |  2 +-
 clang/lib/Parse/ParseDecl.cpp | 41 ++-
 clang/lib/Sema/DeclSpec.cpp   |  4 +-
 clang/lib/Sema/SemaDecl.cpp   |  2 +-
 clang/lib/Sema/SemaDeclCXX.cpp|  2 +
 clang/test/Lexer/cxx-features.cpp |  2 +-
 clang/test/Parser/cxx1z-decomposition.cpp | 38 +
 clang/test/SemaCXX/unused.cpp | 12 +-
 clang/www/cxx_status.html |  2 +-
 15 files changed, 101 insertions(+), 30 deletions(-)

diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..49afd6c7f06bdd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` 
__cpp_conditional_explicit   C+
 ``if consteval`` __cpp_if_consteval   
C++23 C++20
 ``static operator()``__cpp_static_call_operator   
C++23 C++03
 Attributes on Lambda-Expressions  
C++23 C++11
+Attributes on Structured Bindings__cpp_structured_bindings
C++26 C++03
 ``= delete ("should have a reason");``   __cpp_deleted_function   
C++26 C++03
   
- -
 Designated initializers (N494)
C99   C89
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..8c8ded8cde0837 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P0609R3: Attributes for Structured Bindings 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..97e06fe7d2e6aa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3211,7 +3211,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
C23<"", "maybe_unused", 202106>];
-  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
+  let Subjects = SubjectList<[Var, Binding, ObjCIvar, Type, Enum, 
EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
 }
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..74ce0f8b53a48c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "%select{an attribute specifier sequence|%1}0 in this position "
   "is incompatible with C++ standards before C++23">,
   InGroup, DefaultIgnore;
 
+def ext_decl_attrs_on_binding : ExtWarn<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is a C++2c extension">, InGroup;
+
+def warn_cxx23_compat_decl_attrs_on_binding : Warning<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is incompatible with C++ 

[clang] [Clang][AArch64] Extend diagnostics when warning non/streaming about … (PR #88380)

2024-04-24 Thread Dinar Temirbulatov via cfe-commits

https://github.com/dtemirbulatov updated 
https://github.com/llvm/llvm-project/pull/88380

>From 552c73fa0e8b9c393a19c5c13c371d375b015ecd Mon Sep 17 00:00:00 2001
From: Dinar Temirbulatov 
Date: Thu, 11 Apr 2024 10:59:49 +
Subject: [PATCH 1/4] [Clang][AArch64] Extend diagnostics when warning
 non/streaming about vector size difference

Add separate messages about passing arguments or returning parameters with 
scalable types.
---
 .../clang/Basic/DiagnosticSemaKinds.td|  7 ++-
 clang/lib/Sema/SemaChecking.cpp   | 18 +--
 clang/lib/Sema/SemaDecl.cpp   | 10 ++--
 .../Sema/aarch64-incompat-sm-builtin-calls.c  | 12 +++--
 clang/test/Sema/aarch64-sme-func-attrs.c  | 48 +--
 5 files changed, 55 insertions(+), 40 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 63e951daec7477..40bd812752ec03 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3755,12 +3755,11 @@ def err_sme_definition_using_za_in_non_sme_target : 
Error<
 def err_sme_definition_using_zt0_in_non_sme2_target : Error<
   "function using ZT0 state requires 'sme2'">;
 def warn_sme_streaming_pass_return_vl_to_non_streaming : Warning<
-  "passing a VL-dependent argument to/from a function that has a different"
-  " streaming-mode. The streaming and non-streaming vector lengths may be"
-  " different">,
+  "%select{returning|passing}0 a VL-dependent argument %select{from|to}0 a 
function with a different"
+  " streaming-mode is undefined behaviour if the streaming and non-streaming 
vector lengths are different at runtime">,
   InGroup, DefaultIgnore;
 def warn_sme_locally_streaming_has_vl_args_returns : Warning<
-  "passing/returning a VL-dependent argument to/from a __arm_locally_streaming"
+  "%select{returning|passing}0 a VL-dependent argument %select{from|to}0 a 
__arm_locally_streaming"
   " function. The streaming and non-streaming vector"
   " lengths may be different">,
   InGroup, DefaultIgnore;
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 51757f4cf727d6..67132701b41cfd 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -7953,7 +7953,8 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
 // For variadic functions, we may have more args than parameters.
 // For some K functions, we may have less args than parameters.
 const auto N = std::min(Proto->getNumParams(), Args.size());
-bool AnyScalableArgsOrRet = Proto->getReturnType()->isSizelessVectorType();
+bool IsScalableRet = Proto->getReturnType()->isSizelessVectorType();
+bool IsScalableArg = false;
 for (unsigned ArgIdx = 0; ArgIdx < N; ++ArgIdx) {
   // Args[ArgIdx] can be null in malformed code.
   if (const Expr *Arg = Args[ArgIdx]) {
@@ -7968,7 +7969,7 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
 
 QualType ParamTy = Proto->getParamType(ArgIdx);
 if (ParamTy->isSizelessVectorType())
-  AnyScalableArgsOrRet = true;
+  IsScalableArg = true;
 QualType ArgTy = Arg->getType();
 CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),
   ArgTy, ParamTy);
@@ -7993,7 +7994,8 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
 // arguments or return values, then warn the user that the streaming and
 // non-streaming vector lengths may be different.
 const auto *CallerFD = dyn_cast(CurContext);
-if (CallerFD && (!FD || !FD->getBuiltinID()) && AnyScalableArgsOrRet) {
+if (CallerFD && (!FD || !FD->getBuiltinID()) &&
+(IsScalableArg || IsScalableRet)) {
   bool IsCalleeStreaming =
   ExtInfo.AArch64SMEAttributes & FunctionType::SME_PStateSMEnabledMask;
   bool IsCalleeStreamingCompatible =
@@ -8002,8 +8004,14 @@ void Sema::checkCall(NamedDecl *FDecl, const 
FunctionProtoType *Proto,
   ArmStreamingType CallerFnType = getArmStreamingFnType(CallerFD);
   if (!IsCalleeStreamingCompatible &&
   (CallerFnType == ArmStreamingCompatible ||
-   ((CallerFnType == ArmStreaming) ^ IsCalleeStreaming)))
-Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming);
+   ((CallerFnType == ArmStreaming) ^ IsCalleeStreaming))) {
+if (IsScalableArg)
+  Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming)
+  << /*IsArg=*/true;
+if (IsScalableRet)
+  Diag(Loc, diag::warn_sme_streaming_pass_return_vl_to_non_streaming)
+  << /*IsArg=*/false;
+  }
 }
 
 FunctionType::ArmStateValue CalleeArmZAState =
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 452e00fa32b102..378615497b13cf 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ 

[clang] [Clang] Implement C++26 Attributes for Structured Bindings (P0609R3) (PR #89906)

2024-04-24 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)


Changes

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p0609r3.pdf

We support this feature in all language mode.
maybe_unused applied to a binding makes the whole declaration unused. There 
maybe something more clever to do here but that can be explored as a separate 
PR.

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


15 Files Affected:

- (modified) clang/docs/LanguageExtensions.rst (+1) 
- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/include/clang/Basic/Attr.td (+1-1) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+10) 
- (modified) clang/include/clang/Sema/DeclSpec.h (+6-4) 
- (modified) clang/include/clang/Sema/ParsedAttr.h (+1) 
- (modified) clang/lib/Frontend/InitPreprocessor.cpp (+1-1) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+31-10) 
- (modified) clang/lib/Sema/DeclSpec.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+2) 
- (modified) clang/test/Lexer/cxx-features.cpp (+1-1) 
- (modified) clang/test/Parser/cxx1z-decomposition.cpp (+30-8) 
- (modified) clang/test/SemaCXX/unused.cpp (+11-1) 
- (modified) clang/www/cxx_status.html (+1-1) 


``diff
diff --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 84fc4dee02fa80..49afd6c7f06bdd 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -1493,6 +1493,7 @@ Conditional ``explicit`` 
__cpp_conditional_explicit   C+
 ``if consteval`` __cpp_if_consteval   
C++23 C++20
 ``static operator()``__cpp_static_call_operator   
C++23 C++03
 Attributes on Lambda-Expressions  
C++23 C++11
+Attributes on Structured Bindings__cpp_structured_bindings
C++26 C++03
 ``= delete ("should have a reason");``   __cpp_deleted_function   
C++26 C++03
   
- -
 Designated initializers (N494)
C99   C89
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..8c8ded8cde0837 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -131,6 +131,8 @@ C++2c Feature Support
 
 - Implemented `P2573R2: = delete("should have a reason"); 
`_
 
+- Implemented `P0609R3: Attributes for Structured Bindings 
`_
+
 
 Resolutions to C++ Defect Reports
 ^
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 4408d517e70e58..97e06fe7d2e6aa 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3211,7 +3211,7 @@ def ObjCRequiresPropertyDefs : InheritableAttr {
 def Unused : InheritableAttr {
   let Spellings = [CXX11<"", "maybe_unused", 201603>, GCC<"unused">,
C23<"", "maybe_unused", 202106>];
-  let Subjects = SubjectList<[Var, ObjCIvar, Type, Enum, EnumConstant, Label,
+  let Subjects = SubjectList<[Var, Binding, ObjCIvar, Type, Enum, 
EnumConstant, Label,
   Field, ObjCMethod, FunctionLike]>;
   let Documentation = [WarnMaybeUnusedDocs];
 }
diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td 
b/clang/include/clang/Basic/DiagnosticParseKinds.td
index 38174cf3549f14..74ce0f8b53a48c 100644
--- a/clang/include/clang/Basic/DiagnosticParseKinds.td
+++ b/clang/include/clang/Basic/DiagnosticParseKinds.td
@@ -1056,11 +1056,21 @@ def ext_decl_attrs_on_lambda : ExtWarn<
 def ext_lambda_missing_parens : ExtWarn<
   "lambda without a parameter clause is a C++23 extension">,
   InGroup;
+
 def warn_cxx20_compat_decl_attrs_on_lambda : Warning<
   "%select{an attribute specifier sequence|%1}0 in this position "
   "is incompatible with C++ standards before C++23">,
   InGroup, DefaultIgnore;
 
+def ext_decl_attrs_on_binding : ExtWarn<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is a C++2c extension">, InGroup;
+
+def warn_cxx23_compat_decl_attrs_on_binding : Warning<
+  "an attribute specifier sequence attached to a structured binding 
declaration "
+  "is incompatible with C++ standards before C++2c">,
+  InGroup, DefaultIgnore;
+
 // C++17 lambda expressions
 def err_expected_star_this_capture : Error<
   "expected 'this' following '*' in lambda capture list">;
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index c9eecdafe62c7c..760c7980be52bd 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -36,6 +36,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"

[clang] [Driver] Restore compiler-rt arch suffix for PS and Windows (PR #89775)

2024-04-24 Thread Nico Weber via cfe-commits

nico wrote:

> My recollection of the past discussions is that we want users to switch to 
> the new hierarchy.

FWIW this doesn't match my understanding. phosek added the new hierarchy to 
Fuchsia, maskray put in some work to enable it elsewhere, but it's a huge 
headache, and we've forcibly turned it off on all platforms on our end. From 
what I can tell, it doesn't really solve any problems and causes all kinds of 
confusion. I wish the whole thing didn't exist.

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


[clang] [llvm] [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ tile to vector,… (PR #88499)

2024-04-24 Thread Momchil Velikov via cfe-commits


@@ -2832,6 +2832,23 @@ AArch64TargetLowering::EmitTileLoad(unsigned Opc, 
unsigned BaseReg,
   return BB;
 }
 
+MachineBasicBlock *
+AArch64TargetLowering::EmitTileMovaz(unsigned Opc, unsigned BaseReg,

momchil-velikov wrote:

This function looks almost identical to `EmitZAInstr`. It looks to me you can 
reuse `EmitZAInstr` (with a couple of small modifications) and then employ the 
`SMEPseudo2Instr` technique.
Then you won't need the switch cases starting at line 3012.

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


[clang] [llvm] [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ tile to vector,… (PR #88499)

2024-04-24 Thread Momchil Velikov via cfe-commits


@@ -104,6 +104,13 @@ class sme2_move_to_tile_pseudo
+: SMEPseudo2Instr,

momchil-velikov wrote:

This is not needed.

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


[clang] [llvm] [CLANG][LLVM][AArch64]Add SME2.1 intrinsics for MOVAZ tile to vector,… (PR #88499)

2024-04-24 Thread Momchil Velikov via cfe-commits

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


[clang] [Clang] [NFC] Prevent null pointer dereference in Sema::InstantiateFunctionDefinition (PR #89801)

2024-04-24 Thread via cfe-commits

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


[clang] e58dcf1 - [Clang] [NFC] Prevent null pointer dereference in Sema::InstantiateFunctionDefinition (#89801)

2024-04-24 Thread via cfe-commits

Author: smanna12
Date: 2024-04-24T08:41:51-05:00
New Revision: e58dcf135f3a6e453e7b123642675e39b8527f2d

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

LOG: [Clang] [NFC] Prevent null pointer dereference in 
Sema::InstantiateFunctionDefinition (#89801)

In the lambda function within
clang::Sema::InstantiateFunctionDefinition, the return value of a
function that may return null is now checked before dereferencing to
avoid potential null pointer dereference issues which can lead to
crashes or undefined behavior in the program.

Added: 


Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 787a485e0b2f8c..d544cfac55ba36 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5184,6 +5184,7 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
 
 ParmVarDecl *Parm = Function->getParamDecl(0);
 TypeSourceInfo *NewParmSI = IR.TransformType(Parm->getTypeSourceInfo());
+assert(NewParmSI && "Type transformation failed.");
 Parm->setType(NewParmSI->getType());
 Parm->setTypeSourceInfo(NewParmSI);
   };



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


[clang] [CMake] Change GCC_INSTALL_PREFIX from warning to fatal error (PR #85891)

2024-04-24 Thread Harmen Stoppels via cfe-commits

haampie wrote:

I disagree, `--gcc-install-dir` is sure an improvement over `--gcc-toolchain`, 
but they're both weaker than the compile time option `GCC_INSTALL_PREFIX` 
because of runtimes.

You're looking to remove `GCC_INSTALL_PREFIX`, then give a clear alternative 
that's equivalent. The current error message about config files is misleading 
since it potentially runtimes will use an undesired gcc version when they're 
built, which is rather opaque.

A different point: `flang-new` does not accept `--gcc-install-dir`. Is that an 
oversight?

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


[clang] [libcxx] [C++17] Support __GCC_[CON|DE]STRUCTIVE_SIZE (PR #89446)

2024-04-24 Thread Aaron Ballman via cfe-commits

AaronBallman wrote:

> I don't think this feature warrants deviating from our policy that on-by 
> default warnings should be actionable and have a low false-positive rate, nor 
> the complexity to actually produce the warning.

Specific to this point, what concerns me is that there are uses within header 
files that are reasonable so long as the project is built for the same target. 
For example, we have internal header files in Clang and LLVM that could 
potentially make use of this; those headers are not exposed as part of our 
library interfaces, but we'd get these warnings and they would be false 
positives which would encourage us to disable the warning. So it's worth 
keeping in mind that there are false positives with this as well as true 
positives and I don't know of a good way to tell them apart aside from cross-TU 
checking like what is done with sanitizers.

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