Whitelist std::swap in C++ analyses

Reviewed By: jeremydubreil

Differential Revision: D5269267

fbshipit-source-id: 00a4ba8
master
Jia Chen 8 years ago committed by Facebook Github Bot
parent 0806ac067b
commit 1edcbce35b

@ -236,6 +236,7 @@ let whitelisted_cpp_methods = [
"std::forward";
"std::min";
"std::max";
"std::swap";
"google::CheckNotNull";
]

@ -18,6 +18,7 @@ codetoanalyze/cpp/errors/memory_leaks/object_leak.cpp, object_leak, 0, MEMORY_LE
codetoanalyze/cpp/errors/memory_leaks/raii_malloc.cpp, memory_leak, 0, MEMORY_LEAK, [start of procedure memory_leak()]
codetoanalyze/cpp/errors/models/move.cpp, move::div0_moved_from, 3, DIVIDE_BY_ZERO, [start of procedure move::div0_moved_from(),start of procedure X,return from a call to move::X_X,start of procedure X,return from a call to move::X_X]
codetoanalyze/cpp/errors/models/move.cpp, move::div0_moved_to, 3, DIVIDE_BY_ZERO, [start of procedure move::div0_moved_to(),start of procedure X,return from a call to move::X_X,start of procedure X,return from a call to move::X_X]
codetoanalyze/cpp/errors/models/swap.cpp, swap_null_bad, 4, NULL_DEREFERENCE, [start of procedure swap_null_bad()]
codetoanalyze/cpp/errors/mutex/std_mutex.cpp, alarm1, 2, DOUBLE_LOCK, [start of procedure alarm1()]
codetoanalyze/cpp/errors/mutex/std_mutex.cpp, alarm2, 2, DOUBLE_LOCK, [start of procedure alarm2()]
codetoanalyze/cpp/errors/mutex/std_mutex.cpp, alarm2, 2, DOUBLE_LOCK, [start of procedure alarm2()]

@ -0,0 +1,23 @@
/*
* Copyright (c) 2017 - 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 <utility>
int swap_null_ok() {
int a = 0;
int *p = nullptr, *q = &a;
std::swap(p, q);
return *p;
}
int swap_null_bad() {
int a = 0;
int *p = nullptr, *q = &a;
std::swap(p, q);
return *q;
}
Loading…
Cancel
Save