Skip to content

Commit

Permalink
Fix crash in getFullyQualifiedName for inline namespace
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bader committed Dec 28, 2019
1 parent 8612e92 commit 128f39d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/AST/QualTypeNames.cpp
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions clang/unittests/Tooling/QualTypeNamesTest.cpp
Expand Up @@ -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"] =
Expand Down

0 comments on commit 128f39d

Please sign in to comment.