[PATCH] D100630: [Debug-Info][DBX] DW_TAG_rvalue_reference_type should not be generated when dwarf version is smaller than 4

ChenZheng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 19 20:21:42 PDT 2021


shchenz updated this revision to Diff 338695.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100630/new/

https://reviews.llvm.org/D100630

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp


Index: clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
===================================================================
--- clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
@@ -1,4 +1,8 @@
 // RUN: %clang_cc1 -std=c++11 -emit-llvm -debug-info-kind=limited -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=4 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -dwarf-version=3 -debugger-tuning=dbx -emit-llvm -debug-info-kind=limited \
+// RUN:  -triple x86_64-apple-darwin %s -o - | FileCheck %s --check-prefix=NORVALUE
 
 extern "C" {
 extern int printf(const char * format, ...);
@@ -10,3 +14,4 @@
 
 // CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
 // CHECK: ![[INT]] = !DIBasicType(name: "int"
+// NORVALUE: !DIDerivedType(tag: DW_TAG_reference_type, baseType: ![[INT:[0-9]+]], size: 64)
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@
 
 llvm::DIType *CGDebugInfo::CreateType(const RValueReferenceType *Ty,
                                       llvm::DIFile *Unit) {
-  return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty,
-                               Ty->getPointeeType(), Unit);
+  llvm::dwarf::Tag Tag = llvm::dwarf::DW_TAG_rvalue_reference_type;
+  // DW_TAG_rvalue_reference_type was introduced in DWARF 4, in strict DWARF
+  // mode, only generate it when DWARF version is no smaller than 4.
+  if (CGM.getCodeGenOpts().getDebugStrictDwarf() &&
+      CGM.getCodeGenOpts().DwarfVersion < 4)
+    Tag = llvm::dwarf::DW_TAG_reference_type;
+
+  return CreatePointerLikeType(Tag, Ty, Ty->getPointeeType(), Unit);
 }
 
 llvm::DIType *CGDebugInfo::CreateType(const MemberPointerType *Ty,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100630.338695.patch
Type: text/x-patch
Size: 2032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210420/b08fdc35/attachment-0001.bin>


More information about the cfe-commits mailing list