diff options
author | Anna Zaks <ganna@apple.com> | 2011-12-20 22:35:30 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2011-12-20 22:35:30 +0000 |
commit | 5f847144d1c115db7fbb093611af94a01aa60338 (patch) | |
tree | 359b68bbe581bd47c9db286a0ab0e43076211b71 /clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp | |
parent | 0cee2045c994645e913eebaaa39461e3005f2c79 (diff) | |
download | bcm5719-llvm-5f847144d1c115db7fbb093611af94a01aa60338.tar.gz bcm5719-llvm-5f847144d1c115db7fbb093611af94a01aa60338.zip |
[analyzer] Do not invalidate arguments when the parameter's
type is a pointer to const. (radar://10595327)
The regions corresponding to the pointer and reference arguments to
a function get invalidated by the calls since a function call can
possibly modify the pointed to data. With this change, we are not going
to invalidate the data if the argument is a pointer to const. This
change makes the analyzer more optimistic in reporting errors.
(Support for C, C++ and Obj C)
llvm-svn: 147002
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp index 0974fe877ac..1edc3769e7a 100644 --- a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp +++ b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "clang/StaticAnalyzer/Core/PathSensitive/ObjCMessage.h" +#include "clang/AST/DeclCXX.h" using namespace clang; using namespace ento; @@ -162,3 +163,21 @@ CallOrObjCMessage::getInstanceMessageReceiver(const LocationContext *LC) const { assert(isObjCMessage()); return Msg.getInstanceReceiverSVal(State, LC); } + +const Decl *CallOrObjCMessage::getDecl() const { + if (isCXXCall()) { + const CXXMemberCallExpr *CE = + cast<CXXMemberCallExpr>(CallE.dyn_cast<const CallExpr *>()); + assert(CE); + return CE->getMethodDecl(); + } else if (isObjCMessage()) { + return Msg.getMethodDecl(); + } else if (isFunctionCall()) { + // In case of a C style call, use the path sensitive information to find + // the function declaration. + SVal CalleeVal = getFunctionCallee(); + return CalleeVal.getAsFunctionDecl(); + } + return 0; +} + |