2 * Copyright (C) 2015 Oracle.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
19 #include "smatch_slist.h"
20 #include "smatch_extra.h"
22 static bool is_non_null_array(struct expression
*expr
)
30 type
= get_type(expr
);
31 if (!type
|| type
->type
!= SYM_ARRAY
)
33 if (expr
->type
== EXPR_SYMBOL
)
35 if (implied_not_equal(expr
, 0))
38 /* verify that it's not the first member of the struct */
39 if (expr
->type
!= EXPR_DEREF
|| !expr
->member
)
41 name
= expr_to_var_sym(expr
, &sym
);
45 type
= get_real_base_type(sym
);
46 if (!type
|| type
->type
!= SYM_PTR
)
48 type
= get_real_base_type(type
);
49 if (type
->type
!= SYM_STRUCT
)
53 FOR_EACH_PTR(type
->symbol_list
, tmp
) {
57 if (strcmp(expr
->member
->name
, tmp
->ident
->name
) == 0) {
62 } END_FOR_EACH_PTR(tmp
);
67 int get_address_rl(struct expression
*expr
, struct range_list
**rl
)
69 if (is_non_null_array(expr
)) {
70 *rl
= alloc_rl(array_min_sval
, array_max_sval
);