From: Daniel Dunbar Date: Mon, 27 Apr 2009 21:19:07 +0000 (+0000) Subject: Add -empty-input-only option, for timing. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=57cbfc0c52d7a27cce1e12e79d204f80e324e1c8;p=clang 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 bba5723724..6f159e0615 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -168,6 +168,9 @@ static llvm::cl::opt DisableFree("disable-free", llvm::cl::desc("Disable freeing of memory on exit"), llvm::cl::init(false)); +static llvm::cl::opt +EmptyInputOnly("empty-input-only", + llvm::cl::desc("Force running on an empty input file")); enum ProgActions { RewriteObjC, // ObjC->C Rewriter. @@ -1037,8 +1040,13 @@ static bool InitializeSourceManager(Preprocessor &PP, // 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, ""); + SourceMgr.createMainFileIDForMemBuffer(SB); + } else if (InFile != "-") { const FileEntry *File = FileMgr.getFile(InFile); if (File) SourceMgr.createMainFileID(File, SourceLocation()); if (SourceMgr.getMainFileID().isInvalid()) {