forked from OSchip/llvm-project
308 lines
13 KiB
C
308 lines
13 KiB
C
// RUN: %clang_analyze_cc1 %s -analyzer-checker=core.NullDereference -analyzer-output=plist -analyzer-config 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>check_name</key><string>core.NullDereference</string>
|
|
// CHECK-NEXT: <!-- This hash is experimental and going to change! -->
|
|
// CHECK-NEXT: <key>issue_hash_content_of_line_in_context</key><string>a6ef969f9d5a84fe3b6d153fa488020a</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_function_offset</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>
|