method-call-intra-p.cpp revision 2cbe791d3e9b26f30196c4852da75d9ad67b4ad9
1// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
2
3// Intra-procedural C++ tests.
4
5// Test relaxing function call arguments invalidation to be aware of const
6// arguments. radar://10595327
7struct InvalidateArgs {
8  void ttt(const int &nptr);
9  virtual void vttt(const int *nptr);
10};
11struct ChildOfInvalidateArgs: public InvalidateArgs {
12  virtual void vttt(const int *nptr);
13};
14void declarationFun(int x) {
15  InvalidateArgs t;
16  x = 3;
17  int y = x + 1;
18  int *p = 0;
19  t.ttt(y);
20  if (x == y)
21      y = *p; // no-warning
22}
23void virtualFun(int x) {
24  ChildOfInvalidateArgs t;
25  InvalidateArgs *pt = &t;
26  x = 3;
27  int y = x + 1;
28  int *p = 0;
29  pt->vttt(&y);
30  if (x == y)
31      y = *p; // no-warning
32}
33