r222460 - Correctly set the SourceRange a TypoCorrection will replace.
Kaelyn Takata
rikka at google.com
Thu Nov 20 14:06:27 PST 2014
Author: rikka
Date: Thu Nov 20 16:06:26 2014
New Revision: 222460
URL: http://llvm.org/viewvc/llvm-project?rev=222460&view=rev
Log:
Correctly set the SourceRange a TypoCorrection will replace.
Also clean up TypoCorrection::setCorrectionRange while we're at it.
Modified:
cfe/trunk/include/clang/Sema/TypoCorrection.h
cfe/trunk/lib/Sema/SemaLookup.cpp
Modified: cfe/trunk/include/clang/Sema/TypoCorrection.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/TypoCorrection.h?rev=222460&r1=222459&r2=222460&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/TypoCorrection.h (original)
+++ cfe/trunk/include/clang/Sema/TypoCorrection.h Thu Nov 20 16:06:26 2014
@@ -199,10 +199,9 @@ public:
void setCorrectionRange(CXXScopeSpec *SS,
const DeclarationNameInfo &TypoName) {
- CorrectionRange.setBegin(ForceSpecifierReplacement && SS && !SS->isEmpty()
- ? SS->getBeginLoc()
- : TypoName.getLoc());
- CorrectionRange.setEnd(TypoName.getLoc());
+ CorrectionRange = TypoName.getSourceRange();
+ if (ForceSpecifierReplacement && SS && !SS->isEmpty())
+ CorrectionRange.setBegin(SS->getBeginLoc());
}
SourceRange getCorrectionRange() const {
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=222460&r1=222459&r2=222460&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Nov 20 16:06:26 2014
@@ -3414,6 +3414,7 @@ void TypoCorrectionConsumer::addName(Str
TypoCorrection TC(&SemaRef.Context.Idents.get(Name), ND, NNS, ED);
if (isKeyword) TC.makeKeyword();
+ TC.setCorrectionRange(nullptr, Result.getLookupNameInfo());
addCorrection(TC);
}
@@ -3521,8 +3522,6 @@ bool TypoCorrectionConsumer::resolveCorr
IdentifierInfo *Name = Candidate.getCorrectionAsIdentifierInfo();
DeclContext *TempMemberContext = MemberContext;
CXXScopeSpec *TempSS = SS.get();
- if (Candidate.getCorrectionRange().isInvalid())
- Candidate.setCorrectionRange(TempSS, Result.getLookupNameInfo());
retry_lookup:
LookupPotentialTypoResult(SemaRef, Result, Name, S, TempSS, TempMemberContext,
EnteringContext,
@@ -3563,6 +3562,7 @@ retry_lookup:
QualifiedResults.push_back(Candidate);
break;
}
+ Candidate.setCorrectionRange(TempSS, Result.getLookupNameInfo());
return true;
}
return false;
@@ -3628,8 +3628,10 @@ void TypoCorrectionConsumer::performQual
TRD.getPair()) == Sema::AR_accessible)
TC.addCorrectionDecl(*TRD);
}
- if (TC.isResolved())
+ if (TC.isResolved()) {
+ TC.setCorrectionRange(SS.get(), Result.getLookupNameInfo());
addCorrection(TC);
+ }
break;
}
case LookupResult::NotFound:
More information about the cfe-commits
mailing list