[PATCH] D31541: [analyzer] MisusedMovedObjectChecker: Add a printState() method.
This revision was automatically updated to reflect the committed changes. Closed by commit rL315300: [analyzer] MisusedMovedObject: Add printState() method for self-debugging. (authored by dergachev). Changed prior to commit: https://reviews.llvm.org/D31541?vs=93661=118350#toc Repository: rL LLVM https://reviews.llvm.org/D31541 Files: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp @@ -56,6 +56,8 @@ ArrayRef ExplicitRegions, ArrayRef Regions, const LocationContext *LCtx, const CallEvent *Call) const; + void printState(raw_ostream , ProgramStateRef State, + const char *NL, const char *Sep) const override; private: class MovedBugVisitor : public BugReporterVisitorImpl { @@ -476,6 +478,25 @@ return State; } +void MisusedMovedObjectChecker::printState(raw_ostream , + ProgramStateRef State, + const char *NL, + const char *Sep) const { + + TrackedRegionMapTy RS = State->get(); + + if (!RS.isEmpty()) { +Out << Sep << "Moved-from objects :" << NL; +for (auto I: RS) { + I.first->dumpToStream(Out); + if (I.second.isMoved()) +Out << ": moved"; + else +Out << ": moved and reported"; + Out << NL; +} + } +} void ento::registerMisusedMovedObjectChecker(CheckerManager ) { mgr.registerChecker(); } Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp === --- cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp +++ cfe/trunk/lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp @@ -56,6 +56,8 @@ ArrayRef ExplicitRegions, ArrayRef Regions, const LocationContext *LCtx, const CallEvent *Call) const; + void printState(raw_ostream , ProgramStateRef State, + const char *NL, const char *Sep) const override; private: class MovedBugVisitor : public BugReporterVisitorImpl { @@ -476,6 +478,25 @@ return State; } +void MisusedMovedObjectChecker::printState(raw_ostream , + ProgramStateRef State, + const char *NL, + const char *Sep) const { + + TrackedRegionMapTy RS = State->get(); + + if (!RS.isEmpty()) { +Out << Sep << "Moved-from objects :" << NL; +for (auto I: RS) { + I.first->dumpToStream(Out); + if (I.second.isMoved()) +Out << ": moved"; + else +Out << ": moved and reported"; + Out << NL; +} + } +} void ento::registerMisusedMovedObjectChecker(CheckerManager ) { mgr.registerChecker(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31541: [analyzer] MisusedMovedObjectChecker: Add a printState() method.
xazax.hun accepted this revision. xazax.hun added a comment. LGTM! https://reviews.llvm.org/D31541 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31541: [analyzer] MisusedMovedObjectChecker: Add a printState() method.
NoQ added a comment. Hmm, i've been thinking of writing a test for this via `ExprInspection`'s `clang_analyzer_printState()`, however `printState()` functionality is only enabled in debug builds, and i'm not seeing how to enable the test only on debug builds (there's `REQUIRES:` but it only seems to have an asserts flag). https://reviews.llvm.org/D31541 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31541: [analyzer] MisusedMovedObjectChecker: Add a printState() method.
szepet accepted this revision. szepet added a comment. This revision is now accepted and ready to land. LGTM, thank you (again)! https://reviews.llvm.org/D31541 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D31541: [analyzer] MisusedMovedObjectChecker: Add a printState() method.
NoQ created this revision. The `printState()` method adds the checker's information to the `State->dump()`. I find it very handy when debugging by looking at the exploded graphs, so i think it's great to have this method implemented in all checkers. It helped me already. I think it's not a problem if the graphs become too large when all checkers print their state, because since you're always only debugging a few checkers, you can easily disable the rest of them. https://reviews.llvm.org/D31541 Files: lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp Index: lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp @@ -56,6 +56,8 @@ ArrayRef ExplicitRegions, ArrayRef Regions, const LocationContext *LCtx, const CallEvent *Call) const; + void printState(raw_ostream , ProgramStateRef State, + const char *NL, const char *Sep) const override; private: class MovedBugVisitor : public BugReporterVisitorImpl { @@ -476,6 +478,25 @@ return State; } +void MisusedMovedObjectChecker::printState(raw_ostream , + ProgramStateRef State, + const char *NL, + const char *Sep) const { + + TrackedRegionMapTy RS = State->get(); + + if (!RS.isEmpty()) { +Out << Sep << "Moved-from objects :" << NL; +for (auto I: RS) { + I.first->dumpToStream(Out); + if (I.second.isMoved()) +Out << ": moved"; + else +Out << ": moved and reported"; + Out << NL; +} + } +} void ento::registerMisusedMovedObjectChecker(CheckerManager ) { mgr.registerChecker(); } Index: lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp === --- lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp +++ lib/StaticAnalyzer/Checkers/MisusedMovedObjectChecker.cpp @@ -56,6 +56,8 @@ ArrayRef ExplicitRegions, ArrayRef Regions, const LocationContext *LCtx, const CallEvent *Call) const; + void printState(raw_ostream , ProgramStateRef State, + const char *NL, const char *Sep) const override; private: class MovedBugVisitor : public BugReporterVisitorImpl { @@ -476,6 +478,25 @@ return State; } +void MisusedMovedObjectChecker::printState(raw_ostream , + ProgramStateRef State, + const char *NL, + const char *Sep) const { + + TrackedRegionMapTy RS = State->get(); + + if (!RS.isEmpty()) { +Out << Sep << "Moved-from objects :" << NL; +for (auto I: RS) { + I.first->dumpToStream(Out); + if (I.second.isMoved()) +Out << ": moved"; + else +Out << ": moved and reported"; + Out << NL; +} + } +} void ento::registerMisusedMovedObjectChecker(CheckerManager ) { mgr.registerChecker(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits