aboutsummaryrefslogtreecommitdiff
path: root/lib/StaticAnalyzer/Core/CallEvent.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-07-26 21:41:15 +0000
committerJordan Rose <jordan_rose@apple.com>2012-07-26 21:41:15 +0000
commit7c99aa385178c630e29f671299cdd9c104f1c885 (patch)
tree887e4fc7442b8940f9550ae9b9bf37b9be11182d /lib/StaticAnalyzer/Core/CallEvent.cpp
parentf540c54701e3eeb34cb619a3a4eb18f1ac70ef2d (diff)
[analyzer] CallEvent is no longer a value object.
After discussion, the type-based dispatch was decided to be bad for maintenance and made it very easy for subtle bugs to creep in. Instead, we'll just be very careful when we do have to allocate these on the heap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160817 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/CallEvent.cpp')
-rw-r--r--lib/StaticAnalyzer/Core/CallEvent.cpp68
1 files changed, 35 insertions, 33 deletions
diff --git a/lib/StaticAnalyzer/Core/CallEvent.cpp b/lib/StaticAnalyzer/Core/CallEvent.cpp
index 778d86ee2b..2375784681 100644
--- a/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -193,9 +193,43 @@ ProgramPoint CallEvent::getProgramPoint(bool IsPreVisit,
return PostImplicitCall(D, Loc, getLocationContext(), Tag);
}
+SVal CallEvent::getArgSVal(unsigned Index) const {
+ const Expr *ArgE = getArgExpr(Index);
+ if (!ArgE)
+ return UnknownVal();
+ return getSVal(ArgE);
+}
+
+SourceRange CallEvent::getArgSourceRange(unsigned Index) const {
+ const Expr *ArgE = getArgExpr(Index);
+ if (!ArgE)
+ return SourceRange();
+ return ArgE->getSourceRange();
+}
+
+void CallEvent::dump(raw_ostream &Out) const {
+ ASTContext &Ctx = getState()->getStateManager().getContext();
+ if (const Expr *E = getOriginExpr()) {
+ E->printPretty(Out, Ctx, 0, Ctx.getPrintingPolicy());
+ Out << "\n";
+ return;
+ }
+
+ if (const Decl *D = getDecl()) {
+ Out << "Call to ";
+ D->print(Out, Ctx.getPrintingPolicy());
+ return;
+ }
+
+ // FIXME: a string representation of the kind would be nice.
+ Out << "Unknown call (type " << getKind() << ")";
+}
+
bool CallEvent::mayBeInlined(const Stmt *S) {
- return isa<CallExpr>(S);
+ // FIXME: Kill this.
+ return isa<CallExpr>(S) || isa<ObjCMessageExpr>(S)
+ || isa<CXXConstructExpr>(S);
}
@@ -283,20 +317,6 @@ bool AnyFunctionCall::argumentsMayEscape() const {
return false;
}
-SVal AnyFunctionCall::getArgSVal(unsigned Index) const {
- const Expr *ArgE = getArgExpr(Index);
- if (!ArgE)
- return UnknownVal();
- return getSVal(ArgE);
-}
-
-SourceRange AnyFunctionCall::getArgSourceRange(unsigned Index) const {
- const Expr *ArgE = getArgExpr(Index);
- if (!ArgE)
- return SourceRange();
- return ArgE->getSourceRange();
-}
-
const FunctionDecl *SimpleCall::getDecl() const {
const FunctionDecl *D = getOriginExpr()->getDirectCallee();
@@ -306,24 +326,6 @@ const FunctionDecl *SimpleCall::getDecl() const {
return getSVal(getOriginExpr()->getCallee()).getAsFunctionDecl();
}
-void CallEvent::dump(raw_ostream &Out) const {
- ASTContext &Ctx = getState()->getStateManager().getContext();
- if (const Expr *E = getOriginExpr()) {
- E->printPretty(Out, Ctx, 0, Ctx.getLangOpts());
- Out << "\n";
- return;
- }
-
- if (const Decl *D = getDecl()) {
- Out << "Call to ";
- D->print(Out, Ctx.getLangOpts());
- return;
- }
-
- // FIXME: a string representation of the kind would be nice.
- Out << "Unknown call (type " << getKind() << ")";
-}
-
void CXXInstanceCall::getExtraInvalidatedRegions(RegionList &Regions) const {
if (const MemRegion *R = getCXXThisVal().getAsRegion())