[clang] [-Wunsafe-buffer-usage] Fixits for unsafe arguments of function pointer calls (PR #80358)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 14 09:09:01 PST 2024


================
@@ -282,8 +282,8 @@ isInUnspecifiedPointerContext(internal::Matcher<Stmt> InnerMatcher) {
   //    (i.e., computing the distance between two pointers); or ...
 
   auto CallArgMatcher =
-      callExpr(forEachArgumentWithParam(InnerMatcher,
-                  hasPointerType() /* array also decays to pointer type*/),
+      callExpr(forEachArgumentWithParamType(InnerMatcher,
+                  isAnyPointer() /* array also decays to pointer type*/),
----------------
jkorous-apple wrote:

Yes, type sugar is fine, we have about 20 tests cases for just `typedef`.

>From the architectural standpoint this is a definition of DRE context, it shouldn't have used `hasCanonicalType` in the first place and the comment `/* array also decays to pointer type*/` suggests it wasn't the intention.

Handling or not handling typedefs is the responsibility of `fixVariable` function and perhaps individual FixableGadgets1 `getFixits()` method.

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


More information about the cfe-commits mailing list