- See http://llvm.org/bugs/show_bug.cgi?id=16221 for a user's bug report.
- We weren't checking for Document::getRoot() returning NULL. This happens
in the case where the input YAML/JSON object is malformed.
- Document::getRoot() is passed to isa<NullNode>, which asserts on it's
argument being NULL.
- To fix this, we check for this return value, and set the error code
accordingly. We also modify the calling code to check the return value
of input::setCurrentDocument().
The added unit tests hit the assert in trunk, while passing on this branch.
Additionally, the command that reproduces this assert in the bug report:
llvm-build/Debug+Asserts/bin/clang-format -style="{BasedOnStyle:llvm}" tools/clang/tools/clang-format/ClangFormat.cpp
now outputs http://llvm-reviews.chandlerc.com/P55
nit: Please add spaces around assignments.
I'd also rename Handler to DiagHandler and rephrase the comment:
"The DiagHandler can be specified to provide alternative error reporting."