blob: 8057f2fda1c609cd93a4426bdc7ab6f4896e52bf [file] [log] [blame]
Edwin Vane8ef7fa12013-04-09 20:49:49 +00001.. index:: Add-Override Transform
2
3======================
4Add-Override Transform
5======================
6
7The Add-Override Transform adds the ``override`` specifier to member
8functions that override a virtual function in a base class and that
9don't already have the specifier. The transform is enabled with the
10:option:`-add-override` option of :program:`cpp11-migrate`.
11For example:
12
13.. code-block:: c++
14
15 class A {
16 public:
17 virtual void h() const;
18 };
19
20 class B : public A {
21 public:
22 void h() const;
23
24 // The declaration of h is transformed to
25 void h() const override;
26 };
27
28
29Known Limitations
30-----------------
31* This transform will fail if a method declaration has an inlined method
32 body and there is a comment between the method declaration and the body.
33 In this case, the override keyword will incorrectly be inserted at the
34 end of the comment.
35
36.. code-block:: c++
37
38 class B : public A {
39 public:
40 virtual void h() const // comment
41 { }
42
43 // The declaration of h is transformed to
44 virtual void h() const // comment override
45 { }
46 };
47