|
8 | 8 | //===----------------------------------------------------------------------===//
|
9 | 9 |
|
10 | 10 | #include "ClangSACheckers.h"
|
| 11 | +#include "clang/StaticAnalyzer/Checkers/SValExplainer.h" |
11 | 12 | #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
|
12 | 13 | #include "clang/StaticAnalyzer/Core/Checker.h"
|
| 14 | +#include "clang/StaticAnalyzer/Core/IssueHash.h" |
13 | 15 | #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
|
14 |
| -#include "clang/StaticAnalyzer/Checkers/SValExplainer.h" |
15 | 16 | #include "llvm/ADT/StringSwitch.h"
|
16 | 17 | #include "llvm/Support/ScopedPrinter.h"
|
17 | 18 |
|
@@ -41,6 +42,7 @@ class ExprInspectionChecker : public Checker<eval::Call, check::DeadSymbols,
|
41 | 42 | void analyzerExplain(const CallExpr *CE, CheckerContext &C) const;
|
42 | 43 | void analyzerPrintState(const CallExpr *CE, CheckerContext &C) const;
|
43 | 44 | void analyzerGetExtent(const CallExpr *CE, CheckerContext &C) const;
|
| 45 | + void analyzerHashDump(const CallExpr *CE, CheckerContext &C) const; |
44 | 46 |
|
45 | 47 | typedef void (ExprInspectionChecker::*FnCheck)(const CallExpr *,
|
46 | 48 | CheckerContext &C) const;
|
@@ -79,6 +81,7 @@ bool ExprInspectionChecker::evalCall(const CallExpr *CE,
|
79 | 81 | &ExprInspectionChecker::analyzerPrintState)
|
80 | 82 | .Case("clang_analyzer_numTimesReached",
|
81 | 83 | &ExprInspectionChecker::analyzerNumTimesReached)
|
| 84 | + .Case("clang_analyzer_hashDump", &ExprInspectionChecker::analyzerHashDump) |
82 | 85 | .Default(nullptr);
|
83 | 86 |
|
84 | 87 | if (!Handler)
|
@@ -280,7 +283,18 @@ void ExprInspectionChecker::analyzerCrash(const CallExpr *CE,
|
280 | 283 | LLVM_BUILTIN_TRAP;
|
281 | 284 | }
|
282 | 285 |
|
| 286 | +void ExprInspectionChecker::analyzerHashDump(const CallExpr *CE, |
| 287 | + CheckerContext &C) const { |
| 288 | + const LangOptions &Opts = C.getLangOpts(); |
| 289 | + const SourceManager &SM = C.getSourceManager(); |
| 290 | + FullSourceLoc FL(CE->getArg(0)->getLocStart(), SM); |
| 291 | + std::string HashContent = |
| 292 | + GetIssueString(SM, FL, getCheckName().getName(), "Category", |
| 293 | + C.getLocationContext()->getDecl(), Opts); |
| 294 | + |
| 295 | + reportBug(HashContent, C); |
| 296 | +} |
| 297 | + |
283 | 298 | void ento::registerExprInspectionChecker(CheckerManager &Mgr) {
|
284 | 299 | Mgr.registerChecker<ExprInspectionChecker>();
|
285 | 300 | }
|
286 |
| - |
|
0 commit comments