Index: clang-tools-extra/trunk/clangd/AST.h =================================================================== --- clang-tools-extra/trunk/clangd/AST.h +++ clang-tools-extra/trunk/clangd/AST.h @@ -67,7 +67,8 @@ const MacroInfo *MI, const SourceManager &SM); -/// Returns a QualType as string. +/// Returns a QualType as string. The result doesn't contain unwritten scopes +/// like annoymous/inline namespace. std::string printType(const QualType QT, const DeclContext & Context); /// Try to shorten the OriginalName by removing namespaces from the left of Index: clang-tools-extra/trunk/clangd/AST.cpp =================================================================== --- clang-tools-extra/trunk/clangd/AST.cpp +++ clang-tools-extra/trunk/clangd/AST.cpp @@ -192,6 +192,7 @@ std::string printType(const QualType QT, const DeclContext & Context){ PrintingPolicy PP(Context.getParentASTContext().getPrintingPolicy()); + PP.SuppressUnwrittenScope = 1; PP.SuppressTagKeyword = 1; return shortenNamespace( QT.getAsString(PP), Index: clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp =================================================================== --- clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp +++ clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp @@ -663,6 +663,20 @@ const char * x = "test"; )cpp"; checkTransform(ID, Input, Output); + + Input = R"cpp( + namespace { + class Foo {}; + } + au^to f = Foo(); + )cpp"; + Output = R"cpp( + namespace { + class Foo {}; + } + Foo f = Foo(); + )cpp"; + checkTransform(ID, Input, Output); } } // namespace