================
@@ -15844,6 +15844,56 @@ static void DiagnoseShiftCompare(Sema &S, 
SourceLocation OpLoc,
       SourceRange(OCE->getArg(1)->getBeginLoc(), RHSExpr->getEndLoc()));
 }
 
+static bool operandEscapesImmediateMacroExpansion(const SourceManager &SM,
+                                                  SourceLocation OpLoc,
+                                                  SourceRange OperandRange) {
+
+  if (!OpLoc.isMacroID())
+    return false;
+
+  SourceLocation Begin = OperandRange.getBegin();
+  SourceLocation End = OperandRange.getEnd();
+
+  if (!Begin.isValid() || !End.isValid())
+    return false;
+
+  // If operand comes directly from file → definitely escapes
+  if (!Begin.isMacroID() || !End.isMacroID())
+    return true;
+
+  // Compare the immediate expansion location
+  SourceLocation OpExp = SM.getImmediateMacroCallerLoc(OpLoc);
+  SourceLocation BeginExp = SM.getImmediateMacroCallerLoc(Begin);
+  SourceLocation EndExp = SM.getImmediateMacroCallerLoc(End);
+
+  return BeginExp != OpExp || EndExp != OpExp;
+}
+
+static void DiagnoseMacroMixedOperator(Sema &Self, BinaryOperatorKind Opc,
+                                       SourceLocation OpLoc, Expr *LHSExpr,
+                                       Expr *RHSExpr) {
+  const SourceManager &SM = Self.getSourceManager();
+
+  if (!OpLoc.isMacroID())
+    return;
----------------
Rajveer100 wrote:

The case mentioned in 
https://github.com/llvm/llvm-project/pull/184924/changes#r2919832000 fails due 
to this, since here the `* 4` part falls outside hence we miss this case.

https://github.com/llvm/llvm-project/pull/184924
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to