<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/155537>155537</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] namespace duplicated in getQualifiedNameAsString output
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
mizvekov
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
rupprecht
</td>
</tr>
</table>
<pre>
Calling `getQualifiedNameAsString()` for a function decl in a namespace will end up duplicating the namespace.
Test case (using the pattern from [LookupTest.cpp](https://github.com/llvm/llvm-project/blob/main/clang/unittests/Tooling/LookupTest.cpp)):
```cc
namespace {
struct CheckFunctionDeclVisitor : TestVisitor {
bool VisitFunctionDecl(FunctionDecl *FD) override {
EXPECT_EQ("x::y::Foo::Foo<T>", FD->getQualifiedNameAsString());
return true;
}
};
}
TEST(LookupTest, namespaceInQualifiedName) {
CheckFunctionDeclVisitor Visitor;
Visitor.runOver(
"namespace x { namespace y {\n"
"template <typename T> class Foo { Foo() {} };\n"
"}}");
}
```
This passes prior to #147835. After that, and still at trunk, it fails:
```cc
Expected equality of these values:
"x::y::Foo::Foo<T>"
FD->getQualifiedNameAsString()
Which is: "x::y::Foo::x::y::Foo<T>"
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVFGP4zQQ_jXTl9FVqdM06UMeck0jISHgdBXwhhxn0ph142CPyy6_HjlNd7vAwSFFcj31zDff5_EnvdfnkaiE7CMIcdF_XOnJXkEIyOqVDDxYV7owTY7UwKvWdi_lQRqjxzPCLjkTfwrS6F5T9528UOU_s9PjGUQBYg-7BHvrUGIfRsXajtiRMqhHlDjKC_lJKsLftTFIY4dhwi5MRivJsT4P9HZqDUkFSXUiz6ikJwRRBH8_NklmciP2zl4Qso_fWvsUpnh4raYJshpEMTBPHtIKRAOiOWseQrtW9gKiMeZ6Xz5Mzv5KikE0rbEtiOYi9QiiUUZGXk0YNTN59iCak7VmZtv8BVDs45dWt6Zhl9w-pSCp3ohD_hGSyrMLivEwkHpqFp1qUuZH7TVbh5BWGAu_7ucsxNZag3PwMQtE8bhFEFVTg9ijvZJzuruj4vHnH46H0y_HT_NdiefYbVq93JbG2ocfhxOkxzgS4oBN_QHS43_ce-R-axLREQc3IrtA9yDkdVQlr2-BZZtUp-PnE4jiTcsI-CrXN-M7yMhpofJF6Zb1jrts1y6M31_JxWZvPSKCEG_38hwLPwzoywyUHcaowUMG02UykgkhPfDLRDEDo1aojPQeG2vnSlHEWZi5Tl7jQv3vFeMfeT1LvX8nzn2CFqEG7XGS3pPHyWnrkC2CSDfbvEizNVY9k0Me5KygHDv0HB-Z5HgP41OMasZeauOXKX03osfniRRTh_RblJxf0PbxnXnCqzSBliT82rmJDL9qcG5S_DRoNaCOKP8C8Q_hB8BXQquuTLt9upcrKjd5thNZUaTpaij7fdu1SdJtunSTdWme5zuR9Z0S-1TutttspUuRiCwpRJ5stkmarsW2yDZt0std1yYiL2Cb0EVqs47GsbbuvNLeByo3WZal-crIloxfnHWxj9lWXTk7TRvOHraJ0Z79WwnWbGY7vmVk9cMg3t2RuuihX9ISbeAp8Co4U_5v05sZRG9bSFxL8WcAAAD__6qj4FA">