can we know if an array definition has an explicit size ??

The code 


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.

------------------ Original ------------------

Yes, the name is pretty confusing. Basically, it is "extra
information" about a type which doesn't factor into the core type
checking code. E.g.,

char arr[4 + 4];


char arr2[8];

are the same type (Type) to the compiler, but there is a distinction
that you can recover by looking at the TypeSourceInfo.

-- Sean Silva

Hello Sean Silva, kevinlynx

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

PS. This is not a proven info but just one of my study result.