Index: clang/lib/Driver/XRayArgs.cpp =================================================================== --- clang/lib/Driver/XRayArgs.cpp +++ clang/lib/Driver/XRayArgs.cpp @@ -146,21 +146,16 @@ 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 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. @@ -205,4 +200,10 @@ 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)); + } } Index: clang/test/Driver/XRay/xray-mode-flags.cpp =================================================================== --- clang/test/Driver/XRay/xray-mode-flags.cpp +++ clang/test/Driver/XRay/xray-mode-flags.cpp @@ -14,6 +14,18 @@ // 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