non-virtual/virtual const/non-const Decl::getCanonicalDecl()

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.