get a CodeTextRegion when visiting FunctionDecl reference.
get FunctionDecl with more general utility method.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69570 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 7443c52..0e8d67c 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -1694,7 +1694,7 @@
                              Expr* Ex,
                              Expr* Receiver,
                              RetainSummary* Summ,
-                             ExprIterator arg_beg, ExprIterator arg_end,                             
+                             ExprIterator arg_beg, ExprIterator arg_end,
                              ExplodedNode<GRState>* Pred) {
   
   // Get the state.
@@ -1930,9 +1930,9 @@
                           GRStmtNodeBuilder<GRState>& Builder,
                           CallExpr* CE, SVal L,
                           ExplodedNode<GRState>* Pred) {
-
-  RetainSummary* Summ = !isa<loc::FuncVal>(L) ? 0
-                      : Summaries.getSummary(cast<loc::FuncVal>(L).getDecl());
+  const FunctionDecl* FD = L.getAsFunctionDecl();
+  RetainSummary* Summ = !FD ? 0 
+                        : Summaries.getSummary(const_cast<FunctionDecl*>(FD));
   
   EvalSummary(Dst, Eng, Builder, CE, 0, Summ,
               CE->arg_begin(), CE->arg_end(), Pred);
@@ -2582,9 +2582,9 @@
 
     if (CallExpr *CE = dyn_cast<CallExpr>(S)) {
       // Get the name of the callee (if it is available).
-      SVal X = CurrSt.GetSValAsScalarOrLoc(CE->getCallee());        
-      if (loc::FuncVal* FV = dyn_cast<loc::FuncVal>(&X))
-        os << "Call to function '" << FV->getDecl()->getNameAsString() <<'\'';
+      SVal X = CurrSt.GetSValAsScalarOrLoc(CE->getCallee());
+      if (const FunctionDecl* FD = X.getAsFunctionDecl())
+        os << "Call to function '" << FD->getNameAsString() <<'\'';
       else
         os << "function call";      
     }          
@@ -2675,9 +2675,9 @@
     if (contains(AEffects, MakeCollectable)) {
       // Get the name of the function.
       Stmt* S = cast<PostStmt>(N->getLocation()).getStmt();
-      loc::FuncVal FV =
-        cast<loc::FuncVal>(CurrSt.GetSValAsScalarOrLoc(cast<CallExpr>(S)->getCallee()));
-      const std::string& FName = FV.getDecl()->getNameAsString();
+      SVal X = CurrSt.GetSValAsScalarOrLoc(cast<CallExpr>(S)->getCallee());
+      const FunctionDecl* FD = X.getAsFunctionDecl();
+      const std::string& FName = FD->getNameAsString();
       
       if (TF.isGCEnabled()) {
         // Determine if the object's reference count was pushed to zero.