[llvm-branch-commits] [clang] 72cc3f7 - DW_TAG_Rvalue_reference

Chen Zheng via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Apr 26 18:13:17 PDT 2021


Author: Chen Zheng
Date: 2021-04-24T21:41:22-04:00
New Revision: 72cc3f7159b695f1928b82a4f29935db6eb62b42

URL: https://github.com/llvm/llvm-project/commit/72cc3f7159b695f1928b82a4f29935db6eb62b42
DIFF: https://github.com/llvm/llvm-project/commit/72cc3f7159b695f1928b82a4f29935db6eb62b42.diff

LOG: DW_TAG_Rvalue_reference

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 290cdbf8c4e34..1aa48034da69f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2989,8 +2989,14 @@ llvm::DIType *CGDebugInfo::CreateType(const LValueReferenceType *Ty,
 
 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().DebugStrictDwarf &&
+      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,

diff  --git a/clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp b/clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
index de0f65ad9a029..45b19705fae2f 100644
--- a/clang/test/CodeGenCXX/debug-info-rvalue-ref.cpp
+++ b/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 -gstrict-dwarf -dwarf-version=4 -emit-llvm -debug-info-kind=limited \
+// RUN:   -triple x86_64-apple-darwin %s -o - | FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -gstrict-dwarf -dwarf-version=3 -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 @@ void foo (int &&i)
 
 // 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)


        


More information about the llvm-branch-commits mailing list