Author: Alexey Bader Date: 2019-12-28T16:35:51+03:00 New Revision: 128f39da932be50cb49646084820119e6e0d1e22
URL: https://github.com/llvm/llvm-project/commit/128f39da932be50cb49646084820119e6e0d1e22 DIFF: https://github.com/llvm/llvm-project/commit/128f39da932be50cb49646084820119e6e0d1e22.diff LOG: 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 Added: Modified: clang/lib/AST/QualTypeNames.cpp clang/unittests/Tooling/QualTypeNamesTest.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/QualTypeNames.cpp b/clang/lib/AST/QualTypeNames.cpp index f28f00171cce..73a33a208233 100644 --- a/clang/lib/AST/QualTypeNames.cpp +++ b/clang/lib/AST/QualTypeNames.cpp @@ -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 diff --git a/clang/unittests/Tooling/QualTypeNamesTest.cpp b/clang/unittests/Tooling/QualTypeNamesTest.cpp index b6c302977876..ff6b78c2666d 100644 --- a/clang/unittests/Tooling/QualTypeNamesTest.cpp +++ b/clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -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"] = _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits