Currently we return no results when completing inside of the brackets in
a 'char foo[]' declaration. Let the generic expression completion code
handle it instead. We could get fancier here (e.g. filter non-constant
expressions in contexts where VLAs are not allowed), but it's a strict
improvement over the existing version.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261217
91177308-0d34-0410-b5e6-
96231b3b80d8
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS);
void CodeCompleteTag(Scope *S, unsigned TagSpec);
void CodeCompleteTypeQualifiers(DeclSpec &DS);
+ void CodeCompleteBracketDeclarator(Scope *S);
void CodeCompleteCase(Scope *S);
void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef<Expr *> Args);
void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc,
T.getCloseLocation()),
attrs, T.getCloseLocation());
return;
+ } else if (Tok.getKind() == tok::code_completion) {
+ Actions.CodeCompleteBracketDeclarator(getCurScope());
+ return cutOffParsing();
}
// If valid, this location is the position where we read the 'static' keyword.
Results.data(), Results.size());
}
+void Sema::CodeCompleteBracketDeclarator(Scope *S) {
+ CodeCompleteExpression(S, QualType(getASTContext().getSizeType()));
+}
+
void Sema::CodeCompleteCase(Scope *S) {
if (getCurFunction()->SwitchStack.empty() || !CodeCompleter)
return;
--- /dev/null
+#define PATHSIZE 256
+
+static const int len = 1234;
+
+void foo() {
+ char arr[
+// RUN: %clang_cc1 -fsyntax-only -code-completion-macros -code-completion-at=%s:6:12 %s -o - | FileCheck %s
+// CHECK: COMPLETION: len
+// CHECK: COMPLETION: PATHSIZE