[cfe-dev] non-virtual/virtual const/non-const Decl::getCanonicalDecl()
Richard Smith
richard at metafoo.co.uk
Fri Apr 11 14:05:57 PDT 2014
On Mon, Mar 10, 2014 at 11:48 PM, Craig Topper <craig.topper at gmail.com>wrote:
> While adding 'override' keywords I noticed some oddities with
> getCanonicalDecl.
>
> There is a non-const virtual version declared in Decl that is overridden
> in many places. There is also a const version in derived classes that is
> not virtual that just redirects to the const/virtual using const_cast.
>
> This pattern breaks in FunctionDecl and CXXRecordDecl when the const
> version becomes virtual as well.
>
> Was the original intention here to just have a single vtable entry?
>
That sounds really weird, and unlikely to be intentional. It looks like the
intent was probably to have only one vtable entry -- but even that is
weird, since a derived class would need to override both forms if it
overrides the virtual one, and the cost of the extra vtable entry is
basically zero. Maybe the simpler fix would be to make the const form
virtual too? Either way seems OK to me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140411/28741f0d/attachment.html>
More information about the cfe-dev
mailing list