Fixed an expression parser bug that prevented
certain functions from being resolved correctly.

Some functions (particularly varargs functions)
are BitCast before being called, and the problem
was that a CallInst where getCalledValue()
returned a BitCast ConstantExpr was not being
relocated at all.

This problem should now be resolved for the case
of BitCast.


git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@113396 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp
index 345ae34..e220b16 100644
--- a/source/Expression/IRForTarget.cpp
+++ b/source/Expression/IRForTarget.cpp
@@ -579,7 +579,23 @@
     Function *fun = C->getCalledFunction();
     
     if (fun == NULL)
-        return true;
+    {
+        Value *val = C->getCalledValue();
+        
+        ConstantExpr *const_expr = dyn_cast<ConstantExpr>(val);
+        
+        if (const_expr && const_expr->getOpcode() == Instruction::BitCast)
+        {
+            fun = dyn_cast<Function>(const_expr->getOperand(0));
+            
+            if (!fun)
+                return true;
+        }
+        else
+        {
+            return true;
+        }
+    }
     
     clang::NamedDecl *fun_decl = DeclForGlobalValue(M, fun);
     uint64_t fun_addr;