[cfe-commits] [PATCH] cv-qualifiers for C++ methods
Douglas Gregor
dgregor at apple.com
Fri Oct 24 08:32:24 PDT 2008
On Oct 23, 2008, at 7:21 PM, Argiris Kirtzidis wrote:
> The attached patch implements support for cv-qualifiers in the
> function declarator ("void f() const;").
(in class FunctionType):
+ /// TypeQuals - Used only by FunctionTypeProto, put here to pack
with the
+ /// other bitfields.
+ unsigned TypeQuals : 3;
This is an interesting choice, and I think it's the right one. My
first reaction was surprise that the type qualifiers weren't just
handled by a QualType, but that would be subtly wrong; the distinction
is that there are no cv-qualified function types, but there are
function types that have cv qualifiers. This different is probably
comment-worthy :)
+ /// The type qualifiers: const/volatile/restrict.
+ unsigned TypeQuals : 3;
Please note that the qualifier bitmask values are the same as in
QualType.
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp (revision 58037)
+++ lib/Sema/SemaExpr.cpp (working copy)
@@ -402,7 +402,8 @@
if (FD->isInvalidDecl())
return true;
- return new DeclRefExpr(FD, FD->getType(), Loc);
+ return new DeclRefExpr(FD,
+ FD->getType().getWithAdditionalQualifiers(MD-
>getTypeQualifiers()),Loc);
}
I wouldn't have expected this, given that the type qualifiers for the
function are within the FunctionType. Why are they transferred into
the QualType at this point?
Should CXXMethodDecl::getThisType be updated to apply the function
qualifiers to the type of *this?
Other than those little things above, I think this patch is ready to
go in. Thanks!
- Doug
More information about the cfe-commits
mailing list