printPolicy.SuppressScope = true;
printPolicy.ConstantArraySizeAsWritten = true;
printPolicy.UseVoidForZeroParams = false;
+ printPolicy.PrintInjectedClassNameWithArguments = false;
std::string Type = MatchedDecl->getUnderlyingType().getAsString(printPolicy);
std::string Name = MatchedDecl->getNameAsString();
// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
// CHECK-FIXES: using EnumT2_CheckTypedefImpactFromAnotherFile = enum { ea2, eb2 };
+template <int A>
+struct InjectedClassName {
+ typedef InjectedClassName b;
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+ // CHECK-FIXES: using b = InjectedClassName;
+};
+
+template <int>
+struct InjectedClassNameWithUnnamedArgument {
+ typedef InjectedClassNameWithUnnamedArgument b;
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
+ // CHECK-FIXES: using b = InjectedClassNameWithUnnamedArgument;
+};
MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
MSVCFormatting(false), ConstantsAsWritten(false),
SuppressImplicitBase(false), FullyQualifiedName(false),
- PrintCanonicalTypes(false) {}
+ PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true) {}
/// Adjust this printing policy for cases where it's known that we're
/// printing C++ code (for instance, if AST dumping reaches a C++-only
/// Whether to print types as written or canonically.
unsigned PrintCanonicalTypes : 1;
+ /// Whether to print an InjectedClassNameType with template arguments or as
+ /// written. When a template argument is unnamed, printing it results in
+ /// invalid C++ code.
+ unsigned PrintInjectedClassNameWithArguments : 1;
+
/// Callbacks to use to allow the behavior of printing to be customized.
const PrintingCallbacks *Callbacks = nullptr;
};
void TypePrinter::printInjectedClassNameBefore(const InjectedClassNameType *T,
raw_ostream &OS) {
- printTemplateSpecializationBefore(T->getInjectedTST(), OS);
+ if (Policy.PrintInjectedClassNameWithArguments)
+ return printTemplateSpecializationBefore(T->getInjectedTST(), OS);
+
+ IncludeStrongLifetimeRAII Strong(Policy);
+ T->getTemplateName().print(OS, Policy);
+ spaceBeforePlaceHolder(OS);
}
void TypePrinter::printInjectedClassNameAfter(const InjectedClassNameType *T,