clang 20.0.0git
|
Simple class containing the result of Sema::CorrectTypo. More...
#include "clang/Sema/TypoCorrection.h"
Public Types | |
using | decl_iterator = SmallVectorImpl< NamedDecl * >::iterator |
using | const_decl_iterator = SmallVectorImpl< NamedDecl * >::const_iterator |
Public Member Functions | |
TypoCorrection (const DeclarationName &Name, NamedDecl *NameDecl, NestedNameSpecifier *NNS=nullptr, unsigned CharDistance=0, unsigned QualifierDistance=0) | |
TypoCorrection (NamedDecl *Name, NestedNameSpecifier *NNS=nullptr, unsigned CharDistance=0) | |
TypoCorrection (DeclarationName Name, NestedNameSpecifier *NNS=nullptr, unsigned CharDistance=0) | |
TypoCorrection ()=default | |
DeclarationName | getCorrection () const |
Gets the DeclarationName of the typo correction. | |
IdentifierInfo * | getCorrectionAsIdentifierInfo () const |
NestedNameSpecifier * | getCorrectionSpecifier () const |
Gets the NestedNameSpecifier needed to use the typo correction. | |
void | setCorrectionSpecifier (NestedNameSpecifier *NNS) |
void | WillReplaceSpecifier (bool ForceReplacement) |
bool | WillReplaceSpecifier () const |
void | setQualifierDistance (unsigned ED) |
void | setCallbackDistance (unsigned ED) |
unsigned | getEditDistance (bool Normalized=true) const |
Gets the "edit distance" of the typo correction from the typo. | |
NamedDecl * | getFoundDecl () const |
Get the correction declaration found by name lookup (before we looked through using shadow declarations and the like). | |
NamedDecl * | getCorrectionDecl () const |
Gets the pointer to the declaration of the typo correction. | |
template<class DeclClass > | |
DeclClass * | getCorrectionDeclAs () const |
void | ClearCorrectionDecls () |
Clears the list of NamedDecls. | |
void | setCorrectionDecl (NamedDecl *CDecl) |
Clears the list of NamedDecls before adding the new one. | |
void | setCorrectionDecls (ArrayRef< NamedDecl * > Decls) |
Clears the list of NamedDecls and adds the given set. | |
void | addCorrectionDecl (NamedDecl *CDecl) |
Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the DeclarationName of this TypoCorrection. | |
std::string | getAsString (const LangOptions &LO) const |
std::string | getQuoted (const LangOptions &LO) const |
operator bool () const | |
Returns whether this TypoCorrection has a non-empty DeclarationName. | |
void | makeKeyword () |
Mark this TypoCorrection as being a keyword. | |
bool | isKeyword () const |
template<std::size_t StrLen> | |
bool | isKeyword (const char(&Str)[StrLen]) const |
bool | isResolved () const |
bool | isOverloaded () const |
void | setCorrectionRange (CXXScopeSpec *SS, const DeclarationNameInfo &TypoName) |
SourceRange | getCorrectionRange () const |
decl_iterator | begin () |
decl_iterator | end () |
const_decl_iterator | begin () const |
const_decl_iterator | end () const |
bool | requiresImport () const |
Returns whether this typo correction is correcting to a declaration that was declared in a module that has not been imported. | |
void | setRequiresImport (bool Req) |
void | addExtraDiagnostic (PartialDiagnostic PD) |
Extra diagnostics are printed after the first diagnostic for the typo. | |
ArrayRef< PartialDiagnostic > | getExtraDiagnostics () const |
Static Public Member Functions | |
static unsigned | NormalizeEditDistance (unsigned ED) |
Static Public Attributes | |
static const unsigned | InvalidDistance = std::numeric_limits<unsigned>::max() |
static const unsigned | MaximumDistance = 10000U |
static const unsigned | CharDistanceWeight = 100U |
static const unsigned | QualifierDistanceWeight = 110U |
static const unsigned | CallbackDistanceWeight = 150U |
Simple class containing the result of Sema::CorrectTypo.
Definition at line 42 of file TypoCorrection.h.
using clang::TypoCorrection::const_decl_iterator = SmallVectorImpl<NamedDecl *>::const_iterator |
Definition at line 238 of file TypoCorrection.h.
using clang::TypoCorrection::decl_iterator = SmallVectorImpl<NamedDecl *>::iterator |
Definition at line 230 of file TypoCorrection.h.
|
inline |
Definition at line 59 of file TypoCorrection.h.
|
inline |
Definition at line 68 of file TypoCorrection.h.
|
inline |
Definition at line 76 of file TypoCorrection.h.
|
default |
void TypoCorrection::addCorrectionDecl | ( | NamedDecl * | CDecl | ) |
Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the DeclarationName of this TypoCorrection.
Definition at line 5392 of file SemaLookup.cpp.
References clang::NamedDecl::getDeclName(), and isKeyword().
Referenced by setCorrectionDecl().
|
inline |
Extra diagnostics are printed after the first diagnostic for the typo.
This can be used to attach external notes to the diag.
Definition at line 253 of file TypoCorrection.h.
|
inline |
Definition at line 232 of file TypoCorrection.h.
References isKeyword().
Referenced by checkCorrectionVisibility(), and DiagnoseInvalidRedeclaration().
|
inline |
Definition at line 240 of file TypoCorrection.h.
References isKeyword().
|
inline |
Clears the list of NamedDecls.
Definition at line 161 of file TypoCorrection.h.
|
inline |
Definition at line 236 of file TypoCorrection.h.
Referenced by checkCorrectionVisibility(), and DiagnoseInvalidRedeclaration().
|
inline |
Definition at line 244 of file TypoCorrection.h.
std::string TypoCorrection::getAsString | ( | const LangOptions & | LO | ) | const |
Definition at line 5404 of file SemaLookup.cpp.
References clang::DeclarationName::getAsString(), and clang::NestedNameSpecifier::print().
Referenced by clang::TypoCorrectionConsumer::addCorrection(), clang::Sema::DiagnoseEmptyLookup(), clang::Sema::diagnoseTypo(), emitEmptyLookupTypoDiagnostic(), and getQuoted().
|
inline |
Gets the DeclarationName of the typo correction.
Definition at line 84 of file TypoCorrection.h.
Referenced by clang::Sema::CorrectTypo(), clang::Sema::DiagnoseEmptyLookup(), and DiagnoseInvalidRedeclaration().
|
inline |
Definition at line 86 of file TypoCorrection.h.
References clang::DeclarationName::getAsIdentifierInfo().
Referenced by clang::TypoCorrectionConsumer::addCorrection(), DiagnoseInvalidRedeclaration(), clang::Sema::getTypeName(), isKeyword(), and clang::CorrectionCandidateCallback::MatchesTypo().
|
inline |
Gets the pointer to the declaration of the typo correction.
Definition at line 151 of file TypoCorrection.h.
References D, and getFoundDecl().
Referenced by clang::TypoCorrectionConsumer::addCorrection(), clang::Sema::diagnoseExprIntendedAsTemplateName(), DiagnoseInvalidRedeclaration(), getCorrectionDeclAs(), clang::Sema::ImplicitlyDefineFunction(), clang::Sema::resolveAssumedTemplateNameAsType(), and clang::FunctionCallFilterCCC::ValidateCandidate().
|
inline |
Definition at line 156 of file TypoCorrection.h.
References getCorrectionDecl().
Referenced by clang::SemaObjC::actOnObjCTypeArgsOrProtocolQualifiers(), clang::SemaObjC::ActOnStartClassImplementation(), clang::Sema::BuildMemInitializer(), clang::Sema::DiagnoseEmptyLookup(), emitEmptyLookupTypoDiagnostic(), clang::SemaObjC::FindProtocolDeclaration(), clang::Sema::resolveAssumedTemplateNameAsType(), and clang::DeclFilterCCC< C >::ValidateCandidate().
|
inline |
Definition at line 226 of file TypoCorrection.h.
Referenced by attemptRecovery(), clang::Sema::ConvertArgumentsForCall(), DiagnoseInvisibleNamespace(), and clang::Sema::diagnoseTypo().
|
inline |
Gets the NestedNameSpecifier needed to use the typo correction.
Definition at line 91 of file TypoCorrection.h.
Referenced by attemptRecovery(), clang::Sema::DiagnoseEmptyLookup(), clang::Sema::getTypeName(), clang::CorrectionCandidateCallback::MatchesTypo(), and clang::CorrectionCandidateCallback::ValidateCandidate().
Gets the "edit distance" of the typo correction from the typo.
If Normalized is true, scale the distance down by the CharDistanceWeight to return the edit distance in terms of single-character edits.
Definition at line 128 of file TypoCorrection.h.
References CallbackDistanceWeight, CharDistanceWeight, InvalidDistance, MaximumDistance, NormalizeEditDistance(), and QualifierDistanceWeight.
Referenced by clang::TypoCorrectionConsumer::addCorrection(), clang::Sema::CorrectTypo(), and isCandidateViable().
|
inline |
Definition at line 256 of file TypoCorrection.h.
Referenced by clang::Sema::diagnoseTypo().
|
inline |
Get the correction declaration found by name lookup (before we looked through using shadow declarations and the like).
Definition at line 146 of file TypoCorrection.h.
Referenced by clang::TypoCorrectionConsumer::addCorrection(), attemptRecovery(), clang::Sema::DiagnoseEmptyLookup(), DiagnoseInvisibleNamespace(), clang::Sema::diagnoseTypo(), getCorrectionDecl(), and clang::Sema::resolveAssumedTemplateNameAsType().
|
inline |
Definition at line 183 of file TypoCorrection.h.
References getAsString().
Referenced by clang::Sema::diagnoseTypo().
|
inline |
Definition at line 202 of file TypoCorrection.h.
Referenced by addCorrectionDecl(), begin(), clang::Sema::diagnoseExprIntendedAsTemplateName(), clang::Sema::diagnoseTypo(), isKeyword(), clang::CorrectionCandidateCallback::ValidateCandidate(), and clang::FunctionCallFilterCCC::ValidateCandidate().
|
inline |
Definition at line 208 of file TypoCorrection.h.
References getCorrectionAsIdentifierInfo(), isKeyword(), and clang::IdentifierInfo::isStr().
|
inline |
Definition at line 215 of file TypoCorrection.h.
Referenced by clang::Sema::DiagnoseEmptyLookup().
|
inline |
Definition at line 213 of file TypoCorrection.h.
Referenced by clang::TypoCorrectionConsumer::addCorrection(), clang::TypoCorrectionConsumer::getNextCorrection(), clang::CorrectionCandidateCallback::MatchesTypo(), and clang::CorrectionCandidateCallback::ValidateCandidate().
|
inline |
Mark this TypoCorrection as being a keyword.
Since addCorrectionDeclsand setCorrectionDecl don't allow NULL to be added to the list of the correction's NamedDecl pointers, NULL is added as the only element in the list to mark this TypoCorrection as a keyword.
Definition at line 194 of file TypoCorrection.h.
Definition at line 119 of file TypoCorrection.h.
References CharDistanceWeight, InvalidDistance, and MaximumDistance.
Referenced by clang::TypoCorrectionConsumer::getBestEditDistance(), and getEditDistance().
|
inlineexplicit |
Returns whether this TypoCorrection has a non-empty DeclarationName.
Definition at line 188 of file TypoCorrection.h.
References bool.
|
inline |
Returns whether this typo correction is correcting to a declaration that was declared in a module that has not been imported.
Definition at line 248 of file TypoCorrection.h.
Referenced by clang::Sema::diagnoseTypo(), clang::TypoCorrectionConsumer::getNextCorrection(), and clang::CorrectionCandidateCallback::MatchesTypo().
|
inline |
Definition at line 112 of file TypoCorrection.h.
Referenced by isCandidateViable().
|
inline |
Clears the list of NamedDecls before adding the new one.
Definition at line 166 of file TypoCorrection.h.
References addCorrectionDecl().
Referenced by DiagnoseInvalidRedeclaration().
Clears the list of NamedDecls and adds the given set.
Definition at line 172 of file TypoCorrection.h.
Referenced by checkCorrectionVisibility().
|
inline |
Definition at line 219 of file TypoCorrection.h.
References clang::CXXScopeSpec::getBeginLoc(), clang::DeclarationNameInfo::getSourceRange(), clang::CXXScopeSpec::isEmpty(), and clang::SourceRange::setBegin().
Referenced by clang::Sema::CorrectTypo().
|
inline |
Definition at line 95 of file TypoCorrection.h.
|
inline |
Definition at line 108 of file TypoCorrection.h.
|
inline |
Definition at line 249 of file TypoCorrection.h.
Referenced by checkCorrectionVisibility().
|
inline |
Definition at line 104 of file TypoCorrection.h.
|
inline |
Definition at line 100 of file TypoCorrection.h.
Referenced by attemptRecovery(), clang::Sema::DiagnoseEmptyLookup(), and emitEmptyLookupTypoDiagnostic().
|
static |
Definition at line 57 of file TypoCorrection.h.
Referenced by getEditDistance().
|
static |
Definition at line 55 of file TypoCorrection.h.
Referenced by getEditDistance(), and NormalizeEditDistance().
Definition at line 45 of file TypoCorrection.h.
Referenced by getEditDistance(), isCandidateViable(), and NormalizeEditDistance().
|
static |
Definition at line 49 of file TypoCorrection.h.
Referenced by getEditDistance(), and NormalizeEditDistance().
|
static |
Definition at line 56 of file TypoCorrection.h.
Referenced by getEditDistance().