|
clang 23.0.0git
|
#include "clang/Frontend/CompilerInstance.h"#include "clang/AST/ASTConsumer.h"#include "clang/AST/ASTContext.h"#include "clang/AST/Decl.h"#include "clang/Basic/CharInfo.h"#include "clang/Basic/Diagnostic.h"#include "clang/Basic/DiagnosticFrontend.h"#include "clang/Basic/DiagnosticOptions.h"#include "clang/Basic/FileManager.h"#include "clang/Basic/LangStandard.h"#include "clang/Basic/SourceManager.h"#include "clang/Basic/Stack.h"#include "clang/Basic/TargetInfo.h"#include "clang/Basic/Version.h"#include "clang/Config/config.h"#include "clang/Frontend/ChainedDiagnosticConsumer.h"#include "clang/Frontend/FrontendAction.h"#include "clang/Frontend/FrontendActions.h"#include "clang/Frontend/FrontendPluginRegistry.h"#include "clang/Frontend/LogDiagnosticPrinter.h"#include "clang/Frontend/SARIFDiagnosticPrinter.h"#include "clang/Frontend/SerializedDiagnosticPrinter.h"#include "clang/Frontend/TextDiagnosticPrinter.h"#include "clang/Frontend/Utils.h"#include "clang/Frontend/VerifyDiagnosticConsumer.h"#include "clang/Lex/HeaderSearch.h"#include "clang/Lex/Preprocessor.h"#include "clang/Lex/PreprocessorOptions.h"#include "clang/Sema/CodeCompleteConsumer.h"#include "clang/Sema/ParsedAttr.h"#include "clang/Sema/Sema.h"#include "clang/Serialization/ASTReader.h"#include "clang/Serialization/GlobalModuleIndex.h"#include "clang/Serialization/InMemoryModuleCache.h"#include "clang/Serialization/ModuleCache.h"#include "clang/Serialization/ModuleManager.h"#include "clang/Serialization/SerializationDiagnostic.h"#include "llvm/ADT/IntrusiveRefCntPtr.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/ScopeExit.h"#include "llvm/ADT/Statistic.h"#include "llvm/Config/llvm-config.h"#include "llvm/Plugins/PassPlugin.h"#include "llvm/Support/AdvisoryLock.h"#include "llvm/Support/BuryPointer.h"#include "llvm/Support/CrashRecoveryContext.h"#include "llvm/Support/Errc.h"#include "llvm/Support/FileSystem.h"#include "llvm/Support/MemoryBuffer.h"#include "llvm/Support/Path.h"#include "llvm/Support/Signals.h"#include "llvm/Support/SmallVectorMemoryBuffer.h"#include "llvm/Support/TimeProfiler.h"#include "llvm/Support/Timer.h"#include "llvm/Support/VirtualFileSystem.h"#include "llvm/Support/VirtualOutputBackends.h"#include "llvm/Support/VirtualOutputError.h"#include "llvm/Support/raw_ostream.h"#include "llvm/TargetParser/Host.h"#include <optional>#include <time.h>#include <utility>Go to the source code of this file.
Enumerations | |
| enum class | CompileOrReadResult : uint8_t { FailedToCompile , Compiled , FailedToRead , Read } |
| The result of compileModuleBehindLockOrRead(). More... | |
Functions | |
| static void | collectHeaderMaps (const HeaderSearch &HS, std::shared_ptr< ModuleDependencyCollector > MDC) |
| static void | collectIncludePCH (CompilerInstance &CI, std::shared_ptr< ModuleDependencyCollector > MDC) |
| static void | collectVFSEntries (CompilerInstance &CI, std::shared_ptr< ModuleDependencyCollector > MDC) |
| static void | SetUpDiagnosticLog (DiagnosticOptions &DiagOpts, const CodeGenOptions *CodeGenOpts, DiagnosticsEngine &Diags) |
| static void | SetupSerializedDiagnostics (DiagnosticOptions &DiagOpts, DiagnosticsEngine &Diags, StringRef OutputFile) |
| static void | InitializeFileRemapping (DiagnosticsEngine &Diags, SourceManager &SourceMgr, FileManager &FileMgr, const PreprocessorOptions &InitOpts) |
| static bool | EnableCodeCompletion (Preprocessor &PP, StringRef Filename, unsigned Line, unsigned Column) |
| static Language | getLanguageFromOptions (const LangOptions &LangOpts) |
| Determine the appropriate source input kind based on language options. | |
| static OptionalFileEntryRef | getPublicModuleMap (FileEntryRef File, FileManager &FileMgr) |
| static bool | readASTAfterCompileModule (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, SourceLocation ModuleNameLoc, Module *Module, ModuleFileName ModuleFileName, bool *OutOfDate, bool *Missing) |
| Read the AST right after compiling the module. | |
| static bool | compileModuleImpl (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, SourceLocation ModuleNameLoc, Module *Module, ModuleFileName ModuleFileName) |
| Compile a module in a separate compiler instance. | |
| static CompileOrReadResult | compileModuleBehindLockOrRead (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, SourceLocation ModuleNameLoc, Module *Module, ModuleFileName ModuleFileName) |
| Attempt to compile the module in a separate compiler instance behind a lock (to avoid building the same module in multiple compiler instances), or read the AST produced by another compiler instance. | |
| static bool | compileModuleAndReadAST (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, SourceLocation ModuleNameLoc, Module *Module, ModuleFileName ModuleFileName) |
| Compile a module in a separate compiler instance and read the AST, returning true if the module compiles without errors, potentially using a lock manager to avoid building the same module in multiple compiler instances. | |
| static void | checkConfigMacro (Preprocessor &PP, StringRef ConfigMacro, Module *Mod, SourceLocation ImportLoc) |
| Diagnose differences between the current definition of the given configuration macro and the definition provided on the command line. | |
| static void | checkConfigMacros (Preprocessor &PP, Module *M, SourceLocation ImportLoc) |
| static ModuleSource | selectModuleSource (Module *M, StringRef ModuleName, ModuleFileName &ModuleFilename, const std::map< std::string, std::string, std::less<> > &BuiltModules, HeaderSearch &HS) |
| Select a source for loading the named module and compute the filename to load it from. | |
|
strong |
The result of compileModuleBehindLockOrRead().
Definition at line 1532 of file CompilerInstance.cpp.
|
static |
Diagnose differences between the current definition of the given configuration macro and the definition provided on the command line.
Definition at line 1653 of file CompilerInstance.cpp.
References clang::Preprocessor::Diag(), clang::Module::getFullModuleName(), clang::Preprocessor::getIdentifierInfo(), clang::Preprocessor::getLocalMacroDirectiveHistory(), clang::Preprocessor::getMacroInfo(), clang::Preprocessor::getPredefinesFileID(), clang::Preprocessor::getSourceManager(), clang::IdentifierInfo::hadMacroDefinition(), and clang::FileID::isInvalid().
Referenced by checkConfigMacros().
|
static |
Definition at line 1714 of file CompilerInstance.cpp.
References checkConfigMacro(), clang::Module::ConfigMacros, and clang::Module::getTopLevelModule().
Referenced by clang::CompilerInstance::loadModule().
|
static |
Definition at line 228 of file CompilerInstance.cpp.
References clang::HeaderSearch::getHeaderMapFileNames().
Referenced by clang::CompilerInstance::createPreprocessor().
|
static |
Definition at line 236 of file CompilerInstance.cpp.
References clang::CompilerInstance::getFileManager(), clang::CompilerInstance::getModuleCache(), clang::CompilerInstance::getPCHContainerReader(), clang::CompilerInstance::getPreprocessor(), clang::CompilerInstance::getPreprocessorOpts(), clang::PreprocessorOptions::ImplicitPCHInclude, and clang::ASTReader::readASTFileControlBlock().
Referenced by clang::CompilerInstance::createPreprocessor().
|
static |
Definition at line 269 of file CompilerInstance.cpp.
References clang::CompilerInstance::getVirtualFileSystem().
Referenced by clang::CompilerInstance::createPreprocessor().
|
static |
Compile a module in a separate compiler instance and read the AST, returning true if the module compiles without errors, potentially using a lock manager to avoid building the same module in multiple compiler instances.
Definition at line 1620 of file CompilerInstance.cpp.
References clang::FrontendOptions::BuildingImplicitModuleUsesLock, Compiled, compileModuleBehindLockOrRead(), compileModuleImpl(), FailedToCompile, FailedToRead, clang::CompilerInvocation::getFrontendOpts(), clang::CompilerInstance::getInvocation(), Read, and readASTAfterCompileModule().
|
static |
Attempt to compile the module in a separate compiler instance behind a lock (to avoid building the same module in multiple compiler instances), or read the AST produced by another compiler instance.
Definition at line 1547 of file CompilerInstance.cpp.
References Compiled, compileModuleImpl(), FailedToCompile, FailedToRead, clang::CompilerInstance::getDiagnostics(), clang::CompilerInstance::getFrontendOpts(), clang::ModuleCache::getLock(), clang::CompilerInstance::getModuleCache(), clang::FrontendOptions::ImplicitModulesLockTimeoutSeconds, clang::Module::Name, Read, readASTAfterCompileModule(), clang::DiagnosticsEngine::Report(), and toString().
Referenced by compileModuleAndReadAST().
|
static |
Compile a module in a separate compiler instance.
Returns true on success, false on failure.
Definition at line 1474 of file CompilerInstance.cpp.
References clang::InMemoryModuleCache::addBuiltPCM(), clang::CompilerInstance::cloneForModuleCompile(), clang::CompilerInstance::compileModule(), clang::PCHContainerReader::ExtractPCH(), clang::CompilerInstance::getDiagnostics(), clang::Preprocessor::getHeaderSearchInfo(), clang::HeaderSearch::getHeaderSearchOpts(), clang::ModuleCache::getInMemoryModuleCache(), clang::CompilerInstance::getModuleCache(), clang::CompilerInstance::getPCHContainerReader(), clang::CompilerInstance::getPreprocessor(), clang::Module::getTopLevelModuleName(), clang::HeaderSearchOptions::ModulesValidateOncePerBuildSession, clang::Module::Name, clang::DiagnosticsEngine::Report(), clang::ModuleCache::updateModuleTimestamp(), and clang::ModuleCache::write().
Referenced by compileModuleAndReadAST(), and compileModuleBehindLockOrRead().
|
static |
Definition at line 695 of file CompilerInstance.cpp.
References clang::Column, clang::Preprocessor::getDiagnostics(), clang::Preprocessor::getFileManager(), clang::FileManager::getOptionalFileRef(), clang::Line, clang::DiagnosticsEngine::Report(), and clang::Preprocessor::SetCodeCompletionPoint().
Referenced by clang::CompilerInstance::createCodeCompletionConsumer(), and clang::CompilerInstance::createCodeCompletionConsumer().
|
static |
Determine the appropriate source input kind based on language options.
Definition at line 1113 of file CompilerInstance.cpp.
References clang::C, clang::CUDA, clang::CXX, clang::ObjC, clang::ObjCXX, and clang::OpenCL.
Referenced by clang::CompilerInstance::cloneForModuleCompile(), and clang::CompilerInstance::createModuleFromSource().
|
static |
Definition at line 1339 of file CompilerInstance.cpp.
References clang::File.
Referenced by clang::CompilerInstance::cloneForModuleCompile().
|
static |
Definition at line 404 of file CompilerInstance.cpp.
References clang::FileEntryRef::getSize(), clang::PreprocessorOptions::RemappedFileBuffers, clang::PreprocessorOptions::RemappedFiles, clang::PreprocessorOptions::RemappedFilesKeepOriginalName, clang::DiagnosticsEngine::Report(), and clang::PreprocessorOptions::RetainRemappedFileBuffers.
Referenced by clang::CompilerInstance::createPreprocessor().
|
static |
Read the AST right after compiling the module.
Returns true on success, false on failure.
Definition at line 1432 of file CompilerInstance.cpp.
References clang::ASTReader::ARR_Missing, clang::ASTReader::ARR_OutOfDate, clang::CompilerInstance::getASTReader(), clang::CompilerInstance::getDiagnostics(), clang::DiagnosticsEngine::hasErrorOccurred(), clang::ASTReader::Missing, clang::serialization::MK_ImplicitModule, clang::Module::Name, clang::ASTReader::OutOfDate, clang::DiagnosticsEngine::Report(), and clang::ASTReader::Success.
Referenced by compileModuleAndReadAST(), and compileModuleBehindLockOrRead().
|
static |
Select a source for loading the named module and compute the filename to load it from.
Definition at line 1838 of file CompilerInstance.cpp.
References clang::ModuleFileName::empty(), clang::HeaderSearchOptions::EnablePrebuiltImplicitModules, clang::HeaderSearch::getCachedModuleFileName(), clang::HeaderSearch::getHeaderSearchOpts(), clang::HeaderSearch::getPrebuiltImplicitModuleFileName(), clang::HeaderSearch::getPrebuiltModuleFileName(), clang::ModuleFileName::makeExplicit(), clang::HeaderSearchOptions::PrebuiltModuleFiles, and clang::HeaderSearchOptions::PrebuiltModulePaths.
Referenced by clang::CompilerInstance::loadModule().
|
static |
Definition at line 297 of file CompilerInstance.cpp.
References clang::DiagnosticOptions::DiagnosticLogFile, clang::CodeGenOptions::DwarfDebugFlags, clang::DiagnosticsEngine::getClient(), clang::DiagnosticsEngine::ownsClient(), clang::DiagnosticsEngine::Report(), clang::DiagnosticsEngine::setClient(), and clang::DiagnosticsEngine::takeClient().
Referenced by clang::CompilerInstance::createDiagnostics().
|
static |
Definition at line 332 of file CompilerInstance.cpp.
References clang::serialized_diags::create(), clang::DiagnosticsEngine::getClient(), clang::DiagnosticsEngine::ownsClient(), clang::DiagnosticsEngine::setClient(), and clang::DiagnosticsEngine::takeClient().
Referenced by clang::CompilerInstance::createDiagnostics().