aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-10-26 21:13:51 +0000
committerDan Gohman <gohman@apple.com>2010-10-26 21:13:51 +0000
commit694137c54c79a33c9ac6c07e68327750dcd5adf7 (patch)
treebdd0a0ccc7182d235484bc21e39ee543aa8fa4e8 /lib/Frontend/CompilerInstance.cpp
parent0d06e998910934e5ef070f53f4c272e7c6b846c6 (diff)
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
Diffstat (limited to 'lib/Frontend/CompilerInstance.cpp')
-rw-r--r--lib/Frontend/CompilerInstance.cpp10
1 files 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;
}