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 */
19__isl_give isl_ast_node *FN(FN(FN(isl_ast_node,NODE_TYPE),set),FIELD_NAME)(
20 __isl_take isl_ast_node *node, __isl_take FIELD_TYPE *field)
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)(expr: 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)(expr: node->FIELD);
34 node->FIELD = field;
35
36 return node;
37error:
38 isl_ast_node_free(node);
39 FN(FIELD_TYPE,free)(expr: field);
40 return NULL;
41}
42

source code of polly/lib/External/isl/isl_ast_node_set_field_templ.c