[clang] 44e0daf - driver: Allow -fdebug-compilation-dir=foo in joined form.

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 10 16:21:00 PST 2020


Author: Nico Weber
Date: 2020-01-10T19:20:51-05:00
New Revision: 44e0daf16e6985eb44ea9a629402852dbff9cb0b

URL: https://github.com/llvm/llvm-project/commit/44e0daf16e6985eb44ea9a629402852dbff9cb0b
DIFF: https://github.com/llvm/llvm-project/commit/44e0daf16e6985eb44ea9a629402852dbff9cb0b.diff

LOG: driver: Allow -fdebug-compilation-dir=foo in joined form.

All 130+ f_Group flags that take an argument allow it after a '=',
except for fdebug-complation-dir. Add a Joined<> alias so that
it behaves consistently with all the other f_Group flags.
(Keep the old Separate flag for backwards compat.)

Added: 
    

Modified: 
    clang/include/clang/Driver/Options.td
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/CodeGen/debug-info-compilation-dir.c
    clang/test/Driver/cl-options.c
    clang/test/Driver/clang_f_opts.c
    clang/test/Driver/fembed-bitcode.c
    clang/test/Driver/integrated-as.s

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index dd673737b97b..caeed3d7b8ed 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -737,6 +737,9 @@ def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-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.">;
+def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">,
+    Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
+    Alias<fdebug_compilation_dir>;
 def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">,
     Group<f_Group>, Flags<[CC1Option]>,
     HelpText<"Emit extra debug info to make sample profile more accurate.">;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 8fdf1f23e28d..4ef40e974cd6 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2397,6 +2397,12 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
       } else if (Value == "-fdebug-compilation-dir") {
         CmdArgs.push_back("-fdebug-compilation-dir");
         TakeNextArg = true;
+      } else if (Value.consume_front("-fdebug-compilation-dir=")) {
+        // The flag is a -Wa / -Xassembler argument and Options doesn't
+        // parse the argument, so this isn't automatically aliased to
+        // -fdebug-compilation-dir (without '=') here.
+        CmdArgs.push_back("-fdebug-compilation-dir");
+        CmdArgs.push_back(Value.data());
       } else {
         D.Diag(diag::err_drv_unsupported_option_argument)
             << A->getOption().getName() << Value;

diff  --git a/clang/test/CodeGen/debug-info-compilation-dir.c b/clang/test/CodeGen/debug-info-compilation-dir.c
index 786d23556de9..b49a0f5751f8 100644
--- a/clang/test/CodeGen/debug-info-compilation-dir.c
+++ b/clang/test/CodeGen/debug-info-compilation-dir.c
@@ -1,6 +1,7 @@
 // RUN: mkdir -p %t.dir && cd %t.dir
 // RUN: cp %s rel.c
 // RUN: %clang_cc1 -fdebug-compilation-dir /nonsense -emit-llvm -debug-info-kind=limited rel.c -o - | FileCheck -check-prefix=CHECK-NONSENSE %s
+// RUN: %clang_cc1 -fdebug-compilation-dir=/nonsense -emit-llvm -debug-info-kind=limited rel.c -o - | FileCheck -check-prefix=CHECK-NONSENSE %s
 // CHECK-NONSENSE: nonsense
 
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck -check-prefix=CHECK-DIR %s

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 2a5453b10d26..49f5166b95e4 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -627,6 +627,7 @@
 // RUN:     -fdiagnostics-color \
 // RUN:     -fno-diagnostics-color \
 // RUN:     -fdebug-compilation-dir . \
+// RUN:     -fdebug-compilation-dir=. \
 // RUN:     -fdiagnostics-parseable-fixits \
 // RUN:     -fdiagnostics-absolute-paths \
 // RUN:     -ferror-limit=10 \

diff  --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c
index ea6d10af5317..0a7cfdf11281 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -543,7 +543,9 @@
 // CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch
 
 // 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
 // CHECK-DEBUG-COMPILATION-DIR: "-fdebug-compilation-dir" "."
 
 // RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s
@@ -590,4 +592,4 @@
 // CHECK-TRIVIAL-ZERO-BAD: hasn't been enabled
 
 // RUN: %clang -### -S -fno-temp-file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-TEMP-FILE %s
-// CHECK-NO-TEMP-FILE: "-fno-temp-file"
\ No newline at end of file
+// CHECK-NO-TEMP-FILE: "-fno-temp-file"

diff  --git a/clang/test/Driver/fembed-bitcode.c b/clang/test/Driver/fembed-bitcode.c
index c72781dc1992..d01ae6cd8c18 100644
--- a/clang/test/Driver/fembed-bitcode.c
+++ b/clang/test/Driver/fembed-bitcode.c
@@ -4,7 +4,7 @@
 // CHECK-X64: "-cc1"
 
 // CHECK-X64: "-cc1"
-// CHECK-X64-NOT: "-fdebug-compilation-dir"
+// CHECK-X64-NOT: "-fdebug-compilation-dir
 
 // RUN: %clang -target armv7-apple-ios -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
 // RUN:    | FileCheck -check-prefix CHECK-ARM %s
@@ -14,7 +14,7 @@
 // CHECK-ARM: "-cc1"
 // CHECK-ARM: "-target-abi"
 // CHECK-ARM: "apcs-gnu"
-// CHECK-ARM-NOT: "-fdebug-compilation-dir"
+// CHECK-ARM-NOT: "-fdebug-compilation-dir
 
 // RUN: %clang -target arm64-apple-ios -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
 // RUN:    | FileCheck -check-prefix CHECK-AARCH64 %s
@@ -24,7 +24,7 @@
 // CHECK-AARCH64: "-cc1"
 // CHECK-AARCH64: "-target-abi"
 // CHECK-AARCH64: "darwinpcs"
-// CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
+// CHECK-AARCH64-NOT: "-fdebug-compilation-dir
 
 // RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c %s -### 2>&1 \
 // RUN:     | FileCheck --check-prefix=CHECK-HEXAGON %s

diff  --git a/clang/test/Driver/integrated-as.s b/clang/test/Driver/integrated-as.s
index 3ad0860b9020..0194a3d5a438 100644
--- a/clang/test/Driver/integrated-as.s
+++ b/clang/test/Driver/integrated-as.s
@@ -52,7 +52,9 @@
 // PIC: "-mrelocation-model" "pic"
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -Wa,-fdebug-compilation-dir,. 2>&1 | FileCheck --check-prefix=WA_DEBUGDIR %s
+// RUN: %clang -### -target x86_64--- -c -integrated-as %s -Wa,-fdebug-compilation-dir=. 2>&1 | FileCheck --check-prefix=WA_DEBUGDIR %s
 // WA_DEBUGDIR: "-fdebug-compilation-dir" "."
 
 // RUN: %clang -### -target x86_64--- -c -integrated-as %s -Xassembler -fdebug-compilation-dir -Xassembler . 2>&1 | FileCheck --check-prefix=XA_DEBUGDIR %s
+// RUN: %clang -### -target x86_64--- -c -integrated-as %s -Xassembler -fdebug-compilation-dir=. 2>&1 | FileCheck --check-prefix=XA_DEBUGDIR %s
 // XA_DEBUGDIR: "-fdebug-compilation-dir" "."


        


More information about the cfe-commits mailing list