Skip to content

Commit c2cec8a

Browse files
committed
Revert "Reland "[Driver] Support multi /guard: options""
This reverts commit a4f366d. Found a problem during backport it to 16.x branch. https://github.com/llvm/llvm-project-release-prs/actions/runs/5036930270/jobs/9033427592?pr=451 The reason is `-implicit-check-not='warning'` may conflict with option name, e.g., `-treat-scalable-fixed-error-as-warning`
1 parent caf01f9 commit c2cec8a

File tree

3 files changed

+2
-10
lines changed

3 files changed

+2
-10
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7876,7 +7876,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
78767876
if (Args.hasArg(options::OPT__SLASH_kernel))
78777877
CmdArgs.push_back("-fms-kernel");
78787878

7879-
for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
7879+
if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
78807880
StringRef GuardArgs = A->getValue();
78817881
// The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and
78827882
// "ehcont-".
@@ -7895,7 +7895,6 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
78957895
} else {
78967896
D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << GuardArgs;
78977897
}
7898-
A->claim();
78997898
}
79007899
}
79017900

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-
for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
230+
if (Arg *A = Args.getLastArg(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: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -647,13 +647,6 @@
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 -Wall -Wno-msvc-not-found -### -- %s 2>&1 | \
651-
// RUN: FileCheck -check-prefix=BOTHGUARD %s --implicit-check-not=warning
652-
// BOTHGUARD: -cfguard
653-
// BOTHGUARD-SAME: -ehcontguard
654-
// BOTHGUARD: -guard:cf
655-
// BOTHGUARD-SAME: -guard:ehcont
656-
657650
// RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s
658651
// CFGUARDINVALID: invalid value 'foo' in '/guard:'
659652

0 commit comments

Comments
 (0)