Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang-tools-extra/test/pp-trace/pp-trace-include.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
// CHECK-NEXT: Reason: EnterFile
// CHECK-NEXT: FileType: C_User
// CHECK-NEXT: PrevFID: (invalid)
// CHECK: - Callback: MacroDefined
// CHECK: - Callback: FileChanged
// CHECK-NEXT: Loc: "<built-in>:1:1"
// CHECK-NEXT: Reason: ExitFile
Expand Down
1 change: 0 additions & 1 deletion clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ X
// CHECK-NEXT: MacroNameTok: __STDC_EMBED_EMPTY__
// CHECK-NEXT: MacroDirective: MD_Define
// CHECK: - Callback: MacroDefined
// CHECK: - Callback: MacroDefined
// CHECK-NEXT: MacroNameTok: MACRO
// CHECK-NEXT: MacroDirective: MD_Define
// CHECK-NEXT: - Callback: MacroExpands
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/DebugOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ ENUM_DEBUGOPT(EmitDwarfUnwind, EmitDwarfUnwindType, 2,
DEBUGOPT(NoDwarfDirectoryAsm , 1, 0, Benign) ///< Set when -fno-dwarf-directory-asm
///< is enabled.

DEBUGOPT(Dwarf2CFIAsm, 1, 0, NotCompatible) ///< Set when -fdwarf2-cfi-asm is enabled.

DEBUGOPT(NoInlineLineTables, 1, 0, Benign) ///< Whether debug info should contain
///< inline line tables.

Expand Down
8 changes: 6 additions & 2 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2155,8 +2155,12 @@ defm dollars_in_identifiers : BoolFOption<"dollars-in-identifiers",
PosFlag<SetTrue, [], [ClangOption], "Allow">,
NegFlag<SetFalse, [], [ClangOption], "Disallow">,
BothFlags<[], [ClangOption, CC1Option], " '$' in identifiers">>;
def fdwarf2_cfi_asm : Flag<["-"], "fdwarf2-cfi-asm">, Group<clang_ignored_f_Group>;
def fno_dwarf2_cfi_asm : Flag<["-"], "fno-dwarf2-cfi-asm">, Group<clang_ignored_f_Group>;

defm dwarf2_cfi_asm
: BoolFOption<"dwarf2-cfi-asm", CodeGenOpts<"Dwarf2CFIAsm">, DefaultFalse,
PosFlag<SetTrue, [], [ClangOption, CC1Option]>,
NegFlag<SetFalse>>;

defm dwarf_directory_asm : BoolFOption<"dwarf-directory-asm",
CodeGenOpts<"NoDwarfDirectoryAsm">, DefaultFalse,
NegFlag<SetTrue, [], [ClangOption, CC1Option]>,
Expand Down
9 changes: 6 additions & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7879,10 +7879,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
!TC.getTriple().isAndroid() && TC.useIntegratedAs()))
CmdArgs.push_back("-faddrsig");

if ((Triple.isOSBinFormatELF() || Triple.isOSBinFormatMachO()) &&
const bool HasDefaultDwarf2CFIASM =
(Triple.isOSBinFormatELF() || Triple.isOSBinFormatMachO()) &&
(EH || UnwindTables || AsyncUnwindTables ||
DebugInfoKind != llvm::codegenoptions::NoDebugInfo))
CmdArgs.push_back("-D__GCC_HAVE_DWARF2_CFI_ASM=1");
DebugInfoKind != llvm::codegenoptions::NoDebugInfo);
if (Args.hasFlag(options::OPT_fdwarf2_cfi_asm,
options::OPT_fno_dwarf2_cfi_asm, HasDefaultDwarf2CFIASM))
CmdArgs.push_back("-fdwarf2-cfi-asm");

if (Arg *A = Args.getLastArg(options::OPT_fsymbol_partition_EQ)) {
std::string Str = A->getAsString(Args);
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
if (LangOpts.PointerAuthIntrinsics)
Builder.defineMacro("__PTRAUTH__");

if (CGOpts.Dwarf2CFIAsm)
Builder.defineMacro("__GCC_HAVE_DWARF2_CFI_ASM");

// Get other target #defines.
TI.getTargetDefines(LangOpts, Builder);
}
Expand Down
3 changes: 3 additions & 0 deletions clang/test/DebugInfo/KeyInstructions/flag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

// KEY-INSTRUCTIONS: "-gkey-instructions"
// NO-KEY-INSTRUCTIONS-NOT: key-instructions

// Only expect one dwarf related flag.
// NO-DEBUG: -fdwarf2-cfi-asm
// NO-DEBUG-NOT: debug-info-kind
// NO-DEBUG-NOT: dwarf

Expand Down
2 changes: 2 additions & 0 deletions clang/test/Preprocessor/unwind-tables.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// RUN: %clang %s -dM -E -target x86_64-windows | FileCheck %s --check-prefix=NO
// RUN: %clang %s -dM -E -target x86_64 -fno-asynchronous-unwind-tables | FileCheck %s --check-prefix=NO
// RUN: %clang %s -dM -E -target x86_64 -fno-dwarf2-cfi-asm | FileCheck %s --check-prefix=NO

// RUN: %clang %s -dM -E -target x86_64 | FileCheck %s
// RUN: %clang %s -dM -E -target x86_64 -funwind-tables -fno-asynchronous-unwind-tables -g | FileCheck %s
// RUN: %clang %s -dM -E -target aarch64-apple-darwin | FileCheck %s
// RUN: %clang %s -dM -E -target x86_64 -fno-asynchronous-unwind-tables -g | FileCheck %s
// RUN: %clang %s -dM -E -target x86_64 -fno-asynchronous-unwind-tables -fexceptions | FileCheck %s
// RUN: %clang %s -dM -E -target x86_64-windows -fdwarf2-cfi-asm | FileCheck %s

// NO-NOT: #define __GCC_HAVE_DWARF2_CFI_ASM
// CHECK: #define __GCC_HAVE_DWARF2_CFI_ASM 1
Loading