[PATCH] D20040: Treat qualifiers on elaborated types for qualtypenames appropriately.
Sterling Augustine via cfe-commits
cfe-commits at lists.llvm.org
Fri May 6 16:20:34 PDT 2016
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20040.56480.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160506/24dd5e10/attachment.bin>
More information about the cfe-commits
mailing list