1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 namespace blink {
6
7 namespace {
8
9 // Naive renaming will break the build, by leaving return type the same name as
10 // the function name - to avoid this "Get" prefix needs to be prepended as
11 // suggested in https://crbug.com/582312#c17.
12 class Foo582312 {};
13 using Bar = Foo582312;
GetBar()14 static Bar* GetBar() {
15 return nullptr;
16 }
17
18 } // namespace
19
20 // Tests that the prototype for a function is updated.
21 int TestFunctionThatTakesTwoInts(int x, int y);
22 // Overload to test using declarations that introduce multiple shadow
23 // declarations.
24 int TestFunctionThatTakesTwoInts(int x, int y, int z);
25
26 // Test that the actual function definition is also updated.
TestFunctionThatTakesTwoInts(int x,int y)27 int TestFunctionThatTakesTwoInts(int x, int y) {
28 if (x == 0)
29 return y;
30 // Calls to the function also need to be updated.
31 return TestFunctionThatTakesTwoInts(x - 1, y + 1);
32 }
33
34 // This is named like the begin() method which isn't renamed, but
35 // here it's not a method so it should be.
Begin()36 void Begin() {}
37 // Same for trace() and friends.
Trace()38 void Trace() {}
Lock()39 void Lock() {}
40
41 class SwapType {};
42
43 // swap() functions are not renamed.
swap(SwapType & a,SwapType & b)44 void swap(SwapType& a, SwapType& b) {}
45
46 // Note: F is already Google style and should not change.
F()47 void F() {
48 // Test referencing a function without calling it.
49 int (*function_pointer)(int, int) = &TestFunctionThatTakesTwoInts;
50 }
51
52 void Bug640688(int); // Declaration within blink namespace.
53
54 } // namespace blink
55
56 // Definition outside of blink namespace.
Bug640688(int my_param)57 void blink::Bug640688(int my_param) {
58 char my_variable = 'c';
59 }
60
61 using blink::TestFunctionThatTakesTwoInts;
62
G()63 void G() {
64 TestFunctionThatTakesTwoInts(1, 2);
65
66 blink::SwapType a, b;
67 swap(a, b);
68 }
69