[cfe-commits] r117397 - /cfe/trunk/lib/Frontend/CompilerInstance.cpp

Dan Gohman gohman at apple.com
Tue Oct 26 14:13:51 PDT 2010


Author: djg
Date: Tue Oct 26 16:13:51 2010
New Revision: 117397

URL: http://llvm.org/viewvc/llvm-project?rev=117397&view=rev
Log:
Simplify this code: don't check for the same error two
different ways. Check once, and use an assert to handle
consistency checking.

Modified:
    cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=117397&r1=117396&r2=117397&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Oct 26 16:13:51 2010
@@ -468,20 +468,22 @@
   // Figure out where to get and map in the main file.
   if (InputFile != "-") {
     const FileEntry *File = FileMgr.getFile(InputFile);
-    if (File) SourceMgr.createMainFileID(File);
-    if (SourceMgr.getMainFileID().isInvalid()) {
+    if (!File) {
       Diags.Report(diag::err_fe_error_reading) << InputFile;
       return false;
     }
+    SourceMgr.createMainFileID(File);
   } else {
     llvm::MemoryBuffer *SB = llvm::MemoryBuffer::getSTDIN();
-    if (SB) SourceMgr.createMainFileIDForMemBuffer(SB);
-    if (SourceMgr.getMainFileID().isInvalid()) {
+    if (!SB) {
       Diags.Report(diag::err_fe_error_reading_stdin);
       return false;
     }
+    SourceMgr.createMainFileIDForMemBuffer(SB);
   }
 
+  assert(!SourceMgr.getMainFileID().isInvalid() &&
+         "Couldn't establish MainFileID!");
   return true;
 }
 





More information about the cfe-commits mailing list