Skip to content

Commit b9ab309

Browse files
author
Devang Patel
committed
Encode field accessibility.
llvm-svn: 102033
1 parent 26274da commit b9ab309

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,13 +525,20 @@ CollectRecordFields(const RecordDecl *RD, llvm::DIFile Unit,
525525

526526
uint64_t FieldOffset = RL.getFieldOffset(FieldNo);
527527

528+
unsigned Flags = 0;
529+
AccessSpecifier Access = I->getAccess();
530+
if (Access == clang::AS_private)
531+
Flags |= llvm::DIType::FlagPrivate;
532+
else if (Access == clang::AS_protected)
533+
Flags |= llvm::DIType::FlagProtected;
534+
528535
// Create a DW_TAG_member node to remember the offset of this field in the
529536
// struct. FIXME: This is an absolutely insane way to capture this
530537
// information. When we gut debug info, this should be fixed.
531538
FieldTy = DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_member, Unit,
532539
FieldName, FieldDefUnit,
533540
FieldLine, FieldSize, FieldAlign,
534-
FieldOffset, 0, FieldTy);
541+
FieldOffset, Flags, FieldTy);
535542
EltTys.push_back(FieldTy);
536543
}
537544
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -g -S -masm-verbose -o %t %s
2+
// RUN: grep DW_AT_accessibility %t
3+
4+
class A {
5+
public:
6+
int p;
7+
private:
8+
int pr;
9+
};
10+
11+
A a;

0 commit comments

Comments
 (0)