[PATCH] support validation for YAML I/O mappings

Michael Spencer bigcheesegs at gmail.com
Tue Nov 19 18:12:34 PST 2013


On Tue, Nov 19, 2013 at 5:56 PM, Nick Kledzik <kledzik at apple.com> wrote:
> Here is my proposed patch for enhancing YAML I/O to allow semantic level error checking.  I previous made a change in r194655 to allow dyn_cast<> to work with yaml Input and Output types.  So that mapping() methods used  on input, could detect that and do extra checking.  If this new way is better, I’ll revert that change.
>
>
>
>
> Some things to think  about:
>
> 1) When writing yaml, what should happen if the validate() method find the in-memory struct is semantically invalid?  My patch has it triggering an assert().

Assert is fine. I agree with the comments that it's a programming
error to try to write an invalid object.

> 2) Is a StringRef the best way to return the error string?  Another possibility is that the caller of validate() passes in a std::string which the validate() method fills in if there is an error.

Return a std::string? I assume most of the time you'll be building an
error message. Really I would like a proper diagnostics system for all
of LLVM, but we just aren't there yet.

>
> -Nick

Looks good overall. It would be nice if we could give caret
diagnostics at this stage, but we don't have source locs this late.

- Michael Spencer




More information about the llvm-commits mailing list