saugustine created this revision. saugustine added a reviewer: rnk. saugustine added a subscriber: cfe-commits. Herald added a subscriber: klimek.
Treat qualifiers on elaborated types for qualtypenames appropriately. http://reviews.llvm.org/D20040 Files: lib/Tooling/Core/QualTypeNames.cpp unittests/Tooling/QualTypeNamesTest.cpp Index: unittests/Tooling/QualTypeNamesTest.cpp =================================================================== --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -88,6 +88,7 @@ "Foo<X>::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias<int>"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; Visitor.runOver( "int CheckInt;\n" "template <typename T>\n" @@ -108,6 +109,7 @@ " AnotherClass> CheckC);\n" " void Function2(Template0<Template1<C::MyInt, AnotherClass>,\n" " Template0<int, long> > CheckD);\n" + " void Function3(const B::Class0* CheckM);\n" " }\n" "template<typename... Values> class Variadic {};\n" "Variadic<int, B::Template0<int, char>, " Index: lib/Tooling/Core/QualTypeNames.cpp =================================================================== --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -383,7 +383,10 @@ } NestedNameSpecifier *Prefix = nullptr; - Qualifiers PrefixQualifiers; + // Local qualifiers are attached to the Qualtype outside of the + // elaborated type. Retrieve them before descending into the + // elaborated type. + Qualifiers PrefixQualifiers = QT.getLocalQualifiers(); ElaboratedTypeKeyword Keyword = ETK_None; if (const auto *ETypeInput = dyn_cast<ElaboratedType>(QT.getTypePtr())) { QT = ETypeInput->getNamedType(); @@ -395,8 +398,7 @@ true /*FullyQualified*/); // move the qualifiers on the outer type (avoid 'std::const string'!) - if (Prefix) { - PrefixQualifiers = QT.getLocalQualifiers(); + if (Prefix || Keyword != ETK_None) { QT = QualType(QT.getTypePtr(), 0); }
Index: unittests/Tooling/QualTypeNamesTest.cpp =================================================================== --- unittests/Tooling/QualTypeNamesTest.cpp +++ unittests/Tooling/QualTypeNamesTest.cpp @@ -88,6 +88,7 @@ "Foo<X>::non_dependent_type"; Visitor.ExpectedQualTypeNames["AnEnumVar"] = "EnumScopeClass::AnEnum"; Visitor.ExpectedQualTypeNames["AliasTypeVal"] = "A::B::C::InnerAlias<int>"; + Visitor.ExpectedQualTypeNames["CheckM"] = "const A::B::Class0 *"; Visitor.runOver( "int CheckInt;\n" "template <typename T>\n" @@ -108,6 +109,7 @@ " AnotherClass> CheckC);\n" " void Function2(Template0<Template1<C::MyInt, AnotherClass>,\n" " Template0<int, long> > CheckD);\n" + " void Function3(const B::Class0* CheckM);\n" " }\n" "template<typename... Values> class Variadic {};\n" "Variadic<int, B::Template0<int, char>, " Index: lib/Tooling/Core/QualTypeNames.cpp =================================================================== --- lib/Tooling/Core/QualTypeNames.cpp +++ lib/Tooling/Core/QualTypeNames.cpp @@ -383,7 +383,10 @@ } NestedNameSpecifier *Prefix = nullptr; - Qualifiers PrefixQualifiers; + // Local qualifiers are attached to the Qualtype outside of the + // elaborated type. Retrieve them before descending into the + // elaborated type. + Qualifiers PrefixQualifiers = QT.getLocalQualifiers(); ElaboratedTypeKeyword Keyword = ETK_None; if (const auto *ETypeInput = dyn_cast<ElaboratedType>(QT.getTypePtr())) { QT = ETypeInput->getNamedType(); @@ -395,8 +398,7 @@ true /*FullyQualified*/); // move the qualifiers on the outer type (avoid 'std::const string'!) - if (Prefix) { - PrefixQualifiers = QT.getLocalQualifiers(); + if (Prefix || Keyword != ETK_None) { QT = QualType(QT.getTypePtr(), 0); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits