зеркало из https://github.com/microsoft/clang-1.git
Only check the use of memset() if we're refering to a C function named
'memset' with external linkage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130770 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
2bc0e5d955
Коммит
e452c78072
|
@ -319,7 +319,9 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Memset handling
|
// Memset handling
|
||||||
if (FnInfo->isStr("memset"))
|
if (FnInfo->isStr("memset") &&
|
||||||
|
FDecl->getLinkage() == ExternalLinkage &&
|
||||||
|
(!getLangOptions().CPlusPlus || FDecl->isExternC()))
|
||||||
CheckMemsetArguments(TheCall);
|
CheckMemsetArguments(TheCall);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// RUN: %clang_cc1 -fsyntax-only -Wnon-pod-memset -verify %s
|
// RUN: %clang_cc1 -fsyntax-only -Wnon-pod-memset -verify %s
|
||||||
|
|
||||||
extern void *memset(void *, int, unsigned);
|
extern "C" void *memset(void *, int, unsigned);
|
||||||
|
|
||||||
// Several POD types that should not warn.
|
// Several POD types that should not warn.
|
||||||
struct S1 {} s1;
|
struct S1 {} s1;
|
||||||
|
@ -61,3 +61,10 @@ void test_nowarn(void *void_ptr) {
|
||||||
// Dead code shouldn't warn.
|
// Dead code shouldn't warn.
|
||||||
if (false) memset(&x1, 0, sizeof x1);
|
if (false) memset(&x1, 0, sizeof x1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace N {
|
||||||
|
void *memset(void *, int, unsigned);
|
||||||
|
void test_nowarn() {
|
||||||
|
N::memset(&x1, 0, sizeof x1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче