[cfe-dev] Adding new language keywords

Eli Friedman eli.friedman at gmail.com
Thu Nov 1 12:04:40 PDT 2012


On Thu, Nov 1, 2012 at 11:38 AM, Jeff Heckey <jheckey at gmail.com> wrote:
> I've been trying to add new keywords (e.g., module) to Clang for a project,
> but I want to only add the support for my language extensions (because I
> want to keep the merges to a minimum and modify as few things as possible).
> I did this by adding an enum type to the IndentifierTable.cpp namespace:
>
> namespace {
>   enum {
>     KEYC99 = 0x1,
>     KEYCXX = 0x2,
>     KEYCXX0X = 0x4,
>     KEYGNU = 0x8,
>     KEYMS = 0x10,
>     BOOLSUPPORT = 0x20,
>     KEYALTIVEC = 0x40,
>     KEYNOCXX = 0x80,
>     KEYBORLAND = 0x100,
>     KEYOPENCL = 0x200,
>     KEYC11 = 0x400,
>     KEYARC = 0x800,
>     KEYSCAF = 0x1000, // Scaffold enum
>     KEYALL = 0x1fff
>   };
> }
>
> And adding the type to the check in AddKeyword().
>
> I then added the desired keywords to the TokenFeatures:
>
> //Scaffold added keywords
> KEYWORD(qreg                        , KEYSCAF)
> KEYWORD(qint                        , KEYSCAF)
> KEYWORD(module                      , KEYSCAF)
> KEYWORD(c2qg                        , KEYSCAF)
>
> However, once compiled, the keywords are still treated as identifiers, not
> types or keywords.
>
> What am I missing?

See lib/Basic/IdentifierTable.cpp .

-Eli



More information about the cfe-dev mailing list