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)
| 4035 | |
| 4036 | |
| 4037 | def FindCheckMacro(line): |
| 4038 | """Find a replaceable CHECK-like macro. |
| 4039 | |
| 4040 | Args: |
| 4041 | line: line to search on. |
| 4042 | Returns: |
| 4043 | (macro name, start position), or (None, -1) if no replaceable |
| 4044 | macro is found. |
| 4045 | """ |
| 4046 | for macro in _CHECK_MACROS: |
| 4047 | i = line.find(macro) |
| 4048 | if i >= 0: |
| 4049 | # Find opening parenthesis. Do a regular expression match here |
| 4050 | # to make sure that we are matching the expected CHECK macro, as |
| 4051 | # opposed to some other macro that happens to contain the CHECK |
| 4052 | # substring. |
| 4053 | matched = Match(r'^(.*\b' + macro + r'\s*)\(', line) |
| 4054 | if not matched: |
| 4055 | continue |
| 4056 | return (macro, len(matched.group(1))) |
| 4057 | return (None, -1) |
| 4058 | |
| 4059 | |
| 4060 | def CheckCheck(filename, clean_lines, linenum, error): |