13#include "llvm/ADT/DenseMap.h"
14#include "llvm/ADT/STLExtras.h"
15#include "llvm/ADT/StringRef.h"
16#include "llvm/Support/Allocator.h"
17#include "llvm/Support/Error.h"
18#include "llvm/Support/ErrorHandling.h"
42 llvm_unreachable(
"unhandled formula kind");
53 OS << (F.
literal() ?
'T' :
'F');
56 llvm_unreachable(
"unhandled formula kind");
69 llvm_unreachable(
"unhandled formula arity");
75 llvm::DenseMap<unsigned, Atom> &AtomMap) {
77 return llvm::createStringError(llvm::inconvertibleErrorCode(),
78 "unexpected end of input");
81 Str = Str.drop_front();
90 if (Str.consumeInteger(10, AtomID))
91 return llvm::createStringError(llvm::inconvertibleErrorCode(),
93 auto [It, Inserted] = AtomMap.try_emplace(AtomID,
Atom());
101 return OperandOrErr.takeError();
102 return &A.
makeNot(**OperandOrErr);
110 return LeftOrErr.takeError();
114 return RightOrErr.takeError();
116 const Formula &LHS = **LeftOrErr;
117 const Formula &RHS = **RightOrErr;
123 return &A.
makeOr(LHS, RHS);
129 llvm_unreachable(
"unexpected binary op");
133 return llvm::createStringError(llvm::inconvertibleErrorCode(),
134 "unexpected prefix character: %c", Prefix);
140 llvm::DenseMap<unsigned, Atom> &AtomMap) {
141 size_t OriginalSize = Str.size();
144 return F.takeError();
146 return llvm::createStringError(llvm::inconvertibleErrorCode(),
147 (
"unexpected suffix of length: " +
148 llvm::Twine(Str.size() - OriginalSize))
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
The Arena owns the objects that model data within an analysis.
const Formula & makeEquals(const Formula &LHS, const Formula &RHS)
Returns a formula for LHS <=> RHS.
const Formula & makeAtomRef(Atom A)
Returns a formula for the variable A.
Atom makeAtom()
Returns a new atomic boolean variable, distinct from any other.
const Formula & makeNot(const Formula &Val)
Returns a formula for the negation of Val.
const Formula & makeOr(const Formula &LHS, const Formula &RHS)
Returns a formula for the disjunction of LHS and RHS.
const Formula & makeAnd(const Formula &LHS, const Formula &RHS)
Returns a formula for the conjunction of LHS and RHS.
const Formula & makeImplies(const Formula &LHS, const Formula &RHS)
Returns a formula for LHS => RHS.
const Formula & makeLiteral(bool Value)
Returns a formula for a literal true/false.
Dataflow Directional Tag Classes.
static llvm::Expected< const Formula * > parsePrefix(llvm::StringRef &Str, Arena &A, llvm::DenseMap< unsigned, Atom > &AtomMap)
Atom
Identifies an atomic boolean variable such as "V1".
void serializeFormula(const Formula &F, llvm::raw_ostream &OS)
Prints F to OS in a compact format, optimized for easy parsing (deserialization) rather than human us...
llvm::Expected< const Formula * > parseFormula(llvm::StringRef Str, Arena &A, llvm::DenseMap< unsigned, Atom > &AtomMap)
Parses Str to build a serialized Formula.
static char compactSigil(Formula::Kind K)