MSWChar(LO.MicrosoftExt && !LO.WChar), IncludeNewlines(true),
MSVCFormatting(false), ConstantsAsWritten(false),
SuppressImplicitBase(false), FullyQualifiedName(false),
- PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true) {}
+ PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
+ UsePreferredNames(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
/// written. When a template argument is unnamed, printing it results in
/// invalid C++ code.
unsigned PrintInjectedClassNameWithArguments : 1;
+ unsigned UsePreferredNames : 1;
/// Callbacks to use to allow the behavior of printing to be customized.
const PrintingCallbacks *Callbacks = nullptr;
void TypePrinter::printRecordBefore(const RecordType *T, raw_ostream &OS) {
// Print the preferred name if we have one for this type.
- for (const auto *PNA : T->getDecl()->specific_attrs<PreferredNameAttr>()) {
- if (declaresSameEntity(PNA->getTypedefType()->getAsCXXRecordDecl(),
- T->getDecl())) {
+ if (Policy.UsePreferredNames) {
+ for (const auto *PNA : T->getDecl()->specific_attrs<PreferredNameAttr>()) {
+ if (!declaresSameEntity(PNA->getTypedefType()->getAsCXXRecordDecl(),
+ T->getDecl()))
+ continue;
// Find the outermost typedef or alias template.
QualType T = PNA->getTypedefType();
while (true) {
PP.SuppressInlineNamespace = false;
PP.PrintCanonicalTypes = true;
+ PP.UsePreferredNames = false;
// Apply -fdebug-prefix-map.
PP.Callbacks = &PrintCB;
// CHECK: ![[TEMP_TEMP_INL_ARGS]] = !{![[TEMP_TEMP_INL_ARGS_T:[0-9]*]]}
// CHECK: ![[TEMP_TEMP_INL_ARGS_T]] = !DITemplateValueParameter(tag: DW_TAG_GNU_template_template_param, value: !"TemplateTemplateParamInlineNamespace::inl::t1")
} // namespace TemplateTemplateParamInlineNamespace
+
+namespace NoPreferredNames {
+template <typename T> struct t1;
+using t1i = t1<int>;
+template <typename T>
+struct __attribute__((__preferred_name__(t1i))) t1 {};
+template <typename T>
+void f1() {}
+template void f1<t1<int>>();
+// CHECK: !DISubprogram(name: "f1<NoPreferredNames::t1<int> >",
+
+} // namespace NoPreferredNames