Allow multiple PathDiagnosticConsumers to be used with a BugReporter at the same time.
This fixes several issues:
- removes egregious hack where PlistDiagnosticConsumer would forward to HTMLDiagnosticConsumer,
but diagnostics wouldn't be generated consistently in the same way if PlistDiagnosticConsumer
was used by itself.
- emitting diagnostics to the terminal (using clang's diagnostic machinery) is no longer a special
case, just another PathDiagnosticConsumer. This also magically resolved some duplicate warnings,
as we now use PathDiagnosticConsumer's diagnostic pruning, which has scope for the entire translation
unit, not just the scope of a BugReporter (which is limited to a particular ExprEngine).
As an interesting side-effect, diagnostics emitted to the terminal also have their trailing "." stripped,
just like with diagnostics emitted to plists and HTML. This required some tests to be updated, but now
the tests have higher fidelity with what users will see.
There are some inefficiencies in this patch. We currently generate the report graph (from the ExplodedGraph)
once per PathDiagnosticConsumer, which is a bit wasteful, but that could be pulled up higher in the
logic stack. There is some intended duplication, however, as we now generate different PathDiagnostics (for the same issue)
for different PathDiagnosticConsumers. This is necessary to produce the diagnostics that a particular
consumer expects.
llvm-svn: 162028
diff --git a/clang/test/Analysis/stream.c b/clang/test/Analysis/stream.c
index e68835e..4a095cf 100644
--- a/clang/test/Analysis/stream.c
+++ b/clang/test/Analysis/stream.c
@@ -16,25 +16,25 @@
void f1(void) {
FILE *p = fopen("foo", "r");
char buf[1024];
- fread(buf, 1, 1, p); // expected-warning {{Stream pointer might be NULL.}}
+ fread(buf, 1, 1, p); // expected-warning {{Stream pointer might be NULL}}
fclose(p);
}
void f2(void) {
FILE *p = fopen("foo", "r");
- fseek(p, 1, SEEK_SET); // expected-warning {{Stream pointer might be NULL.}}
+ fseek(p, 1, SEEK_SET); // expected-warning {{Stream pointer might be NULL}}
fclose(p);
}
void f3(void) {
FILE *p = fopen("foo", "r");
- ftell(p); // expected-warning {{Stream pointer might be NULL.}}
+ ftell(p); // expected-warning {{Stream pointer might be NULL}}
fclose(p);
}
void f4(void) {
FILE *p = fopen("foo", "r");
- rewind(p); // expected-warning {{Stream pointer might be NULL.}}
+ rewind(p); // expected-warning {{Stream pointer might be NULL}}
fclose(p);
}
@@ -43,26 +43,26 @@
if (!p)
return;
fseek(p, 1, SEEK_SET); // no-warning
- fseek(p, 1, 3); // expected-warning {{The whence argument to fseek() should be SEEK_SET, SEEK_END, or SEEK_CUR.}}
+ fseek(p, 1, 3); // expected-warning {{The whence argument to fseek() should be SEEK_SET, SEEK_END, or SEEK_CUR}}
fclose(p);
}
void f6(void) {
FILE *p = fopen("foo", "r");
fclose(p);
- fclose(p); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour.}}
+ fclose(p); // expected-warning {{Try to close a file Descriptor already closed. Cause undefined behaviour}}
}
void f7(void) {
FILE *p = tmpfile();
- ftell(p); // expected-warning {{Stream pointer might be NULL.}}
+ ftell(p); // expected-warning {{Stream pointer might be NULL}}
fclose(p);
}
void f8(int c) {
FILE *p = fopen("foo.c", "r");
if(c)
- return; // expected-warning {{Opened File never closed. Potential Resource leak.}}
+ return; // expected-warning {{Opened File never closed. Potential Resource leak}}
fclose(p);
}