[PATCH] D63518: WIP BitStream reader: propagate errors

JF Bastien via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 18 14:55:31 PDT 2019


jfb created this revision.
jfb added reviewers: Bigcheese, bruno, arphaman, vsapsai.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, jkorous, hiraditya.
Herald added projects: clang, LLVM.
jfb added a comment.

This is still a work in progress. I still have to debug clang tests that fail, and compile / fix more than clang.


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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63518

Files:
  clang/include/clang/Basic/Diagnostic.h
  clang/include/clang/Frontend/FrontendAction.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/GlobalModuleIndex.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/PrecompiledPreamble.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/lib/Frontend/SerializedDiagnosticReader.cpp
  clang/lib/Frontend/TestModuleFileExtension.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/GlobalModuleIndex.cpp
  llvm/include/llvm/Bitcode/BitstreamReader.h
  llvm/include/llvm/Support/Error.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Reader/BitstreamReader.cpp
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63518.205440.patch
Type: text/x-patch
Size: 142739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190618/33d8add2/attachment-0001.bin>


More information about the cfe-commits mailing list