summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clangd/CodeCompletionStrings.cpp
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-06-27 09:47:20 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-06-27 09:47:20 +0000
commitda8dd8b800e9874d6c262cc354f28f77f305193f (patch)
tree3193ae2ac9fe062f4aa64c9bb77d7709ea0e3572 /clang-tools-extra/clangd/CodeCompletionStrings.cpp
parent0a566bc0ae172ebc5741da1ec7622d71d58ab5ef (diff)
downloadbcm5719-llvm-da8dd8b800e9874d6c262cc354f28f77f305193f.tar.gz
bcm5719-llvm-da8dd8b800e9874d6c262cc354f28f77f305193f.zip
[clangd] Do not show namespace comments.
Summary: Comments from namespaces that clangd produces are too noisy and often not useful. Namespaces have too many redecls and we don't have a good way of determining which of the comments are relevant and which should be ignored (e.g. because they come from code generators like the protobuf compiler). Reviewers: sammccall Reviewed By: sammccall Subscribers: ioeric, MaskRay, jkorous, cfe-commits Differential Revision: https://reviews.llvm.org/D48211 llvm-svn: 335718
Diffstat (limited to 'clang-tools-extra/clangd/CodeCompletionStrings.cpp')
-rw-r--r--clang-tools-extra/clangd/CodeCompletionStrings.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/CodeCompletionStrings.cpp b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
index 504ab6c95bf..6bad0eacd3b 100644
--- a/clang-tools-extra/clangd/CodeCompletionStrings.cpp
+++ b/clang-tools-extra/clangd/CodeCompletionStrings.cpp
@@ -80,8 +80,16 @@ std::string getDocComment(const ASTContext &Ctx,
if (Result.Kind != CodeCompletionResult::RK_Declaration)
return "";
auto *Decl = Result.getDeclaration();
- if (!Decl || !canRequestComment(Ctx, *Decl, CommentsFromHeaders))
+ if (!Decl || llvm::isa<NamespaceDecl>(Decl)) {
+ // Namespaces often have too many redecls for any particular redecl comment
+ // to be useful. Moreover, we often confuse file headers or generated
+ // comments with namespace comments. Therefore we choose to just ignore
+ // the comments for namespaces.
return "";
+ }
+ if (!canRequestComment(Ctx, *Decl, CommentsFromHeaders))
+ return "";
+
const RawComment *RC = getCompletionComment(Ctx, Decl);
if (!RC)
return "";
OpenPOWER on IntegriCloud