]> granicus.if.org Git - clang/commitdiff
Instead of counting totally diagnostics, split the count into a count
authorChris Lattner <sabre@nondot.org>
Wed, 7 Apr 2010 18:47:42 +0000 (18:47 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 7 Apr 2010 18:47:42 +0000 (18:47 +0000)
of errors and warnings.  This allows us to emit something like this:

2 warnings and 1 error generated.

instead of:

3 diagnostics generated.

This also stops counting 'notes' because they are just follow-on information
about the previous diag, not a diagnostic in themselves.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100675 91177308-0d34-0410-b5e6-96231b3b80d8

14 files changed:
include/clang/Basic/Diagnostic.h
lib/Basic/Diagnostic.cpp
lib/Frontend/CompilerInstance.cpp
test/ASTMerge/category.m
test/ASTMerge/enum.c
test/ASTMerge/function.c
test/ASTMerge/interface.m
test/ASTMerge/property.m
test/ASTMerge/struct.c
test/ASTMerge/typedef.c
test/ASTMerge/var.c
test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
test/Rewriter/dllimport-typedef.c
test/Rewriter/missing-dllimport.c

index 57dd6967fc5163b0857fa0271da9c036a20a0d5b..9279871997ccbab20f22f7170a0b45f8760509a4 100644 (file)
@@ -211,8 +211,8 @@ private:
   /// diagnostic that they follow.
   Diagnostic::Level LastDiagLevel;
 
-  unsigned NumDiagnostics;    // Number of diagnostics reported
-  unsigned NumErrors;         // Number of diagnostics that are errors
+  unsigned NumWarnings;       // Number of warnings reported
+  unsigned NumErrors;         // Number of errors reported
 
   /// CustomDiagInfo - Information for uniquing and looking up custom diags.
   diag::CustomDiagInfo *CustomDiagInfo;
@@ -338,7 +338,7 @@ public:
   bool hasFatalErrorOccurred() const { return FatalErrorOccurred; }
 
   unsigned getNumErrors() const { return NumErrors; }
-  unsigned getNumDiagnostics() const { return NumDiagnostics; }
+  unsigned getNumWarnings() const { return NumWarnings; }
 
   /// getCustomDiagID - Return an ID for a diagnostic with the specified message
   /// and level.  If this is the first request for this diagnosic, it is
index 2b7fcd07f9d0c431cdd00f081878c632c11f5c74..a1094ad95cafc2c7076fa308225e8b346e5baf66 100644 (file)
@@ -223,8 +223,8 @@ Diagnostic::Diagnostic(DiagnosticClient *client) : Client(client) {
 
   ErrorOccurred = false;
   FatalErrorOccurred = false;
-  NumDiagnostics = 0;
   
+  NumWarnings = 0;
   NumErrors = 0;
   CustomDiagInfo = 0;
   CurDiagID = ~0U;
@@ -555,7 +555,10 @@ bool Diagnostic::ProcessDiag() {
 
   // Finally, report it.
   Client->HandleDiagnostic(DiagLevel, Info);
-  if (Client->IncludeInDiagnosticCounts()) ++NumDiagnostics;
+  if (Client->IncludeInDiagnosticCounts()) {
+    if (DiagLevel == Diagnostic::Warning)
+      ++NumWarnings;
+  }
 
   CurDiagID = ~0U;
 
index 1f915e3713d3cc0d8ea9ea14c5fff60dd049a8d1..685e6c281cc26e9a907cbb4755646136cb84542a 100644 (file)
@@ -513,11 +513,19 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
     }
   }
 
-  if (getDiagnosticOpts().ShowCarets)
-    if (unsigned NumDiagnostics = getDiagnostics().getNumDiagnostics())
-      OS << NumDiagnostics << " diagnostic"
-         << (NumDiagnostics == 1 ? "" : "s")
-         << " generated.\n";
+  if (getDiagnosticOpts().ShowCarets) {
+    unsigned NumWarnings = getDiagnostics().getNumWarnings();
+    unsigned NumErrors = getDiagnostics().getNumErrors();
+    
+    if (NumWarnings)
+      OS << NumWarnings << " warning" << (NumWarnings == 1 ? "" : "s");
+    if (NumWarnings && NumErrors)
+      OS << " and ";
+    if (NumErrors)
+      OS << NumErrors << " error" << (NumErrors == 1 ? "" : "s");
+    if (NumWarnings || NumErrors)
+      OS << " generated.\n";
+  }
 
   if (getFrontendOpts().ShowStats) {
     getFileManager().PrintStats();
index bf0d11b612928e6f6572f0d6ea9f08afe5c29603..6ba229204147bf8e82872f01f78b0206349d694f 100644 (file)
@@ -6,4 +6,4 @@
 // CHECK: category1.m:16:1: note: instance method 'method2' also declared here
 // CHECK: category2.m:26:1: error: instance method 'method3' has incompatible result types in different translation units ('float' vs. 'int')
 // CHECK: category1.m:24:1: note: instance method 'method3' also declared here
-// CHECK: 4 diagnostics generated.
+// CHECK: 2 errors generated.
index 9b78fd1022e4014ffd21104a3a416457da6490a7..4380d192f1bdc76b4d44f357f6d8f3b629230076 100644 (file)
@@ -22,4 +22,4 @@
 // CHECK: enum1.c:30:6: note: no corresponding enumerator here
 // CHECK: enum2.c:34:3: error: external variable 'x5' declared with incompatible types in different translation units ('enum E5' vs. 'enum E5')
 // CHECK: enum1.c:34:3: note: declared here with type 'enum E5'
-// CHECK: 20 diagnostics generated
+// CHECK: 4 warnings and 4 errors generated
index 581b6ec5882cc2bcbe557c5504e55562e6e5e21b..f97eceed9866d3ff9c6b3a53a7e2f3643afdfe79 100644 (file)
@@ -6,4 +6,4 @@
 // CHECK: function1.c:2:6: note: declared here with type 'void (int, float)'
 // CHECK: function2.c:5:6: error: external function 'f3' declared with incompatible types in different translation units ('void (int)' vs. 'void (void)')
 // CHECK: function1.c:4:6: note: declared here with type 'void (void)'
-// CHECK: 4 diagnostics generated
+// CHECK: 2 errors generated
index 47e4e052692b594b20659cd5c86a87461f445655..420ae38825482a0e677a78a0d85767e28f2bdc2c 100644 (file)
@@ -15,5 +15,5 @@
 // CHECK: interface1.m:46:1: note: class method 'bar:' also declared here
 // CHECK: interface2.m:57:20: error: instance method 'bar:' has a parameter with a different types in different translation units ('double' vs. 'float')
 // CHECK: interface1.m:58:19: note: declared here with type 'float'
-// CHECK: 13 diagnostics generated
+// CHECK: 6 errors generated
 
index 0fd7e4872d7232704e068cda39cf58ee4b755609..5f7a7308da653424f22373749923b52ce8d91f8e 100644 (file)
@@ -6,4 +6,4 @@
 // CHECK: property1.m:10:28: note: declared here with type 'float'
 // CHECK: property2.m:12:26: error: instance method 'Prop1' has incompatible result types in different translation units ('int' vs. 'float')
 // CHECK: property1.m:10:28: note: instance method 'Prop1' also declared here
-// CHECK: 4 diagnostics generated.
+// CHECK: 2 errors generated.
index e72b93b249f906aa70a8ccd0d53b8705054305e3..7217222ae5c12d4e1b1798168090f1d54ec01935 100644 (file)
@@ -39,4 +39,4 @@
 // CHECK: struct2.c:53:43: note: field 'Deeper' has type 'struct DeeperError *' here
 // CHECK: struct2.c:54:3: error: external variable 'xDeep' declared with incompatible types in different translation units ('struct DeepError' vs. 'struct DeepError')
 // CHECK: struct1.c:57:3: note: declared here with type 'struct DeepError'
-// CHECK: 37 diagnostics
+// CHECK: 8 warnings and 7 errors generated
index 4498864b49087a767e0d430ce59ca35b614e4b82..6f911295b96cf5582c9ff0dee95d5010d3f2c386 100644 (file)
@@ -4,4 +4,4 @@
 
 // CHECK: typedef2.c:4:10: error: external variable 'x2' declared with incompatible types in different translation units ('Typedef2' (aka 'double') vs. 'Typedef2' (aka 'int'))
 // CHECK: typedef1.c:4:10: note: declared here with type 'Typedef2' (aka 'int')
-// CHECK: 2 diagnostics
+// CHECK: 1 error
index fd307940aff7c7c0be47206010d12798796f7a72..7f23b9f5d26d58d992e1eeef85a9ccc6fb651416 100644 (file)
@@ -9,4 +9,4 @@
 // CHECK: var1.h:1:8: note: declared here with type 'double'
 // CHECK: error: external variable 'xarray3' declared with incompatible types in different translation units ('int [17]' vs. 'int [18]')
 // CHECK: var1.c:7:5: note: declared here with type 'int [18]'
-// CHECK: 6 diagnostics
+// CHECK: 3 errors
index 5722a04aa2ddf0b0bc249b540c5528261bd0a8b9..2e9c5286120bf38229ba92189908377a43125ce3 100644 (file)
@@ -77,6 +77,6 @@ int marker(void) { // control reaches end of non-void function
 // CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
 // CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
 // CHECK-darwin8: control reaches end of non-void function
-// CHECK-darwin8: 5 diagnostics generated
+// CHECK-darwin8: 5 warnings generated
 // CHECK-darwin9: control reaches end of non-void function
-// CHECK-darwin9: 1 diagnostic generated
+// CHECK-darwin9: 1 warning generated
index 28d2e297fa6725a74745cd73d7bd8d4df9318dc3..b86fa4a1c7375e69815231921979b301a6d77d79 100644 (file)
@@ -10,8 +10,8 @@ typedef __declspec(dllimport) int CB(void);
 void bar() { return 1; }
 
 // CHECK-NEG: warning: void function 'bar' should not return a value
-// CHECK-NEG: 1 diagnostic generated
+// CHECK-NEG: 1 warning generated
 // CHECK-POS: warning: 'dllimport' attribute only applies to variable and function type
 // CHECK-POS: warning: void function 'bar' should not return a value
-// CHECK-POS: 2 diagnostics generated
+// CHECK-POS: 2 warnings generated
 
index d2356bd9567001603b8e4181f518d3cc98f3e189..c060379db0fd91b6e38e5959a7aed3af6317af7b 100644 (file)
@@ -12,8 +12,8 @@ inline int __cdecl foo() { return 0; }
 void bar() { return 1; }
 
 // CHECK-NEG: warning: void function 'bar' should not return a value
-// CHECK-NEG: 1 diagnostic generated
+// CHECK-NEG: 1 warning generated
 // CHECK-POS: warning: 'foo' redeclared without dllimport attribute: previous dllimport ignored
 // CHECK-POS: warning: void function 'bar' should not return a value
-// CHECK-POS: 2 diagnostics generated
+// CHECK-POS: 2 warnings generated