clang
6.0.0
|
This class is used for tools that requires cross translation unit capability. More...
#include "clang/CrossTU/CrossTranslationUnit.h"
Public Member Functions | |
CrossTranslationUnitContext (CompilerInstance &CI) | |
~CrossTranslationUnitContext () | |
llvm::Expected< const FunctionDecl * > | getCrossTUDefinition (const FunctionDecl *FD, StringRef CrossTUDir, StringRef IndexName) |
This function loads a function definition from an external AST file and merge it into the original AST. More... | |
llvm::Expected< ASTUnit * > | loadExternalAST (StringRef LookupName, StringRef CrossTUDir, StringRef IndexName) |
This function loads a function definition from an external AST file. More... | |
llvm::Expected< const FunctionDecl * > | importDefinition (const FunctionDecl *FD) |
This function merges a definition from a separate AST Unit into the current one which was created by the compiler instance that was passed to the constructor. More... | |
void | emitCrossTUDiagnostics (const IndexError &IE) |
Emit diagnostics for the user for potential configuration errors. More... | |
Static Public Member Functions | |
static std::string | getLookupName (const NamedDecl *ND) |
Get a name to identify a function. More... | |
This class is used for tools that requires cross translation unit capability.
This class can load function definitions from external AST files. The loaded definition will be merged back to the original AST using the AST Importer. In order to use this class, an index file is required that describes the locations of the AST files for each function definition.
Note that this class also implements caching.
Definition at line 88 of file CrossTranslationUnit.h.
clang::cross_tu::CrossTranslationUnitContext::CrossTranslationUnitContext | ( | CompilerInstance & | CI | ) |
Definition at line 114 of file CrossTranslationUnit.cpp.
clang::cross_tu::CrossTranslationUnitContext::~CrossTranslationUnitContext | ( | ) |
Definition at line 117 of file CrossTranslationUnit.cpp.
void clang::cross_tu::CrossTranslationUnitContext::emitCrossTUDiagnostics | ( | const IndexError & | IE | ) |
Emit diagnostics for the user for potential configuration errors.
Definition at line 176 of file CrossTranslationUnit.cpp.
References clang::cross_tu::IndexError::getCode(), clang::ASTContext::getDiagnostics(), clang::cross_tu::IndexError::getFileName(), clang::cross_tu::IndexError::getLineNum(), clang::cross_tu::invalid_index_format, clang::cross_tu::missing_index_file, clang::cross_tu::multiple_definitions, and clang::DiagnosticsEngine::Report().
llvm::Expected< const FunctionDecl * > clang::cross_tu::CrossTranslationUnitContext::getCrossTUDefinition | ( | const FunctionDecl * | FD, |
StringRef | CrossTUDir, | ||
StringRef | IndexName | ||
) |
This function loads a function definition from an external AST file and merge it into the original AST.
This method should only be used on functions that have no definitions in the current translation unit. A function definition with the same declaration will be looked up in the index file which should be in the CrossTUDir
directory, called IndexName
. In case the declaration is found in the index the corresponding AST file will be loaded and the definition of the function will be merged into the original AST using the AST Importer.
Note that the AST files should also be in the CrossTUDir
.
Definition at line 150 of file CrossTranslationUnit.cpp.
References clang::cross_tu::failed_import, clang::cross_tu::failed_to_generate_usr, clang::cross_tu::failed_to_get_external_ast, clang::ASTUnit::getASTContext(), clang::ASTUnit::getFileManager(), clang::SourceManager::getFileManager(), getLookupName(), clang::ASTContext::getSourceManager(), clang::ASTContext::getTranslationUnitDecl(), clang::FunctionDecl::hasBody(), importDefinition(), and loadExternalAST().
|
static |
Get a name to identify a function.
Definition at line 119 of file CrossTranslationUnit.cpp.
References clang::DeclContext::decls(), and clang::index::generateUSRForDecl().
Referenced by getCrossTUDefinition().
llvm::Expected< const FunctionDecl * > clang::cross_tu::CrossTranslationUnitContext::importDefinition | ( | const FunctionDecl * | FD | ) |
This function merges a definition from a separate AST Unit into the current one which was created by the compiler instance that was passed to the constructor.
Definition at line 247 of file CrossTranslationUnit.cpp.
References clang::Decl::getASTContext(), clang::FunctionDecl::hasBody(), and clang::ASTImporter::Import().
Referenced by getCrossTUDefinition().
llvm::Expected< ASTUnit * > clang::cross_tu::CrossTranslationUnitContext::loadExternalAST | ( | StringRef | LookupName, |
StringRef | CrossTUDir, | ||
StringRef | IndexName | ||
) |
This function loads a function definition from an external AST file.
A function definition with the same declaration will be looked up in the index file which should be in the CrossTUDir
directory, called IndexName
. In case the declaration is found in the index the corresponding AST file will be loaded.
Note that the AST files should also be in the CrossTUDir
.
Definition at line 195 of file CrossTranslationUnit.cpp.
References clang::CompilerInstance::getFileSystemOpts(), clang::CompilerInstance::getPCHContainerOperations(), clang::ASTUnit::LoadEverything, clang::ASTUnit::LoadFromASTFile(), clang::cross_tu::missing_definition, and clang::cross_tu::parseCrossTUIndex().
Referenced by getCrossTUDefinition().