Add missing permission notice in each source file
[babeltrace.git] / formats / ctf / metadata / ctf-visitor-semantic-validator.c
index fae2b711ec4069513a59fde8004184fa70728d17..13b2fc55adeb9a9b8b2207fb83ea06328aaa108f 100644 (file)
  *
  * The above copyright notice and this permission notice shall be included in
  * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
  */
 
 #include <stdio.h>
 #include <glib.h>
 #include <inttypes.h>
 #include <errno.h>
+#include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/list.h>
 #include "ctf-scanner.h"
 #include "ctf-parser.h"
 #include "ctf-ast.h"
 
-#define _cds_list_first_entry(ptr, type, member)       \
-       cds_list_entry((ptr)->next, type, member)
+#define _bt_list_first_entry(ptr, type, member)        \
+       bt_list_entry((ptr)->next, type, member)
 
 #define fprintf_dbg(fd, fmt, args...)  fprintf(fd, "%s: " fmt, __func__, ## args)
 
@@ -46,7 +55,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
        switch (node->parent->type) {
        case NODE_CTF_EXPRESSION:
                is_ctf_exp = 1;
-               cds_list_for_each_entry(iter, &node->parent->u.ctf_expression.left,
+               bt_list_for_each_entry(iter, &node->parent->u.ctf_expression.left,
                                        siblings) {
                        if (iter == node) {
                                is_ctf_exp_left = 1;
@@ -65,20 +74,32 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
                /* Right child of a ctf expression can be any type of unary exp. */
                break;                  /* OK */
        case NODE_TYPE_DECLARATOR:
-       case NODE_ENUM:
                /*
-                * We are the length of a type declarator or the size of an enum
-                * container. We can only be a numeric constant.
+                * We are the length of a type declarator.
                 */
                switch (node->u.unary_expression.type) {
-               case UNARY_SIGNED_CONSTANT:
                case UNARY_UNSIGNED_CONSTANT:
+               case UNARY_STRING:
                        break;
                default:
-                       fprintf(fd, "[error]: semantic error (children of type declarator and enum can only be numeric constants)\n");
+                       fprintf(fd, "[error]: semantic error (children of type declarator and enum can only be unsigned numeric constants or references to fields (a.b.c))\n");
                        goto errperm;
                }
                break;                  /* OK */
+
+       case NODE_STRUCT:
+               /*
+                * We are the size of a struct align attribute.
+                */
+               switch (node->u.unary_expression.type) {
+               case UNARY_UNSIGNED_CONSTANT:
+                       break;
+               default:
+                       fprintf(fd, "[error]: semantic error (structure alignment attribute can only be unsigned numeric constants)\n");
+                       goto errperm;
+               }
+               break;
+
        case NODE_ENUMERATOR:
                /* The enumerator's parent has validated its validity already. */
                break;                  /* OK */
@@ -94,7 +115,10 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
        case NODE_ROOT:
        case NODE_EVENT:
        case NODE_STREAM:
+       case NODE_ENV:
        case NODE_TRACE:
+       case NODE_CLOCK:
+       case NODE_CALLSITE:
        case NODE_TYPEDEF:
        case NODE_TYPEALIAS_TARGET:
        case NODE_TYPEALIAS_ALIAS:
@@ -104,9 +128,9 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
        case NODE_FLOATING_POINT:
        case NODE_INTEGER:
        case NODE_STRING:
+       case NODE_ENUM:
        case NODE_STRUCT_OR_VARIANT_DECLARATION:
        case NODE_VARIANT:
-       case NODE_STRUCT:
        default:
                goto errinval;
        }
@@ -114,7 +138,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
        switch (node->u.unary_expression.link) {
        case UNARY_LINK_UNKNOWN:
                /* We don't allow empty link except on the first node of the list */
-               if (is_ctf_exp && _cds_list_first_entry(is_ctf_exp_left ?
+               if (is_ctf_exp && _bt_list_first_entry(is_ctf_exp_left ?
                                          &node->parent->u.ctf_expression.left :
                                          &node->parent->u.ctf_expression.right,
                                          struct ctf_node,
@@ -139,7 +163,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
                        goto errperm;
                }
                /* We don't allow link on the first node of the list */
-               if (is_ctf_exp && _cds_list_first_entry(is_ctf_exp_left ?
+               if (is_ctf_exp && _bt_list_first_entry(is_ctf_exp_left ?
                                          &node->parent->u.ctf_expression.left :
                                          &node->parent->u.ctf_expression.right,
                                          struct ctf_node,
@@ -155,7 +179,7 @@ int ctf_visitor_unary_expression(FILE *fd, int depth, struct ctf_node *node)
                        goto errperm;
                }
                /* We don't allow link on the first node of the list */
-               if (_cds_list_first_entry(&node->parent->u.enumerator.values,
+               if (_bt_list_first_entry(&node->parent->u.enumerator.values,
                                          struct ctf_node,
                                          siblings) == node) {
                        fprintf(fd, "[error]: semantic error (link \"...\" is not allowed on the first node of the unary expression list)\n");
@@ -181,7 +205,7 @@ errperm:
 }
 
 static
-int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node)
+int ctf_visitor_type_specifier_list(FILE *fd, int depth, struct ctf_node *node)
 {
        switch (node->parent->type) {
        case NODE_CTF_EXPRESSION:
@@ -191,12 +215,57 @@ int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node)
        case NODE_TYPEALIAS_ALIAS:
        case NODE_ENUM:
        case NODE_STRUCT_OR_VARIANT_DECLARATION:
+       case NODE_ROOT:
+               break;                  /* OK */
+
+       case NODE_EVENT:
+       case NODE_STREAM:
+       case NODE_ENV:
+       case NODE_TRACE:
+       case NODE_CLOCK:
+       case NODE_CALLSITE:
+       case NODE_UNARY_EXPRESSION:
+       case NODE_TYPEALIAS:
+       case NODE_TYPE_SPECIFIER:
+       case NODE_TYPE_SPECIFIER_LIST:
+       case NODE_POINTER:
+       case NODE_FLOATING_POINT:
+       case NODE_INTEGER:
+       case NODE_STRING:
+       case NODE_ENUMERATOR:
+       case NODE_VARIANT:
+       case NODE_STRUCT:
+       default:
+               goto errinval;
+       }
+       return 0;
+errinval:
+       fprintf(fd, "[error] %s: incoherent parent type %s for node type %s\n", __func__,
+               node_type(node->parent), node_type(node));
+       return -EINVAL;         /* Incoherent structure */
+}
+
+static
+int ctf_visitor_type_specifier(FILE *fd, int depth, struct ctf_node *node)
+{
+       switch (node->parent->type) {
+       case NODE_TYPE_SPECIFIER_LIST:
                break;                  /* OK */
 
+       case NODE_CTF_EXPRESSION:
+       case NODE_TYPE_DECLARATOR:
+       case NODE_TYPEDEF:
+       case NODE_TYPEALIAS_TARGET:
+       case NODE_TYPEALIAS_ALIAS:
+       case NODE_ENUM:
+       case NODE_STRUCT_OR_VARIANT_DECLARATION:
        case NODE_ROOT:
        case NODE_EVENT:
        case NODE_STREAM:
+       case NODE_ENV:
        case NODE_TRACE:
+       case NODE_CLOCK:
+       case NODE_CALLSITE:
        case NODE_UNARY_EXPRESSION:
        case NODE_TYPEALIAS:
        case NODE_TYPE_SPECIFIER:
@@ -230,19 +299,56 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                /*
                 * A nested type declarator is not allowed to contain pointers.
                 */
-               if (!cds_list_empty(&node->u.type_declarator.pointers))
+               if (!bt_list_empty(&node->u.type_declarator.pointers))
                        goto errperm;
-               /* Fall-through */
-       case NODE_TYPEDEF:
+               break;                  /* OK */
        case NODE_TYPEALIAS_TARGET:
+               break;                  /* OK */
        case NODE_TYPEALIAS_ALIAS:
+               /*
+                * Only accept alias name containing:
+                * - identifier
+                * - identifier *   (any number of pointers)
+                * NOT accepting alias names containing [] (would otherwise
+                * cause semantic clash for later declarations of
+                * arrays/sequences of elements, where elements could be
+                * arrays/sequences themselves (if allowed in typealias).
+                * NOT accepting alias with identifier. The declarator should
+                * be either empty or contain pointer(s).
+                */
+               if (node->u.type_declarator.type == TYPEDEC_NESTED)
+                       goto errperm;
+               bt_list_for_each_entry(iter, &node->parent->u.typealias_alias.type_specifier_list->u.type_specifier_list.head,
+                                       siblings) {
+                       switch (iter->u.type_specifier.type) {
+                       case TYPESPEC_FLOATING_POINT:
+                       case TYPESPEC_INTEGER:
+                       case TYPESPEC_STRING:
+                       case TYPESPEC_STRUCT:
+                       case TYPESPEC_VARIANT:
+                       case TYPESPEC_ENUM:
+                               if (bt_list_empty(&node->u.type_declarator.pointers))
+                                       goto errperm;
+                               break;
+                       default:
+                               break;
+                       }
+               }
+               if (node->u.type_declarator.type == TYPEDEC_ID &&
+                   node->u.type_declarator.u.id != NULL)
+                       goto errperm;
+               break;                  /* OK */
+       case NODE_TYPEDEF:
        case NODE_STRUCT_OR_VARIANT_DECLARATION:
                break;                  /* OK */
 
        case NODE_ROOT:
        case NODE_EVENT:
        case NODE_STREAM:
+       case NODE_ENV:
        case NODE_TRACE:
+       case NODE_CLOCK:
+       case NODE_CALLSITE:
        case NODE_CTF_EXPRESSION:
        case NODE_UNARY_EXPRESSION:
        case NODE_TYPEALIAS:
@@ -259,30 +365,40 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                goto errinval;
        }
 
-       if (!cds_list_empty(&node->u.type_declarator.pointers)) {
-               cds_list_for_each_entry(iter, &node->u.type_declarator.pointers,
-                                       siblings) {
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
-               }
+       bt_list_for_each_entry(iter, &node->u.type_declarator.pointers,
+                               siblings) {
+               ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+               if (ret)
+                       return ret;
        }
 
        switch (node->u.type_declarator.type) {
        case TYPEDEC_ID:
                break;
        case TYPEDEC_NESTED:
+       {
                if (node->u.type_declarator.u.nested.type_declarator) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1,
                                node->u.type_declarator.u.nested.type_declarator);
                        if (ret)
                                return ret;
                }
-               if (node->u.type_declarator.u.nested.length) {
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1,
-                               node->u.type_declarator.u.nested.length);
-                       if (ret)
-                               return ret;
+               if (!node->u.type_declarator.u.nested.abstract_array) {
+                       bt_list_for_each_entry(iter, &node->u.type_declarator.u.nested.length,
+                                               siblings) {
+                               if (iter->type != NODE_UNARY_EXPRESSION) {
+                                       fprintf(fd, "[error] %s: expecting unary expression as length\n", __func__);
+                                       return -EINVAL;
+                               }
+                               ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+                               if (ret)
+                                       return ret;
+                       }
+               } else {
+                       if (node->parent->type == NODE_TYPEALIAS_TARGET) {
+                               fprintf(fd, "[error] %s: abstract array declarator not permitted as target of typealias\n", __func__);
+                               return -EINVAL;
+                       }
                }
                if (node->u.type_declarator.bitfield_len) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1,
@@ -291,6 +407,7 @@ int ctf_visitor_type_declarator(FILE *fd, int depth, struct ctf_node *node)
                                return ret;
                }
                break;
+       }
        case TYPEDEC_UNKNOWN:
        default:
                fprintf(fd, "[error] %s: unknown type declarator %d\n", __func__,
@@ -319,41 +436,71 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
 
        switch (node->type) {
        case NODE_ROOT:
-               cds_list_for_each_entry(iter, &node->u.root._typedef,
-                                       siblings) {
+               bt_list_for_each_entry(iter, &node->u.root.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.root.typealias,
-                                       siblings) {
+               bt_list_for_each_entry(iter, &node->u.root.trace, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.root.declaration_specifier, siblings) {
+               bt_list_for_each_entry(iter, &node->u.root.stream, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.root.trace, siblings) {
+               bt_list_for_each_entry(iter, &node->u.root.event, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.root.stream, siblings) {
+               break;
+
+       case NODE_EVENT:
+               switch (node->parent->type) {
+               case NODE_ROOT:
+                       break;                  /* OK */
+               default:
+                       goto errinval;
+               }
+
+               bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.root.event, siblings) {
+               break;
+       case NODE_STREAM:
+               switch (node->parent->type) {
+               case NODE_ROOT:
+                       break;                  /* OK */
+               default:
+                       goto errinval;
+               }
+
+               bt_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
                break;
+       case NODE_ENV:
+               switch (node->parent->type) {
+               case NODE_ROOT:
+                       break;                  /* OK */
+               default:
+                       goto errinval;
+               }
 
-       case NODE_EVENT:
+               bt_list_for_each_entry(iter, &node->u.env.declaration_list, siblings) {
+                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
+                       if (ret)
+                               return ret;
+               }
+               break;
+       case NODE_TRACE:
                switch (node->parent->type) {
                case NODE_ROOT:
                        break;                  /* OK */
@@ -361,13 +508,13 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errinval;
                }
 
-               cds_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
                break;
-       case NODE_STREAM:
+       case NODE_CLOCK:
                switch (node->parent->type) {
                case NODE_ROOT:
                        break;                  /* OK */
@@ -375,13 +522,13 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errinval;
                }
 
-               cds_list_for_each_entry(iter, &node->u.stream.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.clock.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
                break;
-       case NODE_TRACE:
+       case NODE_CALLSITE:
                switch (node->parent->type) {
                case NODE_ROOT:
                        break;                  /* OK */
@@ -389,7 +536,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errinval;
                }
 
-               cds_list_for_each_entry(iter, &node->u.trace.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.callsite.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -401,7 +548,10 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_ROOT:
                case NODE_EVENT:
                case NODE_STREAM:
+               case NODE_ENV:
                case NODE_TRACE:
+               case NODE_CLOCK:
+               case NODE_CALLSITE:
                case NODE_FLOATING_POINT:
                case NODE_INTEGER:
                case NODE_STRING:
@@ -415,6 +565,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_STRUCT_OR_VARIANT_DECLARATION:
                case NODE_TYPEALIAS:
                case NODE_TYPE_SPECIFIER:
+               case NODE_TYPE_SPECIFIER_LIST:
                case NODE_POINTER:
                case NODE_TYPE_DECLARATOR:
                case NODE_ENUMERATOR:
@@ -426,12 +577,12 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                }
 
                depth++;
-               cds_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
+               bt_list_for_each_entry(iter, &node->u.ctf_expression.left, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
                }
-               cds_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
+               bt_list_for_each_entry(iter, &node->u.ctf_expression.right, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -459,6 +610,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_TYPEALIAS:
                case NODE_STRUCT_OR_VARIANT_DECLARATION:
                case NODE_TYPE_SPECIFIER:
+               case NODE_TYPE_SPECIFIER_LIST:
                case NODE_POINTER:
                case NODE_TYPE_DECLARATOR:
                case NODE_FLOATING_POINT:
@@ -466,17 +618,19 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_STRING:
                case NODE_ENUMERATOR:
                case NODE_ENUM:
+               case NODE_CLOCK:
+               case NODE_CALLSITE:
+               case NODE_ENV:
                default:
                        goto errinval;
                }
 
                depth++;
-               cds_list_for_each_entry(iter, &node->u._typedef.declaration_specifier, siblings) {
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
-               }
-               cds_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
+               ret = _ctf_visitor_semantic_check(fd, depth + 1,
+                       node->u._typedef.type_specifier_list);
+               if (ret)
+                       return ret;
+               bt_list_for_each_entry(iter, &node->u._typedef.type_declarators, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -484,6 +638,9 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                depth--;
                break;
        case NODE_TYPEALIAS_TARGET:
+       {
+               int nr_declarators;
+
                switch (node->parent->type) {
                case NODE_TYPEALIAS:
                        break;                  /* OK */
@@ -492,19 +649,29 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                }
 
                depth++;
-               cds_list_for_each_entry(iter, &node->u.typealias_target.declaration_specifier, siblings) {
+               ret = _ctf_visitor_semantic_check(fd, depth + 1,
+                       node->u.typealias_target.type_specifier_list);
+               if (ret)
+                       return ret;
+               nr_declarators = 0;
+               bt_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
+                       nr_declarators++;
                }
-               cds_list_for_each_entry(iter, &node->u.typealias_target.type_declarators, siblings) {
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
+               if (nr_declarators > 1) {
+                       fprintf(fd, "[error] %s: Too many declarators in typealias alias (%d, max is 1)\n", __func__, nr_declarators);
+               
+                       return -EINVAL;
                }
                depth--;
                break;
+       }
        case NODE_TYPEALIAS_ALIAS:
+       {
+               int nr_declarators;
+
                switch (node->parent->type) {
                case NODE_TYPEALIAS:
                        break;                  /* OK */
@@ -513,18 +680,25 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                }
 
                depth++;
-               cds_list_for_each_entry(iter, &node->u.typealias_alias.declaration_specifier, siblings) {
+               ret = _ctf_visitor_semantic_check(fd, depth + 1,
+                       node->u.typealias_alias.type_specifier_list);
+               if (ret)
+                       return ret;
+               nr_declarators = 0;
+               bt_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
+                       nr_declarators++;
                }
-               cds_list_for_each_entry(iter, &node->u.typealias_alias.type_declarators, siblings) {
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
+               if (nr_declarators > 1) {
+                       fprintf(fd, "[error] %s: Too many declarators in typealias alias (%d, max is 1)\n", __func__, nr_declarators);
+               
+                       return -EINVAL;
                }
                depth--;
                break;
+       }
        case NODE_TYPEALIAS:
                switch (node->parent->type) {
                case NODE_ROOT:
@@ -543,6 +717,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_TYPEALIAS:
                case NODE_STRUCT_OR_VARIANT_DECLARATION:
                case NODE_TYPE_SPECIFIER:
+               case NODE_TYPE_SPECIFIER_LIST:
                case NODE_POINTER:
                case NODE_TYPE_DECLARATOR:
                case NODE_FLOATING_POINT:
@@ -550,6 +725,9 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                case NODE_STRING:
                case NODE_ENUMERATOR:
                case NODE_ENUM:
+               case NODE_CLOCK:
+               case NODE_CALLSITE:
+               case NODE_ENV:
                default:
                        goto errinval;
                }
@@ -562,6 +740,11 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        return ret;
                break;
 
+       case NODE_TYPE_SPECIFIER_LIST:
+               ret = ctf_visitor_type_specifier_list(fd, depth, node);
+               if (ret)
+                       return ret;
+               break;
        case NODE_TYPE_SPECIFIER:
                ret = ctf_visitor_type_specifier(fd, depth, node);
                if (ret)
@@ -583,35 +766,15 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
 
        case NODE_FLOATING_POINT:
                switch (node->parent->type) {
-               case NODE_CTF_EXPRESSION:
-               case NODE_TYPEDEF:
-               case NODE_TYPEALIAS_TARGET:
-               case NODE_TYPEALIAS_ALIAS:
-               case NODE_STRUCT_OR_VARIANT_DECLARATION:
-                       break;                  /* OK */
-
-               case NODE_ROOT:
-               case NODE_EVENT:
-               case NODE_STREAM:
-               case NODE_TRACE:
-               case NODE_TYPEALIAS:
                case NODE_TYPE_SPECIFIER:
-               case NODE_POINTER:
-               case NODE_TYPE_DECLARATOR:
-               case NODE_FLOATING_POINT:
-               case NODE_INTEGER:
-               case NODE_STRING:
-               case NODE_ENUMERATOR:
-               case NODE_ENUM:
-               case NODE_VARIANT:
-               case NODE_STRUCT:
+                       break;                  /* OK */
                default:
                        goto errinval;
 
                case NODE_UNARY_EXPRESSION:
                        goto errperm;
                }
-               cds_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
+               bt_list_for_each_entry(iter, &node->u.floating_point.expressions, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -619,35 +782,14 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                break;
        case NODE_INTEGER:
                switch (node->parent->type) {
-               case NODE_CTF_EXPRESSION:
-               case NODE_UNARY_EXPRESSION:
-               case NODE_TYPEDEF:
-               case NODE_TYPEALIAS_TARGET:
-               case NODE_TYPEALIAS_ALIAS:
-               case NODE_TYPE_DECLARATOR:
-               case NODE_ENUM:
-               case NODE_STRUCT_OR_VARIANT_DECLARATION:
-                       break;                  /* OK */
-
-               case NODE_ROOT:
-               case NODE_EVENT:
-               case NODE_STREAM:
-               case NODE_TRACE:
-               case NODE_TYPEALIAS:
                case NODE_TYPE_SPECIFIER:
-               case NODE_POINTER:
-               case NODE_FLOATING_POINT:
-               case NODE_INTEGER:
-               case NODE_STRING:
-               case NODE_ENUMERATOR:
-               case NODE_VARIANT:
-               case NODE_STRUCT:
+                       break;                  /* OK */
                default:
                        goto errinval;
 
                }
 
-               cds_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
+               bt_list_for_each_entry(iter, &node->u.integer.expressions, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -655,28 +797,8 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                break;
        case NODE_STRING:
                switch (node->parent->type) {
-               case NODE_CTF_EXPRESSION:
-               case NODE_TYPEDEF:
-               case NODE_TYPEALIAS_TARGET:
-               case NODE_TYPEALIAS_ALIAS:
-               case NODE_STRUCT_OR_VARIANT_DECLARATION:
-                       break;                  /* OK */
-
-               case NODE_ROOT:
-               case NODE_EVENT:
-               case NODE_STREAM:
-               case NODE_TRACE:
-               case NODE_TYPEALIAS:
                case NODE_TYPE_SPECIFIER:
-               case NODE_POINTER:
-               case NODE_TYPE_DECLARATOR:
-               case NODE_FLOATING_POINT:
-               case NODE_INTEGER:
-               case NODE_STRING:
-               case NODE_ENUMERATOR:
-               case NODE_ENUM:
-               case NODE_VARIANT:
-               case NODE_STRUCT:
+                       break;                  /* OK */
                default:
                        goto errinval;
 
@@ -684,7 +806,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        goto errperm;
                }
 
-               cds_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
+               bt_list_for_each_entry(iter, &node->u.string.expressions, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -705,7 +827,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                {
                        int count = 0;
 
-                       cds_list_for_each_entry(iter, &node->u.enumerator.values,
+                       bt_list_for_each_entry(iter, &node->u.enumerator.values,
                                                siblings) {
                                switch (count++) {
                                case 0: if (iter->type != NODE_UNARY_EXPRESSION
@@ -730,7 +852,7 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                        }
                }
 
-               cds_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
+               bt_list_for_each_entry(iter, &node->u.enumerator.values, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -738,28 +860,8 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                break;
        case NODE_ENUM:
                switch (node->parent->type) {
-               case NODE_ROOT:
-               case NODE_EVENT:
-               case NODE_STREAM:
-               case NODE_TRACE:
-               case NODE_CTF_EXPRESSION:
-               case NODE_TYPEDEF:
-               case NODE_TYPEALIAS_TARGET:
-               case NODE_TYPEALIAS_ALIAS:
-               case NODE_TYPE_DECLARATOR:
-               case NODE_STRUCT_OR_VARIANT_DECLARATION:
-                       break;                  /* OK */
-
-               case NODE_TYPEALIAS:
                case NODE_TYPE_SPECIFIER:
-               case NODE_POINTER:
-               case NODE_FLOATING_POINT:
-               case NODE_INTEGER:
-               case NODE_STRING:
-               case NODE_ENUMERATOR:
-               case NODE_ENUM:
-               case NODE_VARIANT:
-               case NODE_STRUCT:
+                       break;                  /* OK */
                default:
                        goto errinval;
 
@@ -768,13 +870,11 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                }
 
                depth++;
-               if (node->u._enum.container_type) {
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1, node->u._enum.container_type);
-                       if (ret)
-                               return ret;
-               }
+               ret = _ctf_visitor_semantic_check(fd, depth + 1, node->u._enum.container_type);
+               if (ret)
+                       return ret;
 
-               cds_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u._enum.enumerator_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -789,12 +889,11 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                default:
                        goto errinval;
                }
-               cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.declaration_specifier, siblings) {
-                       ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
-                       if (ret)
-                               return ret;
-               }
-               cds_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) {
+               ret = _ctf_visitor_semantic_check(fd, depth + 1,
+                       node->u.struct_or_variant_declaration.type_specifier_list);
+               if (ret)
+                       return ret;
+               bt_list_for_each_entry(iter, &node->u.struct_or_variant_declaration.type_declarators, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -802,35 +901,15 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
                break;
        case NODE_VARIANT:
                switch (node->parent->type) {
-               case NODE_ROOT:
-               case NODE_EVENT:
-               case NODE_STREAM:
-               case NODE_TRACE:
-               case NODE_CTF_EXPRESSION:
-               case NODE_TYPEDEF:
-               case NODE_TYPEALIAS_TARGET:
-               case NODE_TYPEALIAS_ALIAS:
-               case NODE_STRUCT_OR_VARIANT_DECLARATION:
-                       break;                  /* OK */
-
-               case NODE_TYPEALIAS:
                case NODE_TYPE_SPECIFIER:
-               case NODE_POINTER:
-               case NODE_TYPE_DECLARATOR:
-               case NODE_FLOATING_POINT:
-               case NODE_INTEGER:
-               case NODE_STRING:
-               case NODE_ENUMERATOR:
-               case NODE_ENUM:
-               case NODE_VARIANT:
-               case NODE_STRUCT:
+                       break;                  /* OK */
                default:
                        goto errinval;
 
                case NODE_UNARY_EXPRESSION:
                        goto errperm;
                }
-               cds_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u.variant.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -839,35 +918,15 @@ int _ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
 
        case NODE_STRUCT:
                switch (node->parent->type) {
-               case NODE_ROOT:
-               case NODE_EVENT:
-               case NODE_STREAM:
-               case NODE_TRACE:
-               case NODE_CTF_EXPRESSION:
-               case NODE_TYPEDEF:
-               case NODE_TYPEALIAS_TARGET:
-               case NODE_TYPEALIAS_ALIAS:
-               case NODE_STRUCT_OR_VARIANT_DECLARATION:
-                       break;                  /* OK */
-
-               case NODE_TYPEALIAS:
                case NODE_TYPE_SPECIFIER:
-               case NODE_POINTER:
-               case NODE_TYPE_DECLARATOR:
-               case NODE_FLOATING_POINT:
-               case NODE_INTEGER:
-               case NODE_STRING:
-               case NODE_ENUMERATOR:
-               case NODE_ENUM:
-               case NODE_VARIANT:
-               case NODE_STRUCT:
+                       break;                  /* OK */
                default:
                        goto errinval;
 
                case NODE_UNARY_EXPRESSION:
                        goto errperm;
                }
-               cds_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
+               bt_list_for_each_entry(iter, &node->u._struct.declaration_list, siblings) {
                        ret = _ctf_visitor_semantic_check(fd, depth + 1, iter);
                        if (ret)
                                return ret;
@@ -902,15 +961,15 @@ int ctf_visitor_semantic_check(FILE *fd, int depth, struct ctf_node *node)
         * take the safe route and recreate them at each validation, just in
         * case the structure has changed.
         */
-       fprintf(fd, "CTF visitor: parent links creation... ");
+       printf_verbose("CTF visitor: parent links creation... ");
        ret = ctf_visitor_parent_links(fd, depth, node);
        if (ret)
                return ret;
-       fprintf(fd, "done.\n");
-       fprintf(fd, "CTF visitor: semantic check... ");
+       printf_verbose("done.\n");
+       printf_verbose("CTF visitor: semantic check... ");
        ret = _ctf_visitor_semantic_check(fd, depth, node);
        if (ret)
                return ret;
-       fprintf(fd, "done.\n");
+       printf_verbose("done.\n");
        return ret;
 }
This page took 0.034711 seconds and 4 git commands to generate.