[clang] [-Wunsafe-buffer-usage] Add alloc_size knowledge to the 2-param span constructor warning (PR #114894)

David Tarditi via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 7 16:49:53 PST 2025


================
@@ -353,23 +355,90 @@ isInUnspecifiedUntypedContext(internal::Matcher<Stmt> InnerMatcher) {
   return stmt(anyOf(CompStmt, IfStmtThen, IfStmtElse));
 }
 
+// Returns true iff integer E1 is equivalent to integer E2.
+//
+// For now we only support such expressions:
+//    expr := DRE | const-value | expr BO expr
+//    BO   := '*' | '+'
+//
+// FIXME: We can reuse the expression comparator of the interop analysis after
----------------
dtarditi wrote:

@ziqingluo-90 Is the expression comparator of the interop analysis the same or different from what is done here?

 I believe this expression comparison can result in exponential work in the size of an expression..  AreEquaIntegralBinaryOperator makes 2 calls to AreEqualIntegers per subexpression.  AreEqualIntegers can call back into EqualIntegeralBinaryOperator on subexpressions of its argument.

If the plan is to eventually replace this code with the expression comparator from interop analysis, then this is not worth fixing now.  However, if the expression comparator has the same issue or that is not the plan, then this should be fixed.   It can be fixed be bounding the amount of work that is allowed, for example, by limiting the recursive depth that is allowed.

https://github.com/llvm/llvm-project/pull/114894


More information about the cfe-commits mailing list