[patch] Don't compute a "patched" storage class

Douglas Gregor dgregor at apple.com
Tue Apr 2 22:13:25 PDT 2013


On Apr 2, 2013, at 10:06 PM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:

>> @@ -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()?
> 
> Done.
> 
>> This API change is probably release-note-worthy, because we're going from a semantic description to a syntactic one.
> 
> Done.
> 
>> +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?
> 
> I am not sure. The only case where getPreviousDecl is not attached is
> 
> struct B {
>  template <class T> static void funcT1();
> };
> template <class T>
> void B::funcT1() {}
> void test() {
>  B::funcT1<int>();
> }
> 
> Should getPreviousDecl in this example reach the static decl? If so,
> we should probably go the other way: remove the
> getTemplateSpecializationInfon check and fix the linking.

The template "funcT1" is not a previous declaration of the specialization B::funcT1<int>. But to figure out that the specialization B::funcT1<int> is static we either need the specialization itself to be marked static or we need to walk through getTemplateSpecializationInfo. The member specialization info is for something like:

template<typename T>
struct C {
  static void funcT2();
};

void test()
  C<int>::funcT2();
}

> New patch attached. I will probably commit it tomorrow and fix
> isStatic in a followup patch.

Sounds good.

	- Doug





More information about the cfe-commits mailing list