LLVM  12.0.0git
Classes | Namespaces | Functions | Variables
JSON.h File Reference

This file supports working with JSON data. More...

#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
Include dependency graph for JSON.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  llvm::json::Object
 An Object is a JSON object, which maps strings to heterogenous JSON values. More...
 
class  llvm::json::Array
 An Array is a JSON array, which contains heterogeneous JSON values. More...
 
class  llvm::json::Value
 A Value is an JSON value of unknown type. More...
 
class  llvm::json::ObjectKey
 ObjectKey is a used to capture keys in Object. More...
 
struct  llvm::json::Object::KV
 
class  llvm::json::Path
 A "cursor" marking a position within a Value. More...
 
class  llvm::json::Path::Root
 The root is the trivial Path to the root value. More...
 
class  llvm::ObjectMapper
 Helper for mapping JSON objects onto protocol structs. More...
 
class  llvm::ParseError
 
class  llvm::OStream
 json::OStream allows writing well-formed JSON without materializing all structures as json::Value ahead of time. More...
 
struct  format_provider< llvm::json::Value >
 Allow printing json::Value with formatv(). More...
 

Namespaces

 llvm
 This class represents lattice values for constants.
 
 llvm::json
 

Functions

bool llvm::json::isUTF8 (llvm::StringRef S, size_t *ErrOffset=nullptr)
 Returns true if S is valid UTF-8, which is required for use as JSON. More...
 
std::string llvm::json::fixUTF8 (llvm::StringRef S)
 Replaces invalid UTF-8 sequences in S with the replacement character (U+FFFD). More...
 
template<typename T >
Value llvm::json::toJSON (const llvm::Optional< T > &Opt)
 
bool llvm::json::operator== (const Object &LHS, const Object &RHS)
 
bool llvm::json::operator!= (const Object &LHS, const Object &RHS)
 
bool llvm::json::operator!= (const Array &L, const Array &R)
 
bool llvm::json::operator== (const Value &, const Value &)
 
bool llvm::json::operator!= (const Value &L, const Value &R)
 
bool llvm::json::operator== (const ObjectKey &L, const ObjectKey &R)
 
bool llvm::json::operator!= (const ObjectKey &L, const ObjectKey &R)
 
bool llvm::json::operator< (const ObjectKey &L, const ObjectKey &R)
 
class llvm::json::Path::Root llvm::json::printErrorContext (const Value &, llvm::raw_ostream &) const
 
 Root (llvm::StringRef Name="")
 
 Root (Root &&)=delete
 
Rootoperator= (Root &&)=delete
 
 Root (const Root &)=delete
 
Rootoperator= (const Root &)=delete
 
Error getError () const
 Returns the last error reported, or else a generic error. More...
 
bool llvm::fromJSON (const Value &E, std::string &Out, Path P)
 
bool llvm::fromJSON (const Value &E, int &Out, Path P)
 
bool llvm::fromJSON (const Value &E, int64_t &Out, Path P)
 
bool llvm::fromJSON (const Value &E, double &Out, Path P)
 
bool llvm::fromJSON (const Value &E, bool &Out, Path P)
 
bool llvm::fromJSON (const Value &E, std::nullptr_t &Out, Path P)
 
template<typename T >
bool llvm::fromJSON (const Value &E, llvm::Optional< T > &Out, Path P)
 
template<typename T >
bool llvm::fromJSON (const Value &E, std::vector< T > &Out, Path P)
 
template<typename T >
bool llvm::fromJSON (const Value &E, std::map< std::string, T > &Out, Path P)
 
template<typename T >
Value llvm::toJSON (const llvm::Optional< T > &Opt)
 
llvm::Expected< Value > llvm::parse (llvm::StringRef JSON)
 Parses the provided JSON source, or returns a ParseError. More...
 
template<typename T >
Expected< Tllvm::parse (const llvm::StringRef &JSON, const char *RootName="")
 Version of parse() that converts the parsed value to the type T. More...
 
raw_ostream & llvm::operator<< (llvm::raw_ostream &OS, const Value &V)
 Serializes this Value to JSON, writing it to the provided stream. More...
 

Variables

llvm::StringRef Name
 
llvm::StringLiteral ErrorMessage
 
std::vector< Path::Segment > ErrorPath
 
 null
 Print the root value with the error shown inline as a comment. More...
 

Detailed Description

This file supports working with JSON data.

It comprises:

Typically, JSON data would be read from an external source, parsed into a Value, and then converted into some native data structure before doing real work on it. (And vice versa when writing).

Other serialization mechanisms you may consider:

Definition in file JSON.h.

Function Documentation

◆ getError()

Error printErrorContext::getError ( ) const

Returns the last error reported, or else a generic error.

◆ operator=() [1/2]

Root& printErrorContext::operator= ( Root &&  )
delete

◆ operator=() [2/2]

Root& printErrorContext::operator= ( const Root )
delete

◆ Root() [1/3]

printErrorContext::Root ( llvm::StringRef  Name = "")

Definition at line 571 of file JSON.h.

Referenced by llvm::ImmutableSetRef< ValT, ValInfo >::add(), llvm::ImmutableSetRef< ValT, ValInfo >::asImmutableSet(), llvm::SuffixTree::begin(), llvm::ImmutableSet< ValT, ValInfo >::begin(), llvm::ImmutableSetRef< ValT, ValInfo >::begin(), calculateByteProvider(), llvm::DomTreeBuilder::SemiNCAInfo< DomTreeT >::CalculateFromScratch(), checkDependencies(), collectHomogenousInstGraphLoopInvariants(), collectLeaves(), combineBasicSADPattern(), CombineCVTAToLocal(), combineX86ShuffleChain(), combineX86ShuffleChainWithExtract(), combineX86ShufflesConstants(), combineX86ShufflesRecursively(), llvm::slpvectorizer::BoUpSLP::computeMinimumValueSizes(), llvm::DomTreeBuilder::SemiNCAInfo< DomTreeT >::ComputeUnreachableDominators(), llvm::ImmutableSet< ValT, ValInfo >::contains(), llvm::ImmutableSetRef< ValT, ValInfo >::contains(), llvm::vfs::RedirectingFileSystem::create(), llvm::MDBuilder::createAnonymousAARoot(), DFS(), llvm::DomTreeBuilder::SemiNCAInfo< DomTreeT >::doFullDFSWalk(), llvm::vfs::RedirectingFileSystem::dump(), llvm::SchedDFSImpl::finalize(), findNonImmUse(), llvm::DomTreeBuilder::SemiNCAInfo< DomTreeT >::FindRoots(), llvm::ImmutableSet< ValT, ValInfo >::foreach(), llvm::AArch64InstrInfo::genAlternativeCodeSequence(), llvm::PPCInstrInfo::genAlternativeCodeSequence(), llvm::TargetInstrInfo::genAlternativeCodeSequence(), genFusedMultiply(), genFusedMultiplyAcc(), genFusedMultiplyAccNeg(), genFusedMultiplyIdx(), genFusedMultiplyIdxNeg(), genMaddR(), genNeg(), false::GepNode::GepNode(), llvm::CacheCost::getCacheCost(), llvm::SelectionDAG::getEHLabel(), llvm::GraphTraits< ModuleSummaryIndex * >::getEntryNode(), llvm::PPCInstrInfo::getFMAPatterns(), getFMAPatterns(), llvm::ImmutableSet< ValT, ValInfo >::getHeight(), llvm::ImmutableSetRef< ValT, ValInfo >::getHeight(), getImmedFromMO(), llvm::SelectionDAG::getLabelNode(), llvm::LoopNest::getLoopNest(), llvm::AArch64InstrInfo::getMachineCombinerPatterns(), llvm::PPCInstrInfo::getMachineCombinerPatterns(), llvm::TargetInstrInfo::getMachineCombinerPatterns(), getMaddPatterns(), llvm::LoopNest::getMaxPerfectDepth(), getMemCmpLoad(), getMemVTFromNode(), llvm::msgpack::Document::getRoot(), llvm::SelectionDAG::getRoot(), llvm::ImmutableSet< ValT, ValInfo >::getRoot(), llvm::vfs::RedirectingFileSystem::getRoots(), llvm::ImmutableSet< ValT, ValInfo >::getRootWithoutRetain(), llvm::ImmutableSetRef< ValT, ValInfo >::getRootWithoutRetain(), llvm::object::WindowsResourceParser::getTree(), getv64i1Argument(), llvm::ImmutableSet< ValT, ValInfo >::ImmutableSet(), llvm::ImmutableSetRef< ValT, ValInfo >::ImmutableSetRef(), llvm::ImutAVLTreeGenericIterator< ImutInfo >::ImutAVLTreeGenericIterator(), llvm::ImutAVLTreeInOrderIterator< ImutInfo >::ImutAVLTreeInOrderIterator(), initializeCounts(), InsertRootInitializers(), invert_find_roots(), llvm::InstructionSelector::isBaseWithConstantOffset(), isCVTAToLocalCombinationCandidate(), isEligibleLoopForm(), llvm::ImmutableSet< ValT, ValInfo >::isEmpty(), llvm::ImmutableSetRef< ValT, ValInfo >::isEmpty(), llvm::SelectionDAGISel::IsLegalToFold(), isLoadCombineCandidateImpl(), isOrXorXorTree(), llvm::MachineRegisterInfo::isReservedRegUnit(), llvm::vfs::RedirectingFileSystemParser::lookupOrCreateEntry(), llvm::LoopNest::LoopNest(), llvm::NVPTXTargetLowering::LowerFormalArguments(), llvm::TargetTransformInfo::matchVectorReduction(), mustExecuteUBIfPoisonOnPathTo(), llvm::Negator::Negate(), node_eq(), nodes_for_root(), llvm::ImmutableSet< ValT, ValInfo >::operator!=(), llvm::ImmutableSetRef< ValT, ValInfo >::operator!=(), false::operator<<(), llvm::ImmutableSet< ValT, ValInfo >::operator==(), llvm::ImmutableSetRef< ValT, ValInfo >::operator==(), llvm::parse(), llvm::vfs::RedirectingFileSystemParser::parse(), llvm::remarks::YAMLRemarkParser::parseRemark(), partitionOuterLoopBlocks(), llvm::TargetInstrInfo::reassociateOps(), llvm::ImmutableSetRef< ValT, ValInfo >::remove(), llvm::DomTreeBuilder::SemiNCAInfo< DomTreeT >::RemoveRedundantRoots(), llvm::replaceDominatedUsesWith(), replaceDominatedUsesWith(), llvm::RootDDGNode::RootDDGNode(), llvm::SCEVExprContains(), llvm::SelectionDAG::setRoot(), stripComments(), tryToRecognizePopCount(), tryToVectorizeHorReductionOrInstOperands(), llvm::ImmutableSet< ValT, ValInfo >::validateTree(), llvm::ImmutableSetRef< ValT, ValInfo >::validateTree(), llvm::DomTreeBuilder::SemiNCAInfo< DomTreeT >::VerifyDFSNumbers(), llvm::SCEVTraversal< SV >::visitAll(), llvm::visitAll(), and llvm::SelectionDAGBuilder::visitBitTestHeader().

◆ Root() [2/3]

printErrorContext::Root ( Root &&  )
delete

◆ Root() [3/3]

printErrorContext::Root ( const Root &  )
delete

Variable Documentation

◆ ErrorMessage

llvm::StringLiteral ErrorMessage

◆ ErrorPath

std::vector<Path::Segment> ErrorPath

Definition at line 566 of file JSON.h.

◆ Name

Definition at line 564 of file JSON.h.

◆ null

null

Print the root value with the error shown inline as a comment.

Unrelated parts of the value are elided for brevity, e.g. { "id": 42, "name": /* expected string

Definition at line 584 of file JSON.h.