[cfe-commits] [PATCH] Add isConstMethod(), isVolatileMethod() to CXXMethodDecl

Sam Panzer panzer at google.com
Tue Aug 7 11:34:26 PDT 2012


On Tue, Aug 7, 2012 at 10:37 AM, David Blaikie <dblaikie at gmail.com> wrote:

>
> On Tue, Aug 7, 2012 at 10:30 AM, Sam Panzer <panzer at google.com> wrote:
> > Several places in the codebase determine if a method is const or
> volatile by
> > querying the method's type qualifiers directly, but it makes sense to
> > centralize the (simple) logic directly in CXXMethodDecl. It's
> particularly
> > useful for refactoring tools :)
>
> Given that they're already members on CXXMethodDecl, the "Method" in
> the name seems a bit redundant (I'm not dead set on this, though - I
> appreciate that "isConst" might be a bit more unclear than the
> existing things like "isVirtual", etc) would "isConst" and
> "isVolatile" suffice?
>

I considered "isConst" and "isConstQualified" along with "isConstMethod" -
mostly to distinguish between type qualifier const and method qualifier
const. I don't think "isConst" is unclear so long as it is accessed from a
well-named variable.


>
> Also how do these methods fail if the method is a static member
> function? Would it be helpful to have an assert there to ensure these
> are only called on non-static member functions?
>

Yes! Asserts added.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120807/ae48cb42/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: const-method.patch
Type: application/octet-stream
Size: 951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120807/ae48cb42/attachment.obj>


More information about the cfe-commits mailing list