On Wed, Feb 5, 2014 at 9:04 PM, Nick Lewycky <[email protected]> wrote:

> Is this better than using isa<>  instead of dyn_cast<>  in some way? Ie,
>>
>>      } else if (isa<FunctionDecl>(ND)) {
>>        const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(ND);
>>        ...
>>
>
> I haven't bothered to check, but probably not. The isa<> method calls
> classof, but you can overload classof at any level. If CXXMethodDecl has
> different classof implementations for when the static type is a
> FunctionDecl vs. NamedDecl, then it could be better.
>
> But I didn't really think about it. It's common to declare the variable
> and then use it, and I figured that it was probably intended that way. I
> don't much care, if you want to change it, or if you want me to change it.
> Whatever.


Well, there is a concrete difference: the table of the switch for casting
from FunctionDecl to CXXMethodDecl is smaller than the table for NamedDecl
to CXXMethodDecl. In that sense, it is a (minute) performance improvement
to use the most-refined type statically available.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to