clang 20.0.0git
DebugSupport.cpp
Go to the documentation of this file.
1//===- DebugSupport.cpp -----------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines functions which generate more readable forms of data
10// structures used in the dataflow analyses, for debugging purposes.
11//
12//===----------------------------------------------------------------------===//
13
14#include <utility>
15
19#include "llvm/ADT/StringRef.h"
20#include "llvm/Support/ErrorHandling.h"
21
22namespace clang {
23namespace dataflow {
24
25llvm::StringRef debugString(Value::Kind Kind) {
26 switch (Kind) {
28 return "Integer";
30 return "Pointer";
32 return "AtomicBool";
34 return "TopBool";
36 return "FormulaBool";
37 }
38 llvm_unreachable("Unhandled value kind");
39}
40
41llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
42 Solver::Result::Assignment Assignment) {
43 switch (Assignment) {
45 return OS << "False";
47 return OS << "True";
48 }
49 llvm_unreachable("Booleans can only be assigned true/false");
50}
51
52llvm::StringRef debugString(Solver::Result::Status Status) {
53 switch (Status) {
55 return "Satisfiable";
57 return "Unsatisfiable";
59 return "TimedOut";
60 }
61 llvm_unreachable("Unhandled SAT check result status");
62}
63
64llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Solver::Result &R) {
65 OS << debugString(R.getStatus()) << "\n";
66 if (auto Solution = R.getSolution()) {
67 std::vector<std::pair<Atom, Solver::Result::Assignment>> Sorted = {
68 Solution->begin(), Solution->end()};
69 llvm::sort(Sorted);
70 for (const auto &Entry : Sorted)
71 OS << Entry.first << " = " << Entry.second << "\n";
72 }
73 return OS;
74}
75
76} // namespace dataflow
77} // namespace clang
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
llvm::StringRef debugString(Value::Kind Kind)
Returns a string representation of a value kind.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, Atom A)
Definition: Formula.h:125
The JSON file list parser is used to communicate input to InstallAPI.
Status getStatus() const
Returns the status of satisfiability checking on the queried boolean formula.
Definition: Solver.h:64
std::optional< llvm::DenseMap< Atom, Assignment > > getSolution() const
Returns a truth assignment to boolean values that satisfies the queried boolean formula if available.
Definition: Solver.h:68
Assignment
A boolean value is set to true or false in a truth assignment.
Definition: Solver.h:46
@ TimedOut
Indicates that the solver gave up trying to find a satisfying assignment for a boolean formula.
@ Unsatisfiable
Indicates that there is no satisfying assignment for a boolean formula.
@ Satisfiable
Indicates that there exists a satisfying assignment for a boolean formula.