aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-09-14 23:59:36 +0000
committerDouglas Gregor <dgregor@apple.com>2010-09-14 23:59:36 +0000
commit0268810a46780144a2d5fb5a017c938d1199189c (patch)
tree6e06d1b58bdb7854ca6481a14459e3ef339e93bf /lib/Sema/SemaCodeComplete.cpp
parent6c52c7850bccb6991470668429a1e1edf01b0873 (diff)
Introduce a new code-completion context for a parenthesized
expression, e.g., after the '(' that could also be a type cast. Here, we provide types as code-completion results in C/Objective-C (C++ already had them), although we wouldn't in a normal expression context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--lib/Sema/SemaCodeComplete.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 135c59365b..7dc2cb3609 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -1176,6 +1176,7 @@ static void AddFunctionSpecifiers(Sema::ParserCompletionContext CCC,
case Sema::PCC_Condition:
case Sema::PCC_RecoveryInFunction:
case Sema::PCC_Type:
+ case Sema::PCC_ParenthesizedExpression:
break;
}
}
@@ -1205,9 +1206,6 @@ static void AddTypedefResult(ResultBuilder &Results) {
static bool WantTypesInContext(Sema::ParserCompletionContext CCC,
const LangOptions &LangOpts) {
- if (LangOpts.CPlusPlus)
- return true;
-
switch (CCC) {
case Sema::PCC_Namespace:
case Sema::PCC_Class:
@@ -1217,16 +1215,19 @@ static bool WantTypesInContext(Sema::ParserCompletionContext CCC,
case Sema::PCC_Statement:
case Sema::PCC_RecoveryInFunction:
case Sema::PCC_Type:
+ case Sema::PCC_ParenthesizedExpression:
return true;
- case Sema::PCC_ObjCInterface:
- case Sema::PCC_ObjCImplementation:
case Sema::PCC_Expression:
case Sema::PCC_Condition:
+ return LangOpts.CPlusPlus;
+
+ case Sema::PCC_ObjCInterface:
+ case Sema::PCC_ObjCImplementation:
return false;
case Sema::PCC_ForInit:
- return LangOpts.ObjC1 || LangOpts.C99;
+ return LangOpts.CPlusPlus || LangOpts.ObjC1 || LangOpts.C99;
}
return false;
@@ -1556,6 +1557,7 @@ static void AddOrdinaryNameResults(Sema::ParserCompletionContext CCC,
AddStorageSpecifiers(CCC, SemaRef.getLangOptions(), Results);
// Fall through: conditions and statements can have expressions.
+ case Sema::PCC_ParenthesizedExpression:
case Sema::PCC_Expression: {
CodeCompletionString *Pattern = 0;
if (SemaRef.getLangOptions().CPlusPlus) {
@@ -2453,6 +2455,9 @@ static enum CodeCompletionContext::Kind mapCodeCompletionContext(Sema &S,
case Sema::PCC_Type:
return CodeCompletionContext::CCC_Type;
+
+ case Sema::PCC_ParenthesizedExpression:
+ return CodeCompletionContext::CCC_ParenthesizedExpression;
}
return CodeCompletionContext::CCC_Other;
@@ -2559,6 +2564,7 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
Results.setPreferredType(Context.VoidTy);
// Fall through
+ case PCC_ParenthesizedExpression:
case PCC_Expression:
case PCC_ForInit:
case PCC_Condition:
@@ -2591,6 +2597,7 @@ void Sema::CodeCompleteOrdinaryName(Scope *S,
Results.ExitScope();
switch (CompletionContext) {
+ case PCC_ParenthesizedExpression:
case PCC_Expression:
case PCC_Statement:
case PCC_RecoveryInFunction: