Check if current position is inside template argument list. Args: clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. pos: position just after the suspected template argument. Returns: True if (linenum, pos) is inside
(self, clean_lines, linenum, pos)
| 2471 | return self.stack and self.stack[-1].inline_asm != _NO_ASM |
| 2472 | |
| 2473 | def InTemplateArgumentList(self, clean_lines, linenum, pos): |
| 2474 | """Check if current position is inside template argument list. |
| 2475 | |
| 2476 | Args: |
| 2477 | clean_lines: A CleansedLines instance containing the file. |
| 2478 | linenum: The number of the line to check. |
| 2479 | pos: position just after the suspected template argument. |
| 2480 | Returns: |
| 2481 | True if (linenum, pos) is inside template arguments. |
| 2482 | """ |
| 2483 | while linenum < clean_lines.NumLines(): |
| 2484 | # Find the earliest character that might indicate a template argument |
| 2485 | line = clean_lines.elided[linenum] |
| 2486 | match = Match(r'^[^{};=\[\]\.<>]*(.)', line[pos:]) |
| 2487 | if not match: |
| 2488 | linenum += 1 |
| 2489 | pos = 0 |
| 2490 | continue |
| 2491 | token = match.group(1) |
| 2492 | pos += len(match.group(0)) |
| 2493 | |
| 2494 | # These things do not look like template argument list: |
| 2495 | # class Suspect { |
| 2496 | # class Suspect x; } |
| 2497 | if token in ('{', '}', ';'): return False |
| 2498 | |
| 2499 | # These things look like template argument list: |
| 2500 | # template <class Suspect> |
| 2501 | # template <class Suspect = default_value> |
| 2502 | # template <class Suspect[]> |
| 2503 | # template <class Suspect...> |
| 2504 | if token in ('>', '=', '[', ']', '.'): return True |
| 2505 | |
| 2506 | # Check if token is an unmatched '<'. |
| 2507 | # If not, move on to the next character. |
| 2508 | if token != '<': |
| 2509 | pos += 1 |
| 2510 | if pos >= len(line): |
| 2511 | linenum += 1 |
| 2512 | pos = 0 |
| 2513 | continue |
| 2514 | |
| 2515 | # We can't be sure if we just find a single '<', and need to |
| 2516 | # find the matching '>'. |
| 2517 | (_, end_line, end_pos) = CloseExpression(clean_lines, linenum, pos - 1) |
| 2518 | if end_pos < 0: |
| 2519 | # Not sure if template argument list or syntax error in file |
| 2520 | return False |
| 2521 | linenum = end_line |
| 2522 | pos = end_pos |
| 2523 | return False |
| 2524 | |
| 2525 | def UpdatePreprocessor(self, line): |
| 2526 | """Update preprocessor stack. |
no test coverage detected