Index: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp @@ -38,11 +38,16 @@ File.end()); SmallVector Tokens; Token Tok; + int NestedParens = 0; while (!RawLexer.LexFromRawLexer(Tok)) { - if (Tok.is(tok::semi) || Tok.is(tok::l_brace)) + if ((Tok.is(tok::semi) || Tok.is(tok::l_brace)) && NestedParens == 0) break; if (Sources.isBeforeInTranslationUnit(Range.getEnd(), Tok.getLocation())) break; + if (Tok.is(tok::l_paren)) + ++NestedParens; + else if (Tok.is(tok::r_paren)) + --NestedParens; if (Tok.is(tok::raw_identifier)) { IdentifierInfo &Info = Result.Context->Idents.get(StringRef( Sources.getCharacterData(Tok.getLocation()), Tok.getLength())); Index: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp @@ -12,6 +12,10 @@ struct MUST_USE_RESULT MustUseResultObject {}; +struct IntPair { + int First, Second; +}; + struct Base { virtual ~Base() {} virtual void a(); @@ -41,6 +45,8 @@ virtual void ne() noexcept(false); virtual void t() throw(); + + virtual void il(IntPair); }; struct SimpleCases : public Base { @@ -221,6 +227,14 @@ // CHECK-FIXES: {{^}} void cv2() const volatile override // some comment }; +struct DefaultArguments : public Base { + // Tests for default arguments (with initializer lists). + // Make sure the override fix is placed after the argument list. + void il(IntPair p = {1, (2 + (3))}) {} + // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this + // CHECK-FIXES: {{^}} void il(IntPair p = {1, (2 + (3))}) override {} +}; + struct Macros : public Base { // Tests for 'virtual' and 'override' being defined through macros. Basically // give up for now.