summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
diff options
context:
space:
mode:
authorCsaba Dabis <dabis.csaba98@gmail.com>2019-05-29 15:43:26 +0000
committerCsaba Dabis <dabis.csaba98@gmail.com>2019-05-29 15:43:26 +0000
commit5df5eb8816361d8be84a5f99cda4344dbcb01f87 (patch)
tree4e94d0d0eb412048ea41f2e6a8be3a2404306e5b /clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
parent56e970d45d021f69e57c351ff1c85cec7c7a03b6 (diff)
downloadbcm5719-llvm-5df5eb8816361d8be84a5f99cda4344dbcb01f87.tar.gz
bcm5719-llvm-5df5eb8816361d8be84a5f99cda4344dbcb01f87.zip
[analyzer] print() JSONify: Constraints implementation
Summary: - Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D62082 llvm-svn: 361978
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index 5c3eb0d66a0..64724227395 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -11,6 +11,7 @@
//
//===----------------------------------------------------------------------===//
+#include "clang/Basic/JsonSupport.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
#include "clang/StaticAnalyzer/Core/PathSensitive/ProgramStateTrait.h"
@@ -261,8 +262,8 @@ public:
ProgramStateRef removeDeadBindings(ProgramStateRef State,
SymbolReaper &SymReaper) override;
- void print(ProgramStateRef State, raw_ostream &Out, const char *nl,
- const char *sep) override;
+ void printJson(raw_ostream &Out, ProgramStateRef State, const char *NL = "\n",
+ unsigned int Space = 0, bool IsDot = false) const override;
//===------------------------------------------------------------------===//
// Implementation for interface from RangedConstraintManager.
@@ -754,25 +755,35 @@ ProgramStateRef RangeConstraintManager::assumeSymOutsideInclusiveRange(
return New.isEmpty() ? nullptr : State->set<ConstraintRange>(Sym, New);
}
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
// Pretty-printing.
-//===------------------------------------------------------------------------===/
-
-void RangeConstraintManager::print(ProgramStateRef St, raw_ostream &Out,
- const char *nl, const char *sep) {
+//===----------------------------------------------------------------------===//
- ConstraintRangeTy Ranges = St->get<ConstraintRange>();
+void RangeConstraintManager::printJson(raw_ostream &Out, ProgramStateRef State,
+ const char *NL, unsigned int Space,
+ bool IsDot) const {
+ ConstraintRangeTy Constraints = State->get<ConstraintRange>();
- if (Ranges.isEmpty()) {
- Out << nl << sep << "Ranges are empty." << nl;
+ Indent(Out, Space, IsDot) << "\"constraints\": ";
+ if (Constraints.isEmpty()) {
+ Out << "null," << NL;
return;
}
- Out << nl << sep << "Ranges of symbol values:";
- for (ConstraintRangeTy::iterator I = Ranges.begin(), E = Ranges.end(); I != E;
- ++I) {
- Out << nl << ' ' << I.getKey() << " : ";
+ ++Space;
+ Out << '[' << NL;
+ for (ConstraintRangeTy::iterator I = Constraints.begin();
+ I != Constraints.end(); ++I) {
+ Indent(Out, Space, IsDot)
+ << "{ \"symbol\": \"" << I.getKey() << "\", \"range\": \"";
I.getData().print(Out);
+ Out << "\" }";
+
+ if (std::next(I) != Constraints.end())
+ Out << ',';
+ Out << NL;
}
- Out << nl;
+
+ --Space;
+ Indent(Out, Space, IsDot) << "]," << NL;
}
OpenPOWER on IntegriCloud