[cfe-commits] r167141 - in /cfe/trunk: lib/Frontend/ASTUnit.cpp lib/Frontend/CompilerInstance.cpp lib/Parse/Parser.cpp test/Index/code-completion-skip-bodies.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Oct 31 10:29:23 PDT 2012


Author: akirtzidis
Date: Wed Oct 31 12:29:22 2012
New Revision: 167141

URL: http://llvm.org/viewvc/llvm-project?rev=167141&view=rev
Log:
Decouple code-completion for the SkipFunctionBodies frontend option and
add a test to make sure code-completion skips bodies.

Added:
    cfe/trunk/test/Index/code-completion-skip-bodies.cpp
Modified:
    cfe/trunk/lib/Frontend/ASTUnit.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Parse/Parser.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=167141&r1=167140&r2=167141&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed Oct 31 12:29:22 2012
@@ -2416,8 +2416,6 @@
     = 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

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=167141&r1=167140&r2=167141&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Oct 31 12:29:22 2012
@@ -89,7 +89,6 @@
 
 void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) {
   CompletionConsumer.reset(Value);
-  getFrontendOpts().SkipFunctionBodies = Value != 0;
 }
 
 // Diagnostics

Modified: cfe/trunk/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/Parser.cpp?rev=167141&r1=167140&r2=167141&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/Parser.cpp (original)
+++ cfe/trunk/lib/Parse/Parser.cpp Wed Oct 31 12:29:22 2012
@@ -48,11 +48,12 @@
   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;

Added: cfe/trunk/test/Index/code-completion-skip-bodies.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/code-completion-skip-bodies.cpp?rev=167141&view=auto
==============================================================================
--- cfe/trunk/test/Index/code-completion-skip-bodies.cpp (added)
+++ cfe/trunk/test/Index/code-completion-skip-bodies.cpp Wed Oct 31 12:29:22 2012
@@ -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}





More information about the cfe-commits mailing list