diff options
author | Anna Zaks <ganna@apple.com> | 2012-01-13 21:52:01 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-01-13 21:52:01 +0000 |
commit | d9b859a74ecaede23a78d37f364498102ef418c9 (patch) | |
tree | 4f63875d9e85449142ebc39904f06dd567ae2e15 /include | |
parent | 31cbe684302a5ccb001fa2131c0e4aeaa372f5c0 (diff) |
Move identification of memory setting and copying functions (memset,
memcmp, strncmp,..) out of Sema and into FunctionDecl so that the logic
could be reused in the analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148142 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/clang/AST/Decl.h | 21 | ||||
-rw-r--r-- | include/clang/Sema/Sema.h | 17 |
2 files changed, 23 insertions, 15 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h index 3b04c25ce5..7e9e9bfb3a 100644 --- a/include/clang/AST/Decl.h +++ b/include/clang/AST/Decl.h @@ -1968,6 +1968,27 @@ public: /// definition of a member function. virtual bool isOutOfLine() const; + /// \brief Enumeration used to identify memory setting or copying functions + /// identified by getMemoryFunctionKind(). + enum MemoryFunctionKind { + MFK_Memset, + MFK_Memcpy, + MFK_Memmove, + MFK_Memcmp, + MFK_Strncpy, + MFK_Strncmp, + MFK_Strncasecmp, + MFK_Strncat, + MFK_Strndup, + MFK_Strlcpy, + MFK_Strlcat, + MFK_Invalid + }; + + /// \brief If the given function is a memory copy or setting function, return + /// it's kind. If the function is not a memory function, returns MFK_Invalid. + MemoryFunctionKind getMemoryFunctionKind(); + // Implement isa/cast/dyncast/etc. static bool classof(const Decl *D) { return classofKind(D->getKind()); } static bool classof(const FunctionDecl *D) { return true; } diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index d570a77936..61d3022d52 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -6311,21 +6311,8 @@ private: unsigned format_idx, unsigned firstDataArg, bool isPrintf); - /// \brief Enumeration used to describe which of the memory setting or copying - /// functions is being checked by \c CheckMemaccessArguments(). - enum CheckedMemoryFunction { - CMF_Memset, - CMF_Memcpy, - CMF_Memmove, - CMF_Memcmp, - CMF_Strncpy, - CMF_Strncmp, - CMF_Strncasecmp, - CMF_Strncat, - CMF_Strndup - }; - - void CheckMemaccessArguments(const CallExpr *Call, CheckedMemoryFunction CMF, + void CheckMemaccessArguments(const CallExpr *Call, + FunctionDecl::MemoryFunctionKind CMF, IdentifierInfo *FnName); void CheckStrlcpycatArguments(const CallExpr *Call, |