Clang assertion

Calling this function: clang_Type_getSizeOf

Sometimes leads to this assertion:

rp: /usr/src/clang/3.8.0/llvm-3.8.0/tools/clang/lib/AST/ASTContext.cpp:1790: clang::TypeInfo clang::ASTContext::getTypeInfoImpl(const clang::Type) const: Assertion `!A->getDeducedType().isNull() && “cannot request the size of an undeduced or dependent auto type”’ failed.

I try to avoid calling this with conditions like these:

const CXType type = clang_getCursorType(ref);
if (type.kind != CXType_LValueReference && type.kind != CXType_RValueReference && type.kind != CXType_Unexposed) {

https://github.com/Andersbakken/rtags/blob/master/src/ClangIndexer.cpp#L1087

What are the correct conditions for when this function is legal to call and not? Also, wouldn’t it be better to just return -1 than assert in this circumstance?

regards

Anders