File: inline-defensive-checks.cpp

package info (click to toggle)
llvm-toolchain-3.4 1%3A3.4.2-13
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 253,236 kB
  • ctags: 276,203
  • sloc: cpp: 1,665,580; ansic: 298,647; asm: 206,157; objc: 84,350; python: 73,119; sh: 23,466; perl: 5,679; makefile: 5,542; ml: 5,250; pascal: 2,467; lisp: 1,420; xml: 679; cs: 236; csh: 117
file content (73 lines) | stat: -rw-r--r-- 1,393 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
// expected-no-diagnostics

extern void __assert_fail (__const char *__assertion, __const char *__file,
                           unsigned int __line, __const char *__function)
__attribute__ ((__noreturn__));
#define assert(expr) \
((expr)  ? (void)(0)  : __assert_fail (#expr, __FILE__, __LINE__, __func__))

class ButterFly {
private:
  ButterFly() { }
public:
	int triggerderef() {
		return 0;
	}
};
ButterFly *getInP();
class X{
	ButterFly *p;
	void setP(ButterFly *inP) {
		if(inP)
      ;
		p = inP;
	};
	void subtest1() {
		ButterFly *inP = getInP();
		setP(inP);
	}
	int subtest2() {
		int c = p->triggerderef(); // no-warning
		return c;
	}
	int test() {
		subtest1();
		return subtest2();
	}
};

typedef const int *Ty;
extern
Ty notNullArg(Ty cf) __attribute__((nonnull));
typedef const void *CFTypeRef;
extern Ty getTyVal();
inline void radar13224271_callee(Ty def, Ty& result ) {
	result = def;
  // Clearly indicates that result cannot be 0 if def is not NULL.
	assert( (result != 0) || (def == 0) );
}
void radar13224271_caller()
{
	Ty value;
	radar13224271_callee(getTyVal(), value );
	notNullArg(value); // no-warning
}

struct Foo {
	int *ptr;
	Foo(int *p)  {
		*p = 1; // no-warning
	}
};
void idc(int *p3) {
  if (p3)
    ;
}
int *retNull() {
  return 0;
}
void test(int *p1, int *p2) {
  idc(p1);
	Foo f(p1);
}