[PATCH] D64627: [clangd] Suppress unwritten scopes when expanding auto.
Haojian Wu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 18 08:16:35 PDT 2019
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64627.210578.patch
Type: text/x-patch
Size: 1706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190718/e114e238/attachment.bin>
More information about the cfe-commits
mailing list