<div dir="ltr">Committed as r331552.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, May 4, 2018 at 12:43 PM, Mikhail Ramalho via Phabricator <span dir="ltr"><<a href="mailto:reviews@reviews.llvm.org" target="_blank">reviews@reviews.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">mikhail.ramalho updated this revision to Diff 145255.<br>
mikhail.ramalho added a comment.<br>
<br>
Fixed the test case.<br>
<div><div class="h5"><br>
<br>
<a href="https://reviews.llvm.org/D36610" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D36610</a><br>
<br>
Files:<br>
include/clang/AST/<wbr>QualTypeNames.h<br>
lib/AST/QualTypeNames.cpp<br>
unittests/Tooling/<wbr>QualTypeNamesTest.cpp<br>
<br>
<br>
Index: unittests/Tooling/<wbr>QualTypeNamesTest.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- unittests/Tooling/<wbr>QualTypeNamesTest.cpp<br>
+++ unittests/Tooling/<wbr>QualTypeNamesTest.cpp<br>
@@ -26,9 +26,13 @@<br>
std::string ExpectedName =<br>
ExpectedQualTypeNames.lookup(<wbr>VD->getNameAsString());<br>
if (ExpectedName != "") {<br>
- std::string ActualName =<br>
- TypeName::<wbr>getFullyQualifiedName(VD-><wbr>getType(), *Context,<br>
- WithGlobalNsPrefix);<br>
+ PrintingPolicy Policy(Context-><wbr>getPrintingPolicy());<br>
+ Policy.SuppressScope = false;<br>
+ Policy.AnonymousTagLocations = true;<br>
+ Policy.PolishForDeclaration = true;<br>
+ Policy.SuppressUnwrittenScope = true;<br>
+ std::string ActualName = TypeName::<wbr>getFullyQualifiedName(<br>
+ VD->getType(), *Context, Policy, WithGlobalNsPrefix);<br>
if (ExpectedName != ActualName) {<br>
// A custom message makes it much easier to see what declaration<br>
// failed compared to EXPECT_EQ.<br>
@@ -217,6 +221,26 @@<br>
" }\n"<br>
"}\n"<br>
);<br>
+<br>
+ TypeNameVisitor AnonStrucs;<br>
+ AnonStrucs.<wbr>ExpectedQualTypeNames["a"] = "short";<br>
+ AnonStrucs.<wbr>ExpectedQualTypeNames["un_in_<wbr>st_1"] =<br>
</div></div>+ "union (anonymous struct at input.cc:1:1)::(anonymous union at "<br>
+ "input.cc:2:27)";<br>
<span class="">+ AnonStrucs.<wbr>ExpectedQualTypeNames["b"] = "short";<br>
+ AnonStrucs.<wbr>ExpectedQualTypeNames["un_in_<wbr>st_2"] =<br>
</span>+ "union (anonymous struct at input.cc:1:1)::(anonymous union at "<br>
+ "input.cc:5:27)";<br>
<span class="">+ AnonStrucs.<wbr>ExpectedQualTypeNames["anon_<wbr>st"] =<br>
+ "struct (anonymous struct at input.cc:1:1)";<br>
+ AnonStrucs.runOver(R"(struct {<br>
+ union {<br>
+ short a;<br>
+ } un_in_st_1;<br>
+ union {<br>
+ short b;<br>
+ } un_in_st_2;<br>
+ } anon_st;)");<br>
}<br>
<br>
</span><span class=""> } // end anonymous namespace<br>
Index: lib/AST/QualTypeNames.cpp<br>
==============================<wbr>==============================<wbr>=======<br>
--- lib/AST/QualTypeNames.cpp<br>
+++ lib/AST/QualTypeNames.cpp<br>
</span>@@ -452,12 +452,8 @@<br>
<div class="HOEnZb"><div class="h5"> <br>
std::string getFullyQualifiedName(QualType QT,<br>
const ASTContext &Ctx,<br>
+ const PrintingPolicy &Policy,<br>
bool WithGlobalNsPrefix) {<br>
- PrintingPolicy Policy(Ctx.getPrintingPolicy()<wbr>);<br>
- Policy.SuppressScope = false;<br>
- Policy.AnonymousTagLocations = false;<br>
- Policy.PolishForDeclaration = true;<br>
- Policy.SuppressUnwrittenScope = true;<br>
QualType FQQT = getFullyQualifiedType(QT, Ctx, WithGlobalNsPrefix);<br>
return FQQT.getAsString(Policy);<br>
}<br>
Index: include/clang/AST/<wbr>QualTypeNames.h<br>
==============================<wbr>==============================<wbr>=======<br>
--- include/clang/AST/<wbr>QualTypeNames.h<br>
+++ include/clang/AST/<wbr>QualTypeNames.h<br>
@@ -72,6 +72,7 @@<br>
/// \param[in] WithGlobalNsPrefix - If true, then the global namespace<br>
/// specifier "::" will be prepended to the fully qualified name.<br>
std::string getFullyQualifiedName(QualType QT, const ASTContext &Ctx,<br>
+ const PrintingPolicy &Policy,<br>
bool WithGlobalNsPrefix = false);<br>
<br>
/// \brief Generates a QualType that can be used to name the same type<br>
<br>
<br>
</div></div></blockquote></div><br></div>