head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC5:1.1.1.2
	netbsd-11-0-RC4:1.1.1.2
	netbsd-11-0-RC3:1.1.1.2
	netbsd-11-0-RC2:1.1.1.2
	netbsd-11-0-RC1:1.1.1.2
	perseant-exfatfs-base-20250801:1.1.1.2
	netbsd-11:1.1.1.2.0.10
	netbsd-11-base:1.1.1.2
	netbsd-10-1-RELEASE:1.1.1.2
	perseant-exfatfs-base-20240630:1.1.1.2
	perseant-exfatfs:1.1.1.2.0.8
	perseant-exfatfs-base:1.1.1.2
	netbsd-9-4-RELEASE:1.1.1.1
	netbsd-10-0-RELEASE:1.1.1.2
	netbsd-10-0-RC6:1.1.1.2
	netbsd-10-0-RC5:1.1.1.2
	netbsd-10-0-RC4:1.1.1.2
	netbsd-10-0-RC3:1.1.1.2
	netbsd-10-0-RC2:1.1.1.2
	netbsd-10-0-RC1:1.1.1.2
	netbsd-10:1.1.1.2.0.6
	netbsd-10-base:1.1.1.2
	netbsd-9-3-RELEASE:1.1.1.1
	cjep_sun2x:1.1.1.2.0.4
	cjep_sun2x-base:1.1.1.2
	cjep_staticlib_x-base1:1.1.1.2
	netbsd-9-2-RELEASE:1.1.1.1
	cjep_staticlib_x:1.1.1.2.0.2
	cjep_staticlib_x-base:1.1.1.2
	netbsd-9-1-RELEASE:1.1.1.1
	phil-wifi-20200421:1.1.1.2
	phil-wifi-20200411:1.1.1.2
	phil-wifi-20200406:1.1.1.2
	netbsd-9-0-RELEASE:1.1.1.1
	netbsd-9-0-RC2:1.1.1.1
	netbsd-9-0-RC1:1.1.1.1
	netbsd-9:1.1.1.1.0.6
	netbsd-9-base:1.1.1.1
	phil-wifi:1.1.1.1.0.4
	phil-wifi-20190609:1.1.1.1
	pgoyette-compat-merge-20190127:1.1.1.1.2.2
	pgoyette-compat-20190127:1.1.1.1
	pgoyette-compat-20190118:1.1.1.1
	pgoyette-compat-1226:1.1.1.1
	pgoyette-compat-1126:1.1.1.1
	pgoyette-compat-1020:1.1.1.1
	pgoyette-compat-0930:1.1.1.1
	pgoyette-compat-0906:1.1.1.1
	pgoyette-compat:1.1.1.1.0.2
	pgoyette-compat-0728:1.1.1.1
	clang-337282:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@// @;


1.1
date	2018.07.17.18.31.47;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	wDzL46ALjrCZgwKA;

1.1.1.1
date	2018.07.17.18.31.47;	author joerg;	state Exp;
branches
	1.1.1.1.2.1
	1.1.1.1.4.1;
next	1.1.1.2;
commitid	wDzL46ALjrCZgwKA;

1.1.1.2
date	2019.11.13.22.19.40;	author joerg;	state dead;
branches;
next	;
commitid	QD8YATxuNG34YJKB;

1.1.1.1.2.1
date	2018.07.17.18.31.47;	author pgoyette;	state dead;
branches;
next	1.1.1.1.2.2;
commitid	1UP1xAIUxv1ZgRLA;

1.1.1.1.2.2
date	2018.07.28.04.33.30;	author pgoyette;	state Exp;
branches;
next	;
commitid	1UP1xAIUxv1ZgRLA;

1.1.1.1.4.1
date	2018.07.17.18.31.47;	author christos;	state dead;
branches;
next	1.1.1.1.4.2;
commitid	jtc8rnCzWiEEHGqB;

1.1.1.1.4.2
date	2019.06.10.21.45.36;	author christos;	state Exp;
branches;
next	1.1.1.1.4.3;
commitid	jtc8rnCzWiEEHGqB;

1.1.1.1.4.3
date	2020.04.13.07.46.52;	author martin;	state dead;
branches;
next	;
commitid	X01YhRUPVUDaec4C;


desc
@@


1.1
log
@Initial revision
@
text
@// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=core -analyzer-output=text -verify %s

int initializer1(int &p, int x) {
  if (x) { // expected-note{{Taking false branch}}
    p = 1;
    return 0;
  } else {
    return 1; // expected-note {{Returning without writing to 'p'}}
  }
}

int param_not_initialized_by_func() {
  int p;                        // expected-note {{'p' declared without an initial value}}
  int out = initializer1(p, 0); // expected-note{{Calling 'initializer1'}}
                                // expected-note@@-1{{Returning from 'initializer1'}}
  return p;                     // expected-note{{Undefined or garbage value returned to caller}}
                                // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

struct S {
  int initialize(int *p, int param) {
    if (param) { //expected-note{{Taking false branch}}
      *p = 1;
      return 1;
    }
    return 0; // expected-note{{Returning without writing to '*p'}}
  }
};

int use(S *s) {
  int p;                //expected-note{{'p' declared without an initial value}}
  s->initialize(&p, 0); //expected-note{{Calling 'S::initialize'}}
                        //expected-note@@-1{{Returning from 'S::initialize'}}
  return p;             // expected-warning{{Undefined or garbage value returned to caller}}
                        // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

int initializer2(const int &p) {
  return 0;
}

int no_msg_const_ref() {
  int p; //expected-note{{'p' declared without an initial value}}
  initializer2(p);
  return p; // expected-warning{{Undefined or garbage value returned to caller}}
            // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

void nested() {}
void init_in_nested_func(int **x) {
  *x = 0; // expected-note{{Null pointer value stored to 'y'}}
  nested();
} // no-note

int call_init_nested() {
  int x = 0;
  int *y = &x;
  init_in_nested_func(&y); // expected-note{{Calling 'init_in_nested_func'}}
                           // expected-note@@-1{{Returning from 'init_in_nested_func'}}
  return *y;               //expected-warning{{Dereference of null pointer (loaded from variable 'y')}}
                           //expected-note@@-1{{Dereference of null pointer (loaded from variable 'y')}}
}

struct A {
  int x;
  int y;
};

void partial_init_by_reference(A &a) {
  a.x = 0;
} // expected-note {{Returning without writing to 'a.y'}}

int use_partial_init_by_reference() {
  A a;
  partial_init_by_reference(a); // expected-note{{Calling 'partial_init_by_reference'}}
                                // expected-note@@-1{{Returning from 'partial_init_by_reference'}}
  return a.y;                   // expected-warning{{Undefined or garbage value returned to caller}}
                                // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

struct B : A {
};

void partially_init_inherited_struct(B *b) {
  b->x = 0;
} // expected-note{{Returning without writing to 'b->y'}}

int use_partially_init_inherited_struct() {
  B b;
  partially_init_inherited_struct(&b); // expected-note{{Calling 'partially_init_inherited_struct'}}
                                       // expected-note@@-1{{Returning from 'partially_init_inherited_struct'}}
  return b.y;                          // expected-warning{{Undefined or garbage value returned to caller}}
                                       // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

struct C {
  int x;
  int y;
  C(int pX, int pY) : x(pX) {} // expected-note{{Returning without writing to 'this->y'}}
};

int use_constructor() {
  C c(0, 0); // expected-note{{Calling constructor for 'C'}}
             // expected-note@@-1{{Returning from constructor for 'C'}}
  return c.y; // expected-note{{Undefined or garbage value returned to caller}}
              // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

struct D {
  void initialize(int *);
};

void D::initialize(int *p) {

} // expected-note{{Returning without writing to '*p'}}

int use_d_initializer(D* d) {
  int p; // expected-note {{'p' declared without an initial value}}
  d->initialize(&p); // expected-note{{Calling 'D::initialize'}}
                     // expected-note@@-1{{Returning from 'D::initialize'}}
  return p;                     // expected-note{{Undefined or garbage value returned to caller}}
                                // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

int coin();

struct S2 {
  int x;
};

int pointerreference(S2* &s) {
  if (coin()) // expected-note{{Assuming the condition is true}}
              // expected-note@@-1{{Taking true branch}}
    return 1; // expected-note{{Returning without writing to 's->x'}}

  s->x = 0;
  return 0;
}

int usepointerreference() {
  S2 s;
  S2* p = &s;
  pointerreference(p); //expected-note{{Calling 'pointerreference'}}
                         //expected-note@@-1{{Returning from 'pointerreference'}}
  return s.x; // expected-warning{{Undefined or garbage value returned to caller}}
              // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

void *has_no_argument_and_returns_null(void) {
  return 0;
}

void rdar40335545() {
    int local; // expected-note{{}}
    void (*takes_int_ptr_argument)(int *) = (void (*)(int*))has_no_argument_and_returns_null;

    takes_int_ptr_argument(&local); // no-crash

    int useLocal = local; //expected-warning{{}}
                          //expected-note@@-1{{}}
    (void)useLocal;
}
@


1.1.1.1
log
@Import clang r337282 from trunk
@
text
@@


1.1.1.2
log
@Mark old LLVM instance as dead.
@
text
@@


1.1.1.1.4.1
log
@file no-store-func-path-notes.cpp was added on branch phil-wifi on 2019-06-10 21:45:36 +0000
@
text
@d1 162
@


1.1.1.1.4.2
log
@Sync with HEAD
@
text
@a0 162
// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=core -analyzer-output=text -verify %s

int initializer1(int &p, int x) {
  if (x) { // expected-note{{Taking false branch}}
    p = 1;
    return 0;
  } else {
    return 1; // expected-note {{Returning without writing to 'p'}}
  }
}

int param_not_initialized_by_func() {
  int p;                        // expected-note {{'p' declared without an initial value}}
  int out = initializer1(p, 0); // expected-note{{Calling 'initializer1'}}
                                // expected-note@@-1{{Returning from 'initializer1'}}
  return p;                     // expected-note{{Undefined or garbage value returned to caller}}
                                // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

struct S {
  int initialize(int *p, int param) {
    if (param) { //expected-note{{Taking false branch}}
      *p = 1;
      return 1;
    }
    return 0; // expected-note{{Returning without writing to '*p'}}
  }
};

int use(S *s) {
  int p;                //expected-note{{'p' declared without an initial value}}
  s->initialize(&p, 0); //expected-note{{Calling 'S::initialize'}}
                        //expected-note@@-1{{Returning from 'S::initialize'}}
  return p;             // expected-warning{{Undefined or garbage value returned to caller}}
                        // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

int initializer2(const int &p) {
  return 0;
}

int no_msg_const_ref() {
  int p; //expected-note{{'p' declared without an initial value}}
  initializer2(p);
  return p; // expected-warning{{Undefined or garbage value returned to caller}}
            // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

void nested() {}
void init_in_nested_func(int **x) {
  *x = 0; // expected-note{{Null pointer value stored to 'y'}}
  nested();
} // no-note

int call_init_nested() {
  int x = 0;
  int *y = &x;
  init_in_nested_func(&y); // expected-note{{Calling 'init_in_nested_func'}}
                           // expected-note@@-1{{Returning from 'init_in_nested_func'}}
  return *y;               //expected-warning{{Dereference of null pointer (loaded from variable 'y')}}
                           //expected-note@@-1{{Dereference of null pointer (loaded from variable 'y')}}
}

struct A {
  int x;
  int y;
};

void partial_init_by_reference(A &a) {
  a.x = 0;
} // expected-note {{Returning without writing to 'a.y'}}

int use_partial_init_by_reference() {
  A a;
  partial_init_by_reference(a); // expected-note{{Calling 'partial_init_by_reference'}}
                                // expected-note@@-1{{Returning from 'partial_init_by_reference'}}
  return a.y;                   // expected-warning{{Undefined or garbage value returned to caller}}
                                // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

struct B : A {
};

void partially_init_inherited_struct(B *b) {
  b->x = 0;
} // expected-note{{Returning without writing to 'b->y'}}

int use_partially_init_inherited_struct() {
  B b;
  partially_init_inherited_struct(&b); // expected-note{{Calling 'partially_init_inherited_struct'}}
                                       // expected-note@@-1{{Returning from 'partially_init_inherited_struct'}}
  return b.y;                          // expected-warning{{Undefined or garbage value returned to caller}}
                                       // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

struct C {
  int x;
  int y;
  C(int pX, int pY) : x(pX) {} // expected-note{{Returning without writing to 'this->y'}}
};

int use_constructor() {
  C c(0, 0); // expected-note{{Calling constructor for 'C'}}
             // expected-note@@-1{{Returning from constructor for 'C'}}
  return c.y; // expected-note{{Undefined or garbage value returned to caller}}
              // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

struct D {
  void initialize(int *);
};

void D::initialize(int *p) {

} // expected-note{{Returning without writing to '*p'}}

int use_d_initializer(D* d) {
  int p; // expected-note {{'p' declared without an initial value}}
  d->initialize(&p); // expected-note{{Calling 'D::initialize'}}
                     // expected-note@@-1{{Returning from 'D::initialize'}}
  return p;                     // expected-note{{Undefined or garbage value returned to caller}}
                                // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

int coin();

struct S2 {
  int x;
};

int pointerreference(S2* &s) {
  if (coin()) // expected-note{{Assuming the condition is true}}
              // expected-note@@-1{{Taking true branch}}
    return 1; // expected-note{{Returning without writing to 's->x'}}

  s->x = 0;
  return 0;
}

int usepointerreference() {
  S2 s;
  S2* p = &s;
  pointerreference(p); //expected-note{{Calling 'pointerreference'}}
                         //expected-note@@-1{{Returning from 'pointerreference'}}
  return s.x; // expected-warning{{Undefined or garbage value returned to caller}}
              // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

void *has_no_argument_and_returns_null(void) {
  return 0;
}

void rdar40335545() {
    int local; // expected-note{{}}
    void (*takes_int_ptr_argument)(int *) = (void (*)(int*))has_no_argument_and_returns_null;

    takes_int_ptr_argument(&local); // no-crash

    int useLocal = local; //expected-warning{{}}
                          //expected-note@@-1{{}}
    (void)useLocal;
}
@


1.1.1.1.4.3
log
@Mostly merge changes from HEAD upto 20200411
@
text
@@


1.1.1.1.2.1
log
@file no-store-func-path-notes.cpp was added on branch pgoyette-compat on 2018-07-28 04:33:30 +0000
@
text
@d1 162
@


1.1.1.1.2.2
log
@Sync with HEAD
@
text
@a0 162
// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=core -analyzer-output=text -verify %s

int initializer1(int &p, int x) {
  if (x) { // expected-note{{Taking false branch}}
    p = 1;
    return 0;
  } else {
    return 1; // expected-note {{Returning without writing to 'p'}}
  }
}

int param_not_initialized_by_func() {
  int p;                        // expected-note {{'p' declared without an initial value}}
  int out = initializer1(p, 0); // expected-note{{Calling 'initializer1'}}
                                // expected-note@@-1{{Returning from 'initializer1'}}
  return p;                     // expected-note{{Undefined or garbage value returned to caller}}
                                // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

struct S {
  int initialize(int *p, int param) {
    if (param) { //expected-note{{Taking false branch}}
      *p = 1;
      return 1;
    }
    return 0; // expected-note{{Returning without writing to '*p'}}
  }
};

int use(S *s) {
  int p;                //expected-note{{'p' declared without an initial value}}
  s->initialize(&p, 0); //expected-note{{Calling 'S::initialize'}}
                        //expected-note@@-1{{Returning from 'S::initialize'}}
  return p;             // expected-warning{{Undefined or garbage value returned to caller}}
                        // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

int initializer2(const int &p) {
  return 0;
}

int no_msg_const_ref() {
  int p; //expected-note{{'p' declared without an initial value}}
  initializer2(p);
  return p; // expected-warning{{Undefined or garbage value returned to caller}}
            // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

void nested() {}
void init_in_nested_func(int **x) {
  *x = 0; // expected-note{{Null pointer value stored to 'y'}}
  nested();
} // no-note

int call_init_nested() {
  int x = 0;
  int *y = &x;
  init_in_nested_func(&y); // expected-note{{Calling 'init_in_nested_func'}}
                           // expected-note@@-1{{Returning from 'init_in_nested_func'}}
  return *y;               //expected-warning{{Dereference of null pointer (loaded from variable 'y')}}
                           //expected-note@@-1{{Dereference of null pointer (loaded from variable 'y')}}
}

struct A {
  int x;
  int y;
};

void partial_init_by_reference(A &a) {
  a.x = 0;
} // expected-note {{Returning without writing to 'a.y'}}

int use_partial_init_by_reference() {
  A a;
  partial_init_by_reference(a); // expected-note{{Calling 'partial_init_by_reference'}}
                                // expected-note@@-1{{Returning from 'partial_init_by_reference'}}
  return a.y;                   // expected-warning{{Undefined or garbage value returned to caller}}
                                // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

struct B : A {
};

void partially_init_inherited_struct(B *b) {
  b->x = 0;
} // expected-note{{Returning without writing to 'b->y'}}

int use_partially_init_inherited_struct() {
  B b;
  partially_init_inherited_struct(&b); // expected-note{{Calling 'partially_init_inherited_struct'}}
                                       // expected-note@@-1{{Returning from 'partially_init_inherited_struct'}}
  return b.y;                          // expected-warning{{Undefined or garbage value returned to caller}}
                                       // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

struct C {
  int x;
  int y;
  C(int pX, int pY) : x(pX) {} // expected-note{{Returning without writing to 'this->y'}}
};

int use_constructor() {
  C c(0, 0); // expected-note{{Calling constructor for 'C'}}
             // expected-note@@-1{{Returning from constructor for 'C'}}
  return c.y; // expected-note{{Undefined or garbage value returned to caller}}
              // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

struct D {
  void initialize(int *);
};

void D::initialize(int *p) {

} // expected-note{{Returning without writing to '*p'}}

int use_d_initializer(D* d) {
  int p; // expected-note {{'p' declared without an initial value}}
  d->initialize(&p); // expected-note{{Calling 'D::initialize'}}
                     // expected-note@@-1{{Returning from 'D::initialize'}}
  return p;                     // expected-note{{Undefined or garbage value returned to caller}}
                                // expected-warning@@-1{{Undefined or garbage value returned to caller}}
}

int coin();

struct S2 {
  int x;
};

int pointerreference(S2* &s) {
  if (coin()) // expected-note{{Assuming the condition is true}}
              // expected-note@@-1{{Taking true branch}}
    return 1; // expected-note{{Returning without writing to 's->x'}}

  s->x = 0;
  return 0;
}

int usepointerreference() {
  S2 s;
  S2* p = &s;
  pointerreference(p); //expected-note{{Calling 'pointerreference'}}
                         //expected-note@@-1{{Returning from 'pointerreference'}}
  return s.x; // expected-warning{{Undefined or garbage value returned to caller}}
              // expected-note@@-1{{Undefined or garbage value returned to caller}}
}

void *has_no_argument_and_returns_null(void) {
  return 0;
}

void rdar40335545() {
    int local; // expected-note{{}}
    void (*takes_int_ptr_argument)(int *) = (void (*)(int*))has_no_argument_and_returns_null;

    takes_int_ptr_argument(&local); // no-crash

    int useLocal = local; //expected-warning{{}}
                          //expected-note@@-1{{}}
    (void)useLocal;
}
@


