clang API Documentation
#include "clang/Frontend/CompilerInstance.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Decl.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.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/PTHManager.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Sema/Sema.h"
#include "clang/Serialization/ASTReader.h"
#include "clang/Serialization/GlobalModuleIndex.h"
#include "llvm/ADT/Statistic.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/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include <sys/stat.h>
#include <system_error>
#include <time.h>
Go to the source code of this file.
Functions | |
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, const std::string &Filename, unsigned Line, unsigned Column) |
static InputKind | getSourceInputKindFromOptions (const LangOptions &LangOpts) |
Determine the appropriate source input kind based on language options. | |
static bool | compileModuleImpl (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, Module *Module, StringRef ModuleFileName) |
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. | |
static bool | compileAndLoadModule (CompilerInstance &ImportingInstance, SourceLocation ImportLoc, SourceLocation ModuleNameLoc, Module *Module, StringRef ModuleFileName) |
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 | writeTimestampFile (StringRef TimestampFile) |
Write a new timestamp file with the given path. | |
static void | pruneModuleCache (const HeaderSearchOptions &HSOpts) |
Prune the module cache of modules that haven't been accessed in a long time. |
static void checkConfigMacro | ( | Preprocessor & | PP, |
StringRef | ConfigMacro, | ||
Module * | Mod, | ||
SourceLocation | ImportLoc | ||
) | [static] |
Diagnose differences between the current definition of the given configuration macro and the definition provided on the command line.
Definition at line 1057 of file CompilerInstance.cpp.
References clang::Preprocessor::Diag(), clang::MacroDirective::getDefinition(), clang::SourceManager::getFileID(), clang::Module::getFullModuleName(), clang::Preprocessor::getIdentifierInfo(), clang::MacroDirective::DefInfo::getLocation(), clang::Preprocessor::getMacroDirectiveHistory(), clang::MacroDirective::DefInfo::getMacroInfo(), clang::Preprocessor::getPredefinesFileID(), clang::MacroDirective::DefInfo::getPreviousDefinition(), clang::Preprocessor::getSourceManager(), clang::MacroDirective::DefInfo::getUndefLocation(), clang::IdentifierInfo::hadMacroDefinition(), clang::IdentifierInfo::hasMacroDefinition(), clang::MacroInfo::isIdenticalTo(), clang::FileID::isInvalid(), clang::MacroDirective::DefInfo::isUndefined(), clang::SourceLocation::isValid(), and SourceMgr.
Referenced by clang::CompilerInstance::loadModule().
static bool compileAndLoadModule | ( | CompilerInstance & | ImportingInstance, |
SourceLocation | ImportLoc, | ||
SourceLocation | ModuleNameLoc, | ||
Module * | Module, | ||
StringRef | ModuleFileName | ||
) | [static] |
Definition at line 989 of file CompilerInstance.cpp.
References clang::ASTReader::ARR_Missing, clang::ASTReader::ARR_OutOfDate, compileModuleImpl(), clang::CompilerInstance::getDiagnostics(), clang::CompilerInstance::getModuleManager(), 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 clang::CompilerInstance::loadModule().
static bool compileModuleImpl | ( | CompilerInstance & | ImportingInstance, |
SourceLocation | ImportLoc, | ||
Module * | Module, | ||
StringRef | ModuleFileName | ||
) | [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 850 of file CompilerInstance.cpp.
References clang::FrontendOptions::DisableFree, clang::PreprocessorOptions::FailedModules, clang::FrontendOptions::GenerateGlobalModuleIndex, clang::ModuleMap::getContainingModuleMapFile(), clang::CompilerInstance::getDiagnosticClient(), clang::CompilerInstance::getDiagnostics(), clang::CompilerInstance::getFileManager(), clang::CompilerInstance::getFrontendOpts(), clang::Preprocessor::getHeaderSearchInfo(), clang::CompilerInstance::getInvocation(), clang::SourceManager::getModuleBuildStack(), clang::CompilerInstance::getModuleDepCollector(), clang::CompilerInvocation::getModuleHash(), clang::HeaderSearch::getModuleMap(), clang::ModuleMap::getModuleMapFileForUniquing(), clang::CompilerInstance::getPreprocessor(), clang::CompilerInvocationBase::getPreprocessorOpts(), getSourceInputKindFromOptions(), clang::CompilerInstance::getSourceManager(), clang::Module::getTopLevelModuleName(), clang::CompilerInstance::getVirtualFileSystem(), clang::FrontendOptions::Inputs, clang::Module::IsSystem, clang::PreprocessorOptions::Macros, clang::HeaderSearchOptions::ModulesIgnoreMacros, clang::Module::Name, clang::FrontendOptions::OutputFile, clang::SourceManager::overrideFileContents(), clang::Module::print(), clang::SourceManager::pushModuleBuildStack(), clang::DiagnosticsEngine::Report(), clang::PreprocessorOptions::resetNonModularOptions(), clang::PreprocessorOptions::RetainRemappedFileBuffers, clang::CompilerInstance::setBuildGlobalModuleIndex(), clang::SourceManager::setModuleBuildStack(), and SourceMgr.
Referenced by compileAndLoadModule().
static bool EnableCodeCompletion | ( | Preprocessor & | PP, |
const std::string & | Filename, | ||
unsigned | Line, | ||
unsigned | Column | ||
) | [static] |
Definition at line 450 of file CompilerInstance.cpp.
References clang::Preprocessor::getDiagnostics(), clang::FileManager::getFile(), clang::Preprocessor::getFileManager(), clang::DiagnosticsEngine::Report(), and clang::Preprocessor::SetCodeCompletionPoint().
Referenced by clang::CompilerInstance::createCodeCompletionConsumer().
static InputKind getSourceInputKindFromOptions | ( | const LangOptions & | LangOpts | ) | [static] |
Determine the appropriate source input kind based on language options.
Definition at line 837 of file CompilerInstance.cpp.
References clang::IK_C, clang::IK_CUDA, clang::IK_CXX, clang::IK_ObjC, clang::IK_ObjCXX, and clang::IK_OpenCL.
Referenced by compileModuleImpl().
static void InitializeFileRemapping | ( | DiagnosticsEngine & | Diags, |
SourceManager & | SourceMgr, | ||
FileManager & | FileMgr, | ||
const PreprocessorOptions & | InitOpts | ||
) | [static] |
Definition at line 239 of file CompilerInstance.cpp.
References clang::FileManager::getFile(), clang::FileEntry::getSize(), 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 void pruneModuleCache | ( | const HeaderSearchOptions & | HSOpts | ) | [static] |
Prune the module cache of modules that haven't been accessed in a long time.
Definition at line 1149 of file CompilerInstance.cpp.
References clang::HeaderSearchOptions::ModuleCachePath, clang::HeaderSearchOptions::ModuleCachePruneAfter, clang::HeaderSearchOptions::ModuleCachePruneInterval, and writeTimestampFile().
Referenced by clang::CompilerInstance::createModuleManager().
static void SetUpDiagnosticLog | ( | DiagnosticOptions * | DiagOpts, |
const CodeGenOptions * | CodeGenOpts, | ||
DiagnosticsEngine & | Diags | ||
) | [static] |
Definition at line 134 of file CompilerInstance.cpp.
References clang::CodeGenOptions::DwarfDebugFlags, clang::DiagnosticsEngine::ownsClient(), clang::DiagnosticsEngine::Report(), clang::DiagnosticsEngine::setClient(), and clang::DiagnosticsEngine::takeClient().
Referenced by clang::CompilerInstance::createDiagnostics().
static void SetupSerializedDiagnostics | ( | DiagnosticOptions * | DiagOpts, |
DiagnosticsEngine & | Diags, | ||
StringRef | OutputFile | ||
) | [static] |
Definition at line 166 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 void writeTimestampFile | ( | StringRef | TimestampFile | ) | [static] |
Write a new timestamp file with the given path.
Definition at line 1142 of file CompilerInstance.cpp.
Referenced by pruneModuleCache().