[PATCH] D60258: [CodeComplete] Fix crash when completing ObjC block parameter with a broken type
Sam McCall via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 04:35:13 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL357686: [CodeComplete] Fix crash when completing ObjC block parameter with a broken type (authored by sammccall, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D60258/new/
https://reviews.llvm.org/D60258
Files:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-blocks.m
Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -2605,6 +2605,11 @@
FormatFunctionParameter(const PrintingPolicy &Policy, const ParmVarDecl *Param,
bool SuppressName = false, bool SuppressBlock = false,
Optional<ArrayRef<QualType>> ObjCSubsts = None) {
+ // Params are unavailable in FunctionTypeLoc if the FunctionType is invalid.
+ // It would be better to pass in the param Type, which is usually avaliable.
+ // But this case is rare, so just pretend we fell back to int as elsewhere.
+ if (!Param)
+ return "int";
bool ObjCMethodParam = isa<ObjCMethodDecl>(Param->getDeclContext());
if (Param->getType()->isDependentType() ||
!Param->getType()->isBlockPointerType()) {
Index: cfe/trunk/test/Index/complete-blocks.m
===================================================================
--- cfe/trunk/test/Index/complete-blocks.m
+++ cfe/trunk/test/Index/complete-blocks.m
@@ -50,6 +50,15 @@
[o method7:0];
}
+// Crash regression test. Param info for broken function types isn't available.
+typedef UnresolvedType *(^XXX)(float);
+ at interface Foo
+-(void) foo:(XXX)arg;
+ at end
+void testUnresolved(Foo* f) {
+ [f foo:0];
+}
+
// RUN: c-index-test -code-completion-at=%s:8:1 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText f}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText g}{LeftParen (}{Placeholder ^(float f, double d)b}{RightParen )} (50)
@@ -74,3 +83,6 @@
// CHECK-CC7: FunctionDecl:{ResultType void}{TypedText f2}{LeftParen (}{Placeholder ^int(int x, int y)block}{RightParen )} (50)
// RUN: c-index-test -code-completion-at=%s:50:6 %s | FileCheck -check-prefix=CHECK-CC8 %s
// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType id}{TypedText method7:}{Placeholder ^int(int x, int y)b} (35)
+
+// RUN: c-index-test -code-completion-at=%s:59:6 %s | FileCheck -check-prefix=CHECK-CC9 %s
+// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType void}{TypedText foo:}{Placeholder ^int *(int)arg} (35)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60258.193689.patch
Type: text/x-patch
Size: 2256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190404/40521ef4/attachment.bin>
More information about the llvm-commits
mailing list