[clang-tools-extra] r288244 - [include-fixer] Don't skip repeated lookups in plugin mode.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 30 06:37:41 PST 2016
Author: d0k
Date: Wed Nov 30 08:37:40 2016
New Revision: 288244
URL: http://llvm.org/viewvc/llvm-project?rev=288244&view=rev
Log:
[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.
Modified:
clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
Modified: clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp?rev=288244&r1=288243&r2=288244&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Wed Nov 30 08:37:40 2016
@@ -350,7 +350,7 @@ IncludeFixerSemaSource::query(StringRef
// 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});
Modified: clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp?rev=288244&r1=288243&r2=288244&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp (original)
+++ clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp Wed Nov 30 08:37:40 2016
@@ -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
More information about the cfe-commits
mailing list