MaskRay updated this revision to Diff 327320. MaskRay retitled this revision from "Define __GCC_HAVE_DWARF2_CFI_ASM to 1 on ELF/Mach-O if CC1 -munwind-tables is specified" to "Define __GCC_HAVE_DWARF2_CFI_ASM if applicable". MaskRay edited the summary of this revision. MaskRay added a comment.
Check -g and exceptions Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D97743/new/ https://reviews.llvm.org/D97743 Files: clang/lib/Frontend/CompilerInvocation.cpp clang/test/Preprocessor/unwind-tables.c Index: clang/test/Preprocessor/unwind-tables.c =================================================================== --- /dev/null +++ clang/test/Preprocessor/unwind-tables.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows +// RUN: %clang_cc1 %s -verify -triple x86_64-unknown-elf + +// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple x86_64-unknown-elf +// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple aarch64-apple-darwin +// RUN: %clang_cc1 %s -verify -debug-info-kind=line-tables-only -DCFI_ASM -triple x86_64-unknown-elf +// RUN: %clang_cc1 %s -verify -fexceptions -DCFI_ASM -triple x86_64-unknown-elf + +// expected-no-diagnostics + +#ifdef CFI_ASM + #if __GCC_HAVE_DWARF2_CFI_ASM != 1 + #error "__GCC_HAVE_DWARF2_CFI_ASM not defined" + #endif +#else + #ifdef __GCC_HAVE_DWARF2_CFI_ASM + #error "__GCC_HAVE_DWARF2_CFI_ASM defined" + #endif +#endif Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -4350,6 +4350,11 @@ Res.getCodeGenOpts().Argv0 = Argv0; Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs; + if ((T.isOSBinFormatELF() || T.isOSBinFormatMachO()) && + (Res.getLangOpts()->Exceptions || Res.getCodeGenOpts().UnwindTables || + Res.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo)) + Res.getPreprocessorOpts().addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1"); + Success &= FixupInvocation(Res, Diags, Args, DashX); return Success;
Index: clang/test/Preprocessor/unwind-tables.c =================================================================== --- /dev/null +++ clang/test/Preprocessor/unwind-tables.c @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 %s -verify -munwind-tables -triple x86_64-windows +// RUN: %clang_cc1 %s -verify -triple x86_64-unknown-elf + +// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple x86_64-unknown-elf +// RUN: %clang_cc1 %s -verify -munwind-tables -DCFI_ASM -triple aarch64-apple-darwin +// RUN: %clang_cc1 %s -verify -debug-info-kind=line-tables-only -DCFI_ASM -triple x86_64-unknown-elf +// RUN: %clang_cc1 %s -verify -fexceptions -DCFI_ASM -triple x86_64-unknown-elf + +// expected-no-diagnostics + +#ifdef CFI_ASM + #if __GCC_HAVE_DWARF2_CFI_ASM != 1 + #error "__GCC_HAVE_DWARF2_CFI_ASM not defined" + #endif +#else + #ifdef __GCC_HAVE_DWARF2_CFI_ASM + #error "__GCC_HAVE_DWARF2_CFI_ASM defined" + #endif +#endif Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -4350,6 +4350,11 @@ Res.getCodeGenOpts().Argv0 = Argv0; Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs; + if ((T.isOSBinFormatELF() || T.isOSBinFormatMachO()) && + (Res.getLangOpts()->Exceptions || Res.getCodeGenOpts().UnwindTables || + Res.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo)) + Res.getPreprocessorOpts().addMacroDef("__GCC_HAVE_DWARF2_CFI_ASM=1"); + Success &= FixupInvocation(Res, Diags, Args, DashX); return Success;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits