r304538 - Avoid calling report_fatal_error in the destructor of raw_fd_ostream

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 2 03:36:57 PDT 2017


Author: arphaman
Date: Fri Jun  2 05:36:56 2017
New Revision: 304538

URL: http://llvm.org/viewvc/llvm-project?rev=304538&view=rev
Log:
Avoid calling report_fatal_error in the destructor of raw_fd_ostream
when saving a module timestamp file

This commit doesn't include a test as it requires a test that reproduces
a file write/close error that couldn't really be constructed artificially.

rdar://31860650

Differential Revision: https://reviews.llvm.org/D33357

Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=304538&r1=304537&r2=304538&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Jun  2 05:36:56 2017
@@ -3697,6 +3697,8 @@ static void updateModuleTimestamp(Module
   if (EC)
     return;
   OS << "Timestamp file\n";
+  OS.close();
+  OS.clear_error(); // Avoid triggering a fatal error.
 }
 
 /// \brief Given a cursor at the start of an AST file, scan ahead and drop the




More information about the cfe-commits mailing list