[clang] ee88c0c - [NFCI] Fix unused variable/function warnings in MacroCallReconstructorTest.cpp when asserts are disabled.

Manuel Klimek via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 13 02:43:11 PDT 2022


This is a functional change, as it removes the debug output when the tokens
do not match, which is important for understanding test failures.

On Wed, Jul 13, 2022 at 1:47 AM Jorge Gorbe Moya via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

>
> Author: Jorge Gorbe Moya
> Date: 2022-07-12T16:46:58-07:00
> New Revision: ee88c0cf09969ba44307068797e12533b94768a6
>
> URL:
> https://github.com/llvm/llvm-project/commit/ee88c0cf09969ba44307068797e12533b94768a6
> DIFF:
> https://github.com/llvm/llvm-project/commit/ee88c0cf09969ba44307068797e12533b94768a6.diff
>
> LOG: [NFCI] Fix unused variable/function warnings in
> MacroCallReconstructorTest.cpp when asserts are disabled.
>
> Added:
>
>
> Modified:
>     clang/unittests/Format/MacroCallReconstructorTest.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/clang/unittests/Format/MacroCallReconstructorTest.cpp
> b/clang/unittests/Format/MacroCallReconstructorTest.cpp
> index 2bda62aa42be..3abe0383aeae 100644
> --- a/clang/unittests/Format/MacroCallReconstructorTest.cpp
> +++ b/clang/unittests/Format/MacroCallReconstructorTest.cpp
> @@ -91,14 +91,6 @@ struct Chunk {
>    llvm::SmallVector<UnwrappedLine, 0> Children;
>  };
>
> -bool tokenMatches(const FormatToken *Left, const FormatToken *Right) {
> -  if (Left->getType() == Right->getType() &&
> -      Left->TokenText == Right->TokenText)
> -    return true;
> -  llvm::dbgs() << Left->TokenText << " != " << Right->TokenText << "\n";
> -  return false;
> -}
> -
>  // Allows to produce chunks of a token list by typing the code of equal
> tokens.
>  //
>  // Created from a list of tokens, users call "consume" to get the next
> chunk
> @@ -110,7 +102,9 @@ struct Matcher {
>    Chunk consume(StringRef Tokens) {
>      TokenList Result;
>      for (const FormatToken *Token : uneof(Lex.lex(Tokens))) {
> -      assert(tokenMatches(*It, Token));
> +      (void)Token;  // Fix unused variable warning when asserts are
> disabled.
> +      assert((*It)->getType() == Token->getType() &&
> +             (*It)->TokenText == Token->TokenText);
>        Result.push_back(*It);
>        ++It;
>      }
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220713/4e547da4/attachment-0001.html>


More information about the cfe-commits mailing list