vleschuk updated this revision to Diff 70949.
vleschuk added a comment.
Reverted formatting changes.
https://reviews.llvm.org/D24426
Files:
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -238,6 +238,13 @@
llvm::DIScope *scope,
const RecordDecl *RD = nullptr);
+ llvm::DIType *createFieldType(StringRef Name, QualType Type,
+SourceLocation Loc, uint64_t AlignInBits,
+uint64_t OffsetInBits,
+llvm::DINode::DIFlags Flags,
+llvm::DIFile *TUnit, llvm::DIScope *Scope,
+const RecordDecl *RD = nullptr);
+
/// Create new bit field member.
llvm::DIType *createBitFieldType(const FieldDecl *BitFieldDecl,
llvm::DIScope *RecordTy,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -999,6 +999,28 @@
AlignInBits, offsetInBits, flags, debugType);
}
+llvm::DIType *
+CGDebugInfo::createFieldType(StringRef Name, QualType Type, SourceLocation Loc,
+ uint64_t AlignInBits, uint64_t OffsetInBits,
+ llvm::DINode::DIFlags Flags,
+ llvm::DIFile *TUnit, llvm::DIScope *Scope,
+ const RecordDecl *RD) {
+ llvm::DIType *DebugType = getOrCreateType(Type, TUnit);
+
+ // Get the location for the field.
+ llvm::DIFile *File = getOrCreateFile(Loc);
+ unsigned Line = getLineNumber(Loc);
+
+ uint64_t SizeInBits = 0;
+ if (!Type->isIncompleteArrayType()) {
+TypeInfo TI = CGM.getContext().getTypeInfo(Type);
+SizeInBits = TI.Width;
+ }
+
+ return DBuilder.createMemberType(Scope, Name, File, Line, SizeInBits,
+ AlignInBits, OffsetInBits, Flags, DebugType);
+}
+
void CGDebugInfo::CollectRecordLambdaFields(
const CXXRecordDecl *CXXDecl, SmallVectorImpl ,
llvm::DIType *RecordTy) {
@@ -1012,15 +1034,21 @@
E = CXXDecl->captures_end();
I != E; ++I, ++Field, ++fieldno) {
const LambdaCapture = *I;
+uint64_t AlignInBits = 0;
+llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
if (C.capturesVariable()) {
SourceLocation Loc = C.getLocation();
assert(!Field->isBitField() && "lambdas don't have bitfield members!");
VarDecl *V = C.getCapturedVar();
StringRef VName = V->getName();
+ AlignInBits = V->getMaxAlignment();
+ Flags |= getAccessFlag(Field->getAccess(), CXXDecl);
+ if (V->hasAttr())
+Flags |= llvm::DINode::FlagAlignment;
llvm::DIFile *VUnit = getOrCreateFile(Loc);
llvm::DIType *FieldType = createFieldType(
- VName, Field->getType(), Loc, Field->getAccess(),
- layout.getFieldOffset(fieldno), VUnit, RecordTy, CXXDecl);
+ VName, Field->getType(), Loc, AlignInBits,
+ layout.getFieldOffset(fieldno), Flags, VUnit, RecordTy, CXXDecl);
elements.push_back(FieldType);
} else if (C.capturesThis()) {
// TODO: Need to handle 'this' in some way by probably renaming the
@@ -1061,9 +1089,14 @@
}
}
+ uint64_t AlignInBits = 0;
llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
+ if (Var->hasAttr()) {
+Flags |= llvm::DINode::FlagAlignment;
+AlignInBits = Var->getMaxAlignment();
+ }
llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
- RecordTy, VName, VUnit, LineNumber, VTy, Flags, C);
+ RecordTy, VName, VUnit, LineNumber, VTy, AlignInBits, Flags, C);
StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
return GV;
}
@@ -1074,6 +1107,14 @@
const RecordDecl *RD) {
StringRef name = field->getName();
QualType type = field->getType();
+ uint64_t AlignInBits = 0;
+ llvm::DINode::DIFlags Flags = getAccessFlag(field->getAccess(), RD);
+ if (field->hasAttr()) {
+Flags |= llvm::DINode::FlagAlignment;
+AlignInBits = field->getMaxAlignment();
+ } else if (!type->isIncompleteArrayType()) {
+AlignInBits = CGM.getContext().getTypeInfo(type).Align;
+ }
// Ignore unnamed fields unless they're anonymous structs/unions.
if (name.empty() && !type->isRecordType())
@@ -1084,8 +1125,8 @@
FieldType = createBitFieldType(field, RecordTy, RD);
} else {
FieldType =
-createFieldType(name, type, field->getLocation(), field->getAccess(),
-OffsetInBits, tunit, RecordTy, RD);
+createFieldType(name, type, field->getLocation(), AlignInBits,
+OffsetInBits, Flags, tunit,