- User *U = *I;
- if (CallInst *CI = dyn_cast<CallInst>(U))
- getNodeFor(CI->getParent()->getParent())->addCalledFunction(Node);
- else if (InvokeInst *II = dyn_cast<InvokeInst>(U))
- getNodeFor(II->getParent()->getParent())->addCalledFunction(Node);
- else // Can't classify the user!
- ExternalNode->addCalledFunction(Node);
+ if (Instruction *Inst = dyn_cast<Instruction>(*I)) {
+ if (isOnlyADirectCall(F, CallSite::get(Inst)))
+ getNodeFor(Inst->getParent()->getParent())->addCalledFunction(Node);
+ else
+ isUsedExternally = true;
+ } else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(*I)) {
+ // THIS IS A DISGUSTING HACK. Brought to you by the power of
+ // ConstantPointerRefs!
+ for (Value::use_iterator I = CPR->use_begin(), E = CPR->use_end();
+ I != E; ++I)
+ if (Instruction *Inst = dyn_cast<Instruction>(*I)) {
+ if (isOnlyADirectCall(F, CallSite::get(Inst)))
+ getNodeFor(Inst->getParent()->getParent())->addCalledFunction(Node);
+ else
+ isUsedExternally = true;
+ } else {
+ isUsedExternally = true;
+ }
+ } else { // Can't classify the user!
+ isUsedExternally = true;
+ }