[cfe-commits] r98978 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/FrontendActions.h include/clang/Frontend/FrontendOptions.h lib/Frontend/CompilerInstance.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendActions.cpp tools/driver/cc1_main.cpp

Daniel Dunbar daniel at zuster.org
Fri Mar 19 12:44:04 PDT 2010


Author: ddunbar
Date: Fri Mar 19 14:44:04 2010
New Revision: 98978

URL: http://llvm.org/viewvc/llvm-project?rev=98978&view=rev
Log:
clang -cc1: Kill off -empty-input only, and replace with -init-only which is an
actual action.
 - This is easier to use, and more reliable for timing the thing this was
   actually meant to be useful for.

Modified:
    cfe/trunk/include/clang/Driver/CC1Options.td
    cfe/trunk/include/clang/Frontend/FrontendActions.h
    cfe/trunk/include/clang/Frontend/FrontendOptions.h
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/lib/Frontend/FrontendActions.cpp
    cfe/trunk/tools/driver/cc1_main.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=98978&r1=98977&r2=98978&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Mar 19 14:44:04 2010
@@ -227,8 +227,6 @@
   HelpText<"Include macros in code-completion results">;
 def disable_free : Flag<"-disable-free">,
   HelpText<"Disable freeing of memory on exit">;
-def empty_input_only : Flag<"-empty-input-only">,
-  HelpText<"Force running on an empty input file">;
 def help : Flag<"-help">,
   HelpText<"Print this help text">;
 def _help : Flag<"--help">, Alias<help>;
@@ -262,6 +260,8 @@
   HelpText<"Run static analysis engine">;
 def dump_tokens : Flag<"-dump-tokens">,
   HelpText<"Run preprocessor, dump internal rep of tokens">;
+def init_only : Flag<"-init-only">,
+  HelpText<"Only execute frontend initialization">;
 def parse_noop : Flag<"-parse-noop">,
   HelpText<"Run parser with noop callbacks (for timings)">;
 def fsyntax_only : Flag<"-fsyntax-only">,

Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=98978&r1=98977&r2=98978&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Fri Mar 19 14:44:04 2010
@@ -18,6 +18,22 @@
 class FixItRewriter;
 
 //===----------------------------------------------------------------------===//
+// Custom Consumer Actions
+//===----------------------------------------------------------------------===//
+
+class InitOnlyAction : public FrontendAction {
+  virtual void ExecuteAction();
+
+  virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+                                         llvm::StringRef InFile);
+
+public:
+  // Don't claim to only use the preprocessor, we want to follow the AST path,
+  // but do nothing.
+  virtual bool usesPreprocessorOnly() const { return false; }
+};
+
+//===----------------------------------------------------------------------===//
 // AST Consumer Actions
 //===----------------------------------------------------------------------===//
 

Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=98978&r1=98977&r2=98978&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Fri Mar 19 14:44:04 2010
@@ -36,6 +36,7 @@
     GeneratePCH,            ///< Generate pre-compiled header.
     GeneratePTH,            ///< Generate pre-tokenized header.
     InheritanceView,        ///< View C++ inheritance for a specified class.
+    InitOnly,               ///< Only execute frontend initialization.
     ParseNoop,              ///< Parse with noop callbacks.
     ParsePrintCallbacks,    ///< Parse and print each callback.
     ParseSyntaxOnly,        ///< Parse and perform semantic analysis.
@@ -71,9 +72,6 @@
   unsigned DebugCodeCompletionPrinter : 1; ///< Use the debug printer for code
                                            /// completion results.
   unsigned DisableFree : 1;                ///< Disable memory freeing on exit.
-  unsigned EmptyInputOnly : 1;             ///< Force input files to be treated
-                                           /// as if they were empty, for timing
-                                           /// the frontend startup.
   unsigned RelocatablePCH : 1;             ///< When generating PCH files,
                                            /// instruct the PCH writer to create
                                            /// relocatable PCH files.
@@ -117,7 +115,6 @@
   FrontendOptions() {
     DebugCodeCompletionPrinter = 1;
     DisableFree = 0;
-    EmptyInputOnly = 0;
     ProgramAction = frontend::ParseSyntaxOnly;
     ActionName = "";
     RelocatablePCH = 0;

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=98978&r1=98977&r2=98978&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Mar 19 14:44:04 2010
@@ -429,12 +429,7 @@
                                                SourceManager &SourceMgr,
                                                const FrontendOptions &Opts) {
   // Figure out where to get and map in the main file.
-  if (Opts.EmptyInputOnly) {
-    const char *EmptyStr = "";
-    llvm::MemoryBuffer *SB =
-      llvm::MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, "<empty input>");
-    SourceMgr.createMainFileIDForMemBuffer(SB);
-  } else if (InputFile != "-") {
+  if (InputFile != "-") {
     const FileEntry *File = FileMgr.getFile(InputFile);
     if (File) SourceMgr.createMainFileID(File, SourceLocation());
     if (SourceMgr.getMainFileID().isInvalid()) {

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=98978&r1=98977&r2=98978&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Mar 19 14:44:04 2010
@@ -288,6 +288,7 @@
   case frontend::FixIt:                  return "-fixit";
   case frontend::GeneratePCH:            return "-emit-pch";
   case frontend::GeneratePTH:            return "-emit-pth";
+  case frontend::InitOnly:               return "-init-only";
   case frontend::ParseNoop:              return "-parse-noop";
   case frontend::ParsePrintCallbacks:    return "-parse-print-callbacks";
   case frontend::ParseSyntaxOnly:        return "-fsyntax-only";
@@ -310,8 +311,6 @@
     Res.push_back("-no-code-completion-debug-printer");
   if (Opts.DisableFree)
     Res.push_back("-disable-free");
-  if (Opts.EmptyInputOnly)
-    Res.push_back("-empty-input-only");
   if (Opts.RelocatablePCH)
     Res.push_back("-relocatable-pch");
   if (Opts.ShowHelp)
@@ -878,6 +877,8 @@
       Opts.ProgramAction = frontend::GeneratePCH; break;
     case OPT_emit_pth:
       Opts.ProgramAction = frontend::GeneratePTH; break;
+    case OPT_init_only:
+      Opts.ProgramAction = frontend::InitOnly; break;
     case OPT_parse_noop:
       Opts.ProgramAction = frontend::ParseNoop; break;
     case OPT_parse_print_callbacks:
@@ -915,7 +916,6 @@
   Opts.DebugCodeCompletionPrinter =
     !Args.hasArg(OPT_no_code_completion_debug_printer);
   Opts.DisableFree = Args.hasArg(OPT_disable_free);
-  Opts.EmptyInputOnly = Args.hasArg(OPT_empty_input_only);
 
   Opts.FixItLocations.clear();
   for (arg_iterator it = Args.filtered_begin(OPT_fixit_at),

Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=98978&r1=98977&r2=98978&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Mar 19 14:44:04 2010
@@ -23,6 +23,18 @@
 using namespace clang;
 
 //===----------------------------------------------------------------------===//
+// Custom Actions
+//===----------------------------------------------------------------------===//
+
+ASTConsumer *InitOnlyAction::CreateASTConsumer(CompilerInstance &CI,
+                                               llvm::StringRef InFile) {
+  return new ASTConsumer();
+}
+
+void InitOnlyAction::ExecuteAction() {
+}
+
+//===----------------------------------------------------------------------===//
 // AST Consumer Actions
 //===----------------------------------------------------------------------===//
 

Modified: cfe/trunk/tools/driver/cc1_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1_main.cpp?rev=98978&r1=98977&r2=98978&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1_main.cpp Fri Mar 19 14:44:04 2010
@@ -74,6 +74,7 @@
   case GeneratePCH:            return new GeneratePCHAction();
   case GeneratePTH:            return new GeneratePTHAction();
   case InheritanceView:        return new InheritanceViewAction();
+  case InitOnly:               return new InitOnlyAction();
   case ParseNoop:              return new ParseOnlyAction();
   case ParsePrintCallbacks:    return new PrintParseAction();
   case ParseSyntaxOnly:        return new SyntaxOnlyAction();





More information about the cfe-commits mailing list