| @@ 5983-6032 (lines=50) @@ | ||
| 5980 | for check_fn in extra_check_functions: |
|
| 5981 | check_fn(filename, clean_lines, line, error) |
|
| 5982 | ||
| 5983 | def FlagCxx11Features(filename, clean_lines, linenum, error): |
|
| 5984 | """Flag those c++11 features that we only allow in certain places. |
|
| 5985 | ||
| 5986 | Args: |
|
| 5987 | filename: The name of the current file. |
|
| 5988 | clean_lines: A CleansedLines instance containing the file. |
|
| 5989 | linenum: The number of the line to check. |
|
| 5990 | error: The function to call with any errors found. |
|
| 5991 | """ |
|
| 5992 | line = clean_lines.elided[linenum] |
|
| 5993 | ||
| 5994 | include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) |
|
| 5995 | ||
| 5996 | # Flag unapproved C++ TR1 headers. |
|
| 5997 | if include and include.group(1).startswith('tr1/'): |
|
| 5998 | error(filename, linenum, 'build/c++tr1', 5, |
|
| 5999 | ('C++ TR1 headers such as <%s> are unapproved.') % include.group(1)) |
|
| 6000 | ||
| 6001 | # Flag unapproved C++11 headers. |
|
| 6002 | if include and include.group(1) in ('cfenv', |
|
| 6003 | 'condition_variable', |
|
| 6004 | 'fenv.h', |
|
| 6005 | 'future', |
|
| 6006 | 'mutex', |
|
| 6007 | 'thread', |
|
| 6008 | 'chrono', |
|
| 6009 | 'ratio', |
|
| 6010 | 'regex', |
|
| 6011 | 'system_error', |
|
| 6012 | ): |
|
| 6013 | error(filename, linenum, 'build/c++11', 5, |
|
| 6014 | ('<%s> is an unapproved C++11 header.') % include.group(1)) |
|
| 6015 | ||
| 6016 | # The only place where we need to worry about C++11 keywords and library |
|
| 6017 | # features in preprocessor directives is in macro definitions. |
|
| 6018 | if Match(r'\s*#', line) and not Match(r'\s*#\s*define\b', line): return |
|
| 6019 | ||
| 6020 | # These are classes and free functions. The classes are always |
|
| 6021 | # mentioned as std::*, but we only catch the free functions if |
|
| 6022 | # they're not found by ADL. They're alphabetical by header. |
|
| 6023 | for top_name in ( |
|
| 6024 | # type_traits |
|
| 6025 | 'alignment_of', |
|
| 6026 | 'aligned_union', |
|
| 6027 | ): |
|
| 6028 | if Search(r'\bstd::%s\b' % top_name, line): |
|
| 6029 | error(filename, linenum, 'build/c++11', 5, |
|
| 6030 | ('std::%s is an unapproved C++11 class or function. Send c-style ' |
|
| 6031 | 'an example of where it would make your code more readable, and ' |
|
| 6032 | 'they may let you use it.') % top_name) |
|
| 6033 | ||
| 6034 | ||
| 6035 | def FlagCxx14Features(filename, clean_lines, linenum, error): |
|
| @@ 5983-6032 (lines=50) @@ | ||
| 5980 | for check_fn in extra_check_functions: |
|
| 5981 | check_fn(filename, clean_lines, line, error) |
|
| 5982 | ||
| 5983 | def FlagCxx11Features(filename, clean_lines, linenum, error): |
|
| 5984 | """Flag those c++11 features that we only allow in certain places. |
|
| 5985 | ||
| 5986 | Args: |
|
| 5987 | filename: The name of the current file. |
|
| 5988 | clean_lines: A CleansedLines instance containing the file. |
|
| 5989 | linenum: The number of the line to check. |
|
| 5990 | error: The function to call with any errors found. |
|
| 5991 | """ |
|
| 5992 | line = clean_lines.elided[linenum] |
|
| 5993 | ||
| 5994 | include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) |
|
| 5995 | ||
| 5996 | # Flag unapproved C++ TR1 headers. |
|
| 5997 | if include and include.group(1).startswith('tr1/'): |
|
| 5998 | error(filename, linenum, 'build/c++tr1', 5, |
|
| 5999 | ('C++ TR1 headers such as <%s> are unapproved.') % include.group(1)) |
|
| 6000 | ||
| 6001 | # Flag unapproved C++11 headers. |
|
| 6002 | if include and include.group(1) in ('cfenv', |
|
| 6003 | 'condition_variable', |
|
| 6004 | 'fenv.h', |
|
| 6005 | 'future', |
|
| 6006 | 'mutex', |
|
| 6007 | 'thread', |
|
| 6008 | 'chrono', |
|
| 6009 | 'ratio', |
|
| 6010 | 'regex', |
|
| 6011 | 'system_error', |
|
| 6012 | ): |
|
| 6013 | error(filename, linenum, 'build/c++11', 5, |
|
| 6014 | ('<%s> is an unapproved C++11 header.') % include.group(1)) |
|
| 6015 | ||
| 6016 | # The only place where we need to worry about C++11 keywords and library |
|
| 6017 | # features in preprocessor directives is in macro definitions. |
|
| 6018 | if Match(r'\s*#', line) and not Match(r'\s*#\s*define\b', line): return |
|
| 6019 | ||
| 6020 | # These are classes and free functions. The classes are always |
|
| 6021 | # mentioned as std::*, but we only catch the free functions if |
|
| 6022 | # they're not found by ADL. They're alphabetical by header. |
|
| 6023 | for top_name in ( |
|
| 6024 | # type_traits |
|
| 6025 | 'alignment_of', |
|
| 6026 | 'aligned_union', |
|
| 6027 | ): |
|
| 6028 | if Search(r'\bstd::%s\b' % top_name, line): |
|
| 6029 | error(filename, linenum, 'build/c++11', 5, |
|
| 6030 | ('std::%s is an unapproved C++11 class or function. Send c-style ' |
|
| 6031 | 'an example of where it would make your code more readable, and ' |
|
| 6032 | 'they may let you use it.') % top_name) |
|
| 6033 | ||
| 6034 | ||
| 6035 | def FlagCxx14Features(filename, clean_lines, linenum, error): |
|