[PATCH] D65426: [Coverage] Hide coverage for regions with incorrect end locations (PR39942)

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 18:01:32 PDT 2019


rnk added a comment.

I did some digging and I figured out where things go wrong. The issue is the repeated string-izing of the macro argument, the repetition of `#func` here. This hacky patch seems to fix the issue:

  diff --git a/clang/lib/Lex/MacroArgs.cpp b/clang/lib/Lex/MacroArgs.cpp
  index 5aa4679fad4..29fd25a43bb 100644
  --- a/clang/lib/Lex/MacroArgs.cpp
  +++ b/clang/lib/Lex/MacroArgs.cpp
  @@ -318,7 +318,7 @@ const Token &MacroArgs::getStringifiedArgument(unsigned ArgNo,
     if (StringifiedArgs.empty())
       StringifiedArgs.resize(getNumMacroArguments(), {});
  
  -  if (StringifiedArgs[ArgNo].isNot(tok::string_literal))
  +  //if (StringifiedArgs[ArgNo].isNot(tok::string_literal))
       StringifiedArgs[ArgNo] = StringifyArgument(getUnexpArgument(ArgNo), PP,
                                                  /*Charify=*/false,
                                                  ExpansionLocStart,

Basically, the second time we process a string-ized macro argument, we hit the cache, which uses the wrong expansion location for the second expansion. I'm going to try cleaning this up and we'll see if the cache is really needed.


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

https://reviews.llvm.org/D65426





More information about the cfe-commits mailing list