[C++] whitelist C++ std::vector iterator implementation

Summary: Access to std::vector shouldn't be treated as SKIP. Implementation is simple enough to use one from std:: headers

Reviewed By: jvillard

Differential Revision: D4339577

fbshipit-source-id: d1fbbee
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot
parent acdc081100
commit 96ba74d18e

@ -208,6 +208,8 @@ let whitelisted_cpp_methods = [
let whitelisted_cpp_classes = [
["std"; "__less"];
["std"; "__wrap_iter"]; (* libc++ internal name of vector iterator *)
["std"; "__normal_iterator"]; (* libstdc++ internal name of vector iterator *)
]

@ -128,6 +128,7 @@ codetoanalyze/cpp/errors/vector/empty_access.cpp, size_check0_empty, 2, EMPTY_VE
codetoanalyze/cpp/errors/vector/empty_access.cpp, vector_as_param_by_value_empty, 2, EMPTY_VECTOR_ACCESS, [start of procedure vector_as_param_by_value_empty(),start of procedure vector_param_by_value_access()]
codetoanalyze/cpp/errors/vector/empty_access.cpp, vector_as_param_clear, 3, EMPTY_VECTOR_ACCESS, [start of procedure vector_as_param_clear(),start of procedure vector_param_clear(),return from a call to vector_param_clear]
codetoanalyze/cpp/errors/vector/empty_access.cpp, vector_as_param_empty, 2, EMPTY_VECTOR_ACCESS, [start of procedure vector_as_param_empty(),start of procedure vector_param_access()]
codetoanalyze/cpp/errors/vector/iterator_access.cpp, iterator_access::possible_npe, 4, NULL_DEREFERENCE, [start of procedure iterator_access::possible_npe(),Condition is true,Condition is true,Condition is true]
codetoanalyze/cpp/shared/attributes/deprecated_hack.cpp, derefFirstArg2_null_deref, 2, NULL_DEREFERENCE, [start of procedure derefFirstArg2_null_deref()]
codetoanalyze/cpp/shared/attributes/deprecated_hack.cpp, derefFirstArg3_null_deref, 2, NULL_DEREFERENCE, [start of procedure derefFirstArg3_null_deref(),start of procedure derefFirstArg3()]
codetoanalyze/cpp/shared/attributes/deprecated_hack.cpp, derefFirstArg_null_deref, 2, NULL_DEREFERENCE, [start of procedure derefFirstArg_null_deref()]

@ -0,0 +1,36 @@
/*
* Copyright (c) 2016 - present Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <vector>
namespace iterator_access {
struct X {
int id;
};
int possible_npe(std::vector<X> in) {
int* x = nullptr;
for (auto iter = in.begin(); iter != in.end(); ++iter) {
if (iter->id >= 0 && iter->id <= 0) {
return *x;
}
}
return 1;
}
int impossible_npe(std::vector<X> in) {
int* x = nullptr;
for (auto iter = in.begin(); iter != in.end(); ++iter) {
if (iter->id > 0 && iter->id <= 0) {
return *x;
}
}
return 1;
}
}
Loading…
Cancel
Save