(text, reqfile, samefiles, cwd, raw=False)
| 51 | |
| 52 | |
| 53 | def _iter_lines(text, reqfile, samefiles, cwd, raw=False): |
| 54 | lines = iter(text.splitlines()) |
| 55 | |
| 56 | # The first line is special. |
| 57 | # The subsequent lines are consistent. |
| 58 | firstlines = [ |
| 59 | f'# 1 "{reqfile}"', |
| 60 | '# 1 "<built-in>" 1', |
| 61 | '# 1 "<built-in>" 3', |
| 62 | '# 370 "<built-in>" 3', |
| 63 | '# 1 "<command line>" 1', |
| 64 | '# 1 "<built-in>" 2', |
| 65 | ] |
| 66 | for expected in firstlines: |
| 67 | line = next(lines) |
| 68 | if line != expected: |
| 69 | raise NotImplementedError((line, expected)) |
| 70 | |
| 71 | # Do all the CLI-provided includes. |
| 72 | filter_reqfile = (lambda f: _gcc._filter_reqfile(f, reqfile, samefiles)) |
| 73 | make_info = (lambda lno: _common.FileInfo(reqfile, lno)) |
| 74 | last = None |
| 75 | for line in lines: |
| 76 | assert last != reqfile, (last,) |
| 77 | # NOTE:condition is clang specific |
| 78 | if not line: |
| 79 | continue |
| 80 | lno, included, flags = _gcc._parse_marker_line(line, reqfile) |
| 81 | if not included: |
| 82 | raise NotImplementedError((line,)) |
| 83 | if included == reqfile: |
| 84 | # This will be the last one. |
| 85 | assert 2 in flags, (line, flags) |
| 86 | else: |
| 87 | # NOTE:first condition is specific to clang |
| 88 | if _normpath(included, cwd) == reqfile: |
| 89 | assert 1 in flags or 2 in flags, (line, flags, included, reqfile) |
| 90 | else: |
| 91 | assert 1 in flags, (line, flags, included, reqfile) |
| 92 | yield from _gcc._iter_top_include_lines( |
| 93 | lines, |
| 94 | _normpath(included, cwd), |
| 95 | cwd, |
| 96 | filter_reqfile, |
| 97 | make_info, |
| 98 | raw, |
| 99 | EXIT_MARKERS |
| 100 | ) |
| 101 | last = included |
| 102 | # The last one is always the requested file. |
| 103 | # NOTE:_normpath is clang specific |
| 104 | assert _normpath(included, cwd) == reqfile, (line,) |
no test coverage detected
searching dependent graphs…