Skip to content
This repository has been archived by the owner on Jul 13, 2019. It is now read-only.

Commit

Permalink
Merge branch 'fix-rvalueref-whitespace'
Browse files Browse the repository at this point in the history
  • Loading branch information
tkruse committed Apr 24, 2016
2 parents ddd4ee2 + c8b472d commit f59a765
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpplint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2470,7 +2470,7 @@ def Update(self, filename, clean_lines, linenum, error):
# class LOCKABLE API Object {
# };
class_decl_match = Match(
r'^(\s*(?:template\s*<[\w\s<>,:]*>\s*)?'
r'^(\s*(?:template\s*<[\w\s<>,:=]*>\s*)?'
r'(class|struct)\s+(?:[A-Z_]+\s+)*(\w+(?:::\w+)*))'
r'(.*)$', line)
if (class_decl_match and
Expand Down Expand Up @@ -3541,7 +3541,7 @@ def IsRValueType(typenames, clean_lines, nesting_state, linenum, column):
# We want to skip over identifiers and commas to get to a symbol.
# Commas are skipped so that we can find the opening parenthesis
# for function parameter lists.
match_symbol = Match(r'^(.*)([^\w\s,])[\w\s,]*$', line)
match_symbol = Match(r'^(.*)([^\w\s,:&*])[\w\s,:&*]*$', line)
if match_symbol:
break
start -= 1
Expand Down
27 changes: 27 additions & 0 deletions cpplint_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,22 @@ def testCleanseLine(self):
cpplint.CleanseComments('f(a, /**/b/**/, c);'))

def testRawStrings(self):
self.TestMultiLineLint(
"""
int main() {
struct A {
A(std::string s, A&& a);
};
}""",
'RValue references are an unapproved C++ feature. [build/c++11] [3]')

self.TestMultiLineLint(
"""
template <class T, class D = default_delete<T>> class unique_ptr {
public:
unique_ptr(unique_ptr&& u) noexcept;
};""",
'RValue references are an unapproved C++ feature. [build/c++11] [3]')
self.TestMultiLineLint(
"""
void Func() {
Expand Down Expand Up @@ -2577,6 +2593,11 @@ def testRvalueReference(self):
self.TestLint('const a&& b = c;', rvalue_error)
self.TestLint('struct a&& b = c;', rvalue_error)
self.TestLint('decltype(a)&& b = c;', rvalue_error)
self.TestLint('A(int s, A&& a);', rvalue_error)
self.TestLint('A(std::string s, A&& a);', rvalue_error)
self.TestLint('A(const std::string &s, A&& a);', rvalue_error)
self.TestLint('A(int* s, A&& a);', rvalue_error)
self.TestLint('unique_ptr(unique_ptr&& u) noexcept;', rvalue_error)

# Cast expressions
self.TestLint('a = const_cast<b&&>(c);', rvalue_error)
Expand Down Expand Up @@ -5440,6 +5461,12 @@ def testTemplate(self):
self.assertTrue(isinstance(self.nesting_state.stack[0], cpplint._ClassInfo))
self.assertEquals(self.nesting_state.stack[0].name, 'K')

def testTemplateDefaultArg(self):
self.UpdateWithLines([
'template <class T, class D = default_delete<T>> class unique_ptr {',])
self.assertEquals(len(self.nesting_state.stack), 1)
self.assertTrue(self.nesting_state.stack[0], isinstance(self.nesting_state.stack[0], cpplint._ClassInfo))

def testTemplateInnerClass(self):
self.UpdateWithLines(['class A {',
' public:'])
Expand Down

0 comments on commit f59a765

Please sign in to comment.