[cfe-commits] r125594 - in /cfe/trunk: include/clang/Sema/CodeCompleteConsumer.h include/clang/Sema/Sema.h lib/Parse/ParseDecl.cpp lib/Sema/SemaCodeComplete.cpp test/Index/complete-declarators.m
Douglas Gregor
dgregor at apple.com
Tue Feb 15 12:33:25 PST 2011
Author: dgregor
Date: Tue Feb 15 14:33:25 2011
New Revision: 125594
URL: http://llvm.org/viewvc/llvm-project?rev=125594&view=rev
Log:
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>.
Modified:
cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-declarators.m
Modified: cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h?rev=125594&r1=125593&r2=125594&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h (original)
+++ cfe/trunk/include/clang/Sema/CodeCompleteConsumer.h Tue Feb 15 14:33:25 2011
@@ -146,7 +146,7 @@
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.
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=125594&r1=125593&r2=125594&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Feb 15 14:33:25 2011
@@ -4938,7 +4938,10 @@
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,
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=125594&r1=125593&r2=125594&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Feb 15 14:33:25 2011
@@ -920,7 +920,9 @@
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)
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=125594&r1=125593&r2=125594&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Feb 15 14:33:25 2011
@@ -1286,6 +1286,7 @@
case Sema::PCC_RecoveryInFunction:
case Sema::PCC_Type:
case Sema::PCC_ParenthesizedExpression:
+ case Sema::PCC_LocalDeclarationSpecifiers:
break;
}
}
@@ -1325,6 +1326,7 @@
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 @@
}
case Sema::PCC_Type:
+ case Sema::PCC_LocalDeclarationSpecifiers:
break;
}
@@ -2719,6 +2722,9 @@
case Sema::PCC_ParenthesizedExpression:
return CodeCompletionContext::CCC_ParenthesizedExpression;
+
+ case Sema::PCC_LocalDeclarationSpecifiers:
+ return CodeCompletionContext::CCC_Type;
}
return CodeCompletionContext::CCC_Other;
@@ -2818,6 +2824,7 @@
case PCC_Template:
case PCC_MemberTemplate:
case PCC_Type:
+ case PCC_LocalDeclarationSpecifiers:
Results.setFilter(&ResultBuilder::IsOrdinaryNonValueName);
break;
@@ -2873,6 +2880,7 @@
case PCC_ForInit:
case PCC_Condition:
case PCC_Type:
+ case PCC_LocalDeclarationSpecifiers:
break;
}
Modified: cfe/trunk/test/Index/complete-declarators.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-declarators.m?rev=125594&r1=125593&r2=125594&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-declarators.m (original)
+++ cfe/trunk/test/Index/complete-declarators.m Tue Feb 15 14:33:25 2011
@@ -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)
More information about the cfe-commits
mailing list