Fix has_type when used in the context of namespace

Reviewed By: jvillard

Differential Revision: D9117843

fbshipit-source-id: 3deb4c517
master
Dino Distefano 7 years ago committed by Facebook Github Bot
parent 3870ebb747
commit 1efc44c27f

@ -498,8 +498,8 @@ and c_type_equal c_type abs_ctype =
typename_equal pointer ae
| TypedefType (_, tdi), TypeName ae ->
typename_equal tdi.tti_decl_ptr ae
| TypedefType (ti, _), ObjCGenProt _ -> (
match ti.ti_desugared_type with Some dt -> check_type_ptr dt abs_ctype | None -> false )
| ElaboratedType ti, TypeName _
| TypedefType (ti, _), ObjCGenProt _
| AttributedType (ti, _), Pointer _ -> (
match ti.ti_desugared_type with Some dt -> check_type_ptr dt abs_ctype | None -> false )
| _, _ ->

@ -24,3 +24,14 @@ DEFINE-CHECKER EXTRA_COPY = {
//};
};
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";
};

@ -1,2 +1,3 @@
codetoanalyze/cpp/linters/extracopy.cpp, test_a, 33, EXTRA_COPY, no_bucket, WARNING, []
codetoanalyze/cpp/linters/extracopy.cpp, test_map, 43, EXTRA_COPY, no_bucket, WARNING, []
codetoanalyze/cpp/linters/extracopy.cpp, test_a, 27, EXTRA_COPY, no_bucket, WARNING, []
codetoanalyze/cpp/linters/extracopy.cpp, test_map, 37, EXTRA_COPY, no_bucket, WARNING, []
codetoanalyze/cpp/linters/type_namespace.cpp, test, 6, NAMESPACE_STRING, no_bucket, WARNING, []

@ -0,0 +1,11 @@
/*
* 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.
*/
#include <string>
using namespace std;
void test() { std::string s1 = "a"; }
Loading…
Cancel
Save