9#ifndef LLVM_CLANG_DRIVER_MULTILIB_H 
   10#define LLVM_CLANG_DRIVER_MULTILIB_H 
   13#include "llvm/ADT/ArrayRef.h" 
   14#include "llvm/ADT/STLExtras.h" 
   15#include "llvm/ADT/StringRef.h" 
   16#include "llvm/ADT/StringSet.h" 
   17#include "llvm/Support/Compiler.h" 
   18#include "llvm/Support/SourceMgr.h" 
   40  std::string GCCSuffix;
 
   42  std::string IncludeSuffix;
 
   52  std::string ExclusiveGroup;
 
   57  std::optional<std::string> Error;
 
   63  Multilib(StringRef GCCSuffix = {}, StringRef OSSuffix = {},
 
   65           StringRef ExclusiveGroup = {},
 
   66           std::optional<StringRef> Error = std::nullopt);
 
   70  const std::string &
gccSuffix()
 const { 
return GCCSuffix; }
 
   74  const std::string &
osSuffix()
 const { 
return OSSuffix; }
 
   87  LLVM_DUMP_METHOD 
void dump() 
const;
 
   89  void print(raw_ostream &OS) 
const;
 
   93  { 
return GCCSuffix.empty() && OSSuffix.empty() && IncludeSuffix.empty(); }
 
 
   97  bool isError()
 const { 
return Error.has_value(); }
 
 
  102raw_ostream &
operator<<(raw_ostream &OS, 
const Multilib &M);
 
  125static constexpr StringRef 
Prefix = 
"-fmultilib-flag=";
 
 
  157      : Multilibs(
std::move(Multilibs)), FlagMatchers(
std::move(FlagMatchers)),
 
  158        CustomFlagDecls(
std::move(CustomFlagDecls)) {}
 
 
  176  std::pair<Multilib::flags_list, SmallVector<StringRef>>
 
  184  unsigned size()
 const { 
return Multilibs.size(); }
 
  191  LLVM_DUMP_METHOD 
void dump() 
const;
 
  192  void print(raw_ostream &OS) 
const;
 
  195    IncludeCallback = std::move(F);
 
 
  202    FilePathsCallback = std::move(F);
 
 
  208  static llvm::ErrorOr<MultilibSet>
 
  209  parseYaml(llvm::MemoryBufferRef, llvm::SourceMgr::DiagHandlerTy = 
nullptr,
 
  210            void *DiagHandlerCtxt = 
nullptr);
 
 
  213raw_ostream &
operator<<(raw_ostream &OS, 
const MultilibSet &MS);
 
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
See also MultilibSetBuilder for combining multilibs into a set.
bool select(const Driver &D, const Multilib::flags_list &Flags, llvm::SmallVectorImpl< Multilib > &, llvm::SmallVector< StringRef > *=nullptr) const
Select compatible variants,.
MultilibSet & setFilePathsCallback(IncludeDirsFunc F)
LLVM_DUMP_METHOD void dump() const
llvm::function_ref< bool(const Multilib &)> FilterCallback
const_iterator end() const
const multilib_list & getMultilibs()
static llvm::ErrorOr< MultilibSet > parseYaml(llvm::MemoryBufferRef, llvm::SourceMgr::DiagHandlerTy=nullptr, void *DiagHandlerCtxt=nullptr)
void print(raw_ostream &OS) const
MultilibSet & FilterOut(FilterCallback F)
Filter out some subset of the Multilibs using a user defined callback.
std::vector< Multilib > multilib_list
const IncludeDirsFunc & filePathsCallback() const
llvm::StringSet expandFlags(const Multilib::flags_list &) const
Get the given flags plus flags found by matching them against the FlagMatchers and choosing the Flags...
void push_back(const Multilib &M)
Add a completed Multilib to the set.
MultilibSet(multilib_list &&Multilibs, SmallVector< FlagMatcher > &&FlagMatchers={}, SmallVector< custom_flag::Declaration > &&CustomFlagDecls={})
const IncludeDirsFunc & includeDirsCallback() const
MultilibSet & setIncludeDirsCallback(IncludeDirsFunc F)
std::pair< Multilib::flags_list, SmallVector< StringRef > > processCustomFlags(const Driver &D, const Multilib::flags_list &Flags) const
Process custom flags from Flags and returns an expanded flags list and a list of macro defines.
multilib_list::const_iterator const_iterator
const_iterator begin() const
std::function< std::vector< std::string >(const Multilib &M)> IncludeDirsFunc
This corresponds to a single GCC Multilib, or a segment of one controlled by a command line flag.
const std::string & gccSuffix() const
Get the detected GCC installation path suffix for the multi-arch target variant.
const std::string & getErrorMessage() const
const std::string & osSuffix() const
Get the detected os path suffix for the multi-arch target variant.
const flags_list & flags() const
Get the flags that indicate or contraindicate this multilib's use All elements begin with either '-' ...
std::vector< std::string > flags_list
Multilib(StringRef GCCSuffix={}, StringRef OSSuffix={}, StringRef IncludeSuffix={}, const flags_list &Flags=flags_list(), StringRef ExclusiveGroup={}, std::optional< StringRef > Error=std::nullopt)
GCCSuffix, OSSuffix & IncludeSuffix will be appended directly to the sysroot string so they must eith...
const std::string & includeSuffix() const
Get the include directory suffix.
LLVM_DUMP_METHOD void dump() const
const std::string & exclusiveGroup() const
Get the exclusive group label.
void print(raw_ostream &OS) const
print summary of the Multilib
bool isDefault() const
Check whether the default is selected.
bool operator==(const Multilib &Other) const
static constexpr StringRef Prefix
raw_ostream & operator<<(raw_ostream &OS, const Multilib &M)
The JSON file list parser is used to communicate input to InstallAPI.
@ Other
Other implicit parameter.
int const char * function
Uses regular expressions to simplify flags used for multilib selection.
std::vector< std::string > Flags
SmallVector< ValueDetail > ValueList
Declaration & operator=(const Declaration &)
std::optional< size_t > DefaultValueIdx
std::optional< SmallVector< std::string > > MacroDefines