diff options
author | John McCall <rjmccall@apple.com> | 2011-03-02 01:50:55 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-03-02 01:50:55 +0000 |
commit | b4526252db52ddbb931c0ea09a1f3dba3b5ce3f9 (patch) | |
tree | 8f9cd2793db72bf31d5bc6dbba25e5c16aeb54d2 /clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp | |
parent | 846ded2e53c77b43aae86a6ed60772ae46647e63 (diff) | |
download | bcm5719-llvm-b4526252db52ddbb931c0ea09a1f3dba3b5ce3f9.tar.gz bcm5719-llvm-b4526252db52ddbb931c0ea09a1f3dba3b5ce3f9.zip |
Move some of the logic about classifying Objective-C methods into
conventional categories into Basic and AST. Update the self-init checker
to use this logic; CFRefCountChecker is complicated enough that I didn't
want to touch it.
llvm-svn: 126817
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp index 2e370d62e44..b2272968bb9 100644 --- a/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp +++ b/clang/lib/StaticAnalyzer/Core/ObjCMessage.cpp @@ -37,6 +37,35 @@ Selector ObjCMessage::getSelector() const { return propE->getGetterSelector(); } +ObjCMethodFamily ObjCMessage::getMethodFamily() const { + assert(isValid() && "This ObjCMessage is uninitialized!"); + // Case 1. Explicit message send. + if (const ObjCMessageExpr *msgE = dyn_cast<ObjCMessageExpr>(MsgOrPropE)) + return msgE->getMethodFamily(); + + const ObjCPropertyRefExpr *propE = cast<ObjCPropertyRefExpr>(MsgOrPropE); + + // Case 2. Reference to implicit property. + if (propE->isImplicitProperty()) { + if (isPropertySetter()) + return propE->getImplicitPropertySetter()->getMethodFamily(); + else + return propE->getImplicitPropertyGetter()->getMethodFamily(); + } + + // Case 3. Reference to explicit property. + const ObjCPropertyDecl *prop = propE->getExplicitProperty(); + if (isPropertySetter()) { + if (prop->getSetterMethodDecl()) + return prop->getSetterMethodDecl()->getMethodFamily(); + return prop->getSetterName().getMethodFamily(); + } else { + if (prop->getGetterMethodDecl()) + return prop->getGetterMethodDecl()->getMethodFamily(); + return prop->getGetterName().getMethodFamily(); + } +} + const ObjCMethodDecl *ObjCMessage::getMethodDecl() const { assert(isValid() && "This ObjCMessage is uninitialized!"); if (const ObjCMessageExpr *msgE = dyn_cast<ObjCMessageExpr>(MsgOrPropE)) |