-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsmatch_unknown_value.c
73 lines (63 loc) · 1.98 KB
/
smatch_unknown_value.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (C) 2014 Oracle.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
*/
/*
* The situation here is that we often need to fake an assignment but we don't
* know anything about the right hand side of the assignment. We use a fake
* function call of &llong_ctype. The reason for using a function call instead
* of a value is so we don't start storing the equivalence.
*
*/
#include "smatch.h"
struct ident fake_assign = {
.len = sizeof("fake assign"),
.name = "fake assign",
};
static struct symbol fake_fn_symbol = {
.type = SYM_FN,
.ident = &fake_assign,
};
static struct symbol fake_node_symbol = {
.type = SYM_NODE,
.ident = &fake_assign,
};
static struct expression fake_fn_expr = {
.type = EXPR_SYMBOL,
.ctype = &llong_ctype,
};
static struct expression fake_call = {
.type = EXPR_CALL,
.ctype = &llong_ctype,
};
static void __attribute__((constructor)) initialize_local_variables(void)
{
fake_fn_symbol.ctype.base_type = &llong_ctype;
fake_node_symbol.ctype.base_type = &fake_fn_symbol;
fake_fn_expr.symbol = &fake_node_symbol;
fake_fn_expr.symbol_name = &fake_assign;
fake_call.fn = &fake_fn_expr;
}
struct expression *unknown_value_expression(struct expression *expr)
{
/* FIXME: This should take the type into consideration */
fake_fn_expr.parent = 0;
fake_call.parent = 0;
return &fake_call;
}
int is_fake_call(struct expression *expr)
{
return expr == &fake_call;
}