/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/polly/lib/External/isl/extract_key.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2013 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 | | #include <string.h> |
11 | | |
12 | | /* Extract a mapping key from the token "tok". |
13 | | * Return KEY_ERROR on error, i.e., if "tok" does not |
14 | | * correspond to any known key. |
15 | | */ |
16 | | static KEY extract_key(__isl_keep isl_stream *s, struct isl_token *tok) |
17 | 0 | { |
18 | 0 | int type; |
19 | 0 | char *name; |
20 | 0 | KEY key; |
21 | 0 | isl_ctx *ctx; |
22 | 0 |
|
23 | 0 | if (!tok) |
24 | 0 | return KEY_ERROR; |
25 | 0 | type = isl_token_get_type(tok); |
26 | 0 | if (type != ISL_TOKEN_IDENT && type != ISL_TOKEN_STRING) { |
27 | 0 | isl_stream_error(s, tok, "expecting key"); |
28 | 0 | return KEY_ERROR; |
29 | 0 | } |
30 | 0 |
|
31 | 0 | ctx = isl_stream_get_ctx(s); |
32 | 0 | name = isl_token_get_str(ctx, tok); |
33 | 0 | if (!name) |
34 | 0 | return KEY_ERROR; |
35 | 0 | |
36 | 0 | for (key = 0; key < KEY_END; ++key) { |
37 | 0 | if (!strcmp(name, key_str[key])) |
38 | 0 | break; |
39 | 0 | } |
40 | 0 | free(name); |
41 | 0 |
|
42 | 0 | if (key >= KEY_END) |
43 | 0 | isl_die(ctx, isl_error_invalid, "unknown key", |
44 | 0 | return KEY_ERROR); |
45 | 0 | return key; |
46 | 0 | } Unexecuted instantiation: isl_flow.c:extract_key Unexecuted instantiation: isl_schedule_constraints.c:extract_key Unexecuted instantiation: isl_schedule_read.c:extract_key |
47 | | |
48 | | /* Read a key from "s" and return the corresponding enum. |
49 | | * Return KEY_ERROR on error, i.e., if the first token |
50 | | * on the stream does not correspond to any known key. |
51 | | */ |
52 | | static KEY get_key(__isl_keep isl_stream *s) |
53 | 0 | { |
54 | 0 | struct isl_token *tok; |
55 | 0 | KEY key; |
56 | 0 |
|
57 | 0 | tok = isl_stream_next_token(s); |
58 | 0 | key = extract_key(s, tok); |
59 | 0 | isl_token_free(tok); |
60 | 0 |
|
61 | 0 | return key; |
62 | 0 | } Unexecuted instantiation: isl_flow.c:get_key Unexecuted instantiation: isl_schedule_constraints.c:get_key Unexecuted instantiation: isl_schedule_read.c:get_key |