[cfe-dev] Written name of conversion operator
Douglas Gregor
dgregor at apple.com
Fri Jun 4 15:16:25 PDT 2010
On Jun 4, 2010, at 2:38 PM, Abramo Bagnara wrote:
> Il 04/06/2010 22:52, Douglas Gregor ha scritto:
>> I have a different idea of how to address this issue, for which I had previously filed this bug report:
>>
>> http://llvm.org/bugs/show_bug.cgi?id=6357
>>
>> Essentially, it suggests adding a DeclarationNameLoc type that, similarly to TypeLoc, contains information about the exact spelling of and the source locations for a declaration name. DeclarationNameLoc should remain small (IdentifierInfo* + SourceLocation for the common case), and use separate storage when we need to store extra information (e.g., a conversion operator would refer to the TypeSourceInfo * of the conversion type as written).
>>
>> There would have to be a way---probably via the ASTContext---to extract a DeclarationName from a DeclarationNameLoc, for name-lookup purposes.
>>
>> We would use DeclarationNameLoc within the ASTs (MemberExpr, DeclRefExpr, etc.) in lieu of DeclarationName.
>
> You're more inclined toward:
>
> struct DeclarationNameLoc {
> DeclarationName Name;
> char Extra[0];
> };
>
> and to have a field DeclarationNameLoc* NameLoc inside AST nodes
>
> or
>
> struct DeclarationNameLoc {
> DeclarationName Name;
> void* Extra;
> };
>
> and to have a field DeclarationNameLoc NameLoc inside AST nodes?
Something like the latter, since we absolutely must make sure that the common case of (IdentifierInfo*, SourceLocation) doesn't require an extra memory allocation. I would probably end up creating something similar to DeclarationName itself, with a bit-mangled pointer for the name and storage for the first two locations.
struct DeclarationNameLoc {
void *Ptr;
SourceLocations Locs[2];
};
> Another possibility is to have Extra data allocated at end of containing
> node, but I think this might become too messy.
I think that would be too messy.
- Doug
More information about the cfe-dev
mailing list