================
@@ -15844,6 +15844,55 @@ 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;
+}
----------------
Rajveer100 wrote:
```suggestion
}
```
https://github.com/llvm/llvm-project/pull/184924
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits