[cfe-dev] Pseudo-functions taking types as arguments - keywords?

Chris Lattner clattner at apple.com
Mon Dec 29 09:41:02 PST 2008


On Dec 29, 2008, at 9:26 AM, Eli Friedman wrote:

> On Mon, Dec 29, 2008 at 3:38 AM, Sebastian Redl
> <sebastian.redl at getdesigned.at> wrote:
>> The question is, how do I implement the names of these functions? If
>> they are normal identifiers, their arguments will be mis-parsed,  
>> unless
>> I introduce a lot of special cases in the parser. However, it's a  
>> lot of
>> keywords to add. Thus, I'm wondering if Clang has some pre- 
>> established
>> way of handling such things.
>
> In the past, we've just used keywords; as far as I recall, the only
> cases we've had to deal with so far are sizeof, alignof, and typeof.
> You're pretty much forced to use keywords, actually, because you'll
> need a special action to pass the type names to Sema.  If you want to
> avoid adding 15 Actions, you can probably make a single ActOnTypeTrait
> which takes an enum.

Yep, we already have several other builtins that take types (e.g.  
__builtin_types_compatible_p, etc).  These are all handled in the  
parser as language keywords, because they have ad-hoc and weird  
different parsing rules.

Since these are C++ specific builtins, would it make sense to have  
"builtin templates" that handle these?  That way these could just be  
implicitly declared templates and take their arguments as type  
parameters?

-Chris



More information about the cfe-dev mailing list