Update scanner in TParseContext when changing the input stream.

After parsing a #include directive, we push a TokenizableString
which contains the content of the included file into the input
stack. Henceforth, tokens will be read from the newly pushed
TokenizableString. However, the scanner in TParseContext still
points to the previous input stream. We need to update the scanner
to point to the new input stream inside TokenizableString. Thus,
the setCurrent{String|Line|..} method in TParseContext updates
the status of the correct input stream. After finishing the newly
pushed TokenizableString, we need to restore the scanner to the
previous input stream.
This commit is contained in:
Lei Zhang 2015-07-05 16:50:21 -04:00
parent 9c1280b225
commit 2b4ebbb1e1
3 changed files with 25 additions and 3 deletions

View file

@ -615,7 +615,7 @@ int TPpContext::CPPinclude(TPpToken* ppToken)
bool success;
std::tie(success, replacement) = includer.include(name);
if (success) {
pushInput(new TokenizableString(replacement, this));
pushInput(new TokenizableString(directiveLoc, replacement, this));
// At EOF, there's no "current" location anymore.
if (token != EndOfInput) parseContext.setCurrentColumn(0);
// Don't accidentally return EndOfInput, which will end all preprocessing.