Simplify this code: don't check for the same error two
different ways. Check once, and use an assert to handle
consistency checking.
llvm-svn: 117397
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 2777e4d..a187140 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -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;
}