forked from OSchip/llvm-project
Don't include FixIts with a null replacement range. Fixes <rdar://problem/11040133>.
llvm-svn: 153122
This commit is contained in:
parent
e6b4a16ddd
commit
4a64230ee7
|
@ -946,7 +946,8 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
|
|||
|
||||
inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
|
||||
const FixItHint &Hint) {
|
||||
DB.AddFixItHint(Hint);
|
||||
if (!Hint.isNull())
|
||||
DB.AddFixItHint(Hint);
|
||||
return DB;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,13 +36,20 @@ void test1(A *a, struct UnsafeS *unsafeS) {
|
|||
}
|
||||
|
||||
// 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
|
||||
|
||||
|
|
|
@ -25,9 +25,15 @@ void testMacro() {
|
|||
// 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 @@ void testMacro() {
|
|||
// 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
|
||||
|
||||
|
|
|
@ -381,6 +381,7 @@ void PrintDiagnostic(CXDiagnostic Diagnostic) {
|
|||
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 printRanges(CXDiagnostic D, unsigned indent) {
|
|||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue