From 59848dad0b711856fc1bfb81748bbe944b045640 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Sat, 23 Jul 2011 20:35:19 -0700 Subject: Import cpplint.py and make target cpplint-art Imported without change from http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py Will start making local changes to cpplint.py in followup changes. Change-Id: I0fda185f4a9f96815739db8f862cf8537402bf3b --- tools/cpplint.py | 3126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 3126 insertions(+) create mode 100755 tools/cpplint.py (limited to 'tools/cpplint.py') diff --git a/tools/cpplint.py b/tools/cpplint.py new file mode 100755 index 0000000000..86154ededa --- /dev/null +++ b/tools/cpplint.py @@ -0,0 +1,3126 @@ +#!/usr/bin/python2.4 +# +# Copyright (c) 2009 Google Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Here are some issues that I've had people identify in my code during reviews, +# that I think are possible to flag automatically in a lint tool. If these were +# caught by lint, it would save time both for myself and that of my reviewers. +# Most likely, some of these are beyond the scope of the current lint framework, +# but I think it is valuable to retain these wish-list items even if they cannot +# be immediately implemented. +# +# Suggestions +# ----------- +# - Check for no 'explicit' for multi-arg ctor +# - Check for boolean assign RHS in parens +# - Check for ctor initializer-list colon position and spacing +# - Check that if there's a ctor, there should be a dtor +# - Check accessors that return non-pointer member variables are +# declared const +# - Check accessors that return non-const pointer member vars are +# *not* declared const +# - Check for using public includes for testing +# - Check for spaces between brackets in one-line inline method +# - Check for no assert() +# - Check for spaces surrounding operators +# - Check for 0 in pointer context (should be NULL) +# - Check for 0 in char context (should be '\0') +# - Check for camel-case method name conventions for methods +# that are not simple inline getters and setters +# - Check that base classes have virtual destructors +# put " // namespace" after } that closes a namespace, with +# namespace's name after 'namespace' if it is named. +# - Do not indent namespace contents +# - Avoid inlining non-trivial constructors in header files +# include base/basictypes.h if DISALLOW_EVIL_CONSTRUCTORS is used +# - Check for old-school (void) cast for call-sites of functions +# ignored return value +# - Check gUnit usage of anonymous namespace +# - Check for class declaration order (typedefs, consts, enums, +# ctor(s?), dtor, friend declarations, methods, member vars) +# + +"""Does google-lint on c++ files. + +The goal of this script is to identify places in the code that *may* +be in non-compliance with google style. It does not attempt to fix +up these problems -- the point is to educate. It does also not +attempt to find all problems, or to ensure that everything it does +find is legitimately a problem. + +In particular, we can get very confused by /* and // inside strings! +We do a small hack, which is to ignore //'s with "'s after them on the +same line, but it is far from perfect (in either direction). +""" + +import codecs +import getopt +import math # for log +import os +import re +import sre_compile +import string +import sys +import unicodedata + + +_USAGE = """ +Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] + [--counting=total|toplevel|detailed] + [file] ... + + The style guidelines this tries to follow are those in + http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml + + Every problem is given a confidence score from 1-5, with 5 meaning we are + certain of the problem, and 1 meaning it could be a legitimate construct. + This will miss some errors, and is not a substitute for a code review. + + To suppress false-positive errors of a certain category, add a + 'NOLINT(category)' comment to the line. NOLINT or NOLINT(*) + suppresses errors of all categories on that line. + + The files passed in will be linted; at least one file must be provided. + Linted extensions are .cc, .cpp, and .h. Other file types will be ignored. + + Flags: + + output=vs7 + By default, the output is formatted to ease emacs parsing. Visual Studio + compatible output (vs7) may also be used. Other formats are unsupported. + + verbose=# + Specify a number 0-5 to restrict errors to certain verbosity levels. + + filter=-x,+y,... + Specify a comma-separated list of category-filters to apply: only + error messages whose category names pass the filters will be printed. + (Category names are printed with the message and look like + "[whitespace/indent]".) Filters are evaluated left to right. + "-FOO" and "FOO" means "do not print categories that start with FOO". + "+FOO" means "do print categories that start with FOO". + + Examples: --filter=-whitespace,+whitespace/braces + --filter=whitespace,runtime/printf,+runtime/printf_format + --filter=-,+build/include_what_you_use + + To see a list of all the categories used in cpplint, pass no arg: + --filter= + + counting=total|toplevel|detailed + The total number of errors found is always printed. If + 'toplevel' is provided, then the count of errors in each of + the top-level categories like 'build' and 'whitespace' will + also be printed. If 'detailed' is provided, then a count + is provided for each category like 'build/class'. +""" + +# We categorize each error message we print. Here are the categories. +# We want an explicit list so we can list them all in cpplint --filter=. +# If you add a new error message with a new category, add it to the list +# here! cpplint_unittest.py should tell you if you forget to do this. +# \ used for clearer layout -- pylint: disable-msg=C6013 +_ERROR_CATEGORIES = [ + 'build/class', + 'build/deprecated', + 'build/endif_comment', + 'build/forward_decl', + 'build/header_guard', + 'build/include', + 'build/include_alpha', + 'build/include_order', + 'build/include_what_you_use', + 'build/namespaces', + 'build/printf_format', + 'build/storage_class', + 'legal/copyright', + 'readability/braces', + 'readability/casting', + 'readability/check', + 'readability/constructors', + 'readability/fn_size', + 'readability/function', + 'readability/multiline_comment', + 'readability/multiline_string', + 'readability/nolint', + 'readability/streams', + 'readability/todo', + 'readability/utf8', + 'runtime/arrays', + 'runtime/casting', + 'runtime/explicit', + 'runtime/int', + 'runtime/init', + 'runtime/invalid_increment', + 'runtime/member_string_references', + 'runtime/memset', + 'runtime/operator', + 'runtime/printf', + 'runtime/printf_format', + 'runtime/references', + 'runtime/rtti', + 'runtime/sizeof', + 'runtime/string', + 'runtime/threadsafe_fn', + 'runtime/virtual', + 'whitespace/blank_line', + 'whitespace/braces', + 'whitespace/comma', + 'whitespace/comments', + 'whitespace/end_of_line', + 'whitespace/ending_newline', + 'whitespace/indent', + 'whitespace/labels', + 'whitespace/line_length', + 'whitespace/newline', + 'whitespace/operators', + 'whitespace/parens', + 'whitespace/semicolon', + 'whitespace/tab', + 'whitespace/todo' + ] + +# The default state of the category filter. This is overrided by the --filter= +# flag. By default all errors are on, so only add here categories that should be +# off by default (i.e., categories that must be enabled by the --filter= flags). +# All entries here should start with a '-' or '+', as in the --filter= flag. +_DEFAULT_FILTERS = [ '-build/include_alpha' ] + +# We used to check for high-bit characters, but after much discussion we +# decided those were OK, as long as they were in UTF-8 and didn't represent +# hard-coded international strings, which belong in a seperate i18n file. + +# Headers that we consider STL headers. +_STL_HEADERS = frozenset([ + 'algobase.h', 'algorithm', 'alloc.h', 'bitset', 'deque', 'exception', + 'function.h', 'functional', 'hash_map', 'hash_map.h', 'hash_set', + 'hash_set.h', 'iterator', 'list', 'list.h', 'map', 'memory', 'new', + 'pair.h', 'pthread_alloc', 'queue', 'set', 'set.h', 'sstream', 'stack', + 'stl_alloc.h', 'stl_relops.h', 'type_traits.h', + 'utility', 'vector', 'vector.h', + ]) + + +# Non-STL C++ system headers. +_CPP_HEADERS = frozenset([ + 'algo.h', 'builtinbuf.h', 'bvector.h', 'cassert', 'cctype', + 'cerrno', 'cfloat', 'ciso646', 'climits', 'clocale', 'cmath', + 'complex', 'complex.h', 'csetjmp', 'csignal', 'cstdarg', 'cstddef', + 'cstdio', 'cstdlib', 'cstring', 'ctime', 'cwchar', 'cwctype', + 'defalloc.h', 'deque.h', 'editbuf.h', 'exception', 'fstream', + 'fstream.h', 'hashtable.h', 'heap.h', 'indstream.h', 'iomanip', + 'iomanip.h', 'ios', 'iosfwd', 'iostream', 'iostream.h', 'istream.h', + 'iterator.h', 'limits', 'map.h', 'multimap.h', 'multiset.h', + 'numeric', 'ostream.h', 'parsestream.h', 'pfstream.h', 'PlotFile.h', + 'procbuf.h', 'pthread_alloc.h', 'rope', 'rope.h', 'ropeimpl.h', + 'SFile.h', 'slist', 'slist.h', 'stack.h', 'stdexcept', + 'stdiostream.h', 'streambuf.h', 'stream.h', 'strfile.h', 'string', + 'strstream', 'strstream.h', 'tempbuf.h', 'tree.h', 'typeinfo', 'valarray', + ]) + + +# Assertion macros. These are defined in base/logging.h and +# testing/base/gunit.h. Note that the _M versions need to come first +# for substring matching to work. +_CHECK_MACROS = [ + 'DCHECK', 'CHECK', + 'EXPECT_TRUE_M', 'EXPECT_TRUE', + 'ASSERT_TRUE_M', 'ASSERT_TRUE', + 'EXPECT_FALSE_M', 'EXPECT_FALSE', + 'ASSERT_FALSE_M', 'ASSERT_FALSE', + ] + +# Replacement macros for CHECK/DCHECK/EXPECT_TRUE/EXPECT_FALSE +_CHECK_REPLACEMENT = dict([(m, {}) for m in _CHECK_MACROS]) + +for op, replacement in [('==', 'EQ'), ('!=', 'NE'), + ('>=', 'GE'), ('>', 'GT'), + ('<=', 'LE'), ('<', 'LT')]: + _CHECK_REPLACEMENT['DCHECK'][op] = 'DCHECK_%s' % replacement + _CHECK_REPLACEMENT['CHECK'][op] = 'CHECK_%s' % replacement + _CHECK_REPLACEMENT['EXPECT_TRUE'][op] = 'EXPECT_%s' % replacement + _CHECK_REPLACEMENT['ASSERT_TRUE'][op] = 'ASSERT_%s' % replacement + _CHECK_REPLACEMENT['EXPECT_TRUE_M'][op] = 'EXPECT_%s_M' % replacement + _CHECK_REPLACEMENT['ASSERT_TRUE_M'][op] = 'ASSERT_%s_M' % replacement + +for op, inv_replacement in [('==', 'NE'), ('!=', 'EQ'), + ('>=', 'LT'), ('>', 'LE'), + ('<=', 'GT'), ('<', 'GE')]: + _CHECK_REPLACEMENT['EXPECT_FALSE'][op] = 'EXPECT_%s' % inv_replacement + _CHECK_REPLACEMENT['ASSERT_FALSE'][op] = 'ASSERT_%s' % inv_replacement + _CHECK_REPLACEMENT['EXPECT_FALSE_M'][op] = 'EXPECT_%s_M' % inv_replacement + _CHECK_REPLACEMENT['ASSERT_FALSE_M'][op] = 'ASSERT_%s_M' % inv_replacement + + +# These constants define types of headers for use with +# _IncludeState.CheckNextIncludeOrder(). +_C_SYS_HEADER = 1 +_CPP_SYS_HEADER = 2 +_LIKELY_MY_HEADER = 3 +_POSSIBLE_MY_HEADER = 4 +_OTHER_HEADER = 5 + + +_regexp_compile_cache = {} + +# Finds occurrences of NOLINT or NOLINT(...). +_RE_SUPPRESSION = re.compile(r'\bNOLINT\b(\([^)]*\))?') + +# {str, set(int)}: a map from error categories to sets of linenumbers +# on which those errors are expected and should be suppressed. +_error_suppressions = {} + +def ParseNolintSuppressions(filename, raw_line, linenum, error): + """Updates the global list of error-suppressions. + + Parses any NOLINT comments on the current line, updating the global + error_suppressions store. Reports an error if the NOLINT comment + was malformed. + + Args: + filename: str, the name of the input file. + raw_line: str, the line of input text, with comments. + linenum: int, the number of the current line. + error: function, an error handler. + """ + # FIXME(adonovan): "NOLINT(" is misparsed as NOLINT(*). + m = _RE_SUPPRESSION.search(raw_line) + if m: + category = m.group(1) + if category in (None, '(*)'): # => "suppress all" + _error_suppressions.setdefault(None, set()).add(linenum) + else: + if category.startswith('(') and category.endswith(')'): + category = category[1:-1] + if category in _ERROR_CATEGORIES: + _error_suppressions.setdefault(category, set()).add(linenum) + else: + error(filename, linenum, 'readability/nolint', 5, + 'Unknown NOLINT error category: %s' % category) + + +def ResetNolintSuppressions(): + "Resets the set of NOLINT suppressions to empty." + _error_suppressions.clear() + + +def IsErrorSuppressedByNolint(category, linenum): + """Returns true if the specified error category is suppressed on this line. + + Consults the global error_suppressions map populated by + ParseNolintSuppressions/ResetNolintSuppressions. + + Args: + category: str, the category of the error. + linenum: int, the current line number. + Returns: + bool, True iff the error should be suppressed due to a NOLINT comment. + """ + return (linenum in _error_suppressions.get(category, set()) or + linenum in _error_suppressions.get(None, set())) + +def Match(pattern, s): + """Matches the string with the pattern, caching the compiled regexp.""" + # The regexp compilation caching is inlined in both Match and Search for + # performance reasons; factoring it out into a separate function turns out + # to be noticeably expensive. + if not pattern in _regexp_compile_cache: + _regexp_compile_cache[pattern] = sre_compile.compile(pattern) + return _regexp_compile_cache[pattern].match(s) + + +def Search(pattern, s): + """Searches the string for the pattern, caching the compiled regexp.""" + if not pattern in _regexp_compile_cache: + _regexp_compile_cache[pattern] = sre_compile.compile(pattern) + return _regexp_compile_cache[pattern].search(s) + + +class _IncludeState(dict): + """Tracks line numbers for includes, and the order in which includes appear. + + As a dict, an _IncludeState object serves as a mapping between include + filename and line number on which that file was included. + + Call CheckNextIncludeOrder() once for each header in the file, passing + in the type constants defined above. Calls in an illegal order will + raise an _IncludeError with an appropriate error message. + + """ + # self._section will move monotonically through this set. If it ever + # needs to move backwards, CheckNextIncludeOrder will raise an error. + _INITIAL_SECTION = 0 + _MY_H_SECTION = 1 + _C_SECTION = 2 + _CPP_SECTION = 3 + _OTHER_H_SECTION = 4 + + _TYPE_NAMES = { + _C_SYS_HEADER: 'C system header', + _CPP_SYS_HEADER: 'C++ system header', + _LIKELY_MY_HEADER: 'header this file implements', + _POSSIBLE_MY_HEADER: 'header this file may implement', + _OTHER_HEADER: 'other header', + } + _SECTION_NAMES = { + _INITIAL_SECTION: "... nothing. (This can't be an error.)", + _MY_H_SECTION: 'a header this file implements', + _C_SECTION: 'C system header', + _CPP_SECTION: 'C++ system header', + _OTHER_H_SECTION: 'other header', + } + + def __init__(self): + dict.__init__(self) + # The name of the current section. + self._section = self._INITIAL_SECTION + # The path of last found header. + self._last_header = '' + + def CanonicalizeAlphabeticalOrder(self, header_path): + """Returns a path canonicalized for alphabetical comparisson. + + - replaces "-" with "_" so they both cmp the same. + - removes '-inl' since we don't require them to be after the main header. + - lowercase everything, just in case. + + Args: + header_path: Path to be canonicalized. + + Returns: + Canonicalized path. + """ + return header_path.replace('-inl.h', '.h').replace('-', '_').lower() + + def IsInAlphabeticalOrder(self, header_path): + """Check if a header is in alphabetical order with the previous header. + + Args: + header_path: Header to be checked. + + Returns: + Returns true if the header is in alphabetical order. + """ + canonical_header = self.CanonicalizeAlphabeticalOrder(header_path) + if self._last_header > canonical_header: + return False + self._last_header = canonical_header + return True + + def CheckNextIncludeOrder(self, header_type): + """Returns a non-empty error message if the next header is out of order. + + This function also updates the internal state to be ready to check + the next include. + + Args: + header_type: One of the _XXX_HEADER constants defined above. + + Returns: + The empty string if the header is in the right order, or an + error message describing what's wrong. + + """ + error_message = ('Found %s after %s' % + (self._TYPE_NAMES[header_type], + self._SECTION_NAMES[self._section])) + + last_section = self._section + + if header_type == _C_SYS_HEADER: + if self._section <= self._C_SECTION: + self._section = self._C_SECTION + else: + self._last_header = '' + return error_message + elif header_type == _CPP_SYS_HEADER: + if self._section <= self._CPP_SECTION: + self._section = self._CPP_SECTION + else: + self._last_header = '' + return error_message + elif header_type == _LIKELY_MY_HEADER: + if self._section <= self._MY_H_SECTION: + self._section = self._MY_H_SECTION + else: + self._section = self._OTHER_H_SECTION + elif header_type == _POSSIBLE_MY_HEADER: + if self._section <= self._MY_H_SECTION: + self._section = self._MY_H_SECTION + else: + # This will always be the fallback because we're not sure + # enough that the header is associated with this file. + self._section = self._OTHER_H_SECTION + else: + assert header_type == _OTHER_HEADER + self._section = self._OTHER_H_SECTION + + if last_section != self._section: + self._last_header = '' + + return '' + + +class _CppLintState(object): + """Maintains module-wide state..""" + + def __init__(self): + self.verbose_level = 1 # global setting. + self.error_count = 0 # global count of reported errors + # filters to apply when emitting error messages + self.filters = _DEFAULT_FILTERS[:] + self.counting = 'total' # In what way are we counting errors? + self.errors_by_category = {} # string to int dict storing error counts + + # output format: + # "emacs" - format that emacs can parse (default) + # "vs7" - format that Microsoft Visual Studio 7 can parse + self.output_format = 'emacs' + + def SetOutputFormat(self, output_format): + """Sets the output format for errors.""" + self.output_format = output_format + + def SetVerboseLevel(self, level): + """Sets the module's verbosity, and returns the previous setting.""" + last_verbose_level = self.verbose_level + self.verbose_level = level + return last_verbose_level + + def SetCountingStyle(self, counting_style): + """Sets the module's counting options.""" + self.counting = counting_style + + def SetFilters(self, filters): + """Sets the error-message filters. + + These filters are applied when deciding whether to emit a given + error message. + + Args: + filters: A string of comma-separated filters (eg "+whitespace/indent"). + Each filter should start with + or -; else we die. + + Raises: + ValueError: The comma-separated filters did not all start with '+' or '-'. + E.g. "-,+whitespace,-whitespace/indent,whitespace/badfilter" + """ + # Default filters always have less priority than the flag ones. + self.filters = _DEFAULT_FILTERS[:] + for filt in filters.split(','): + clean_filt = filt.strip() + if clean_filt: + self.filters.append(clean_filt) + for filt in self.filters: + if not (filt.startswith('+') or filt.startswith('-')): + raise ValueError('Every filter in --filters must start with + or -' + ' (%s does not)' % filt) + + def ResetErrorCounts(self): + """Sets the module's error statistic back to zero.""" + self.error_count = 0 + self.errors_by_category = {} + + def IncrementErrorCount(self, category): + """Bumps the module's error statistic.""" + self.error_count += 1 + if self.counting in ('toplevel', 'detailed'): + if self.counting != 'detailed': + category = category.split('/')[0] + if category not in self.errors_by_category: + self.errors_by_category[category] = 0 + self.errors_by_category[category] += 1 + + def PrintErrorCounts(self): + """Print a summary of errors by category, and the total.""" + for category, count in self.errors_by_category.iteritems(): + sys.stderr.write('Category \'%s\' errors found: %d\n' % + (category, count)) + sys.stderr.write('Total errors found: %d\n' % self.error_count) + +_cpplint_state = _CppLintState() + + +def _OutputFormat(): + """Gets the module's output format.""" + return _cpplint_state.output_format + + +def _SetOutputFormat(output_format): + """Sets the module's output format.""" + _cpplint_state.SetOutputFormat(output_format) + + +def _VerboseLevel(): + """Returns the module's verbosity setting.""" + return _cpplint_state.verbose_level + + +def _SetVerboseLevel(level): + """Sets the module's verbosity, and returns the previous setting.""" + return _cpplint_state.SetVerboseLevel(level) + + +def _SetCountingStyle(level): + """Sets the module's counting options.""" + _cpplint_state.SetCountingStyle(level) + + +def _Filters(): + """Returns the module's list of output filters, as a list.""" + return _cpplint_state.filters + + +def _SetFilters(filters): + """Sets the module's error-message filters. + + These filters are applied when deciding whether to emit a given + error message. + + Args: + filters: A string of comma-separated filters (eg "whitespace/indent"). + Each filter should start with + or -; else we die. + """ + _cpplint_state.SetFilters(filters) + + +class _FunctionState(object): + """Tracks current function name and the number of lines in its body.""" + + _NORMAL_TRIGGER = 250 # for --v=0, 500 for --v=1, etc. + _TEST_TRIGGER = 400 # about 50% more than _NORMAL_TRIGGER. + + def __init__(self): + self.in_a_function = False + self.lines_in_function = 0 + self.current_function = '' + + def Begin(self, function_name): + """Start analyzing function body. + + Args: + function_name: The name of the function being tracked. + """ + self.in_a_function = True + self.lines_in_function = 0 + self.current_function = function_name + + def Count(self): + """Count line in current function body.""" + if self.in_a_function: + self.lines_in_function += 1 + + def Check(self, error, filename, linenum): + """Report if too many lines in function body. + + Args: + error: The function to call with any errors found. + filename: The name of the current file. + linenum: The number of the line to check. + """ + if Match(r'T(EST|est)', self.current_function): + base_trigger = self._TEST_TRIGGER + else: + base_trigger = self._NORMAL_TRIGGER + trigger = base_trigger * 2**_VerboseLevel() + + if self.lines_in_function > trigger: + error_level = int(math.log(self.lines_in_function / base_trigger, 2)) + # 50 => 0, 100 => 1, 200 => 2, 400 => 3, 800 => 4, 1600 => 5, ... + if error_level > 5: + error_level = 5 + error(filename, linenum, 'readability/fn_size', error_level, + 'Small and focused functions are preferred:' + ' %s has %d non-comment lines' + ' (error triggered by exceeding %d lines).' % ( + self.current_function, self.lines_in_function, trigger)) + + def End(self): + """Stop analizing function body.""" + self.in_a_function = False + + +class _IncludeError(Exception): + """Indicates a problem with the include order in a file.""" + pass + + +class FileInfo: + """Provides utility functions for filenames. + + FileInfo provides easy access to the components of a file's path + relative to the project root. + """ + + def __init__(self, filename): + self._filename = filename + + def FullName(self): + """Make Windows paths like Unix.""" + return os.path.abspath(self._filename).replace('\\', '/') + + def RepositoryName(self): + """FullName after removing the local path to the repository. + + If we have a real absolute path name here we can try to do something smart: + detecting the root of the checkout and truncating /path/to/checkout from + the name so that we get header guards that don't include things like + "C:\Documents and Settings\..." or "/home/username/..." in them and thus + people on different computers who have checked the source out to different + locations won't see bogus errors. + """ + fullname = self.FullName() + + if os.path.exists(fullname): + project_dir = os.path.dirname(fullname) + + if os.path.exists(os.path.join(project_dir, ".svn")): + # If there's a .svn file in the current directory, we recursively look + # up the directory tree for the top of the SVN checkout + root_dir = project_dir + one_up_dir = os.path.dirname(root_dir) + while os.path.exists(os.path.join(one_up_dir, ".svn")): + root_dir = os.path.dirname(root_dir) + one_up_dir = os.path.dirname(one_up_dir) + + prefix = os.path.commonprefix([root_dir, project_dir]) + return fullname[len(prefix) + 1:] + + # Not SVN? Try to find a git or hg top level directory by searching up + # from the current path. + root_dir = os.path.dirname(fullname) + while (root_dir != os.path.dirname(root_dir) and + not os.path.exists(os.path.join(root_dir, ".git")) and + not os.path.exists(os.path.join(root_dir, ".hg"))): + root_dir = os.path.dirname(root_dir) + + if (os.path.exists(os.path.join(root_dir, ".git")) or + os.path.exists(os.path.join(root_dir, ".hg"))): + prefix = os.path.commonprefix([root_dir, project_dir]) + return fullname[len(prefix) + 1:] + + # Don't know what to do; header guard warnings may be wrong... + return fullname + + def Split(self): + """Splits the file into the directory, basename, and extension. + + For 'chrome/browser/browser.cc', Split() would + return ('chrome/browser', 'browser', '.cc') + + Returns: + A tuple of (directory, basename, extension). + """ + + googlename = self.RepositoryName() + project, rest = os.path.split(googlename) + return (project,) + os.path.splitext(rest) + + def BaseName(self): + """File base name - text after the final slash, before the final period.""" + return self.Split()[1] + + def Extension(self): + """File extension - text following the final period.""" + return self.Split()[2] + + def NoExtension(self): + """File has no source file extension.""" + return '/'.join(self.Split()[0:2]) + + def IsSource(self): + """File has a source file extension.""" + return self.Extension()[1:] in ('c', 'cc', 'cpp', 'cxx') + + +def _ShouldPrintError(category, confidence, linenum): + """Returns true iff confidence >= verbose, category passes + filter and is not NOLINT-suppressed.""" + + # There are three ways we might decide not to print an error message: + # a "NOLINT(category)" comment appears in the source, + # the verbosity level isn't high enough, or the filters filter it out. + if IsErrorSuppressedByNolint(category, linenum): + return False + if confidence < _cpplint_state.verbose_level: + return False + + is_filtered = False + for one_filter in _Filters(): + if one_filter.startswith('-'): + if category.startswith(one_filter[1:]): + is_filtered = True + elif one_filter.startswith('+'): + if category.startswith(one_filter[1:]): + is_filtered = False + else: + assert False # should have been checked for in SetFilter. + if is_filtered: + return False + + return True + + +def Error(filename, linenum, category, confidence, message): + """Logs the fact we've found a lint error. + + We log where the error was found, and also our confidence in the error, + that is, how certain we are this is a legitimate style regression, and + not a misidentification or a use that's sometimes justified. + + False positives can be suppressed by the use of + "cpplint(category)" comments on the offending line. These are + parsed into _error_suppressions. + + Args: + filename: The name of the file containing the error. + linenum: The number of the line containing the error. + category: A string used to describe the "category" this bug + falls under: "whitespace", say, or "runtime". Categories + may have a hierarchy separated by slashes: "whitespace/indent". + confidence: A number from 1-5 representing a confidence score for + the error, with 5 meaning that we are certain of the problem, + and 1 meaning that it could be a legitimate construct. + message: The error message. + """ + if _ShouldPrintError(category, confidence, linenum): + _cpplint_state.IncrementErrorCount(category) + if _cpplint_state.output_format == 'vs7': + sys.stderr.write('%s(%s): %s [%s] [%d]\n' % ( + filename, linenum, message, category, confidence)) + else: + sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( + filename, linenum, message, category, confidence)) + + +# Matches standard C++ escape esequences per 2.13.2.3 of the C++ standard. +_RE_PATTERN_CLEANSE_LINE_ESCAPES = re.compile( + r'\\([abfnrtv?"\\\']|\d+|x[0-9a-fA-F]+)') +# Matches strings. Escape codes should already be removed by ESCAPES. +_RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES = re.compile(r'"[^"]*"') +# Matches characters. Escape codes should already be removed by ESCAPES. +_RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES = re.compile(r"'.'") +# Matches multi-line C++ comments. +# This RE is a little bit more complicated than one might expect, because we +# have to take care of space removals tools so we can handle comments inside +# statements better. +# The current rule is: We only clear spaces from both sides when we're at the +# end of the line. Otherwise, we try to remove spaces from the right side, +# if this doesn't work we try on left side but only if there's a non-character +# on the right. +_RE_PATTERN_CLEANSE_LINE_C_COMMENTS = re.compile( + r"""(\s*/\*.*\*/\s*$| + /\*.*\*/\s+| + \s+/\*.*\*/(?=\W)| + /\*.*\*/)""", re.VERBOSE) + + +def IsCppString(line): + """Does line terminate so, that the next symbol is in string constant. + + This function does not consider single-line nor multi-line comments. + + Args: + line: is a partial line of code starting from the 0..n. + + Returns: + True, if next character appended to 'line' is inside a + string constant. + """ + + line = line.replace(r'\\', 'XX') # after this, \\" does not match to \" + return ((line.count('"') - line.count(r'\"') - line.count("'\"'")) & 1) == 1 + + +def FindNextMultiLineCommentStart(lines, lineix): + """Find the beginning marker for a multiline comment.""" + while lineix < len(lines): + if lines[lineix].strip().startswith('/*'): + # Only return this marker if the comment goes beyond this line + if lines[lineix].strip().find('*/', 2) < 0: + return lineix + lineix += 1 + return len(lines) + + +def FindNextMultiLineCommentEnd(lines, lineix): + """We are inside a comment, find the end marker.""" + while lineix < len(lines): + if lines[lineix].strip().endswith('*/'): + return lineix + lineix += 1 + return len(lines) + + +def RemoveMultiLineCommentsFromRange(lines, begin, end): + """Clears a range of lines for multi-line comments.""" + # Having // dummy comments makes the lines non-empty, so we will not get + # unnecessary blank line warnings later in the code. + for i in range(begin, end): + lines[i] = '// dummy' + + +def RemoveMultiLineComments(filename, lines, error): + """Removes multiline (c-style) comments from lines.""" + lineix = 0 + while lineix < len(lines): + lineix_begin = FindNextMultiLineCommentStart(lines, lineix) + if lineix_begin >= len(lines): + return + lineix_end = FindNextMultiLineCommentEnd(lines, lineix_begin) + if lineix_end >= len(lines): + error(filename, lineix_begin + 1, 'readability/multiline_comment', 5, + 'Could not find end of multi-line comment') + return + RemoveMultiLineCommentsFromRange(lines, lineix_begin, lineix_end + 1) + lineix = lineix_end + 1 + + +def CleanseComments(line): + """Removes //-comments and single-line C-style /* */ comments. + + Args: + line: A line of C++ source. + + Returns: + The line with single-line comments removed. + """ + commentpos = line.find('//') + if commentpos != -1 and not IsCppString(line[:commentpos]): + line = line[:commentpos] + # get rid of /* ... */ + return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) + + +class CleansedLines(object): + """Holds 3 copies of all lines with different preprocessing applied to them. + + 1) elided member contains lines without strings and comments, + 2) lines member contains lines without comments, and + 3) raw member contains all the lines without processing. + All these three members are of , and of the same length. + """ + + def __init__(self, lines): + self.elided = [] + self.lines = [] + self.raw_lines = lines + self.num_lines = len(lines) + for linenum in range(len(lines)): + self.lines.append(CleanseComments(lines[linenum])) + elided = self._CollapseStrings(lines[linenum]) + self.elided.append(CleanseComments(elided)) + + def NumLines(self): + """Returns the number of lines represented.""" + return self.num_lines + + @staticmethod + def _CollapseStrings(elided): + """Collapses strings and chars on a line to simple "" or '' blocks. + + We nix strings first so we're not fooled by text like '"http://"' + + Args: + elided: The line being processed. + + Returns: + The line with collapsed strings. + """ + if not _RE_PATTERN_INCLUDE.match(elided): + # Remove escaped characters first to make quote/single quote collapsing + # basic. Things that look like escaped characters shouldn't occur + # outside of strings and chars. + elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided) + elided = _RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES.sub("''", elided) + elided = _RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES.sub('""', elided) + return elided + + +def CloseExpression(clean_lines, linenum, pos): + """If input points to ( or { or [, finds the position that closes it. + + If lines[linenum][pos] points to a '(' or '{' or '[', finds the the + linenum/pos that correspond to the closing of the expression. + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + pos: A position on the line. + + Returns: + A tuple (line, linenum, pos) pointer *past* the closing brace, or + (line, len(lines), -1) if we never find a close. Note we ignore + strings and comments when matching; and the line we return is the + 'cleansed' line at linenum. + """ + + line = clean_lines.elided[linenum] + startchar = line[pos] + if startchar not in '({[': + return (line, clean_lines.NumLines(), -1) + if startchar == '(': endchar = ')' + if startchar == '[': endchar = ']' + if startchar == '{': endchar = '}' + + num_open = line.count(startchar) - line.count(endchar) + while linenum < clean_lines.NumLines() and num_open > 0: + linenum += 1 + line = clean_lines.elided[linenum] + num_open += line.count(startchar) - line.count(endchar) + # OK, now find the endchar that actually got us back to even + endpos = len(line) + while num_open >= 0: + endpos = line.rfind(')', 0, endpos) + num_open -= 1 # chopped off another ) + return (line, linenum, endpos + 1) + + +def CheckForCopyright(filename, lines, error): + """Logs an error if no Copyright message appears at the top of the file.""" + + # We'll say it should occur by line 10. Don't forget there's a + # dummy line at the front. + for line in xrange(1, min(len(lines), 11)): + if re.search(r'Copyright', lines[line], re.I): break + else: # means no copyright line was found + error(filename, 0, 'legal/copyright', 5, + 'No copyright message found. ' + 'You should have a line: "Copyright [year] "') + + +def GetHeaderGuardCPPVariable(filename): + """Returns the CPP variable that should be used as a header guard. + + Args: + filename: The name of a C++ header file. + + Returns: + The CPP variable that should be used as a header guard in the + named file. + + """ + + # Restores original filename in case that cpplint is invoked from Emacs's + # flymake. + filename = re.sub(r'_flymake\.h$', '.h', filename) + + fileinfo = FileInfo(filename) + return re.sub(r'[-./\s]', '_', fileinfo.RepositoryName()).upper() + '_' + + +def CheckForHeaderGuard(filename, lines, error): + """Checks that the file contains a header guard. + + Logs an error if no #ifndef header guard is present. For other + headers, checks that the full pathname is used. + + Args: + filename: The name of the C++ header file. + lines: An array of strings, each representing a line of the file. + error: The function to call with any errors found. + """ + + cppvar = GetHeaderGuardCPPVariable(filename) + + ifndef = None + ifndef_linenum = 0 + define = None + endif = None + endif_linenum = 0 + for linenum, line in enumerate(lines): + linesplit = line.split() + if len(linesplit) >= 2: + # find the first occurrence of #ifndef and #define, save arg + if not ifndef and linesplit[0] == '#ifndef': + # set ifndef to the header guard presented on the #ifndef line. + ifndef = linesplit[1] + ifndef_linenum = linenum + if not define and linesplit[0] == '#define': + define = linesplit[1] + # find the last occurrence of #endif, save entire line + if line.startswith('#endif'): + endif = line + endif_linenum = linenum + + if not ifndef or not define or ifndef != define: + error(filename, 0, 'build/header_guard', 5, + 'No #ifndef header guard found, suggested CPP variable is: %s' % + cppvar) + return + + # The guard should be PATH_FILE_H_, but we also allow PATH_FILE_H__ + # for backward compatibility. + if ifndef != cppvar: + error_level = 0 + if ifndef != cppvar + '_': + error_level = 5 + + ParseNolintSuppressions(filename, lines[ifndef_linenum], ifndef_linenum, + error) + error(filename, ifndef_linenum, 'build/header_guard', error_level, + '#ifndef header guard has wrong style, please use: %s' % cppvar) + + if endif != ('#endif // %s' % cppvar): + error_level = 0 + if endif != ('#endif // %s' % (cppvar + '_')): + error_level = 5 + + ParseNolintSuppressions(filename, lines[endif_linenum], endif_linenum, + error) + error(filename, endif_linenum, 'build/header_guard', error_level, + '#endif line should be "#endif // %s"' % cppvar) + + +def CheckForUnicodeReplacementCharacters(filename, lines, error): + """Logs an error for each line containing Unicode replacement characters. + + These indicate that either the file contained invalid UTF-8 (likely) + or Unicode replacement characters (which it shouldn't). Note that + it's possible for this to throw off line numbering if the invalid + UTF-8 occurred adjacent to a newline. + + Args: + filename: The name of the current file. + lines: An array of strings, each representing a line of the file. + error: The function to call with any errors found. + """ + for linenum, line in enumerate(lines): + if u'\ufffd' in line: + error(filename, linenum, 'readability/utf8', 5, + 'Line contains invalid UTF-8 (or Unicode replacement character).') + + +def CheckForNewlineAtEOF(filename, lines, error): + """Logs an error if there is no newline char at the end of the file. + + Args: + filename: The name of the current file. + lines: An array of strings, each representing a line of the file. + error: The function to call with any errors found. + """ + + # The array lines() was created by adding two newlines to the + # original file (go figure), then splitting on \n. + # To verify that the file ends in \n, we just have to make sure the + # last-but-two element of lines() exists and is empty. + if len(lines) < 3 or lines[-2]: + error(filename, len(lines) - 2, 'whitespace/ending_newline', 5, + 'Could not find a newline character at the end of the file.') + + +def CheckForMultilineCommentsAndStrings(filename, clean_lines, linenum, error): + """Logs an error if we see /* ... */ or "..." that extend past one line. + + /* ... */ comments are legit inside macros, for one line. + Otherwise, we prefer // comments, so it's ok to warn about the + other. Likewise, it's ok for strings to extend across multiple + lines, as long as a line continuation character (backslash) + terminates each line. Although not currently prohibited by the C++ + style guide, it's ugly and unnecessary. We don't do well with either + in this lint program, so we warn about both. + + 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. + """ + line = clean_lines.elided[linenum] + + # Remove all \\ (escaped backslashes) from the line. They are OK, and the + # second (escaped) slash may trigger later \" detection erroneously. + line = line.replace('\\\\', '') + + if line.count('/*') > line.count('*/'): + error(filename, linenum, 'readability/multiline_comment', 5, + 'Complex multi-line /*...*/-style comment found. ' + 'Lint may give bogus warnings. ' + 'Consider replacing these with //-style comments, ' + 'with #if 0...#endif, ' + 'or with more clearly structured multi-line comments.') + + if (line.count('"') - line.count('\\"')) % 2: + error(filename, linenum, 'readability/multiline_string', 5, + 'Multi-line string ("...") found. This lint script doesn\'t ' + 'do well with such strings, and may give bogus warnings. They\'re ' + 'ugly and unnecessary, and you should use concatenation instead".') + + +threading_list = ( + ('asctime(', 'asctime_r('), + ('ctime(', 'ctime_r('), + ('getgrgid(', 'getgrgid_r('), + ('getgrnam(', 'getgrnam_r('), + ('getlogin(', 'getlogin_r('), + ('getpwnam(', 'getpwnam_r('), + ('getpwuid(', 'getpwuid_r('), + ('gmtime(', 'gmtime_r('), + ('localtime(', 'localtime_r('), + ('rand(', 'rand_r('), + ('readdir(', 'readdir_r('), + ('strtok(', 'strtok_r('), + ('ttyname(', 'ttyname_r('), + ) + + +def CheckPosixThreading(filename, clean_lines, linenum, error): + """Checks for calls to thread-unsafe functions. + + Much code has been originally written without consideration of + multi-threading. Also, engineers are relying on their old experience; + they have learned posix before threading extensions were added. These + tests guide the engineers to use thread-safe functions (when using + posix directly). + + 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. + """ + line = clean_lines.elided[linenum] + for single_thread_function, multithread_safe_function in threading_list: + ix = line.find(single_thread_function) + # Comparisons made explicit for clarity -- pylint: disable-msg=C6403 + if ix >= 0 and (ix == 0 or (not line[ix - 1].isalnum() and + line[ix - 1] not in ('_', '.', '>'))): + error(filename, linenum, 'runtime/threadsafe_fn', 2, + 'Consider using ' + multithread_safe_function + + '...) instead of ' + single_thread_function + + '...) for improved thread safety.') + + +# Matches invalid increment: *count++, which moves pointer instead of +# incrementing a value. +_RE_PATTERN_INVALID_INCREMENT = re.compile( + r'^\s*\*\w+(\+\+|--);') + + +def CheckInvalidIncrement(filename, clean_lines, linenum, error): + """Checks for invalid increment *count++. + + For example following function: + void increment_counter(int* count) { + *count++; + } + is invalid, because it effectively does count++, moving pointer, and should + be replaced with ++*count, (*count)++ or *count += 1. + + 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. + """ + line = clean_lines.elided[linenum] + if _RE_PATTERN_INVALID_INCREMENT.match(line): + error(filename, linenum, 'runtime/invalid_increment', 5, + 'Changing pointer instead of value (or unused value of operator*).') + + +class _ClassInfo(object): + """Stores information about a class.""" + + def __init__(self, name, linenum): + self.name = name + self.linenum = linenum + self.seen_open_brace = False + self.is_derived = False + self.virtual_method_linenumber = None + self.has_virtual_destructor = False + self.brace_depth = 0 + + +class _ClassState(object): + """Holds the current state of the parse relating to class declarations. + + It maintains a stack of _ClassInfos representing the parser's guess + as to the current nesting of class declarations. The innermost class + is at the top (back) of the stack. Typically, the stack will either + be empty or have exactly one entry. + """ + + def __init__(self): + self.classinfo_stack = [] + + def CheckFinished(self, filename, error): + """Checks that all classes have been completely parsed. + + Call this when all lines in a file have been processed. + Args: + filename: The name of the current file. + error: The function to call with any errors found. + """ + if self.classinfo_stack: + # Note: This test can result in false positives if #ifdef constructs + # get in the way of brace matching. See the testBuildClass test in + # cpplint_unittest.py for an example of this. + error(filename, self.classinfo_stack[0].linenum, 'build/class', 5, + 'Failed to find complete declaration of class %s' % + self.classinfo_stack[0].name) + + +def CheckForNonStandardConstructs(filename, clean_lines, linenum, + class_state, error): + """Logs an error if we see certain non-ANSI constructs ignored by gcc-2. + + Complain about several constructs which gcc-2 accepts, but which are + not standard C++. Warning about these in lint is one way to ease the + transition to new compilers. + - put storage class first (e.g. "static const" instead of "const static"). + - "%lld" instead of %qd" in printf-type functions. + - "%1$d" is non-standard in printf-type functions. + - "\%" is an undefined character escape sequence. + - text after #endif is not allowed. + - invalid inner-style forward declaration. + - >? and ?= and )\?=?\s*(\w+|[+-]?\d+)(\.\d*)?', + line): + error(filename, linenum, 'build/deprecated', 3, + '>? and ))?' + # r'\s*const\s*' + type_name + '\s*&\s*\w+\s*;' + error(filename, linenum, 'runtime/member_string_references', 2, + 'const string& members are dangerous. It is much better to use ' + 'alternatives, such as pointers or simple constants.') + + # Track class entry and exit, and attempt to find cases within the + # class declaration that don't meet the C++ style + # guidelines. Tracking is very dependent on the code matching Google + # style guidelines, but it seems to perform well enough in testing + # to be a worthwhile addition to the checks. + classinfo_stack = class_state.classinfo_stack + # Look for a class declaration + class_decl_match = Match( + r'\s*(template\s*<[\w\s<>,:]*>\s*)?(class|struct)\s+(\w+(::\w+)*)', line) + if class_decl_match: + classinfo_stack.append(_ClassInfo(class_decl_match.group(3), linenum)) + + # Everything else in this function uses the top of the stack if it's + # not empty. + if not classinfo_stack: + return + + classinfo = classinfo_stack[-1] + + # If the opening brace hasn't been seen look for it and also + # parent class declarations. + if not classinfo.seen_open_brace: + # If the line has a ';' in it, assume it's a forward declaration or + # a single-line class declaration, which we won't process. + if line.find(';') != -1: + classinfo_stack.pop() + return + classinfo.seen_open_brace = (line.find('{') != -1) + # Look for a bare ':' + if Search('(^|[^:]):($|[^:])', line): + classinfo.is_derived = True + if not classinfo.seen_open_brace: + return # Everything else in this function is for after open brace + + # The class may have been declared with namespace or classname qualifiers. + # The constructor and destructor will not have those qualifiers. + base_classname = classinfo.name.split('::')[-1] + + # Look for single-argument constructors that aren't marked explicit. + # Technically a valid construct, but against style. + args = Match(r'(? 1: + error(filename, linenum, 'whitespace/todo', 2, + 'Too many spaces before TODO') + + username = match.group(2) + if not username: + error(filename, linenum, 'readability/todo', 2, + 'Missing username in TODO; it should look like ' + '"// TODO(my_username): Stuff."') + + middle_whitespace = match.group(3) + # Comparisons made explicit for correctness -- pylint: disable-msg=C6403 + if middle_whitespace != ' ' and middle_whitespace != '': + error(filename, linenum, 'whitespace/todo', 2, + 'TODO(my_username) should be followed by a space') + + +def CheckSpacing(filename, clean_lines, linenum, error): + """Checks for the correctness of various spacing issues in the code. + + Things we check for: spaces around operators, spaces after + if/for/while/switch, no spaces around parens in function calls, two + spaces between code and comment, don't start a block with a blank + line, don't end a function with a blank line, don't have too many + blank lines in a row. + + 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. + """ + + raw = clean_lines.raw_lines + line = raw[linenum] + + # Before nixing comments, check if the line is blank for no good + # reason. This includes the first line after a block is opened, and + # blank lines at the end of a function (ie, right before a line like '}' + if IsBlankLine(line): + elided = clean_lines.elided + prev_line = elided[linenum - 1] + prevbrace = prev_line.rfind('{') + # TODO(unknown): Don't complain if line before blank line, and line after, + # both start with alnums and are indented the same amount. + # This ignores whitespace at the start of a namespace block + # because those are not usually indented. + if (prevbrace != -1 and prev_line[prevbrace:].find('}') == -1 + and prev_line[:prevbrace].find('namespace') == -1): + # OK, we have a blank line at the start of a code block. Before we + # complain, we check if it is an exception to the rule: The previous + # non-empty line has the paramters of a function header that are indented + # 4 spaces (because they did not fit in a 80 column line when placed on + # the same line as the function name). We also check for the case where + # the previous line is indented 6 spaces, which may happen when the + # initializers of a constructor do not fit into a 80 column line. + exception = False + if Match(r' {6}\w', prev_line): # Initializer list? + # We are looking for the opening column of initializer list, which + # should be indented 4 spaces to cause 6 space indentation afterwards. + search_position = linenum-2 + while (search_position >= 0 + and Match(r' {6}\w', elided[search_position])): + search_position -= 1 + exception = (search_position >= 0 + and elided[search_position][:5] == ' :') + else: + # Search for the function arguments or an initializer list. We use a + # simple heuristic here: If the line is indented 4 spaces; and we have a + # closing paren, without the opening paren, followed by an opening brace + # or colon (for initializer lists) we assume that it is the last line of + # a function header. If we have a colon indented 4 spaces, it is an + # initializer list. + exception = (Match(r' {4}\w[^\(]*\)\s*(const\s*)?(\{\s*$|:)', + prev_line) + or Match(r' {4}:', prev_line)) + + if not exception: + error(filename, linenum, 'whitespace/blank_line', 2, + 'Blank line at the start of a code block. Is this needed?') + # This doesn't ignore whitespace at the end of a namespace block + # because that is too hard without pairing open/close braces; + # however, a special exception is made for namespace closing + # brackets which have a comment containing "namespace". + # + # Also, ignore blank lines at the end of a block in a long if-else + # chain, like this: + # if (condition1) { + # // Something followed by a blank line + # + # } else if (condition2) { + # // Something else + # } + if linenum + 1 < clean_lines.NumLines(): + next_line = raw[linenum + 1] + if (next_line + and Match(r'\s*}', next_line) + and next_line.find('namespace') == -1 + and next_line.find('} else ') == -1): + error(filename, linenum, 'whitespace/blank_line', 3, + 'Blank line at the end of a code block. Is this needed?') + + # Next, we complain if there's a comment too near the text + commentpos = line.find('//') + if commentpos != -1: + # Check if the // may be in quotes. If so, ignore it + # Comparisons made explicit for clarity -- pylint: disable-msg=C6403 + if (line.count('"', 0, commentpos) - + line.count('\\"', 0, commentpos)) % 2 == 0: # not in quotes + # Allow one space for new scopes, two spaces otherwise: + if (not Match(r'^\s*{ //', line) and + ((commentpos >= 1 and + line[commentpos-1] not in string.whitespace) or + (commentpos >= 2 and + line[commentpos-2] not in string.whitespace))): + error(filename, linenum, 'whitespace/comments', 2, + 'At least two spaces is best between code and comments') + # There should always be a space between the // and the comment + commentend = commentpos + 2 + if commentend < len(line) and not line[commentend] == ' ': + # but some lines are exceptions -- e.g. if they're big + # comment delimiters like: + # //---------------------------------------------------------- + # or are an empty C++ style Doxygen comment, like: + # /// + # or they begin with multiple slashes followed by a space: + # //////// Header comment + match = (Search(r'[=/-]{4,}\s*$', line[commentend:]) or + Search(r'^/$', line[commentend:]) or + Search(r'^/+ ', line[commentend:])) + if not match: + error(filename, linenum, 'whitespace/comments', 4, + 'Should have a space between // and comment') + CheckComment(line[commentpos:], filename, linenum, error) + + line = clean_lines.elided[linenum] # get rid of comments and strings + + # Don't try to do spacing checks for operator methods + line = re.sub(r'operator(==|!=|<|<<|<=|>=|>>|>)\(', 'operator\(', line) + + # We allow no-spaces around = within an if: "if ( (a=Foo()) == 0 )". + # Otherwise not. Note we only check for non-spaces on *both* sides; + # sometimes people put non-spaces on one side when aligning ='s among + # many lines (not that this is behavior that I approve of...) + if Search(r'[\w.]=[\w.]', line) and not Search(r'\b(if|while) ', line): + error(filename, linenum, 'whitespace/operators', 4, + 'Missing spaces around =') + + # It's ok not to have spaces around binary operators like + - * /, but if + # there's too little whitespace, we get concerned. It's hard to tell, + # though, so we punt on this one for now. TODO. + + # You should always have whitespace around binary operators. + # Alas, we can't test < or > because they're legitimately used sans spaces + # (a->b, vector a). The only time we can tell is a < with no >, and + # only if it's not template params list spilling into the next line. + match = Search(r'[^<>=!\s](==|!=|<=|>=)[^<>=!\s]', line) + if not match: + # Note that while it seems that the '<[^<]*' term in the following + # regexp could be simplified to '<.*', which would indeed match + # the same class of strings, the [^<] means that searching for the + # regexp takes linear rather than quadratic time. + if not Search(r'<[^<]*,\s*$', line): # template params spill + match = Search(r'[^<>=!\s](<)[^<>=!\s]([^>]|->)*$', line) + if match: + error(filename, linenum, 'whitespace/operators', 3, + 'Missing spaces around %s' % match.group(1)) + # We allow no-spaces around << and >> when used like this: 10<<20, but + # not otherwise (particularly, not when used as streams) + match = Search(r'[^0-9\s](<<|>>)[^0-9\s]', line) + if match: + error(filename, linenum, 'whitespace/operators', 3, + 'Missing spaces around %s' % match.group(1)) + + # There shouldn't be space around unary operators + match = Search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line) + if match: + error(filename, linenum, 'whitespace/operators', 4, + 'Extra space for operator %s' % match.group(1)) + + # A pet peeve of mine: no spaces after an if, while, switch, or for + match = Search(r' (if\(|for\(|while\(|switch\()', line) + if match: + error(filename, linenum, 'whitespace/parens', 5, + 'Missing space before ( in %s' % match.group(1)) + + # For if/for/while/switch, the left and right parens should be + # consistent about how many spaces are inside the parens, and + # there should either be zero or one spaces inside the parens. + # We don't want: "if ( foo)" or "if ( foo )". + # Exception: "for ( ; foo; bar)" and "for (foo; bar; )" are allowed. + match = Search(r'\b(if|for|while|switch)\s*' + r'\(([ ]*)(.).*[^ ]+([ ]*)\)\s*{\s*$', + line) + if match: + if len(match.group(2)) != len(match.group(4)): + if not (match.group(3) == ';' and + len(match.group(2)) == 1 + len(match.group(4)) or + not match.group(2) and Search(r'\bfor\s*\(.*; \)', line)): + error(filename, linenum, 'whitespace/parens', 5, + 'Mismatching spaces inside () in %s' % match.group(1)) + if not len(match.group(2)) in [0, 1]: + error(filename, linenum, 'whitespace/parens', 5, + 'Should have zero or one spaces inside ( and ) in %s' % + match.group(1)) + + # You should always have a space after a comma (either as fn arg or operator) + if Search(r',[^\s]', line): + error(filename, linenum, 'whitespace/comma', 3, + 'Missing space after ,') + + # Next we will look for issues with function calls. + CheckSpacingForFunctionCall(filename, line, linenum, error) + + # Except after an opening paren, you should have spaces before your braces. + # And since you should never have braces at the beginning of a line, this is + # an easy test. + if Search(r'[^ (]{', line): + error(filename, linenum, 'whitespace/braces', 5, + 'Missing space before {') + + # Make sure '} else {' has spaces. + if Search(r'}else', line): + error(filename, linenum, 'whitespace/braces', 5, + 'Missing space before else') + + # You shouldn't have spaces before your brackets, except maybe after + # 'delete []' or 'new char * []'. + if Search(r'\w\s+\[', line) and not Search(r'delete\s+\[', line): + error(filename, linenum, 'whitespace/braces', 5, + 'Extra space before [') + + # You shouldn't have a space before a semicolon at the end of the line. + # There's a special case for "for" since the style guide allows space before + # the semicolon there. + if Search(r':\s*;\s*$', line): + error(filename, linenum, 'whitespace/semicolon', 5, + 'Semicolon defining empty statement. Use { } instead.') + elif Search(r'^\s*;\s*$', line): + error(filename, linenum, 'whitespace/semicolon', 5, + 'Line contains only semicolon. If this should be an empty statement, ' + 'use { } instead.') + elif (Search(r'\s+;\s*$', line) and + not Search(r'\bfor\b', line)): + error(filename, linenum, 'whitespace/semicolon', 5, + 'Extra space before last semicolon. If this should be an empty ' + 'statement, use { } instead.') + + +def GetPreviousNonBlankLine(clean_lines, linenum): + """Return the most recent non-blank line and its line number. + + Args: + clean_lines: A CleansedLines instance containing the file contents. + linenum: The number of the line to check. + + Returns: + A tuple with two elements. The first element is the contents of the last + non-blank line before the current line, or the empty string if this is the + first non-blank line. The second is the line number of that line, or -1 + if this is the first non-blank line. + """ + + prevlinenum = linenum - 1 + while prevlinenum >= 0: + prevline = clean_lines.elided[prevlinenum] + if not IsBlankLine(prevline): # if not a blank line... + return (prevline, prevlinenum) + prevlinenum -= 1 + return ('', -1) + + +def CheckBraces(filename, clean_lines, linenum, error): + """Looks for misplaced braces (e.g. at the end of line). + + 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. + """ + + line = clean_lines.elided[linenum] # get rid of comments and strings + + if Match(r'\s*{\s*$', line): + # We allow an open brace to start a line in the case where someone + # is using braces in a block to explicitly create a new scope, + # which is commonly used to control the lifetime of + # stack-allocated variables. We don't detect this perfectly: we + # just don't complain if the last non-whitespace character on the + # previous non-blank line is ';', ':', '{', or '}'. + prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] + if not Search(r'[;:}{]\s*$', prevline): + error(filename, linenum, 'whitespace/braces', 4, + '{ should almost always be at the end of the previous line') + + # An else clause should be on the same line as the preceding closing brace. + if Match(r'\s*else\s*', line): + prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] + if Match(r'\s*}\s*$', prevline): + error(filename, linenum, 'whitespace/newline', 4, + 'An else should appear on the same line as the preceding }') + + # If braces come on one side of an else, they should be on both. + # However, we have to worry about "else if" that spans multiple lines! + if Search(r'}\s*else[^{]*$', line) or Match(r'[^}]*else\s*{', line): + if Search(r'}\s*else if([^{]*)$', line): # could be multi-line if + # find the ( after the if + pos = line.find('else if') + pos = line.find('(', pos) + if pos > 0: + (endline, _, endpos) = CloseExpression(clean_lines, linenum, pos) + if endline[endpos:].find('{') == -1: # must be brace after if + error(filename, linenum, 'readability/braces', 5, + 'If an else has a brace on one side, it should have it on both') + else: # common case: else not followed by a multi-line if + error(filename, linenum, 'readability/braces', 5, + 'If an else has a brace on one side, it should have it on both') + + # Likewise, an else should never have the else clause on the same line + if Search(r'\belse [^\s{]', line) and not Search(r'\belse if\b', line): + error(filename, linenum, 'whitespace/newline', 4, + 'Else clause should never be on same line as else (use 2 lines)') + + # In the same way, a do/while should never be on one line + if Match(r'\s*do [^\s{]', line): + error(filename, linenum, 'whitespace/newline', 4, + 'do/while clauses should not be on a single line') + + # Braces shouldn't be followed by a ; unless they're defining a struct + # or initializing an array. + # We can't tell in general, but we can for some common cases. + prevlinenum = linenum + while True: + (prevline, prevlinenum) = GetPreviousNonBlankLine(clean_lines, prevlinenum) + if Match(r'\s+{.*}\s*;', line) and not prevline.count(';'): + line = prevline + line + else: + break + if (Search(r'{.*}\s*;', line) and + line.count('{') == line.count('}') and + not Search(r'struct|class|enum|\s*=\s*{', line)): + error(filename, linenum, 'readability/braces', 4, + "You don't need a ; after a }") + + +def ReplaceableCheck(operator, macro, line): + """Determine whether a basic CHECK can be replaced with a more specific one. + + For example suggest using CHECK_EQ instead of CHECK(a == b) and + similarly for CHECK_GE, CHECK_GT, CHECK_LE, CHECK_LT, CHECK_NE. + + Args: + operator: The C++ operator used in the CHECK. + macro: The CHECK or EXPECT macro being called. + line: The current source line. + + Returns: + True if the CHECK can be replaced with a more specific one. + """ + + # This matches decimal and hex integers, strings, and chars (in that order). + match_constant = r'([-+]?(\d+|0[xX][0-9a-fA-F]+)[lLuU]{0,3}|".*"|\'.*\')' + + # Expression to match two sides of the operator with something that + # looks like a literal, since CHECK(x == iterator) won't compile. + # This means we can't catch all the cases where a more specific + # CHECK is possible, but it's less annoying than dealing with + # extraneous warnings. + match_this = (r'\s*' + macro + r'\((\s*' + + match_constant + r'\s*' + operator + r'[^<>].*|' + r'.*[^<>]' + operator + r'\s*' + match_constant + + r'\s*\))') + + # Don't complain about CHECK(x == NULL) or similar because + # CHECK_EQ(x, NULL) won't compile (requires a cast). + # Also, don't complain about more complex boolean expressions + # involving && or || such as CHECK(a == b || c == d). + return Match(match_this, line) and not Search(r'NULL|&&|\|\|', line) + + +def CheckCheck(filename, clean_lines, linenum, error): + """Checks the use of CHECK and EXPECT macros. + + 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. + """ + + # Decide the set of replacement macros that should be suggested + raw_lines = clean_lines.raw_lines + current_macro = '' + for macro in _CHECK_MACROS: + if raw_lines[linenum].find(macro) >= 0: + current_macro = macro + break + if not current_macro: + # Don't waste time here if line doesn't contain 'CHECK' or 'EXPECT' + return + + line = clean_lines.elided[linenum] # get rid of comments and strings + + # Encourage replacing plain CHECKs with CHECK_EQ/CHECK_NE/etc. + for operator in ['==', '!=', '>=', '>', '<=', '<']: + if ReplaceableCheck(operator, current_macro, line): + error(filename, linenum, 'readability/check', 2, + 'Consider using %s instead of %s(a %s b)' % ( + _CHECK_REPLACEMENT[current_macro][operator], + current_macro, operator)) + break + + +def GetLineWidth(line): + """Determines the width of the line in column positions. + + Args: + line: A string, which may be a Unicode string. + + Returns: + The width of the line in column positions, accounting for Unicode + combining characters and wide characters. + """ + if isinstance(line, unicode): + width = 0 + for c in unicodedata.normalize('NFC', line): + if unicodedata.east_asian_width(c) in ('W', 'F'): + width += 2 + elif not unicodedata.combining(c): + width += 1 + return width + else: + return len(line) + + +def CheckStyle(filename, clean_lines, linenum, file_extension, error): + """Checks rules from the 'C++ style rules' section of cppguide.html. + + Most of these rules are hard to test (naming, comment style), but we + do what we can. In particular we check for 2-space indents, line lengths, + tab usage, spaces inside code, etc. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + file_extension: The extension (without the dot) of the filename. + error: The function to call with any errors found. + """ + + raw_lines = clean_lines.raw_lines + line = raw_lines[linenum] + + if line.find('\t') != -1: + error(filename, linenum, 'whitespace/tab', 1, + 'Tab found; better to use spaces') + + # One or three blank spaces at the beginning of the line is weird; it's + # hard to reconcile that with 2-space indents. + # NOTE: here are the conditions rob pike used for his tests. Mine aren't + # as sophisticated, but it may be worth becoming so: RLENGTH==initial_spaces + # if(RLENGTH > 20) complain = 0; + # if(match($0, " +(error|private|public|protected):")) complain = 0; + # if(match(prev, "&& *$")) complain = 0; + # if(match(prev, "\\|\\| *$")) complain = 0; + # if(match(prev, "[\",=><] *$")) complain = 0; + # if(match($0, " <<")) complain = 0; + # if(match(prev, " +for \\(")) complain = 0; + # if(prevodd && match(prevprev, " +for \\(")) complain = 0; + initial_spaces = 0 + cleansed_line = clean_lines.elided[linenum] + while initial_spaces < len(line) and line[initial_spaces] == ' ': + initial_spaces += 1 + if line and line[-1].isspace(): + error(filename, linenum, 'whitespace/end_of_line', 4, + 'Line ends in whitespace. Consider deleting these extra spaces.') + # There are certain situations we allow one space, notably for labels + elif ((initial_spaces == 1 or initial_spaces == 3) and + not Match(r'\s*\w+\s*:\s*$', cleansed_line)): + error(filename, linenum, 'whitespace/indent', 3, + 'Weird number of spaces at line-start. ' + 'Are you using a 2-space indent?') + # Labels should always be indented at least one space. + elif not initial_spaces and line[:2] != '//' and Search(r'[^:]:\s*$', + line): + error(filename, linenum, 'whitespace/labels', 4, + 'Labels should always be indented at least one space. ' + 'If this is a member-initializer list in a constructor or ' + 'the base class list in a class definition, the colon should ' + 'be on the following line.') + + + # Check if the line is a header guard. + is_header_guard = False + if file_extension == 'h': + cppvar = GetHeaderGuardCPPVariable(filename) + if (line.startswith('#ifndef %s' % cppvar) or + line.startswith('#define %s' % cppvar) or + line.startswith('#endif // %s' % cppvar)): + is_header_guard = True + # #include lines and header guards can be long, since there's no clean way to + # split them. + # + # URLs can be long too. It's possible to split these, but it makes them + # harder to cut&paste. + if (not line.startswith('#include') and not is_header_guard and + not Match(r'^\s*//.*http(s?)://\S*$', line)): + line_width = GetLineWidth(line) + if line_width > 100: + error(filename, linenum, 'whitespace/line_length', 4, + 'Lines should very rarely be longer than 100 characters') + elif line_width > 80: + error(filename, linenum, 'whitespace/line_length', 2, + 'Lines should be <= 80 characters long') + + if (cleansed_line.count(';') > 1 and + # for loops are allowed two ;'s (and may run over two lines). + cleansed_line.find('for') == -1 and + (GetPreviousNonBlankLine(clean_lines, linenum)[0].find('for') == -1 or + GetPreviousNonBlankLine(clean_lines, linenum)[0].find(';') != -1) and + # It's ok to have many commands in a switch case that fits in 1 line + not ((cleansed_line.find('case ') != -1 or + cleansed_line.find('default:') != -1) and + cleansed_line.find('break;') != -1)): + error(filename, linenum, 'whitespace/newline', 4, + 'More than one command on the same line') + + # Some more style checks + CheckBraces(filename, clean_lines, linenum, error) + CheckSpacing(filename, clean_lines, linenum, error) + CheckCheck(filename, clean_lines, linenum, error) + + +_RE_PATTERN_INCLUDE_NEW_STYLE = re.compile(r'#include +"[^/]+\.h"') +_RE_PATTERN_INCLUDE = re.compile(r'^\s*#\s*include\s*([<"])([^>"]*)[>"].*$') +# Matches the first component of a filename delimited by -s and _s. That is: +# _RE_FIRST_COMPONENT.match('foo').group(0) == 'foo' +# _RE_FIRST_COMPONENT.match('foo.cc').group(0) == 'foo' +# _RE_FIRST_COMPONENT.match('foo-bar_baz.cc').group(0) == 'foo' +# _RE_FIRST_COMPONENT.match('foo_bar-baz.cc').group(0) == 'foo' +_RE_FIRST_COMPONENT = re.compile(r'^[^-_.]+') + + +def _DropCommonSuffixes(filename): + """Drops common suffixes like _test.cc or -inl.h from filename. + + For example: + >>> _DropCommonSuffixes('foo/foo-inl.h') + 'foo/foo' + >>> _DropCommonSuffixes('foo/bar/foo.cc') + 'foo/bar/foo' + >>> _DropCommonSuffixes('foo/foo_internal.h') + 'foo/foo' + >>> _DropCommonSuffixes('foo/foo_unusualinternal.h') + 'foo/foo_unusualinternal' + + Args: + filename: The input filename. + + Returns: + The filename with the common suffix removed. + """ + for suffix in ('test.cc', 'regtest.cc', 'unittest.cc', + 'inl.h', 'impl.h', 'internal.h'): + if (filename.endswith(suffix) and len(filename) > len(suffix) and + filename[-len(suffix) - 1] in ('-', '_')): + return filename[:-len(suffix) - 1] + return os.path.splitext(filename)[0] + + +def _IsTestFilename(filename): + """Determines if the given filename has a suffix that identifies it as a test. + + Args: + filename: The input filename. + + Returns: + True if 'filename' looks like a test, False otherwise. + """ + if (filename.endswith('_test.cc') or + filename.endswith('_unittest.cc') or + filename.endswith('_regtest.cc')): + return True + else: + return False + + +def _ClassifyInclude(fileinfo, include, is_system): + """Figures out what kind of header 'include' is. + + Args: + fileinfo: The current file cpplint is running over. A FileInfo instance. + include: The path to a #included file. + is_system: True if the #include used <> rather than "". + + Returns: + One of the _XXX_HEADER constants. + + For example: + >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'stdio.h', True) + _C_SYS_HEADER + >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'string', True) + _CPP_SYS_HEADER + >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/foo.h', False) + _LIKELY_MY_HEADER + >>> _ClassifyInclude(FileInfo('foo/foo_unknown_extension.cc'), + ... 'bar/foo_other_ext.h', False) + _POSSIBLE_MY_HEADER + >>> _ClassifyInclude(FileInfo('foo/foo.cc'), 'foo/bar.h', False) + _OTHER_HEADER + """ + # This is a list of all standard c++ header files, except + # those already checked for above. + is_stl_h = include in _STL_HEADERS + is_cpp_h = is_stl_h or include in _CPP_HEADERS + + if is_system: + if is_cpp_h: + return _CPP_SYS_HEADER + else: + return _C_SYS_HEADER + + # If the target file and the include we're checking share a + # basename when we drop common extensions, and the include + # lives in . , then it's likely to be owned by the target file. + target_dir, target_base = ( + os.path.split(_DropCommonSuffixes(fileinfo.RepositoryName()))) + include_dir, include_base = os.path.split(_DropCommonSuffixes(include)) + if target_base == include_base and ( + include_dir == target_dir or + include_dir == os.path.normpath(target_dir + '/../public')): + return _LIKELY_MY_HEADER + + # If the target and include share some initial basename + # component, it's possible the target is implementing the + # include, so it's allowed to be first, but we'll never + # complain if it's not there. + target_first_component = _RE_FIRST_COMPONENT.match(target_base) + include_first_component = _RE_FIRST_COMPONENT.match(include_base) + if (target_first_component and include_first_component and + target_first_component.group(0) == + include_first_component.group(0)): + return _POSSIBLE_MY_HEADER + + return _OTHER_HEADER + + + +def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): + """Check rules that are applicable to #include lines. + + Strings on #include lines are NOT removed from elided line, to make + certain tasks easier. However, to prevent false positives, checks + applicable to #include lines in CheckLanguage must be put here. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + include_state: An _IncludeState instance in which the headers are inserted. + error: The function to call with any errors found. + """ + fileinfo = FileInfo(filename) + + line = clean_lines.lines[linenum] + + # "include" should use the new style "foo/bar.h" instead of just "bar.h" + if _RE_PATTERN_INCLUDE_NEW_STYLE.search(line): + error(filename, linenum, 'build/include', 4, + 'Include the directory when naming .h files') + + # we shouldn't include a file more than once. actually, there are a + # handful of instances where doing so is okay, but in general it's + # not. + match = _RE_PATTERN_INCLUDE.search(line) + if match: + include = match.group(2) + is_system = (match.group(1) == '<') + if include in include_state: + error(filename, linenum, 'build/include', 4, + '"%s" already included at %s:%s' % + (include, filename, include_state[include])) + else: + include_state[include] = linenum + + # We want to ensure that headers appear in the right order: + # 1) for foo.cc, foo.h (preferred location) + # 2) c system files + # 3) cpp system files + # 4) for foo.cc, foo.h (deprecated location) + # 5) other google headers + # + # We classify each include statement as one of those 5 types + # using a number of techniques. The include_state object keeps + # track of the highest type seen, and complains if we see a + # lower type after that. + error_message = include_state.CheckNextIncludeOrder( + _ClassifyInclude(fileinfo, include, is_system)) + if error_message: + error(filename, linenum, 'build/include_order', 4, + '%s. Should be: %s.h, c system, c++ system, other.' % + (error_message, fileinfo.BaseName())) + if not include_state.IsInAlphabeticalOrder(include): + error(filename, linenum, 'build/include_alpha', 4, + 'Include "%s" not in alphabetical order' % include) + + # Look for any of the stream classes that are part of standard C++. + match = _RE_PATTERN_INCLUDE.match(line) + if match: + include = match.group(2) + if Match(r'(f|ind|io|i|o|parse|pf|stdio|str|)?stream$', include): + # Many unit tests use cout, so we exempt them. + if not _IsTestFilename(filename): + error(filename, linenum, 'readability/streams', 3, + 'Streams are highly discouraged.') + +def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, + error): + """Checks rules from the 'C++ language rules' section of cppguide.html. + + Some of these rules are hard to test (function overloading, using + uint32 inappropriately), but we do the best we can. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + file_extension: The extension (without the dot) of the filename. + include_state: An _IncludeState instance in which the headers are inserted. + error: The function to call with any errors found. + """ + # If the line is empty or consists of entirely a comment, no need to + # check it. + line = clean_lines.elided[linenum] + if not line: + return + + match = _RE_PATTERN_INCLUDE.search(line) + if match: + CheckIncludeLine(filename, clean_lines, linenum, include_state, error) + return + + # Create an extended_line, which is the concatenation of the current and + # next lines, for more effective checking of code that may span more than one + # line. + if linenum + 1 < clean_lines.NumLines(): + extended_line = line + clean_lines.elided[linenum + 1] + else: + extended_line = line + + # Make Windows paths like Unix. + fullname = os.path.abspath(filename).replace('\\', '/') + + # TODO(unknown): figure out if they're using default arguments in fn proto. + + # Check for non-const references in functions. This is tricky because & + # is also used to take the address of something. We allow <> for templates, + # (ignoring whatever is between the braces) and : for classes. + # These are complicated re's. They try to capture the following: + # paren (for fn-prototype start), typename, &, varname. For the const + # version, we're willing for const to be before typename or after + # Don't check the implemention on same line. + fnline = line.split('{', 1)[0] + if (len(re.findall(r'\([^()]*\b(?:[\w:]|<[^()]*>)+(\s?&|&\s?)\w+', fnline)) > + len(re.findall(r'\([^()]*\bconst\s+(?:typename\s+)?(?:struct\s+)?' + r'(?:[\w:]|<[^()]*>)+(\s?&|&\s?)\w+', fnline)) + + len(re.findall(r'\([^()]*\b(?:[\w:]|<[^()]*>)+\s+const(\s?&|&\s?)[\w]+', + fnline))): + + # We allow non-const references in a few standard places, like functions + # called "swap()" or iostream operators like "<<" or ">>". + if not Search( + r'(swap|Swap|operator[<>][<>])\s*\(\s*(?:[\w:]|<.*>)+\s*&', + fnline): + error(filename, linenum, 'runtime/references', 2, + 'Is this a non-const reference? ' + 'If so, make const or use a pointer.') + + # Check to see if they're using an conversion function cast. + # I just try to capture the most common basic types, though there are more. + # Parameterless conversion functions, such as bool(), are allowed as they are + # probably a member operator declaration or default constructor. + match = Search( + r'(\bnew\s+)?\b' # Grab 'new' operator, if it's there + r'(int|float|double|bool|char|int32|uint32|int64|uint64)\([^)]', line) + if match: + # gMock methods are defined using some variant of MOCK_METHODx(name, type) + # where type may be float(), int(string), etc. Without context they are + # virtually indistinguishable from int(x) casts. + if (match.group(1) is None and # If new operator, then this isn't a cast + not Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line)): + error(filename, linenum, 'readability/casting', 4, + 'Using deprecated casting style. ' + 'Use static_cast<%s>(...) instead' % + match.group(2)) + + CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], + 'static_cast', + r'\((int|float|double|bool|char|u?int(16|32|64))\)', + error) + # This doesn't catch all cases. Consider (const char * const)"hello". + CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], + 'reinterpret_cast', r'\((\w+\s?\*+\s?)\)', error) + + # In addition, we look for people taking the address of a cast. This + # is dangerous -- casts can assign to temporaries, so the pointer doesn't + # point where you think. + if Search( + r'(&\([^)]+\)[\w(])|(&(static|dynamic|reinterpret)_cast\b)', line): + error(filename, linenum, 'runtime/casting', 4, + ('Are you taking an address of a cast? ' + 'This is dangerous: could be a temp var. ' + 'Take the address before doing the cast, rather than after')) + + # Check for people declaring static/global STL strings at the top level. + # This is dangerous because the C++ language does not guarantee that + # globals with constructors are initialized before the first access. + match = Match( + r'((?:|static +)(?:|const +))string +([a-zA-Z0-9_:]+)\b(.*)', + line) + # Make sure it's not a function. + # Function template specialization looks like: "string foo(...". + # Class template definitions look like: "string Foo::Method(...". + if match and not Match(r'\s*(<.*>)?(::[a-zA-Z0-9_]+)?\s*\(([^"]|$)', + match.group(3)): + error(filename, linenum, 'runtime/string', 4, + 'For a static/global string constant, use a C style string instead: ' + '"%schar %s[]".' % + (match.group(1), match.group(2))) + + # Check that we're not using RTTI outside of testing code. + if Search(r'\bdynamic_cast<', line) and not _IsTestFilename(filename): + error(filename, linenum, 'runtime/rtti', 5, + 'Do not use dynamic_cast<>. If you need to cast within a class ' + "hierarchy, use static_cast<> to upcast. Google doesn't support " + 'RTTI.') + + if Search(r'\b([A-Za-z0-9_]*_)\(\1\)', line): + error(filename, linenum, 'runtime/init', 4, + 'You seem to be initializing a member variable with itself.') + + if file_extension == 'h': + # TODO(unknown): check that 1-arg constructors are explicit. + # How to tell it's a constructor? + # (handled in CheckForNonStandardConstructs for now) + # TODO(unknown): check that classes have DISALLOW_EVIL_CONSTRUCTORS + # (level 1 error) + pass + + # Check if people are using the verboten C basic types. The only exception + # we regularly allow is "unsigned short port" for port. + if Search(r'\bshort port\b', line): + if not Search(r'\bunsigned short port\b', line): + error(filename, linenum, 'runtime/int', 4, + 'Use "unsigned short" for ports, not "short"') + else: + match = Search(r'\b(short|long(?! +double)|long long)\b', line) + if match: + error(filename, linenum, 'runtime/int', 4, + 'Use int16/int64/etc, rather than the C type %s' % match.group(1)) + + # When snprintf is used, the second argument shouldn't be a literal. + match = Search(r'snprintf\s*\(([^,]*),\s*([0-9]*)\s*,', line) + if match and match.group(2) != '0': + # If 2nd arg is zero, snprintf is used to calculate size. + error(filename, linenum, 'runtime/printf', 3, + 'If you can, use sizeof(%s) instead of %s as the 2nd arg ' + 'to snprintf.' % (match.group(1), match.group(2))) + + # Check if some verboten C functions are being used. + if Search(r'\bsprintf\b', line): + error(filename, linenum, 'runtime/printf', 5, + 'Never use sprintf. Use snprintf instead.') + match = Search(r'\b(strcpy|strcat)\b', line) + if match: + error(filename, linenum, 'runtime/printf', 4, + 'Almost always, snprintf is better than %s' % match.group(1)) + + if Search(r'\bsscanf\b', line): + error(filename, linenum, 'runtime/printf', 1, + 'sscanf can be ok, but is slow and can overflow buffers.') + + # Check if some verboten operator overloading is going on + # TODO(unknown): catch out-of-line unary operator&: + # class X {}; + # int operator&(const X& x) { return 42; } // unary operator& + # The trick is it's hard to tell apart from binary operator&: + # class Y { int operator&(const Y& x) { return 23; } }; // binary operator& + if Search(r'\boperator\s*&\s*\(\s*\)', line): + error(filename, linenum, 'runtime/operator', 4, + 'Unary operator& is dangerous. Do not use it.') + + # Check for suspicious usage of "if" like + # } if (a == b) { + if Search(r'\}\s*if\s*\(', line): + error(filename, linenum, 'readability/braces', 4, + 'Did you mean "else if"? If not, start a new line for "if".') + + # Check for potential format string bugs like printf(foo). + # We constrain the pattern not to pick things like DocidForPrintf(foo). + # Not perfect but it can catch printf(foo.c_str()) and printf(foo->c_str()) + match = re.search(r'\b((?:string)?printf)\s*\(([\w.\->()]+)\)', line, re.I) + if match: + error(filename, linenum, 'runtime/printf', 4, + 'Potential format string bug. Do %s("%%s", %s) instead.' + % (match.group(1), match.group(2))) + + # Check for potential memset bugs like memset(buf, sizeof(buf), 0). + match = Search(r'memset\s*\(([^,]*),\s*([^,]*),\s*0\s*\)', line) + if match and not Match(r"^''|-?[0-9]+|0x[0-9A-Fa-f]$", match.group(2)): + error(filename, linenum, 'runtime/memset', 4, + 'Did you mean "memset(%s, 0, %s)"?' + % (match.group(1), match.group(2))) + + if Search(r'\busing namespace\b', line): + error(filename, linenum, 'build/namespaces', 5, + 'Do not use namespace using-directives. ' + 'Use using-declarations instead.') + + # Detect variable-length arrays. + match = Match(r'\s*(.+::)?(\w+) [a-z]\w*\[(.+)];', line) + if (match and match.group(2) != 'return' and match.group(2) != 'delete' and + match.group(3).find(']') == -1): + # Split the size using space and arithmetic operators as delimiters. + # If any of the resulting tokens are not compile time constants then + # report the error. + tokens = re.split(r'\s|\+|\-|\*|\/|<<|>>]', match.group(3)) + is_const = True + skip_next = False + for tok in tokens: + if skip_next: + skip_next = False + continue + + if Search(r'sizeof\(.+\)', tok): continue + if Search(r'arraysize\(\w+\)', tok): continue + + tok = tok.lstrip('(') + tok = tok.rstrip(')') + if not tok: continue + if Match(r'\d+', tok): continue + if Match(r'0[xX][0-9a-fA-F]+', tok): continue + if Match(r'k[A-Z0-9]\w*', tok): continue + if Match(r'(.+::)?k[A-Z0-9]\w*', tok): continue + if Match(r'(.+::)?[A-Z][A-Z0-9_]*', tok): continue + # A catch all for tricky sizeof cases, including 'sizeof expression', + # 'sizeof(*type)', 'sizeof(const type)', 'sizeof(struct StructName)' + # requires skipping the next token becasue we split on ' ' and '*'. + if tok.startswith('sizeof'): + skip_next = True + continue + is_const = False + break + if not is_const: + error(filename, linenum, 'runtime/arrays', 1, + 'Do not use variable-length arrays. Use an appropriately named ' + "('k' followed by CamelCase) compile-time constant for the size.") + + # If DISALLOW_EVIL_CONSTRUCTORS, DISALLOW_COPY_AND_ASSIGN, or + # DISALLOW_IMPLICIT_CONSTRUCTORS is present, then it should be the last thing + # in the class declaration. + match = Match( + (r'\s*' + r'(DISALLOW_(EVIL_CONSTRUCTORS|COPY_AND_ASSIGN|IMPLICIT_CONSTRUCTORS))' + r'\(.*\);$'), + line) + if match and linenum + 1 < clean_lines.NumLines(): + next_line = clean_lines.elided[linenum + 1] + if not Search(r'^\s*};', next_line): + error(filename, linenum, 'readability/constructors', 3, + match.group(1) + ' should be the last thing in the class') + + # Check for use of unnamed namespaces in header files. Registration + # macros are typically OK, so we allow use of "namespace {" on lines + # that end with backslashes. + if (file_extension == 'h' + and Search(r'\bnamespace\s*{', line) + and line[-1] != '\\'): + error(filename, linenum, 'build/namespaces', 4, + 'Do not use unnamed namespaces in header files. See ' + 'http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Namespaces' + ' for more information.') + + +def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, + error): + """Checks for a C-style cast by looking for the pattern. + + This also handles sizeof(type) warnings, due to similarity of content. + + Args: + filename: The name of the current file. + linenum: The number of the line to check. + line: The line of code to check. + raw_line: The raw line of code to check, with comments. + cast_type: The string for the C++ cast to recommend. This is either + reinterpret_cast or static_cast, depending. + pattern: The regular expression used to find C-style casts. + error: The function to call with any errors found. + """ + match = Search(pattern, line) + if not match: + return + + # e.g., sizeof(int) + sizeof_match = Match(r'.*sizeof\s*$', line[0:match.start(1) - 1]) + if sizeof_match: + error(filename, linenum, 'runtime/sizeof', 1, + 'Using sizeof(type). Use sizeof(varname) instead if possible') + return + + remainder = line[match.end(0):] + + # The close paren is for function pointers as arguments to a function. + # eg, void foo(void (*bar)(int)); + # The semicolon check is a more basic function check; also possibly a + # function pointer typedef. + # eg, void foo(int); or void foo(int) const; + # The equals check is for function pointer assignment. + # eg, void *(*foo)(int) = ... + # + # Right now, this will only catch cases where there's a single argument, and + # it's unnamed. It should probably be expanded to check for multiple + # arguments with some unnamed. + function_match = Match(r'\s*(\)|=|(const)?\s*(;|\{|throw\(\)))', remainder) + if function_match: + if (not function_match.group(3) or + function_match.group(3) == ';' or + raw_line.find('/*') < 0): + error(filename, linenum, 'readability/function', 3, + 'All parameters should be named in a function') + return + + # At this point, all that should be left is actual casts. + error(filename, linenum, 'readability/casting', 4, + 'Using C-style cast. Use %s<%s>(...) instead' % + (cast_type, match.group(1))) + + +_HEADERS_CONTAINING_TEMPLATES = ( + ('', ('deque',)), + ('', ('unary_function', 'binary_function', + 'plus', 'minus', 'multiplies', 'divides', 'modulus', + 'negate', + 'equal_to', 'not_equal_to', 'greater', 'less', + 'greater_equal', 'less_equal', + 'logical_and', 'logical_or', 'logical_not', + 'unary_negate', 'not1', 'binary_negate', 'not2', + 'bind1st', 'bind2nd', + 'pointer_to_unary_function', + 'pointer_to_binary_function', + 'ptr_fun', + 'mem_fun_t', 'mem_fun', 'mem_fun1_t', 'mem_fun1_ref_t', + 'mem_fun_ref_t', + 'const_mem_fun_t', 'const_mem_fun1_t', + 'const_mem_fun_ref_t', 'const_mem_fun1_ref_t', + 'mem_fun_ref', + )), + ('', ('numeric_limits',)), + ('', ('list',)), + ('', ('map', 'multimap',)), + ('', ('allocator',)), + ('', ('queue', 'priority_queue',)), + ('', ('set', 'multiset',)), + ('', ('stack',)), + ('', ('char_traits', 'basic_string',)), + ('', ('pair',)), + ('', ('vector',)), + + # gcc extensions. + # Note: std::hash is their hash, ::hash is our hash + ('', ('hash_map', 'hash_multimap',)), + ('', ('hash_set', 'hash_multiset',)), + ('', ('slist',)), + ) + +_HEADERS_ACCEPTED_BUT_NOT_PROMOTED = { + # We can trust with reasonable confidence that map gives us pair<>, too. + 'pair<>': ('map', 'multimap', 'hash_map', 'hash_multimap') +} + +_RE_PATTERN_STRING = re.compile(r'\bstring\b') + +_re_pattern_algorithm_header = [] +for _template in ('copy', 'max', 'min', 'min_element', 'sort', 'swap', + 'transform'): + # Match max(..., ...), max(..., ...), but not foo->max, foo.max or + # type::max(). + _re_pattern_algorithm_header.append( + (re.compile(r'[^>.]\b' + _template + r'(<.*?>)?\([^\)]'), + _template, + '')) + +_re_pattern_templates = [] +for _header, _templates in _HEADERS_CONTAINING_TEMPLATES: + for _template in _templates: + _re_pattern_templates.append( + (re.compile(r'(\<|\b)' + _template + r'\s*\<'), + _template + '<>', + _header)) + + +def FilesBelongToSameModule(filename_cc, filename_h): + """Check if these two filenames belong to the same module. + + The concept of a 'module' here is a as follows: + foo.h, foo-inl.h, foo.cc, foo_test.cc and foo_unittest.cc belong to the + same 'module' if they are in the same directory. + some/path/public/xyzzy and some/path/internal/xyzzy are also considered + to belong to the same module here. + + If the filename_cc contains a longer path than the filename_h, for example, + '/absolute/path/to/base/sysinfo.cc', and this file would include + 'base/sysinfo.h', this function also produces the prefix needed to open the + header. This is used by the caller of this function to more robustly open the + header file. We don't have access to the real include paths in this context, + so we need this guesswork here. + + Known bugs: tools/base/bar.cc and base/bar.h belong to the same module + according to this implementation. Because of this, this function gives + some false positives. This should be sufficiently rare in practice. + + Args: + filename_cc: is the path for the .cc file + filename_h: is the path for the header path + + Returns: + Tuple with a bool and a string: + bool: True if filename_cc and filename_h belong to the same module. + string: the additional prefix needed to open the header file. + """ + + if not filename_cc.endswith('.cc'): + return (False, '') + filename_cc = filename_cc[:-len('.cc')] + if filename_cc.endswith('_unittest'): + filename_cc = filename_cc[:-len('_unittest')] + elif filename_cc.endswith('_test'): + filename_cc = filename_cc[:-len('_test')] + filename_cc = filename_cc.replace('/public/', '/') + filename_cc = filename_cc.replace('/internal/', '/') + + if not filename_h.endswith('.h'): + return (False, '') + filename_h = filename_h[:-len('.h')] + if filename_h.endswith('-inl'): + filename_h = filename_h[:-len('-inl')] + filename_h = filename_h.replace('/public/', '/') + filename_h = filename_h.replace('/internal/', '/') + + files_belong_to_same_module = filename_cc.endswith(filename_h) + common_path = '' + if files_belong_to_same_module: + common_path = filename_cc[:-len(filename_h)] + return files_belong_to_same_module, common_path + + +def UpdateIncludeState(filename, include_state, io=codecs): + """Fill up the include_state with new includes found from the file. + + Args: + filename: the name of the header to read. + include_state: an _IncludeState instance in which the headers are inserted. + io: The io factory to use to read the file. Provided for testability. + + Returns: + True if a header was succesfully added. False otherwise. + """ + headerfile = None + try: + headerfile = io.open(filename, 'r', 'utf8', 'replace') + except IOError: + return False + linenum = 0 + for line in headerfile: + linenum += 1 + clean_line = CleanseComments(line) + match = _RE_PATTERN_INCLUDE.search(clean_line) + if match: + include = match.group(2) + # The value formatting is cute, but not really used right now. + # What matters here is that the key is in include_state. + include_state.setdefault(include, '%s:%d' % (filename, linenum)) + return True + + +def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, + io=codecs): + """Reports for missing stl includes. + + This function will output warnings to make sure you are including the headers + necessary for the stl containers and functions that you use. We only give one + reason to include a header. For example, if you use both equal_to<> and + less<> in a .h file, only one (the latter in the file) of these will be + reported as a reason to include the . + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + include_state: An _IncludeState instance. + error: The function to call with any errors found. + io: The IO factory to use to read the header file. Provided for unittest + injection. + """ + required = {} # A map of header name to linenumber and the template entity. + # Example of required: { '': (1219, 'less<>') } + + for linenum in xrange(clean_lines.NumLines()): + line = clean_lines.elided[linenum] + if not line or line[0] == '#': + continue + + # String is special -- it is a non-templatized type in STL. + m = _RE_PATTERN_STRING.search(line) + if m: + # Don't warn about strings in non-STL namespaces: + # (We check only the first match per line; good enough.) + prefix = line[:m.start()] + if prefix.endswith('std::') or not prefix.endswith('::'): + required[''] = (linenum, 'string') + + for pattern, template, header in _re_pattern_algorithm_header: + if pattern.search(line): + required[header] = (linenum, template) + + # The following function is just a speed up, no semantics are changed. + if not '<' in line: # Reduces the cpu time usage by skipping lines. + continue + + for pattern, template, header in _re_pattern_templates: + if pattern.search(line): + required[header] = (linenum, template) + + # The policy is that if you #include something in foo.h you don't need to + # include it again in foo.cc. Here, we will look at possible includes. + # Let's copy the include_state so it is only messed up within this function. + include_state = include_state.copy() + + # Did we find the header for this file (if any) and succesfully load it? + header_found = False + + # Use the absolute path so that matching works properly. + abs_filename = os.path.abspath(filename) + + # For Emacs's flymake. + # If cpplint is invoked from Emacs's flymake, a temporary file is generated + # by flymake and that file name might end with '_flymake.cc'. In that case, + # restore original file name here so that the corresponding header file can be + # found. + # e.g. If the file name is 'foo_flymake.cc', we should search for 'foo.h' + # instead of 'foo_flymake.h' + abs_filename = re.sub(r'_flymake\.cc$', '.cc', abs_filename) + + # include_state is modified during iteration, so we iterate over a copy of + # the keys. + for header in include_state.keys(): #NOLINT + (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) + fullpath = common_path + header + if same_module and UpdateIncludeState(fullpath, include_state, io): + header_found = True + + # If we can't find the header file for a .cc, assume it's because we don't + # know where to look. In that case we'll give up as we're not sure they + # didn't include it in the .h file. + # TODO(unknown): Do a better job of finding .h files so we are confident that + # not having the .h file means there isn't one. + if filename.endswith('.cc') and not header_found: + return + + # All the lines have been processed, report the errors found. + for required_header_unstripped in required: + template = required[required_header_unstripped][1] + if template in _HEADERS_ACCEPTED_BUT_NOT_PROMOTED: + headers = _HEADERS_ACCEPTED_BUT_NOT_PROMOTED[template] + if [True for header in headers if header in include_state]: + continue + if required_header_unstripped.strip('<>"') not in include_state: + error(filename, required[required_header_unstripped][0], + 'build/include_what_you_use', 4, + 'Add #include ' + required_header_unstripped + ' for ' + template) + + +def ProcessLine(filename, file_extension, + clean_lines, line, include_state, function_state, + class_state, error): + """Processes a single line in the file. + + Args: + filename: Filename of the file that is being processed. + file_extension: The extension (dot not included) of the file. + clean_lines: An array of strings, each representing a line of the file, + with comments stripped. + line: Number of line being processed. + include_state: An _IncludeState instance in which the headers are inserted. + function_state: A _FunctionState instance which counts function lines, etc. + class_state: A _ClassState instance which maintains information about + the current stack of nested class declarations being parsed. + error: A callable to which errors are reported, which takes 4 arguments: + filename, line number, error level, and message + + """ + raw_lines = clean_lines.raw_lines + ParseNolintSuppressions(filename, raw_lines[line], line, error) + CheckForFunctionLengths(filename, clean_lines, line, function_state, error) + CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error) + CheckStyle(filename, clean_lines, line, file_extension, error) + CheckLanguage(filename, clean_lines, line, file_extension, include_state, + error) + CheckForNonStandardConstructs(filename, clean_lines, line, + class_state, error) + CheckPosixThreading(filename, clean_lines, line, error) + CheckInvalidIncrement(filename, clean_lines, line, error) + + +def ProcessFileData(filename, file_extension, lines, error): + """Performs lint checks and reports any errors to the given error function. + + Args: + filename: Filename of the file that is being processed. + file_extension: The extension (dot not included) of the file. + lines: An array of strings, each representing a line of the file, with the + last element being empty if the file is termined with a newline. + error: A callable to which errors are reported, which takes 4 arguments: + """ + lines = (['// marker so line numbers and indices both start at 1'] + lines + + ['// marker so line numbers end in a known way']) + + include_state = _IncludeState() + function_state = _FunctionState() + class_state = _ClassState() + + ResetNolintSuppressions() + + CheckForCopyright(filename, lines, error) + + if file_extension == 'h': + CheckForHeaderGuard(filename, lines, error) + + RemoveMultiLineComments(filename, lines, error) + clean_lines = CleansedLines(lines) + for line in xrange(clean_lines.NumLines()): + ProcessLine(filename, file_extension, clean_lines, line, + include_state, function_state, class_state, error) + class_state.CheckFinished(filename, error) + + CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) + + # We check here rather than inside ProcessLine so that we see raw + # lines rather than "cleaned" lines. + CheckForUnicodeReplacementCharacters(filename, lines, error) + + CheckForNewlineAtEOF(filename, lines, error) + +def ProcessFile(filename, vlevel): + """Does google-lint on a single file. + + Args: + filename: The name of the file to parse. + + vlevel: The level of errors to report. Every error of confidence + >= verbose_level will be reported. 0 is a good default. + """ + + _SetVerboseLevel(vlevel) + + try: + # Support the UNIX convention of using "-" for stdin. Note that + # we are not opening the file with universal newline support + # (which codecs doesn't support anyway), so the resulting lines do + # contain trailing '\r' characters if we are reading a file that + # has CRLF endings. + # If after the split a trailing '\r' is present, it is removed + # below. If it is not expected to be present (i.e. os.linesep != + # '\r\n' as in Windows), a warning is issued below if this file + # is processed. + + if filename == '-': + lines = codecs.StreamReaderWriter(sys.stdin, + codecs.getreader('utf8'), + codecs.getwriter('utf8'), + 'replace').read().split('\n') + else: + lines = codecs.open(filename, 'r', 'utf8', 'replace').read().split('\n') + + carriage_return_found = False + # Remove trailing '\r'. + for linenum in range(len(lines)): + if lines[linenum].endswith('\r'): + lines[linenum] = lines[linenum].rstrip('\r') + carriage_return_found = True + + except IOError: + sys.stderr.write( + "Skipping input '%s': Can't open for reading\n" % filename) + return + + # Note, if no dot is found, this will give the entire filename as the ext. + file_extension = filename[filename.rfind('.') + 1:] + + # When reading from stdin, the extension is unknown, so no cpplint tests + # should rely on the extension. + if (filename != '-' and file_extension != 'cc' and file_extension != 'h' + and file_extension != 'cpp'): + sys.stderr.write('Ignoring %s; not a .cc or .h file\n' % filename) + else: + ProcessFileData(filename, file_extension, lines, Error) + if carriage_return_found and os.linesep != '\r\n': + # Use 0 for linenum since outputing only one error for potentially + # several lines. + Error(filename, 0, 'whitespace/newline', 1, + 'One or more unexpected \\r (^M) found;' + 'better to use only a \\n') + + sys.stderr.write('Done processing %s\n' % filename) + + +def PrintUsage(message): + """Prints a brief usage string and exits, optionally with an error message. + + Args: + message: The optional error message. + """ + sys.stderr.write(_USAGE) + if message: + sys.exit('\nFATAL ERROR: ' + message) + else: + sys.exit(1) + + +def PrintCategories(): + """Prints a list of all the error-categories used by error messages. + + These are the categories used to filter messages via --filter. + """ + sys.stderr.write(''.join(' %s\n' % cat for cat in _ERROR_CATEGORIES)) + sys.exit(0) + + +def ParseArguments(args): + """Parses the command line arguments. + + This may set the output format and verbosity level as side-effects. + + Args: + args: The command line arguments: + + Returns: + The list of filenames to lint. + """ + try: + (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', + 'counting=', + 'filter=']) + except getopt.GetoptError: + PrintUsage('Invalid arguments.') + + verbosity = _VerboseLevel() + output_format = _OutputFormat() + filters = '' + counting_style = '' + + for (opt, val) in opts: + if opt == '--help': + PrintUsage(None) + elif opt == '--output': + if not val in ('emacs', 'vs7'): + PrintUsage('The only allowed output formats are emacs and vs7.') + output_format = val + elif opt == '--verbose': + verbosity = int(val) + elif opt == '--filter': + filters = val + if not filters: + PrintCategories() + elif opt == '--counting': + if val not in ('total', 'toplevel', 'detailed'): + PrintUsage('Valid counting options are total, toplevel, and detailed') + counting_style = val + + if not filenames: + PrintUsage('No files were specified.') + + _SetOutputFormat(output_format) + _SetVerboseLevel(verbosity) + _SetFilters(filters) + _SetCountingStyle(counting_style) + + return filenames + + +def main(): + filenames = ParseArguments(sys.argv[1:]) + + # Change stderr to write with replacement characters so we don't die + # if we try to print something containing non-ASCII characters. + sys.stderr = codecs.StreamReaderWriter(sys.stderr, + codecs.getreader('utf8'), + codecs.getwriter('utf8'), + 'replace') + + _cpplint_state.ResetErrorCounts() + for filename in filenames: + ProcessFile(filename, _cpplint_state.verbose_level) + _cpplint_state.PrintErrorCounts() + + sys.exit(_cpplint_state.error_count > 0) + + +if __name__ == '__main__': + main() -- cgit v1.2.3-59-g8ed1b From 08b82a99de4dfeb0a74b0922051f46516ca85398 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 5 Apr 2012 12:13:56 -0700 Subject: Don't explicitly request python2.4. This is obsolete historical cruft. Change-Id: I140a93ac04f5be0034812f90204e6f9ae36d2d5f --- tools/cpplint.py | 2 +- tools/generate-operator-out.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tools/cpplint.py') diff --git a/tools/cpplint.py b/tools/cpplint.py index 86154ededa..73a4644aa1 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2.4 +#!/usr/bin/python # # Copyright (c) 2009 Google Inc. All rights reserved. # diff --git a/tools/generate-operator-out.py b/tools/generate-operator-out.py index 91d4669cc7..ba2b4d1fda 100755 --- a/tools/generate-operator-out.py +++ b/tools/generate-operator-out.py @@ -1,4 +1,4 @@ -#!/usr/bin/python2.4 +#!/usr/bin/python # # Copyright 2012 Google Inc. All Rights Reserved. # -- cgit v1.2.3-59-g8ed1b From db385708bfcfbd64bdc9cb46fdc0e66344363848 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 21 Jun 2012 10:41:20 -0700 Subject: Update cpplint.py. From https://code.google.com/p/google-styleguide/source/browse/trunk#trunk%2Fcpplint . Change-Id: Ie9c0efe36c9af5c1fead502ae673ca6693f3cf7b --- tools/cpplint.py | 411 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 323 insertions(+), 88 deletions(-) (limited to 'tools/cpplint.py') diff --git a/tools/cpplint.py b/tools/cpplint.py index 73a4644aa1..526b9556dc 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -150,6 +150,7 @@ _ERROR_CATEGORIES = [ 'build/class', 'build/deprecated', 'build/endif_comment', + 'build/explicit_make_pair', 'build/forward_decl', 'build/header_guard', 'build/include', @@ -210,11 +211,11 @@ _ERROR_CATEGORIES = [ # flag. By default all errors are on, so only add here categories that should be # off by default (i.e., categories that must be enabled by the --filter= flags). # All entries here should start with a '-' or '+', as in the --filter= flag. -_DEFAULT_FILTERS = [ '-build/include_alpha' ] +_DEFAULT_FILTERS = ['-build/include_alpha'] # We used to check for high-bit characters, but after much discussion we # decided those were OK, as long as they were in UTF-8 and didn't represent -# hard-coded international strings, which belong in a seperate i18n file. +# hard-coded international strings, which belong in a separate i18n file. # Headers that we consider STL headers. _STL_HEADERS = frozenset([ @@ -235,11 +236,11 @@ _CPP_HEADERS = frozenset([ 'cstdio', 'cstdlib', 'cstring', 'ctime', 'cwchar', 'cwctype', 'defalloc.h', 'deque.h', 'editbuf.h', 'exception', 'fstream', 'fstream.h', 'hashtable.h', 'heap.h', 'indstream.h', 'iomanip', - 'iomanip.h', 'ios', 'iosfwd', 'iostream', 'iostream.h', 'istream.h', - 'iterator.h', 'limits', 'map.h', 'multimap.h', 'multiset.h', - 'numeric', 'ostream.h', 'parsestream.h', 'pfstream.h', 'PlotFile.h', - 'procbuf.h', 'pthread_alloc.h', 'rope', 'rope.h', 'ropeimpl.h', - 'SFile.h', 'slist', 'slist.h', 'stack.h', 'stdexcept', + 'iomanip.h', 'ios', 'iosfwd', 'iostream', 'iostream.h', 'istream', + 'istream.h', 'iterator.h', 'limits', 'map.h', 'multimap.h', 'multiset.h', + 'numeric', 'ostream', 'ostream.h', 'parsestream.h', 'pfstream.h', + 'PlotFile.h', 'procbuf.h', 'pthread_alloc.h', 'rope', 'rope.h', + 'ropeimpl.h', 'SFile.h', 'slist', 'slist.h', 'stack.h', 'stdexcept', 'stdiostream.h', 'streambuf.h', 'stream.h', 'strfile.h', 'string', 'strstream', 'strstream.h', 'tempbuf.h', 'tree.h', 'typeinfo', 'valarray', ]) @@ -310,9 +311,9 @@ def ParseNolintSuppressions(filename, raw_line, linenum, error): error: function, an error handler. """ # FIXME(adonovan): "NOLINT(" is misparsed as NOLINT(*). - m = _RE_SUPPRESSION.search(raw_line) - if m: - category = m.group(1) + matched = _RE_SUPPRESSION.search(raw_line) + if matched: + category = matched.group(1) if category in (None, '(*)'): # => "suppress all" _error_suppressions.setdefault(None, set()).add(linenum) else: @@ -322,7 +323,7 @@ def ParseNolintSuppressions(filename, raw_line, linenum, error): _error_suppressions.setdefault(category, set()).add(linenum) else: error(filename, linenum, 'readability/nolint', 5, - 'Unknown NOLINT error category: %s' % category) + 'Unknown NOLINT error category: %s' % category) def ResetNolintSuppressions(): @@ -404,7 +405,7 @@ class _IncludeState(dict): self._last_header = '' def CanonicalizeAlphabeticalOrder(self, header_path): - """Returns a path canonicalized for alphabetical comparisson. + """Returns a path canonicalized for alphabetical comparison. - replaces "-" with "_" so they both cmp the same. - removes '-inl' since we don't require them to be after the main header. @@ -662,7 +663,7 @@ class _FunctionState(object): self.current_function, self.lines_in_function, trigger)) def End(self): - """Stop analizing function body.""" + """Stop analyzing function body.""" self.in_a_function = False @@ -712,16 +713,18 @@ class FileInfo: prefix = os.path.commonprefix([root_dir, project_dir]) return fullname[len(prefix) + 1:] - # Not SVN? Try to find a git or hg top level directory by searching up - # from the current path. + # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by + # searching up from the current path. root_dir = os.path.dirname(fullname) while (root_dir != os.path.dirname(root_dir) and not os.path.exists(os.path.join(root_dir, ".git")) and - not os.path.exists(os.path.join(root_dir, ".hg"))): + not os.path.exists(os.path.join(root_dir, ".hg")) and + not os.path.exists(os.path.join(root_dir, ".svn"))): root_dir = os.path.dirname(root_dir) if (os.path.exists(os.path.join(root_dir, ".git")) or - os.path.exists(os.path.join(root_dir, ".hg"))): + os.path.exists(os.path.join(root_dir, ".hg")) or + os.path.exists(os.path.join(root_dir, ".svn"))): prefix = os.path.commonprefix([root_dir, project_dir]) return fullname[len(prefix) + 1:] @@ -760,8 +763,7 @@ class FileInfo: def _ShouldPrintError(category, confidence, linenum): - """Returns true iff confidence >= verbose, category passes - filter and is not NOLINT-suppressed.""" + """If confidence >= verbose, category passes filter and is not suppressed.""" # There are three ways we might decide not to print an error message: # a "NOLINT(category)" comment appears in the source, @@ -913,7 +915,7 @@ def CleanseComments(line): """ commentpos = line.find('//') if commentpos != -1 and not IsCppString(line[:commentpos]): - line = line[:commentpos] + line = line[:commentpos].rstrip() # get rid of /* ... */ return _RE_PATTERN_CLEANSE_LINE_C_COMMENTS.sub('', line) @@ -966,7 +968,7 @@ class CleansedLines(object): def CloseExpression(clean_lines, linenum, pos): """If input points to ( or { or [, finds the position that closes it. - If lines[linenum][pos] points to a '(' or '{' or '[', finds the the + If lines[linenum][pos] points to a '(' or '{' or '[', finds the linenum/pos that correspond to the closing of the expression. Args: @@ -1069,12 +1071,18 @@ def CheckForHeaderGuard(filename, lines, error): endif = line endif_linenum = linenum - if not ifndef or not define or ifndef != define: + if not ifndef: error(filename, 0, 'build/header_guard', 5, 'No #ifndef header guard found, suggested CPP variable is: %s' % cppvar) return + if not define: + error(filename, 0, 'build/header_guard', 5, + 'No #define header guard found, suggested CPP variable is: %s' % + cppvar) + return + # The guard should be PATH_FILE_H_, but we also allow PATH_FILE_H__ # for backward compatibility. if ifndef != cppvar: @@ -1087,6 +1095,12 @@ def CheckForHeaderGuard(filename, lines, error): error(filename, ifndef_linenum, 'build/header_guard', error_level, '#ifndef header guard has wrong style, please use: %s' % cppvar) + if define != ifndef: + error(filename, 0, 'build/header_guard', 5, + '#ifndef and #define don\'t match, suggested CPP variable is: %s' % + cppvar) + return + if endif != ('#endif // %s' % cppvar): error_level = 0 if endif != ('#endif // %s' % (cppvar + '_')): @@ -1248,7 +1262,7 @@ def CheckInvalidIncrement(filename, clean_lines, linenum, error): class _ClassInfo(object): """Stores information about a class.""" - def __init__(self, name, linenum): + def __init__(self, name, clean_lines, linenum): self.name = name self.linenum = linenum self.seen_open_brace = False @@ -1257,6 +1271,20 @@ class _ClassInfo(object): self.has_virtual_destructor = False self.brace_depth = 0 + # Try to find the end of the class. This will be confused by things like: + # class A { + # } *x = { ... + # + # But it's still good enough for CheckSectionSpacing. + self.last_line = 0 + depth = 0 + for i in range(linenum, clean_lines.NumLines()): + line = clean_lines.lines[i] + depth += line.count('{') - line.count('}') + if not depth: + self.last_line = i + break + class _ClassState(object): """Holds the current state of the parse relating to class declarations. @@ -1378,11 +1406,16 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, # style guidelines, but it seems to perform well enough in testing # to be a worthwhile addition to the checks. classinfo_stack = class_state.classinfo_stack - # Look for a class declaration + # Look for a class declaration. The regexp accounts for decorated classes + # such as in: + # class LOCKABLE API Object { + # }; class_decl_match = Match( - r'\s*(template\s*<[\w\s<>,:]*>\s*)?(class|struct)\s+(\w+(::\w+)*)', line) + r'\s*(template\s*<[\w\s<>,:]*>\s*)?' + '(class|struct)\s+([A-Z_]+\s+)*(\w+(::\w+)*)', line) if class_decl_match: - classinfo_stack.append(_ClassInfo(class_decl_match.group(3), linenum)) + classinfo_stack.append(_ClassInfo( + class_decl_match.group(4), clean_lines, linenum)) # Everything else in this function uses the top of the stack if it's # not empty. @@ -1412,12 +1445,12 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, # Look for single-argument constructors that aren't marked explicit. # Technically a valid construct, but against style. - args = Match(r'(?\s*)?&' % re.escape(base_classname), args.group(1).strip())): error(filename, linenum, 'runtime/explicit', 5, 'Single-argument constructors should be marked explicit.') @@ -1508,8 +1541,14 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error): # If the ) is followed only by a newline or a { + newline, assume it's # part of a control statement (if/while/etc), and don't complain if Search(r'[^)]\s+\)\s*[^{\s]', fncall): - error(filename, linenum, 'whitespace/parens', 2, - 'Extra space before )') + # If the closing parenthesis is preceded by only whitespaces, + # try to give a more descriptive error message. + if Search(r'^\s+\)', fncall): + error(filename, linenum, 'whitespace/parens', 2, + 'Closing ) should be moved to the previous line') + else: + error(filename, linenum, 'whitespace/parens', 2, + 'Extra space before )') def IsBlankLine(line): @@ -1540,7 +1579,7 @@ def CheckForFunctionLengths(filename, clean_lines, linenum, Trivial bodies are unchecked, so constructors with huge initializer lists may be missed. Blank/comment lines are not counted so as to avoid encouraging the removal - of vertical space and commments just to get through a lint check. + of vertical space and comments just to get through a lint check. NOLINT *on the last line of a function* disables this check. Args: @@ -1636,8 +1675,8 @@ def CheckSpacing(filename, clean_lines, linenum, error): Things we check for: spaces around operators, spaces after if/for/while/switch, no spaces around parens in function calls, two spaces between code and comment, don't start a block with a blank - line, don't end a function with a blank line, don't have too many - blank lines in a row. + line, don't end a function with a blank line, don't add a blank line + after public/protected/private, don't have too many blank lines in a row. Args: filename: The name of the current file. @@ -1664,7 +1703,7 @@ def CheckSpacing(filename, clean_lines, linenum, error): and prev_line[:prevbrace].find('namespace') == -1): # OK, we have a blank line at the start of a code block. Before we # complain, we check if it is an exception to the rule: The previous - # non-empty line has the paramters of a function header that are indented + # non-empty line has the parameters of a function header that are indented # 4 spaces (because they did not fit in a 80 column line when placed on # the same line as the function name). We also check for the case where # the previous line is indented 6 spaces, which may happen when the @@ -1715,6 +1754,11 @@ def CheckSpacing(filename, clean_lines, linenum, error): error(filename, linenum, 'whitespace/blank_line', 3, 'Blank line at the end of a code block. Is this needed?') + matched = Match(r'\s*(public|protected|private):', prev_line) + if matched: + error(filename, linenum, 'whitespace/blank_line', 3, + 'Do not leave a blank line after "%s:"' % matched.group(1)) + # Next, we complain if there's a comment too near the text commentpos = line.find('//') if commentpos != -1: @@ -1824,13 +1868,22 @@ def CheckSpacing(filename, clean_lines, linenum, error): error(filename, linenum, 'whitespace/comma', 3, 'Missing space after ,') + # You should always have a space after a semicolon + # except for few corner cases + # TODO(unknown): clarify if 'if (1) { return 1;}' is requires one more + # space after ; + if Search(r';[^\s};\\)/]', line): + error(filename, linenum, 'whitespace/semicolon', 3, + 'Missing space after ;') + # Next we will look for issues with function calls. CheckSpacingForFunctionCall(filename, line, linenum, error) - # Except after an opening paren, you should have spaces before your braces. - # And since you should never have braces at the beginning of a line, this is - # an easy test. - if Search(r'[^ (]{', line): + # Except after an opening paren, or after another opening brace (in case of + # an initializer list, for instance), you should have spaces before your + # braces. And since you should never have braces at the beginning of a line, + # this is an easy test. + if Search(r'[^ ({]{', line): error(filename, linenum, 'whitespace/braces', 5, 'Missing space before {') @@ -1862,6 +1915,58 @@ def CheckSpacing(filename, clean_lines, linenum, error): 'statement, use { } instead.') +def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): + """Checks for additional blank line issues related to sections. + + Currently the only thing checked here is blank line before protected/private. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + class_info: A _ClassInfo objects. + linenum: The number of the line to check. + error: The function to call with any errors found. + """ + # Skip checks if the class is small, where small means 25 lines or less. + # 25 lines seems like a good cutoff since that's the usual height of + # terminals, and any class that can't fit in one screen can't really + # be considered "small". + # + # Also skip checks if we are on the first line. This accounts for + # classes that look like + # class Foo { public: ... }; + # + # If we didn't find the end of the class, last_line would be zero, + # and the check will be skipped by the first condition. + if (class_info.last_line - class_info.linenum <= 24 or + linenum <= class_info.linenum): + return + + matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum]) + if matched: + # Issue warning if the line before public/protected/private was + # not a blank line, but don't do this if the previous line contains + # "class" or "struct". This can happen two ways: + # - We are at the beginning of the class. + # - We are forward-declaring an inner class that is semantically + # private, but needed to be public for implementation reasons. + prev_line = clean_lines.lines[linenum - 1] + if (not IsBlankLine(prev_line) and + not Search(r'\b(class|struct)\b', prev_line)): + # Try a bit harder to find the beginning of the class. This is to + # account for multi-line base-specifier lists, e.g.: + # class Derived + # : public Base { + end_class_head = class_info.linenum + for i in range(class_info.linenum, linenum): + if Search(r'\{\s*$', clean_lines.lines[i]): + end_class_head = i + break + if end_class_head < linenum - 1: + error(filename, linenum, 'whitespace/blank_line', 3, + '"%s:" should be preceded by a blank line' % matched.group(1)) + + def GetPreviousNonBlankLine(clean_lines, linenum): """Return the most recent non-blank line and its line number. @@ -2039,17 +2144,18 @@ def GetLineWidth(line): """ if isinstance(line, unicode): width = 0 - for c in unicodedata.normalize('NFC', line): - if unicodedata.east_asian_width(c) in ('W', 'F'): + for uc in unicodedata.normalize('NFC', line): + if unicodedata.east_asian_width(uc) in ('W', 'F'): width += 2 - elif not unicodedata.combining(c): + elif not unicodedata.combining(uc): width += 1 return width else: return len(line) -def CheckStyle(filename, clean_lines, linenum, file_extension, error): +def CheckStyle(filename, clean_lines, linenum, file_extension, class_state, + error): """Checks rules from the 'C++ style rules' section of cppguide.html. Most of these rules are hard to test (naming, comment style), but we @@ -2119,8 +2225,12 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error): # # URLs can be long too. It's possible to split these, but it makes them # harder to cut&paste. + # + # The "$Id:...$" comment may also get very long without it being the + # developers fault. if (not line.startswith('#include') and not is_header_guard and - not Match(r'^\s*//.*http(s?)://\S*$', line)): + not Match(r'^\s*//.*http(s?)://\S*$', line) and + not Match(r'^// \$Id:.*#[0-9]+ \$$', line)): line_width = GetLineWidth(line) if line_width > 100: error(filename, linenum, 'whitespace/line_length', 4, @@ -2145,6 +2255,9 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, error): CheckBraces(filename, clean_lines, linenum, error) CheckSpacing(filename, clean_lines, linenum, error) CheckCheck(filename, clean_lines, linenum, error) + if class_state and class_state.classinfo_stack: + CheckSectionSpacing(filename, clean_lines, + class_state.classinfo_stack[-1], linenum, error) _RE_PATTERN_INCLUDE_NEW_STYLE = re.compile(r'#include +"[^/]+\.h"') @@ -2330,6 +2443,63 @@ def CheckIncludeLine(filename, clean_lines, linenum, include_state, error): error(filename, linenum, 'readability/streams', 3, 'Streams are highly discouraged.') + +def _GetTextInside(text, start_pattern): + """Retrieves all the text between matching open and close parentheses. + + Given a string of lines and a regular expression string, retrieve all the text + following the expression and between opening punctuation symbols like + (, [, or {, and the matching close-punctuation symbol. This properly nested + occurrences of the punctuations, so for the text like + printf(a(), b(c())); + a call to _GetTextInside(text, r'printf\(') will return 'a(), b(c())'. + start_pattern must match string having an open punctuation symbol at the end. + + Args: + text: The lines to extract text. Its comments and strings must be elided. + It can be single line and can span multiple lines. + start_pattern: The regexp string indicating where to start extracting + the text. + Returns: + The extracted text. + None if either the opening string or ending punctuation could not be found. + """ + # TODO(sugawarayu): Audit cpplint.py to see what places could be profitably + # rewritten to use _GetTextInside (and use inferior regexp matching today). + + # Give opening punctuations to get the matching close-punctuations. + matching_punctuation = {'(': ')', '{': '}', '[': ']'} + closing_punctuation = set(matching_punctuation.itervalues()) + + # Find the position to start extracting text. + match = re.search(start_pattern, text, re.M) + if not match: # start_pattern not found in text. + return None + start_position = match.end(0) + + assert start_position > 0, ( + 'start_pattern must ends with an opening punctuation.') + assert text[start_position - 1] in matching_punctuation, ( + 'start_pattern must ends with an opening punctuation.') + # Stack of closing punctuations we expect to have in text after position. + punctuation_stack = [matching_punctuation[text[start_position - 1]]] + position = start_position + while punctuation_stack and position < len(text): + if text[position] == punctuation_stack[-1]: + punctuation_stack.pop() + elif text[position] in closing_punctuation: + # A closing punctuation without matching opening punctuations. + return None + elif text[position] in matching_punctuation: + punctuation_stack.append(matching_punctuation[text[position]]) + position += 1 + if punctuation_stack: + # Opening punctuations left without matching close-punctuations. + return None + # punctuations match. + return text[start_position:position - 1] + + def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, error): """Checks rules from the 'C++ language rules' section of cppguide.html. @@ -2375,7 +2545,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, # These are complicated re's. They try to capture the following: # paren (for fn-prototype start), typename, &, varname. For the const # version, we're willing for const to be before typename or after - # Don't check the implemention on same line. + # Don't check the implementation on same line. fnline = line.split('{', 1)[0] if (len(re.findall(r'\([^()]*\b(?:[\w:]|<[^()]*>)+(\s?&|&\s?)\w+', fnline)) > len(re.findall(r'\([^()]*\bconst\s+(?:typename\s+)?(?:struct\s+)?' @@ -2402,9 +2572,12 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, if match: # gMock methods are defined using some variant of MOCK_METHODx(name, type) # where type may be float(), int(string), etc. Without context they are - # virtually indistinguishable from int(x) casts. + # virtually indistinguishable from int(x) casts. Likewise, gMock's + # MockCallback takes a template parameter of the form return_type(arg_type), + # which looks much like the cast we're trying to detect. if (match.group(1) is None and # If new operator, then this isn't a cast - not Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line)): + not (Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line) or + Match(r'^\s*MockCallback<.*>', line))): error(filename, linenum, 'readability/casting', 4, 'Using deprecated casting style. ' 'Use static_cast<%s>(...) instead' % @@ -2412,11 +2585,19 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], 'static_cast', - r'\((int|float|double|bool|char|u?int(16|32|64))\)', - error) - # This doesn't catch all cases. Consider (const char * const)"hello". - CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], - 'reinterpret_cast', r'\((\w+\s?\*+\s?)\)', error) + r'\((int|float|double|bool|char|u?int(16|32|64))\)', error) + + # This doesn't catch all cases. Consider (const char * const)"hello". + # + # (char *) "foo" should always be a const_cast (reinterpret_cast won't + # compile). + if CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], + 'const_cast', r'\((char\s?\*+\s?)\)\s*"', error): + pass + else: + # Check pointer casts for other than string constants + CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], + 'reinterpret_cast', r'\((\w+\s?\*+\s?)\)', error) # In addition, we look for people taking the address of a cast. This # is dangerous -- casts can assign to temporaries, so the pointer doesn't @@ -2515,11 +2696,19 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, # Check for potential format string bugs like printf(foo). # We constrain the pattern not to pick things like DocidForPrintf(foo). # Not perfect but it can catch printf(foo.c_str()) and printf(foo->c_str()) - match = re.search(r'\b((?:string)?printf)\s*\(([\w.\->()]+)\)', line, re.I) - if match: - error(filename, linenum, 'runtime/printf', 4, - 'Potential format string bug. Do %s("%%s", %s) instead.' - % (match.group(1), match.group(2))) + # TODO(sugawarayu): Catch the following case. Need to change the calling + # convention of the whole function to process multiple line to handle it. + # printf( + # boy_this_is_a_really_long_variable_that_cannot_fit_on_the_prev_line); + printf_args = _GetTextInside(line, r'(?i)\b(string)?printf\s*\(') + if printf_args: + match = Match(r'([\w.\->()]+)$', printf_args) + if match: + function_name = re.search(r'\b((?:string)?printf)\s*\(', + line, re.I).group(1) + error(filename, linenum, 'runtime/printf', 4, + 'Potential format string bug. Do %s("%%s", %s) instead.' + % (function_name, match.group(1))) # Check for potential memset bugs like memset(buf, sizeof(buf), 0). match = Search(r'memset\s*\(([^,]*),\s*([^,]*),\s*0\s*\)', line) @@ -2561,7 +2750,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, if Match(r'(.+::)?[A-Z][A-Z0-9_]*', tok): continue # A catch all for tricky sizeof cases, including 'sizeof expression', # 'sizeof(*type)', 'sizeof(const type)', 'sizeof(struct StructName)' - # requires skipping the next token becasue we split on ' ' and '*'. + # requires skipping the next token because we split on ' ' and '*'. if tok.startswith('sizeof'): skip_next = True continue @@ -2582,7 +2771,13 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, line) if match and linenum + 1 < clean_lines.NumLines(): next_line = clean_lines.elided[linenum + 1] - if not Search(r'^\s*};', next_line): + # We allow some, but not all, declarations of variables to be present + # in the statement that defines the class. The [\w\*,\s]* fragment of + # the regular expression below allows users to declare instances of + # the class or pointers to instances, but not less common types such + # as function pointers or arrays. It's a tradeoff between allowing + # reasonable code and avoiding trying to parse more C++ using regexps. + if not Search(r'^\s*}[\w\*,\s]*;', next_line): error(filename, linenum, 'readability/constructors', 3, match.group(1) + ' should be the last thing in the class') @@ -2610,20 +2805,24 @@ def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, line: The line of code to check. raw_line: The raw line of code to check, with comments. cast_type: The string for the C++ cast to recommend. This is either - reinterpret_cast or static_cast, depending. + reinterpret_cast, static_cast, or const_cast, depending. pattern: The regular expression used to find C-style casts. error: The function to call with any errors found. + + Returns: + True if an error was emitted. + False otherwise. """ match = Search(pattern, line) if not match: - return + return False # e.g., sizeof(int) sizeof_match = Match(r'.*sizeof\s*$', line[0:match.start(1) - 1]) if sizeof_match: error(filename, linenum, 'runtime/sizeof', 1, 'Using sizeof(type). Use sizeof(varname) instead if possible') - return + return True remainder = line[match.end(0):] @@ -2634,24 +2833,28 @@ def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, # eg, void foo(int); or void foo(int) const; # The equals check is for function pointer assignment. # eg, void *(*foo)(int) = ... + # The > is for MockCallback<...> ... # # Right now, this will only catch cases where there's a single argument, and # it's unnamed. It should probably be expanded to check for multiple # arguments with some unnamed. - function_match = Match(r'\s*(\)|=|(const)?\s*(;|\{|throw\(\)))', remainder) + function_match = Match(r'\s*(\)|=|(const)?\s*(;|\{|throw\(\)|>))', remainder) if function_match: if (not function_match.group(3) or function_match.group(3) == ';' or - raw_line.find('/*') < 0): + ('MockCallback<' not in raw_line and + '/*' not in raw_line)): error(filename, linenum, 'readability/function', 3, 'All parameters should be named in a function') - return + return True # At this point, all that should be left is actual casts. error(filename, linenum, 'readability/casting', 4, 'Using C-style cast. Use %s<%s>(...) instead' % (cast_type, match.group(1))) + return True + _HEADERS_CONTAINING_TEMPLATES = ( ('', ('deque',)), @@ -2690,11 +2893,6 @@ _HEADERS_CONTAINING_TEMPLATES = ( ('', ('slist',)), ) -_HEADERS_ACCEPTED_BUT_NOT_PROMOTED = { - # We can trust with reasonable confidence that map gives us pair<>, too. - 'pair<>': ('map', 'multimap', 'hash_map', 'hash_multimap') -} - _RE_PATTERN_STRING = re.compile(r'\bstring\b') _re_pattern_algorithm_header = [] @@ -2827,11 +3025,11 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, continue # String is special -- it is a non-templatized type in STL. - m = _RE_PATTERN_STRING.search(line) - if m: + matched = _RE_PATTERN_STRING.search(line) + if matched: # Don't warn about strings in non-STL namespaces: # (We check only the first match per line; good enough.) - prefix = line[:m.start()] + prefix = line[:matched.start()] if prefix.endswith('std::') or not prefix.endswith('::'): required[''] = (linenum, 'string') @@ -2856,7 +3054,7 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, header_found = False # Use the absolute path so that matching works properly. - abs_filename = os.path.abspath(filename) + abs_filename = FileInfo(filename).FullName() # For Emacs's flymake. # If cpplint is invoked from Emacs's flymake, a temporary file is generated @@ -2869,7 +3067,8 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, # include_state is modified during iteration, so we iterate over a copy of # the keys. - for header in include_state.keys(): #NOLINT + header_keys = include_state.keys() + for header in header_keys: (same_module, common_path) = FilesBelongToSameModule(abs_filename, header) fullpath = common_path + header if same_module and UpdateIncludeState(fullpath, include_state, io): @@ -2886,19 +3085,40 @@ def CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error, # All the lines have been processed, report the errors found. for required_header_unstripped in required: template = required[required_header_unstripped][1] - if template in _HEADERS_ACCEPTED_BUT_NOT_PROMOTED: - headers = _HEADERS_ACCEPTED_BUT_NOT_PROMOTED[template] - if [True for header in headers if header in include_state]: - continue if required_header_unstripped.strip('<>"') not in include_state: error(filename, required[required_header_unstripped][0], 'build/include_what_you_use', 4, 'Add #include ' + required_header_unstripped + ' for ' + template) +_RE_PATTERN_EXPLICIT_MAKEPAIR = re.compile(r'\bmake_pair\s*<') + + +def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error): + """Check that make_pair's template arguments are deduced. + + G++ 4.6 in C++0x mode fails badly if make_pair's template arguments are + specified explicitly, and such use isn't intended in any case. + + 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. + """ + raw = clean_lines.raw_lines + line = raw[linenum] + match = _RE_PATTERN_EXPLICIT_MAKEPAIR.search(line) + if match: + error(filename, linenum, 'build/explicit_make_pair', + 4, # 4 = high confidence + 'Omit template arguments from make_pair OR use pair directly OR' + ' if appropriate, construct a pair directly') + + def ProcessLine(filename, file_extension, clean_lines, line, include_state, function_state, - class_state, error): + class_state, error, extra_check_functions=[]): """Processes a single line in the file. Args: @@ -2913,30 +3133,39 @@ def ProcessLine(filename, file_extension, the current stack of nested class declarations being parsed. error: A callable to which errors are reported, which takes 4 arguments: filename, line number, error level, and message - + extra_check_functions: An array of additional check functions that will be + run on each source line. Each function takes 4 + arguments: filename, clean_lines, line, error """ raw_lines = clean_lines.raw_lines ParseNolintSuppressions(filename, raw_lines[line], line, error) CheckForFunctionLengths(filename, clean_lines, line, function_state, error) CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error) - CheckStyle(filename, clean_lines, line, file_extension, error) + CheckStyle(filename, clean_lines, line, file_extension, class_state, error) CheckLanguage(filename, clean_lines, line, file_extension, include_state, error) CheckForNonStandardConstructs(filename, clean_lines, line, class_state, error) CheckPosixThreading(filename, clean_lines, line, error) CheckInvalidIncrement(filename, clean_lines, line, error) + CheckMakePairUsesDeduction(filename, clean_lines, line, error) + for check_fn in extra_check_functions: + check_fn(filename, clean_lines, line, error) - -def ProcessFileData(filename, file_extension, lines, error): +def ProcessFileData(filename, file_extension, lines, error, + extra_check_functions=[]): """Performs lint checks and reports any errors to the given error function. Args: filename: Filename of the file that is being processed. file_extension: The extension (dot not included) of the file. lines: An array of strings, each representing a line of the file, with the - last element being empty if the file is termined with a newline. + last element being empty if the file is terminated with a newline. error: A callable to which errors are reported, which takes 4 arguments: + filename, line number, error level, and message + extra_check_functions: An array of additional check functions that will be + run on each source line. Each function takes 4 + arguments: filename, clean_lines, line, error """ lines = (['// marker so line numbers and indices both start at 1'] + lines + ['// marker so line numbers end in a known way']) @@ -2956,7 +3185,8 @@ def ProcessFileData(filename, file_extension, lines, error): clean_lines = CleansedLines(lines) for line in xrange(clean_lines.NumLines()): ProcessLine(filename, file_extension, clean_lines, line, - include_state, function_state, class_state, error) + include_state, function_state, class_state, error, + extra_check_functions) class_state.CheckFinished(filename, error) CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) @@ -2967,7 +3197,7 @@ def ProcessFileData(filename, file_extension, lines, error): CheckForNewlineAtEOF(filename, lines, error) -def ProcessFile(filename, vlevel): +def ProcessFile(filename, vlevel, extra_check_functions=[]): """Does google-lint on a single file. Args: @@ -2975,6 +3205,10 @@ def ProcessFile(filename, vlevel): vlevel: The level of errors to report. Every error of confidence >= verbose_level will be reported. 0 is a good default. + + extra_check_functions: An array of additional check functions that will be + run on each source line. Each function takes 4 + arguments: filename, clean_lines, line, error """ _SetVerboseLevel(vlevel) @@ -3019,9 +3253,10 @@ def ProcessFile(filename, vlevel): and file_extension != 'cpp'): sys.stderr.write('Ignoring %s; not a .cc or .h file\n' % filename) else: - ProcessFileData(filename, file_extension, lines, Error) + ProcessFileData(filename, file_extension, lines, Error, + extra_check_functions) if carriage_return_found and os.linesep != '\r\n': - # Use 0 for linenum since outputing only one error for potentially + # Use 0 for linenum since outputting only one error for potentially # several lines. Error(filename, 0, 'whitespace/newline', 1, 'One or more unexpected \\r (^M) found;' -- cgit v1.2.3-59-g8ed1b From 08fc03ae5dded4adc9b45b7014a4b9dfedbe95a6 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 26 Jun 2012 17:34:00 -0700 Subject: Include held locks in SIGQUIT thread dumps. Handy if you have an ANR that's locking related. Quick tour: at org.apache.harmony.dalvik.NativeTestTarget.emptyJniStaticSynchronizedMethod0(Native method) - locked <0x60135aa8> (a java.lang.Class) at java.lang.reflect.Method.invoke(Native method) at C.whileTrue(Main.java:63) at C.synchronizedOnClassString(Main.java:56) - locked <0x60002a70> (a java.lang.Class) at C.nestedSynchronizationWithTryCatch(Main.java:44) - locked <0x61336b90> (a java.lang.String) - locked <0x61336bd0> (a java.lang.String) at C.nestedSynchronization(Main.java:35) - locked <0x61336b18> (a java.lang.String) - locked <0x61336b50> (a java.lang.String) at C.synchronizedOnClassC(Main.java:30) - locked <0x613366f8> (a java.lang.Class) at C.noLocks(Main.java:27) at C.(Main.java:24) - locked <0x613366f8> (a java.lang.Class) at Main.main(Main.java:19) A non-static synchronized native method works too: at org.apache.harmony.dalvik.NativeTestTarget.emptyJniSynchronizedMethod0(Native method) - locked <0x613371a8> (a org.apache.harmony.dalvik.NativeTestTarget) ... Note that most stack traces don't look any different; the above is a pathological example that exercises different kinds of locking. Testing with system_server shows most threads don't hold any locks. Future work (marked by TODO) is that explicit JNI MonitorEnter calls in native code aren't shown. Change-Id: I2747f5cddb4ef64b1935736f084a68fe8e4005e9 --- src/debugger.cc | 22 +++++----- src/monitor.cc | 70 +++++++++++++++++++++++++++++- src/monitor.h | 2 + src/native/dalvik_system_VMStack.cc | 6 ++- src/nth_caller_visitor.h | 6 ++- src/stack.cc | 7 ++- src/stack.h | 13 ++++-- src/stl_util.h | 8 ++++ src/thread.cc | 34 +++++++++------ src/trace.cc | 2 +- src/verifier/method_verifier.cc | 33 ++++++++++++++ src/verifier/method_verifier.h | 12 +++++ src/verifier/register_line.h | 8 ++++ test/ReferenceMap/stack_walk_refmap_jni.cc | 2 +- test/StackWalk/stack_walk_jni.cc | 4 +- tools/cpplint.py | 10 ++++- 16 files changed, 199 insertions(+), 40 deletions(-) (limited to 'tools/cpplint.py') diff --git a/src/debugger.cc b/src/debugger.cc index 147a9b65db..9dcdda5dde 100644 --- a/src/debugger.cc +++ b/src/debugger.cc @@ -1489,7 +1489,7 @@ static int GetStackDepth(Thread* thread) { struct CountStackDepthVisitor : public StackVisitor { CountStackDepthVisitor(const ManagedStack* stack, const std::vector* trace_stack) - : StackVisitor(stack, trace_stack), depth(0) {} + : StackVisitor(stack, trace_stack, NULL), depth(0) {} bool VisitFrame() { if (!GetMethod()->IsRuntimeMethod()) { @@ -1499,6 +1499,7 @@ static int GetStackDepth(Thread* thread) { } size_t depth; }; + CountStackDepthVisitor visitor(thread->GetManagedStack(), thread->GetTraceStack()); visitor.WalkStack(); return visitor.depth; @@ -1515,7 +1516,7 @@ JDWP::JdwpError Dbg::GetThreadFrames(JDWP::ObjectId thread_id, size_t start_fram public: GetFrameVisitor(const ManagedStack* stack, const std::vector* trace_stack, size_t start_frame, size_t frame_count, JDWP::ExpandBuf* buf) - : StackVisitor(stack, trace_stack), depth_(0), + : StackVisitor(stack, trace_stack, NULL), depth_(0), start_frame_(start_frame), frame_count_(frame_count), buf_(buf) { expandBufAdd4BE(buf_, frame_count_); } @@ -1621,7 +1622,7 @@ static Object* GetThis(Method** quickFrame) { struct FrameIdVisitor : public StackVisitor { FrameIdVisitor(const ManagedStack* stack, const std::vector* trace_stack, Method** m) - : StackVisitor(stack, trace_stack), quick_frame_to_find(m) , frame_id(0) {} + : StackVisitor(stack, trace_stack, NULL), quick_frame_to_find(m) , frame_id(0) {} virtual bool VisitFrame() { if (quick_frame_to_find != GetCurrentQuickFrame()) { @@ -1779,11 +1780,11 @@ void Dbg::GetLocalValue(JDWP::ObjectId threadId, JDWP::FrameId frameId, int slot void Dbg::SetLocalValue(JDWP::ObjectId threadId, JDWP::FrameId frameId, int slot, JDWP::JdwpTag tag, uint64_t value, size_t width) { struct SetLocalVisitor : public StackVisitor { - SetLocalVisitor(const ManagedStack* stack, const std::vector* trace_stack, + SetLocalVisitor(const ManagedStack* stack, const std::vector* trace_stack, Context* context, JDWP::FrameId frame_id, int slot, JDWP::JdwpTag tag, uint64_t value, size_t width) - : StackVisitor(stack, trace_stack), frame_id_(frame_id), slot_(slot), tag_(tag), - value_(value), width_(width) {} + : StackVisitor(stack, trace_stack, context), + frame_id_(frame_id), slot_(slot), tag_(tag), value_(value), width_(width) {} bool VisitFrame() { if (GetFrameId() != frame_id_) { @@ -1841,8 +1842,9 @@ void Dbg::SetLocalValue(JDWP::ObjectId threadId, JDWP::FrameId frameId, int slot const size_t width_; }; Thread* thread = DecodeThread(threadId); - SetLocalVisitor visitor(thread->GetManagedStack(), thread->GetTraceStack(), frameId, slot, tag, - value, width); + UniquePtr context(Context::Create()); + SetLocalVisitor visitor(thread->GetManagedStack(), thread->GetTraceStack(), context.get(), + frameId, slot, tag, value, width); visitor.WalkStack(); } @@ -2060,7 +2062,7 @@ JDWP::JdwpError Dbg::ConfigureStep(JDWP::ObjectId threadId, JDWP::JdwpStepSize s struct SingleStepStackVisitor : public StackVisitor { SingleStepStackVisitor(const ManagedStack* stack, const std::vector* trace_stack) - : StackVisitor(stack, trace_stack) { + : StackVisitor(stack, trace_stack, NULL) { MutexLock mu(gBreakpointsLock); // Keep GCC happy. gSingleStepControl.method = NULL; gSingleStepControl.stack_depth = 0; @@ -2955,7 +2957,7 @@ void Dbg::SetAllocTrackingEnabled(bool enabled) { struct AllocRecordStackVisitor : public StackVisitor { AllocRecordStackVisitor(const ManagedStack* stack, const std::vector* trace_stack, AllocRecord* record) - : StackVisitor(stack, trace_stack), record(record), depth(0) {} + : StackVisitor(stack, trace_stack, NULL), record(record), depth(0) {} bool VisitFrame() { if (depth >= kMaxAllocRecordStackDepth) { diff --git a/src/monitor.cc b/src/monitor.cc index de08b88447..e5e867a38c 100644 --- a/src/monitor.cc +++ b/src/monitor.cc @@ -24,7 +24,10 @@ #include #include +#include + #include "class_linker.h" +#include "dex_instruction.h" #include "mutex.h" #include "object.h" #include "object_utils.h" @@ -33,6 +36,7 @@ #include "stl_util.h" #include "thread.h" #include "thread_list.h" +#include "verifier/method_verifier.h" #include "well_known_classes.h" namespace art { @@ -867,11 +871,10 @@ void Monitor::DescribeWait(std::ostream& os, const Thread* thread) { // We're not waiting on anything. return; } - os << "<" << object << ">"; // - waiting on <0x613f83d8> (a java.lang.ThreadLock) held by thread 5 // - waiting on <0x6008c468> (a java.lang.Class) - os << " (a " << PrettyTypeOf(object) << ")"; + os << "<" << object << "> (a " << PrettyTypeOf(object) << ")"; if (lock_owner != ThreadList::kInvalidId) { os << " held by thread " << lock_owner; @@ -880,6 +883,69 @@ void Monitor::DescribeWait(std::ostream& os, const Thread* thread) { os << "\n"; } +static void DumpLockedObject(std::ostream& os, Object* o) { + os << " - locked <" << o << "> (a " << PrettyTypeOf(o) << ")\n"; +} + +void Monitor::DescribeLocks(std::ostream& os, StackVisitor* stack_visitor) { + Method* m = stack_visitor->GetMethod(); + CHECK(m != NULL); + + // Native methods are an easy special case. + // TODO: use the JNI implementation's table of explicit MonitorEnter calls and dump those too. + if (m->IsNative()) { + if (m->IsSynchronized()) { + Object* jni_this = stack_visitor->GetCurrentSirt()->GetReference(0); + DumpLockedObject(os, jni_this); + } + return; + } + + // is another special case. The runtime holds the class lock while calling . + MethodHelper mh(m); + if (mh.IsClassInitializer()) { + DumpLockedObject(os, m->GetDeclaringClass()); + // Fall through because there might be synchronization in the user code too. + } + + // Is there any reason to believe there's any synchronization in this method? + const DexFile::CodeItem* code_item = mh.GetCodeItem(); + CHECK(code_item != NULL); + if (code_item->tries_size_ == 0) { + return; // No "tries" implies no synchronization, so no held locks to report. + } + + // Ask the verifier for the dex pcs of all the monitor-enter instructions corresponding to + // the locks held in this stack frame. + std::vector monitor_enter_dex_pcs; + verifier::MethodVerifier::FindLocksAtDexPc(m, stack_visitor->GetDexPc(), monitor_enter_dex_pcs); + if (monitor_enter_dex_pcs.empty()) { + return; + } + + // Verification is an iterative process, so it can visit the same monitor-enter instruction + // repeatedly with increasingly accurate type information. Our callers don't want to see + // duplicates. + STLSortAndRemoveDuplicates(&monitor_enter_dex_pcs); + + for (size_t i = 0; i < monitor_enter_dex_pcs.size(); ++i) { + // The verifier works in terms of the dex pcs of the monitor-enter instructions. + // We want the registers used by those instructions (so we can read the values out of them). + uint32_t dex_pc = monitor_enter_dex_pcs[i]; + uint16_t monitor_enter_instruction = code_item->insns_[dex_pc]; + + // Quick sanity check. + if ((monitor_enter_instruction & 0xff) != Instruction::MONITOR_ENTER) { + LOG(FATAL) << "expected monitor-enter @" << dex_pc << "; was " + << reinterpret_cast(monitor_enter_instruction); + } + + uint16_t monitor_register = ((monitor_enter_instruction >> 8) & 0xff); + Object* o = reinterpret_cast(stack_visitor->GetVReg(m, monitor_register)); + DumpLockedObject(os, o); + } +} + void Monitor::TranslateLocation(const Method* method, uint32_t dex_pc, const char*& source_file, uint32_t& line_number) const { // If method is null, location is unknown diff --git a/src/monitor.h b/src/monitor.h index 300e5a520d..d72ff73d4f 100644 --- a/src/monitor.h +++ b/src/monitor.h @@ -58,6 +58,7 @@ namespace art { class Method; class Object; class Thread; +class StackVisitor; class Monitor { public: @@ -76,6 +77,7 @@ class Monitor { static void Wait(Thread* self, Object* obj, int64_t ms, int32_t ns, bool interruptShouldThrow); static void DescribeWait(std::ostream& os, const Thread* thread); + static void DescribeLocks(std::ostream& os, StackVisitor* stack_visitor); Object* GetObject(); diff --git a/src/native/dalvik_system_VMStack.cc b/src/native/dalvik_system_VMStack.cc index 933a5d5b10..12fa8db904 100644 --- a/src/native/dalvik_system_VMStack.cc +++ b/src/native/dalvik_system_VMStack.cc @@ -56,8 +56,9 @@ static jobject VMStack_getClosestUserClassLoader(JNIEnv* env, jclass, jobject ja ClosestUserClassLoaderVisitor(const ManagedStack* stack, const std::vector* trace_stack, Object* bootstrap, Object* system) - : StackVisitor(stack, trace_stack), bootstrap(bootstrap), system(system), - class_loader(NULL) {} + : StackVisitor(stack, trace_stack, NULL), + bootstrap(bootstrap), system(system), class_loader(NULL) {} + bool VisitFrame() { DCHECK(class_loader == NULL); Class* c = GetMethod()->GetDeclaringClass(); @@ -68,6 +69,7 @@ static jobject VMStack_getClosestUserClassLoader(JNIEnv* env, jclass, jobject ja } return true; } + Object* bootstrap; Object* system; Object* class_loader; diff --git a/src/nth_caller_visitor.h b/src/nth_caller_visitor.h index db4d28cc10..0f29ae720f 100644 --- a/src/nth_caller_visitor.h +++ b/src/nth_caller_visitor.h @@ -24,8 +24,9 @@ namespace art { // Walks up the stack 'n' callers, when used with Thread::WalkStack. struct NthCallerVisitor : public StackVisitor { - NthCallerVisitor(const ManagedStack* stack, const std::vector* trace_stack, - size_t n) : StackVisitor(stack, trace_stack), n(n), count(0), caller(NULL) {} + NthCallerVisitor(const ManagedStack* stack, const std::vector* trace_stack, size_t n) + : StackVisitor(stack, trace_stack, NULL), n(n), count(0), caller(NULL) {} + bool VisitFrame() { DCHECK(caller == NULL); if (count++ == n) { @@ -34,6 +35,7 @@ struct NthCallerVisitor : public StackVisitor { } return true; } + size_t n; size_t count; Method* caller; diff --git a/src/stack.cc b/src/stack.cc index e7c632c439..c419530e37 100644 --- a/src/stack.cc +++ b/src/stack.cc @@ -27,7 +27,7 @@ namespace art { class StackGetter { public: StackGetter(const ScopedJniThreadState& ts, Thread* thread) - : ts_(ts), thread_(thread), trace_(NULL) { + : ts_(ts), thread_(thread), trace_(NULL) { } static void Callback(void* arg) { @@ -106,6 +106,7 @@ uint32_t StackVisitor::GetDexPc() const { } uint32_t StackVisitor::GetVReg(Method* m, int vreg) const { + DCHECK(context_ != NULL); // You can't reliably read registers without a context. DCHECK(m == GetMethod()); uint32_t core_spills = m->GetCoreSpillMask(); const VmapTable vmap_table(m->GetVmapTableRaw()); @@ -135,6 +136,7 @@ uint32_t StackVisitor::GetVReg(Method* m, int vreg) const { } void StackVisitor::SetVReg(Method* m, int vreg, uint32_t new_value) { + DCHECK(context_ != NULL); // You can't reliably write registers without a context. DCHECK(m == GetMethod()); const VmapTable vmap_table(m->GetVmapTableRaw()); uint32_t vmap_offset; @@ -174,12 +176,13 @@ size_t StackVisitor::ComputeNumFrames() const { struct NumFramesVisitor : public StackVisitor { explicit NumFramesVisitor(const ManagedStack* stack, const std::vector* trace_stack) - : StackVisitor(stack, trace_stack), frames(0) {} + : StackVisitor(stack, trace_stack, NULL), frames(0) {} virtual bool VisitFrame() { frames++; return true; } + size_t frames; }; diff --git a/src/stack.h b/src/stack.h index ff0bcd0356..254451d71e 100644 --- a/src/stack.h +++ b/src/stack.h @@ -31,6 +31,7 @@ namespace art { class Method; class Object; class ShadowFrame; +class StackIndirectReferenceTable; class ScopedJniThreadState; class Thread; @@ -215,7 +216,7 @@ class PACKED ManagedStack { class StackVisitor { protected: StackVisitor(const ManagedStack* stack, const std::vector* trace_stack, - Context* context = NULL) + Context* context) : stack_start_(stack), trace_stack_(trace_stack), cur_shadow_frame_(NULL), cur_quick_frame_(NULL), cur_quick_frame_pc_(0), num_frames_(0), cur_depth_(0), context_(context) {} @@ -256,12 +257,12 @@ class StackVisitor { uint32_t GetDexPc() const; - // Gets the height of the stack in the managed stack frames, including transitions. + // Returns the height of the stack in the managed stack frames, including transitions. size_t GetFrameHeight() { return GetNumFrames() - cur_depth_; } - // Get a frame ID where 0 is a special value. + // Returns a frame ID for JDWP use, starting from 1. size_t GetFrameId() { return GetFrameHeight() + 1; } @@ -359,6 +360,12 @@ class StackVisitor { return cur_shadow_frame_; } + StackIndirectReferenceTable* GetCurrentSirt() const { + Method** sp = GetCurrentQuickFrame(); + ++sp; // Skip Method*; SIRT comes next; + return reinterpret_cast(sp); + } + private: size_t ComputeNumFrames() const; diff --git a/src/stl_util.h b/src/stl_util.h index c0fe6b1330..1282cc4230 100644 --- a/src/stl_util.h +++ b/src/stl_util.h @@ -17,10 +17,18 @@ #ifndef ART_SRC_STL_UTIL_H_ #define ART_SRC_STL_UTIL_H_ +#include #include namespace art { +// Sort and remove duplicates of an STL vector or deque. +template +void STLSortAndRemoveDuplicates(T* v) { + std::sort(v->begin(), v->end()); + v->erase(std::unique(v->begin(), v->end()), v->end()); +} + // STLDeleteContainerPointers() // For a range within a container of pointers, calls delete // (non-array version) on these pointers. diff --git a/src/thread.cc b/src/thread.cc index 9f88f5a3e6..8fe016030a 100644 --- a/src/thread.cc +++ b/src/thread.cc @@ -519,9 +519,10 @@ void Thread::DumpState(std::ostream& os) const { } struct StackDumpVisitor : public StackVisitor { - StackDumpVisitor(std::ostream& os, const Thread* thread) - : StackVisitor(thread->GetManagedStack(), thread->GetTraceStack()), last_method(NULL), - last_line_number(0), repetition_count(0), os(os), thread(thread), frame_count(0) { + StackDumpVisitor(std::ostream& os, const Thread* thread, Context* context, bool can_allocate) + : StackVisitor(thread->GetManagedStack(), thread->GetTraceStack(), context), + os(os), thread(thread), can_allocate(can_allocate), + last_method(NULL), last_line_number(0), repetition_count(0), frame_count(0) { } virtual ~StackDumpVisitor() { @@ -565,19 +566,24 @@ struct StackDumpVisitor : public StackVisitor { << ":" << line_number << ")"; } os << "\n"; + if (frame_count == 0) { + Monitor::DescribeWait(os, thread); + } + if (can_allocate) { + Monitor::DescribeLocks(os, this); + } } - if (frame_count++ == 0) { - Monitor::DescribeWait(os, thread); - } + ++frame_count; return true; } + std::ostream& os; + const Thread* thread; + bool can_allocate; MethodHelper mh; Method* last_method; int last_line_number; int repetition_count; - std::ostream& os; - const Thread* thread; int frame_count; }; @@ -587,7 +593,8 @@ void Thread::DumpStack(std::ostream& os) const { DumpKernelStack(os, GetTid(), " kernel: ", false); DumpNativeStack(os, GetTid(), " native: ", false); } - StackDumpVisitor dumper(os, this); + UniquePtr context(Context::Create()); + StackDumpVisitor dumper(os, this, context.get(), !throwing_OutOfMemoryError_); dumper.WalkStack(); } @@ -999,7 +1006,8 @@ class CountStackDepthVisitor : public StackVisitor { public: CountStackDepthVisitor(const ManagedStack* stack, const std::vector* trace_stack) - : StackVisitor(stack, trace_stack), depth_(0), skip_depth_(0), skipping_(true) {} + : StackVisitor(stack, trace_stack, NULL), + depth_(0), skip_depth_(0), skipping_(true) {} bool VisitFrame() { // We want to skip frames up to and including the exception's constructor. @@ -1039,8 +1047,8 @@ class BuildInternalStackTraceVisitor : public StackVisitor { explicit BuildInternalStackTraceVisitor(const ManagedStack* stack, const std::vector* trace_stack, int skip_depth) - : StackVisitor(stack, trace_stack), skip_depth_(skip_depth), count_(0), dex_pc_trace_(NULL), - method_trace_(NULL) {} + : StackVisitor(stack, trace_stack, NULL), + skip_depth_(skip_depth), count_(0), dex_pc_trace_(NULL), method_trace_(NULL) {} bool Init(int depth, const ScopedJniThreadState& ts) { // Allocate method trace with an extra slot that will hold the PC trace @@ -1551,7 +1559,7 @@ Method* Thread::GetCurrentMethod(uint32_t* dex_pc, size_t* frame_id) const { struct CurrentMethodVisitor : public StackVisitor { CurrentMethodVisitor(const ManagedStack* stack, const std::vector* trace_stack) - : StackVisitor(stack, trace_stack), method_(NULL), dex_pc_(0), frame_id_(0) {} + : StackVisitor(stack, trace_stack, NULL), method_(NULL), dex_pc_(0), frame_id_(0) {} virtual bool VisitFrame() { Method* m = GetMethod(); diff --git a/src/trace.cc b/src/trace.cc index 6b5d668f2a..cd594cf65b 100644 --- a/src/trace.cc +++ b/src/trace.cc @@ -197,7 +197,7 @@ static bool UninstallStubsClassVisitor(Class* klass, void*) { static void TraceRestoreStack(Thread* self, void*) { struct RestoreStackVisitor : public StackVisitor { RestoreStackVisitor(Thread* self) - : StackVisitor(self->GetManagedStack(), self->GetTraceStack()), self_(self) {} + : StackVisitor(self->GetManagedStack(), self->GetTraceStack(), NULL), self_(self) {} virtual bool VisitFrame() { if (self_->IsTraceStackEmpty()) { diff --git a/src/verifier/method_verifier.cc b/src/verifier/method_verifier.cc index 178c2a92dd..908217218d 100644 --- a/src/verifier/method_verifier.cc +++ b/src/verifier/method_verifier.cc @@ -328,12 +328,35 @@ MethodVerifier::MethodVerifier(const DexFile* dex_file, DexCache* dex_cache, class_loader_(class_loader), class_def_idx_(class_def_idx), code_item_(code_item), + interesting_dex_pc_(-1), + monitor_enter_dex_pcs_(NULL), have_pending_hard_failure_(false), have_pending_rewrite_failure_(false), new_instance_count_(0), monitor_enter_count_(0) { } +void MethodVerifier::FindLocksAtDexPc(Method* m, uint32_t dex_pc, std::vector& monitor_enter_dex_pcs) { + MethodHelper mh(m); + MethodVerifier verifier(&mh.GetDexFile(), mh.GetDexCache(), mh.GetClassLoader(), + mh.GetClassDefIndex(), mh.GetCodeItem(), m->GetDexMethodIndex(), + m, m->GetAccessFlags()); + verifier.interesting_dex_pc_ = dex_pc; + verifier.monitor_enter_dex_pcs_ = &monitor_enter_dex_pcs; + verifier.FindLocksAtDexPc(); +} + +void MethodVerifier::FindLocksAtDexPc() { + CHECK(monitor_enter_dex_pcs_ != NULL); + CHECK(code_item_ != NULL); // This only makes sense for methods with code. + + // Strictly speaking, we ought to be able to get away with doing a subset of the full method + // verification. In practice, the phase we want relies on data structures set up by all the + // earlier passes, so we just run the full method verification and bail out early when we've + // got what we wanted. + Verify(); +} + bool MethodVerifier::Verify() { // If there aren't any instructions, make sure that's expected, then exit successfully. if (code_item_ == NULL) { @@ -1276,6 +1299,16 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { } #endif + // If we're doing FindLocksAtDexPc, check whether we're at the dex pc we care about. + // We want the state _before_ the instruction, for the case where the dex pc we're + // interested in is itself a monitor-enter instruction (which is a likely place + // for a thread to be suspended). + if (monitor_enter_dex_pcs_ != NULL && work_insn_idx_ == interesting_dex_pc_) { + for (size_t i = 0; i < work_line_->GetMonitorEnterCount(); ++i) { + monitor_enter_dex_pcs_->push_back(work_line_->GetMonitorEnterDexPc(i)); + } + } + /* * Once we finish decoding the instruction, we need to figure out where * we can go from here. There are three possible ways to transfer diff --git a/src/verifier/method_verifier.h b/src/verifier/method_verifier.h index 64a723ef2e..8eef71aa37 100644 --- a/src/verifier/method_verifier.h +++ b/src/verifier/method_verifier.h @@ -202,6 +202,10 @@ class MethodVerifier { static const std::vector* GetGcMap(Compiler::MethodReference ref); + // Fills 'monitor_enter_dex_pcs' with the dex pcs of the monitor-enter instructions corresponding + // to the locks held at 'dex_pc' in 'm'. + static void FindLocksAtDexPc(Method* m, uint32_t dex_pc, std::vector& monitor_enter_dex_pcs); + static void Init(); static void Shutdown(); @@ -242,6 +246,8 @@ class MethodVerifier { // has an irrecoverable corruption. bool Verify(); + void FindLocksAtDexPc(); + /* * Compute the width of the instruction at each address in the instruction stream, and store it in * insn_flags_. Addresses that are in the middle of an instruction, or that are part of switch @@ -617,6 +623,12 @@ class MethodVerifier { const DexFile::CodeItem* code_item_; // The code item containing the code for the method. UniquePtr insn_flags_; // Instruction widths and flags, one entry per code unit. + // The dex PC of a FindLocksAtDexPc request, -1 otherwise. + uint32_t interesting_dex_pc_; + // The container into which FindLocksAtDexPc should write the registers containing held locks, + // NULL if we're not doing FindLocksAtDexPc. + std::vector* monitor_enter_dex_pcs_; + // The types of any error that occurs. std::vector failures_; // Error messages associated with failures. diff --git a/src/verifier/register_line.h b/src/verifier/register_line.h index e501e1347e..e4066783bd 100644 --- a/src/verifier/register_line.h +++ b/src/verifier/register_line.h @@ -230,6 +230,14 @@ class RegisterLine { // Write a bit at each register location that holds a reference void WriteReferenceBitMap(std::vector& data, size_t max_bytes); + size_t GetMonitorEnterCount() { + return monitors_.size(); + } + + uint32_t GetMonitorEnterDexPc(size_t i) { + return monitors_[i]; + } + private: void CopyRegToLockDepth(size_t dst, size_t src) { SafeMap::iterator it = reg_to_lock_depths_.find(src); diff --git a/test/ReferenceMap/stack_walk_refmap_jni.cc b/test/ReferenceMap/stack_walk_refmap_jni.cc index d7910af222..ddda260cd5 100644 --- a/test/ReferenceMap/stack_walk_refmap_jni.cc +++ b/test/ReferenceMap/stack_walk_refmap_jni.cc @@ -43,7 +43,7 @@ namespace art { struct ReferenceMap2Visitor : public StackVisitor { explicit ReferenceMap2Visitor(const ManagedStack* stack, const std::vector* trace_stack) : - StackVisitor(stack, trace_stack) { + StackVisitor(stack, trace_stack, NULL) { } bool VisitFrame() { diff --git a/test/StackWalk/stack_walk_jni.cc b/test/StackWalk/stack_walk_jni.cc index 37731981ff..9382b8ffab 100644 --- a/test/StackWalk/stack_walk_jni.cc +++ b/test/StackWalk/stack_walk_jni.cc @@ -40,8 +40,8 @@ static int gJava_StackWalk_refmap_calls = 0; struct TestReferenceMapVisitor : public StackVisitor { explicit TestReferenceMapVisitor(const ManagedStack* stack, - const std::vector* trace_stack) : - StackVisitor(stack, trace_stack) { + const std::vector* trace_stack) + : StackVisitor(stack, trace_stack, NULL) { } bool VisitFrame() { diff --git a/tools/cpplint.py b/tools/cpplint.py index 526b9556dc..ff92d70f06 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -2568,7 +2568,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, # probably a member operator declaration or default constructor. match = Search( r'(\bnew\s+)?\b' # Grab 'new' operator, if it's there - r'(int|float|double|bool|char|int32|uint32|int64|uint64)\([^)]', line) + r'(int|float|double|bool|char|u?int(8|16|32|64)_t)\([^)]', line) # TODO(enh): upstream change to handle all stdint types. if match: # gMock methods are defined using some variant of MOCK_METHODx(name, type) # where type may be float(), int(string), etc. Without context they are @@ -2585,7 +2585,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], 'static_cast', - r'\((int|float|double|bool|char|u?int(16|32|64))\)', error) + r'\((int|float|double|bool|char|u?int(8|16|32|64))\)', error) # TODO(enh): upstream change to handle all stdint types. # This doesn't catch all cases. Consider (const char * const)"hello". # @@ -3300,6 +3300,7 @@ def ParseArguments(args): """ try: (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', + 'stdout', # TODO(enh): added --stdout 'counting=', 'filter=']) except getopt.GetoptError: @@ -3307,12 +3308,15 @@ def ParseArguments(args): verbosity = _VerboseLevel() output_format = _OutputFormat() + output_stream = sys.stderr # TODO(enh): added --stdout filters = '' counting_style = '' for (opt, val) in opts: if opt == '--help': PrintUsage(None) + elif opt == '--stdout': # TODO(enh): added --stdout + output_stream = sys.stdout # TODO(enh): added --stdout elif opt == '--output': if not val in ('emacs', 'vs7'): PrintUsage('The only allowed output formats are emacs and vs7.') @@ -3336,6 +3340,8 @@ def ParseArguments(args): _SetFilters(filters) _SetCountingStyle(counting_style) + sys.stderr = output_stream # TODO(enh): added --stdout + return filenames -- cgit v1.2.3-59-g8ed1b From fc0e3219edc9a5bf81b166e82fd5db2796eb6a0d Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Wed, 17 Jul 2013 14:40:12 -0700 Subject: Fix multiple inclusion guards to match new pathnames Change-Id: Id7735be1d75bc315733b1773fba45c1deb8ace43 --- Android.mk | 20 +++++++++++++++----- compiler/dex/arena_allocator.h | 6 +++--- compiler/dex/arena_bit_vector.h | 6 +++--- compiler/dex/backend.h | 6 +++--- compiler/dex/compiler_enums.h | 6 +++--- compiler/dex/compiler_internals.h | 6 +++--- compiler/dex/compiler_ir.h | 6 +++--- compiler/dex/dataflow_iterator-inl.h | 6 +++--- compiler/dex/dataflow_iterator.h | 6 +++--- compiler/dex/frontend.h | 6 +++--- compiler/dex/growable_array.h | 6 +++--- compiler/dex/local_value_numbering.h | 6 +++--- compiler/dex/mir_graph.h | 6 +++--- compiler/dex/portable/mir_to_gbc.h | 6 +++--- compiler/dex/quick/arm/arm_lir.h | 6 +++--- compiler/dex/quick/arm/codegen_arm.h | 6 +++--- compiler/dex/quick/mips/codegen_mips.h | 6 +++--- compiler/dex/quick/mips/mips_lir.h | 6 +++--- compiler/dex/quick/mir_to_lir-inl.h | 6 +++--- compiler/dex/quick/mir_to_lir.h | 6 +++--- compiler/dex/quick/x86/codegen_x86.h | 6 +++--- compiler/dex/quick/x86/x86_lir.h | 6 +++--- compiler/driver/compiler_driver.h | 6 +++--- compiler/driver/dex_compilation_unit.h | 6 +++--- compiler/elf_fixup.h | 6 +++--- compiler/elf_stripper.h | 6 +++--- compiler/elf_writer.h | 6 +++--- compiler/elf_writer_mclinker.h | 6 +++--- compiler/elf_writer_quick.h | 6 +++--- compiler/image_writer.h | 6 +++--- compiler/jni/portable/jni_compiler.h | 6 +++--- compiler/jni/quick/arm/calling_convention_arm.h | 6 +++--- compiler/jni/quick/calling_convention.h | 6 +++--- compiler/jni/quick/mips/calling_convention_mips.h | 6 +++--- compiler/jni/quick/x86/calling_convention_x86.h | 6 +++--- compiler/llvm/backend_options.h | 6 +++--- compiler/llvm/backend_types.h | 6 +++--- compiler/llvm/compiler_llvm.h | 6 +++--- compiler/llvm/intrinsic_helper.h | 6 +++--- compiler/llvm/ir_builder.h | 6 +++--- compiler/llvm/llvm_compilation_unit.h | 6 +++--- compiler/llvm/md_builder.h | 6 +++--- compiler/llvm/runtime_support_builder.h | 6 +++--- compiler/llvm/runtime_support_builder_arm.h | 6 +++--- compiler/llvm/runtime_support_builder_thumb2.h | 6 +++--- compiler/llvm/runtime_support_builder_x86.h | 6 +++--- compiler/llvm/runtime_support_llvm_func.h | 6 +++--- compiler/llvm/utils_llvm.h | 6 +++--- compiler/oat_writer.h | 6 +++--- compiler/sea_ir/instruction_tools.h | 6 +++--- compiler/sea_ir/sea.h | 6 +++--- compiler/stubs/stubs.h | 6 +++--- jdwpspy/Common.h | 6 +++--- runtime/asm_support.h | 6 +++--- runtime/atomic.h | 6 +++--- runtime/atomic_integer.h | 6 +++--- runtime/barrier.h | 6 +++--- runtime/base/casts.h | 6 +++--- runtime/base/histogram-inl.h | 6 +++--- runtime/base/histogram.h | 6 +++--- runtime/base/logging.h | 6 +++--- runtime/base/macros.h | 6 +++--- runtime/base/mutex-inl.h | 6 +++--- runtime/base/mutex.h | 6 +++--- runtime/base/stl_util.h | 6 +++--- runtime/base/stringpiece.h | 6 +++--- runtime/base/stringprintf.h | 6 +++--- runtime/base/timing_logger.h | 6 +++--- runtime/base/unix_file/fd_file.h | 6 +++--- runtime/base/unix_file/mapped_file.h | 6 +++--- runtime/base/unix_file/null_file.h | 6 +++--- runtime/base/unix_file/random_access_file.h | 6 +++--- runtime/base/unix_file/random_access_file_test.h | 6 +++--- runtime/base/unix_file/random_access_file_utils.h | 6 +++--- runtime/base/unix_file/string_file.h | 6 +++--- runtime/class_linker-inl.h | 6 +++--- runtime/class_linker.h | 6 +++--- runtime/class_reference.h | 6 +++--- runtime/closure.h | 6 +++--- runtime/common_test.h | 5 +++++ runtime/common_throws.h | 6 +++--- runtime/compiled_class.h | 6 +++--- runtime/compiled_method.h | 6 +++--- runtime/constants_arm.h | 6 +++--- runtime/constants_mips.h | 6 +++--- runtime/constants_x86.h | 6 +++--- runtime/debugger.h | 6 +++--- runtime/dex_file-inl.h | 6 +++--- runtime/dex_file.h | 6 +++--- runtime/dex_file_verifier.h | 6 +++--- runtime/dex_instruction-inl.h | 6 +++--- runtime/dex_instruction.h | 6 +++--- runtime/dex_instruction_list.h | 6 ++++++ runtime/dex_instruction_visitor.h | 6 +++--- runtime/dex_method_iterator.h | 6 +++--- runtime/disassembler.h | 6 +++--- runtime/disassembler_arm.h | 6 +++--- runtime/disassembler_mips.h | 6 +++--- runtime/disassembler_x86.h | 6 +++--- runtime/elf_file.h | 6 +++--- runtime/file_output_stream.h | 6 +++--- runtime/gc/accounting/atomic_stack.h | 6 +++--- runtime/gc/accounting/card_table-inl.h | 6 +++--- runtime/gc/accounting/card_table.h | 6 +++--- runtime/gc/accounting/heap_bitmap-inl.h | 6 +++--- runtime/gc/accounting/heap_bitmap.h | 6 +++--- runtime/gc/accounting/mod_union_table-inl.h | 6 +++--- runtime/gc/accounting/mod_union_table.h | 6 +++--- runtime/gc/accounting/space_bitmap-inl.h | 6 +++--- runtime/gc/accounting/space_bitmap.h | 6 +++--- runtime/gc/allocator/dlmalloc.h | 6 +++--- runtime/gc/collector/garbage_collector.h | 6 +++--- runtime/gc/collector/gc_type.h | 6 +++--- runtime/gc/collector/mark_sweep-inl.h | 6 +++--- runtime/gc/collector/mark_sweep.h | 6 +++--- runtime/gc/collector/partial_mark_sweep.h | 6 +++--- runtime/gc/collector/sticky_mark_sweep.h | 6 +++--- runtime/gc/heap.h | 6 +++--- runtime/gc/space/dlmalloc_space.h | 6 +++--- runtime/gc/space/image_space.h | 6 +++--- runtime/gc/space/large_object_space.h | 6 +++--- runtime/gc/space/space-inl.h | 6 +++--- runtime/gc/space/space.h | 6 +++--- runtime/gc_map.h | 6 +++--- runtime/globals.h | 6 +++--- runtime/hprof/hprof.h | 6 +++--- runtime/image.h | 6 +++--- runtime/indenter.h | 6 +++--- runtime/indirect_reference_table.h | 6 +++--- runtime/instruction_set.h | 6 +++--- runtime/instrumentation.h | 6 +++--- runtime/intern_table.h | 6 +++--- runtime/interpreter/interpreter.h | 6 +++--- runtime/invoke_arg_array_builder.h | 6 +++--- runtime/invoke_type.h | 6 +++--- runtime/jdwp/jdwp.h | 6 +++--- runtime/jdwp/jdwp_bits.h | 6 +++--- runtime/jdwp/jdwp_constants.h | 6 +++--- runtime/jdwp/jdwp_event.h | 6 +++--- runtime/jdwp/jdwp_expand_buf.h | 6 +++--- runtime/jdwp/jdwp_priv.h | 6 +++--- runtime/jdwp/object_registry.h | 5 +++++ runtime/jni_internal.h | 6 +++--- runtime/jobject_comparator.h | 6 +++--- runtime/jvalue.h | 6 +++--- runtime/leb128.h | 6 +++--- runtime/locks.h | 6 +++--- runtime/log_severity.h | 6 +++--- runtime/mem_map.h | 6 +++--- runtime/memory_region.h | 6 +++--- runtime/method_reference.h | 6 +++--- runtime/mirror/abstract_method-inl.h | 6 +++--- runtime/mirror/abstract_method.h | 6 +++--- runtime/mirror/array-inl.h | 6 +++--- runtime/mirror/array.h | 6 +++--- runtime/mirror/class-inl.h | 6 +++--- runtime/mirror/class.h | 6 +++--- runtime/mirror/class_loader.h | 6 +++--- runtime/mirror/dex_cache-inl.h | 6 +++--- runtime/mirror/dex_cache.h | 6 +++--- runtime/mirror/field-inl.h | 6 +++--- runtime/mirror/field.h | 6 +++--- runtime/mirror/iftable-inl.h | 6 +++--- runtime/mirror/iftable.h | 6 +++--- runtime/mirror/object-inl.h | 6 +++--- runtime/mirror/object.h | 6 +++--- runtime/mirror/object_array-inl.h | 6 +++--- runtime/mirror/object_array.h | 6 +++--- runtime/mirror/proxy.h | 6 +++--- runtime/mirror/stack_trace_element.h | 6 +++--- runtime/mirror/string.h | 6 +++--- runtime/mirror/throwable.h | 6 +++--- runtime/modifiers.h | 6 +++--- runtime/monitor.h | 6 +++--- runtime/nth_caller_visitor.h | 6 +++--- runtime/oat.h | 6 +++--- runtime/oat/runtime/argument_visitor.h | 6 +++--- runtime/oat/runtime/arm/context_arm.h | 6 +++--- runtime/oat/runtime/callee_save_frame.h | 6 +++--- runtime/oat/runtime/context.h | 6 +++--- runtime/oat/runtime/mips/context_mips.h | 6 +++--- runtime/oat/runtime/oat_support_entrypoints.h | 6 +++--- runtime/oat/runtime/x86/context_x86.h | 6 +++--- runtime/oat/utils/arm/assembler_arm.h | 6 +++--- runtime/oat/utils/arm/managed_register_arm.h | 6 +++--- runtime/oat/utils/assembler.h | 6 +++--- runtime/oat/utils/managed_register.h | 6 +++--- runtime/oat/utils/mips/assembler_mips.h | 6 +++--- runtime/oat/utils/mips/managed_register_mips.h | 6 +++--- runtime/oat/utils/x86/assembler_x86.h | 6 +++--- runtime/oat/utils/x86/managed_register_x86.h | 6 +++--- runtime/oat_file.h | 6 +++--- runtime/object_utils.h | 6 +++--- runtime/offsets.h | 6 +++--- runtime/os.h | 6 +++--- runtime/output_stream.h | 6 +++--- runtime/primitive.h | 6 +++--- runtime/reference_table.h | 6 +++--- runtime/reflection.h | 6 +++--- runtime/root_visitor.h | 6 +++--- runtime/runtime.h | 6 +++--- runtime/runtime_stats.h | 6 +++--- runtime/runtime_support.h | 6 +++--- runtime/runtime_support_llvm.h | 6 +++--- runtime/runtime_support_llvm_func_list.h | 6 ++++++ runtime/safe_map.h | 6 +++--- runtime/scoped_thread_state_change.h | 6 +++--- runtime/signal_catcher.h | 6 +++--- runtime/signal_set.h | 6 +++--- runtime/sirt_ref.h | 6 +++--- runtime/stack.h | 6 +++--- runtime/stack_indirect_reference_table.h | 6 +++--- runtime/strutil.h | 6 +++--- runtime/thread-inl.h | 6 +++--- runtime/thread.h | 6 +++--- runtime/thread_list.h | 6 +++--- runtime/thread_pool.h | 6 +++--- runtime/thread_state.h | 6 +++--- runtime/throw_location.h | 6 +++--- runtime/trace.h | 6 +++--- runtime/utf.h | 6 +++--- runtime/utils.h | 6 +++--- runtime/vector_output_stream.h | 6 +++--- runtime/verifier/dex_gc_map.h | 6 +++--- runtime/verifier/instruction_flags.h | 6 +++--- runtime/verifier/method_verifier.h | 6 +++--- runtime/verifier/reg_type.h | 6 +++--- runtime/verifier/reg_type_cache-inl.h | 6 +++--- runtime/verifier/reg_type_cache.h | 6 +++--- runtime/verifier/register_line-inl.h | 6 +++--- runtime/verifier/register_line.h | 6 +++--- runtime/well_known_classes.h | 6 +++--- runtime/zip_archive.h | 6 +++--- tools/cpplint.py | 7 +++++-- 234 files changed, 726 insertions(+), 691 deletions(-) (limited to 'tools/cpplint.py') diff --git a/Android.mk b/Android.mk index 4ffa9ac0ab..5a28723e8e 100644 --- a/Android.mk +++ b/Android.mk @@ -78,8 +78,11 @@ clean-oat-target: adb shell rm system/app/*.odex adb shell rm data/run-test/test-*/dalvik-cache/*@classes.dex +######################################################################## +# darwin build + # we aren't building most of art on darwin right now, but we do need to build new dalvikvm -ifeq ($(HOST_OS)-$(HOST_ARCH),darwin-x86) +ifeq ($(HOST_OS),darwin) art_dont_bother := true include $(art_path)/dalvikvm/Android.mk endif @@ -325,14 +328,21 @@ dump-oat-Calculator: $(TARGET_OUT_APPS)/Calculator.odex $(TARGET_BOOT_IMG_OUT) $ endif ######################################################################## -# cpplint target +# cpplint targets to style check art source files -# "mm cpplint-art" to style check art source files +# "mm cpplint-art" to verify we aren't regressing .PHONY: cpplint-art cpplint-art: ./art/tools/cpplint.py \ - --filter=-whitespace/comments,-whitespace/line_length,-build/include,-build/header_guard,-readability/function,-readability/streams,-readability/todo,-runtime/references \ - $(ANDROID_BUILD_TOP)/art/src/*.h $(ANDROID_BUILD_TOP)/art/src/*.cc + --filter=-,+build/header_guard, \ + $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION)) + +# "mm cpplint-art-aspirational" to see warnings we would like to fix +.PHONY: cpplint-art-aspirational +cpplint-art-aspirational: + ./art/tools/cpplint.py \ + --filter=-whitespace/comments,-whitespace/line_length,-build/include,-readability/function,-readability/streams,-readability/todo,-runtime/references \ + $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION)) ######################################################################## # targets to switch back and forth from libdvm to libart diff --git a/compiler/dex/arena_allocator.h b/compiler/dex/arena_allocator.h index 78d4614f90..23d6b9f06b 100644 --- a/compiler/dex/arena_allocator.h +++ b/compiler/dex/arena_allocator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_ARENA_ALLOCATOR_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_ARENA_ALLOCATOR_H_ +#ifndef ART_COMPILER_DEX_ARENA_ALLOCATOR_H_ +#define ART_COMPILER_DEX_ARENA_ALLOCATOR_H_ #include #include @@ -93,4 +93,4 @@ struct MemStats { } // namespace art -#endif // ART_SRC_COMPILER_DEX_COMPILER_ARENA_ALLOCATOR_H_ +#endif // ART_COMPILER_DEX_ARENA_ALLOCATOR_H_ diff --git a/compiler/dex/arena_bit_vector.h b/compiler/dex/arena_bit_vector.h index a950e82498..0b7bbc5f16 100644 --- a/compiler/dex/arena_bit_vector.h +++ b/compiler/dex/arena_bit_vector.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_ARENA_BIT_VECTOR_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_ARENA_BIT_VECTOR_H_ +#ifndef ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ +#define ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ #include #include @@ -124,4 +124,4 @@ class ArenaBitVector { } // namespace art -#endif // ART_SRC_COMPILER_DEX_COMPILER_ARENA_BIT_VECTOR_H_ +#endif // ART_COMPILER_DEX_ARENA_BIT_VECTOR_H_ diff --git a/compiler/dex/backend.h b/compiler/dex/backend.h index 45a1531b85..6f5ba388e1 100644 --- a/compiler/dex/backend.h +++ b/compiler/dex/backend.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_BACKEND_H_ -#define ART_SRC_COMPILER_DEX_BACKEND_H_ +#ifndef ART_COMPILER_DEX_BACKEND_H_ +#define ART_COMPILER_DEX_BACKEND_H_ #include "compiled_method.h" #include "arena_allocator.h" @@ -37,4 +37,4 @@ class Backend { } // namespace art -#endif // ART_SRC_COMPILER_DEX_BACKEND_H_ +#endif // ART_COMPILER_DEX_BACKEND_H_ diff --git a/compiler/dex/compiler_enums.h b/compiler/dex/compiler_enums.h index bc456b2e70..88240e8c40 100644 --- a/compiler/dex/compiler_enums.h +++ b/compiler/dex/compiler_enums.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILERENUMS_H_ -#define ART_SRC_COMPILER_DEX_COMPILERENUMS_H_ +#ifndef ART_COMPILER_DEX_COMPILER_ENUMS_H_ +#define ART_COMPILER_DEX_COMPILER_ENUMS_H_ #include "dex_instruction.h" @@ -414,4 +414,4 @@ std::ostream& operator<<(std::ostream& os, const OatBitMapKind& kind); } // namespace art -#endif // ART_SRC_COMPILER_DEX_COMPILERENUMS_H_ +#endif // ART_COMPILER_DEX_COMPILER_ENUMS_H_ diff --git a/compiler/dex/compiler_internals.h b/compiler/dex/compiler_internals.h index a3fa25e842..9dd0272e50 100644 --- a/compiler/dex/compiler_internals.h +++ b/compiler/dex/compiler_internals.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_INTERNAL_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_INTERNAL_H_ +#ifndef ART_COMPILER_DEX_COMPILER_INTERNALS_H_ +#define ART_COMPILER_DEX_COMPILER_INTERNALS_H_ #include #include @@ -33,4 +33,4 @@ #include "thread.h" #include "utils.h" -#endif // ART_SRC_COMPILER_DEX_COMPILER_INTERNAL_H_ +#endif // ART_COMPILER_DEX_COMPILER_INTERNALS_H_ diff --git a/compiler/dex/compiler_ir.h b/compiler/dex/compiler_ir.h index c6f99f3a88..a9b5bf68fc 100644 --- a/compiler/dex/compiler_ir.h +++ b/compiler/dex/compiler_ir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_IR_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_IR_H_ +#ifndef ART_COMPILER_DEX_COMPILER_IR_H_ +#define ART_COMPILER_DEX_COMPILER_IR_H_ #include #include @@ -112,4 +112,4 @@ struct CompilationUnit { } // namespace art -#endif // ART_SRC_COMPILER_DEX_COMPILER_IR_H_ +#endif // ART_COMPILER_DEX_COMPILER_IR_H_ diff --git a/compiler/dex/dataflow_iterator-inl.h b/compiler/dex/dataflow_iterator-inl.h index b20004decc..06cc505a9a 100644 --- a/compiler/dex/dataflow_iterator-inl.h +++ b/compiler/dex/dataflow_iterator-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ -#define ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ +#ifndef ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ +#define ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ #include "dataflow_iterator.h" @@ -65,4 +65,4 @@ inline BasicBlock* AllNodesIterator::NextBody(bool had_change) { } // namespace art -#endif // ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ +#endif // ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_ diff --git a/compiler/dex/dataflow_iterator.h b/compiler/dex/dataflow_iterator.h index 12cbf9cadf..4c112f9678 100644 --- a/compiler/dex/dataflow_iterator.h +++ b/compiler/dex/dataflow_iterator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_H_ -#define ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_H_ +#ifndef ART_COMPILER_DEX_DATAFLOW_ITERATOR_H_ +#define ART_COMPILER_DEX_DATAFLOW_ITERATOR_H_ #include "compiler_ir.h" #include "mir_graph.h" @@ -155,4 +155,4 @@ namespace art { } // namespace art -#endif // ART_SRC_COMPILER_DEX_DATAFLOW_ITERATOR_H_ +#endif // ART_COMPILER_DEX_DATAFLOW_ITERATOR_H_ diff --git a/compiler/dex/frontend.h b/compiler/dex/frontend.h index 69d7f7728c..a86338950c 100644 --- a/compiler/dex/frontend.h +++ b/compiler/dex/frontend.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_COMPILER_H_ -#define ART_SRC_COMPILER_DEX_COMPILER_H_ +#ifndef ART_COMPILER_DEX_FRONTEND_H_ +#define ART_COMPILER_DEX_FRONTEND_H_ #include "dex_file.h" #include "dex_instruction.h" @@ -123,4 +123,4 @@ extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, -#endif // ART_SRC_COMPILER_DEX_COMPILER_H_ +#endif // ART_COMPILER_DEX_FRONTEND_H_ diff --git a/compiler/dex/growable_array.h b/compiler/dex/growable_array.h index c4684a71f6..6ab0f1630a 100644 --- a/compiler/dex/growable_array.h +++ b/compiler/dex/growable_array.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_GROWABLE_LIST_H_ -#define ART_SRC_COMPILER_DEX_GROWABLE_LIST_H_ +#ifndef ART_COMPILER_DEX_GROWABLE_ARRAY_H_ +#define ART_COMPILER_DEX_GROWABLE_ARRAY_H_ #include #include @@ -168,4 +168,4 @@ class GrowableArray { } // namespace art -#endif // ART_SRC_COMPILER_DEX_GROWABLE_LIST_H_ +#endif // ART_COMPILER_DEX_GROWABLE_ARRAY_H_ diff --git a/compiler/dex/local_value_numbering.h b/compiler/dex/local_value_numbering.h index beb4cea733..f2b2291e56 100644 --- a/compiler/dex/local_value_numbering.h +++ b/compiler/dex/local_value_numbering.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ -#define ART_SRC_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ +#ifndef ART_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ +#define ART_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ #include "compiler_internals.h" @@ -140,4 +140,4 @@ class LocalValueNumbering { } // namespace art -#endif // ART_SRC_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ +#endif // ART_COMPILER_DEX_LOCAL_VALUE_NUMBERING_H_ diff --git a/compiler/dex/mir_graph.h b/compiler/dex/mir_graph.h index 2b1c21fd70..a40fa97ad5 100644 --- a/compiler/dex/mir_graph.h +++ b/compiler/dex/mir_graph.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_MIRGRAPH_H_ -#define ART_SRC_COMPILER_DEX_MIRGRAPH_H_ +#ifndef ART_COMPILER_DEX_MIR_GRAPH_H_ +#define ART_COMPILER_DEX_MIR_GRAPH_H_ #include "dex_file.h" #include "dex_instruction.h" @@ -667,4 +667,4 @@ class MIRGraph { } // namespace art -#endif // ART_SRC_COMPILER_DEX_MIRGRAPH_H_ +#endif // ART_COMPILER_DEX_MIR_GRAPH_H_ diff --git a/compiler/dex/portable/mir_to_gbc.h b/compiler/dex/portable/mir_to_gbc.h index 8aa0271761..278631466f 100644 --- a/compiler/dex/portable/mir_to_gbc.h +++ b/compiler/dex/portable/mir_to_gbc.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_PORTABLE_MIRTOGBC_H_ -#define ART_SRC_COMPILER_DEX_PORTABLE_MIRTOGBC_H_ +#ifndef ART_COMPILER_DEX_PORTABLE_MIR_TO_GBC_H_ +#define ART_COMPILER_DEX_PORTABLE_MIR_TO_GBC_H_ #include "invoke_type.h" #include "compiled_method.h" @@ -192,4 +192,4 @@ class MirConverter : public Backend { } // namespace art -#endif // ART_SRC_COMPILER_DEX_PORTABLE_MIRTOGBC_H_ +#endif // ART_COMPILER_DEX_PORTABLE_MIR_TO_GBC_H_ diff --git a/compiler/dex/quick/arm/arm_lir.h b/compiler/dex/quick/arm/arm_lir.h index 9dd7dafcd6..fca17a1640 100644 --- a/compiler/dex/quick/arm/arm_lir.h +++ b/compiler/dex/quick/arm/arm_lir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_ARM_ARMLIR_H_ -#define ART_SRC_COMPILER_DEX_QUICK_ARM_ARMLIR_H_ +#ifndef ART_COMPILER_DEX_QUICK_ARM_ARM_LIR_H_ +#define ART_COMPILER_DEX_QUICK_ARM_ARM_LIR_H_ #include "dex/compiler_internals.h" @@ -496,4 +496,4 @@ struct ArmEncodingMap { } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_ARM_ARMLIR_H_ +#endif // ART_COMPILER_DEX_QUICK_ARM_ARM_LIR_H_ diff --git a/compiler/dex/quick/arm/codegen_arm.h b/compiler/dex/quick/arm/codegen_arm.h index a9199dfa7c..1599941ef6 100644 --- a/compiler/dex/quick/arm/codegen_arm.h +++ b/compiler/dex/quick/arm/codegen_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_ARM_CODEGENARM_H_ -#define ART_SRC_COMPILER_DEX_QUICK_ARM_CODEGENARM_H_ +#ifndef ART_COMPILER_DEX_QUICK_ARM_CODEGEN_ARM_H_ +#define ART_COMPILER_DEX_QUICK_ARM_CODEGEN_ARM_H_ #include "dex/compiler_internals.h" @@ -192,4 +192,4 @@ class ArmMir2Lir : public Mir2Lir { } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_ARM_CODEGENARM_H_ +#endif // ART_COMPILER_DEX_QUICK_ARM_CODEGEN_ARM_H_ diff --git a/compiler/dex/quick/mips/codegen_mips.h b/compiler/dex/quick/mips/codegen_mips.h index 9723b899a9..376ad7f10e 100644 --- a/compiler/dex/quick/mips/codegen_mips.h +++ b/compiler/dex/quick/mips/codegen_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_QUICK_CODEGEN_MIPS_CODEGENMIPS_H_ -#define ART_SRC_DEX_QUICK_CODEGEN_MIPS_CODEGENMIPS_H_ +#ifndef ART_COMPILER_DEX_QUICK_MIPS_CODEGEN_MIPS_H_ +#define ART_COMPILER_DEX_QUICK_MIPS_CODEGEN_MIPS_H_ #include "dex/compiler_internals.h" #include "mips_lir.h" @@ -180,4 +180,4 @@ class MipsMir2Lir : public Mir2Lir { } // namespace art -#endif // ART_SRC_DEX_QUICK_CODEGEN_MIPS_CODEGENMIPS_H_ +#endif // ART_COMPILER_DEX_QUICK_MIPS_CODEGEN_MIPS_H_ diff --git a/compiler/dex/quick/mips/mips_lir.h b/compiler/dex/quick/mips/mips_lir.h index ceab9ab1e5..8a99e93f09 100644 --- a/compiler/dex/quick/mips/mips_lir.h +++ b/compiler/dex/quick/mips/mips_lir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_MIPS_MIPSLIR_H_ -#define ART_SRC_COMPILER_DEX_QUICK_MIPS_MIPSLIR_H_ +#ifndef ART_COMPILER_DEX_QUICK_MIPS_MIPS_LIR_H_ +#define ART_COMPILER_DEX_QUICK_MIPS_MIPS_LIR_H_ #include "dex/compiler_internals.h" @@ -429,4 +429,4 @@ extern MipsEncodingMap EncodingMap[kMipsLast]; } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_MIPS_MIPSLIR_H_ +#endif // ART_COMPILER_DEX_QUICK_MIPS_MIPS_LIR_H_ diff --git a/compiler/dex/quick/mir_to_lir-inl.h b/compiler/dex/quick/mir_to_lir-inl.h index 4eef264a0f..d9aef5d968 100644 --- a/compiler/dex/quick/mir_to_lir-inl.h +++ b/compiler/dex/quick/mir_to_lir-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ -#define ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ +#ifndef ART_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ +#define ART_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ #include "mir_to_lir.h" @@ -198,4 +198,4 @@ inline void Mir2Lir::SetupResourceMasks(LIR* lir) { } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ +#endif // ART_COMPILER_DEX_QUICK_MIR_TO_LIR_INL_H_ diff --git a/compiler/dex/quick/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h index 47514f769f..bec86c181e 100644 --- a/compiler/dex/quick/mir_to_lir.h +++ b/compiler/dex/quick/mir_to_lir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ -#define ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ +#ifndef ART_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ +#define ART_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ #include "invoke_type.h" #include "compiled_method.h" @@ -776,4 +776,4 @@ class Mir2Lir : public Backend { } // namespace art -#endif //ART_SRC_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ +#endif // ART_COMPILER_DEX_QUICK_MIR_TO_LIR_H_ diff --git a/compiler/dex/quick/x86/codegen_x86.h b/compiler/dex/quick/x86/codegen_x86.h index 3e30141594..4fa9dfb4d9 100644 --- a/compiler/dex/quick/x86/codegen_x86.h +++ b/compiler/dex/quick/x86/codegen_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_X86_CODEGENX86_H_ -#define ART_SRC_COMPILER_DEX_QUICK_X86_CODEGENX86_H_ +#ifndef ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ +#define ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ #include "dex/compiler_internals.h" #include "x86_lir.h" @@ -202,4 +202,4 @@ class X86Mir2Lir : public Mir2Lir { } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_X86_CODEGENX86_H_ +#endif // ART_COMPILER_DEX_QUICK_X86_CODEGEN_X86_H_ diff --git a/compiler/dex/quick/x86/x86_lir.h b/compiler/dex/quick/x86/x86_lir.h index 600bd03026..a39231b75a 100644 --- a/compiler/dex/quick/x86/x86_lir.h +++ b/compiler/dex/quick/x86/x86_lir.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_QUICK_X86_X86LIR_H_ -#define ART_SRC_COMPILER_DEX_QUICK_X86_X86LIR_H_ +#ifndef ART_COMPILER_DEX_QUICK_X86_X86_LIR_H_ +#define ART_COMPILER_DEX_QUICK_X86_X86_LIR_H_ #include "dex/compiler_internals.h" @@ -439,4 +439,4 @@ extern X86ConditionCode X86ConditionEncoding(ConditionCode cond); } // namespace art -#endif // ART_SRC_COMPILER_DEX_QUICK_X86_X86LIR_H_ +#endif // ART_COMPILER_DEX_QUICK_X86_X86_LIR_H_ diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index 4d7f0cf7b6..80cc89b95f 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ -#define ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ +#ifndef ART_COMPILER_DRIVER_COMPILER_DRIVER_H_ +#define ART_COMPILER_DRIVER_COMPILER_DRIVER_H_ #include #include @@ -410,4 +410,4 @@ class CompilerDriver { } // namespace art -#endif // ART_SRC_COMPILER_DRIVER_COMPILER_DRIVER_H_ +#endif // ART_COMPILER_DRIVER_COMPILER_DRIVER_H_ diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h index 3c6129d642..53efd12ba7 100644 --- a/compiler/driver/dex_compilation_unit.h +++ b/compiler/driver/dex_compilation_unit.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ -#define ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ +#ifndef ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ +#define ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ #include @@ -113,4 +113,4 @@ class DexCompilationUnit { } // namespace art -#endif // ART_SRC_COMPILER_DEX_DEX_COMPILATION_UNIT_H_ +#endif // ART_COMPILER_DRIVER_DEX_COMPILATION_UNIT_H_ diff --git a/compiler/elf_fixup.h b/compiler/elf_fixup.h index 79c45c1874..1abf06b1c5 100644 --- a/compiler/elf_fixup.h +++ b/compiler/elf_fixup.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_FIXUP_H_ -#define ART_SRC_ELF_FIXUP_H_ +#ifndef ART_COMPILER_ELF_FIXUP_H_ +#define ART_COMPILER_ELF_FIXUP_H_ #include @@ -53,4 +53,4 @@ class ElfFixup { } // namespace art -#endif // ART_SRC_ELF_FIXUP_H_ +#endif // ART_COMPILER_ELF_FIXUP_H_ diff --git a/compiler/elf_stripper.h b/compiler/elf_stripper.h index b202e6e1f0..6015b30cb2 100644 --- a/compiler/elf_stripper.h +++ b/compiler/elf_stripper.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_STRIPPER_H_ -#define ART_SRC_ELF_STRIPPER_H_ +#ifndef ART_COMPILER_ELF_STRIPPER_H_ +#define ART_COMPILER_ELF_STRIPPER_H_ #include "base/macros.h" #include "os.h" @@ -34,4 +34,4 @@ class ElfStripper { } // namespace art -#endif // ART_SRC_ELF_STRIPPER_H_ +#endif // ART_COMPILER_ELF_STRIPPER_H_ diff --git a/compiler/elf_writer.h b/compiler/elf_writer.h index 7392e67d7f..ab436e4fb3 100644 --- a/compiler/elf_writer.h +++ b/compiler/elf_writer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_WRITER_H_ -#define ART_SRC_ELF_WRITER_H_ +#ifndef ART_COMPILER_ELF_WRITER_H_ +#define ART_COMPILER_ELF_WRITER_H_ #include @@ -62,4 +62,4 @@ class ElfWriter { } // namespace art -#endif // ART_SRC_ELF_WRITER_H_ +#endif // ART_COMPILER_ELF_WRITER_H_ diff --git a/compiler/elf_writer_mclinker.h b/compiler/elf_writer_mclinker.h index 21f23e113d..468fa9a84f 100644 --- a/compiler/elf_writer_mclinker.h +++ b/compiler/elf_writer_mclinker.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_WRITER_MCLINKER_H_ -#define ART_SRC_ELF_WRITER_MCLINKER_H_ +#ifndef ART_COMPILER_ELF_WRITER_MCLINKER_H_ +#define ART_COMPILER_ELF_WRITER_MCLINKER_H_ #include "elf_writer.h" @@ -96,4 +96,4 @@ class ElfWriterMclinker : public ElfWriter { } // namespace art -#endif // ART_SRC_ELF_WRITER_MCLINKER_H_ +#endif // ART_COMPILER_ELF_WRITER_MCLINKER_H_ diff --git a/compiler/elf_writer_quick.h b/compiler/elf_writer_quick.h index a1a386b3d7..a15c239de9 100644 --- a/compiler/elf_writer_quick.h +++ b/compiler/elf_writer_quick.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_WRITER_MCLINKER_H_ -#define ART_SRC_ELF_WRITER_MCLINKER_H_ +#ifndef ART_COMPILER_ELF_WRITER_QUICK_H_ +#define ART_COMPILER_ELF_WRITER_QUICK_H_ #include "elf_writer.h" @@ -48,4 +48,4 @@ class ElfWriterQuick : public ElfWriter { } // namespace art -#endif // ART_SRC_ELF_WRITER_MCLINKER_H_ +#endif // ART_COMPILER_ELF_WRITER_QUICK_H_ diff --git a/compiler/image_writer.h b/compiler/image_writer.h index 9b0d671604..e43ec6338f 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_IMAGE_WRITER_H_ -#define ART_SRC_IMAGE_WRITER_H_ +#ifndef ART_COMPILER_IMAGE_WRITER_H_ +#define ART_COMPILER_IMAGE_WRITER_H_ #include @@ -207,4 +207,4 @@ class ImageWriter { } // namespace art -#endif // ART_SRC_IMAGE_WRITER_H_ +#endif // ART_COMPILER_IMAGE_WRITER_H_ diff --git a/compiler/jni/portable/jni_compiler.h b/compiler/jni/portable/jni_compiler.h index a04277c9e6..9bdf35ef10 100644 --- a/compiler/jni/portable/jni_compiler.h +++ b/compiler/jni/portable/jni_compiler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ -#define ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ +#ifndef ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ +#define ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ #include @@ -84,4 +84,4 @@ class JniCompiler { } // namespace art -#endif // ART_SRC_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ +#endif // ART_COMPILER_JNI_PORTABLE_JNI_COMPILER_H_ diff --git a/compiler/jni/quick/arm/calling_convention_arm.h b/compiler/jni/quick/arm/calling_convention_arm.h index 3787d45c6f..f188700746 100644 --- a/compiler/jni/quick/arm/calling_convention_arm.h +++ b/compiler/jni/quick/arm/calling_convention_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_JNI_ARM_CALLING_CONVENTION_ARM_H_ -#define ART_SRC_OAT_JNI_ARM_CALLING_CONVENTION_ARM_H_ +#ifndef ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_ +#define ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_ #include "jni/quick/calling_convention.h" @@ -85,4 +85,4 @@ class ArmJniCallingConvention : public JniCallingConvention { } // namespace arm } // namespace art -#endif // ART_SRC_OAT_JNI_ARM_CALLING_CONVENTION_ARM_H_ +#endif // ART_COMPILER_JNI_QUICK_ARM_CALLING_CONVENTION_ARM_H_ diff --git a/compiler/jni/quick/calling_convention.h b/compiler/jni/quick/calling_convention.h index 121d1f80ae..d492b42237 100644 --- a/compiler/jni/quick/calling_convention.h +++ b/compiler/jni/quick/calling_convention.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_JNI_CALLING_CONVENTION_H_ -#define ART_SRC_OAT_JNI_CALLING_CONVENTION_H_ +#ifndef ART_COMPILER_JNI_QUICK_CALLING_CONVENTION_H_ +#define ART_COMPILER_JNI_QUICK_CALLING_CONVENTION_H_ #include #include "oat/utils/managed_register.h" @@ -286,4 +286,4 @@ class JniCallingConvention : public CallingConvention { } // namespace art -#endif // ART_SRC_OAT_JNI_CALLING_CONVENTION_H_ +#endif // ART_COMPILER_JNI_QUICK_CALLING_CONVENTION_H_ diff --git a/compiler/jni/quick/mips/calling_convention_mips.h b/compiler/jni/quick/mips/calling_convention_mips.h index 90681362bc..8412898dd8 100644 --- a/compiler/jni/quick/mips/calling_convention_mips.h +++ b/compiler/jni/quick/mips/calling_convention_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_JNI_MIPS_CALLING_CONVENTION_MIPS_H_ -#define ART_SRC_OAT_JNI_MIPS_CALLING_CONVENTION_MIPS_H_ +#ifndef ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ +#define ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ #include "jni/quick/calling_convention.h" @@ -83,4 +83,4 @@ class MipsJniCallingConvention : public JniCallingConvention { } // namespace mips } // namespace art -#endif // ART_SRC_OAT_JNI_MIPS_CALLING_CONVENTION_MIPS_H_ +#endif // ART_COMPILER_JNI_QUICK_MIPS_CALLING_CONVENTION_MIPS_H_ diff --git a/compiler/jni/quick/x86/calling_convention_x86.h b/compiler/jni/quick/x86/calling_convention_x86.h index ea8a26e7d5..082c1c8eb1 100644 --- a/compiler/jni/quick/x86/calling_convention_x86.h +++ b/compiler/jni/quick/x86/calling_convention_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_JNI_X86_CALLING_CONVENTION_X86_H_ -#define ART_SRC_OAT_JNI_X86_CALLING_CONVENTION_X86_H_ +#ifndef ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ +#define ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ #include "jni/quick/calling_convention.h" @@ -80,4 +80,4 @@ class X86JniCallingConvention : public JniCallingConvention { } // namespace x86 } // namespace art -#endif // ART_SRC_OAT_JNI_X86_CALLING_CONVENTION_X86_H_ +#endif // ART_COMPILER_JNI_QUICK_X86_CALLING_CONVENTION_X86_H_ diff --git a/compiler/llvm/backend_options.h b/compiler/llvm/backend_options.h index 924a34639c..2a08bda2f1 100644 --- a/compiler/llvm/backend_options.h +++ b/compiler/llvm/backend_options.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_ -#define ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_ +#ifndef ART_COMPILER_LLVM_BACKEND_OPTIONS_H_ +#define ART_COMPILER_LLVM_BACKEND_OPTIONS_H_ #include @@ -47,4 +47,4 @@ inline void InitialBackendOptions() { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_ +#endif // ART_COMPILER_LLVM_BACKEND_OPTIONS_H_ diff --git a/compiler/llvm/backend_types.h b/compiler/llvm/backend_types.h index c89504a859..095040e5eb 100644 --- a/compiler/llvm/backend_types.h +++ b/compiler/llvm/backend_types.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_ -#define ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_ +#ifndef ART_COMPILER_LLVM_BACKEND_TYPES_H_ +#define ART_COMPILER_LLVM_BACKEND_TYPES_H_ #include "base/logging.h" @@ -101,4 +101,4 @@ inline JType GetJTypeFromShorty(char shorty_jty) { } // namespace art -#endif // ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_ +#endif // ART_COMPILER_LLVM_BACKEND_TYPES_H_ diff --git a/compiler/llvm/compiler_llvm.h b/compiler/llvm/compiler_llvm.h index b70ddc5e20..77841d8564 100644 --- a/compiler/llvm/compiler_llvm.h +++ b/compiler/llvm/compiler_llvm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ -#define ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ +#ifndef ART_COMPILER_LLVM_COMPILER_LLVM_H_ +#define ART_COMPILER_LLVM_COMPILER_LLVM_H_ #include "base/macros.h" #include "dex_file.h" @@ -100,4 +100,4 @@ class CompilerLLVM { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_ +#endif // ART_COMPILER_LLVM_COMPILER_LLVM_H_ diff --git a/compiler/llvm/intrinsic_helper.h b/compiler/llvm/intrinsic_helper.h index 49b8a95230..bb123fd575 100644 --- a/compiler/llvm/intrinsic_helper.h +++ b/compiler/llvm/intrinsic_helper.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GREENLAND_INTRINSIC_HELPER_H_ -#define ART_SRC_GREENLAND_INTRINSIC_HELPER_H_ +#ifndef ART_COMPILER_LLVM_INTRINSIC_HELPER_H_ +#define ART_COMPILER_LLVM_INTRINSIC_HELPER_H_ #include "base/logging.h" @@ -154,4 +154,4 @@ class IntrinsicHelper { } // namespace llvm } // namespace art -#endif // ART_SRC_GREENLAND_INTRINSIC_HELPER_H_ +#endif // ART_COMPILER_LLVM_INTRINSIC_HELPER_H_ diff --git a/compiler/llvm/ir_builder.h b/compiler/llvm/ir_builder.h index 734b22f791..65da005e9b 100644 --- a/compiler/llvm/ir_builder.h +++ b/compiler/llvm/ir_builder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_IR_BUILDER_H_ -#define ART_SRC_COMPILER_LLVM_IR_BUILDER_H_ +#ifndef ART_COMPILER_LLVM_IR_BUILDER_H_ +#define ART_COMPILER_LLVM_IR_BUILDER_H_ #include "backend_types.h" #include "dex/compiler_enums.h" @@ -487,4 +487,4 @@ class IRBuilder : public LLVMIRBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_IR_BUILDER_H_ +#endif // ART_COMPILER_LLVM_IR_BUILDER_H_ diff --git a/compiler/llvm/llvm_compilation_unit.h b/compiler/llvm/llvm_compilation_unit.h index a4f0adbab8..9de132379b 100644 --- a/compiler/llvm/llvm_compilation_unit.h +++ b/compiler/llvm/llvm_compilation_unit.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ -#define ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ +#ifndef ART_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ +#define ART_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ #include "base/logging.h" #include "base/mutex.h" @@ -135,4 +135,4 @@ class LlvmCompilationUnit { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ +#endif // ART_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_ diff --git a/compiler/llvm/md_builder.h b/compiler/llvm/md_builder.h index 79a7caa04c..cc169a3219 100644 --- a/compiler/llvm/md_builder.h +++ b/compiler/llvm/md_builder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_MD_BUILDER_H_ -#define ART_SRC_COMPILER_LLVM_MD_BUILDER_H_ +#ifndef ART_COMPILER_LLVM_MD_BUILDER_H_ +#define ART_COMPILER_LLVM_MD_BUILDER_H_ #include "backend_types.h" @@ -68,4 +68,4 @@ class MDBuilder : public LLVMMDBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_MD_BUILDER_H_ +#endif // ART_COMPILER_LLVM_MD_BUILDER_H_ diff --git a/compiler/llvm/runtime_support_builder.h b/compiler/llvm/runtime_support_builder.h index 267b406232..c3c0856bd0 100644 --- a/compiler/llvm/runtime_support_builder.h +++ b/compiler/llvm/runtime_support_builder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ #include "backend_types.h" #include "base/logging.h" @@ -95,4 +95,4 @@ class RuntimeSupportBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_ diff --git a/compiler/llvm/runtime_support_builder_arm.h b/compiler/llvm/runtime_support_builder_arm.h index 3c5972fc33..6aa23b2306 100644 --- a/compiler/llvm/runtime_support_builder_arm.h +++ b/compiler/llvm/runtime_support_builder_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ #include "runtime_support_builder.h" @@ -43,4 +43,4 @@ class RuntimeSupportBuilderARM : public RuntimeSupportBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_ diff --git a/compiler/llvm/runtime_support_builder_thumb2.h b/compiler/llvm/runtime_support_builder_thumb2.h index 4762a269f9..941bd6b2bb 100644 --- a/compiler/llvm/runtime_support_builder_thumb2.h +++ b/compiler/llvm/runtime_support_builder_thumb2.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ #include "runtime_support_builder_arm.h" @@ -34,4 +34,4 @@ class RuntimeSupportBuilderThumb2 : public RuntimeSupportBuilderARM { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_ diff --git a/compiler/llvm/runtime_support_builder_x86.h b/compiler/llvm/runtime_support_builder_x86.h index e5fdbc2e26..831d022ce5 100644 --- a/compiler/llvm/runtime_support_builder_x86.h +++ b/compiler/llvm/runtime_support_builder_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ #include "runtime_support_builder.h" @@ -39,4 +39,4 @@ class RuntimeSupportBuilderX86 : public RuntimeSupportBuilder { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_ diff --git a/compiler/llvm/runtime_support_llvm_func.h b/compiler/llvm/runtime_support_llvm_func.h index ac6f3b869f..c0e76addc6 100644 --- a/compiler/llvm/runtime_support_llvm_func.h +++ b/compiler/llvm/runtime_support_llvm_func.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_ +#ifndef ART_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_FUNC_H_ +#define ART_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_FUNC_H_ namespace art { namespace llvm { @@ -35,4 +35,4 @@ namespace runtime_support { } // namespace llvm } // namespace art -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_ +#endif // ART_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_FUNC_H_ diff --git a/compiler/llvm/utils_llvm.h b/compiler/llvm/utils_llvm.h index 2e273f4fe9..a606b91958 100644 --- a/compiler/llvm/utils_llvm.h +++ b/compiler/llvm/utils_llvm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_UTILS_LLVM_H_ -#define ART_SRC_UTILS_LLVM_H_ +#ifndef ART_COMPILER_LLVM_UTILS_LLVM_H_ +#define ART_COMPILER_LLVM_UTILS_LLVM_H_ #include @@ -29,4 +29,4 @@ namespace art { } // namespace art -#endif // ART_SRC_UTILS_LLVM_H_ +#endif // ART_COMPILER_LLVM_UTILS_LLVM_H_ diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h index 1f97bf853c..ea7156ea49 100644 --- a/compiler/oat_writer.h +++ b/compiler/oat_writer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_WRITER_H_ -#define ART_SRC_OAT_WRITER_H_ +#ifndef ART_COMPILER_OAT_WRITER_H_ +#define ART_COMPILER_OAT_WRITER_H_ #include @@ -224,4 +224,4 @@ class OatWriter { } // namespace art -#endif // ART_SRC_OAT_WRITER_H_ +#endif // ART_COMPILER_OAT_WRITER_H_ diff --git a/compiler/sea_ir/instruction_tools.h b/compiler/sea_ir/instruction_tools.h index f68cdd0784..b0bbc272c8 100644 --- a/compiler/sea_ir/instruction_tools.h +++ b/compiler/sea_ir/instruction_tools.h @@ -17,8 +17,8 @@ #include "dex_instruction.h" -#ifndef INSTRUCTION_TOOLS_H_ -#define INSTRUCTION_TOOLS_H_ +#ifndef ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_ +#define ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_ // Note: This file has content cannibalized for SEA_IR from the MIR implementation, // to avoid having a dependence on MIR. @@ -121,4 +121,4 @@ class InstructionTools { static const int instruction_attributes_[]; }; } // end namespace sea_ir -#endif // INSTRUCTION_TOOLS_H_ +#endif // ART_COMPILER_SEA_IR_INSTRUCTION_TOOLS_H_ diff --git a/compiler/sea_ir/sea.h b/compiler/sea_ir/sea.h index f2c71469e5..ce4624d438 100644 --- a/compiler/sea_ir/sea.h +++ b/compiler/sea_ir/sea.h @@ -15,8 +15,8 @@ */ -#ifndef SEA_IR_H_ -#define SEA_IR_H_ +#ifndef ART_COMPILER_SEA_IR_SEA_H_ +#define ART_COMPILER_SEA_IR_SEA_H_ #include #include @@ -159,4 +159,4 @@ class SeaGraph { } // end namespace sea_ir -#endif +#endif // ART_COMPILER_SEA_IR_SEA_H_ diff --git a/compiler/stubs/stubs.h b/compiler/stubs/stubs.h index ebe761df35..d85eae8e1e 100644 --- a/compiler/stubs/stubs.h +++ b/compiler/stubs/stubs.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_STUBS_STUBS_H_ -#define ART_SRC_COMPILER_STUBS_STUBS_H_ +#ifndef ART_COMPILER_STUBS_STUBS_H_ +#define ART_COMPILER_STUBS_STUBS_H_ #include "runtime.h" @@ -56,4 +56,4 @@ const std::vector* CreateInterpreterToQuickEntry() } // namespace art -#endif // ART_SRC_COMPILER_STUBS_STUBS_H_ +#endif // ART_COMPILER_STUBS_STUBS_H_ diff --git a/jdwpspy/Common.h b/jdwpspy/Common.h index 0bd305643a..33f1a670ea 100644 --- a/jdwpspy/Common.h +++ b/jdwpspy/Common.h @@ -3,8 +3,8 @@ * * jdwpspy common stuff. */ -#ifndef _JDWPSPY_COMMON -#define _JDWPSPY_COMMON +#ifndef ART_JDWPSPY_COMMON_H_ +#define ART_JDWPSPY_COMMON_H_ #include #include @@ -99,4 +99,4 @@ void printHexDump2(const void* vaddr, size_t length, const char* prefix); void printHexDumpEx(FILE* fp, const void* vaddr, size_t length, HexDumpMode mode, const char* prefix); -#endif /*_JDWPSPY_COMMON*/ +#endif // ART_JDWPSPY_COMMON_H_ diff --git a/runtime/asm_support.h b/runtime/asm_support.h index 8ea4adfcf2..7b20c7aee0 100644 --- a/runtime/asm_support.h +++ b/runtime/asm_support.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ASM_SUPPORT_H_ -#define ART_SRC_ASM_SUPPORT_H_ +#ifndef ART_RUNTIME_ASM_SUPPORT_H_ +#define ART_RUNTIME_ASM_SUPPORT_H_ // Value loaded into rSUSPEND for quick. When this value is counted down to zero we do a suspend // check. @@ -55,4 +55,4 @@ #define THREAD_EXCEPTION_OFFSET 12 #endif -#endif // ART_SRC_ASM_SUPPORT_H_ +#endif // ART_RUNTIME_ASM_SUPPORT_H_ diff --git a/runtime/atomic.h b/runtime/atomic.h index d340dc5474..cb6f86b921 100644 --- a/runtime/atomic.h +++ b/runtime/atomic.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ATOMIC_H_ -#define ART_SRC_ATOMIC_H_ +#ifndef ART_RUNTIME_ATOMIC_H_ +#define ART_RUNTIME_ATOMIC_H_ #include @@ -54,4 +54,4 @@ class QuasiAtomic { } // namespace art -#endif // ART_SRC_ATOMIC_H_ +#endif // ART_RUNTIME_ATOMIC_H_ diff --git a/runtime/atomic_integer.h b/runtime/atomic_integer.h index c4a8de9817..57836d6e26 100644 --- a/runtime/atomic_integer.h +++ b/runtime/atomic_integer.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ATOMIC_INTEGER_H_ -#define ART_SRC_ATOMIC_INTEGER_H_ +#ifndef ART_RUNTIME_ATOMIC_INTEGER_H_ +#define ART_RUNTIME_ATOMIC_INTEGER_H_ #include "cutils/atomic.h" #include "cutils/atomic-inline.h" @@ -76,4 +76,4 @@ class AtomicInteger { } -#endif // ART_SRC_ATOMIC_INTEGER_H_ +#endif // ART_RUNTIME_ATOMIC_INTEGER_H_ diff --git a/runtime/barrier.h b/runtime/barrier.h index 2b0429a7c2..e0ad239eab 100644 --- a/runtime/barrier.h +++ b/runtime/barrier.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BARRIER_H_ -#define ART_SRC_BARRIER_H_ +#ifndef ART_RUNTIME_BARRIER_H_ +#define ART_RUNTIME_BARRIER_H_ #include "base/mutex.h" #include "locks.h" @@ -52,4 +52,4 @@ class Barrier { }; } // namespace art -#endif // ART_SRC_GC_BARRIER_H_ +#endif // ART_RUNTIME_BARRIER_H_ diff --git a/runtime/base/casts.h b/runtime/base/casts.h index 34c05af4e3..be94c2eb78 100644 --- a/runtime/base/casts.h +++ b/runtime/base/casts.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_CASTS_H_ -#define ART_SRC_BASE_CASTS_H_ +#ifndef ART_RUNTIME_BASE_CASTS_H_ +#define ART_RUNTIME_BASE_CASTS_H_ #include #include @@ -90,4 +90,4 @@ inline Dest bit_cast(const Source& source) { } // namespace art -#endif // ART_SRC_BASE_CASTS_H_ +#endif // ART_RUNTIME_BASE_CASTS_H_ diff --git a/runtime/base/histogram-inl.h b/runtime/base/histogram-inl.h index 9514209c11..bbca60308a 100644 --- a/runtime/base/histogram-inl.h +++ b/runtime/base/histogram-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef SRC_BASE_HISTOGRAM_INL_H_ -#define SRC_BASE_HISTOGRAM_INL_H_ +#ifndef ART_RUNTIME_BASE_HISTOGRAM_INL_H_ +#define ART_RUNTIME_BASE_HISTOGRAM_INL_H_ #include "histogram.h" @@ -251,5 +251,5 @@ inline double Histogram::Percentile(double per) const { } } // namespace art -#endif // SRC_BASE_HISTOGRAM_INL_H_ +#endif // ART_RUNTIME_BASE_HISTOGRAM_INL_H_ diff --git a/runtime/base/histogram.h b/runtime/base/histogram.h index 6878e71ccc..8724d2c582 100644 --- a/runtime/base/histogram.h +++ b/runtime/base/histogram.h @@ -13,8 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#ifndef ART_SRC_BASE_HISTOGRAM_H_ -#define ART_SRC_BASE_HISTOGRAM_H_ +#ifndef ART_RUNTIME_BASE_HISTOGRAM_H_ +#define ART_RUNTIME_BASE_HISTOGRAM_H_ #include #include @@ -117,4 +117,4 @@ template class Histogram { }; } -#endif // ART_SRC_BASE_HISTOGRAM_H_ +#endif // ART_RUNTIME_BASE_HISTOGRAM_H_ diff --git a/runtime/base/logging.h b/runtime/base/logging.h index 8d89e4d0cb..f02a39a1f9 100644 --- a/runtime/base/logging.h +++ b/runtime/base/logging.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_LOGGING_H_ -#define ART_SRC_BASE_LOGGING_H_ +#ifndef ART_RUNTIME_BASE_LOGGING_H_ +#define ART_RUNTIME_BASE_LOGGING_H_ #include #include @@ -334,4 +334,4 @@ extern const char* ProgramInvocationShortName(); } // namespace art -#endif // ART_SRC_BASE_LOGGING_H_ +#endif // ART_RUNTIME_BASE_LOGGING_H_ diff --git a/runtime/base/macros.h b/runtime/base/macros.h index 847105d20c..4a196f28e7 100644 --- a/runtime/base/macros.h +++ b/runtime/base/macros.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_MACROS_H_ -#define ART_SRC_BASE_MACROS_H_ +#ifndef ART_RUNTIME_BASE_MACROS_H_ +#define ART_RUNTIME_BASE_MACROS_H_ #include // for size_t @@ -198,4 +198,4 @@ template void UNUSED(const T&) {} #endif // defined(__SUPPORT_TS_ANNOTATION__) -#endif // ART_SRC_BASE_MACROS_H_ +#endif // ART_RUNTIME_BASE_MACROS_H_ diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index f911054b86..07157da7aa 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_MUTEX_INL_H_ -#define ART_SRC_BASE_MUTEX_INL_H_ +#ifndef ART_RUNTIME_BASE_MUTEX_INL_H_ +#define ART_RUNTIME_BASE_MUTEX_INL_H_ #include "mutex.h" @@ -184,4 +184,4 @@ inline void ReaderWriterMutex::SharedUnlock(Thread* self) { } // namespace art -#endif // ART_SRC_BASE_MUTEX_INL_H_ +#endif // ART_RUNTIME_BASE_MUTEX_INL_H_ diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h index b62755917c..dea52a6615 100644 --- a/runtime/base/mutex.h +++ b/runtime/base/mutex.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_MUTEX_H_ -#define ART_SRC_BASE_MUTEX_H_ +#ifndef ART_RUNTIME_BASE_MUTEX_H_ +#define ART_RUNTIME_BASE_MUTEX_H_ #include #include @@ -398,4 +398,4 @@ class SCOPED_LOCKABLE WriterMutexLock { } // namespace art -#endif // ART_SRC_BASE_MUTEX_H_ +#endif // ART_RUNTIME_BASE_MUTEX_H_ diff --git a/runtime/base/stl_util.h b/runtime/base/stl_util.h index eb8be42df3..ff9f40cbf8 100644 --- a/runtime/base/stl_util.h +++ b/runtime/base/stl_util.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_STL_UTIL_H_ -#define ART_SRC_BASE_STL_UTIL_H_ +#ifndef ART_RUNTIME_BASE_STL_UTIL_H_ +#define ART_RUNTIME_BASE_STL_UTIL_H_ #include #include @@ -94,4 +94,4 @@ std::string ToString(const T& v) { } // namespace art -#endif // ART_SRC_BASE_STL_UTIL_H_ +#endif // ART_RUNTIME_BASE_STL_UTIL_H_ diff --git a/runtime/base/stringpiece.h b/runtime/base/stringpiece.h index 3664218860..62088cc183 100644 --- a/runtime/base/stringpiece.h +++ b/runtime/base/stringpiece.h @@ -25,8 +25,8 @@ // Systematic usage of StringPiece is encouraged as it will reduce unnecessary // conversions from "const char*" to "string" and back again. -#ifndef ART_SRC_BASE_STRINGPIECE_H_ -#define ART_SRC_BASE_STRINGPIECE_H_ +#ifndef ART_RUNTIME_BASE_STRINGPIECE_H_ +#define ART_RUNTIME_BASE_STRINGPIECE_H_ #include #include @@ -223,4 +223,4 @@ struct StringPieceHash { } // namespace art -#endif // ART_SRC_BASE_STRINGPIECE_H_ +#endif // ART_RUNTIME_BASE_STRINGPIECE_H_ diff --git a/runtime/base/stringprintf.h b/runtime/base/stringprintf.h index d707cc02d6..4767a750c3 100644 --- a/runtime/base/stringprintf.h +++ b/runtime/base/stringprintf.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_BASE_STRINGPRINTF_H_ -#define ART_SRC_BASE_STRINGPRINTF_H_ +#ifndef ART_RUNTIME_BASE_STRINGPRINTF_H_ +#define ART_RUNTIME_BASE_STRINGPRINTF_H_ #include #include @@ -35,4 +35,4 @@ void StringAppendV(std::string* dst, const char* format, va_list ap); } // namespace art -#endif // ART_SRC_BASE_STRINGPRINTF_H_ +#endif // ART_RUNTIME_BASE_STRINGPRINTF_H_ diff --git a/runtime/base/timing_logger.h b/runtime/base/timing_logger.h index 65732b170d..816cbeadec 100644 --- a/runtime/base/timing_logger.h +++ b/runtime/base/timing_logger.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_TIMING_LOGGER_H_ -#define ART_SRC_TIMING_LOGGER_H_ +#ifndef ART_RUNTIME_BASE_TIMING_LOGGER_H_ +#define ART_RUNTIME_BASE_TIMING_LOGGER_H_ #include "base/histogram.h" #include "base/macros.h" @@ -139,4 +139,4 @@ class NewTimingLogger { } // namespace base } // namespace art -#endif // ART_SRC_TIMING_LOGGER_H_ +#endif // ART_RUNTIME_BASE_TIMING_LOGGER_H_ diff --git a/runtime/base/unix_file/fd_file.h b/runtime/base/unix_file/fd_file.h index 2b339613ba..79a0db9eda 100644 --- a/runtime/base/unix_file/fd_file.h +++ b/runtime/base/unix_file/fd_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_FD_FILE_H_ -#define BASE_UNIX_FILE_FD_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ #include #include @@ -72,4 +72,4 @@ class FdFile : public RandomAccessFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_FD_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_FD_FILE_H_ diff --git a/runtime/base/unix_file/mapped_file.h b/runtime/base/unix_file/mapped_file.h index 161100b0d5..28cc5514f7 100644 --- a/runtime/base/unix_file/mapped_file.h +++ b/runtime/base/unix_file/mapped_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_MAPPED_FILE_H_ -#define BASE_UNIX_FILE_MAPPED_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_MAPPED_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_MAPPED_FILE_H_ #include #include @@ -94,4 +94,4 @@ class MappedFile : public FdFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_MAPPED_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_MAPPED_FILE_H_ diff --git a/runtime/base/unix_file/null_file.h b/runtime/base/unix_file/null_file.h index e716603687..33947311f0 100644 --- a/runtime/base/unix_file/null_file.h +++ b/runtime/base/unix_file/null_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_NULL_FILE_H_ -#define BASE_UNIX_FILE_NULL_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ #include "base/unix_file/random_access_file.h" #include "base/macros.h" @@ -47,4 +47,4 @@ class NullFile : public RandomAccessFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_NULL_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_NULL_FILE_H_ diff --git a/runtime/base/unix_file/random_access_file.h b/runtime/base/unix_file/random_access_file.h index 22da37f03e..31a6dbe1fc 100644 --- a/runtime/base/unix_file/random_access_file.h +++ b/runtime/base/unix_file/random_access_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ -#define BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ #include @@ -65,4 +65,4 @@ class RandomAccessFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_H_ diff --git a/runtime/base/unix_file/random_access_file_test.h b/runtime/base/unix_file/random_access_file_test.h index 3baaeae8ac..9d8550d6f6 100644 --- a/runtime/base/unix_file/random_access_file_test.h +++ b/runtime/base/unix_file/random_access_file_test.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ -#define BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ #include @@ -169,4 +169,4 @@ class RandomAccessFileTest : public testing::Test { } // namespace unix_file -#endif // BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_TEST_H_ diff --git a/runtime/base/unix_file/random_access_file_utils.h b/runtime/base/unix_file/random_access_file_utils.h index 0535ead8c5..30c81c09aa 100644 --- a/runtime/base/unix_file/random_access_file_utils.h +++ b/runtime/base/unix_file/random_access_file_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ -#define BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ namespace unix_file { @@ -27,4 +27,4 @@ bool CopyFile(const RandomAccessFile& src, RandomAccessFile* dst); } // namespace unix_file -#endif // BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_RANDOM_ACCESS_FILE_UTILS_H_ diff --git a/runtime/base/unix_file/string_file.h b/runtime/base/unix_file/string_file.h index 8944373344..26904f89a6 100644 --- a/runtime/base/unix_file/string_file.h +++ b/runtime/base/unix_file/string_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef BASE_UNIX_FILE_STRING_FILE_H_ -#define BASE_UNIX_FILE_STRING_FILE_H_ +#ifndef ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ +#define ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ #include @@ -56,4 +56,4 @@ class StringFile : public RandomAccessFile { } // namespace unix_file -#endif // BASE_UNIX_FILE_STRING_FILE_H_ +#endif // ART_RUNTIME_BASE_UNIX_FILE_STRING_FILE_H_ diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index 6cf49912a2..4d01b66f0a 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLASS_LINKER_INL_H_ -#define ART_SRC_CLASS_LINKER_INL_H_ +#ifndef ART_RUNTIME_CLASS_LINKER_INL_H_ +#define ART_RUNTIME_CLASS_LINKER_INL_H_ #include "class_linker.h" @@ -143,4 +143,4 @@ inline mirror::Class* ClassLinker::GetClassRoot(ClassRoot class_root) } // namespace art -#endif // ART_SRC_CLASS_LINKER_INL_H_ +#endif // ART_RUNTIME_CLASS_LINKER_INL_H_ diff --git a/runtime/class_linker.h b/runtime/class_linker.h index df1ecc6207..3993cb214b 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLASS_LINKER_H_ -#define ART_SRC_CLASS_LINKER_H_ +#ifndef ART_RUNTIME_CLASS_LINKER_H_ +#define ART_RUNTIME_CLASS_LINKER_H_ #include #include @@ -627,4 +627,4 @@ class ClassLinker { } // namespace art -#endif // ART_SRC_CLASS_LINKER_H_ +#endif // ART_RUNTIME_CLASS_LINKER_H_ diff --git a/runtime/class_reference.h b/runtime/class_reference.h index c3be720ea5..77c296facd 100644 --- a/runtime/class_reference.h +++ b/runtime/class_reference.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLASS_REFERENCE_H_ -#define ART_SRC_CLASS_REFERENCE_H_ +#ifndef ART_RUNTIME_CLASS_REFERENCE_H_ +#define ART_RUNTIME_CLASS_REFERENCE_H_ #include @@ -38,4 +38,4 @@ inline bool operator<(const ClassReference& lhs, const ClassReference& rhs) { } // namespace art -#endif // ART_SRC_CLASS_REFERENCE_H_ +#endif // ART_RUNTIME_CLASS_REFERENCE_H_ diff --git a/runtime/closure.h b/runtime/closure.h index 17f2b84d82..9bea28fa58 100644 --- a/runtime/closure.h +++ b/runtime/closure.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLOSURE_H_ -#define ART_SRC_CLOSURE_H_ +#ifndef ART_RUNTIME_CLOSURE_H_ +#define ART_RUNTIME_CLOSURE_H_ namespace art { @@ -29,4 +29,4 @@ class Closure { } // namespace art -#endif // ART_SRC_CLOSURE_H_ +#endif // ART_RUNTIME_CLOSURE_H_ diff --git a/runtime/common_test.h b/runtime/common_test.h index f03b1f9cdb..73c47b5a8c 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef ART_RUNTIME_COMMON_TEST_H_ +#define ART_RUNTIME_COMMON_TEST_H_ + #include #include #include @@ -586,3 +589,5 @@ std::ostream& operator<<(std::ostream& os, const std::vector& rhs) { } } // namespace std + +#endif // ART_RUNTIME_COMMON_TEST_H_ diff --git a/runtime/common_throws.h b/runtime/common_throws.h index 4bf12c0d01..b7f2754df1 100644 --- a/runtime/common_throws.h +++ b/runtime/common_throws.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMMON_THROWS__H_ -#define ART_SRC_COMMON_THROWS_H_ +#ifndef ART_RUNTIME_COMMON_THROWS_H_ +#define ART_RUNTIME_COMMON_THROWS_H_ #include "base/mutex.h" #include "invoke_type.h" @@ -183,4 +183,4 @@ void ThrowVerifyError(const mirror::Class* referrer, const char* fmt, ...) } // namespace art -#endif // ART_SRC_COMMON_THROWS_H_ +#endif // ART_RUNTIME_COMMON_THROWS_H_ diff --git a/runtime/compiled_class.h b/runtime/compiled_class.h index f050ee6a7e..c53d500502 100644 --- a/runtime/compiled_class.h +++ b/runtime/compiled_class.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILED_CLASS_H_ -#define ART_SRC_COMPILED_CLASS_H_ +#ifndef ART_RUNTIME_COMPILED_CLASS_H_ +#define ART_RUNTIME_COMPILED_CLASS_H_ #include "mirror/class.h" @@ -34,4 +34,4 @@ class CompiledClass { } // namespace art -#endif // ART_SRC_COMPILED_CLASS_H_ +#endif // ART_RUNTIME_COMPILED_CLASS_H_ diff --git a/runtime/compiled_method.h b/runtime/compiled_method.h index fb0172cc19..800dde2208 100644 --- a/runtime/compiled_method.h +++ b/runtime/compiled_method.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILED_METHOD_H_ -#define ART_SRC_COMPILED_METHOD_H_ +#ifndef ART_RUNTIME_COMPILED_METHOD_H_ +#define ART_RUNTIME_COMPILED_METHOD_H_ #include #include @@ -177,4 +177,4 @@ class CompiledMethod : public CompiledCode { } // namespace art -#endif // ART_SRC_COMPILED_METHOD_H_ +#endif // ART_RUNTIME_COMPILED_METHOD_H_ diff --git a/runtime/constants_arm.h b/runtime/constants_arm.h index 601c57247e..bbb9242def 100644 --- a/runtime/constants_arm.h +++ b/runtime/constants_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CONSTANTS_ARM_H_ -#define ART_SRC_CONSTANTS_ARM_H_ +#ifndef ART_RUNTIME_CONSTANTS_ARM_H_ +#define ART_RUNTIME_CONSTANTS_ARM_H_ #include @@ -516,4 +516,4 @@ class Instr { } // namespace arm } // namespace art -#endif // ART_SRC_CONSTANTS_ARM_H_ +#endif // ART_RUNTIME_CONSTANTS_ARM_H_ diff --git a/runtime/constants_mips.h b/runtime/constants_mips.h index 87a13554fb..fb56493a14 100644 --- a/runtime/constants_mips.h +++ b/runtime/constants_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CONSTANTS_MIPS_H_ -#define ART_SRC_CONSTANTS_MIPS_H_ +#ifndef ART_RUNTIME_CONSTANTS_MIPS_H_ +#define ART_RUNTIME_CONSTANTS_MIPS_H_ #include @@ -183,4 +183,4 @@ class Instr { } // namespace mips } // namespace art -#endif // ART_SRC_CONSTANTS_MIPS_H_ +#endif // ART_RUNTIME_CONSTANTS_MIPS_H_ diff --git a/runtime/constants_x86.h b/runtime/constants_x86.h index e48b281599..bb18b6b23b 100644 --- a/runtime/constants_x86.h +++ b/runtime/constants_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CONSTANTS_X86_H_ -#define ART_SRC_CONSTANTS_X86_H_ +#ifndef ART_RUNTIME_CONSTANTS_X86_H_ +#define ART_RUNTIME_CONSTANTS_X86_H_ #include @@ -137,4 +137,4 @@ class Instr { } // namespace x86 } // namespace art -#endif // ART_SRC_CONSTANTS_X86_H_ +#endif // ART_RUNTIME_CONSTANTS_X86_H_ diff --git a/runtime/debugger.h b/runtime/debugger.h index eb17695249..94f3cbed76 100644 --- a/runtime/debugger.h +++ b/runtime/debugger.h @@ -18,8 +18,8 @@ * Dalvik-specific side of debugger support. (The JDWP code is intended to * be relatively generic.) */ -#ifndef ART_DEBUGGER_H_ -#define ART_DEBUGGER_H_ +#ifndef ART_RUNTIME_DEBUGGER_H_ +#define ART_RUNTIME_DEBUGGER_H_ #include @@ -429,4 +429,4 @@ class Dbg { } // namespace art -#endif // ART_DEBUGGER_H_ +#endif // ART_RUNTIME_DEBUGGER_H_ diff --git a/runtime/dex_file-inl.h b/runtime/dex_file-inl.h index 5d8216eda5..dee80269d6 100644 --- a/runtime/dex_file-inl.h +++ b/runtime/dex_file-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_FILE_INL_H_ -#define ART_SRC_DEX_FILE_INL_H_ +#ifndef ART_RUNTIME_DEX_FILE_INL_H_ +#define ART_RUNTIME_DEX_FILE_INL_H_ #include "base/logging.h" #include "dex_file.h" @@ -44,4 +44,4 @@ inline const DexFile::TryItem* DexFile::GetTryItems(const CodeItem& code_item, u } // namespace art -#endif // ART_SRC_DEX_FILE_INL_H_ +#endif // ART_RUNTIME_DEX_FILE_INL_H_ diff --git a/runtime/dex_file.h b/runtime/dex_file.h index e09270e018..28e06cc5b9 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_FILE_H_ -#define ART_SRC_DEX_FILE_H_ +#ifndef ART_RUNTIME_DEX_FILE_H_ +#define ART_RUNTIME_DEX_FILE_H_ #include #include @@ -1220,4 +1220,4 @@ class CatchHandlerIterator { } // namespace art -#endif // ART_SRC_DEX_FILE_H_ +#endif // ART_RUNTIME_DEX_FILE_H_ diff --git a/runtime/dex_file_verifier.h b/runtime/dex_file_verifier.h index 5538d4aa75..3797dc77e5 100644 --- a/runtime/dex_file_verifier.h +++ b/runtime/dex_file_verifier.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_FILE_VERIFIER_H_ -#define ART_SRC_DEX_FILE_VERIFIER_H_ +#ifndef ART_RUNTIME_DEX_FILE_VERIFIER_H_ +#define ART_RUNTIME_DEX_FILE_VERIFIER_H_ #include "dex_file.h" #include "safe_map.h" @@ -94,4 +94,4 @@ class DexFileVerifier { } // namespace art -#endif // ART_SRC_DEX_FILE_VERIFIER_H_ +#endif // ART_RUNTIME_DEX_FILE_VERIFIER_H_ diff --git a/runtime/dex_instruction-inl.h b/runtime/dex_instruction-inl.h index b426e66a1c..2cb5235417 100644 --- a/runtime/dex_instruction-inl.h +++ b/runtime/dex_instruction-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_INSTRUCTION_INL_H_ -#define ART_SRC_DEX_INSTRUCTION_INL_H_ +#ifndef ART_RUNTIME_DEX_INSTRUCTION_INL_H_ +#define ART_RUNTIME_DEX_INSTRUCTION_INL_H_ #include "dex_instruction.h" @@ -319,4 +319,4 @@ inline void Instruction::GetArgs(uint32_t arg[5]) const { } // namespace art -#endif // ART_SRC_DEX_INSTRUCTION_INL_H_ +#endif // ART_RUNTIME_DEX_INSTRUCTION_INL_H_ diff --git a/runtime/dex_instruction.h b/runtime/dex_instruction.h index 0407c57935..d2ad989395 100644 --- a/runtime/dex_instruction.h +++ b/runtime/dex_instruction.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_INSTRUCTION_H_ -#define ART_SRC_DEX_INSTRUCTION_H_ +#ifndef ART_RUNTIME_DEX_INSTRUCTION_H_ +#define ART_RUNTIME_DEX_INSTRUCTION_H_ #include "base/logging.h" #include "base/macros.h" @@ -443,4 +443,4 @@ struct DecodedInstruction { } // namespace art -#endif // ART_SRC_DEX_INSTRUCTION_H_ +#endif // ART_RUNTIME_DEX_INSTRUCTION_H_ diff --git a/runtime/dex_instruction_list.h b/runtime/dex_instruction_list.h index 8257c783e7..31d51c9b41 100644 --- a/runtime/dex_instruction_list.h +++ b/runtime/dex_instruction_list.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef ART_RUNTIME_DEX_INSTRUCTION_LIST_H_ +#define ART_RUNTIME_DEX_INSTRUCTION_LIST_H_ + #define DEX_INSTRUCTION_LIST(V) \ V(0x00, NOP, "nop", k10x, false, kNone, kContinue, kVerifyNone) \ V(0x01, MOVE, "move", k12x, true, kNone, kContinue, kVerifyRegA | kVerifyRegB) \ @@ -297,3 +300,6 @@ V(k35c) \ V(k3rc) \ V(k51l) + +#endif // ART_RUNTIME_DEX_INSTRUCTION_LIST_H_ +#undef ART_RUNTIME_DEX_INSTRUCTION_LIST_H_ // the guard in this file is just for cpplint diff --git a/runtime/dex_instruction_visitor.h b/runtime/dex_instruction_visitor.h index ff4620f8f0..795b95bf76 100644 --- a/runtime/dex_instruction_visitor.h +++ b/runtime/dex_instruction_visitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_INSTRUCTION_VISITOR_H_ -#define ART_SRC_DEX_INSTRUCTION_VISITOR_H_ +#ifndef ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ +#define ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ #include "base/macros.h" #include "dex_instruction.h" @@ -69,4 +69,4 @@ class DexInstructionVisitor { } // namespace art -#endif // ART_SRC_DEX_INSTRUCTION_VISITOR_H_ +#endif // ART_RUNTIME_DEX_INSTRUCTION_VISITOR_H_ diff --git a/runtime/dex_method_iterator.h b/runtime/dex_method_iterator.h index dc2e712681..cb71cb5b11 100644 --- a/runtime/dex_method_iterator.h +++ b/runtime/dex_method_iterator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DEX_METHOD_ITERATOR_H_ -#define ART_SRC_DEX_METHOD_ITERATOR_H_ +#ifndef ART_RUNTIME_DEX_METHOD_ITERATOR_H_ +#define ART_RUNTIME_DEX_METHOD_ITERATOR_H_ #include @@ -147,4 +147,4 @@ class DexMethodIterator { } // namespace art -#endif // ART_SRC_DEX_METHOD_ITERATOR_H_ +#endif // ART_RUNTIME_DEX_METHOD_ITERATOR_H_ diff --git a/runtime/disassembler.h b/runtime/disassembler.h index 1f50bfc9c0..805ff4d079 100644 --- a/runtime/disassembler.h +++ b/runtime/disassembler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DISASSEMBLER_H_ -#define ART_SRC_DISASSEMBLER_H_ +#ifndef ART_RUNTIME_DISASSEMBLER_H_ +#define ART_RUNTIME_DISASSEMBLER_H_ #include @@ -45,4 +45,4 @@ class Disassembler { } // namespace art -#endif // ART_SRC_DISASSEMBLER_H_ +#endif // ART_RUNTIME_DISASSEMBLER_H_ diff --git a/runtime/disassembler_arm.h b/runtime/disassembler_arm.h index 103876f33b..cab9150108 100644 --- a/runtime/disassembler_arm.h +++ b/runtime/disassembler_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DISASSEMBLER_ARM_H_ -#define ART_SRC_DISASSEMBLER_ARM_H_ +#ifndef ART_RUNTIME_DISASSEMBLER_ARM_H_ +#define ART_RUNTIME_DISASSEMBLER_ARM_H_ #include @@ -48,4 +48,4 @@ class DisassemblerArm : public Disassembler { } // namespace arm } // namespace art -#endif // ART_SRC_DISASSEMBLER_ARM_H_ +#endif // ART_RUNTIME_DISASSEMBLER_ARM_H_ diff --git a/runtime/disassembler_mips.h b/runtime/disassembler_mips.h index ed45113db7..e248503963 100644 --- a/runtime/disassembler_mips.h +++ b/runtime/disassembler_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DISASSEMBLER_MIPS_H_ -#define ART_SRC_DISASSEMBLER_MIPS_H_ +#ifndef ART_RUNTIME_DISASSEMBLER_MIPS_H_ +#define ART_RUNTIME_DISASSEMBLER_MIPS_H_ #include @@ -37,4 +37,4 @@ class DisassemblerMips : public Disassembler { } // namespace mips } // namespace art -#endif // ART_SRC_DISASSEMBLER_MIPS_H_ +#endif // ART_RUNTIME_DISASSEMBLER_MIPS_H_ diff --git a/runtime/disassembler_x86.h b/runtime/disassembler_x86.h index 13f8503720..ff4322c8b8 100644 --- a/runtime/disassembler_x86.h +++ b/runtime/disassembler_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_DISASSEMBLER_X86_H_ -#define ART_SRC_DISASSEMBLER_X86_H_ +#ifndef ART_RUNTIME_DISASSEMBLER_X86_H_ +#define ART_RUNTIME_DISASSEMBLER_X86_H_ #include "disassembler.h" @@ -35,4 +35,4 @@ class DisassemblerX86 : public Disassembler { } // namespace x86 } // namespace art -#endif // ART_SRC_DISASSEMBLER_X86_H_ +#endif // ART_RUNTIME_DISASSEMBLER_X86_H_ diff --git a/runtime/elf_file.h b/runtime/elf_file.h index cb95cb0df0..33b5fc3f9b 100644 --- a/runtime/elf_file.h +++ b/runtime/elf_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ELF_FILE_H_ -#define ART_SRC_ELF_FILE_H_ +#ifndef ART_RUNTIME_ELF_FILE_H_ +#define ART_RUNTIME_ELF_FILE_H_ #include #include @@ -172,4 +172,4 @@ class ElfFile { } // namespace art -#endif // ART_SRC_ELF_FILE_H_ +#endif // ART_RUNTIME_ELF_FILE_H_ diff --git a/runtime/file_output_stream.h b/runtime/file_output_stream.h index b5eb4f8194..10405eff1f 100644 --- a/runtime/file_output_stream.h +++ b/runtime/file_output_stream.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_FILE_OUTPUT_STREAM_H_ -#define ART_SRC_FILE_OUTPUT_STREAM_H_ +#ifndef ART_RUNTIME_FILE_OUTPUT_STREAM_H_ +#define ART_RUNTIME_FILE_OUTPUT_STREAM_H_ #include "output_stream.h" @@ -41,4 +41,4 @@ class FileOutputStream : public OutputStream { } // namespace art -#endif // ART_SRC_FILE_OUTPUT_STREAM_H_ +#endif // ART_RUNTIME_FILE_OUTPUT_STREAM_H_ diff --git a/runtime/gc/accounting/atomic_stack.h b/runtime/gc/accounting/atomic_stack.h index 4e1c253bdf..5310c18ec6 100644 --- a/runtime/gc/accounting/atomic_stack.h +++ b/runtime/gc/accounting/atomic_stack.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_ATOMIC_STACK_H_ -#define ART_SRC_GC_ACCOUNTING_ATOMIC_STACK_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_ATOMIC_STACK_H_ +#define ART_RUNTIME_GC_ACCOUNTING_ATOMIC_STACK_H_ #include @@ -189,4 +189,4 @@ typedef AtomicStack ObjectStack; } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_ATOMIC_STACK_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_ATOMIC_STACK_H_ diff --git a/runtime/gc/accounting/card_table-inl.h b/runtime/gc/accounting/card_table-inl.h index 1e7529084a..f8f2773582 100644 --- a/runtime/gc/accounting/card_table-inl.h +++ b/runtime/gc/accounting/card_table-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_CARDTABLE_INL_H_ -#define ART_SRC_GC_CARDTABLE_INL_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_INL_H_ +#define ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_INL_H_ #include "base/logging.h" #include "card_table.h" @@ -210,4 +210,4 @@ inline void CardTable::CheckCardValid(byte* card) const { } // namespace gc } // namespace art -#endif // ART_SRC_GC_CARDTABLE_INL_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_INL_H_ diff --git a/runtime/gc/accounting/card_table.h b/runtime/gc/accounting/card_table.h index cf85d15448..1acaf5bdfc 100644 --- a/runtime/gc/accounting/card_table.h +++ b/runtime/gc/accounting/card_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_CARDTABLE_H_ -#define ART_SRC_GC_CARDTABLE_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_H_ +#define ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_H_ #include "globals.h" #include "locks.h" @@ -153,4 +153,4 @@ class CardTable { } // namespace gc } // namespace art -#endif // ART_SRC_GC_CARDTABLE_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_CARD_TABLE_H_ diff --git a/runtime/gc/accounting/heap_bitmap-inl.h b/runtime/gc/accounting/heap_bitmap-inl.h index 8e3123b974..76226041d1 100644 --- a/runtime/gc/accounting/heap_bitmap-inl.h +++ b/runtime/gc/accounting/heap_bitmap-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ -#define ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ +#define ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ #include "heap_bitmap.h" @@ -47,4 +47,4 @@ inline void HeapBitmap::Visit(const Visitor& visitor) { } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_INL_H_ diff --git a/runtime/gc/accounting/heap_bitmap.h b/runtime/gc/accounting/heap_bitmap.h index 5ff40c6426..a12809ea55 100644 --- a/runtime/gc/accounting/heap_bitmap.h +++ b/runtime/gc/accounting/heap_bitmap.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_H_ -#define ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_ +#define ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_ #include "base/logging.h" #include "locks.h" @@ -126,4 +126,4 @@ class HeapBitmap { } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_HEAP_BITMAP_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_HEAP_BITMAP_H_ diff --git a/runtime/gc/accounting/mod_union_table-inl.h b/runtime/gc/accounting/mod_union_table-inl.h index 656af94853..32ac95f9f8 100644 --- a/runtime/gc/accounting/mod_union_table-inl.h +++ b/runtime/gc/accounting/mod_union_table-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_MOD_UNION_TABLE_INL_H_ -#define ART_SRC_GC_MOD_UNION_TABLE_INL_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_INL_H_ +#define ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_INL_H_ #include "mod_union_table.h" @@ -72,4 +72,4 @@ class ModUnionTableToAllocspace : public ModUnionTableReferenceCache { } // namespace gc } // namespace art -#endif // ART_SRC_GC_MOD_UNION_TABLE_INL_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_INL_H_ diff --git a/runtime/gc/accounting/mod_union_table.h b/runtime/gc/accounting/mod_union_table.h index 5d25e05658..543562563b 100644 --- a/runtime/gc/accounting/mod_union_table.h +++ b/runtime/gc/accounting/mod_union_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_MOD_UNION_TABLE_H_ -#define ART_SRC_GC_ACCOUNTING_MOD_UNION_TABLE_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_H_ +#define ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_H_ #include "globals.h" #include "safe_map.h" @@ -150,4 +150,4 @@ class ModUnionTableCardCache : public ModUnionTable { } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_MOD_UNION_TABLE_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_MOD_UNION_TABLE_H_ diff --git a/runtime/gc/accounting/space_bitmap-inl.h b/runtime/gc/accounting/space_bitmap-inl.h index a4fd330c8f..d074a0f578 100644 --- a/runtime/gc/accounting/space_bitmap-inl.h +++ b/runtime/gc/accounting/space_bitmap-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ -#define ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ +#define ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ #include "base/logging.h" #include "cutils/atomic-inline.h" @@ -144,4 +144,4 @@ inline bool SpaceBitmap::Modify(const mirror::Object* obj, bool do_set) { } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_INL_H_ diff --git a/runtime/gc/accounting/space_bitmap.h b/runtime/gc/accounting/space_bitmap.h index bb487d88d0..32ab440f31 100644 --- a/runtime/gc/accounting/space_bitmap.h +++ b/runtime/gc/accounting/space_bitmap.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_H_ -#define ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_H_ +#ifndef ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_H_ +#define ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_H_ #include "locks.h" #include "globals.h" @@ -262,4 +262,4 @@ std::ostream& operator << (std::ostream& stream, const SpaceBitmap& bitmap); } // namespace gc } // namespace art -#endif // ART_SRC_GC_ACCOUNTING_SPACE_BITMAP_H_ +#endif // ART_RUNTIME_GC_ACCOUNTING_SPACE_BITMAP_H_ diff --git a/runtime/gc/allocator/dlmalloc.h b/runtime/gc/allocator/dlmalloc.h index 6b02a44ffe..07ebd1c0e3 100644 --- a/runtime/gc/allocator/dlmalloc.h +++ b/runtime/gc/allocator/dlmalloc.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_ALLOCATOR_DLMALLOC_H_ -#define ART_SRC_GC_ALLOCATOR_DLMALLOC_H_ +#ifndef ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ +#define ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ // Configure dlmalloc for mspaces. #define HAVE_MMAP 0 @@ -37,4 +37,4 @@ extern "C" int dlmalloc_trim(size_t); // pages back to the kernel. extern "C" void DlmallocMadviseCallback(void* start, void* end, size_t used_bytes, void* /*arg*/); -#endif // ART_SRC_GC_ALLOCATOR_DLMALLOC_H_ +#endif // ART_RUNTIME_GC_ALLOCATOR_DLMALLOC_H_ diff --git a/runtime/gc/collector/garbage_collector.h b/runtime/gc/collector/garbage_collector.h index 1ab395775b..a22faac43b 100644 --- a/runtime/gc/collector/garbage_collector.h +++ b/runtime/gc/collector/garbage_collector.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_GARBAGE_COLLECTOR_H_ -#define ART_SRC_GC_GARBAGE_COLLECTOR_H_ +#ifndef ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_ +#define ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_ #include "gc_type.h" #include "locks.h" @@ -119,4 +119,4 @@ class GarbageCollector { } // namespace gc } // namespace art -#endif // ART_SRC_GC_GARBAGE_COLLECTOR_H_ +#endif // ART_RUNTIME_GC_COLLECTOR_GARBAGE_COLLECTOR_H_ diff --git a/runtime/gc/collector/gc_type.h b/runtime/gc/collector/gc_type.h index bb25bb93f9..f18e40fa74 100644 --- a/runtime/gc/collector/gc_type.h +++ b/runtime/gc/collector/gc_type.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_COLLECTOR_GC_TYPE_H_ -#define ART_SRC_GC_COLLECTOR_GC_TYPE_H_ +#ifndef ART_RUNTIME_GC_COLLECTOR_GC_TYPE_H_ +#define ART_RUNTIME_GC_COLLECTOR_GC_TYPE_H_ #include @@ -43,4 +43,4 @@ std::ostream& operator<<(std::ostream& os, const GcType& policy); } // namespace gc } // namespace art -#endif // ART_SRC_GC_COLLECTOR_GC_TYPE_H_ +#endif // ART_RUNTIME_GC_COLLECTOR_GC_TYPE_H_ diff --git a/runtime/gc/collector/mark_sweep-inl.h b/runtime/gc/collector/mark_sweep-inl.h index ea9fced84a..6b1b617eb4 100644 --- a/runtime/gc/collector/mark_sweep-inl.h +++ b/runtime/gc/collector/mark_sweep-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_MARK_SWEEP_INL_H_ -#define ART_SRC_GC_MARK_SWEEP_INL_H_ +#ifndef ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_ +#define ART_RUNTIME_GC_COLLECTOR_MARK_SWEEP_INL_H_ #include "gc/collector/mark_sweep.h" @@ -162,4 +162,4 @@ inline void MarkSweep::VisitObjectArrayReferences(const mirror::ObjectArray #include @@ -609,4 +609,4 @@ class Heap { } // namespace gc } // namespace art -#endif // ART_SRC_GC_HEAP_H_ +#endif // ART_RUNTIME_GC_HEAP_H_ diff --git a/runtime/gc/space/dlmalloc_space.h b/runtime/gc/space/dlmalloc_space.h index 00df0e6d42..8a4314c716 100644 --- a/runtime/gc/space/dlmalloc_space.h +++ b/runtime/gc/space/dlmalloc_space.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_DLMALLOC_SPACE_H_ -#define ART_SRC_GC_SPACE_DLMALLOC_SPACE_H_ +#ifndef ART_RUNTIME_GC_SPACE_DLMALLOC_SPACE_H_ +#define ART_RUNTIME_GC_SPACE_DLMALLOC_SPACE_H_ #include "gc/allocator/dlmalloc.h" #include "space.h" @@ -182,4 +182,4 @@ class DlMallocSpace : public MemMapSpace, public AllocSpace { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_DLMALLOC_SPACE_H_ +#endif // ART_RUNTIME_GC_SPACE_DLMALLOC_SPACE_H_ diff --git a/runtime/gc/space/image_space.h b/runtime/gc/space/image_space.h index 833fb8d73a..fde2b419ac 100644 --- a/runtime/gc/space/image_space.h +++ b/runtime/gc/space/image_space.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_IMAGE_SPACE_H_ -#define ART_SRC_GC_SPACE_IMAGE_SPACE_H_ +#ifndef ART_RUNTIME_GC_SPACE_IMAGE_SPACE_H_ +#define ART_RUNTIME_GC_SPACE_IMAGE_SPACE_H_ #include "space.h" @@ -115,4 +115,4 @@ class ImageSpace : public MemMapSpace { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_IMAGE_SPACE_H_ +#endif // ART_RUNTIME_GC_SPACE_IMAGE_SPACE_H_ diff --git a/runtime/gc/space/large_object_space.h b/runtime/gc/space/large_object_space.h index 197fad3854..74d9cca6db 100644 --- a/runtime/gc/space/large_object_space.h +++ b/runtime/gc/space/large_object_space.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_LARGE_OBJECT_SPACE_H_ -#define ART_SRC_GC_SPACE_LARGE_OBJECT_SPACE_H_ +#ifndef ART_RUNTIME_GC_SPACE_LARGE_OBJECT_SPACE_H_ +#define ART_RUNTIME_GC_SPACE_LARGE_OBJECT_SPACE_H_ #include "dlmalloc_space.h" @@ -190,4 +190,4 @@ class FreeListSpace : public LargeObjectSpace { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_LARGE_OBJECT_SPACE_H_ +#endif // ART_RUNTIME_GC_SPACE_LARGE_OBJECT_SPACE_H_ diff --git a/runtime/gc/space/space-inl.h b/runtime/gc/space/space-inl.h index 54bf604822..2c3b93c60d 100644 --- a/runtime/gc/space/space-inl.h +++ b/runtime/gc/space/space-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_SPACE_INL_H_ -#define ART_SRC_GC_SPACE_SPACE_INL_H_ +#ifndef ART_RUNTIME_GC_SPACE_SPACE_INL_H_ +#define ART_RUNTIME_GC_SPACE_SPACE_INL_H_ #include "space.h" @@ -45,4 +45,4 @@ inline LargeObjectSpace* Space::AsLargeObjectSpace() { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_SPACE_INL_H_ +#endif // ART_RUNTIME_GC_SPACE_SPACE_INL_H_ diff --git a/runtime/gc/space/space.h b/runtime/gc/space/space.h index ca01c55497..48f0579d83 100644 --- a/runtime/gc/space/space.h +++ b/runtime/gc/space/space.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_SPACE_SPACE_H_ -#define ART_SRC_GC_SPACE_SPACE_H_ +#ifndef ART_RUNTIME_GC_SPACE_SPACE_H_ +#define ART_RUNTIME_GC_SPACE_SPACE_H_ #include @@ -292,4 +292,4 @@ class MemMapSpace : public ContinuousSpace { } // namespace gc } // namespace art -#endif // ART_SRC_GC_SPACE_SPACE_H_ +#endif // ART_RUNTIME_GC_SPACE_SPACE_H_ diff --git a/runtime/gc_map.h b/runtime/gc_map.h index 473b39a629..33d09f29f6 100644 --- a/runtime/gc_map.h +++ b/runtime/gc_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GC_MAP_H_ -#define ART_SRC_GC_MAP_H_ +#ifndef ART_RUNTIME_GC_MAP_H_ +#define ART_RUNTIME_GC_MAP_H_ #include @@ -108,4 +108,4 @@ class NativePcOffsetToReferenceMap { } // namespace art -#endif // ART_SRC_GC_MAP_H_ +#endif // ART_RUNTIME_GC_MAP_H_ diff --git a/runtime/globals.h b/runtime/globals.h index dc9341ae0f..c3974943cd 100644 --- a/runtime/globals.h +++ b/runtime/globals.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_GLOBALS_H_ -#define ART_SRC_GLOBALS_H_ +#ifndef ART_RUNTIME_GLOBALS_H_ +#define ART_RUNTIME_GLOBALS_H_ #include #include @@ -75,4 +75,4 @@ const bool kIsTargetBuild = false; } // namespace art -#endif // ART_SRC_GLOBALS_H_ +#endif // ART_RUNTIME_GLOBALS_H_ diff --git a/runtime/hprof/hprof.h b/runtime/hprof/hprof.h index c6222dcb90..91684648a5 100644 --- a/runtime/hprof/hprof.h +++ b/runtime/hprof/hprof.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef HPROF_HPROF_H_ -#define HPROF_HPROF_H_ +#ifndef ART_RUNTIME_HPROF_HPROF_H_ +#define ART_RUNTIME_HPROF_HPROF_H_ namespace art { @@ -27,4 +27,4 @@ void DumpHeap(const char* filename, int fd, bool direct_to_ddms); } // namespace art -#endif // HPROF_HPROF_H_ +#endif // ART_RUNTIME_HPROF_HPROF_H_ diff --git a/runtime/image.h b/runtime/image.h index f14d7d190a..35e4c5cabd 100644 --- a/runtime/image.h +++ b/runtime/image.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_IMAGE_H_ -#define ART_SRC_IMAGE_H_ +#ifndef ART_RUNTIME_IMAGE_H_ +#define ART_RUNTIME_IMAGE_H_ #include @@ -131,4 +131,4 @@ class PACKED(4) ImageHeader { } // namespace art -#endif // ART_SRC_IMAGE_H_ +#endif // ART_RUNTIME_IMAGE_H_ diff --git a/runtime/indenter.h b/runtime/indenter.h index 4ac0c01163..c432e1ba8d 100644 --- a/runtime/indenter.h +++ b/runtime/indenter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INDENTER_H_ -#define ART_SRC_INDENTER_H_ +#ifndef ART_RUNTIME_INDENTER_H_ +#define ART_RUNTIME_INDENTER_H_ #include "base/macros.h" #include @@ -60,4 +60,4 @@ class Indenter : public std::streambuf { DISALLOW_COPY_AND_ASSIGN(Indenter); }; -#endif // ART_SRC_INDENTER_H_ +#endif // ART_RUNTIME_INDENTER_H_ diff --git a/runtime/indirect_reference_table.h b/runtime/indirect_reference_table.h index e09043dba7..34b0f3abe2 100644 --- a/runtime/indirect_reference_table.h +++ b/runtime/indirect_reference_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INDIRECT_REFERENCE_TABLE_H_ -#define ART_SRC_INDIRECT_REFERENCE_TABLE_H_ +#ifndef ART_RUNTIME_INDIRECT_REFERENCE_TABLE_H_ +#define ART_RUNTIME_INDIRECT_REFERENCE_TABLE_H_ #include @@ -378,4 +378,4 @@ class IndirectReferenceTable { } // namespace art -#endif // ART_SRC_INDIRECT_REFERENCE_TABLE_H_ +#endif // ART_RUNTIME_INDIRECT_REFERENCE_TABLE_H_ diff --git a/runtime/instruction_set.h b/runtime/instruction_set.h index c4dae4dcb6..2217f7f76e 100644 --- a/runtime/instruction_set.h +++ b/runtime/instruction_set.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INSTRUCTION_SET_H_ -#define ART_SRC_INSTRUCTION_SET_H_ +#ifndef ART_RUNTIME_INSTRUCTION_SET_H_ +#define ART_RUNTIME_INSTRUCTION_SET_H_ #include @@ -33,4 +33,4 @@ std::ostream& operator<<(std::ostream& os, const InstructionSet& rhs); } // namespace art -#endif // ART_SRC_INSTRUCTION_SET_H_ +#endif // ART_RUNTIME_INSTRUCTION_SET_H_ diff --git a/runtime/instrumentation.h b/runtime/instrumentation.h index 5fea34f388..e0f1fa978b 100644 --- a/runtime/instrumentation.h +++ b/runtime/instrumentation.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INSTRUMENTATION_H_ -#define ART_SRC_INSTRUMENTATION_H_ +#ifndef ART_RUNTIME_INSTRUMENTATION_H_ +#define ART_RUNTIME_INSTRUMENTATION_H_ #include "base/macros.h" #include "locks.h" @@ -290,4 +290,4 @@ struct InstrumentationStackFrame { } // namespace instrumentation } // namespace art -#endif // ART_SRC_INSTRUMENTATION_H_ +#endif // ART_RUNTIME_INSTRUMENTATION_H_ diff --git a/runtime/intern_table.h b/runtime/intern_table.h index 1ff4f6d3c6..5031ce3c5a 100644 --- a/runtime/intern_table.h +++ b/runtime/intern_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INTERN_TABLE_H_ -#define ART_SRC_INTERN_TABLE_H_ +#ifndef ART_RUNTIME_INTERN_TABLE_H_ +#define ART_RUNTIME_INTERN_TABLE_H_ #include "base/mutex.h" #include "root_visitor.h" @@ -95,4 +95,4 @@ class InternTable { } // namespace art -#endif // ART_SRC_CLASS_LINKER_H_ +#endif // ART_RUNTIME_INTERN_TABLE_H_ diff --git a/runtime/interpreter/interpreter.h b/runtime/interpreter/interpreter.h index 20166ac545..17884b9a63 100644 --- a/runtime/interpreter/interpreter.h +++ b/runtime/interpreter/interpreter.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INTERPRETER_INTERPRETER_H_ -#define ART_SRC_INTERPRETER_INTERPRETER_H_ +#ifndef ART_RUNTIME_INTERPRETER_INTERPRETER_H_ +#define ART_RUNTIME_INTERPRETER_INTERPRETER_H_ #include "dex_file.h" #include "locks.h" @@ -55,4 +55,4 @@ extern "C" void artInterpreterToInterpreterEntry(Thread* self, MethodHelper& mh, } // namespace interpreter } // namespace art -#endif // ART_SRC_INTERPRETER_INTERPRETER_H_ +#endif // ART_RUNTIME_INTERPRETER_INTERPRETER_H_ diff --git a/runtime/invoke_arg_array_builder.h b/runtime/invoke_arg_array_builder.h index b57d60a70f..c1d8249fd3 100644 --- a/runtime/invoke_arg_array_builder.h +++ b/runtime/invoke_arg_array_builder.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INVOKE_ARG_ARRAY_BUILDER_H_ -#define ART_SRC_INVOKE_ARG_ARRAY_BUILDER_H_ +#ifndef ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ +#define ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ #include "mirror/object.h" #include "scoped_thread_state_change.h" @@ -180,4 +180,4 @@ class ArgArray { } // namespace art -#endif // ART_SRC_INVOKE_ARG_ARRAY_BUILDER_H_ +#endif // ART_RUNTIME_INVOKE_ARG_ARRAY_BUILDER_H_ diff --git a/runtime/invoke_type.h b/runtime/invoke_type.h index d724fdb9c1..cdf9be87d9 100644 --- a/runtime/invoke_type.h +++ b/runtime/invoke_type.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_INVOKE_TYPE_H_ -#define ART_SRC_INVOKE_TYPE_H_ +#ifndef ART_RUNTIME_INVOKE_TYPE_H_ +#define ART_RUNTIME_INVOKE_TYPE_H_ #include @@ -34,4 +34,4 @@ std::ostream& operator<<(std::ostream& os, const InvokeType& rhs); } // namespace art -#endif // ART_SRC_INVOKE_TYPE_H_ +#endif // ART_RUNTIME_INVOKE_TYPE_H_ diff --git a/runtime/jdwp/jdwp.h b/runtime/jdwp/jdwp.h index 436525c3d0..6a5d0d19fb 100644 --- a/runtime/jdwp/jdwp.h +++ b/runtime/jdwp/jdwp.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_JDWP_JDWP_H_ -#define ART_JDWP_JDWP_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_H_ +#define ART_RUNTIME_JDWP_JDWP_H_ #include "base/mutex.h" #include "jdwp/jdwp_bits.h" @@ -429,4 +429,4 @@ class Request { } // namespace art -#endif // ART_JDWP_JDWP_H_ +#endif // ART_RUNTIME_JDWP_JDWP_H_ diff --git a/runtime/jdwp/jdwp_bits.h b/runtime/jdwp/jdwp_bits.h index 2a3c775164..9f80cbe307 100644 --- a/runtime/jdwp/jdwp_bits.h +++ b/runtime/jdwp/jdwp_bits.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_JDWP_BITS_H_ -#define ART_JDWP_BITS_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_BITS_H_ +#define ART_RUNTIME_JDWP_JDWP_BITS_H_ #include #include @@ -121,4 +121,4 @@ static inline void Write8BE(uint8_t** dst, uint64_t value) { } // namespace art -#endif // ART_JDWP_BITS_H_ +#endif // ART_RUNTIME_JDWP_JDWP_BITS_H_ diff --git a/runtime/jdwp/jdwp_constants.h b/runtime/jdwp/jdwp_constants.h index ebc575b6b6..a8db325c66 100644 --- a/runtime/jdwp/jdwp_constants.h +++ b/runtime/jdwp/jdwp_constants.h @@ -16,8 +16,8 @@ /* * These come out of the JDWP documentation. */ -#ifndef ART_JDWP_JDWPCONSTANTS_H_ -#define ART_JDWP_JDWPCONSTANTS_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_CONSTANTS_H_ +#define ART_RUNTIME_JDWP_JDWP_CONSTANTS_H_ #include @@ -246,4 +246,4 @@ std::ostream& operator<<(std::ostream& os, const JdwpTag& value); } // namespace art -#endif // ART_JDWP_JDWPCONSTANTS_H_ +#endif // ART_RUNTIME_JDWP_JDWP_CONSTANTS_H_ diff --git a/runtime/jdwp/jdwp_event.h b/runtime/jdwp/jdwp_event.h index a6eabb1371..d269761999 100644 --- a/runtime/jdwp/jdwp_event.h +++ b/runtime/jdwp/jdwp_event.h @@ -16,8 +16,8 @@ /* * Handle registration of events, and debugger event notification. */ -#ifndef ART_JDWP_JDWPEVENT_H_ -#define ART_JDWP_JDWPEVENT_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_EVENT_H_ +#define ART_RUNTIME_JDWP_JDWP_EVENT_H_ #include "jdwp/jdwp.h" #include "jdwp/jdwp_constants.h" @@ -110,4 +110,4 @@ void EventFree(JdwpEvent* pEvent); } // namespace art -#endif // ART_JDWP_JDWPEVENT_H_ +#endif // ART_RUNTIME_JDWP_JDWP_EVENT_H_ diff --git a/runtime/jdwp/jdwp_expand_buf.h b/runtime/jdwp/jdwp_expand_buf.h index 820f62d6a0..81e01e2100 100644 --- a/runtime/jdwp/jdwp_expand_buf.h +++ b/runtime/jdwp/jdwp_expand_buf.h @@ -16,8 +16,8 @@ /* * Expanding byte buffer, with primitives for appending basic data types. */ -#ifndef ART_JDWP_EXPANDBUF_H_ -#define ART_JDWP_EXPANDBUF_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_EXPAND_BUF_H_ +#define ART_RUNTIME_JDWP_JDWP_EXPAND_BUF_H_ #include @@ -67,4 +67,4 @@ void expandBufAddLocation(ExpandBuf* pReply, const JdwpLocation& location); } // namespace art -#endif // ART_JDWP_EXPANDBUF_H_ +#endif // ART_RUNTIME_JDWP_JDWP_EXPAND_BUF_H_ diff --git a/runtime/jdwp/jdwp_priv.h b/runtime/jdwp/jdwp_priv.h index c8a7b2686d..ab89339347 100644 --- a/runtime/jdwp/jdwp_priv.h +++ b/runtime/jdwp/jdwp_priv.h @@ -16,8 +16,8 @@ /* * JDWP internal interfaces. */ -#ifndef ART_JDWP_JDWPPRIV_H_ -#define ART_JDWP_JDWPPRIV_H_ +#ifndef ART_RUNTIME_JDWP_JDWP_PRIV_H_ +#define ART_RUNTIME_JDWP_JDWP_PRIV_H_ #include "debugger.h" #include "jdwp/jdwp.h" @@ -101,4 +101,4 @@ class JdwpNetStateBase { } // namespace art -#endif // ART_JDWP_JDWPPRIV_H_ +#endif // ART_RUNTIME_JDWP_JDWP_PRIV_H_ diff --git a/runtime/jdwp/object_registry.h b/runtime/jdwp/object_registry.h index d0ea59da71..345f0ad73a 100644 --- a/runtime/jdwp/object_registry.h +++ b/runtime/jdwp/object_registry.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef ART_RUNTIME_JDWP_OBJECT_REGISTRY_H_ +#define ART_RUNTIME_JDWP_OBJECT_REGISTRY_H_ + #include #include @@ -98,3 +101,5 @@ class ObjectRegistry { }; } // namespace art + +#endif // ART_RUNTIME_JDWP_OBJECT_REGISTRY_H_ diff --git a/runtime/jni_internal.h b/runtime/jni_internal.h index 7b43f95cb3..ad66ada329 100644 --- a/runtime/jni_internal.h +++ b/runtime/jni_internal.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_JNI_INTERNAL_H_ -#define ART_SRC_JNI_INTERNAL_H_ +#ifndef ART_RUNTIME_JNI_INTERNAL_H_ +#define ART_RUNTIME_JNI_INTERNAL_H_ #include "jni.h" @@ -198,4 +198,4 @@ class ScopedJniEnvLocalRefState { std::ostream& operator<<(std::ostream& os, const jobjectRefType& rhs); -#endif // ART_SRC_JNI_INTERNAL_H_ +#endif // ART_RUNTIME_JNI_INTERNAL_H_ diff --git a/runtime/jobject_comparator.h b/runtime/jobject_comparator.h index 17098aaebb..698d6678d6 100644 --- a/runtime/jobject_comparator.h +++ b/runtime/jobject_comparator.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_JOBJECT_COMPARATOR_H_ -#define ART_SRC_JOBJECT_COMPARATOR_H_ +#ifndef ART_RUNTIME_JOBJECT_COMPARATOR_H_ +#define ART_RUNTIME_JOBJECT_COMPARATOR_H_ #include @@ -27,4 +27,4 @@ struct JobjectComparator { } // namespace art -#endif // ART_SRC_JOBJECT_COMPARATOR_H_ +#endif // ART_RUNTIME_JOBJECT_COMPARATOR_H_ diff --git a/runtime/jvalue.h b/runtime/jvalue.h index 66cd93e2c0..0c1aadb462 100644 --- a/runtime/jvalue.h +++ b/runtime/jvalue.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_JVALUE_H_ -#define ART_SRC_JVALUE_H_ +#ifndef ART_RUNTIME_JVALUE_H_ +#define ART_RUNTIME_JVALUE_H_ #include "base/macros.h" @@ -75,4 +75,4 @@ union PACKED(4) JValue { } // namespace art -#endif // ART_SRC_JVALUE_H_ +#endif // ART_RUNTIME_JVALUE_H_ diff --git a/runtime/leb128.h b/runtime/leb128.h index a5a6683aee..ca955b0921 100644 --- a/runtime/leb128.h +++ b/runtime/leb128.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_LEB128_H_ -#define ART_SRC_LEB128_H_ +#ifndef ART_RUNTIME_LEB128_H_ +#define ART_RUNTIME_LEB128_H_ #include "globals.h" @@ -121,4 +121,4 @@ static inline uint8_t* WriteUnsignedLeb128(uint8_t* ptr, uint32_t data) { } // namespace art -#endif // ART_SRC_LEB128_H_ +#endif // ART_RUNTIME_LEB128_H_ diff --git a/runtime/locks.h b/runtime/locks.h index 91437e1830..6b0e96f8b9 100644 --- a/runtime/locks.h +++ b/runtime/locks.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_LOCKS_H_ -#define ART_SRC_LOCKS_H_ +#ifndef ART_RUNTIME_LOCKS_H_ +#define ART_RUNTIME_LOCKS_H_ #include @@ -165,4 +165,4 @@ class Locks { } // namespace art -#endif // ART_SRC_LOCKS_H_ +#endif // ART_RUNTIME_LOCKS_H_ diff --git a/runtime/log_severity.h b/runtime/log_severity.h index 126019bdb6..bb7679d218 100644 --- a/runtime/log_severity.h +++ b/runtime/log_severity.h @@ -14,12 +14,12 @@ * limitations under the License. */ -#ifndef BASE_LOG_SEVERITY_H_ -#define BASE_LOG_SEVERITY_H_ +#ifndef ART_RUNTIME_LOG_SEVERITY_H_ +#define ART_RUNTIME_LOG_SEVERITY_H_ typedef int LogSeverity; const int VERBOSE = 0, DEBUG = 1, INFO = 2, WARNING = 3, ERROR = 4, FATAL = 5; const int INTERNAL_FATAL = 6; // For Runtime::Abort. -#endif // BASE_LOG_SEVERITY_H_ +#endif // ART_RUNTIME_LOG_SEVERITY_H_ diff --git a/runtime/mem_map.h b/runtime/mem_map.h index 2eb7772705..7d418a5c6a 100644 --- a/runtime/mem_map.h +++ b/runtime/mem_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MEM_MAP_H_ -#define ART_SRC_MEM_MAP_H_ +#ifndef ART_RUNTIME_MEM_MAP_H_ +#define ART_RUNTIME_MEM_MAP_H_ #include @@ -101,4 +101,4 @@ class MemMap { } // namespace art -#endif // ART_SRC_MEM_MAP_H_ +#endif // ART_RUNTIME_MEM_MAP_H_ diff --git a/runtime/memory_region.h b/runtime/memory_region.h index cfbe42dddf..849ab1c420 100644 --- a/runtime/memory_region.h +++ b/runtime/memory_region.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MEMORY_REGION_H_ -#define ART_SRC_MEMORY_REGION_H_ +#ifndef ART_RUNTIME_MEMORY_REGION_H_ +#define ART_RUNTIME_MEMORY_REGION_H_ #include @@ -96,4 +96,4 @@ class MemoryRegion { } // namespace art -#endif // ART_MEMORY_REGION_H_ +#endif // ART_RUNTIME_MEMORY_REGION_H_ diff --git a/runtime/method_reference.h b/runtime/method_reference.h index ff8bf313f0..1ff4ea0942 100644 --- a/runtime/method_reference.h +++ b/runtime/method_reference.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_METHOD_REFERENCE_H_ -#define ART_SRC_METHOD_REFERENCE_H_ +#ifndef ART_RUNTIME_METHOD_REFERENCE_H_ +#define ART_RUNTIME_METHOD_REFERENCE_H_ namespace art { @@ -44,4 +44,4 @@ struct MethodReferenceComparator { } // namespace art -#endif // ART_SRC_METHOD_REFERENCE_H_ +#endif // ART_RUNTIME_METHOD_REFERENCE_H_ diff --git a/runtime/mirror/abstract_method-inl.h b/runtime/mirror/abstract_method-inl.h index a8238867aa..6fcd705e55 100644 --- a/runtime/mirror/abstract_method-inl.h +++ b/runtime/mirror/abstract_method-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_METHOD_INL_H_ -#define ART_SRC_MIRROR_METHOD_INL_H_ +#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ +#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ #include "abstract_method.h" @@ -196,4 +196,4 @@ inline bool AbstractMethod::IsResolutionMethod() const { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_METHOD_INL_H_ +#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_INL_H_ diff --git a/runtime/mirror/abstract_method.h b/runtime/mirror/abstract_method.h index 339471dd5d..d909058e0d 100644 --- a/runtime/mirror/abstract_method.h +++ b/runtime/mirror/abstract_method.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_METHOD_H_ -#define ART_SRC_MIRROR_METHOD_H_ +#ifndef ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ +#define ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ #include "class.h" #include "dex_file.h" @@ -515,4 +515,4 @@ class MANAGED AbstractMethodClass : public Class { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_METHOD_H_ +#endif // ART_RUNTIME_MIRROR_ABSTRACT_METHOD_H_ diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h index b7f212f50f..eb73c7dd38 100644 --- a/runtime/mirror/array-inl.h +++ b/runtime/mirror/array-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_ARRAY_INL_H_ -#define ART_SRC_MIRROR_ARRAY_INL_H_ +#ifndef ART_RUNTIME_MIRROR_ARRAY_INL_H_ +#define ART_RUNTIME_MIRROR_ARRAY_INL_H_ #include "array.h" @@ -36,4 +36,4 @@ inline size_t Array::SizeOf() const { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_ARRAY_INL_H_ +#endif // ART_RUNTIME_MIRROR_ARRAY_INL_H_ diff --git a/runtime/mirror/array.h b/runtime/mirror/array.h index 98b8ea0008..b195a87fc0 100644 --- a/runtime/mirror/array.h +++ b/runtime/mirror/array.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_ARRAY_H_ -#define ART_SRC_MIRROR_ARRAY_H_ +#ifndef ART_RUNTIME_MIRROR_ARRAY_H_ +#define ART_RUNTIME_MIRROR_ARRAY_H_ #include "object.h" @@ -145,4 +145,4 @@ class MANAGED PrimitiveArray : public Array { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_ARRAY_H_ +#endif // ART_RUNTIME_MIRROR_ARRAY_H_ diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 6819fb2954..d323c3333b 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_CLASS_INL_H_ -#define ART_SRC_MIRROR_CLASS_INL_H_ +#ifndef ART_RUNTIME_MIRROR_CLASS_INL_H_ +#define ART_RUNTIME_MIRROR_CLASS_INL_H_ #include "class.h" @@ -346,4 +346,4 @@ inline void Class::SetName(String* name) { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_CLASS_INL_H_ +#endif // ART_RUNTIME_MIRROR_CLASS_INL_H_ diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 084aa24c7c..9a506c29af 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_CLASS_H_ -#define ART_SRC_MIRROR_CLASS_H_ +#ifndef ART_RUNTIME_MIRROR_CLASS_H_ +#define ART_RUNTIME_MIRROR_CLASS_H_ #include "modifiers.h" #include "object.h" @@ -882,4 +882,4 @@ class MANAGED ClassClass : public Class { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_CLASS_H_ +#endif // ART_RUNTIME_MIRROR_CLASS_H_ diff --git a/runtime/mirror/class_loader.h b/runtime/mirror/class_loader.h index 0d635f1d21..415cb67c6c 100644 --- a/runtime/mirror/class_loader.h +++ b/runtime/mirror/class_loader.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_CLASS_LOADER_H_ -#define ART_SRC_CLASS_LOADER_H_ +#ifndef ART_RUNTIME_MIRROR_CLASS_LOADER_H_ +#define ART_RUNTIME_MIRROR_CLASS_LOADER_H_ #include @@ -43,4 +43,4 @@ class MANAGED ClassLoader : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_CLASS_LOADER_H_ +#endif // ART_RUNTIME_MIRROR_CLASS_LOADER_H_ diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h index 3b17c428a5..369dc49ed0 100644 --- a/runtime/mirror/dex_cache-inl.h +++ b/runtime/mirror/dex_cache-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_DEX_CACHE_INL_H_ -#define ART_SRC_MIRROR_DEX_CACHE_INL_H_ +#ifndef ART_RUNTIME_MIRROR_DEX_CACHE_INL_H_ +#define ART_RUNTIME_MIRROR_DEX_CACHE_INL_H_ #include "dex_cache.h" @@ -37,4 +37,4 @@ inline AbstractMethod* DexCache::GetResolvedMethod(uint32_t method_idx) const } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_DEX_CACHE_INL_H_ +#endif // ART_RUNTIME_MIRROR_DEX_CACHE_INL_H_ diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index 307588b581..fd3f5f44b8 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_DEX_CACHE_H_ -#define ART_SRC_MIRROR_DEX_CACHE_H_ +#ifndef ART_RUNTIME_MIRROR_DEX_CACHE_H_ +#define ART_RUNTIME_MIRROR_DEX_CACHE_H_ #include "abstract_method.h" #include "class.h" @@ -179,4 +179,4 @@ class MANAGED DexCache : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_DEX_CACHE_H_ +#endif // ART_RUNTIME_MIRROR_DEX_CACHE_H_ diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/field-inl.h index be5dcab03d..3e3d6db4a6 100644 --- a/runtime/mirror/field-inl.h +++ b/runtime/mirror/field-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_FIELD_INL_H_ -#define ART_SRC_MIRROR_FIELD_INL_H_ +#ifndef ART_RUNTIME_MIRROR_FIELD_INL_H_ +#define ART_RUNTIME_MIRROR_FIELD_INL_H_ #include "field.h" @@ -218,4 +218,4 @@ inline void Field::SetObject(Object* object, const Object* l) const { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_FIELD_INL_H_ +#endif // ART_RUNTIME_MIRROR_FIELD_INL_H_ diff --git a/runtime/mirror/field.h b/runtime/mirror/field.h index 4e7abe8550..6e508a362f 100644 --- a/runtime/mirror/field.h +++ b/runtime/mirror/field.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_FIELD_H_ -#define ART_SRC_MIRROR_FIELD_H_ +#ifndef ART_RUNTIME_MIRROR_FIELD_H_ +#define ART_RUNTIME_MIRROR_FIELD_H_ #include "class.h" #include "modifiers.h" @@ -165,4 +165,4 @@ class MANAGED FieldClass : public Class { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_FIELD_H_ +#endif // ART_RUNTIME_MIRROR_FIELD_H_ diff --git a/runtime/mirror/iftable-inl.h b/runtime/mirror/iftable-inl.h index 72803b8002..9d5fa7475a 100644 --- a/runtime/mirror/iftable-inl.h +++ b/runtime/mirror/iftable-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_IFTABLE_INL_H_ -#define ART_SRC_MIRROR_IFTABLE_INL_H_ +#ifndef ART_RUNTIME_MIRROR_IFTABLE_INL_H_ +#define ART_RUNTIME_MIRROR_IFTABLE_INL_H_ #include "iftable.h" @@ -32,4 +32,4 @@ inline void IfTable::SetInterface(int32_t i, Class* interface) { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_IFTABLE_INL_H_ +#endif // ART_RUNTIME_MIRROR_IFTABLE_INL_H_ diff --git a/runtime/mirror/iftable.h b/runtime/mirror/iftable.h index ffb2e51582..aea8fddafe 100644 --- a/runtime/mirror/iftable.h +++ b/runtime/mirror/iftable.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_IFTABLE_H_ -#define ART_SRC_MIRROR_IFTABLE_H_ +#ifndef ART_RUNTIME_MIRROR_IFTABLE_H_ +#define ART_RUNTIME_MIRROR_IFTABLE_H_ #include "object_array.h" @@ -76,4 +76,4 @@ class MANAGED IfTable : public ObjectArray { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_IFTABLE_H_ +#endif // ART_RUNTIME_MIRROR_IFTABLE_H_ diff --git a/runtime/mirror/object-inl.h b/runtime/mirror/object-inl.h index 1a91dd3e6f..5818a800bf 100644 --- a/runtime/mirror/object-inl.h +++ b/runtime/mirror/object-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_OBJECT_INL_H_ -#define ART_SRC_MIRROR_OBJECT_INL_H_ +#ifndef ART_RUNTIME_MIRROR_OBJECT_INL_H_ +#define ART_RUNTIME_MIRROR_OBJECT_INL_H_ #include "object.h" @@ -272,4 +272,4 @@ inline void Object::VerifyObject(const Object* obj) { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_OBJECT_INL_H_ +#endif // ART_RUNTIME_MIRROR_OBJECT_INL_H_ diff --git a/runtime/mirror/object.h b/runtime/mirror/object.h index 71b628db52..a40c906eb0 100644 --- a/runtime/mirror/object.h +++ b/runtime/mirror/object.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_OBJECT_H_ -#define ART_SRC_MIRROR_OBJECT_H_ +#ifndef ART_RUNTIME_MIRROR_OBJECT_H_ +#define ART_RUNTIME_MIRROR_OBJECT_H_ #include "base/casts.h" #include "base/logging.h" @@ -260,4 +260,4 @@ class MANAGED Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_OBJECT_H_ +#endif // ART_RUNTIME_MIRROR_OBJECT_H_ diff --git a/runtime/mirror/object_array-inl.h b/runtime/mirror/object_array-inl.h index b130dac514..8675c31b37 100644 --- a/runtime/mirror/object_array-inl.h +++ b/runtime/mirror/object_array-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_OBJECT_ARRAY_INL_H_ -#define ART_SRC_MIRROR_OBJECT_ARRAY_INL_H_ +#ifndef ART_RUNTIME_MIRROR_OBJECT_ARRAY_INL_H_ +#define ART_RUNTIME_MIRROR_OBJECT_ARRAY_INL_H_ #include "object_array.h" @@ -142,4 +142,4 @@ inline ObjectArray* ObjectArray::CopyOf(Thread* self, int32_t new_length) } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_OBJET_ARRAY_INL_H_ +#endif // ART_RUNTIME_MIRROR_OBJECT_ARRAY_INL_H_ diff --git a/runtime/mirror/object_array.h b/runtime/mirror/object_array.h index 08a8d62567..09ff5193ae 100644 --- a/runtime/mirror/object_array.h +++ b/runtime/mirror/object_array.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_OBJECT_ARRAY_H_ -#define ART_SRC_MIRROR_OBJECT_ARRAY_H_ +#ifndef ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ +#define ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ #include "array.h" @@ -61,4 +61,4 @@ class MANAGED ObjectArray : public Array { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_OBJECT_ARRAY_H_ +#endif // ART_RUNTIME_MIRROR_OBJECT_ARRAY_H_ diff --git a/runtime/mirror/proxy.h b/runtime/mirror/proxy.h index cac028a731..7c5bc39429 100644 --- a/runtime/mirror/proxy.h +++ b/runtime/mirror/proxy.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_PROXY_H_ -#define ART_SRC_MIRROR_PROXY_H_ +#ifndef ART_RUNTIME_MIRROR_PROXY_H_ +#define ART_RUNTIME_MIRROR_PROXY_H_ #include "mirror/object.h" @@ -52,4 +52,4 @@ class MANAGED Proxy : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_PROXY_H_ +#endif // ART_RUNTIME_MIRROR_PROXY_H_ diff --git a/runtime/mirror/stack_trace_element.h b/runtime/mirror/stack_trace_element.h index d53c8602dc..a9751f9988 100644 --- a/runtime/mirror/stack_trace_element.h +++ b/runtime/mirror/stack_trace_element.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_STACK_TRACE_ELEMENT_H_ -#define ART_SRC_MIRROR_STACK_TRACE_ELEMENT_H_ +#ifndef ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ +#define ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ #include "object.h" @@ -80,4 +80,4 @@ class MANAGED StackTraceElement : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_STACK_TRACE_ELEMENT_H_ +#endif // ART_RUNTIME_MIRROR_STACK_TRACE_ELEMENT_H_ diff --git a/runtime/mirror/string.h b/runtime/mirror/string.h index 8109dcb9a9..bf545eaefb 100644 --- a/runtime/mirror/string.h +++ b/runtime/mirror/string.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_STRING_H_ -#define ART_SRC_MIRROR_STRING_H_ +#ifndef ART_RUNTIME_MIRROR_STRING_H_ +#define ART_RUNTIME_MIRROR_STRING_H_ #include "class.h" #include "gtest/gtest.h" @@ -164,4 +164,4 @@ class MANAGED StringClass : public Class { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_STRING_H_ +#endif // ART_RUNTIME_MIRROR_STRING_H_ diff --git a/runtime/mirror/throwable.h b/runtime/mirror/throwable.h index aafcc07d86..909228e4d9 100644 --- a/runtime/mirror/throwable.h +++ b/runtime/mirror/throwable.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MIRROR_THROWABLE_H_ -#define ART_SRC_MIRROR_THROWABLE_H_ +#ifndef ART_RUNTIME_MIRROR_THROWABLE_H_ +#define ART_RUNTIME_MIRROR_THROWABLE_H_ #include "object.h" #include "string.h" @@ -72,4 +72,4 @@ class MANAGED Throwable : public Object { } // namespace mirror } // namespace art -#endif // ART_SRC_MIRROR_THROWABLE_H_ +#endif // ART_RUNTIME_MIRROR_THROWABLE_H_ diff --git a/runtime/modifiers.h b/runtime/modifiers.h index 85bc06da65..9b61ee0cf0 100644 --- a/runtime/modifiers.h +++ b/runtime/modifiers.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MODIFIERS_H_ -#define ART_SRC_MODIFIERS_H_ +#ifndef ART_RUNTIME_MODIFIERS_H_ +#define ART_RUNTIME_MODIFIERS_H_ #include @@ -63,5 +63,5 @@ static const uint32_t kAccReferenceFlagsMask = (kAccClassIsReference | kAccClassIsFinalizerReference | kAccClassIsPhantomReference); -#endif // ART_SRC_MODIFIERS_H_ +#endif // ART_RUNTIME_MODIFIERS_H_ diff --git a/runtime/monitor.h b/runtime/monitor.h index 9194c08ab4..9206131a5b 100644 --- a/runtime/monitor.h +++ b/runtime/monitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_MONITOR_H_ -#define ART_SRC_MONITOR_H_ +#ifndef ART_RUNTIME_MONITOR_H_ +#define ART_RUNTIME_MONITOR_H_ #include #include @@ -208,4 +208,4 @@ class MonitorInfo { } // namespace art -#endif // ART_SRC_MONITOR_H_ +#endif // ART_RUNTIME_MONITOR_H_ diff --git a/runtime/nth_caller_visitor.h b/runtime/nth_caller_visitor.h index c32a46aa02..e3593d805d 100644 --- a/runtime/nth_caller_visitor.h +++ b/runtime/nth_caller_visitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_NTH_CALLER_VISITOR_H_ -#define ART_SRC_NTH_CALLER_VISITOR_H_ +#ifndef ART_RUNTIME_NTH_CALLER_VISITOR_H_ +#define ART_RUNTIME_NTH_CALLER_VISITOR_H_ #include "mirror/abstract_method.h" #include "locks.h" @@ -58,4 +58,4 @@ struct NthCallerVisitor : public StackVisitor { } // namespace art -#endif // ART_SRC_NTH_CALLER_VISITOR_H_ +#endif // ART_RUNTIME_NTH_CALLER_VISITOR_H_ diff --git a/runtime/oat.h b/runtime/oat.h index c67a1a6630..fb28962762 100644 --- a/runtime/oat.h +++ b/runtime/oat.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_H_ -#define ART_SRC_OAT_H_ +#ifndef ART_RUNTIME_OAT_H_ +#define ART_RUNTIME_OAT_H_ #include @@ -113,4 +113,4 @@ class PACKED(4) OatMethodOffsets { } // namespace art -#endif // ART_SRC_OAT_H_ +#endif // ART_RUNTIME_OAT_H_ diff --git a/runtime/oat/runtime/argument_visitor.h b/runtime/oat/runtime/argument_visitor.h index 4ab05b9e4d..d92ff19d13 100644 --- a/runtime/oat/runtime/argument_visitor.h +++ b/runtime/oat/runtime/argument_visitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_ARGUMENT_VISITOR_H_ -#define ART_SRC_OAT_RUNTIME_ARGUMENT_VISITOR_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_ARGUMENT_VISITOR_H_ +#define ART_RUNTIME_OAT_RUNTIME_ARGUMENT_VISITOR_H_ #include "object_utils.h" @@ -246,4 +246,4 @@ class QuickArgumentVisitor { } -#endif // ART_SRC_OAT_RUNTIME_ARGUMENT_VISITOR_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_ARGUMENT_VISITOR_H_ diff --git a/runtime/oat/runtime/arm/context_arm.h b/runtime/oat/runtime/arm/context_arm.h index ec1d4cb7f6..0be85e3577 100644 --- a/runtime/oat/runtime/arm/context_arm.h +++ b/runtime/oat/runtime/arm/context_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ -#define ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ +#define ART_RUNTIME_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ #include "locks.h" #include "constants_arm.h" @@ -64,4 +64,4 @@ class ArmContext : public Context { } // namespace arm } // namespace art -#endif // ART_SRC_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_ARM_CONTEXT_ARM_H_ diff --git a/runtime/oat/runtime/callee_save_frame.h b/runtime/oat/runtime/callee_save_frame.h index dd2f3fa69e..59f46acbac 100644 --- a/runtime/oat/runtime/callee_save_frame.h +++ b/runtime/oat/runtime/callee_save_frame.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ -#define ART_SRC_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ +#define ART_RUNTIME_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ #include "base/mutex.h" #include "thread-inl.h" @@ -38,4 +38,4 @@ static void FinishCalleeSaveFrameSetup(Thread* self, mirror::AbstractMethod** sp } // namespace art -#endif // ART_SRC_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_CALLEE_SAVE_FRAME_H_ diff --git a/runtime/oat/runtime/context.h b/runtime/oat/runtime/context.h index 895abf99ed..ac43e9a7e9 100644 --- a/runtime/oat/runtime/context.h +++ b/runtime/oat/runtime/context.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_CONTEXT_H_ -#define ART_SRC_OAT_RUNTIME_CONTEXT_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_CONTEXT_H_ +#define ART_RUNTIME_OAT_RUNTIME_CONTEXT_H_ #include #include @@ -67,4 +67,4 @@ class Context { } // namespace art -#endif // ART_SRC_OAT_RUNTIME_CONTEXT_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_CONTEXT_H_ diff --git a/runtime/oat/runtime/mips/context_mips.h b/runtime/oat/runtime/mips/context_mips.h index fc8ef9655f..f27124c79b 100644 --- a/runtime/oat/runtime/mips/context_mips.h +++ b/runtime/oat/runtime/mips/context_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ -#define ART_SRC_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ +#define ART_RUNTIME_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ #include "constants_mips.h" #include "oat/runtime/context.h" @@ -61,4 +61,4 @@ class MipsContext : public Context { } // namespace mips } // namespace art -#endif // ART_SRC_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_MIPS_CONTEXT_MIPS_H_ diff --git a/runtime/oat/runtime/oat_support_entrypoints.h b/runtime/oat/runtime/oat_support_entrypoints.h index c1a2587c45..546ee01c6f 100644 --- a/runtime/oat/runtime/oat_support_entrypoints.h +++ b/runtime/oat/runtime/oat_support_entrypoints.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ -#define ART_SRC_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ +#define ART_RUNTIME_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ #include "dex_file-inl.h" #include "runtime.h" @@ -174,4 +174,4 @@ void ChangeDebuggerEntryPoint(EntryPoints* points, bool enabled); } // namespace art -#endif // ART_SRC_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_OAT_SUPPORT_ENTRYPOINTS_H_ diff --git a/runtime/oat/runtime/x86/context_x86.h b/runtime/oat/runtime/x86/context_x86.h index 7928fd860f..4ecfc51b04 100644 --- a/runtime/oat/runtime/x86/context_x86.h +++ b/runtime/oat/runtime/x86/context_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_RUNTIME_X86_CONTEXT_X86_H_ -#define ART_SRC_OAT_RUNTIME_X86_CONTEXT_X86_H_ +#ifndef ART_RUNTIME_OAT_RUNTIME_X86_CONTEXT_X86_H_ +#define ART_RUNTIME_OAT_RUNTIME_X86_CONTEXT_X86_H_ #include "constants_x86.h" #include "oat/runtime/context.h" @@ -64,4 +64,4 @@ class X86Context : public Context { } // namespace x86 } // namespace art -#endif // ART_SRC_OAT_RUNTIME_X86_CONTEXT_X86_H_ +#endif // ART_RUNTIME_OAT_RUNTIME_X86_CONTEXT_X86_H_ diff --git a/runtime/oat/utils/arm/assembler_arm.h b/runtime/oat/utils/arm/assembler_arm.h index 06e0a55f63..b8c79d21b9 100644 --- a/runtime/oat/utils/arm/assembler_arm.h +++ b/runtime/oat/utils/arm/assembler_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ -#define ART_SRC_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ +#ifndef ART_RUNTIME_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ +#define ART_RUNTIME_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ #include @@ -656,4 +656,4 @@ class ArmExceptionSlowPath : public SlowPath { } // namespace arm } // namespace art -#endif // ART_SRC_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ +#endif // ART_RUNTIME_OAT_UTILS_ARM_ASSEMBLER_ARM_H_ diff --git a/runtime/oat/utils/arm/managed_register_arm.h b/runtime/oat/utils/arm/managed_register_arm.h index b069f6dedd..01596bb6b1 100644 --- a/runtime/oat/utils/arm/managed_register_arm.h +++ b/runtime/oat/utils/arm/managed_register_arm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ -#define ART_SRC_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ +#ifndef ART_RUNTIME_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ +#define ART_RUNTIME_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ #include "base/logging.h" #include "constants_arm.h" @@ -271,4 +271,4 @@ inline arm::ArmManagedRegister ManagedRegister::AsArm() const { } // namespace art -#endif // ART_SRC_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ +#endif // ART_RUNTIME_OAT_UTILS_ARM_MANAGED_REGISTER_ARM_H_ diff --git a/runtime/oat/utils/assembler.h b/runtime/oat/utils/assembler.h index cbf145b949..05e2732c5f 100644 --- a/runtime/oat/utils/assembler.h +++ b/runtime/oat/utils/assembler.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_ASSEMBLER_H_ -#define ART_SRC_OAT_UTILS_ASSEMBLER_H_ +#ifndef ART_RUNTIME_OAT_UTILS_ASSEMBLER_H_ +#define ART_RUNTIME_OAT_UTILS_ASSEMBLER_H_ #include @@ -456,4 +456,4 @@ class Assembler { } // namespace art -#endif // ART_SRC_OAT_UTILS_ASSEMBLER_H_ +#endif // ART_RUNTIME_OAT_UTILS_ASSEMBLER_H_ diff --git a/runtime/oat/utils/managed_register.h b/runtime/oat/utils/managed_register.h index a3d5795665..4dd2acd8fe 100644 --- a/runtime/oat/utils/managed_register.h +++ b/runtime/oat/utils/managed_register.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_MANAGED_REGISTER_H_ -#define ART_SRC_OAT_UTILS_MANAGED_REGISTER_H_ +#ifndef ART_RUNTIME_OAT_UTILS_MANAGED_REGISTER_H_ +#define ART_RUNTIME_OAT_UTILS_MANAGED_REGISTER_H_ namespace art { @@ -69,4 +69,4 @@ class ManagedRegister { } // namespace art -#endif // ART_SRC_OAT_UTILS_MANAGED_REGISTER_H_ +#endif // ART_RUNTIME_OAT_UTILS_MANAGED_REGISTER_H_ diff --git a/runtime/oat/utils/mips/assembler_mips.h b/runtime/oat/utils/mips/assembler_mips.h index 02759e4efb..eeb4a57db2 100644 --- a/runtime/oat/utils/mips/assembler_mips.h +++ b/runtime/oat/utils/mips/assembler_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ -#define ART_SRC_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ +#ifndef ART_RUNTIME_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ +#define ART_RUNTIME_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ #include @@ -510,4 +510,4 @@ class MipsExceptionSlowPath : public SlowPath { } // namespace mips } // namespace art -#endif // ART_SRC_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ +#endif // ART_RUNTIME_OAT_UTILS_MIPS_ASSEMBLER_MIPS_H_ diff --git a/runtime/oat/utils/mips/managed_register_mips.h b/runtime/oat/utils/mips/managed_register_mips.h index aaaabfcc0c..b335ff9649 100644 --- a/runtime/oat/utils/mips/managed_register_mips.h +++ b/runtime/oat/utils/mips/managed_register_mips.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ -#define ART_SRC_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ +#ifndef ART_RUNTIME_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ +#define ART_RUNTIME_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ #include "constants_mips.h" #include "oat/utils/managed_register.h" @@ -225,4 +225,4 @@ inline mips::MipsManagedRegister ManagedRegister::AsMips() const { } // namespace art -#endif // ART_SRC_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ +#endif // ART_RUNTIME_OAT_UTILS_MIPS_MANAGED_REGISTER_MIPS_H_ diff --git a/runtime/oat/utils/x86/assembler_x86.h b/runtime/oat/utils/x86/assembler_x86.h index dddb9b1885..390f7aa898 100644 --- a/runtime/oat/utils/x86/assembler_x86.h +++ b/runtime/oat/utils/x86/assembler_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_X86_ASSEMBLER_X86_H_ -#define ART_SRC_OAT_UTILS_X86_ASSEMBLER_X86_H_ +#ifndef ART_RUNTIME_OAT_UTILS_X86_ASSEMBLER_X86_H_ +#define ART_RUNTIME_OAT_UTILS_X86_ASSEMBLER_X86_H_ #include #include "base/macros.h" @@ -652,4 +652,4 @@ class X86ExceptionSlowPath : public SlowPath { } // namespace x86 } // namespace art -#endif // ART_SRC_OAT_UTILS_X86_ASSEMBLER_X86_H_ +#endif // ART_RUNTIME_OAT_UTILS_X86_ASSEMBLER_X86_H_ diff --git a/runtime/oat/utils/x86/managed_register_x86.h b/runtime/oat/utils/x86/managed_register_x86.h index 4481456315..b564a8396f 100644 --- a/runtime/oat/utils/x86/managed_register_x86.h +++ b/runtime/oat/utils/x86/managed_register_x86.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ -#define ART_SRC_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ +#ifndef ART_RUNTIME_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ +#define ART_RUNTIME_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ #include "constants_x86.h" #include "oat/utils/managed_register.h" @@ -215,4 +215,4 @@ inline x86::X86ManagedRegister ManagedRegister::AsX86() const { } // namespace art -#endif // ART_SRC_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ +#endif // ART_RUNTIME_OAT_UTILS_X86_MANAGED_REGISTER_X86_H_ diff --git a/runtime/oat_file.h b/runtime/oat_file.h index ecc8d0c965..fff6c8a1a6 100644 --- a/runtime/oat_file.h +++ b/runtime/oat_file.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OAT_FILE_H_ -#define ART_SRC_OAT_FILE_H_ +#ifndef ART_RUNTIME_OAT_FILE_H_ +#define ART_RUNTIME_OAT_FILE_H_ #include #include @@ -265,4 +265,4 @@ class OatFile { } // namespace art -#endif // ART_SRC_OAT_WRITER_H_ +#endif // ART_RUNTIME_OAT_FILE_H_ diff --git a/runtime/object_utils.h b/runtime/object_utils.h index 4af5d4c30b..fa7763e11f 100644 --- a/runtime/object_utils.h +++ b/runtime/object_utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OBJECT_UTILS_H_ -#define ART_SRC_OBJECT_UTILS_H_ +#ifndef ART_RUNTIME_OBJECT_UTILS_H_ +#define ART_RUNTIME_OBJECT_UTILS_H_ #include "class_linker-inl.h" #include "dex_file.h" @@ -684,4 +684,4 @@ class MethodHelper { } // namespace art -#endif // ART_SRC_OBJECT_UTILS_H_ +#endif // ART_RUNTIME_OBJECT_UTILS_H_ diff --git a/runtime/offsets.h b/runtime/offsets.h index f37dbd4413..94ae805e4a 100644 --- a/runtime/offsets.h +++ b/runtime/offsets.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OFFSETS_H_ -#define ART_SRC_OFFSETS_H_ +#ifndef ART_RUNTIME_OFFSETS_H_ +#define ART_RUNTIME_OFFSETS_H_ #include // NOLINT #include "globals.h" @@ -59,4 +59,4 @@ class MemberOffset : public Offset { } // namespace art -#endif // ART_SRC_OFFSETS_H_ +#endif // ART_RUNTIME_OFFSETS_H_ diff --git a/runtime/os.h b/runtime/os.h index 3428b6afb3..6767566673 100644 --- a/runtime/os.h +++ b/runtime/os.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OS_H_ -#define ART_SRC_OS_H_ +#ifndef ART_RUNTIME_OS_H_ +#define ART_RUNTIME_OS_H_ namespace unix_file { class FdFile; @@ -41,4 +41,4 @@ class OS { } // namespace art -#endif // ART_SRC_OS_H_ +#endif // ART_RUNTIME_OS_H_ diff --git a/runtime/output_stream.h b/runtime/output_stream.h index b03092ddf7..d2a77d898e 100644 --- a/runtime/output_stream.h +++ b/runtime/output_stream.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_OUTPUT_STREAM_H_ -#define ART_SRC_OUTPUT_STREAM_H_ +#ifndef ART_RUNTIME_OUTPUT_STREAM_H_ +#define ART_RUNTIME_OUTPUT_STREAM_H_ #include @@ -53,4 +53,4 @@ class OutputStream { } // namespace art -#endif // ART_SRC_OUTPUT_STREAM_H_ +#endif // ART_RUNTIME_OUTPUT_STREAM_H_ diff --git a/runtime/primitive.h b/runtime/primitive.h index eaa04cd054..5e07311073 100644 --- a/runtime/primitive.h +++ b/runtime/primitive.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_PRIMITIVE_H_ -#define ART_SRC_PRIMITIVE_H_ +#ifndef ART_RUNTIME_PRIMITIVE_H_ +#define ART_RUNTIME_PRIMITIVE_H_ #include @@ -123,4 +123,4 @@ std::ostream& operator<<(std::ostream& os, const Primitive::Type& state); } // namespace art -#endif // ART_SRC_PRIMITIVE_H_ +#endif // ART_RUNTIME_PRIMITIVE_H_ diff --git a/runtime/reference_table.h b/runtime/reference_table.h index 5abb5c7b46..4b6b50e183 100644 --- a/runtime/reference_table.h +++ b/runtime/reference_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_REFERENCE_TABLE_H_ -#define ART_SRC_REFERENCE_TABLE_H_ +#ifndef ART_RUNTIME_REFERENCE_TABLE_H_ +#define ART_RUNTIME_REFERENCE_TABLE_H_ #include #include @@ -62,4 +62,4 @@ class ReferenceTable { } // namespace art -#endif // ART_SRC_REFERENCE_TABLE_H_ +#endif // ART_RUNTIME_REFERENCE_TABLE_H_ diff --git a/runtime/reflection.h b/runtime/reflection.h index e9f4e0893e..56ab4712db 100644 --- a/runtime/reflection.h +++ b/runtime/reflection.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_REFLECTION_H_ -#define ART_SRC_REFLECTION_H_ +#ifndef ART_RUNTIME_REFLECTION_H_ +#define ART_RUNTIME_REFLECTION_H_ #include "jni.h" #include "primitive.h" @@ -56,4 +56,4 @@ bool VerifyObjectInClass(mirror::Object* o, mirror::Class* c) } // namespace art -#endif // ART_SRC_REFLECTION_H_ +#endif // ART_RUNTIME_REFLECTION_H_ diff --git a/runtime/root_visitor.h b/runtime/root_visitor.h index d53acd3621..3aa9b4bac0 100644 --- a/runtime/root_visitor.h +++ b/runtime/root_visitor.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ROOT_VISITOR_H_ -#define ART_SRC_ROOT_VISITOR_H_ +#ifndef ART_RUNTIME_ROOT_VISITOR_H_ +#define ART_RUNTIME_ROOT_VISITOR_H_ namespace art { namespace mirror { @@ -30,4 +30,4 @@ typedef bool (IsMarkedTester)(const mirror::Object* object, void* arg); } // namespace art -#endif // ART_SRC_ROOT_VISITOR_H_ +#endif // ART_RUNTIME_ROOT_VISITOR_H_ diff --git a/runtime/runtime.h b/runtime/runtime.h index 97b7c2518b..58f985fae7 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_RUNTIME_H_ -#define ART_SRC_RUNTIME_H_ +#ifndef ART_RUNTIME_RUNTIME_H_ +#define ART_RUNTIME_RUNTIME_H_ #include #include @@ -476,4 +476,4 @@ class Runtime { } // namespace art -#endif // ART_SRC_RUNTIME_H_ +#endif // ART_RUNTIME_RUNTIME_H_ diff --git a/runtime/runtime_stats.h b/runtime/runtime_stats.h index 55e57ecc1d..05d3fbb60f 100644 --- a/runtime/runtime_stats.h +++ b/runtime/runtime_stats.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_RUNTIME_STATS_H_ -#define ART_SRC_RUNTIME_STATS_H_ +#ifndef ART_RUNTIME_RUNTIME_STATS_H_ +#define ART_RUNTIME_RUNTIME_STATS_H_ #include @@ -111,4 +111,4 @@ struct PACKED(4) RuntimeStats { } // namespace art -#endif // ART_SRC_HEAP_H_ +#endif // ART_RUNTIME_RUNTIME_STATS_H_ diff --git a/runtime/runtime_support.h b/runtime/runtime_support.h index 0cb82a5466..051981f99e 100644 --- a/runtime/runtime_support.h +++ b/runtime/runtime_support.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_RUNTIME_SUPPORT_H_ -#define ART_SRC_RUNTIME_SUPPORT_H_ +#ifndef ART_RUNTIME_RUNTIME_SUPPORT_H_ +#define ART_RUNTIME_RUNTIME_SUPPORT_H_ #include "class_linker.h" #include "common_throws.h" @@ -412,4 +412,4 @@ static inline void* GetJniDlsymLookupStub() { } // namespace art -#endif // ART_SRC_RUNTIME_SUPPORT_H_ +#endif // ART_RUNTIME_RUNTIME_SUPPORT_H_ diff --git a/runtime/runtime_support_llvm.h b/runtime/runtime_support_llvm.h index af99842089..566f7bcb16 100644 --- a/runtime/runtime_support_llvm.h +++ b/runtime/runtime_support_llvm.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_ -#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_ +#ifndef ART_RUNTIME_RUNTIME_SUPPORT_LLVM_H_ +#define ART_RUNTIME_RUNTIME_SUPPORT_LLVM_H_ extern "C" { @@ -27,4 +27,4 @@ void* art_portable_find_runtime_support_func(void* context, const char* name); } // extern "C" -#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_ +#endif // ART_RUNTIME_RUNTIME_SUPPORT_LLVM_H_ diff --git a/runtime/runtime_support_llvm_func_list.h b/runtime/runtime_support_llvm_func_list.h index a58b061e16..d371421a16 100644 --- a/runtime/runtime_support_llvm_func_list.h +++ b/runtime/runtime_support_llvm_func_list.h @@ -14,6 +14,9 @@ * limitations under the License. */ +#ifndef ART_RUNTIME_RUNTIME_SUPPORT_LLVM_FUNC_LIST_H_ +#define ART_RUNTIME_RUNTIME_SUPPORT_LLVM_FUNC_LIST_H_ + #define RUNTIME_SUPPORT_FUNC_LIST(V) \ V(LockObject, art_portable_lock_object_from_code) \ V(UnlockObject, art_portable_unlock_object_from_code) \ @@ -74,3 +77,6 @@ V(JniMethodEndSynchronized, art_portable_jni_method_end_synchronized) \ V(JniMethodEndWithReference, art_portable_jni_method_end_with_reference) \ V(JniMethodEndWithReferenceSynchronized, art_portable_jni_method_end_with_reference_synchronized) + +#endif // ART_RUNTIME_RUNTIME_SUPPORT_LLVM_FUNC_LIST_H_ +#undef ART_RUNTIME_RUNTIME_SUPPORT_LLVM_FUNC_LIST_H_ // the guard in this file is just for cpplint diff --git a/runtime/safe_map.h b/runtime/safe_map.h index b9a6ecf5e7..dcc172de01 100644 --- a/runtime/safe_map.h +++ b/runtime/safe_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_SAFE_MAP_H_ -#define ART_SRC_SAFE_MAP_H_ +#ifndef ART_RUNTIME_SAFE_MAP_H_ +#define ART_RUNTIME_SAFE_MAP_H_ #include @@ -102,4 +102,4 @@ bool operator!=(const SafeMap& lhs, const SafeMap @@ -59,4 +59,4 @@ class SignalSet { } // namespace art -#endif // ART_SRC_SIGNAL_SET_H_ +#endif // ART_RUNTIME_SIGNAL_SET_H_ diff --git a/runtime/sirt_ref.h b/runtime/sirt_ref.h index 12f8326347..81f0dff217 100644 --- a/runtime/sirt_ref.h +++ b/runtime/sirt_ref.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_SIRT_REF_H_ -#define ART_SRC_SIRT_REF_H_ +#ifndef ART_RUNTIME_SIRT_REF_H_ +#define ART_RUNTIME_SIRT_REF_H_ #include "base/logging.h" #include "base/macros.h" @@ -52,4 +52,4 @@ class SirtRef { } // namespace art -#endif // ART_SRC_SIRT_REF_H_ +#endif // ART_RUNTIME_SIRT_REF_H_ diff --git a/runtime/stack.h b/runtime/stack.h index fbfacb1733..0e2c4c5b86 100644 --- a/runtime/stack.h +++ b/runtime/stack.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_STACK_H_ -#define ART_SRC_STACK_H_ +#ifndef ART_RUNTIME_STACK_H_ +#define ART_RUNTIME_STACK_H_ #include "dex_file.h" #include "instrumentation.h" @@ -644,4 +644,4 @@ class VmapTable { } // namespace art -#endif // ART_SRC_STACK_H_ +#endif // ART_RUNTIME_STACK_H_ diff --git a/runtime/stack_indirect_reference_table.h b/runtime/stack_indirect_reference_table.h index dd106344de..4c9b038423 100644 --- a/runtime/stack_indirect_reference_table.h +++ b/runtime/stack_indirect_reference_table.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ -#define ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ +#ifndef ART_RUNTIME_STACK_INDIRECT_REFERENCE_TABLE_H_ +#define ART_RUNTIME_STACK_INDIRECT_REFERENCE_TABLE_H_ #include "base/logging.h" #include "base/macros.h" @@ -96,4 +96,4 @@ class StackIndirectReferenceTable { } // namespace art -#endif // ART_SRC_STACK_INDIRECT_REFERENCE_TABLE_H_ +#endif // ART_RUNTIME_STACK_INDIRECT_REFERENCE_TABLE_H_ diff --git a/runtime/strutil.h b/runtime/strutil.h index b8769183da..c8d39e2311 100644 --- a/runtime/strutil.h +++ b/runtime/strutil.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_STRUTIL_H_ -#define ART_SRC_STRUTIL_H_ +#ifndef ART_RUNTIME_STRUTIL_H_ +#define ART_RUNTIME_STRUTIL_H_ #include @@ -37,4 +37,4 @@ struct CStringEq { } // namespace art -#endif // ART_SRC_STRUTIL_H_ +#endif // ART_RUNTIME_STRUTIL_H_ diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h index 2fc5987306..c22f2cd921 100644 --- a/runtime/thread-inl.h +++ b/runtime/thread-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_INL_H_ -#define ART_SRC_THREAD_INL_H_ +#ifndef ART_RUNTIME_THREAD_INL_H_ +#define ART_RUNTIME_THREAD_INL_H_ #include "thread.h" @@ -133,4 +133,4 @@ inline void Thread::VerifyStack() { } // namespace art -#endif // ART_SRC_THREAD_INL_H_ +#endif // ART_RUNTIME_THREAD_INL_H_ diff --git a/runtime/thread.h b/runtime/thread.h index 0daf763359..64ff7c22fa 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_H_ -#define ART_SRC_THREAD_H_ +#ifndef ART_RUNTIME_THREAD_H_ +#define ART_RUNTIME_THREAD_H_ #include @@ -788,4 +788,4 @@ std::ostream& operator<<(std::ostream& os, const ThreadState& state); } // namespace art -#endif // ART_SRC_THREAD_H_ +#endif // ART_RUNTIME_THREAD_H_ diff --git a/runtime/thread_list.h b/runtime/thread_list.h index 0470cfc3b9..87abbda479 100644 --- a/runtime/thread_list.h +++ b/runtime/thread_list.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_LIST_H_ -#define ART_SRC_THREAD_LIST_H_ +#ifndef ART_RUNTIME_THREAD_LIST_H_ +#define ART_RUNTIME_THREAD_LIST_H_ #include "base/mutex.h" #include "root_visitor.h" @@ -144,4 +144,4 @@ class ThreadList { } // namespace art -#endif // ART_SRC_THREAD_LIST_H_ +#endif // ART_RUNTIME_THREAD_LIST_H_ diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h index 814e654ad7..3462d5efbb 100644 --- a/runtime/thread_pool.h +++ b/runtime/thread_pool.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_POOL_H_ -#define ART_SRC_THREAD_POOL_H_ +#ifndef ART_RUNTIME_THREAD_POOL_H_ +#define ART_RUNTIME_THREAD_POOL_H_ #include #include @@ -177,4 +177,4 @@ class WorkStealingThreadPool : public ThreadPool { } // namespace art -#endif // ART_SRC_THREAD_POOL_H_ +#endif // ART_RUNTIME_THREAD_POOL_H_ diff --git a/runtime/thread_state.h b/runtime/thread_state.h index 52f092efa0..fc4812a427 100644 --- a/runtime/thread_state.h +++ b/runtime/thread_state.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THREAD_STATE_H_ -#define ART_SRC_THREAD_STATE_H_ +#ifndef ART_RUNTIME_THREAD_STATE_H_ +#define ART_RUNTIME_THREAD_STATE_H_ namespace art { @@ -44,4 +44,4 @@ enum ThreadState { } // namespace art -#endif // ART_SRC_THREAD_STATE_H_ +#endif // ART_RUNTIME_THREAD_STATE_H_ diff --git a/runtime/throw_location.h b/runtime/throw_location.h index 8c1b9410af..b2cd4d5803 100644 --- a/runtime/throw_location.h +++ b/runtime/throw_location.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_THROW_LOCATION_H_ -#define ART_SRC_THROW_LOCATION_H_ +#ifndef ART_RUNTIME_THROW_LOCATION_H_ +#define ART_RUNTIME_THROW_LOCATION_H_ #include "base/macros.h" #include "root_visitor.h" @@ -75,4 +75,4 @@ class PACKED(4) ThrowLocation { } // namespace art -#endif // ART_SRC_THROW_LOCATION_H_ +#endif // ART_RUNTIME_THROW_LOCATION_H_ diff --git a/runtime/trace.h b/runtime/trace.h index 9432e718ff..5bd6a8d5ca 100644 --- a/runtime/trace.h +++ b/runtime/trace.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_TRACE_H_ -#define ART_SRC_TRACE_H_ +#ifndef ART_RUNTIME_TRACE_H_ +#define ART_RUNTIME_TRACE_H_ #include #include @@ -129,4 +129,4 @@ class Trace : public instrumentation::InstrumentationListener { } // namespace art -#endif // ART_SRC_TRACE_H_ +#endif // ART_RUNTIME_TRACE_H_ diff --git a/runtime/utf.h b/runtime/utf.h index 57c811f21d..4c9a1d959e 100644 --- a/runtime/utf.h +++ b/runtime/utf.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_UTF_H_ -#define ART_SRC_UTF_H_ +#ifndef ART_RUNTIME_UTF_H_ +#define ART_RUNTIME_UTF_H_ #include "base/macros.h" @@ -94,4 +94,4 @@ uint16_t GetUtf16FromUtf8(const char** utf8_data_in); } // namespace art -#endif // ART_SRC_UTF_H_ +#endif // ART_RUNTIME_UTF_H_ diff --git a/runtime/utils.h b/runtime/utils.h index e5028bae86..a08e46524b 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_UTILS_H_ -#define ART_SRC_UTILS_H_ +#ifndef ART_RUNTIME_UTILS_H_ +#define ART_RUNTIME_UTILS_H_ #include @@ -372,4 +372,4 @@ class VoidFunctor { } // namespace art -#endif // ART_SRC_UTILS_H_ +#endif // ART_RUNTIME_UTILS_H_ diff --git a/runtime/vector_output_stream.h b/runtime/vector_output_stream.h index 3546c8d577..7daa39ffa5 100644 --- a/runtime/vector_output_stream.h +++ b/runtime/vector_output_stream.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VECTOR_OUTPUT_STREAM_H_ -#define ART_SRC_VECTOR_OUTPUT_STREAM_H_ +#ifndef ART_RUNTIME_VECTOR_OUTPUT_STREAM_H_ +#define ART_RUNTIME_VECTOR_OUTPUT_STREAM_H_ #include "output_stream.h" @@ -62,4 +62,4 @@ class VectorOutputStream : public OutputStream { } // namespace art -#endif // ART_SRC_VECTOR_OUTPUT_STREAM_H_ +#endif // ART_RUNTIME_VECTOR_OUTPUT_STREAM_H_ diff --git a/runtime/verifier/dex_gc_map.h b/runtime/verifier/dex_gc_map.h index 673112b213..be7415e1d6 100644 --- a/runtime/verifier/dex_gc_map.h +++ b/runtime/verifier/dex_gc_map.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_DEX_GC_MAP_H_ -#define ART_SRC_VERIFIER_DEX_GC_MAP_H_ +#ifndef ART_RUNTIME_VERIFIER_DEX_GC_MAP_H_ +#define ART_RUNTIME_VERIFIER_DEX_GC_MAP_H_ #include @@ -119,4 +119,4 @@ class DexPcToReferenceMap { } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_DEX_GC_MAP_H_ +#endif // ART_RUNTIME_VERIFIER_DEX_GC_MAP_H_ diff --git a/runtime/verifier/instruction_flags.h b/runtime/verifier/instruction_flags.h index 9dc3ea7a7c..df89beecfb 100644 --- a/runtime/verifier/instruction_flags.h +++ b/runtime/verifier/instruction_flags.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_METHOD_INSTRUCTION_FLAGS_H_ -#define ART_SRC_VERIFIER_METHOD_INSTRUCTION_FLAGS_H_ +#ifndef ART_RUNTIME_VERIFIER_INSTRUCTION_FLAGS_H_ +#define ART_RUNTIME_VERIFIER_INSTRUCTION_FLAGS_H_ #include "base/logging.h" @@ -113,4 +113,4 @@ class InstructionFlags { } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_METHOD_INSTRUCTION_FLAGS_H_ +#endif // ART_RUNTIME_VERIFIER_INSTRUCTION_FLAGS_H_ diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index ac0de9e1f7..57d630de5a 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_METHOD_VERIFIER_H_ -#define ART_SRC_VERIFIER_METHOD_VERIFIER_H_ +#ifndef ART_RUNTIME_VERIFIER_METHOD_VERIFIER_H_ +#define ART_RUNTIME_VERIFIER_METHOD_VERIFIER_H_ #include #include @@ -723,4 +723,4 @@ std::ostream& operator<<(std::ostream& os, const MethodVerifier::FailureKind& rh } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_METHOD_VERIFIER_H_ +#endif // ART_RUNTIME_VERIFIER_METHOD_VERIFIER_H_ diff --git a/runtime/verifier/reg_type.h b/runtime/verifier/reg_type.h index 9ac0ecac8a..1553f1e554 100644 --- a/runtime/verifier/reg_type.h +++ b/runtime/verifier/reg_type.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REG_TYPE_H_ -#define ART_SRC_VERIFIER_REG_TYPE_H_ +#ifndef ART_RUNTIME_VERIFIER_REG_TYPE_H_ +#define ART_RUNTIME_VERIFIER_REG_TYPE_H_ #include "base/macros.h" #include "globals.h" @@ -922,4 +922,4 @@ std::ostream& operator<<(std::ostream& os, const RegType& rhs) } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REG_TYPE_H_ +#endif // ART_RUNTIME_VERIFIER_REG_TYPE_H_ diff --git a/runtime/verifier/reg_type_cache-inl.h b/runtime/verifier/reg_type_cache-inl.h index 42474d1849..295e27198d 100644 --- a/runtime/verifier/reg_type_cache-inl.h +++ b/runtime/verifier/reg_type_cache-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REG_TYPE_CACHE_INL_H_ -#define ART_SRC_VERIFIER_REG_TYPE_CACHE_INL_H_ +#ifndef ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_INL_H_ +#define ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_INL_H_ #include "reg_type.h" #include "reg_type_cache.h" @@ -43,4 +43,4 @@ inline const art::verifier::RegType& RegTypeCache::GetFromId(uint16_t id) const } } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REG_TYPE_CACHE_INL_H_ +#endif // ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_INL_H_ diff --git a/runtime/verifier/reg_type_cache.h b/runtime/verifier/reg_type_cache.h index d70123c2de..814dff79f6 100644 --- a/runtime/verifier/reg_type_cache.h +++ b/runtime/verifier/reg_type_cache.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REG_TYPE_CACHE_H_ -#define ART_SRC_VERIFIER_REG_TYPE_CACHE_H_ +#ifndef ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_H_ +#define ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_H_ #include "base/casts.h" #include "base/macros.h" @@ -163,4 +163,4 @@ class RegTypeCache { } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REG_TYPE_CACHE_H_ +#endif // ART_RUNTIME_VERIFIER_REG_TYPE_CACHE_H_ diff --git a/runtime/verifier/register_line-inl.h b/runtime/verifier/register_line-inl.h index 157e136cc1..b3a28470db 100644 --- a/runtime/verifier/register_line-inl.h +++ b/runtime/verifier/register_line-inl.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REGISTER_LINE_INL_H_ -#define ART_SRC_VERIFIER_REGISTER_LINE_INL_H_ +#ifndef ART_RUNTIME_VERIFIER_REGISTER_LINE_INL_H_ +#define ART_RUNTIME_VERIFIER_REGISTER_LINE_INL_H_ #include "register_line.h" #include "method_verifier.h" @@ -32,4 +32,4 @@ inline const RegType& RegisterLine::GetRegisterType(uint32_t vsrc) const { } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REGISTER_LINE_INL_H_ +#endif // ART_RUNTIME_VERIFIER_REGISTER_LINE_INL_H_ diff --git a/runtime/verifier/register_line.h b/runtime/verifier/register_line.h index 5f17049e8e..cde7b9b0be 100644 --- a/runtime/verifier/register_line.h +++ b/runtime/verifier/register_line.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_VERIFIER_REGISTER_LINE_H_ -#define ART_SRC_VERIFIER_REGISTER_LINE_H_ +#ifndef ART_RUNTIME_VERIFIER_REGISTER_LINE_H_ +#define ART_RUNTIME_VERIFIER_REGISTER_LINE_H_ #include #include @@ -355,4 +355,4 @@ std::ostream& operator<<(std::ostream& os, const RegisterLine& rhs); } // namespace verifier } // namespace art -#endif // ART_SRC_VERIFIER_REGISTER_LINE_H_ +#endif // ART_RUNTIME_VERIFIER_REGISTER_LINE_H_ diff --git a/runtime/well_known_classes.h b/runtime/well_known_classes.h index 8170520d45..a8069bc9cb 100644 --- a/runtime/well_known_classes.h +++ b/runtime/well_known_classes.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_WELL_KNOWN_CLASSES_H_ -#define ART_SRC_WELL_KNOWN_CLASSES_H_ +#ifndef ART_RUNTIME_WELL_KNOWN_CLASSES_H_ +#define ART_RUNTIME_WELL_KNOWN_CLASSES_H_ #include "base/mutex.h" #include "jni.h" @@ -104,4 +104,4 @@ struct WellKnownClasses { } // namespace art -#endif // ART_SRC_WELL_KNOWN_CLASSES_H_ +#endif // ART_RUNTIME_WELL_KNOWN_CLASSES_H_ diff --git a/runtime/zip_archive.h b/runtime/zip_archive.h index ef3148696e..d648517aae 100644 --- a/runtime/zip_archive.h +++ b/runtime/zip_archive.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef ART_SRC_ZIP_ARCHIVE_H_ -#define ART_SRC_ZIP_ARCHIVE_H_ +#ifndef ART_RUNTIME_ZIP_ARCHIVE_H_ +#define ART_RUNTIME_ZIP_ARCHIVE_H_ #include #include @@ -129,4 +129,4 @@ class ZipArchive { } // namespace art -#endif // ART_SRC_ZIP_ARCHIVE_H_ +#endif // ART_RUNTIME_ZIP_ARCHIVE_H_ diff --git a/tools/cpplint.py b/tools/cpplint.py index ff92d70f06..30c712856e 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -726,7 +726,11 @@ class FileInfo: os.path.exists(os.path.join(root_dir, ".hg")) or os.path.exists(os.path.join(root_dir, ".svn"))): prefix = os.path.commonprefix([root_dir, project_dir]) - return fullname[len(prefix) + 1:] + # BEGIN android-changed + # return fullname[len(prefix) + 1:] + return "art/" + fullname[len(prefix) + 1:] + # END android-changed + # Don't know what to do; header guard warnings may be wrong... return fullname @@ -1032,7 +1036,6 @@ def GetHeaderGuardCPPVariable(filename): # Restores original filename in case that cpplint is invoked from Emacs's # flymake. filename = re.sub(r'_flymake\.h$', '.h', filename) - fileinfo = FileInfo(filename) return re.sub(r'[-./\s]', '_', fileinfo.RepositoryName()).upper() + '_' -- cgit v1.2.3-59-g8ed1b From df62950e7a32031b82360c407d46a37b94188fbb Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Wed, 17 Jul 2013 22:39:56 -0700 Subject: Fix cpplint whitespace/parens issues Change-Id: Ifc678d59a8bed24ffddde5a0e543620b17b0aba9 --- compiler/dex/arena_bit_vector.h | 2 +- compiler/dex/dataflow_iterator.h | 2 +- compiler/dex/frontend.cc | 4 ++-- compiler/dex/mir_dataflow.cc | 4 ++-- compiler/dex/mir_graph.cc | 11 ++++++----- compiler/dex/mir_optimization.cc | 4 ++-- compiler/dex/portable/mir_to_gbc.cc | 8 ++++---- compiler/dex/quick/arm/fp_arm.cc | 2 +- compiler/dex/quick/arm/int_arm.cc | 10 +++++----- compiler/dex/quick/arm/utility_arm.cc | 2 +- compiler/dex/quick/codegen_util.cc | 18 +++++++++--------- compiler/dex/quick/gen_common.cc | 4 ++-- compiler/dex/quick/mips/utility_mips.cc | 6 +++--- compiler/dex/quick/mir_to_lir.h | 2 +- compiler/dex/quick/ralloc_util.cc | 3 +-- compiler/dex/quick/x86/utility_x86.cc | 2 +- compiler/dex/ssa_transformation.cc | 2 +- compiler/dex/vreg_analysis.cc | 2 +- compiler/llvm/llvm_compilation_unit.cc | 2 +- compiler/oat_writer.cc | 3 +-- runtime/atomic_integer.h | 2 +- runtime/base/mutex-inl.h | 4 ++-- runtime/base/mutex.cc | 16 ++++++++-------- runtime/check_jni.cc | 2 +- runtime/class_linker_test.cc | 14 +++++++------- runtime/common_test.h | 5 ++--- runtime/debugger.cc | 4 ++-- runtime/dex_file.h | 2 +- runtime/dex_instruction.cc | 5 ++--- runtime/disassembler_arm.cc | 4 ++-- runtime/elf_file.cc | 2 +- runtime/gc/accounting/atomic_stack.h | 2 +- runtime/gc/accounting/mod_union_table.cc | 30 +++++++++++++++--------------- runtime/gc/accounting/space_bitmap.h | 4 ++-- runtime/gc/accounting/space_bitmap_test.cc | 2 +- runtime/gc/collector/mark_sweep.cc | 16 ++++++++-------- runtime/gc/heap.cc | 20 ++++++++++---------- runtime/gc/heap.h | 2 +- runtime/interpreter/interpreter.cc | 10 +++++----- runtime/oat.h | 3 +-- runtime/reflection.cc | 9 +++------ runtime/stack.cc | 6 +++--- runtime/thread.cc | 2 +- runtime/thread.h | 2 +- runtime/thread_list.cc | 2 +- runtime/trace.cc | 2 +- runtime/utils.h | 6 +++--- runtime/verifier/method_verifier.cc | 16 ++++++++-------- runtime/verifier/reg_type.cc | 4 ++-- runtime/verifier/reg_type_cache.cc | 2 +- runtime/verifier/reg_type_cache.h | 2 +- runtime/verifier/reg_type_test.cc | 2 +- test/ReferenceMap/stack_walk_refmap_jni.cc | 4 ++-- test/StackWalk/stack_walk_jni.cc | 4 ++-- tools/cpplint.py | 5 ++++- 55 files changed, 153 insertions(+), 157 deletions(-) (limited to 'tools/cpplint.py') diff --git a/compiler/dex/arena_bit_vector.h b/compiler/dex/arena_bit_vector.h index de30859bfd..2a05b77092 100644 --- a/compiler/dex/arena_bit_vector.h +++ b/compiler/dex/arena_bit_vector.h @@ -83,7 +83,7 @@ class ArenaBitVector { OatBitMapKind kind = kBitMapMisc); ~ArenaBitVector() {}; - static void* operator new( size_t size, ArenaAllocator* arena) { + static void* operator new(size_t size, ArenaAllocator* arena) { return arena->NewMem(sizeof(ArenaBitVector), true, ArenaAllocator::kAllocGrowableBitMap); } static void operator delete(void* p) {}; // Nop. diff --git a/compiler/dex/dataflow_iterator.h b/compiler/dex/dataflow_iterator.h index e427862956..847a614727 100644 --- a/compiler/dex/dataflow_iterator.h +++ b/compiler/dex/dataflow_iterator.h @@ -137,7 +137,7 @@ namespace art { AllNodesIterator(MIRGraph* mir_graph, bool is_iterative) : DataflowIterator(mir_graph, is_iterative, 0, 0, false) { all_nodes_iterator_ = - new (mir_graph->GetArena()) GrowableArray::Iterator (mir_graph->GetBlockList()); + new (mir_graph->GetArena()) GrowableArray::Iterator(mir_graph->GetBlockList()); } void Reset() { diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc index 08039147a0..ae160d607d 100644 --- a/compiler/dex/frontend.cc +++ b/compiler/dex/frontend.cc @@ -53,7 +53,7 @@ LLVMInfo::LLVMInfo() { llvm_module_ = new ::llvm::Module("art", *llvm_context_); ::llvm::StructType::create(*llvm_context_, "JavaObject"); art::llvm::makeLLVMModuleContents(llvm_module_); - intrinsic_helper_.reset( new art::llvm::IntrinsicHelper(*llvm_context_, *llvm_module_)); + intrinsic_helper_.reset(new art::llvm::IntrinsicHelper(*llvm_context_, *llvm_module_)); ir_builder_.reset(new art::llvm::IRBuilder(*llvm_context_, *llvm_module_, *intrinsic_helper_)); } @@ -276,7 +276,7 @@ CompiledMethod* CompileOneMethod(CompilerDriver& compiler, #if defined(ART_USE_PORTABLE_COMPILER) , llvm_compilation_unit #endif - ); + ); // NOLINT(whitespace/parens) } } // namespace art diff --git a/compiler/dex/mir_dataflow.cc b/compiler/dex/mir_dataflow.cc index 9632388e19..be19d5a6ae 100644 --- a/compiler/dex/mir_dataflow.cc +++ b/compiler/dex/mir_dataflow.cc @@ -1122,9 +1122,9 @@ void MIRGraph::CompilerInitializeSSAConversion() { size_t num_dalvik_reg = cu_->num_dalvik_registers; ssa_base_vregs_ = new (arena_) GrowableArray(arena_, num_dalvik_reg + GetDefCount() + 128, - kGrowableArraySSAtoDalvikMap); + kGrowableArraySSAtoDalvikMap); ssa_subscripts_ = new (arena_) GrowableArray(arena_, num_dalvik_reg + GetDefCount() + 128, - kGrowableArraySSAtoDalvikMap); + kGrowableArraySSAtoDalvikMap); /* * Initial number of SSA registers is equal to the number of Dalvik * registers. diff --git a/compiler/dex/mir_graph.cc b/compiler/dex/mir_graph.cc index 0b3fa46faa..634c576874 100644 --- a/compiler/dex/mir_graph.cc +++ b/compiler/dex/mir_graph.cc @@ -410,7 +410,7 @@ void MIRGraph::ProcessCanSwitch(BasicBlock* cur_block, MIR* insn, int cur_offset (insn->dalvikInsn.opcode == Instruction::PACKED_SWITCH) ? kPackedSwitch : kSparseSwitch; cur_block->successor_block_list.blocks = - new (arena_)GrowableArray(arena_, size, kGrowableArraySuccessorBlocks); + new (arena_) GrowableArray(arena_, size, kGrowableArraySuccessorBlocks); for (i = 0; i < size; i++) { BasicBlock *case_block = FindBlock(cur_offset + target_table[i], /* split */ true, @@ -427,8 +427,8 @@ void MIRGraph::ProcessCanSwitch(BasicBlock* cur_block, MIR* insn, int cur_offset } /* Fall-through case */ - BasicBlock* fallthrough_block = FindBlock( cur_offset + width, /* split */ false, - /* create */ true, /* immed_pred_block_p */ NULL); + BasicBlock* fallthrough_block = FindBlock(cur_offset + width, /* split */ false, + /* create */ true, /* immed_pred_block_p */ NULL); cur_block->fall_through = fallthrough_block; fallthrough_block->predecessors->Insert(cur_block); } @@ -1146,8 +1146,9 @@ BasicBlock* MIRGraph::NewMemBB(BBType block_type, int block_id) { bb->block_type = block_type; bb->id = block_id; // TUNING: better estimate of the exit block predecessors? - bb->predecessors = new (arena_) - GrowableArray(arena_, (block_type == kExitBlock) ? 2048 : 2, kGrowableArrayPredecessors); + bb->predecessors = new (arena_) GrowableArray(arena_, + (block_type == kExitBlock) ? 2048 : 2, + kGrowableArrayPredecessors); bb->successor_block_list.block_list_type = kNotUsed; block_id_map_.Put(block_id, block_id); return bb; diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc index 882b81a4a6..f83bbb23c6 100644 --- a/compiler/dex/mir_optimization.cc +++ b/compiler/dex/mir_optimization.cc @@ -228,7 +228,7 @@ bool MIRGraph::BasicBlockOpt(BasicBlock* bb) { MIR* mir_next = mir->next; Instruction::Code br_opcode = mir_next->dalvikInsn.opcode; ConditionCode ccode = kCondNv; - switch(br_opcode) { + switch (br_opcode) { case Instruction::IF_EQZ: ccode = kCondEq; break; @@ -255,7 +255,7 @@ bool MIRGraph::BasicBlockOpt(BasicBlock* bb) { (mir->ssa_rep->defs[0] == mir_next->ssa_rep->uses[0]) && (GetSSAUseCount(mir->ssa_rep->defs[0]) == 1)) { mir_next->dalvikInsn.arg[0] = ccode; - switch(opcode) { + switch (opcode) { case Instruction::CMPL_FLOAT: mir_next->dalvikInsn.opcode = static_cast(kMirOpFusedCmplFloat); diff --git a/compiler/dex/portable/mir_to_gbc.cc b/compiler/dex/portable/mir_to_gbc.cc index cfd3dafbee..85ffec50e7 100644 --- a/compiler/dex/portable/mir_to_gbc.cc +++ b/compiler/dex/portable/mir_to_gbc.cc @@ -297,7 +297,7 @@ void MirConverter::EmitSuspendCheck() { ::llvm::Value* src1, ::llvm::Value* src2) { ::llvm::Value* res = NULL; DCHECK_EQ(src1->getType(), src2->getType()); - switch(cc) { + switch (cc) { case kCondEq: res = irb_->CreateICmpEQ(src1, src2); break; case kCondNe: res = irb_->CreateICmpNE(src1, src2); break; case kCondLt: res = irb_->CreateICmpSLT(src1, src2); break; @@ -369,7 +369,7 @@ void MirConverter::ConvertCompareZeroAndBranch(BasicBlock* bb, ::llvm::Value* MirConverter::GenArithOp(OpKind op, bool is_long, ::llvm::Value* src1, ::llvm::Value* src2) { ::llvm::Value* res = NULL; - switch(op) { + switch (op) { case kOpAdd: res = irb_->CreateAdd(src1, src2); break; case kOpSub: res = irb_->CreateSub(src1, src2); break; case kOpRsub: res = irb_->CreateSub(src2, src1); break; @@ -393,7 +393,7 @@ void MirConverter::ConvertFPArithOp(OpKind op, RegLocation rl_dest, ::llvm::Value* src1 = GetLLVMValue(rl_src1.orig_sreg); ::llvm::Value* src2 = GetLLVMValue(rl_src2.orig_sreg); ::llvm::Value* res = NULL; - switch(op) { + switch (op) { case kOpAdd: res = irb_->CreateFAdd(src1, src2); break; case kOpSub: res = irb_->CreateFSub(src1, src2); break; case kOpMul: res = irb_->CreateFMul(src1, src2); break; @@ -1781,7 +1781,7 @@ char RemapShorty(char shorty_type) { * types (which is valid so long as we always do a real expansion of passed * arguments and field loads). */ - switch(shorty_type) { + switch (shorty_type) { case 'Z' : shorty_type = 'I'; break; case 'B' : shorty_type = 'I'; break; case 'S' : shorty_type = 'I'; break; diff --git a/compiler/dex/quick/arm/fp_arm.cc b/compiler/dex/quick/arm/fp_arm.cc index 2c626a0e8f..8f73f0c2f5 100644 --- a/compiler/dex/quick/arm/fp_arm.cc +++ b/compiler/dex/quick/arm/fp_arm.cc @@ -193,7 +193,7 @@ void ArmMir2Lir::GenFusedFPCmpBranch(BasicBlock* bb, MIR* mir, bool gt_bias, } NewLIR0(kThumb2Fmstat); ConditionCode ccode = static_cast(mir->dalvikInsn.arg[0]); - switch(ccode) { + switch (ccode) { case kCondEq: case kCondNe: break; diff --git a/compiler/dex/quick/arm/int_arm.cc b/compiler/dex/quick/arm/int_arm.cc index e12df6c56c..3a367c984d 100644 --- a/compiler/dex/quick/arm/int_arm.cc +++ b/compiler/dex/quick/arm/int_arm.cc @@ -129,7 +129,7 @@ void ArmMir2Lir::GenFusedLongCmpImmBranch(BasicBlock* bb, RegLocation rl_src1, int32_t low_reg = rl_src1.low_reg; int32_t high_reg = rl_src1.high_reg; - switch(ccode) { + switch (ccode) { case kCondEq: case kCondNe: LIR* target; @@ -270,7 +270,7 @@ void ArmMir2Lir::GenFusedLongCmpBranch(BasicBlock* bb, MIR* mir) { rl_src1 = LoadValueWide(rl_src1, kCoreReg); rl_src2 = LoadValueWide(rl_src2, kCoreReg); OpRegReg(kOpCmp, rl_src1.high_reg, rl_src2.high_reg); - switch(ccode) { + switch (ccode) { case kCondEq: OpCondBranch(kCondNe, not_taken); break; @@ -436,7 +436,7 @@ bool ArmMir2Lir::SmallLiteralDivide(Instruction::Code dalvik_opcode, int r_hi = AllocTemp(); int r_lo = AllocTemp(); NewLIR4(kThumb2Smull, r_lo, r_hi, r_magic, rl_src.low_reg); - switch(pattern) { + switch (pattern) { case Divide3: OpRegRegRegShift(kOpSub, rl_result.low_reg, r_hi, rl_src.low_reg, EncodeShift(kArmAsr, 31)); @@ -1002,7 +1002,7 @@ void ArmMir2Lir::GenShiftImmOpLong(Instruction::Code opcode, return; } RegLocation rl_result = EvalLoc(rl_dest, kCoreReg, true); - switch(opcode) { + switch (opcode) { case Instruction::SHL_LONG: case Instruction::SHL_LONG_2ADDR: if (shift_amount == 1) { @@ -1090,7 +1090,7 @@ void ArmMir2Lir::GenArithImmOpLong(Instruction::Code opcode, int32_t mod_imm_hi = ModifiedImmediate(val_hi); // Only a subset of add/sub immediate instructions set carry - so bail if we don't fit - switch(opcode) { + switch (opcode) { case Instruction::ADD_LONG: case Instruction::ADD_LONG_2ADDR: case Instruction::SUB_LONG: diff --git a/compiler/dex/quick/arm/utility_arm.cc b/compiler/dex/quick/arm/utility_arm.cc index 80f597d640..305a14798a 100644 --- a/compiler/dex/quick/arm/utility_arm.cc +++ b/compiler/dex/quick/arm/utility_arm.cc @@ -549,7 +549,7 @@ LIR* ArmMir2Lir::OpRegImm(OpKind op, int r_dest_src1, int value) { ArmOpcode opcode = kThumbBkpt; switch (op) { case kOpAdd: - if ( !neg && (r_dest_src1 == r13sp) && (value <= 508)) { /* sp */ + if (!neg && (r_dest_src1 == r13sp) && (value <= 508)) { /* sp */ DCHECK_EQ((value & 0x3), 0); return NewLIR1(kThumbAddSpI7, value >> 2); } else if (short_form) { diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc index 8698b1f9ed..7a59644273 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -55,7 +55,7 @@ bool Mir2Lir::FastInstance(uint32_t field_idx, int& field_offset, bool& is_volat } /* Convert an instruction to a NOP */ -void Mir2Lir::NopLIR( LIR* lir) { +void Mir2Lir::NopLIR(LIR* lir) { lir->flags.is_nop = true; } @@ -190,10 +190,10 @@ void Mir2Lir::DumpLIRInsn(LIR* lir, unsigned char* base_addr) { } if (lir->use_mask && (!lir->flags.is_nop || dump_nop)) { - DUMP_RESOURCE_MASK(DumpResourceMask((LIR* ) lir, lir->use_mask, "use")); + DUMP_RESOURCE_MASK(DumpResourceMask((LIR*) lir, lir->use_mask, "use")); } if (lir->def_mask && (!lir->flags.is_nop || dump_nop)) { - DUMP_RESOURCE_MASK(DumpResourceMask((LIR* ) lir, lir->def_mask, "def")); + DUMP_RESOURCE_MASK(DumpResourceMask((LIR*) lir, lir->def_mask, "def")); } } @@ -336,10 +336,10 @@ LIR* Mir2Lir::AddWideData(LIR* *constant_list_p, int val_lo, int val_hi) { } static void PushWord(std::vector&buf, int data) { - buf.push_back( data & 0xff); - buf.push_back( (data >> 8) & 0xff); - buf.push_back( (data >> 16) & 0xff); - buf.push_back( (data >> 24) & 0xff); + buf.push_back(data & 0xff); + buf.push_back((data >> 8) & 0xff); + buf.push_back((data >> 16) & 0xff); + buf.push_back((data >> 24) & 0xff); } static void AlignBuffer(std::vector&buf, size_t offset) { @@ -454,8 +454,8 @@ void Mir2Lir::InstallFillArrayData() { if (tab_rec == NULL) break; AlignBuffer(code_buffer_, tab_rec->offset); for (int i = 0; i < (tab_rec->size + 1) / 2; i++) { - code_buffer_.push_back( tab_rec->table[i] & 0xFF); - code_buffer_.push_back( (tab_rec->table[i] >> 8) & 0xFF); + code_buffer_.push_back(tab_rec->table[i] & 0xFF); + code_buffer_.push_back((tab_rec->table[i] >> 8) & 0xFF); } } } diff --git a/compiler/dex/quick/gen_common.cc b/compiler/dex/quick/gen_common.cc index a34d2a9e76..d1bfd2d9d9 100644 --- a/compiler/dex/quick/gen_common.cc +++ b/compiler/dex/quick/gen_common.cc @@ -279,7 +279,7 @@ void Mir2Lir::GenFilledNewArray(CallInfo* info) { int r_dst = AllocTemp(); int r_idx = AllocTemp(); int r_val = INVALID_REG; - switch(cu_->instruction_set) { + switch (cu_->instruction_set) { case kThumb2: r_val = TargetReg(kLr); break; @@ -1311,7 +1311,7 @@ void Mir2Lir::GenArithOpInt(Instruction::Code opcode, RegLocation rl_dest, GenImmedCheck(kCondEq, TargetReg(kArg1), 0, kThrowDivZero); } // NOTE: callout here is not a safepoint - CallHelper(r_tgt, func_offset, false /* not a safepoint */ ); + CallHelper(r_tgt, func_offset, false /* not a safepoint */); if (op == kOpDiv) rl_result = GetReturn(false); else diff --git a/compiler/dex/quick/mips/utility_mips.cc b/compiler/dex/quick/mips/utility_mips.cc index 8510006051..127d191a5d 100644 --- a/compiler/dex/quick/mips/utility_mips.cc +++ b/compiler/dex/quick/mips/utility_mips.cc @@ -107,7 +107,7 @@ LIR* MipsMir2Lir::LoadConstantNoClobber(int r_dest, int value) { } LIR* MipsMir2Lir::OpUnconditionalBranch(LIR* target) { - LIR* res = NewLIR1(kMipsB, 0 /* offset to be patched during assembly*/ ); + LIR* res = NewLIR1(kMipsB, 0 /* offset to be patched during assembly*/); res->target = target; return res; } @@ -642,8 +642,8 @@ LIR* MipsMir2Lir::OpMem(OpKind op, int rBase, int disp) { return NULL; } -LIR* MipsMir2Lir::StoreBaseIndexedDisp( int rBase, int r_index, int scale, int displacement, - int r_src, int r_src_hi, OpSize size, int s_reg) { +LIR* MipsMir2Lir::StoreBaseIndexedDisp(int rBase, int r_index, int scale, int displacement, + int r_src, int r_src_hi, OpSize size, int s_reg) { LOG(FATAL) << "Unexpected use of StoreBaseIndexedDisp for MIPS"; return NULL; } diff --git a/compiler/dex/quick/mir_to_lir.h b/compiler/dex/quick/mir_to_lir.h index 41e5a2d988..7765eaaeef 100644 --- a/compiler/dex/quick/mir_to_lir.h +++ b/compiler/dex/quick/mir_to_lir.h @@ -233,7 +233,7 @@ class Mir2Lir : public Backend { RegisterClass oat_reg_class_by_size(OpSize size) { return (size == kUnsignedHalf || size == kSignedHalf || size == kUnsignedByte || - size == kSignedByte ) ? kCoreReg : kAnyReg; + size == kSignedByte) ? kCoreReg : kAnyReg; } size_t CodeBufferSizeInBytes() { diff --git a/compiler/dex/quick/ralloc_util.cc b/compiler/dex/quick/ralloc_util.cc index 4c91223687..bc3740a4e1 100644 --- a/compiler/dex/quick/ralloc_util.cc +++ b/compiler/dex/quick/ralloc_util.cc @@ -1021,8 +1021,7 @@ void Mir2Lir::DoPromotion() { if (!(cu_->disable_opt & (1 << kPromoteRegs))) { // Promote FpRegs - for (int i = 0; (i < num_regs) && - (FpRegs[i].count >= promotion_threshold ); i++) { + for (int i = 0; (i < num_regs) && (FpRegs[i].count >= promotion_threshold); i++) { int p_map_idx = SRegToPMap(FpRegs[i].s_reg); if (promotion_map_[p_map_idx].fp_location != kLocPhysReg) { int reg = AllocPreservedFPReg(FpRegs[i].s_reg, diff --git a/compiler/dex/quick/x86/utility_x86.cc b/compiler/dex/quick/x86/utility_x86.cc index 6376e3b87a..75367a340a 100644 --- a/compiler/dex/quick/x86/utility_x86.cc +++ b/compiler/dex/quick/x86/utility_x86.cc @@ -100,7 +100,7 @@ LIR* X86Mir2Lir::LoadConstantNoClobber(int r_dest, int value) { } LIR* X86Mir2Lir::OpUnconditionalBranch(LIR* target) { - LIR* res = NewLIR1(kX86Jmp8, 0 /* offset to be patched during assembly*/ ); + LIR* res = NewLIR1(kX86Jmp8, 0 /* offset to be patched during assembly*/); res->target = target; return res; } diff --git a/compiler/dex/ssa_transformation.cc b/compiler/dex/ssa_transformation.cc index 3a0cbcc67c..7739e2996f 100644 --- a/compiler/dex/ssa_transformation.cc +++ b/compiler/dex/ssa_transformation.cc @@ -266,7 +266,7 @@ bool MIRGraph::ComputeDominanceFrontier(BasicBlock* bb) { void MIRGraph::InitializeDominationInfo(BasicBlock* bb) { int num_total_blocks = GetBasicBlockListCount(); - if (bb->dominators == NULL ) { + if (bb->dominators == NULL) { bb->dominators = new (arena_) ArenaBitVector(arena_, num_total_blocks, false /* expandable */, kBitMapDominators); bb->i_dominated = new (arena_) ArenaBitVector(arena_, num_total_blocks, diff --git a/compiler/dex/vreg_analysis.cc b/compiler/dex/vreg_analysis.cc index 10bbd1f8b8..f361dd75e0 100644 --- a/compiler/dex/vreg_analysis.cc +++ b/compiler/dex/vreg_analysis.cc @@ -160,7 +160,7 @@ bool MIRGraph::InferTypeAndSize(BasicBlock* bb) { if ((mir->dalvikInsn.opcode == Instruction::RETURN) || (mir->dalvikInsn.opcode == Instruction::RETURN_WIDE) || (mir->dalvikInsn.opcode == Instruction::RETURN_OBJECT)) { - switch(cu_->shorty[0]) { + switch (cu_->shorty[0]) { case 'I': changed |= SetCore(ssa_rep->uses[0], true); break; diff --git a/compiler/llvm/llvm_compilation_unit.cc b/compiler/llvm/llvm_compilation_unit.cc index 1f2b977921..592059e6a6 100644 --- a/compiler/llvm/llvm_compilation_unit.cc +++ b/compiler/llvm/llvm_compilation_unit.cc @@ -114,7 +114,7 @@ LlvmCompilationUnit::LlvmCompilationUnit(const CompilerLLVM* compiler_llvm, size irb_.reset(new IRBuilder(*context_, *module_, *intrinsic_helper_)); // We always need a switch case, so just use a normal function. - switch(GetInstructionSet()) { + switch (GetInstructionSet()) { default: runtime_support_.reset(new RuntimeSupportBuilder(*context_, *module_, *irb_)); break; diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index 4c32506d43..da05c49e0e 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -399,8 +399,7 @@ size_t OatWriter::InitOatCodeMethod(size_t offset, size_t oat_class_index, fp_spill_mask, mapping_table_offset, vmap_table_offset, - gc_map_offset - ); + gc_map_offset); if (compiler_driver_->IsImage()) { ClassLinker* linker = Runtime::Current()->GetClassLinker(); diff --git a/runtime/atomic_integer.h b/runtime/atomic_integer.h index 6711722672..05024b4680 100644 --- a/runtime/atomic_integer.h +++ b/runtime/atomic_integer.h @@ -34,7 +34,7 @@ class AtomicInteger { return *this; } - operator int32_t () const { + operator int32_t() const { return value_; } diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h index 07157da7aa..b3f5092c76 100644 --- a/runtime/base/mutex-inl.h +++ b/runtime/base/mutex-inl.h @@ -148,7 +148,7 @@ inline void ReaderWriterMutex::SharedLock(Thread* self) { } android_atomic_dec(&num_pending_readers_); } - } while(!done); + } while (!done); #else CHECK_MUTEX_CALL(pthread_rwlock_rdlock, (&rwlock_)); #endif @@ -176,7 +176,7 @@ inline void ReaderWriterMutex::SharedUnlock(Thread* self) { } else { LOG(FATAL) << "Unexpected state_:" << cur_state << " for " << name_; } - } while(!done); + } while (!done); #else CHECK_MUTEX_CALL(pthread_rwlock_unlock, (&rwlock_)); #endif diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc index 25c0b9ea8e..1df0207503 100644 --- a/runtime/base/mutex.cc +++ b/runtime/base/mutex.cc @@ -178,7 +178,7 @@ void BaseMutex::RecordContention(uint64_t blocked_tid, uint64_t owner_tid, uint6 do { slot = cur_content_log_entry_; new_slot = (slot + 1) % kContentionLogSize; - } while(!cur_content_log_entry_.CompareAndSwap(slot, new_slot)); + } while (!cur_content_log_entry_.CompareAndSwap(slot, new_slot)); contention_log_[new_slot].blocked_tid = blocked_tid; contention_log_[new_slot].owner_tid = owner_tid; contention_log_[new_slot].count = 1; @@ -312,7 +312,7 @@ void Mutex::ExclusiveLock(Thread* self) { } android_atomic_dec(&num_contenders_); } - } while(!done); + } while (!done); DCHECK_EQ(state_, 1); exclusive_owner_ = SafeGetTid(self); #else @@ -344,7 +344,7 @@ bool Mutex::ExclusiveTryLock(Thread* self) { } else { return false; } - } while(!done); + } while (!done); DCHECK_EQ(state_, 1); exclusive_owner_ = SafeGetTid(self); #else @@ -404,7 +404,7 @@ void Mutex::ExclusiveUnlock(Thread* self) { _exit(1); } } - } while(!done); + } while (!done); #else CHECK_MUTEX_CALL(pthread_mutex_unlock, (&mutex_)); #endif @@ -513,7 +513,7 @@ void ReaderWriterMutex::ExclusiveLock(Thread* self) { } android_atomic_dec(&num_pending_writers_); } - } while(!done); + } while (!done); DCHECK_EQ(state_, -1); exclusive_owner_ = SafeGetTid(self); #else @@ -545,7 +545,7 @@ void ReaderWriterMutex::ExclusiveUnlock(Thread* self) { } else { LOG(FATAL) << "Unexpected state_:" << cur_state << " for " << name_; } - } while(!done); + } while (!done); #else CHECK_MUTEX_CALL(pthread_rwlock_unlock, (&rwlock_)); #endif @@ -583,7 +583,7 @@ bool ReaderWriterMutex::ExclusiveLockWithTimeout(Thread* self, int64_t ms, int32 } android_atomic_dec(&num_pending_writers_); } - } while(!done); + } while (!done); exclusive_owner_ = SafeGetTid(self); #else timespec ts; @@ -616,7 +616,7 @@ bool ReaderWriterMutex::SharedTryLock(Thread* self) { // Owner holds it exclusively. return false; } - } while(!done); + } while (!done); #else int result = pthread_rwlock_tryrdlock(&rwlock_); if (result == EBUSY) { diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc index 403a2eb348..7429ab11a9 100644 --- a/runtime/check_jni.cc +++ b/runtime/check_jni.cc @@ -401,7 +401,7 @@ class ScopedCheck { * * Use the kFlag_NullableUtf flag where 'u' field(s) are nullable. */ - void Check(bool entry, const char* fmt0, ...) SHARED_LOCKS_REQUIRED (Locks::mutator_lock_) { + void Check(bool entry, const char* fmt0, ...) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { va_list ap; const mirror::AbstractMethod* traceMethod = NULL; diff --git a/runtime/class_linker_test.cc b/runtime/class_linker_test.cc index e5844b0038..3c1cd7850e 100644 --- a/runtime/class_linker_test.cc +++ b/runtime/class_linker_test.cc @@ -937,14 +937,14 @@ TEST_F(ClassLinkerTest, StaticFields) { // TODO: Remove EXPECT_FALSE when GCC can handle EXPECT_EQ // http://code.google.com/p/googletest/issues/detail?id=322 - EXPECT_FALSE( s0->GetBoolean(statics)); - EXPECT_EQ(6, s1->GetByte(statics)); - EXPECT_EQ('b', s2->GetChar(statics)); - EXPECT_EQ(-535, s3->GetShort(statics)); - EXPECT_EQ(2000000001, s4->GetInt(statics)); + EXPECT_FALSE(s0->GetBoolean(statics)); + EXPECT_EQ(6, s1->GetByte(statics)); + EXPECT_EQ('b', s2->GetChar(statics)); + EXPECT_EQ(-535, s3->GetShort(statics)); + EXPECT_EQ(2000000001, s4->GetInt(statics)); EXPECT_EQ(0x34567890abcdef12LL, s5->GetLong(statics)); - EXPECT_EQ(0.75, s6->GetFloat(statics)); - EXPECT_EQ(16777219, s7->GetDouble(statics)); + EXPECT_EQ(0.75, s6->GetFloat(statics)); + EXPECT_EQ(16777219, s7->GetDouble(statics)); EXPECT_TRUE(s8->GetObject(statics)->AsString()->Equals("robot")); } diff --git a/runtime/common_test.h b/runtime/common_test.h index 73c47b5a8c..e735e279b6 100644 --- a/runtime/common_test.h +++ b/runtime/common_test.h @@ -178,8 +178,7 @@ class CommonTest : public testing::Test { fp_spill_mask, reinterpret_cast(mapping_table), reinterpret_cast(vmap_table), - reinterpret_cast(gc_map) - ); + reinterpret_cast(gc_map)); } void MakeExecutable(mirror::AbstractMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -308,7 +307,7 @@ class CommonTest : public testing::Test { options.push_back(std::make_pair("-Xcheck:jni", reinterpret_cast(NULL))); options.push_back(std::make_pair(min_heap_string.c_str(), reinterpret_cast(NULL))); options.push_back(std::make_pair(max_heap_string.c_str(), reinterpret_cast(NULL))); - if(!Runtime::Create(options, false)) { + if (!Runtime::Create(options, false)) { LOG(FATAL) << "Failed to create runtime"; return; } diff --git a/runtime/debugger.cc b/runtime/debugger.cc index b502c9ab58..4fbee51045 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -184,7 +184,7 @@ static Dbg::HpsgWhat gDdmNhsgWhat; static ObjectRegistry* gRegistry = NULL; // Recent allocation tracking. -static Mutex gAllocTrackerLock DEFAULT_MUTEX_ACQUIRED_AFTER ("AllocTracker lock"); +static Mutex gAllocTrackerLock DEFAULT_MUTEX_ACQUIRED_AFTER("AllocTracker lock"); AllocRecord* Dbg::recent_allocation_records_ PT_GUARDED_BY(gAllocTrackerLock) = NULL; // TODO: CircularBuffer static size_t gAllocRecordMax GUARDED_BY(gAllocTrackerLock) = 0; static size_t gAllocRecordHead GUARDED_BY(gAllocTrackerLock) = 0; @@ -2761,7 +2761,7 @@ JDWP::JdwpError Dbg::InvokeMethod(JDWP::ObjectId thread_id, JDWP::ObjectId objec VLOG(jdwp) << " Control has returned from event thread"; /* wait for thread to re-suspend itself */ - SuspendThread(thread_id, false /* request_suspension */ ); + SuspendThread(thread_id, false /* request_suspension */); self->TransitionFromSuspendedToRunnable(); } diff --git a/runtime/dex_file.h b/runtime/dex_file.h index 28e06cc5b9..8edeb18418 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -1039,7 +1039,7 @@ class ClassDataItemIterator { } InvokeType GetMethodInvokeType(const DexFile::ClassDef& class_def) const { if (HasNextDirectMethod()) { - if ((GetMemberAccessFlags() & kAccStatic) != 0 ) { + if ((GetMemberAccessFlags() & kAccStatic) != 0) { return kStatic; } else { return kDirect; diff --git a/runtime/dex_instruction.cc b/runtime/dex_instruction.cc index 6527f103eb..a36d7c5166 100644 --- a/runtime/dex_instruction.cc +++ b/runtime/dex_instruction.cc @@ -56,12 +56,11 @@ int const Instruction::kInstructionVerifyFlags[] = { int const Instruction::kInstructionSizeInCodeUnits[] = { #define INSTRUCTION_SIZE(opcode, c, p, format, r, i, a, v) \ - (( opcode == NOP ) ? -1 : \ + ((opcode == NOP) ? -1 : \ ((format >= k10x) && (format <= k10t)) ? 1 : \ ((format >= k20t) && (format <= k22c)) ? 2 : \ ((format >= k32x) && (format <= k3rc)) ? 3 : \ - ( format == k51l ) ? 5 : -1 \ - ), + (format == k51l) ? 5 : -1), #include "dex_instruction_list.h" DEX_INSTRUCTION_LIST(INSTRUCTION_SIZE) #undef DEX_INSTRUCTION_LIST diff --git a/runtime/disassembler_arm.cc b/runtime/disassembler_arm.cc index 172bef84d6..3c9cb6ecab 100644 --- a/runtime/disassembler_arm.cc +++ b/runtime/disassembler_arm.cc @@ -1184,7 +1184,7 @@ size_t DisassemblerArm::DumpThumb16(std::ostream& os, const uint8_t* instr_ptr) ThumbRegister Rm(instr, 6); ThumbRegister Rn(instr, 3); ThumbRegister Rt(instr, 0); - switch(opB) { + switch (opB) { case 0: opcode << "str"; break; case 1: opcode << "strh"; break; case 2: opcode << "strb"; break; @@ -1206,7 +1206,7 @@ size_t DisassemblerArm::DumpThumb16(std::ostream& os, const uint8_t* instr_ptr) uint16_t opB = (instr >> 11) & 1; ThumbRegister Rn(instr, 3); ThumbRegister Rt(instr, 0); - switch(opA) { + switch (opA) { case 6: imm5 <<= 2; opcode << (opB == 0 ? "str" : "ldr"); diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc index da122e68ee..6ce36e8f6a 100644 --- a/runtime/elf_file.cc +++ b/runtime/elf_file.cc @@ -366,7 +366,7 @@ static unsigned elfhash(const char *_name) { const unsigned char *name = (const unsigned char *) _name; unsigned h = 0, g; - while(*name) { + while (*name) { h = (h << 4) + *name++; g = h & 0xf0000000; h ^= g; diff --git a/runtime/gc/accounting/atomic_stack.h b/runtime/gc/accounting/atomic_stack.h index 5310c18ec6..1e8beda0fd 100644 --- a/runtime/gc/accounting/atomic_stack.h +++ b/runtime/gc/accounting/atomic_stack.h @@ -66,7 +66,7 @@ class AtomicStack { // Stack overflow. return false; } - } while(!back_index_.CompareAndSwap(index, index + 1)); + } while (!back_index_.CompareAndSwap(index, index + 1)); begin_[index] = value; return true; } diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc index aa02f82679..91c92537b5 100644 --- a/runtime/gc/accounting/mod_union_table.cc +++ b/runtime/gc/accounting/mod_union_table.cc @@ -44,8 +44,8 @@ class MarkIfReachesAllocspaceVisitor { } // Extra parameters are required since we use this same visitor signature for checking objects. - void operator ()(const Object* obj, const Object* ref, const MemberOffset& /* offset */, - bool /* is_static */) const { + void operator()(const Object* obj, const Object* ref, const MemberOffset& /* offset */, + bool /* is_static */) const { // TODO: Optimize? // TODO: C++0x auto const std::vector& spaces = heap_->GetContinuousSpaces(); @@ -70,7 +70,7 @@ class ModUnionVisitor { bitmap_(bitmap) { } - void operator ()(const Object* obj) const + void operator()(const Object* obj) const SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_) { DCHECK(obj != NULL); @@ -90,7 +90,7 @@ class ModUnionClearCardSetVisitor { : cleared_cards_(cleared_cards) { } - inline void operator ()(byte* card, byte expected_value, byte new_value) const { + inline void operator()(byte* card, byte expected_value, byte new_value) const { if (expected_value == CardTable::kCardDirty) { cleared_cards_->insert(card); } @@ -106,7 +106,7 @@ class ModUnionClearCardVisitor { : cleared_cards_(cleared_cards) { } - void operator ()(byte* card, byte expected_card, byte new_card) const { + void operator()(byte* card, byte expected_card, byte new_card) const { if (expected_card == CardTable::kCardDirty) { cleared_cards_->push_back(card); } @@ -120,7 +120,7 @@ class ModUnionScanImageRootVisitor { explicit ModUnionScanImageRootVisitor(collector::MarkSweep* const mark_sweep) : mark_sweep_(mark_sweep) {} - void operator ()(const Object* root) const + void operator()(const Object* root) const EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { DCHECK(root != NULL); @@ -147,8 +147,8 @@ class AddToReferenceArrayVisitor { } // Extra parameters are required since we use this same visitor signature for checking objects. - void operator ()(const Object* obj, const Object* ref, const MemberOffset& /* offset */, - bool /* is_static */) const { + void operator()(const Object* obj, const Object* ref, const MemberOffset& /* offset */, + bool /* is_static */) const { // Only add the reference if it is non null and fits our criteria. if (ref != NULL && mod_union_table_->AddReference(obj, ref)) { references_->push_back(ref); @@ -168,7 +168,7 @@ class ModUnionReferenceVisitor { references_(references) { } - void operator ()(const Object* obj) const + void operator()(const Object* obj) const SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_) { DCHECK(obj != NULL); // We don't have an early exit since we use the visitor pattern, an early @@ -191,8 +191,8 @@ class CheckReferenceVisitor { // Extra parameters are required since we use this same visitor signature for checking objects. // TODO: Fixme when anotatalysis works with visitors. - void operator ()(const Object* obj, const Object* ref, const MemberOffset& /* offset */, - bool /* is_static */) const + void operator()(const Object* obj, const Object* ref, const MemberOffset& /* offset */, + bool /* is_static */) const SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_) { Heap* heap = mod_union_table_->GetHeap(); if (ref != NULL && mod_union_table_->AddReference(obj, ref) && @@ -216,13 +216,13 @@ class CheckReferenceVisitor { class ModUnionCheckReferences { public: - explicit ModUnionCheckReferences (ModUnionTableReferenceCache* mod_union_table, - const std::set& references) + explicit ModUnionCheckReferences(ModUnionTableReferenceCache* mod_union_table, + const std::set& references) EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_) : mod_union_table_(mod_union_table), references_(references) { } - void operator ()(const Object* obj) const NO_THREAD_SAFETY_ANALYSIS { + void operator()(const Object* obj) const NO_THREAD_SAFETY_ANALYSIS { Locks::heap_bitmap_lock_->AssertSharedHeld(Thread::Current()); DCHECK(obj != NULL); CheckReferenceVisitor visitor(mod_union_table_, references_); @@ -333,7 +333,7 @@ void ModUnionTableReferenceCache::MarkReferences(collector::MarkSweep* mark_swee typedef SafeMap >::const_iterator It; for (It it = references_.begin(); it != references_.end(); ++it) { typedef std::vector::const_iterator It2; - for (It2 it_ref = it->second.begin(); it_ref != it->second.end(); ++it_ref ) { + for (It2 it_ref = it->second.begin(); it_ref != it->second.end(); ++it_ref) { mark_sweep->MarkRoot(*it_ref); ++count; } diff --git a/runtime/gc/accounting/space_bitmap.h b/runtime/gc/accounting/space_bitmap.h index bf4c1ed9af..77f93a266c 100644 --- a/runtime/gc/accounting/space_bitmap.h +++ b/runtime/gc/accounting/space_bitmap.h @@ -103,7 +103,7 @@ class SpaceBitmap { : bitmap_(bitmap) { } - void operator ()(mirror::Object* obj) const { + void operator()(mirror::Object* obj) const { bitmap_->Clear(obj); } private: @@ -112,7 +112,7 @@ class SpaceBitmap { template void VisitRange(uintptr_t visit_begin, uintptr_t visit_end, const Visitor& visitor) const { - for (; visit_begin < visit_end; visit_begin += kAlignment ) { + for (; visit_begin < visit_end; visit_begin += kAlignment) { visitor(reinterpret_cast(visit_begin)); } } diff --git a/runtime/gc/accounting/space_bitmap_test.cc b/runtime/gc/accounting/space_bitmap_test.cc index d00d7c2739..516a44991e 100644 --- a/runtime/gc/accounting/space_bitmap_test.cc +++ b/runtime/gc/accounting/space_bitmap_test.cc @@ -46,7 +46,7 @@ class BitmapVerify { begin_(begin), end_(end) {} - void operator ()(const mirror::Object* obj) { + void operator()(const mirror::Object* obj) { EXPECT_TRUE(obj >= begin_); EXPECT_TRUE(obj <= end_); EXPECT_TRUE(bitmap_->Test(obj) == ((reinterpret_cast(obj) & 0xF) != 0)); diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index a5bad2f958..2ca5f2dd7a 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -72,7 +72,7 @@ class SetFingerVisitor { public: explicit SetFingerVisitor(MarkSweep* const mark_sweep) : mark_sweep_(mark_sweep) {} - void operator ()(void* finger) const { + void operator()(void* finger) const { mark_sweep_->SetFinger(reinterpret_cast(finger)); } @@ -524,7 +524,7 @@ class CheckObjectVisitor { public: explicit CheckObjectVisitor(MarkSweep* const mark_sweep) : mark_sweep_(mark_sweep) {} - void operator ()(const Object* obj, const Object* ref, MemberOffset offset, bool is_static) const + void operator()(const Object* obj, const Object* ref, MemberOffset offset, bool is_static) const NO_THREAD_SAFETY_ANALYSIS { if (kDebugLocking) { Locks::heap_bitmap_lock_->AssertSharedHeld(Thread::Current()); @@ -565,7 +565,7 @@ class ScanObjectVisitor { explicit ScanObjectVisitor(MarkSweep* const mark_sweep) : mark_sweep_(mark_sweep) {} // TODO: Fixme when anotatalysis works with visitors. - void operator ()(const Object* obj) const NO_THREAD_SAFETY_ANALYSIS { + void operator()(const Object* obj) const NO_THREAD_SAFETY_ANALYSIS { if (kDebugLocking) { Locks::mutator_lock_->AssertSharedHeld(Thread::Current()); Locks::heap_bitmap_lock_->AssertExclusiveHeld(Thread::Current()); @@ -609,7 +609,7 @@ class CheckBitmapVisitor { public: explicit CheckBitmapVisitor(MarkSweep* mark_sweep) : mark_sweep_(mark_sweep) {} - void operator ()(const Object* obj) const NO_THREAD_SAFETY_ANALYSIS { + void operator()(const Object* obj) const NO_THREAD_SAFETY_ANALYSIS { if (kDebugLocking) { Locks::heap_bitmap_lock_->AssertSharedHeld(Thread::Current()); } @@ -1081,8 +1081,8 @@ class MarkObjectVisitor { explicit MarkObjectVisitor(MarkSweep* const mark_sweep) : mark_sweep_(mark_sweep) {} // TODO: Fixme when anotatalysis works with visitors. - void operator ()(const Object* /* obj */, const Object* ref, const MemberOffset& /* offset */, - bool /* is_static */) const + void operator()(const Object* /* obj */, const Object* ref, const MemberOffset& /* offset */, + bool /* is_static */) const NO_THREAD_SAFETY_ANALYSIS { if (kDebugLocking) { Locks::mutator_lock_->AssertSharedHeld(Thread::Current()); @@ -1148,8 +1148,8 @@ class MarkStackChunk : public Task { public: explicit MarkObjectParallelVisitor(MarkStackChunk* chunk_task) : chunk_task_(chunk_task) {} - void operator ()(const Object* /* obj */, const Object* ref, - const MemberOffset& /* offset */, bool /* is_static */) const { + void operator()(const Object* /* obj */, const Object* ref, + const MemberOffset& /* offset */, bool /* is_static */) const { if (ref != NULL && chunk_task_->mark_sweep_->MarkObjectParallel(ref)) { chunk_task_->MarkStackPush(ref); } diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index deb1b8c3e5..7bd7c5d7e2 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -228,7 +228,7 @@ void Heap::DeleteThreadPool() { // Sort spaces based on begin address struct ContinuousSpaceSorter { - bool operator ()(const space::ContinuousSpace* a, const space::ContinuousSpace* b) const { + bool operator()(const space::ContinuousSpace* a, const space::ContinuousSpace* b) const { return a->Begin() < b->Begin(); } }; @@ -894,8 +894,8 @@ class ReferringObjectsFinder { } // For MarkSweep::VisitObjectReferences. - void operator ()(const mirror::Object* referrer, const mirror::Object* object, - const MemberOffset&, bool) const { + void operator()(const mirror::Object* referrer, const mirror::Object* object, + const MemberOffset&, bool) const { if (object == object_ && (max_count_ == 0 || referring_objects_.size() < max_count_)) { referring_objects_.push_back(const_cast(referrer)); } @@ -1165,7 +1165,7 @@ static void RootMatchesObjectVisitor(const mirror::Object* root, void* arg) { class ScanVisitor { public: - void operator ()(const mirror::Object* obj) const { + void operator()(const mirror::Object* obj) const { LOG(INFO) << "Would have rescanned object " << obj; } }; @@ -1183,8 +1183,8 @@ class VerifyReferenceVisitor { // TODO: Fix lock analysis to not use NO_THREAD_SAFETY_ANALYSIS, requires support for smarter // analysis on visitors. - void operator ()(const mirror::Object* obj, const mirror::Object* ref, - const MemberOffset& offset, bool /* is_static */) const + void operator()(const mirror::Object* obj, const mirror::Object* ref, + const MemberOffset& offset, bool /* is_static */) const NO_THREAD_SAFETY_ANALYSIS { // Verify that the reference is live. if (UNLIKELY(ref != NULL && !IsLive(ref))) { @@ -1264,7 +1264,7 @@ class VerifyObjectVisitor { public: explicit VerifyObjectVisitor(Heap* heap) : heap_(heap), failed_(false) {} - void operator ()(const mirror::Object* obj) const + void operator()(const mirror::Object* obj) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_) { // Note: we are verifying the references in obj but not obj itself, this is because obj must // be live or else how did we find it in the live bitmap? @@ -1311,8 +1311,8 @@ class VerifyReferenceCardVisitor { // TODO: Fix lock analysis to not use NO_THREAD_SAFETY_ANALYSIS, requires support for // annotalysis on visitors. - void operator ()(const mirror::Object* obj, const mirror::Object* ref, const MemberOffset& offset, - bool is_static) const NO_THREAD_SAFETY_ANALYSIS { + void operator()(const mirror::Object* obj, const mirror::Object* ref, const MemberOffset& offset, + bool is_static) const NO_THREAD_SAFETY_ANALYSIS { // Filter out class references since changing an object's class does not mark the card as dirty. // Also handles large objects, since the only reference they hold is a class reference. if (ref != NULL && !ref->IsClass()) { @@ -1378,7 +1378,7 @@ class VerifyLiveStackReferences { : heap_(heap), failed_(false) {} - void operator ()(const mirror::Object* obj) const + void operator()(const mirror::Object* obj) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_) { VerifyReferenceCardVisitor visitor(heap_, const_cast(&failed_)); collector::MarkSweep::VisitObjectReferences(obj, visitor); diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h index 630d063ff0..32e068cdae 100644 --- a/runtime/gc/heap.h +++ b/runtime/gc/heap.h @@ -70,7 +70,7 @@ namespace space { class AgeCardVisitor { public: - byte operator ()(byte card) const { + byte operator()(byte card) const { if (card == accounting::CardTable::kCardDirty) { return card - 1; } else { diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index 45314c231b..376d3be0a7 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -969,11 +969,11 @@ static inline const Instruction* FindNextInstructionFollowingException(Thread* s return JValue(); /* Handled in caller. */ \ } \ } else { \ - inst = inst-> next_function (); \ + inst = inst->next_function(); \ } static void UnexpectedOpcode(const Instruction* inst, MethodHelper& mh) - __attribute__ ((cold, noreturn, noinline)); + __attribute__((cold, noreturn, noinline)); static void UnexpectedOpcode(const Instruction* inst, MethodHelper& mh) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { @@ -989,7 +989,7 @@ static void UnexpectedOpcode(const Instruction* inst, MethodHelper& mh) template static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register) - NO_THREAD_SAFETY_ANALYSIS __attribute__ ((hot)); + NO_THREAD_SAFETY_ANALYSIS __attribute__((hot)); template static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item, @@ -1254,7 +1254,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte if (UNLIKELY(s == NULL)) { HANDLE_PENDING_EXCEPTION(); } else { - shadow_frame.SetVRegReference( inst->VRegA_21c(), s); + shadow_frame.SetVRegReference(inst->VRegA_21c(), s); inst = inst->Next_2xx(); } break; @@ -1265,7 +1265,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte if (UNLIKELY(s == NULL)) { HANDLE_PENDING_EXCEPTION(); } else { - shadow_frame.SetVRegReference( inst->VRegA_31c(), s); + shadow_frame.SetVRegReference(inst->VRegA_31c(), s); inst = inst->Next_3xx(); } break; diff --git a/runtime/oat.h b/runtime/oat.h index fb28962762..4bd1871a71 100644 --- a/runtime/oat.h +++ b/runtime/oat.h @@ -97,8 +97,7 @@ class PACKED(4) OatMethodOffsets { uint32_t fp_spill_mask, uint32_t mapping_table_offset, uint32_t vmap_table_offset, - uint32_t gc_map_offset - ); + uint32_t gc_map_offset); ~OatMethodOffsets(); diff --git a/runtime/reflection.cc b/runtime/reflection.cc index 467575cdf5..359b539fff 100644 --- a/runtime/reflection.cc +++ b/runtime/reflection.cc @@ -206,8 +206,7 @@ bool ConvertPrimitiveValue(const ThrowLocation* throw_location, bool unbox_for_r ThrowClassCastException(throw_location, StringPrintf("Couldn't convert result of type %s to %s", PrettyDescriptor(srcType).c_str(), - PrettyDescriptor(dstType).c_str() - ).c_str()); + PrettyDescriptor(dstType).c_str()).c_str()); } return false; } @@ -297,8 +296,7 @@ static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* ThrowClassCastException(throw_location, StringPrintf("Couldn't convert result of type %s to %s", PrettyTypeOf(o).c_str(), - PrettyDescriptor(dst_class).c_str() - ).c_str()); + PrettyDescriptor(dst_class).c_str()).c_str()); } return false; } @@ -359,8 +357,7 @@ static bool UnboxPrimitive(const ThrowLocation* throw_location, mirror::Object* StringPrintf("%s has type %s, got %s", UnboxingFailureKind(m, index, f).c_str(), PrettyDescriptor(dst_class).c_str(), - PrettyDescriptor(src_descriptor.c_str()).c_str() - ).c_str()); + PrettyDescriptor(src_descriptor.c_str()).c_str()).c_str()); return false; } diff --git a/runtime/stack.cc b/runtime/stack.cc index fcd0f2dc7e..bf0f78fd37 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -185,12 +185,12 @@ void StackVisitor::SetVReg(mirror::AbstractMethod* m, uint16_t vreg, uint32_t ne } uintptr_t StackVisitor::GetGPR(uint32_t reg) const { - DCHECK (cur_quick_frame_ != NULL) << "This is a quick frame routine"; + DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; return context_->GetGPR(reg); } void StackVisitor::SetGPR(uint32_t reg, uintptr_t value) { - DCHECK (cur_quick_frame_ != NULL) << "This is a quick frame routine"; + DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; context_->SetGPR(reg, value); } @@ -344,7 +344,7 @@ void StackVisitor::WalkStack(bool include_transitions) { } cur_depth_++; cur_shadow_frame_ = cur_shadow_frame_->GetLink(); - } while(cur_shadow_frame_ != NULL); + } while (cur_shadow_frame_ != NULL); } if (include_transitions) { bool should_continue = VisitFrame(); diff --git a/runtime/thread.cc b/runtime/thread.cc index a1fb862a17..fb50ed1ef3 100644 --- a/runtime/thread.cc +++ b/runtime/thread.cc @@ -1816,7 +1816,7 @@ class CatchBlockStackVisitor : public StackVisitor { m->GetDexMethodIndex(), m, m->GetAccessFlags(), false, true); verifier.Verify(); std::vector kinds = verifier.DescribeVRegs(dex_pc); - for(uint16_t reg = 0; reg < num_regs; reg++) { + for (uint16_t reg = 0; reg < num_regs; reg++) { VRegKind kind = static_cast(kinds.at(reg * 2)); switch (kind) { case kUndefined: diff --git a/runtime/thread.h b/runtime/thread.h index 64ff7c22fa..5c9e8c3ec7 100644 --- a/runtime/thread.h +++ b/runtime/thread.h @@ -104,7 +104,7 @@ class PACKED(4) Thread { static Thread* Current() { // We rely on Thread::Current returning NULL for a detached thread, so it's not obvious // that we can replace this with a direct %fs access on x86. - if(!is_started_) { + if (!is_started_) { return NULL; } else { void* thread = pthread_getspecific(Thread::pthread_key_self_); diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc index 59c38b4345..7aa835a387 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -468,7 +468,7 @@ void ThreadList::WaitForOtherNonDaemonThreadsToExit() { // Wait for another thread to exit before re-checking. thread_exit_cond_.Wait(self); } - } while(!all_threads_are_daemons); + } while (!all_threads_are_daemons); } void ThreadList::SuspendAllDaemonThreads() { diff --git a/runtime/trace.cc b/runtime/trace.cc index 32932907e5..2227b8dde7 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -230,7 +230,7 @@ void Trace::Start(const char* trace_filename, int trace_fd, int buffer_size, int // Create Trace object. { MutexLock mu(self, *Locks::trace_lock_); - if(the_trace_ != NULL) { + if (the_trace_ != NULL) { LOG(ERROR) << "Trace already in progress, ignoring this request"; } else { the_trace_ = new Trace(trace_file.release(), buffer_size, flags); diff --git a/runtime/utils.h b/runtime/utils.h index a08e46524b..72597f5ea4 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -352,18 +352,18 @@ bool IsValidOatFilename(const std::string& filename); class VoidFunctor { public: template - inline void operator () (A a) const { + inline void operator() (A a) const { UNUSED(a); } template - inline void operator () (A a, B b) const { + inline void operator() (A a, B b) const { UNUSED(a); UNUSED(b); } template - inline void operator () (A a, B b, C c) const { + inline void operator() (A a, B b, C c) const { UNUSED(a); UNUSED(b); UNUSED(c); diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index ff7f594501..59de9b34aa 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -1014,12 +1014,12 @@ bool MethodVerifier::VerifyCodeFlow() { verifier::MethodVerifier::SetDexGcMap(ref, *dex_gc_map); MethodVerifier::MethodSafeCastSet* method_to_safe_casts = GenerateSafeCastSet(); - if(method_to_safe_casts != NULL ) { + if (method_to_safe_casts != NULL) { SetSafeCastMap(ref, method_to_safe_casts); } MethodVerifier::PcToConcreteMethodMap* pc_to_concrete_method = GenerateDevirtMap(); - if(pc_to_concrete_method != NULL ) { + if (pc_to_concrete_method != NULL) { SetDevirtMap(ref, pc_to_concrete_method); } return true; @@ -1824,7 +1824,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { uint32_t instance_of_idx = 0; if (0 != work_insn_idx_) { instance_of_idx = work_insn_idx_ - 1; - while(0 != instance_of_idx && !insn_flags_[instance_of_idx].IsOpcode()) { + while (0 != instance_of_idx && !insn_flags_[instance_of_idx].IsOpcode()) { instance_of_idx--; } CHECK(insn_flags_[instance_of_idx].IsOpcode()); @@ -1854,7 +1854,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { // which is not done because of the multiple inheritance implications. const RegType& cast_type = ResolveClassAndCheckAccess(instance_of_inst->VRegC_22c()); - if(!cast_type.IsUnresolvedTypes() && !cast_type.GetClass()->IsInterface()) { + if (!cast_type.IsUnresolvedTypes() && !cast_type.GetClass()->IsInterface()) { RegisterLine* update_line = new RegisterLine(code_item_->registers_size_, this); if (inst->Opcode() == Instruction::IF_EQZ) { fallthrough_line.reset(update_line); @@ -1868,7 +1868,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { // register encoding space of instance-of, and propagate type information to the source // of the move-object. uint32_t move_idx = instance_of_idx - 1; - while(0 != move_idx && !insn_flags_[move_idx].IsOpcode()) { + while (0 != move_idx && !insn_flags_[move_idx].IsOpcode()) { move_idx--; } CHECK(insn_flags_[move_idx].IsOpcode()); @@ -3766,7 +3766,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { bool is_interface = (inst->Opcode() == Instruction::INVOKE_INTERFACE) || (inst->Opcode() == Instruction::INVOKE_INTERFACE_RANGE); - if(!is_interface && !is_virtual) { + if (!is_interface && !is_virtual) { continue; } // Get reg type for register holding the reference to the object that will be dispatched upon. @@ -3792,7 +3792,7 @@ MethodVerifier::PcToConcreteMethodMap* MethodVerifier::GenerateDevirtMap() { } mirror::AbstractMethod* abstract_method = dex_cache_->GetResolvedMethod(is_range ? inst->VRegB_3rc() : inst->VRegB_35c()); - if(abstract_method == NULL) { + if (abstract_method == NULL) { // If the method is not found in the cache this means that it was never found // by ResolveMethodAndCheckAccess() called when verifying invoke_*. continue; @@ -3986,7 +3986,7 @@ const MethodReference* MethodVerifier::GetDevirtMap(const MethodReference& ref, // Look up the PC in the map, get the concrete method to execute and return its reference. MethodVerifier::PcToConcreteMethodMap::const_iterator pc_to_concrete_method = it->second->find(dex_pc); - if(pc_to_concrete_method != it->second->end()) { + if (pc_to_concrete_method != it->second->end()) { return &(pc_to_concrete_method->second); } else { return NULL; diff --git a/runtime/verifier/reg_type.cc b/runtime/verifier/reg_type.cc index 1c61a29cee..8418928a83 100644 --- a/runtime/verifier/reg_type.cc +++ b/runtime/verifier/reg_type.cc @@ -211,7 +211,7 @@ void LongHiType::Destroy() { } LongLoType* LongLoType::GetInstance() { - CHECK (instance_ != NULL); + CHECK(instance_ != NULL); return instance_; } @@ -355,7 +355,7 @@ BooleanType* BooleanType::GetInstance() { } void BooleanType::Destroy() { - if(BooleanType::instance != NULL) { + if (BooleanType::instance != NULL) { delete instance; instance = NULL; } diff --git a/runtime/verifier/reg_type_cache.cc b/runtime/verifier/reg_type_cache.cc index 6013250835..22c585ca29 100644 --- a/runtime/verifier/reg_type_cache.cc +++ b/runtime/verifier/reg_type_cache.cc @@ -377,7 +377,7 @@ const RegType& RegTypeCache::FromUninitialized(const RegType& uninit_type) { entry = new UnresolvedReferenceType(descriptor.c_str(), entries_.size()); } else { mirror::Class* klass = uninit_type.GetClass(); - if(uninit_type.IsUninitializedThisReference() && !klass->IsFinal()) { + if (uninit_type.IsUninitializedThisReference() && !klass->IsFinal()) { // For uninitialized "this reference" look for reference types that are not precise. for (size_t i = primitive_count_; i < entries_.size(); i++) { RegType* cur_entry = entries_[i]; diff --git a/runtime/verifier/reg_type_cache.h b/runtime/verifier/reg_type_cache.h index 814dff79f6..24117586e3 100644 --- a/runtime/verifier/reg_type_cache.h +++ b/runtime/verifier/reg_type_cache.h @@ -44,7 +44,7 @@ class RegTypeCache { } ~RegTypeCache(); static void Init() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - if(!RegTypeCache::primitive_initialized_) { + if (!RegTypeCache::primitive_initialized_) { CHECK_EQ(RegTypeCache::primitive_count_, 0); CreatePrimitiveTypes(); CHECK_EQ(RegTypeCache::primitive_count_, kNumPrimitives); diff --git a/runtime/verifier/reg_type_test.cc b/runtime/verifier/reg_type_test.cc index d2c9dd6ba7..a24c3c9120 100644 --- a/runtime/verifier/reg_type_test.cc +++ b/runtime/verifier/reg_type_test.cc @@ -405,7 +405,7 @@ TEST_F(RegTypeReferenceTest, Dump) { std::string expected = "Unresolved Reference: java.lang.DoesNotExist"; EXPECT_EQ(expected, unresolved_ref.Dump()); expected = "Precise Reference: java.lang.String"; - EXPECT_EQ( expected, resolved_ref.Dump()); + EXPECT_EQ(expected, resolved_ref.Dump()); expected ="Uninitialized Reference: java.lang.String Allocation PC: 10"; EXPECT_EQ(expected, resolved_unintialiesd.Dump()); expected = "Unresolved And Uninitialized Reference: java.lang.DoesNotExist Allocation PC: 12"; diff --git a/test/ReferenceMap/stack_walk_refmap_jni.cc b/test/ReferenceMap/stack_walk_refmap_jni.cc index 492916ed90..ccdbffd338 100644 --- a/test/ReferenceMap/stack_walk_refmap_jni.cc +++ b/test/ReferenceMap/stack_walk_refmap_jni.cc @@ -33,8 +33,8 @@ namespace art { #define IS_IN_REF_BITMAP(mh, ref_bitmap, reg) \ - ( ((reg) < mh.GetCodeItem()->registers_size_) && \ - (( *((ref_bitmap) + (reg)/8) >> ((reg) % 8) ) & 0x01) ) + (((reg) < mh.GetCodeItem()->registers_size_) && \ + ((*((ref_bitmap) + (reg)/8) >> ((reg) % 8) ) & 0x01)) #define CHECK_REGS_CONTAIN_REFS(...) \ do { \ diff --git a/test/StackWalk/stack_walk_jni.cc b/test/StackWalk/stack_walk_jni.cc index fc156b15d1..d100c1071d 100644 --- a/test/StackWalk/stack_walk_jni.cc +++ b/test/StackWalk/stack_walk_jni.cc @@ -31,8 +31,8 @@ namespace art { #define REG(mh, reg_bitmap, reg) \ - ( ((reg) < mh.GetCodeItem()->registers_size_) && \ - (( *((reg_bitmap) + (reg)/8) >> ((reg) % 8) ) & 0x01) ) + (((reg) < mh.GetCodeItem()->registers_size_) && \ + ((*((reg_bitmap) + (reg)/8) >> ((reg) % 8) ) & 0x01)) #define CHECK_REGS(...) if (!IsShadowFrame()) { \ int t[] = {__VA_ARGS__}; \ diff --git a/tools/cpplint.py b/tools/cpplint.py index 30c712856e..da5a938fd3 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -1526,7 +1526,10 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error): # Note that we assume the contents of [] to be short enough that # they'll never need to wrap. if ( # Ignore control structures. - not Search(r'\b(if|for|while|switch|return|delete)\b', fncall) and + # BEGIN android-changed + # not Search(r'\b(if|for|while|switch|return|delete)\b', fncall) and + not Search(r'\b(if|for|while|switch|return|delete|new)\b', fncall) and + # END android-changed # Ignore pointers/references to functions. not Search(r' \([^)]+\)\([^)]*(\)|,$)', fncall) and # Ignore pointers/references to arrays. -- cgit v1.2.3-59-g8ed1b From 1895ea386ca78573302483f589ebabd8ce1480e7 Mon Sep 17 00:00:00 2001 From: Brian Carlstrom Date: Thu, 18 Jul 2013 13:28:37 -0700 Subject: Fix cpplint readability/fn_size issues Change-Id: I1efdb07a948a2af49db1a9d21ccab16dacc03a54 --- Android.mk | 2 +- compiler/dex/portable/mir_to_gbc.cc | 2 +- compiler/dex/quick/mir_to_lir.cc | 2 +- compiler/llvm/gbc_expander.cc | 2 +- runtime/disassembler_arm.cc | 2 +- runtime/disassembler_x86.cc | 5 ++--- runtime/interpreter/interpreter.cc | 2 +- runtime/verifier/method_verifier.cc | 2 +- tools/cpplint.py | 5 +++++ 9 files changed, 14 insertions(+), 10 deletions(-) (limited to 'tools/cpplint.py') diff --git a/Android.mk b/Android.mk index 66eb095a4b..ff08dca340 100644 --- a/Android.mk +++ b/Android.mk @@ -334,7 +334,7 @@ endif .PHONY: cpplint-art cpplint-art: ./art/tools/cpplint.py \ - --filter=-,+build/header_guard,+whitespace/braces,+whitespace/comma,+runtime/explicit,+whitespace/newline,+whitespace/parens,+build/namespaces \ + --filter=-,+build/header_guard,+whitespace/braces,+whitespace/comma,+runtime/explicit,+whitespace/newline,+whitespace/parens,+build/namespaces,+readability/fn_size \ $(shell find art -name *.h -o -name *$(ART_CPP_EXTENSION) | grep -v art/compiler/llvm/generated/) # "mm cpplint-art-aspirational" to see warnings we would like to fix diff --git a/compiler/dex/portable/mir_to_gbc.cc b/compiler/dex/portable/mir_to_gbc.cc index 85ffec50e7..ad7a6a88e9 100644 --- a/compiler/dex/portable/mir_to_gbc.cc +++ b/compiler/dex/portable/mir_to_gbc.cc @@ -1500,7 +1500,7 @@ bool MirConverter::ConvertMIRNode(MIR* mir, BasicBlock* bb, res = true; } return res; -} +} // NOLINT(readability/fn_size) void MirConverter::SetDexOffset(int32_t offset) { current_dalvik_offset_ = offset; diff --git a/compiler/dex/quick/mir_to_lir.cc b/compiler/dex/quick/mir_to_lir.cc index b758fb538e..74eaa661a8 100644 --- a/compiler/dex/quick/mir_to_lir.cc +++ b/compiler/dex/quick/mir_to_lir.cc @@ -655,7 +655,7 @@ void Mir2Lir::CompileDalvikInstruction(MIR* mir, BasicBlock* bb, LIR* label_list default: LOG(FATAL) << "Unexpected opcode: " << opcode; } -} +} // NOLINT(readability/fn_size) // Process extended MIR instructions void Mir2Lir::HandleExtendedMethodMIR(BasicBlock* bb, MIR* mir) { diff --git a/compiler/llvm/gbc_expander.cc b/compiler/llvm/gbc_expander.cc index a2c69988f8..a7793aec26 100644 --- a/compiler/llvm/gbc_expander.cc +++ b/compiler/llvm/gbc_expander.cc @@ -3791,7 +3791,7 @@ GBCExpanderPass::ExpandIntrinsic(IntrinsicHelper::IntrinsicId intr_id, } UNIMPLEMENTED(FATAL) << "Unexpected GBC intrinsic: " << static_cast(intr_id); return NULL; -} +} // NOLINT(readability/fn_size) } // anonymous namespace diff --git a/runtime/disassembler_arm.cc b/runtime/disassembler_arm.cc index 3c9cb6ecab..a7319a5486 100644 --- a/runtime/disassembler_arm.cc +++ b/runtime/disassembler_arm.cc @@ -1034,7 +1034,7 @@ size_t DisassemblerArm::DumpThumb32(std::ostream& os, const uint8_t* instr_ptr) os << StringPrintf("%p: %08x\t%-7s ", instr_ptr, instr, opcode.str().c_str()) << args.str() << '\n'; return 4; -} +} // NOLINT(readability/fn_size) size_t DisassemblerArm::DumpThumb16(std::ostream& os, const uint8_t* instr_ptr) { uint16_t instr = ReadU16(instr_ptr); diff --git a/runtime/disassembler_x86.cc b/runtime/disassembler_x86.cc index bda162a5a4..48f7b6b6e9 100644 --- a/runtime/disassembler_x86.cc +++ b/runtime/disassembler_x86.cc @@ -25,8 +25,7 @@ namespace art { namespace x86 { -DisassemblerX86::DisassemblerX86() { -} +DisassemblerX86::DisassemblerX86() {} size_t DisassemblerX86::Dump(std::ostream& os, const uint8_t* begin) { return DumpInstruction(os, begin); @@ -745,7 +744,7 @@ DISASSEMBLER_ENTRY(cmp, prefixed_opcode.str().c_str()) << args.str() << '\n'; return instr - begin_instr; -} +} // NOLINT(readability/fn_size) } // namespace x86 } // namespace art diff --git a/runtime/interpreter/interpreter.cc b/runtime/interpreter/interpreter.cc index f624aa4efe..09a0fc7364 100644 --- a/runtime/interpreter/interpreter.cc +++ b/runtime/interpreter/interpreter.cc @@ -2964,7 +2964,7 @@ static JValue ExecuteImpl(Thread* self, MethodHelper& mh, const DexFile::CodeIte UnexpectedOpcode(inst, mh); } } -} +} // NOLINT(readability/fn_size) static JValue Execute(Thread* self, MethodHelper& mh, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register) diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 59de9b34aa..f414b791ea 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -2696,7 +2696,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) { DCHECK(insn_flags_[*start_guess].IsOpcode()); return true; -} +} // NOLINT(readability/fn_size) const RegType& MethodVerifier::ResolveClassAndCheckAccess(uint32_t class_idx) { const char* descriptor = dex_file_->StringByTypeIdx(class_idx); diff --git a/tools/cpplint.py b/tools/cpplint.py index da5a938fd3..4f069b77ad 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -645,6 +645,11 @@ class _FunctionState(object): filename: The name of the current file. linenum: The number of the line to check. """ + # BEGIN android-added + if not self.in_a_function: + return + # END android-added + if Match(r'T(EST|est)', self.current_function): base_trigger = self._TEST_TRIGGER else: -- cgit v1.2.3-59-g8ed1b From 3b074e60b2b906e9da5257d09de62b14867cb48e Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Fri, 19 Jul 2013 16:51:57 -0700 Subject: readdir is safer than readdir_r. The upstream cpplint.py already made this change. Change-Id: I9614d51080557eab6730cffd476e01e7872729d0 --- tools/cpplint.py | 1 - 1 file changed, 1 deletion(-) (limited to 'tools/cpplint.py') diff --git a/tools/cpplint.py b/tools/cpplint.py index 4f069b77ad..0b5fb93536 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -1206,7 +1206,6 @@ threading_list = ( ('gmtime(', 'gmtime_r('), ('localtime(', 'localtime_r('), ('rand(', 'rand_r('), - ('readdir(', 'readdir_r('), ('strtok(', 'strtok_r('), ('ttyname(', 'ttyname_r('), ) -- cgit v1.2.3-59-g8ed1b From 02e25119b15a6f619f17db99f5d05124a5807ff3 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Wed, 14 Aug 2013 16:14:24 -0700 Subject: Fix up TODO: c++0x, update cpplint. Needed to update cpplint to handle const auto. Fixed a few cpplint errors that were being missed before. Replaced most of the TODO c++0x with ranged based loops. Loops which do not have a descriptive container name have a concrete type instead of auto. Change-Id: Id7cc0f27030f56057c544e94277300b3f298c9c5 --- compiler/driver/compiler_driver.cc | 12 +- compiler/elf_fixup.cc | 1 - compiler/image_writer.cc | 48 +- compiler/image_writer.h | 3 +- compiler/sea_ir/ir/regions_test.cc | 2 +- compiler/sea_ir/types/type_data_test.cc | 2 +- compiler/sea_ir/types/type_inference_visitor.cc | 4 +- compiler/sea_ir/types/type_inference_visitor.h | 2 +- .../sea_ir/types/type_inference_visitor_test.cc | 2 +- compiler/utils/assembler.h | 1 + oatdump/oatdump.cc | 37 +- runtime/base/histogram.h | 2 +- runtime/class_linker.cc | 49 +- runtime/debugger.cc | 13 +- runtime/dex_file_verifier.cc | 3 +- runtime/gc/accounting/gc_allocator.cc | 6 +- runtime/gc/accounting/gc_allocator.h | 6 +- runtime/gc/accounting/heap_bitmap-inl.h | 16 +- runtime/gc/accounting/heap_bitmap.cc | 46 +- runtime/gc/accounting/heap_bitmap.h | 16 +- runtime/gc/accounting/mod_union_table.cc | 149 +-- runtime/gc/collector/garbage_collector.cc | 13 +- runtime/gc/collector/mark_sweep.cc | 95 +- runtime/gc/collector/mark_sweep.h | 1 + runtime/gc/collector/partial_mark_sweep.cc | 6 +- runtime/gc/collector/partial_mark_sweep.h | 1 + runtime/gc/collector/sticky_mark_sweep.cc | 6 +- runtime/gc/collector/sticky_mark_sweep.h | 1 + runtime/gc/heap.cc | 81 +- runtime/indirect_reference_table.cc | 5 +- runtime/indirect_reference_table.h | 10 +- runtime/instrumentation.cc | 28 +- runtime/intern_table.cc | 15 +- runtime/intern_table_test.cc | 3 +- runtime/jni_internal.cc | 12 +- runtime/mirror/art_method.h | 1 + runtime/monitor.cc | 4 +- runtime/native/dalvik_system_DexFile.cc | 10 +- runtime/output_stream_test.cc | 2 +- runtime/reference_table.cc | 5 +- runtime/thread_list.cc | 57 +- runtime/thread_list.h | 2 - runtime/thread_pool.h | 3 + runtime/trace.cc | 7 +- runtime/verifier/method_verifier.h | 2 +- runtime/verifier/reg_type.cc | 8 +- runtime/verifier/reg_type.h | 1 + runtime/verifier/register_line.cc | 5 +- tools/cpplint.py | 1026 ++++++++++++++++---- 49 files changed, 1108 insertions(+), 722 deletions(-) (limited to 'tools/cpplint.py') diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index b8727fe103..0ef0428619 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -664,8 +664,7 @@ void CompilerDriver::LoadImageClasses(base::TimingLogger& timings) Thread* self = Thread::Current(); ScopedObjectAccess soa(self); ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); - typedef DescriptorSet::iterator It; // TODO: C++0x auto - for (It it = image_classes_->begin(), end = image_classes_->end(); it != end;) { + for (auto it = image_classes_->begin(), end = image_classes_->end(); it != end;) { std::string descriptor(*it); SirtRef klass(self, class_linker->FindSystemClass(descriptor.c_str())); if (klass.get() == NULL) { @@ -687,12 +686,9 @@ void CompilerDriver::LoadImageClasses(base::TimingLogger& timings) unresolved_exception_types.clear(); class_linker->VisitClasses(ResolveCatchBlockExceptionsClassVisitor, &unresolved_exception_types); - typedef std::set >::const_iterator It; // TODO: C++0x auto - for (It it = unresolved_exception_types.begin(), - end = unresolved_exception_types.end(); - it != end; ++it) { - uint16_t exception_type_idx = it->first; - const DexFile* dex_file = it->second; + for (const std::pair& exception_type : unresolved_exception_types) { + uint16_t exception_type_idx = exception_type.first; + const DexFile* dex_file = exception_type.second; mirror::DexCache* dex_cache = class_linker->FindDexCache(*dex_file); mirror:: ClassLoader* class_loader = NULL; SirtRef klass(self, class_linker->ResolveType(*dex_file, exception_type_idx, diff --git a/compiler/elf_fixup.cc b/compiler/elf_fixup.cc index 6c090fdbec..359c4936a6 100644 --- a/compiler/elf_fixup.cc +++ b/compiler/elf_fixup.cc @@ -80,7 +80,6 @@ bool ElfFixup::Fixup(File* file, uintptr_t oat_data_begin) { #define DT_MIPS_RLD_MAP 0x70000016 // d_ptr bool ElfFixup::FixupDynamic(ElfFile& elf_file, uintptr_t base_address) { - // TODO: C++0x auto. for (::llvm::ELF::Elf32_Word i = 0; i < elf_file.GetDynamicNum(); i++) { ::llvm::ELF::Elf32_Dyn& elf_dyn = elf_file.GetDynamic(i); ::llvm::ELF::Elf32_Word d_tag = elf_dyn.d_tag; diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 4e9ae54d8e..548ea9eee4 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -74,10 +74,7 @@ bool ImageWriter::Write(const std::string& image_filename, ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); const std::vector& all_dex_caches = class_linker->GetDexCaches(); - for (size_t i = 0; i < all_dex_caches.size(); i++) { - DexCache* dex_cache = all_dex_caches[i]; - dex_caches_.insert(dex_cache); - } + dex_caches_.insert(all_dex_caches.begin(), all_dex_caches.end()); UniquePtr oat_file(OS::OpenFileReadWrite(oat_filename.c_str())); if (oat_file.get() == NULL) { @@ -117,11 +114,7 @@ bool ImageWriter::Write(const std::string& image_filename, gc::Heap* heap = Runtime::Current()->GetHeap(); heap->CollectGarbage(false); // Remove garbage. // Trim size of alloc spaces. - const std::vector& spaces = heap->GetContinuousSpaces(); - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - gc::space::ContinuousSpace* space = *it; + for (const auto& space : heap->GetContinuousSpaces()) { if (space->IsDlMallocSpace()) { space->AsDlMallocSpace()->Trim(); } @@ -163,13 +156,8 @@ bool ImageWriter::Write(const std::string& image_filename, } bool ImageWriter::AllocMemory() { - gc::Heap* heap = Runtime::Current()->GetHeap(); - const std::vector& spaces = heap->GetContinuousSpaces(); size_t size = 0; - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - gc::space::ContinuousSpace* space = *it; + for (const auto& space : Runtime::Current()->GetHeap()->GetContinuousSpaces()) { if (space->IsDlMallocSpace()) { size += space->Size(); } @@ -203,9 +191,7 @@ void ImageWriter::ComputeEagerResolvedStringsCallback(Object* obj, void* arg) { String* string = obj->AsString(); const uint16_t* utf16_string = string->GetCharArray()->GetData() + string->GetOffset(); ImageWriter* writer = reinterpret_cast(arg); - typedef Set::const_iterator CacheIt; // TODO: C++0x auto - for (CacheIt it = writer->dex_caches_.begin(), end = writer->dex_caches_.end(); it != end; ++it) { - DexCache* dex_cache = *it; + for (DexCache* dex_cache : writer->dex_caches_) { const DexFile& dex_file = *dex_cache->GetDexFile(); const DexFile::StringId* string_id = dex_file.FindStringId(utf16_string); if (string_id != NULL) { @@ -251,16 +237,13 @@ void ImageWriter::PruneNonImageClasses() { class_linker->VisitClasses(NonImageClassesVisitor, &context); // Remove the undesired classes from the class roots. - typedef std::set::const_iterator ClassIt; // TODO: C++0x auto - for (ClassIt it = non_image_classes.begin(), end = non_image_classes.end(); it != end; ++it) { - class_linker->RemoveClass((*it).c_str(), NULL); + for (const std::string& it : non_image_classes) { + class_linker->RemoveClass(it.c_str(), NULL); } // Clear references to removed classes from the DexCaches. ArtMethod* resolution_method = runtime->GetResolutionMethod(); - typedef Set::const_iterator CacheIt; // TODO: C++0x auto - for (CacheIt it = dex_caches_.begin(), end = dex_caches_.end(); it != end; ++it) { - DexCache* dex_cache = *it; + for (DexCache* dex_cache : dex_caches_) { for (size_t i = 0; i < dex_cache->NumResolvedTypes(); i++) { Class* klass = dex_cache->GetResolvedType(i); if (klass != NULL && !IsImageClass(klass)) { @@ -324,9 +307,8 @@ void ImageWriter::CheckNonImageClassesRemovedCallback(Object* obj, void* arg) { void ImageWriter::DumpImageClasses() { CompilerDriver::DescriptorSet* image_classes = compiler_driver_.GetImageClasses(); CHECK(image_classes != NULL); - typedef std::set::const_iterator It; // TODO: C++0x auto - for (It it = image_classes->begin(), end = image_classes->end(); it != end; ++it) { - LOG(INFO) << " " << *it; + for (const std::string& image_class : *image_classes) { + LOG(INFO) << " " << image_class; } } @@ -368,9 +350,8 @@ ObjectArray* ImageWriter::CreateImageRoots() const { ObjectArray* dex_caches = ObjectArray::Alloc(self, object_array_class, dex_caches_.size()); int i = 0; - typedef Set::const_iterator It; // TODO: C++0x auto - for (It it = dex_caches_.begin(), end = dex_caches_.end(); it != end; ++it, ++i) { - dex_caches->Set(i, *it); + for (DexCache* dex_cache : dex_caches_) { + dex_caches->Set(i++, dex_cache); } // build an Object[] of the roots needed to restore the runtime @@ -403,7 +384,7 @@ void ImageWriter::CalculateNewObjectOffsets(size_t oat_loaded_size, size_t oat_d SirtRef > image_roots(self, CreateImageRoots()); gc::Heap* heap = Runtime::Current()->GetHeap(); - const std::vector& spaces = heap->GetContinuousSpaces(); + const auto& spaces = heap->GetContinuousSpaces(); DCHECK(!spaces.empty()); DCHECK_EQ(0U, image_end_); @@ -418,10 +399,7 @@ void ImageWriter::CalculateNewObjectOffsets(size_t oat_loaded_size, size_t oat_d // TODO: Add InOrderWalk to heap bitmap. const char* old = self->StartAssertNoThreadSuspension("ImageWriter"); DCHECK(heap->GetLargeObjectsSpace()->GetLiveObjects()->IsEmpty()); - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - gc::space::ContinuousSpace* space = *it; + for (const auto& space : spaces) { space->GetLiveBitmap()->InOrderWalk(CalculateNewObjectOffsetsCallback, this); DCHECK_LT(image_end_, image_->Size()); } diff --git a/compiler/image_writer.h b/compiler/image_writer.h index 750109d1d9..6a126b84ab 100644 --- a/compiler/image_writer.h +++ b/compiler/image_writer.h @@ -204,8 +204,7 @@ class ImageWriter { uint32_t quick_to_interpreter_bridge_offset_; // DexCaches seen while scanning for fixing up CodeAndDirectMethods - typedef std::set Set; - Set dex_caches_; + std::set dex_caches_; }; } // namespace art diff --git a/compiler/sea_ir/ir/regions_test.cc b/compiler/sea_ir/ir/regions_test.cc index 9813465db8..8ca51e4851 100644 --- a/compiler/sea_ir/ir/regions_test.cc +++ b/compiler/sea_ir/ir/regions_test.cc @@ -56,4 +56,4 @@ TEST_F(RegionsTest, Basics) { EXPECT_EQ(root, preds->at(0)); } -} // namespace art +} // namespace sea_ir diff --git a/compiler/sea_ir/types/type_data_test.cc b/compiler/sea_ir/types/type_data_test.cc index a66ebce38f..f7a5362fa4 100644 --- a/compiler/sea_ir/types/type_data_test.cc +++ b/compiler/sea_ir/types/type_data_test.cc @@ -38,4 +38,4 @@ TEST_F(TypeDataTest, Basics) { EXPECT_TRUE(byte_type == td.FindTypeOf(second_instruction_id)); } -} // namespace art +} // namespace sea_ir diff --git a/compiler/sea_ir/types/type_inference_visitor.cc b/compiler/sea_ir/types/type_inference_visitor.cc index 3da2fc1e2c..81a8f4d615 100644 --- a/compiler/sea_ir/types/type_inference_visitor.cc +++ b/compiler/sea_ir/types/type_inference_visitor.cc @@ -78,9 +78,9 @@ std::vector TypeInferenceVisitor::GetOperandTypes( const Type* TypeInferenceVisitor::MergeTypes(std::vector& types) const { const Type* type = NULL; - if (types.size()>0) { + if (types.size() > 0) { type = *(types.begin()); - if (types.size()>1) { + if (types.size() > 1) { for (std::vector::const_iterator cit = types.begin(); cit != types.end(); cit++) { if (!type->Equals(**cit)) { diff --git a/compiler/sea_ir/types/type_inference_visitor.h b/compiler/sea_ir/types/type_inference_visitor.h index 200b9f0253..4bdac38404 100644 --- a/compiler/sea_ir/types/type_inference_visitor.h +++ b/compiler/sea_ir/types/type_inference_visitor.h @@ -61,7 +61,7 @@ class TypeInferenceVisitor: public IRVisitor { std::vector GetOperandTypes(InstructionNode* instruction) const; const Type* GetType() { // TODO: Currently multiple defined types are not supported. - if (crt_type_.size()>0) { + if (!crt_type_.empty()) { const Type* single_type = crt_type_.at(0); crt_type_.clear(); return single_type; diff --git a/compiler/sea_ir/types/type_inference_visitor_test.cc b/compiler/sea_ir/types/type_inference_visitor_test.cc index 8a249ebceb..77acb3d277 100644 --- a/compiler/sea_ir/types/type_inference_visitor_test.cc +++ b/compiler/sea_ir/types/type_inference_visitor_test.cc @@ -130,4 +130,4 @@ TEST_F(TypeInferenceVisitorTest, GetOperandTypes) { } -} // namespace art +} // namespace sea_ir diff --git a/compiler/utils/assembler.h b/compiler/utils/assembler.h index 9d79002625..c9be4edbf8 100644 --- a/compiler/utils/assembler.h +++ b/compiler/utils/assembler.h @@ -137,6 +137,7 @@ class SlowPath { // Next in linked list of slow paths SlowPath *next_; + private: friend class AssemblerBuffer; DISALLOW_COPY_AND_ASSIGN(SlowPath); }; diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index fbfdfd9e8d..8bc787745b 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -736,13 +736,10 @@ class ImageDumper { oat_dumper_.reset(new OatDumper(host_prefix_, *oat_file)); - std::vector oat_dex_files = oat_file->GetOatDexFiles(); - for (size_t i = 0; i < oat_dex_files.size(); i++) { - const OatFile::OatDexFile* oat_dex_file = oat_dex_files[i]; + for (const OatFile::OatDexFile* oat_dex_file : oat_file->GetOatDexFiles()) { CHECK(oat_dex_file != NULL); - std::pair entry(oat_dex_file->GetDexFileLocation(), - oat_dex_file->FileSize()); - stats_.oat_dex_file_sizes.push_back(entry); + stats_.oat_dex_file_sizes.push_back(std::make_pair(oat_dex_file->GetDexFileLocation(), + oat_dex_file->FileSize())); } os << "OBJECTS:\n" << std::flush; @@ -761,10 +758,7 @@ class ImageDumper { std::ostream indent_os(&indent_filter); os_ = &indent_os; ReaderMutexLock mu(self, *Locks::heap_bitmap_lock_); - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - gc::space::Space* space = *it; + for (const auto& space : spaces) { if (space->IsImageSpace()) { gc::space::ImageSpace* image_space = space->AsImageSpace(); image_space->GetLiveBitmap()->Walk(ImageDumper::Callback, this); @@ -1263,16 +1257,16 @@ class ImageDumper { os << "object_bytes breakdown:\n"; size_t object_bytes_total = 0; - typedef SizeAndCountTable::const_iterator It; // TODO: C++0x auto - for (It it = sizes_and_counts.begin(), end = sizes_and_counts.end(); it != end; ++it) { - const std::string& descriptor(it->first); - double average = static_cast(it->second.bytes) / static_cast(it->second.count); - double percent = PercentOfObjectBytes(it->second.bytes); + for (const auto& sizes_and_count : sizes_and_counts) { + const std::string& descriptor(sizes_and_count.first); + double average = static_cast(sizes_and_count.second.bytes) / + static_cast(sizes_and_count.second.count); + double percent = PercentOfObjectBytes(sizes_and_count.second.bytes); os << StringPrintf("%32s %8zd bytes %6zd instances " "(%4.0f bytes/instance) %2.0f%% of object_bytes\n", - descriptor.c_str(), it->second.bytes, it->second.count, - average, percent); - object_bytes_total += it->second.bytes; + descriptor.c_str(), sizes_and_count.second.bytes, + sizes_and_count.second.count, average, percent); + object_bytes_total += sizes_and_count.second.bytes; } os << "\n" << std::flush; CHECK_EQ(object_bytes, object_bytes_total); @@ -1292,11 +1286,10 @@ class ImageDumper { large_initializer_code_bytes, PercentOfOatBytes(large_initializer_code_bytes), large_method_code_bytes, PercentOfOatBytes(large_method_code_bytes)) << "DexFile sizes:\n"; - typedef std::vector >::const_iterator It2; - for (It2 it = oat_dex_file_sizes.begin(); it != oat_dex_file_sizes.end(); - ++it) { + for (const std::pair& oat_dex_file_size : oat_dex_file_sizes) { os << StringPrintf("%s = %zd (%2.0f%% of oat file bytes)\n", - it->first.c_str(), it->second, PercentOfOatBytes(it->second)); + oat_dex_file_size.first.c_str(), oat_dex_file_size.second, + PercentOfOatBytes(oat_dex_file_size.second)); } os << "\n" << StringPrintf("gc_map_bytes = %7zd (%2.0f%% of oat file bytes)\n" diff --git a/runtime/base/histogram.h b/runtime/base/histogram.h index f508af993e..2a02cf4245 100644 --- a/runtime/base/histogram.h +++ b/runtime/base/histogram.h @@ -112,6 +112,6 @@ template class Histogram { DISALLOW_COPY_AND_ASSIGN(Histogram); }; -} +} // namespace art #endif // ART_RUNTIME_BASE_HISTOGRAM_H_ diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc index 039e7bc0a7..ef27321f0e 100644 --- a/runtime/class_linker.cc +++ b/runtime/class_linker.cc @@ -1111,16 +1111,15 @@ void ClassLinker::VisitRoots(RootVisitor* visitor, void* arg, bool clean_dirty) Thread* self = Thread::Current(); { ReaderMutexLock mu(self, dex_lock_); - for (size_t i = 0; i < dex_caches_.size(); i++) { - visitor(dex_caches_[i], arg); + for (mirror::DexCache* dex_cache : dex_caches_) { + visitor(dex_cache, arg); } } { ReaderMutexLock mu(self, *Locks::classlinker_classes_lock_); - typedef Table::const_iterator It; // TODO: C++0x auto - for (It it = classes_.begin(), end = classes_.end(); it != end; ++it) { - visitor(it->second, arg); + for (const std::pair& it : classes_) { + visitor(it.second, arg); } // We deliberately ignore the class roots in the image since we @@ -1135,14 +1134,13 @@ void ClassLinker::VisitRoots(RootVisitor* visitor, void* arg, bool clean_dirty) void ClassLinker::VisitClasses(ClassVisitor* visitor, void* arg) const { ReaderMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_); - typedef Table::const_iterator It; // TODO: C++0x auto - for (It it = classes_.begin(), end = classes_.end(); it != end; ++it) { - if (!visitor(it->second, arg)) { + for (const std::pair& it : classes_) { + if (!visitor(it.second, arg)) { return; } } - for (It it = image_classes_.begin(), end = image_classes_.end(); it != end; ++it) { - if (!visitor(it->second, arg)) { + for (const std::pair& it : image_classes_) { + if (!visitor(it.second, arg)) { return; } } @@ -1157,9 +1155,8 @@ static bool GetClassesVisitor(mirror::Class* c, void* arg) { void ClassLinker::VisitClassesWithoutClassesLock(ClassVisitor* visitor, void* arg) const { std::set classes; VisitClasses(GetClassesVisitor, &classes); - typedef std::set::const_iterator It; // TODO: C++0x auto - for (It it = classes.begin(), end = classes.end(); it != end; ++it) { - if (!visitor(*it, arg)) { + for (mirror::Class* klass : classes) { + if (!visitor(klass, arg)) { return; } } @@ -2160,10 +2157,9 @@ mirror::Class* ClassLinker::InsertClass(const StringPiece& descriptor, mirror::C bool ClassLinker::RemoveClass(const char* descriptor, const mirror::ClassLoader* class_loader) { size_t hash = Hash(descriptor); WriterMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_); - typedef Table::iterator It; // TODO: C++0x auto // TODO: determine if its better to search classes_ or image_classes_ first ClassHelper kh; - for (It it = classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; + for (auto it = classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; ++it) { mirror::Class* klass = it->second; kh.ChangeClass(klass); @@ -2172,7 +2168,7 @@ bool ClassLinker::RemoveClass(const char* descriptor, const mirror::ClassLoader* return true; } } - for (It it = image_classes_.lower_bound(hash), end = classes_.end(); + for (auto it = image_classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; ++it) { mirror::Class* klass = it->second; kh.ChangeClass(klass); @@ -2204,8 +2200,9 @@ mirror::Class* ClassLinker::LookupClassLocked(const char* descriptor, const mirror::ClassLoader* class_loader, size_t hash, const Table& classes) { ClassHelper kh(NULL, this); - typedef Table::const_iterator It; // TODO: C++0x auto - for (It it = classes.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; ++it) { + auto end = classes_.end(); + for (auto it = classes.lower_bound(hash); it != end && it->first == hash; + ++it) { mirror::Class* klass = it->second; kh.ChangeClass(klass); if (strcmp(descriptor, kh.GetDescriptor()) == 0 && klass->GetClassLoader() == class_loader) { @@ -2228,17 +2225,18 @@ void ClassLinker::LookupClasses(const char* descriptor, std::vectorfirst == hash; ++it) { + for (auto it = classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; + ++it) { mirror::Class* klass = it->second; kh.ChangeClass(klass); if (strcmp(descriptor, kh.GetDescriptor()) == 0) { classes.push_back(klass); } } - for (It it = image_classes_.lower_bound(hash), end = classes_.end(); it != end && it->first == hash; ++it) { + for (auto it = image_classes_.lower_bound(hash), end = classes_.end(); + it != end && it->first == hash; ++it) { mirror::Class* klass = it->second; kh.ChangeClass(klass); if (strcmp(descriptor, kh.GetDescriptor()) == 0) { @@ -3967,12 +3965,11 @@ void ClassLinker::DumpAllClasses(int flags) const { std::vector all_classes; { ReaderMutexLock mu(Thread::Current(), *Locks::classlinker_classes_lock_); - typedef Table::const_iterator It; // TODO: C++0x auto - for (It it = classes_.begin(), end = classes_.end(); it != end; ++it) { - all_classes.push_back(it->second); + for (const std::pair& it : classes_) { + all_classes.push_back(it.second); } - for (It it = image_classes_.begin(), end = image_classes_.end(); it != end; ++it) { - all_classes.push_back(it->second); + for (const std::pair& it : image_classes_) { + all_classes.push_back(it.second); } } diff --git a/runtime/debugger.cc b/runtime/debugger.cc index 569a370b3f..a72ae22d71 100644 --- a/runtime/debugger.cc +++ b/runtime/debugger.cc @@ -3033,9 +3033,8 @@ void Dbg::DdmSetThreadNotification(bool enable) { } { ScopedObjectAccess soa(self); - typedef std::list::const_iterator It; // TODO: C++0x auto - for (It it = threads.begin(), end = threads.end(); it != end; ++it) { - Dbg::DdmSendThreadNotification(*it, CHUNK_TYPE("THCR")); + for (Thread* thread : threads) { + Dbg::DdmSendThreadNotification(thread, CHUNK_TYPE("THCR")); } } ResumeVM(); @@ -3600,8 +3599,7 @@ class StringTable { } size_t IndexOf(const char* s) const { - typedef std::set::const_iterator It; // TODO: C++0x auto - It it = table_.find(s); + auto it = table_.find(s); if (it == table_.end()) { LOG(FATAL) << "IndexOf(\"" << s << "\") failed"; } @@ -3613,9 +3611,8 @@ class StringTable { } void WriteTo(std::vector& bytes) const { - typedef std::set::const_iterator It; // TODO: C++0x auto - for (It it = table_.begin(); it != table_.end(); ++it) { - const char* s = (*it).c_str(); + for (const std::string& str : table_) { + const char* s = str.c_str(); size_t s_len = CountModifiedUtf8Chars(s); UniquePtr s_utf16(new uint16_t[s_len]); ConvertModifiedUtf8ToUtf16(s_utf16.get(), s); diff --git a/runtime/dex_file_verifier.cc b/runtime/dex_file_verifier.cc index 09e929c2d0..5b076e07b7 100644 --- a/runtime/dex_file_verifier.cc +++ b/runtime/dex_file_verifier.cc @@ -1299,8 +1299,7 @@ bool DexFileVerifier::CheckIntraSection() { } bool DexFileVerifier::CheckOffsetToTypeMap(uint32_t offset, uint16_t type) { - typedef SafeMap::iterator It; // TODO: C++0x auto - It it = offset_to_type_map_.find(offset); + auto it = offset_to_type_map_.find(offset); if (it == offset_to_type_map_.end()) { LOG(ERROR) << StringPrintf("No data map entry found @ %x; expected %x", offset, type); return false; diff --git a/runtime/gc/accounting/gc_allocator.cc b/runtime/gc/accounting/gc_allocator.cc index 0b0d3edc1d..11d0e679b1 100644 --- a/runtime/gc/accounting/gc_allocator.cc +++ b/runtime/gc/accounting/gc_allocator.cc @@ -31,6 +31,6 @@ namespace accounting { Runtime::Current()->GetHeap()->RegisterGCDeAllocation(bytes); free(p); } -} -} -} +} // namespace accounting +} // namespace gc +} // namespace art diff --git a/runtime/gc/accounting/gc_allocator.h b/runtime/gc/accounting/gc_allocator.h index d1356a745c..1fba858882 100644 --- a/runtime/gc/accounting/gc_allocator.h +++ b/runtime/gc/accounting/gc_allocator.h @@ -75,8 +75,8 @@ namespace accounting { GCAllocatorImpl, std::allocator >::value { }; -} -} -} +} // namespace accounting +} // namespace gc +} // namespace art #endif // ART_RUNTIME_GC_ACCOUNTING_GC_ALLOCATOR_H_ diff --git a/runtime/gc/accounting/heap_bitmap-inl.h b/runtime/gc/accounting/heap_bitmap-inl.h index 0524ccb69c..18b93d43d6 100644 --- a/runtime/gc/accounting/heap_bitmap-inl.h +++ b/runtime/gc/accounting/heap_bitmap-inl.h @@ -25,20 +25,12 @@ namespace accounting { template inline void HeapBitmap::Visit(const Visitor& visitor) { - // TODO: C++0x auto - typedef SpaceBitmapVector::iterator It; - for (It it = continuous_space_bitmaps_.begin(), end = continuous_space_bitmaps_.end(); - it != end; ++it) { - SpaceBitmap* bitmap = *it; + for (const auto& bitmap : continuous_space_bitmaps_) { bitmap->VisitMarkedRange(bitmap->HeapBegin(), bitmap->HeapLimit(), visitor); } - // TODO: C++0x auto - typedef SpaceSetMapVector::iterator It2; - DCHECK(discontinuous_space_sets_.begin() != discontinuous_space_sets_.end()); - for (It2 it = discontinuous_space_sets_.begin(), end = discontinuous_space_sets_.end(); - it != end; ++it) { - SpaceSetMap* set = *it; - set->Visit(visitor); + DCHECK(!discontinuous_space_sets_.empty()); + for (const auto& space_set : discontinuous_space_sets_) { + space_set->Visit(visitor); } } diff --git a/runtime/gc/accounting/heap_bitmap.cc b/runtime/gc/accounting/heap_bitmap.cc index 046290513d..55894616b9 100644 --- a/runtime/gc/accounting/heap_bitmap.cc +++ b/runtime/gc/accounting/heap_bitmap.cc @@ -23,12 +23,9 @@ namespace gc { namespace accounting { void HeapBitmap::ReplaceBitmap(SpaceBitmap* old_bitmap, SpaceBitmap* new_bitmap) { - // TODO: C++0x auto - typedef SpaceBitmapVector::iterator It; - for (It it = continuous_space_bitmaps_.begin(), end = continuous_space_bitmaps_.end(); - it != end; ++it) { - if (*it == old_bitmap) { - *it = new_bitmap; + for (auto& bitmap : continuous_space_bitmaps_) { + if (bitmap == old_bitmap) { + bitmap = new_bitmap; return; } } @@ -36,12 +33,9 @@ void HeapBitmap::ReplaceBitmap(SpaceBitmap* old_bitmap, SpaceBitmap* new_bitmap) } void HeapBitmap::ReplaceObjectSet(SpaceSetMap* old_set, SpaceSetMap* new_set) { - // TODO: C++0x auto - typedef SpaceSetMapVector::iterator It; - for (It it = discontinuous_space_sets_.begin(), end = discontinuous_space_sets_.end(); - it != end; ++it) { - if (*it == old_set) { - *it = new_set; + for (auto& space_set : discontinuous_space_sets_) { + if (space_set == old_set) { + space_set = new_set; return; } } @@ -52,13 +46,10 @@ void HeapBitmap::AddContinuousSpaceBitmap(accounting::SpaceBitmap* bitmap) { DCHECK(bitmap != NULL); // Check for interval overlap. - typedef SpaceBitmapVector::iterator It; - for (It it = continuous_space_bitmaps_.begin(), end = continuous_space_bitmaps_.end(); - it != end; ++it) { - SpaceBitmap* bitmap = *it; - SpaceBitmap* cur_bitmap = *it; - CHECK(bitmap->HeapBegin() < cur_bitmap->HeapLimit() && - bitmap->HeapLimit() > cur_bitmap->HeapBegin()) + for (const auto& cur_bitmap : continuous_space_bitmaps_) { + CHECK(!( + bitmap->HeapBegin() < cur_bitmap->HeapLimit() && + bitmap->HeapLimit() > cur_bitmap->HeapBegin())) << "Bitmap " << bitmap->Dump() << " overlaps with existing bitmap " << cur_bitmap->Dump(); } continuous_space_bitmaps_.push_back(bitmap); @@ -70,20 +61,13 @@ void HeapBitmap::AddDiscontinuousObjectSet(SpaceSetMap* set) { } void HeapBitmap::Walk(SpaceBitmap::Callback* callback, void* arg) { - // TODO: C++0x auto - typedef SpaceBitmapVector::iterator It; - for (It it = continuous_space_bitmaps_.begin(), end = continuous_space_bitmaps_.end(); - it != end; ++it) { - SpaceBitmap* bitmap = *it; + for (const auto& bitmap : continuous_space_bitmaps_) { bitmap->Walk(callback, arg); } - // TODO: C++0x auto - typedef SpaceSetMapVector::iterator It2; - DCHECK(discontinuous_space_sets_.begin() != discontinuous_space_sets_.end()); - for (It2 it = discontinuous_space_sets_.begin(), end = discontinuous_space_sets_.end(); - it != end; ++it) { - SpaceSetMap* set = *it; - set->Walk(callback, arg); + + DCHECK(!discontinuous_space_sets_.empty()); + for (const auto& space_set : discontinuous_space_sets_) { + space_set->Walk(callback, arg); } } diff --git a/runtime/gc/accounting/heap_bitmap.h b/runtime/gc/accounting/heap_bitmap.h index ada976fff6..2ca8c4a82e 100644 --- a/runtime/gc/accounting/heap_bitmap.h +++ b/runtime/gc/accounting/heap_bitmap.h @@ -66,11 +66,7 @@ class HeapBitmap { } SpaceBitmap* GetContinuousSpaceBitmap(const mirror::Object* obj) { - // TODO: C++0x auto - typedef SpaceBitmapVector::iterator It; - for (It it = continuous_space_bitmaps_.begin(), end = continuous_space_bitmaps_.end(); - it != end; ++it) { - SpaceBitmap* bitmap = *it; + for (const auto& bitmap : continuous_space_bitmaps_) { if (bitmap->HasAddress(obj)) { return bitmap; } @@ -79,13 +75,9 @@ class HeapBitmap { } SpaceSetMap* GetDiscontinuousSpaceObjectSet(const mirror::Object* obj) { - // TODO: C++0x auto - typedef SpaceSetMapVector::iterator It; - for (It it = discontinuous_space_sets_.begin(), end = discontinuous_space_sets_.end(); - it != end; ++it) { - SpaceSetMap* set = *it; - if (set->Test(obj)) { - return set; + for (const auto& space_set : discontinuous_space_sets_) { + if (space_set->Test(obj)) { + return space_set; } } return NULL; diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc index 3bbc3810a0..486521951a 100644 --- a/runtime/gc/accounting/mod_union_table.cc +++ b/runtime/gc/accounting/mod_union_table.cc @@ -36,54 +36,6 @@ namespace art { namespace gc { namespace accounting { -class MarkIfReachesAllocspaceVisitor { - public: - explicit MarkIfReachesAllocspaceVisitor(Heap* const heap, accounting::SpaceBitmap* bitmap) - : heap_(heap), - bitmap_(bitmap) { - } - - // Extra parameters are required since we use this same visitor signature for checking objects. - void operator()(const Object* obj, const Object* ref, const MemberOffset& /* offset */, - bool /* is_static */) const { - // TODO: Optimize? - // TODO: C++0x auto - const std::vector& spaces = heap_->GetContinuousSpaces(); - typedef std::vector::const_iterator It; - for (It cur = spaces.begin(); cur != spaces.end(); ++cur) { - if ((*cur)->IsDlMallocSpace() && (*cur)->Contains(ref)) { - bitmap_->Set(obj); - break; - } - } - } - - private: - Heap* const heap_; - accounting::SpaceBitmap* const bitmap_; -}; - -class ModUnionVisitor { - public: - explicit ModUnionVisitor(Heap* const heap, accounting::SpaceBitmap* bitmap) - : heap_(heap), - bitmap_(bitmap) { - } - - void operator()(const Object* obj) const - SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, - Locks::mutator_lock_) { - DCHECK(obj != NULL); - // We don't have an early exit since we use the visitor pattern, an early exit should - // significantly speed this up. - MarkIfReachesAllocspaceVisitor visitor(heap_, bitmap_); - collector::MarkSweep::VisitObjectReferences(obj, visitor); - } - private: - Heap* const heap_; - accounting::SpaceBitmap* const bitmap_; -}; - class ModUnionClearCardSetVisitor { public: explicit ModUnionClearCardSetVisitor(ModUnionTable::CardSet* const cleared_cards) @@ -237,29 +189,23 @@ class ModUnionCheckReferences { void ModUnionTableReferenceCache::Verify() { // Start by checking that everything in the mod union table is marked. Heap* heap = GetHeap(); - typedef SafeMap >::const_iterator It; - typedef std::vector::const_iterator It2; - for (It it = references_.begin(), end = references_.end(); it != end; ++it) { - for (It2 it_ref = it->second.begin(), end_ref = it->second.end(); it_ref != end_ref; - ++it_ref ) { - CHECK(heap->IsLiveObjectLocked(*it_ref)); + for (const std::pair >& it : references_) { + for (const Object* ref : it.second) { + CHECK(heap->IsLiveObjectLocked(ref)); } } // Check the references of each clean card which is also in the mod union table. CardTable* card_table = heap->GetCardTable(); - for (It it = references_.begin(); it != references_.end(); ++it) { - const byte* card = &*it->first; + for (const std::pair > & it : references_) { + const byte* card = it.first; if (*card == CardTable::kCardClean) { - std::set reference_set; - for (It2 itr = it->second.begin(); itr != it->second.end(); ++itr) { - reference_set.insert(*itr); - } + std::set reference_set(it.second.begin(), it.second.end()); ModUnionCheckReferences visitor(this, reference_set); uintptr_t start = reinterpret_cast(card_table->AddrFromCard(card)); uintptr_t end = start + CardTable::kCardSize; - space::ContinuousSpace* space = - heap->FindContinuousSpaceFromObject(reinterpret_cast(start), false); + auto* space = heap->FindContinuousSpaceFromObject(reinterpret_cast(start), false); + DCHECK(space != nullptr); SpaceBitmap* live_bitmap = space->GetLiveBitmap(); live_bitmap->VisitMarkedRange(start, end, visitor); } @@ -268,24 +214,20 @@ void ModUnionTableReferenceCache::Verify() { void ModUnionTableReferenceCache::Dump(std::ostream& os) { CardTable* card_table = heap_->GetCardTable(); - typedef std::set::const_iterator It; os << "ModUnionTable cleared cards: ["; - for (It it = cleared_cards_.begin(); it != cleared_cards_.end(); ++it) { - byte* card = *it; - uintptr_t start = reinterpret_cast(card_table->AddrFromCard(card)); + for (byte* card_addr : cleared_cards_) { + uintptr_t start = reinterpret_cast(card_table->AddrFromCard(card_addr)); uintptr_t end = start + CardTable::kCardSize; os << reinterpret_cast(start) << "-" << reinterpret_cast(end) << ","; } os << "]\nModUnionTable references: ["; - typedef SafeMap >::const_iterator It2; - for (It2 it = references_.begin(); it != references_.end(); ++it) { - const byte* card = &*it->first; - uintptr_t start = reinterpret_cast(card_table->AddrFromCard(card)); + for (const std::pair >& it : references_) { + const byte* card_addr = it.first; + uintptr_t start = reinterpret_cast(card_table->AddrFromCard(card_addr)); uintptr_t end = start + CardTable::kCardSize; os << reinterpret_cast(start) << "-" << reinterpret_cast(end) << "->{"; - typedef std::vector::const_iterator It3; - for (It3 itr = it->second.begin(); itr != it->second.end(); ++itr) { - os << reinterpret_cast(*itr) << ","; + for (const mirror::Object* ref : it.second) { + os << reinterpret_cast(ref) << ","; } os << "},"; } @@ -298,20 +240,18 @@ void ModUnionTableReferenceCache::Update() { std::vector cards_references; ModUnionReferenceVisitor visitor(this, &cards_references); - typedef std::set::iterator It; - for (It it = cleared_cards_.begin(), cc_end = cleared_cards_.end(); it != cc_end; ++it) { - byte* card = *it; + for (const auto& card : cleared_cards_) { // Clear and re-compute alloc space references associated with this card. cards_references.clear(); uintptr_t start = reinterpret_cast(card_table->AddrFromCard(card)); uintptr_t end = start + CardTable::kCardSize; - SpaceBitmap* live_bitmap = - heap->FindContinuousSpaceFromObject(reinterpret_cast(start), false)->GetLiveBitmap(); + auto* space = heap->FindContinuousSpaceFromObject(reinterpret_cast(start), false); + DCHECK(space != nullptr); + SpaceBitmap* live_bitmap = space->GetLiveBitmap(); live_bitmap->VisitMarkedRange(start, end, visitor); // Update the corresponding references for the card. - // TODO: C++0x auto - SafeMap >::iterator found = references_.find(card); + auto found = references_.find(card); if (found == references_.end()) { if (cards_references.empty()) { // No reason to add empty array. @@ -326,14 +266,11 @@ void ModUnionTableReferenceCache::Update() { } void ModUnionTableReferenceCache::MarkReferences(collector::MarkSweep* mark_sweep) { - // TODO: C++0x auto size_t count = 0; - typedef SafeMap >::const_iterator It; - for (It it = references_.begin(); it != references_.end(); ++it) { - typedef std::vector::const_iterator It2; - for (It2 it_ref = it->second.begin(); it_ref != it->second.end(); ++it_ref) { - mark_sweep->MarkRoot(*it_ref); + for (const auto& ref : references_) { + for (const auto& obj : ref.second) { + mark_sweep->MarkRoot(obj); ++count; } } @@ -353,38 +290,28 @@ void ModUnionTableCardCache::ClearCards(space::ContinuousSpace* space) { void ModUnionTableCardCache::MarkReferences(collector::MarkSweep* mark_sweep) { CardTable* card_table = heap_->GetCardTable(); ModUnionScanImageRootVisitor visitor(mark_sweep); - typedef std::set::const_iterator It; - It it = cleared_cards_.begin(); - It cc_end = cleared_cards_.end(); - if (it != cc_end) { - byte* card = *it; - uintptr_t start = reinterpret_cast(card_table->AddrFromCard(card)); - uintptr_t end = start + CardTable::kCardSize; - space::ContinuousSpace* cur_space = - heap_->FindContinuousSpaceFromObject(reinterpret_cast(start), false); - accounting::SpaceBitmap* cur_live_bitmap = cur_space->GetLiveBitmap(); - cur_live_bitmap->VisitMarkedRange(start, end, visitor); - for (++it; it != cc_end; ++it) { - card = *it; - start = reinterpret_cast(card_table->AddrFromCard(card)); - end = start + CardTable::kCardSize; - if (UNLIKELY(!cur_space->Contains(reinterpret_cast(start)))) { - cur_space = heap_->FindContinuousSpaceFromObject(reinterpret_cast(start), false); - cur_live_bitmap = cur_space->GetLiveBitmap(); - } - cur_live_bitmap->VisitMarkedRange(start, end, visitor); + space::ContinuousSpace* space = nullptr; + SpaceBitmap* bitmap = nullptr; + for (const byte* card_addr : cleared_cards_) { + auto start = reinterpret_cast(card_table->AddrFromCard(card_addr)); + auto end = start + CardTable::kCardSize; + auto obj_start = reinterpret_cast(start); + if (UNLIKELY(space == nullptr || !space->Contains(obj_start))) { + space = heap_->FindContinuousSpaceFromObject(obj_start, false); + DCHECK(space != nullptr); + bitmap = space->GetLiveBitmap(); + DCHECK(bitmap != nullptr); } + bitmap->VisitMarkedRange(start, end, visitor); } } void ModUnionTableCardCache::Dump(std::ostream& os) { CardTable* card_table = heap_->GetCardTable(); - typedef std::set::const_iterator It; os << "ModUnionTable dirty cards: ["; - for (It it = cleared_cards_.begin(); it != cleared_cards_.end(); ++it) { - byte* card = *it; - uintptr_t start = reinterpret_cast(card_table->AddrFromCard(card)); - uintptr_t end = start + CardTable::kCardSize; + for (const byte* card_addr : cleared_cards_) { + auto start = reinterpret_cast(card_table->AddrFromCard(card_addr)); + auto end = start + CardTable::kCardSize; os << reinterpret_cast(start) << "-" << reinterpret_cast(end) << ","; } os << "]"; diff --git a/runtime/gc/collector/garbage_collector.cc b/runtime/gc/collector/garbage_collector.cc index 378a971250..926013753d 100644 --- a/runtime/gc/collector/garbage_collector.cc +++ b/runtime/gc/collector/garbage_collector.cc @@ -114,11 +114,7 @@ void GarbageCollector::SwapBitmaps() { // these bitmaps. The bitmap swapping is an optimization so that we do not need to clear the live // bits of dead objects in the live bitmap. const GcType gc_type = GetGcType(); - const std::vector& cont_spaces = GetHeap()->GetContinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = cont_spaces.begin(), end = cont_spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { // We never allocate into zygote spaces. if (space->GetGcRetentionPolicy() == space::kGcRetentionPolicyAlwaysCollect || (gc_type == kGcTypeFull && @@ -132,11 +128,8 @@ void GarbageCollector::SwapBitmaps() { } } } - const std::vector& disc_spaces = GetHeap()->GetDiscontinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It2; - for (It2 it = disc_spaces.begin(), end = disc_spaces.end(); it != end; ++it) { - space::LargeObjectSpace* space = down_cast(*it); + for (const auto& disc_space : GetHeap()->GetDiscontinuousSpaces()) { + space::LargeObjectSpace* space = down_cast(disc_space); accounting::SpaceSetMap* live_set = space->GetLiveObjects(); accounting::SpaceSetMap* mark_set = space->GetMarkObjects(); heap_->GetLiveBitmap()->ReplaceObjectSet(live_set, mark_set); diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc index 61570ae393..e93bcd1a05 100644 --- a/runtime/gc/collector/mark_sweep.cc +++ b/runtime/gc/collector/mark_sweep.cc @@ -84,16 +84,13 @@ void MarkSweep::ImmuneSpace(space::ContinuousSpace* space) { SetImmuneRange(reinterpret_cast(space->Begin()), reinterpret_cast(space->End())); } else { - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); - const space::ContinuousSpace* prev_space = NULL; + const space::ContinuousSpace* prev_space = nullptr; // Find out if the previous space is immune. - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - if (*it == space) { + for (space::ContinuousSpace* cur_space : GetHeap()->GetContinuousSpaces()) { + if (cur_space == space) { break; } - prev_space = *it; + prev_space = cur_space; } // If previous space was immune, then extend the immune region. Relies on continuous spaces @@ -322,13 +319,9 @@ void MarkSweep::SetImmuneRange(Object* begin, Object* end) { void MarkSweep::FindDefaultMarkBitmap() { base::TimingLogger::ScopedSplit split("FindDefaultMarkBitmap", &timings_); - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { if (space->GetGcRetentionPolicy() == space::kGcRetentionPolicyAlwaysCollect) { - current_mark_bitmap_ = (*it)->GetMarkBitmap(); + current_mark_bitmap_ = space->GetMarkBitmap(); CHECK(current_mark_bitmap_ != NULL); return; } @@ -344,11 +337,10 @@ void MarkSweep::ExpandMarkStack() { // Someone else acquired the lock and expanded the mark stack before us. return; } - std::vector temp; - temp.insert(temp.begin(), mark_stack_->Begin(), mark_stack_->End()); + std::vector temp(mark_stack_->Begin(), mark_stack_->End()); mark_stack_->Resize(mark_stack_->Capacity() * 2); - for (size_t i = 0; i < temp.size(); ++i) { - mark_stack_->PushBack(temp[i]); + for (const auto& obj : temp) { + mark_stack_->PushBack(obj); } } @@ -608,12 +600,8 @@ class ScanObjectVisitor { void MarkSweep::ScanGrayObjects(byte minimum_age) { accounting::CardTable* card_table = GetHeap()->GetCardTable(); - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); ScanObjectVisitor visitor(this); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), space_end = spaces.end(); it != space_end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { switch (space->GetGcRetentionPolicy()) { case space::kGcRetentionPolicyNeverCollect: timings_.StartSplit("ScanGrayImageSpaceObjects"); @@ -656,15 +644,12 @@ void MarkSweep::VerifyImageRoots() { // space timings_.StartSplit("VerifyImageRoots"); CheckBitmapVisitor visitor(this); - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - if ((*it)->IsImageSpace()) { - space::ImageSpace* space = (*it)->AsImageSpace(); - uintptr_t begin = reinterpret_cast(space->Begin()); - uintptr_t end = reinterpret_cast(space->End()); - accounting::SpaceBitmap* live_bitmap = space->GetLiveBitmap(); + for (const auto& space : GetHeap()->GetContinuousSpaces()) { + if (space->IsImageSpace()) { + space::ImageSpace* image_space = space->AsImageSpace(); + uintptr_t begin = reinterpret_cast(image_space->Begin()); + uintptr_t end = reinterpret_cast(image_space->End()); + accounting::SpaceBitmap* live_bitmap = image_space->GetLiveBitmap(); DCHECK(live_bitmap != NULL); live_bitmap->VisitMarkedRange(begin, end, visitor); } @@ -687,11 +672,7 @@ void MarkSweep::RecursiveMark() { const bool partial = GetGcType() == kGcTypePartial; ScanObjectVisitor scan_visitor(this); if (!kDisableFinger) { - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { if ((space->GetGcRetentionPolicy() == space::kGcRetentionPolicyAlwaysCollect) || (!partial && space->GetGcRetentionPolicy() == space::kGcRetentionPolicyFullCollect)) { current_mark_bitmap_ = space->GetMarkBitmap(); @@ -729,10 +710,7 @@ void MarkSweep::ReMarkRoots() { void MarkSweep::SweepJniWeakGlobals(IsMarkedTester is_marked, void* arg) { JavaVMExt* vm = Runtime::Current()->GetJavaVM(); MutexLock mu(Thread::Current(), vm->weak_globals_lock); - IndirectReferenceTable* table = &vm->weak_globals; - typedef IndirectReferenceTable::iterator It; // TODO: C++0x auto - for (It it = table->begin(), end = table->end(); it != end; ++it) { - const Object** entry = *it; + for (const Object** entry : vm->weak_globals) { if (!is_marked(*entry, arg)) { *entry = kClearedJniWeakGlobal; } @@ -815,10 +793,7 @@ void MarkSweep::VerifySystemWeaks() { JavaVMExt* vm = runtime->GetJavaVM(); MutexLock mu(Thread::Current(), vm->weak_globals_lock); - IndirectReferenceTable* table = &vm->weak_globals; - typedef IndirectReferenceTable::iterator It; // TODO: C++0x auto - for (It it = table->begin(), end = table->end(); it != end; ++it) { - const Object** entry = *it; + for (const Object** entry : vm->weak_globals) { VerifyIsLive(*entry); } } @@ -988,11 +963,7 @@ void MarkSweep::Sweep(bool swap_bitmaps) { SweepCallbackContext scc; scc.mark_sweep = this; scc.self = Thread::Current(); - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { // We always sweep always collect spaces. bool sweep_space = (space->GetGcRetentionPolicy() == space::kGcRetentionPolicyAlwaysCollect); if (!partial && !sweep_space) { @@ -1040,11 +1011,9 @@ void MarkSweep::SweepLargeObjects(bool swap_bitmaps) { size_t freed_objects = 0; size_t freed_bytes = 0; Thread* self = Thread::Current(); - // TODO: C++0x - typedef accounting::SpaceSetMap::Objects::iterator It; - for (It it = live_objects.begin(), end = live_objects.end(); it != end; ++it) { - if (!large_mark_objects->Test(*it)) { - freed_bytes += large_object_space->Free(self, const_cast(*it)); + for (const Object* obj : live_objects) { + if (!large_mark_objects->Test(obj)) { + freed_bytes += large_object_space->Free(self, const_cast(obj)); ++freed_objects; } } @@ -1054,11 +1023,7 @@ void MarkSweep::SweepLargeObjects(bool swap_bitmaps) { } void MarkSweep::CheckReference(const Object* obj, const Object* ref, MemberOffset offset, bool is_static) { - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { if (space->IsDlMallocSpace() && space->Contains(ref)) { DCHECK(IsMarked(obj)); @@ -1508,11 +1473,7 @@ void MarkSweep::ProcessReferences(Object** soft_references, bool clear_soft, void MarkSweep::UnBindBitmaps() { base::TimingLogger::ScopedSplit split("UnBindBitmaps", &timings_); - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { if (space->IsDlMallocSpace()) { space::DlMallocSpace* alloc_space = space->AsDlMallocSpace(); if (alloc_space->temp_bitmap_.get() != NULL) { @@ -1585,11 +1546,7 @@ void MarkSweep::FinishPhase() { cumulative_timings_.End(); // Clear all of the spaces' mark bitmaps. - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { if (space->GetGcRetentionPolicy() != space::kGcRetentionPolicyNeverCollect) { space->GetMarkBitmap()->Clear(); } diff --git a/runtime/gc/collector/mark_sweep.h b/runtime/gc/collector/mark_sweep.h index e39e2f7e8f..8db03d3fb0 100644 --- a/runtime/gc/collector/mark_sweep.h +++ b/runtime/gc/collector/mark_sweep.h @@ -428,6 +428,7 @@ class MarkSweep : public GarbageCollector { bool clear_soft_references_; + private: friend class AddIfReachesAllocSpaceVisitor; // Used by mod-union table. friend class CheckBitmapVisitor; friend class CheckObjectVisitor; diff --git a/runtime/gc/collector/partial_mark_sweep.cc b/runtime/gc/collector/partial_mark_sweep.cc index ef893c50b0..cc3cfe544d 100644 --- a/runtime/gc/collector/partial_mark_sweep.cc +++ b/runtime/gc/collector/partial_mark_sweep.cc @@ -33,14 +33,10 @@ PartialMarkSweep::PartialMarkSweep(Heap* heap, bool is_concurrent, const std::st void PartialMarkSweep::BindBitmaps() { MarkSweep::BindBitmaps(); - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); WriterMutexLock mu(Thread::Current(), *Locks::heap_bitmap_lock_); // For partial GCs we need to bind the bitmap of the zygote space so that all objects in the // zygote space are viewed as marked. - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { if (space->GetGcRetentionPolicy() == space::kGcRetentionPolicyFullCollect) { CHECK(space->IsZygoteSpace()); ImmuneSpace(space); diff --git a/runtime/gc/collector/partial_mark_sweep.h b/runtime/gc/collector/partial_mark_sweep.h index 25304b999a..3b788f4683 100644 --- a/runtime/gc/collector/partial_mark_sweep.h +++ b/runtime/gc/collector/partial_mark_sweep.h @@ -38,6 +38,7 @@ class PartialMarkSweep : public MarkSweep { // collections, ie the Zygote space. Also mark this space is immune. virtual void BindBitmaps() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + private: DISALLOW_COPY_AND_ASSIGN(PartialMarkSweep); }; diff --git a/runtime/gc/collector/sticky_mark_sweep.cc b/runtime/gc/collector/sticky_mark_sweep.cc index aad7c2973f..008d3e00b5 100644 --- a/runtime/gc/collector/sticky_mark_sweep.cc +++ b/runtime/gc/collector/sticky_mark_sweep.cc @@ -33,15 +33,11 @@ StickyMarkSweep::StickyMarkSweep(Heap* heap, bool is_concurrent, const std::stri void StickyMarkSweep::BindBitmaps() { PartialMarkSweep::BindBitmaps(); - const std::vector& spaces = GetHeap()->GetContinuousSpaces(); WriterMutexLock mu(Thread::Current(), *Locks::heap_bitmap_lock_); // For sticky GC, we want to bind the bitmaps of all spaces as the allocation stack lets us // know what was allocated since the last GC. A side-effect of binding the allocation space mark // and live bitmap is that marking the objects will place them in the live bitmap. - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : GetHeap()->GetContinuousSpaces()) { if (space->GetGcRetentionPolicy() == space::kGcRetentionPolicyAlwaysCollect) { BindLiveToMarkBitmap(space); } diff --git a/runtime/gc/collector/sticky_mark_sweep.h b/runtime/gc/collector/sticky_mark_sweep.h index e009b62c4b..2099c7929b 100644 --- a/runtime/gc/collector/sticky_mark_sweep.h +++ b/runtime/gc/collector/sticky_mark_sweep.h @@ -45,6 +45,7 @@ class StickyMarkSweep : public PartialMarkSweep { void Sweep(bool swap_bitmaps) EXCLUSIVE_LOCKS_REQUIRED(Locks::heap_bitmap_lock_); + private: DISALLOW_COPY_AND_ASSIGN(StickyMarkSweep); }; diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index a2453b8405..d5a8d75b87 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -183,11 +183,8 @@ Heap::Heap(size_t initial_size, size_t growth_limit, size_t min_free, size_t max heap_capacity += continuous_spaces_.back()->AsDlMallocSpace()->NonGrowthLimitCapacity(); } - // Mark image objects in the live bitmap - // TODO: C++0x - typedef std::vector::iterator It; - for (It it = continuous_spaces_.begin(); it != continuous_spaces_.end(); ++it) { - space::ContinuousSpace* space = *it; + // Mark image objects in the live bitmap. + for (const auto& space : continuous_spaces_) { if (space->IsImageSpace()) { space::ImageSpace* image_space = space->AsImageSpace(); image_space->RecordImageAllocations(image_space->GetLiveBitmap()); @@ -393,9 +390,7 @@ void Heap::AddContinuousSpace(space::ContinuousSpace* space) { // Ensure that ImageSpaces < ZygoteSpaces < AllocSpaces so that we can do address based checks to // avoid redundant marking. bool seen_zygote = false, seen_alloc = false; - typedef std::vector::const_iterator It; - for (It it = continuous_spaces_.begin(); it != continuous_spaces_.end(); ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : continuous_spaces_) { if (space->IsImageSpace()) { DCHECK(!seen_zygote); DCHECK(!seen_alloc); @@ -436,17 +431,13 @@ void Heap::DumpGcPerformanceInfo(std::ostream& os) { uint64_t total_duration = 0; // Dump cumulative loggers for each GC type. - // TODO: C++0x uint64_t total_paused_time = 0; - typedef std::vector::const_iterator It; - for (It it = mark_sweep_collectors_.begin(); - it != mark_sweep_collectors_.end(); ++it) { - collector::MarkSweep* collector = *it; + for (const auto& collector : mark_sweep_collectors_) { CumulativeLogger& logger = collector->GetCumulativeTimings(); if (logger.GetTotalNs() != 0) { os << Dumpable(logger); const uint64_t total_ns = logger.GetTotalNs(); - const uint64_t total_pause_ns = (*it)->GetTotalPausedTimeNs(); + const uint64_t total_pause_ns = collector->GetTotalPausedTimeNs(); double seconds = NsToMs(logger.GetTotalNs()) / 1000.0; const uint64_t freed_bytes = collector->GetTotalFreedBytes(); const uint64_t freed_objects = collector->GetTotalFreedObjects(); @@ -507,11 +498,9 @@ Heap::~Heap() { space::ContinuousSpace* Heap::FindContinuousSpaceFromObject(const mirror::Object* obj, bool fail_ok) const { - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = continuous_spaces_.begin(), end = continuous_spaces_.end(); it != end; ++it) { - if ((*it)->Contains(obj)) { - return *it; + for (const auto& space : continuous_spaces_) { + if (space->Contains(obj)) { + return space; } } if (!fail_ok) { @@ -522,11 +511,9 @@ space::ContinuousSpace* Heap::FindContinuousSpaceFromObject(const mirror::Object space::DiscontinuousSpace* Heap::FindDiscontinuousSpaceFromObject(const mirror::Object* obj, bool fail_ok) const { - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = discontinuous_spaces_.begin(), end = discontinuous_spaces_.end(); it != end; ++it) { - if ((*it)->Contains(obj)) { - return *it; + for (const auto& space : discontinuous_spaces_) { + if (space->Contains(obj)) { + return space; } } if (!fail_ok) { @@ -544,11 +531,9 @@ space::Space* Heap::FindSpaceFromObject(const mirror::Object* obj, bool fail_ok) } space::ImageSpace* Heap::GetImageSpace() const { - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = continuous_spaces_.begin(), end = continuous_spaces_.end(); it != end; ++it) { - if ((*it)->IsImageSpace()) { - return (*it)->AsImageSpace(); + for (const auto& space : continuous_spaces_) { + if (space->IsImageSpace()) { + return space->AsImageSpace(); } } return NULL; @@ -627,10 +612,7 @@ mirror::Object* Heap::AllocObject(Thread* self, mirror::Class* c, size_t byte_co // If the allocation failed due to fragmentation, print out the largest continuous allocation. if (!large_object_allocation && total_bytes_free >= byte_count) { size_t max_contiguous_allocation = 0; - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = continuous_spaces_.begin(), end = continuous_spaces_.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : continuous_spaces_) { if (space->IsDlMallocSpace()) { space->AsDlMallocSpace()->Walk(MSpaceChunkCallback, &max_contiguous_allocation); } @@ -706,19 +688,14 @@ void Heap::VerifyObjectImpl(const mirror::Object* obj) { } void Heap::DumpSpaces() { - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = continuous_spaces_.begin(), end = continuous_spaces_.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : continuous_spaces_) { accounting::SpaceBitmap* live_bitmap = space->GetLiveBitmap(); accounting::SpaceBitmap* mark_bitmap = space->GetMarkBitmap(); LOG(INFO) << space << " " << *space << "\n" << live_bitmap << " " << *live_bitmap << "\n" << mark_bitmap << " " << *mark_bitmap; } - typedef std::vector::const_iterator It2; - for (It2 it = discontinuous_spaces_.begin(), end = discontinuous_spaces_.end(); it != end; ++it) { - space::DiscontinuousSpace* space = *it; + for (const auto& space : discontinuous_spaces_) { LOG(INFO) << space << " " << *space << "\n"; } } @@ -1143,11 +1120,8 @@ void Heap::PreZygoteFork() { have_zygote_space_ = true; // Reset the cumulative loggers since we now have a few additional timing phases. - // TODO: C++0x - typedef std::vector::const_iterator It; - for (It it = mark_sweep_collectors_.begin(), end = mark_sweep_collectors_.end(); - it != end; ++it) { - (*it)->ResetCumulativeStatistics(); + for (const auto& collector : mark_sweep_collectors_) { + collector->ResetCumulativeStatistics(); } } @@ -1238,10 +1212,7 @@ collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type, GcCaus ATRACE_BEGIN(gc_cause_and_type_strings[gc_cause][gc_type]); collector::MarkSweep* collector = NULL; - typedef std::vector::iterator It; - for (It it = mark_sweep_collectors_.begin(), end = mark_sweep_collectors_.end(); - it != end; ++it) { - collector::MarkSweep* cur_collector = *it; + for (const auto& cur_collector : mark_sweep_collectors_) { if (cur_collector->IsConcurrent() == concurrent_gc_ && cur_collector->GetGcType() == gc_type) { collector = cur_collector; break; @@ -1596,9 +1567,7 @@ void Heap::SwapStacks() { void Heap::ProcessCards(base::TimingLogger& timings) { // Clear cards and keep track of cards cleared in the mod-union table. - typedef std::vector::iterator It; - for (It it = continuous_spaces_.begin(), end = continuous_spaces_.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : continuous_spaces_) { if (space->IsImageSpace()) { base::TimingLogger::ScopedSplit split("ImageModUnionClearCards", &timings); image_mod_union_table_->ClearCards(space); @@ -2085,9 +2054,7 @@ void Heap::RegisterNativeFree(int bytes) { int64_t Heap::GetTotalMemory() const { int64_t ret = 0; - typedef std::vector::const_iterator It; - for (It it = continuous_spaces_.begin(), end = continuous_spaces_.end(); it != end; ++it) { - space::ContinuousSpace* space = *it; + for (const auto& space : continuous_spaces_) { if (space->IsImageSpace()) { // Currently don't include the image space. } else if (space->IsDlMallocSpace()) { @@ -2095,9 +2062,7 @@ int64_t Heap::GetTotalMemory() const { ret += space->AsDlMallocSpace()->GetFootprint(); } } - typedef std::vector::const_iterator It2; - for (It2 it = discontinuous_spaces_.begin(), end = discontinuous_spaces_.end(); it != end; ++it) { - space::DiscontinuousSpace* space = *it; + for (const auto& space : discontinuous_spaces_) { if (space->IsLargeObjectSpace()) { ret += space->AsLargeObjectSpace()->GetBytesAllocated(); } diff --git a/runtime/indirect_reference_table.cc b/runtime/indirect_reference_table.cc index 3e75716ce8..8af4d7eaab 100644 --- a/runtime/indirect_reference_table.cc +++ b/runtime/indirect_reference_table.cc @@ -309,9 +309,8 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) { } void IndirectReferenceTable::VisitRoots(RootVisitor* visitor, void* arg) { - typedef IndirectReferenceTable::iterator It; // TODO: C++0x auto - for (It it = begin(), end = this->end(); it != end; ++it) { - visitor(**it, arg); + for (auto ref : *this) { + visitor(*ref, arg); } } diff --git a/runtime/indirect_reference_table.h b/runtime/indirect_reference_table.h index 97706b82bb..26f53db4ad 100644 --- a/runtime/indirect_reference_table.h +++ b/runtime/indirect_reference_table.h @@ -248,8 +248,6 @@ bool inline operator!=(const IrtIterator& lhs, const IrtIterator& rhs) { class IndirectReferenceTable { public: - typedef IrtIterator iterator; - IndirectReferenceTable(size_t initialCount, size_t maxCount, IndirectRefKind kind); ~IndirectReferenceTable(); @@ -301,12 +299,12 @@ class IndirectReferenceTable { return segment_state_.parts.topIndex; } - iterator begin() { - return iterator(table_, 0, Capacity()); + IrtIterator begin() { + return IrtIterator(table_, 0, Capacity()); } - iterator end() { - return iterator(table_, Capacity(), Capacity()); + IrtIterator end() { + return IrtIterator(table_, Capacity(), Capacity()); } void VisitRoots(RootVisitor* visitor, void* arg); diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc index ae3a165a70..6caad0110d 100644 --- a/runtime/instrumentation.cc +++ b/runtime/instrumentation.cc @@ -206,12 +206,9 @@ static void InstrumentationRestoreStack(Thread* thread, void* arg) } return true; // Ignore upcalls. } - typedef std::deque::const_iterator It; // TODO: C++0x auto bool removed_stub = false; // TODO: make this search more efficient? - for (It it = instrumentation_stack_->begin(), end = instrumentation_stack_->end(); it != end; - ++it) { - InstrumentationStackFrame instrumentation_frame = *it; + for (InstrumentationStackFrame instrumentation_frame : *instrumentation_stack_) { if (instrumentation_frame.frame_id_ == GetFrameId()) { if (kVerboseInstrumentation) { LOG(INFO) << " Removing exit stub in " << DescribeLocation(); @@ -407,8 +404,7 @@ const void* Instrumentation::GetQuickCodeFor(const mirror::ArtMethod* method) co void Instrumentation::MethodEnterEventImpl(Thread* thread, mirror::Object* this_object, const mirror::ArtMethod* method, uint32_t dex_pc) const { - typedef std::list::const_iterator It; // TODO: C++0x auto - It it = method_entry_listeners_.begin(); + auto it = method_entry_listeners_.begin(); bool is_end = (it == method_entry_listeners_.end()); // Implemented this way to prevent problems caused by modification of the list while iterating. while (!is_end) { @@ -422,8 +418,7 @@ void Instrumentation::MethodEnterEventImpl(Thread* thread, mirror::Object* this_ void Instrumentation::MethodExitEventImpl(Thread* thread, mirror::Object* this_object, const mirror::ArtMethod* method, uint32_t dex_pc, const JValue& return_value) const { - typedef std::list::const_iterator It; // TODO: C++0x auto - It it = method_exit_listeners_.begin(); + auto it = method_exit_listeners_.begin(); bool is_end = (it == method_exit_listeners_.end()); // Implemented this way to prevent problems caused by modification of the list while iterating. while (!is_end) { @@ -438,10 +433,8 @@ void Instrumentation::MethodUnwindEvent(Thread* thread, mirror::Object* this_obj const mirror::ArtMethod* method, uint32_t dex_pc) const { if (have_method_unwind_listeners_) { - typedef std::list::const_iterator It; // TODO: C++0x auto - for (It it = method_unwind_listeners_.begin(), end = method_unwind_listeners_.end(); it != end; - ++it) { - (*it)->MethodUnwind(thread, method, dex_pc); + for (InstrumentationListener* listener : method_unwind_listeners_) { + listener->MethodUnwind(thread, method, dex_pc); } } } @@ -454,9 +447,8 @@ void Instrumentation::DexPcMovedEventImpl(Thread* thread, mirror::Object* this_o // around the problem and in general we may have to move to something like reference counting to // ensure listeners are deleted correctly. std::list copy(dex_pc_listeners_); - typedef std::list::const_iterator It; // TODO: C++0x auto - for (It it = copy.begin(), end = copy.end(); it != end; ++it) { - (*it)->DexPcMoved(thread, this_object, method, dex_pc); + for (InstrumentationListener* listener : copy) { + listener->DexPcMoved(thread, this_object, method, dex_pc); } } @@ -467,10 +459,8 @@ void Instrumentation::ExceptionCaughtEvent(Thread* thread, const ThrowLocation& if (have_exception_caught_listeners_) { DCHECK_EQ(thread->GetException(NULL), exception_object); thread->ClearException(); - typedef std::list::const_iterator It; // TODO: C++0x auto - for (It it = exception_caught_listeners_.begin(), end = exception_caught_listeners_.end(); - it != end; ++it) { - (*it)->ExceptionCaught(thread, throw_location, catch_method, catch_dex_pc, exception_object); + for (InstrumentationListener* listener : exception_caught_listeners_) { + listener->ExceptionCaught(thread, throw_location, catch_method, catch_dex_pc, exception_object); } thread->SetException(throw_location, exception_object); } diff --git a/runtime/intern_table.cc b/runtime/intern_table.cc index e2c1a64dec..d7398caa57 100644 --- a/runtime/intern_table.cc +++ b/runtime/intern_table.cc @@ -40,9 +40,8 @@ void InternTable::DumpForSigQuit(std::ostream& os) const { void InternTable::VisitRoots(RootVisitor* visitor, void* arg, bool clean_dirty) { MutexLock mu(Thread::Current(), intern_table_lock_); - typedef Table::const_iterator It; // TODO: C++0x auto - for (It it = strong_interns_.begin(), end = strong_interns_.end(); it != end; ++it) { - visitor(it->second, arg); + for (const auto& strong_intern : strong_interns_) { + visitor(strong_intern.second, arg); } if (clean_dirty) { is_dirty_ = false; @@ -52,8 +51,7 @@ void InternTable::VisitRoots(RootVisitor* visitor, void* arg, bool clean_dirty) mirror::String* InternTable::Lookup(Table& table, mirror::String* s, uint32_t hash_code) { intern_table_lock_.AssertHeld(Thread::Current()); - typedef Table::const_iterator It; // TODO: C++0x auto - for (It it = table.find(hash_code), end = table.end(); it != end; ++it) { + for (auto it = table.find(hash_code), end = table.end(); it != end; ++it) { mirror::String* existing_string = it->second; if (existing_string->Equals(s)) { return existing_string; @@ -75,8 +73,7 @@ void InternTable::RegisterStrong(mirror::String* s) { void InternTable::Remove(Table& table, const mirror::String* s, uint32_t hash_code) { intern_table_lock_.AssertHeld(Thread::Current()); - typedef Table::iterator It; // TODO: C++0x auto - for (It it = table.find(hash_code), end = table.end(); it != end; ++it) { + for (auto it = table.find(hash_code), end = table.end(); it != end; ++it) { if (it->second == s) { table.erase(it); return; @@ -166,8 +163,8 @@ bool InternTable::ContainsWeak(mirror::String* s) { void InternTable::SweepInternTableWeaks(IsMarkedTester is_marked, void* arg) { MutexLock mu(Thread::Current(), intern_table_lock_); - typedef Table::iterator It; // TODO: C++0x auto - for (It it = weak_interns_.begin(), end = weak_interns_.end(); it != end;) { + // TODO: std::remove_if + lambda. + for (auto it = weak_interns_.begin(), end = weak_interns_.end(); it != end;) { mirror::Object* object = it->second; if (!is_marked(object, arg)) { weak_interns_.erase(it++); diff --git a/runtime/intern_table_test.cc b/runtime/intern_table_test.cc index ffb93eb672..d79d2c4b31 100644 --- a/runtime/intern_table_test.cc +++ b/runtime/intern_table_test.cc @@ -58,8 +58,7 @@ class TestPredicate { public: bool IsMarked(const mirror::Object* s) const { bool erased = false; - typedef std::vector::iterator It; // TODO: C++0x auto - for (It it = expected_.begin(), end = expected_.end(); it != end; ++it) { + for (auto it = expected_.begin(), end = expected_.end(); it != end; ++it) { if (*it == s) { expected_.erase(it); erased = true; diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc index 852dd00a77..460e3b0f30 100644 --- a/runtime/jni_internal.cc +++ b/runtime/jni_internal.cc @@ -538,12 +538,12 @@ class Libraries { void Dump(std::ostream& os) const { bool first = true; - for (It it = libraries_.begin(); it != libraries_.end(); ++it) { + for (const auto& library : libraries_) { if (!first) { os << ' '; } first = false; - os << it->first; + os << library.first; } } @@ -552,7 +552,7 @@ class Libraries { } SharedLibrary* Get(const std::string& path) { - It it = libraries_.find(path); + auto it = libraries_.find(path); return (it == libraries_.end()) ? NULL : it->second; } @@ -566,8 +566,8 @@ class Libraries { std::string jni_short_name(JniShortName(m)); std::string jni_long_name(JniLongName(m)); const ClassLoader* declaring_class_loader = m->GetDeclaringClass()->GetClassLoader(); - for (It it = libraries_.begin(); it != libraries_.end(); ++it) { - SharedLibrary* library = it->second; + for (const auto& lib : libraries_) { + SharedLibrary* library = lib.second; if (library->GetClassLoader() != declaring_class_loader) { // We only search libraries loaded by the appropriate ClassLoader. continue; @@ -591,8 +591,6 @@ class Libraries { } private: - typedef SafeMap::const_iterator It; // TODO: C++0x auto - SafeMap libraries_; }; diff --git a/runtime/mirror/art_method.h b/runtime/mirror/art_method.h index 7301f23747..5d4a6ea0d5 100644 --- a/runtime/mirror/art_method.h +++ b/runtime/mirror/art_method.h @@ -442,6 +442,7 @@ class MANAGED ArtMethod : public Object { static Class* java_lang_reflect_ArtMethod_; + private: friend struct art::ArtMethodOffsets; // for verifying offset information DISALLOW_IMPLICIT_CONSTRUCTORS(ArtMethod); }; diff --git a/runtime/monitor.cc b/runtime/monitor.cc index 48c05692b4..ff193c9534 100644 --- a/runtime/monitor.cc +++ b/runtime/monitor.cc @@ -979,9 +979,7 @@ void MonitorList::Add(Monitor* m) { void MonitorList::SweepMonitorList(IsMarkedTester is_marked, void* arg) { MutexLock mu(Thread::Current(), monitor_list_lock_); - typedef std::list::iterator It; // TODO: C++0x auto - It it = list_.begin(); - while (it != list_.end()) { + for (auto it = list_.begin(); it != list_.end(); ) { Monitor* m = *it; if (!is_marked(m->GetObject(), arg)) { VLOG(monitor) << "freeing monitor " << m << " belonging to unmarked object " << m->GetObject(); diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc index 061dfb84db..4ee353359b 100644 --- a/runtime/native/dalvik_system_DexFile.cc +++ b/runtime/native/dalvik_system_DexFile.cc @@ -253,14 +253,10 @@ static jboolean DexFile_isDexOptNeeded(JNIEnv* env, jclass, jstring javaFilename return JNI_TRUE; } - gc::Heap* heap = runtime->GetHeap(); - const std::vector& spaces = heap->GetContinuousSpaces(); - // TODO: C++0x auto - typedef std::vector::const_iterator It; - for (It it = spaces.begin(), end = spaces.end(); it != end; ++it) { - if ((*it)->IsImageSpace()) { + for (const auto& space : runtime->GetHeap()->GetContinuousSpaces()) { + if (space->IsImageSpace()) { // TODO: Ensure this works with multiple image spaces. - const ImageHeader& image_header = (*it)->AsImageSpace()->GetImageHeader(); + const ImageHeader& image_header = space->AsImageSpace()->GetImageHeader(); if (oat_file->GetOatHeader().GetImageFileLocationOatChecksum() != image_header.GetOatChecksum()) { ScopedObjectAccess soa(env); LOG(INFO) << "DexFile_isDexOptNeeded cache file " << cache_location diff --git a/runtime/output_stream_test.cc b/runtime/output_stream_test.cc index 8da2ac91fe..d5e97558c0 100644 --- a/runtime/output_stream_test.cc +++ b/runtime/output_stream_test.cc @@ -78,4 +78,4 @@ TEST_F(OutputStreamTest, Vector) { CheckTestOutput(output); } -} // namespace std +} // namespace art diff --git a/runtime/reference_table.cc b/runtime/reference_table.cc index de64c26155..8e23cbb153 100644 --- a/runtime/reference_table.cc +++ b/runtime/reference_table.cc @@ -232,9 +232,8 @@ void ReferenceTable::Dump(std::ostream& os, const Table& entries) { } void ReferenceTable::VisitRoots(RootVisitor* visitor, void* arg) { - typedef Table::const_iterator It; // TODO: C++0x auto - for (It it = entries_.begin(), end = entries_.end(); it != end; ++it) { - visitor(*it, arg); + for (const auto& ref : entries_) { + visitor(ref, arg); } } diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc index 9c28c87b84..671924a620 100644 --- a/runtime/thread_list.cc +++ b/runtime/thread_list.cc @@ -53,8 +53,8 @@ bool ThreadList::Contains(Thread* thread) { } bool ThreadList::Contains(pid_t tid) { - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - if ((*it)->tid_ == tid) { + for (const auto& thread : list_) { + if (thread->tid_ == tid) { return true; } } @@ -113,8 +113,8 @@ void ThreadList::DumpUnattachedThreads(std::ostream& os) { void ThreadList::DumpLocked(std::ostream& os) { os << "DALVIK THREADS (" << list_.size() << "):\n"; - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - (*it)->Dump(os); + for (const auto& thread : list_) { + thread->Dump(os); os << "\n"; } } @@ -122,8 +122,7 @@ void ThreadList::DumpLocked(std::ostream& os) { void ThreadList::AssertThreadsAreSuspended(Thread* self, Thread* ignore1, Thread* ignore2) { MutexLock mu(self, *Locks::thread_list_lock_); MutexLock mu2(self, *Locks::thread_suspend_count_lock_); - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { if (thread != ignore1 && thread != ignore2) { CHECK(thread->IsSuspended()) << "\nUnsuspended thread: <<" << *thread << "\n" @@ -160,9 +159,7 @@ size_t ThreadList::RunCheckpoint(Closure* checkpoint_function) { // Call a checkpoint function for each thread, threads which are suspend get their checkpoint // manually called. MutexLock mu(self, *Locks::thread_list_lock_); - // TODO: C++0x auto. - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { if (thread != self) { for (;;) { if (thread->RequestCheckpoint(checkpoint_function)) { @@ -189,8 +186,7 @@ size_t ThreadList::RunCheckpoint(Closure* checkpoint_function) { checkpoint_function->Run(self); // Run the checkpoint on the suspended threads. - for (size_t i = 0; i < suspended_count_modified_threads.size(); ++i) { - Thread* thread = suspended_count_modified_threads[i]; + for (const auto& thread : suspended_count_modified_threads) { if (!thread->IsSuspended()) { // Wait until the thread is suspended. uint64_t start = NanoTime(); @@ -243,8 +239,7 @@ void ThreadList::SuspendAll() { // Update global suspend all state for attaching threads. ++suspend_all_count_; // Increment everybody's suspend count (except our own). - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { if (thread == self) { continue; } @@ -285,8 +280,7 @@ void ThreadList::ResumeAll() { // Update global suspend all state for attaching threads. --suspend_all_count_; // Decrement the suspend counts for all threads. - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { if (thread == self) { continue; } @@ -341,8 +335,7 @@ void ThreadList::SuspendAllForDebugger() { ++suspend_all_count_; ++debug_suspend_all_count_; // Increment everybody's suspend count (except our own). - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { if (thread == self || thread == debug_thread) { continue; } @@ -427,8 +420,7 @@ void ThreadList::UndoDebuggerSuspensions() { suspend_all_count_ -= debug_suspend_all_count_; debug_suspend_all_count_ = 0; // Update running threads. - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { if (thread == self || thread->debug_suspend_count_ == 0) { continue; } @@ -457,8 +449,7 @@ void ThreadList::WaitForOtherNonDaemonThreadsToExit() { } all_threads_are_daemons = true; MutexLock mu(self, *Locks::thread_list_lock_); - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { if (thread != self && !thread->IsDaemon()) { all_threads_are_daemons = false; break; @@ -476,8 +467,7 @@ void ThreadList::SuspendAllDaemonThreads() { MutexLock mu(self, *Locks::thread_list_lock_); { // Tell all the daemons it's time to suspend. MutexLock mu2(self, *Locks::thread_suspend_count_lock_); - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { // This is only run after all non-daemon threads have exited, so the remainder should all be // daemons. CHECK(thread->IsDaemon()) << *thread; @@ -491,8 +481,7 @@ void ThreadList::SuspendAllDaemonThreads() { for (int i = 0; i < 10; ++i) { usleep(200 * 1000); bool all_suspended = true; - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - Thread* thread = *it; + for (const auto& thread : list_) { if (thread != self && thread->GetState() == kRunnable) { if (!have_complained) { LOG(WARNING) << "daemon thread not yet suspended: " << *thread; @@ -567,22 +556,22 @@ void ThreadList::Unregister(Thread* self) { } void ThreadList::ForEach(void (*callback)(Thread*, void*), void* context) { - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - callback(*it, context); + for (const auto& thread : list_) { + callback(thread, context); } } void ThreadList::VisitRoots(RootVisitor* visitor, void* arg) const { MutexLock mu(Thread::Current(), *Locks::thread_list_lock_); - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - (*it)->VisitRoots(visitor, arg); + for (const auto& thread : list_) { + thread->VisitRoots(visitor, arg); } } void ThreadList::VerifyRoots(VerifyRootVisitor* visitor, void* arg) const { MutexLock mu(Thread::Current(), *Locks::thread_list_lock_); - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - (*it)->VerifyRoots(visitor, arg); + for (const auto& thread : list_) { + thread->VerifyRoots(visitor, arg); } } @@ -607,9 +596,9 @@ void ThreadList::ReleaseThreadId(Thread* self, uint32_t id) { Thread* ThreadList::FindThreadByThinLockId(uint32_t thin_lock_id) { MutexLock mu(Thread::Current(), *Locks::thread_list_lock_); - for (It it = list_.begin(), end = list_.end(); it != end; ++it) { - if ((*it)->GetThinLockId() == thin_lock_id) { - return *it; + for (const auto& thread : list_) { + if (thread->GetThinLockId() == thin_lock_id) { + return thread; } } return NULL; diff --git a/runtime/thread_list.h b/runtime/thread_list.h index d95f191553..3df3e2c841 100644 --- a/runtime/thread_list.h +++ b/runtime/thread_list.h @@ -102,8 +102,6 @@ class ThreadList { Thread* FindThreadByThinLockId(uint32_t thin_lock_id); private: - typedef std::list::const_iterator It; // TODO: C++0x auto - uint32_t AllocThreadId(Thread* self); void ReleaseThreadId(Thread* self, uint32_t id) LOCKS_EXCLUDED(allocated_ids_lock_); diff --git a/runtime/thread_pool.h b/runtime/thread_pool.h index c26926cf74..9c6d47b0a9 100644 --- a/runtime/thread_pool.h +++ b/runtime/thread_pool.h @@ -55,6 +55,7 @@ class ThreadPoolWorker { const size_t stack_size_; pthread_t pthread_; + private: friend class ThreadPool; DISALLOW_COPY_AND_ASSIGN(ThreadPoolWorker); }; @@ -117,6 +118,7 @@ class ThreadPool { uint64_t total_wait_time_; Barrier creation_barier_; + private: friend class ThreadPoolWorker; friend class WorkStealingWorker; DISALLOW_COPY_AND_ASSIGN(ThreadPool); @@ -153,6 +155,7 @@ class WorkStealingWorker : public ThreadPoolWorker { WorkStealingWorker(ThreadPool* thread_pool, const std::string& name, size_t stack_size); virtual void Run(); + private: friend class WorkStealingThreadPool; DISALLOW_COPY_AND_ASSIGN(WorkStealingWorker); }; diff --git a/runtime/trace.cc b/runtime/trace.cc index 13e2bf6deb..5d6943c959 100644 --- a/runtime/trace.cc +++ b/runtime/trace.cc @@ -610,12 +610,9 @@ void Trace::GetVisitedMethods(size_t buf_size, } } -void Trace::DumpMethodList(std::ostream& os, - const std::set& visited_methods) { - typedef std::set::const_iterator It; // TODO: C++0x auto +void Trace::DumpMethodList(std::ostream& os, const std::set& visited_methods) { MethodHelper mh; - for (It it = visited_methods.begin(); it != visited_methods.end(); ++it) { - mirror::ArtMethod* method = *it; + for (const auto& method : visited_methods) { mh.ChangeMethod(method); os << StringPrintf("%p\t%s\t%s\t%s\t%s\n", method, PrettyDescriptor(mh.GetDeclaringClassDescriptor()).c_str(), mh.GetName(), diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h index 6171943a6c..ff4386e104 100644 --- a/runtime/verifier/method_verifier.h +++ b/runtime/verifier/method_verifier.h @@ -122,7 +122,7 @@ class PcToRegisterLineTable { uint16_t registers_size, MethodVerifier* verifier); RegisterLine* GetLine(size_t idx) { - Table::iterator result = pc_to_register_line_.find(idx); // TODO: C++0x auto + auto result = pc_to_register_line_.find(idx); if (result == pc_to_register_line_.end()) { return NULL; } else { diff --git a/runtime/verifier/reg_type.cc b/runtime/verifier/reg_type.cc index 8418928a83..25f840cc56 100644 --- a/runtime/verifier/reg_type.cc +++ b/runtime/verifier/reg_type.cc @@ -395,8 +395,7 @@ std::string UnresolvedMergedType::Dump() const { std::stringstream result; std::set types = GetMergedTypes(); result << "UnresolvedMergedReferences("; - typedef std::set::const_iterator It; // TODO: C++0x auto - It it = types.begin(); + auto it = types.begin(); result << reg_type_cache_->GetFromId(*it).Dump(); for (++it; it != types.end(); ++it) { result << ", "; @@ -609,9 +608,8 @@ std::set UnresolvedMergedType::GetMergedTypes() const { types.insert(refs.second); } if (kIsDebugBuild) { - typedef std::set::const_iterator It; // TODO: C++0x auto - for (It it = types.begin(); it != types.end(); ++it) { - CHECK(!reg_type_cache_->GetFromId(*it).IsUnresolvedMergedReference()); + for (const auto& type : types) { + CHECK(!reg_type_cache_->GetFromId(type).IsUnresolvedMergedReference()); } } return types; diff --git a/runtime/verifier/reg_type.h b/runtime/verifier/reg_type.h index 33f4195885..865ba20d44 100644 --- a/runtime/verifier/reg_type.h +++ b/runtime/verifier/reg_type.h @@ -287,6 +287,7 @@ class RegType { friend class RegTypeCache; + private: DISALLOW_COPY_AND_ASSIGN(RegType); }; diff --git a/runtime/verifier/register_line.cc b/runtime/verifier/register_line.cc index 24a626b277..5affe4759a 100644 --- a/runtime/verifier/register_line.cc +++ b/runtime/verifier/register_line.cc @@ -208,9 +208,8 @@ std::string RegisterLine::Dump() const { result += GetRegisterType(i).Dump(); result += "],"; } - typedef std::deque::const_iterator It; // TODO: C++0x auto - for (It it = monitors_.begin(), end = monitors_.end(); it != end; ++it) { - result += StringPrintf("{%d},", *it); + for (const auto& monitor : monitors_) { + result += StringPrintf("{%d},", monitor); } return result; } diff --git a/tools/cpplint.py b/tools/cpplint.py index 0b5fb93536..30b5216b12 100755 --- a/tools/cpplint.py +++ b/tools/cpplint.py @@ -53,12 +53,8 @@ # - Check for 0 in char context (should be '\0') # - Check for camel-case method name conventions for methods # that are not simple inline getters and setters -# - Check that base classes have virtual destructors -# put " // namespace" after } that closes a namespace, with -# namespace's name after 'namespace' if it is named. # - Do not indent namespace contents # - Avoid inlining non-trivial constructors in header files -# include base/basictypes.h if DISALLOW_EVIL_CONSTRUCTORS is used # - Check for old-school (void) cast for call-sites of functions # ignored return value # - Check gUnit usage of anonymous namespace @@ -80,6 +76,7 @@ same line, but it is far from perfect (in either direction). """ import codecs +import copy import getopt import math # for log import os @@ -139,6 +136,22 @@ Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] the top-level categories like 'build' and 'whitespace' will also be printed. If 'detailed' is provided, then a count is provided for each category like 'build/class'. + + root=subdir + The root directory used for deriving header guard CPP variable. + By default, the header guard CPP variable is calculated as the relative + path to the directory that contains .git, .hg, or .svn. When this flag + is specified, the relative path is calculated from the specified + directory. If the specified directory does not exist, this flag is + ignored. + + Examples: + Assuing that src/.git exists, the header guard CPP variables for + src/chrome/browser/ui/browser.h are: + + No flag => CHROME_BROWSER_UI_BROWSER_H_ + --root=chrome => BROWSER_UI_BROWSER_H_ + --root=chrome/browser => UI_BROWSER_H_ """ # We categorize each error message we print. Here are the categories. @@ -161,6 +174,7 @@ _ERROR_CATEGORIES = [ 'build/printf_format', 'build/storage_class', 'legal/copyright', + 'readability/alt_tokens', 'readability/braces', 'readability/casting', 'readability/check', @@ -169,6 +183,7 @@ _ERROR_CATEGORIES = [ 'readability/function', 'readability/multiline_comment', 'readability/multiline_string', + 'readability/namespace', 'readability/nolint', 'readability/streams', 'readability/todo', @@ -189,13 +204,14 @@ _ERROR_CATEGORIES = [ 'runtime/sizeof', 'runtime/string', 'runtime/threadsafe_fn', - 'runtime/virtual', 'whitespace/blank_line', 'whitespace/braces', 'whitespace/comma', 'whitespace/comments', + 'whitespace/empty_loop_body', 'whitespace/end_of_line', 'whitespace/ending_newline', + 'whitespace/forcolon', 'whitespace/indent', 'whitespace/labels', 'whitespace/line_length', @@ -241,8 +257,9 @@ _CPP_HEADERS = frozenset([ 'numeric', 'ostream', 'ostream.h', 'parsestream.h', 'pfstream.h', 'PlotFile.h', 'procbuf.h', 'pthread_alloc.h', 'rope', 'rope.h', 'ropeimpl.h', 'SFile.h', 'slist', 'slist.h', 'stack.h', 'stdexcept', - 'stdiostream.h', 'streambuf.h', 'stream.h', 'strfile.h', 'string', - 'strstream', 'strstream.h', 'tempbuf.h', 'tree.h', 'typeinfo', 'valarray', + 'stdiostream.h', 'streambuf', 'streambuf.h', 'stream.h', 'strfile.h', + 'string', 'strstream', 'strstream.h', 'tempbuf.h', 'tree.h', 'typeinfo', + 'valarray', ]) @@ -278,6 +295,34 @@ for op, inv_replacement in [('==', 'NE'), ('!=', 'EQ'), _CHECK_REPLACEMENT['EXPECT_FALSE_M'][op] = 'EXPECT_%s_M' % inv_replacement _CHECK_REPLACEMENT['ASSERT_FALSE_M'][op] = 'ASSERT_%s_M' % inv_replacement +# Alternative tokens and their replacements. For full list, see section 2.5 +# Alternative tokens [lex.digraph] in the C++ standard. +# +# Digraphs (such as '%:') are not included here since it's a mess to +# match those on a word boundary. +_ALT_TOKEN_REPLACEMENT = { + 'and': '&&', + 'bitor': '|', + 'or': '||', + 'xor': '^', + 'compl': '~', + 'bitand': '&', + 'and_eq': '&=', + 'or_eq': '|=', + 'xor_eq': '^=', + 'not': '!', + 'not_eq': '!=' + } + +# Compile regular expression that matches all the above keywords. The "[ =()]" +# bit is meant to avoid matching these keywords outside of boolean expressions. +# +# False positives include C-style multi-line comments (http://go/nsiut ) +# and multi-line strings (http://go/beujw ), but those have always been +# troublesome for cpplint. +_ALT_TOKEN_REPLACEMENT_PATTERN = re.compile( + r'[ =()](' + ('|'.join(_ALT_TOKEN_REPLACEMENT.keys())) + r')(?=[ (]|$)') + # These constants define types of headers for use with # _IncludeState.CheckNextIncludeOrder(). @@ -287,6 +332,17 @@ _LIKELY_MY_HEADER = 3 _POSSIBLE_MY_HEADER = 4 _OTHER_HEADER = 5 +# These constants define the current inline assembly state +_NO_ASM = 0 # Outside of inline assembly block +_INSIDE_ASM = 1 # Inside inline assembly block +_END_ASM = 2 # Last line of inline assembly block +_BLOCK_ASM = 3 # The whole block is an inline assembly block + +# Match start of assembly blocks +_MATCH_ASM = re.compile(r'^\s*(?:asm|_asm|__asm|__asm__)' + r'(?:\s+(volatile|__volatile__))?' + r'\s*[{(]') + _regexp_compile_cache = {} @@ -297,6 +353,10 @@ _RE_SUPPRESSION = re.compile(r'\bNOLINT\b(\([^)]*\))?') # on which those errors are expected and should be suppressed. _error_suppressions = {} +# The root directory used for deriving header guard CPP variable. +# This is set by --root flag. +_root = None + def ParseNolintSuppressions(filename, raw_line, linenum, error): """Updates the global list of error-suppressions. @@ -649,7 +709,6 @@ class _FunctionState(object): if not self.in_a_function: return # END android-added - if Match(r'T(EST|est)', self.current_function): base_trigger = self._TEST_TRIGGER else: @@ -736,7 +795,6 @@ class FileInfo: return "art/" + fullname[len(prefix) + 1:] # END android-changed - # Don't know what to do; header guard warnings may be wrong... return fullname @@ -825,6 +883,9 @@ def Error(filename, linenum, category, confidence, message): if _cpplint_state.output_format == 'vs7': sys.stderr.write('%s(%s): %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) + elif _cpplint_state.output_format == 'eclipse': + sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( + filename, linenum, message, category, confidence)) else: sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( filename, linenum, message, category, confidence)) @@ -934,7 +995,7 @@ class CleansedLines(object): 1) elided member contains lines without strings and comments, 2) lines member contains lines without comments, and - 3) raw member contains all the lines without processing. + 3) raw_lines member contains all the lines without processing. All these three members are of , and of the same length. """ @@ -974,6 +1035,29 @@ class CleansedLines(object): return elided +def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar): + """Find the position just after the matching endchar. + + Args: + line: a CleansedLines line. + startpos: start searching at this position. + depth: nesting level at startpos. + startchar: expression opening character. + endchar: expression closing character. + + Returns: + Index just after endchar. + """ + for i in xrange(startpos, len(line)): + if line[i] == startchar: + depth += 1 + elif line[i] == endchar: + depth -= 1 + if depth == 0: + return i + 1 + return -1 + + def CloseExpression(clean_lines, linenum, pos): """If input points to ( or { or [, finds the position that closes it. @@ -1000,18 +1084,23 @@ def CloseExpression(clean_lines, linenum, pos): if startchar == '[': endchar = ']' if startchar == '{': endchar = '}' - num_open = line.count(startchar) - line.count(endchar) - while linenum < clean_lines.NumLines() and num_open > 0: + # Check first line + end_pos = FindEndOfExpressionInLine(line, pos, 0, startchar, endchar) + if end_pos > -1: + return (line, linenum, end_pos) + tail = line[pos:] + num_open = tail.count(startchar) - tail.count(endchar) + while linenum < clean_lines.NumLines() - 1: linenum += 1 line = clean_lines.elided[linenum] - num_open += line.count(startchar) - line.count(endchar) - # OK, now find the endchar that actually got us back to even - endpos = len(line) - while num_open >= 0: - endpos = line.rfind(')', 0, endpos) - num_open -= 1 # chopped off another ) - return (line, linenum, endpos + 1) + delta = line.count(startchar) - line.count(endchar) + if num_open + delta <= 0: + return (line, linenum, + FindEndOfExpressionInLine(line, 0, num_open, startchar, endchar)) + num_open += delta + # Did not find endchar before end of file, give up + return (line, clean_lines.NumLines(), -1) def CheckForCopyright(filename, lines, error): """Logs an error if no Copyright message appears at the top of the file.""" @@ -1041,8 +1130,13 @@ def GetHeaderGuardCPPVariable(filename): # Restores original filename in case that cpplint is invoked from Emacs's # flymake. filename = re.sub(r'_flymake\.h$', '.h', filename) + filename = re.sub(r'/\.flymake/([^/]*)$', r'/\1', filename) + fileinfo = FileInfo(filename) - return re.sub(r'[-./\s]', '_', fileinfo.RepositoryName()).upper() + '_' + file_path_from_root = fileinfo.RepositoryName() + if _root: + file_path_from_root = re.sub('^' + _root + os.sep, '', file_path_from_root) + return re.sub(r'[-./\s]', '_', file_path_from_root).upper() + '_' def CheckForHeaderGuard(filename, lines, error): @@ -1206,6 +1300,7 @@ threading_list = ( ('gmtime(', 'gmtime_r('), ('localtime(', 'localtime_r('), ('rand(', 'rand_r('), + ('readdir(', 'readdir_r('), ('strtok(', 'strtok_r('), ('ttyname(', 'ttyname_r('), ) @@ -1266,17 +1361,55 @@ def CheckInvalidIncrement(filename, clean_lines, linenum, error): 'Changing pointer instead of value (or unused value of operator*).') -class _ClassInfo(object): +class _BlockInfo(object): + """Stores information about a generic block of code.""" + + def __init__(self, seen_open_brace): + self.seen_open_brace = seen_open_brace + self.open_parentheses = 0 + self.inline_asm = _NO_ASM + + def CheckBegin(self, filename, clean_lines, linenum, error): + """Run checks that applies to text up to the opening brace. + + This is mostly for checking the text after the class identifier + and the "{", usually where the base class is specified. For other + blocks, there isn't much to check, so we always pass. + + 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. + """ + pass + + def CheckEnd(self, filename, clean_lines, linenum, error): + """Run checks that applies to text after the closing brace. + + This is mostly used for checking end of namespace comments. + + 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. + """ + pass + + +class _ClassInfo(_BlockInfo): """Stores information about a class.""" - def __init__(self, name, clean_lines, linenum): + def __init__(self, name, class_or_struct, clean_lines, linenum): + _BlockInfo.__init__(self, False) self.name = name - self.linenum = linenum - self.seen_open_brace = False + self.starting_linenum = linenum self.is_derived = False - self.virtual_method_linenumber = None - self.has_virtual_destructor = False - self.brace_depth = 0 + if class_or_struct == 'struct': + self.access = 'public' + else: + self.access = 'private' # Try to find the end of the class. This will be confused by things like: # class A { @@ -1286,26 +1419,324 @@ class _ClassInfo(object): self.last_line = 0 depth = 0 for i in range(linenum, clean_lines.NumLines()): - line = clean_lines.lines[i] + line = clean_lines.elided[i] depth += line.count('{') - line.count('}') if not depth: self.last_line = i break + def CheckBegin(self, filename, clean_lines, linenum, error): + # Look for a bare ':' + if Search('(^|[^:]):($|[^:])', clean_lines.elided[linenum]): + self.is_derived = True -class _ClassState(object): - """Holds the current state of the parse relating to class declarations. - It maintains a stack of _ClassInfos representing the parser's guess - as to the current nesting of class declarations. The innermost class - is at the top (back) of the stack. Typically, the stack will either - be empty or have exactly one entry. - """ +class _NamespaceInfo(_BlockInfo): + """Stores information about a namespace.""" + + def __init__(self, name, linenum): + _BlockInfo.__init__(self, False) + self.name = name or '' + self.starting_linenum = linenum + + def CheckEnd(self, filename, clean_lines, linenum, error): + """Check end of namespace comments.""" + line = clean_lines.raw_lines[linenum] + + # Check how many lines is enclosed in this namespace. Don't issue + # warning for missing namespace comments if there aren't enough + # lines. However, do apply checks if there is already an end of + # namespace comment and it's incorrect. + # + # TODO(unknown): We always want to check end of namespace comments + # if a namespace is large, but sometimes we also want to apply the + # check if a short namespace contained nontrivial things (something + # other than forward declarations). There is currently no logic on + # deciding what these nontrivial things are, so this check is + # triggered by namespace size only, which works most of the time. + if (linenum - self.starting_linenum < 10 + and not Match(r'};*\s*(//|/\*).*\bnamespace\b', line)): + return + + # Look for matching comment at end of namespace. + # + # Note that we accept C style "/* */" comments for terminating + # namespaces, so that code that terminate namespaces inside + # preprocessor macros can be cpplint clean. Example: http://go/nxpiz + # + # We also accept stuff like "// end of namespace ." with the + # period at the end. + # + # Besides these, we don't accept anything else, otherwise we might + # get false negatives when existing comment is a substring of the + # expected namespace. Example: http://go/ldkdc, http://cl/23548205 + if self.name: + # Named namespace + if not Match((r'};*\s*(//|/\*).*\bnamespace\s+' + re.escape(self.name) + + r'[\*/\.\\\s]*$'), + line): + error(filename, linenum, 'readability/namespace', 5, + 'Namespace should be terminated with "// namespace %s"' % + self.name) + else: + # Anonymous namespace + if not Match(r'};*\s*(//|/\*).*\bnamespace[\*/\.\\\s]*$', line): + error(filename, linenum, 'readability/namespace', 5, + 'Namespace should be terminated with "// namespace"') + + +class _PreprocessorInfo(object): + """Stores checkpoints of nesting stacks when #if/#else is seen.""" + + def __init__(self, stack_before_if): + # The entire nesting stack before #if + self.stack_before_if = stack_before_if + + # The entire nesting stack up to #else + self.stack_before_else = [] + + # Whether we have already seen #else or #elif + self.seen_else = False + + +class _NestingState(object): + """Holds states related to parsing braces.""" def __init__(self): - self.classinfo_stack = [] + # Stack for tracking all braces. An object is pushed whenever we + # see a "{", and popped when we see a "}". Only 3 types of + # objects are possible: + # - _ClassInfo: a class or struct. + # - _NamespaceInfo: a namespace. + # - _BlockInfo: some other type of block. + self.stack = [] + + # Stack of _PreprocessorInfo objects. + self.pp_stack = [] + + def SeenOpenBrace(self): + """Check if we have seen the opening brace for the innermost block. + + Returns: + True if we have seen the opening brace, False if the innermost + block is still expecting an opening brace. + """ + return (not self.stack) or self.stack[-1].seen_open_brace + + def InNamespaceBody(self): + """Check if we are currently one level inside a namespace body. + + Returns: + True if top of the stack is a namespace block, False otherwise. + """ + return self.stack and isinstance(self.stack[-1], _NamespaceInfo) + + def UpdatePreprocessor(self, line): + """Update preprocessor stack. + + We need to handle preprocessors due to classes like this: + #ifdef SWIG + struct ResultDetailsPageElementExtensionPoint { + #else + struct ResultDetailsPageElementExtensionPoint : public Extension { + #endif + (see http://go/qwddn for original example) + + We make the following assumptions (good enough for most files): + - Preprocessor condition evaluates to true from #if up to first + #else/#elif/#endif. + + - Preprocessor condition evaluates to false from #else/#elif up + to #endif. We still perform lint checks on these lines, but + these do not affect nesting stack. + + Args: + line: current line to check. + """ + if Match(r'^\s*#\s*(if|ifdef|ifndef)\b', line): + # Beginning of #if block, save the nesting stack here. The saved + # stack will allow us to restore the parsing state in the #else case. + self.pp_stack.append(_PreprocessorInfo(copy.deepcopy(self.stack))) + elif Match(r'^\s*#\s*(else|elif)\b', line): + # Beginning of #else block + if self.pp_stack: + if not self.pp_stack[-1].seen_else: + # This is the first #else or #elif block. Remember the + # whole nesting stack up to this point. This is what we + # keep after the #endif. + self.pp_stack[-1].seen_else = True + self.pp_stack[-1].stack_before_else = copy.deepcopy(self.stack) + + # Restore the stack to how it was before the #if + self.stack = copy.deepcopy(self.pp_stack[-1].stack_before_if) + else: + # TODO(unknown): unexpected #else, issue warning? + pass + elif Match(r'^\s*#\s*endif\b', line): + # End of #if or #else blocks. + if self.pp_stack: + # If we saw an #else, we will need to restore the nesting + # stack to its former state before the #else, otherwise we + # will just continue from where we left off. + if self.pp_stack[-1].seen_else: + # Here we can just use a shallow copy since we are the last + # reference to it. + self.stack = self.pp_stack[-1].stack_before_else + # Drop the corresponding #if + self.pp_stack.pop() + else: + # TODO(unknown): unexpected #endif, issue warning? + pass - def CheckFinished(self, filename, error): + def Update(self, filename, clean_lines, linenum, error): + """Update nesting state with current line. + + 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. + """ + line = clean_lines.elided[linenum] + + # Update pp_stack first + self.UpdatePreprocessor(line) + + # Count parentheses. This is to avoid adding struct arguments to + # the nesting stack. + if self.stack: + inner_block = self.stack[-1] + depth_change = line.count('(') - line.count(')') + inner_block.open_parentheses += depth_change + + # Also check if we are starting or ending an inline assembly block. + if inner_block.inline_asm in (_NO_ASM, _END_ASM): + if (depth_change != 0 and + inner_block.open_parentheses == 1 and + _MATCH_ASM.match(line)): + # Enter assembly block + inner_block.inline_asm = _INSIDE_ASM + else: + # Not entering assembly block. If previous line was _END_ASM, + # we will now shift to _NO_ASM state. + inner_block.inline_asm = _NO_ASM + elif (inner_block.inline_asm == _INSIDE_ASM and + inner_block.open_parentheses == 0): + # Exit assembly block + inner_block.inline_asm = _END_ASM + + # Consume namespace declaration at the beginning of the line. Do + # this in a loop so that we catch same line declarations like this: + # namespace proto2 { namespace bridge { class MessageSet; } } + while True: + # Match start of namespace. The "\b\s*" below catches namespace + # declarations even if it weren't followed by a whitespace, this + # is so that we don't confuse our namespace checker. The + # missing spaces will be flagged by CheckSpacing. + namespace_decl_match = Match(r'^\s*namespace\b\s*([:\w]+)?(.*)$', line) + if not namespace_decl_match: + break + + new_namespace = _NamespaceInfo(namespace_decl_match.group(1), linenum) + self.stack.append(new_namespace) + + line = namespace_decl_match.group(2) + if line.find('{') != -1: + new_namespace.seen_open_brace = True + line = line[line.find('{') + 1:] + + # Look for a class declaration in whatever is left of the line + # after parsing namespaces. The regexp accounts for decorated classes + # such as in: + # class LOCKABLE API Object { + # }; + # + # Templates with class arguments may confuse the parser, for example: + # template , + # class Vector = vector > + # class HeapQueue { + # + # Because this parser has no nesting state about templates, by the + # time it saw "class Comparator", it may think that it's a new class. + # Nested templates have a similar problem: + # template < + # typename ExportedType, + # typename TupleType, + # template class ImplTemplate> + # + # To avoid these cases, we ignore classes that are followed by '=' or '>' + class_decl_match = Match( + r'\s*(template\s*<[\w\s<>,:]*>\s*)?' + '(class|struct)\s+([A-Z_]+\s+)*(\w+(?:::\w+)*)' + '(([^=>]|<[^<>]*>)*)$', line) + if (class_decl_match and + (not self.stack or self.stack[-1].open_parentheses == 0)): + self.stack.append(_ClassInfo( + class_decl_match.group(4), class_decl_match.group(2), + clean_lines, linenum)) + line = class_decl_match.group(5) + + # If we have not yet seen the opening brace for the innermost block, + # run checks here. + if not self.SeenOpenBrace(): + self.stack[-1].CheckBegin(filename, clean_lines, linenum, error) + + # Update access control if we are inside a class/struct + if self.stack and isinstance(self.stack[-1], _ClassInfo): + access_match = Match(r'\s*(public|private|protected)\s*:', line) + if access_match: + self.stack[-1].access = access_match.group(1) + + # Consume braces or semicolons from what's left of the line + while True: + # Match first brace, semicolon, or closed parenthesis. + matched = Match(r'^[^{;)}]*([{;)}])(.*)$', line) + if not matched: + break + + token = matched.group(1) + if token == '{': + # If namespace or class hasn't seen a opening brace yet, mark + # namespace/class head as complete. Push a new block onto the + # stack otherwise. + if not self.SeenOpenBrace(): + self.stack[-1].seen_open_brace = True + else: + self.stack.append(_BlockInfo(True)) + if _MATCH_ASM.match(line): + self.stack[-1].inline_asm = _BLOCK_ASM + elif token == ';' or token == ')': + # If we haven't seen an opening brace yet, but we already saw + # a semicolon, this is probably a forward declaration. Pop + # the stack for these. + # + # Similarly, if we haven't seen an opening brace yet, but we + # already saw a closing parenthesis, then these are probably + # function arguments with extra "class" or "struct" keywords. + # Also pop these stack for these. + if not self.SeenOpenBrace(): + self.stack.pop() + else: # token == '}' + # Perform end of block checks and pop the stack. + if self.stack: + self.stack[-1].CheckEnd(filename, clean_lines, linenum, error) + self.stack.pop() + line = matched.group(2) + + def InnermostClass(self): + """Get class info on the top of the stack. + + Returns: + A _ClassInfo object if we are inside a class, or None otherwise. + """ + for i in range(len(self.stack), 0, -1): + classinfo = self.stack[i - 1] + if isinstance(classinfo, _ClassInfo): + return classinfo + return None + + def CheckClassFinished(self, filename, error): """Checks that all classes have been completely parsed. Call this when all lines in a file have been processed. @@ -1313,17 +1744,18 @@ class _ClassState(object): filename: The name of the current file. error: The function to call with any errors found. """ - if self.classinfo_stack: - # Note: This test can result in false positives if #ifdef constructs - # get in the way of brace matching. See the testBuildClass test in - # cpplint_unittest.py for an example of this. - error(filename, self.classinfo_stack[0].linenum, 'build/class', 5, - 'Failed to find complete declaration of class %s' % - self.classinfo_stack[0].name) + # Note: This test can result in false positives if #ifdef constructs + # get in the way of brace matching. See the testBuildClass test in + # cpplint_unittest.py for an example of this. + for obj in self.stack: + if isinstance(obj, _ClassInfo): + error(filename, obj.starting_linenum, 'build/class', 5, + 'Failed to find complete declaration of class %s' % + obj.name) def CheckForNonStandardConstructs(filename, clean_lines, linenum, - class_state, error): + nesting_state, error): """Logs an error if we see certain non-ANSI constructs ignored by gcc-2. Complain about several constructs which gcc-2 accepts, but which are @@ -1336,8 +1768,6 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, - text after #endif is not allowed. - invalid inner-style forward declaration. - >? and ?= and ,:]*>\s*)?' - '(class|struct)\s+([A-Z_]+\s+)*(\w+(::\w+)*)', line) - if class_decl_match: - classinfo_stack.append(_ClassInfo( - class_decl_match.group(4), clean_lines, linenum)) - - # Everything else in this function uses the top of the stack if it's - # not empty. - if not classinfo_stack: + # Everything else in this function operates on class declarations. + # Return early if the top of the nesting stack is not a class, or if + # the class head is not completed yet. + classinfo = nesting_state.InnermostClass() + if not classinfo or not classinfo.seen_open_brace: return - classinfo = classinfo_stack[-1] - - # If the opening brace hasn't been seen look for it and also - # parent class declarations. - if not classinfo.seen_open_brace: - # If the line has a ';' in it, assume it's a forward declaration or - # a single-line class declaration, which we won't process. - if line.find(';') != -1: - classinfo_stack.pop() - return - classinfo.seen_open_brace = (line.find('{') != -1) - # Look for a bare ':' - if Search('(^|[^:]):($|[^:])', line): - classinfo.is_derived = True - if not classinfo.seen_open_brace: - return # Everything else in this function is for after open brace - # The class may have been declared with namespace or classname qualifiers. # The constructor and destructor will not have those qualifiers. base_classname = classinfo.name.split('::')[-1] @@ -1462,35 +1860,6 @@ def CheckForNonStandardConstructs(filename, clean_lines, linenum, error(filename, linenum, 'runtime/explicit', 5, 'Single-argument constructors should be marked explicit.') - # Look for methods declared virtual. - if Search(r'\bvirtual\b', line): - classinfo.virtual_method_linenumber = linenum - # Only look for a destructor declaration on the same line. It would - # be extremely unlikely for the destructor declaration to occupy - # more than one line. - if Search(r'~%s\s*\(' % base_classname, line): - classinfo.has_virtual_destructor = True - - # Look for class end. - brace_depth = classinfo.brace_depth - brace_depth = brace_depth + line.count('{') - line.count('}') - if brace_depth <= 0: - classinfo = classinfo_stack.pop() - # Try to detect missing virtual destructor declarations. - # For now, only warn if a non-derived class with virtual methods lacks - # a virtual destructor. This is to make it less likely that people will - # declare derived virtual destructors without declaring the base - # destructor virtual. - if ((classinfo.virtual_method_linenumber is not None) and - (not classinfo.has_virtual_destructor) and - (not classinfo.is_derived)): # Only warn for base classes - error(filename, classinfo.linenum, 'runtime/virtual', 4, - 'The class %s probably needs a virtual destructor due to ' - 'having virtual method(s), one declared at line %d.' - % (classinfo.name, classinfo.virtual_method_linenumber)) - else: - classinfo.brace_depth = brace_depth - def CheckSpacingForFunctionCall(filename, line, linenum, error): """Checks for the correctness of various spacing around function calls. @@ -1545,7 +1914,8 @@ def CheckSpacingForFunctionCall(filename, line, linenum, error): error(filename, linenum, 'whitespace/parens', 2, 'Extra space after (') if (Search(r'\w\s+\(', fncall) and - not Search(r'#\s*define|typedef', fncall)): + not Search(r'#\s*define|typedef', fncall) and + not Search(r'\w\s+\((\w+::)?\*\w+\)\(', fncall)): error(filename, linenum, 'whitespace/parens', 4, 'Extra space before ( in function call') # If the ) is followed only by a newline or a { + newline, assume it's @@ -1678,8 +2048,165 @@ def CheckComment(comment, filename, linenum, error): error(filename, linenum, 'whitespace/todo', 2, 'TODO(my_username) should be followed by a space') +def CheckAccess(filename, clean_lines, linenum, nesting_state, error): + """Checks for improper use of DISALLOW* macros. + + Args: + filename: The name of the current file. + clean_lines: A CleansedLines instance containing the file. + linenum: The number of the line to check. + nesting_state: A _NestingState instance which maintains information about + the current stack of nested blocks being parsed. + error: The function to call with any errors found. + """ + line = clean_lines.elided[linenum] # get rid of comments and strings + + matched = Match((r'\s*(DISALLOW_COPY_AND_ASSIGN|' + r'DISALLOW_EVIL_CONSTRUCTORS|' + r'DISALLOW_IMPLICIT_CONSTRUCTORS)'), line) + if not matched: + return + if nesting_state.stack and isinstance(nesting_state.stack[-1], _ClassInfo): + if nesting_state.stack[-1].access != 'private': + error(filename, linenum, 'readability/constructors', 3, + '%s must be in the private: section' % matched.group(1)) + + else: + # Found DISALLOW* macro outside a class declaration, or perhaps it + # was used inside a function when it should have been part of the + # class declaration. We could issue a warning here, but it + # probably resulted in a compiler error already. + pass + + +def FindNextMatchingAngleBracket(clean_lines, linenum, init_suffix): + """Find the corresponding > to close a template. + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: Current line number. + init_suffix: Remainder of the current line after the initial <. + + Returns: + True if a matching bracket exists. + """ + line = init_suffix + nesting_stack = ['<'] + while True: + # Find the next operator that can tell us whether < is used as an + # opening bracket or as a less-than operator. We only want to + # warn on the latter case. + # + # We could also check all other operators and terminate the search + # early, e.g. if we got something like this "a(),;\[\]]*([<>(),;\[\]])(.*)$', line) + if match: + # Found an operator, update nesting stack + operator = match.group(1) + line = match.group(2) + + if nesting_stack[-1] == '<': + # Expecting closing angle bracket + if operator in ('<', '(', '['): + nesting_stack.append(operator) + elif operator == '>': + nesting_stack.pop() + if not nesting_stack: + # Found matching angle bracket + return True + elif operator == ',': + # Got a comma after a bracket, this is most likely a template + # argument. We have not seen a closing angle bracket yet, but + # it's probably a few lines later if we look for it, so just + # return early here. + return True + else: + # Got some other operator. + return False + + else: + # Expecting closing parenthesis or closing bracket + if operator in ('<', '(', '['): + nesting_stack.append(operator) + elif operator in (')', ']'): + # We don't bother checking for matching () or []. If we got + # something like (] or [), it would have been a syntax error. + nesting_stack.pop() + + else: + # Scan the next line + linenum += 1 + if linenum >= len(clean_lines.elided): + break + line = clean_lines.elided[linenum] + + # Exhausted all remaining lines and still no matching angle bracket. + # Most likely the input was incomplete, otherwise we should have + # seen a semicolon and returned early. + return True + + +def FindPreviousMatchingAngleBracket(clean_lines, linenum, init_prefix): + """Find the corresponding < that started a template. + + Args: + clean_lines: A CleansedLines instance containing the file. + linenum: Current line number. + init_prefix: Part of the current line before the initial >. + + Returns: + True if a matching bracket exists. + """ + line = init_prefix + nesting_stack = ['>'] + while True: + # Find the previous operator + match = Search(r'^(.*)([<>(),;\[\]])[^<>(),;\[\]]*$', line) + if match: + # Found an operator, update nesting stack + operator = match.group(2) + line = match.group(1) + + if nesting_stack[-1] == '>': + # Expecting opening angle bracket + if operator in ('>', ')', ']'): + nesting_stack.append(operator) + elif operator == '<': + nesting_stack.pop() + if not nesting_stack: + # Found matching angle bracket + return True + elif operator == ',': + # Got a comma before a bracket, this is most likely a + # template argument. The opening angle bracket is probably + # there if we look for it, so just return early here. + return True + else: + # Got some other operator. + return False + + else: + # Expecting opening parenthesis or opening bracket + if operator in ('>', ')', ']'): + nesting_stack.append(operator) + elif operator in ('(', '['): + nesting_stack.pop() -def CheckSpacing(filename, clean_lines, linenum, error): + else: + # Scan the previous line + linenum -= 1 + if linenum < 0: + break + line = clean_lines.elided[linenum] + + # Exhausted all earlier lines and still no matching angle bracket. + return False + + +def CheckSpacing(filename, clean_lines, linenum, nesting_state, error): """Checks for the correctness of various spacing issues in the code. Things we check for: spaces around operators, spaces after @@ -1692,6 +2219,8 @@ def CheckSpacing(filename, clean_lines, linenum, error): filename: The name of the current file. clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. + nesting_state: A _NestingState instance which maintains information about + the current stack of nested blocks being parsed. error: The function to call with any errors found. """ @@ -1701,7 +2230,16 @@ def CheckSpacing(filename, clean_lines, linenum, error): # Before nixing comments, check if the line is blank for no good # reason. This includes the first line after a block is opened, and # blank lines at the end of a function (ie, right before a line like '}' - if IsBlankLine(line): + # + # Skip all the blank line checks if we are immediately inside a + # namespace body. In other words, don't issue blank line warnings + # for this block: + # namespace { + # + # } + # + # A warning about missing end of namespace comments will be issued instead. + if IsBlankLine(line) and not nesting_state.InNamespaceBody(): elided = clean_lines.elided prev_line = elided[linenum - 1] prevbrace = prev_line.rfind('{') @@ -1709,8 +2247,7 @@ def CheckSpacing(filename, clean_lines, linenum, error): # both start with alnums and are indented the same amount. # This ignores whitespace at the start of a namespace block # because those are not usually indented. - if (prevbrace != -1 and prev_line[prevbrace:].find('}') == -1 - and prev_line[:prevbrace].find('namespace') == -1): + if prevbrace != -1 and prev_line[prevbrace:].find('}') == -1: # OK, we have a blank line at the start of a code block. Before we # complain, we check if it is an exception to the rule: The previous # non-empty line has the parameters of a function header that are indented @@ -1742,12 +2279,7 @@ def CheckSpacing(filename, clean_lines, linenum, error): if not exception: error(filename, linenum, 'whitespace/blank_line', 2, 'Blank line at the start of a code block. Is this needed?') - # This doesn't ignore whitespace at the end of a namespace block - # because that is too hard without pairing open/close braces; - # however, a special exception is made for namespace closing - # brackets which have a comment containing "namespace". - # - # Also, ignore blank lines at the end of a block in a long if-else + # Ignore blank lines at the end of a block in a long if-else # chain, like this: # if (condition1) { # // Something followed by a blank line @@ -1759,7 +2291,6 @@ def CheckSpacing(filename, clean_lines, linenum, error): next_line = raw[linenum + 1] if (next_line and Match(r'\s*}', next_line) - and next_line.find('namespace') == -1 and next_line.find('} else ') == -1): error(filename, linenum, 'whitespace/blank_line', 3, 'Blank line at the end of a code block. Is this needed?') @@ -1820,26 +2351,59 @@ def CheckSpacing(filename, clean_lines, linenum, error): # though, so we punt on this one for now. TODO. # You should always have whitespace around binary operators. - # Alas, we can't test < or > because they're legitimately used sans spaces - # (a->b, vector a). The only time we can tell is a < with no >, and - # only if it's not template params list spilling into the next line. + # + # Check <= and >= first to avoid false positives with < and >, then + # check non-include lines for spacing around < and >. match = Search(r'[^<>=!\s](==|!=|<=|>=)[^<>=!\s]', line) - if not match: - # Note that while it seems that the '<[^<]*' term in the following - # regexp could be simplified to '<.*', which would indeed match - # the same class of strings, the [^<] means that searching for the - # regexp takes linear rather than quadratic time. - if not Search(r'<[^<]*,\s*$', line): # template params spill - match = Search(r'[^<>=!\s](<)[^<>=!\s]([^>]|->)*$', line) if match: error(filename, linenum, 'whitespace/operators', 3, 'Missing spaces around %s' % match.group(1)) - # We allow no-spaces around << and >> when used like this: 10<<20, but + # We allow no-spaces around << when used like this: 10<<20, but # not otherwise (particularly, not when used as streams) - match = Search(r'[^0-9\s](<<|>>)[^0-9\s]', line) + match = Search(r'(\S)(?:L|UL|ULL|l|ul|ull)?<<(\S)', line) + if match and not (match.group(1).isdigit() and match.group(2).isdigit()): + error(filename, linenum, 'whitespace/operators', 3, + 'Missing spaces around <<') + elif not Match(r'#.*include', line): + # Avoid false positives on -> + reduced_line = line.replace('->', '') + + # Look for < that is not surrounded by spaces. This is only + # triggered if both sides are missing spaces, even though + # technically should should flag if at least one side is missing a + # space. This is done to avoid some false positives with shifts. + match = Search(r'[^\s<]<([^\s=<].*)', reduced_line) + if (match and + not FindNextMatchingAngleBracket(clean_lines, linenum, match.group(1))): + error(filename, linenum, 'whitespace/operators', 3, + 'Missing spaces around <') + + # Look for > that is not surrounded by spaces. Similar to the + # above, we only trigger if both sides are missing spaces to avoid + # false positives with shifts. + match = Search(r'^(.*[^\s>])>[^\s=>]', reduced_line) + if (match and + not FindPreviousMatchingAngleBracket(clean_lines, linenum, + match.group(1))): + error(filename, linenum, 'whitespace/operators', 3, + 'Missing spaces around >') + + # We allow no-spaces around >> for almost anything. This is because + # C++11 allows ">>" to close nested templates, which accounts for + # most cases when ">>" is not followed by a space. + # + # We still warn on ">>" followed by alpha character, because that is + # likely due to ">>" being used for right shifts, e.g.: + # value >> alpha + # + # When ">>" is used to close templates, the alphanumeric letter that + # follows would be part of an identifier, and there should still be + # a space separating the template type and the identifier. + # type> alpha + match = Search(r'>>[a-zA-Z_]', line) if match: error(filename, linenum, 'whitespace/operators', 3, - 'Missing spaces around %s' % match.group(1)) + 'Missing spaces around >>') # There shouldn't be space around unary operators match = Search(r'(!\s|~\s|[\s]--[\s;]|[\s]\+\+[\s;])', line) @@ -1913,16 +2477,23 @@ def CheckSpacing(filename, clean_lines, linenum, error): # the semicolon there. if Search(r':\s*;\s*$', line): error(filename, linenum, 'whitespace/semicolon', 5, - 'Semicolon defining empty statement. Use { } instead.') + 'Semicolon defining empty statement. Use {} instead.') elif Search(r'^\s*;\s*$', line): error(filename, linenum, 'whitespace/semicolon', 5, 'Line contains only semicolon. If this should be an empty statement, ' - 'use { } instead.') + 'use {} instead.') elif (Search(r'\s+;\s*$', line) and not Search(r'\bfor\b', line)): error(filename, linenum, 'whitespace/semicolon', 5, 'Extra space before last semicolon. If this should be an empty ' - 'statement, use { } instead.') + 'statement, use {} instead.') + + # In range-based for, we wanted spaces before and after the colon, but + # not around "::" tokens that might appear. + if (Search('for *\(.*[^:]:[^: ]', line) or + Search('for *\(.*[^: ]:[^:]', line)): + error(filename, linenum, 'whitespace/forcolon', 2, + 'Missing space around colon in range-based for loop') def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): @@ -1948,8 +2519,8 @@ def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): # # If we didn't find the end of the class, last_line would be zero, # and the check will be skipped by the first condition. - if (class_info.last_line - class_info.linenum <= 24 or - linenum <= class_info.linenum): + if (class_info.last_line - class_info.starting_linenum <= 24 or + linenum <= class_info.starting_linenum): return matched = Match(r'\s*(public|protected|private):', clean_lines.lines[linenum]) @@ -1960,15 +2531,18 @@ def CheckSectionSpacing(filename, clean_lines, class_info, linenum, error): # - We are at the beginning of the class. # - We are forward-declaring an inner class that is semantically # private, but needed to be public for implementation reasons. + # Also ignores cases where the previous line ends with a backslash as can be + # common when defining classes in C macros. prev_line = clean_lines.lines[linenum - 1] if (not IsBlankLine(prev_line) and - not Search(r'\b(class|struct)\b', prev_line)): + not Search(r'\b(class|struct)\b', prev_line) and + not Search(r'\\$', prev_line)): # Try a bit harder to find the beginning of the class. This is to # account for multi-line base-specifier lists, e.g.: # class Derived # : public Base { - end_class_head = class_info.linenum - for i in range(class_info.linenum, linenum): + end_class_head = class_info.starting_linenum + for i in range(class_info.starting_linenum, linenum): if Search(r'\{\s*$', clean_lines.lines[i]): end_class_head = i break @@ -2018,9 +2592,11 @@ def CheckBraces(filename, clean_lines, linenum, error): # which is commonly used to control the lifetime of # stack-allocated variables. We don't detect this perfectly: we # just don't complain if the last non-whitespace character on the - # previous non-blank line is ';', ':', '{', or '}'. + # previous non-blank line is ';', ':', '{', or '}', or if the previous + # line starts a preprocessor block. prevline = GetPreviousNonBlankLine(clean_lines, linenum)[0] - if not Search(r'[;:}{]\s*$', prevline): + if (not Search(r'[;:}{]\s*$', prevline) and + not Match(r'\s*#', prevline)): error(filename, linenum, 'whitespace/braces', 4, '{ should almost always be at the end of the previous line') @@ -2074,6 +2650,33 @@ def CheckBraces(filename, clean_lines, linenum, error): "You don't need a ; after a }") +def CheckEmptyLoopBody(filename, clean_lines, linenum, error): + """Loop for empty loop body with only a single semicolon. + + 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. + """ + + # Search for loop keywords at the beginning of the line. Because only + # whitespaces are allowed before the keywords, this will also ignore most + # do-while-loops, since those lines should start with closing brace. + line = clean_lines.elided[linenum] + if Match(r'\s*(for|while)\s*\(', line): + # Find the end of the conditional expression + (end_line, end_linenum, end_pos) = CloseExpression( + clean_lines, linenum, line.find('(')) + + # Output warning if what follows the condition expression is a semicolon. + # No warning for all other cases, including whitespace or newline, since we + # have a separate check for semicolons preceded by whitespace. + if end_pos >= 0 and Match(r';', end_line[end_pos:]): + error(filename, end_linenum, 'whitespace/empty_loop_body', 5, + 'Empty loop bodies should use {} or continue') + + def ReplaceableCheck(operator, macro, line): """Determine whether a basic CHECK can be replaced with a more specific one. @@ -2142,6 +2745,38 @@ def CheckCheck(filename, clean_lines, linenum, error): break +def CheckAltTokens(filename, clean_lines, linenum, error): + """Check alternative keywords being used in boolean expressions. + + 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. + """ + line = clean_lines.elided[linenum] + + # Avoid preprocessor lines + if Match(r'^\s*#', line): + return + + # Last ditch effort to avoid multi-line comments. This will not help + # if the comment started before the current line or ended after the + # current line, but it catches most of the false positives. At least, + # it provides a way to workaround this warning for people who use + # multi-line comments in preprocessor macros. + # + # TODO(unknown): remove this once cpplint has better support for + # multi-line comments. + if line.find('/*') >= 0 or line.find('*/') >= 0: + return + + for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line): + error(filename, linenum, 'readability/alt_tokens', 2, + 'Use operator %s instead of %s' % ( + _ALT_TOKEN_REPLACEMENT[match.group(1)], match.group(1))) + + def GetLineWidth(line): """Determines the width of the line in column positions. @@ -2164,7 +2799,7 @@ def GetLineWidth(line): return len(line) -def CheckStyle(filename, clean_lines, linenum, file_extension, class_state, +def CheckStyle(filename, clean_lines, linenum, file_extension, nesting_state, error): """Checks rules from the 'C++ style rules' section of cppguide.html. @@ -2177,6 +2812,8 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, class_state, clean_lines: A CleansedLines instance containing the file. linenum: The number of the line to check. file_extension: The extension (without the dot) of the filename. + nesting_state: A _NestingState instance which maintains information about + the current stack of nested blocks being parsed. error: The function to call with any errors found. """ @@ -2258,16 +2895,19 @@ def CheckStyle(filename, clean_lines, linenum, file_extension, class_state, not ((cleansed_line.find('case ') != -1 or cleansed_line.find('default:') != -1) and cleansed_line.find('break;') != -1)): - error(filename, linenum, 'whitespace/newline', 4, + error(filename, linenum, 'whitespace/newline', 0, 'More than one command on the same line') # Some more style checks CheckBraces(filename, clean_lines, linenum, error) - CheckSpacing(filename, clean_lines, linenum, error) + CheckEmptyLoopBody(filename, clean_lines, linenum, error) + CheckAccess(filename, clean_lines, linenum, nesting_state, error) + CheckSpacing(filename, clean_lines, linenum, nesting_state, error) CheckCheck(filename, clean_lines, linenum, error) - if class_state and class_state.classinfo_stack: - CheckSectionSpacing(filename, clean_lines, - class_state.classinfo_stack[-1], linenum, error) + CheckAltTokens(filename, clean_lines, linenum, error) + classinfo = nesting_state.InnermostClass() + if classinfo: + CheckSectionSpacing(filename, clean_lines, classinfo, linenum, error) _RE_PATTERN_INCLUDE_NEW_STYLE = re.compile(r'#include +"[^/]+\.h"') @@ -2564,9 +3204,11 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, fnline))): # We allow non-const references in a few standard places, like functions - # called "swap()" or iostream operators like "<<" or ">>". + # called "swap()" or iostream operators like "<<" or ">>". We also filter + # out for loops, which lint otherwise mistakenly thinks are functions. if not Search( - r'(swap|Swap|operator[<>][<>])\s*\(\s*(?:[\w:]|<.*>)+\s*&', + r'(for|swap|Swap|operator[<>][<>])\s*\(\s*' + r'(?:(?:typename\s*)?[\w:]|<.*>)+\s*&', fnline): error(filename, linenum, 'runtime/references', 2, 'Is this a non-const reference? ' @@ -2578,7 +3220,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, # probably a member operator declaration or default constructor. match = Search( r'(\bnew\s+)?\b' # Grab 'new' operator, if it's there - r'(int|float|double|bool|char|u?int(8|16|32|64)_t)\([^)]', line) # TODO(enh): upstream change to handle all stdint types. + r'(int|float|double|bool|char|int32|uint32|int64|uint64)\([^)]', line) if match: # gMock methods are defined using some variant of MOCK_METHODx(name, type) # where type may be float(), int(string), etc. Without context they are @@ -2588,14 +3230,23 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, if (match.group(1) is None and # If new operator, then this isn't a cast not (Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(', line) or Match(r'^\s*MockCallback<.*>', line))): - error(filename, linenum, 'readability/casting', 4, - 'Using deprecated casting style. ' - 'Use static_cast<%s>(...) instead' % - match.group(2)) + # Try a bit harder to catch gmock lines: the only place where + # something looks like an old-style cast is where we declare the + # return type of the mocked method, and the only time when we + # are missing context is if MOCK_METHOD was split across + # multiple lines (for example http://go/hrfhr ), so we only need + # to check the previous line for MOCK_METHOD. + if (linenum == 0 or + not Match(r'^\s*MOCK_(CONST_)?METHOD\d+(_T)?\(\S+,\s*$', + clean_lines.elided[linenum - 1])): + error(filename, linenum, 'readability/casting', 4, + 'Using deprecated casting style. ' + 'Use static_cast<%s>(...) instead' % + match.group(2)) CheckCStyleCast(filename, linenum, line, clean_lines.raw_lines[linenum], 'static_cast', - r'\((int|float|double|bool|char|u?int(8|16|32|64))\)', error) # TODO(enh): upstream change to handle all stdint types. + r'\((int|float|double|bool|char|u?int(16|32|64))\)', error) # This doesn't catch all cases. Consider (const char * const)"hello". # @@ -2713,7 +3364,7 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension, include_state, printf_args = _GetTextInside(line, r'(?i)\b(string)?printf\s*\(') if printf_args: match = Match(r'([\w.\->()]+)$', printf_args) - if match: + if match and match.group(1) != '__VA_ARGS__': function_name = re.search(r'\b((?:string)?printf)\s*\(', line, re.I).group(1) error(filename, linenum, 'runtime/printf', 4, @@ -2834,6 +3485,11 @@ def CheckCStyleCast(filename, linenum, line, raw_line, cast_type, pattern, 'Using sizeof(type). Use sizeof(varname) instead if possible') return True + # operator++(int) and operator--(int) + if (line[0:match.start(1) - 1].endswith(' operator++') or + line[0:match.start(1) - 1].endswith(' operator--')): + return False + remainder = line[match.end(0):] # The close paren is for function pointers as arguments to a function. @@ -3122,13 +3778,13 @@ def CheckMakePairUsesDeduction(filename, clean_lines, linenum, error): if match: error(filename, linenum, 'build/explicit_make_pair', 4, # 4 = high confidence - 'Omit template arguments from make_pair OR use pair directly OR' - ' if appropriate, construct a pair directly') + 'For C++11-compatibility, omit template arguments from make_pair' + ' OR use pair directly OR if appropriate, construct a pair directly') -def ProcessLine(filename, file_extension, - clean_lines, line, include_state, function_state, - class_state, error, extra_check_functions=[]): +def ProcessLine(filename, file_extension, clean_lines, line, + include_state, function_state, nesting_state, error, + extra_check_functions=[]): """Processes a single line in the file. Args: @@ -3139,8 +3795,8 @@ def ProcessLine(filename, file_extension, line: Number of line being processed. include_state: An _IncludeState instance in which the headers are inserted. function_state: A _FunctionState instance which counts function lines, etc. - class_state: A _ClassState instance which maintains information about - the current stack of nested class declarations being parsed. + nesting_state: A _NestingState instance which maintains information about + the current stack of nested blocks being parsed. error: A callable to which errors are reported, which takes 4 arguments: filename, line number, error level, and message extra_check_functions: An array of additional check functions that will be @@ -3149,13 +3805,16 @@ def ProcessLine(filename, file_extension, """ raw_lines = clean_lines.raw_lines ParseNolintSuppressions(filename, raw_lines[line], line, error) + nesting_state.Update(filename, clean_lines, line, error) + if nesting_state.stack and nesting_state.stack[-1].inline_asm != _NO_ASM: + return CheckForFunctionLengths(filename, clean_lines, line, function_state, error) CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error) - CheckStyle(filename, clean_lines, line, file_extension, class_state, error) + CheckStyle(filename, clean_lines, line, file_extension, nesting_state, error) CheckLanguage(filename, clean_lines, line, file_extension, include_state, error) CheckForNonStandardConstructs(filename, clean_lines, line, - class_state, error) + nesting_state, error) CheckPosixThreading(filename, clean_lines, line, error) CheckInvalidIncrement(filename, clean_lines, line, error) CheckMakePairUsesDeduction(filename, clean_lines, line, error) @@ -3182,7 +3841,7 @@ def ProcessFileData(filename, file_extension, lines, error, include_state = _IncludeState() function_state = _FunctionState() - class_state = _ClassState() + nesting_state = _NestingState() ResetNolintSuppressions() @@ -3195,9 +3854,9 @@ def ProcessFileData(filename, file_extension, lines, error, clean_lines = CleansedLines(lines) for line in xrange(clean_lines.NumLines()): ProcessLine(filename, file_extension, clean_lines, line, - include_state, function_state, class_state, error, + include_state, function_state, nesting_state, error, extra_check_functions) - class_state.CheckFinished(filename, error) + nesting_state.CheckClassFinished(filename, error) CheckForIncludeWhatYouUse(filename, clean_lines, include_state, error) @@ -3312,7 +3971,8 @@ def ParseArguments(args): (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', 'stdout', # TODO(enh): added --stdout 'counting=', - 'filter=']) + 'filter=', + 'root=']) except getopt.GetoptError: PrintUsage('Invalid arguments.') @@ -3328,8 +3988,8 @@ def ParseArguments(args): elif opt == '--stdout': # TODO(enh): added --stdout output_stream = sys.stdout # TODO(enh): added --stdout elif opt == '--output': - if not val in ('emacs', 'vs7'): - PrintUsage('The only allowed output formats are emacs and vs7.') + if not val in ('emacs', 'vs7', 'eclipse'): + PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.') output_format = val elif opt == '--verbose': verbosity = int(val) @@ -3341,6 +4001,9 @@ def ParseArguments(args): if val not in ('total', 'toplevel', 'detailed'): PrintUsage('Valid counting options are total, toplevel, and detailed') counting_style = val + elif opt == '--root': + global _root + _root = val if not filenames: PrintUsage('No files were specified.') @@ -3349,7 +4012,6 @@ def ParseArguments(args): _SetVerboseLevel(verbosity) _SetFilters(filters) _SetCountingStyle(counting_style) - sys.stderr = output_stream # TODO(enh): added --stdout return filenames -- cgit v1.2.3-59-g8ed1b