forked from OSchip/llvm-project
[analyzer] Fix a diagnostics bug which lead to a crash on the buildbot.
This bug was triggered by r157851. It only happens in the case where we don't perform optimal diagnostic pruning. llvm-svn: 157950
This commit is contained in:
parent
eac87f87ce
commit
4ff9097fcc
|
@ -382,6 +382,11 @@ void PlistDiagnostics::FlushDiagnosticsImpl(
|
|||
|
||||
if (const PathDiagnosticCallPiece *call =
|
||||
dyn_cast<PathDiagnosticCallPiece>(piece)) {
|
||||
IntrusiveRefCntPtr<PathDiagnosticEventPiece>
|
||||
callEnterWithin = call->getCallEnterWithinCallerEvent();
|
||||
if (callEnterWithin)
|
||||
AddFID(FM, Fids, SM, callEnterWithin->getLocation().asLocation());
|
||||
|
||||
WorkList.push_back(&call->path);
|
||||
}
|
||||
else if (const PathDiagnosticMacroPiece *macro =
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
void callee() {
|
||||
;
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist -o %t %s
|
||||
// RUN: FileCheck --input-file %t %s
|
||||
|
||||
#include "undef-value-callee.h"
|
||||
|
||||
// This code used to cause a crash since we were not adding fileID of the header to the plist diagnostic.
|
||||
// Note, in the future, we do not even need to step into this callee since it does not influence the result.
|
||||
int test_calling_unimportant_callee(int argc, char *argv[]) {
|
||||
int x;
|
||||
callee();
|
||||
return x; // expected-warning {{Undefined or garbage value returned to caller}}
|
||||
}
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>files</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <string>/Users/anya/workspace/gllvm/llvm/tools/clang/test/Analysis/diagnostics/undef-value-caller.c</string>
|
||||
//CHECK: <string>/Users/anya/workspace/gllvm/llvm/tools/clang/test/Analysis/diagnostics/undef-value-callee.h</string>
|
||||
//CHECK: </array>
|
||||
//CHECK: <key>diagnostics</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>path</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>kind</key><string>event</string>
|
||||
//CHECK: <key>location</key>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>9</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <key>ranges</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>9</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>9</integer>
|
||||
//CHECK: <key>col</key><integer>7</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </array>
|
||||
//CHECK: <key>depth</key><integer>0</integer>
|
||||
//CHECK: <key>extended_message</key>
|
||||
//CHECK: <string>Variable 'x' declared without an initial value</string>
|
||||
//CHECK: <key>message</key>
|
||||
//CHECK: <string>Variable 'x' declared without an initial value</string>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>kind</key><string>control</string>
|
||||
//CHECK: <key>edges</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>start</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>9</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>9</integer>
|
||||
//CHECK: <key>col</key><integer>7</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: <key>end</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>kind</key><string>event</string>
|
||||
//CHECK: <key>location</key>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <key>ranges</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>10</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </array>
|
||||
//CHECK: <key>depth</key><integer>0</integer>
|
||||
//CHECK: <key>extended_message</key>
|
||||
//CHECK: <string>Calling 'callee'</string>
|
||||
//CHECK: <key>message</key>
|
||||
//CHECK: <string>Calling 'callee'</string>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>kind</key><string>event</string>
|
||||
//CHECK: <key>location</key>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>2</integer>
|
||||
//CHECK: <key>col</key><integer>1</integer>
|
||||
//CHECK: <key>file</key><integer>1</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <key>depth</key><integer>1</integer>
|
||||
//CHECK: <key>extended_message</key>
|
||||
//CHECK: <string>Entered call from 'test_calling_unimportant_callee'</string>
|
||||
//CHECK: <key>message</key>
|
||||
//CHECK: <string>Entered call from 'test_calling_unimportant_callee'</string>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>kind</key><string>event</string>
|
||||
//CHECK: <key>location</key>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <key>ranges</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>10</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </array>
|
||||
//CHECK: <key>depth</key><integer>1</integer>
|
||||
//CHECK: <key>extended_message</key>
|
||||
//CHECK: <string>Returning from 'callee'</string>
|
||||
//CHECK: <key>message</key>
|
||||
//CHECK: <string>Returning from 'callee'</string>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>kind</key><string>control</string>
|
||||
//CHECK: <key>edges</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>start</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>10</integer>
|
||||
//CHECK: <key>col</key><integer>10</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: <key>end</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>11</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>11</integer>
|
||||
//CHECK: <key>col</key><integer>10</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>kind</key><string>event</string>
|
||||
//CHECK: <key>location</key>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>11</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <key>ranges</key>
|
||||
//CHECK: <array>
|
||||
//CHECK: <array>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>11</integer>
|
||||
//CHECK: <key>col</key><integer>10</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>11</integer>
|
||||
//CHECK: <key>col</key><integer>10</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </array>
|
||||
//CHECK: <key>depth</key><integer>0</integer>
|
||||
//CHECK: <key>extended_message</key>
|
||||
//CHECK: <string>Undefined or garbage value returned to caller</string>
|
||||
//CHECK: <key>message</key>
|
||||
//CHECK: <string>Undefined or garbage value returned to caller</string>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: <key>description</key><string>Undefined or garbage value returned to caller</string>
|
||||
//CHECK: <key>category</key><string>Logic error</string>
|
||||
//CHECK: <key>type</key><string>Garbage return value</string>
|
||||
//CHECK: <key>issue_context_kind</key><string>function</string>
|
||||
//CHECK: <key>issue_context</key><string>test_calling_unimportant_callee</string>
|
||||
//CHECK: <key>location</key>
|
||||
//CHECK: <dict>
|
||||
//CHECK: <key>line</key><integer>11</integer>
|
||||
//CHECK: <key>col</key><integer>3</integer>
|
||||
//CHECK: <key>file</key><integer>0</integer>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </array>
|
||||
//CHECK: </dict>
|
||||
//CHECK: </plist>
|
Loading…
Reference in New Issue