diff options
| author | Dan Gohman <gohman@apple.com> | 2010-10-26 21:13:51 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-10-26 21:13:51 +0000 |
| commit | 52765215d00290326b81e1f8d2bc96187541f304 (patch) | |
| tree | c85abcfdbe99cd57767648c52444d701846687c1 /clang/lib/Frontend/CompilerInstance.cpp | |
| parent | 0fbb20769fa4e6def8d7e54e08d0e5eb06077722 (diff) | |
| download | llvm-52765215d00290326b81e1f8d2bc96187541f304.zip llvm-52765215d00290326b81e1f8d2bc96187541f304.tar.gz llvm-52765215d00290326b81e1f8d2bc96187541f304.tar.bz2 | |
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
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
| -rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
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 @@ 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; } |
