[cfe-commits] r100747 - in /cfe/trunk: include/clang/Basic/LangOptions.h include/clang/Driver/CC1Options.td include/clang/Frontend/ASTConsumers.h include/clang/Frontend/FrontendActions.h include/clang/Frontend/FrontendOptions.h lib/Frontend/ASTConsumers.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendActions.cpp lib/Sema/ParseAST.cpp tools/driver/cc1_main.cpp
Daniel Dunbar
daniel at zuster.org
Wed Apr 7 19:59:56 PDT 2010
Author: ddunbar
Date: Wed Apr 7 21:59:56 2010
New Revision: 100747
URL: http://llvm.org/viewvc/llvm-project?rev=100747&view=rev
Log:
Fronted: Kill overly specialized RecordLayoutDumper, just make -dump-record-layouts a bit that Sema honors.
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/ASTConsumers.h
cfe/trunk/include/clang/Frontend/FrontendActions.h
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Frontend/ASTConsumers.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Sema/ParseAST.cpp
cfe/trunk/tools/driver/cc1_main.cpp
Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Wed Apr 7 21:59:56 2010
@@ -98,8 +98,8 @@
unsigned ElideConstructors : 1; // Whether C++ copy constructors should be
// elided if possible.
unsigned CatchUndefined : 1; // Generate code to check for undefined ops.
- unsigned DumpVtableLayouts : 1; // Dump the layouts of all the emitted
- // vtables.
+ unsigned DumpRecordLayouts : 1; /// Dump the layout of IRgen'd records.
+ unsigned DumpVtableLayouts : 1; /// Dump the layouts of emitted vtables.
private:
unsigned GC : 2; // Objective-C Garbage Collection modes. We
// declare this enum as unsigned because MSVC
@@ -169,6 +169,7 @@
CharIsSigned = 1;
ShortWChar = 0;
CatchUndefined = 0;
+ DumpRecordLayouts = 0;
DumpVtableLayouts = 0;
}
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Apr 7 21:59:56 2010
@@ -285,8 +285,6 @@
HelpText<"Build ASTs and view them with GraphViz">;
def print_decl_contexts : Flag<"-print-decl-contexts">,
HelpText<"Print DeclContexts and their Decls">;
-def dump_record_layouts : Flag<"-dump-record-layouts">,
- HelpText<"Dump record layout information">;
def emit_pth : Flag<"-emit-pth">,
HelpText<"Generate pre-tokenized header file">;
def emit_pch : Flag<"-emit-pch">,
@@ -317,6 +315,9 @@
def ftime_report : Flag<"-ftime-report">,
HelpText<"Print the amount of time each phase of compilation takes">;
+def dump_record_layouts : Flag<"-dump-record-layouts">,
+ HelpText<"Dump record layout information">;
+
//===----------------------------------------------------------------------===//
// Language Options
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/include/clang/Frontend/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTConsumers.h?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ASTConsumers.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTConsumers.h Wed Apr 7 21:59:56 2010
@@ -57,10 +57,6 @@
// to stderr; this is intended for debugging.
ASTConsumer *CreateDeclContextPrinter();
-// RecordLayout dumper: prints out the record layout information for all records
-// in the translation unit; this is intended for debugging.
-ASTConsumer *CreateRecordLayoutDumper();
-
// ObjC rewriter: attempts tp rewrite ObjC constructs into pure C code.
// This is considered experimental, and only works with Apple's ObjC runtime.
ASTConsumer *CreateObjCRewriter(const std::string &InFile,
Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Wed Apr 7 21:59:56 2010
@@ -73,12 +73,6 @@
llvm::StringRef InFile);
};
-class DumpRecordAction : public ASTFrontendAction {
-protected:
- virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
- llvm::StringRef InFile);
-};
-
class FixItAction : public ASTFrontendAction {
private:
llvm::OwningPtr<FixItRewriter> Rewriter;
Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Wed Apr 7 21:59:56 2010
@@ -24,7 +24,6 @@
ASTPrintXML, ///< Parse ASTs and print them in XML.
ASTView, ///< Parse ASTs and view them in Graphviz.
DumpRawTokens, ///< Dump out raw tokens.
- DumpRecordLayouts, ///< Dump record layout information.
DumpTokens, ///< Dump out preprocessed tokens.
EmitAssembly, ///< Emit a .s file.
EmitBC, ///< Emit a .bc file.
Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Wed Apr 7 21:59:56 2010
@@ -436,38 +436,6 @@
}
//===----------------------------------------------------------------------===//
-/// RecordLayoutDumper - C++ Record Layout Dumping.
-namespace {
-class RecordLayoutDumper : public ASTConsumer {
-public:
- RecordLayoutDumper() {}
-
- void HandleTranslationUnit(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());
- }
- }
-};
-} // end anonymous namespace
-ASTConsumer *clang::CreateRecordLayoutDumper() {
- return new RecordLayoutDumper();
-}
-
-//===----------------------------------------------------------------------===//
/// InheritanceViewer - C++ Inheritance Visualization
namespace {
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Apr 7 21:59:56 2010
@@ -283,7 +283,6 @@
case frontend::ASTPrintXML: return "-ast-print-xml";
case frontend::ASTView: return "-ast-view";
case frontend::DumpRawTokens: return "-dump-raw-tokens";
- case frontend::DumpRecordLayouts: return "-dump-record-layouts";
case frontend::DumpTokens: return "-dump-tokens";
case frontend::EmitAssembly: return "-S";
case frontend::EmitBC: return "-emit-llvm-bc";
@@ -865,8 +864,6 @@
Opts.ProgramAction = frontend::ASTView; break;
case OPT_dump_raw_tokens:
Opts.ProgramAction = frontend::DumpRawTokens; break;
- case OPT_dump_record_layouts:
- Opts.ProgramAction = frontend::DumpRecordLayouts; break;
case OPT_dump_tokens:
Opts.ProgramAction = frontend::DumpTokens; break;
case OPT_S:
@@ -1208,6 +1205,7 @@
Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions);
Opts.Static = Args.hasArg(OPT_static_define);
+ Opts.DumpRecordLayouts = Args.hasArg(OPT_dump_record_layouts);
Opts.DumpVtableLayouts = Args.hasArg(OPT_fdump_vtable_layouts);
Opts.OptimizeSize = 0;
Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Wed Apr 7 21:59:56 2010
@@ -74,11 +74,6 @@
return CreateDeclContextPrinter();
}
-ASTConsumer *DumpRecordAction::CreateASTConsumer(CompilerInstance &CI,
- llvm::StringRef InFile) {
- return CreateRecordLayoutDumper();
-}
-
ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI,
llvm::StringRef InFile) {
const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot;
Modified: cfe/trunk/lib/Sema/ParseAST.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParseAST.cpp?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/ParseAST.cpp (original)
+++ cfe/trunk/lib/Sema/ParseAST.cpp Wed Apr 7 21:59:56 2010
@@ -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
//===----------------------------------------------------------------------===//
@@ -82,6 +102,10 @@
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 =
Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=100747&r1=100746&r2=100747&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Wed Apr 7 21:59:56 2010
@@ -64,7 +64,6 @@
case ASTPrintXML: return new ASTPrintXMLAction();
case ASTView: return new ASTViewAction();
case DumpRawTokens: return new DumpRawTokensAction();
- case DumpRecordLayouts: return new DumpRecordAction();
case DumpTokens: return new DumpTokensAction();
case EmitAssembly: return new EmitAssemblyAction();
case EmitBC: return new EmitBCAction();
More information about the cfe-commits
mailing list