summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/RecordLayoutBuilder.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-04-19 20:44:53 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-04-19 20:44:53 +0000
commitccabe48235f8269cceba7f01a7acd88e252b4293 (patch)
tree93c3f611af311987e57de63a2b3df3a86a77d9aa /clang/lib/AST/RecordLayoutBuilder.cpp
parent2ea5183b5951d125673e510198af04d92591623c (diff)
downloadbcm5719-llvm-ccabe48235f8269cceba7f01a7acd88e252b4293.tar.gz
bcm5719-llvm-ccabe48235f8269cceba7f01a7acd88e252b4293.zip
AST: Dump ASTRecordLayout objects when they are created with -fdump-record-layouts.
llvm-svn: 101815
Diffstat (limited to 'clang/lib/AST/RecordLayoutBuilder.cpp')
-rw-r--r--clang/lib/AST/RecordLayoutBuilder.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp
index 3038d912fc3..3782985e530 100644
--- a/clang/lib/AST/RecordLayoutBuilder.cpp
+++ b/clang/lib/AST/RecordLayoutBuilder.cpp
@@ -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";
+}
OpenPOWER on IntegriCloud