When code-completing within a list of declaration specifiers,

separately handle the case of a local declaration-specifier list,
including all types in the set of options. Fixes
<rdar://problem/8790735> and <rdar://problem/8662831>.

llvm-svn: 125594
This commit is contained in:
Douglas Gregor 2011-02-15 20:33:25 +00:00
parent 6f93f63955
commit 8003924d10
5 changed files with 43 additions and 3 deletions

View File

@ -146,7 +146,7 @@ class Sema;
class CodeCompletionContext {
public:
enum Kind {
/// \brief An unspecified code-completion context, where the
/// \brief An unspecified code-completion context.
CCC_Other,
/// \brief Code completion occurred within a "top-level" completion context,
/// e.g., at namespace or global scope.

View File

@ -4938,7 +4938,10 @@ public:
PCC_Type,
/// \brief Code completion occurs in a parenthesized expression, which
/// might also be a type cast.
PCC_ParenthesizedExpression
PCC_ParenthesizedExpression,
/// \brief Code completion occurs within a sequence of declaration
/// specifiers within a function, method, or block.
PCC_LocalDeclarationSpecifiers
};
void CodeCompleteOrdinaryName(Scope *S,

View File

@ -920,7 +920,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
return;
}
if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
if (getCurScope()->getFnParent() || getCurScope()->getBlockParent())
CCC = Sema::PCC_LocalDeclarationSpecifiers;
else if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
CCC = DSContext == DSC_class? Sema::PCC_MemberTemplate
: Sema::PCC_Template;
else if (DSContext == DSC_class)

View File

@ -1286,6 +1286,7 @@ static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC,
case Sema::PCC_RecoveryInFunction:
case Sema::PCC_Type:
case Sema::PCC_ParenthesizedExpression:
case Sema::PCC_LocalDeclarationSpecifiers:
break;
}
}
@ -1325,6 +1326,7 @@ static bool WantTypesInContext(Sema::ParserCompletionContext CCC,
case Sema::PCC_RecoveryInFunction:
case Sema::PCC_Type:
case Sema::PCC_ParenthesizedExpression:
case Sema::PCC_LocalDeclarationSpecifiers:
return true;
case Sema::PCC_Expression:
@ -1768,6 +1770,7 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC,
}
case Sema::PCC_Type:
case Sema::PCC_LocalDeclarationSpecifiers:
break;
}
@ -2719,6 +2722,9 @@ static enum CodeCompletionContext::Kind mapCodeCompletionContext(Sema &S,
case Sema::PCC_ParenthesizedExpression:
return CodeCompletionContext::CCC_ParenthesizedExpression;
case Sema::PCC_LocalDeclarationSpecifiers:
return CodeCompletionContext::CCC_Type;
}
return CodeCompletionContext::CCC_Other;
@ -2818,6 +2824,7 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
case PCC_Template:
case PCC_MemberTemplate:
case PCC_Type:
case PCC_LocalDeclarationSpecifiers:
Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
break;
@ -2873,6 +2880,7 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
case PCC_ForInit:
case PCC_Condition:
case PCC_Type:
case PCC_LocalDeclarationSpecifiers:
break;
}

View File

@ -19,6 +19,8 @@
for(q in param1) {
int y;
}
static P *p = 0;
}
@end
@ -43,3 +45,28 @@
// CHECK-CC4-NOT: VarDecl:{ResultType int}{TypedText q2}
// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText self} (34)
// CHECK-CC4: NotImplemented:{TypedText sizeof}{LeftParen (}{Placeholder expression-or-type}{RightParen )} (40)
// RUN: c-index-test -code-completion-at=%s:23:10 %s | FileCheck -check-prefix=CHECK-CC5 %s
// CHECK-CC5: NotImplemented:{TypedText _Bool} (50)
// CHECK-CC5: NotImplemented:{TypedText _Complex} (50)
// CHECK-CC5: NotImplemented:{TypedText _Imaginary} (50)
// CHECK-CC5: ObjCInterfaceDecl:{TypedText A} (50)
// CHECK-CC5: NotImplemented:{TypedText char} (50)
// CHECK-CC5: TypedefDecl:{TypedText Class} (50)
// CHECK-CC5: NotImplemented:{TypedText const} (50)
// CHECK-CC5: NotImplemented:{TypedText double} (50)
// CHECK-CC5: NotImplemented:{TypedText enum} (50)
// CHECK-CC5: NotImplemented:{TypedText float} (50)
// CHECK-CC5: TypedefDecl:{TypedText id} (50)
// CHECK-CC5: NotImplemented:{TypedText int} (50)
// CHECK-CC5: NotImplemented:{TypedText long} (50)
// CHECK-CC5: NotImplemented:{TypedText restrict} (50)
// CHECK-CC5: TypedefDecl:{TypedText SEL} (50)
// CHECK-CC5: NotImplemented:{TypedText short} (50)
// CHECK-CC5: NotImplemented:{TypedText signed} (50)
// CHECK-CC5: NotImplemented:{TypedText struct} (50)
// CHECK-CC5: NotImplemented:{TypedText typeof}{HorizontalSpace }{Placeholder expression} (40)
// CHECK-CC5: NotImplemented:{TypedText typeof}{LeftParen (}{Placeholder type}{RightParen )} (40)
// CHECK-CC5: NotImplemented:{TypedText union} (50)
// CHECK-CC5: NotImplemented:{TypedText unsigned} (50)
// CHECK-CC5: NotImplemented:{TypedText void} (50)
// CHECK-CC5: NotImplemented:{TypedText volatile} (50)