| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2009 Google Inc. All rights reserved. | 3 # Copyright (c) 2009 Google Inc. All rights reserved. |
| 4 # | 4 # |
| 5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions are | 6 # modification, are permitted provided that the following conditions are |
| 7 # met: | 7 # met: |
| 8 # | 8 # |
| 9 # * Redistributions of source code must retain the above copyright | 9 # * Redistributions of source code must retain the above copyright |
| 10 # notice, this list of conditions and the following disclaimer. | 10 # notice, this list of conditions and the following disclaimer. |
| (...skipping 5627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5638 | 5638 |
| 5639 for pattern, template, header in _re_pattern_algorithm_header: | 5639 for pattern, template, header in _re_pattern_algorithm_header: |
| 5640 if pattern.search(line): | 5640 if pattern.search(line): |
| 5641 required[header] = (linenum, template) | 5641 required[header] = (linenum, template) |
| 5642 | 5642 |
| 5643 # The following function is just a speed up, no semantics are changed. | 5643 # The following function is just a speed up, no semantics are changed. |
| 5644 if not '<' in line: # Reduces the cpu time usage by skipping lines. | 5644 if not '<' in line: # Reduces the cpu time usage by skipping lines. |
| 5645 continue | 5645 continue |
| 5646 | 5646 |
| 5647 for pattern, template, header in _re_pattern_templates: | 5647 for pattern, template, header in _re_pattern_templates: |
| 5648 if pattern.search(line): | 5648 matched = pattern.search(line) |
| 5649 required[header] = (linenum, template) | 5649 if matched: |
| 5650 # Don't warn about IWYU in non-STL namespaces: |
| 5651 # (We check only the first match per line; good enough.) |
| 5652 prefix = line[:matched.start()] |
| 5653 if prefix.endswith('std::') or not prefix.endswith('::'): |
| 5654 required[header] = (linenum, template) |
| 5650 | 5655 |
| 5651 # The policy is that if you #include something in foo.h you don't need to | 5656 # The policy is that if you #include something in foo.h you don't need to |
| 5652 # include it again in foo.cc. Here, we will look at possible includes. | 5657 # include it again in foo.cc. Here, we will look at possible includes. |
| 5653 # Let's flatten the include_state include_list and copy it into a dictionary. | 5658 # Let's flatten the include_state include_list and copy it into a dictionary. |
| 5654 include_dict = dict([item for sublist in include_state.include_list | 5659 include_dict = dict([item for sublist in include_state.include_list |
| 5655 for item in sublist]) | 5660 for item in sublist]) |
| 5656 | 5661 |
| 5657 # Did we find the header for this file (if any) and successfully load it? | 5662 # Did we find the header for this file (if any) and successfully load it? |
| 5658 header_found = False | 5663 header_found = False |
| 5659 | 5664 |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6314 _cpplint_state.ResetErrorCounts() | 6319 _cpplint_state.ResetErrorCounts() |
| 6315 for filename in filenames: | 6320 for filename in filenames: |
| 6316 ProcessFile(filename, _cpplint_state.verbose_level) | 6321 ProcessFile(filename, _cpplint_state.verbose_level) |
| 6317 _cpplint_state.PrintErrorCounts() | 6322 _cpplint_state.PrintErrorCounts() |
| 6318 | 6323 |
| 6319 sys.exit(_cpplint_state.error_count > 0) | 6324 sys.exit(_cpplint_state.error_count > 0) |
| 6320 | 6325 |
| 6321 | 6326 |
| 6322 if __name__ == '__main__': | 6327 if __name__ == '__main__': |
| 6323 main() | 6328 main() |
| OLD | NEW |