mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-19 01:46:49 +00:00
[Driver] Adjust -fsanitize=function & -mexecute-only interop after D158614
clangDriver depends on clangBasic, so clangBasic should not depend on clangDriver, even just its header. Also remove clangBasic's dependency on LLVMOption. The issue can be seen through the bazel commit d26dd681f9726ed7d43d7c0bdd8ee3cb2db69a2b which is reverted now. Add hasFlagNoClaim and use it as we don't want to suppress -Wunused-command-line-argument for -mexecute-only just because -fsanitize= is specified.
This commit is contained in:
parent
c138c8a72e
commit
051aa171d2
@ -209,11 +209,6 @@ StringRef AsanDetectStackUseAfterReturnModeToString(
|
||||
llvm::AsanDetectStackUseAfterReturnMode
|
||||
AsanDetectStackUseAfterReturnModeFromString(StringRef modeStr);
|
||||
|
||||
/// Return true if an execute-only target disallows data access to code
|
||||
/// sections.
|
||||
bool isExecuteOnlyTarget(const llvm::Triple &Triple,
|
||||
const llvm::opt::ArgList &Args);
|
||||
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_BASIC_SANITIZERS_H
|
||||
|
@ -1,5 +1,4 @@
|
||||
set(LLVM_LINK_COMPONENTS
|
||||
Option
|
||||
Support
|
||||
TargetParser
|
||||
)
|
||||
|
@ -11,13 +11,10 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Basic/Sanitizers.h"
|
||||
#include "clang/Driver/Options.h"
|
||||
#include "llvm/ADT/Hashing.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/TargetParser/Triple.h"
|
||||
|
||||
using namespace clang;
|
||||
|
||||
@ -115,14 +112,4 @@ AsanDetectStackUseAfterReturnModeFromString(StringRef modeStr) {
|
||||
.Default(llvm::AsanDetectStackUseAfterReturnMode::Invalid);
|
||||
}
|
||||
|
||||
bool isExecuteOnlyTarget(const llvm::Triple &Triple,
|
||||
const llvm::opt::ArgList &Args) {
|
||||
if (Triple.isPS5())
|
||||
return true;
|
||||
|
||||
// On Arm, the clang `-mexecute-only` option is used to generate the
|
||||
// execute-only output (no data access to code sections).
|
||||
return Args.hasFlag(clang::driver::options::OPT_mexecute_only,
|
||||
clang::driver::options::OPT_mno_execute_only, false);
|
||||
}
|
||||
} // namespace clang
|
||||
|
@ -143,6 +143,16 @@ static std::string describeSanitizeArg(const llvm::opt::Arg *A,
|
||||
/// Sanitizers set.
|
||||
static std::string toString(const clang::SanitizerSet &Sanitizers);
|
||||
|
||||
/// Return true if an execute-only target disallows data access to code
|
||||
/// sections.
|
||||
static bool isExecuteOnlyTarget(const llvm::Triple &Triple,
|
||||
const llvm::opt::ArgList &Args) {
|
||||
if (Triple.isPS5())
|
||||
return true;
|
||||
return Args.hasFlagNoClaim(options::OPT_mexecute_only,
|
||||
options::OPT_mno_execute_only, false);
|
||||
}
|
||||
|
||||
static void validateSpecialCaseListFormat(const Driver &D,
|
||||
std::vector<std::string> &SCLFiles,
|
||||
unsigned MalformedSCLErrorDiagID,
|
||||
|
@ -299,6 +299,7 @@ public:
|
||||
/// \p Default if neither option is given. If both the option and its
|
||||
/// negation are present, the last one wins.
|
||||
bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
|
||||
bool hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg, bool Default) const;
|
||||
|
||||
/// hasFlag - Given an option \p Pos, an alias \p PosAlias and its negative
|
||||
/// form \p Neg, return true if the option or its alias is present, false if
|
||||
|
@ -75,6 +75,13 @@ bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const {
|
||||
return Default;
|
||||
}
|
||||
|
||||
bool ArgList::hasFlagNoClaim(OptSpecifier Pos, OptSpecifier Neg,
|
||||
bool Default) const {
|
||||
if (Arg *A = getLastArgNoClaim(Pos, Neg))
|
||||
return A->getOption().matches(Pos);
|
||||
return Default;
|
||||
}
|
||||
|
||||
bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
|
||||
bool Default) const {
|
||||
if (Arg *A = getLastArg(Pos, PosAlias, Neg))
|
||||
|
Loading…
x
Reference in New Issue
Block a user