neel
neel

Reputation: 9061

Check pointer to pointer type in LLVM

How to check an operand is pointer to pointer type in LLVM? We can check is operand pointer or not, but how to check is it pointing to a pointer? I am using Clang to generate intermediate code and using C++ for source file.

Upvotes: 6

Views: 3312

Answers (1)

Oak
Oak

Reputation: 26868

You can invoke Type::getContainedType(int) to get access to the pointee type. So it should look like this:

bool isPointerToPointer(const Value* V) {
    const Type* T = V->getType();
    return T->isPointerTy() && T->getContainedType(0)->isPointerTy();
}

Upvotes: 10

Related Questions