Skip to content

Commit 3b6f7e4

Browse files
committed
[Driver] Support multi /guard: options
Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D150645
1 parent 0c4d7d1 commit 3b6f7e4

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7865,7 +7865,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
78657865
if (Args.hasArg(options::OPT__SLASH_kernel))
78667866
CmdArgs.push_back("-fms-kernel");
78677867

7868-
if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
7868+
for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
78697869
StringRef GuardArgs = A->getValue();
78707870
// The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and
78717871
// "ehcont-".

clang/lib/Driver/ToolChains/MSVC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
227227
Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
228228

229229
// Control Flow Guard checks
230-
if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
230+
for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
231231
StringRef GuardArgs = A->getValue();
232232
if (GuardArgs.equals_insensitive("cf") ||
233233
GuardArgs.equals_insensitive("cf,nochecks")) {

clang/test/Driver/cl-options.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@
647647
// RUN: %clang_cl /guard:ehcont -### -- %s 2>&1 | FileCheck -check-prefix=EHCONTGUARD %s
648648
// EHCONTGUARD: -ehcontguard
649649

650+
// RUN: %clang_cl /guard:cf /guard:ehcont -### -- %s 2>&1 | FileCheck -check-prefix=BOTHGUARD %s
651+
// BOTHGUARD: -cfguard
652+
// BOTHGUARD-SAME: -ehcontguard
653+
650654
// RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s
651655
// CFGUARDINVALID: invalid value 'foo' in '/guard:'
652656

0 commit comments

Comments
 (0)