aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/clangd/CodeComplete.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/clangd/CodeComplete.cpp')
-rw-r--r--clang-tools-extra/clangd/CodeComplete.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang-tools-extra/clangd/CodeComplete.cpp b/clang-tools-extra/clangd/CodeComplete.cpp
index c6deed3..e4df758 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -43,6 +43,7 @@
#include "support/Trace.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
+#include "clang/AST/DeclTemplate.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceLocation.h"
@@ -1886,7 +1887,15 @@ private:
for (auto &Cand : C.first) {
if (Cand.SemaResult &&
Cand.SemaResult->Kind == CodeCompletionResult::RK_Declaration) {
- auto ID = clangd::getSymbolID(Cand.SemaResult->getDeclaration());
+ const NamedDecl *DeclToLookup = Cand.SemaResult->getDeclaration();
+ // For instantiations of members of class templates, the
+ // documentation will be stored at the member's original
+ // declaration.
+ if (const NamedDecl *Adjusted =
+ dyn_cast<NamedDecl>(&adjustDeclToTemplate(*DeclToLookup))) {
+ DeclToLookup = Adjusted;
+ }
+ auto ID = clangd::getSymbolID(DeclToLookup);
if (!ID)
continue;
Req.IDs.insert(ID);