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

An abstraction for Xcode-style SDKs that works like ArchSpec. More...

#include <XcodeSDK.h>

Classes

struct  Info
 A parsed SDK directory name. More...
 

Public Types

enum  Type : int {
  MacOSX = 0 , iPhoneSimulator , iPhoneOS , AppleTVSimulator ,
  AppleTVOS , WatchSimulator , watchOS , XRSimulator ,
  XROS , bridgeOS , Linux , unknown = -1
}
 Different types of Xcode SDKs. More...
 

Public Member Functions

 XcodeSDK ()=default
 Default constructor, constructs an empty string.
 
 XcodeSDK (Info info)
 Construct an XcodeSDK object from a specification.
 
 XcodeSDK (std::string &&name)
 Initialize an XcodeSDK object with an SDK name.
 
void Merge (const XcodeSDK &other)
 The merge function follows a strict order to maintain monotonicity:
 
XcodeSDKoperator= (const XcodeSDK &other)
 
 XcodeSDK (const XcodeSDK &)=default
 
bool operator== (const XcodeSDK &other) const
 
Info Parse () const
 Return parsed SDK type and version number.
 
bool IsAppleInternalSDK () const
 
llvm::VersionTuple GetVersion () const
 
Type GetType () const
 
llvm::StringRef GetString () const
 
bool SupportsSwift () const
 Whether this Xcode SDK supports Swift.
 

Static Public Member Functions

static XcodeSDK GetAnyMacOS ()
 
static bool SDKSupportsModules (Type type, llvm::VersionTuple version)
 Whether LLDB feels confident importing Clang modules from this SDK.
 
static bool SDKSupportsModules (Type desired_type, const FileSpec &sdk_path)
 
static bool SDKSupportsBuiltinModules (const llvm::Triple &target_triple, llvm::VersionTuple sdk_version)
 Returns true if the SDK for the specified triple supports builtin modules in system headers.
 
static std::string GetCanonicalName (Info info)
 Return the canonical SDK name, such as "macosx" for the macOS SDK.
 
static XcodeSDK::Type GetSDKTypeForTriple (const llvm::Triple &triple)
 Return the best-matching SDK type for a specific triple.
 
static std::string FindXcodeContentsDirectoryInPath (llvm::StringRef path)
 

Static Public Attributes

static constexpr int numSDKTypes = Linux + 1
 

Private Attributes

std::string m_name
 

Detailed Description

An abstraction for Xcode-style SDKs that works like ArchSpec.

Definition at line 24 of file XcodeSDK.h.

Member Enumeration Documentation

◆ Type

Different types of Xcode SDKs.

Enumerator
MacOSX 
iPhoneSimulator 
iPhoneOS 
AppleTVSimulator 
AppleTVOS 
WatchSimulator 
watchOS 
XRSimulator 
XROS 
bridgeOS 
Linux 
unknown 

Definition at line 29 of file XcodeSDK.h.

Constructor & Destructor Documentation

◆ XcodeSDK() [1/4]

lldb_private::XcodeSDK::XcodeSDK ( )
default

Default constructor, constructs an empty string.

Referenced by GetAnyMacOS().

◆ XcodeSDK() [2/4]

XcodeSDK::XcodeSDK ( XcodeSDK::Info  info)

Construct an XcodeSDK object from a specification.

Definition at line 51 of file XcodeSDK.cpp.

References lldb_private::XcodeSDK::Info::internal, m_name, and lldb_private::XcodeSDK::Info::version.

◆ XcodeSDK() [3/4]

lldb_private::XcodeSDK::XcodeSDK ( std::string &&  name)
inline

Initialize an XcodeSDK object with an SDK name.

The SDK name is the last directory component of a path one would pass to clang's -isysroot parameter. For example, "MacOSX.10.14.sdk".

Definition at line 64 of file XcodeSDK.h.

◆ XcodeSDK() [4/4]

lldb_private::XcodeSDK::XcodeSDK ( const XcodeSDK )
default

Member Function Documentation

◆ FindXcodeContentsDirectoryInPath()

std::string XcodeSDK::FindXcodeContentsDirectoryInPath ( llvm::StringRef  path)
static

◆ GetAnyMacOS()

static XcodeSDK lldb_private::XcodeSDK::GetAnyMacOS ( )
inlinestatic

◆ GetCanonicalName()

std::string XcodeSDK::GetCanonicalName ( XcodeSDK::Info  info)
static

◆ GetSDKTypeForTriple()

XcodeSDK::Type XcodeSDK::GetSDKTypeForTriple ( const llvm::Triple &  triple)
static

Return the best-matching SDK type for a specific triple.

Definition at line 296 of file XcodeSDK.cpp.

References AppleTVOS, AppleTVSimulator, iPhoneOS, iPhoneSimulator, Linux, MacOSX, unknown, watchOS, WatchSimulator, XROS, and XRSimulator.

◆ GetString()

llvm::StringRef XcodeSDK::GetString ( ) const

◆ GetType()

XcodeSDK::Type XcodeSDK::GetType ( ) const

Definition at line 138 of file XcodeSDK.cpp.

References m_name, and ParseSDKName().

Referenced by SDKSupportsModules().

◆ GetVersion()

llvm::VersionTuple XcodeSDK::GetVersion ( ) const

Definition at line 132 of file XcodeSDK.cpp.

References m_name, ParseSDKName(), and ParseSDKVersion().

Referenced by SDKSupportsModules().

◆ IsAppleInternalSDK()

bool XcodeSDK::IsAppleInternalSDK ( ) const

◆ Merge()

void XcodeSDK::Merge ( const XcodeSDK other)

The merge function follows a strict order to maintain monotonicity:

  1. SDK with the higher SDKType wins.
  2. The newer SDK wins.

Definition at line 155 of file XcodeSDK.cpp.

References l, m_name, and Parse().

Referenced by lldb_private::PlatformDarwin::GetSDKPathFromDebugInfo().

◆ operator=()

XcodeSDK & XcodeSDK::operator= ( const XcodeSDK other)
default

◆ operator==()

bool XcodeSDK::operator== ( const XcodeSDK other) const

Definition at line 63 of file XcodeSDK.cpp.

References m_name.

◆ Parse()

XcodeSDK::Info XcodeSDK::Parse ( ) const

◆ SDKSupportsBuiltinModules()

bool XcodeSDK::SDKSupportsBuiltinModules ( const llvm::Triple &  target_triple,
llvm::VersionTuple  sdk_version 
)
static

Returns true if the SDK for the specified triple supports builtin modules in system headers.

NOTE: should be kept in sync with sdkSupportsBuiltinModules in Toolchains/Darwin.cpp

FIXME: this function will be removed once LLDB's ClangExpressionParser constructs the compiler instance through the driver/toolchain. See SetupImportStdModuleLangOpts

Definition at line 262 of file XcodeSDK.cpp.

Referenced by sdkSupportsBuiltinModules().

◆ SDKSupportsModules() [1/2]

bool XcodeSDK::SDKSupportsModules ( XcodeSDK::Type  desired_type,
const FileSpec sdk_path 
)
static

◆ SDKSupportsModules() [2/2]

bool XcodeSDK::SDKSupportsModules ( XcodeSDK::Type  sdk_type,
llvm::VersionTuple  version 
)
static

Whether LLDB feels confident importing Clang modules from this SDK.

Definition at line 216 of file XcodeSDK.cpp.

References AppleTVOS, AppleTVSimulator, iPhoneOS, iPhoneSimulator, MacOSX, watchOS, WatchSimulator, XROS, and XRSimulator.

Referenced by lldb_private::PlatformDarwin::DirectoryEnumerator(), lldb_private::PlatformDarwin::GetSDKDirectoryForModules(), and SDKSupportsModules().

◆ SupportsSwift()

bool XcodeSDK::SupportsSwift ( ) const

Member Data Documentation

◆ m_name

std::string lldb_private::XcodeSDK::m_name
private

◆ numSDKTypes

constexpr int lldb_private::XcodeSDK::numSDKTypes = Linux + 1
staticconstexpr

Definition at line 43 of file XcodeSDK.h.

Referenced by ParseSDKName().


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