diff --git a/infer/src/clang/ctl_parser_types.ml b/infer/src/clang/ctl_parser_types.ml index edc26a31f..653cd695d 100644 --- a/infer/src/clang/ctl_parser_types.ml +++ b/infer/src/clang/ctl_parser_types.ml @@ -498,7 +498,27 @@ and c_type_equal c_type abs_ctype = typename_equal pointer ae | TypedefType (_, tdi), TypeName ae -> typename_equal tdi.tti_decl_ptr ae + | NoneType ti, TypeName _ + | ComplexType ti, TypeName _ + | DependentSizedExtVectorType ti, TypeName _ + | VectorType ti, TypeName _ + | ExtVectorType ti, TypeName _ + | UnresolvedUsingType ti, TypeName _ + | TypeOfExprType ti, TypeName _ + | TypeOfType ti, TypeName _ + | UnaryTransformType ti, TypeName _ + | TemplateTypeParmType ti, TypeName _ + | SubstTemplateTypeParmType ti, TypeName _ + | SubstTemplateTypeParmPackType ti, TypeName _ + | DeducedTemplateSpecializationType ti, TypeName _ + | InjectedClassNameType ti, TypeName _ + | DependentNameType ti, TypeName _ + | DependentTemplateSpecializationType ti, TypeName _ + | ObjCTypeParamType ti, TypeName _ + | PackExpansionType ti, TypeName _ + | PipeType ti, TypeName _ | ElaboratedType ti, TypeName _ + | AutoType ti, TypeName _ | TypedefType (ti, _), ObjCGenProt _ | AttributedType (ti, _), Pointer _ -> ( match ti.ti_desugared_type with Some dt -> check_type_ptr dt abs_ctype | None -> false ) diff --git a/infer/tests/codetoanalyze/cpp/linters/extracopy.al b/infer/tests/codetoanalyze/cpp/linters/extracopy.al index 91df0036c..43724b4c1 100644 --- a/infer/tests/codetoanalyze/cpp/linters/extracopy.al +++ b/infer/tests/codetoanalyze/cpp/linters/extracopy.al @@ -35,3 +35,14 @@ DEFINE-CHECKER NAMESPACE_STRING = { 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"; + +}; diff --git a/infer/tests/codetoanalyze/cpp/linters/issues.exp b/infer/tests/codetoanalyze/cpp/linters/issues.exp index 4d48b4834..8317e439d 100644 --- a/infer/tests/codetoanalyze/cpp/linters/issues.exp +++ b/infer/tests/codetoanalyze/cpp/linters/issues.exp @@ -1,3 +1,6 @@ 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, [] +codetoanalyze/cpp/linters/iter.cpp, test, 11, ITERATOR, no_bucket, WARNING, [] +codetoanalyze/cpp/linters/iter.cpp, test, 12, EXTRA_COPY, no_bucket, WARNING, [] +codetoanalyze/cpp/linters/iter.cpp, test, 12, ITERATOR, no_bucket, WARNING, [] +codetoanalyze/cpp/linters/type_namespace.cpp, test, 11, NAMESPACE_STRING, no_bucket, WARNING, [] diff --git a/infer/tests/codetoanalyze/cpp/linters/iter.cpp b/infer/tests/codetoanalyze/cpp/linters/iter.cpp new file mode 100644 index 000000000..eb82db083 --- /dev/null +++ b/infer/tests/codetoanalyze/cpp/linters/iter.cpp @@ -0,0 +1,13 @@ +/* + * 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 + +void test() { + std::map m; + auto itr1 = m.begin(); + auto itr2 = itr1; +}