Home | History | Annotate | Download | only in diagnostics
      1 // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false -o %t %s
      2 // RUN: FileCheck --input-file %t %s
      3 
      4 #include "undef-value-callee.h"
      5 
      6 // This code used to cause a crash since we were not adding fileID of the header to the plist diagnostic.
      7 
      8 int test_calling_unimportant_callee(int argc, char *argv[]) {
      9   int x;
     10   callee();
     11   return x; // expected-warning {{Undefined or garbage value returned to caller}}
     12 }
     13 
     14 // CHECK:  <key>diagnostics</key>
     15 // CHECK-NEXT:  <array>
     16 // CHECK-NEXT:   <dict>
     17 // CHECK-NEXT:    <key>path</key>
     18 // CHECK-NEXT:    <array>
     19 // CHECK-NEXT:     <dict>
     20 // CHECK-NEXT:      <key>kind</key><string>event</string>
     21 // CHECK-NEXT:      <key>location</key>
     22 // CHECK-NEXT:      <dict>
     23 // CHECK-NEXT:       <key>line</key><integer>9</integer>
     24 // CHECK-NEXT:       <key>col</key><integer>3</integer>
     25 // CHECK-NEXT:       <key>file</key><integer>0</integer>
     26 // CHECK-NEXT:      </dict>
     27 // CHECK-NEXT:      <key>ranges</key>
     28 // CHECK-NEXT:      <array>
     29 // CHECK-NEXT:        <array>
     30 // CHECK-NEXT:         <dict>
     31 // CHECK-NEXT:          <key>line</key><integer>9</integer>
     32 // CHECK-NEXT:          <key>col</key><integer>3</integer>
     33 // CHECK-NEXT:          <key>file</key><integer>0</integer>
     34 // CHECK-NEXT:         </dict>
     35 // CHECK-NEXT:         <dict>
     36 // CHECK-NEXT:          <key>line</key><integer>9</integer>
     37 // CHECK-NEXT:          <key>col</key><integer>7</integer>
     38 // CHECK-NEXT:          <key>file</key><integer>0</integer>
     39 // CHECK-NEXT:         </dict>
     40 // CHECK-NEXT:        </array>
     41 // CHECK-NEXT:      </array>
     42 // CHECK-NEXT:      <key>depth</key><integer>0</integer>
     43 // CHECK-NEXT:      <key>extended_message</key>
     44 // CHECK-NEXT:      <string>&apos;x&apos; declared without an initial value</string>
     45 // CHECK-NEXT:      <key>message</key>
     46 // CHECK-NEXT:      <string>&apos;x&apos; declared without an initial value</string>
     47 // CHECK-NEXT:     </dict>
     48 // CHECK-NEXT:     <dict>
     49 // CHECK-NEXT:      <key>kind</key><string>control</string>
     50 // CHECK-NEXT:      <key>edges</key>
     51 // CHECK-NEXT:       <array>
     52 // CHECK-NEXT:        <dict>
     53 // CHECK-NEXT:         <key>start</key>
     54 // CHECK-NEXT:          <array>
     55 // CHECK-NEXT:           <dict>
     56 // CHECK-NEXT:            <key>line</key><integer>9</integer>
     57 // CHECK-NEXT:            <key>col</key><integer>3</integer>
     58 // CHECK-NEXT:            <key>file</key><integer>0</integer>
     59 // CHECK-NEXT:           </dict>
     60 // CHECK-NEXT:           <dict>
     61 // CHECK-NEXT:            <key>line</key><integer>9</integer>
     62 // CHECK-NEXT:            <key>col</key><integer>5</integer>
     63 // CHECK-NEXT:            <key>file</key><integer>0</integer>
     64 // CHECK-NEXT:           </dict>
     65 // CHECK-NEXT:          </array>
     66 // CHECK-NEXT:         <key>end</key>
     67 // CHECK-NEXT:          <array>
     68 // CHECK-NEXT:           <dict>
     69 // CHECK-NEXT:            <key>line</key><integer>10</integer>
     70 // CHECK-NEXT:            <key>col</key><integer>3</integer>
     71 // CHECK-NEXT:            <key>file</key><integer>0</integer>
     72 // CHECK-NEXT:           </dict>
     73 // CHECK-NEXT:           <dict>
     74 // CHECK-NEXT:            <key>line</key><integer>10</integer>
     75 // CHECK-NEXT:            <key>col</key><integer>8</integer>
     76 // CHECK-NEXT:            <key>file</key><integer>0</integer>
     77 // CHECK-NEXT:           </dict>
     78 // CHECK-NEXT:          </array>
     79 // CHECK-NEXT:        </dict>
     80 // CHECK-NEXT:       </array>
     81 // CHECK-NEXT:     </dict>
     82 // CHECK-NEXT:     <dict>
     83 // CHECK-NEXT:      <key>kind</key><string>control</string>
     84 // CHECK-NEXT:      <key>edges</key>
     85 // CHECK-NEXT:       <array>
     86 // CHECK-NEXT:        <dict>
     87 // CHECK-NEXT:         <key>start</key>
     88 // CHECK-NEXT:          <array>
     89 // CHECK-NEXT:           <dict>
     90 // CHECK-NEXT:            <key>line</key><integer>10</integer>
     91 // CHECK-NEXT:            <key>col</key><integer>3</integer>
     92 // CHECK-NEXT:            <key>file</key><integer>0</integer>
     93 // CHECK-NEXT:           </dict>
     94 // CHECK-NEXT:           <dict>
     95 // CHECK-NEXT:            <key>line</key><integer>10</integer>
     96 // CHECK-NEXT:            <key>col</key><integer>8</integer>
     97 // CHECK-NEXT:            <key>file</key><integer>0</integer>
     98 // CHECK-NEXT:           </dict>
     99 // CHECK-NEXT:          </array>
    100 // CHECK-NEXT:         <key>end</key>
    101 // CHECK-NEXT:          <array>
    102 // CHECK-NEXT:           <dict>
    103 // CHECK-NEXT:            <key>line</key><integer>11</integer>
    104 // CHECK-NEXT:            <key>col</key><integer>3</integer>
    105 // CHECK-NEXT:            <key>file</key><integer>0</integer>
    106 // CHECK-NEXT:           </dict>
    107 // CHECK-NEXT:           <dict>
    108 // CHECK-NEXT:            <key>line</key><integer>11</integer>
    109 // CHECK-NEXT:            <key>col</key><integer>8</integer>
    110 // CHECK-NEXT:            <key>file</key><integer>0</integer>
    111 // CHECK-NEXT:           </dict>
    112 // CHECK-NEXT:          </array>
    113 // CHECK-NEXT:        </dict>
    114 // CHECK-NEXT:       </array>
    115 // CHECK-NEXT:     </dict>
    116 // CHECK-NEXT:     <dict>
    117 // CHECK-NEXT:      <key>kind</key><string>event</string>
    118 // CHECK-NEXT:      <key>location</key>
    119 // CHECK-NEXT:      <dict>
    120 // CHECK-NEXT:       <key>line</key><integer>11</integer>
    121 // CHECK-NEXT:       <key>col</key><integer>3</integer>
    122 // CHECK-NEXT:       <key>file</key><integer>0</integer>
    123 // CHECK-NEXT:      </dict>
    124 // CHECK-NEXT:      <key>ranges</key>
    125 // CHECK-NEXT:      <array>
    126 // CHECK-NEXT:        <array>
    127 // CHECK-NEXT:         <dict>
    128 // CHECK-NEXT:          <key>line</key><integer>11</integer>
    129 // CHECK-NEXT:          <key>col</key><integer>10</integer>
    130 // CHECK-NEXT:          <key>file</key><integer>0</integer>
    131 // CHECK-NEXT:         </dict>
    132 // CHECK-NEXT:         <dict>
    133 // CHECK-NEXT:          <key>line</key><integer>11</integer>
    134 // CHECK-NEXT:          <key>col</key><integer>10</integer>
    135 // CHECK-NEXT:          <key>file</key><integer>0</integer>
    136 // CHECK-NEXT:         </dict>
    137 // CHECK-NEXT:        </array>
    138 // CHECK-NEXT:      </array>
    139 // CHECK-NEXT:      <key>depth</key><integer>0</integer>
    140 // CHECK-NEXT:      <key>extended_message</key>
    141 // CHECK-NEXT:      <string>Undefined or garbage value returned to caller</string>
    142 // CHECK-NEXT:      <key>message</key>
    143 // CHECK-NEXT:      <string>Undefined or garbage value returned to caller</string>
    144 // CHECK-NEXT:     </dict>
    145 // CHECK-NEXT:    </array>
    146 // CHECK-NEXT:    <key>description</key><string>Undefined or garbage value returned to caller</string>
    147 // CHECK-NEXT:    <key>category</key><string>Logic error</string>
    148 // CHECK-NEXT:    <key>type</key><string>Garbage return value</string>
    149 // CHECK-NEXT:   <key>issue_context_kind</key><string>function</string>
    150 // CHECK-NEXT:   <key>issue_context</key><string>test_calling_unimportant_callee</string>
    151 // CHECK-NEXT:   <key>issue_hash</key><string>3</string>
    152 // CHECK-NEXT:   <key>location</key>
    153 // CHECK-NEXT:   <dict>
    154 // CHECK-NEXT:    <key>line</key><integer>11</integer>
    155 // CHECK-NEXT:    <key>col</key><integer>3</integer>
    156 // CHECK-NEXT:    <key>file</key><integer>0</integer>
    157 // CHECK-NEXT:   </dict>
    158 // CHECK-NEXT:   </dict>
    159 // CHECK-NEXT:  </array>
    160