From a0a4008e17d72bba5f4e30ac83beca45670447af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 7 Aug 2009 16:23:28 +0200 Subject: [PATCH] Fixed #525 (false positive: vector range checking with <) --- src/checkstl.cpp | 5 +++-- test/teststl.cpp | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/checkstl.cpp b/src/checkstl.cpp index 52d25f841..21f85567d 100644 --- a/src/checkstl.cpp +++ b/src/checkstl.cpp @@ -20,8 +20,6 @@ #include "tokenize.h" #include "token.h" -// All STL Containers -#define STL_CONTAINER_LIST "bitset|deque|list|map|multimap|multiset|priority_queue|queue|set|stack|vector|hash_map|hash_multimap|hash_set" // Register this check class (by creating a static instance of it) @@ -378,6 +376,9 @@ void CheckStl::invalidPointerError(const Token *tok, const std::string &pointer_ void CheckStl::stlBoundries() { + // containers (not the vector).. + static const char STL_CONTAINER_LIST[] = "bitset|deque|list|map|multimap|multiset|priority_queue|queue|set|stack|hash_map|hash_multimap|hash_set"; + for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) { // Declaring iterator.. diff --git a/test/teststl.cpp b/test/teststl.cpp index 66e212f6b..ecc425b20 100644 --- a/test/teststl.cpp +++ b/test/teststl.cpp @@ -389,9 +389,9 @@ private: void stlBoundries1() { - const int STL_CONTAINER_LIST = 10; + const int STL_CONTAINER_LIST = 9; const std::string stlCont[STL_CONTAINER_LIST] = - {"vector", "deque", "list", "set", "multiset", "map", + {"deque", "list", "set", "multiset", "map", "multimap", "hash_map", "hash_multimap", "hash_set" }; @@ -422,7 +422,7 @@ private: check(checkStr.c_str()); - ASSERT_EQUALS("[test.cpp:5]: (error) vector range check should use != and not < since the order of the pointers isn't guaranteed\n[test.cpp:6]: (error) vector range check should use != and not < since the order of the pointers isn't guaranteed\n", errout.str()); + ASSERT_EQUALS("", errout.str()); } };