Expr objects and Evaluate*

Hi,

I have an Expr object. How can I know if I can invoke
EvaluateAsBooleanCondition, EvaluateAsRValue, EvaluateAsInt and
EvaluateAsFloat ?
Because if I just call them on any Expr object, I get assertions like:

llvm/tools/clang/include/clang/AST/Type.h:612: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve a NULL type pointer"' failed

#3 0x00007f65aa2111b2 in __GI___assert_fail (assertion=0x11e6450 "!isNull() && \"Cannot retrieve a NULL type pointer\"", file=0x11e61d0 "/home/folkert/llvm/tools/clang/include/clang/AST/Type.h", line=612,
    function=0x1780040 <_ZZNK5clang8QualType12getCommonPtrEvE19__PRETTY_FUNCTION__> "const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const") at assert.c:101
#4 0x0000000000ea5713 in clang::QualType::getCommonPtr() const [clone .part.1700] ()
#5 0x0000000000ec3727 in clang::Expr::EvaluateAsInt(llvm::APSInt&, clang::ASTContext const&, clang::Expr::SideEffectsKind) const ()

Folkert van Heusden