Skip to content

Commit

Permalink
dump value when assert fails
Browse files Browse the repository at this point in the history
  • Loading branch information
jumormt committed Dec 21, 2023
1 parent c13f87e commit 40a36fb
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions svf-llvm/include/SVF-LLVM/LLVMUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ static inline Type* getPtrElementType(const PointerType* pty)
#endif
}

std::string dumpValue(const Value* val);

std::string dumpType(const Type* type);

/// Infer type based on llvm value, this is for the migration to opaque pointer
/// please refer to: https://llvm.org/docs/OpaquePointers.html#migration-instructions
static inline Type *getPointeeType(const Value *value) {
Expand Down Expand Up @@ -166,7 +170,7 @@ static inline Type *getPointeeType(const Value *value) {
// e.g., for `%call = call ptr @_Znwm(i64 noundef 8)`, we return i64
return func->getFunctionType();
} else {
assert(false && "Unknown llvm Type, cannot get Ptr Element Type");
assert(false && (dumpValue(value) + ": Unknown llvm Type, cannot get Ptr Element Type").c_str());

Check warning on line 173 in svf-llvm/include/SVF-LLVM/LLVMUtil.h

View check run for this annotation

Codecov / codecov/patch

svf-llvm/include/SVF-LLVM/LLVMUtil.h#L173

Added line #L173 was not covered by tests
abort();
}
}
Expand Down Expand Up @@ -560,9 +564,7 @@ bool VCallInCtorOrDtor(const CallBase* cs);
bool isSameThisPtrInConstructor(const Argument* thisPtr1,
const Value* thisPtr2);

std::string dumpValue(const Value* val);

std::string dumpType(const Type* type);


/**
Expand Down

0 comments on commit 40a36fb

Please sign in to comment.