clang 20.0.0git
|
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/ToolChain.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>
#include "clang/Basic/Sanitizers.def"
Go to the source code of this file.
Macros | |
#define | SANITIZER(NAME, ID) |
#define | SANITIZER_GROUP(NAME, ID, ALIAS) |
#define | SANITIZER(NAME, ID) |
Enumerations | |
enum | CoverageFeature { CoverageFunc = 1 << 0 , CoverageBB = 1 << 1 , CoverageEdge = 1 << 2 , CoverageIndirCall = 1 << 3 , CoverageTraceBB = 1 << 4 , CoverageTraceCmp = 1 << 5 , CoverageTraceDiv = 1 << 6 , CoverageTraceGep = 1 << 7 , Coverage8bitCounters = 1 << 8 , CoverageTracePC = 1 << 9 , CoverageTracePCGuard = 1 << 10 , CoverageNoPrune = 1 << 11 , CoverageInline8bitCounters = 1 << 12 , CoveragePCTable = 1 << 13 , CoverageStackDepth = 1 << 14 , CoverageInlineBoolFlag = 1 << 15 , CoverageTraceLoads = 1 << 16 , CoverageTraceStores = 1 << 17 , CoverageControlFlow = 1 << 18 } |
enum | BinaryMetadataFeature { BinaryMetadataCovered = 1 << 0 , BinaryMetadataAtomics = 1 << 1 , BinaryMetadataUAR = 1 << 2 } |
Functions | |
static SanitizerMask | parseArgValues (const Driver &D, const llvm::opt::Arg *A, bool DiagnoseErrors) |
Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any invalid components. | |
static int | parseCoverageFeatures (const Driver &D, const llvm::opt::Arg *A, bool DiagnoseErrors) |
Parse -f(no-)?sanitize-coverage= flag values, diagnosing any invalid components. | |
static int | parseOverflowPatternExclusionValues (const Driver &D, const llvm::opt::Arg *A, bool DiagnoseErrors) |
Parse -fsanitize-undefined-ignore-overflow-pattern= flag values, diagnosing any invalid values. | |
static int | parseBinaryMetadataFeatures (const Driver &D, const llvm::opt::Arg *A, bool DiagnoseErrors) |
Parse -f(no-)?sanitize-metadata= flag values, diagnosing any invalid components. | |
static std::string | lastArgumentForMask (const Driver &D, const llvm::opt::ArgList &Args, SanitizerMask Mask) |
Produce an argument string from ArgList Args , which shows how it provides some sanitizer kind from Mask . | |
static std::string | describeSanitizeArg (const llvm::opt::Arg *A, SanitizerMask Mask) |
Produce an argument string from argument A , which shows how it provides a value in Mask . | |
static std::string | toString (const clang::SanitizerSet &Sanitizers) |
Produce a string containing comma-separated names of sanitizers in Sanitizers set. | |
static bool | isExecuteOnlyTarget (const llvm::Triple &Triple, const llvm::opt::ArgList &Args) |
Return true if an execute-only target disallows data access to code sections. | |
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) |
Parse -f(no-)?sanitize-(coverage-)?(allow|ignore)list argument's values, diagnosing any invalid file paths and validating special case list format. | |
static SanitizerMask | setGroupBits (SanitizerMask Kinds) |
Sets group bits for every group that has at least one representative already enabled in Kinds . | |
static SanitizerMask | parseSanitizeArgs (const Driver &D, const llvm::opt::ArgList &Args, bool DiagnoseErrors, SanitizerMask Default, SanitizerMask AlwaysIn, SanitizerMask AlwaysOut, int OptInID, int OptOutID) |
static SanitizerMask | parseSanitizeTrapArgs (const Driver &D, const llvm::opt::ArgList &Args, bool DiagnoseErrors) |
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) |
Variables | |
static const SanitizerMask | NeedsUbsanRt |
static const SanitizerMask | NeedsUbsanCxxRt |
static const SanitizerMask | NotAllowedWithTrap = SanitizerKind::Vptr |
static const SanitizerMask | NotAllowedWithMinimalRuntime = SanitizerKind::Vptr |
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 = SanitizerKind::CFI |
static const SanitizerMask | TrappingSupported |
static const SanitizerMask | MergeDefault = SanitizerKind::Undefined |
static const SanitizerMask | TrappingDefault |
static const SanitizerMask | CFIClasses |
static const SanitizerMask | CompatibleWithMinimalRuntime |
#define SANITIZER | ( | NAME, | |
ID | |||
) |
#define SANITIZER | ( | NAME, | |
ID | |||
) |
Enumerator | |
---|---|
BinaryMetadataCovered | |
BinaryMetadataAtomics | |
BinaryMetadataUAR |
Definition at line 105 of file SanitizerArgs.cpp.
enum CoverageFeature |
Definition at line 83 of file SanitizerArgs.cpp.
|
static |
Definition at line 175 of file SanitizerArgs.cpp.
References D, clang::File, Path, and validateSpecialCaseListFormat().
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 1160 of file SanitizerArgs.cpp.
References clang::driver::ToolChain::getTriple().
Referenced by clang::driver::SanitizerArgs::addArgs().
|
static |
Definition at line 1149 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::addArgs().
|
static |
Produce an argument string from argument A
, which shows how it provides a value in Mask
.
For instance, the argument "-fsanitize=address,alignment" with mask NeedsUbsanRt
would produce "-fsanitize=alignment".
Definition at line 1601 of file SanitizerArgs.cpp.
References clang::expandSanitizerGroups(), and clang::parseSanitizerValue().
Referenced by lastArgumentForMask(), and clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 1174 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::addArgs().
|
static |
Return true if an execute-only target disallows data access to code sections.
Definition at line 153 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Produce an argument string from ArgList Args
, which shows how it provides some sanitizer kind from Mask
.
For example, the argument list "-fsanitize=thread,vptr -fsanitize=address" with mask NeedsUbsanRt
would produce "-fsanitize=vptr".
Definition at line 1581 of file SanitizerArgs.cpp.
References D, describeSanitizeArg(), E, clang::expandSanitizerGroups(), and parseArgValues().
Referenced by clang::driver::SanitizerArgs::addArgs(), and clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Parse a -fsanitize= or -fno-sanitize= argument's values, diagnosing any invalid components.
Returns a SanitizerMask.
Definition at line 1465 of file SanitizerArgs.cpp.
References D, and clang::parseSanitizerValue().
Referenced by lastArgumentForMask(), parseSanitizeArgs(), and clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Parse -f(no-)?sanitize-metadata= flag values, diagnosing any invalid components.
Returns OR of members of BinaryMetadataFeature
enumeration.
Definition at line 1558 of file SanitizerArgs.cpp.
References BinaryMetadataAtomics, BinaryMetadataCovered, BinaryMetadataUAR, and D.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Parse -f(no-)?sanitize-coverage= flag values, diagnosing any invalid components.
Returns OR of members of CoverageFeature
enumeration.
Definition at line 1522 of file SanitizerArgs.cpp.
References Coverage8bitCounters, CoverageBB, CoverageControlFlow, CoverageEdge, CoverageFunc, CoverageIndirCall, CoverageInline8bitCounters, CoverageInlineBoolFlag, CoverageNoPrune, CoveragePCTable, CoverageStackDepth, CoverageTraceBB, CoverageTraceCmp, CoverageTraceDiv, CoverageTraceGep, CoverageTraceLoads, CoverageTracePC, CoverageTracePCGuard, CoverageTraceStores, and D.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Parse -fsanitize-undefined-ignore-overflow-pattern= flag values, diagnosing any invalid values.
Returns a mask of excluded overflow patterns.
Definition at line 1497 of file SanitizerArgs.cpp.
References clang::LangOptionsBase::AddSignedOverflowTest, clang::LangOptionsBase::AddUnsignedOverflowTest, clang::LangOptionsBase::All, D, E, clang::LangOptionsBase::NegUnsignedConst, clang::LangOptionsBase::None, and clang::LangOptionsBase::PostDecrInWhile.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 260 of file SanitizerArgs.cpp.
References D, clang::Default, clang::expandSanitizerGroups(), clang::SanitizerSet::Mask, parseArgValues(), and toString().
Referenced by parseSanitizeTrapArgs(), and clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 311 of file SanitizerArgs.cpp.
References D, parseSanitizeArgs(), setGroupBits(), TrappingDefault, and TrappingSupported.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Parse -f(no-)?sanitize-(coverage-)?(allow|ignore)list argument's values, diagnosing any invalid file paths and validating special case list format.
Definition at line 215 of file SanitizerArgs.cpp.
References D, and validateSpecialCaseListFormat().
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Sets group bits for every group that has at least one representative already enabled in Kinds
.
Definition at line 244 of file SanitizerArgs.cpp.
Referenced by parseSanitizeTrapArgs(), and clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Produce a string containing comma-separated names of sanitizers in Sanitizers
set.
Definition at line 1137 of file SanitizerArgs.cpp.
Referenced by clang::SemaOpenACC::ActOnArraySectionExpr(), clang::Sema::ActOnDesignatedInitializer(), clang::Sema::ActOnFinishSwitchStmt(), clang::Sema::ActOnGCCAsmStmt(), clang::SemaOpenMP::ActOnOMPArraySectionExpr(), clang::SemaOpenMP::ActOnOMPArrayShapingExpr(), clang::SemaOpenMP::ActOnOpenMPCriticalDirective(), clang::Sema::ActOnPragmaClangSection(), clang::driver::SanitizerArgs::addArgs(), clang::interp::AddSubMulHelper(), clang::format::JavaScriptImportSorter::analyze(), AnalyzeBitFieldAssignment(), clang::ast_matchers::AST_MATCHER_P(), clang::Sema::BuildArrayType(), clang::Sema::BuildCXXNew(), BuiltinAlignment(), clang::Sema::BuiltinConstantArgRange(), CheckArrayDesignatorExpr(), checkCaseValue(), checkCodeSegName(), CheckedIntArithmetic(), clang::Sema::CheckEnumConstant(), CheckForDuplicateEnumValues(), clang::Sema::CheckImplicitConversion(), clang::Sema::CheckLoopHintExpr(), checkPositiveIntArgument(), clang::Sema::checkSectionName(), checkSimpleDecomposition(), clang::Sema::CheckTemplateArgument(), checkTupleLikeDecomposition(), clang::Sema::CheckTypedefForVariablyModifiedType(), clang::Sema::checkUInt32Argument(), DefineTypeSize(), diagnoseWellFormedUnsatisfiedConstraintExpr(), diagnoseXorMisusedAsPow(), DiagTemplateArg(), clang::ento::Range::dump(), clang::ento::CheckerInfo::dumpToStream(), EvaluateDirectiveSubExpr(), getModuleContextHash(), clang::CompilerInvocation::getModuleHash(), clang::threadSafety::getSourceLiteralString(), clang::tooling::RefactoringASTConsumer::HandleTranslationUnit(), clang::interp::IncDecHelper(), IsStructurallyEquivalent(), clang::Preprocessor::LexEmbedParameters(), makeLaunchBoundsArgExpr(), clang::interp::Neg(), clang::operator<<(), parseSanitizeArgs(), PrettyPrintInRange(), clang::format::internal::reformat(), clang::ento::CheckerManager::runCheckersForEvalCall(), clang::driver::SanitizerArgs::SanitizerArgs(), clang::format::sortCppIncludes(), clang::format::sortJavaImports(), toString(), clang::Sema::tryToFixVariablyModifiedVarType(), clang::Sema::VerifyBitField(), clang::TextNodeDumper::VisitIntegerLiteral(), clang::Interpreter::~Interpreter(), and clang::SavedStreamPosition::~SavedStreamPosition().
|
static |
Definition at line 161 of file SanitizerArgs.cpp.
References D.
Referenced by addDefaultIgnorelists(), and parseSpecialCaseListArg().
|
static |
Definition at line 62 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 74 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::addArgs().
|
static |
Definition at line 78 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 71 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 65 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::needsLTO(), and clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 33 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::needsUbsanCXXRt(), and clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 28 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::needsUbsanRt().
|
static |
Definition at line 39 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::needsUnwindTables().
|
static |
Definition at line 37 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 36 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 35 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 56 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 43 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().
|
static |
Definition at line 72 of file SanitizerArgs.cpp.
Referenced by parseSanitizeTrapArgs().
|
static |
Definition at line 66 of file SanitizerArgs.cpp.
Referenced by parseSanitizeTrapArgs().
|
static |
Definition at line 60 of file SanitizerArgs.cpp.
Referenced by clang::driver::SanitizerArgs::SanitizerArgs().