Skip to content

Commit

Permalink
[clang][driver] Enable MisExpect diagnostics flag outside of CC1
Browse files Browse the repository at this point in the history
Previously we only accepted the `-fdiagnostics-misexpect-tolerance=` at
CC1, when it should have been handled identically to
`-fdiagnostics-hotness-threshold=`. It should not have been required to
pass this flag w/ `-Xclang` as reported here:
https://reviews.llvm.org/D115907#inline-1440745

Reviewed By: hans, phosek

Differential Revision: https://reviews.llvm.org/D149206
  • Loading branch information
ilovepi committed Apr 27, 2023
1 parent 012ea74 commit 61976af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Expand Up @@ -4033,6 +4033,13 @@ static void RenderDiagnosticsOptions(const Driver &D, const ArgList &Args,
CmdArgs.push_back(Args.MakeArgString(Opt));
}

if (const Arg *A =
Args.getLastArg(options::OPT_fdiagnostics_misexpect_tolerance_EQ)) {
std::string Opt =
std::string("-fdiagnostics-misexpect-tolerance=") + A->getValue();
CmdArgs.push_back(Args.MakeArgString(Opt));
}

if (const Arg *A = Args.getLastArg(options::OPT_fdiagnostics_format_EQ)) {
CmdArgs.push_back("-fdiagnostics-format");
CmdArgs.push_back(A->getValue());
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Driver/clang_f_opts.c
Expand Up @@ -140,6 +140,10 @@
// CHECK-PROFILE-USE-DIR: "-fprofile-instrument-use-path={{.*}}.d/some/dir{{/|\\\\}}default.profdata"
// CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof"

// RUN: %clang -### -S -fprofile-instr-use=%t.profdata -fdiagnostics-misexpect-tolerance=10 -Wmisexpect %s 2>&1 | FileCheck %s --check-prefix=CHECK-MISEXPECT-TOLLERANCE
// CHECK-MISEXPECT-TOLLERANCE: "-fdiagnostics-misexpect-tolerance=10"
// CHECK-MISEXPECT-TOLLERANCE-NOT: argument unused

// RUN: %clang -### -S -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
// RUN: %clang -### -S -fno-vectorize -fvectorize %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
// RUN: %clang -### -S -fno-vectorize %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE %s
Expand Down

0 comments on commit 61976af

Please sign in to comment.