| @@ 5126-5165 (lines=40) @@ | ||
| 5123 | return False |
|
| 5124 | ||
| 5125 | ||
| 5126 | def IsInitializerList(clean_lines, linenum): |
|
| 5127 | """Check if current line is inside constructor initializer list. |
|
| 5128 | ||
| 5129 | Args: |
|
| 5130 | clean_lines: A CleansedLines instance containing the file. |
|
| 5131 | linenum: The number of the line to check. |
|
| 5132 | Returns: |
|
| 5133 | True if current line appears to be inside constructor initializer |
|
| 5134 | list, False otherwise. |
|
| 5135 | """ |
|
| 5136 | for i in xrange(linenum, 1, -1): |
|
| 5137 | line = clean_lines.elided[i] |
|
| 5138 | if i == linenum: |
|
| 5139 | remove_function_body = Match(r'^(.*)\{\s*$', line) |
|
| 5140 | if remove_function_body: |
|
| 5141 | line = remove_function_body.group(1) |
|
| 5142 | ||
| 5143 | if Search(r'\s:\s*\w+[({]', line): |
|
| 5144 | # A lone colon tend to indicate the start of a constructor |
|
| 5145 | # initializer list. It could also be a ternary operator, which |
|
| 5146 | # also tend to appear in constructor initializer lists as |
|
| 5147 | # opposed to parameter lists. |
|
| 5148 | return True |
|
| 5149 | if Search(r'\}\s*,\s*$', line): |
|
| 5150 | # A closing brace followed by a comma is probably the end of a |
|
| 5151 | # brace-initialized member in constructor initializer list. |
|
| 5152 | return True |
|
| 5153 | if Search(r'[{};]\s*$', line): |
|
| 5154 | # Found one of the following: |
|
| 5155 | # - A closing brace or semicolon, probably the end of the previous |
|
| 5156 | # function. |
|
| 5157 | # - An opening brace, probably the start of current class or namespace. |
|
| 5158 | # |
|
| 5159 | # Current line is probably not inside an initializer list since |
|
| 5160 | # we saw one of those things without seeing the starting colon. |
|
| 5161 | return False |
|
| 5162 | ||
| 5163 | # Got to the beginning of the file without seeing the start of |
|
| 5164 | # constructor initializer list. |
|
| 5165 | return False |
|
| 5166 | ||
| 5167 | ||
| 5168 | def CheckForNonConstReference(filename, clean_lines, linenum, |
|
| @@ 5126-5165 (lines=40) @@ | ||
| 5123 | return False |
|
| 5124 | ||
| 5125 | ||
| 5126 | def IsInitializerList(clean_lines, linenum): |
|
| 5127 | """Check if current line is inside constructor initializer list. |
|
| 5128 | ||
| 5129 | Args: |
|
| 5130 | clean_lines: A CleansedLines instance containing the file. |
|
| 5131 | linenum: The number of the line to check. |
|
| 5132 | Returns: |
|
| 5133 | True if current line appears to be inside constructor initializer |
|
| 5134 | list, False otherwise. |
|
| 5135 | """ |
|
| 5136 | for i in xrange(linenum, 1, -1): |
|
| 5137 | line = clean_lines.elided[i] |
|
| 5138 | if i == linenum: |
|
| 5139 | remove_function_body = Match(r'^(.*)\{\s*$', line) |
|
| 5140 | if remove_function_body: |
|
| 5141 | line = remove_function_body.group(1) |
|
| 5142 | ||
| 5143 | if Search(r'\s:\s*\w+[({]', line): |
|
| 5144 | # A lone colon tend to indicate the start of a constructor |
|
| 5145 | # initializer list. It could also be a ternary operator, which |
|
| 5146 | # also tend to appear in constructor initializer lists as |
|
| 5147 | # opposed to parameter lists. |
|
| 5148 | return True |
|
| 5149 | if Search(r'\}\s*,\s*$', line): |
|
| 5150 | # A closing brace followed by a comma is probably the end of a |
|
| 5151 | # brace-initialized member in constructor initializer list. |
|
| 5152 | return True |
|
| 5153 | if Search(r'[{};]\s*$', line): |
|
| 5154 | # Found one of the following: |
|
| 5155 | # - A closing brace or semicolon, probably the end of the previous |
|
| 5156 | # function. |
|
| 5157 | # - An opening brace, probably the start of current class or namespace. |
|
| 5158 | # |
|
| 5159 | # Current line is probably not inside an initializer list since |
|
| 5160 | # we saw one of those things without seeing the starting colon. |
|
| 5161 | return False |
|
| 5162 | ||
| 5163 | # Got to the beginning of the file without seeing the start of |
|
| 5164 | # constructor initializer list. |
|
| 5165 | return False |
|
| 5166 | ||
| 5167 | ||
| 5168 | def CheckForNonConstReference(filename, clean_lines, linenum, |
|