diff options
author | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-17 09:59:12 +0000 |
---|---|---|
committer | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-17 09:59:12 +0000 |
commit | ce70f43356e19c14deb3a89da25ebe89d6cb255a (patch) | |
tree | 372dab78d59e4e58eead8df4f751726cec9b98b4 /gcc/doc/cppopts.texi | |
parent | 97bfb9ef7f7e4d8e5261385db972ebbffac11c31 (diff) | |
download | gcc-ce70f43356e19c14deb3a89da25ebe89d6cb255a.tar.gz |
Generate virtual locations for tokens
This second instalment uses the infrastructure of the previous patch
to allocate a macro map for each macro expansion and assign a virtual
location to each token resulting from the expansion.
To date when cpp_get_token comes across a token that happens to be a
macro, the macro expander kicks in, expands the macro, pushes the
resulting tokens onto a "token context" and returns a dummy padding
token. The next call to cpp_get_token goes look into the token context
for the next token [which is going to result from the previous macro
expansion] and returns it. If the token is a macro, the macro expander
kicks in and you know the story.
This patch piggy-backs on that macro expansion process, so to speak.
First it modifies the macro expander to make it create a macro map for
each macro expansion. It then allocates a virtual location for each
resulting token. Virtual locations of tokens resulting from macro
expansions are then stored on a special kind of context called an
"expanded tokens context". In other words, in an expanded tokens
context, there are tokens resulting from macro expansion and their
associated virtual locations. cpp_get_token_with_location is modified
to return the virtual location of tokens resulting from macro
expansion. Note that once all tokens from an expanded token context have
been consumed and the context and is freed, the memory used to store the
virtual locations of the tokens held in that context is freed as well.
This helps reducing the overall peak memory consumption.
The client code that was getting macro expansion point location from
cpp_get_token_with_location now gets virtual location from it. Those
virtual locations can in turn be resolved into the different
interesting physical locations thanks to the linemap API exposed by
the previous patch.
Expensive progress. Possibly. So this whole virtual location
allocation business is switched off by default. So by default no
extended token is created. No extended token context is created
either. One has to use -ftrack-macro-expansion to switch this on. This
complicates the code but I believe it can be useful as some of our
friends found out at http://llvm.org/bugs/show_bug.cgi?id=5610
The patch tries to reduce the memory consumption by freeing some token
context memory that was being reused before. I didn't notice any
compilation slow down due to this immediate freeing on my GNU/Linux
system.
As no client code tries to resolve virtual locations to anything but
what was being done before, no new test case has been added.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180082 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/doc/cppopts.texi')
-rw-r--r-- | gcc/doc/cppopts.texi | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi index 5212478389d..b2252367ef5 100644 --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi @@ -583,6 +583,24 @@ correct column numbers in warnings or errors, even if tabs appear on the line. If the value is less than 1 or greater than 100, the option is ignored. The default is 8. +@item -ftrack-macro-expansion@r{[}=@var{level}@r{]} +@opindex ftrack-macro-expansion +Track locations of tokens across macro expansions. This allows the +compiler to emit diagnostic about the current macro expansion stack +when a compilation error occurs in a macro expansion. Using this +option makes the preprocessor and the compiler consume more +memory. The @var{level} parameter can be used to choose the level of +precision of token location tracking thus decreasing the memory +consumption if necessary. Value @samp{0} of @var{level} de-activates +this option just as if no @option{-ftrack-macro-expansion} was present +on the command line. Value @samp{1} tracks tokens locations in a +degraded mode for the sake of minimal memory overhead. In this mode +all tokens resulting from the expansion of an argument of a +function-like macro have the same location. Value @samp{2} tracks +tokens locations completely. This value is the most memory hungry. +When this option is given no argument, the default parameter value is +@samp{2}. + @item -fexec-charset=@var{charset} @opindex fexec-charset @cindex character set, execution |