[Driver] Clean up some Separate form options

Drop the `Separate` form of `-fmodule-name X`, `-fprofile-remapping-file X`, and `-frewrite-map-file X`.
To the best of my knowledge they are not used. Their conventional Joined forms (`-fFOO=`) should be used instead.

`-fdebug-compilation-dir X` is used in several places, e.g.  chromium/infra/goma.
It is also advertised in http://blog.llvm.org/2019/11/deterministic-builds-with-clang-and-lld.html
So we keep it but make the EQ form canonical and the Separate form an alias.

Differential Revision: https://reviews.llvm.org/D96886
This commit is contained in:
Fangrui Song 2021-02-17 13:49:41 -08:00
parent cf1ddae7e3
commit 0c2bb6b446
11 changed files with 30 additions and 59 deletions

View File

@ -1096,13 +1096,13 @@ def fauto_profile_accurate : Flag<["-"], "fauto-profile-accurate">,
Group<f_Group>, Alias<fprofile_sample_accurate>; Group<f_Group>, Alias<fprofile_sample_accurate>;
def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">, def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">,
Group<f_Group>, Alias<fno_profile_sample_accurate>; Group<f_Group>, Alias<fno_profile_sample_accurate>;
def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
HelpText<"The compilation directory to embed in the debug info.">,
MarshallingInfoString<CodeGenOpts<"DebugCompilationDir">>;
def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">, def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">,
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>, Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
Alias<fdebug_compilation_dir>; HelpText<"The compilation directory to embed in the debug info">,
MarshallingInfoString<CodeGenOpts<"DebugCompilationDir">>;
def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
Alias<fdebug_compilation_dir_EQ>;
defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling", defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling",
CodeGenOpts<"DebugInfoForProfiling">, DefaultFalse, CodeGenOpts<"DebugInfoForProfiling">, DefaultFalse,
PosFlag<SetTrue, [CC1Option], "Emit extra debug info to make sample profile more accurate">, PosFlag<SetTrue, [CC1Option], "Emit extra debug info to make sample profile more accurate">,
@ -1122,8 +1122,6 @@ def fprofile_remapping_file_EQ : Joined<["-"], "fprofile-remapping-file=">,
Group<f_Group>, Flags<[CC1Option, CoreOption]>, MetaVarName<"<file>">, Group<f_Group>, Flags<[CC1Option, CoreOption]>, MetaVarName<"<file>">,
HelpText<"Use the remappings described in <file> to match the profile data against names in the program">, HelpText<"Use the remappings described in <file> to match the profile data against names in the program">,
MarshallingInfoString<CodeGenOpts<"ProfileRemappingFile">>; MarshallingInfoString<CodeGenOpts<"ProfileRemappingFile">>;
def fprofile_remapping_file : Separate<["-"], "fprofile-remapping-file">,
Group<f_Group>, Flags<[CoreOption]>, Alias<fprofile_remapping_file_EQ>;
defm coverage_mapping : BoolFOption<"coverage-mapping", defm coverage_mapping : BoolFOption<"coverage-mapping",
CodeGenOpts<"CoverageMapping">, DefaultFalse, CodeGenOpts<"CoverageMapping">, DefaultFalse,
PosFlag<SetTrue, [CC1Option], "Generate coverage mapping to enable code coverage analysis">, PosFlag<SetTrue, [CC1Option], "Generate coverage mapping to enable code coverage analysis">,
@ -1654,13 +1652,10 @@ defm delete_null_pointer_checks : BoolFOption<"delete-null-pointer-checks",
PosFlag<SetFalse, [], "Treat usage of null pointers as undefined behavior (default)">, PosFlag<SetFalse, [], "Treat usage of null pointers as undefined behavior (default)">,
BothFlags<[CoreOption]>>; BothFlags<[CoreOption]>>;
def frewrite_map_file : Separate<["-"], "frewrite-map-file">,
Group<f_Group>,
Flags<[ NoXarchOption, CC1Option ]>,
MarshallingInfoStringVector<CodeGenOpts<"RewriteMapFiles">>;
def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">, def frewrite_map_file_EQ : Joined<["-"], "frewrite-map-file=">,
Group<f_Group>, Group<f_Group>,
Flags<[NoXarchOption]>; Flags<[NoXarchOption, CC1Option]>,
MarshallingInfoStringVector<CodeGenOpts<"RewriteMapFiles">>;
defm use_line_directives : BoolFOption<"use-line-directives", defm use_line_directives : BoolFOption<"use-line-directives",
PreprocessorOutputOpts<"UseLineDirectives">, DefaultFalse, PreprocessorOutputOpts<"UseLineDirectives">, DefaultFalse,
@ -1984,7 +1979,6 @@ def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group<f_Group>,
Flags<[NoXarchOption,CC1Option]>, MetaVarName<"<name>">, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"<name>">,
HelpText<"Specify the name of the module to build">, HelpText<"Specify the name of the module to build">,
MarshallingInfoString<LangOpts<"ModuleName">>; MarshallingInfoString<LangOpts<"ModuleName">>;
def fmodule_name : Separate<["-"], "fmodule-name">, Alias<fmodule_name_EQ>;
def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">, def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,
Flags<[CC1Option]>, Alias<fmodule_name_EQ>; Flags<[CC1Option]>, Alias<fmodule_name_EQ>;
def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>, def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>,

View File

@ -1484,8 +1484,7 @@ void Driver::generateCompilationDiagnostics(
} }
} }
for (const auto &A : C.getArgs().filtered(options::OPT_frewrite_map_file, for (const auto &A : C.getArgs().filtered(options::OPT_frewrite_map_file_EQ))
options::OPT_frewrite_map_file_EQ))
Diag(clang::diag::note_drv_command_failed_diag_msg) << A->getValue(); Diag(clang::diag::note_drv_command_failed_diag_msg) << A->getValue();
Diag(clang::diag::note_drv_command_failed_diag_msg) Diag(clang::diag::note_drv_command_failed_diag_msg)

View File

@ -617,13 +617,11 @@ getFramePointerKind(const ArgList &Args, const llvm::Triple &Triple) {
/// Add a CC1 option to specify the debug compilation directory. /// Add a CC1 option to specify the debug compilation directory.
static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs, static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs,
const llvm::vfs::FileSystem &VFS) { const llvm::vfs::FileSystem &VFS) {
if (Arg *A = Args.getLastArg(options::OPT_fdebug_compilation_dir)) { if (Arg *A = Args.getLastArg(options::OPT_fdebug_compilation_dir_EQ)) {
CmdArgs.push_back("-fdebug-compilation-dir"); A->render(Args, CmdArgs);
CmdArgs.push_back(A->getValue());
} else if (llvm::ErrorOr<std::string> CWD = } else if (llvm::ErrorOr<std::string> CWD =
VFS.getCurrentWorkingDirectory()) { VFS.getCurrentWorkingDirectory()) {
CmdArgs.push_back("-fdebug-compilation-dir"); CmdArgs.push_back(Args.MakeArgString("-fdebug-compilation-dir=" + *CWD));
CmdArgs.push_back(Args.MakeArgString(*CWD));
} }
} }
@ -4674,18 +4672,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// LLVM Code Generator Options. // LLVM Code Generator Options.
if (Args.hasArg(options::OPT_frewrite_map_file) || for (const Arg *A : Args.filtered(options::OPT_frewrite_map_file_EQ)) {
Args.hasArg(options::OPT_frewrite_map_file_EQ)) { StringRef Map = A->getValue();
for (const Arg *A : Args.filtered(options::OPT_frewrite_map_file, if (!llvm::sys::fs::exists(Map)) {
options::OPT_frewrite_map_file_EQ)) { D.Diag(diag::err_drv_no_such_file) << Map;
StringRef Map = A->getValue(); } else {
if (!llvm::sys::fs::exists(Map)) { A->render(Args, CmdArgs);
D.Diag(diag::err_drv_no_such_file) << Map; A->claim();
} else {
CmdArgs.push_back("-frewrite-map-file");
CmdArgs.push_back(A->getValue());
A->claim();
}
} }
} }

View File

@ -1011,7 +1011,7 @@ const char *tools::SplitDebugName(const JobAction &JA, const ArgList &Args,
} else { } else {
// Use the compilation dir. // Use the compilation dir.
SmallString<128> T( SmallString<128> T(
Args.getLastArgValue(options::OPT_fdebug_compilation_dir)); Args.getLastArgValue(options::OPT_fdebug_compilation_dir_EQ));
SmallString<128> F(llvm::sys::path::stem(Input.getBaseInput())); SmallString<128> F(llvm::sys::path::stem(Input.getBaseInput()));
AddPostfix(F); AddPostfix(F);
T += F; T += F;

View File

@ -99,7 +99,7 @@
// RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s // RUN: %clang -### -S -fcoverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-COVERAGE-AND-GEN %s
// RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s // RUN: %clang -### -S -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
// RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping -fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE %s
// RUN: %clang -### -S -fprofile-remapping-file foo/bar.txt %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-REMAP %s // RUN: %clang -### -S -fprofile-remapping-file=foo/bar.txt %s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-REMAP %s
// RUN: %clang -### -S -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR %s // RUN: %clang -### -S -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR %s
// RUN: %clang -### -flto -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR-LTO %s // RUN: %clang -### -flto -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR-LTO %s
// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang" // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
@ -504,7 +504,7 @@
// RUN: %clang -### -S -fdebug-compilation-dir=. %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -S -fdebug-compilation-dir=. %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
// RUN: %clang -### -fdebug-compilation-dir . -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -fdebug-compilation-dir . -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
// RUN: %clang -### -fdebug-compilation-dir=. -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s // RUN: %clang -### -fdebug-compilation-dir=. -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
// CHECK-DEBUG-COMPILATION-DIR: "-fdebug-compilation-dir" "." // CHECK-DEBUG-COMPILATION-DIR: "-fdebug-compilation-dir=."
// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s // RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s
// RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISCARD-NAMES %s // RUN: %clang -### -S -fno-discard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISCARD-NAMES %s

View File

@ -1,2 +1,3 @@
// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s // RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}} // RUN: cd %S && %clang -x c -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
// CHECK-PWD: "-fdebug-compilation-dir={{.*Driver.*}}"

View File

@ -1,2 +0,0 @@
// RUN: cd %S && %clang -### -g %s -c 2>&1 | FileCheck -check-prefix=CHECK-PWD %s
// CHECK-PWD: {{"-fdebug-compilation-dir" ".*Driver.*"}}

View File

@ -1,2 +1,2 @@
// RUN: %clang -### -frewrite-map-file %t.map -c %s -o /dev/null 2>&1 | FileCheck %s // RUN: %clang -### -frewrite-map-file=%t.map -c %s -o /dev/null 2>&1 | FileCheck %s
// CHECK: error: no such file or directory: // CHECK: error: no such file or directory:

View File

@ -1,7 +1,7 @@
// RUN: rm -rf "%t" // RUN: rm -rf "%t"
// RUN: mkdir -p "%t" // RUN: mkdir -p "%t"
// RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTION=1 \ // RUN: env TMPDIR="%t" TEMP="%t" TMP="%t" RC_DEBUG_OPTION=1 \
// RUN: not %clang -fsyntax-only -frewrite-map-file %p/Inputs/rewrite.map %s 2>&1 \ // RUN: not %clang -fsyntax-only -frewrite-map-file=%p/Inputs/rewrite.map %s 2>&1 \
// RUN: | FileCheck %s // RUN: | FileCheck %s
#pragma clang __debug parser_crash #pragma clang __debug parser_crash

View File

@ -1,21 +1,7 @@
// RUN: %clang -frewrite-map-file %S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE // RUN: %clang -frewrite-map-file=%S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE
// CHECK-SINGLE: "-frewrite-map-file" "{{.*[\\/]}}rewrite.map" // CHECK-SINGLE: "-frewrite-map-file={{.*[\\/]}}rewrite.map"
// RUN: %clang -frewrite-map-file %S/Inputs/rewrite-1.map -frewrite-map-file %S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE // RUN: %clang -frewrite-map-file=%S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE
// CHECK-MULTIPLE: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map" "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-SINGLE-EQ
// CHECK-SINGLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite.map"
// RUN: %clang -frewrite-map-file=%S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MULTIPLE-EQ
// CHECK-MULTIPLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map"
// CHECK-MULTIPLE-EQ: "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
// RUN: %clang -frewrite-map-file %S/Inputs/rewrite-1.map -frewrite-map-file=%S/Inputs/rewrite-2.map -### %s 2>&1 | FileCheck %s -check-prefix CHECK-MIXED
// CHECK-MIXED: "-frewrite-map-file" "{{.*[\\/]}}rewrite-1.map" "-frewrite-map-file" "{{.*[\\/]}}rewrite-2.map"
// CHECK-MULTIPLE: "-frewrite-map-file={{.*[\\/]}}rewrite-1.map" "-frewrite-map-file={{.*[\\/]}}rewrite-2.map"

View File

@ -8,4 +8,4 @@
// CHECK_WORKS: "-coverage-notes-file" "{{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs{{/|\\\\}}pchfile.gcno" // CHECK_WORKS: "-coverage-notes-file" "{{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs{{/|\\\\}}pchfile.gcno"
// CHECK_WORKS: "-working-directory" "{{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs" // CHECK_WORKS: "-working-directory" "{{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs"
// CHECK_WORKS: "-fdebug-compilation-dir" "{{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs" // CHECK_WORKS: "-fdebug-compilation-dir={{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs"