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)
| 2962 | return self.stack and self.stack[-1].inline_asm != _NO_ASM |
| 2963 | |
| 2964 | def InTemplateArgumentList(self, clean_lines, linenum, pos): |
| 2965 | """Check if current position is inside template argument list. |
| 2966 | |
| 2967 | Args: |
| 2968 | clean_lines: A CleansedLines instance containing the file. |
| 2969 | linenum: The number of the line to check. |
| 2970 | pos: position just after the suspected template argument. |
| 2971 | Returns: |
| 2972 | True if (linenum, pos) is inside template arguments. |
| 2973 | """ |
| 2974 | while linenum < clean_lines.NumLines(): |
| 2975 | # Find the earliest character that might indicate a template argument |
| 2976 | line = clean_lines.elided[linenum] |
| 2977 | match = Match(r'^[^{};=\[\]\.<>]*(.)', line[pos:]) |
| 2978 | if not match: |
| 2979 | linenum += 1 |
| 2980 | pos = 0 |
| 2981 | continue |
| 2982 | token = match.group(1) |
| 2983 | pos += len(match.group(0)) |
| 2984 | |
| 2985 | # These things do not look like template argument list: |
| 2986 | # class Suspect { |
| 2987 | # class Suspect x; } |
| 2988 | if token in ('{', '}', ';'): return False |
| 2989 | |
| 2990 | # These things look like template argument list: |
| 2991 | # template <class Suspect> |
| 2992 | # template <class Suspect = default_value> |
| 2993 | # template <class Suspect[]> |
| 2994 | # template <class Suspect...> |
| 2995 | if token in ('>', '=', '[', ']', '.'): return True |
| 2996 | |
| 2997 | # Check if token is an unmatched '<'. |
| 2998 | # If not, move on to the next character. |
| 2999 | if token != '<': |
| 3000 | pos += 1 |
| 3001 | if pos >= len(line): |
| 3002 | linenum += 1 |
| 3003 | pos = 0 |
| 3004 | continue |
| 3005 | |
| 3006 | # We can't be sure if we just find a single '<', and need to |
| 3007 | # find the matching '>'. |
| 3008 | (_, end_line, end_pos) = CloseExpression(clean_lines, linenum, pos - 1) |
| 3009 | if end_pos < 0: |
| 3010 | # Not sure if template argument list or syntax error in file |
| 3011 | return False |
| 3012 | linenum = end_line |
| 3013 | pos = end_pos |
| 3014 | return False |
| 3015 | |
| 3016 | def UpdatePreprocessor(self, line): |
| 3017 | """Update preprocessor stack. |
no test coverage detected