[PATCH] D143128: [-Wunsafe-buffer-usage][WIP] Fix-Its transforming `&DRE[any]` to `DRE.data() + any`
Ziqing Luo via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 6 15:17:21 PST 2023
ziqingluo-90 added inline comments.
================
Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:162
+ InnerMatcher)),
+ unless(callee(functionDecl(hasAttr(attr::UnsafeBufferUsage)))));
+ auto CastOperandMatcher =
----------------
jkorous wrote:
> I am just wondering how does the callee matcher work in situation with multiple re-declarations 🤔
>
> Something like this:
> ```
> void foo(int* ptr);
> [[clang::unsafe_buffer_usage]] void foo(int* ptr);
> void foo(int* ptr);
>
> void bar(int* ptr) {
> foo(ptr);
> }
> ```
I think we are fine. According to the doc of `FunctionDecl`:
```
/// Represents a function declaration or definition.
///
/// Since a given function can be declared several times in a program,
/// there may be several FunctionDecls that correspond to that
/// function. Only one of those FunctionDecls will be found when
/// traversing the list of declarations in the context of the
/// FunctionDecl (e.g., the translation unit); this FunctionDecl
/// contains all of the information known about the function. Other,
/// previous declarations of the function are available via the
/// getPreviousDecl() chain.
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143128/new/
https://reviews.llvm.org/D143128
More information about the cfe-commits
mailing list