summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-04-14 22:19:45 +0000
committerDouglas Gregor <dgregor@apple.com>2010-04-14 22:19:45 +0000
commit2d2d90750cfc4e11c3879c4bf7f913980a325575 (patch)
tree2d78c089ab73df78b14d203527a117fa339e9d26
parent99bfbca6ec232c0ee876c5843ffe63fcd9ec724b (diff)
downloadbcm5719-llvm-2d2d90750cfc4e11c3879c4bf7f913980a325575.tar.gz
bcm5719-llvm-2d2d90750cfc4e11c3879c4bf7f913980a325575.zip
Once we've emitted a fatal diagnostic, keep counting errors but with a
separate count of "suppressed" errors. This way, semantic analysis bits that depend on the error count to determine whether problems occured (e.g., some template argument deduction failures, jump-scope checking) will not get confused. The actual problem here is that a missing #include (which is a fatal error) could cause the jump-scope checker to run on invalid code, which it is not prepared to do. Trivial fix for both <rdar://problem/7775941> and <rdar://problem/7775709>. llvm-svn: 101297
-rw-r--r--clang/include/clang/Basic/Diagnostic.h4
-rw-r--r--clang/lib/Basic/Diagnostic.cpp9
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp3
-rw-r--r--clang/test/SemaCXX/missing-header.cpp9
4 files changed, 22 insertions, 3 deletions
diff --git a/clang/include/clang/Basic/Diagnostic.h b/clang/include/clang/Basic/Diagnostic.h
index 8c959b7cea2..21e2b3e1a5f 100644
--- a/clang/include/clang/Basic/Diagnostic.h
+++ b/clang/include/clang/Basic/Diagnostic.h
@@ -214,7 +214,8 @@ private:
unsigned NumWarnings; // Number of warnings reported
unsigned NumErrors; // Number of errors reported
-
+ unsigned NumErrorsSuppressed; // Number of errors suppressed
+
/// CustomDiagInfo - Information for uniquing and looking up custom diags.
diag::CustomDiagInfo *CustomDiagInfo;
@@ -343,6 +344,7 @@ public:
bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
unsigned getNumErrors() const { return NumErrors; }
+ unsigned getNumErrorsSuppressed() const { return NumErrorsSuppressed; }
unsigned getNumWarnings() const { return NumWarnings; }
/// getCustomDiagID - Return an ID for a diagnostic with the specified message
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index bd1d6e8b70e..755fbed66f3 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -227,6 +227,7 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
NumWarnings = 0;
NumErrors = 0;
+ NumErrorsSuppressed = 0;
CustomDiagInfo = 0;
CurDiagID = ~0U;
LastDiagLevel = Ignored;
@@ -537,8 +538,14 @@ bool Diagnostic::ProcessDiag() {
// If a fatal error has already been emitted, silence all subsequent
// diagnostics.
- if (FatalErrorOccurred)
+ if (FatalErrorOccurred) {
+ if (DiagLevel >= Diagnostic::Error) {
+ ++NumErrors;
+ ++NumErrorsSuppressed;
+ }
+
return false;
+ }
// If the client doesn't care about this message, don't issue it. If this is
// a note and the last real diagnostic was ignored, ignore it too.
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index 685e6c281cc..5ed9c409a3d 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -515,7 +515,8 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
if (getDiagnosticOpts().ShowCarets) {
unsigned NumWarnings = getDiagnostics().getNumWarnings();
- unsigned NumErrors = getDiagnostics().getNumErrors();
+ unsigned NumErrors = getDiagnostics().getNumErrors() -
+ getDiagnostics().getNumErrorsSuppressed();
if (NumWarnings)
OS << NumWarnings << " warning" << (NumWarnings == 1 ? "" : "s");
diff --git a/clang/test/SemaCXX/missing-header.cpp b/clang/test/SemaCXX/missing-header.cpp
new file mode 100644
index 00000000000..f4365799005
--- /dev/null
+++ b/clang/test/SemaCXX/missing-header.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "not exist" // expected-error{{'not exist' file not found}}
+
+class AnalysisContext {};
+static ControlFlowKind CheckFallThrough(AnalysisContext &AC) {
+ if (const AsmStmt *AS = dyn_cast<AsmStmt>(S)) {}
+ bool NoReturnEdge = false;
+}
OpenPOWER on IntegriCloud