diff options
author | Anna Zaks <ganna@apple.com> | 2011-12-01 05:57:37 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-12-01 05:57:37 +0000 |
commit | b805c8ff133ef0c62df032fa711d6b13c5afd7f4 (patch) | |
tree | 79e10913c825cdf113d9267320edc29decaaf4aa /lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp | |
parent | a078ecf3484d62b01d9f8c01e0fecffd65c583e1 (diff) |
[analyzer] Refactor checkers to use helper function for getting callee Decl and name.
We are getting name of the called function or it's declaration in a few checkers. Refactor them to use the helper function in the CheckerContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145576 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp b/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp index 7bdb871db9..27d8fb5abb 100644 --- a/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/OSAtomicChecker.cpp @@ -35,23 +35,26 @@ private: }; } +static StringRef getCalleeName(const ProgramState *State, + const CallExpr *CE) { + const Expr *Callee = CE->getCallee(); + SVal L = State->getSVal(Callee); + const FunctionDecl *funDecl = L.getAsFunctionDecl(); + if (!funDecl) + return StringRef(); + IdentifierInfo *funI = funDecl->getIdentifier(); + if (!funI) + return StringRef(); + return funI->getName(); +} + bool OSAtomicChecker::inlineCall(const CallExpr *CE, ExprEngine &Eng, ExplodedNode *Pred, ExplodedNodeSet &Dst) const { - const ProgramState *state = Pred->getState(); - const Expr *Callee = CE->getCallee(); - SVal L = state->getSVal(Callee); - - const FunctionDecl *FD = L.getAsFunctionDecl(); - if (!FD) - return false; - - const IdentifierInfo *II = FD->getIdentifier(); - if (!II) + StringRef FName = getCalleeName(Pred->getState(), CE); + if (FName.empty()) return false; - - StringRef FName(II->getName()); // Check for compare and swap. if (FName.startswith("OSAtomicCompareAndSwap") || |