The code
cast<ArrayTypeLoc>(A->getTypeSourceInfo()->getTypeLoc())->getSizeExpr()
is not valid in my clang version becaues getTypeLoc do not return a pointer, but
inline TypeLoc TypeSourceInfo::getTypeLoc() const
But by your helpful information, i can check whether an array definition has an explicit size by :
TypeLoc loc = decl->getTypeSourceInfo()->getTypeLoc();
if (loc.getType()->isIncompleteArrayType()) // works
On the other hand, can you explan what a TypeSourceInfo is ? I check out the class comments, but still don’t get the meaning. And what a canonical is ? Thanks a lot.
In my previous study,
- an AST node of an array is composed of clang::TypeSourceInfo and identifier.
- clang::TypeSourceInfo is composed of clang::Type and clang::TypeLoc.
- identifier is the name of the array(variable).
Best regards
Journeyer
PS. This is not a proven info but just one of my study result.