diff options
author | Erik Verbruggen <erikjv@me.com> | 2012-04-12 10:11:59 +0000 |
---|---|---|
committer | Erik Verbruggen <erikjv@me.com> | 2012-04-12 10:11:59 +0000 |
commit | 6a91d385618ea4d28236c496f540a26877c95525 (patch) | |
tree | 519b6349002f939312dbf362c992bd0507211beb /include | |
parent | f33d549b16a4d2f7325a099eee0ab7ee50c9528f (diff) |
Added a flag to the parser to skip method bodies.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154584 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang-c/Index.h | 11 | ||||
-rw-r--r-- | include/clang/Frontend/ASTUnit.h | 1 | ||||
-rw-r--r-- | include/clang/Frontend/FrontendOptions.h | 5 | ||||
-rw-r--r-- | include/clang/Parse/ParseAST.h | 6 | ||||
-rw-r--r-- | include/clang/Parse/Parser.h | 6 |
5 files changed, 24 insertions, 5 deletions
diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index b297e54512..13ba6ba2ae 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -1069,7 +1069,16 @@ enum CXTranslationUnit_Flags { * Note: this is a *temporary* option that is available only while * we are testing C++ precompiled preamble support. It is deprecated. */ - CXTranslationUnit_CXXChainedPCH = 0x20 + CXTranslationUnit_CXXChainedPCH = 0x20, + + /** + * \brief Used to indicate that function/method bodies should be skipped while + * parsing. + * + * This option can be used to search for declarations/definitions while + * ignoring the usages. + */ + CXTranslationUnit_SkipFunctionBodies = 0x40 }; /** diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 2fd87c941e..5e4ecadd69 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -741,6 +741,7 @@ public: TranslationUnitKind TUKind = TU_Complete, bool CacheCodeCompletionResults = false, bool AllowPCHWithCompilerErrors = false, + bool SkipFunctionBodies = false, OwningPtr<ASTUnit> *ErrAST = 0); /// \brief Reparse the source files using the same command-line options that diff --git a/include/clang/Frontend/FrontendOptions.h b/include/clang/Frontend/FrontendOptions.h index 49a9ec189d..a051d7ff62 100644 --- a/include/clang/Frontend/FrontendOptions.h +++ b/include/clang/Frontend/FrontendOptions.h @@ -112,6 +112,10 @@ public: unsigned FixToTemporaries : 1; ///< Apply fixes to temporary files. unsigned ARCMTMigrateEmitARCErrors : 1; /// Emit ARC errors even if the /// migrator can fix them + unsigned SkipFunctionBodies : 1; ///< Skip over function bodies to + /// speed up parsing in cases you do + /// not need them (e.g. with code + /// completion). enum { ARCMT_None, @@ -188,6 +192,7 @@ public: ShowVersion = 0; ARCMTAction = ARCMT_None; ARCMTMigrateEmitARCErrors = 0; + SkipFunctionBodies = 0; ObjCMTAction = ObjCMT_None; } diff --git a/include/clang/Parse/ParseAST.h b/include/clang/Parse/ParseAST.h index 725387024e..2405a0ccd6 100644 --- a/include/clang/Parse/ParseAST.h +++ b/include/clang/Parse/ParseAST.h @@ -36,11 +36,13 @@ namespace clang { void ParseAST(Preprocessor &pp, ASTConsumer *C, ASTContext &Ctx, bool PrintStats = false, TranslationUnitKind TUKind = TU_Complete, - CodeCompleteConsumer *CompletionConsumer = 0); + CodeCompleteConsumer *CompletionConsumer = 0, + bool SkipFunctionBodies = false); /// \brief Parse the main file known to the preprocessor, producing an /// abstract syntax tree. - void ParseAST(Sema &S, bool PrintStats = false); + void ParseAST(Sema &S, bool PrintStats = false, + bool SkipFunctionBodies = false); } // end namespace clang diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 9d784c9e96..0e5e8c7d88 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -198,8 +198,10 @@ class Parser : public CodeCompletionHandler { IdentifierInfo *getSEHExceptKeyword(); + bool SkipFunctionBodies; + public: - Parser(Preprocessor &PP, Sema &Actions); + Parser(Preprocessor &PP, Sema &Actions, bool SkipFunctionBodies); ~Parser(); const LangOptions &getLangOpts() const { return PP.getLangOpts(); } @@ -1671,7 +1673,7 @@ private: /// unless the body contains the code-completion point. /// /// \returns true if the function body was skipped. - bool trySkippingFunctionBodyForCodeCompletion(); + bool trySkippingFunctionBody(); bool ParseImplicitInt(DeclSpec &DS, CXXScopeSpec *SS, const ParsedTemplateInfo &TemplateInfo, |