You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.4 KiB

// Copyright (c) 2018-present, Facebook, Inc.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
DEFINE-CHECKER EXTRA_COPY = {
LET name_not_contains_copy = NOT declaration_has_name(REGEXP("[cC]opy"));
LET is_local_var = NOT is_global_var AND NOT is_static_local_var;
LET is_copy_contructor =
HOLDS-NEXT WITH-TRANSITION InitExpr
(is_node("CXXConstructExpr") AND is_cxx_copy_constructor);
SET report_when =
WHEN name_not_contains_copy AND is_local_var AND is_copy_contructor
HOLDS-IN-NODE VarDecl;
SET message = "Potentially unnecessary to copy var %name%";
SET severity = "WARNING";
SET mode = "ON";
//SET whitelist_path = {
// REGEXP("admarket/.*"),
// REGEXP("multifeed/.*")
//};
};
DEFINE-CHECKER NAMESPACE_STRING = {
SET report_when =
WHEN has_type("REGEXP('string')")
HOLDS-IN-NODE VarDecl;
SET message = "Found type strings with namespace";
SET mode = "ON";
};
DEFINE-CHECKER ITERATOR = {
SET report_when =
WHEN has_type("REGEXP('iterator')")
HOLDS-IN-NODE VarDecl;
SET message = "Found type iterator";
SET mode = "ON";
};
DEFINE-CHECKER CXX11_CONSTANT_EXPR = {
SET report_when =
WHEN
is_init_expr_cxx11_constant()
HOLDS-IN-NODE VarDecl;
SET message = "Found cxx11 constant expression";
SET mode = "ON";
};