Skip to content

Reland: [clang] Improved canonicalization for template specialization types #135414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 12, 2025

Conversation

mizvekov
Copy link
Contributor

@mizvekov mizvekov commented Apr 11, 2025

This relands #135119, after fixing crashes seen in LLDB CI reported here: #135119 (comment)

Fixes #135119

This changes the TemplateArgument representation to hold a flag indicating whether a tempalte argument of expression type is supposed to be canonical or not.

This gets one step closer to solving #92292

This still doesn't try to unique as-written TSTs. While this would increase the amount of memory savings and make code dealing with the AST more well-behaved, profiling template argument lists is still too expensive for this to be worthwhile, at least for now.

This also fixes the context creation of TSTs, so that they don't in some cases get incorrectly flagged as sugar over their own canonical form. This is captured in the test expectation change of some AST dumps.

This fixes some places which were unnecessarily canonicalizing these TSTs.

@mizvekov mizvekov self-assigned this Apr 11, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category clang-tools-extra clangd clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules labels Apr 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 11, 2025

@llvm/pr-subscribers-clang-modules

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)

Changes

This changes the TemplateArgument representation to hold a flag indicating whether a tempalte argument of expression type is supposed to be canonical or not.

This gets one step closer to solving #92292

This still doesn't try to unique as-written TSTs. While this would increase the amount of memory savings and make code dealing with the AST more well-behaved, profiling template argument lists is still too expensive for this to be worthwhile, at least for now.

This also fixes the context creation of TSTs, so that they don't in some cases get incorrectly flagged as sugar over their own canonical form. This is captured in the test expectation change of some AST dumps.

This fixes some places which were unnecessarily canonicalizing these TSTs.


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

29 Files Affected:

  • (modified) .ci/compute_projects.py (+1-1)
  • (modified) clang-tools-extra/clangd/AST.cpp (+2-1)
  • (modified) clang/docs/ReleaseNotes.rst (+2)
  • (modified) clang/include/clang/AST/ASTContext.h (+31-15)
  • (modified) clang/include/clang/AST/PropertiesBase.td (+4-1)
  • (modified) clang/include/clang/AST/TemplateBase.h (+11-2)
  • (modified) clang/include/clang/AST/Type.h (+3-4)
  • (modified) clang/include/clang/AST/TypeProperties.td (+5-25)
  • (modified) clang/lib/AST/ASTContext.cpp (+129-107)
  • (modified) clang/lib/AST/ASTDiagnostic.cpp (+4-4)
  • (modified) clang/lib/AST/ASTImporter.cpp (+21-13)
  • (modified) clang/lib/AST/DeclTemplate.cpp (+5-2)
  • (modified) clang/lib/AST/QualTypeNames.cpp (+2-1)
  • (modified) clang/lib/AST/TemplateBase.cpp (+15-4)
  • (modified) clang/lib/AST/Type.cpp (+27-23)
  • (modified) clang/lib/Sema/SemaCXXScopeSpec.cpp (+8-10)
  • (modified) clang/lib/Sema/SemaExpr.cpp (+17-3)
  • (modified) clang/lib/Sema/SemaLookup.cpp (+2-1)
  • (modified) clang/lib/Sema/SemaTemplate.cpp (+78-84)
  • (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+27-18)
  • (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+6-5)
  • (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+2-1)
  • (modified) clang/lib/Sema/TreeTransform.h (+9-4)
  • (modified) clang/test/CXX/class.derived/class.derived.general/p2.cpp (+1-1)
  • (modified) clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp (+2-2)
  • (modified) clang/test/SemaCXX/undefined-partial-specialization.cpp (+1-1)
  • (modified) clang/test/SemaTemplate/make_integer_seq.cpp (+16-45)
  • (modified) clang/test/SemaTemplate/type_pack_element.cpp (+15-42)
  • (modified) clang/unittests/AST/TypePrinterTest.cpp (+3-3)
diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py
index ff43547c9bbe5..9930998b2e94b 100644
--- a/.ci/compute_projects.py
+++ b/.ci/compute_projects.py
@@ -49,7 +49,7 @@
     },
     "lld": {"bolt", "cross-project-tests"},
     # TODO(issues/132795): LLDB should be enabled on clang changes.
-    "clang": {"clang-tools-extra", "compiler-rt", "cross-project-tests"},
+    "clang": {"clang-tools-extra", "compiler-rt", "cross-project-tests", "lldb"},
     "clang-tools-extra": {"libc"},
     "mlir": {"flang"},
 }
diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp
index 66b587f00ff4a..3b991e5e9013f 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -439,7 +439,8 @@ QualType declaredType(const TypeDecl *D) {
   if (const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(D))
     if (const auto *Args = CTSD->getTemplateArgsAsWritten())
       return Context.getTemplateSpecializationType(
-          TemplateName(CTSD->getSpecializedTemplate()), Args->arguments());
+          TemplateName(CTSD->getSpecializedTemplate()), Args->arguments(),
+          /*CanonicalArgs=*/std::nullopt);
   return Context.getTypeDeclType(D);
 }
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9c45965dc4d82..11f62bc881b03 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -303,6 +303,8 @@ Improvements to Clang's diagnostics
 - Clang now better preserves the sugared types of pointers to member.
 - Clang now better preserves the presence of the template keyword with dependent
   prefixes.
+- Clang now in more cases avoids printing 'type-parameter-X-X' instead of the name of
+  the template parameter.
 - Clang now respects the current language mode when printing expressions in
   diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also
   a bunch of HLSL types being printed as their C++ equivalents.
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index b1e6344576eb5..b8ea2af9215d2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -367,9 +367,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
                                      const ASTContext&>
     CanonTemplateTemplateParms;
 
-  TemplateTemplateParmDecl *
-    getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
-
   /// The typedef for the __int128_t type.
   mutable TypedefDecl *Int128Decl = nullptr;
 
@@ -1811,22 +1808,26 @@ class ASTContext : public RefCountedBase<ASTContext> {
                           bool ParameterPack,
                           TemplateTypeParmDecl *ParmDecl = nullptr) const;
 
-  QualType getTemplateSpecializationType(TemplateName T,
-                                         ArrayRef<TemplateArgument> Args,
-                                         QualType Canon = QualType()) const;
+  QualType getCanonicalTemplateSpecializationType(
+      TemplateName T, ArrayRef<TemplateArgument> CanonicalArgs) const;
 
   QualType
-  getCanonicalTemplateSpecializationType(TemplateName T,
-                                         ArrayRef<TemplateArgument> Args) const;
+  getTemplateSpecializationType(TemplateName T,
+                                ArrayRef<TemplateArgument> SpecifiedArgs,
+                                ArrayRef<TemplateArgument> CanonicalArgs,
+                                QualType Underlying = QualType()) const;
 
-  QualType getTemplateSpecializationType(TemplateName T,
-                                         ArrayRef<TemplateArgumentLoc> Args,
-                                         QualType Canon = QualType()) const;
+  QualType
+  getTemplateSpecializationType(TemplateName T,
+                                ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
+                                ArrayRef<TemplateArgument> CanonicalArgs,
+                                QualType Canon = QualType()) const;
 
-  TypeSourceInfo *
-  getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc,
-                                    const TemplateArgumentListInfo &Args,
-                                    QualType Canon = QualType()) const;
+  TypeSourceInfo *getTemplateSpecializationTypeInfo(
+      TemplateName T, SourceLocation TLoc,
+      const TemplateArgumentListInfo &SpecifiedArgs,
+      ArrayRef<TemplateArgument> CanonicalArgs,
+      QualType Canon = QualType()) const;
 
   QualType getParenType(QualType NamedType) const;
 
@@ -2942,6 +2943,21 @@ class ASTContext : public RefCountedBase<ASTContext> {
   TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg)
     const;
 
+  /// Canonicalize the given template argument list.
+  ///
+  /// Returns true if any arguments were non-canonical, false otherwise.
+  bool
+  canonicalizeTemplateArguments(MutableArrayRef<TemplateArgument> Args) const;
+
+  /// Canonicalize the given TemplateTemplateParmDecl.
+  TemplateTemplateParmDecl *
+  getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
+
+  TemplateTemplateParmDecl *findCanonicalTemplateTemplateParmDeclInternal(
+      TemplateTemplateParmDecl *TTP) const;
+  TemplateTemplateParmDecl *insertCanonicalTemplateTemplateParmDeclInternal(
+      TemplateTemplateParmDecl *CanonTTP) const;
+
   /// Type Query functions.  If the type is an instance of the specified class,
   /// return the Type pointer for the underlying maximally pretty type.  This
   /// is a member of ASTContext because this may need to do some amount of
diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td
index 90537d47dd9c9..33336d57b6298 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -877,11 +877,14 @@ let Class = PropertyTypeCase<TemplateArgument, "Expression"> in {
   def : Property<"expression", ExprRef> {
     let Read = [{ node.getAsExpr() }];
   }
+  def : Property<"IsCanonical", Bool> {
+    let Read = [{ node.isCanonicalExpr() }];
+  }
   def : Property<"isDefaulted", Bool> {
     let Read = [{ node.getIsDefaulted() }];
   }
   def : Creator<[{
-    return TemplateArgument(expression, isDefaulted);
+    return TemplateArgument(expression, IsCanonical, isDefaulted);
   }]>;
 }
 let Class = PropertyTypeCase<TemplateArgument, "Pack"> in {
diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h
index bea624eb04942..279feb858e665 100644
--- a/clang/include/clang/AST/TemplateBase.h
+++ b/clang/include/clang/AST/TemplateBase.h
@@ -167,6 +167,8 @@ class TemplateArgument {
     unsigned Kind : 31;
     LLVM_PREFERRED_TYPE(bool)
     unsigned IsDefaulted : 1;
+    LLVM_PREFERRED_TYPE(bool)
+    unsigned IsCanonicalExpr : 1;
     uintptr_t V;
   };
   union {
@@ -187,7 +189,8 @@ class TemplateArgument {
 
 public:
   /// Construct an empty, invalid template argument.
-  constexpr TemplateArgument() : TypeOrValue({Null, 0, /* IsDefaulted */ 0}) {}
+  constexpr TemplateArgument()
+      : TypeOrValue{Null, /*IsDefaulted=*/0, /*IsCanonicalExpr=*/0, /*V=*/0} {}
 
   /// Construct a template type argument.
   TemplateArgument(QualType T, bool isNullPtr = false,
@@ -262,9 +265,10 @@ class TemplateArgument {
   /// This form of template argument only occurs in template argument
   /// lists used for dependent types and for expression; it will not
   /// occur in a non-dependent, canonical template argument list.
-  explicit TemplateArgument(Expr *E, bool IsDefaulted = false) {
+  TemplateArgument(Expr *E, bool IsCanonical, bool IsDefaulted = false) {
     TypeOrValue.Kind = Expression;
     TypeOrValue.IsDefaulted = IsDefaulted;
+    TypeOrValue.IsCanonicalExpr = IsCanonical;
     TypeOrValue.V = reinterpret_cast<uintptr_t>(E);
   }
 
@@ -407,6 +411,11 @@ class TemplateArgument {
     return reinterpret_cast<Expr *>(TypeOrValue.V);
   }
 
+  bool isCanonicalExpr() const {
+    assert(getKind() == Expression && "Unexpected kind");
+    return TypeOrValue.IsCanonicalExpr;
+  }
+
   /// Iterator that traverses the elements of a template argument pack.
   using pack_iterator = const TemplateArgument *;
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 9f6189440fabf..dc57170bf9160 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6676,10 +6676,9 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode {
   /// replacement must, recursively, be one of these).
   TemplateName Template;
 
-  TemplateSpecializationType(TemplateName T,
+  TemplateSpecializationType(TemplateName T, bool IsAlias,
                              ArrayRef<TemplateArgument> Args,
-                             QualType Canon,
-                             QualType Aliased);
+                             QualType Underlying);
 
 public:
   /// Determine whether any of the given template arguments are dependent.
@@ -6747,7 +6746,7 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode {
 
   void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx);
   static void Profile(llvm::FoldingSetNodeID &ID, TemplateName T,
-                      ArrayRef<TemplateArgument> Args,
+                      ArrayRef<TemplateArgument> Args, QualType Underlying,
                       const ASTContext &Context);
 
   static bool classof(const Type *T) {
diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td
index 66d490850678a..3bf9239e9cbf5 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -737,39 +737,19 @@ let Class = DependentAddressSpaceType in {
 }
 
 let Class = TemplateSpecializationType in {
-  def : Property<"dependent", Bool> {
-    let Read = [{ node->isDependentType() }];
-  }
   def : Property<"templateName", TemplateName> {
     let Read = [{ node->getTemplateName() }];
   }
-  def : Property<"templateArguments", Array<TemplateArgument>> {
+  def : Property<"args", Array<TemplateArgument>> {
     let Read = [{ node->template_arguments() }];
   }
-  def : Property<"underlyingType", Optional<QualType>> {
-    let Read = [{
-      node->isTypeAlias()
-        ? std::optional<QualType>(node->getAliasedType())
-        : node->isCanonicalUnqualified()
-            ? std::nullopt
-            : std::optional<QualType>(node->getCanonicalTypeInternal())
-    }];
+  def : Property<"UnderlyingType", QualType> {
+    let Read = [{ node->isCanonicalUnqualified() ? QualType() :
+                                                   node->desugar() }];
   }
 
   def : Creator<[{
-    QualType result;
-    if (!underlyingType) {
-      result = ctx.getCanonicalTemplateSpecializationType(templateName,
-                                                          templateArguments);
-    } else {
-      result = ctx.getTemplateSpecializationType(templateName,
-                                                 templateArguments,
-                                                 *underlyingType);
-    }
-    if (dependent)
-      const_cast<Type *>(result.getTypePtr())
-          ->addDependence(TypeDependence::DependentInstantiation);
-    return result;
+    return ctx.getTemplateSpecializationType(templateName, args, std::nullopt, UnderlyingType);
   }]>;
 }
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 00e2fa267a460..b8e6245230475 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -844,6 +844,31 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
   return CanonTTP;
 }
 
+TemplateTemplateParmDecl *
+ASTContext::findCanonicalTemplateTemplateParmDeclInternal(
+    TemplateTemplateParmDecl *TTP) const {
+  llvm::FoldingSetNodeID ID;
+  CanonicalTemplateTemplateParm::Profile(ID, *this, TTP);
+  void *InsertPos = nullptr;
+  CanonicalTemplateTemplateParm *Canonical =
+      CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
+  return Canonical ? Canonical->getParam() : nullptr;
+}
+
+TemplateTemplateParmDecl *
+ASTContext::insertCanonicalTemplateTemplateParmDeclInternal(
+    TemplateTemplateParmDecl *CanonTTP) const {
+  llvm::FoldingSetNodeID ID;
+  CanonicalTemplateTemplateParm::Profile(ID, *this, CanonTTP);
+  void *InsertPos = nullptr;
+  if (auto *Existing =
+          CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos))
+    return Existing->getParam();
+  CanonTemplateTemplateParms.InsertNode(
+      new (*this) CanonicalTemplateTemplateParm(CanonTTP), InsertPos);
+  return CanonTTP;
+}
+
 /// Check if a type can have its sanitizer instrumentation elided based on its
 /// presence within an ignorelist.
 bool ASTContext::isTypeIgnoredBySanitizer(const SanitizerMask &Mask,
@@ -3083,12 +3108,19 @@ static auto getCanonicalTemplateArguments(const ASTContext &C,
                                           ArrayRef<TemplateArgument> Args,
                                           bool &AnyNonCanonArgs) {
   SmallVector<TemplateArgument, 16> CanonArgs(Args);
-  for (auto &Arg : CanonArgs) {
+  AnyNonCanonArgs |= C.canonicalizeTemplateArguments(CanonArgs);
+  return CanonArgs;
+}
+
+bool ASTContext::canonicalizeTemplateArguments(
+    MutableArrayRef<TemplateArgument> Args) const {
+  bool AnyNonCanonArgs = false;
+  for (auto &Arg : Args) {
     TemplateArgument OrigArg = Arg;
-    Arg = C.getCanonicalTemplateArgument(Arg);
+    Arg = getCanonicalTemplateArgument(Arg);
     AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
   }
-  return CanonArgs;
+  return AnyNonCanonArgs;
 }
 
 //===----------------------------------------------------------------------===//
@@ -5538,129 +5570,118 @@ QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index,
   return QualType(TypeParm, 0);
 }
 
-TypeSourceInfo *
-ASTContext::getTemplateSpecializationTypeInfo(TemplateName Name,
-                                              SourceLocation NameLoc,
-                                        const TemplateArgumentListInfo &Args,
-                                              QualType Underlying) const {
-  assert(!Name.getAsDependentTemplateName() &&
-         "No dependent template names here!");
-  QualType TST =
-      getTemplateSpecializationType(Name, Args.arguments(), Underlying);
+TypeSourceInfo *ASTContext::getTemplateSpecializationTypeInfo(
+    TemplateName Name, SourceLocation NameLoc,
+    const TemplateArgumentListInfo &SpecifiedArgs,
+    ArrayRef<TemplateArgument> CanonicalArgs, QualType Underlying) const {
+  QualType TST = getTemplateSpecializationType(Name, SpecifiedArgs.arguments(),
+                                               CanonicalArgs, Underlying);
 
   TypeSourceInfo *DI = CreateTypeSourceInfo(TST);
   TemplateSpecializationTypeLoc TL =
       DI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>();
   TL.setTemplateKeywordLoc(SourceLocation());
   TL.setTemplateNameLoc(NameLoc);
-  TL.setLAngleLoc(Args.getLAngleLoc());
-  TL.setRAngleLoc(Args.getRAngleLoc());
+  TL.setLAngleLoc(SpecifiedArgs.getLAngleLoc());
+  TL.setRAngleLoc(SpecifiedArgs.getRAngleLoc());
   for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
-    TL.setArgLocInfo(i, Args[i].getLocInfo());
+    TL.setArgLocInfo(i, SpecifiedArgs[i].getLocInfo());
   return DI;
 }
 
-QualType
-ASTContext::getTemplateSpecializationType(TemplateName Template,
-                                          ArrayRef<TemplateArgumentLoc> Args,
-                                          QualType Underlying) const {
-  assert(!Template.getAsDependentTemplateName() &&
-         "No dependent template names here!");
+QualType ASTContext::getTemplateSpecializationType(
+    TemplateName Template, ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
+    ArrayRef<TemplateArgument> CanonicalArgs, QualType Underlying) const {
+  SmallVector<TemplateArgument, 4> SpecifiedArgVec;
+  SpecifiedArgVec.reserve(SpecifiedArgs.size());
+  for (const TemplateArgumentLoc &Arg : SpecifiedArgs)
+    SpecifiedArgVec.push_back(Arg.getArgument());
 
-  SmallVector<TemplateArgument, 4> ArgVec;
-  ArgVec.reserve(Args.size());
-  for (const TemplateArgumentLoc &Arg : Args)
-    ArgVec.push_back(Arg.getArgument());
-
-  return getTemplateSpecializationType(Template, ArgVec, Underlying);
+  return getTemplateSpecializationType(Template, SpecifiedArgVec, CanonicalArgs,
+                                       Underlying);
 }
 
-#ifndef NDEBUG
-static bool hasAnyPackExpansions(ArrayRef<TemplateArgument> Args) {
+[[maybe_unused]] static bool
+hasAnyPackExpansions(ArrayRef<TemplateArgument> Args) {
   for (const TemplateArgument &Arg : Args)
     if (Arg.isPackExpansion())
       return true;
-
-  return true;
+  return false;
 }
-#endif
 
-QualType
-ASTContext::getTemplateSpecializationType(TemplateName Template,
-                                          ArrayRef<TemplateArgument> Args,
-                                          QualType Underlying) const {
-  assert(!Template.getAsDependentTemplateName() &&
-         "No dependent template names here!");
+QualType ASTContext::getCanonicalTemplateSpecializationType(
+    TemplateName Template, ArrayRef<TemplateArgument> Args) const {
+  assert(Template ==
+         getCanonicalTemplateName(Template, /*IgnoreDeduced=*/true));
+  assert(!Args.empty());
+#ifndef NDEBUG
+  for (const auto &Arg : Args)
+    assert(Arg.structurallyEquals(getCanonicalTemplateArgument(Arg)));
+#endif
 
-  const auto *TD = Template.getAsTemplateDecl(/*IgnoreDeduced=*/true);
-  bool IsTypeAlias = TD && TD->isTypeAlias();
-  QualType CanonType;
-  if (!Underlying.isNull())
-    CanonType = getCanonicalType(Underlying);
-  else {
-    // We can get here with an alias template when the specialization contains
-    // a pack expansion that does not match up with a parameter pack.
-    assert((!IsTypeAlias || hasAnyPackExpansions(Args)) &&
-           "Caller must compute aliased type");
-    IsTypeAlias = false;
-    CanonType = getCanonicalTemplateSpecializationType(Template, Args);
-  }
+  llvm::FoldingSetNodeID ID;
+  TemplateSpecializationType::Profile(ID, Template, Args, QualType(), *this);
+  void *InsertPos = nullptr;
+  if (auto *T = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
+    return QualType(T, 0);
 
-  // Allocate the (non-canonical) template specialization type, but don't
-  // try to unique it: these types typically have location information that
-  // we don't unique and don't want to lose.
   void *Mem = Allocate(sizeof(TemplateSpecializationType) +
-                           sizeof(TemplateArgument) * Args.size() +
-                           (IsTypeAlias ? sizeof(QualType) : 0),
+                           sizeof(TemplateArgument) * Args.size(),
                        alignof(TemplateSpecializationType));
-  auto *Spec
-    = new (Mem) TemplateSpecializationType(Template, Args, CanonType,
-                                         IsTypeAlias ? Underlying : QualType());
-
+  auto *Spec = new (Mem)
+      TemplateSpecializationType(Template, /*IsAlias=*/false, Args, QualType());
+  assert(Spec->isDependentType() &&
+         "canonical template specialization must be dependent");
   Types.push_back(Spec);
+  TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
   return QualType(Spec, 0);
 }
 
-QualType ASTContext::getCanonicalTemplateSpecializationType(
-    TemplateName Template, ArrayRef<TemplateArgument> Args) const {
-  assert(!Template.getAsDependentTemplateName() &&
+QualType ASTContext::getTemplateSpecializationType(
+    TemplateName Template, ArrayRef<TemplateArgument> SpecifiedArgs,
+    ArrayRef<TemplateArgument> CanonicalArgs, QualType Underlying) const {
+  assert(!Template.getUnderlying().getAsDependentTemplateName() &&
          "No dependent template names here!");
 
-  // Build the canonical template specialization type.
-  // Any DeducedTemplateNames are ignored, because the effective name of a TST
-  // accounts for the TST arguments laid over any default arguments contained in
-  // its name.
-  TemplateName CanonTemplate =
-      getCanonicalTemplateName(Template, /*IgnoreDeduced=*/true);
-
-  bool AnyNonCanonArgs = false;
-  auto CanonArgs =
-      ::getCanonicalTemplateArguments(*this, Args, AnyNonCanonArgs);
-
-  // Determine whether this canonical template specialization type already
-  // exists.
-  llvm::FoldingSetNodeID ID;
-  Template...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Apr 11, 2025

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

Author: Matheus Izvekov (mizvekov)

Changes

This changes the TemplateArgument representation to hold a flag indicating whether a tempalte argument of expression type is supposed to be canonical or not.

This gets one step closer to solving #92292

This still doesn't try to unique as-written TSTs. While this would increase the amount of memory savings and make code dealing with the AST more well-behaved, profiling template argument lists is still too expensive for this to be worthwhile, at least for now.

This also fixes the context creation of TSTs, so that they don't in some cases get incorrectly flagged as sugar over their own canonical form. This is captured in the test expectation change of some AST dumps.

This fixes some places which were unnecessarily canonicalizing these TSTs.


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

29 Files Affected:

  • (modified) .ci/compute_projects.py (+1-1)
  • (modified) clang-tools-extra/clangd/AST.cpp (+2-1)
  • (modified) clang/docs/ReleaseNotes.rst (+2)
  • (modified) clang/include/clang/AST/ASTContext.h (+31-15)
  • (modified) clang/include/clang/AST/PropertiesBase.td (+4-1)
  • (modified) clang/include/clang/AST/TemplateBase.h (+11-2)
  • (modified) clang/include/clang/AST/Type.h (+3-4)
  • (modified) clang/include/clang/AST/TypeProperties.td (+5-25)
  • (modified) clang/lib/AST/ASTContext.cpp (+129-107)
  • (modified) clang/lib/AST/ASTDiagnostic.cpp (+4-4)
  • (modified) clang/lib/AST/ASTImporter.cpp (+21-13)
  • (modified) clang/lib/AST/DeclTemplate.cpp (+5-2)
  • (modified) clang/lib/AST/QualTypeNames.cpp (+2-1)
  • (modified) clang/lib/AST/TemplateBase.cpp (+15-4)
  • (modified) clang/lib/AST/Type.cpp (+27-23)
  • (modified) clang/lib/Sema/SemaCXXScopeSpec.cpp (+8-10)
  • (modified) clang/lib/Sema/SemaExpr.cpp (+17-3)
  • (modified) clang/lib/Sema/SemaLookup.cpp (+2-1)
  • (modified) clang/lib/Sema/SemaTemplate.cpp (+78-84)
  • (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+27-18)
  • (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+6-5)
  • (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+2-1)
  • (modified) clang/lib/Sema/TreeTransform.h (+9-4)
  • (modified) clang/test/CXX/class.derived/class.derived.general/p2.cpp (+1-1)
  • (modified) clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp (+2-2)
  • (modified) clang/test/SemaCXX/undefined-partial-specialization.cpp (+1-1)
  • (modified) clang/test/SemaTemplate/make_integer_seq.cpp (+16-45)
  • (modified) clang/test/SemaTemplate/type_pack_element.cpp (+15-42)
  • (modified) clang/unittests/AST/TypePrinterTest.cpp (+3-3)
diff --git a/.ci/compute_projects.py b/.ci/compute_projects.py
index ff43547c9bbe5..9930998b2e94b 100644
--- a/.ci/compute_projects.py
+++ b/.ci/compute_projects.py
@@ -49,7 +49,7 @@
     },
     "lld": {"bolt", "cross-project-tests"},
     # TODO(issues/132795): LLDB should be enabled on clang changes.
-    "clang": {"clang-tools-extra", "compiler-rt", "cross-project-tests"},
+    "clang": {"clang-tools-extra", "compiler-rt", "cross-project-tests", "lldb"},
     "clang-tools-extra": {"libc"},
     "mlir": {"flang"},
 }
diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp
index 66b587f00ff4a..3b991e5e9013f 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -439,7 +439,8 @@ QualType declaredType(const TypeDecl *D) {
   if (const auto *CTSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(D))
     if (const auto *Args = CTSD->getTemplateArgsAsWritten())
       return Context.getTemplateSpecializationType(
-          TemplateName(CTSD->getSpecializedTemplate()), Args->arguments());
+          TemplateName(CTSD->getSpecializedTemplate()), Args->arguments(),
+          /*CanonicalArgs=*/std::nullopt);
   return Context.getTypeDeclType(D);
 }
 
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9c45965dc4d82..11f62bc881b03 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -303,6 +303,8 @@ Improvements to Clang's diagnostics
 - Clang now better preserves the sugared types of pointers to member.
 - Clang now better preserves the presence of the template keyword with dependent
   prefixes.
+- Clang now in more cases avoids printing 'type-parameter-X-X' instead of the name of
+  the template parameter.
 - Clang now respects the current language mode when printing expressions in
   diagnostics. This fixes a bunch of `bool` being printed as `_Bool`, and also
   a bunch of HLSL types being printed as their C++ equivalents.
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index b1e6344576eb5..b8ea2af9215d2 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -367,9 +367,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
                                      const ASTContext&>
     CanonTemplateTemplateParms;
 
-  TemplateTemplateParmDecl *
-    getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
-
   /// The typedef for the __int128_t type.
   mutable TypedefDecl *Int128Decl = nullptr;
 
@@ -1811,22 +1808,26 @@ class ASTContext : public RefCountedBase<ASTContext> {
                           bool ParameterPack,
                           TemplateTypeParmDecl *ParmDecl = nullptr) const;
 
-  QualType getTemplateSpecializationType(TemplateName T,
-                                         ArrayRef<TemplateArgument> Args,
-                                         QualType Canon = QualType()) const;
+  QualType getCanonicalTemplateSpecializationType(
+      TemplateName T, ArrayRef<TemplateArgument> CanonicalArgs) const;
 
   QualType
-  getCanonicalTemplateSpecializationType(TemplateName T,
-                                         ArrayRef<TemplateArgument> Args) const;
+  getTemplateSpecializationType(TemplateName T,
+                                ArrayRef<TemplateArgument> SpecifiedArgs,
+                                ArrayRef<TemplateArgument> CanonicalArgs,
+                                QualType Underlying = QualType()) const;
 
-  QualType getTemplateSpecializationType(TemplateName T,
-                                         ArrayRef<TemplateArgumentLoc> Args,
-                                         QualType Canon = QualType()) const;
+  QualType
+  getTemplateSpecializationType(TemplateName T,
+                                ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
+                                ArrayRef<TemplateArgument> CanonicalArgs,
+                                QualType Canon = QualType()) const;
 
-  TypeSourceInfo *
-  getTemplateSpecializationTypeInfo(TemplateName T, SourceLocation TLoc,
-                                    const TemplateArgumentListInfo &Args,
-                                    QualType Canon = QualType()) const;
+  TypeSourceInfo *getTemplateSpecializationTypeInfo(
+      TemplateName T, SourceLocation TLoc,
+      const TemplateArgumentListInfo &SpecifiedArgs,
+      ArrayRef<TemplateArgument> CanonicalArgs,
+      QualType Canon = QualType()) const;
 
   QualType getParenType(QualType NamedType) const;
 
@@ -2942,6 +2943,21 @@ class ASTContext : public RefCountedBase<ASTContext> {
   TemplateArgument getCanonicalTemplateArgument(const TemplateArgument &Arg)
     const;
 
+  /// Canonicalize the given template argument list.
+  ///
+  /// Returns true if any arguments were non-canonical, false otherwise.
+  bool
+  canonicalizeTemplateArguments(MutableArrayRef<TemplateArgument> Args) const;
+
+  /// Canonicalize the given TemplateTemplateParmDecl.
+  TemplateTemplateParmDecl *
+  getCanonicalTemplateTemplateParmDecl(TemplateTemplateParmDecl *TTP) const;
+
+  TemplateTemplateParmDecl *findCanonicalTemplateTemplateParmDeclInternal(
+      TemplateTemplateParmDecl *TTP) const;
+  TemplateTemplateParmDecl *insertCanonicalTemplateTemplateParmDeclInternal(
+      TemplateTemplateParmDecl *CanonTTP) const;
+
   /// Type Query functions.  If the type is an instance of the specified class,
   /// return the Type pointer for the underlying maximally pretty type.  This
   /// is a member of ASTContext because this may need to do some amount of
diff --git a/clang/include/clang/AST/PropertiesBase.td b/clang/include/clang/AST/PropertiesBase.td
index 90537d47dd9c9..33336d57b6298 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -877,11 +877,14 @@ let Class = PropertyTypeCase<TemplateArgument, "Expression"> in {
   def : Property<"expression", ExprRef> {
     let Read = [{ node.getAsExpr() }];
   }
+  def : Property<"IsCanonical", Bool> {
+    let Read = [{ node.isCanonicalExpr() }];
+  }
   def : Property<"isDefaulted", Bool> {
     let Read = [{ node.getIsDefaulted() }];
   }
   def : Creator<[{
-    return TemplateArgument(expression, isDefaulted);
+    return TemplateArgument(expression, IsCanonical, isDefaulted);
   }]>;
 }
 let Class = PropertyTypeCase<TemplateArgument, "Pack"> in {
diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h
index bea624eb04942..279feb858e665 100644
--- a/clang/include/clang/AST/TemplateBase.h
+++ b/clang/include/clang/AST/TemplateBase.h
@@ -167,6 +167,8 @@ class TemplateArgument {
     unsigned Kind : 31;
     LLVM_PREFERRED_TYPE(bool)
     unsigned IsDefaulted : 1;
+    LLVM_PREFERRED_TYPE(bool)
+    unsigned IsCanonicalExpr : 1;
     uintptr_t V;
   };
   union {
@@ -187,7 +189,8 @@ class TemplateArgument {
 
 public:
   /// Construct an empty, invalid template argument.
-  constexpr TemplateArgument() : TypeOrValue({Null, 0, /* IsDefaulted */ 0}) {}
+  constexpr TemplateArgument()
+      : TypeOrValue{Null, /*IsDefaulted=*/0, /*IsCanonicalExpr=*/0, /*V=*/0} {}
 
   /// Construct a template type argument.
   TemplateArgument(QualType T, bool isNullPtr = false,
@@ -262,9 +265,10 @@ class TemplateArgument {
   /// This form of template argument only occurs in template argument
   /// lists used for dependent types and for expression; it will not
   /// occur in a non-dependent, canonical template argument list.
-  explicit TemplateArgument(Expr *E, bool IsDefaulted = false) {
+  TemplateArgument(Expr *E, bool IsCanonical, bool IsDefaulted = false) {
     TypeOrValue.Kind = Expression;
     TypeOrValue.IsDefaulted = IsDefaulted;
+    TypeOrValue.IsCanonicalExpr = IsCanonical;
     TypeOrValue.V = reinterpret_cast<uintptr_t>(E);
   }
 
@@ -407,6 +411,11 @@ class TemplateArgument {
     return reinterpret_cast<Expr *>(TypeOrValue.V);
   }
 
+  bool isCanonicalExpr() const {
+    assert(getKind() == Expression && "Unexpected kind");
+    return TypeOrValue.IsCanonicalExpr;
+  }
+
   /// Iterator that traverses the elements of a template argument pack.
   using pack_iterator = const TemplateArgument *;
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 9f6189440fabf..dc57170bf9160 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6676,10 +6676,9 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode {
   /// replacement must, recursively, be one of these).
   TemplateName Template;
 
-  TemplateSpecializationType(TemplateName T,
+  TemplateSpecializationType(TemplateName T, bool IsAlias,
                              ArrayRef<TemplateArgument> Args,
-                             QualType Canon,
-                             QualType Aliased);
+                             QualType Underlying);
 
 public:
   /// Determine whether any of the given template arguments are dependent.
@@ -6747,7 +6746,7 @@ class TemplateSpecializationType : public Type, public llvm::FoldingSetNode {
 
   void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Ctx);
   static void Profile(llvm::FoldingSetNodeID &ID, TemplateName T,
-                      ArrayRef<TemplateArgument> Args,
+                      ArrayRef<TemplateArgument> Args, QualType Underlying,
                       const ASTContext &Context);
 
   static bool classof(const Type *T) {
diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td
index 66d490850678a..3bf9239e9cbf5 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -737,39 +737,19 @@ let Class = DependentAddressSpaceType in {
 }
 
 let Class = TemplateSpecializationType in {
-  def : Property<"dependent", Bool> {
-    let Read = [{ node->isDependentType() }];
-  }
   def : Property<"templateName", TemplateName> {
     let Read = [{ node->getTemplateName() }];
   }
-  def : Property<"templateArguments", Array<TemplateArgument>> {
+  def : Property<"args", Array<TemplateArgument>> {
     let Read = [{ node->template_arguments() }];
   }
-  def : Property<"underlyingType", Optional<QualType>> {
-    let Read = [{
-      node->isTypeAlias()
-        ? std::optional<QualType>(node->getAliasedType())
-        : node->isCanonicalUnqualified()
-            ? std::nullopt
-            : std::optional<QualType>(node->getCanonicalTypeInternal())
-    }];
+  def : Property<"UnderlyingType", QualType> {
+    let Read = [{ node->isCanonicalUnqualified() ? QualType() :
+                                                   node->desugar() }];
   }
 
   def : Creator<[{
-    QualType result;
-    if (!underlyingType) {
-      result = ctx.getCanonicalTemplateSpecializationType(templateName,
-                                                          templateArguments);
-    } else {
-      result = ctx.getTemplateSpecializationType(templateName,
-                                                 templateArguments,
-                                                 *underlyingType);
-    }
-    if (dependent)
-      const_cast<Type *>(result.getTypePtr())
-          ->addDependence(TypeDependence::DependentInstantiation);
-    return result;
+    return ctx.getTemplateSpecializationType(templateName, args, std::nullopt, UnderlyingType);
   }]>;
 }
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 00e2fa267a460..b8e6245230475 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -844,6 +844,31 @@ ASTContext::getCanonicalTemplateTemplateParmDecl(
   return CanonTTP;
 }
 
+TemplateTemplateParmDecl *
+ASTContext::findCanonicalTemplateTemplateParmDeclInternal(
+    TemplateTemplateParmDecl *TTP) const {
+  llvm::FoldingSetNodeID ID;
+  CanonicalTemplateTemplateParm::Profile(ID, *this, TTP);
+  void *InsertPos = nullptr;
+  CanonicalTemplateTemplateParm *Canonical =
+      CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos);
+  return Canonical ? Canonical->getParam() : nullptr;
+}
+
+TemplateTemplateParmDecl *
+ASTContext::insertCanonicalTemplateTemplateParmDeclInternal(
+    TemplateTemplateParmDecl *CanonTTP) const {
+  llvm::FoldingSetNodeID ID;
+  CanonicalTemplateTemplateParm::Profile(ID, *this, CanonTTP);
+  void *InsertPos = nullptr;
+  if (auto *Existing =
+          CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos))
+    return Existing->getParam();
+  CanonTemplateTemplateParms.InsertNode(
+      new (*this) CanonicalTemplateTemplateParm(CanonTTP), InsertPos);
+  return CanonTTP;
+}
+
 /// Check if a type can have its sanitizer instrumentation elided based on its
 /// presence within an ignorelist.
 bool ASTContext::isTypeIgnoredBySanitizer(const SanitizerMask &Mask,
@@ -3083,12 +3108,19 @@ static auto getCanonicalTemplateArguments(const ASTContext &C,
                                           ArrayRef<TemplateArgument> Args,
                                           bool &AnyNonCanonArgs) {
   SmallVector<TemplateArgument, 16> CanonArgs(Args);
-  for (auto &Arg : CanonArgs) {
+  AnyNonCanonArgs |= C.canonicalizeTemplateArguments(CanonArgs);
+  return CanonArgs;
+}
+
+bool ASTContext::canonicalizeTemplateArguments(
+    MutableArrayRef<TemplateArgument> Args) const {
+  bool AnyNonCanonArgs = false;
+  for (auto &Arg : Args) {
     TemplateArgument OrigArg = Arg;
-    Arg = C.getCanonicalTemplateArgument(Arg);
+    Arg = getCanonicalTemplateArgument(Arg);
     AnyNonCanonArgs |= !Arg.structurallyEquals(OrigArg);
   }
-  return CanonArgs;
+  return AnyNonCanonArgs;
 }
 
 //===----------------------------------------------------------------------===//
@@ -5538,129 +5570,118 @@ QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index,
   return QualType(TypeParm, 0);
 }
 
-TypeSourceInfo *
-ASTContext::getTemplateSpecializationTypeInfo(TemplateName Name,
-                                              SourceLocation NameLoc,
-                                        const TemplateArgumentListInfo &Args,
-                                              QualType Underlying) const {
-  assert(!Name.getAsDependentTemplateName() &&
-         "No dependent template names here!");
-  QualType TST =
-      getTemplateSpecializationType(Name, Args.arguments(), Underlying);
+TypeSourceInfo *ASTContext::getTemplateSpecializationTypeInfo(
+    TemplateName Name, SourceLocation NameLoc,
+    const TemplateArgumentListInfo &SpecifiedArgs,
+    ArrayRef<TemplateArgument> CanonicalArgs, QualType Underlying) const {
+  QualType TST = getTemplateSpecializationType(Name, SpecifiedArgs.arguments(),
+                                               CanonicalArgs, Underlying);
 
   TypeSourceInfo *DI = CreateTypeSourceInfo(TST);
   TemplateSpecializationTypeLoc TL =
       DI->getTypeLoc().castAs<TemplateSpecializationTypeLoc>();
   TL.setTemplateKeywordLoc(SourceLocation());
   TL.setTemplateNameLoc(NameLoc);
-  TL.setLAngleLoc(Args.getLAngleLoc());
-  TL.setRAngleLoc(Args.getRAngleLoc());
+  TL.setLAngleLoc(SpecifiedArgs.getLAngleLoc());
+  TL.setRAngleLoc(SpecifiedArgs.getRAngleLoc());
   for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
-    TL.setArgLocInfo(i, Args[i].getLocInfo());
+    TL.setArgLocInfo(i, SpecifiedArgs[i].getLocInfo());
   return DI;
 }
 
-QualType
-ASTContext::getTemplateSpecializationType(TemplateName Template,
-                                          ArrayRef<TemplateArgumentLoc> Args,
-                                          QualType Underlying) const {
-  assert(!Template.getAsDependentTemplateName() &&
-         "No dependent template names here!");
+QualType ASTContext::getTemplateSpecializationType(
+    TemplateName Template, ArrayRef<TemplateArgumentLoc> SpecifiedArgs,
+    ArrayRef<TemplateArgument> CanonicalArgs, QualType Underlying) const {
+  SmallVector<TemplateArgument, 4> SpecifiedArgVec;
+  SpecifiedArgVec.reserve(SpecifiedArgs.size());
+  for (const TemplateArgumentLoc &Arg : SpecifiedArgs)
+    SpecifiedArgVec.push_back(Arg.getArgument());
 
-  SmallVector<TemplateArgument, 4> ArgVec;
-  ArgVec.reserve(Args.size());
-  for (const TemplateArgumentLoc &Arg : Args)
-    ArgVec.push_back(Arg.getArgument());
-
-  return getTemplateSpecializationType(Template, ArgVec, Underlying);
+  return getTemplateSpecializationType(Template, SpecifiedArgVec, CanonicalArgs,
+                                       Underlying);
 }
 
-#ifndef NDEBUG
-static bool hasAnyPackExpansions(ArrayRef<TemplateArgument> Args) {
+[[maybe_unused]] static bool
+hasAnyPackExpansions(ArrayRef<TemplateArgument> Args) {
   for (const TemplateArgument &Arg : Args)
     if (Arg.isPackExpansion())
       return true;
-
-  return true;
+  return false;
 }
-#endif
 
-QualType
-ASTContext::getTemplateSpecializationType(TemplateName Template,
-                                          ArrayRef<TemplateArgument> Args,
-                                          QualType Underlying) const {
-  assert(!Template.getAsDependentTemplateName() &&
-         "No dependent template names here!");
+QualType ASTContext::getCanonicalTemplateSpecializationType(
+    TemplateName Template, ArrayRef<TemplateArgument> Args) const {
+  assert(Template ==
+         getCanonicalTemplateName(Template, /*IgnoreDeduced=*/true));
+  assert(!Args.empty());
+#ifndef NDEBUG
+  for (const auto &Arg : Args)
+    assert(Arg.structurallyEquals(getCanonicalTemplateArgument(Arg)));
+#endif
 
-  const auto *TD = Template.getAsTemplateDecl(/*IgnoreDeduced=*/true);
-  bool IsTypeAlias = TD && TD->isTypeAlias();
-  QualType CanonType;
-  if (!Underlying.isNull())
-    CanonType = getCanonicalType(Underlying);
-  else {
-    // We can get here with an alias template when the specialization contains
-    // a pack expansion that does not match up with a parameter pack.
-    assert((!IsTypeAlias || hasAnyPackExpansions(Args)) &&
-           "Caller must compute aliased type");
-    IsTypeAlias = false;
-    CanonType = getCanonicalTemplateSpecializationType(Template, Args);
-  }
+  llvm::FoldingSetNodeID ID;
+  TemplateSpecializationType::Profile(ID, Template, Args, QualType(), *this);
+  void *InsertPos = nullptr;
+  if (auto *T = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
+    return QualType(T, 0);
 
-  // Allocate the (non-canonical) template specialization type, but don't
-  // try to unique it: these types typically have location information that
-  // we don't unique and don't want to lose.
   void *Mem = Allocate(sizeof(TemplateSpecializationType) +
-                           sizeof(TemplateArgument) * Args.size() +
-                           (IsTypeAlias ? sizeof(QualType) : 0),
+                           sizeof(TemplateArgument) * Args.size(),
                        alignof(TemplateSpecializationType));
-  auto *Spec
-    = new (Mem) TemplateSpecializationType(Template, Args, CanonType,
-                                         IsTypeAlias ? Underlying : QualType());
-
+  auto *Spec = new (Mem)
+      TemplateSpecializationType(Template, /*IsAlias=*/false, Args, QualType());
+  assert(Spec->isDependentType() &&
+         "canonical template specialization must be dependent");
   Types.push_back(Spec);
+  TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
   return QualType(Spec, 0);
 }
 
-QualType ASTContext::getCanonicalTemplateSpecializationType(
-    TemplateName Template, ArrayRef<TemplateArgument> Args) const {
-  assert(!Template.getAsDependentTemplateName() &&
+QualType ASTContext::getTemplateSpecializationType(
+    TemplateName Template, ArrayRef<TemplateArgument> SpecifiedArgs,
+    ArrayRef<TemplateArgument> CanonicalArgs, QualType Underlying) const {
+  assert(!Template.getUnderlying().getAsDependentTemplateName() &&
          "No dependent template names here!");
 
-  // Build the canonical template specialization type.
-  // Any DeducedTemplateNames are ignored, because the effective name of a TST
-  // accounts for the TST arguments laid over any default arguments contained in
-  // its name.
-  TemplateName CanonTemplate =
-      getCanonicalTemplateName(Template, /*IgnoreDeduced=*/true);
-
-  bool AnyNonCanonArgs = false;
-  auto CanonArgs =
-      ::getCanonicalTemplateArguments(*this, Args, AnyNonCanonArgs);
-
-  // Determine whether this canonical template specialization type already
-  // exists.
-  llvm::FoldingSetNodeID ID;
-  Template...
[truncated]

@mizvekov
Copy link
Contributor Author

Adding lldb back to the ci script, as otherwise lldb cannot be tested locally.

@slydiman
Copy link
Contributor

slydiman commented Apr 11, 2025

Note lldb-x86_64-debian and lldb-aarch64-windows did not fail because they used gcc and msvc to build lldb. But failed lldb tests required the latest clang (the cross build). I will test this patch on the environment similar to lldb-remote-linux-win.

@mizvekov mizvekov force-pushed the users/mizvekov/tst-refactor branch 3 times, most recently from 10f5545 to 2898180 Compare April 11, 2025 21:07
@slydiman
Copy link
Contributor

I have tested the initial commit f8e6b60

The issue is still there

Assertion failed: Arg.structurallyEquals(getCanonicalTemplateArgument(Arg)), file D:\as\mainline\llvm-project\clang\lib\AST\ASTContext.cpp, line 5619
 Windows fatal exception: code 0x80000003

Current thread 0x00006b58 (most recent call first):
  File "D:\test\build-lldb\Lib\site-packages\lldb\__init__.py", line 6539 in EvaluateExpression
  File "D:\test\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 2547 in expect_expr
  File "D:\test\llvm-project\lldb\test\API\commands\expression\import-std-module\array\TestArrayFromStdModule.py", line 29 in test
  File "D:\test\llvm-project\lldb\packages\Python\lldbsuite\test\decorators.py", line 148 in wrapper
  File "D:\test\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 1804 in test_method
  File "C:\Python312\Lib\unittest\case.py", line 589 in _callTestMethod
  File "C:\Python312\Lib\unittest\case.py", line 634 in run
  File "C:\Python312\Lib\unittest\case.py", line 690 in __call__
  File "C:\Python312\Lib\unittest\suite.py", line 122 in run
  File "C:\Python312\Lib\unittest\suite.py", line 84 in __call__
  File "C:\Python312\Lib\unittest\suite.py", line 122 in run
  File "C:\Python312\Lib\unittest\suite.py", line 84 in __call__
  File "C:\Python312\Lib\unittest\runner.py", line 240 in run
  File "D:\test\llvm-project\lldb\packages\Python\lldbsuite\test\dotest.py", line 1108 in run_suite
  File "D:\test\llvm-project\lldb\test\API\dotest.py", line 8 in <module>
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Exception Code: 0x80000003
  #0 0x00007ffd386632f5 PyInit__lldb (D:\test\build-lldb\Lib\site-packages\lldb\_lldb.cp312-win_amd64.pyd+0x9f32f5)
  #1 0x00007ffe13a71989 (C:\WINDOWS\System32\ucrtbase.dll+0xc1989)
  #2 0x00007ffe13a54ab1 (C:\WINDOWS\System32\ucrtbase.dll+0xa4ab1)
  #3 0x00007ffe13a72986 (C:\WINDOWS\System32\ucrtbase.dll+0xc2986)
  #4 0x00007ffe13a72b61 (C:\WINDOWS\System32\ucrtbase.dll+0xc2b61)
  #5 0x00007ffd3af1f959 PyInit__lldb (D:\test\build-lldb\Lib\site-packages\lldb\_lldb.cp312-win_amd64.pyd+0x32af959)
  #6 0x00007ffd3b18d481 PyInit__lldb (D:\test\build-lldb\Lib\site-packages\lldb\_lldb.cp312-win_amd64.pyd+0x351d481)
...

I will rebuild the debug version to get the useful stack trace.

@mizvekov
Copy link
Contributor Author

Thanks, yeah this relanding was just to try to get LLDB CI up and running, which I am still trying.

@mizvekov mizvekov force-pushed the users/mizvekov/tst-refactor branch 3 times, most recently from c490e8d to 5290f09 Compare April 11, 2025 21:45
@slydiman
Copy link
Contributor

slydiman commented Apr 11, 2025

I tried the single test
C:/Python312/python_d.exe D:/test/llvm-project/lldb/test/API/dotest.py ... D:/test/llvm-project/lldb/test/API/commands/expression/import-std-module/array -p TestArrayFromStdModule.py

Here is the debug stack trace:

runCmd: settings set target.import-std-module true
output: 

Assertion failed: Arg.structurallyEquals(getCanonicalTemplateArgument(Arg)), file D:\test\llvm-project\clang\lib\AST\ASTContext.cpp, line 5619
 Windows fatal exception: code 0x80000003
 
Current thread 0x00006a18 (most recent call first):
  File "D:\test\build-lldb\Lib\site-packages\lldb\__init__.py", line 6539 in EvaluateExpression
  File "D:\test\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 2547 in expect_expr
  File "D:\test\llvm-project\lldb\test\API\commands\expression\import-std-module\array\TestArrayFromStdModule.py", line 29 in test
  File "D:\test\llvm-project\lldb\packages\Python\lldbsuite\test\decorators.py", line 148 in wrapper
  File "D:\test\llvm-project\lldb\packages\Python\lldbsuite\test\lldbtest.py", line 1804 in test_method
  File "C:\Python312\Lib\unittest\case.py", line 589 in _callTestMethod
  File "C:\Python312\Lib\unittest\case.py", line 634 in run
  File "C:\Python312\Lib\unittest\case.py", line 690 in __call__
  File "C:\Python312\Lib\unittest\suite.py", line 122 in run
  File "C:\Python312\Lib\unittest\suite.py", line 84 in __call__
  File "C:\Python312\Lib\unittest\suite.py", line 122 in run
  File "C:\Python312\Lib\unittest\suite.py", line 84 in __call__
  File "C:\Python312\Lib\unittest\runner.py", line 240 in run
  File "D:\test\llvm-project\lldb\packages\Python\lldbsuite\test\dotest.py", line 1108 in run_suite
  File "D:\test\llvm-project\lldb\test\API\dotest.py", line 8 in <module>
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Exception Code: 0x80000003
  #0 0x00007ffd2b9f5bac HandleAbort D:\test\llvm-project\llvm\lib\Support\Windows\Signals.inc:429:0
  #1 0x00007ffdcdf390ed (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa90ed)
  #2 0x00007ffdcdf3ae49 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xaae49)
  #3 0x00007ffdcdf40c6f (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xb0c6f)
  #4 0x00007ffdcdf3eba1 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xaeba1)
  #5 0x00007ffdcdf418af (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xb18af)
  #6 0x00007ffd33b0afe1 clang::ASTContext::getCanonicalTemplateSpecializationType(class clang::TemplateName, class llvm::ArrayRef<class clang::TemplateArgument>) const D:\test\llvm-project\clang\lib\AST\ASTContext.cpp:5619:0
  #7 0x00007ffd340cff87 clang::ASTNodeImporter::VisitTemplateSpecializationType(class clang::TemplateSpecializationType const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:1665:0
  #8 0x00007ffd34184739 clang::TypeVisitor<class clang::ASTNodeImporter, class llvm::Expected<class clang::QualType>>::Visit(class clang::Type const *) D:\test\build-lldb\tools\clang\include\clang\AST\TypeNodes.inc:77:0
  #9 0x00007ffd340b9a49 clang::ASTImporter::Import(class clang::Type const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9166:0
 #10 0x00007ffd340b9c23 clang::ASTImporter::Import(class clang::QualType) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9180:0
 #11 0x00007ffd34156589 clang::ASTNodeImporter::import<class clang::QualType>(class clang::QualType const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:217:0
 #12 0x00007ffd340cffe8 clang::ASTNodeImporter::VisitTemplateSpecializationType(class clang::TemplateSpecializationType const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:1669:0
 #13 0x00007ffd34184739 clang::TypeVisitor<class clang::ASTNodeImporter, class llvm::Expected<class clang::QualType>>::Visit(class clang::Type const *) D:\test\build-lldb\tools\clang\include\clang\AST\TypeNodes.inc:77:0
 #14 0x00007ffd340b9a49 clang::ASTImporter::Import(class clang::Type const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9166:0
 #15 0x00007ffd340bd0b3 clang::ASTImporter::Import(class clang::NestedNameSpecifier *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9795:0
 #16 0x00007ffd34161596 clang::ASTImporter::importInto<class clang::NestedNameSpecifier *>(class clang::NestedNameSpecifier *&, class clang::NestedNameSpecifier *const &) D:\test\llvm-project\clang\include\clang\AST\ASTImporter.h:310:0
 #17 0x00007ffd340bd375 clang::ASTImporter::Import(class clang::NestedNameSpecifierLoc) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9823:0
 #18 0x00007ffd3415557b clang::ASTNodeImporter::import<class clang::NestedNameSpecifierLoc>(class clang::NestedNameSpecifierLoc const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:217:0
 #19 0x00007ffd34160edd clang::ASTNodeImporter::importChecked<class clang::NestedNameSpecifierLoc>(class llvm::Error &, class clang::NestedNameSpecifierLoc const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
 #20 0x00007ffd34108489 clang::ASTNodeImporter::VisitDependentScopeDeclRefExpr(class clang::DependentScopeDeclRefExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8561:0
 #21 0x00007ffd3417d423 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:462:0
 #22 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
 #23 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
 #24 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #25 0x00007ffd3415e4fc clang::ASTNodeImporter::importChecked<class clang::Expr *>(class llvm::Error &, class clang::Expr *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
 #26 0x00007ffd34100c08 clang::ASTNodeImporter::VisitBinaryOperator(class clang::BinaryOperator *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7819:0
 #27 0x00007ffd34185229 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::VisitBinLAnd(class clang::BinaryOperator *) D:\test\llvm-project\clang\include\clang\AST\StmtVisitor.h:138:0
 #28 0x00007ffd3417ada6 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\llvm-project\clang\include\clang\AST\StmtVisitor.h:72:0
 #29 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
 #30 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
 #31 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #32 0x00007ffd34102942 clang::ASTNodeImporter::VisitImplicitCastExpr(class clang::ImplicitCastExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7973:0
 #33 0x00007ffd3417d7d9 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:534:0
 #34 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
 #35 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
 #36 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #37 0x00007ffd34111476 clang::ASTNodeImporter::import<class clang::TemplateArgument>(class clang::TemplateArgument const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:895:0
 #38 0x00007ffd340d7271 clang::ASTNodeImporter::ImportTemplateArguments(class llvm::ArrayRef<class clang::TemplateArgument>, class llvm::SmallVectorImpl<class clang::TemplateArgument> &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:2447:0
 #39 0x00007ffd340cfe37 clang::ASTNodeImporter::VisitTemplateSpecializationType(class clang::TemplateSpecializationType const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:1660:0
 #40 0x00007ffd34184739 clang::TypeVisitor<class clang::ASTNodeImporter, class llvm::Expected<class clang::QualType>>::Visit(class clang::Type const *) D:\test\build-lldb\tools\clang\include\clang\AST\TypeNodes.inc:77:0
 #41 0x00007ffd340b9a49 clang::ASTImporter::Import(class clang::Type const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9166:0
 #42 0x00007ffd340b9c23 clang::ASTImporter::Import(class clang::QualType) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9180:0
 #43 0x00007ffd34156589 clang::ASTNodeImporter::import<class clang::QualType>(class clang::QualType const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:217:0
 #44 0x00007ffd340cc6e5 clang::ASTNodeImporter::VisitElaboratedType(class clang::ElaboratedType const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:1682:0
 #45 0x00007ffd34184469 clang::TypeVisitor<class clang::ASTNodeImporter, class llvm::Expected<class clang::QualType>>::Visit(class clang::Type const *) D:\test\build-lldb\tools\clang\include\clang\AST\TypeNodes.inc:49:0
 #46 0x00007ffd340b9a49 clang::ASTImporter::Import(class clang::Type const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9166:0
 #47 0x00007ffd340b9c23 clang::ASTImporter::Import(class clang::QualType) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9180:0
 #48 0x00007ffd34156589 clang::ASTNodeImporter::import<class clang::QualType>(class clang::QualType const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:217:0
 #49 0x00007ffd340cffe8 clang::ASTNodeImporter::VisitTemplateSpecializationType(class clang::TemplateSpecializationType const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:1669:0
 #50 0x00007ffd34184739 clang::TypeVisitor<class clang::ASTNodeImporter, class llvm::Expected<class clang::QualType>>::Visit(class clang::Type const *) D:\test\build-lldb\tools\clang\include\clang\AST\TypeNodes.inc:77:0
 #51 0x00007ffd340b9a49 clang::ASTImporter::Import(class clang::Type const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9166:0
 #52 0x00007ffd340b9c23 clang::ASTImporter::Import(class clang::QualType) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9180:0
 #53 0x00007ffd34156589 clang::ASTNodeImporter::import<class clang::QualType>(class clang::QualType const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:217:0
 #54 0x00007ffd340cc6e5 clang::ASTNodeImporter::VisitElaboratedType(class clang::ElaboratedType const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:1682:0
 #55 0x00007ffd34184469 clang::TypeVisitor<class clang::ASTNodeImporter, class llvm::Expected<class clang::QualType>>::Visit(class clang::Type const *) D:\test\build-lldb\tools\clang\include\clang\AST\TypeNodes.inc:49:0
 #56 0x00007ffd340b9a49 clang::ASTImporter::Import(class clang::Type const *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9166:0
 #57 0x00007ffd340b9c23 clang::ASTImporter::Import(class clang::QualType) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9180:0
 #58 0x00007ffd34156589 clang::ASTNodeImporter::import<class clang::QualType>(class clang::QualType const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:217:0
 #59 0x00007ffd34110b94 clang::ASTNodeImporter::import<class clang::TemplateArgument>(class clang::TemplateArgument const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:833:0
 #60 0x00007ffd341117f5 clang::ASTNodeImporter::import<class clang::TemplateArgumentLoc>(class clang::TemplateArgumentLoc const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:919:0
 #61 0x00007ffd34162f6b clang::ASTNodeImporter::importTemplateParameterDefaultArgument<class clang::TemplateTypeParmDecl>(class clang::TemplateTypeParmDecl const *, class clang::TemplateTypeParmDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:388:0
 #62 0x00007ffd340eee2d clang::ASTNodeImporter::VisitTemplateTypeParmDecl(class clang::TemplateTypeParmDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:5983:0
 #63 0x00007ffd341793b6 clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:500:0
 #64 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
 #65 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
 #66 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
 #67 0x00007ffd341551ef clang::ASTNodeImporter::import<class clang::NamedDecl>(class clang::NamedDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #68 0x00007ffd341489b6 clang::ASTNodeImporter::ImportArrayChecked<class clang::NamedDecl *const *, class clang::NamedDecl **>(class clang::NamedDecl *const *, class clang::NamedDecl *const *, class clang::NamedDecl **) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:705:0
 #69 0x00007ffd3414a439 clang::ASTNodeImporter::ImportContainerChecked<class clang::TemplateParameterList, class llvm::SmallVector<class clang::NamedDecl *, 4>>(class clang::TemplateParameterList const &, class llvm::SmallVector<class clang::NamedDecl *, 4> &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:719:0
 #70 0x00007ffd34110500 clang::ASTNodeImporter::import<class clang::TemplateParameterList>(class clang::TemplateParameterList *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:798:0
 #71 0x00007ffd340f461c clang::ASTNodeImporter::VisitFunctionTemplateDecl(class clang::FunctionTemplateDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6734:0
 #72 0x00007ffd3417950e clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:536:0
 #73 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
 #74 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
 #75 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
 #76 0x00007ffd341551ef clang::ASTNodeImporter::import<class clang::NamedDecl>(class clang::NamedDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #77 0x00007ffd341090bc clang::ASTNodeImporter::VisitUnresolvedLookupExpr(class clang::UnresolvedLookupExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8630:0
 #78 0x00007ffd3417c2bc clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:180:0
 #79 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
 #80 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
 #81 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #82 0x00007ffd3415e4fc clang::ASTNodeImporter::importChecked<class clang::Expr *>(class llvm::Error &, class clang::Expr *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
 #83 0x00007ffd3410bc09 clang::ASTNodeImporter::VisitCallExpr(class clang::CallExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8713:0
 #84 0x00007ffd3417dbf3 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:614:0
 #85 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
 #86 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
 #87 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #88 0x00007ffd3415e4fc clang::ASTNodeImporter::importChecked<class clang::Expr *>(class llvm::Error &, class clang::Expr *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
 #89 0x00007ffd340f7006 clang::ASTNodeImporter::VisitIfStmt(class clang::IfStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7002:0
 #90 0x00007ffd341817cf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1604:0
 #91 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
 #92 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #93 0x00007ffd3415f0dc clang::ASTNodeImporter::importChecked<class clang::Stmt *>(class llvm::Error &, class clang::Stmt *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
 #94 0x00007ffd340f77de clang::ASTNodeImporter::VisitWhileStmt(class clang::WhileStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7057:0
 #95 0x00007ffd3417ba08 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:24:0
 #96 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
 #97 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
 #98 0x00007ffd34148416 clang::ASTNodeImporter::ImportArrayChecked<class clang::Stmt **, class clang::Stmt **>(class clang::Stmt **, class clang::Stmt **, class clang::Stmt **) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:705:0
 #99 0x00007ffd3414a019 clang::ASTNodeImporter::ImportContainerChecked<class llvm::iterator_range<class clang::Stmt **>, class llvm::SmallVector<class clang::Stmt *, 8>>(class llvm::iterator_range<class clang::Stmt **> const &, class llvm::SmallVector<class clang::Stmt *, 8> &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:719:0
#100 0x00007ffd340f6080 clang::ASTNodeImporter::VisitCompoundStmt(class clang::CompoundStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6918:0
#101 0x00007ffd34181aaf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1652:0
#102 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#103 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#104 0x00007ffd340d8086 clang::ASTNodeImporter::ImportFunctionDeclBody(class clang::FunctionDecl *, class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:3509:0
#105 0x00007ffd340e17c6 clang::ASTNodeImporter::VisitFunctionDecl(class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:4111:0
#106 0x00007ffd341787f5 clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:256:0
#107 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#108 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
#109 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
#110 0x00007ffd34161b41 clang::ASTNodeImporter::importInto<class clang::FunctionDecl>(class clang::FunctionDecl *&, class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:192:0
#111 0x00007ffd340f46c1 clang::ASTNodeImporter::VisitFunctionTemplateDecl(class clang::FunctionTemplateDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6739:0
#112 0x00007ffd3417950e clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:536:0
#113 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#114 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
#115 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
#116 0x00007ffd341551ef clang::ASTNodeImporter::import<class clang::NamedDecl>(class clang::NamedDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#117 0x00007ffd341090bc clang::ASTNodeImporter::VisitUnresolvedLookupExpr(class clang::UnresolvedLookupExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8630:0
#118 0x00007ffd3417c2bc clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:180:0
#119 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#120 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
#121 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#122 0x00007ffd3415e4fc clang::ASTNodeImporter::importChecked<class clang::Expr *>(class llvm::Error &, class clang::Expr *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#123 0x00007ffd3410bc09 clang::ASTNodeImporter::VisitCallExpr(class clang::CallExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8713:0
#124 0x00007ffd3417dbf3 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:614:0
#125 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#126 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
#127 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#128 0x00007ffd3415e4fc clang::ASTNodeImporter::importChecked<class clang::Expr *>(class llvm::Error &, class clang::Expr *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#129 0x00007ffd34100418 clang::ASTNodeImporter::VisitUnaryOperator(class clang::UnaryOperator *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7769:0
#130 0x00007ffd3418b7c9 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::VisitUnaryDeref(class clang::UnaryOperator *) D:\test\llvm-project\clang\include\clang\AST\StmtVisitor.h:164:0
#131 0x00007ffd3417b5f4 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\llvm-project\clang\include\clang\AST\StmtVisitor.h:94:0
#132 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#133 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
#134 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#135 0x00007ffd3415e4fc clang::ASTNodeImporter::importChecked<class clang::Expr *>(class llvm::Error &, class clang::Expr *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#136 0x00007ffd340f86d6 clang::ASTNodeImporter::VisitReturnStmt(class clang::ReturnStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7147:0
#137 0x00007ffd3417edf5 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:944:0
#138 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#139 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#140 0x00007ffd34148416 clang::ASTNodeImporter::ImportArrayChecked<class clang::Stmt **, class clang::Stmt **>(class clang::Stmt **, class clang::Stmt **, class clang::Stmt **) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:705:0
#141 0x00007ffd3414a019 clang::ASTNodeImporter::ImportContainerChecked<class llvm::iterator_range<class clang::Stmt **>, class llvm::SmallVector<class clang::Stmt *, 8>>(class llvm::iterator_range<class clang::Stmt **> const &, class llvm::SmallVector<class clang::Stmt *, 8> &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:719:0
#142 0x00007ffd340f6080 clang::ASTNodeImporter::VisitCompoundStmt(class clang::CompoundStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6918:0
#143 0x00007ffd34181aaf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1652:0
#144 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#145 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#146 0x00007ffd340d8086 clang::ASTNodeImporter::ImportFunctionDeclBody(class clang::FunctionDecl *, class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:3509:0
#147 0x00007ffd340e17c6 clang::ASTNodeImporter::VisitFunctionDecl(class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:4111:0
#148 0x00007ffd341787f5 clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:256:0
#149 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#150 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
#151 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
#152 0x00007ffd34161b41 clang::ASTNodeImporter::importInto<class clang::FunctionDecl>(class clang::FunctionDecl *&, class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:192:0
#153 0x00007ffd340f46c1 clang::ASTNodeImporter::VisitFunctionTemplateDecl(class clang::FunctionTemplateDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6739:0
#154 0x00007ffd3417950e clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:536:0
#155 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#156 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
#157 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
#158 0x00007ffd341551ef clang::ASTNodeImporter::import<class clang::NamedDecl>(class clang::NamedDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#159 0x00007ffd341090bc clang::ASTNodeImporter::VisitUnresolvedLookupExpr(class clang::UnresolvedLookupExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8630:0
#160 0x00007ffd3417c2bc clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:180:0
#161 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#162 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
#163 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#164 0x00007ffd3415e4fc clang::ASTNodeImporter::importChecked<class clang::Expr *>(class llvm::Error &, class clang::Expr *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#165 0x00007ffd3410bc09 clang::ASTNodeImporter::VisitCallExpr(class clang::CallExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8713:0
#166 0x00007ffd3417dbf3 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:614:0
#167 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#168 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
#169 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#170 0x00007ffd340d43aa clang::ASTNodeImporter::ImportInitializer(class clang::VarDecl *, class clang::VarDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:2394:0
#171 0x00007ffd340e590f clang::ASTNodeImporter::VisitVarDecl(class clang::VarDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:4661:0
#172 0x00007ffd341789f9 clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:296:0
#173 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#174 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
#175 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
#176 0x00007ffd3415435f clang::ASTNodeImporter::import<class clang::Decl>(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#177 0x00007ffd34111f61 clang::ASTNodeImporter::import<class clang::DeclGroupRef>(class clang::DeclGroupRef const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:964:0
#178 0x00007ffd34160c36 clang::ASTNodeImporter::importChecked<class clang::DeclGroupRef>(class llvm::Error &, class clang::DeclGroupRef const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#179 0x00007ffd340f5d06 clang::ASTNodeImporter::VisitDeclStmt(class clang::DeclStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6900:0
#180 0x00007ffd3418192b clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1628:0
#181 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#182 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#183 0x00007ffd34148416 clang::ASTNodeImporter::ImportArrayChecked<class clang::Stmt **, class clang::Stmt **>(class clang::Stmt **, class clang::Stmt **, class clang::Stmt **) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:705:0
#184 0x00007ffd3414a019 clang::ASTNodeImporter::ImportContainerChecked<class llvm::iterator_range<class clang::Stmt **>, class llvm::SmallVector<class clang::Stmt *, 8>>(class llvm::iterator_range<class clang::Stmt **> const &, class llvm::SmallVector<class clang::Stmt *, 8> &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:719:0
#185 0x00007ffd340f6080 clang::ASTNodeImporter::VisitCompoundStmt(class clang::CompoundStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6918:0
#186 0x00007ffd34181aaf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1652:0
#187 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#188 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#189 0x00007ffd3415f0dc clang::ASTNodeImporter::importChecked<class clang::Stmt *>(class llvm::Error &, class clang::Stmt *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#190 0x00007ffd340f70a1 clang::ASTNodeImporter::VisitIfStmt(class clang::IfStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7005:0
#191 0x00007ffd341817cf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1604:0
#192 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#193 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#194 0x00007ffd34148416 clang::ASTNodeImporter::ImportArrayChecked<class clang::Stmt **, class clang::Stmt **>(class clang::Stmt **, class clang::Stmt **, class clang::Stmt **) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:705:0
#195 0x00007ffd3414a019 clang::ASTNodeImporter::ImportContainerChecked<class llvm::iterator_range<class clang::Stmt **>, class llvm::SmallVector<class clang::Stmt *, 8>>(class llvm::iterator_range<class clang::Stmt **> const &, class llvm::SmallVector<class clang::Stmt *, 8> &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:719:0
#196 0x00007ffd340f6080 clang::ASTNodeImporter::VisitCompoundStmt(class clang::CompoundStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6918:0
#197 0x00007ffd34181aaf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1652:0
#198 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#199 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#200 0x00007ffd340d8086 clang::ASTNodeImporter::ImportFunctionDeclBody(class clang::FunctionDecl *, class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:3509:0
#201 0x00007ffd340e17c6 clang::ASTNodeImporter::VisitFunctionDecl(class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:4111:0
#202 0x00007ffd341787f5 clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:256:0
#203 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#204 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
#205 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
#206 0x00007ffd34161b41 clang::ASTNodeImporter::importInto<class clang::FunctionDecl>(class clang::FunctionDecl *&, class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:192:0
#207 0x00007ffd340f46c1 clang::ASTNodeImporter::VisitFunctionTemplateDecl(class clang::FunctionTemplateDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6739:0
#208 0x00007ffd3417950e clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:536:0
#209 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#210 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
#211 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
#212 0x00007ffd341551ef clang::ASTNodeImporter::import<class clang::NamedDecl>(class clang::NamedDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#213 0x00007ffd341090bc clang::ASTNodeImporter::VisitUnresolvedLookupExpr(class clang::UnresolvedLookupExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8630:0
#214 0x00007ffd3417c2bc clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:180:0
#215 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#216 0x00007ffd340bc779 clang::ASTImporter::Import(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9720:0
#217 0x00007ffd3415478f clang::ASTNodeImporter::import<class clang::Expr>(class clang::Expr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#218 0x00007ffd3415e4fc clang::ASTNodeImporter::importChecked<class clang::Expr *>(class llvm::Error &, class clang::Expr *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#219 0x00007ffd3410bc09 clang::ASTNodeImporter::VisitCallExpr(class clang::CallExpr *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:8713:0
#220 0x00007ffd3417dbf3 clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:614:0
#221 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#222 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#223 0x00007ffd3415f0dc clang::ASTNodeImporter::importChecked<class clang::Stmt *>(class llvm::Error &, class clang::Stmt *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#224 0x00007ffd340f70a1 clang::ASTNodeImporter::VisitIfStmt(class clang::IfStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7005:0
#225 0x00007ffd341817cf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1604:0
#226 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#227 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#228 0x00007ffd34148416 clang::ASTNodeImporter::ImportArrayChecked<class clang::Stmt **, class clang::Stmt **>(class clang::Stmt **, class clang::Stmt **, class clang::Stmt **) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:705:0
#229 0x00007ffd3414a019 clang::ASTNodeImporter::ImportContainerChecked<class llvm::iterator_range<class clang::Stmt **>, class llvm::SmallVector<class clang::Stmt *, 8>>(class llvm::iterator_range<class clang::Stmt **> const &, class llvm::SmallVector<class clang::Stmt *, 8> &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:719:0
#230 0x00007ffd340f6080 clang::ASTNodeImporter::VisitCompoundStmt(class clang::CompoundStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6918:0
#231 0x00007ffd34181aaf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1652:0
#232 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#233 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#234 0x00007ffd3415f0dc clang::ASTNodeImporter::importChecked<class clang::Stmt *>(class llvm::Error &, class clang::Stmt *const &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:693:0
#235 0x00007ffd340f70a1 clang::ASTNodeImporter::VisitIfStmt(class clang::IfStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:7005:0
#236 0x00007ffd341817cf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1604:0
#237 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#238 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#239 0x00007ffd34148416 clang::ASTNodeImporter::ImportArrayChecked<class clang::Stmt **, class clang::Stmt **>(class clang::Stmt **, class clang::Stmt **, class clang::Stmt **) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:705:0
#240 0x00007ffd3414a019 clang::ASTNodeImporter::ImportContainerChecked<class llvm::iterator_range<class clang::Stmt **>, class llvm::SmallVector<class clang::Stmt *, 8>>(class llvm::iterator_range<class clang::Stmt **> const &, class llvm::SmallVector<class clang::Stmt *, 8> &) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:719:0
#241 0x00007ffd340f6080 clang::ASTNodeImporter::VisitCompoundStmt(class clang::CompoundStmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6918:0
#242 0x00007ffd34181aaf clang::StmtVisitorBase<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Stmt *>>::Visit(class clang::Stmt *) D:\test\build-lldb\tools\clang\include\clang\AST\StmtNodes.inc:1652:0
#243 0x00007ffd340bc975 clang::ASTImporter::Import(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9738:0
#244 0x00007ffd3415684f clang::ASTNodeImporter::import<class clang::Stmt>(class clang::Stmt *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:204:0
#245 0x00007ffd340d8086 clang::ASTNodeImporter::ImportFunctionDeclBody(class clang::FunctionDecl *, class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:3509:0
#246 0x00007ffd340e17c6 clang::ASTNodeImporter::VisitFunctionDecl(class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:4111:0
#247 0x00007ffd341787f5 clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:256:0
#248 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#249 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0
#250 0x00007ffd340bb38f clang::ASTImporter::Import(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9530:0
#251 0x00007ffd34161b41 clang::ASTNodeImporter::importInto<class clang::FunctionDecl>(class clang::FunctionDecl *&, class clang::FunctionDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:192:0
#252 0x00007ffd340f46c1 clang::ASTNodeImporter::VisitFunctionTemplateDecl(class clang::FunctionTemplateDecl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:6739:0
#253 0x00007ffd3417950e clang::declvisitor::Base<struct std::add_pointer, class clang::ASTNodeImporter, class llvm::Expected<class clang::Decl *>>::Visit(class clang::Decl *) D:\test\build-lldb\tools\clang\include\clang\AST\DeclNodes.inc:536:0
#254 0x00007ffd340b93f7 clang::ASTImporter::ImportImpl(class clang::Decl *) D:\test\llvm-project\clang\lib\AST\ASTImporter.cpp:9134:0
#255 0x00007ffd2d593993 lldb_private::ClangASTImporter::ASTImporterDelegate::ImportImpl(class clang::Decl *) D:\test\llvm-project\lldb\source\Plugins\ExpressionParser\Clang\ClangASTImporter.cpp:1134:0

@mizvekov mizvekov force-pushed the users/mizvekov/tst-refactor branch from 5290f09 to 2d4b74f Compare April 11, 2025 22:07
@mizvekov
Copy link
Contributor Author

Thanks, that narrows it down a lot!

I still wish I could test lldb locally. I will keep trying.

@slydiman
Copy link
Contributor

I still wish I could test lldb locally. I will keep trying.

Please note lldb uses the system's debugserver on macOS. But on other systems (Linux, Windows) it uses its own lldb-server. You may not be able to reproduce the problem on macOS.

@mizvekov
Copy link
Contributor Author

mizvekov commented Apr 11, 2025

@slydiman

Thanks. You can see I made changes to our CI in this PR, and I managed to enable lldb, enable python testing and everything, but everything still passes in the lldb test suite.

This is a linux system too, so it should be capable to reproduce this, right?

Can you help get this CI up to reproducing this problem?

@mizvekov mizvekov force-pushed the users/mizvekov/tst-refactor branch from 2d4b74f to 4f5c7ec Compare April 11, 2025 23:26
Copy link

github-actions bot commented Apr 11, 2025

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

@mizvekov mizvekov force-pushed the users/mizvekov/tst-refactor branch from 4f5c7ec to 01b1863 Compare April 11, 2025 23:30
@mizvekov
Copy link
Contributor Author

Nevermind, I managed to do it :)

@mizvekov mizvekov force-pushed the users/mizvekov/tst-refactor branch 2 times, most recently from 105942e to 2b33b96 Compare April 12, 2025 03:42
@mizvekov mizvekov force-pushed the users/mizvekov/tst-refactor branch 7 times, most recently from 935935a to 338a836 Compare April 12, 2025 16:21
… types

This changes the TemplateArgument representation to hold a flag indicating
whether a tempalte argument of expression type is supposed to be canonical
or not.

This gets one step closer to solving #92292

This still doesn't try to unique as-written TSTs. While this would
increase the amount of memory savings and make code dealing with
the AST more well-behaved, profiling template argument lists is
still too expensive for this to be worthwhile, at least for now.

This also fixes the context creation of TSTs, so that they don't
in some cases get incorrectly flagged as sugar over their own canonical
form. This is captured in the test expectation change of some AST dumps.

This fixes some places which were unnecessarily canonicalizing these TSTs.
This makes sure UnaryTransformTypes are all uniqued,
which makes the AST node more well behaved, and helps
with aka suppression in diagnostics.

This also makes sure a canonical UnaryTransformType round trips
back to a canonical type when recreated from its components.
This makes sure a canonical DecltypeType round-trips back to a
canonical type when rebuilt from its components.
@mizvekov mizvekov force-pushed the users/mizvekov/tst-refactor branch from 338a836 to d1a9483 Compare April 12, 2025 16:55
@mizvekov mizvekov merged commit 761787d into main Apr 12, 2025
12 checks passed
@mizvekov mizvekov deleted the users/mizvekov/tst-refactor branch April 12, 2025 17:26
@llvm-ci
Copy link
Collaborator

llvm-ci commented Apr 12, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-fast running on sanitizer-buildbot4 while building clang-tools-extra,clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/10397

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 90177 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80
FAIL: Clang :: Interpreter/global-dtor.cpp (37396 of 90177)
******************** TEST 'Clang :: Interpreter/global-dtor.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
cat /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang-repl | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp # RUN: at line 6
+ cat /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang-repl
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp
JIT session error: In graph incr_module_10-jitted-objectbuffer, section .text.startup: relocation target "__dso_handle" at address 0x7c63462ba000 is out of range of Delta32 fixup at 0x786344e0d02f (<anonymous block> @ 0x786344e0d010 + 0x1f)
error: Failed to materialize symbols: { (main, { $.incr_module_10.__inits.0, _ZN1DC2Ev, __clang_call_terminate, DW.ref.__gxx_personality_v0, d, _ZN1DD2Ev, __orc_init_func.incr_module_10 }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_10 }) }
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp:11:11: error: CHECK: expected string not found in input
// CHECK: D[f=1.000000, m=0x0]
          ^
<stdin>:1:1: note: scanning from here
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
^
<stdin>:1:11: note: possible intended match here
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
          ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl>  
check:11'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:11'1               ?                                                                                                                                                   possible intended match
>>>>>>

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
Step 10 (stage2/asan_ubsan check) failure: stage2/asan_ubsan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:520: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 90177 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80
FAIL: Clang :: Interpreter/global-dtor.cpp (37396 of 90177)
******************** TEST 'Clang :: Interpreter/global-dtor.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
cat /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang-repl | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp # RUN: at line 6
+ cat /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/clang-repl
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_asan_ubsan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp
JIT session error: In graph incr_module_10-jitted-objectbuffer, section .text.startup: relocation target "__dso_handle" at address 0x7c63462ba000 is out of range of Delta32 fixup at 0x786344e0d02f (<anonymous block> @ 0x786344e0d010 + 0x1f)
error: Failed to materialize symbols: { (main, { $.incr_module_10.__inits.0, _ZN1DC2Ev, __clang_call_terminate, DW.ref.__gxx_personality_v0, d, _ZN1DD2Ev, __orc_init_func.incr_module_10 }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_10 }) }
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp:11:11: error: CHECK: expected string not found in input
// CHECK: D[f=1.000000, m=0x0]
          ^
<stdin>:1:1: note: scanning from here
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
^
<stdin>:1:11: note: possible intended match here
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
          ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Interpreter/global-dtor.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl>  
check:11'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
check:11'1               ?                                                                                                                                                   possible intended match
>>>>>>

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 

var-const pushed a commit to ldionne/llvm-project that referenced this pull request Apr 17, 2025
… types (llvm#135414)

This relands llvm#135119, after
fixing crashes seen in LLDB CI reported here:
llvm#135119 (comment)

Fixes llvm#135119

This changes the TemplateArgument representation to hold a flag
indicating whether a tempalte argument of expression type is supposed to
be canonical or not.

This gets one step closer to solving
llvm#92292

This still doesn't try to unique as-written TSTs. While this would
increase the amount of memory savings and make code dealing with the AST
more well-behaved, profiling template argument lists is still too
expensive for this to be worthwhile, at least for now.

This also fixes the context creation of TSTs, so that they don't in some
cases get incorrectly flagged as sugar over their own canonical form.
This is captured in the test expectation change of some AST dumps.

This fixes some places which were unnecessarily canonicalizing these
TSTs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:modules C++20 modules and Clang Header Modules clang Clang issues not falling into any other category clang-tools-extra clangd
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants