diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-05-16 15:06:55 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2018-05-17 07:08:58 +0000 |
commit | cbe51a943adebe43cfd8f20a190670a1d6a0e908 (patch) | |
tree | 4a9ddc355d6d194b791f648711d1c6af0e33c221 /include/clang | |
parent | 0e790628055f8e1edbc4a1176e3cc064cf544a2b (diff) |
[backported/clang-7][libclang] Allow skipping function bodies in preamble only
--------------------------------------------------------------------------
* https://reviews.llvm.org/D45815
* Speed ups parse/reparse significantly but on the other hand does not
issue any more diagnostics from template functions from headers.
--------------------------------------------------------------------------
As an addition to CXTranslationUnit_SkipFunctionBodies, provide the
new option CXTranslationUnit_LimitSkipFunctionBodiesToPreamble,
which constraints the skipping of functions bodies to the preamble
only. Function bodies in the main file are not affected if this
option is set.
Skipping function bodies only in the preamble is what clangd already
does and the introduced flag implements it for libclang clients.
Change-Id: I092a2d78d1e59a9e546d317ee2f18c98cdc7dcdb
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'include/clang')
-rw-r--r-- | include/clang/Frontend/ASTUnit.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 5d04dcd191..09aeab5b6f 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -66,6 +66,9 @@ namespace vfs { class FileSystem; } +/// \brief Enumerates the available scopes for skipping function bodies. +enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile }; + /// \brief Utility class for loading a ASTContext from an AST file. /// class ASTUnit { @@ -335,6 +338,9 @@ private: /// inconsistent state, and is not safe to free. unsigned UnsafeToFree : 1; + /// \brief Enumerator specifying the scope for skipping function bodies. + SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None; + /// \brief Cache any "global" code-completion results, so that we can avoid /// recomputing them with each completion. void CacheCodeCompletionResults(); @@ -353,7 +359,7 @@ private: std::unique_ptr<llvm::MemoryBuffer> getMainBufferWithPrecompiledPreamble( std::shared_ptr<PCHContainerOperations> PCHContainerOps, - const CompilerInvocation &PreambleInvocationIn, + CompilerInvocation &PreambleInvocationIn, IntrusiveRefCntPtr<vfs::FileSystem> VFS, bool AllowRebuild = true, unsigned MaxLines = 0); void RealizeTopLevelDeclsFromPreamble(); @@ -782,9 +788,11 @@ public: TranslationUnitKind TUKind = TU_Complete, bool CacheCodeCompletionResults = false, bool IncludeBriefCommentsInCodeCompletion = false, - bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies = false, - bool SingleFileParse = false, - bool UserFilesAreVolatile = false, bool ForSerialization = false, + bool AllowPCHWithCompilerErrors = false, + SkipFunctionBodiesScope SkipFunctionBodies = + SkipFunctionBodiesScope::None, + bool SingleFileParse = false, bool UserFilesAreVolatile = false, + bool ForSerialization = false, llvm::Optional<StringRef> ModuleFormat = llvm::None, std::unique_ptr<ASTUnit> *ErrAST = nullptr, IntrusiveRefCntPtr<vfs::FileSystem> VFS = nullptr); |