SuppressImplicitBase(false), FullyQualifiedName(false),
PrintCanonicalTypes(false), PrintInjectedClassNameWithArguments(true),
UsePreferredNames(true), AlwaysIncludeTypeForTemplateArgument(false),
- CleanUglifiedParameters(false), EntireContentsOfLargeArray(true) {}
+ CleanUglifiedParameters(false), EntireContentsOfLargeArray(true),
+ UseEnumerators(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
/// template parameters, no matter how many elements there are.
unsigned EntireContentsOfLargeArray : 1;
+ /// Whether to print enumerator non-type template parameters with a matching
+ /// enumerator name or via cast of an integer.
+ unsigned UseEnumerators : 1;
+
/// Callbacks to use to allow the behavior of printing to be customized.
const PrintingCallbacks *Callbacks = nullptr;
};
const Type *T = TemplArg.getIntegralType().getTypePtr();
const llvm::APSInt &Val = TemplArg.getAsIntegral();
- if (const EnumType *ET = T->getAs<EnumType>()) {
- for (const EnumConstantDecl* ECD : ET->getDecl()->enumerators()) {
- // In Sema::CheckTemplateArugment, enum template arguments value are
- // extended to the size of the integer underlying the enum type. This
- // may create a size difference between the enum value and template
- // argument value, requiring isSameValue here instead of operator==.
- if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
- ECD->printQualifiedName(Out, Policy);
- return;
+ if (Policy.UseEnumerators) {
+ if (const EnumType *ET = T->getAs<EnumType>()) {
+ for (const EnumConstantDecl *ECD : ET->getDecl()->enumerators()) {
+ // In Sema::CheckTemplateArugment, enum template arguments value are
+ // extended to the size of the integer underlying the enum type. This
+ // may create a size difference between the enum value and template
+ // argument value, requiring isSameValue here instead of operator==.
+ if (llvm::APSInt::isSameValue(ECD->getInitVal(), Val)) {
+ ECD->printQualifiedName(Out, Policy);
+ return;
+ }
}
}
}
PP.PrintCanonicalTypes = true;
PP.UsePreferredNames = false;
PP.AlwaysIncludeTypeForTemplateArgument = true;
+ PP.UseEnumerators = false;
// Apply -fdebug-prefix-map.
PP.Callbacks = &PrintCB;
};
t4 v1;
-// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "t3<(anonymous namespace)::LocalEnum, (anonymous namespace)::LocalEnum1>"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "t3<(anonymous namespace)::LocalEnum, ((anonymous namespace)::LocalEnum)0>"
void f() {
// Basic examples of simplifiable/rebuildable names
f1<>();
DWARFDie T = resolveReferencedType(C);
Sep();
if (T.getTag() == DW_TAG_enumeration_type) {
- auto V = C.find(DW_AT_const_value);
- bool FoundEnumerator = false;
- for (const DWARFDie &Enumerator : T) {
- auto EV = Enumerator.find(DW_AT_const_value);
- if (V && EV &&
- V->getAsSignedConstant() == EV->getAsSignedConstant()) {
- if (T.find(DW_AT_enum_class)) {
- appendQualifiedName(T);
- OS << "::";
- } else
- appendScopes(T.getParent());
- OS << Enumerator.getShortName();
- FoundEnumerator = true;
- break;
- }
- }
- if (FoundEnumerator)
- continue;
OS << '(';
appendQualifiedName(T);
OS << ')';
+ auto V = C.find(DW_AT_const_value);
OS << to_string(*V->getAsSignedConstant());
continue;
}
# CHECK: DW_AT_type{{.*}}"t2<t2<int> >"
# enum literals
-# CHECK: DW_AT_type{{.*}}"tv<e1, E1>")
+# CHECK: DW_AT_type{{.*}}"tv<e1, (e1)0>")
# CHECK: DW_AT_type{{.*}}"tv<e1, (e1)1>")
-# CHECK: DW_AT_type{{.*}}"tv<e2, e2::E2>")
+# CHECK: DW_AT_type{{.*}}"tv<e2, (e2)0>")
# char literals
# CHECK: DW_AT_type{{.*}}"tv<unsigned char, (unsigned char)'x'>")
.Linfo_string195:
.asciz "_Z2f3IN2ns11EnumerationEJLS1_1ELS1_2EEEvv" # string offset=2877
.Linfo_string196:
- .asciz "_STNf3|<ns::Enumeration, ns::Enumerator2, (ns::Enumeration)2>" # string offset=2919
+ .asciz "_STNf3|<ns::Enumeration, (ns::Enumeration)1, (ns::Enumeration)2>" # string offset=2919
.Linfo_string197:
.asciz "_Z2f3IN2ns16EnumerationClassEJLS1_1ELS1_2EEEvv" # string offset=2981
.Linfo_string198:
- .asciz "_STNf3|<ns::EnumerationClass, ns::EnumerationClass::Enumerator2, (ns::EnumerationClass)2>" # string offset=3028
+ .asciz "_STNf3|<ns::EnumerationClass, (ns::EnumerationClass)1, (ns::EnumerationClass)2>" # string offset=3028
.Linfo_string199:
.asciz "_Z2f3IN2ns16EnumerationSmallEJLS1_255EEEvv" # string offset=3118
.Linfo_string200:
- .asciz "_STNf3|<ns::EnumerationSmall, ns::kNeg>" # string offset=3161
+ .asciz "_STNf3|<ns::EnumerationSmall, (ns::EnumerationSmall)255>" # string offset=3161
.Linfo_string201:
.asciz "_Z2f3IN2ns3$_0EJLS1_1ELS1_2EEEvv" # string offset=3201
.Linfo_string202: