@@ -7,11 +7,10 @@ void clang_analyzer_dump_ptr(void *);
7
7
8
8
int global;
9
9
void testRValueOutput () {
10
- int &ref = global;
11
- ref = 1 ;
10
+ int origVal = global;
12
11
__asm__ (" " : " =r" (((int )(global)))); // don't crash on rvalue output operand
13
- clang_analyzer_eval (global == 1 ) ; // expected-warning{{UNKNOWN}}
14
- clang_analyzer_eval (ref == 1 ); // expected-warning{{UNKNOWN }}
12
+ int newVal = global ; // Value "after" the invalidation.
13
+ clang_analyzer_eval (origVal == newVal ); // expected-warning{{TRUE}} expected-warning{{FALSE }}
15
14
}
16
15
17
16
void *MyMemcpy (void *d, const void *s, const int n) {
@@ -40,7 +39,20 @@ void testInlineAsmMemcpyUninit(void)
40
39
{
41
40
int a[10 ], b[10 ] = {}, c;
42
41
MyMemcpy (&a[1 ], &b[1 ], sizeof (b) - sizeof (b[1 ]));
43
- c = a[0 ]; // expected-warning{{Assigned value is garbage or undefined}}
42
+ c = a[0 ]; // FIXME: should be warning about uninitialized value, but invalidateRegions() also
43
+ // invalidates super region.
44
+ }
45
+
46
+ void testInlineAsmMemcpyUninitLoop (const void *src, unsigned long len)
47
+ {
48
+ int a[10 ], c;
49
+ unsigned long toCopy = sizeof (a) < len ? sizeof (a) : len;
50
+
51
+ MyMemcpy (a, src, toCopy);
52
+
53
+ // Use index 1, since before use of invalidateRegions in VisitGCCAsmStmt, engine bound unknown SVal only to
54
+ // first element.
55
+ c = a[1 ]; // no-warning
44
56
}
45
57
46
58
void testAsmWithVoidPtrArgument ()
@@ -49,6 +61,6 @@ void testAsmWithVoidPtrArgument()
49
61
clang_analyzer_dump (*(int *)globalVoidPtr); // expected-warning-re {{reg_${{[0-9]+}}<int Element{SymRegion{reg_${{[0-9]+}}<void * globalVoidPtr>},0 S64b,int}>}}
50
62
clang_analyzer_dump_ptr (globalVoidPtr); // expected-warning-re {{&SymRegion{reg_${{[0-9]+}}<void * globalVoidPtr>}}}
51
63
asm (" " : : " a" (globalVoidPtr)); // no crash
52
- clang_analyzer_dump (*(int *)globalVoidPtr); // expected-warning {{Unknown }}
64
+ clang_analyzer_dump (*(int *)globalVoidPtr); // expected-warning {{derived_ }}
53
65
clang_analyzer_dump_ptr (globalVoidPtr); // expected-warning-re {{&SymRegion{reg_${{[0-9]+}}<void * globalVoidPtr>}}}
54
66
}
0 commit comments