Artem Dergachev | 71ee164 | 2019-09-06 20:55:29 +0000 | [diff] [blame] | 1 | // RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.VirtualCall \ |
| 2 | // RUN: -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true \ |
| 3 | // RUN: %s 2>&1 | FileCheck -check-prefix=TEXT %s |
| 4 | // RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.VirtualCall \ |
| 5 | // RUN: -analyzer-config optin.cplusplus.VirtualCall:ShowFixIts=true \ |
| 6 | // RUN: -analyzer-config fixits-as-remarks=true \ |
| 7 | // RUN: -analyzer-output=plist -o %t.plist -verify %s |
| 8 | // RUN: cat %t.plist | FileCheck -check-prefix=PLIST %s |
| 9 | |
| 10 | struct S { |
| 11 | virtual void foo(); |
| 12 | S() { |
| 13 | foo(); |
| 14 | // expected-warning@-1{{Call to virtual method 'S::foo' during construction bypasses virtual dispatch}} |
| 15 | // expected-remark@-2{{5-5: 'S::'}} |
| 16 | } |
| 17 | ~S(); |
| 18 | }; |
| 19 | |
| 20 | // TEXT: warning: Call to virtual method 'S::foo' during construction |
| 21 | // TEXT-SAME: bypasses virtual dispatch |
| 22 | // TEXT-NEXT: foo(); |
| 23 | // TEXT-NEXT: ^~~~~ |
| 24 | // TEXT-NEXT: S:: |
| 25 | // TEXT-NEXT: 1 warning generated. |
| 26 | |
| 27 | // PLIST: <key>fixits</key> |
| 28 | // PLIST-NEXT: <array> |
| 29 | // PLIST-NEXT: <dict> |
| 30 | // PLIST-NEXT: <key>remove_range</key> |
| 31 | // PLIST-NEXT: <array> |
| 32 | // PLIST-NEXT: <dict> |
| 33 | // PLIST-NEXT: <key>line</key><integer>13</integer> |
| 34 | // PLIST-NEXT: <key>col</key><integer>5</integer> |
| 35 | // PLIST-NEXT: <key>file</key><integer>0</integer> |
| 36 | // PLIST-NEXT: </dict> |
| 37 | // PLIST-NEXT: <dict> |
| 38 | // PLIST-NEXT: <key>line</key><integer>13</integer> |
| 39 | // PLIST-NEXT: <key>col</key><integer>4</integer> |
| 40 | // PLIST-NEXT: <key>file</key><integer>0</integer> |
| 41 | // PLIST-NEXT: </dict> |
| 42 | // PLIST-NEXT: </array> |
| 43 | // PLIST-NEXT: <key>insert_string</key><string>S::</string> |
| 44 | // PLIST-NEXT: </dict> |
| 45 | // PLIST-NEXT: </array> |