| Index: tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
|
| diff --git a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
|
| index eced8e2d4ff3c77b31cae9180377157432352bf9..97f7cfea312f98c2494524029b2f32cc8ea6ce36 100644
|
| --- a/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
|
| +++ b/tools/clang/rewrite_to_chrome_style/RewriteToChromeStyle.cpp
|
| @@ -1214,28 +1214,29 @@ class GMockMemberRewriter
|
| // Find location of the gmock_##MockedMethod identifier.
|
| clang::SourceLocation target_loc = Base::GetTargetLoc(result);
|
|
|
| - // Find location of EXPECT_CALL macro invocation.
|
| + // Find location of EXPECT_CALL or ON_CALL macro invocation.
|
| clang::SourceLocation macro_call_loc =
|
| result.SourceManager->getExpansionLoc(target_loc);
|
|
|
| // Map |macro_call_loc| to argument location (location of the method name
|
| // that needs renaming).
|
| - auto it = expect_call_to_2nd_arg.find(macro_call_loc);
|
| - if (it == expect_call_to_2nd_arg.end())
|
| + auto it = gmock_macro_call_to_2nd_arg.find(macro_call_loc);
|
| + if (it == gmock_macro_call_to_2nd_arg.end())
|
| return clang::SourceLocation();
|
| return it->second;
|
| }
|
|
|
| private:
|
| - std::map<clang::SourceLocation, clang::SourceLocation> expect_call_to_2nd_arg;
|
| + std::map<clang::SourceLocation, clang::SourceLocation>
|
| + gmock_macro_call_to_2nd_arg;
|
|
|
| - // Called from PPCallbacks with the locations of EXPECT_CALL macro invocation:
|
| - // Example:
|
| + // Called from PPCallbacks with the locations of EXPECT_CALL and ON_CALL macro
|
| + // invocation. Example:
|
| // EXPECT_CALL(my_mock, myMethod(123, 456));
|
| // ^- expansion_loc ^- actual_arg_loc
|
| - void RecordExpectCallMacroInvocation(clang::SourceLocation expansion_loc,
|
| - clang::SourceLocation second_arg_loc) {
|
| - expect_call_to_2nd_arg[expansion_loc] = second_arg_loc;
|
| + void RecordGMockMacroInvocation(clang::SourceLocation expansion_loc,
|
| + clang::SourceLocation second_arg_loc) {
|
| + gmock_macro_call_to_2nd_arg[expansion_loc] = second_arg_loc;
|
| }
|
|
|
| class PPCallbacks : public clang::PPCallbacks {
|
| @@ -1250,7 +1251,7 @@ class GMockMemberRewriter
|
| if (!id)
|
| return;
|
|
|
| - if (id->getName() != "EXPECT_CALL")
|
| + if (id->getName() != "EXPECT_CALL" && id->getName() != "ON_CALL")
|
| return;
|
|
|
| if (def.getMacroInfo()->getNumArgs() != 2)
|
| @@ -1260,7 +1261,7 @@ class GMockMemberRewriter
|
| // is in testing/gmock/include/gmock/gmock-spec-builders.h but I don't
|
| // know how to get clang::SourceManager to call getFileName.
|
|
|
| - rewriter_->RecordExpectCallMacroInvocation(
|
| + rewriter_->RecordGMockMacroInvocation(
|
| name.getLocation(), args->getUnexpArgument(1)->getLocation());
|
| }
|
|
|
| @@ -1818,7 +1819,9 @@ int main(int argc, const char* argv[]) {
|
| // GMock calls lookup ========
|
| // Given
|
| // EXPECT_CALL(obj, myMethod(...))
|
| - // will match obj.gmock_myMethod(...) call generated by the macro
|
| + // or
|
| + // ON_CALL(obj, myMethod(...))
|
| + // will match obj.gmock_myMethod(...) call generated by the macros
|
| // (but only if it mocks a Blink method).
|
| auto gmock_member_matcher =
|
| id("expr", memberExpr(hasDeclaration(
|
|
|