[clang-tools-extra] r288043 - [include-fixer] Don't interfere with typo correction if we found nothing.
Benjamin Kramer via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 28 09:16:18 PST 2016
Author: d0k
Date: Mon Nov 28 11:16:18 2016
New Revision: 288043
URL: http://llvm.org/viewvc/llvm-project?rev=288043&view=rev
Log:
[include-fixer] Don't interfere with typo correction if we found nothing.
Just let the existing typo correction machinery handle that.
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=288043&r1=288042&r2=288043&view=diff
==============================================================================
--- clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/IncludeFixer.cpp Mon Nov 28 11:16:18 2016
@@ -279,9 +279,9 @@ clang::TypoCorrection IncludeFixerSemaSo
std::vector<find_all_symbols::SymbolInfo> MatchedSymbols =
query(QueryString, TypoScopeString, SymbolRange);
- clang::TypoCorrection Correction(Typo.getName());
- Correction.setCorrectionRange(SS, Typo);
if (!MatchedSymbols.empty() && GenerateDiagnostics) {
+ TypoCorrection Correction(Typo.getName());
+ Correction.setCorrectionRange(SS, Typo);
FileID FID = SM.getFileID(Typo.getLoc());
StringRef Code = SM.getBufferData(FID);
SourceLocation StartOfFile = SM.getLocForStartOfFile(FID);
@@ -290,8 +290,9 @@ clang::TypoCorrection IncludeFixerSemaSo
getIncludeFixerContext(SM, CI->getPreprocessor().getHeaderSearchInfo(),
MatchedSymbols),
Code, StartOfFile, CI->getASTContext());
+ return Correction;
}
- return Correction;
+ return TypoCorrection();
}
/// Get the minimal include for a given path.
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=288043&r1=288042&r2=288043&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp (original)
+++ clang-tools-extra/trunk/test/include-fixer/yamldb_plugin.cpp Mon Nov 28 11:16:18 2016
@@ -10,8 +10,7 @@ unknown u;
// CHECK: Number FIX-ITs = 1
// CHECK: FIX-IT: Replace [3:1 - 3:4] with "#include "foo.h"
// CHECK: yamldb_plugin.cpp:4:1:
-// CHECK: error: unknown type name 'unknown'; did you mean 'unknown'?
-// CHECK: Number FIX-ITs = 1
-// CHECK: FIX-IT: Replace [4:1 - 4:8] with "unknown"
+// CHECK: error: unknown type name 'unknown'
+// CHECK: Number FIX-ITs = 0
// CHECK-NOT: error
// CHECK-NOT: FIX-IT
More information about the cfe-commits
mailing list