DescriptionInstall notion of diagnostic handler into PNaCl bitcode readers.
There has been much divergence between the LLVM and PNaCl bitcode
readers. Part of this has been due to incremental changes in upstream
LLVM, that resulted in two different models of error handling.
The first change in upstream LLVM was a simplification of error
messages to a short list of error codes. When this was ported to
PNaCl, a notion of "verbose" was added to keep more descriptive error
messages.
The second change in upstream LLVM was than to replace the error codes
with a call to a "diagnostic handler function" that took an error_code
and an error message. The diagnostic handler function is responsable
for generating the corresponding error message and (optionally)
stopping the program after generating the corresponding error.
By default, the LLVM bitcode parsers use the diagnostic handler
defined by the LLVM context of the module, which generates a
corresponding fatal error (terminating) the program.
The advantage of this second scheme can be seen for testing. In
testing, we want the test function to complete (rather than fatally
terminate), so that the corresponding tests on the results can be
applied. Hence, the diagnostic handler function (in such cases)
records the diagnostics in a string stream, so that it can be
extracted after the test completes. This latter form of diagnostic
handler supercedes the need for "verbose" arguments to bitcode
parsers.
This patch changes the PNaCl bitcode readers to use a diagnostic
handler, instead of simple error_codes and a "verbose" argument to
record error messages for testing. To make redirecting diagnostic
error messages easier, the function redirectNaClDiagnosticToStream was
added.
In addition, to simplify testing, a "stripErrorPrefix" function was
added to some unit tests. This function removes the diagnostic
sevevity prefix from the string containing error messages. This makes
tests more stable in that they do not need to test severity levels,
and the many variants of how severity is inserted.
BUG=None
R=dschuff@chromium.org
Committed: https://chromium.googlesource.com/native_client/pnacl-llvm/+/91f9db5ac6b069656f3190fbd0c4d109f497ebb9
Patch Set 1 #Patch Set 2 : Reformat and fix nits. #
Total comments: 18
Patch Set 3 : Fix issues in patch set 2. #Messages
Total messages: 12 (1 generated)
|