Skip to content

Conversation

@ziqingluo-90
Copy link

No description provided.

ziqingluo-90 and others added 3 commits December 22, 2025 13:52
…ctions (llvm#145862)

The character buffer passed to a "%.*s" specifier may be safely bound if
the precision is properly specified, even if the buffer does not
guarantee null-termination.
For example,
```
void f(std::span<char> span) {
  printf("%.*s", (int)span.size(), span.data());  // "span.data()" does not guarantee null-termination but is safely bound by "span.size()", so this call is safe
}
```
rdar://154072130

(cherry picked from commit e10b182)

Conflicts:
	clang/lib/Analysis/UnsafeBufferUsage.cpp
	clang/test/SemaCXX/warn-unsafe-buffer-usage-libc-functions.cpp
…ction names (llvm#151270)

This commit fixes the false positive that C++ class methods with libc
function names would be false warned about. For example,

```
struct T {void strcpy() const;};
void test(const T& t) {  str.strcpy(); // no warn }
```

rdar://156264388
(cherry picked from commit 0abf497)

 Conflicts:
	clang/lib/Analysis/UnsafeBufferUsage.cpp
…vm#170496)

`clang::analyze_format_string::ParsePrintfString` also returns `true`
when we get an invalid or erroneous format string, so `UnsafeArg` will
not be set, but `hasUnsafeFormatOrSArg`'s caller assumes `UnsafeArg`
will be valid when it returns true, which leads to crash.

Closes llvm#169629

(cherry picked from commit b5dd6cc)

 Conflicts:
	clang/docs/ReleaseNotes.rst
	clang/lib/Analysis/UnsafeBufferUsage.cpp
@ziqingluo-90 ziqingluo-90 requested a review from a team as a code owner December 23, 2025 00:55
@ziqingluo-90
Copy link
Author

@swift-ci test

@ziqingluo-90
Copy link
Author

@swift-ci test llvm

@ziqingluo-90
Copy link
Author

@swift-ci test windows

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