diff options
Diffstat (limited to 'lib/Sema/ParseAST.cpp')
-rw-r--r-- | lib/Sema/ParseAST.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/Sema/ParseAST.cpp b/lib/Sema/ParseAST.cpp index 7cd3989..bb0bd9e 100644 --- a/lib/Sema/ParseAST.cpp +++ b/lib/Sema/ParseAST.cpp @@ -24,6 +24,26 @@ using namespace clang; +static void DumpRecordLayouts(ASTContext &C) { + for (ASTContext::type_iterator I = C.types_begin(), E = C.types_end(); + I != E; ++I) { + const RecordType *RT = dyn_cast<RecordType>(*I); + if (!RT) + continue; + + const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl()); + if (!RD || RD->isImplicit() || RD->isDependentType() || + RD->isInvalidDecl() || !RD->getDefinition()) + continue; + + // FIXME: Do we really need to hard code this? + if (RD->getQualifiedNameAsString() == "__va_list_tag") + continue; + + C.DumpRecordLayout(RD, llvm::errs()); + } +} + //===----------------------------------------------------------------------===// // Public interface to the file //===----------------------------------------------------------------------===// @@ -44,8 +64,7 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, Sema S(PP, Ctx, *Consumer, CompleteTranslationUnit, CompletionConsumer); Parser P(PP, S); - if (PP.EnterMainSourceFile()) - return; + PP.EnterMainSourceFile(); // Initialize the parser. P.Initialize(); @@ -82,6 +101,10 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer, E = S.WeakTopLevelDecls().end(); I != E; ++I) Consumer->HandleTopLevelDecl(DeclGroupRef(*I)); + // Dump record layouts, if requested. + if (PP.getLangOptions().DumpRecordLayouts) + DumpRecordLayouts(Ctx); + Consumer->HandleTranslationUnit(Ctx); if (ExternalSemaSource *ESS = |