This revision was automatically updated to reflect the committed changes. Closed by commit rL366446: [clangd] Suppress unwritten scopes when expanding auto. (authored by hokein, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D64627?vs=209454&id=210578#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64627/new/ https://reviews.llvm.org/D64627 Files: clang-tools-extra/trunk/clangd/AST.cpp clang-tools-extra/trunk/clangd/AST.h clang-tools-extra/trunk/clangd/unittests/TweakTests.cpp 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/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/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
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/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/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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits