[patch] Don't compute a "patched" storage class
Douglas Gregor
dgregor at apple.com
Tue Apr 2 20:33:59 PDT 2013
On Mar 31, 2013, at 10:00 AM, Rafael EspĂndola <rafael.espindola at gmail.com> wrote:
> For variables and functions clang stores two storage classes. The one
> "as written" in the code and a patched one, which, for example,
> propagates static to the following decls.
>
> This apparently is from the days clang lacked linkage computation. It
> is now redundant and this patch removes it.
Excellent!
@@ -766,14 +763,7 @@ public:
StorageClass getStorageClass() const {
return (StorageClass) VarDeclBits.SClass;
}
Can you add a comment on getStorageClass() (both of them) noting that this is the storage class as written in the source code, pointing to getLinkage()? This API change is probably release-note-worthy, because we're going from a semantic description to a syntactic one.
+bool CXXMethodDecl::isStatic() const {
+ const CXXMethodDecl *MD = this;
+ for (;;) {
+ const CXXMethodDecl *C = MD->getCanonicalDecl();
+ if (C != MD) {
+ MD = C;
+ continue;
+ }
+
+ FunctionTemplateSpecializationInfo *Info = MD->getTemplateSpecializationInfo();
+ if (!Info)
+ break;
+ MD = cast<CXXMethodDecl>(Info->getTemplate()->getTemplatedDecl());
+ }
Also look through member specialization info?
Otherwise, this LGTM!
- Doug
More information about the cfe-commits
mailing list