Skip to content

Commit 44e0daf

Browse files
committed
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.)
1 parent 9a6f4d4 commit 44e0daf

File tree

7 files changed

+19
-4
lines changed

7 files changed

+19
-4
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,9 @@ def fno_auto_profile_accurate : Flag<["-"], "fno-auto-profile-accurate">,
737737
def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
738738
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
739739
HelpText<"The compilation directory to embed in the debug info.">;
740+
def fdebug_compilation_dir_EQ : Joined<["-"], "fdebug-compilation-dir=">,
741+
Group<f_Group>, Flags<[CC1Option, CC1AsOption, CoreOption]>,
742+
Alias<fdebug_compilation_dir>;
740743
def fdebug_info_for_profiling : Flag<["-"], "fdebug-info-for-profiling">,
741744
Group<f_Group>, Flags<[CC1Option]>,
742745
HelpText<"Emit extra debug info to make sample profile more accurate.">;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,12 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
23972397
} else if (Value == "-fdebug-compilation-dir") {
23982398
CmdArgs.push_back("-fdebug-compilation-dir");
23992399
TakeNextArg = true;
2400+
} else if (Value.consume_front("-fdebug-compilation-dir=")) {
2401+
// The flag is a -Wa / -Xassembler argument and Options doesn't
2402+
// parse the argument, so this isn't automatically aliased to
2403+
// -fdebug-compilation-dir (without '=') here.
2404+
CmdArgs.push_back("-fdebug-compilation-dir");
2405+
CmdArgs.push_back(Value.data());
24002406
} else {
24012407
D.Diag(diag::err_drv_unsupported_option_argument)
24022408
<< A->getOption().getName() << Value;

clang/test/CodeGen/debug-info-compilation-dir.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: mkdir -p %t.dir && cd %t.dir
22
// RUN: cp %s rel.c
33
// RUN: %clang_cc1 -fdebug-compilation-dir /nonsense -emit-llvm -debug-info-kind=limited rel.c -o - | FileCheck -check-prefix=CHECK-NONSENSE %s
4+
// RUN: %clang_cc1 -fdebug-compilation-dir=/nonsense -emit-llvm -debug-info-kind=limited rel.c -o - | FileCheck -check-prefix=CHECK-NONSENSE %s
45
// CHECK-NONSENSE: nonsense
56

67
// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck -check-prefix=CHECK-DIR %s

clang/test/Driver/cl-options.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@
627627
// RUN: -fdiagnostics-color \
628628
// RUN: -fno-diagnostics-color \
629629
// RUN: -fdebug-compilation-dir . \
630+
// RUN: -fdebug-compilation-dir=. \
630631
// RUN: -fdiagnostics-parseable-fixits \
631632
// RUN: -fdiagnostics-absolute-paths \
632633
// RUN: -ferror-limit=10 \

clang/test/Driver/clang_f_opts.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,9 @@
543543
// CHECK-NO-CF-PROTECTION-BRANCH-NOT: -fcf-protection=branch
544544

545545
// RUN: %clang -### -S -fdebug-compilation-dir . %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
546+
// RUN: %clang -### -S -fdebug-compilation-dir=. %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
546547
// RUN: %clang -### -fdebug-compilation-dir . -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
548+
// RUN: %clang -### -fdebug-compilation-dir=. -x assembler %s 2>&1 | FileCheck -check-prefix=CHECK-DEBUG-COMPILATION-DIR %s
547549
// CHECK-DEBUG-COMPILATION-DIR: "-fdebug-compilation-dir" "."
548550

549551
// RUN: %clang -### -S -fdiscard-value-names %s 2>&1 | FileCheck -check-prefix=CHECK-DISCARD-NAMES %s
@@ -590,4 +592,4 @@
590592
// CHECK-TRIVIAL-ZERO-BAD: hasn't been enabled
591593

592594
// RUN: %clang -### -S -fno-temp-file %s 2>&1 | FileCheck -check-prefix=CHECK-NO-TEMP-FILE %s
593-
// CHECK-NO-TEMP-FILE: "-fno-temp-file"
595+
// CHECK-NO-TEMP-FILE: "-fno-temp-file"

clang/test/Driver/fembed-bitcode.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// CHECK-X64: "-cc1"
55

66
// CHECK-X64: "-cc1"
7-
// CHECK-X64-NOT: "-fdebug-compilation-dir"
7+
// CHECK-X64-NOT: "-fdebug-compilation-dir
88

99
// RUN: %clang -target armv7-apple-ios -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
1010
// RUN: | FileCheck -check-prefix CHECK-ARM %s
@@ -14,7 +14,7 @@
1414
// CHECK-ARM: "-cc1"
1515
// CHECK-ARM: "-target-abi"
1616
// CHECK-ARM: "apcs-gnu"
17-
// CHECK-ARM-NOT: "-fdebug-compilation-dir"
17+
// CHECK-ARM-NOT: "-fdebug-compilation-dir
1818

1919
// RUN: %clang -target arm64-apple-ios -fembed-bitcode=all -c %s -o /dev/null -### 2>&1 \
2020
// RUN: | FileCheck -check-prefix CHECK-AARCH64 %s
@@ -24,7 +24,7 @@
2424
// CHECK-AARCH64: "-cc1"
2525
// CHECK-AARCH64: "-target-abi"
2626
// CHECK-AARCH64: "darwinpcs"
27-
// CHECK-AARCH64-NOT: "-fdebug-compilation-dir"
27+
// CHECK-AARCH64-NOT: "-fdebug-compilation-dir
2828

2929
// RUN: %clang -target hexagon-unknown-elf -ffixed-r19 -fembed-bitcode=all -c %s -### 2>&1 \
3030
// RUN: | FileCheck --check-prefix=CHECK-HEXAGON %s

clang/test/Driver/integrated-as.s

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@
5252
// PIC: "-mrelocation-model" "pic"
5353

5454
// RUN: %clang -### -target x86_64--- -c -integrated-as %s -Wa,-fdebug-compilation-dir,. 2>&1 | FileCheck --check-prefix=WA_DEBUGDIR %s
55+
// RUN: %clang -### -target x86_64--- -c -integrated-as %s -Wa,-fdebug-compilation-dir=. 2>&1 | FileCheck --check-prefix=WA_DEBUGDIR %s
5556
// WA_DEBUGDIR: "-fdebug-compilation-dir" "."
5657

5758
// RUN: %clang -### -target x86_64--- -c -integrated-as %s -Xassembler -fdebug-compilation-dir -Xassembler . 2>&1 | FileCheck --check-prefix=XA_DEBUGDIR %s
59+
// RUN: %clang -### -target x86_64--- -c -integrated-as %s -Xassembler -fdebug-compilation-dir=. 2>&1 | FileCheck --check-prefix=XA_DEBUGDIR %s
5860
// XA_DEBUGDIR: "-fdebug-compilation-dir" "."

0 commit comments

Comments
 (0)