Add -empty-input-only option, for timing.
 - Forces input file to be empty to time startup/shutdown costs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70249 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index bba5723..6f159e0 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -168,6 +168,9 @@
 DisableFree("disable-free",
            llvm::cl::desc("Disable freeing of memory on exit"),
            llvm::cl::init(false));
+static llvm::cl::opt<bool>
+EmptyInputOnly("empty-input-only", 
+      llvm::cl::desc("Force running on an empty input file"));
 
 enum ProgActions {
   RewriteObjC,                  // ObjC->C Rewriter.
@@ -1037,8 +1040,13 @@
   // Figure out where to get and map in the main file.
   SourceManager &SourceMgr = PP.getSourceManager();
   FileManager &FileMgr = PP.getFileManager();
-  
-  if (InFile != "-") {
+
+  if (EmptyInputOnly) {
+    const char *EmptyStr = "";
+    llvm::MemoryBuffer *SB = 
+      llvm::MemoryBuffer::getMemBuffer(EmptyStr, EmptyStr, "<empty input>");
+    SourceMgr.createMainFileIDForMemBuffer(SB);
+  } else if (InFile != "-") {
     const FileEntry *File = FileMgr.getFile(InFile);
     if (File) SourceMgr.createMainFileID(File, SourceLocation());
     if (SourceMgr.getMainFileID().isInvalid()) {