]> granicus.if.org Git - clang/commit
BitStream reader: propagate errors
authorJF Bastien <jfbastien@apple.com>
Wed, 26 Jun 2019 19:50:12 +0000 (19:50 +0000)
committerJF Bastien <jfbastien@apple.com>
Wed, 26 Jun 2019 19:50:12 +0000 (19:50 +0000)
commit0ad57c86b23bd29ec94af2ba29d5ff57582f3076
treeeacbf0473da17298b1cb05aca9f24f580388eca8
parentfb2a26cc2e40e007f19532b4e139d5f0a636d5c9
BitStream reader: propagate errors

The bitstream reader handles errors poorly. This has two effects:

 * Bugs in file handling (especially modules) manifest as an "unexpected end of
   file" crash
 * Users of clang as a library end up aborting because the code unconditionally
   calls `report_fatal_error`

The bitstream reader should be more resilient and return Expected / Error as
soon as an error is encountered, not way late like it does now. This patch
starts doing so and adopting the error handling where I think it makes sense.
There's plenty more to do: this patch propagates errors to be minimally useful,
and follow-ups will propagate them further and improve diagnostics.

https://bugs.llvm.org/show_bug.cgi?id=42311
<rdar://problem/33159405>

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@364464 91177308-0d34-0410-b5e6-96231b3b80d8
16 files changed:
include/clang/Basic/Diagnostic.h
include/clang/Frontend/FrontendAction.h
include/clang/Serialization/ASTReader.h
include/clang/Serialization/GlobalModuleIndex.h
lib/Frontend/ASTUnit.cpp
lib/Frontend/CompilerInstance.cpp
lib/Frontend/FrontendAction.cpp
lib/Frontend/PrecompiledPreamble.cpp
lib/Frontend/Rewrite/FrontendActions.cpp
lib/Frontend/SerializedDiagnosticReader.cpp
lib/Frontend/TestModuleFileExtension.cpp
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTReaderStmt.cpp
lib/Serialization/GlobalModuleIndex.cpp
test/Index/pch-from-libclang.c