Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/Analysis/UnsafeBufferUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ class UnsafeLibcFunctionCallGadget : public WarningGadget {
if (!CE || !CE->getDirectCallee())
return false;
const auto *FD = dyn_cast<FunctionDecl>(CE->getDirectCallee());
if (!FD)
if (!FD || isa<CXXMethodDecl>(FD))
return false;
auto isSingleStringLiteralArg = false;
if (CE->getNumArgs() == 1) {
Expand Down
18 changes: 18 additions & 0 deletions clang/test/SemaCXX/warn-unsafe-buffer-usage-libc-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,21 @@ void ff(char * p, char * q, std::span<char> s, std::span<char> s2) {
wcscpy_s();
#pragma clang diagnostic pop
}


namespace CXXMethodNoWarn {
struct StrBuff
{
void strcpy() const;
void strcpy(char* dst) const;
void Strcpy(char* dst) const;
};

void test(const StrBuff& str)
{
char buff[64];
str.strcpy();
str.strcpy(buff);
str.Strcpy(buff);
}
} // namespace CXXMethodNoWarn
Loading