From: Adrian Prantl Date: Wed, 18 Dec 2013 21:48:18 +0000 (+0000) Subject: Debug info: Implement (rvalue) reference qualifiers for C++11 non-static X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e18818e489b017145a792e907a8a8948b82f618;p=clang Debug info: Implement (rvalue) reference qualifiers for C++11 non-static member functions. Paired commit with LLVM. rdar://problem/15356637 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197612 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index df6868ab1a..5483e27693 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -37,7 +37,7 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Dwarf.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/Path.h" +#include "llvm/Support/Path.h" using namespace clang; using namespace clang::CodeGen; @@ -1005,7 +1005,13 @@ llvm::DICompositeType CGDebugInfo::getOrCreateInstanceMethodType( llvm::DIArray EltTypeArray = DBuilder.getOrCreateArray(Elts); - return DBuilder.createSubroutineType(Unit, EltTypeArray); + unsigned Flags = 0; + if (Func->getExtProtoInfo().RefQualifier == RQ_LValue) + Flags |= llvm::DIDescriptor::FlagLValueReference; + if (Func->getExtProtoInfo().RefQualifier == RQ_RValue) + Flags |= llvm::DIDescriptor::FlagRValueReference; + + return DBuilder.createSubroutineType(Unit, EltTypeArray, Flags); } /// isFunctionLocalClass - Return true if CXXRecordDecl is defined @@ -1084,6 +1090,10 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, } if (Method->hasPrototype()) Flags |= llvm::DIDescriptor::FlagPrototyped; + if (Method->getRefQualifier() == RQ_LValue) + Flags |= llvm::DIDescriptor::FlagLValueReference; + if (Method->getRefQualifier() == RQ_RValue) + Flags |= llvm::DIDescriptor::FlagRValueReference; llvm::DIArray TParamsArray = CollectFunctionTemplateParams(Method, Unit); llvm::DISubprogram SP = diff --git a/test/CodeGenCXX/debug-info-qualifiers.cpp b/test/CodeGenCXX/debug-info-qualifiers.cpp new file mode 100644 index 0000000000..9139b1d2ff --- /dev/null +++ b/test/CodeGenCXX/debug-info-qualifiers.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s +// Test (r)value qualifiers on C++11 non-static member functions. +class A { +public: + // CHECK: [ DW_TAG_subprogram ] [line [[@LINE+1]]] [reference] [l] + void l() const &; + // CHECK: [ DW_TAG_subprogram ] [line [[@LINE+1]]] [rvalue reference] [r] + void r() const &&; +}; + +void g() { + A a; + // The type of pl is "void (A::*)() const &". + // CHECK: metadata ![[PL:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_auto_variable ] [pl] [line [[@LINE+3]]] + // CHECK: metadata ![[PLSR:[0-9]+]], metadata !"{{.*}}"} ; [ DW_TAG_ptr_to_member_type ] + // CHECK: ![[PLSR]] ={{.*}}[ DW_TAG_subroutine_type ]{{.*}}[reference] + auto pl = &A::l; + + // CHECK: metadata ![[PR:[0-9]+]], i32 0, i32 0} ; [ DW_TAG_auto_variable ] [pr] [line [[@LINE+3]]] + // CHECK: metadata ![[PRSR:[0-9]+]], metadata !"{{.*}}"} ; [ DW_TAG_ptr_to_member_type ] + // CHECK: ![[PRSR]] ={{.*}}[ DW_TAG_subroutine_type ]{{.*}}[rvalue reference] + auto pr = &A::r; +}