From 694137c54c79a33c9ac6c07e68327750dcd5adf7 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 26 Oct 2010 21:13:51 +0000 Subject: [PATCH] Simplify this code: don't check for the same error two different ways. Check once, and use an assert to handle consistency checking. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117397 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/CompilerInstance.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 2777e4dae4..a187140ca0 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -468,20 +468,22 @@ bool CompilerInstance::InitializeSourceManager(llvm::StringRef InputFile, // 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; } -- 2.40.0