blob: bead20fecd54c660570e769e6f15a2845697e9e7 [file] [log] [blame]
Dominic Chen184c6242017-03-03 18:02:02 +00001// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store region -verify %s
Andy Gibbsc6e68da2012-10-19 12:44:48 +00002// expected-no-diagnostics
Anna Zaks5f847142011-12-20 22:35:30 +00003
4// Intra-procedural C++ tests.
5
6// Test relaxing function call arguments invalidation to be aware of const
7// arguments. radar://10595327
8struct InvalidateArgs {
9 void ttt(const int &nptr);
10 virtual void vttt(const int *nptr);
11};
12struct ChildOfInvalidateArgs: public InvalidateArgs {
13 virtual void vttt(const int *nptr);
14};
15void declarationFun(int x) {
16 InvalidateArgs t;
17 x = 3;
18 int y = x + 1;
19 int *p = 0;
20 t.ttt(y);
21 if (x == y)
22 y = *p; // no-warning
23}
24void virtualFun(int x) {
25 ChildOfInvalidateArgs t;
26 InvalidateArgs *pt = &t;
27 x = 3;
28 int y = x + 1;
29 int *p = 0;
30 pt->vttt(&y);
31 if (x == y)
32 y = *p; // no-warning
33}