305 lines
13 KiB
C
305 lines
13 KiB
C
|
// RUN: %clang --analyze %s -Xanalyzer -analyzer-config -Xanalyzer path-diagnostics-alternate=false -o %t > /dev/null 2>&1
|
||
|
// RUN: FileCheck -input-file %t %s
|
||
|
|
||
|
static inline bug(int *p) {
|
||
|
*p = 0xDEADBEEF;
|
||
|
}
|
||
|
|
||
|
void test_bug_1() {
|
||
|
int *p = 0;
|
||
|
bug(p);
|
||
|
}
|
||
|
|
||
|
void test_bug_2() {
|
||
|
int *p = 0;
|
||
|
bug(p);
|
||
|
}
|
||
|
|
||
|
|
||
|
// CHECK: <key>diagnostics</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>path</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>event</string>
|
||
|
// CHECK-NEXT: <key>location</key>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>14</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <key>ranges</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>14</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>14</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>8</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>depth</key><integer>0</integer>
|
||
|
// CHECK-NEXT: <key>extended_message</key>
|
||
|
// CHECK-NEXT: <string>'p' initialized to a null pointer value</string>
|
||
|
// CHECK-NEXT: <key>message</key>
|
||
|
// CHECK-NEXT: <string>'p' initialized to a null pointer value</string>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>control</string>
|
||
|
// CHECK-NEXT: <key>edges</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>start</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>14</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>14</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>end</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>control</string>
|
||
|
// CHECK-NEXT: <key>edges</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>start</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>end</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>7</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>7</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>event</string>
|
||
|
// CHECK-NEXT: <key>location</key>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>7</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <key>ranges</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>7</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>7</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>depth</key><integer>0</integer>
|
||
|
// CHECK-NEXT: <key>extended_message</key>
|
||
|
// CHECK-NEXT: <string>Passing null pointer value via 1st parameter 'p'</string>
|
||
|
// CHECK-NEXT: <key>message</key>
|
||
|
// CHECK-NEXT: <string>Passing null pointer value via 1st parameter 'p'</string>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>event</string>
|
||
|
// CHECK-NEXT: <key>location</key>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <key>ranges</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>15</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>8</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>depth</key><integer>0</integer>
|
||
|
// CHECK-NEXT: <key>extended_message</key>
|
||
|
// CHECK-NEXT: <string>Calling 'bug'</string>
|
||
|
// CHECK-NEXT: <key>message</key>
|
||
|
// CHECK-NEXT: <string>Calling 'bug'</string>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>event</string>
|
||
|
// CHECK-NEXT: <key>location</key>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>4</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>1</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <key>depth</key><integer>1</integer>
|
||
|
// CHECK-NEXT: <key>extended_message</key>
|
||
|
// CHECK-NEXT: <string>Entered call from 'test_bug_2'</string>
|
||
|
// CHECK-NEXT: <key>message</key>
|
||
|
// CHECK-NEXT: <string>Entered call from 'test_bug_2'</string>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>control</string>
|
||
|
// CHECK-NEXT: <key>edges</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>start</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>4</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>1</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>4</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>6</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>end</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>control</string>
|
||
|
// CHECK-NEXT: <key>edges</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>start</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>3</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>end</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>6</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>6</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>kind</key><string>event</string>
|
||
|
// CHECK-NEXT: <key>location</key>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>6</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <key>ranges</key>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <array>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>4</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>4</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>depth</key><integer>1</integer>
|
||
|
// CHECK-NEXT: <key>extended_message</key>
|
||
|
// CHECK-NEXT: <string>Dereference of null pointer (loaded from variable 'p')</string>
|
||
|
// CHECK-NEXT: <key>message</key>
|
||
|
// CHECK-NEXT: <string>Dereference of null pointer (loaded from variable 'p')</string>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|
||
|
// CHECK-NEXT: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string>
|
||
|
// CHECK-NEXT: <key>category</key><string>Logic error</string>
|
||
|
// CHECK-NEXT: <key>type</key><string>Dereference of null pointer</string>
|
||
|
// CHECK-NEXT: <key>issue_context_kind</key><string>function</string>
|
||
|
// CHECK-NEXT: <key>issue_context</key><string>bug</string>
|
||
|
// CHECK-NEXT: <key>issue_hash</key><string>1</string>
|
||
|
// CHECK-NEXT: <key>location</key>
|
||
|
// CHECK-NEXT: <dict>
|
||
|
// CHECK-NEXT: <key>line</key><integer>5</integer>
|
||
|
// CHECK-NEXT: <key>col</key><integer>6</integer>
|
||
|
// CHECK-NEXT: <key>file</key><integer>0</integer>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </dict>
|
||
|
// CHECK-NEXT: </array>
|