[cfe-commits] r100675 - in /cfe/trunk: 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
Chris Lattner
sabre at nondot.org
Wed Apr 7 11:47:42 PDT 2010
Author: lattner
Date: Wed Apr 7 13:47:42 2010
New Revision: 100675
URL: http://llvm.org/viewvc/llvm-project?rev=100675&view=rev
Log:
Instead of counting totally diagnostics, split the count into a count
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.
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/test/ASTMerge/category.m
cfe/trunk/test/ASTMerge/enum.c
cfe/trunk/test/ASTMerge/function.c
cfe/trunk/test/ASTMerge/interface.m
cfe/trunk/test/ASTMerge/property.m
cfe/trunk/test/ASTMerge/struct.c
cfe/trunk/test/ASTMerge/typedef.c
cfe/trunk/test/ASTMerge/var.c
cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
cfe/trunk/test/Rewriter/dllimport-typedef.c
cfe/trunk/test/Rewriter/missing-dllimport.c
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Wed Apr 7 13:47:42 2010
@@ -211,8 +211,8 @@
/// 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 @@
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
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Wed Apr 7 13:47:42 2010
@@ -223,8 +223,8 @@
ErrorOccurred = false;
FatalErrorOccurred = false;
- NumDiagnostics = 0;
+ NumWarnings = 0;
NumErrors = 0;
CustomDiagInfo = 0;
CurDiagID = ~0U;
@@ -555,7 +555,10 @@
// Finally, report it.
Client->HandleDiagnostic(DiagLevel, Info);
- if (Client->IncludeInDiagnosticCounts()) ++NumDiagnostics;
+ if (Client->IncludeInDiagnosticCounts()) {
+ if (DiagLevel == Diagnostic::Warning)
+ ++NumWarnings;
+ }
CurDiagID = ~0U;
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Apr 7 13:47:42 2010
@@ -513,11 +513,19 @@
}
}
- 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();
Modified: cfe/trunk/test/ASTMerge/category.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/category.m?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/category.m (original)
+++ cfe/trunk/test/ASTMerge/category.m Wed Apr 7 13:47:42 2010
@@ -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.
Modified: cfe/trunk/test/ASTMerge/enum.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/enum.c?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/enum.c (original)
+++ cfe/trunk/test/ASTMerge/enum.c Wed Apr 7 13:47:42 2010
@@ -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
Modified: cfe/trunk/test/ASTMerge/function.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/function.c?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/function.c (original)
+++ cfe/trunk/test/ASTMerge/function.c Wed Apr 7 13:47:42 2010
@@ -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
Modified: cfe/trunk/test/ASTMerge/interface.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/interface.m?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/interface.m (original)
+++ cfe/trunk/test/ASTMerge/interface.m Wed Apr 7 13:47:42 2010
@@ -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
Modified: cfe/trunk/test/ASTMerge/property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/property.m?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/property.m (original)
+++ cfe/trunk/test/ASTMerge/property.m Wed Apr 7 13:47:42 2010
@@ -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.
Modified: cfe/trunk/test/ASTMerge/struct.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/struct.c?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/struct.c (original)
+++ cfe/trunk/test/ASTMerge/struct.c Wed Apr 7 13:47:42 2010
@@ -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
Modified: cfe/trunk/test/ASTMerge/typedef.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/typedef.c?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/typedef.c (original)
+++ cfe/trunk/test/ASTMerge/typedef.c Wed Apr 7 13:47:42 2010
@@ -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
Modified: cfe/trunk/test/ASTMerge/var.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/var.c?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/ASTMerge/var.c (original)
+++ cfe/trunk/test/ASTMerge/var.c Wed Apr 7 13:47:42 2010
@@ -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
Modified: cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m (original)
+++ cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret.m Wed Apr 7 13:47:42 2010
@@ -77,6 +77,6 @@
// 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
Modified: cfe/trunk/test/Rewriter/dllimport-typedef.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/dllimport-typedef.c?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/dllimport-typedef.c (original)
+++ cfe/trunk/test/Rewriter/dllimport-typedef.c Wed Apr 7 13:47:42 2010
@@ -10,8 +10,8 @@
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
Modified: cfe/trunk/test/Rewriter/missing-dllimport.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/missing-dllimport.c?rev=100675&r1=100674&r2=100675&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/missing-dllimport.c (original)
+++ cfe/trunk/test/Rewriter/missing-dllimport.c Wed Apr 7 13:47:42 2010
@@ -12,8 +12,8 @@
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
More information about the cfe-commits
mailing list