IntegerLiteral::Create operates on integer types. For that reason
when we parse DWARF into an AST, when we encounter a constant
initialized enum member variable, we try to determine the underlying
integer type before creating the IntegerLiteral. However, we
currently don't desugar the type and for enum typedefs
dyn_cast<EnumType> fails. In debug builds this triggers following
assert:
Assertion failed: (type->isIntegerType() && "Illegal type in IntegerLiteral"), function IntegerLiteral, file Expr.cpp, line 892
This patch turns the dyn_cast<EnumType> into a getAs<EnumType>
which dyn_casts the canonical type, allowing us to get to the
underlying integer type.
Testing
- API test
- Manual repro is fixed
In case someone else is curious what the difference between before and after is:
https://clang.llvm.org/doxygen/Type_8h_source.html#l07302