• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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;
bar()14 static Bar* bar() {
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 (*functionPointer)(int, int) = &testFunctionThatTakesTwoInts;
50 }
51 
52 void bug640688(int);  // Declaration within blink namespace.
53 
54 // Tests for --method-blocklist cmdline parameter.
55 namespace IdlFunctions {
56 void foo();
57 }  // namespace IdlFunctions
58 
59 }  // namespace blink
60 
61 // Definition outside of blink namespace.
bug640688(int myParam)62 void blink::bug640688(int myParam) {
63   char myVariable = 'c';
64 }
65 
66 using blink::testFunctionThatTakesTwoInts;
67 
G()68 void G() {
69   testFunctionThatTakesTwoInts(1, 2);
70 
71   blink::SwapType a, b;
72   swap(a, b);
73 }
74