aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/CodeCompleteConsumer.cpp
diff options
context:
space:
mode:
authorQwinci <32550582+Qwinci@users.noreply.github.com>2022-07-19 20:02:24 -0400
committerNathan Ridge <zeratul976@hotmail.com>2022-07-19 20:02:26 -0400
commit3f73c5793515867935d59ff8c511c61ace848e79 (patch)
treef68b335089e50f64e8b746379ebb9880043fef5f /clang/lib/Sema/CodeCompleteConsumer.cpp
parent7d815ab9b405f5832618264c5d0ef196eacf37a3 (diff)
downloadllvm-3f73c5793515867935d59ff8c511c61ace848e79.zip
llvm-3f73c5793515867935d59ff8c511c61ace848e79.tar.gz
llvm-3f73c5793515867935d59ff8c511c61ace848e79.tar.bz2
Argument name support for function pointer signature hints
Fixes https://github.com/clangd/clangd/issues/1068 Reviewed By: nridge Differential Revision: https://reviews.llvm.org/D125120
Diffstat (limited to 'clang/lib/Sema/CodeCompleteConsumer.cpp')
-rw-r--r--clang/lib/Sema/CodeCompleteConsumer.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp
index 8e8a1be..e93be3e 100644
--- a/clang/lib/Sema/CodeCompleteConsumer.cpp
+++ b/clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -515,7 +515,8 @@ CodeCompleteConsumer::OverloadCandidate::getFunctionType() const {
case CK_FunctionType:
return Type;
-
+ case CK_FunctionProtoTypeLoc:
+ return ProtoTypeLoc.getTypePtr();
case CK_Template:
case CK_Aggregate:
return nullptr;
@@ -524,6 +525,13 @@ CodeCompleteConsumer::OverloadCandidate::getFunctionType() const {
llvm_unreachable("Invalid CandidateKind!");
}
+const FunctionProtoTypeLoc
+CodeCompleteConsumer::OverloadCandidate::getFunctionProtoTypeLoc() const {
+ if (Kind == CK_FunctionProtoTypeLoc)
+ return ProtoTypeLoc;
+ return FunctionProtoTypeLoc();
+}
+
unsigned CodeCompleteConsumer::OverloadCandidate::getNumParams() const {
if (Kind == CK_Template)
return Template->getTemplateParameters()->size();
@@ -597,7 +605,12 @@ CodeCompleteConsumer::OverloadCandidate::getParamDecl(unsigned N) const {
if (const auto *FD = getFunction()) {
if (N < FD->param_size())
return FD->getParamDecl(N);
+ } else if (Kind == CK_FunctionProtoTypeLoc) {
+ if (N < ProtoTypeLoc.getNumParams()) {
+ return ProtoTypeLoc.getParam(N);
+ }
}
+
return nullptr;
}