Skip to content

Commit d0d076f

Browse files
committed
[Driver] Flip the CC1 default of -fdiagnostics-show-option
The driver enables -fdiagnostics-show-option by default, so flip the CC1 default to reduce the lengths of common CC1 command lines. This change also makes ParseDiagnosticArgs() consistently enable -fdiagnostics-show-option by default.
1 parent b576701 commit d0d076f

File tree

14 files changed

+35
-39
lines changed

14 files changed

+35
-39
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ def fdiagnostics_hotness_threshold_EQ : Joined<["-"], "fdiagnostics-hotness-thre
899899
Group<f_Group>, Flags<[CC1Option]>, MetaVarName<"<number>">,
900900
HelpText<"Prevent optimization remarks from being output if they do not have at least this profile count">;
901901
def fdiagnostics_show_option : Flag<["-"], "fdiagnostics-show-option">, Group<f_Group>,
902-
Flags<[CC1Option]>, HelpText<"Print option name with mappable diagnostics">;
902+
HelpText<"Print option name with mappable diagnostics">;
903903
def fdiagnostics_show_note_include_stack : Flag<["-"], "fdiagnostics-show-note-include-stack">,
904904
Group<f_Group>, Flags<[CC1Option]>, HelpText<"Display include stacks for diagnostic notes">;
905905
def fdiagnostics_format_EQ : Joined<["-"], "fdiagnostics-format=">, Group<f_clang_Group>;
@@ -1515,7 +1515,7 @@ def fno_cxx_modules : Flag <["-"], "fno-cxx-modules">, Group<f_Group>,
15151515
def fno_diagnostics_fixit_info : Flag<["-"], "fno-diagnostics-fixit-info">, Group<f_Group>,
15161516
Flags<[CC1Option]>, HelpText<"Do not include fixit information in diagnostics">;
15171517
def fno_diagnostics_show_hotness : Flag<["-"], "fno-diagnostics-show-hotness">, Group<f_Group>;
1518-
def fno_diagnostics_show_option : Flag<["-"], "fno-diagnostics-show-option">, Group<f_Group>;
1518+
def fno_diagnostics_show_option : Flag<["-"], "fno-diagnostics-show-option">, Group<f_Group>, Flags<[CC1Option]>;
15191519
def fno_diagnostics_show_note_include_stack : Flag<["-"], "fno-diagnostics-show-note-include-stack">,
15201520
Flags<[CC1Option]>, Group<f_Group>;
15211521
def fdigraphs : Flag<["-"], "fdigraphs">, Group<f_Group>, Flags<[CC1Option]>,

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ class TargetOptions;
5959
/// report the error(s).
6060
bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
6161
DiagnosticsEngine *Diags = nullptr,
62-
bool DefaultDiagColor = true,
63-
bool DefaultShowOpt = true);
62+
bool DefaultDiagColor = true);
6463

6564
class CompilerInvocationBase {
6665
public:

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3559,9 +3559,9 @@ static void RenderDiagnosticsOptions(const Driver &D, const ArgList &Args,
35593559
CmdArgs.push_back("-fno-diagnostics-fixit-info");
35603560

35613561
// Enable -fdiagnostics-show-option by default.
3562-
if (Args.hasFlag(options::OPT_fdiagnostics_show_option,
3563-
options::OPT_fno_diagnostics_show_option))
3564-
CmdArgs.push_back("-fdiagnostics-show-option");
3562+
if (!Args.hasFlag(options::OPT_fdiagnostics_show_option,
3563+
options::OPT_fno_diagnostics_show_option, true))
3564+
CmdArgs.push_back("-fno-diagnostics-show-option");
35653565

35663566
if (const Arg *A =
35673567
Args.getLastArg(options::OPT_fdiagnostics_show_category_EQ)) {

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ static bool checkVerifyPrefixes(const std::vector<std::string> &VerifyPrefixes,
15471547

15481548
bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
15491549
DiagnosticsEngine *Diags,
1550-
bool DefaultDiagColor, bool DefaultShowOpt) {
1550+
bool DefaultDiagColor) {
15511551
bool Success = true;
15521552

15531553
Opts.DiagnosticLogFile =
@@ -1565,9 +1565,7 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
15651565
Opts.ShowFixits = !Args.hasArg(OPT_fno_diagnostics_fixit_info);
15661566
Opts.ShowLocation = !Args.hasArg(OPT_fno_show_source_location);
15671567
Opts.AbsolutePath = Args.hasArg(OPT_fdiagnostics_absolute_paths);
1568-
Opts.ShowOptionNames =
1569-
Args.hasFlag(OPT_fdiagnostics_show_option,
1570-
OPT_fno_diagnostics_show_option, DefaultShowOpt);
1568+
Opts.ShowOptionNames = !Args.hasArg(OPT_fno_diagnostics_show_option);
15711569

15721570
llvm::sys::Process::UseANSIEscapeCodes(Args.hasArg(OPT_fansi_escape_codes));
15731571

@@ -3597,9 +3595,8 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
35973595
Diags.Report(diag::err_fe_dependency_file_requires_MT);
35983596
Success = false;
35993597
}
3600-
Success &=
3601-
ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
3602-
false /*DefaultDiagColor*/, false /*DefaultShowOpt*/);
3598+
Success &= ParseDiagnosticArgs(Res.getDiagnosticOpts(), Args, &Diags,
3599+
/*DefaultDiagColor=*/false);
36033600
ParseCommentArgs(LangOpts.CommentOpts, Args);
36043601
ParseFileSystemArgs(Res.getFileSystemOpts(), Args);
36053602
// FIXME: We shouldn't have to pass the DashX option around here

clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fdiagnostics-show-option -verify %s
1+
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
22

33
template<typename T>
44
struct set{};

clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s
2-
// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++98 %s
3-
// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++11 %s
1+
// RUN: %clang_cc1 -fsyntax-only -verify %s
2+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3+
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
44

55
// C++98 [basic.lookup.classref]p1:
66
// In a class member access expression (5.2.5), if the . or -> token is

clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsyntax-only -std=c++03 -fdiagnostics-show-option -Wbind-to-temporary-copy -verify %s
1+
// RUN: %clang_cc1 -fsyntax-only -std=c++03 -Wbind-to-temporary-copy -verify %s
22

33
// C++03 requires that we check for a copy constructor when binding a
44
// reference to a temporary, since we are allowed to make a copy, Even
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/// -fdiagnostics-show-option is the default
2+
// RUN: %clang -### -c %s 2>&1 | FileCheck --check-prefix=ENABLED %s
3+
// ENABLED-NOT: "-fno-diagnostics-show-option"
4+
5+
// RUN: %clang -### -c %s -fdiagnostics-show-option -fno-diagnostics-show-option 2>&1 | \
6+
// RUN: FileCheck --check-prefix=DISABLED %s
7+
// DISABLED: "-fno-diagnostics-show-option"

clang/test/Driver/rewrite-legacy-objc.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// TEST0: clang{{.*}}" "-cc1"
44
// TEST0: "-rewrite-objc"
55
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
6-
// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
6+
// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"
77
// TEST0: rewrite-legacy-objc.m"
88
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.9.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
99
// RUN: FileCheck -check-prefix=TEST1 %s
1010
// RUN: %clang -no-canonical-prefixes -target i386-apple-macosx10.6.0 -rewrite-legacy-objc %s -o - -### 2>&1 | \
1111
// RUN: FileCheck -check-prefix=TEST2 %s
12-
// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
13-
// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
12+
// TEST1: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"
13+
// TEST2: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx-fragile" "-fobjc-subscripting-legacy-runtime" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fmax-type-align=16"

clang/test/Driver/rewrite-objc.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
// TEST0: clang{{.*}}" "-cc1"
44
// TEST0: "-rewrite-objc"
55
// FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead.
6-
// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16" "-fdiagnostics-show-option"
6+
// TEST0: "-stack-protector" "1" "-fblocks" "-fencode-extended-block-signature" "-fregister-global-dtors-with-atexit" "-fgnuc-version=4.2.1" "-fobjc-runtime=macosx" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fmax-type-align=16"

0 commit comments

Comments
 (0)