File indexing completed on 2026-05-10 08:36:55
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_FRONTEND_ASTUNIT_H
0014 #define LLVM_CLANG_FRONTEND_ASTUNIT_H
0015
0016 #include "clang-c/Index.h"
0017 #include "clang/AST/ASTContext.h"
0018 #include "clang/Basic/Diagnostic.h"
0019 #include "clang/Basic/FileSystemOptions.h"
0020 #include "clang/Basic/LLVM.h"
0021 #include "clang/Basic/LangOptions.h"
0022 #include "clang/Basic/SourceLocation.h"
0023 #include "clang/Basic/SourceManager.h"
0024 #include "clang/Basic/TargetOptions.h"
0025 #include "clang/Lex/HeaderSearchOptions.h"
0026 #include "clang/Lex/ModuleLoader.h"
0027 #include "clang/Lex/PreprocessingRecord.h"
0028 #include "clang/Sema/CodeCompleteConsumer.h"
0029 #include "clang/Serialization/ASTBitCodes.h"
0030 #include "clang/Frontend/PrecompiledPreamble.h"
0031 #include "llvm/ADT/ArrayRef.h"
0032 #include "llvm/ADT/DenseMap.h"
0033 #include "llvm/ADT/IntrusiveRefCntPtr.h"
0034 #include "llvm/ADT/STLExtras.h"
0035 #include "llvm/ADT/SmallVector.h"
0036 #include "llvm/ADT/StringMap.h"
0037 #include "llvm/ADT/StringRef.h"
0038 #include "llvm/ADT/iterator_range.h"
0039 #include <cassert>
0040 #include <cstddef>
0041 #include <cstdint>
0042 #include <memory>
0043 #include <optional>
0044 #include <string>
0045 #include <utility>
0046 #include <vector>
0047
0048 namespace llvm {
0049
0050 class MemoryBuffer;
0051
0052 namespace vfs {
0053
0054 class FileSystem;
0055
0056 }
0057 }
0058
0059 namespace clang {
0060
0061 class ASTContext;
0062 class ASTDeserializationListener;
0063 class ASTMutationListener;
0064 class ASTReader;
0065 class CompilerInstance;
0066 class CompilerInvocation;
0067 class Decl;
0068 class FileEntry;
0069 class FileManager;
0070 class FrontendAction;
0071 class HeaderSearch;
0072 class InputKind;
0073 class InMemoryModuleCache;
0074 class PCHContainerOperations;
0075 class PCHContainerReader;
0076 class Preprocessor;
0077 class PreprocessorOptions;
0078 class Sema;
0079 class TargetInfo;
0080 class SyntaxOnlyAction;
0081
0082
0083 enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };
0084
0085
0086 enum class CaptureDiagsKind { None, All, AllWithoutNonErrorsFromIncludes };
0087
0088
0089 class ASTUnit {
0090 public:
0091 struct StandaloneFixIt {
0092 std::pair<unsigned, unsigned> RemoveRange;
0093 std::pair<unsigned, unsigned> InsertFromRange;
0094 std::string CodeToInsert;
0095 bool BeforePreviousInsertions;
0096 };
0097
0098 struct StandaloneDiagnostic {
0099 unsigned ID;
0100 DiagnosticsEngine::Level Level;
0101 std::string Message;
0102 std::string Filename;
0103 unsigned LocOffset;
0104 std::vector<std::pair<unsigned, unsigned>> Ranges;
0105 std::vector<StandaloneFixIt> FixIts;
0106 };
0107
0108 private:
0109 std::shared_ptr<LangOptions> LangOpts;
0110 IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
0111 IntrusiveRefCntPtr<FileManager> FileMgr;
0112 IntrusiveRefCntPtr<SourceManager> SourceMgr;
0113 IntrusiveRefCntPtr<InMemoryModuleCache> ModuleCache;
0114 std::unique_ptr<HeaderSearch> HeaderInfo;
0115 IntrusiveRefCntPtr<TargetInfo> Target;
0116 std::shared_ptr<Preprocessor> PP;
0117 IntrusiveRefCntPtr<ASTContext> Ctx;
0118 std::shared_ptr<TargetOptions> TargetOpts;
0119 std::shared_ptr<HeaderSearchOptions> HSOpts;
0120 std::shared_ptr<PreprocessorOptions> PPOpts;
0121 IntrusiveRefCntPtr<ASTReader> Reader;
0122 bool HadModuleLoaderFatalFailure = false;
0123 bool StorePreamblesInMemory = false;
0124
0125 struct ASTWriterData;
0126 std::unique_ptr<ASTWriterData> WriterData;
0127
0128 FileSystemOptions FileSystemOpts;
0129 std::string PreambleStoragePath;
0130
0131
0132
0133 std::unique_ptr<ASTConsumer> Consumer;
0134
0135
0136
0137 std::unique_ptr<Sema> TheSema;
0138
0139
0140
0141 std::shared_ptr<CompilerInvocation> Invocation;
0142
0143
0144 TrivialModuleLoader ModuleLoader;
0145
0146
0147
0148
0149 bool OnlyLocalDecls = false;
0150
0151
0152 CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None;
0153
0154
0155 bool MainFileIsAST;
0156
0157
0158 TranslationUnitKind TUKind = TU_Complete;
0159
0160
0161 bool WantTiming;
0162
0163
0164 bool OwnsRemappedFileBuffers = true;
0165
0166
0167
0168
0169
0170
0171
0172
0173 std::vector<Decl*> TopLevelDecls;
0174
0175
0176 using LocDeclsTy = SmallVector<std::pair<unsigned, Decl *>, 64>;
0177 using FileDeclsTy = llvm::DenseMap<FileID, std::unique_ptr<LocDeclsTy>>;
0178
0179
0180
0181 FileDeclsTy FileDecls;
0182
0183
0184 std::string OriginalSourceFile;
0185
0186
0187 SmallVector<StandaloneDiagnostic, 4> PreambleDiagnostics;
0188
0189
0190
0191 SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
0192
0193
0194
0195 SmallVector<StoredDiagnostic, 4> FailedParseDiagnostics;
0196
0197
0198
0199
0200
0201
0202 unsigned NumStoredDiagnosticsFromDriver = 0;
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213 unsigned PreambleRebuildCountdown = 0;
0214
0215
0216 unsigned PreambleCounter = 0;
0217
0218
0219
0220
0221
0222
0223
0224 llvm::StringMap<SourceLocation> PreambleSrcLocCache;
0225
0226
0227 std::optional<PrecompiledPreamble> Preamble;
0228
0229
0230
0231
0232 std::unique_ptr<llvm::MemoryBuffer> SavedMainFileBuffer;
0233
0234
0235
0236
0237
0238
0239
0240 unsigned NumWarningsInPreamble = 0;
0241
0242
0243
0244 std::vector<LocalDeclID> TopLevelDeclsInPreamble;
0245
0246
0247 bool ShouldCacheCodeCompletionResults : 1;
0248
0249
0250
0251 bool IncludeBriefCommentsInCodeCompletion : 1;
0252
0253
0254
0255 bool UserFilesAreVolatile : 1;
0256
0257 static void ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
0258 ASTUnit &AST, CaptureDiagsKind CaptureDiagnostics);
0259
0260 void TranslateStoredDiagnostics(FileManager &FileMgr,
0261 SourceManager &SrcMan,
0262 const SmallVectorImpl<StandaloneDiagnostic> &Diags,
0263 SmallVectorImpl<StoredDiagnostic> &Out);
0264
0265 void clearFileLevelDecls();
0266
0267 public:
0268
0269
0270 struct CachedCodeCompletionResult {
0271
0272
0273 CodeCompletionString *Completion;
0274
0275
0276
0277
0278
0279
0280
0281
0282 uint64_t ShowInContexts;
0283
0284
0285 unsigned Priority;
0286
0287
0288
0289 CXCursorKind Kind;
0290
0291
0292 CXAvailabilityKind Availability;
0293
0294
0295 SimplifiedTypeClass TypeClass;
0296
0297
0298
0299
0300
0301
0302
0303 unsigned Type;
0304 };
0305
0306
0307
0308 llvm::StringMap<unsigned> &getCachedCompletionTypes() {
0309 return CachedCompletionTypes;
0310 }
0311
0312
0313 std::shared_ptr<GlobalCodeCompletionAllocator>
0314 getCachedCompletionAllocator() {
0315 return CachedCompletionAllocator;
0316 }
0317
0318 CodeCompletionTUInfo &getCodeCompletionTUInfo() {
0319 if (!CCTUInfo)
0320 CCTUInfo = std::make_unique<CodeCompletionTUInfo>(
0321 std::make_shared<GlobalCodeCompletionAllocator>());
0322 return *CCTUInfo;
0323 }
0324
0325 private:
0326
0327 std::shared_ptr<GlobalCodeCompletionAllocator> CachedCompletionAllocator;
0328
0329 std::unique_ptr<CodeCompletionTUInfo> CCTUInfo;
0330
0331
0332 std::vector<CachedCodeCompletionResult> CachedCompletionResults;
0333
0334
0335
0336 llvm::StringMap<unsigned> CachedCompletionTypes;
0337
0338
0339
0340
0341
0342
0343 unsigned CompletionCacheTopLevelHashValue = 0;
0344
0345
0346
0347
0348
0349
0350 unsigned PreambleTopLevelHashValue = 0;
0351
0352
0353
0354 unsigned CurrentTopLevelHashValue = 0;
0355
0356
0357
0358 LLVM_PREFERRED_TYPE(bool)
0359 unsigned UnsafeToFree : 1;
0360
0361
0362 SkipFunctionBodiesScope SkipFunctionBodies = SkipFunctionBodiesScope::None;
0363
0364
0365
0366 void CacheCodeCompletionResults();
0367
0368
0369 void ClearCachedCompletionResults();
0370
0371 explicit ASTUnit(bool MainFileIsAST);
0372
0373 bool Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
0374 std::unique_ptr<llvm::MemoryBuffer> OverrideMainBuffer,
0375 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
0376
0377 std::unique_ptr<llvm::MemoryBuffer> getMainBufferWithPrecompiledPreamble(
0378 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
0379 CompilerInvocation &PreambleInvocationIn,
0380 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS, bool AllowRebuild = true,
0381 unsigned MaxLines = 0);
0382 void RealizeTopLevelDeclsFromPreamble();
0383
0384
0385
0386 void transferASTDataFromCompilerInstance(CompilerInstance &CI);
0387
0388
0389
0390
0391
0392
0393
0394
0395 class ConcurrencyState {
0396 void *Mutex;
0397
0398 public:
0399 ConcurrencyState();
0400 ~ConcurrencyState();
0401
0402 void start();
0403 void finish();
0404 };
0405 ConcurrencyState ConcurrencyCheckValue;
0406
0407 public:
0408 friend class ConcurrencyCheck;
0409
0410 class ConcurrencyCheck {
0411 ASTUnit &Self;
0412
0413 public:
0414 explicit ConcurrencyCheck(ASTUnit &Self) : Self(Self) {
0415 Self.ConcurrencyCheckValue.start();
0416 }
0417
0418 ~ConcurrencyCheck() {
0419 Self.ConcurrencyCheckValue.finish();
0420 }
0421 };
0422
0423 ASTUnit(const ASTUnit &) = delete;
0424 ASTUnit &operator=(const ASTUnit &) = delete;
0425 ~ASTUnit();
0426
0427 bool isMainFileAST() const { return MainFileIsAST; }
0428
0429 bool isUnsafeToFree() const { return UnsafeToFree; }
0430 void setUnsafeToFree(bool Value) { UnsafeToFree = Value; }
0431
0432 const DiagnosticsEngine &getDiagnostics() const { return *Diagnostics; }
0433 DiagnosticsEngine &getDiagnostics() { return *Diagnostics; }
0434
0435 const SourceManager &getSourceManager() const { return *SourceMgr; }
0436 SourceManager &getSourceManager() { return *SourceMgr; }
0437
0438 const Preprocessor &getPreprocessor() const { return *PP; }
0439 Preprocessor &getPreprocessor() { return *PP; }
0440 std::shared_ptr<Preprocessor> getPreprocessorPtr() const { return PP; }
0441
0442 const ASTContext &getASTContext() const { return *Ctx; }
0443 ASTContext &getASTContext() { return *Ctx; }
0444
0445 void setASTContext(ASTContext *ctx) { Ctx = ctx; }
0446 void setPreprocessor(std::shared_ptr<Preprocessor> pp);
0447
0448
0449
0450
0451
0452
0453
0454
0455 void enableSourceFileDiagnostics();
0456
0457 bool hasSema() const { return (bool)TheSema; }
0458
0459 Sema &getSema() const {
0460 assert(TheSema && "ASTUnit does not have a Sema object!");
0461 return *TheSema;
0462 }
0463
0464 const LangOptions &getLangOpts() const {
0465 assert(LangOpts && "ASTUnit does not have language options");
0466 return *LangOpts;
0467 }
0468
0469 const HeaderSearchOptions &getHeaderSearchOpts() const {
0470 assert(HSOpts && "ASTUnit does not have header search options");
0471 return *HSOpts;
0472 }
0473
0474 const PreprocessorOptions &getPreprocessorOpts() const {
0475 assert(PPOpts && "ASTUnit does not have preprocessor options");
0476 return *PPOpts;
0477 }
0478
0479 const FileManager &getFileManager() const { return *FileMgr; }
0480 FileManager &getFileManager() { return *FileMgr; }
0481
0482 const FileSystemOptions &getFileSystemOpts() const { return FileSystemOpts; }
0483
0484 IntrusiveRefCntPtr<ASTReader> getASTReader() const;
0485
0486 StringRef getOriginalSourceFileName() const {
0487 return OriginalSourceFile;
0488 }
0489
0490 ASTMutationListener *getASTMutationListener();
0491 ASTDeserializationListener *getDeserializationListener();
0492
0493 bool getOnlyLocalDecls() const { return OnlyLocalDecls; }
0494
0495 bool getOwnsRemappedFileBuffers() const { return OwnsRemappedFileBuffers; }
0496 void setOwnsRemappedFileBuffers(bool val) { OwnsRemappedFileBuffers = val; }
0497
0498 StringRef getMainFileName() const;
0499
0500
0501 StringRef getASTFileName() const;
0502
0503 using top_level_iterator = std::vector<Decl *>::iterator;
0504
0505 top_level_iterator top_level_begin() {
0506 assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
0507 if (!TopLevelDeclsInPreamble.empty())
0508 RealizeTopLevelDeclsFromPreamble();
0509 return TopLevelDecls.begin();
0510 }
0511
0512 top_level_iterator top_level_end() {
0513 assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
0514 if (!TopLevelDeclsInPreamble.empty())
0515 RealizeTopLevelDeclsFromPreamble();
0516 return TopLevelDecls.end();
0517 }
0518
0519 std::size_t top_level_size() const {
0520 assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
0521 return TopLevelDeclsInPreamble.size() + TopLevelDecls.size();
0522 }
0523
0524 bool top_level_empty() const {
0525 assert(!isMainFileAST() && "Invalid call for AST based ASTUnit!");
0526 return TopLevelDeclsInPreamble.empty() && TopLevelDecls.empty();
0527 }
0528
0529
0530 void addTopLevelDecl(Decl *D) {
0531 TopLevelDecls.push_back(D);
0532 }
0533
0534
0535 void addFileLevelDecl(Decl *D);
0536
0537
0538
0539
0540 void findFileRegionDecls(FileID File, unsigned Offset, unsigned Length,
0541 SmallVectorImpl<Decl *> &Decls);
0542
0543
0544
0545
0546 unsigned &getCurrentTopLevelHashValue() { return CurrentTopLevelHashValue; }
0547
0548
0549
0550
0551
0552
0553 SourceLocation getLocation(const FileEntry *File,
0554 unsigned Line, unsigned Col) const;
0555
0556
0557 SourceLocation getLocation(const FileEntry *File, unsigned Offset) const;
0558
0559
0560
0561
0562 SourceLocation mapLocationFromPreamble(SourceLocation Loc) const;
0563
0564
0565
0566
0567 SourceLocation mapLocationToPreamble(SourceLocation Loc) const;
0568
0569 bool isInPreambleFileID(SourceLocation Loc) const;
0570 bool isInMainFileID(SourceLocation Loc) const;
0571 SourceLocation getStartOfMainFileID() const;
0572 SourceLocation getEndOfPreambleFileID() const;
0573
0574
0575 SourceRange mapRangeFromPreamble(SourceRange R) const {
0576 return SourceRange(mapLocationFromPreamble(R.getBegin()),
0577 mapLocationFromPreamble(R.getEnd()));
0578 }
0579
0580
0581 SourceRange mapRangeToPreamble(SourceRange R) const {
0582 return SourceRange(mapLocationToPreamble(R.getBegin()),
0583 mapLocationToPreamble(R.getEnd()));
0584 }
0585
0586 unsigned getPreambleCounterForTests() const { return PreambleCounter; }
0587
0588
0589 using stored_diag_iterator = StoredDiagnostic *;
0590 using stored_diag_const_iterator = const StoredDiagnostic *;
0591
0592 stored_diag_const_iterator stored_diag_begin() const {
0593 return StoredDiagnostics.begin();
0594 }
0595
0596 stored_diag_iterator stored_diag_begin() {
0597 return StoredDiagnostics.begin();
0598 }
0599
0600 stored_diag_const_iterator stored_diag_end() const {
0601 return StoredDiagnostics.end();
0602 }
0603
0604 stored_diag_iterator stored_diag_end() {
0605 return StoredDiagnostics.end();
0606 }
0607
0608 unsigned stored_diag_size() const { return StoredDiagnostics.size(); }
0609
0610 stored_diag_iterator stored_diag_afterDriver_begin() {
0611 if (NumStoredDiagnosticsFromDriver > StoredDiagnostics.size())
0612 NumStoredDiagnosticsFromDriver = 0;
0613 return StoredDiagnostics.begin() + NumStoredDiagnosticsFromDriver;
0614 }
0615
0616 using cached_completion_iterator =
0617 std::vector<CachedCodeCompletionResult>::iterator;
0618
0619 cached_completion_iterator cached_completion_begin() {
0620 return CachedCompletionResults.begin();
0621 }
0622
0623 cached_completion_iterator cached_completion_end() {
0624 return CachedCompletionResults.end();
0625 }
0626
0627 unsigned cached_completion_size() const {
0628 return CachedCompletionResults.size();
0629 }
0630
0631
0632
0633
0634 llvm::iterator_range<PreprocessingRecord::iterator>
0635 getLocalPreprocessingEntities() const;
0636
0637
0638
0639 using DeclVisitorFn = bool (*)(void *context, const Decl *D);
0640
0641
0642
0643
0644
0645 bool visitLocalTopLevelDecls(void *context, DeclVisitorFn Fn);
0646
0647
0648 OptionalFileEntryRef getPCHFile();
0649
0650
0651
0652 bool isModuleFile() const;
0653
0654 std::unique_ptr<llvm::MemoryBuffer>
0655 getBufferForFile(StringRef Filename, std::string *ErrorStr = nullptr);
0656
0657
0658 TranslationUnitKind getTranslationUnitKind() const { return TUKind; }
0659
0660
0661 InputKind getInputKind() const;
0662
0663
0664
0665 using RemappedFile = std::pair<std::string, llvm::MemoryBuffer *>;
0666
0667
0668 static std::unique_ptr<ASTUnit>
0669 create(std::shared_ptr<CompilerInvocation> CI,
0670 IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
0671 CaptureDiagsKind CaptureDiagnostics, bool UserFilesAreVolatile);
0672
0673 enum WhatToLoad {
0674
0675 LoadPreprocessorOnly,
0676
0677
0678 LoadASTOnly,
0679
0680
0681 LoadEverything
0682 };
0683
0684
0685
0686
0687
0688
0689
0690
0691
0692
0693
0694 static std::unique_ptr<ASTUnit>
0695 LoadFromASTFile(StringRef Filename, const PCHContainerReader &PCHContainerRdr,
0696 WhatToLoad ToLoad,
0697 IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
0698 const FileSystemOptions &FileSystemOpts,
0699 std::shared_ptr<HeaderSearchOptions> HSOpts,
0700 std::shared_ptr<LangOptions> LangOpts = nullptr,
0701 bool OnlyLocalDecls = false,
0702 CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
0703 bool AllowASTWithCompilerErrors = false,
0704 bool UserFilesAreVolatile = false,
0705 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
0706 llvm::vfs::getRealFileSystem());
0707
0708 private:
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723 bool LoadFromCompilerInvocation(
0724 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
0725 unsigned PrecompilePreambleAfterNParses,
0726 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
0727
0728 public:
0729
0730
0731
0732
0733
0734
0735
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757 static ASTUnit *LoadFromCompilerInvocationAction(
0758 std::shared_ptr<CompilerInvocation> CI,
0759 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
0760 IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
0761 FrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,
0762 bool Persistent = true, StringRef ResourceFilesPath = StringRef(),
0763 bool OnlyLocalDecls = false,
0764 CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
0765 unsigned PrecompilePreambleAfterNParses = 0,
0766 bool CacheCodeCompletionResults = false,
0767 bool UserFilesAreVolatile = false,
0768 std::unique_ptr<ASTUnit> *ErrAST = nullptr);
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784 static std::unique_ptr<ASTUnit> LoadFromCompilerInvocation(
0785 std::shared_ptr<CompilerInvocation> CI,
0786 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
0787 IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
0788 bool OnlyLocalDecls = false,
0789 CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
0790 unsigned PrecompilePreambleAfterNParses = 0,
0791 TranslationUnitKind TUKind = TU_Complete,
0792 bool CacheCodeCompletionResults = false,
0793 bool IncludeBriefCommentsInCodeCompletion = false,
0794 bool UserFilesAreVolatile = false);
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804
0805
0806
0807
0808
0809
0810
0811
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826
0827
0828
0829
0830
0831
0832 static std::unique_ptr<ASTUnit> LoadFromCommandLine(
0833 const char **ArgBegin, const char **ArgEnd,
0834 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
0835 IntrusiveRefCntPtr<DiagnosticsEngine> Diags, StringRef ResourceFilesPath,
0836 bool StorePreamblesInMemory = false,
0837 StringRef PreambleStoragePath = StringRef(), bool OnlyLocalDecls = false,
0838 CaptureDiagsKind CaptureDiagnostics = CaptureDiagsKind::None,
0839 ArrayRef<RemappedFile> RemappedFiles = {},
0840 bool RemappedFilesKeepOriginalName = true,
0841 unsigned PrecompilePreambleAfterNParses = 0,
0842 TranslationUnitKind TUKind = TU_Complete,
0843 bool CacheCodeCompletionResults = false,
0844 bool IncludeBriefCommentsInCodeCompletion = false,
0845 bool AllowPCHWithCompilerErrors = false,
0846 SkipFunctionBodiesScope SkipFunctionBodies =
0847 SkipFunctionBodiesScope::None,
0848 bool SingleFileParse = false, bool UserFilesAreVolatile = false,
0849 bool ForSerialization = false,
0850 bool RetainExcludedConditionalBlocks = false,
0851 std::optional<StringRef> ModuleFormat = std::nullopt,
0852 std::unique_ptr<ASTUnit> *ErrAST = nullptr,
0853 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
0854
0855
0856
0857
0858
0859
0860
0861
0862
0863
0864
0865
0866 bool Reparse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
0867 ArrayRef<RemappedFile> RemappedFiles = {},
0868 IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS = nullptr);
0869
0870
0871
0872
0873 void ResetForParse();
0874
0875
0876
0877
0878
0879
0880
0881
0882
0883
0884
0885
0886
0887
0888
0889
0890
0891
0892
0893
0894
0895
0896
0897
0898
0899 void CodeComplete(StringRef File, unsigned Line, unsigned Column,
0900 ArrayRef<RemappedFile> RemappedFiles, bool IncludeMacros,
0901 bool IncludeCodePatterns, bool IncludeBriefComments,
0902 CodeCompleteConsumer &Consumer,
0903 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
0904 DiagnosticsEngine &Diag, LangOptions &LangOpts,
0905 SourceManager &SourceMgr, FileManager &FileMgr,
0906 SmallVectorImpl<StoredDiagnostic> &StoredDiagnostics,
0907 SmallVectorImpl<const llvm::MemoryBuffer *> &OwnedBuffers,
0908 std::unique_ptr<SyntaxOnlyAction> Act);
0909
0910
0911
0912
0913
0914 bool Save(StringRef File);
0915
0916
0917
0918
0919 bool serialize(raw_ostream &OS);
0920 };
0921
0922 }
0923
0924 #endif