print source context together with each report

Summary: public
For instance:

  cd examples/
  infer -- gcc -c hello.c

gives:

  Starting analysis (Infer version git-c66ed7b302c996f238b6ec20cfcf4f6193fcbd88)
  Analysis done

  hello.c:5: error: NULL_DEREFERENCE
    pointer s last assigned on line 4 could be null and is dereferenced at line 5, column 3
    3.   void test() {
    4.     int *s = NULL;
    5. >   *s = 42;
    6.   }

Reviewed By: jeremydubreil

Differential Revision: D2600864

fb-gh-sync-id: 71e0bd4
master
Jules Villard 9 years ago committed by facebook-github-bot-7
parent 0091d3bdbb
commit 159d335da5

@ -352,8 +352,7 @@ def print_errors(csv_report, bugs_out):
)
with open(bugs_out, 'w') as file_out:
if not errors:
print_and_write(file_out, 'No issues found')
text_errors_list = []
for row in errors:
filename = row[utils.CSV_INDEX_FILENAME]
if os.path.isfile(filename):
@ -361,16 +360,26 @@ def print_errors(csv_report, bugs_out):
line = row[utils.CSV_INDEX_LINE]
error_type = row[utils.CSV_INDEX_TYPE]
msg = row[utils.CSV_INDEX_QUALIFIER]
print_and_write(
file_out,
'{0}:{1}: {2}: {3}\n {4}\n'.format(
indenter = utils.Indenter()
indenter.indent_push()
indenter.add(utils.build_source_context(filename,
int(line)))
source_context = str(indenter)
text_errors_list.append(
'{0}:{1}: {2}: {3}\n {4}\n{5}'.format(
filename,
line,
kind.lower(),
error_type,
msg,
source_context,
)
)
if len(text_errors_list) == 0:
print_and_write(file_out, 'No issues found')
else:
text_errors = '\n\n'.join(text_errors_list)
print_and_write(file_out, text_errors)
def run_command(cmd, debug_mode, javac_arguments, step, analyzer):

Loading…
Cancel
Save