llvm::copy(XRaySupportedModes, std::back_inserter(Modes));
else
for (const auto &Arg : SpecifiedModes) {
- if (Arg == "none") {
- Modes.clear();
- break;
- }
- if (Arg == "all") {
- Modes.clear();
- llvm::copy(XRaySupportedModes, std::back_inserter(Modes));
- break;
- }
-
// Parse CSV values for -fxray-modes=...
llvm::SmallVector<StringRef, 2> ModeParts;
llvm::SplitString(Arg, ModeParts, ",");
for (const auto &M : ModeParts)
- Modes.push_back(M);
+ if (M == "none")
+ Modes.clear();
+ else if (M == "all")
+ llvm::copy(XRaySupportedModes, std::back_inserter(Modes));
+ else
+ Modes.push_back(M);
}
// Then we want to sort and unique the modes we've collected.
ExtraDepOpt += Dep;
CmdArgs.push_back(Args.MakeArgString(ExtraDepOpt));
}
+
+ for (const auto &Mode : Modes) {
+ SmallString<64> ModeOpt("-fxray-modes=");
+ ModeOpt += Mode;
+ CmdArgs.push_back(Args.MakeArgString(ModeOpt));
+ }
}
// RUN: 2>&1 | FileCheck --check-prefixes FDR,BASIC %s
// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none -### %s \
// RUN: 2>&1 | FileCheck --check-prefixes NONE %s
+//
+// We also should support overriding the modes in an additive manner.
+//
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none,xray-fdr \
+// RUN: -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes FDR %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=xray-fdr,none \
+// RUN: -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes NONE %s
+// RUN: %clang -v -o /dev/null -fxray-instrument -fxray-modes=none,all \
+// RUN: -### %s \
+// RUN: 2>&1 | FileCheck --check-prefixes FDR,BASIC %s
// BASIC: libclang_rt.xray-basic
// FDR: libclang_rt.xray-fdr