aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-08 22:47:51 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-08 22:47:51 +0000
commit382762582c8fcbc06b395a806fd57879381897a8 (patch)
tree91bc3483301b9a85ddf6522f5a0eab5c2e59f47b /lib/Sema/SemaCodeComplete.cpp
parent757b77a5eee0a7c5d8b144e0148b61ee6727a993 (diff)
When providing a completion for a function/method parameter of block
pointer type, actually provide a usable block literal expression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113431 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--lib/Sema/SemaCodeComplete.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index c367d52704..d8c2c4ff20 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -1830,23 +1830,28 @@ static std::string FormatFunctionParameter(ASTContext &Context,
// We have the function prototype behind the block pointer type, as it was
// written in the source.
- std::string Result = "(^)(";
- for (unsigned I = 0, N = Block->getNumArgs(); I != N; ++I) {
- if (I)
- Result += ", ";
- Result += FormatFunctionParameter(Context, Block->getArg(I));
-
- if (I == N - 1 && Block->getTypePtr()->isVariadic())
- Result += ", ...";
+ std::string Result;
+ QualType ResultType = Block->getTypePtr()->getResultType();
+ if (!ResultType->isVoidType())
+ ResultType.getAsStringInternal(Result, Context.PrintingPolicy);
+
+ Result = '^' + Result;
+ if (Block->getNumArgs() == 0) {
+ if (Block->getTypePtr()->isVariadic())
+ Result += "(...)";
+ } else {
+ Result += "(";
+ for (unsigned I = 0, N = Block->getNumArgs(); I != N; ++I) {
+ if (I)
+ Result += ", ";
+ Result += FormatFunctionParameter(Context, Block->getArg(I));
+
+ if (I == N - 1 && Block->getTypePtr()->isVariadic())
+ Result += ", ...";
+ }
+ Result += ")";
}
- if (Block->getTypePtr()->isVariadic() && Block->getNumArgs() == 0)
- Result += "...";
- else if (Block->getNumArgs() == 0 && !Context.getLangOptions().CPlusPlus)
- Result += "void";
-
- Result += ")";
- Block->getTypePtr()->getResultType().getAsStringInternal(Result,
- Context.PrintingPolicy);
+
return Result;
}