Polly 20.0.0git
isl_ast_node_set_field_templ.c
Go to the documentation of this file.
1/*
2 * Copyright 2012 Ecole Normale Superieure
3 *
4 * Use of this software is governed by the MIT license
5 *
6 * Written by Sven Verdoolaege,
7 * Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
8 */
9
10#define xFN(TYPE,NAME) TYPE ## _ ## NAME
11#define FN(TYPE,NAME) xFN(TYPE,NAME)
12
13/* Replace the field FIELD of "node" by "field",
14 * where the field may or may not have already been set in "node".
15 * However, if the field has not already been set,
16 * then "node" is required to have a single reference.
17 * In this case the call to isl_ast_node_cow has no effect.
18 */
21{
22 if (FN(isl_ast_node_check,NODE_TYPE)(node) < 0 || !field)
23 goto error;
24 if (node->FIELD == field) {
25 FN(FIELD_TYPE,free)(field);
26 return node;
27 }
28
29 node = isl_ast_node_cow(node);
30 if (!node)
31 goto error;
32
33 FN(FIELD_TYPE,free)(node->FIELD);
34 node->FIELD = field;
35
36 return node;
37error:
39 FN(FIELD_TYPE,free)(field);
40 return NULL;
41}
__isl_null isl_ast_node * isl_ast_node_free(__isl_take isl_ast_node *node)
Definition: isl_ast.c:1180
#define __isl_take
Definition: ctx.h:22
#define __isl_give
Definition: ctx.h:19
#define FIELD_NAME
Definition: isl_ast.c:1720
__isl_give isl_ast_node * isl_ast_node_cow(__isl_take isl_ast_node *node)
Definition: isl_ast.c:1169
#define FIELD_TYPE
Definition: isl_ast.c:1722
#define NODE_TYPE
Definition: isl_ast.c:1718
#define FN(TYPE, NAME)
const char * set
Definition: isl_test.c:1356