mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-22 21:15:40 -04:00

Summary: This patch applies a change similar to rC363069, but for SARIF files. The `%diff_sarif` lit substitution invokes `diff` with a non-portable `-I` option. The intended effect can be achieved by normalizing the inputs to `diff` beforehand. Such normalization can be done with `grep -Ev`, which is also used by other tests. Additionally, this patch updates the SARIF output to have a newline at the end of the file. This makes it so that the SARIF file qualifies as a POSIX text file, which increases the consumability of the generated file in relation to various tools. Reviewers: NoQ, sfertile, xingxue, jasonliu, daltenty, aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62952 llvm-svn: 363822
30 lines
686 B
C
30 lines
686 B
C
// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.security.taint,debug.TaintTest %s -verify -analyzer-output=sarif -o - | %normalize_sarif | diff -U1 -b %S/Inputs/expected-sarif/sarif-multi-diagnostic-test.c.sarif -
|
|
#include "../Inputs/system-header-simulator.h"
|
|
|
|
int atoi(const char *nptr);
|
|
|
|
void f(void) {
|
|
char s[80];
|
|
scanf("%s", s);
|
|
int d = atoi(s); // expected-warning {{tainted}}
|
|
}
|
|
|
|
void g(void) {
|
|
void (*fp)(int);
|
|
fp(12); // expected-warning {{Called function pointer is an uninitialized pointer value}}
|
|
}
|
|
|
|
int h(int i) {
|
|
if (i == 0)
|
|
return 1 / i; // expected-warning {{Division by zero}}
|
|
return 0;
|
|
}
|
|
|
|
int main(void) {
|
|
f();
|
|
g();
|
|
h(0);
|
|
return 0;
|
|
}
|
|
|