[PATCH] D83592: [Coverage] Add comment to skipped regions

Zequan Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 09:45:42 PDT 2020


zequanwu marked an inline comment as done.
zequanwu added inline comments.


================
Comment at: clang/lib/Lex/Preprocessor.cpp:973
+  if ((LexLevel == 0 || PreprocessToken) &&
+      !Result.getFlag(Token::IsReinjected)) {
+    if (LexLevel == 0)
----------------
hans wrote:
> zequanwu wrote:
> > @hans , can you take a look on this part? I saw `TokenCount` was introduced for a warning `-Wmax-tokens`.
> Can you explain why things are changing here?
> 
> The idea of TokenCount is to simply count the preprocessor tokens. At this point I think you have more knowledge here than I did when I added it :)
In `CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks`, I set `OnToken` to a lambda to update `PrevTokLoc` after lexing a new token. But, the original condition ` if (LexLevel == 0 && !Result.getFlag(Token::IsReinjected)) ` will not call `OnToken` if it's  lexing a directive, like `#if`, `#define` etc, because the LexLevel is greater than 0. In order to update `PrevTokLoc` even when lexing directive, I add `PreprocessToken` which will be set to true in `CodeGen::CoverageMappingModuleGen::setUpCoverageCallbacks` just to invoke `OnToken` without increment `TokenCount` when lexing directives. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83592/new/

https://reviews.llvm.org/D83592





More information about the llvm-commits mailing list