aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaCodeComplete.cpp33
-rw-r--r--test/Index/complete-objc-message.m11
2 files changed, 39 insertions, 5 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 66ecae0b79..15a54f8d0a 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -1933,6 +1933,28 @@ static void MaybeAddSentinel(ASTContext &Context, NamedDecl *FunctionOrMethod,
}
}
+static void appendWithSpace(std::string &Result, StringRef Text) {
+ if (!Result.empty())
+ Result += ' ';
+ Result += Text.str();
+}
+static std::string formatObjCParamQualifiers(unsigned ObjCQuals) {
+ std::string Result;
+ if (ObjCQuals & Decl::OBJC_TQ_In)
+ appendWithSpace(Result, "in");
+ else if (ObjCQuals & Decl::OBJC_TQ_Inout)
+ appendWithSpace(Result, "inout");
+ else if (ObjCQuals & Decl::OBJC_TQ_Out)
+ appendWithSpace(Result, "out");
+ if (ObjCQuals & Decl::OBJC_TQ_Bycopy)
+ appendWithSpace(Result, "bycopy");
+ else if (ObjCQuals & Decl::OBJC_TQ_Byref)
+ appendWithSpace(Result, "byref");
+ if (ObjCQuals & Decl::OBJC_TQ_Oneway)
+ appendWithSpace(Result, "oneway");
+ return Result;
+}
+
static std::string FormatFunctionParameter(ASTContext &Context,
ParmVarDecl *Param,
bool SuppressName = false) {
@@ -1953,8 +1975,8 @@ static std::string FormatFunctionParameter(ASTContext &Context,
Param->getType().getAsStringInternal(Result, Policy);
if (ObjCMethodParam) {
- Result = "(" + Result;
- Result += ")";
+ Result = "(" + formatObjCParamQualifiers(Param->getObjCDeclQualifier())
+ + Result + ")";
if (Param->getIdentifier() && !SuppressName)
Result += Param->getIdentifier()->getName();
}
@@ -2003,8 +2025,8 @@ static std::string FormatFunctionParameter(ASTContext &Context,
Param->getType().getUnqualifiedType().getAsStringInternal(Result, Policy);
if (ObjCMethodParam) {
- Result = "(" + Result;
- Result += ")";
+ Result = "(" + formatObjCParamQualifiers(Param->getObjCDeclQualifier())
+ + Result + ")";
if (Param->getIdentifier())
Result += Param->getIdentifier()->getName();
}
@@ -2508,7 +2530,8 @@ CodeCompletionResult::CreateCodeCompletionString(Sema &S,
Arg = FormatFunctionParameter(S.Context, *P, true);
else {
(*P)->getType().getAsStringInternal(Arg, Policy);
- Arg = "(" + Arg + ")";
+ Arg = "(" + formatObjCParamQualifiers((*P)->getObjCDeclQualifier())
+ + Arg + ")";
if (IdentifierInfo *II = (*P)->getIdentifier())
if (DeclaringEntity || AllParametersAreInformative)
Arg += II->getName();
diff --git a/test/Index/complete-objc-message.m b/test/Index/complete-objc-message.m
index 7477f3f09a..955ab6f144 100644
--- a/test/Index/complete-objc-message.m
+++ b/test/Index/complete-objc-message.m
@@ -181,6 +181,14 @@ void test_block_invoke(A *(^block1)(int),
[block1(5) init];
}
+@interface DO
+- (void)method:(in bycopy A*)ain result:(out byref A**)aout;
+@end
+
+void test_DO(DO *d, A* a) {
+ [d method:a aout:&a];
+}
+
// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: {TypedText categoryClassMethod}
// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)}{HorizontalSpace }{TypedText withKeyword:}{Placeholder (int)}
@@ -323,3 +331,6 @@ void test_block_invoke(A *(^block1)(int),
// RUN: c-index-test -code-completion-at=%s:141:30 %s | FileCheck -check-prefix=CHECK-CCE %s
// RUN: c-index-test -code-completion-at=%s:175:12 %s | FileCheck -check-prefix=CHECK-CLASS-RESULT %s
+
+// RUN: c-index-test -code-completion-at=%s:189:6 %s | FileCheck -check-prefix=CHECK-DISTRIB-OBJECTS %s
+// CHECK-DISTRIB-OBJECTS: ObjCInstanceMethodDecl:{ResultType void}{TypedText method:}{Placeholder (in bycopyA *)}{HorizontalSpace }{TypedText result:}{Placeholder (out byrefA **)} (35)