blob: be150c92cc346f4688e60aecb3c0f6bef1f6a5ac [file] [log] [blame]
Ted Kremenekd87682e2009-12-17 01:44:13 +00001// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
2// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
Ted Kremenekd87682e2009-12-17 01:44:13 +00003
Ted Kremenek53287512009-12-18 20:13:39 +00004// Test basic handling of references.
Ted Kremenekd87682e2009-12-17 01:44:13 +00005char &test1_aux();
6char *test1() {
7 return &test1_aux();
8}
Ted Kremenek53287512009-12-18 20:13:39 +00009
Zhongxing Xu910e4082009-12-19 03:17:55 +000010// Test test1_aux() evaluates to char &.
Ted Kremenek53287512009-12-18 20:13:39 +000011char test1_as_rvalue() {
12 return test1_aux();
13}
14
Ted Kremenek949bdb42009-12-23 00:26:16 +000015// Test passing a value as a reference. The 'const' in test2_aux() adds
16// an ImplicitCastExpr, which is evaluated as an lvalue.
17int test2_aux(const int &n);
18int test2(int n) {
19 return test2_aux(n);
20}
21
22int test2_b_aux(const short &n);
23int test2_b(int n) {
24 return test2_b_aux(n);
25}
Ted Kremenek077a40d2009-12-23 01:19:20 +000026
27// Test getting the lvalue of a derived and converting it to a base. This
28// previously crashed.
29class Test3_Base {};
30class Test3_Derived : public Test3_Base {};
31
32int test3_aux(Test3_Base &x);
33int test3(Test3_Derived x) {
34 return test3_aux(x);
35}
36