[all-commits] [llvm/llvm-project] 4cd761: [-Wunsafe-buffer-usage] Fixits for array args of f...
jkorous-apple via All-commits
all-commits at lists.llvm.org
Wed Feb 14 17:19:51 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4cd7616f6b13513bb13f2b6dd14d140a4c62c937
https://github.com/llvm/llvm-project/commit/4cd7616f6b13513bb13f2b6dd14d140a4c62c937
Author: jkorous-apple <32549412+jkorous-apple at users.noreply.github.com>
Date: 2024-02-14 (Wed, 14 Feb 2024)
Changed paths:
M clang/lib/Analysis/UnsafeBufferUsage.cpp
A clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-pointer-arg-to-func-ptr-call.cpp
Log Message:
-----------
[-Wunsafe-buffer-usage] Fixits for array args of func-ptr calls (#80358)
Currently we ignore calls on function pointers (unlike direct calls of
functions and class methods). This patch adds support for function pointers as
well.
The change is to simply replace use of forEachArgumentWithParam matcher in UPC
gadget with forEachArgumentWithParamType.
from the documentation of forEachArgumentWithParamType:
/// Matches all arguments and their respective types for a \c CallExpr or
/// \c CXXConstructExpr. It is very similar to \c forEachArgumentWithParam but
/// it works on calls through function pointers as well.
Currently the matcher also uses hasPointerType() which checks that the
canonical type of an argument is pointer and won't match on arrays decayed to
pointer. Replacing hasPointerType() with isAnyPointerType() which allows
implicit casts allows for the arrays to be matched as well and this way we get
fixits for array arguments to function pointer calls too.
More information about the All-commits
mailing list