AST: Dump ASTRecordLayout objects when they are created with -fdump-record-layouts.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101815 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-04-19 20:44:53 +00:00
Родитель 2e7b7c2f26
Коммит 8d8ab749f6
3 изменённых файлов: 31 добавлений и 13 удалений

Просмотреть файл

@ -998,6 +998,11 @@ const ASTRecordLayout &ASTContext::getASTRecordLayout(const RecordDecl *D) {
ASTRecordLayoutBuilder::ComputeLayout(*this, D);
ASTRecordLayouts[D] = NewEntry;
if (getLangOptions().DumpRecordLayouts) {
llvm::errs() << "\n*** Dumping AST Record Layout\n";
DumpRecordLayout(D, llvm::errs());
}
return *NewEntry;
}

Просмотреть файл

@ -860,7 +860,7 @@ const CXXMethodDecl *
ASTRecordLayoutBuilder::ComputeKeyFunction(const CXXRecordDecl *RD) {
assert(RD->isDynamicClass() && "Class does not have any virtual methods!");
// If a class isnt' polymorphic it doesn't have a key function.
// If a class isn't polymorphic it doesn't have a key function.
if (!RD->isPolymorphic())
return 0;
@ -983,17 +983,6 @@ static void DumpCXXRecordLayout(llvm::raw_ostream &OS,
"(primary virtual base)" : "(virtual base)",
/*IncludeVirtualBases=*/false);
}
}
void ASTContext::DumpRecordLayout(const RecordDecl *RD,
llvm::raw_ostream &OS) {
const ASTRecordLayout &Info = getASTRecordLayout(RD);
if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD))
DumpCXXRecordLayout(OS, CXXRD, *this, 0, 0, 0,
/*IncludeVirtualBases=*/true);
else
OS << getTypeDeclType(RD).getAsString();
OS << " sizeof=" << Info.getSize() / 8;
OS << ", dsize=" << Info.getDataSize() / 8;
@ -1002,3 +991,27 @@ void ASTContext::DumpRecordLayout(const RecordDecl *RD,
OS << ", nvalign=" << Info.getNonVirtualAlign() / 8 << '\n';
OS << '\n';
}
void ASTContext::DumpRecordLayout(const RecordDecl *RD,
llvm::raw_ostream &OS) {
const ASTRecordLayout &Info = getASTRecordLayout(RD);
if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD))
return DumpCXXRecordLayout(OS, CXXRD, *this, 0, 0, 0,
/*IncludeVirtualBases=*/true);
OS << "Type: " << getTypeDeclType(RD).getAsString() << "\n";
OS << "Record: ";
RD->dump();
OS << "\nLayout: ";
OS << "<ASTRecordLayout\n";
OS << " Size:" << Info.getSize() << "\n";
OS << " DataSize:" << Info.getDataSize() << "\n";
OS << " Alignment:" << Info.getAlignment() << "\n";
OS << " FieldOffsets: [";
for (unsigned i = 0, e = Info.getFieldCount(); i != e; ++i) {
if (i) OS << ", ";
OS << Info.getFieldOffset(i);
}
OS << "]>\n";
}

Просмотреть файл

@ -566,7 +566,7 @@ CGRecordLayout *CodeGenTypes::ComputeRecordLayout(const RecordDecl *D) {
// Dump the layout, if requested.
if (getContext().getLangOptions().DumpRecordLayouts) {
llvm::errs() << "\n*** Dumping Record Layout\n";
llvm::errs() << "\n*** Dumping IRgen Record Layout\n";
llvm::errs() << "Record: ";
D->dump();
llvm::errs() << "\nLayout: ";