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)
| 5207 | |
| 5208 | |
| 5209 | def FindCheckMacro(line): |
| 5210 | """Find a replaceable CHECK-like macro. |
| 5211 | |
| 5212 | Args: |
| 5213 | line: line to search on. |
| 5214 | Returns: |
| 5215 | (macro name, start position), or (None, -1) if no replaceable |
| 5216 | macro is found. |
| 5217 | """ |
| 5218 | for macro in _CHECK_MACROS: |
| 5219 | i = line.find(macro) |
| 5220 | if i >= 0: |
| 5221 | # Find opening parenthesis. Do a regular expression match here |
| 5222 | # to make sure that we are matching the expected CHECK macro, as |
| 5223 | # opposed to some other macro that happens to contain the CHECK |
| 5224 | # substring. |
| 5225 | matched = re.match(r"^(.*\b" + macro + r"\s*)\(", line) |
| 5226 | if not matched: |
| 5227 | continue |
| 5228 | return (macro, len(matched.group(1))) |
| 5229 | return (None, -1) |
| 5230 | |
| 5231 | |
| 5232 | def CheckCheck(filename, clean_lines, linenum, error): |