Flag those c++11 features that we only allow in certain places. Args: filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. error: The function to call with any errors found.
(filename, clean_lines, linenum, error)
| 6391 | check_fn(filename, clean_lines, line, error) |
| 6392 | |
| 6393 | def FlagCxx11Features(filename, clean_lines, linenum, error): |
| 6394 | """Flag those c++11 features that we only allow in certain places. |
| 6395 | |
| 6396 | Args: |
| 6397 | filename: The name of the current file. |
| 6398 | clean_lines: A CleansedLines instance containing the file. |
| 6399 | linenum: The number of the line to check. |
| 6400 | error: The function to call with any errors found. |
| 6401 | """ |
| 6402 | line = clean_lines.elided[linenum] |
| 6403 | |
| 6404 | include = Match(r'\s*#\s*include\s+[<"]([^<"]+)[">]', line) |
| 6405 | |
| 6406 | # Flag unapproved C++ TR1 headers. |
| 6407 | if include and include.group(1).startswith('tr1/'): |
| 6408 | error(filename, linenum, 'build/c++tr1', 5, |
| 6409 | ('C++ TR1 headers such as <%s> are unapproved.') % include.group(1)) |
| 6410 | |
| 6411 | # Flag unapproved C++11 headers. |
| 6412 | if include and include.group(1) in ('cfenv', |
| 6413 | 'condition_variable', |
| 6414 | 'fenv.h', |
| 6415 | 'future', |
| 6416 | 'thread', |
| 6417 | 'chrono', |
| 6418 | 'ratio', |
| 6419 | 'regex', |
| 6420 | 'system_error', |
| 6421 | ): |
| 6422 | error(filename, linenum, 'build/c++11', 5, |
| 6423 | ('<%s> is an unapproved C++11 header.') % include.group(1)) |
| 6424 | |
| 6425 | # The only place where we need to worry about C++11 keywords and library |
| 6426 | # features in preprocessor directives is in macro definitions. |
| 6427 | if Match(r'\s*#', line) and not Match(r'\s*#\s*define\b', line): return |
| 6428 | |
| 6429 | # These are classes and free functions. The classes are always |
| 6430 | # mentioned as std::*, but we only catch the free functions if |
| 6431 | # they're not found by ADL. They're alphabetical by header. |
| 6432 | for top_name in ( |
| 6433 | # type_traits |
| 6434 | 'alignment_of', |
| 6435 | 'aligned_union', |
| 6436 | ): |
| 6437 | if Search(r'\bstd::%s\b' % top_name, line): |
| 6438 | error(filename, linenum, 'build/c++11', 5, |
| 6439 | ('std::%s is an unapproved C++11 class or function. Send c-style ' |
| 6440 | 'an example of where it would make your code more readable, and ' |
| 6441 | 'they may let you use it.') % top_name) |
| 6442 | |
| 6443 | |
| 6444 | def FlagCxx14Features(filename, clean_lines, linenum, error): |
no test coverage detected