]> granicus.if.org Git - clang/commitdiff
Fronted: Kill overly specialized RecordLayoutDumper, just make -dump-record-layouts...
authorDaniel Dunbar <daniel@zuster.org>
Thu, 8 Apr 2010 02:59:56 +0000 (02:59 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 8 Apr 2010 02:59:56 +0000 (02:59 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100747 91177308-0d34-0410-b5e6-96231b3b80d8

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

index fdf69d063f4d82178d3ad2c7db2133819f2f8aa4..1dfc7a1dfa80b094f71442aaa863d6ee4680c323 100644 (file)
@@ -98,8 +98,8 @@ public:
   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 @@ public:
     CharIsSigned = 1;
     ShortWChar = 0;
     CatchUndefined = 0;
+    DumpRecordLayouts = 0;
     DumpVtableLayouts = 0;
   }
 
index 93cf495b52891e323398c0443fa63dc940424e64..3d730153be9f98b03c03fdc7a595514166e2ff44 100644 (file)
@@ -285,8 +285,6 @@ def ast_view : Flag<"-ast-view">,
   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 print_stats : Flag<"-print-stats">,
 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
 //===----------------------------------------------------------------------===//
index b5b09f536d6ea7363490aa87eac1059846c38cd1..9163a208de2eddbc94b026874798bc7b548f754c 100644 (file)
@@ -57,10 +57,6 @@ ASTConsumer *CreateASTViewer();
 // 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,
index a7b6aa7e752f3698dc90c4178d07abc1dc034bb8..8c9ebca88732d2a15507f228926078d904268e34 100644 (file)
@@ -73,12 +73,6 @@ protected:
                                          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;
index ee3811a30b946f09cf9348ba9ff7ba88cd6a3c05..7b4df1f667fe5599dd9560e595fd2df2dfa625fb 100644 (file)
@@ -24,7 +24,6 @@ namespace frontend {
     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.
index 9186e4572ffb260e2c49ab71a62d47e02ce28213..b53a80e47bc5c127dc6017249087b38c70811ebe 100644 (file)
@@ -435,38 +435,6 @@ ASTConsumer *clang::CreateDeclContextPrinter() {
   return new DeclContextPrinter();
 }
 
-//===----------------------------------------------------------------------===//
-/// 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
 
index 8aaef80b6e0836af796dc9209027d8f599072577..0ab70a9c16353a15c3bce9a329e588edcf2e4b95 100644 (file)
@@ -283,7 +283,6 @@ static const char *getActionName(frontend::ActionKind Kind) {
   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 @@ ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, Diagnostic &Diags) {
       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 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args,
   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;
 
index 87badc7711f405a39404a2c1afb7eb3f9548d2f1..6d7c6a8460bff108cf0da793c6f593e8ea553a92 100644 (file)
@@ -74,11 +74,6 @@ ASTConsumer *DeclContextPrintAction::CreateASTConsumer(CompilerInstance &CI,
   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;
index 7cd39895f6fde9d3b2c9ce4e321f809d325afaa4..f620927a8dd6b8a90b85e58adad7fc946a146d87 100644 (file)
 
 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 @@ 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 =
index d329c525ac1d38269d7f775704689902fa2cccf7..e9663f4bbc591b5a5690aaba7828cb77ec00ca9f 100644 (file)
@@ -64,7 +64,6 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {
   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();