#include "clang/Driver/SanitizerArgs.h"
#include "ToolChains/CommonArgs.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/SpecialCaseList.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
#include "llvm/TargetParser/RISCVTargetParser.h"
#include "llvm/TargetParser/TargetParser.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
#include <memory>
usingnamespaceclang;
usingnamespaceclang::driver;
usingnamespacellvm::opt;
static const SanitizerMask NeedsUbsanRt = …;
static const SanitizerMask NeedsUbsanCxxRt = …;
static const SanitizerMask NotAllowedWithTrap = …;
static const SanitizerMask NotAllowedWithMinimalRuntime = …;
static const SanitizerMask NotAllowedWithExecuteOnly = …;
static const SanitizerMask NeedsUnwindTables = …;
static const SanitizerMask SupportsCoverage = …;
static const SanitizerMask RecoverableByDefault = …;
static const SanitizerMask Unrecoverable = …;
static const SanitizerMask AlwaysRecoverable = …;
static const SanitizerMask NeedsLTO = …;
static const SanitizerMask TrappingSupported = …;
static const SanitizerMask TrappingDefault = …;
static const SanitizerMask CFIClasses = …;
static const SanitizerMask CompatibleWithMinimalRuntime = …;
enum CoverageFeature { … };
enum BinaryMetadataFeature { … };
static SanitizerMask parseArgValues(const Driver &D, const llvm::opt::Arg *A,
bool DiagnoseErrors);
static int parseCoverageFeatures(const Driver &D, const llvm::opt::Arg *A,
bool DiagnoseErrors);
static int parseOverflowPatternExclusionValues(const Driver &D,
const llvm::opt::Arg *A,
bool DiagnoseErrors);
static int parseBinaryMetadataFeatures(const Driver &D, const llvm::opt::Arg *A,
bool DiagnoseErrors);
static std::string lastArgumentForMask(const Driver &D,
const llvm::opt::ArgList &Args,
SanitizerMask Mask);
static std::string describeSanitizeArg(const llvm::opt::Arg *A,
SanitizerMask Mask);
static std::string toString(const clang::SanitizerSet &Sanitizers);
static bool isExecuteOnlyTarget(const llvm::Triple &Triple,
const llvm::opt::ArgList &Args) { … }
static void validateSpecialCaseListFormat(const Driver &D,
std::vector<std::string> &SCLFiles,
unsigned MalformedSCLErrorDiagID,
bool DiagnoseErrors) { … }
static void addDefaultIgnorelists(const Driver &D, SanitizerMask Kinds,
std::vector<std::string> &IgnorelistFiles,
bool DiagnoseErrors) { … }
static void parseSpecialCaseListArg(const Driver &D,
const llvm::opt::ArgList &Args,
std::vector<std::string> &SCLFiles,
llvm::opt::OptSpecifier SCLOptionID,
llvm::opt::OptSpecifier NoSCLOptionID,
unsigned MalformedSCLErrorDiagID,
bool DiagnoseErrors) { … }
static SanitizerMask setGroupBits(SanitizerMask Kinds) { … }
static SanitizerMask parseSanitizeTrapArgs(const Driver &D,
const llvm::opt::ArgList &Args,
bool DiagnoseErrors) { … }
bool SanitizerArgs::needsFuzzerInterceptors() const { … }
bool SanitizerArgs::needsUbsanRt() const { … }
bool SanitizerArgs::needsCfiRt() const { … }
bool SanitizerArgs::needsCfiDiagRt() const { … }
bool SanitizerArgs::requiresPIE() const { … }
bool SanitizerArgs::needsUnwindTables() const { … }
bool SanitizerArgs::needsLTO() const { … }
SanitizerArgs::SanitizerArgs(const ToolChain &TC,
const llvm::opt::ArgList &Args,
bool DiagnoseErrors) { … }
static std::string toString(const clang::SanitizerSet &Sanitizers) { … }
static void addSpecialCaseListOpt(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
const char *SCLOptFlag,
const std::vector<std::string> &SCLFiles) { … }
static void addIncludeLinkerOption(const ToolChain &TC,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
StringRef SymbolName) { … }
static bool hasTargetFeatureMTE(const llvm::opt::ArgStringList &CmdArgs) { … }
void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
types::ID InputType) const { … }
SanitizerMask parseArgValues(const Driver &D, const llvm::opt::Arg *A,
bool DiagnoseErrors) { … }
static int parseOverflowPatternExclusionValues(const Driver &D,
const llvm::opt::Arg *A,
bool DiagnoseErrors) { … }
int parseCoverageFeatures(const Driver &D, const llvm::opt::Arg *A,
bool DiagnoseErrors) { … }
int parseBinaryMetadataFeatures(const Driver &D, const llvm::opt::Arg *A,
bool DiagnoseErrors) { … }
std::string lastArgumentForMask(const Driver &D, const llvm::opt::ArgList &Args,
SanitizerMask Mask) { … }
std::string describeSanitizeArg(const llvm::opt::Arg *A, SanitizerMask Mask) { … }