File tree Expand file tree Collapse file tree
lib/PhasarLLVM/ControlFlow/Resolver Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020#include " llvm/IR/Constants.h"
2121#include " llvm/IR/DerivedTypes.h"
2222#include " llvm/IR/InstrTypes.h"
23+ #include " llvm/IR/Instructions.h"
24+ #include " llvm/Support/Casting.h"
2325
2426#include " phasar/DB/ProjectIRDB.h"
2527#include " phasar/PhasarLLVM/ControlFlow/Resolver/Resolver.h"
@@ -51,15 +53,29 @@ std::optional<unsigned> getVFTIndex(const llvm::CallBase *CallSite) {
5153}
5254
5355const llvm::StructType *getReceiverType (const llvm::CallBase *CallSite) {
54- if (!CallSite->arg_empty ()) {
55- const auto *Receiver = CallSite->getArgOperand (0 );
56- if (Receiver->getType ()->isPointerTy ()) {
57- if (const auto *ReceiverTy = llvm::dyn_cast<llvm::StructType>(
58- Receiver->getType ()->getPointerElementType ())) {
59- return ReceiverTy;
60- }
61- }
56+ if (CallSite->arg_empty () ||
57+ (CallSite->hasStructRetAttr () && CallSite->arg_size () < 2 )) {
58+ return nullptr ;
59+ }
60+
61+ const auto *Receiver =
62+ CallSite->getArgOperand (unsigned (CallSite->hasStructRetAttr ()));
63+
64+ if (!Receiver->getType ()->isPointerTy ()) {
65+ return nullptr ;
6266 }
67+
68+ if (Receiver->getType ()->isOpaquePointerTy ()) {
69+ llvm::errs () << " WARNING: The IR under analysis uses opaque pointers, "
70+ " which are not supported by phasar yet!\n " ;
71+ return nullptr ;
72+ }
73+
74+ if (const auto *ReceiverTy = llvm::dyn_cast<llvm::StructType>(
75+ Receiver->getType ()->getPointerElementType ())) {
76+ return ReceiverTy;
77+ }
78+
6379 return nullptr ;
6480}
6581
You can’t perform that action at this time.
0 commit comments