[include-fixer] Don't interfere with typo correction if we found nothing.

Just let the existing typo correction machinery handle that.

llvm-svn: 288043
This commit is contained in:
Benjamin Kramer 2016-11-28 17:16:18 +00:00
parent fb50133076
commit 7902aa79bb
2 changed files with 6 additions and 6 deletions

View File

@ -279,9 +279,9 @@ clang::TypoCorrection IncludeFixerSemaSource::CorrectTypo(
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 IncludeFixerSemaSource::CorrectTypo(
getIncludeFixerContext(SM, CI->getPreprocessor().getHeaderSearchInfo(),
MatchedSymbols),
Code, StartOfFile, CI->getASTContext());
return Correction;
}
return Correction;
return TypoCorrection();
}
/// Get the minimal include for a given path.

View File

@ -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