[all-commits] [llvm/llvm-project] 16619e: [JSON] Facility to track position within an object...
Sam McCall via All-commits
all-commits at lists.llvm.org
Wed Sep 23 15:10:28 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 16619e7139bdcb0021598ba76cb5cf30ac669dbb
https://github.com/llvm/llvm-project/commit/16619e7139bdcb0021598ba76cb5cf30ac669dbb
Author: Sam McCall <sam.mccall at gmail.com>
Date: 2020-09-24 (Thu, 24 Sep 2020)
Changed paths:
M llvm/include/llvm/Support/JSON.h
M llvm/lib/Support/JSON.cpp
M llvm/unittests/Support/JSONTest.cpp
Log Message:
-----------
[JSON] Facility to track position within an object and report errors.
This error model should be rich enough for most applications. It comprises:
- a name for the root object, so the user knows what we're parsing
- a path from the root object to the JSON node most associated with the error
- a local error message
This can be presented as an llvm::Error e.g.
"expected string at ConfigFile.credentials[0].username"
It's designed to be cheap: Paths are a linked list of lightweight
objects on the stack. No heap allocations unless errors are encountered.
A subsequent commit will make use of this in the JSON-to-object
translation facilities: fromJSON and ObjectMapper.
However it's independent of these and can be used for e.g. validation alone.
Another subsequent commit will support showing the error in its context
within the parsed value.
Differential Revision: https://reviews.llvm.org/D88103
More information about the All-commits
mailing list