From 35d53951a452b0a76665af7f1a74430733768b75 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 30 Nov 2016 14:37:40 +0000 Subject: [PATCH] [include-fixer] Don't skip repeated lookups in plugin mode. In this mode not all the errors are fixed so it doesn't make sense to ignore later ones. llvm-svn: 288244 --- clang-tools-extra/include-fixer/IncludeFixer.cpp | 2 +- clang-tools-extra/test/include-fixer/yamldb_plugin.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clang-tools-extra/include-fixer/IncludeFixer.cpp b/clang-tools-extra/include-fixer/IncludeFixer.cpp index cef6fa5..20683e0 100644 --- a/clang-tools-extra/include-fixer/IncludeFixer.cpp +++ b/clang-tools-extra/include-fixer/IncludeFixer.cpp @@ -350,7 +350,7 @@ IncludeFixerSemaSource::query(StringRef Query, StringRef ScopedQualifiers, // here. The symbols which have the same ScopedQualifier and RawIdentifier // are considered equal. So that include-fixer avoids false positives, and // always adds missing qualifiers to correct symbols. - if (!QuerySymbolInfos.empty()) { + if (!GenerateDiagnostics && !QuerySymbolInfos.empty()) { if (ScopedQualifiers == QuerySymbolInfos.front().ScopedQualifiers && Query == QuerySymbolInfos.front().RawIdentifier) { QuerySymbolInfos.push_back({Query.str(), ScopedQualifiers, Range}); diff --git a/clang-tools-extra/test/include-fixer/yamldb_plugin.cpp b/clang-tools-extra/test/include-fixer/yamldb_plugin.cpp index fa486cf..8de643e 100644 --- a/clang-tools-extra/test/include-fixer/yamldb_plugin.cpp +++ b/clang-tools-extra/test/include-fixer/yamldb_plugin.cpp @@ -1,6 +1,7 @@ // RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-include-fixer -fspell-checking -Xclang -plugin-arg-clang-include-fixer -Xclang -input=%p/Inputs/fake_yaml_db.yaml 2>&1 | FileCheck %s foo f; +foo g; unknown u; // CHECK: yamldb_plugin.cpp:3:1: error: unknown type name 'foo'; did you mean 'foo'? @@ -9,8 +10,14 @@ unknown u; // CHECK: yamldb_plugin.cpp:3:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] // CHECK: Number FIX-ITs = 1 // CHECK: FIX-IT: Insert "#include "foo.h" +// CHECK: yamldb_plugin.cpp:4:1: error: unknown type name 'foo'; did you mean 'foo'? +// CHECK: Number FIX-ITs = 1 +// CHECK: FIX-IT: Replace [4:1 - 4:4] with "foo" +// CHECK: yamldb_plugin.cpp:4:1: note: Add '#include "foo.h"' to provide the missing declaration [clang-include-fixer] +// CHECK: Number FIX-ITs = 1 +// CHECK: FIX-IT: Insert "#include "foo.h" // CHECK: " at 3:1 -// CHECK: yamldb_plugin.cpp:4:1: +// CHECK: yamldb_plugin.cpp:5:1: // CHECK: error: unknown type name 'unknown' // CHECK: Number FIX-ITs = 0 // CHECK-NOT: error -- 2.7.4