Exercises
Here are some simple questions and exercises that you might want to play around with by yourself:
- Though most of the time
Tokens
are harvested from provided source code, in some cases,Tokens
might be generated dynamically inside thePreprocessor
. For example, the__LINE__
built-in macro is expanded to the current line number, and the__DATE__
macro is expanded to the current calendar date. How does Clang put that generated textual content into the source code buffer ofSourceManager
? How does Clang assignSourceLocation
to these tokens? - When we were talking about implementing a custom
PragmaHandler
, we were leveragingPreprocessor::Lex
to fetchTokens
followed after the pragma name, until we hit theeod
token kind. Can we keep lexing beyond theeod
token? What interesting things will you do if you can consume arbitrary tokens after the#pragma
directive? - In the
macro guard
project from the Developing custom preprocessor plugins and callbacks section, the...