diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-12-03 09:13:06 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-12-03 09:13:06 +0000 |
commit | 93ebb1ba9f35ab5e7bff37c471baeb360eeb0b04 (patch) | |
tree | c83562ef561260f6a3e73125c9bbe48de999daf5 /lib/Frontend | |
parent | 3be0d19503f8291b1581a39a8f6ca01d74bf5cb1 (diff) |
Switch PCHReader::getOriginalSourceFile to use proper diagnostics.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 6 | ||||
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 15 |
2 files changed, 9 insertions, 12 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index ccf60fb9e3..2ecbcfe862 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1205,11 +1205,9 @@ static void ParsePreprocessorArgs(PreprocessorOptions &Opts, ArgList &Args, // PCH is handled specially, we need to extra the original include path. if (it->getOption().matches(OPT_include_pch)) { std::string OriginalFile = - PCHReader::getOriginalSourceFile(it->getValue(Args)); - - // FIXME: Don't fail like this. + PCHReader::getOriginalSourceFile(it->getValue(Args), Diags); if (OriginalFile.empty()) - exit(1); + continue; Opts.Includes.push_back(OriginalFile); } else diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index cb96bcb48a..40eb9ca536 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -1569,13 +1569,14 @@ void PCHReader::InitializeContext(ASTContext &Ctx) { /// \brief Retrieve the name of the original source file name /// directly from the PCH file, without actually loading the PCH /// file. -std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) { +std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName, + Diagnostic &Diags) { // Open the PCH file. std::string ErrStr; llvm::OwningPtr<llvm::MemoryBuffer> Buffer; Buffer.reset(llvm::MemoryBuffer::getFile(PCHFileName.c_str(), &ErrStr)); if (!Buffer) { - fprintf(stderr, "error: %s\n", ErrStr.c_str()); + Diags.Report(diag::err_fe_unable_to_read_pch_file) << ErrStr; return std::string(); } @@ -1591,9 +1592,7 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) { Stream.Read(8) != 'P' || Stream.Read(8) != 'C' || Stream.Read(8) != 'H') { - fprintf(stderr, - "error: '%s' does not appear to be a precompiled header file\n", - PCHFileName.c_str()); + Diags.Report(diag::err_fe_not_a_pch_file) << PCHFileName; return std::string(); } @@ -1608,14 +1607,14 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) { switch (BlockID) { case pch::PCH_BLOCK_ID: if (Stream.EnterSubBlock(pch::PCH_BLOCK_ID)) { - fprintf(stderr, "error: malformed block record in PCH file\n"); + Diags.Report(diag::err_fe_pch_malformed_block) << PCHFileName; return std::string(); } break; default: if (Stream.SkipBlock()) { - fprintf(stderr, "error: malformed block record in PCH file\n"); + Diags.Report(diag::err_fe_pch_malformed_block) << PCHFileName; return std::string(); } break; @@ -1625,7 +1624,7 @@ std::string PCHReader::getOriginalSourceFile(const std::string &PCHFileName) { if (Code == llvm::bitc::END_BLOCK) { if (Stream.ReadBlockEnd()) { - fprintf(stderr, "error: error at end of module block in PCH file\n"); + Diags.Report(diag::err_fe_pch_error_at_end_block) << PCHFileName; return std::string(); } continue; |