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