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.
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
set(LLVM_LINK_COMPONENTS
- Option
Support
TargetParser
)
//===----------------------------------------------------------------------===//
#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;
.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
/// 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,
/// \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
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))