diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-04-11 02:11:16 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2012-04-11 02:11:16 +0000 |
commit | e722ed6f5464232e23be52f4976312ef526fae99 (patch) | |
tree | a0996067f02cadf86b040e792f2dc5cfb19ba4fc /include/clang/Frontend/ASTUnit.h | |
parent | 259052d8c819d101f6f627f960f56e582ecbcebc (diff) |
[libclang] If displayDiagnostics is set (when calling clang_createIndex), make sure to
output the errors that occurred even if we did not get an AST (e.g. because the
PCH failed to load).
Also honor displayDiagnostics in clang_indexSourceFile().
rdar://11203489
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154472 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend/ASTUnit.h')
-rw-r--r-- | include/clang/Frontend/ASTUnit.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index 5b869a2136..2fd87c941e 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -46,6 +46,7 @@ class ASTContext; class ASTReader; class CodeCompleteConsumer; class CompilerInvocation; +class CompilerInstance; class Decl; class DiagnosticsEngine; class FileEntry; @@ -143,6 +144,10 @@ private: /// translation unit. SmallVector<StoredDiagnostic, 4> StoredDiagnostics; + /// \brief The set of diagnostics produced when failing to parse, e.g. due + /// to failure to load the PCH. + SmallVector<StoredDiagnostic, 4> FailedParseDiagnostics; + /// \brief The number of stored diagnostics that come from the driver /// itself. /// @@ -384,7 +389,11 @@ private: bool AllowRebuild = true, unsigned MaxLines = 0); void RealizeTopLevelDeclsFromPreamble(); - + + /// \brief Transfers ownership of the objects (like SourceManager) from + /// \param CI to this ASTUnit. + void transferASTDataFromCompilerInstance(CompilerInstance &CI); + /// \brief Allows us to assert that ASTUnit is not being used concurrently, /// which is not supported. /// @@ -663,6 +672,13 @@ public: /// \param Persistent - if true the returned ASTUnit will be complete. /// false means the caller is only interested in getting info through the /// provided \see Action. + /// + /// \param ErrAST - If non-null and parsing failed without any AST to return + /// (e.g. because the PCH could not be loaded), this accepts the ASTUnit + /// mainly to allow the caller to see the diagnostics. + /// This will only receive an ASTUnit if a new one was created. If an already + /// created ASTUnit was passed in \param Unit then the caller can check that. + /// static ASTUnit *LoadFromCompilerInvocationAction(CompilerInvocation *CI, IntrusiveRefCntPtr<DiagnosticsEngine> Diags, ASTFrontendAction *Action = 0, @@ -672,7 +688,8 @@ public: bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, bool PrecompilePreamble = false, - bool CacheCodeCompletionResults = false); + bool CacheCodeCompletionResults = false, + OwningPtr<ASTUnit> *ErrAST = 0); /// LoadFromCompilerInvocation - Create an ASTUnit from a source file, via a /// CompilerInvocation object. @@ -704,7 +721,11 @@ public: /// lifetime is expected to extend past that of the returned ASTUnit. /// /// \param ResourceFilesPath - The path to the compiler resource files. - // + /// + /// \param ErrAST - If non-null and parsing failed without any AST to return + /// (e.g. because the PCH could not be loaded), this accepts the ASTUnit + /// mainly to allow the caller to see the diagnostics. + /// // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we // shouldn't need to specify them at construction time. static ASTUnit *LoadFromCommandLine(const char **ArgBegin, @@ -719,7 +740,8 @@ public: bool PrecompilePreamble = false, TranslationUnitKind TUKind = TU_Complete, bool CacheCodeCompletionResults = false, - bool AllowPCHWithCompilerErrors = false); + bool AllowPCHWithCompilerErrors = false, + OwningPtr<ASTUnit> *ErrAST = 0); /// \brief Reparse the source files using the same command-line options that /// were originally used to produce this translation unit. |