<pre>The code <br><br>    cast<ArrayTypeLoc>(A->getTypeSourceInfo()->getTypeLoc())->getSizeExpr()</pre><div><div>is not valid in my clang version becaues getTypeLoc do not return a pointer, but <br><br>   inline TypeLoc TypeSourceInfo::getTypeLoc() const<br></div><div><br>But by your helpful information, i can check whether an array definition has an explicit size by :<br><br>        TypeLoc loc = decl->getTypeSourceInfo()->getTypeLoc();<br>        if (loc.getType()->isIncompleteArrayType())  // works<br><br>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.<br><br><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b> "Sean Silva"<silvas@purdue.edu>;</div><div><b>Date: </b> Sun, Jan 6, 2013 04:31 PM</div><div><b>To: </b> "kevinlynx"<kevinlynx@gmail.com>; <wbr></div><div><b>Cc: </b> "cfe-dev"<cfe-dev@cs.uiuc.edu>; <wbr></div><div><b>Subject: </b> Re: [cfe-dev] can we know if an array definition has an explicit size ??</div></div><div><br></div>Oh sorry, I misunderstood your question. See<br><http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-August/023849.html><br>for an answer to almost exactly the same question. I'm pretty sure<br>that the getSizeExpr() will be null if there was none written.<br><br>-- Sean Silva<br><br>On Sun, Jan 6, 2013 at 3:14 AM, kevinlynx <kevinlynx@gmail.com> wrote:<br>> No.<br>><br>>     int arr[3] = { 1, 2, 3 }<br>><br>> still get a ConstantArrayType.<br>><br>> Actually, if there's no explict size,<br>> RecursiveASTVisitor::VisitIncompleteArrayType will get called, but in this<br>> function context, i can not get the source location (because the argument to<br>> VisitIncompleteArrayType is only a type, not a stmt).<br>><br>> Thanks<br>><br>> ------------------ Original ------------------<br>> From:  "Sean Silva"<silvas@purdue.edu>;<br>> Date:  Sun, Jan 6, 2013 04:09 PM<br>> To:  "kevinlynx"<kevinlynx@gmail.com>;<br>> Cc:  "cfe-dev"<cfe-dev@cs.uiuc.edu>;<br>> Subject:  Re: [cfe-dev] can we know if an array definition has an explicit<br>> size ??<br>><br>> You can probably check that it is a ConstantArrayType<br>> <http://clang.llvm.org/doxygen/classclang_1_1ConstantArrayType.html>.<br>><br>> -- Sean Silva<br>><br>> On Sun, Jan 6, 2013 at 1:10 AM, kevinlynx <kevinlynx@gmail.com> wrote:<br>>> say,<br>>><br>>>     int arr[] = { 1, 2, 3 }<br>>><br>>> here `arr` size is determined by the initializer expression automatically,<br>>> but how to know this ? I implement `RecursiveASTVisitor::VisitVarDecl` and<br>>> get a `VarDecl` object.<br>>><br>>> Thanks<br>>><br>>><br>>><br>>> _______________________________________________<br>>> cfe-dev mailing list<br>>> cfe-dev@cs.uiuc.edu<br>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br>>><br></div>