[clang][AST][NFC] Expose clang::isSubstitutedDefaultArgument to clang/AST consumers
authorMichael Buch <michaelbuch12@gmail.com>
Thu, 15 Dec 2022 21:26:33 +0000 (21:26 +0000)
committerMichael Buch <michaelbuch12@gmail.com>
Fri, 16 Dec 2022 11:38:50 +0000 (11:38 +0000)
**Summary**
A use-case has come up in DWARF CodeGen where we want to determine
whether a particular template argument matches the default template
parameter declaration.

Re-using this TypePrinter component there allows us to avoid duplicating
most of this code and immediately allows us to cover a wider range
of use-cases than the DWARF CodeGen does today.

clang/include/clang/AST/Type.h
clang/lib/AST/TypePrinter.cpp

index 70f2132..54896e7 100644 (file)
@@ -5462,6 +5462,13 @@ void printTemplateArgumentList(raw_ostream &OS,
                                const PrintingPolicy &Policy,
                                const TemplateParameterList *TPL = nullptr);
 
+/// Make a best-effort determination of whether the type T can be produced by
+/// substituting Args into the default argument of Param.
+bool isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg,
+                                  const NamedDecl *Param,
+                                  ArrayRef<TemplateArgument> Args,
+                                  unsigned Depth);
+
 /// The injected class name of a C++ class template or class
 /// template partial specialization.  Used to record that a type was
 /// spelled with a bare identifier rather than as a template-id; the
index 5353243..bfab41b 100644 (file)
@@ -2044,9 +2044,7 @@ static bool isSubstitutedTemplateArgument(ASTContext &Ctx, TemplateArgument Arg,
   return false;
 }
 
-/// Make a best-effort determination of whether the type T can be produced by
-/// substituting Args into the default argument of Param.
-static bool isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg,
+bool clang::isSubstitutedDefaultArgument(ASTContext &Ctx, TemplateArgument Arg,
                                          const NamedDecl *Param,
                                          ArrayRef<TemplateArgument> Args,
                                          unsigned Depth) {