|
| 1 | +//===-- CreateInvocationFromArgs.h - Create an ASTUnit from Args-*- C++ -*-===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// |
| 9 | +// Utility for creating an ASTUnit from a vector of command line arguments. |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#ifndef LLVM_CLANG_DRIVER_CREATEASTUNITFROMARGS_H |
| 14 | +#define LLVM_CLANG_DRIVER_CREATEASTUNITFROMARGS_H |
| 15 | + |
| 16 | +#include "clang/Frontend/ASTUnit.h" |
| 17 | + |
| 18 | +namespace clang { |
| 19 | + |
| 20 | +/// Create an ASTUnit from a vector of command line arguments, which must |
| 21 | +/// specify exactly one source file. |
| 22 | +/// |
| 23 | +/// \param ArgBegin - The beginning of the argument vector. |
| 24 | +/// |
| 25 | +/// \param ArgEnd - The end of the argument vector. |
| 26 | +/// |
| 27 | +/// \param PCHContainerOps - The PCHContainerOperations to use for loading and |
| 28 | +/// creating modules. |
| 29 | +/// |
| 30 | +/// \param Diags - The diagnostics engine to use for reporting errors; its |
| 31 | +/// lifetime is expected to extend past that of the returned ASTUnit. |
| 32 | +/// |
| 33 | +/// \param ResourceFilesPath - The path to the compiler resource files. |
| 34 | +/// |
| 35 | +/// \param StorePreamblesInMemory - Whether to store PCH in memory. If false, |
| 36 | +/// PCH are stored in temporary files. |
| 37 | +/// |
| 38 | +/// \param PreambleStoragePath - The path to a directory, in which to create |
| 39 | +/// temporary PCH files. If empty, the default system temporary directory is |
| 40 | +/// used. This parameter is ignored if \p StorePreamblesInMemory is true. |
| 41 | +/// |
| 42 | +/// \param ModuleFormat - If provided, uses the specific module format. |
| 43 | +/// |
| 44 | +/// \param ErrAST - If non-null and parsing failed without any AST to return |
| 45 | +/// (e.g. because the PCH could not be loaded), this accepts the ASTUnit |
| 46 | +/// mainly to allow the caller to see the diagnostics. |
| 47 | +/// |
| 48 | +/// \param VFS - A llvm::vfs::FileSystem to be used for all file accesses. |
| 49 | +/// Note that preamble is saved to a temporary directory on a RealFileSystem, |
| 50 | +/// so in order for it to be loaded correctly, VFS should have access to |
| 51 | +/// it(i.e., be an overlay over RealFileSystem). RealFileSystem will be used |
| 52 | +/// if \p VFS is nullptr. |
| 53 | +/// |
| 54 | +// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we |
| 55 | +// shouldn't need to specify them at construction time. |
| 56 | +std::unique_ptr<ASTUnit> CreateASTUnitFromCommandLine( |
| 57 | + const char **ArgBegin, const char **ArgEnd, |
| 58 | + std::shared_ptr<PCHContainerOperations> PCHContainerOps, |
| 59 | + std::shared_ptr<DiagnosticOptions> DiagOpts, |
| 60 | + IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath, |
| 61 | + bool StorePreamblesInMemory = false, |
| 62 | + StringRef PreambleStoragePath = StringRef(), bool OnlyLocalDecls = false, |
| 63 | + CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None, |
| 64 | + ArrayRef<ASTUnit::RemappedFile> RemappedFiles = {}, |
| 65 | + bool RemappedFilesKeepOriginalName = true, |
| 66 | + unsigned PrecompilePreambleAfterNParses = 0, |
| 67 | + TranslationUnitKind TUKind = TU_Complete, |
| 68 | + bool CacheCodeCompletionResults = false, |
| 69 | + bool IncludeBriefCommentsInCodeCompletion = false, |
| 70 | + bool AllowPCHWithCompilerErrors = false, |
| 71 | + SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None, |
| 72 | + bool SingleFileParse = false, bool UserFilesAreVolatile = false, |
| 73 | + bool ForSerialization = false, bool RetainExcludedConditionalBlocks = false, |
| 74 | + std::optional<StringRef> ModuleFormat = std::nullopt, |
| 75 | + std::unique_ptr<ASTUnit> *ErrAST = nullptr, |
| 76 | + IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr); |
| 77 | + |
| 78 | +} // namespace clang |
| 79 | + |
| 80 | +#endif // LLVM_CLANG_DRIVER_CREATEASTUNITFROMARGS_H |
0 commit comments