[cfe-dev] Setting LangOpts flags

Eli Friedman eli.friedman at gmail.com
Thu Oct 25 14:31:10 PDT 2012


On Thu, Oct 25, 2012 at 2:25 PM, Jeff Heckey <jheckey at gmail.com> wrote:
> Hi all,
>
> I'm working on a language that uses many C constructs, but is not a strict
> superset or subset of C, so some of the keywords exist and some do not.  My
> changes so far have been:
>
> 1) Add an enum to lib/Basic/IdentifierTable.cpp:
> namespace {
>   enum {
>     ....
>     KEYFOO = 0x1000,
>     KEYALL = 0x0fff       // Do not at KEYFOO to all
>   };
> }
>
> 2) Add all of the keywords I wanted to include/clang/Basic/TokenKinds.def:
> KEYWORD(break             , KEYALL|KEYFOO)
> KEYWORD(foo                , KEYFOO)
> KEYWORD(atomic           , KEYALL)
>
> 3) Add a language option to include/clang/Basic/LangOptions.def:
> LANGOPT(FOO              , 1, 0, "FooQua")
>
> When I include KEYFOO in KEYALL, the keyword "foo" is found, but I want to
> keep the keyword list separate. How can I change the LangOptions Flag to
> only look for KEYFOO keywords?

You can hack up AddKeyword in IdentifierTable.cpp .  Or just delete
the C keywords you don't want. :)

-Eli



More information about the cfe-dev mailing list