[cfe-commits] r153122 - in /cfe/trunk: include/clang/Basic/Diagnostic.h test/ARCMT/check-with-serialized-diag.m test/Misc/serialized-diags.c tools/c-index-test/c-index-test.c
Ted Kremenek
kremenek at apple.com
Tue Mar 20 13:49:46 PDT 2012
Author: kremenek
Date: Tue Mar 20 15:49:45 2012
New Revision: 153122
URL: http://llvm.org/viewvc/llvm-project?rev=153122&view=rev
Log:
Don't include FixIts with a null replacement range. Fixes <rdar://problem/11040133>.
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
cfe/trunk/test/ARCMT/check-with-serialized-diag.m
cfe/trunk/test/Misc/serialized-diags.c
cfe/trunk/tools/c-index-test/c-index-test.c
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=153122&r1=153121&r2=153122&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue Mar 20 15:49:45 2012
@@ -946,7 +946,8 @@
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
const FixItHint &Hint) {
- DB.AddFixItHint(Hint);
+ if (!Hint.isNull())
+ DB.AddFixItHint(Hint);
return DB;
}
Modified: cfe/trunk/test/ARCMT/check-with-serialized-diag.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/check-with-serialized-diag.m?rev=153122&r1=153121&r2=153122&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/check-with-serialized-diag.m (original)
+++ cfe/trunk/test/ARCMT/check-with-serialized-diag.m Tue Mar 20 15:49:45 2012
@@ -36,13 +36,20 @@
}
// RUN: not %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 %s -serialize-diagnostic-file %t.diag
-// RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s
+// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
// CHECK: {{.*}}check-with-serialized-diag.m:32:4: error: [rewriter] it is not safe to remove 'retain' message on an __unsafe_unretained type
+// CHECK-NEXT: Number FIXITs = 0
// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: [rewriter] it is not safe to remove 'retain' message on a global variable
+// CHECK-NEXT: Number FIXITs = 0
// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:32:4: error: ARC forbids explicit message send of 'retain'
// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:32:23 {{.*}}check-with-serialized-diag.m:32:29
+// CHECK-NEXT: Number FIXITs = 0
// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:34:4: error: ARC forbids explicit message send of 'retain'
// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:34:15 {{.*}}check-with-serialized-diag.m:34:21
+// CHECK-NEXT: Number FIXITs = 0
// CHECK-NEXT: {{.*}}check-with-serialized-diag.m:35:4: error: ARC forbids explicit message send of 'retainCount'
// CHECK-NEXT: Range: {{.*}}check-with-serialized-diag.m:35:6 {{.*}}check-with-serialized-diag.m:35:17
+// CHECK-NEXT: Number FIXITs = 0
+
Modified: cfe/trunk/test/Misc/serialized-diags.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/serialized-diags.c?rev=153122&r1=153121&r2=153122&view=diff
==============================================================================
--- cfe/trunk/test/Misc/serialized-diags.c (original)
+++ cfe/trunk/test/Misc/serialized-diags.c Tue Mar 20 15:49:45 2012
@@ -25,9 +25,15 @@
// Test handling of issues from #includes.
#include "serialized-diags.h"
+// Test handling of warnings that have empty fixits.
+void rdar11040133() {
+ unsigned x;
+}
+
// RUN: rm -f %t
-// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t > /dev/null 2>&1 || true
-// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s
+// RUN: %clang -Wall -fsyntax-only %s --serialize-diagnostics %t.diag > /dev/null 2>&1 || true
+// RUN: c-index-test -read-diagnostics %t.diag > %t 2>&1
+// RUN: FileCheck --input-file=%t %s
// This test case tests that we can handle multiple diagnostics which contain
// FIXITs at different levels (one at the note, another at the main diagnostic).
@@ -55,5 +61,8 @@
// CHECK: {{.*[/\\]}}serialized-diags.h:5:7: warning: incompatible integer to pointer conversion initializing 'char *' with an expression of type 'int'; [-Wint-conversion]
// CHECK: Range: {{.*[/\\]}}serialized-diags.h:5:16 {{.*[/\\]}}serialized-diags.h:5:17
// CHECK: +-{{.*[/\\]}}serialized-diags.c:26:10: note: in file included from {{.*[/\\]}}serialized-diags.c:26: []
-// CHECK: Number of diagnostics: 5
+// CHECK: Number FIXITs = 0
+// CHECK: {{.*[/\\]}}serialized-diags.c:30:12: warning: unused variable 'x'
+// CHECK: Number FIXITs = 0
+// CHECK: Number of diagnostics: 6
Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=153122&r1=153121&r2=153122&view=diff
==============================================================================
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue Mar 20 15:49:45 2012
@@ -381,6 +381,7 @@
return;
num_fixits = clang_getDiagnosticNumFixIts(Diagnostic);
+ fprintf(stderr, "Number FIX-ITs = %d\n", num_fixits);
for (i = 0; i != num_fixits; ++i) {
CXSourceRange range;
CXString insertion_text = clang_getDiagnosticFixIt(Diagnostic, i, &range);
@@ -2501,6 +2502,7 @@
static void printFixIts(CXDiagnostic D, unsigned indent) {
unsigned i, n = clang_getDiagnosticNumFixIts(D);
+ fprintf(stderr, "Number FIXITs = %d\n", n);
for (i = 0 ; i < n; ++i) {
CXSourceRange ReplacementRange;
CXString text;
More information about the cfe-commits
mailing list