24#include "llvm/ADT/Statistic.h"
25#include "llvm/Option/ArgList.h"
26#include "llvm/Support/ErrorHandling.h"
27#include "llvm/Support/IOSandbox.h"
28#include "llvm/Support/ManagedStatic.h"
29#include "llvm/Support/Path.h"
30#include "llvm/Support/YAMLParser.h"
31#include "llvm/Support/raw_ostream.h"
32#include "llvm/TargetParser/Triple.h"
44#define DEBUG_TYPE "CrossTranslationUnit"
45STATISTIC(NumGetCTUCalled,
"The # of getCTUDefinition function called");
48 "The # of getCTUDefinition called but the function is not in any other TU");
50 "The # of getCTUDefinition successfully returned the "
51 "requested function's body");
52STATISTIC(NumUnsupportedNodeFound,
"The # of imports when the ASTImporter "
53 "encountered an unsupported AST Node");
54STATISTIC(NumNameConflicts,
"The # of imports when the ASTImporter "
55 "encountered an ODR error");
56STATISTIC(NumTripleMismatch,
"The # of triple mismatches");
57STATISTIC(NumLangMismatch,
"The # of language mismatches");
58STATISTIC(NumLangDialectMismatch,
"The # of language dialect mismatches");
60 "The # of ASTs not loaded because of threshold");
64bool hasEqualKnownFields(
const llvm::Triple &Lhs,
const llvm::Triple &Rhs) {
66 if (Lhs.getArch() != Triple::UnknownArch &&
67 Rhs.getArch() != Triple::UnknownArch && Lhs.getArch() != Rhs.getArch())
69 if (Lhs.getSubArch() != Triple::NoSubArch &&
70 Rhs.getSubArch() != Triple::NoSubArch &&
71 Lhs.getSubArch() != Rhs.getSubArch())
73 if (Lhs.getVendor() != Triple::UnknownVendor &&
74 Rhs.getVendor() != Triple::UnknownVendor &&
75 Lhs.getVendor() != Rhs.getVendor())
77 if (!Lhs.isOSUnknown() && !Rhs.isOSUnknown() &&
78 Lhs.getOS() != Rhs.getOS())
80 if (Lhs.getEnvironment() != Triple::UnknownEnvironment &&
81 Rhs.getEnvironment() != Triple::UnknownEnvironment &&
82 Lhs.getEnvironment() != Rhs.getEnvironment())
84 if (Lhs.getObjectFormat() != Triple::UnknownObjectFormat &&
85 Rhs.getObjectFormat() != Triple::UnknownObjectFormat &&
86 Lhs.getObjectFormat() != Rhs.getObjectFormat())
92class IndexErrorCategory :
public std::error_category {
94 const char *
name() const noexcept
override {
return "clang.index"; }
96 std::string message(
int Condition)
const override {
103 return "An unknown error has occurred.";
105 return "The index file is missing.";
107 return "Invalid index file format.";
109 return "Multiple definitions in the index file.";
111 return "Missing definition from the index file.";
113 return "Failed to import the definition.";
115 return "Failed to load external AST source.";
117 return "Failed to generate USR.";
119 return "Triple mismatch";
121 return "Language mismatch";
123 return "Language dialect mismatch";
125 return "Load threshold reached";
127 return "Invocation list file contains multiple references to the same "
130 return "Invocation list file is not found.";
132 return "Invocation list file is empty.";
134 return "Invocation list file is in wrong format.";
136 return "Invocation list file does not contain the requested source file.";
138 llvm_unreachable(
"Unrecognized index_error_code.");
142static llvm::ManagedStatic<IndexErrorCategory> Category;
148 OS << Category->message(
static_cast<int>(Code)) <<
'\n';
152 return std::error_code(
static_cast<int>(Code), *Category);
162 StringRef &FilePath) {
165 size_t USRLength = 0;
166 if (LineRef.consumeInteger(10, USRLength))
168 assert(USRLength &&
"USRLength should be greater than zero.");
170 if (!LineRef.consume_front(
":"))
176 if (USRLength >= LineRef.size() ||
' ' != LineRef[USRLength])
179 LookupName = LineRef.substr(0, USRLength);
180 FilePath = LineRef.substr(USRLength + 1);
186 std::ifstream ExternalMapFile{std::string(IndexPath)};
187 if (!ExternalMapFile)
191 llvm::StringMap<std::string>
Result;
194 while (std::getline(ExternalMapFile,
Line)) {
196 StringRef LookupName, FilePathInIndex;
198 return llvm::make_error<IndexError>(
203 llvm::sys::path::native(FilePath, llvm::sys::path::Style::posix);
205 bool InsertionOccurred;
206 std::tie(std::ignore, InsertionOccurred) =
207 Result.try_emplace(LookupName, FilePath.begin(), FilePath.end());
208 if (!InsertionOccurred)
209 return llvm::make_error<IndexError>(
219 std::ostringstream
Result;
220 for (
const auto &E : Index)
221 Result << E.getKey().size() <<
':' << E.getKey().str() <<
' '
222 << E.getValue() <<
'\n';
243 : Context(CI.getASTContext()), ASTStorage(CI) {
246 auto S = CI.getVirtualFileSystem().status(CI.getAnalyzerOpts().CTUDir);
247 if (!S || S->getType() != llvm::sys::fs::file_type::directory_file)
248 CI.getDiagnostics().Report(diag::err_analyzer_config_invalid_input)
256std::optional<std::string>
262 return std::string(DeclUSR);
269CrossTranslationUnitContext::findDefInDeclContext(
const DeclContext *DC,
270 StringRef LookupName) {
271 assert(DC &&
"Declaration Context must not be null");
273 const auto *SubDC = dyn_cast<DeclContext>(D);
275 if (
const auto *ND = findDefInDeclContext<T>(SubDC, LookupName))
278 const auto *ND = dyn_cast<T>(D);
282 std::optional<std::string> ResultLookupName =
getLookupName(ResultDecl);
283 if (!ResultLookupName || *ResultLookupName != LookupName)
292 const T *D, StringRef CrossTUDir, StringRef IndexName,
293 bool DisplayCTUProgress) {
294 assert(D &&
"D is missing, bad call to this function!");
296 "D has a body or init in current translation unit!");
298 const std::optional<std::string> LookupName =
getLookupName(D);
300 return llvm::make_error<IndexError>(
303 loadExternalAST(*LookupName, CrossTUDir, IndexName, DisplayCTUProgress);
305 return ASTUnitOrError.takeError();
306 ASTUnit *Unit = *ASTUnitOrError;
307 assert(&Unit->getFileManager() ==
308 &Unit->getASTContext().getSourceManager().getFileManager());
310 const llvm::Triple &TripleTo = Context.getTargetInfo().getTriple();
311 const llvm::Triple &TripleFrom =
312 Unit->getASTContext().getTargetInfo().getTriple();
317 if (!hasEqualKnownFields(TripleTo, TripleFrom)) {
322 std::string(Unit->getMainFileName()),
323 TripleTo.str(), TripleFrom.str());
326 const auto &LangTo = Context.getLangOpts();
327 const auto &LangFrom = Unit->getASTContext().getLangOpts();
331 if (LangTo.CPlusPlus != LangFrom.CPlusPlus) {
349 if (LangTo.CPlusPlus11 != LangFrom.CPlusPlus11 ||
350 LangTo.CPlusPlus14 != LangFrom.CPlusPlus14 ||
351 LangTo.CPlusPlus17 != LangFrom.CPlusPlus17 ||
352 LangTo.CPlusPlus20 != LangFrom.CPlusPlus20) {
353 ++NumLangDialectMismatch;
354 return llvm::make_error<IndexError>(
358 TranslationUnitDecl *TU = Unit->getASTContext().getTranslationUnitDecl();
359 if (
const T *ResultDecl = findDefInDeclContext<T>(TU, *LookupName))
364llvm::Expected<const FunctionDecl *>
366 StringRef CrossTUDir,
368 bool DisplayCTUProgress) {
369 return getCrossTUDefinitionImpl(FD, CrossTUDir, IndexName,
375 StringRef CrossTUDir,
377 bool DisplayCTUProgress) {
378 return getCrossTUDefinitionImpl(VD, CrossTUDir, IndexName,
385 Context.getDiagnostics().Report(diag::err_ctu_error_opening)
389 Context.getDiagnostics().Report(diag::err_extdefmap_parsing)
393 Context.getDiagnostics().Report(diag::err_multiple_def_index)
397 Context.getDiagnostics().Report(diag::warn_ctu_incompat_triple)
405CrossTranslationUnitContext::ASTUnitStorage::ASTUnitStorage(
407 : Loader(CI, CI.getAnalyzerOpts().CTUDir,
408 CI.getAnalyzerOpts().CTUInvocationList),
409 LoadGuard(CI.getASTContext().getLangOpts().
CPlusPlus
410 ? CI.getAnalyzerOpts().CTUImportCppThreshold
411 : CI.getAnalyzerOpts().CTUImportThreshold) {}
414CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFile(
415 StringRef
FileName,
bool DisplayCTUProgress) {
417 auto ASTCacheEntry = FileASTUnitMap.find(
FileName);
418 if (ASTCacheEntry == FileASTUnitMap.end()) {
422 ++NumASTLoadThresholdReached;
423 return llvm::make_error<IndexError>(
427 auto LoadAttempt = Loader.load(
FileName);
430 return LoadAttempt.takeError();
432 std::unique_ptr<ASTUnit> LoadedUnit = std::move(LoadAttempt.get());
435 ASTUnit *Unit = LoadedUnit.get();
438 FileASTUnitMap[
FileName] = std::move(LoadedUnit);
440 LoadGuard.indicateLoadSuccess();
442 if (DisplayCTUProgress)
443 llvm::errs() <<
"CTU loaded AST file: " <<
FileName <<
"\n";
449 return ASTCacheEntry->second.get();
453llvm::Expected<ASTUnit *>
454CrossTranslationUnitContext::ASTUnitStorage::getASTUnitForFunction(
455 StringRef FunctionName, StringRef CrossTUDir, StringRef IndexName,
456 bool DisplayCTUProgress) {
458 auto ASTCacheEntry = NameASTUnitMap.find(FunctionName);
459 if (ASTCacheEntry == NameASTUnitMap.end()) {
463 if (llvm::Error IndexLoadError =
464 ensureCTUIndexLoaded(CrossTUDir, IndexName))
465 return std::move(IndexLoadError);
468 auto It = NameFileMap.find(FunctionName);
469 if (It == NameFileMap.end()) {
476 if (llvm::Expected<ASTUnit *> FoundForFile =
477 getASTUnitForFile(It->second, DisplayCTUProgress)) {
480 NameASTUnitMap[FunctionName] = *FoundForFile;
481 return *FoundForFile;
484 return FoundForFile.takeError();
488 return ASTCacheEntry->second;
492llvm::Expected<std::string>
493CrossTranslationUnitContext::ASTUnitStorage::getFileForFunction(
494 StringRef FunctionName, StringRef CrossTUDir, StringRef IndexName) {
495 if (llvm::Error IndexLoadError = ensureCTUIndexLoaded(CrossTUDir, IndexName))
496 return std::move(IndexLoadError);
497 return NameFileMap[FunctionName];
500llvm::Error CrossTranslationUnitContext::ASTUnitStorage::ensureCTUIndexLoaded(
501 StringRef CrossTUDir, StringRef IndexName) {
503 if (!NameFileMap.empty())
504 return llvm::Error::success();
507 SmallString<256> IndexFile = CrossTUDir;
508 if (llvm::sys::path::is_absolute(IndexName))
509 IndexFile = IndexName;
511 llvm::sys::path::append(IndexFile, IndexName);
515 NameFileMap = *IndexMapping;
516 return llvm::Error::success();
519 return IndexMapping.takeError();
524 StringRef LookupName, StringRef CrossTUDir, StringRef IndexName,
525 bool DisplayCTUProgress) {
533 LookupName, CrossTUDir, IndexName, DisplayCTUProgress);
536 return Unit.takeError();
540 return llvm::make_error<IndexError>(
546CrossTranslationUnitContext::ASTLoader::ASTLoader(
548 : CI(CI), CTUDir(CTUDir), InvocationListFilePath(InvocationListFilePath) {}
550CrossTranslationUnitContext::LoadResultTy
551CrossTranslationUnitContext::ASTLoader::load(StringRef Identifier) {
553 if (llvm::sys::path::is_absolute(Identifier, PathStyle)) {
557 llvm::sys::path::append(Path, PathStyle, Identifier);
562 llvm::sys::path::native(Path, PathStyle);
565 llvm::sys::path::remove_dots(Path,
true, PathStyle);
567 if (Path.ends_with(
".ast"))
568 return loadFromDump(Path);
570 return loadFromSource(Path);
573CrossTranslationUnitContext::LoadResultTy
574CrossTranslationUnitContext::ASTLoader::loadFromDump(StringRef ASTDumpPath) {
575 auto DiagOpts = std::make_shared<DiagnosticOptions>();
576 TextDiagnosticPrinter *DiagClient =
577 new TextDiagnosticPrinter(llvm::errs(), *DiagOpts);
578 auto Diags = llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(
581 ASTDumpPath, CI.getPCHContainerOperations()->getRawReader(),
583 CI.getFileSystemOpts(), CI.getHeaderSearchOpts());
597CrossTranslationUnitContext::LoadResultTy
598CrossTranslationUnitContext::ASTLoader::loadFromSource(
599 StringRef SourceFilePath) {
601 if (llvm::Error InitError = lazyInitInvocationList())
602 return std::move(InitError);
603 assert(InvocationList);
605 auto Invocation = InvocationList->find(SourceFilePath);
606 if (Invocation == InvocationList->end())
607 return llvm::make_error<IndexError>(
610 const InvocationListTy::mapped_type &InvocationCommand = Invocation->second;
612 SmallVector<const char *, 32> CommandLineArgs(InvocationCommand.size());
613 std::transform(InvocationCommand.begin(), InvocationCommand.end(),
614 CommandLineArgs.begin(),
615 [](
auto &&CmdPart) { return CmdPart.c_str(); });
617 auto DiagOpts = std::make_shared<DiagnosticOptions>(CI.getDiagnosticOpts());
618 auto *DiagClient =
new ForwardingDiagnosticConsumer{CI.getDiagnosticClient()};
619 IntrusiveRefCntPtr<DiagnosticIDs> DiagID{
620 CI.getDiagnostics().getDiagnosticIDs()};
621 auto Diags = llvm::makeIntrusiveRefCnt<DiagnosticsEngine>(DiagID, *DiagOpts,
625 auto BypassSandbox = llvm::sys::sandbox::scopedDisable();
627 CommandLineArgs.begin(), (CommandLineArgs.end()),
628 CI.getPCHContainerOperations(), DiagOpts, Diags,
629 CI.getHeaderSearchOpts().ResourceDir);
632llvm::Expected<InvocationListTy>
638 llvm::yaml::Stream InvocationFile(FileContent,
SM);
641 llvm::yaml::document_iterator FirstInvocationFile = InvocationFile.begin();
644 if (FirstInvocationFile == InvocationFile.end())
645 return llvm::make_error<IndexError>(
648 llvm::yaml::Node *DocumentRoot = FirstInvocationFile->getRoot();
650 return llvm::make_error<IndexError>(
656 auto *Mappings = dyn_cast<llvm::yaml::MappingNode>(DocumentRoot);
658 return llvm::make_error<IndexError>(
661 for (
auto &NextMapping : *Mappings) {
663 auto *Key = dyn_cast<llvm::yaml::ScalarNode>(NextMapping.getKey());
665 return llvm::make_error<IndexError>(
669 StringRef SourcePath = Key->getValue(ValueStorage);
673 llvm::sys::path::native(NativeSourcePath, PathStyle);
675 StringRef InvocationKey = NativeSourcePath;
677 if (InvocationList.contains(InvocationKey))
678 return llvm::make_error<IndexError>(
683 auto *Args = dyn_cast<llvm::yaml::SequenceNode>(NextMapping.getValue());
685 return llvm::make_error<IndexError>(
688 for (
auto &Arg : *Args) {
689 auto *CmdString = dyn_cast<llvm::yaml::ScalarNode>(&Arg);
691 return llvm::make_error<IndexError>(
695 ValueStorage.clear();
696 InvocationList[InvocationKey].emplace_back(
697 CmdString->getValue(ValueStorage));
700 if (InvocationList[InvocationKey].empty())
701 return llvm::make_error<IndexError>(
705 return InvocationList;
708llvm::Error CrossTranslationUnitContext::ASTLoader::lazyInitInvocationList() {
711 return llvm::Error::success();
713 return llvm::make_error<IndexError>(PreviousParsingResult);
715 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileContent =
716 CI.getVirtualFileSystem().getBufferForFile(InvocationListFilePath);
719 return llvm::make_error<IndexError>(PreviousParsingResult);
721 std::unique_ptr<llvm::MemoryBuffer> ContentBuffer = std::move(*FileContent);
722 assert(ContentBuffer &&
"If no error was produced after loading, the pointer "
723 "should not be nullptr.");
729 if (!ExpectedInvocationList) {
730 llvm::handleAllErrors(
731 ExpectedInvocationList.takeError(),
732 [&](
const IndexError &E) { PreviousParsingResult = E.getCode(); });
733 return llvm::make_error<IndexError>(PreviousParsingResult);
736 InvocationList = *ExpectedInvocationList;
738 return llvm::Error::success();
742llvm::Expected<const T *>
743CrossTranslationUnitContext::importDefinitionImpl(
const T *D, ASTUnit *Unit) {
744 assert(
hasBodyOrInit(D) &&
"Decls to be imported should have body or init.");
746 assert(&D->getASTContext() == &Unit->getASTContext() &&
747 "ASTContext of Decl and the unit should match.");
748 ASTImporter &Importer = getOrCreateASTImporter(Unit);
750 auto ToDeclOrError = Importer.Import(D);
751 if (!ToDeclOrError) {
752 handleAllErrors(ToDeclOrError.takeError(), [&](
const ASTImportError &IE) {
754 case ASTImportError::NameConflict:
757 case ASTImportError::UnsupportedConstruct:
758 ++NumUnsupportedNodeFound;
760 case ASTImportError::Unknown:
761 llvm_unreachable(
"Unknown import error happened.");
767 auto *ToDecl =
cast<T>(*ToDeclOrError);
768 assert(
hasBodyOrInit(ToDecl) &&
"Imported Decl should have body or init.");
772 ToDecl->getASTContext().getParentMapContext().clear();
777llvm::Expected<const FunctionDecl *>
780 return importDefinitionImpl(FD, Unit);
786 return importDefinitionImpl(VD, Unit);
789void CrossTranslationUnitContext::lazyInitImporterSharedSt(
791 if (!ImporterSharedSt)
792 ImporterSharedSt = std::make_shared<ASTImporterSharedState>(*ToTU);
796CrossTranslationUnitContext::getOrCreateASTImporter(
ASTUnit *Unit) {
800 if (I != ASTUnitImporterMap.end())
802 lazyInitImporterSharedSt(Context.getTranslationUnitDecl());
804 Context, Context.getSourceManager().getFileManager(), From,
810std::optional<clang::MacroExpansionContext>
818 if (!ImporterSharedSt)
820 return ImporterSharedSt->isNewDecl(
const_cast<Decl *
>(ToDecl));
824 if (!ImporterSharedSt)
826 return static_cast<bool>(
827 ImporterSharedSt->getImportDeclErrorIfAny(
const_cast<Decl *
>(ToDecl)));
STATISTIC(NumObjCCallEdges, "Number of Objective-C method call edges")
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Imports selected nodes from one AST context into another context, merging AST nodes where appropriate...
Utility class for loading a ASTContext from an AST file.
static std::unique_ptr< ASTUnit > LoadFromASTFile(StringRef Filename, const PCHContainerReader &PCHContainerRdr, WhatToLoad ToLoad, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, std::shared_ptr< DiagnosticOptions > DiagOpts, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, const FileSystemOptions &FileSystemOpts, const HeaderSearchOptions &HSOpts, const LangOptions *LangOpts=nullptr, bool OnlyLocalDecls=false, CaptureDiagsKind CaptureDiagnostics=CaptureDiagsKind::None, bool AllowASTWithCompilerErrors=false, bool UserFilesAreVolatile=false)
Create a ASTUnit from an AST file.
@ LoadEverything
Load everything, including Sema.
const ASTContext & getASTContext() const
unsigned ShouldEmitErrorsOnInvalidConfigValue
bool isConstQualified() const
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
AnalyzerOptions & getAnalyzerOpts()
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Decl - This represents one declaration (or definition), e.g.
static llvm::IntrusiveRefCntPtr< DiagnosticIDs > create()
Represents a function declaration or definition.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
bool isTrivialType(const ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
Encodes a location in the source.
FileManager & getFileManager() const
The top declaration context.
Represents a variable declaration or definition.
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to.
void emitCrossTUDiagnostics(const IndexError &IE)
Emit diagnostics for the user for potential configuration errors.
llvm::Expected< const FunctionDecl * > getCrossTUDefinition(const FunctionDecl *FD, StringRef CrossTUDir, StringRef IndexName, bool DisplayCTUProgress=false)
This function loads a function or variable definition from an external AST file and merges it into th...
llvm::Expected< const FunctionDecl * > importDefinition(const FunctionDecl *FD, ASTUnit *Unit)
This function merges a definition from a separate AST Unit into the current one which was created by ...
CrossTranslationUnitContext(CompilerInstance &CI)
static std::optional< std::string > getLookupName(const Decl *D)
Get a name to identify a decl.
std::optional< clang::MacroExpansionContext > getMacroExpansionContextForSourceLocation(const clang::SourceLocation &ToLoc) const
Returns the MacroExpansionContext for the imported TU to which the given source-location corresponds.
bool hasError(const Decl *ToDecl) const
Returns true if the given Decl is mapped (or created) during an import but there was an unrecoverable...
bool isImportedAsNew(const Decl *ToDecl) const
Returns true if the given Decl is newly created during the import.
~CrossTranslationUnitContext()
llvm::Expected< ASTUnit * > loadExternalAST(StringRef LookupName, StringRef CrossTUDir, StringRef IndexName, bool DisplayCTUProgress=false)
This function loads a definition from an external AST file.
index_error_code getCode() const
std::string getTripleToName() const
std::error_code convertToErrorCode() const override
void log(raw_ostream &OS) const override
std::string getTripleFromName() const
std::string getFileName() const
Defines the clang::TargetInfo interface.
bool shouldImport(const VarDecl *VD, const ASTContext &ACtx)
Returns true if it makes sense to import a foreign variable definition.
llvm::Expected< llvm::StringMap< std::string > > parseCrossTUIndex(StringRef IndexPath)
This function parses an index file that determines which translation unit contains which definition.
std::string createCrossTUIndexString(const llvm::StringMap< std::string > &Index)
llvm::Expected< InvocationListTy > parseInvocationList(StringRef FileContent, llvm::sys::path::Style PathStyle=llvm::sys::path::Style::posix)
Parse the YAML formatted invocation list file content FileContent.
static bool hasBodyOrInit(const FunctionDecl *D, const FunctionDecl *&DefD)
@ invocation_list_wrong_format
@ invocation_list_file_not_found
@ invocation_list_lookup_unsuccessful
@ failed_to_get_external_ast
@ invocation_list_ambiguous
static bool parseCrossTUIndexItem(StringRef LineRef, StringRef &LookupName, StringRef &FilePath)
Parse one line of the input CTU index file.
llvm::StringMap< llvm::SmallVector< std::string, 32 > > InvocationListTy
bool generateUSRForDecl(const Decl *D, SmallVectorImpl< char > &Buf)
Generate a USR for a Decl, including the USR prefix.
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
std::unique_ptr< ASTUnit > CreateASTUnitFromCommandLine(const char **ArgBegin, const char **ArgEnd, std::shared_ptr< PCHContainerOperations > PCHContainerOps, std::shared_ptr< DiagnosticOptions > DiagOpts, IntrusiveRefCntPtr< DiagnosticsEngine > Diags, StringRef ResourceFilesPath, bool StorePreamblesInMemory=false, StringRef PreambleStoragePath=StringRef(), bool OnlyLocalDecls=false, CaptureDiagsKind CaptureDiagnostics=CaptureDiagsKind::None, ArrayRef< ASTUnit::RemappedFile > RemappedFiles={}, bool RemappedFilesKeepOriginalName=true, unsigned PrecompilePreambleAfterNParses=0, TranslationUnitKind TUKind=TU_Complete, bool CacheCodeCompletionResults=false, bool IncludeBriefCommentsInCodeCompletion=false, bool AllowPCHWithCompilerErrors=false, SkipFunctionBodiesScope SkipFunctionBodies=SkipFunctionBodiesScope::None, bool SingleFileParse=false, bool UserFilesAreVolatile=false, bool ForSerialization=false, bool RetainExcludedConditionalBlocks=false, std::optional< StringRef > ModuleFormat=std::nullopt, std::unique_ptr< ASTUnit > *ErrAST=nullptr, IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr)
Create an ASTUnit from a vector of command line arguments, which must specify exactly one source file...
@ Result
The result type of a method or function.
const FunctionProtoType * T
U cast(CodeGen::Address addr)