LLDB  mainline
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
lldb_private::CppModuleConfiguration Class Reference

A Clang configuration when importing C++ modules. More...

#include <CppModuleConfiguration.h>

Collaboration diagram for lldb_private::CppModuleConfiguration:
Collaboration graph
[legend]

Classes

class  SetOncePath
 Utility class for a path that can only be set once. More...
 

Public Member Functions

 CppModuleConfiguration (const FileSpecList &support_files, const llvm::Triple &triple)
 Creates a configuration by analyzing the given list of used source files. More...
 
 CppModuleConfiguration ()=default
 Creates an empty and invalid configuration. More...
 
bool hasValidConfig ()
 Returns true iff this is a valid configuration that can be used to load and compile modules. More...
 
llvm::ArrayRef< std::stringGetIncludeDirs () const
 Returns a list of include directories that should be used when using this configuration (e.g. More...
 
llvm::ArrayRef< std::stringGetImportedModules () const
 Returns a list of (top level) modules that should be imported when using this configuration (e.g. More...
 

Private Member Functions

bool analyzeFile (const FileSpec &f, const llvm::Triple &triple)
 Analyze a given source file to build the current configuration. More...
 

Private Attributes

SetOncePath m_std_inc
 If valid, the include path used for the std module. More...
 
SetOncePath m_std_target_inc
 If valid, the per-target include path used for the std module. More...
 
SetOncePath m_c_inc
 If valid, the include path to the C library (e.g. /usr/include). More...
 
SetOncePath m_c_target_inc
 If valid, the include path to target-specific C library files (e.g. More...
 
std::string m_resource_inc
 The Clang resource include path for this configuration. More...
 
std::vector< std::stringm_include_dirs
 
std::vector< std::stringm_imported_modules
 

Detailed Description

A Clang configuration when importing C++ modules.

This class computes a list of include paths and module names that can be imported given a list of source files. Currently only used when importing the 'std' module and its dependencies.

Definition at line 22 of file CppModuleConfiguration.h.

Constructor & Destructor Documentation

◆ CppModuleConfiguration() [1/2]

CppModuleConfiguration::CppModuleConfiguration ( const FileSpecList &  support_files,
const llvm::Triple &  triple 
)
explicit

Creates a configuration by analyzing the given list of used source files.

The triple (if valid) is used to search for target-specific include paths.

Definition at line 133 of file CppModuleConfiguration.cpp.

References analyzeFile(), error(), lldb_private::CppModuleConfiguration::SetOncePath::Get(), lldb_private::GetClangResourceDir(), hasValidConfig(), m_c_inc, m_c_target_inc, m_imported_modules, m_include_dirs, m_resource_inc, m_std_inc, m_std_target_inc, string(), and lldb_private::CppModuleConfiguration::SetOncePath::Valid().

◆ CppModuleConfiguration() [2/2]

lldb_private::CppModuleConfiguration::CppModuleConfiguration ( )
default

Creates an empty and invalid configuration.

Member Function Documentation

◆ analyzeFile()

bool CppModuleConfiguration::analyzeFile ( const FileSpec f,
const llvm::Triple &  triple 
)
private

Analyze a given source file to build the current configuration.

Returns false iff there was a fatal error that makes analyzing any further files pointless as the configuration is now invalid.

Definition at line 61 of file CppModuleConfiguration.cpp.

References lldb_private::FileSpec::GetDirectory(), lldb_private::FileSpec::GetPath(), lldb_private::ConstString::GetStringRef(), getTargetIncludePaths(), guessIncludePath(), m_c_inc, m_c_target_inc, m_std_inc, m_std_target_inc, string(), and lldb_private::CppModuleConfiguration::SetOncePath::TrySet().

Referenced by CppModuleConfiguration().

◆ GetImportedModules()

llvm::ArrayRef<std::string> lldb_private::CppModuleConfiguration::GetImportedModules ( ) const
inline

Returns a list of (top level) modules that should be imported when using this configuration (e.g.

{"std"}).

Definition at line 83 of file CppModuleConfiguration.h.

References m_imported_modules.

Referenced by lldb_private::ClangUserExpression::SetupCppModuleImports().

◆ GetIncludeDirs()

llvm::ArrayRef<std::string> lldb_private::CppModuleConfiguration::GetIncludeDirs ( ) const
inline

Returns a list of include directories that should be used when using this configuration (e.g.

{"/usr/include", "/usr/include/c++/v1"}).

Definition at line 79 of file CppModuleConfiguration.h.

References m_include_dirs.

Referenced by lldb_private::ClangUserExpression::SetupCppModuleImports().

◆ hasValidConfig()

bool CppModuleConfiguration::hasValidConfig ( )

Returns true iff this is a valid configuration that can be used to load and compile modules.

Definition at line 106 of file CppModuleConfiguration.cpp.

References lldb_private::CppModuleConfiguration::SetOncePath::Get(), lldb_private::FileSystem::Instance(), m_c_inc, m_std_inc, MakePath(), and lldb_private::CppModuleConfiguration::SetOncePath::Valid().

Referenced by CppModuleConfiguration().

Member Data Documentation

◆ m_c_inc

SetOncePath lldb_private::CppModuleConfiguration::m_c_inc
private

If valid, the include path to the C library (e.g. /usr/include).

Definition at line 49 of file CppModuleConfiguration.h.

Referenced by analyzeFile(), CppModuleConfiguration(), and hasValidConfig().

◆ m_c_target_inc

SetOncePath lldb_private::CppModuleConfiguration::m_c_target_inc
private

If valid, the include path to target-specific C library files (e.g.

/usr/include/x86_64-linux-gnu). This is an optional path only required on some systems.

Definition at line 53 of file CppModuleConfiguration.h.

Referenced by analyzeFile(), and CppModuleConfiguration().

◆ m_imported_modules

std::vector<std::string> lldb_private::CppModuleConfiguration::m_imported_modules
private

Definition at line 58 of file CppModuleConfiguration.h.

Referenced by CppModuleConfiguration(), and GetImportedModules().

◆ m_include_dirs

std::vector<std::string> lldb_private::CppModuleConfiguration::m_include_dirs
private

Definition at line 57 of file CppModuleConfiguration.h.

Referenced by CppModuleConfiguration(), and GetIncludeDirs().

◆ m_resource_inc

std::string lldb_private::CppModuleConfiguration::m_resource_inc
private

The Clang resource include path for this configuration.

Definition at line 55 of file CppModuleConfiguration.h.

Referenced by CppModuleConfiguration().

◆ m_std_inc

SetOncePath lldb_private::CppModuleConfiguration::m_std_inc
private

If valid, the include path used for the std module.

Definition at line 44 of file CppModuleConfiguration.h.

Referenced by analyzeFile(), CppModuleConfiguration(), and hasValidConfig().

◆ m_std_target_inc

SetOncePath lldb_private::CppModuleConfiguration::m_std_target_inc
private

If valid, the per-target include path used for the std module.

This is an optional path only required on some systems.

Definition at line 47 of file CppModuleConfiguration.h.

Referenced by analyzeFile(), and CppModuleConfiguration().


The documentation for this class was generated from the following files: