Skip to content

Commit 5793c44

Browse files
authored
Merge pull request #11748 from cyndyishida/eng/PR-preDef
[clang] Make "__GCC_HAVE_DWARF2_CFI_ASM" a proper predefined macro (#…
2 parents ebd0b1f + c0e1190 commit 5793c44

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

clang-tools-extra/test/pp-trace/pp-trace-include.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
// CHECK-NEXT: Reason: EnterFile
4040
// CHECK-NEXT: FileType: C_User
4141
// CHECK-NEXT: PrevFID: (invalid)
42-
// CHECK: - Callback: MacroDefined
4342
// CHECK: - Callback: FileChanged
4443
// CHECK-NEXT: Loc: "<built-in>:1:1"
4544
// CHECK-NEXT: Reason: ExitFile

clang-tools-extra/test/pp-trace/pp-trace-macro.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ X
4040
// CHECK-NEXT: MacroNameTok: __STDC_EMBED_EMPTY__
4141
// CHECK-NEXT: MacroDirective: MD_Define
4242
// CHECK: - Callback: MacroDefined
43-
// CHECK: - Callback: MacroDefined
4443
// CHECK-NEXT: MacroNameTok: MACRO
4544
// CHECK-NEXT: MacroDirective: MD_Define
4645
// CHECK-NEXT: - Callback: MacroExpands

clang/include/clang/Basic/DebugOptions.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ ENUM_DEBUGOPT(EmitDwarfUnwind, llvm::EmitDwarfUnwindType, 2,
4646
DEBUGOPT(NoDwarfDirectoryAsm , 1, 0, Benign) ///< Set when -fno-dwarf-directory-asm
4747
///< is enabled.
4848

49+
DEBUGOPT(Dwarf2CFIAsm, 1, 0, Affecting) ///< Set when -fdwarf2-cfi-asm is enabled.
50+
4951
DEBUGOPT(NoInlineLineTables, 1, 0, Benign) ///< Whether debug info should contain
5052
///< inline line tables.
5153

clang/include/clang/Driver/Options.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,8 +2310,12 @@ defm dollars_in_identifiers : BoolFOption<"dollars-in-identifiers",
23102310
PosFlag<SetTrue, [], [ClangOption], "Allow">,
23112311
NegFlag<SetFalse, [], [ClangOption], "Disallow">,
23122312
BothFlags<[], [ClangOption, CC1Option], " '$' in identifiers">>;
2313-
def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, Group<clang_ignored_f_Group>;
2314-
def fno_dwarf2_cfi_asm : Flag<["-"], "fno-dwarf2-cfi-asm">, Group<clang_ignored_f_Group>;
2313+
2314+
defm dwarf2_cfi_asm
2315+
: BoolFOption<"dwarf2-cfi-asm", CodeGenOpts<"Dwarf2CFIAsm">, DefaultFalse,
2316+
PosFlag<SetTrue, [], [ClangOption, CC1Option]>,
2317+
NegFlag<SetFalse>>;
2318+
23152319
defm dwarf_directory_asm : BoolFOption<"dwarf-directory-asm",
23162320
CodeGenOpts<"NoDwarfDirectoryAsm">, DefaultFalse,
23172321
NegFlag<SetTrue, [], [ClangOption, CC1Option]>,

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8328,10 +8328,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &Job,
83288328
!TC.getTriple().isAndroid() && TC.useIntegratedAs()))
83298329
CmdArgs.push_back("-faddrsig");
83308330

8331-
if ((Triple.isOSBinFormatELF() || Triple.isOSBinFormatMachO()) &&
8331+
const bool HasDefaultDwarf2CFIASM =
8332+
(Triple.isOSBinFormatELF() || Triple.isOSBinFormatMachO()) &&
83328333
(EH || UnwindTables || AsyncUnwindTables ||
8333-
DebugInfoKind != llvm::codegenoptions::NoDebugInfo))
8334-
CmdArgs.push_back("-D__GCC_HAVE_DWARF2_CFI_ASM=1");
8334+
DebugInfoKind != llvm::codegenoptions::NoDebugInfo);
8335+
if (Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
8336+
options::OPT_fno_dwarf2_cfi_asm, HasDefaultDwarf2CFIASM))
8337+
CmdArgs.push_back("-fdwarf2-cfi-asm");
83358338

83368339
if (Arg *A = Args.getLastArg(options::OPT_fsymbol_partition_EQ)) {
83378340
std::string Str = A->getAsString(Args);

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,9 @@ void clang::InitializePreprocessor(Preprocessor &PP,
15961596
}
15971597
}
15981598

1599+
if (CodeGenOpts.Dwarf2CFIAsm)
1600+
Builder.defineMacro("__GCC_HAVE_DWARF2_CFI_ASM");
1601+
15991602
// Even with predefines off, some macros are still predefined.
16001603
// These should all be defined in the preprocessor according to the
16011604
// current language configuration.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// RUN: %clang %s -dM -E -target x86_64-windows | FileCheck %s --check-prefix=NO
22
// RUN: %clang %s -dM -E -target x86_64 -fno-asynchronous-unwind-tables | FileCheck %s --check-prefix=NO
3+
// RUN: %clang %s -dM -E -target x86_64 -fno-dwarf2-cfi-asm | FileCheck %s --check-prefix=NO
34

45
// RUN: %clang %s -dM -E -target x86_64 | FileCheck %s
56
// RUN: %clang %s -dM -E -target x86_64 -funwind-tables -fno-asynchronous-unwind-tables -g | FileCheck %s
67
// RUN: %clang %s -dM -E -target aarch64-apple-darwin | FileCheck %s
78
// RUN: %clang %s -dM -E -target x86_64 -fno-asynchronous-unwind-tables -g | FileCheck %s
89
// RUN: %clang %s -dM -E -target x86_64 -fno-asynchronous-unwind-tables -fexceptions | FileCheck %s
10+
// RUN: %clang %s -dM -E -target x86_64-windows -fdwarf2-cfi-asm | FileCheck %s
911

1012
// NO-NOT: #define __GCC_HAVE_DWARF2_CFI_ASM
1113
// CHECK: #define __GCC_HAVE_DWARF2_CFI_ASM 1

0 commit comments

Comments
 (0)