本文整理汇总了C++中Sema::CorrectTypo方法的典型用法代码示例。如果您正苦于以下问题:C++ Sema::CorrectTypo方法的具体用法?C++ Sema::CorrectTypo怎么用?C++ Sema::CorrectTypo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sema
的用法示例。
在下文中一共展示了Sema::CorrectTypo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CorrectedStr
// Returns true on failure.
static bool
LookupMemberExprInRecord(Sema &SemaRef, LookupResult &R,
//SourceRange BaseRange,
const StructType *STy,
SourceLocation OpLoc) {
StructTypeDecl *SDecl = STy->getDecl();
DeclContext *DC = SDecl;
// The record definition is complete, now look up the member.
SemaRef.LookupQualifiedName(R, DC);
if (!R.empty())
return false;
#if 0
// We didn't find anything with the given name, so try to correct
// for typos.
DeclarationName Name = R.getLookupName();
RecordMemberExprValidatorCCC Validator;
TypoCorrection Corrected = SemaRef.CorrectTypo(R.getLookupNameInfo(),
R.getLookupKind(), NULL,
&SS, Validator, DC);
R.clear();
if (NamedDecl *ND = Corrected.getCorrectionDecl()) {
std::string CorrectedStr(
Corrected.getAsString(SemaRef.getLangOpts()));
std::string CorrectedQuotedStr(
Corrected.getQuoted(SemaRef.getLangOpts()));
R.setLookupName(Corrected.getCorrection());
R.addDecl(ND);
SemaRef.Diag(R.getNameLoc(), diag::err_no_member_suggest)
<< Name << DC << CorrectedQuotedStr << SS.getRange()
<< FixItHint::CreateReplacement(Corrected.getCorrectionRange(),
CorrectedStr);
SemaRef.Diag(ND->getLocation(), diag::note_previous_decl)
<< ND->getDeclName();
}
#endif
// FIXME: Is this right? (also in clang)
return false;
}