clang
10.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/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/FrontendDiagnostic.h"
#include "clang/Frontend/LogDiagnosticPrinter.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/Sema.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/GlobalModuleIndex.h"
#include "clang/Serialization/InMemoryModuleCache.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/BuryPointer.h"
#include "llvm/Support/CrashRecoveryContext.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/LockFileManager.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include <time.h>
#include <utility>
Go to the source code of this file.
Enumerations | |
enum | ModuleSource |
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. More... | |
static bool | compileModuleImpl (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, StringRef ModuleName, FrontendInputFile Input, StringRef OriginalModuleMapFile, StringRef ModuleFileName, llvm::function_ref< void(CompilerInstance &)> PreBuildStep=[](CompilerInstance &) {}, llvm::function_ref< void(CompilerInstance &)> PostBuildStep=[](CompilerInstance &) {}) |
Compile a module file for the given module, using the options provided by the importing compiler instance. More... | |
static const FileEntry * | getPublicModuleMap (const FileEntry *File, FileManager &FileMgr) |
static bool | compileModule (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName) |
Compile a module file for the given module in a separate compiler instance, using the options provided by the importing compiler instance. More... | |
static bool | compileModuleAndReadAST (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, SourceLocation ModuleNameLoc, Module *Module, StringRef ModuleFileName) |
Compile a module in a separate compiler instance and read the AST, returning true if the module compiles without errors. More... | |
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. More... | |
static void | writeTimestampFile (StringRef TimestampFile) |
Write a new timestamp file with the given path. More... | |
static void | pruneModuleCache (const HeaderSearchOptions &HSOpts) |
Prune the module cache of modules that haven't been accessed in a long time. More... | |
static ModuleSource | selectModuleSource (Module *M, StringRef ModuleName, std::string &ModuleFilename, const std::map< std::string, std::string > &BuiltModules, HeaderSearch &HS) |
Select a source for loading the named module and compute the filename to load it from. More... | |
enum ModuleSource |
Definition at line 1623 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 1340 of file CompilerInstance.cpp.
References clang::Preprocessor::Diag(), clang::SourceManager::getFileID(), clang::Module::getFullModuleName(), clang::Preprocessor::getIdentifierInfo(), clang::Preprocessor::getLocalMacroDirectiveHistory(), clang::Preprocessor::getMacroInfo(), clang::Preprocessor::getPredefinesFileID(), clang::Preprocessor::getSourceManager(), clang::IdentifierInfo::hadMacroDefinition(), Id, and clang::FileID::isInvalid().
|
static |
Definition at line 157 of file CompilerInstance.cpp.
References clang::HeaderSearch::getHeaderMapFileNames().
Referenced by clang::CompilerInstance::createPreprocessor().
|
static |
Definition at line 165 of file CompilerInstance.cpp.
References clang::FileManager::getDirectory(), clang::CompilerInstance::getFileManager(), clang::CompilerInstance::getPreprocessorOpts(), and clang::PreprocessorOptions::ImplicitPCHInclude.
Referenced by clang::CompilerInstance::createPreprocessor().
|
static |
Definition at line 197 of file CompilerInstance.cpp.
References clang::CompilerInstance::getHeaderSearchOpts(), and clang::HeaderSearchOptions::VFSOverlayFiles.
Referenced by clang::CompilerInstance::createPreprocessor().
|
static |
Compile a module file for the given module in a separate compiler instance, using the options provided by the importing compiler instance.
Returns true if the module was built without errors.
Definition at line 1186 of file CompilerInstance.cpp.
References compileModuleImpl(), clang::Module::Directory, clang::FrontendOptions::GenerateGlobalModuleIndex, clang::ModuleMap::getContainingModuleMapFile(), clang::CompilerInstance::getFileManager(), clang::CompilerInstance::getFrontendOpts(), clang::Preprocessor::getHeaderSearchInfo(), clang::CompilerInstance::getLangOpts(), getLanguageFromOptions(), clang::HeaderSearch::getModuleMap(), clang::ModuleMap::getModuleMapFileForUniquing(), clang::DirectoryEntry::getName(), clang::FileEntry::getName(), clang::CompilerInstance::getPreprocessor(), getPublicModuleMap(), clang::Module::getTopLevelModuleName(), clang::Module::IsSystem, clang::InputKind::ModuleMap, clang::Module::print(), clang::Result, and clang::CompilerInstance::setBuildGlobalModuleIndex().
Referenced by compileModuleAndReadAST().
|
static |
Compile a module in a separate compiler instance and read the AST, returning true if the module compiles without errors.
Uses a lock file manager and exponential backoff to reduce the chances that multiple instances will compete to create the same module. On timeout, deletes the lock file in order to avoid deadlock from crashing processes or bugs in the lock file manager.
Definition at line 1255 of file CompilerInstance.cpp.
References clang::ASTReader::ARR_Missing, clang::ASTReader::ARR_OutOfDate, compileModule(), 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 selectModuleSource().
|
static |
Compile a module file for the given module, using the options provided by the importing compiler instance.
Returns true if the module was built without errors.
Definition at line 1039 of file CompilerInstance.cpp.
References clang::FrontendOptions::BuildingImplicitModule, clang::DesiredStackSize, clang::FrontendOptions::DisableFree, clang::ASTFrontendAction::ExecuteAction(), clang::PreprocessorOptions::FailedModules, clang::FrontendOptions::GenerateGlobalModuleIndex, clang::CompilerInstance::getDiagnosticClient(), clang::CompilerInstance::getDiagnostics(), clang::CompilerInstance::getFileManager(), clang::CompilerInstance::getInvocation(), clang::CompilerInvocationBase::getLangOpts(), clang::SourceManager::getModuleBuildStack(), clang::CompilerInstance::getModuleCache(), clang::CompilerInstance::getModuleDepCollector(), clang::CompilerInvocation::getModuleHash(), clang::CompilerInstance::getPCHContainerOperations(), clang::CompilerInvocationBase::getPreprocessorOpts(), clang::CompilerInstance::getSourceManager(), clang::FrontendOptions::Inputs, clang::LangOptions::ModuleName, clang::HeaderSearchOptions::ModulesHashContent, clang::HeaderSearchOptions::ModulesIgnoreMacros, clang::FrontendOptions::OriginalModuleMap, clang::FrontendOptions::OutputFile, clang::SourceManager::pushModuleBuildStack(), clang::DiagnosticsEngine::Report(), and clang::SourceManager::setModuleBuildStack().
Referenced by compileModule(), and clang::CompilerInstance::createModuleFromSource().
|
static |
Definition at line 565 of file CompilerInstance.cpp.
References Filename, clang::Preprocessor::getDiagnostics(), clang::FileManager::getFile(), clang::Preprocessor::getFileManager(), clang::DiagnosticsEngine::Report(), and clang::Preprocessor::SetCodeCompletionPoint().
Referenced by clang::CompilerInstance::createCodeCompletionConsumer().
|
static |
Determine the appropriate source input kind based on language options.
Definition at line 1025 of file CompilerInstance.cpp.
References clang::C, clang::CUDA, clang::CXX, clang::ObjC, clang::ObjCXX, and clang::OpenCL.
Referenced by compileModule(), and clang::CompilerInstance::createModuleFromSource().
|
static |
Definition at line 1168 of file CompilerInstance.cpp.
References Filename, clang::FileEntry::getDir(), clang::FileManager::getFile(), clang::DirectoryEntry::getName(), and clang::FileEntry::getName().
Referenced by compileModule().
|
static |
Definition at line 329 of file CompilerInstance.cpp.
References clang::FileManager::getFile(), clang::FileManager::getVirtualFile(), clang::SourceManager::overrideFileContents(), clang::PreprocessorOptions::RemappedFileBuffers, clang::PreprocessorOptions::RemappedFiles, clang::PreprocessorOptions::RemappedFilesKeepOriginalName, clang::DiagnosticsEngine::Report(), clang::PreprocessorOptions::RetainRemappedFileBuffers, and clang::SourceManager::setOverridenFilesKeepOriginalName().
Referenced by clang::CompilerInstance::createPreprocessor().
|
static |
Prune the module cache of modules that haven't been accessed in a long time.
Definition at line 1404 of file CompilerInstance.cpp.
References clang::HeaderSearchOptions::ModuleCachePath, clang::HeaderSearchOptions::ModuleCachePruneAfter, clang::HeaderSearchOptions::ModuleCachePruneInterval, clang::transformer::remove(), and writeTimestampFile().
Referenced by clang::CompilerInstance::createASTReader().
|
static |
Select a source for loading the named module and compute the filename to load it from.
Definition at line 1634 of file CompilerInstance.cpp.
References clang::ASTReader::ARR_ConfigurationMismatch, clang::ASTReader::ARR_Missing, clang::ASTReader::ARR_OutOfDate, compileModuleAndReadAST(), clang::ModuleLoadResult::ConfigMismatch, clang::ASTReader::ConfigurationMismatch, clang::CompilerInstance::createASTReader(), clang::PreprocessorOptions::FailedModules, clang::ASTReader::Failure, clang::Module::getASTFile(), clang::CompilerInstance::getASTReader(), clang::HeaderSearch::getCachedModuleFileName(), clang::CompilerInstance::getDiagnostics(), clang::HeaderSearch::getHeaderSearchOpts(), clang::SourceManager::getModuleBuildStack(), clang::HeaderSearch::getPrebuiltModuleFileName(), clang::CompilerInstance::getPreprocessorOpts(), clang::CompilerInstance::getSourceManager(), clang::ASTReader::HadErrors, clang::ModuleLoader::HadFatalFailure, clang::Module::HasIncompatibleModuleFile, clang::HeaderSearch::lookupModule(), clang::ASTReader::Missing, clang::serialization::MK_ExplicitModule, clang::serialization::MK_ImplicitModule, clang::serialization::MK_PrebuiltModule, clang::ModuleLoadResult::OtherUncachedFailure, clang::ASTReader::OutOfDate, clang::HeaderSearchOptions::PrebuiltModuleFiles, clang::HeaderSearchOptions::PrebuiltModulePaths, clang::DiagnosticsEngine::Report(), clang::ASTReader::Success, and clang::ASTReader::VersionMismatch.
|
static |
Definition at line 218 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 253 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().
|
static |
Write a new timestamp file with the given path.
Definition at line 1397 of file CompilerInstance.cpp.
Referenced by pruneModuleCache().