patch-r271432-clang-r205331-debug-info-crash.diff revision 271729
1commit 96365aef99ec463375dfdaf6eb260823e0477b6a
2Author: Adrian Prantl <aprantl@apple.com>
3Date:   Tue Apr 1 17:52:06 2014 +0000
4
5    Debug info: fix a crash when emitting IndirectFieldDecls, which were
6    previously not handled at all.
7    rdar://problem/16348575
8    
9    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205331 91177308-0d34-0410-b5e6-96231b3b80d8
10
11diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
12index 82db942..2556cf9 100644
13--- tools/clang/lib/CodeGen/CGDebugInfo.cpp
14+++ tools/clangb/lib/CodeGen/CGDebugInfo.cpp
15@@ -1252,7 +1252,7 @@ CollectTemplateParams(const TemplateParameterList *TPList,
16         V = CGM.GetAddrOfFunction(FD);
17       // Member data pointers have special handling too to compute the fixed
18       // offset within the object.
19-      if (isa<FieldDecl>(D)) {
20+      if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) {
21         // These five lines (& possibly the above member function pointer
22         // handling) might be able to be refactored to use similar code in
23         // CodeGenModule::getMemberPointerConstant
24diff --git a/test/CodeGenCXX/debug-info-indirect-field-decl.cpp b/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
25new file mode 100644
26index 0000000..131ceba
27--- /dev/null
28+++ tools/clang/test/CodeGenCXX/debug-info-indirect-field-decl.cpp
29@@ -0,0 +1,17 @@
30+// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s
31+//
32+// Test that indirect field decls are handled gracefully.
33+// rdar://problem/16348575
34+//
35+template <class T, int T::*ptr> class Foo {  };
36+
37+struct Bar {
38+  int i1;
39+  // CHECK: [ DW_TAG_member ] [line [[@LINE+1]], size 32, align 32, offset 32] [from _ZTSN3BarUt_E]
40+  union {
41+    // CHECK: [ DW_TAG_member ] [i2] [line [[@LINE+1]], size 32, align 32, offset 0] [from int]
42+    int i2;
43+  };
44+};
45+
46+Foo<Bar, &Bar::i2> the_foo;
47