diff options
author | George Karpenkov <ekarpenkov@apple.com> | 2018-01-17 20:27:29 +0000 |
---|---|---|
committer | George Karpenkov <ekarpenkov@apple.com> | 2018-01-17 20:27:29 +0000 |
commit | d703ec94a95221c2916f5a89304673d65639527e (patch) | |
tree | 4ec0c656ac06bff3d96cdbd73e83c102d81830b8 /clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp | |
parent | cf9ff89663d7fac3759eb2b0bb9030a7bf97e47f (diff) | |
download | bcm5719-llvm-d703ec94a95221c2916f5a89304673d65639527e.tar.gz bcm5719-llvm-d703ec94a95221c2916f5a89304673d65639527e.zip |
[analyzer] introduce getSVal(Stmt *) helper on ExplodedNode, make sure the helper is used consistently
In most cases using
`N->getState()->getSVal(E, N->getLocationContext())`
is ugly, verbose, and also opens up more surface area for bugs if an
inconsistent location context is used.
This patch introduces a helper on an exploded node, and ensures
consistent usage of either `ExplodedNode::getSVal` or
`CheckContext::getSVal` across the codebase.
As a result, a large number of redundant lines is removed.
Differential Revision: https://reviews.llvm.org/D42155
llvm-svn: 322753
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp index 82ab910d1e3..fac0d380d47 100644 --- a/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp +++ b/clang/lib/StaticAnalyzer/Core/PathDiagnostic.cpp @@ -1195,12 +1195,10 @@ std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){ return getMessageForSymbolNotFound(); // Check if one of the parameters are set to the interesting symbol. - ProgramStateRef State = N->getState(); - const LocationContext *LCtx = N->getLocationContext(); unsigned ArgIndex = 0; for (CallExpr::const_arg_iterator I = CE->arg_begin(), E = CE->arg_end(); I != E; ++I, ++ArgIndex){ - SVal SV = State->getSVal(*I, LCtx); + SVal SV = N->getSVal(*I); // Check if the variable corresponding to the symbol is passed by value. SymbolRef AS = SV.getAsLocSymbol(); @@ -1210,7 +1208,7 @@ std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){ // Check if the parameter is a pointer to the symbol. if (Optional<loc::MemRegionVal> Reg = SV.getAs<loc::MemRegionVal>()) { - SVal PSV = State->getSVal(Reg->getRegion()); + SVal PSV = N->getState()->getSVal(Reg->getRegion()); SymbolRef AS = PSV.getAsLocSymbol(); if (AS == Sym) { return getMessageForArg(*I, ArgIndex); @@ -1219,7 +1217,7 @@ std::string StackHintGeneratorForSymbol::getMessage(const ExplodedNode *N){ } // Check if we are returning the interesting symbol. - SVal SV = State->getSVal(CE, LCtx); + SVal SV = N->getSVal(CE); SymbolRef RetSym = SV.getAsLocSymbol(); if (RetSym == Sym) { return getMessageForReturn(CE); |