Author: Chen Zheng Date: 2021-05-23T21:24:13-04:00 New Revision: 99d45ed22fd9c08ae81110956a817ac0eacded2e
URL: https://github.com/llvm/llvm-project/commit/99d45ed22fd9c08ae81110956a817ac0eacded2e DIFF: https://github.com/llvm/llvm-project/commit/99d45ed22fd9c08ae81110956a817ac0eacded2e.diff LOG: [Debug-Info] handle DW_TAG_rvalue_reference_type at strict DWARF. When -gstrict-dwarf is specified, generate DW_TAG_rvalue_reference_type at DWARF 4 or above Reviewed By: dblaikie, aprantl Differential Revision: https://reviews.llvm.org/D100630 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 fefcf7a4e973..e8c310e0c060 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2989,8 +2989,13 @@ 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. + 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 de0f65ad9a02..c9500ee59b7f 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 -dwarf-version=4 -gstrict-dwarf -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 -gstrict-dwarf -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) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits