[clang] 0c2bb6b - [Driver] Clean up some Separate form options
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 17 13:49:49 PST 2021
Author: Fangrui Song
Date: 2021-02-17T13:49:41-08:00
New Revision: 0c2bb6b446c584ab8a8b1231a136f657fa070e47
URL: https://github.com/llvm/llvm-project/commit/0c2bb6b446c584ab8a8b1231a136f657fa070e47
DIFF: https://github.com/llvm/llvm-project/commit/0c2bb6b446c584ab8a8b1231a136f657fa070e47.diff
LOG: [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
Added:
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/clang_f_opts.c
clang/test/Driver/debug-comp-dir.S
clang/test/Driver/rewrite-map-files.c
clang/test/Driver/rewrite-map-in-diagnostics.c
clang/test/Driver/symbol-rewriter.c
clang/test/Driver/working-directory.c
Removed:
clang/test/Driver/debug.c
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 0451fa829c00..13d3dcd868ab 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1096,13 +1096,13 @@ def fauto_profile_accurate : Flag<["-"], "fauto-profile-accurate">,
Group<f_Group>, Alias<fprofile_sample_accurate>;
def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">,
Group<f_Group>, Alias<fno_profile_sample_accurate>;
-def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
+def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">,
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
- HelpText<"The compilation directory to embed in the debug info.">,
+ 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 : Separate<["-"], "fdebug-compilation-dir">,
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
- Alias<fdebug_compilation_dir>;
+ Alias<fdebug_compilation_dir_EQ>;
defm debug_info_for_profiling : BoolFOption<"debug-info-for-profiling",
CodeGenOpts<"DebugInfoForProfiling">, DefaultFalse,
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>">,
HelpText<"Use the remappings described in <file> to match the profile data against names in the program">,
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",
CodeGenOpts<"CoverageMapping">, DefaultFalse,
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)">,
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=">,
Group<f_Group>,
- Flags<[NoXarchOption]>;
+ Flags<[NoXarchOption, CC1Option]>,
+ MarshallingInfoStringVector<CodeGenOpts<"RewriteMapFiles">>;
defm use_line_directives : BoolFOption<"use-line-directives",
PreprocessorOutputOpts<"UseLineDirectives">, DefaultFalse,
@@ -1984,7 +1979,6 @@ def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group<f_Group>,
Flags<[NoXarchOption,CC1Option]>, MetaVarName<"<name>">,
HelpText<"Specify the name of the module to build">,
MarshallingInfoString<LangOpts<"ModuleName">>;
-def fmodule_name : Separate<["-"], "fmodule-name">, Alias<fmodule_name_EQ>;
def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,
Flags<[CC1Option]>, Alias<fmodule_name_EQ>;
def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>,
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 02f4f478031f..f684ea7c93f7 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1484,8 +1484,7 @@ void Driver::generateCompilationDiagnostics(
}
}
- for (const auto &A : C.getArgs().filtered(options::OPT_frewrite_map_file,
- options::OPT_frewrite_map_file_EQ))
+ for (const auto &A : C.getArgs().filtered(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)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 03166232cf42..2ae6c400f692 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -617,13 +617,11 @@ getFramePointerKind(const ArgList &Args, const llvm::Triple &Triple) {
/// Add a CC1 option to specify the debug compilation directory.
static void addDebugCompDirArg(const ArgList &Args, ArgStringList &CmdArgs,
const llvm::vfs::FileSystem &VFS) {
- if (Arg *A = Args.getLastArg(options::OPT_fdebug_compilation_dir)) {
- CmdArgs.push_back("-fdebug-compilation-dir");
- CmdArgs.push_back(A->getValue());
+ if (Arg *A = Args.getLastArg(options::OPT_fdebug_compilation_dir_EQ)) {
+ A->render(Args, CmdArgs);
} else if (llvm::ErrorOr<std::string> CWD =
VFS.getCurrentWorkingDirectory()) {
- CmdArgs.push_back("-fdebug-compilation-dir");
- CmdArgs.push_back(Args.MakeArgString(*CWD));
+ CmdArgs.push_back(Args.MakeArgString("-fdebug-compilation-dir=" + *CWD));
}
}
@@ -4674,18 +4672,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
// LLVM Code Generator Options.
- if (Args.hasArg(options::OPT_frewrite_map_file) ||
- Args.hasArg(options::OPT_frewrite_map_file_EQ)) {
- for (const Arg *A : Args.filtered(options::OPT_frewrite_map_file,
- options::OPT_frewrite_map_file_EQ)) {
- StringRef Map = A->getValue();
- if (!llvm::sys::fs::exists(Map)) {
- D.Diag(diag::err_drv_no_such_file) << Map;
- } else {
- CmdArgs.push_back("-frewrite-map-file");
- CmdArgs.push_back(A->getValue());
- A->claim();
- }
+ for (const Arg *A : Args.filtered(options::OPT_frewrite_map_file_EQ)) {
+ StringRef Map = A->getValue();
+ if (!llvm::sys::fs::exists(Map)) {
+ D.Diag(diag::err_drv_no_such_file) << Map;
+ } else {
+ A->render(Args, CmdArgs);
+ A->claim();
}
}
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1cbf5e5dfb4e..375b6b32b631 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1011,7 +1011,7 @@ const char *tools::SplitDebugName(const JobAction &JA, const ArgList &Args,
} else {
// Use the compilation dir.
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()));
AddPostfix(F);
T += F;
diff --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c
index c011f2e6bad6..85758aef4ea8 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -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 -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 -### -flto -forder-file-instrumentation %s 2>&1 | FileCheck -check-prefix=CHECK-ORDERFILE-INSTR-LTO %s
// 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 -### -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 -fno-discard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-NO-DISCARD-NAMES %s
diff --git a/clang/test/Driver/debug-comp-dir.S b/clang/test/Driver/debug-comp-dir.S
index 5bf3b9295a32..19ced0059a2b 100644
--- a/clang/test/Driver/debug-comp-dir.S
+++ b/clang/test/Driver/debug-comp-dir.S
@@ -1,2 +1,3 @@
// 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.*}}"
diff --git a/clang/test/Driver/debug.c b/clang/test/Driver/debug.c
deleted file mode 100644
index 5bf3b9295a32..000000000000
--- a/clang/test/Driver/debug.c
+++ /dev/null
@@ -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.*"}}
diff --git a/clang/test/Driver/rewrite-map-files.c b/clang/test/Driver/rewrite-map-files.c
index fe04fbaa1f42..f079347c5943 100644
--- a/clang/test/Driver/rewrite-map-files.c
+++ b/clang/test/Driver/rewrite-map-files.c
@@ -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:
diff --git a/clang/test/Driver/rewrite-map-in-diagnostics.c b/clang/test/Driver/rewrite-map-in-diagnostics.c
index ef598ff66b84..d49d0ec8358f 100644
--- a/clang/test/Driver/rewrite-map-in-diagnostics.c
+++ b/clang/test/Driver/rewrite-map-in-diagnostics.c
@@ -1,7 +1,7 @@
// RUN: rm -rf "%t"
// RUN: mkdir -p "%t"
// 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
#pragma clang __debug parser_crash
diff --git a/clang/test/Driver/symbol-rewriter.c b/clang/test/Driver/symbol-rewriter.c
index 3cfdb9d09cd9..2bee07b4b028 100644
--- a/clang/test/Driver/symbol-rewriter.c
+++ b/clang/test/Driver/symbol-rewriter.c
@@ -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
-
-// 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"
+// 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"
diff --git a/clang/test/Driver/working-directory.c b/clang/test/Driver/working-directory.c
index bba9574ef6d4..75c6dc46e417 100644
--- a/clang/test/Driver/working-directory.c
+++ b/clang/test/Driver/working-directory.c
@@ -8,4 +8,4 @@
// CHECK_WORKS: "-coverage-notes-file" "{{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs{{/|\\\\}}pchfile.gcno"
// CHECK_WORKS: "-working-directory" "{{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs"
-// CHECK_WORKS: "-fdebug-compilation-dir" "{{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs"
+// CHECK_WORKS: "-fdebug-compilation-dir={{[^"]+}}test{{/|\\\\}}Driver{{/|\\\\}}Inputs"
More information about the cfe-commits
mailing list