GCC Code Coverage Report


Directory: src/
File: src/cmdline/jformat-tree-main.cpp
Date: 2025-10-24 11:14:59
Exec Total Coverage
Lines: 14 21 66.7%
Functions: 1 1 100.0%
Branches: 3 6 50.0%

Line Branch Exec Source
1 /* Copyright 2025 Jonathan S. Arney
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * https://github.com/jarney/gyoji/blob/master/LICENSE
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include <gyoji-frontend.hpp>
16 #include <gyoji-misc/input-source-file.hpp>
17 #include "jformat-tree.hpp"
18
19 using namespace Gyoji::context;
20 using namespace Gyoji::frontend;
21 using namespace Gyoji::frontend::tree;
22 using namespace Gyoji::frontend::namespaces;
23 using namespace Gyoji::cmdline;
24
25 48 int main(int argc, char **argv)
26 {
27
28
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if (argc != 2) {
29 fprintf(stderr, "Invalid number of arguments %d\n", argc);
30 fprintf(stderr, "Usage: parser backend file\n");
31 exit(1);
32 }
33
34 48 int input = open(argv[1], O_RDONLY);
35
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if (input == -1) {
36 fprintf(stderr, "Cannot open file %s\n", argv[1]);
37 exit(1);
38 }
39
40 48 CompilerContext context(argv[1]);
41
42 48 Gyoji::misc::InputSourceFile input_source(input);
43
44 Gyoji::owned<ParseResult> parse_result =
45 Parser::parse(
46 context,
47 input_source
48 48 );
49 48 close(input);
50
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 48 times.
48 if (parse_result->has_errors()) {
51 parse_result->get_errors().print();
52 return -1;
53 }
54
55 48 const TranslationUnit & translation_unit = parse_result->get_translation_unit();
56
57 48 JFormatTree formatter;
58 48 formatter.process(translation_unit.get_syntax_node());
59
60 48 return 0;
61 48 }
62