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 (
(self, clean_lines, linenum, pos)
| 3288 | return self.stack and self.stack[-1].inline_asm != _NO_ASM |
| 3289 | |
| 3290 | def InTemplateArgumentList(self, clean_lines, linenum, pos): |
| 3291 | """Check if current position is inside template argument list. |
| 3292 | |
| 3293 | Args: |
| 3294 | clean_lines: A CleansedLines instance containing the file. |
| 3295 | linenum: The number of the line to check. |
| 3296 | pos: position just after the suspected template argument. |
| 3297 | Returns: |
| 3298 | True if (linenum, pos) is inside template arguments. |
| 3299 | """ |
| 3300 | while linenum < clean_lines.NumLines(): |
| 3301 | # Find the earliest character that might indicate a template argument |
| 3302 | line = clean_lines.elided[linenum] |
| 3303 | match = re.match(r"^[^{};=\[\]\.<>]*(.)", line[pos:]) |
| 3304 | if not match: |
| 3305 | linenum += 1 |
| 3306 | pos = 0 |
| 3307 | continue |
| 3308 | token = match.group(1) |
| 3309 | pos += len(match.group(0)) |
| 3310 | |
| 3311 | # These things do not look like template argument list: |
| 3312 | # class Suspect { |
| 3313 | # class Suspect x; } |
| 3314 | if token in ("{", "}", ";"): |
| 3315 | return False |
| 3316 | |
| 3317 | # These things look like template argument list: |
| 3318 | # template <class Suspect> |
| 3319 | # template <class Suspect = default_value> |
| 3320 | # template <class Suspect[]> |
| 3321 | # template <class Suspect...> |
| 3322 | if token in (">", "=", "[", "]", "."): |
| 3323 | return True |
| 3324 | |
| 3325 | # Check if token is an unmatched '<'. |
| 3326 | # If not, move on to the next character. |
| 3327 | if token != "<": |
| 3328 | pos += 1 |
| 3329 | if pos >= len(line): |
| 3330 | linenum += 1 |
| 3331 | pos = 0 |
| 3332 | continue |
| 3333 | |
| 3334 | # We can't be sure if we just find a single '<', and need to |
| 3335 | # find the matching '>'. |
| 3336 | (_, end_line, end_pos) = CloseExpression(clean_lines, linenum, pos - 1) |
| 3337 | if end_pos < 0: |
| 3338 | # Not sure if template argument list or syntax error in file |
| 3339 | return False |
| 3340 | linenum = end_line |
| 3341 | pos = end_pos |
| 3342 | return False |
| 3343 | |
| 3344 | def UpdatePreprocessor(self, line): |
| 3345 | """Update preprocessor stack. |
no test coverage detected