[cfe-dev] Source information for types
Argyrios Kyrtzidis
kyrtzidis at apple.com
Wed Jul 8 18:11:27 PDT 2009
On Jul 8, 2009, at 4:49 PM, Eli Friedman wrote:
> On Wed, Jul 8, 2009 at 4:34 PM, Argyrios
> Kyrtzidis<kyrtzidis at apple.com> wrote:
>> Ideally all the type source info for the above type would be readily
>> available from the AST; recomputing all the information from the
>> tokens
>> isn't practical, Sema already did the hard work, we just need to
>> store it.
>
> Hmm... are you planning to make the SourceType recursive?
Possibly but no concrete plans about C++ yet. Let's start focusing on
the single typedef case for now :-)
>
>>> Also, your suggestion doesn't really address where exactly you
>>> plan to
>>> store your flag; there aren't any spare bits in QualType.
>>
>> The flag is just a boolean to pass to Sema to tell it whether to
>> create
>> SourceTypes or not. If the flag is false, Sema will discard the
>> source info
>> and just pass QualTypes to the Decls, as it currently does.
>
> Oh, I see; it would vary with a flag on the ASTContext rather than the
> individual Decls.
Yes exactly; but note that whether a TypeSpecifier wraps a 'plain'
QualType or a QualType containing a SourceType can be varied and
checked using TypeSpecifier::isSourceType().
This is basically what the TypeSpecifier would look like:
class TypeSpecifier {
QualType Ty;
public:
explicit TypeSpecifier(QualType type) : Ty(type) { }
TypeSpecifier(SourceType *sourceTy) : Ty(QualType(sourceTy, 0)) { }
QualType getType() const {
if (SourceType *ST = dyn_cast_or_null<SourceType>(Ty.getTypePtr()))
return ST->getBaseType();
return Ty;
}
bool isSourceType() const {
return dyn_cast_or_null<SourceType>(Ty.getTypePtr()) != 0;
}
SourceType *getSourceType() const { return cast<SourceType>(Ty); }
};
-Argiris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090708/ebcfa291/attachment.html>
More information about the cfe-dev
mailing list