bader created this revision. bader added reviewers: bkramer, ilya-biryukov. Herald added subscribers: cfe-commits, ebevhan. Herald added a project: clang.
The ICE happens when the most outer namespace is an inline namespace. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D71962 Files: clang/lib/AST/QualTypeNames.cpp clang/unittests/Tooling/QualTypeNamesTest.cpp Index: clang/unittests/Tooling/QualTypeNamesTest.cpp =================================================================== --- clang/unittests/Tooling/QualTypeNamesTest.cpp +++ clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -223,6 +223,17 @@ "}\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"] = Index: clang/lib/AST/QualTypeNames.cpp =================================================================== --- clang/lib/AST/QualTypeNames.cpp +++ clang/lib/AST/QualTypeNames.cpp @@ -192,7 +192,7 @@ // 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
Index: clang/unittests/Tooling/QualTypeNamesTest.cpp =================================================================== --- clang/unittests/Tooling/QualTypeNamesTest.cpp +++ clang/unittests/Tooling/QualTypeNamesTest.cpp @@ -223,6 +223,17 @@ "}\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"] = Index: clang/lib/AST/QualTypeNames.cpp =================================================================== --- clang/lib/AST/QualTypeNames.cpp +++ clang/lib/AST/QualTypeNames.cpp @@ -192,7 +192,7 @@ // 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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits