CastXML / CastXML

C-family Abstract Syntax Tree XML Output
Apache License 2.0
480 stars 90 forks source link

Wrong access for class templates inside another class. #56

Closed taillonm closed 8 years ago

taillonm commented 8 years ago

If you run castxml on this code:

class TestClass
{
protected:
  template <class T> class TemplateSubclass
  {
  public:
    T mData;
  };

  TemplateSubclass<double> mInstance;
};

then the class TemplateSubclass has access="public" instead of "protected" like other non template classes.

bradking commented 8 years ago

Thanks. Fixed by commit b367e2db71910f088856849fd2990207cf5841c4.

PhilMarek commented 8 years ago

If you write instead

class TestClass
{
protected:
  template <class T> class TemplateSubclass
  {
  public:
    T mData;
  };

  typedef TemplateSubclass<double> mInstance;
};

then the attribute "access" is completely missing. Before this bugfix, the attribute was there, of course always with value "public".

bradking commented 8 years ago

@PhilMarek thanks for pointing this out. It seems Clang is reporting AS_none as the access for the incomplete class type (the typedef does not cause the full type to be instantiated). Prior to the change here CastXML incorrectly treated AS_none as equivalent to AS_public. I think no access information is better than wrong access information. Further investigation will be needed to see if proper access information can be determined.

bradking commented 8 years ago

In commit c7de52912ca365accc004b01ba95a2bfebe14b0e I improve the fix to handle the incomplete case too.