
A patch by Karthik Bhat! This patch fixes a regression introduced by r224398. Prior to r224398 we were able to analyze the following code in test-include.c and report a null deref in this case. But post r224398 this analysis is being skipped. E.g. // test-include.c #include "test-include.h" void test(int * data) { data = 0; *data = 1; } // test-include.h void test(int * data); This patch uses the function body (instead of its declaration) as the location of the function when deciding if the Decl should be analyzed with path-sensitive analysis. (Prior to r224398, the call graph was guaranteed to have a definition when available.) llvm-svn: 240800
21 lines
570 B
C
21 lines
570 B
C
// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
|
|
|
|
#include "test-include.h"
|
|
#define DIVYX(X,Y) Y/X
|
|
|
|
void test_01(int *data) {
|
|
data = 0;
|
|
*data = 1; // expected-warning{{Dereference of null pointer}}
|
|
}
|
|
|
|
int test_02() {
|
|
int res = DIVXY(1,0); // expected-warning{{Division by zero}}
|
|
// expected-warning@-1{{division by zero is undefined}}
|
|
return res;
|
|
}
|
|
|
|
int test_03() {
|
|
int res = DIVYX(0,1); // expected-warning{{Division by zero}}
|
|
// expected-warning@-1{{division by zero is undefined}}
|
|
return res;
|
|
} |