]> granicus.if.org Git - clang/commitdiff
Debug info: fix a crash when emitting IndirectFieldDecls, which were
authorAdrian Prantl <aprantl@apple.com>
Tue, 1 Apr 2014 17:52:06 +0000 (17:52 +0000)
committerAdrian Prantl <aprantl@apple.com>
Tue, 1 Apr 2014 17:52:06 +0000 (17:52 +0000)
previously not handled at all.
rdar://problem/16348575

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205331 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 82db942e2956d9dc327adef29bdab9664a697fbb..2556cf98508cd2f76bd591b5ca9494bb161e2e60 100644 (file)
@@ -1252,7 +1252,7 @@ CollectTemplateParams(const TemplateParameterList *TPList,
         V = CGM.GetAddrOfFunction(FD);
       // Member data pointers have special handling too to compute the fixed
       // offset within the object.
-      if (isa<FieldDecl>(D)) {
+      if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) {
         // These five lines (& possibly the above member function pointer
         // handling) might be able to be refactored to use similar code in
         // CodeGenModule::getMemberPointerConstant
diff --git a/test/CodeGenCXX/debug-info-indirect-field-decl.cpp b/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
new file mode 100644 (file)
index 0000000..131ceba
--- /dev/null
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
+//
+// Test that indirect field decls are handled gracefully.
+// rdar://problem/16348575
+//
+template <class T, int T::*ptr> class Foo {  };
+
+struct Bar {
+  int i1;
+  // CHECK: [ DW_TAG_member ] [line [[@LINE+1]], size 32, align 32, offset 32] [from _ZTSN3BarUt_E]
+  union {
+    // CHECK: [ DW_TAG_member ] [i2] [line [[@LINE+1]], size 32, align 32, offset 0] [from int]
+    int i2;
+  };
+};
+
+Foo<Bar, &Bar::i2> the_foo;