Home | History | Annotate | Download | only in Analysis
      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
      7 struct InvalidateArgs {
      8   void ttt(const int &nptr);
      9   virtual void vttt(const int *nptr);
     10 };
     11 struct ChildOfInvalidateArgs: public InvalidateArgs {
     12   virtual void vttt(const int *nptr);
     13 };
     14 void 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 }
     23 void 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