Skip to content

Commit 5200acc

Browse files
authored
[clang][Driver] Add -gdwarf-6 option (#162454)
Now that we slowly started adding support for upcoming DWARFv6 attributes add `-gdwarf-6` as a supported flag.
1 parent 9ac8cd6 commit 5200acc

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4715,6 +4715,10 @@ def gdwarf_4 : Flag<["-"], "gdwarf-4">, Group<g_Group>,
47154715
HelpText<"Generate source-level debug information with dwarf version 4">;
47164716
def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group<g_Group>,
47174717
HelpText<"Generate source-level debug information with dwarf version 5">;
4718+
def gdwarf_6
4719+
: Flag<["-"], "gdwarf-6">,
4720+
Group<g_Group>,
4721+
HelpText<"Generate source-level debug information with dwarf version 6">;
47184722
}
47194723
def gdwarf64 : Flag<["-"], "gdwarf64">, Group<g_Group>,
47204724
Visibility<[ClangOption, CC1Option, CC1AsOption]>,

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,7 +2231,7 @@ static unsigned ParseDebugDefaultVersion(const ToolChain &TC,
22312231
return 0;
22322232

22332233
unsigned Value = 0;
2234-
if (StringRef(A->getValue()).getAsInteger(10, Value) || Value > 5 ||
2234+
if (StringRef(A->getValue()).getAsInteger(10, Value) || Value > 6 ||
22352235
Value < 2)
22362236
TC.getDriver().Diag(diag::err_drv_invalid_int_value)
22372237
<< A->getAsString(Args) << A->getValue();
@@ -2244,13 +2244,14 @@ unsigned tools::DwarfVersionNum(StringRef ArgValue) {
22442244
.Case("-gdwarf-3", 3)
22452245
.Case("-gdwarf-4", 4)
22462246
.Case("-gdwarf-5", 5)
2247+
.Case("-gdwarf-6", 6)
22472248
.Default(0);
22482249
}
22492250

22502251
const Arg *tools::getDwarfNArg(const ArgList &Args) {
22512252
return Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
22522253
options::OPT_gdwarf_4, options::OPT_gdwarf_5,
2253-
options::OPT_gdwarf);
2254+
options::OPT_gdwarf_6, options::OPT_gdwarf);
22542255
}
22552256

22562257
unsigned tools::getDwarfVersion(const ToolChain &TC,

clang/test/CodeGen/dwarf-version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: %clang -target x86_64-linux-gnu -gdwarf-3 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER3
33
// RUN: %clang -target x86_64-linux-gnu -gdwarf-4 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER4
44
// RUN: %clang -target x86_64-linux-gnu -gdwarf-5 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
5+
// RUN: %clang -target x86_64-linux-gnu -gdwarf-6 -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER6
56
// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
67
// RUN: %clang -target x86_64-linux-gnu -gdwarf -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
78
// RUN: %clang --target=i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER5
@@ -61,6 +62,7 @@ int main (void) {
6162
// VER3: !{i32 7, !"Dwarf Version", i32 3}
6263
// VER4: !{i32 7, !"Dwarf Version", i32 4}
6364
// VER5: !{i32 7, !"Dwarf Version", i32 5}
65+
// VER6: !{i32 7, !"Dwarf Version", i32 6}
6466
// UNSUPPORTED-VER5: error: unsupported option '-gdwarf-5'
6567

6668
// NODWARF-NOT: !"Dwarf Version"

0 commit comments

Comments
 (0)