aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-15 22:37:09 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-15 22:37:09 +0000
commit830072c2de881aadfe0f6efd3baccc9129a77e37 (patch)
treeabf8f420cc52c1f1f1cc4c0f3572f77c79508299 /lib/Sema/SemaCodeComplete.cpp
parent4e274e955451632e6ba287bb03fb7a7840c3505e (diff)
Teach code completion to cope with block types written without a
prototype, e.g., ^() rather than ^(void). Fixes <rdar://problem/8875712>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125608 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--lib/Sema/SemaCodeComplete.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 1d7cf98264..3a07ef6783 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -1894,7 +1894,8 @@ static std::string FormatFunctionParameter(ASTContext &Context,
// The argument for a block pointer parameter is a block literal with
// the appropriate type.
- FunctionProtoTypeLoc *Block = 0;
+ FunctionTypeLoc *Block = 0;
+ FunctionProtoTypeLoc *BlockProto = 0;
TypeLoc TL;
if (TypeSourceInfo *TSInfo = Param->getTypeSourceInfo()) {
TL = TSInfo->getTypeLoc().getUnqualifiedLoc();
@@ -1919,7 +1920,8 @@ static std::string FormatFunctionParameter(ASTContext &Context,
if (BlockPointerTypeLoc *BlockPtr
= dyn_cast<BlockPointerTypeLoc>(&TL)) {
TL = BlockPtr->getPointeeLoc().IgnoreParens();
- Block = dyn_cast<FunctionProtoTypeLoc>(&TL);
+ Block = dyn_cast<FunctionTypeLoc>(&TL);
+ BlockProto = dyn_cast<FunctionProtoTypeLoc>(&TL);
}
break;
}
@@ -1950,8 +1952,8 @@ static std::string FormatFunctionParameter(ASTContext &Context,
ResultType.getAsStringInternal(Result, Context.PrintingPolicy);
Result = '^' + Result;
- if (Block->getNumArgs() == 0) {
- if (Block->getTypePtr()->isVariadic())
+ if (!BlockProto || Block->getNumArgs() == 0) {
+ if (BlockProto && BlockProto->getTypePtr()->isVariadic())
Result += "(...)";
else
Result += "(void)";
@@ -1962,7 +1964,7 @@ static std::string FormatFunctionParameter(ASTContext &Context,
Result += ", ";
Result += FormatFunctionParameter(Context, Block->getArg(I));
- if (I == N - 1 && Block->getTypePtr()->isVariadic())
+ if (I == N - 1 && BlockProto->getTypePtr()->isVariadic())
Result += ", ...";
}
Result += ")";