diff options
Diffstat (limited to 'clang/lib/StaticAnalyzer')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 56 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ProgramState.cpp | 2 |
2 files changed, 56 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 39f36477bde..3df69e891b7 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -383,8 +383,62 @@ ExprEngine::processRegionChanges(ProgramStateRef state, LCtx, Call); } +static void printInitializedTemporariesForContext(raw_ostream &Out, + ProgramStateRef State, + const char *NL, + const char *Sep, + const LocationContext *LC) { + PrintingPolicy PP = + LC->getAnalysisDeclContext()->getASTContext().getPrintingPolicy(); + for (auto I : State->get<InitializedTemporariesSet>()) { + if (I.second != LC) + continue; + Out << '(' << I.second << ',' << I.first << ") "; + I.first->printPretty(Out, nullptr, PP); + Out << NL; + } +} + +static void printCXXNewAllocatorValuesForContext(raw_ostream &Out, + ProgramStateRef State, + const char *NL, + const char *Sep, + const LocationContext *LC) { + PrintingPolicy PP = + LC->getAnalysisDeclContext()->getASTContext().getPrintingPolicy(); + + for (auto I : State->get<CXXNewAllocatorValues>()) { + std::pair<const CXXNewExpr *, const LocationContext *> Key = I.first; + SVal Value = I.second; + if (Key.second != LC) + continue; + Out << '(' << Key.second << ',' << Key.first << ") "; + Key.first->printPretty(Out, nullptr, PP); + Out << " : " << Value << NL; + } +} + void ExprEngine::printState(raw_ostream &Out, ProgramStateRef State, - const char *NL, const char *Sep) { + const char *NL, const char *Sep, + const LocationContext *LCtx) { + if (LCtx) { + if (!State->get<InitializedTemporariesSet>().isEmpty()) { + Out << Sep << "Initialized temporaries:" << NL; + + LCtx->dumpStack(Out, "", NL, Sep, [&](const LocationContext *LC) { + printInitializedTemporariesForContext(Out, State, NL, Sep, LC); + }); + } + + if (!State->get<CXXNewAllocatorValues>().isEmpty()) { + Out << Sep << "operator new() allocator return values:" << NL; + + LCtx->dumpStack(Out, "", NL, Sep, [&](const LocationContext *LC) { + printCXXNewAllocatorValuesForContext(Out, State, NL, Sep, LC); + }); + } + } + getCheckerManager().runCheckersForPrintState(Out, State, NL, Sep); } diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp index 53646e295ef..eccbc30bbe5 100644 --- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -450,7 +450,7 @@ void ProgramState::print(raw_ostream &Out, const char *NL, const char *Sep, Mgr.getConstraintManager().print(this, Out, NL, Sep); // Print checker-specific data. - Mgr.getOwningEngine()->printState(Out, this, NL, Sep); + Mgr.getOwningEngine()->printState(Out, this, NL, Sep, LC); } void ProgramState::printDOT(raw_ostream &Out, const LocationContext *LC) const { |