Find a replaceable CHECK-like macro. Args: line: line to search on. Returns: (macro name, start position), or (None, -1) if no replaceable macro is found.
(line)
| 4613 | |
| 4614 | |
| 4615 | def FindCheckMacro(line): |
| 4616 | """Find a replaceable CHECK-like macro. |
| 4617 | |
| 4618 | Args: |
| 4619 | line: line to search on. |
| 4620 | Returns: |
| 4621 | (macro name, start position), or (None, -1) if no replaceable |
| 4622 | macro is found. |
| 4623 | """ |
| 4624 | for macro in _CHECK_MACROS: |
| 4625 | i = line.find(macro) |
| 4626 | if i >= 0: |
| 4627 | # Find opening parenthesis. Do a regular expression match here |
| 4628 | # to make sure that we are matching the expected CHECK macro, as |
| 4629 | # opposed to some other macro that happens to contain the CHECK |
| 4630 | # substring. |
| 4631 | matched = Match(r'^(.*\b' + macro + r'\s*)\(', line) |
| 4632 | if not matched: |
| 4633 | continue |
| 4634 | return (macro, len(matched.group(1))) |
| 4635 | return (None, -1) |
| 4636 | |
| 4637 | |
| 4638 | def CheckCheck(filename, clean_lines, linenum, error): |