[cfe-dev] adding attribute bits to types
Mattias Holm
holm at liacs.nl
Thu Aug 20 06:04:31 PDT 2009
Hi,
I am currently working on an experiment where I am adding additional
type qualifiers on struct instances (this is done with the __attribute__
syntax).
Syntactically in C, I am trying to do something like this at the moment:
typedef struct Foo {
...
} Foo;
#define BAR __attribute__((bar))
void f(void) {
BAR Foo *baz = ...;
...
}
This attribute will then be used to influence the code generator.
I made some hacks to add these extra attributes in the attribute parser
and then some in SemaType.cpp: ProcessTypeAttributeList in order to
process these attributes. So far that works well.
My idea then is that I add some extra tag bits to the RecordType class
(or to subclass it, but that's a minor issue) in order to keep track of
these extra qualifiers, but that then means that I probably need to
unique these as new record types and add the new (attribute) qualified
types to the ASTContext, right? Here I am stuck at the moment, and I do
not understand how and where a record type is looked up and added to the
AST context. Some pointers where I should look would be nice.
Would it be a better and/or easier approach, to add the bits to the
QualType class instead?
Regards,
Mattias
More information about the cfe-dev
mailing list