mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 01:16:06 +00:00
Decouple code-completion for the SkipFunctionBodies frontend option and
add a test to make sure code-completion skips bodies. llvm-svn: 167141
This commit is contained in:
parent
9d08a15b0f
commit
3a6c8141f9
@ -2416,8 +2416,6 @@ void ASTUnit::CodeComplete(StringRef File, unsigned Line, unsigned Column,
|
||||
= new AugmentedCodeCompleteConsumer(*this, Consumer, CodeCompleteOpts);
|
||||
Clang->setCodeCompletionConsumer(AugmentedConsumer);
|
||||
|
||||
Clang->getFrontendOpts().SkipFunctionBodies = true;
|
||||
|
||||
// If we have a precompiled preamble, try to use it. We only allow
|
||||
// the use of the precompiled preamble if we're if the completion
|
||||
// point is within the main file, after the end of the precompiled
|
||||
|
@ -89,7 +89,6 @@ void CompilerInstance::setASTConsumer(ASTConsumer *Value) {
|
||||
|
||||
void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) {
|
||||
CompletionConsumer.reset(Value);
|
||||
getFrontendOpts().SkipFunctionBodies = Value != 0;
|
||||
}
|
||||
|
||||
// Diagnostics
|
||||
|
@ -48,11 +48,12 @@ IdentifierInfo *Parser::getSEHExceptKeyword() {
|
||||
return Ident__except;
|
||||
}
|
||||
|
||||
Parser::Parser(Preprocessor &pp, Sema &actions, bool SkipFunctionBodies)
|
||||
Parser::Parser(Preprocessor &pp, Sema &actions, bool skipFunctionBodies)
|
||||
: PP(pp), Actions(actions), Diags(PP.getDiagnostics()),
|
||||
GreaterThanIsOperator(true), ColonIsSacred(false),
|
||||
InMessageExpression(false), TemplateParameterDepth(0),
|
||||
ParsingInObjCContainer(false), SkipFunctionBodies(SkipFunctionBodies) {
|
||||
ParsingInObjCContainer(false) {
|
||||
SkipFunctionBodies = pp.isCodeCompletionEnabled() || skipFunctionBodies;
|
||||
Tok.startToken();
|
||||
Tok.setKind(tok::eof);
|
||||
Actions.CurScope = 0;
|
||||
|
17
clang/test/Index/code-completion-skip-bodies.cpp
Normal file
17
clang/test/Index/code-completion-skip-bodies.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
// This is to make sure we skip function bodies.
|
||||
void func_to_skip() {
|
||||
undeclared1 = 0;
|
||||
}
|
||||
|
||||
struct S { int x; };
|
||||
|
||||
void func(S *s) {
|
||||
undeclared2 = 0;
|
||||
s->x = 0;
|
||||
}
|
||||
|
||||
// RUN: c-index-test -code-completion-at=%s:11:6 %s 2>&1 | FileCheck %s
|
||||
// CHECK-NOT: error: use of undeclared identifier 'undeclared1'
|
||||
// CHECK: error: use of undeclared identifier 'undeclared2'
|
||||
// CHECK: FieldDecl:{ResultType int}{TypedText x}
|
Loading…
x
Reference in New Issue
Block a user