Skip to content

[🍒][-Wunsafe-buffer-usage] Warning unsafe libc calls #9287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ziqingluo-90
Copy link

cherry-picked from swiftlang/llvm-project/next

@ziqingluo-90
Copy link
Author

@swift-ci test

@ziqingluo-90
Copy link
Author

I somehow can't find @jkorous-apple in the reviewer list.

@haoNoQ
Copy link

haoNoQ commented Sep 19, 2024

I somehow can't find @jkorous-apple in the reviewer list.

Doesn't work for me either hmm.

@jkorous-apple
Copy link

Weird, I am here 🤷
So, do IIUC we want to hold-off merging this until we land the changes VendorOverrides internally?

@ziqingluo-90
Copy link
Author

Weird, I am here 🤷 So, do IIUC we want to hold-off merging this until we land the changes VendorOverrides internally?

yeah, that works the best.

@ziqingluo-90
Copy link
Author

Rebased, and @swift-ci test

@ziqingluo-90
Copy link
Author

Rebased, and @swift-ci test

ziqingluo-90 and others added 7 commits October 14, 2024 16:40
[-Wunsafe-buffer-usage] Add warn on unsafe calls to libc functions

Warning about calls to libc functions involving buffer access.  Warned
functions are hardcoded by names.

(rdar://117182250)

(cherry picked from commit 0fffdeb)
This reverts commit 0fffdeb.

Will re-land this commit soon with a way to opt-out

(cherry picked from commit 2345796)
Revert commit 2345796, and re-land
with a new flag "-Wunsafe-buffer-usage-in-libc-call" for the new
warning.

(rdar://117182250)

(cherry picked from commit d7dd2c4)
…1583)"

The commit d7dd2c4 crashes for such
an example:
```
void printf() { printf(); }
```
Because it assumes `printf` must have arguments. This commit fixes
this issue.

(rdar://117182250)

(cherry picked from commit de88d7d)
…n libc warnings (llvm#108308)

For `snprintf(a, sizeof a, ...)`, the first two arguments form a safe
pattern if `a` is a constant array. In such a case, this commit will
suppress the warning.

(rdar://117182250)

(cherry picked from commit ebf25d9)
… Warning Libc functions (llvm#101583)"

StringLiteral::getString() is not applicable to strings of wide
characters.  Added handling for that.

(rdar://117182250)

(cherry picked from commit 48498ec)
…les (llvm#109496)

- Fix a bug in UnsafeBufferUsage.cpp related to casting to PointerType
- Suppress -Wunsafe-buffer-usage-in-libc-call for C files

(rdar://117182250)

(cherry picked from commit 090dc77)
@ziqingluo-90 ziqingluo-90 force-pushed the ziqing/stable/20240723 branch from 99d1407 to 7d22451 Compare October 14, 2024 23:41
@ziqingluo-90
Copy link
Author

Rebased, and @swift-ci test

@jkorous-apple
Copy link

LGTM

@ziqingluo-90 ziqingluo-90 merged commit 0878de2 into swiftlang:stable/20240723 Oct 15, 2024
1 of 3 checks passed
@ziqingluo-90 ziqingluo-90 deleted the ziqing/stable/20240723 branch December 19, 2024 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants