Extending type parser to deal with typedefs

Reviewed By: dulmarod

Differential Revision: D5155322

fbshipit-source-id: 9af8d8b
master
Dino Distefano 8 years ago committed by Facebook Github Bot
parent 4ef487928c
commit 0809279b3b

@ -172,6 +172,14 @@ let rec pointer_type_equal p ap =
| _, _ -> display_equality_warning ();
false
and typename_equal pointer typename =
match CAst_utils.get_decl pointer with
| Some decl ->
(match Clang_ast_proj.get_named_decl_tuple decl with
| Some (_, name_decl) -> ALVar.compare_str_with_alexp name_decl.ni_name typename
| None -> false)
| _ -> false
(* Temporary, partial equality function. Cover only what's covered
by the types_parser. It needs to be replaced by a real
@ -190,12 +198,9 @@ and c_type_equal c_type abs_ctype =
| ObjCObjectPointerType _, Pointer _ ->
pointer_type_equal c_type abs_ctype
| ObjCInterfaceType (_, pointer), TypeName ae ->
(match CAst_utils.get_decl pointer with
| Some decl ->
(match Clang_ast_proj.get_named_decl_tuple decl with
| Some (_, name_decl) -> ALVar.compare_str_with_alexp name_decl.ni_name ae
| None -> false)
| _ -> false)
typename_equal pointer ae
| TypedefType (_, tdi), TypeName ae ->
typename_equal tdi.tti_decl_ptr ae
| _, _ -> display_equality_warning ();
false

@ -37,6 +37,9 @@ codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 53
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 53, IMPORTED_MACRO_SUBCLASS, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 53, LOCAL_MACRO_SUBCLASS, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 53, SUBCLASSING_TEST_EXAMPLE, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 111, TEST_TYPEDEF_CHECK, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 119, TEST_TYPEDEF_CHECK, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, Linters_dummy_method, 123, TEST_TYPEDEF_CHECK, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, TestType_m1, 73, TEST_BUILTIN_TYPE, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, TestType_m10, 82, TEST_BUILTIN_TYPE, []
codetoanalyze/objc/linters-for-test-only/subclassing.m, TestType_m11, 83, TEST_BUILTIN_TYPE, []

@ -176,6 +176,18 @@ DEFINE-CHECKER TEST_VAR_TYPE_CHECK = {
SET message = "Var has type int or long";
};
DEFINE-CHECKER TEST_TYPEDEF_CHECK = {
SET report_when =
WHEN
has_type("my_ulong") OR
has_type("my_pS") OR
has_type("my_listNode")
HOLDS-IN-NODE VarDecl;
SET message = "Var has type....";
};
DEFINE-CHECKER TEST_PARAM_TYPE_CHECK = {
SET report_when =

@ -105,3 +105,19 @@
pname3:(ThisIsAVeryLongName*)p3
pname4:(A*)p4;
@end
typedef unsigned long my_ulong;
my_ulong l;
typedef struct {
int a;
int b;
int c;
} S, *my_pS;
my_pS p;
typedef struct Node { struct my_listNode* next; } my_listNode;
my_listNode ln;

Loading…
Cancel
Save