Fix crash in getFullyQualifiedName for inline namespace

Summary: The ICE happens when the most outer namespace is an inline namespace.

Reviewers: bkramer, ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: ebevhan, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71962
This commit is contained in:
Alexey Bader 2019-12-28 16:13:33 +03:00
parent 8612e92ed5
commit 128f39da93
2 changed files with 12 additions and 1 deletions

View File

@ -192,7 +192,7 @@ static NestedNameSpecifier *createOuterNNS(const ASTContext &Ctx, const Decl *D,
// Ignore inline namespace;
NS = dyn_cast<NamespaceDecl>(NS->getDeclContext());
}
if (NS->getDeclName()) {
if (NS && NS->getDeclName()) {
return createNestedNameSpecifier(Ctx, NS, WithGlobalNsPrefix);
}
return nullptr; // no starting '::', no anonymous

View File

@ -223,6 +223,17 @@ TEST(QualTypeNameTest, getFullyQualifiedName) {
"}\n"
);
TypeNameVisitor InlineNamespace;
InlineNamespace.ExpectedQualTypeNames["c"] = "B::C";
InlineNamespace.runOver("inline namespace A {\n"
" namespace B {\n"
" class C {};\n"
" }\n"
"}\n"
"using namespace A::B;\n"
"C c;\n",
TypeNameVisitor::Lang_CXX11);
TypeNameVisitor AnonStrucs;
AnonStrucs.ExpectedQualTypeNames["a"] = "short";
AnonStrucs.ExpectedQualTypeNames["un_in_st_1"] =