diff options
-rw-r--r-- | lib/StaticAnalyzer/Core/PlistDiagnostics.cpp | 11 | ||||
-rw-r--r-- | test/Analysis/inline-plist.c | 6 | ||||
-rw-r--r-- | test/Analysis/malloc-plist.c | 15 | ||||
-rw-r--r-- | test/Analysis/plist-output-alternate.m | 7 | ||||
-rw-r--r-- | test/Analysis/plist-output.m | 9 |
5 files changed, 48 insertions, 0 deletions
diff --git a/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp b/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp index f1c620a018..4156e4fb0c 100644 --- a/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp +++ b/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp @@ -489,6 +489,17 @@ void PlistDiagnostics::FlushDiagnosticsImpl( o << " <key>issue_context</key>"; EmitString(o, declName) << '\n'; } + + // Output the bug hash for issue unique-ing. Currently, it's just an + // offset from the beginning of the function. + if (const Stmt *Body = DeclWithIssue->getBody()) { + FullSourceLoc Loc(SM->getExpansionLoc(D->getLocation().asLocation()), + *SM); + FullSourceLoc FunLoc(SM->getExpansionLoc(Body->getLocStart()), *SM); + o << " <key>issue_hash</key><integer>" + << Loc.getExpansionLineNumber() - FunLoc.getExpansionLineNumber() + << "</integer>\n"; + } } } diff --git a/test/Analysis/inline-plist.c b/test/Analysis/inline-plist.c index 7f4822480f..1523e82cc2 100644 --- a/test/Analysis/inline-plist.c +++ b/test/Analysis/inline-plist.c @@ -274,6 +274,7 @@ void test_block_arg() { // CHECK: <key>type</key><string>Division by zero</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>foo</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>14</integer> @@ -396,6 +397,7 @@ void test_block_arg() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>has_bug</string> +// CHECK: <key>issue_hash</key><integer>1</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>19</integer> @@ -649,6 +651,7 @@ void test_block_arg() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>triggers_bug</string> +// CHECK: <key>issue_hash</key><integer>1</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>27</integer> @@ -945,6 +948,7 @@ void test_block_arg() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_block_ret</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>51</integer> @@ -1058,6 +1062,7 @@ void test_block_arg() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_block_blockvar</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>57</integer> @@ -1171,6 +1176,7 @@ void test_block_arg() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_block_arg</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>63</integer> diff --git a/test/Analysis/malloc-plist.c b/test/Analysis/malloc-plist.c index ef40192543..11eef3e140 100644 --- a/test/Analysis/malloc-plist.c +++ b/test/Analysis/malloc-plist.c @@ -364,6 +364,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>diagnosticTest</string> +// CHECK: <key>issue_hash</key><integer>5</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>14</integer> @@ -525,6 +526,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>myArrayAllocation</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>21</integer> @@ -909,6 +911,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>reallocDiagnostics</string> +// CHECK: <key>issue_hash</key><integer>5</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>28</integer> @@ -1307,6 +1310,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_wrapper</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>45</integer> @@ -1826,6 +1830,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Use-after-free</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_double_action_call</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>61</integer> @@ -2384,6 +2389,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>reallocIntra</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>76</integer> @@ -2651,6 +2657,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>use_ret</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>86</integer> @@ -2812,6 +2819,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>LeakedSymbol</string> +// CHECK: <key>issue_hash</key><integer>8</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>97</integer> @@ -3016,6 +3024,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>function_with_leak1</string> +// CHECK: <key>issue_hash</key><integer>1</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>102</integer> @@ -3220,6 +3229,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>function_with_leak2</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>111</integer> @@ -3492,6 +3502,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>function_with_leak3</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>120</integer> @@ -3764,6 +3775,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>function_with_leak4</string> +// CHECK: <key>issue_hash</key><integer>5</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>131</integer> @@ -3968,6 +3980,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>function_with_leak5</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>142</integer> @@ -4172,6 +4185,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>function_with_leak6</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>153</integer> @@ -4405,6 +4419,7 @@ void use_function_with_leak7() { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>use_function_with_leak7</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>169</integer> diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m index 43f8340ab7..a338a79491 100644 --- a/test/Analysis/plist-output-alternate.m +++ b/test/Analysis/plist-output-alternate.m @@ -137,6 +137,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_init</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>6</integer> @@ -216,6 +217,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_assign</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>12</integer> @@ -295,6 +297,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_assign_transitive</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>19</integer> @@ -437,6 +440,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_cond</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>24</integer> @@ -584,6 +588,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_cond_transitive</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>31</integer> @@ -697,6 +702,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_field</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>38</integer> @@ -960,6 +966,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>rdar8331641</string> +// CHECK: <key>issue_hash</key><integer>6</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>58</integer> diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m index 3d04cbfe46..cae08abe5f 100644 --- a/test/Analysis/plist-output.m +++ b/test/Analysis/plist-output.m @@ -160,6 +160,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_init</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>6</integer> @@ -239,6 +240,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_assign</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>12</integer> @@ -318,6 +320,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_assign_transitive</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>19</integer> @@ -460,6 +463,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_cond</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>24</integer> @@ -607,6 +611,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_cond_transitive</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>32</integer> @@ -720,6 +725,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_field</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>39</integer> @@ -935,6 +941,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_assumptions</string> +// CHECK: <key>issue_hash</key><integer>8</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>51</integer> @@ -1145,6 +1152,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_cond_assign</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>59</integer> @@ -1326,6 +1334,7 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>Objective-C method</string> // CHECK: <key>issue_context</key><string>test</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>78</integer> |