diff options
author | Anna Zaks <ganna@apple.com> | 2012-02-01 19:08:57 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-02-01 19:08:57 +0000 |
commit | c36bedc90c687caa71748480c60707ea4608b092 (patch) | |
tree | a21d9b6834bf018c6254d1760f20707d7125394a /lib/AST/Decl.cpp | |
parent | b710dfe5231b0cd44dd987b9bd33c7f6ac165807 (diff) |
Add a new compiler warning, which flags anti-patterns used as the size
argument in strncat.
The warning is ignored by default since it needs more qualification.
TODO: The warning message and the note are messy when
strncat is a builtin due to the macro expansion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149524 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 49227e9195..aa7bb0812a 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -2333,6 +2333,7 @@ unsigned FunctionDecl::getMemoryFunctionKind() const { return Builtin::BIstrncasecmp; case Builtin::BI__builtin_strncat: + case Builtin::BI__builtin___strncat_chk: case Builtin::BIstrncat: return Builtin::BIstrncat; @@ -2340,6 +2341,10 @@ unsigned FunctionDecl::getMemoryFunctionKind() const { case Builtin::BIstrndup: return Builtin::BIstrndup; + case Builtin::BI__builtin_strlen: + case Builtin::BIstrlen: + return Builtin::BIstrlen; + default: if (isExternC()) { if (FnInfo->isStr("memset")) @@ -2360,6 +2365,8 @@ unsigned FunctionDecl::getMemoryFunctionKind() const { return Builtin::BIstrncat; else if (FnInfo->isStr("strndup")) return Builtin::BIstrndup; + else if (FnInfo->isStr("strlen")) + return Builtin::BIstrlen; } break; } |