================
@@ -847,11 +869,104 @@ static bool areExprsMacroAndNonMacro(const Expr 
*&LhsExpr,
   if (!LhsExpr || !RhsExpr)
     return false;
 
-  SourceLocation LhsLoc = LhsExpr->getExprLoc();
-  SourceLocation RhsLoc = RhsExpr->getExprLoc();
+  const SourceLocation LhsLoc = LhsExpr->getExprLoc();
+  const SourceLocation RhsLoc = RhsExpr->getExprLoc();
 
   return LhsLoc.isMacroID() != RhsLoc.isMacroID();
 }
+
+static bool areStringsSameIgnoreSpaces(const llvm::StringRef *Left,
+                                       const llvm::StringRef *Right) {
+  if (Left == Right)
+    return true;
+  if (Left->compare(*Right) == 0) {
+    return true;
+  }
+  // Do running index comparison
+  size_t LIdx = 0;
+  size_t RIdx = 0;
+  const char *LData = Left->data();
+  const char *RData = Right->data();
+  while (LIdx < Left->size() && RIdx < Right->size()) {
----------------
PiotrZSL wrote:

write this using ltrim and drop_front, we in 2025, no need to go back to legacy 
C++

```
  Left = Left.trim();
  Right = Right.trim();
  while(!Left.empty() && !Right.empty()) {
     Left = Left.ltrim();
     Right = Right.ltrim();
     if (Left.front() != Right.front()) return false;
    Left = Left.drop_front();
    Right = Right.drop_front();
  }
  return Left.empty() && Right.empty();
```

https://github.com/llvm/llvm-project/pull/122841
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to