]> granicus.if.org Git - clang/commitdiff
Encode field accessibility.
authorDevang Patel <dpatel@apple.com>
Wed, 21 Apr 2010 23:12:37 +0000 (23:12 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 21 Apr 2010 23:12:37 +0000 (23:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102033 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 1fdb2e5c20db5a648138c2a4f0b317138959b4cd..2a5b7af71212e8b1b4e8edb1007c487c3b5a01bf 100644 (file)
@@ -525,13 +525,20 @@ CollectRecordFields(const RecordDecl *RD, llvm::DIFile Unit,
 
     uint64_t FieldOffset = RL.getFieldOffset(FieldNo);
 
+    unsigned Flags = 0;
+    AccessSpecifier Access = I->getAccess();
+    if (Access == clang::AS_private)
+      Flags |= llvm::DIType::FlagPrivate;
+    else if (Access == clang::AS_protected)
+      Flags |= llvm::DIType::FlagProtected;
+
     // Create a DW_TAG_member node to remember the offset of this field in the
     // struct.  FIXME: This is an absolutely insane way to capture this
     // information.  When we gut debug info, this should be fixed.
     FieldTy = DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_member, Unit,
                                              FieldName, FieldDefUnit,
                                              FieldLine, FieldSize, FieldAlign,
-                                             FieldOffset, 0, FieldTy);
+                                             FieldOffset, Flags, FieldTy);
     EltTys.push_back(FieldTy);
   }
 }
diff --git a/test/CodeGenCXX/field-access-debug-info.cpp b/test/CodeGenCXX/field-access-debug-info.cpp
new file mode 100644 (file)
index 0000000..907fe04
--- /dev/null
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -g -S -masm-verbose -o %t %s
+// RUN: grep DW_AT_accessibility %t
+
+class A {
+public:
+  int p;
+private:
+  int pr;
+};
+
+A a;