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/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 43d7331..d00bfe6 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -976,7 +976,7 @@
 
   } else if (const FunctionDecl* FD = dyn_cast<FunctionDecl>(D)) {
     assert(asLValue);
-    SVal V = loc::FuncVal(FD);
+    SVal V = ValMgr.getFunctionPointer(FD);
     MakeNode(Dst, Ex, Pred, BindExpr(state, Ex, V));
     return;
   }
@@ -1369,11 +1369,10 @@
                          GRStmtNodeBuilder<GRState>& Builder,
                          CallExpr* CE, SVal L,
                          ExplodedNode<GRState>* Pred) {
-  
-  if (!isa<loc::FuncVal>(L))
+  const FunctionDecl* FD = L.getAsFunctionDecl();
+  if (!FD)
     return false;
-  
-  const FunctionDecl *FD = cast<loc::FuncVal>(L).getDecl();
+
   const char *FName = FD->getNameAsCString();
   
   // Check for compare and swap.
@@ -1473,11 +1472,8 @@
     // Check for the "noreturn" attribute.
     
     SaveAndRestore<bool> OldSink(Builder->BuildSinks);
-    
-    if (isa<loc::FuncVal>(L)) {      
-      
-      FunctionDecl* FD = cast<loc::FuncVal>(L).getDecl();
-      
+    const FunctionDecl* FD = L.getAsFunctionDecl();
+    if (FD) {      
       if (FD->getAttr<NoReturnAttr>() || FD->getAttr<AnalyzerNoReturnAttr>())
         Builder->BuildSinks = true;
       else {
@@ -1559,10 +1555,9 @@
     
     // Evaluate the call.
 
-    if (isa<loc::FuncVal>(L)) {
+    if (FD) {
       
-      if (unsigned id 
-            = cast<loc::FuncVal>(L).getDecl()->getBuiltinID(getContext()))
+      if (unsigned id = FD->getBuiltinID(getContext()))
         switch (id) {
           case Builtin::BI__builtin_expect: {
             // For __builtin_expect, just return the value of the subexpression.