[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-29 Thread Matheus Izvekov via cfe-commits

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


[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-29 Thread Matheus Izvekov via cfe-commits

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

Small nit, otherwise after you address @efriedma-quic 's concerns, this LGTM.

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


[clang] [libcxx] [clang] Preserve Qualifiers and type sugar in TemplateNames (PR #93433)

2024-05-29 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] Improve ast-dumper text printing of TemplateArgument (PR #93431)

2024-05-29 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] fix printing of canonical template template parameters take 2 (PR #93448)

2024-05-29 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/93448

>From 4ed34c959afa51328102ec037b418dbfc84ab063 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 27 May 2024 05:51:18 -0300
Subject: [PATCH] [clang] fix printing of canonical template template
 parameters take 2

Since they can also occur as the template name of
template specializations, handle them from TemplateName
printing instead of TemplateArgument.
---
 clang/lib/AST/TemplateBase.cpp  | 11 +--
 clang/lib/AST/TemplateName.cpp  | 14 ++
 clang/test/SemaTemplate/deduction-guide.cpp | 10 +-
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/clang/lib/AST/TemplateBase.cpp b/clang/lib/AST/TemplateBase.cpp
index 6d3c843cfd29e..46f7b79b272ef 100644
--- a/clang/lib/AST/TemplateBase.cpp
+++ b/clang/lib/AST/TemplateBase.cpp
@@ -544,16 +544,7 @@ void TemplateArgument::print(const PrintingPolicy , 
raw_ostream ,
 break;
 
   case Template: {
-TemplateName TN = getAsTemplate();
-if (const auto *TD = TN.getAsTemplateDecl();
-TD && TD->getDeclName().isEmpty()) {
-  assert(isa(TD) &&
- "Unexpected anonymous template");
-  const auto *TTP = cast(TD);
-  Out << "template-parameter-" << TTP->getDepth() << "-" << 
TTP->getIndex();
-} else {
-  TN.print(Out, Policy);
-}
+getAsTemplate().print(Out, Policy);
 break;
   }
 
diff --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index 3aae998eceeb0..3dbdad92813f6 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -292,6 +292,14 @@ void TemplateName::Profile(llvm::FoldingSetNodeID ) {
 
 void TemplateName::print(raw_ostream , const PrintingPolicy ,
  Qualified Qual) const {
+  auto handleAnonymousTTP = [](TemplateDecl *TD, raw_ostream ) {
+if (TemplateTemplateParmDecl *TTP = dyn_cast(TD);
+TTP && TTP->getIdentifier() == nullptr) {
+  OS << "template-parameter-" << TTP->getDepth() << "-" << TTP->getIndex();
+  return true;
+}
+return false;
+  };
   if (NameKind Kind = getKind();
   Kind == TemplateName::Template || Kind == TemplateName::UsingTemplate) {
 // After `namespace ns { using std::vector }`, what is the fully-qualified
@@ -304,6 +312,8 @@ void TemplateName::print(raw_ostream , const 
PrintingPolicy ,
 // names more often than to export them, thus using the original name is
 // most useful in this case.
 TemplateDecl *Template = getAsTemplateDecl();
+if (handleAnonymousTTP(Template, OS))
+  return;
 if (Qual == Qualified::None)
   OS << *Template;
 else
@@ -320,6 +330,10 @@ void TemplateName::print(raw_ostream , const 
PrintingPolicy ,
Underlying.getKind() == TemplateName::UsingTemplate);
 
 TemplateDecl *UTD = Underlying.getAsTemplateDecl();
+
+if (handleAnonymousTTP(UTD, OS))
+  return;
+
 if (IdentifierInfo *II = UTD->getIdentifier();
 Policy.CleanUglifiedParameters && II &&
 isa(UTD))
diff --git a/clang/test/SemaTemplate/deduction-guide.cpp 
b/clang/test/SemaTemplate/deduction-guide.cpp
index 96b4cd9622a24..100b580fe9f02 100644
--- a/clang/test/SemaTemplate/deduction-guide.cpp
+++ b/clang/test/SemaTemplate/deduction-guide.cpp
@@ -315,19 +315,19 @@ namespace TTP {
 // CHECK-NEXT:  |-TemplateTypeParmDecl {{.+}} class depth 0 index 0 T{{$}}
 // CHECK-NEXT:  |-TemplateTemplateParmDecl {{.+}} depth 0 index 1 TT{{$}}
 // CHECK-NEXT:  | `-TemplateTypeParmDecl {{.+}} class depth 1 index 0{{$}}
-// CHECK-NEXT:  |-CXXDeductionGuideDecl {{.+}} 'auto () -> B'{{$}}
-// CHECK-NEXT:  | `-ParmVarDecl {{.+}} ''{{$}}
+// CHECK-NEXT:  |-CXXDeductionGuideDecl {{.+}} 'auto 
(template-parameter-0-1) -> B'{{$}}
+// CHECK-NEXT:  | `-ParmVarDecl {{.+}} 'template-parameter-0-1'{{$}}
 // CHECK-NEXT:  `-CXXDeductionGuideDecl {{.+}} 'auto (A) -> TTP::B'
 // CHECK-NEXT:|-TemplateArgument type 'int'
 // CHECK-NEXT:| `-BuiltinType {{.+}} 'int'{{$}}
 // CHECK-NEXT:|-TemplateArgument template 'TTP::A'{{$}}
 // CHECK-NEXT:| `-ClassTemplateDecl {{.+}} A{{$}}
 // CHECK-NEXT:`-ParmVarDecl {{.+}} 'A':'TTP::A'{{$}}
-// CHECK-NEXT:  FunctionProtoType {{.+}} 'auto () -> B' dependent 
trailing_return cdecl{{$}}
+// CHECK-NEXT:  FunctionProtoType {{.+}} 'auto (template-parameter-0-1) -> 
B' dependent trailing_return cdecl{{$}}
 // CHECK-NEXT:  |-InjectedClassNameType {{.+}} 'B' dependent{{$}}
 // CHECK-NEXT:  | `-CXXRecord {{.+}} 'B'{{$}}
-// CHECK-NEXT:  `-ElaboratedType {{.+}} '' sugar dependent{{$}}
-// CHECK-NEXT:`-TemplateSpecializationType {{.+}} '' dependent {{$}}
+// CHECK-NEXT:  `-ElaboratedType {{.+}} 'template-parameter-0-1' sugar 
dependent{{$}}
+// CHECK-NEXT:`-TemplateSpecializationType {{.+}} 
'template-parameter-0-1' dependent template-parameter-0-1{{$}}
 // CHECK-NEXT:  `-TemplateArgument type 'T':'type-parameter-0-0'{{$}}
 // CHECK-NEXT:

[clang] [libcxx] [clang] Preserve Qualifiers and type sugar in TemplateNames (PR #93433)

2024-05-29 Thread Matheus Izvekov via cfe-commits

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


[clang] [libcxx] [clang] fix printing of canonical template template parameters take 2 (PR #93448)

2024-05-29 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] Fix a crash when a variable is captured by a block nested inside a lambda (PR #93749)

2024-05-30 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov commented:

I see it stops crashing, but is it actually working now?

Why `hasInit` returns true, but the variable doesn't actually have an 
initializer?
Shouldn't the fix go there?

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


[clang] [Clang][Sema] Diagnose variable template explicit specializations with storage-class-specifiers (PR #93873)

2024-05-30 Thread Matheus Izvekov via cfe-commits


@@ -3541,6 +3541,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier 
AS, Declarator ,
 
 IdentifierInfo *II = Name.getAsIdentifierInfo();
 
+#if 0

mizvekov wrote:

Leftover

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


[clang] [Clang][Sema] Diagnose variable template explicit specializations with storage-class-specifiers (PR #93873)

2024-05-30 Thread Matheus Izvekov via cfe-commits


@@ -3561,6 +3562,7 @@ Sema::ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier 
AS, Declarator ,
   }
   return nullptr;
 }
+#endif

mizvekov wrote:

Leftover

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


[clang] [Clang][Sema] Diagnose variable template explicit specializations with storage-class-specifiers (PR #93873)

2024-05-30 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov commented:

Interestingly, only GCC errors on a case like this:

```
namespace {
  template int A = 0;
}
template<> int A = 0;
```

https://godbolt.org/z/TTjssKxz5

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


[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)

2024-05-21 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/92852

>From 984ac614f6d6e3196961690fa957df6a03f37782 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 20 May 2024 00:39:55 -0300
Subject: [PATCH] [clang] NFCI: use TemplateArgumentLoc for NTTP
 DefaultArgument

This is an enabler for a future patch.
---
 clang-tools-extra/clangd/Hover.cpp|  3 +-
 clang/include/clang/AST/ASTNodeTraverser.h|  6 +--
 clang/include/clang/AST/DeclTemplate.h| 11 +++--
 clang/include/clang/AST/RecursiveASTVisitor.h |  2 +-
 clang/lib/AST/ASTContext.cpp  |  6 ++-
 clang/lib/AST/ASTDiagnostic.cpp   |  2 +-
 clang/lib/AST/ASTImporter.cpp |  5 +-
 clang/lib/AST/DeclPrinter.cpp |  4 +-
 clang/lib/AST/DeclTemplate.cpp| 15 --
 clang/lib/AST/JSONNodeDumper.cpp  |  2 +-
 clang/lib/AST/ODRDiagsEmitter.cpp |  7 ++-
 clang/lib/AST/ODRHash.cpp |  2 +-
 clang/lib/AST/TypePrinter.cpp |  5 +-
 clang/lib/ExtractAPI/DeclarationFragments.cpp |  5 +-
 clang/lib/Index/IndexDecl.cpp |  3 +-
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 10 ++--
 clang/lib/Sema/SemaTemplate.cpp   | 46 +--
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 10 ++--
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  7 +--
 clang/lib/Serialization/ASTReaderDecl.cpp |  3 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  2 +-
 clang/test/AST/ast-dump-decl.cpp  |  4 +-
 clang/test/SemaTemplate/deduction-guide.cpp   |  6 +--
 clang/tools/libclang/CIndex.cpp   |  5 +-
 clang/unittests/AST/ASTImporterTest.cpp   |  2 +-
 25 files changed, 99 insertions(+), 74 deletions(-)

diff --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 2ec0994e846e9..de103e011c708 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -262,7 +262,8 @@ fetchTemplateParameters(const TemplateParameterList *Params,
   if (NTTP->hasDefaultArgument()) {
 P.Default.emplace();
 llvm::raw_string_ostream Out(*P.Default);
-NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP);
+NTTP->getDefaultArgument().getArgument().print(PP, Out,
+   /*IncludeType=*/false);
   }
 } else if (const auto *TTPD = dyn_cast(Param)) {
   P.Type = printType(TTPD, PP);
diff --git a/clang/include/clang/AST/ASTNodeTraverser.h 
b/clang/include/clang/AST/ASTNodeTraverser.h
index 98db1cb578990..616f92691ec32 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -704,9 +704,9 @@ class ASTNodeTraverser
 if (const auto *E = D->getPlaceholderTypeConstraint())
   Visit(E);
 if (D->hasDefaultArgument())
-  Visit(D->getDefaultArgument(), SourceRange(),
-D->getDefaultArgStorage().getInheritedFrom(),
-D->defaultArgumentWasInherited() ? "inherited from" : "previous");
+  dumpTemplateArgumentLoc(
+  D->getDefaultArgument(), 
D->getDefaultArgStorage().getInheritedFrom(),
+  D->defaultArgumentWasInherited() ? "inherited from" : "previous");
   }
 
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) {
diff --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 07b08b5ed43ca..5b6a6b40b28ef 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -1360,7 +1360,8 @@ class NonTypeTemplateParmDecl final
 
   /// The default template argument, if any, and whether or not
   /// it was inherited.
-  using DefArgStorage = DefaultArgStorage;
+  using DefArgStorage =
+  DefaultArgStorage;
   DefArgStorage DefaultArgument;
 
   // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index
@@ -1430,7 +1431,10 @@ class NonTypeTemplateParmDecl final
   bool hasDefaultArgument() const { return DefaultArgument.isSet(); }
 
   /// Retrieve the default argument, if any.
-  Expr *getDefaultArgument() const { return DefaultArgument.get(); }
+  const TemplateArgumentLoc () const {
+static const TemplateArgumentLoc NoneLoc;
+return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc;
+  }
 
   /// Retrieve the location of the default argument, if any.
   SourceLocation getDefaultArgumentLoc() const;
@@ -1444,7 +1448,8 @@ class NonTypeTemplateParmDecl final
   /// Set the default argument for this template parameter, and
   /// whether that default argument was inherited from another
   /// declaration.
-  void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); }
+  void setDefaultArgument(const ASTContext ,
+  const TemplateArgumentLoc );
   void setInheritedDefaultArgument(const ASTContext ,

[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (PR #92854)

2024-05-21 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/92854

>From 142c3f394e1b34dcefcaf0887a6fd4711b78eeb3 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 20 May 2024 16:30:46 -0300
Subject: [PATCH] [clang] NFCI: use TemplateArgumentLoc for type-param
 DefaultArgument

This is an enabler for a future patch.
---
 .../ForwardingReferenceOverloadCheck.cpp  |  4 +-
 .../bugprone/IncorrectEnableIfCheck.cpp   |  5 +-
 .../modernize/UseConstraintsCheck.cpp |  8 ++-
 clang-tools-extra/clangd/Hover.cpp|  8 ++-
 clang/include/clang/AST/ASTNodeTraverser.h|  2 +-
 clang/include/clang/AST/DeclTemplate.h| 17 ++---
 clang/include/clang/AST/RecursiveASTVisitor.h |  2 +-
 clang/include/clang/Sema/Sema.h   |  4 +-
 clang/lib/AST/ASTContext.cpp  |  3 +-
 clang/lib/AST/ASTImporter.cpp |  6 +-
 clang/lib/AST/DeclPrinter.cpp |  3 +-
 clang/lib/AST/DeclTemplate.cpp| 17 +++--
 clang/lib/AST/JSONNodeDumper.cpp  |  2 +-
 clang/lib/AST/ODRDiagsEmitter.cpp | 12 ++--
 clang/lib/AST/ODRHash.cpp |  2 +-
 clang/lib/AST/TypePrinter.cpp |  4 +-
 clang/lib/ExtractAPI/DeclarationFragments.cpp |  8 +--
 clang/lib/Index/IndexDecl.cpp |  3 +-
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 48 +++--
 clang/lib/Sema/SemaTemplate.cpp   | 69 ++-
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 10 +--
 clang/lib/Sema/SemaTemplateInstantiate.cpp| 11 +--
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  9 ++-
 clang/lib/Serialization/ASTReaderDecl.cpp |  3 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  2 +-
 clang/tools/libclang/CIndex.cpp   |  7 +-
 clang/unittests/AST/ASTImporterTest.cpp   |  2 +-
 27 files changed, 144 insertions(+), 127 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
index 36687a8e761e8..c87b3ea7e2616 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
@@ -54,7 +54,9 @@ AST_MATCHER(QualType, isEnableIf) {
 AST_MATCHER_P(TemplateTypeParmDecl, hasDefaultArgument,
   clang::ast_matchers::internal::Matcher, TypeMatcher) {
   return Node.hasDefaultArgument() &&
- TypeMatcher.matches(Node.getDefaultArgument(), Finder, Builder);
+ TypeMatcher.matches(
+ Node.getDefaultArgument().getArgument().getAsType(), Finder,
+ Builder);
 }
 AST_MATCHER(TemplateDecl, hasAssociatedConstraints) {
   return Node.hasAssociatedConstraints();
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp
index 09aaf3e31d5dd..75f1107904fce 100644
--- a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp
@@ -19,10 +19,11 @@ namespace {
 AST_MATCHER_P(TemplateTypeParmDecl, hasUnnamedDefaultArgument,
   ast_matchers::internal::Matcher, InnerMatcher) {
   if (Node.getIdentifier() != nullptr || !Node.hasDefaultArgument() ||
-  Node.getDefaultArgumentInfo() == nullptr)
+  Node.getDefaultArgument().getArgument().isNull())
 return false;
 
-  TypeLoc DefaultArgTypeLoc = Node.getDefaultArgumentInfo()->getTypeLoc();
+  TypeLoc DefaultArgTypeLoc =
+  Node.getDefaultArgument().getTypeSourceInfo()->getTypeLoc();
   return InnerMatcher.matches(DefaultArgTypeLoc, Finder, Builder);
 }
 
diff --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
index 7a021fe14436a..ea4d99586c711 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
@@ -177,9 +177,11 @@ matchTrailingTemplateParam(const FunctionTemplateDecl 
*FunctionTemplate) {
   dyn_cast(LastParam)) {
 if (LastTemplateParam->hasDefaultArgument() &&
 LastTemplateParam->getIdentifier() == nullptr) {
-  return {matchEnableIfSpecialization(
-  LastTemplateParam->getDefaultArgumentInfo()->getTypeLoc()),
-  LastTemplateParam};
+  return {
+  matchEnableIfSpecialization(LastTemplateParam->getDefaultArgument()
+  .getTypeSourceInfo()
+  ->getTypeLoc()),
+  LastTemplateParam};
 }
   }
   return {};
diff --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 06b949bc4a2b5..2ec0994e846e9 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -247,8 +247,12 @@ 

[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)

2024-05-21 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/92852

>From 229cb63b95bb3b0db8d73947a40dede945b8b378 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 20 May 2024 00:39:55 -0300
Subject: [PATCH] [clang] NFCI: use TemplateArgumentLoc for NTTP
 DefaultArgument

This is an enabler for a future patch.
---
 clang-tools-extra/clangd/Hover.cpp|  3 +-
 clang/include/clang/AST/ASTNodeTraverser.h|  6 +--
 clang/include/clang/AST/DeclTemplate.h| 11 +++--
 clang/include/clang/AST/RecursiveASTVisitor.h |  2 +-
 clang/lib/AST/ASTContext.cpp  |  6 ++-
 clang/lib/AST/ASTDiagnostic.cpp   |  2 +-
 clang/lib/AST/ASTImporter.cpp |  5 +-
 clang/lib/AST/DeclPrinter.cpp |  4 +-
 clang/lib/AST/DeclTemplate.cpp| 15 --
 clang/lib/AST/JSONNodeDumper.cpp  |  2 +-
 clang/lib/AST/ODRDiagsEmitter.cpp |  7 ++-
 clang/lib/AST/ODRHash.cpp |  2 +-
 clang/lib/AST/TypePrinter.cpp |  5 +-
 clang/lib/ExtractAPI/DeclarationFragments.cpp |  5 +-
 clang/lib/Index/IndexDecl.cpp |  3 +-
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 10 ++--
 clang/lib/Sema/SemaTemplate.cpp   | 46 +--
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 10 ++--
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  7 +--
 clang/lib/Serialization/ASTReaderDecl.cpp |  3 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  2 +-
 clang/test/AST/ast-dump-decl.cpp  |  4 +-
 clang/test/SemaTemplate/deduction-guide.cpp   |  6 +--
 clang/tools/libclang/CIndex.cpp   |  5 +-
 clang/unittests/AST/ASTImporterTest.cpp   |  2 +-
 25 files changed, 99 insertions(+), 74 deletions(-)

diff --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 2ec0994e846e9..de103e011c708 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -262,7 +262,8 @@ fetchTemplateParameters(const TemplateParameterList *Params,
   if (NTTP->hasDefaultArgument()) {
 P.Default.emplace();
 llvm::raw_string_ostream Out(*P.Default);
-NTTP->getDefaultArgument()->printPretty(Out, nullptr, PP);
+NTTP->getDefaultArgument().getArgument().print(PP, Out,
+   /*IncludeType=*/false);
   }
 } else if (const auto *TTPD = dyn_cast(Param)) {
   P.Type = printType(TTPD, PP);
diff --git a/clang/include/clang/AST/ASTNodeTraverser.h 
b/clang/include/clang/AST/ASTNodeTraverser.h
index 98db1cb578990..616f92691ec32 100644
--- a/clang/include/clang/AST/ASTNodeTraverser.h
+++ b/clang/include/clang/AST/ASTNodeTraverser.h
@@ -704,9 +704,9 @@ class ASTNodeTraverser
 if (const auto *E = D->getPlaceholderTypeConstraint())
   Visit(E);
 if (D->hasDefaultArgument())
-  Visit(D->getDefaultArgument(), SourceRange(),
-D->getDefaultArgStorage().getInheritedFrom(),
-D->defaultArgumentWasInherited() ? "inherited from" : "previous");
+  dumpTemplateArgumentLoc(
+  D->getDefaultArgument(), 
D->getDefaultArgStorage().getInheritedFrom(),
+  D->defaultArgumentWasInherited() ? "inherited from" : "previous");
   }
 
   void VisitTemplateTemplateParmDecl(const TemplateTemplateParmDecl *D) {
diff --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 07b08b5ed43ca..5b6a6b40b28ef 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -1360,7 +1360,8 @@ class NonTypeTemplateParmDecl final
 
   /// The default template argument, if any, and whether or not
   /// it was inherited.
-  using DefArgStorage = DefaultArgStorage;
+  using DefArgStorage =
+  DefaultArgStorage;
   DefArgStorage DefaultArgument;
 
   // FIXME: Collapse this into TemplateParamPosition; or, just move depth/index
@@ -1430,7 +1431,10 @@ class NonTypeTemplateParmDecl final
   bool hasDefaultArgument() const { return DefaultArgument.isSet(); }
 
   /// Retrieve the default argument, if any.
-  Expr *getDefaultArgument() const { return DefaultArgument.get(); }
+  const TemplateArgumentLoc () const {
+static const TemplateArgumentLoc NoneLoc;
+return DefaultArgument.isSet() ? *DefaultArgument.get() : NoneLoc;
+  }
 
   /// Retrieve the location of the default argument, if any.
   SourceLocation getDefaultArgumentLoc() const;
@@ -1444,7 +1448,8 @@ class NonTypeTemplateParmDecl final
   /// Set the default argument for this template parameter, and
   /// whether that default argument was inherited from another
   /// declaration.
-  void setDefaultArgument(Expr *DefArg) { DefaultArgument.set(DefArg); }
+  void setDefaultArgument(const ASTContext ,
+  const TemplateArgumentLoc );
   void setInheritedDefaultArgument(const ASTContext ,

[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)

2024-05-21 Thread Matheus Izvekov via cfe-commits

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits


@@ -720,7 +720,7 @@ Parser::DeclGroupPtrTy Parser::ParseUsingDeclaration(
   return nullptr;
 }
 CXXScopeSpec SS;
-if (ParseOptionalCXXScopeSpecifier(SS, /*ParsedType=*/nullptr,
+if (ParseOptionalCXXScopeSpecifier(SS, /*ObjectType=*/nullptr,

mizvekov wrote:

Land this cleanup separately as well.

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits


@@ -397,22 +397,32 @@ NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, 
NestedNameSpecifier *NNS) {
   while (NNS->getPrefix())
 NNS = NNS->getPrefix();
 
-  if (NNS->getKind() != NestedNameSpecifier::Identifier)
-return nullptr;
-
-  LookupResult Found(*this, NNS->getAsIdentifier(), SourceLocation(),
- LookupNestedNameSpecifierName);
+  // FIXME: This is a rather nasty hack! Ideally we should get the results
+  // from LookupTemplateName/BuildCXXNestedNameSpecifier.
+  const IdentifierInfo *II = NNS->getAsIdentifier();
+  if (!II) {
+if (const auto *DTST =
+dyn_cast_if_present(
+NNS->getAsType()))
+  II = DTST->getIdentifier();
+else
+  return nullptr;
+  }

mizvekov wrote:

I am not sure why you think this is a nasty hack, this looks legitimate to me.

I think this looks ugly because of the lack of a NNS kind for an Identifier 
with template arguments, so we abuse a type kind storing a 
DependentTemplateSpecializationType with no qualifier.

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits


@@ -55,15 +55,21 @@ namespace PR11856 {
 
   template T *end(T*);
 
-  class X { };
+  struct X { };
+  struct Y {
+int end;
+  };
   template 
   void Foo2() {
 T it1;
-if (it1->end < it1->end) {
-}
+if (it1->end < it1->end) { }
 
 X *x;
-if (x->end < 7) {  // expected-error{{no member named 'end' in 
'PR11856::X'}}
-}
+if (x->end < 7) { } // expected-error{{expected '>'}}
+// expected-note@-1{{to match this '<'}}
+// expected-error@-2{{expected unqualified-id}}

mizvekov wrote:

This doesn't look expected to me, what is going on?

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits


@@ -2893,6 +2893,8 @@ class TreeTransform {
 
 CXXScopeSpec SS;
 SS.Adopt(QualifierLoc);
+if (FirstQualifierInScope)
+  SS.setFoundFirstQualifierInScope(FirstQualifierInScope);

mizvekov wrote:

It looks like adding 'FirstQualifierInScope' as a property to SS makes it so 
keeping and passing both around is redundant.

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits


@@ -47,8 +47,8 @@ template
 void DerivedT::Inner() {
   Derived1T::Foo();
   Derived2T::Member = 42;
-  this->Derived1T::Foo();
-  this->Derived2T::Member = 42;
+  this->Derived1T::Foo(); // expected-error{{use 'template' keyword to 
treat 'Derived1T' as a dependent template name}}
+  this->Derived2T::Member = 42; // expected-error{{use 'template' keyword 
to treat 'Derived2T' as a dependent template name}}

mizvekov wrote:

This is an access control test:
```suggestion
  this->template Derived1T::Foo();
  this->template Derived2T::Member = 42;
```

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits


@@ -6891,7 +6891,7 @@ class Sema final : public SemaBase {
   const TemplateArgumentListInfo *TemplateArgs);
 
   ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc,
-   tok::TokenKind OpKind, CXXScopeSpec ,
+   bool IsArrow, CXXScopeSpec ,

mizvekov wrote:

You could land this refactoring straight away on an NFC commit, to clean up for 
the review a bit.

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov commented:

I think overall this looks like the right direction to me.

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


[clang] [Clang] Implement resolution for CWG1835 (PR #92957)

2024-05-21 Thread Matheus Izvekov via cfe-commits


@@ -618,7 +618,6 @@ namespace cwg141 { // cwg141: 3.1
 // FIXME: we issue a useful diagnostic first, then some bogus ones.

mizvekov wrote:

It looks like this FIXME is fixed as per change below.

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


[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (PR #92854)

2024-05-21 Thread Matheus Izvekov via cfe-commits

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


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

2024-05-21 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for type-param DefaultArgument (PR #92854)

2024-05-21 Thread Matheus Izvekov via cfe-commits

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


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

2024-05-22 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang-tools-extra] [clang] NFCI: use TemplateArgumentLoc for NTTP DefaultArgument (PR #92852)

2024-05-22 Thread Matheus Izvekov via cfe-commits

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


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

2024-05-23 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

> Heads up: this commit has triggered some weird errors for a compile, but only 
> when clang header modules are enabled. 
> That seems to _probably_ indicate a bug in this commit (presumably related to 
> AST serialization or deserialization?), but I don't have a test-case, and, 
> that's harder to get for issues that only arise with modules enabled...

Thanks for the heads-up, James.

Indeed, and it's not only modules, our tooling for reducing test cases is 
getting less and less effective.

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


[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-23 Thread Matheus Izvekov via cfe-commits


@@ -3833,6 +3833,11 @@ def note_cannot_use_trivial_abi_reason : Note<
   "it is polymorphic|"
   "it has a base of a non-trivial class type|it has a virtual base|"
   "it has a __weak field|it has a field of a non-trivial class type}1">;
+def warn_ppc_musttail_maybe_ignored: Warning<
+  "'musttail' attribute may be ignored on ppc targets">,
+  InGroup;

mizvekov wrote:

musttail can't be ignored with just a warning: This is a promise by the 
implementation, and this is not just an optimization, it is often required to 
get correct behavior on code that relies on it.

I expect this will lead to crashes due to stack exhaustion in such programs, or 
other UB with assembly interop.

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


[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-23 Thread Matheus Izvekov via cfe-commits

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


[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-23 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov requested changes to this pull request.


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


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

2024-05-23 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

Thanks for the heads up, this does look like a problem. I am reverting it for 
now.

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


[clang] [clang] Avoid crash due to unimplemented StructuralValue support in the template differ (PR #93265)

2024-05-23 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/93265

This was not implemented in https://github.com/llvm/llvm-project/pull/78041 
when StructuralValue TemplateArguments were originally added.

This patch does not implement this functionality, it just falls back to the 
expression when possible.

Otherwise, such as when dealing with canonical types to begin with, this will 
just ignore the argument as if it wasn't even there.

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

>From c7a056d39dd4148cc8872e8ca136a9f9525ff654 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 23 May 2024 21:23:21 -0300
Subject: [PATCH] [clang] Avoid crash due to unimplemented StructuralValue
 support in the template differ

This was not implemented in https://github.com/llvm/llvm-project/pull/78041

This patch does not implement this fucntionality, it just falls back to the 
expression
when possible.

Otherwise, such as when dealing with canonical types to begin with,
this will just ignore the argument as if it wasn't even there.

Fixes https://github.com/llvm/llvm-project/issues/93068
---
 clang/docs/ReleaseNotes.rst   |   1 +
 clang/lib/AST/ASTDiagnostic.cpp   | 106 +++---
 ...ng.cpp => diag-template-diffing-cxx11.cpp} |   0
 .../test/Misc/diag-template-diffing-cxx26.cpp |  49 
 4 files changed, 114 insertions(+), 42 deletions(-)
 rename clang/test/Misc/{diag-template-diffing.cpp => 
diag-template-diffing-cxx11.cpp} (100%)
 create mode 100644 clang/test/Misc/diag-template-diffing-cxx26.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7bcdee96e213e..6e8687fadc6f7 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -790,6 +790,7 @@ Miscellaneous Clang Crashes Fixed
 
 - Do not attempt to dump the layout of dependent types or invalid declarations
   when ``-fdump-record-layouts-complete`` is passed. Fixes #GH83684.
+- Unhandled StructuralValues in the template differ (#GH93068).
 
 OpenACC Specific Changes
 
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 91bc1b22acfc7..7e4a5709a44ce 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -1215,46 +1215,19 @@ class TemplateDiff {
  bool ) {
 if (!Iter.isEnd()) {
   switch (Iter->getKind()) {
-default:
-  llvm_unreachable("unknown ArgumentKind");
-case TemplateArgument::Integral:
-  Value = Iter->getAsIntegral();
-  HasInt = true;
-  IntType = Iter->getIntegralType();
-  return;
-case TemplateArgument::Declaration: {
-  VD = Iter->getAsDecl();
-  QualType ArgType = Iter->getParamTypeForDecl();
-  QualType VDType = VD->getType();
-  if (ArgType->isPointerType() &&
-  Context.hasSameType(ArgType->getPointeeType(), VDType))
-NeedAddressOf = true;
-  return;
-}
-case TemplateArgument::NullPtr:
-  IsNullPtr = true;
-  return;
-case TemplateArgument::Expression:
-  E = Iter->getAsExpr();
-  }
-} else if (!Default->isParameterPack()) {
-  E = Default->getDefaultArgument().getArgument().getAsExpr();
-}
-
-if (!Iter.hasDesugaredTA()) return;
-
-const TemplateArgument& TA = Iter.getDesugaredTA();
-switch (TA.getKind()) {
-  default:
-llvm_unreachable("unknown ArgumentKind");
+  case TemplateArgument::StructuralValue:
+// FIXME: Diffing of structural values is not implemented.
+// There is no possible fallback in this case, this will show up
+// as '(no argument)'.
+return;
   case TemplateArgument::Integral:
-Value = TA.getAsIntegral();
+Value = Iter->getAsIntegral();
 HasInt = true;
-IntType = TA.getIntegralType();
+IntType = Iter->getIntegralType();
 return;
   case TemplateArgument::Declaration: {
-VD = TA.getAsDecl();
-QualType ArgType = TA.getParamTypeForDecl();
+VD = Iter->getAsDecl();
+QualType ArgType = Iter->getParamTypeForDecl();
 QualType VDType = VD->getType();
 if (ArgType->isPointerType() &&
 Context.hasSameType(ArgType->getPointeeType(), VDType))
@@ -1265,13 +1238,62 @@ class TemplateDiff {
 IsNullPtr = true;
 return;
   case TemplateArgument::Expression:
-// TODO: Sometimes, the desugared template argument Expr differs from
-// the sugared template argument Expr.  It may be useful in the future
-// but for now, it is just discarded.
-if (!E)
-  E = TA.getAsExpr();
-return;
+E = Iter->getAsExpr();
+break;
+  case TemplateArgument::Null:
+  case TemplateArgument::Type:
+  case TemplateArgument::Template:
+  case 

[clang] [clang-tools-extra] [lldb] [c++20] P1907R1: Support for generalized non-type template arguments of scalar type. (PR #78041)

2024-05-23 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

This missed adding support to StructuralValue template arguments to the 
template differ.

See https://github.com/llvm/llvm-project/pull/93265

Te support is still missing, we are just avoiding the crash for now.

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


[clang] Revert "[clang] Implement CWG2398 provisional TTP matching to class templates" (PR #93258)

2024-05-23 Thread Matheus Izvekov via cfe-commits

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


[clang] Revert "[clang] Implement CWG2398 provisional TTP matching to class templates" (PR #93258)

2024-05-23 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/93258

Reverts llvm/llvm-project#92855

This is causing issues, there are still being reduced, but does look like a 
problem.

>From 8871ef58ece10234b8cd97c5e7199dee7d7a8b08 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 23 May 2024 21:30:43 -0300
Subject: [PATCH] =?UTF-8?q?Revert=20"[clang]=20Implement=20CWG2398=20provi?=
 =?UTF-8?q?sional=20TTP=20matching=20to=20class=20templates=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit ff3f41deb04c03ba57658776e4e0dc26ef01187d.
---
 clang/lib/Sema/SemaTemplate.cpp   |  5 +-
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 76 ---
 .../CXX/temp/temp.decls/temp.alias/p2.cpp |  5 +-
 clang/test/SemaTemplate/cwg2398.cpp   |  3 +
 4 files changed, 36 insertions(+), 53 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 268f079980a6c..39e9dbed0c3e0 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1807,8 +1807,6 @@ static void SetNestedNameSpecifier(Sema , TagDecl *T,
 // Returns the template parameter list with all default template argument
 // information.
 static TemplateParameterList *GetTemplateParameterList(TemplateDecl *TD) {
-  if (TD->isImplicit())
-return TD->getTemplateParameters();
   // Make sure we get the template parameter list from the most
   // recent declaration, since that is the only one that is guaranteed to
   // have all the default template argument information.
@@ -1829,8 +1827,7 @@ static TemplateParameterList 
*GetTemplateParameterList(TemplateDecl *TD) {
   //template  friend struct C;
   //  };
   //  template struct S;
-  while ((D->isImplicit() ||
-  D->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None) &&
+  while (D->getFriendObjectKind() != Decl::FriendObjectKind::FOK_None &&
  D->getPreviousDecl())
 D = D->getPreviousDecl();
   return cast(D)->getTemplateParameters();
diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 08a69d3cb2589..f9ec34163e656 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -527,8 +527,8 @@ static NamedDecl *getTemplateParameterWithDefault(Sema , 
NamedDecl *A,
 R->setDefaultArgument(
 S.Context,
 S.getTrivialTemplateArgumentLoc(Default, QualType(), 
SourceLocation()));
-if (T->hasTypeConstraint()) {
-  auto *C = T->getTypeConstraint();
+if (R->hasTypeConstraint()) {
+  auto *C = R->getTypeConstraint();
   R->setTypeConstraint(C->getConceptReference(),
C->getImmediatelyDeclaredConstraint());
 }
@@ -583,53 +583,37 @@ DeduceTemplateArguments(Sema , TemplateParameterList 
*TemplateParams,
   return TemplateDeductionResult::Success;
 
 auto NewDeduced = DeducedTemplateArgument(Arg);
-// Provisional resolution for CWG2398: If Arg names a template
-// specialization, then we deduce a synthesized template template parameter
-// based on A, but using the TS's arguments as defaults.
-if (DefaultArguments.size() != 0) {
+// 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);
-  TemplateDecl *TempArg = Arg.getAsTemplateDecl();
+  assert(!TempArg->isExpandedParameterPack());
+
   TemplateParameterList *As = TempArg->getTemplateParameters();
-  assert(DefaultArguments.size() <= As->size());
-
-  SmallVector Params(As->size());
-  for (unsigned I = 0; I < DefaultArguments.size(); ++I)
-Params[I] = getTemplateParameterWithDefault(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.
-  auto *TPL = TemplateParameterList::Create(
-  S.Context, SourceLocation(), SourceLocation(), Params,
-  SourceLocation(), As->getRequiresClause());
-
-  TemplateDecl *TD;
-  switch (TempArg->getKind()) {
-  case Decl::TemplateTemplateParm: {
-auto *A = cast(TempArg);
-assert(!A->isExpandedParameterPack());
-TD = TemplateTemplateParmDecl::Create(
-S.Context, A->getDeclContext(), SourceLocation(), A->getDepth(),
-A->getPosition(), 

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

2024-05-23 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

I figured a reproducer based on your hints:

```C++
template struct A {};

template class TT> auto f(TT a) { return a; }

A v1;
A v2;

using X = decltype(f(v1));
using Y = decltype(f(v2));
```

Fails with:
```
t.cc:9:20: error: no matching function for call to 'f'
9 | using Y = decltype(f(v2));
  |^
t.cc:3:41: note: candidate template ignored: deduced type 'A<[...], (default) 
float>' of 1st parameter does not match adjusted type 'A<[...], double>' of 
argument [with TT = A]
3 | template class TT> auto f(TT a) { return a; }
  | ^
```

This shows we are not properly canonicalizing the synthesized template 
declaration.

The problem does not show up with class template partial specializations due to 
a pre-existing issue, but otherwise this was an oversight on my part.

No need to keep reducing on your end, I already have enough to go with.

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


[clang] [clang] Improve ast-dumper text printing of TemplateArgument (PR #93431)

2024-05-26 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/93431

This improves and unifies our approach to printing all template arguments.

The same approach to printing types is extended to all TemplateArguments: A 
sugared version is printed in quotes, followed by printing the canonical form, 
unless they would print the same.

Special improvements are done to add more detail to template template arguments.

It's planned in a future patch to use this improved TemplateName printer for 
other places besides TemplateArguments.

Note: The sugared/desugared printing does not show up for TemplateNames in 
tests yet, because we do a poor job of preserving their type sugar. This will 
be improved in a future patch.

>From 51ca62950c19648895f1947bbf981408193d9002 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 24 May 2024 12:22:55 -0300
Subject: [PATCH] [clang] Improve ast-dumper text printing of TemplateArgument

This improves and unifies our approach to printing all template
arguments.

The same approach to printing types is extended to all
TemplateArguments: A sugared version is printed in quotes,
followed by printing the canonical form, unless they would print
the same.

Special improvements are done to add more detail to template template
arguments.

It's planned in a future patch to use this improved TemplateName
printer for other places besides TemplateArguments.

Note: The sugared/desugared printing does not show up for
TemplateNames in tests yet, because we do a poor job of preserving
their type sugar. This will be improved in a future patch.
---
 clang/docs/ReleaseNotes.rst   |  5 +
 clang/include/clang/AST/TextNodeDumper.h  |  3 +
 clang/lib/AST/TextNodeDumper.cpp  | 94 ---
 clang/test/AST/ast-dump-decl.cpp  | 25 ++---
 ...penmp-begin-declare-variant_template_2.cpp |  6 +-
 clang/test/AST/ast-dump-template-name.cpp | 54 +++
 clang/test/AST/ast-dump-using-template.cpp|  8 +-
 .../constraints-explicit-instantiation.cpp|  6 +-
 clang/test/OpenMP/align_clause_ast_print.cpp  |  2 +-
 clang/test/OpenMP/generic_loop_ast_print.cpp  |  2 +-
 clang/test/OpenMP/interop_ast_print.cpp   |  2 +-
 clang/test/SemaOpenACC/sub-array-ast.cpp  |  2 +-
 .../aggregate-deduction-candidate.cpp | 16 ++--
 clang/test/SemaTemplate/attributes.cpp| 64 ++---
 clang/test/SemaTemplate/deduction-guide.cpp   | 14 +--
 clang/test/SemaTemplate/make_integer_seq.cpp  | 68 --
 clang/test/SemaTemplate/type_pack_element.cpp | 20 ++--
 17 files changed, 266 insertions(+), 125 deletions(-)
 create mode 100644 clang/test/AST/ast-dump-template-name.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 825e91876ffce..403a107edef17 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -818,6 +818,11 @@ Miscellaneous Clang Crashes Fixed
   when ``-fdump-record-layouts-complete`` is passed. Fixes #GH83684.
 - Unhandled StructuralValues in the template differ (#GH93068).
 
+Miscellaneous Clang Improvements
+^
+
+- The text ast-dumper has improved printing of TemplateArguments.
+
 OpenACC Specific Changes
 
 
diff --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 1fede6e462e92..0d057b8011164 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -211,8 +211,11 @@ class TextNodeDumper
   void dumpAccessSpecifier(AccessSpecifier AS);
   void dumpCleanupObject(const ExprWithCleanups::CleanupObject );
   void dumpTemplateSpecializationKind(TemplateSpecializationKind TSK);
+  void dumpBareNestedNameSpecifier(NestedNameSpecifier *NNS);
   void dumpNestedNameSpecifier(const NestedNameSpecifier *NNS);
   void dumpConceptReference(const ConceptReference *R);
+  void dumpTemplateArgument(const TemplateArgument );
+  void dumpTemplateName(TemplateName TN);
 
   void dumpDeclRef(const Decl *D, StringRef Label = {});
 
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 4a1e94ffe283b..742203e3b946d 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -947,6 +947,26 @@ void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef 
Label) {
   });
 }
 
+void TextNodeDumper::dumpTemplateArgument(const TemplateArgument ) {
+  llvm::SmallString<128> Str;
+  {
+llvm::raw_svector_ostream SS(Str);
+TA.print(PrintPolicy, SS, /*IncludeType=*/true);
+  }
+  OS << " '" << Str << "'";
+
+  if (TemplateArgument CanonTA = Context->getCanonicalTemplateArgument(TA);
+  !CanonTA.structurallyEquals(TA)) {
+llvm::SmallString<128> CanonStr;
+{
+  llvm::raw_svector_ostream SS(CanonStr);
+  CanonTA.print(PrintPolicy, SS, /*IncludeType=*/true);
+}
+if (CanonStr != Str)
+  OS << ":'" << CanonStr << "'";
+  }
+}
+
 const char 

[clang] [clang] Improve ast-dumper text printing of TemplateArgument (PR #93431)

2024-05-26 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/93431

>From c23a96038a8233b44b49bc0a1d2a2475e4d2a8ae Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 24 May 2024 12:22:55 -0300
Subject: [PATCH] [clang] Improve ast-dumper text printing of TemplateArgument

This improves and unifies our approach to printing all template
arguments.

The same approach to printing types is extended to all
TemplateArguments: A sugared version is printed in quotes,
followed by printing the canonical form, unless they would print
the same.

Special improvements are done to add more detail to template template
arguments.

It's planned in a future patch to use this improved TemplateName
printer for other places besides TemplateArguments.

Note: The sugared/desugared printing does not show up for
TemplateNames in tests yet, because we do a poor job of preserving
their type sugar. This will be improved in a future patch.
---
 clang/docs/ReleaseNotes.rst   |  5 +
 clang/include/clang/AST/TextNodeDumper.h  |  2 +
 clang/lib/AST/TextNodeDumper.cpp  | 94 ---
 clang/test/AST/ast-dump-decl.cpp  | 25 ++---
 ...penmp-begin-declare-variant_template_2.cpp |  6 +-
 clang/test/AST/ast-dump-template-name.cpp | 54 +++
 clang/test/AST/ast-dump-using-template.cpp|  8 +-
 .../constraints-explicit-instantiation.cpp|  6 +-
 clang/test/OpenMP/align_clause_ast_print.cpp  |  2 +-
 clang/test/OpenMP/generic_loop_ast_print.cpp  |  2 +-
 clang/test/OpenMP/interop_ast_print.cpp   |  2 +-
 clang/test/SemaOpenACC/sub-array-ast.cpp  |  2 +-
 .../aggregate-deduction-candidate.cpp | 16 ++--
 clang/test/SemaTemplate/attributes.cpp| 64 ++---
 clang/test/SemaTemplate/deduction-guide.cpp   | 14 +--
 clang/test/SemaTemplate/make_integer_seq.cpp  | 68 --
 clang/test/SemaTemplate/type_pack_element.cpp | 20 ++--
 17 files changed, 265 insertions(+), 125 deletions(-)
 create mode 100644 clang/test/AST/ast-dump-template-name.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 825e91876ffce..403a107edef17 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -818,6 +818,11 @@ Miscellaneous Clang Crashes Fixed
   when ``-fdump-record-layouts-complete`` is passed. Fixes #GH83684.
 - Unhandled StructuralValues in the template differ (#GH93068).
 
+Miscellaneous Clang Improvements
+^
+
+- The text ast-dumper has improved printing of TemplateArguments.
+
 OpenACC Specific Changes
 
 
diff --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 1fede6e462e92..63fa16c9ec47c 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -213,6 +213,8 @@ class TextNodeDumper
   void dumpTemplateSpecializationKind(TemplateSpecializationKind TSK);
   void dumpNestedNameSpecifier(const NestedNameSpecifier *NNS);
   void dumpConceptReference(const ConceptReference *R);
+  void dumpTemplateArgument(const TemplateArgument );
+  void dumpTemplateName(TemplateName TN);
 
   void dumpDeclRef(const Decl *D, StringRef Label = {});
 
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 4a1e94ffe283b..742203e3b946d 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -947,6 +947,26 @@ void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef 
Label) {
   });
 }
 
+void TextNodeDumper::dumpTemplateArgument(const TemplateArgument ) {
+  llvm::SmallString<128> Str;
+  {
+llvm::raw_svector_ostream SS(Str);
+TA.print(PrintPolicy, SS, /*IncludeType=*/true);
+  }
+  OS << " '" << Str << "'";
+
+  if (TemplateArgument CanonTA = Context->getCanonicalTemplateArgument(TA);
+  !CanonTA.structurallyEquals(TA)) {
+llvm::SmallString<128> CanonStr;
+{
+  llvm::raw_svector_ostream SS(CanonStr);
+  CanonTA.print(PrintPolicy, SS, /*IncludeType=*/true);
+}
+if (CanonStr != Str)
+  OS << ":'" << CanonStr << "'";
+  }
+}
+
 const char *TextNodeDumper::getCommandName(unsigned CommandID) {
   if (Traits)
 return Traits->getCommandInfo(CommandID)->Name;
@@ -1086,45 +1106,91 @@ void TextNodeDumper::VisitNullTemplateArgument(const 
TemplateArgument &) {
 
 void TextNodeDumper::VisitTypeTemplateArgument(const TemplateArgument ) {
   OS << " type";
-  dumpType(TA.getAsType());
+  dumpTemplateArgument(TA);
 }
 
 void TextNodeDumper::VisitDeclarationTemplateArgument(
 const TemplateArgument ) {
   OS << " decl";
+  dumpTemplateArgument(TA);
   dumpDeclRef(TA.getAsDecl());
 }
 
-void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &) {
+void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument ) {
   OS << " nullptr";
+  dumpTemplateArgument(TA);
 }
 
 void TextNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument 

[clang] [clang] NFCI: Make ASTContext optional in the AST text dumper again (PR #94522)

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

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


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

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

mizvekov wrote:

> Can you elaborate on what specifically you find hard? Building should be 
> fairly straightforward, besides Python and SWIG, which are required to run 
> the tests, most of our dependencies are optional. Unlike the compiler, the 
> debugger is (1) tied to the system it's running on, and (2) an interactive 
> tool, so maybe that's what you're referring to? Either way, if there are 
> concrete ways we can make LLDB easier to work on, I'd love to hear your 
> suggestions!

This was about a year ago, and I remember @erichkeane had similar issues, but 
the main points:
1) Windows support
2) Build system does not support Multi-config generators. You can grep for 
https://cmake.org/cmake/help/latest/variable/CMAKE_CFG_INTDIR.html as an 
example.
3) Not all tests pass and it's quite unclear when that is not your fault.

AFAIK, on windows I would run into this issue where running the LLDB test suite 
would cause hundreds of frozen terminal windows to spawn, and that was quite 
difficult to recover from without rebooting.
This might be related to 2) above, before I figured it out.

I eventually thought that was too dangerous to run on windows and managed to 
get it working on linux virtual machine.


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


[clang] [clang] NFCI: Make ASTContext optional again (PR #94522)

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

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/94522

Previous patches 3cabbf60393cc8d55fe635e35e89e5973162de33 and 
1a2f3309765fdc143fdc3809211fb85d2e2ca341 broke the assumption that the AST 
Context was optional for the text node dumper.

While missing an ASTContext makes some helpful information unavailable, the 
pure `dump` overloads taking no parameters are quite convenient for quick 
debugging, so let's make that work again.

>From 422e23d1daed53e096eb55ceb2e915904ee3635b Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Wed, 5 Jun 2024 16:01:33 -0300
Subject: [PATCH] [clang] NFCI: Make ASTContext optional again

Previous patches 3cabbf60393cc8d55fe635e35e89e5973162de33 and 
1a2f3309765fdc143fdc3809211fb85d2e2ca341
broke the assumption that the AST Context was optional for the text node dumper.

While missing an ASTContext makes some helpful information unavailable,
the pure `dump` overloads taking no parameters are quite convenient for
quick debugging, so let's make that work again.
---
 clang/lib/AST/TextNodeDumper.cpp | 21 +
 clang/lib/AST/Type.cpp   |  1 -
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 8bacceea0f22b..1076dcd40a694 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -958,6 +958,9 @@ void TextNodeDumper::dumpTemplateArgument(const 
TemplateArgument ) {
   }
   OS << " '" << Str << "'";
 
+  if (!Context)
+return;
+
   if (TemplateArgument CanonTA = Context->getCanonicalTemplateArgument(TA);
   !CanonTA.structurallyEquals(TA)) {
 llvm::SmallString<128> CanonStr;
@@ -1139,15 +1142,17 @@ void TextNodeDumper::dumpTemplateName(TemplateName TN, 
StringRef Label) {
   }
   OS << " '" << Str << "'";
 
-  if (TemplateName CanonTN = Context->getCanonicalTemplateName(TN);
-  CanonTN != TN) {
-llvm::SmallString<128> CanonStr;
-{
-  llvm::raw_svector_ostream SS(CanonStr);
-  CanonTN.print(SS, PrintPolicy);
+  if (Context) {
+if (TemplateName CanonTN = Context->getCanonicalTemplateName(TN);
+CanonTN != TN) {
+  llvm::SmallString<128> CanonStr;
+  {
+llvm::raw_svector_ostream SS(CanonStr);
+CanonTN.print(SS, PrintPolicy);
+  }
+  if (CanonStr != Str)
+OS << ":'" << CanonStr << "'";
 }
-if (CanonStr != Str)
-  OS << ":'" << CanonStr << "'";
   }
 }
 dumpBareTemplateName(TN);
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 2097b29b7e0b6..2cc06a3df9d18 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -,7 +,6 @@ static CachedProperties computeCachedProperties(const 
Type *T) {
 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class,Base) case Type::Class:
 #include "clang/AST/TypeNodes.inc"
 // Treat instantiation-dependent types as external.
-if (!T->isInstantiationDependentType()) T->dump();
 assert(T->isInstantiationDependentType());
 return CachedProperties(Linkage::External, false);
 

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


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

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

mizvekov wrote:

I would normally have no issue making the changes needed to other projects, and 
I mostly try to do that.
But lldb sets itself apart in how hard it is to get a project setup going, and 
how impactful it is.

It's a bit concerning when the changes needed are quite trivial, for example 
just changing diagnostics expectations, but you have no other way to test that.

I think the lldb pre-commit CI would at least help here, for trivial changes, 
we can keep trying to fix and verifying it by pushing to the PR, no changes 
needed on developer setup side.

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


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

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

mizvekov wrote:

> > 2. Build system does not support Multi-config generators. You can grep for 
> > https://cmake.org/cmake/help/latest/variable/CMAKE_CFG_INTDIR.html as an 
> > example.
> 
> This simply isn't true. Xcode is a multi-config build system and we have [a 
> bot](https://ci.swift.org/view/all/job/llvm.org/view/LLDB/job/lldb-cmake-standalone/)
>  that ensures that doesn't break. Maybe there's something different about 
> MSVC?

The page I linked about this deprecated variable talks about poor support in 
"Ninja Multi-Config" specifically, which is what I use, but implies it can be 
used in Xcode.

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


[clang] [clang] NFCI: Make ASTContext optional in the AST text dumper again (PR #94522)

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

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

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

mizvekov wrote:

> Even with this fix, I'm seeing a segfault in clang/lib/AST/QualTypeNames.cpp 
> at line 216.
> I have a fix in testing that adds this check, but if you would double check 
> it after it goes in, that would be helpful.
> 
> Unfortunately the failure is in an internal tool, against internal sources, 
> which makes getting a reproducer a long process. I'm also working on that.

The fix gets the intended behavior right.

There are `unittests` for QualTypeNames, a new test case could go in there.

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


[clang] [clang] NFCI: remove obsolete workaround for template default arguments (PR #94311)

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

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/94311

This removes a workaround for template template arguments pointing to older 
template declarations, which don't have the most recent default argument 
definition.

The removed workaround was introduced in 
1abacfcb2358a1928f0ced693e149a6cf2fc482e, but 
https://github.com/llvm/llvm-project/pull/75569 introduced a better fix which 
is more comprehensive and doesn't require rebuilding TemplateNames.

>From 7b0186176437e22a5bfe221dd6ed3daf0c949fea Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Tue, 4 Jun 2024 01:26:10 -0300
Subject: [PATCH] [clang] NFCI: remove obsolete workaround for template default
 arguments

This removes a workaround for template template arguments pointing to
older template declarations, which don't have the most recent default
argument definition.

The removed workaround was introduced in 
1abacfcb2358a1928f0ced693e149a6cf2fc482e,
but https://github.com/llvm/llvm-project/pull/75569 introduced a
better fix which is more comprehensive and doesn't require rebuilding
TemplateNames.
---
 clang/include/clang/AST/TemplateName.h |  5 -
 clang/lib/AST/TemplateName.cpp | 17 -
 clang/lib/Sema/SemaTemplateInstantiate.cpp | 10 --
 3 files changed, 4 insertions(+), 28 deletions(-)

diff --git a/clang/include/clang/AST/TemplateName.h 
b/clang/include/clang/AST/TemplateName.h
index 7aedc086ab7d0..489fccb2ef74d 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -314,11 +314,6 @@ class TemplateName {
 
   TemplateName getUnderlying() const;
 
-  /// Get the template name to substitute when this template name is used as a
-  /// template template argument. This refers to the most recent declaration of
-  /// the template, including any default template arguments.
-  TemplateName getNameToSubstitute() const;
-
   TemplateNameDependence getDependence() const;
 
   /// Determines whether this is a dependent template name.
diff --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index 3dbdad92813f6..4fc25cb34803e 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -214,23 +214,6 @@ UsingShadowDecl *TemplateName::getAsUsingShadowDecl() 
const {
   return nullptr;
 }
 
-TemplateName TemplateName::getNameToSubstitute() const {
-  TemplateDecl *Decl = getAsTemplateDecl();
-
-  // Substituting a dependent template name: preserve it as written.
-  if (!Decl)
-return *this;
-
-  // If we have a template declaration, use the most recent non-friend
-  // declaration of that template.
-  Decl = cast(Decl->getMostRecentDecl());
-  while (Decl->getFriendObjectKind()) {
-Decl = cast(Decl->getPreviousDecl());
-assert(Decl && "all declarations of template are friends");
-  }
-  return TemplateName(Decl);
-}
-
 TemplateNameDependence TemplateName::getDependence() const {
   auto D = TemplateNameDependence::None;
   switch (getKind()) {
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index abb8a260faab9..863cc53c55afa 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1856,7 +1856,7 @@ Decl *TemplateInstantiator::TransformDecl(SourceLocation 
Loc, Decl *D) {
 Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
   }
 
-  TemplateName Template = Arg.getAsTemplate().getNameToSubstitute();
+  TemplateName Template = Arg.getAsTemplate();
   assert(!Template.isNull() && Template.getAsTemplateDecl() &&
  "Wrong kind of template template argument");
   return Template.getAsTemplateDecl();
@@ -2029,10 +2029,8 @@ TemplateName TemplateInstantiator::TransformTemplateName(
 Arg = getPackSubstitutedTemplateArgument(getSema(), Arg);
   }
 
-  TemplateName Template = Arg.getAsTemplate().getNameToSubstitute();
+  TemplateName Template = Arg.getAsTemplate();
   assert(!Template.isNull() && "Null template template argument");
-  assert(!Template.getAsQualifiedTemplateName() &&
- "template decl to substitute is qualified?");
 
   if (Final)
 return Template;
@@ -2052,8 +2050,8 @@ TemplateName TemplateInstantiator::TransformTemplateName(
 if (SubstPack->getFinal())
   return Template;
 return getSema().Context.getSubstTemplateTemplateParm(
-Template.getNameToSubstitute(), SubstPack->getAssociatedDecl(),
-SubstPack->getIndex(), getPackIndex(Pack));
+Template, SubstPack->getAssociatedDecl(), SubstPack->getIndex(),
+getPackIndex(Pack));
   }
 
   return inherited::TransformTemplateName(SS, Name, NameLoc, ObjectType,

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


[clang] [libcxx] [Clang] Implement resolution for CWG1835 (PR #92957)

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


@@ -55,15 +55,21 @@ namespace PR11856 {
 
   template T *end(T*);
 
-  class X { };
+  struct X { };
+  struct Y {
+int end;
+  };
   template 
   void Foo2() {
 T it1;
-if (it1->end < it1->end) {
-}
+if (it1->end < it1->end) { }
 
 X *x;
-if (x->end < 7) {  // expected-error{{no member named 'end' in 
'PR11856::X'}}
-}
+if (x->end < 7) { } // expected-error{{expected '>'}}
+// expected-note@-1{{to match this '<'}}
+// expected-error@-2{{expected unqualified-id}}

mizvekov wrote:

Yes, this looks great now, thanks!

I still have to finish review of the rest of this huge patch, this is going to 
take a while :)

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


[clang] [clang] NFCI: remove obsolete workaround for template default arguments (PR #94311)

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

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


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

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

mizvekov wrote:

> I think it makes a lot of sense for lldb to have a precommit CI pipeline 
> which tests changes to lldb. I don't think we're at a point where it would 
> make sense to enable lldb precommit CI testing for changes to clang, though.
> 
> For starters, the false positive rate from flaky lldb test failures is pretty 
> high:

I think we only need a subset of lldb tests for pure clang changes, and my 
experience is that those aren't as flaky.

> But also, changes in Clang that break lldb do not necessarily mean that a PR 
> is not ready to land. There are conforming changes that can be made to Clang 
> which lldb needs to react to as a downstream consumer of Clang as a library 
> rather than a PR author needing to react to it. (e.g., adding a new AST node 
> to Clang or changing diagnostic wording/behavior). We should try to come up 
> with and document a policy about what the expectations are regarding Clang 
> and lldb interactions before we add lldb to Clang's precommit CI pipeline.

Yeah clarifying this would be helpful. In my past experience, this is not the 
expectation lldb maintainers have. I have had clang patches reverted only 
because they broke lldb tests on pure diagnostics / type printing improvements.

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


[clang] [clang] CWG150: add tests and change to unreleased (PR #93758)

2024-05-29 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/93758

None

>From 834696f9b0a74c5a4c0d261480be6cff71fc91f5 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Wed, 29 May 2024 22:23:01 -0300
Subject: [PATCH] [clang] CWG150: add tests and change to unreleased

---
 clang/test/CXX/drs/cwg1xx.cpp | 40 +++
 clang/www/cxx_dr_status.html  |  2 +-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6bc63760f8333..6016af67aae1a 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -753,6 +753,46 @@ namespace cwg148 { // cwg148: yes
 
 // cwg149: na
 
+namespace cwg150 { // cwg150: yes
+  namespace p1 {
+template 
+class ARG { };
+
+template  class PARM>
+void f(PARM) { }
+
+void g() {
+  ARG x;
+  f(x);
+}
+  } // namespace p1
+
+  namespace p2 {
+template  class PARM>
+class C {
+  PARM pi;
+};
+  } // namespace p2
+
+  namespace n1 {
+struct Dense { static const unsigned int dim = 1; };
+
+template  class View,
+  typename Block>
+void operator+(float, View const&);
+
+template 
+class Lvalue_proxy { operator float() const; };
+
+void test_1d (void) {
+  Lvalue_proxy p;
+  float b;
+  b + p;
+}
+  } // namespace n1
+}
+
 namespace cwg151 { // cwg151: 3.1
   struct X {};
   typedef int X::*p;
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 4cce88fe0490f..628ee12992e6b 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -938,7 +938,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/150.html;>150
 C++17
 Template template parameters and default arguments
-Unknown
+Clang 19
   
   
 https://cplusplus.github.io/CWG/issues/151.html;>151

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


[clang] [clang] fix printing of canonical template template parameters take 2 (PR #93448)

2024-05-29 Thread Matheus Izvekov via cfe-commits

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


[clang] 498da62 - [NFC] [clang] add tests for merging of UsingShadowDecl

2024-05-29 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2024-05-30T02:56:57-03:00
New Revision: 498da62088b22ef1d4e90d6021a80ae7bab6abae

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

LOG: [NFC] [clang] add tests for merging of UsingShadowDecl

Added: 
clang/test/Modules/cxx20-decls.cppm

Modified: 


Removed: 




diff  --git a/clang/test/Modules/cxx20-decls.cppm 
b/clang/test/Modules/cxx20-decls.cppm
new file mode 100644
index 0..9f0c40685b68f
--- /dev/null
+++ b/clang/test/Modules/cxx20-decls.cppm
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 -I %t %t/A.cppm -emit-module-interface -o 
%t/A.pcm -verify
+// RUN: %clang_cc1 -std=c++20 -I %t %t/B.cpp -fmodule-file=A=%t/A.pcm 
-fsyntax-only -verify -ast-dump-all -ast-dump-filter baz | FileCheck %s
+
+//--- foo.h
+namespace baz {
+  using foo = char;
+  using baz::foo;
+}
+
+//--- A.cppm
+// expected-no-diagnostics
+module;
+#include "foo.h"
+export module A;
+
+//--- B.cpp
+// expected-no-diagnostics
+#include "foo.h"
+import A;
+// Since modules are loaded lazily, force loading by performing a lookup.
+using xxx = baz::foo;
+
+// CHECK-LABEL: Dumping baz:
+// CHECK-NEXT: NamespaceDecl 0x[[BAZ_REDECL_ADDR:[^ ]*]] prev 0x[[BAZ_ADDR:[^ 
]*]]
+// CHECK:  TypeAliasDecl 0x[[ALIAS_REDECL_ADDR:[^ ]*]] prev 
0x[[ALIAS_ADDR:[^ ]*]]
+// FIXME: UsingShadowDecl should have been merged
+// CHECK:  UsingShadowDecl 0x{{[^ ]*}} <{{.*}}> col:{{.*}} imported in 
A. hidden implicit TypeAlias 0x[[ALIAS_REDECL_ADDR]] 'foo'
+
+// CHECK-LABEL: Dumping baz:
+// CHECK-NEXT: NamespaceDecl 0x[[BAZ_ADDR]] <{{.*}}> line:{{.*}} baz
+// CHECK:  UsingShadowDecl 0x[[SHADOW_ADDR:[^ ]*]] <{{.*}}> col:{{.*}} 
implicit TypeAlias 0x[[ALIAS_ADDR]] 'foo'



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


[clang] [clang] fix merging of UsingShadowDecl (PR #80245)

2024-05-30 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/80245

>From 9763cc9e6f081bc28b74164c77a2b80ac42aec1c Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 1 Feb 2024 02:26:10 -0300
Subject: [PATCH] [clang] fix merging of UsingShadowDecl

Previously, when deciding if two UsingShadowDecls where mergeable,
we would incorrectly only look for both pointing to the exact redecla
ration, whereas the correct thing is to look for declarations to the
same entity.

This problem has existed as far back as 2013, introduced in commit
fd8634a09de71.

This problem could manifest itself as ODR check false positives
when importing modules.

Fixes: #80252
---
 clang/docs/ReleaseNotes.rst | 3 +++
 clang/lib/AST/ASTContext.cpp| 2 +-
 clang/test/Modules/cxx20-decls.cppm | 4 ++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 44035f48cb3f9..9dc93f53fe716 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -813,6 +813,9 @@ Bug Fixes to C++ Support
 - Clang now allows ``@$``` in raw string literals. Fixes (#GH93130).
 - Fix an assertion failure when checking invalid ``this`` usage in the wrong 
context. (Fixes #GH91536).
 - Clang no longer models dependent NTTP arguments as 
``TemplateParamObjectDecl`` s. Fixes (#GH84052).
+- Fix incorrect merging of modules which contain using declarations which 
shadow
+  other declarations. This could manifest as ODR checker false positives.
+  Fixes (`#80252 `_)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 06780ceba4074..73d3b152c49f1 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -6794,7 +6794,7 @@ bool ASTContext::isSameEntity(const NamedDecl *X, const 
NamedDecl *Y) const {
   // Using shadow declarations with the same target match.
   if (const auto *USX = dyn_cast(X)) {
 const auto *USY = cast(Y);
-return USX->getTargetDecl() == USY->getTargetDecl();
+return declaresSameEntity(USX->getTargetDecl(), USY->getTargetDecl());
   }
 
   // Using declarations with the same qualifier match. (We already know that
diff --git a/clang/test/Modules/cxx20-decls.cppm 
b/clang/test/Modules/cxx20-decls.cppm
index 9f0c40685b68f..0e8b59708ab4c 100644
--- a/clang/test/Modules/cxx20-decls.cppm
+++ b/clang/test/Modules/cxx20-decls.cppm
@@ -28,8 +28,8 @@ using xxx = baz::foo;
 // CHECK-NEXT: NamespaceDecl 0x[[BAZ_REDECL_ADDR:[^ ]*]] prev 0x[[BAZ_ADDR:[^ 
]*]]
 // CHECK:  TypeAliasDecl 0x[[ALIAS_REDECL_ADDR:[^ ]*]] prev 
0x[[ALIAS_ADDR:[^ ]*]]
 // FIXME: UsingShadowDecl should have been merged
-// CHECK:  UsingShadowDecl 0x{{[^ ]*}} <{{.*}}> col:{{.*}} imported in 
A. hidden implicit TypeAlias 0x[[ALIAS_REDECL_ADDR]] 'foo'
+// CHECK:  UsingShadowDecl 0x{{[^ ]*}} prev 0x[[SHADOW_ADDR:[^ ]*]] {{.*}} 
imported in A. {{.*}} 'foo'
 
 // CHECK-LABEL: Dumping baz:
 // CHECK-NEXT: NamespaceDecl 0x[[BAZ_ADDR]] <{{.*}}> line:{{.*}} baz
-// CHECK:  UsingShadowDecl 0x[[SHADOW_ADDR:[^ ]*]] <{{.*}}> col:{{.*}} 
implicit TypeAlias 0x[[ALIAS_ADDR]] 'foo'
+// CHECK:  UsingShadowDecl 0x[[SHADOW_ADDR]] {{.*}} 'foo'

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


[clang] [clang] fix merging of UsingShadowDecl (PR #80245)

2024-05-30 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

I have revived this PR after a long time.

The original ODR violation bad diagnostic from the GH issue is gone from main, 
so I have removed the test for it.
My best guess is that the ODR checking must have gotten weakened somehow.
I really don't have time to dig into it though.

The original bug is still there in main, is self evident from looking at the 
source code, and can be confirmed bad and that it gets fixed by just looking at 
the AST dump.

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


[clang] [clang] fix merging of UsingShadowDecl (PR #80245)

2024-05-30 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] Improve ast-dumper text printing of TemplateArgument (PR #93431)

2024-05-26 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/93431

>From 031e7c235ce5cbae31504c21eeecc7655fbd1566 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 24 May 2024 12:22:55 -0300
Subject: [PATCH] [clang] Improve ast-dumper text printing of TemplateArgument

This improves and unifies our approach to printing all template
arguments.

The same approach to printing types is extended to all
TemplateArguments: A sugared version is printed in quotes,
followed by printing the canonical form, unless they would print
the same.

Special improvements are done to add more detail to template template
arguments.

It's planned in a future patch to use this improved TemplateName
printer for other places besides TemplateArguments.

Note: The sugared/desugared printing does not show up for
TemplateNames in tests yet, because we do a poor job of preserving
their type sugar. This will be improved in a future patch.
---
 clang/docs/ReleaseNotes.rst   |   5 +
 clang/include/clang/AST/TextNodeDumper.h  |   2 +
 clang/lib/AST/TextNodeDumper.cpp  | 103 +++---
 clang/test/AST/ast-dump-decl.cpp  |  25 +++--
 ...penmp-begin-declare-variant_template_2.cpp |   6 +-
 clang/test/AST/ast-dump-template-name.cpp |  54 +
 clang/test/AST/ast-dump-using-template.cpp|   8 +-
 .../constraints-explicit-instantiation.cpp|   6 +-
 clang/test/OpenMP/align_clause_ast_print.cpp  |   2 +-
 clang/test/OpenMP/generic_loop_ast_print.cpp  |   2 +-
 clang/test/OpenMP/interop_ast_print.cpp   |   2 +-
 clang/test/SemaOpenACC/sub-array-ast.cpp  |   2 +-
 .../aggregate-deduction-candidate.cpp |  16 +--
 clang/test/SemaTemplate/attributes.cpp|  64 +--
 clang/test/SemaTemplate/deduction-guide.cpp   |  14 +--
 clang/test/SemaTemplate/make_integer_seq.cpp  |  68 +++-
 clang/test/SemaTemplate/type_pack_element.cpp |  20 ++--
 17 files changed, 274 insertions(+), 125 deletions(-)
 create mode 100644 clang/test/AST/ast-dump-template-name.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 825e91876ffce..403a107edef17 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -818,6 +818,11 @@ Miscellaneous Clang Crashes Fixed
   when ``-fdump-record-layouts-complete`` is passed. Fixes #GH83684.
 - Unhandled StructuralValues in the template differ (#GH93068).
 
+Miscellaneous Clang Improvements
+^
+
+- The text ast-dumper has improved printing of TemplateArguments.
+
 OpenACC Specific Changes
 
 
diff --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 1fede6e462e92..63fa16c9ec47c 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -213,6 +213,8 @@ class TextNodeDumper
   void dumpTemplateSpecializationKind(TemplateSpecializationKind TSK);
   void dumpNestedNameSpecifier(const NestedNameSpecifier *NNS);
   void dumpConceptReference(const ConceptReference *R);
+  void dumpTemplateArgument(const TemplateArgument );
+  void dumpTemplateName(TemplateName TN);
 
   void dumpDeclRef(const Decl *D, StringRef Label = {});
 
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index 4a1e94ffe283b..ed343ffb74124 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -947,6 +947,26 @@ void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef 
Label) {
   });
 }
 
+void TextNodeDumper::dumpTemplateArgument(const TemplateArgument ) {
+  llvm::SmallString<128> Str;
+  {
+llvm::raw_svector_ostream SS(Str);
+TA.print(PrintPolicy, SS, /*IncludeType=*/true);
+  }
+  OS << " '" << Str << "'";
+
+  if (TemplateArgument CanonTA = Context->getCanonicalTemplateArgument(TA);
+  !CanonTA.structurallyEquals(TA)) {
+llvm::SmallString<128> CanonStr;
+{
+  llvm::raw_svector_ostream SS(CanonStr);
+  CanonTA.print(PrintPolicy, SS, /*IncludeType=*/true);
+}
+if (CanonStr != Str)
+  OS << ":'" << CanonStr << "'";
+  }
+}
+
 const char *TextNodeDumper::getCommandName(unsigned CommandID) {
   if (Traits)
 return Traits->getCommandInfo(CommandID)->Name;
@@ -1086,45 +1106,100 @@ void TextNodeDumper::VisitNullTemplateArgument(const 
TemplateArgument &) {
 
 void TextNodeDumper::VisitTypeTemplateArgument(const TemplateArgument ) {
   OS << " type";
-  dumpType(TA.getAsType());
+  dumpTemplateArgument(TA);
 }
 
 void TextNodeDumper::VisitDeclarationTemplateArgument(
 const TemplateArgument ) {
   OS << " decl";
+  dumpTemplateArgument(TA);
   dumpDeclRef(TA.getAsDecl());
 }
 
-void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &) {
+void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument ) {
   OS << " nullptr";
+  dumpTemplateArgument(TA);
 }
 
 void TextNodeDumper::VisitIntegralTemplateArgument(const 

[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)

2024-05-26 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov commented:

The problem here is the loss of the qualification on the TemplateNames

This patch fixes the problem, without taking any workarounds: 
https://github.com/llvm/llvm-project/pull/93433

It also doesn't cause any change in diagnostics in 
`clang/test/SemaTemplate/typename-specifier-3.cpp`.

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


[clang] [llvm] Add option to generate additional debug info for expression dereferencing pointer to pointers. (PR #81545)

2024-05-29 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

I think the fix for the breakage is to just pin the new test to a fixed triple 
like so `-triple x86_64-linux-gnu`.

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


[clang] [clang] CWG150: add tests and change to unreleased (PR #93758)

2024-05-30 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/93758

>From 5ecb3c36d40bb4a361b9af8776e9c4e45fa15b8d Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Wed, 29 May 2024 22:23:01 -0300
Subject: [PATCH] [clang] CWG150: add tests and change to unreleased

---
 clang/test/CXX/drs/cwg1xx.cpp | 40 +++
 clang/www/cxx_dr_status.html  |  2 +-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/clang/test/CXX/drs/cwg1xx.cpp b/clang/test/CXX/drs/cwg1xx.cpp
index 6bc63760f8333..b39cc21fa4917 100644
--- a/clang/test/CXX/drs/cwg1xx.cpp
+++ b/clang/test/CXX/drs/cwg1xx.cpp
@@ -753,6 +753,46 @@ namespace cwg148 { // cwg148: yes
 
 // cwg149: na
 
+namespace cwg150 { // cwg150: 19
+  namespace p1 {
+template 
+class ARG { };
+
+template  class PARM>
+void f(PARM) { }
+
+void g() {
+  ARG x;
+  f(x);
+}
+  } // namespace p1
+
+  namespace p2 {
+template  class PARM>
+class C {
+  PARM pi;
+};
+  } // namespace p2
+
+  namespace n1 {
+struct Dense { static const unsigned int dim = 1; };
+
+template  class View,
+  typename Block>
+void operator+(float, View const&);
+
+template 
+class Lvalue_proxy { operator float() const; };
+
+void test_1d (void) {
+  Lvalue_proxy p;
+  float b;
+  b + p;
+}
+  } // namespace n1
+}
+
 namespace cwg151 { // cwg151: 3.1
   struct X {};
   typedef int X::*p;
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 4cce88fe0490f..628ee12992e6b 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -938,7 +938,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/150.html;>150
 C++17
 Template template parameters and default arguments
-Unknown
+Clang 19
   
   
 https://cplusplus.github.io/CWG/issues/151.html;>151

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


[clang] [libcxx] [clang] Preserve Qualifiers and type sugar in TemplateNames (PR #93433)

2024-05-30 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

@nikic Thanks for the heads-up. I expected some impact. There are some ideas to 
regain that loss in follow up work.

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


[clang] [clang] text ast-dumper: dump TemplateName for TST and DTST (PR #93766)

2024-05-30 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] CWG150: add tests and change to unreleased (PR #93758)

2024-05-30 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] text ast-dumper: dump TemplateName for TST and DTST (PR #93766)

2024-05-30 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/93766

>From 774fa391d3ba427adf81919c361dd4f01e72d6a1 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 30 May 2024 01:24:53 -0300
Subject: [PATCH] [clang] text ast-dumper: dump TemplateName for TST and DTST

Implement AST text dumping of the TemplateName for
TemplateSpecializationType and VisitDeducedTemplateSpecializationType.
---
 clang/include/clang/AST/TemplateName.h|  4 ++
 clang/include/clang/AST/TextNodeDumper.h  |  3 +-
 clang/lib/AST/TextNodeDumper.cpp  | 43 
 clang/test/AST/ast-dump-ctad-alias.cpp|  6 ++-
 clang/test/AST/ast-dump-template-decls.cpp| 14 --
 clang/test/AST/ast-dump-template-name.cpp |  6 +++
 clang/test/AST/ast-dump-using-template.cpp| 18 +--
 clang/test/Import/builtin-template/test.cpp   | 11 +---
 .../aggregate-deduction-candidate.cpp |  4 +-
 clang/test/SemaTemplate/deduction-guide.cpp   | 22 
 clang/test/SemaTemplate/make_integer_seq.cpp  | 50 +--
 clang/test/SemaTemplate/type_pack_element.cpp | 34 +
 12 files changed, 149 insertions(+), 66 deletions(-)

diff --git a/clang/include/clang/AST/TemplateName.h 
b/clang/include/clang/AST/TemplateName.h
index 876be463c71d0..7aedc086ab7d0 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -360,6 +360,10 @@ class TemplateName {
   static TemplateName getFromVoidPointer(void *Ptr) {
 return TemplateName(Ptr);
   }
+
+  /// Structural equality.
+  bool operator==(TemplateName Other) const { return Storage == Other.Storage; 
}
+  bool operator!=(TemplateName Other) const { return !operator==(Other); }
 };
 
 /// Insertion operator for diagnostics.  This allows sending TemplateName's
diff --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 63fa16c9ec47c..caa33abd99e47 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -214,7 +214,8 @@ class TextNodeDumper
   void dumpNestedNameSpecifier(const NestedNameSpecifier *NNS);
   void dumpConceptReference(const ConceptReference *R);
   void dumpTemplateArgument(const TemplateArgument );
-  void dumpTemplateName(TemplateName TN);
+  void dumpBareTemplateName(TemplateName TN);
+  void dumpTemplateName(TemplateName TN, StringRef Label = {});
 
   void dumpDeclRef(const Decl *D, StringRef Label = {});
 
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index a0eedc71ea220..0e0e0a86f5cfc 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1126,7 +1126,32 @@ void TextNodeDumper::VisitIntegralTemplateArgument(const 
TemplateArgument ) {
   dumpTemplateArgument(TA);
 }
 
-void TextNodeDumper::dumpTemplateName(TemplateName TN) {
+void TextNodeDumper::dumpTemplateName(TemplateName TN, StringRef Label) {
+  AddChild(Label, [=] {
+{
+  llvm::SmallString<128> Str;
+  {
+llvm::raw_svector_ostream SS(Str);
+TN.print(SS, PrintPolicy);
+  }
+  OS << " '" << Str << "'";
+
+  if (TemplateName CanonTN = Context->getCanonicalTemplateName(TN);
+  CanonTN != TN) {
+llvm::SmallString<128> CanonStr;
+{
+  llvm::raw_svector_ostream SS(CanonStr);
+  CanonTN.print(SS, PrintPolicy);
+}
+if (CanonStr != Str)
+  OS << ":'" << CanonStr << "'";
+  }
+}
+dumpBareTemplateName(TN);
+  });
+}
+
+void TextNodeDumper::dumpBareTemplateName(TemplateName TN) {
   switch (TN.getKind()) {
   case TemplateName::Template:
 AddChild([=] { Visit(TN.getAsTemplateDecl()); });
@@ -1143,7 +1168,7 @@ void TextNodeDumper::dumpTemplateName(TemplateName TN) {
 if (QTN->hasTemplateKeyword())
   OS << " keyword";
 dumpNestedNameSpecifier(QTN->getQualifier());
-dumpTemplateName(QTN->getUnderlyingTemplate());
+dumpBareTemplateName(QTN->getUnderlyingTemplate());
 return;
   }
   case TemplateName::DependentTemplate: {
@@ -1162,7 +1187,7 @@ void TextNodeDumper::dumpTemplateName(TemplateName TN) {
 if (const TemplateTemplateParmDecl *P = STS->getParameter())
   AddChild("parameter", [=] { Visit(P); });
 dumpDeclRef(STS->getAssociatedDecl(), "associated");
-AddChild("replacement", [=] { dumpTemplateName(STS->getReplacement()); });
+dumpTemplateName(STS->getReplacement(), "replacement");
 return;
   }
   // FIXME: Implement these.
@@ -1182,14 +1207,14 @@ void TextNodeDumper::dumpTemplateName(TemplateName TN) {
 void TextNodeDumper::VisitTemplateTemplateArgument(const TemplateArgument ) 
{
   OS << " template";
   dumpTemplateArgument(TA);
-  dumpTemplateName(TA.getAsTemplate());
+  dumpBareTemplateName(TA.getAsTemplate());
 }
 
 void TextNodeDumper::VisitTemplateExpansionTemplateArgument(
 const TemplateArgument ) {
   OS << " template expansion";
   dumpTemplateArgument(TA);
- 

[clang] [clang] text ast-dumper: dump TemplateName for TST and DTST (PR #93766)

2024-05-30 Thread Matheus Izvekov via cfe-commits

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


[clang] [Clang][Sema][TemplateDeduction] Skip pack expansion type at the end of default template argument list if unneeded (PR #94659)

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

https://github.com/mizvekov requested changes to this pull request.

Please include test case.

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


[clang] [clang] always use resolved arguments for default argument deduction (PR #94756)

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

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


[clang] [clang] always use resolved arguments for default argument deduction (PR #94756)

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

mizvekov wrote:

@kadircet @yozhu FYI this fixes the problem you reported.

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


[clang] [clang] always use resolved arguments for default argument deduction (PR #94756)

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

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/94756

This fixes a regression introduced with the changes in 
https://github.com/llvm/llvm-project/pull/93433 around preservation of 
TemplateName sugar in template type deduction.

Since the argument side TST is non-canonical, we have to extract the arguments 
from it's canonical type.
This was done for the deduction of the TST arguments, but we missed it for the 
default arguments used in the deduction of the TST name.

>From df6049fd91c95e341dd80a61e5bd173ce5837131 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 7 Jun 2024 10:32:12 -0300
Subject: [PATCH] [clang] always use resolved arguments for default argument
 deduction

This fixes a regression introduced with the changes in
https://github.com/llvm/llvm-project/pull/93433 around preservation
of TemplateName sugar in template type deduction.

Since the argument side TST is non-canonical, we have to extract the
arguments from it's canonical type.
This was done for the deduction of the TST arguments, but we missed it
for the default arguments used in the deduction of the TST name.
---
 clang/lib/Sema/SemaTemplateDeduction.cpp | 13 ++---
 clang/test/SemaTemplate/cwg2398.cpp  | 16 
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 1011db2d2830d..befeb38e1fe5b 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -712,13 +712,6 @@ DeduceTemplateSpecArguments(Sema , TemplateParameterList 
*TemplateParams,
 if (const auto *TD = TNA.getAsTemplateDecl(); TD && TD->isTypeAlias())
   return TemplateDeductionResult::Success;
 
-// Perform template argument deduction for the template name.
-if (auto Result =
-DeduceTemplateArguments(S, TemplateParams, TNP, TNA, Info,
-SA->template_arguments(), Deduced);
-Result != TemplateDeductionResult::Success)
-  return Result;
-
 // FIXME: To preserve sugar, the TST needs to carry sugared resolved
 // arguments.
 ArrayRef AResolved =
@@ -726,6 +719,12 @@ DeduceTemplateSpecArguments(Sema , TemplateParameterList 
*TemplateParams,
 ->castAs()
 ->template_arguments();
 
+// Perform template argument deduction for the template name.
+if (auto Result = DeduceTemplateArguments(S, TemplateParams, TNP, TNA, 
Info,
+  AResolved, Deduced);
+Result != TemplateDeductionResult::Success)
+  return Result;
+
 // Perform template argument deduction on each template
 // argument. Ignore any missing/extra arguments, since they could be
 // filled in by default arguments.
diff --git a/clang/test/SemaTemplate/cwg2398.cpp 
b/clang/test/SemaTemplate/cwg2398.cpp
index 45e74cce3a98c..f7f69e9d4268a 100644
--- a/clang/test/SemaTemplate/cwg2398.cpp
+++ b/clang/test/SemaTemplate/cwg2398.cpp
@@ -201,3 +201,19 @@ namespace consistency {
 // new-error@-1 {{ambiguous partial specializations}}
   } // namespace t2
 } // namespace consistency
+
+namespace regression1 {
+  template  struct map {};
+  template  class foo {};
+
+  template  class MapType, typename Value>
+  Value bar(MapType map);
+
+  template  class MapType, typename Value>
+  Value bar(MapType> map);
+
+  void aux() {
+map> input;
+bar(input);
+  }
+} // namespace regression1

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


[clang] [libcxx] [Clang] Implement resolution for CWG1835 (PR #92957)

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

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


[clang] [libcxx] [Clang] Implement resolution for CWG1835 (PR #92957)

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


@@ -2923,10 +2920,9 @@ class TreeTransform {
 }
 
 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
-  SS, TemplateKWLoc,
-  FirstQualifierInScope,
-  R, ExplicitTemplateArgs,
-  /*S*/nullptr);
+  SS, TemplateKWLoc, R,
+  ExplicitTemplateArgs,
+  /*S*/ nullptr);

mizvekov wrote:

```suggestion
  /*S=*/nullptr);
```

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


[clang] [libcxx] [Clang] Implement resolution for CWG1835 (PR #92957)

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

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

LGTM save a few minor cleanups needed.

I think this patch has an incredible amount of noise due to amount of cosmetic 
changes caused by reformatting, specially due to changing parameters and such.

This is fine for now and I am not suggesting you go back and do it for this 
patch, but I think it would have been helpful to pre-clang-format the file, and 
offload more of the minor changes into a previous patch.

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


[clang] [libcxx] [Clang] Implement resolution for CWG1835 (PR #92957)

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


@@ -548,6 +575,7 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, 
NestedNameSpecInfo ,
 // Perform unqualified name lookup in the current scope.
 LookupName(Found, S);
   }
+#endif

mizvekov wrote:

A left-over.

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


[clang] [libcxx] [Clang] Implement resolution for CWG1835 (PR #92957)

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


@@ -390,29 +390,37 @@ bool Sema::isAcceptableNestedNameSpecifier(const 
NamedDecl *SD,
 /// (e.g., Base::), perform name lookup for that identifier as a
 /// nested-name-specifier within the given scope, and return the result of that
 /// name lookup.
-NamedDecl *Sema::FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS) 
{
-  if (!S || !NNS)
-return nullptr;
+bool Sema::LookupFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS,
+   UnresolvedSetImpl ) {
+  if (!S)
+return false;
 
   while (NNS->getPrefix())
 NNS = NNS->getPrefix();
 
-  if (NNS->getKind() != NestedNameSpecifier::Identifier)
-return nullptr;
-
-  LookupResult Found(*this, NNS->getAsIdentifier(), SourceLocation(),
- LookupNestedNameSpecifierName);
+  // FIXME: This is a rather nasty hack! Ideally we should get the results

mizvekov wrote:

I don't think this is a hack per se, I think this is just a consequence of not 
having a special NNS kind for this situation, and representing it with a DTST.

The alternative that I see is to implement a new NNS prefix which is composed 
by an identifier followed by template arguments.

It can still be represented internally with the type, if that's cheaper, but 
having a special accessor, and making `NNS->getAsIdentifier()` work for it, 
would be nicer.

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


[clang] [libcxx] [clang] Preserve Qualifiers and type sugar in TemplateNames (PR #93433)

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

mizvekov wrote:

> so after this patch, clang seems to be crashing on:

Thanks for the reproducer. Yeah this is about default argument deduction, which 
doesn't involve default arguments as written in source.

I confirm the crash and it's indeed caused by changes in this patch. The fix is 
very simple and I will be posting a patch shortly.



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


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

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

mizvekov wrote:

@Endilll This looks good, thanks!

How will this affect test capacity? Right now, the Linux bots are lagging, 
while the Windows bot is breezing through.

This is the opposite of the usual. Are we under-provisioned on Linux CI 
resources? How much worse will it get when we add this extra workload?

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits


@@ -855,10 +855,14 @@ bool 
RecursiveASTVisitor::TraverseDeclarationNameInfo(
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateName(TemplateName Template) 
{
-  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
+  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
-  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
-TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+  } else if (QualifiedTemplateName *QTN =
+ Template.getAsQualifiedTemplateName()) {
+if (QTN->getQualifier()) {
+  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+}
+  }

mizvekov wrote:

I am going to merge since this fixes broken build bot.

Let's continue in post.

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/93926

>From 55d946648a44e7a0b2fc45d20866f29ef4528c15 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 31 May 2024 02:53:18 -0300
Subject: [PATCH] [clang] AST Visitor: skip empty qualifiers in
 QualifiedTemplateName

This change was missed in #93433.
---
 clang/include/clang/AST/RecursiveASTVisitor.h | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 4bbb4380cdd7f..99093aa17972c 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -855,10 +855,14 @@ bool 
RecursiveASTVisitor::TraverseDeclarationNameInfo(
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateName(TemplateName Template) 
{
-  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
+  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
-  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
-TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+  } else if (QualifiedTemplateName *QTN =
+ Template.getAsQualifiedTemplateName()) {
+if (QTN->getQualifier()) {
+  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+}
+  }
 
   return true;
 }

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-30 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/93926

This change was missed in #93433.

>From dd8839b4f3294241b2a6df8bc10e869176baff72 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 31 May 2024 02:53:18 -0300
Subject: [PATCH] [clang] AST Visitor: skip empty qualifiers in
 QualifiedTemplateName

This change was missed in #93433.
---
 clang/include/clang/AST/RecursiveASTVisitor.h | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 4bbb4380cdd7f..28a90dffcb8dc 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -855,10 +855,13 @@ bool 
RecursiveASTVisitor::TraverseDeclarationNameInfo(
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateName(TemplateName Template) 
{
-  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
+  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
-  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
-TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+  } else if (QualifiedTemplateName *QTN = 
Template.getAsQualifiedTemplateName()) {
+if (T->getQualifier()) {
+  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+}
+  }
 
   return true;
 }

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/93926

>From db56ac3130164f570942d54686ffb39cf7d2ae33 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Fri, 31 May 2024 02:53:18 -0300
Subject: [PATCH] [clang] AST Visitor: skip empty qualifiers in
 QualifiedTemplateName

This change was missed in #93433.
---
 clang/include/clang/AST/RecursiveASTVisitor.h | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 4bbb4380cdd7f..d16074443b2dc 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -855,10 +855,14 @@ bool 
RecursiveASTVisitor::TraverseDeclarationNameInfo(
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateName(TemplateName Template) 
{
-  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
+  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
-  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
-TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+  } else if (QualifiedTemplateName *QTN =
+ Template.getAsQualifiedTemplateName()) {
+if (T->getQualifier()) {
+  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+}
+  }
 
   return true;
 }

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] AST Visitor: skip empty qualifiers in QualifiedTemplateName (PR #93926)

2024-05-31 Thread Matheus Izvekov via cfe-commits


@@ -855,10 +855,14 @@ bool 
RecursiveASTVisitor::TraverseDeclarationNameInfo(
 
 template 
 bool RecursiveASTVisitor::TraverseTemplateName(TemplateName Template) 
{
-  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
+  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
 TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
-  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
-TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+  } else if (QualifiedTemplateName *QTN =
+ Template.getAsQualifiedTemplateName()) {
+if (QTN->getQualifier()) {
+  TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
+}
+  }

mizvekov wrote:

I understand that looks cleaner at first glance, but the intention in the 
original code was to match each kind of `TemplateName`.

For example, this doesn't traverse `OverloadTemplateName` right now, but if we 
wanted to add it after this change, this would necessitate to refactor the if 
branches once again.

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


[clang] [libcxx] [clang] Preserve Qualifiers and type sugar in TemplateNames (PR #93433)

2024-05-31 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

@pcc https://github.com/llvm/llvm-project/pull/93926 should fix it, can you 
double check that it gets all issues?

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


[clang] [clang] Be const-correct with all uses of `Module *`. (PR #93493)

2024-05-28 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

I could agree on being const correct here, but mostly by removing const, not 
adding more, in the general case.

The problem here is that this is such a big code base, and where some times 
parameters can be passed down from function to function for a very long depth, 
that this can make some seemingly small local changes propagate into a lot of 
code churn.

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


[clang] [Clang][Sema] Use StructuralValues to model dependent NTTP arguments (PR #93556)

2024-05-28 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

LGTM as well, thanks!

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


[clang] [clang] Improve ast-dumper text printing of TemplateArgument (PR #93431)

2024-05-28 Thread Matheus Izvekov via cfe-commits


@@ -947,6 +947,26 @@ void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef 
Label) {
   });
 }
 
+void TextNodeDumper::dumpTemplateArgument(const TemplateArgument ) {
+  llvm::SmallString<128> Str;
+  {
+llvm::raw_svector_ostream SS(Str);
+TA.print(PrintPolicy, SS, /*IncludeType=*/true);
+  }
+  OS << " '" << Str << "'";
+
+  if (TemplateArgument CanonTA = Context->getCanonicalTemplateArgument(TA);

mizvekov wrote:

`getCanonicalTemplateArgument` returns a TemplateArgument by value. These are 
small objects we don't manually allocate, and don't unique tem (but may unique 
things it references internally). This is similar to how we don't take const 
references to QualType.

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


[clang] [Clang][Sema] Use correct TemplateName when transforming TemplateSpecializationType (PR #93411)

2024-05-28 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

> > The problem here is the loss of the qualification on the TemplateNames
> > This patch fixes the problem, without taking any workarounds: #93433
> > It also doesn't cause any change in diagnostics in 
> > `clang/test/SemaTemplate/typename-specifier-3.cpp`.
> 
> I think we should report this message since `B::arg` in `A` is a NTTP.

Yeah, I am not saying that is wrong, but this needs more investigation.

I am not looking at this bug specifically: I just noticed my patch would have 
an effect here, and after testing it sure did, but I haven't looked closely.

Maybe I used the term 'fixes' incorrectly, as in my patch makes it not crash, 
but it's strange that type sugar would have a semantic effect here, that is not 
supposed to happen.

Again, thinking in first principles, without looking at this example too 
specifically, my intuition says that what might be happening here is that we 
transformed a `DependentTemplateSpecializationType` into a 
`TemplateSpecializationType` too early, before resolving everything that needs 
to be resolved related to it's TemplateName and NestedNameSpecifier.

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


[clang] [clang] Improve ast-dumper text printing of TemplateArgument (PR #93431)

2024-05-28 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

> Should we also be updating JSONNodeDumper.cpp at the same time?

We would ideally update it as well.

Not necessarily in the same PR, as it's a separate change that doesn't need to 
be synchronized.

It's just not important to me, because I don't personally use the JSON dumper 
for debugging.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-05-29 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

> :( My goal now is to fix xtensor implementation/original tests, so this is 
> not a question of reduction. I need to understand where the compiler picked a 
> different specialization with relaxed argument matching.

So from the reduction you can see you have a problem where `svector` is 
matching a partial specialization of `xtype_for_shape`, which it shouldn't.

I see that you have a very similar problem to your first one, which is not 
fixed in main yet, where one of the partial specializations is ifdef'd out in a 
similar manner, that also very suspiciously looks like it should have been 
using the feature test macro instead:
https://github.com/xtensor-stack/xtensor/blob/d9c3782ed51027b2d00be3c26288b2f74e4dbe94/include/xtensor/xexpression_traits.hpp#L106

Does changing that to the feature test macro help?

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] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-05-28 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

No, I never used templight for this. I don't know of any easy to use tools that 
would work for a complex sample without modification.

Otherwise, the reduction wasn't difficult, it was mostly that creduce / cvise 
are lacking steps to reduce template type aliases, and the typedef within a 
class template equivalent.

There is also a seemingly complex pack expansion of a boolean expression, that 
you can just replace with false; cvise missed this as well.

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] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-05-28 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

@eaeltsin You example boils down to https://godbolt.org/z/axnanxP1z:
```C++
template  struct xtype_for_shape;
template  class S, class X, long N>
struct xtype_for_shape> {};

template  struct svector;
template struct xtype_for_shape>;
```
There is wide divergence between implementations on what happens during 
deduction, at least when NTTPs are involved.

clang picks the partial specialization, all other implementations pick the 
primary template.
This is not something new from this PR either.

The other implementations reject the matching in deduction, but all 
implementations agree that it would work if directly specified: 
https://godbolt.org/z/Gfs3dbYEe

(discounting EDG which doesn't seem to implement P0522R0 at all).

I think what clang does makes the most sense; I see no point in having 
deduction be more strict than the matching itself.

Also, you can create a similar situation with NTTPs where this adds new 
ambiguity: https://godbolt.org/z/cWPM7jWvd

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] Improve ast-dumper text printing of TemplateArgument (PR #93431)

2024-05-28 Thread Matheus Izvekov via cfe-commits


@@ -947,6 +947,26 @@ void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef 
Label) {
   });
 }
 
+void TextNodeDumper::dumpTemplateArgument(const TemplateArgument ) {
+  llvm::SmallString<128> Str;
+  {
+llvm::raw_svector_ostream SS(Str);
+TA.print(PrintPolicy, SS, /*IncludeType=*/true);
+  }
+  OS << " '" << Str << "'";

mizvekov wrote:

I think the problem is that it makes little sense to show the char as a char 
literal for this integral dumper.

This is a resolved argument, it's not supposed to print as-written anyway.

This dumper is a debugging aid and the most important things are showing the 
value and the type it had.
The suffixed literals are going to obscure any typedefs. The char literal is 
going to obscure the signed-ness of the char besides that.

The most helpful representation is the cast followed by the plain literal. Ie 
(uintptr_t)28999
I think we should have a mode in that literal printer for that.

This would remove the plain ugly case of the char literal, but still the single 
quotes can appear within the printed type of the literal, which can already 
happen anyway.

Shafik would that also alleviate your concern?



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


[clang] [Clang] Initialize AtLeastAsSpecialized to prevent undefined behavior in Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs() (PR #95195)

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


@@ -6447,7 +6447,7 @@ bool 
Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
   if (Inst.isInvalid())
 return false;
 
-  bool AtLeastAsSpecialized;
+  bool AtLeastAsSpecialized = false;
   runWithSufficientStackSpace(Info.getLocation(), [&] {

mizvekov wrote:

runWithSufficientStackSpace is a small helper used to prevent stack exhaustion.

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


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

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

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/94981

>From d12c7d50b67cd669f09b3701ccf34154876786c9 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Mon, 20 May 2024 01:15:03 -0300
Subject: [PATCH] [clang] Implement CWG2398 provisional TTP matching to class
 templates

This extends default argument deduction to cover class templates as
well, and also applies outside of partial ordering, adding to the
provisional wording introduced in 
https://github.com/llvm/llvm-project/pull/89807.

This solves some ambuguity introduced in P0522 regarding how
template template parameters are partially ordered, and should reduce
the negative impact of enabling `-frelaxed-template-template-args`
by default.

Given the following example:
```C++
template  struct A;
template  struct B;

template  class TT1, class T5> struct B>;   // #1
template   struct B>; // #2

template struct B>;
```
Prior to P0522, `#2` was picked. Afterwards, this became ambiguous.
This patch restores the pre-P0522 behavior, `#2` is picked again.

As the consequences are not restricted to partial ordering,
the following code becomes valid:
```C++
template struct A {};
A v;
template class TT> void f(TT);

// OK: TT picks 'float' as the default argument for the second parameter.
void g() { f(v); }
```

Also, since 'f' deduced from `A` is different from 'f'
deduced from `A`, this implements an additional mangling
rule.

---

Since this changes provisional implementation of CWG2398 which has
not been released yet, and already contains a changelog entry,
we don't provide a changelog entry here.
---
 clang-tools-extra/clangd/DumpAST.cpp  |   1 +
 .../clangd/SemanticHighlighting.cpp   |   1 +
 clang/include/clang/AST/ASTContext.h  |   8 +-
 clang/include/clang/AST/ASTImporter.h |   5 +
 clang/include/clang/AST/DependenceFlags.h |   5 +
 clang/include/clang/AST/PropertiesBase.td |  17 ++
 clang/include/clang/AST/TemplateName.h|  59 ++-
 clang/include/clang/Sema/Sema.h   |  10 +-
 clang/lib/AST/ASTContext.cpp  | 129 --
 clang/lib/AST/ASTDiagnostic.cpp   |  24 +--
 clang/lib/AST/ASTImporter.cpp |  15 ++
 clang/lib/AST/ASTStructuralEquivalence.cpp|   3 +
 clang/lib/AST/ItaniumMangle.cpp   |  11 ++
 clang/lib/AST/ODRHash.cpp |   1 +
 clang/lib/AST/TemplateName.cpp| 157 ++
 clang/lib/AST/TextNodeDumper.cpp  |  12 ++
 clang/lib/AST/Type.cpp|   3 +-
 clang/lib/Sema/SemaTemplate.cpp   |  63 +--
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 128 --
 .../lib/Sema/SemaTemplateInstantiateDecl.cpp  |  24 +--
 .../CXX/temp/temp.decls/temp.alias/p2.cpp |   5 +-
 clang/test/CodeGenCXX/mangle-cwg2398.cpp  |  11 ++
 clang/test/SemaTemplate/cwg2398.cpp   |  60 +--
 clang/tools/libclang/CIndex.cpp   |   3 +
 clang/unittests/AST/ASTImporterTest.cpp   |  17 ++
 25 files changed, 564 insertions(+), 208 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/mangle-cwg2398.cpp

diff --git a/clang-tools-extra/clangd/DumpAST.cpp 
b/clang-tools-extra/clangd/DumpAST.cpp
index 9a525efb938e8..e605f82e91fe4 100644
--- a/clang-tools-extra/clangd/DumpAST.cpp
+++ b/clang-tools-extra/clangd/DumpAST.cpp
@@ -187,6 +187,7 @@ class DumpVisitor : public RecursiveASTVisitor 
{
   TEMPLATE_KIND(SubstTemplateTemplateParm);
   TEMPLATE_KIND(SubstTemplateTemplateParmPack);
   TEMPLATE_KIND(UsingTemplate);
+  TEMPLATE_KIND(DeducedTemplate);
 #undef TEMPLATE_KIND
 }
 llvm_unreachable("Unhandled NameKind enum");
diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp 
b/clang-tools-extra/clangd/SemanticHighlighting.cpp
index a366f1331c2d3..e6d16af2495fe 100644
--- a/clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -1120,6 +1120,7 @@ class CollectExtraHighlightings
 case TemplateName::SubstTemplateTemplateParm:
 case TemplateName::SubstTemplateTemplateParmPack:
 case TemplateName::UsingTemplate:
+case TemplateName::DeducedTemplate:
   // Names that could be resolved to a TemplateDecl are handled elsewhere.
   break;
 }
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 8bce4812f0d48..8818314de9364 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -262,6 +262,8 @@ class ASTContext : public RefCountedBase {
   mutable llvm::ContextualFoldingSet
 SubstTemplateTemplateParmPacks;
+  mutable llvm::ContextualFoldingSet
+  DeducedTemplates;
 
   mutable llvm::ContextualFoldingSet
   ArrayParameterTypes;
@@ -2247,6 +2249,9 @@ class ASTContext : public RefCountedBase {
 unsigned Index,

[clang] [Clang] Initialize AtLeastAsSpecialized to prevent undefined behavior in Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs() (PR #95195)

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

mizvekov wrote:

There is no potential UB, this is a false positive: this lambda will always be 
executed before runWithSufficientStackSpace returns.

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


[clang] [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr comparison (PR #95190)

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

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

LGTM, Thanks!

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