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 | 314cd09b5c79fcf2173e5650f4a470af673844f8 (patch) | |
tree | 39636809fc2fdab1a4050bfb476f464f2c0a2984 /clang/lib/AST/Decl.cpp | |
parent | fdad6794ac8008bea0413fb5c7468f80ca392ca3 (diff) | |
download | bcm5719-llvm-314cd09b5c79fcf2173e5650f4a470af673844f8.tar.gz bcm5719-llvm-314cd09b5c79fcf2173e5650f4a470af673844f8.zip |
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.
llvm-svn: 149524
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 49227e91958..aa7bb0812a3 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/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; } |