clang  12.0.0git
Classes | Typedefs | Enumerations | Functions
clang::cross_tu Namespace Reference

Classes

class  CrossTranslationUnitContext
 This class is used for tools that requires cross translation unit capability. More...
 
class  IndexError
 

Typedefs

using InvocationListTy = llvm::StringMap< llvm::SmallVector< std::string, 32 > >
 

Enumerations

enum  index_error_code {
  index_error_code::unspecified = 1, index_error_code::missing_index_file, index_error_code::invalid_index_format, index_error_code::multiple_definitions,
  index_error_code::missing_definition, index_error_code::failed_import, index_error_code::failed_to_get_external_ast, index_error_code::failed_to_generate_usr,
  index_error_code::triple_mismatch, index_error_code::lang_mismatch, index_error_code::lang_dialect_mismatch, index_error_code::load_threshold_reached,
  index_error_code::invocation_list_ambiguous, index_error_code::invocation_list_file_not_found, index_error_code::invocation_list_empty, index_error_code::invocation_list_wrong_format,
  index_error_code::invocation_list_lookup_unsuccessful
}
 

Functions

llvm::Expected< llvm::StringMap< std::string > > parseCrossTUIndex (StringRef IndexPath)
 This function parses an index file that determines which translation unit contains which definition. More...
 
std::string createCrossTUIndexString (const llvm::StringMap< std::string > &Index)
 
llvm::Expected< InvocationListTyparseInvocationList (StringRef FileContent, llvm::sys::path::Style PathStyle=llvm::sys::path::Style::posix)
 Parse the YAML formatted invocation list file content FileContent. More...
 
bool containsConst (const VarDecl *VD, const ASTContext &ACtx)
 
static bool hasBodyOrInit (const FunctionDecl *D, const FunctionDecl *&DefD)
 
static bool hasBodyOrInit (const VarDecl *D, const VarDecl *&DefD)
 
template<typename T >
static bool hasBodyOrInit (const T *D)
 

Typedef Documentation

◆ InvocationListTy

using clang::cross_tu::InvocationListTy = typedef llvm::StringMap<llvm::SmallVector<std::string, 32> >

Definition at line 100 of file CrossTranslationUnit.h.

Enumeration Type Documentation

◆ index_error_code

Enumerator
unspecified 
missing_index_file 
invalid_index_format 
multiple_definitions 
missing_definition 
failed_import 
failed_to_get_external_ast 
failed_to_generate_usr 
triple_mismatch 
lang_mismatch 
lang_dialect_mismatch 
load_threshold_reached 
invocation_list_ambiguous 
invocation_list_file_not_found 
invocation_list_empty 
invocation_list_wrong_format 
invocation_list_lookup_unsuccessful 

Definition at line 39 of file CrossTranslationUnit.h.

Function Documentation

◆ containsConst()

bool clang::cross_tu::containsConst ( const VarDecl VD,
const ASTContext ACtx 
)

◆ createCrossTUIndexString()

std::string clang::cross_tu::createCrossTUIndexString ( const llvm::StringMap< std::string > &  Index)

◆ hasBodyOrInit() [1/3]

static bool clang::cross_tu::hasBodyOrInit ( const FunctionDecl D,
const FunctionDecl *&  DefD 
)
static

◆ hasBodyOrInit() [2/3]

static bool clang::cross_tu::hasBodyOrInit ( const VarDecl D,
const VarDecl *&  DefD 
)
static

Definition at line 204 of file CrossTranslationUnit.cpp.

References clang::VarDecl::getAnyInitializer().

◆ hasBodyOrInit() [3/3]

template<typename T >
static bool clang::cross_tu::hasBodyOrInit ( const T *  D)
static

Definition at line 207 of file CrossTranslationUnit.cpp.

References hasBodyOrInit(), and Unused.

◆ parseCrossTUIndex()

llvm::Expected< llvm::StringMap< std::string > > clang::cross_tu::parseCrossTUIndex ( StringRef  IndexPath)

This function parses an index file that determines which translation unit contains which definition.

The IndexPath is not prefixed with CTUDir, so an absolute path is expected for consistent results.

The index file format is the following: each line consists of an USR and a filepath separated by a space.

Returns
Returns a map where the USR is the key and the filepath is the value or an error.

Definition at line 149 of file CrossTranslationUnit.cpp.

References invalid_index_format, Line, missing_index_file, and multiple_definitions.

Referenced by clang::cross_tu::CrossTranslationUnitContext::emitCrossTUDiagnostics(), and clang::cross_tu::IndexError::getTripleFromName().

◆ parseInvocationList()

llvm::Expected< InvocationListTy > clang::cross_tu::parseInvocationList ( StringRef  FileContent,
llvm::sys::path::Style  PathStyle = llvm::sys::path::Style::posix 
)

Parse the YAML formatted invocation list file content FileContent.

The format is expected to be a mapping from from absolute source file paths in the filesystem to a list of command-line parts, which constitute the invocation needed to compile that file. That invocation will be used to produce the AST of the TU.

LLVM YAML parser is used to extract information from invocation list file.

Only the first document is processed.

There has to be at least one document available.

According to the format specified the document must be a mapping, where the keys are paths to source files, and values are sequences of invocation parts.

The keys should be strings, which represent a source-file path.

The values should be sequences of strings, each representing a part of the invocation.

Every conversion starts with an empty working storage, as it is not clear if this is a requirement of the YAML parser.

LLVM YAML parser is used to extract information from invocation list file.

Only the first document is processed.

There has to be at least one document available.

According to the format specified the document must be a mapping, where the keys are paths to source files, and values are sequences of invocation parts.

The keys should be strings, which represent a source-file path.

The values should be sequences of strings, each representing a part of the invocation.

Every conversion starts with an empty working storage, as it is not clear if this is a requirement of the YAML parser.

Definition at line 592 of file CrossTranslationUnit.cpp.

References clang::Error, failed_import, clang::ASTUnit::getASTContext(), hasBodyOrInit(), invocation_list_ambiguous, invocation_list_empty, invocation_list_file_not_found, invocation_list_wrong_format, clang::ImportError::NameConflict, Node, SM, clang::ImportError::Unknown, and clang::ImportError::UnsupportedConstruct.