diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-11-03 00:16:13 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-11-03 00:16:13 +0000 |
commit | 2e10cf9620885bb2d81b93ecd98421beb51c4889 (patch) | |
tree | 97f841f8e4b8f241def6102fd4fe406824873177 /clang/lib | |
parent | 9589872af9e1a88799d43b1bd403db7d338ba5f0 (diff) | |
download | bcm5719-llvm-2e10cf9620885bb2d81b93ecd98421beb51c4889.tar.gz bcm5719-llvm-2e10cf9620885bb2d81b93ecd98421beb51c4889.zip |
Add a printing policy flag to suppress printing "<anonymous>::" prior
to types. Enable this flag for code completion, where knowing whether
something is in an anonymous or inline namespace is actually not
useful, since you don't have to type it anyway. Fixes
<rdar://problem/10208818>.
llvm-svn: 143599
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/NestedNameSpecifier.cpp | 3 | ||||
-rw-r--r-- | clang/lib/AST/TypePrinter.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 1 |
3 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/NestedNameSpecifier.cpp b/clang/lib/AST/NestedNameSpecifier.cpp index 1ff2e7177b3..858cf12dc66 100644 --- a/clang/lib/AST/NestedNameSpecifier.cpp +++ b/clang/lib/AST/NestedNameSpecifier.cpp @@ -229,6 +229,9 @@ NestedNameSpecifier::print(raw_ostream &OS, break; case Namespace: + if (getAsNamespace()->isAnonymousNamespace()) + return; + OS << getAsNamespace()->getName(); break; diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index fb7b918ca2f..ec6cb48bf86 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -600,6 +600,9 @@ void TypePrinter::AppendScope(DeclContext *DC, std::string &Buffer) { unsigned OldSize = Buffer.size(); if (NamespaceDecl *NS = dyn_cast<NamespaceDecl>(DC)) { + if (Policy.SuppressUnwrittenScope && + (NS->isAnonymousNamespace() || NS->isInline())) + return; if (NS->getIdentifier()) Buffer += NS->getNameAsString(); else @@ -620,6 +623,8 @@ void TypePrinter::AppendScope(DeclContext *DC, std::string &Buffer) { Buffer += Typedef->getIdentifier()->getName(); else if (Tag->getIdentifier()) Buffer += Tag->getIdentifier()->getName(); + else + return; } if (Buffer.size() != OldSize) diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 4066a06e529..f964ec14836 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -1381,6 +1381,7 @@ static PrintingPolicy getCompletionPrintingPolicy(Sema &S) { PrintingPolicy Policy = S.getPrintingPolicy(); Policy.AnonymousTagLocations = false; Policy.SuppressStrongLifetime = true; + Policy.SuppressUnwrittenScope = true; return Policy; } |