diff options
Diffstat (limited to 'include/clang/Frontend/ASTUnit.h')
| -rw-r--r-- | include/clang/Frontend/ASTUnit.h | 41 | 
1 files changed, 26 insertions, 15 deletions
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h index d0b532cf2d343..7fb1d2d93380c 100644 --- a/include/clang/Frontend/ASTUnit.h +++ b/include/clang/Frontend/ASTUnit.h @@ -1,9 +1,8 @@  //===- ASTUnit.h - ASTUnit utility ------------------------------*- C++ -*-===//  // -//                     The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception  //  //===----------------------------------------------------------------------===//  // @@ -72,7 +71,7 @@ class FileManager;  class FrontendAction;  class HeaderSearch;  class InputKind; -class MemoryBufferCache; +class InMemoryModuleCache;  class PCHContainerOperations;  class PCHContainerReader;  class Preprocessor; @@ -83,6 +82,9 @@ class TargetInfo;  /// \brief Enumerates the available scopes for skipping function bodies.  enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile }; +/// \brief Enumerates the available kinds for capturing diagnostics. +enum class CaptureDiagsKind { None, All, AllWithoutNonErrorsFromIncludes }; +  /// Utility class for loading a ASTContext from an AST file.  class ASTUnit {  public: @@ -108,7 +110,7 @@ private:    IntrusiveRefCntPtr<DiagnosticsEngine>   Diagnostics;    IntrusiveRefCntPtr<FileManager>         FileMgr;    IntrusiveRefCntPtr<SourceManager>       SourceMgr; -  IntrusiveRefCntPtr<MemoryBufferCache>   PCMCache; +  IntrusiveRefCntPtr<InMemoryModuleCache> ModuleCache;    std::unique_ptr<HeaderSearch>           HeaderInfo;    IntrusiveRefCntPtr<TargetInfo>          Target;    std::shared_ptr<Preprocessor>           PP; @@ -145,7 +147,7 @@ private:    bool OnlyLocalDecls = false;    /// Whether to capture any diagnostics produced. -  bool CaptureDiagnostics = false; +  CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None;    /// Track whether the main file was loaded from an AST or not.    bool MainFileIsAST; @@ -206,7 +208,10 @@ private:    /// we'll attempt to rebuild the precompiled header. This way, if    /// building the precompiled preamble fails, we won't try again for    /// some number of calls. -  unsigned PreambleRebuildCounter = 0; +  unsigned PreambleRebuildCountdown = 0; + +  /// Counter indicating how often the preamble was build in total. +  unsigned PreambleCounter = 0;    /// Cache pairs "filename - source location"    /// @@ -248,7 +253,7 @@ private:    bool UserFilesAreVolatile : 1;    static void ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags, -                             ASTUnit &AST, bool CaptureDiagnostics); +                             ASTUnit &AST, CaptureDiagsKind CaptureDiagnostics);    void TranslateStoredDiagnostics(FileManager &FileMgr,                                    SourceManager &SrcMan, @@ -575,6 +580,8 @@ public:                         mapLocationToPreamble(R.getEnd()));    } +  unsigned getPreambleCounterForTests() const { return PreambleCounter; } +    // Retrieve the diagnostics associated with this AST    using stored_diag_iterator = StoredDiagnostic *;    using stored_diag_const_iterator = const StoredDiagnostic *; @@ -657,8 +664,8 @@ public:    /// Create a ASTUnit. Gets ownership of the passed CompilerInvocation.    static std::unique_ptr<ASTUnit>    create(std::shared_ptr<CompilerInvocation> CI, -         IntrusiveRefCntPtr<DiagnosticsEngine> Diags, bool CaptureDiagnostics, -         bool UserFilesAreVolatile); +         IntrusiveRefCntPtr<DiagnosticsEngine> Diags, +         CaptureDiagsKind CaptureDiagnostics, bool UserFilesAreVolatile);    enum WhatToLoad {      /// Load options and the preprocessor state. @@ -686,7 +693,8 @@ public:        WhatToLoad ToLoad, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,        const FileSystemOptions &FileSystemOpts, bool UseDebugInfo = false,        bool OnlyLocalDecls = false, ArrayRef<RemappedFile> RemappedFiles = None, -      bool CaptureDiagnostics = false, bool AllowPCHWithCompilerErrors = false, +      CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None, +      bool AllowPCHWithCompilerErrors = false,        bool UserFilesAreVolatile = false);  private: @@ -744,7 +752,8 @@ public:        IntrusiveRefCntPtr<DiagnosticsEngine> Diags,        FrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,        bool Persistent = true, StringRef ResourceFilesPath = StringRef(), -      bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, +      bool OnlyLocalDecls = false, +      CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,        unsigned PrecompilePreambleAfterNParses = 0,        bool CacheCodeCompletionResults = false,        bool IncludeBriefCommentsInCodeCompletion = false, @@ -769,7 +778,8 @@ public:        std::shared_ptr<CompilerInvocation> CI,        std::shared_ptr<PCHContainerOperations> PCHContainerOps,        IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr, -      bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, +      bool OnlyLocalDecls = false, +      CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,        unsigned PrecompilePreambleAfterNParses = 0,        TranslationUnitKind TUKind = TU_Complete,        bool CacheCodeCompletionResults = false, @@ -809,7 +819,8 @@ public:        const char **ArgBegin, const char **ArgEnd,        std::shared_ptr<PCHContainerOperations> PCHContainerOps,        IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath, -      bool OnlyLocalDecls = false, bool CaptureDiagnostics = false, +      bool OnlyLocalDecls = false, +      CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,        ArrayRef<RemappedFile> RemappedFiles = None,        bool RemappedFilesKeepOriginalName = true,        unsigned PrecompilePreambleAfterNParses = 0,  | 
