aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/CodeCompleteConsumer.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2021-12-29 04:16:47 +0100
committerSam McCall <sam.mccall@gmail.com>2022-01-03 16:28:16 +0100
commitcd45e8c7bc16dec2eeec9cc71eb3ba87d1bd6bab (patch)
tree3db9bfda04d2f78dc9bf0067bc2b4ebf56c9258a /clang/lib/Sema/CodeCompleteConsumer.cpp
parent3a33c0b1ce0db465c9d85c493674efc6c5005dbe (diff)
downloadllvm-cd45e8c7bc16dec2eeec9cc71eb3ba87d1bd6bab.zip
llvm-cd45e8c7bc16dec2eeec9cc71eb3ba87d1bd6bab.tar.gz
llvm-cd45e8c7bc16dec2eeec9cc71eb3ba87d1bd6bab.tar.bz2
[CodeCompletion] Signature help for template argument lists
Provide signature while typing template arguments: Foo< ^here > Here the parameters are e.g. "typename x", and the result type is e.g. "struct" (class template) or "int" (variable template) or "bool (std::string)" (function template). Multiple overloads are possible when a template name is used for several overloaded function templates. Fixes https://github.com/clangd/clangd/issues/299 Differential Revision: https://reviews.llvm.org/D116352
Diffstat (limited to 'clang/lib/Sema/CodeCompleteConsumer.cpp')
-rw-r--r--clang/lib/Sema/CodeCompleteConsumer.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp
index 0a2ca54..f0968ed 100644
--- a/clang/lib/Sema/CodeCompleteConsumer.cpp
+++ b/clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -506,11 +506,22 @@ CodeCompleteConsumer::OverloadCandidate::getFunctionType() const {
case CK_FunctionType:
return Type;
+
+ case CK_Template:
+ return nullptr;
}
llvm_unreachable("Invalid CandidateKind!");
}
+unsigned CodeCompleteConsumer::OverloadCandidate::getNumParams() const {
+ if (Kind == CK_Template)
+ return Template->getTemplateParameters()->size();
+ if (const auto *FPT = dyn_cast_or_null<FunctionProtoType>(getFunctionType()))
+ return FPT->getNumParams();
+ return 0;
+}
+
//===----------------------------------------------------------------------===//
// Code completion consumer implementation
//===----------------------------------------------------------------------===//