diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:02:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:02:28 +0000 |
commit | 7442d6faa2719e4e7d33a7021c406c5a4facd74d (patch) | |
tree | c72b9241553fc9966179aba84f90f17bfa9235c3 /lib/Lex/Pragma.cpp | |
parent | b52119637f743680a99710ce5fdb6646da2772af (diff) |
Diffstat (limited to 'lib/Lex/Pragma.cpp')
-rw-r--r-- | lib/Lex/Pragma.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index 100da514144a6..f81eaa31e9e99 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -160,12 +160,23 @@ public: ~LexingFor_PragmaRAII() { if (InMacroArgPreExpansion) { + // When committing/backtracking the cached pragma tokens in a macro + // argument pre-expansion we want to ensure that either the tokens which + // have been committed will be removed from the cache or that the tokens + // over which we just backtracked won't remain in the cache after they're + // consumed and that the caching will stop after consuming them. + // Otherwise the caching will interfere with the way macro expansion + // works, because we will continue to cache tokens after consuming the + // backtracked tokens, which shouldn't happen when we're dealing with + // macro argument pre-expansion. + auto CachedTokenRange = PP.LastCachedTokenRange(); if (Failed) { PP.CommitBacktrackedTokens(); } else { PP.Backtrack(); OutTok = PragmaTok; } + PP.EraseCachedTokens(CachedTokenRange); } } |