[clang] ca8c615 - Fix test output regression from ee88c0cf09969ba44307068797e12533b94768a6.

Manuel Klimek via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 25 05:55:58 PST 2022


Author: Manuel Klimek
Date: 2022-11-25T13:53:34Z
New Revision: ca8c6156f27003ffa0e24bace2be7c25307f50a3

URL: https://github.com/llvm/llvm-project/commit/ca8c6156f27003ffa0e24bace2be7c25307f50a3
DIFF: https://github.com/llvm/llvm-project/commit/ca8c6156f27003ffa0e24bace2be7c25307f50a3.diff

LOG: Fix test output regression from ee88c0cf09969ba44307068797e12533b94768a6.

The unused variable fix also remove the test output of the tokens
that do not match, making debugging tests harder. Undo the semantic
changes of the build fix.

Added: 
    

Modified: 
    clang/unittests/Format/MacroCallReconstructorTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Format/MacroCallReconstructorTest.cpp b/clang/unittests/Format/MacroCallReconstructorTest.cpp
index 2b880d75b514f..eee980bae8d8b 100644
--- a/clang/unittests/Format/MacroCallReconstructorTest.cpp
+++ b/clang/unittests/Format/MacroCallReconstructorTest.cpp
@@ -97,12 +97,20 @@ struct Matcher {
   Matcher(const TokenList &Tokens, TestLexer &Lex)
       : Tokens(Tokens), It(this->Tokens.begin()), Lex(Lex) {}
 
+  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;
+  }
+
   Chunk consume(StringRef Tokens) {
     TokenList Result;
     for (const FormatToken *Token : uneof(Lex.lex(Tokens))) {
       (void)Token; // Fix unused variable warning when asserts are disabled.
-      assert((*It)->getType() == Token->getType() &&
-             (*It)->TokenText == Token->TokenText);
+      assert(tokenMatches(*It, Token));
       Result.push_back(*It);
       ++It;
     }


        


More information about the cfe-commits mailing list