[llvm] r373420 - DebugInfo: Update support for detecting C++ language variants in debug info emission

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 08:50:12 PDT 2019



> On Oct 1, 2019, at 6:39 PM, David Blaikie via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: dblaikie
> Date: Tue Oct  1 18:39:48 2019
> New Revision: 373420
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=373420&view=rev
> Log:
> DebugInfo: Update support for detecting C++ language variants in debug info emission
> 
> Modified:
>    llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
>    llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll
> 
> Modified: llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Dwarf.h?rev=373420&r1=373419&r2=373420&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/BinaryFormat/Dwarf.h (original)
> +++ llvm/trunk/include/llvm/BinaryFormat/Dwarf.h Tue Oct  1 18:39:48 2019
> @@ -180,6 +180,58 @@ enum SourceLanguage {
>   DW_LANG_hi_user = 0xffff
> };
> 
> +inline bool isCPlusPlus(SourceLanguage S) {
> +  // Deliberately enumerate all the language options so we get a warning when
> +  // new language options are added (-Wswitch) that'll hopefully help keep this
> +  // switch up-to-date when new C++ versions are added.
> +  switch (S) {
> +  case DW_LANG_C_plus_plus:
> +  case DW_LANG_C_plus_plus_03:
> +  case DW_LANG_C_plus_plus_11:
> +  case DW_LANG_C_plus_plus_14:

DW_LANG_ObjC_plus_plus should be considered C++, too, since Objective-C++ ought to be a superset of C++.

-- adrian

> +    return true;
> +  case DW_LANG_C89:
> +  case DW_LANG_C:
> +  case DW_LANG_Ada83:
> +  case DW_LANG_Cobol74:
> +  case DW_LANG_Cobol85:
> +  case DW_LANG_Fortran77:
> +  case DW_LANG_Fortran90:
> +  case DW_LANG_Pascal83:
> +  case DW_LANG_Modula2:
> +  case DW_LANG_Java:
> +  case DW_LANG_C99:
> +  case DW_LANG_Ada95:
> +  case DW_LANG_Fortran95:
> +  case DW_LANG_PLI:
> +  case DW_LANG_ObjC:
> +  case DW_LANG_ObjC_plus_plus:
> +  case DW_LANG_UPC:
> +  case DW_LANG_D:
> +  case DW_LANG_Python:
> +  case DW_LANG_OpenCL:
> +  case DW_LANG_Go:
> +  case DW_LANG_Modula3:
> +  case DW_LANG_Haskell:
> +  case DW_LANG_OCaml:
> +  case DW_LANG_Rust:
> +  case DW_LANG_C11:
> +  case DW_LANG_Swift:
> +  case DW_LANG_Julia:
> +  case DW_LANG_Dylan:
> +  case DW_LANG_Fortran03:
> +  case DW_LANG_Fortran08:
> +  case DW_LANG_RenderScript:
> +  case DW_LANG_BLISS:
> +  case DW_LANG_Mips_Assembler:
> +  case DW_LANG_GOOGLE_RenderScript:
> +  case DW_LANG_BORLAND_Delphi:
> +  case DW_LANG_lo_user:
> +  case DW_LANG_hi_user:
> +    return false;
> +  }
> +}
> +
> enum CaseSensitivity {
>   // Identifier case codes
>   DW_ID_case_sensitive = 0x00,
> 
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=373420&r1=373419&r2=373420&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Oct  1 18:39:48 2019
> @@ -1989,9 +1989,10 @@ static dwarf::PubIndexEntryDescriptor co
>   case dwarf::DW_TAG_union_type:
>   case dwarf::DW_TAG_enumeration_type:
>     return dwarf::PubIndexEntryDescriptor(
> -        dwarf::GIEK_TYPE, CU->getLanguage() != dwarf::DW_LANG_C_plus_plus
> -                              ? dwarf::GIEL_STATIC
> -                              : dwarf::GIEL_EXTERNAL);
> +        dwarf::GIEK_TYPE,
> +        dwarf::isCPlusPlus((dwarf::SourceLanguage)CU->getLanguage())
> +            ? dwarf::GIEL_EXTERNAL
> +            : dwarf::GIEL_STATIC);
>   case dwarf::DW_TAG_typedef:
>   case dwarf::DW_TAG_base_type:
>   case dwarf::DW_TAG_subrange_type:
> 
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=373420&r1=373419&r2=373420&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Tue Oct  1 18:39:48 2019
> @@ -722,7 +722,7 @@ std::string DwarfUnit::getParentContextS
>     return "";
> 
>   // FIXME: Decide whether to implement this for non-C++ languages.
> -  if (getLanguage() != dwarf::DW_LANG_C_plus_plus)
> +  if (!dwarf::isCPlusPlus((dwarf::SourceLanguage)getLanguage()))
>     return "";
> 
>   std::string CS;
> 
> Modified: llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll?rev=373420&r1=373419&r2=373420&view=diff
> ==============================================================================
> --- llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll (original)
> +++ llvm/trunk/test/DebugInfo/X86/gnu-public-names.ll Tue Oct  1 18:39:48 2019
> @@ -354,7 +354,7 @@ attributes #1 = { nounwind readnone spec
> 
> !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
> !1 = distinct !DIGlobalVariable(name: "static_member_variable", linkageName: "_ZN1C22static_member_variableE", scope: !2, file: !3, line: 7, type: !13, isLocal: false, isDefinition: true, declaration: !22)
> -!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 9.0.0 (trunk 363288) (llvm/trunk 363294)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !16, globals: !17, imports: !54, nameTableKind: GNU)
> +!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_03, file: !3, producer: "clang version 9.0.0 (trunk 363288) (llvm/trunk 363294)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !16, globals: !17, imports: !54, nameTableKind: GNU)
> !3 = !DIFile(filename: "names.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
> !4 = !{!5, !9, !12}
> !5 = !DICompositeType(tag: DW_TAG_enumeration_type, file: !3, line: 49, baseType: !6, size: 32, elements: !7)
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list