From a154e5b192b01366f25a62715a145a4cec3f8d23 Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Mon, 30 Oct 2017 12:02:23 +0000 Subject: [analyzer] Make issue hash related tests more concise Extend ExprInspection checker to make it possible to dump the issue hash of arbitrary expressions. This change makes it possible to make issue hash related tests more concise and also makes debugging issue hash related problems easier. Differential Revision: https://reviews.llvm.org/D38844 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@316899 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Checkers/DebugCheckers.cpp | 33 ---------------------- .../Checkers/ExprInspectionChecker.cpp | 18 ++++++++++-- 2 files changed, 16 insertions(+), 35 deletions(-) (limited to 'lib/StaticAnalyzer') diff --git a/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp b/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp index 2eef1688d4..810a33ed40 100644 --- a/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp +++ b/lib/StaticAnalyzer/Checkers/DebugCheckers.cpp @@ -16,7 +16,6 @@ #include "clang/Analysis/Analyses/LiveVariables.h" #include "clang/Analysis/CallGraph.h" #include "clang/StaticAnalyzer/Core/Checker.h" -#include "clang/StaticAnalyzer/Core/IssueHash.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" @@ -213,35 +212,3 @@ void ento::registerExplodedGraphViewer(CheckerManager &mgr) { mgr.registerChecker(); } -//===----------------------------------------------------------------------===// -// DumpBugHash -//===----------------------------------------------------------------------===// - -namespace { -class BugHashDumper : public Checker> { -public: - mutable std::unique_ptr BT; - - void checkPostStmt(const Stmt *S, CheckerContext &C) const { - if (!BT) - BT.reset(new BugType(this, "Dump hash components", "debug")); - - ExplodedNode *N = C.generateNonFatalErrorNode(); - if (!N) - return; - - const LangOptions &Opts = C.getLangOpts(); - const SourceManager &SM = C.getSourceManager(); - FullSourceLoc FL(S->getLocStart(), SM); - std::string HashContent = - GetIssueString(SM, FL, getCheckName().getName(), BT->getCategory(), - C.getLocationContext()->getDecl(), Opts); - - C.emitReport(llvm::make_unique(*BT, HashContent, N)); - } -}; -} - -void ento::registerBugHashDumper(CheckerManager &mgr) { - mgr.registerChecker(); -} diff --git a/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp b/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp index 4a581bddd9..0005ec470d 100644 --- a/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp @@ -8,10 +8,11 @@ //===----------------------------------------------------------------------===// #include "ClangSACheckers.h" +#include "clang/StaticAnalyzer/Checkers/SValExplainer.h" #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" #include "clang/StaticAnalyzer/Core/Checker.h" +#include "clang/StaticAnalyzer/Core/IssueHash.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" -#include "clang/StaticAnalyzer/Checkers/SValExplainer.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Support/ScopedPrinter.h" @@ -41,6 +42,7 @@ class ExprInspectionChecker : public CheckergetArg(0)->getLocStart(), SM); + std::string HashContent = + GetIssueString(SM, FL, getCheckName().getName(), "Category", + C.getLocationContext()->getDecl(), Opts); + + reportBug(HashContent, C); +} + void ento::registerExprInspectionChecker(CheckerManager &Mgr) { Mgr.registerChecker(); } - -- cgit v1.2.3