]> granicus.if.org Git - clang/commitdiff
Debug info: Implement (rvalue) reference qualifiers for C++11 non-static
authorAdrian Prantl <aprantl@apple.com>
Wed, 18 Dec 2013 21:48:18 +0000 (21:48 +0000)
committerAdrian Prantl <aprantl@apple.com>
Wed, 18 Dec 2013 21:48:18 +0000 (21:48 +0000)
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

lib/CodeGen/CGDebugInfo.cpp
test/CodeGenCXX/debug-info-qualifiers.cpp [new file with mode: 0644]

index df6868ab1a5415612e78da3ec7130bd80c73ab75..5483e27693c8cec7d63fa74d80e73c6588754e3c 100644 (file)
@@ -37,7 +37,7 @@
 #include "llvm/IR/Module.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/Support/Path.h"\r
+#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 (file)
index 0000000..9139b1d
--- /dev/null
@@ -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;
+}