clang API Documentation
Simple class containing the result of Sema::CorrectTypo. More...
#include <TypoCorrection.h>
Public Types | |
typedef SmallVectorImpl < NamedDecl * >::iterator | decl_iterator |
typedef SmallVectorImpl < NamedDecl * > ::const_iterator | const_decl_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 () | |
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. If Normalized is true, scale the distance down by the CharDistanceWeight to return the edit distance in terms of single-character edits. | |
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 |
LLVM_EXPLICIT | operator bool () const |
Returns whether this TypoCorrection has a non-empty DeclarationName. | |
void | makeKeyword () |
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. | |
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) |
Static Public Member Functions | |
static unsigned | NormalizeEditDistance (unsigned ED) |
Static Public Attributes | |
static const unsigned | InvalidDistance = ~0U |
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 26 of file TypoCorrection.h.
typedef SmallVectorImpl<NamedDecl *>::const_iterator clang::TypoCorrection::const_decl_iterator |
Definition at line 217 of file TypoCorrection.h.
typedef SmallVectorImpl<NamedDecl *>::iterator clang::TypoCorrection::decl_iterator |
Definition at line 212 of file TypoCorrection.h.
clang::TypoCorrection::TypoCorrection | ( | const DeclarationName & | Name, |
NamedDecl * | NameDecl, | ||
NestedNameSpecifier * | NNS = nullptr , |
||
unsigned | CharDistance = 0 , |
||
unsigned | QualifierDistance = 0 |
||
) | [inline] |
Definition at line 42 of file TypoCorrection.h.
clang::TypoCorrection::TypoCorrection | ( | NamedDecl * | Name, |
NestedNameSpecifier * | NNS = nullptr , |
||
unsigned | CharDistance = 0 |
||
) | [inline] |
Definition at line 53 of file TypoCorrection.h.
clang::TypoCorrection::TypoCorrection | ( | DeclarationName | Name, |
NestedNameSpecifier * | NNS = nullptr , |
||
unsigned | CharDistance = 0 |
||
) | [inline] |
Definition at line 62 of file TypoCorrection.h.
clang::TypoCorrection::TypoCorrection | ( | ) | [inline] |
Definition at line 68 of file TypoCorrection.h.
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 4384 of file SemaLookup.cpp.
References clang::NamedDecl::getDeclName(), clang::NamedDecl::getUnderlyingDecl(), and isKeyword().
Referenced by setCorrectionDecl().
decl_iterator clang::TypoCorrection::begin | ( | ) | [inline] |
Definition at line 213 of file TypoCorrection.h.
References isKeyword().
Referenced by checkCorrectionVisibility(), clang::Sema::DiagnoseEmptyLookup(), DiagnoseInvalidRedeclaration(), and clang::TypoCorrectionConsumer::getNextCorrection().
const_decl_iterator clang::TypoCorrection::begin | ( | ) | const [inline] |
Definition at line 218 of file TypoCorrection.h.
References isKeyword().
void clang::TypoCorrection::ClearCorrectionDecls | ( | ) | [inline] |
Clears the list of NamedDecls.
Definition at line 142 of file TypoCorrection.h.
decl_iterator clang::TypoCorrection::end | ( | ) | [inline] |
Definition at line 216 of file TypoCorrection.h.
Referenced by checkCorrectionVisibility(), clang::Sema::DiagnoseEmptyLookup(), and DiagnoseInvalidRedeclaration().
const_decl_iterator clang::TypoCorrection::end | ( | ) | const [inline] |
Definition at line 221 of file TypoCorrection.h.
std::string TypoCorrection::getAsString | ( | const LangOptions & | LO | ) | const |
Definition at line 4396 of file SemaLookup.cpp.
References clang::DeclarationName::getAsString(), and clang::NestedNameSpecifier::print().
Referenced by clang::TypoCorrectionConsumer::addCorrection(), clang::Sema::DiagnoseEmptyLookup(), clang::Sema::diagnoseTypo(), getQuoted(), and LookupMemberExprInRecord().
DeclarationName clang::TypoCorrection::getCorrection | ( | ) | const [inline] |
Gets the DeclarationName of the typo correction.
Definition at line 74 of file TypoCorrection.h.
Referenced by clang::Sema::CorrectTypo(), clang::Sema::DiagnoseEmptyLookup(), DiagnoseInvalidRedeclaration(), and LookupMemberExprInRecord().
IdentifierInfo* clang::TypoCorrection::getCorrectionAsIdentifierInfo | ( | ) | const [inline] |
Definition at line 75 of file TypoCorrection.h.
References clang::DeclarationName::getAsIdentifierInfo().
Referenced by clang::TypoCorrectionConsumer::addCorrection(), DiagnoseInvalidRedeclaration(), clang::Sema::getTypeName(), isKeyword(), and clang::CorrectionCandidateCallback::MatchesTypo().
NamedDecl* clang::TypoCorrection::getCorrectionDecl | ( | ) | const [inline] |
Gets the pointer to the declaration of the typo correction.
Definition at line 133 of file TypoCorrection.h.
Referenced by clang::TypoCorrectionConsumer::addCorrection(), clang::Sema::DiagnoseEmptyLookup(), DiagnoseInvalidRedeclaration(), clang::Sema::diagnoseTypo(), getCorrectionDeclAs(), and clang::FunctionCallFilterCCC::ValidateCandidate().
DeclClass* clang::TypoCorrection::getCorrectionDeclAs | ( | ) | const [inline] |
Definition at line 137 of file TypoCorrection.h.
References getCorrectionDecl().
Referenced by clang::Sema::ActOnStartClassImplementation(), clang::Sema::BuildMemInitializer(), clang::Sema::FindProtocolDeclaration(), and clang::DeclFilterCCC< C >::ValidateCandidate().
SourceRange clang::TypoCorrection::getCorrectionRange | ( | ) | const [inline] |
Definition at line 208 of file TypoCorrection.h.
Referenced by clang::Sema::ConvertArgumentsForCall(), and clang::Sema::diagnoseTypo().
NestedNameSpecifier* clang::TypoCorrection::getCorrectionSpecifier | ( | ) | const [inline] |
Gets the NestedNameSpecifier needed to use the typo correction.
Definition at line 80 of file TypoCorrection.h.
Referenced by clang::Sema::DiagnoseEmptyLookup(), clang::Sema::getTypeName(), and clang::CorrectionCandidateCallback::MatchesTypo().
unsigned clang::TypoCorrection::getEditDistance | ( | bool | Normalized = true | ) | const [inline] |
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 116 of file TypoCorrection.h.
References CallbackDistanceWeight, CharDistanceWeight, InvalidDistance, MaximumDistance, NormalizeEditDistance(), and QualifierDistanceWeight.
Referenced by clang::TypoCorrectionConsumer::addCorrection(), clang::Sema::CorrectTypo(), and isCandidateViable().
std::string clang::TypoCorrection::getQuoted | ( | const LangOptions & | LO | ) | const [inline] |
Definition at line 163 of file TypoCorrection.h.
References getAsString().
Referenced by clang::Sema::diagnoseTypo().
bool clang::TypoCorrection::isKeyword | ( | ) | const [inline] |
Definition at line 182 of file TypoCorrection.h.
Referenced by addCorrectionDecl(), begin(), clang::Sema::CorrectTypo(), clang::Sema::diagnoseTypo(), isKeyword(), LookupMemberExprInRecord(), clang::CorrectionCandidateCallback::ValidateCandidate(), and clang::FunctionCallFilterCCC::ValidateCandidate().
bool clang::TypoCorrection::isKeyword | ( | const char(&) | Str[StrLen] | ) | const [inline] |
Definition at line 189 of file TypoCorrection.h.
References getCorrectionAsIdentifierInfo(), isKeyword(), and clang::IdentifierInfo::isStr().
bool clang::TypoCorrection::isOverloaded | ( | ) | const [inline] |
Definition at line 196 of file TypoCorrection.h.
Referenced by clang::Sema::DiagnoseEmptyLookup().
bool clang::TypoCorrection::isResolved | ( | ) | const [inline] |
Definition at line 194 of file TypoCorrection.h.
Referenced by clang::TypoCorrectionConsumer::addCorrection(), clang::TypoCorrectionConsumer::getNextCorrection(), clang::CorrectionCandidateCallback::MatchesTypo(), and clang::CorrectionCandidateCallback::ValidateCandidate().
void clang::TypoCorrection::makeKeyword | ( | ) | [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 174 of file TypoCorrection.h.
static unsigned clang::TypoCorrection::NormalizeEditDistance | ( | unsigned | ED | ) | [inline, static] |
Definition at line 107 of file TypoCorrection.h.
References CharDistanceWeight, InvalidDistance, and MaximumDistance.
Referenced by clang::TypoCorrectionConsumer::getBestEditDistance(), and getEditDistance().
LLVM_EXPLICIT clang::TypoCorrection::operator bool | ( | ) | const [inline] |
Returns whether this TypoCorrection has a non-empty DeclarationName.
Definition at line 168 of file TypoCorrection.h.
References bool.
bool clang::TypoCorrection::requiresImport | ( | ) | const [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 225 of file TypoCorrection.h.
Referenced by clang::Sema::diagnoseTypo(), clang::TypoCorrectionConsumer::getNextCorrection(), and clang::CorrectionCandidateCallback::MatchesTypo().
void clang::TypoCorrection::setCallbackDistance | ( | unsigned | ED | ) | [inline] |
Definition at line 100 of file TypoCorrection.h.
Referenced by isCandidateViable().
void clang::TypoCorrection::setCorrectionDecl | ( | NamedDecl * | CDecl | ) | [inline] |
Clears the list of NamedDecls before adding the new one.
Definition at line 147 of file TypoCorrection.h.
References addCorrectionDecl().
Referenced by clang::Sema::DiagnoseEmptyLookup(), and DiagnoseInvalidRedeclaration().
void clang::TypoCorrection::setCorrectionDecls | ( | ArrayRef< NamedDecl * > | Decls | ) | [inline] |
Clears the list of NamedDecls and adds the given set.
Definition at line 153 of file TypoCorrection.h.
Referenced by checkCorrectionVisibility().
void clang::TypoCorrection::setCorrectionRange | ( | CXXScopeSpec * | SS, |
const DeclarationNameInfo & | TypoName | ||
) | [inline] |
Definition at line 200 of file TypoCorrection.h.
References clang::CXXScopeSpec::getBeginLoc(), clang::DeclarationNameInfo::getLoc(), clang::CXXScopeSpec::isEmpty(), clang::SourceRange::setBegin(), and clang::SourceRange::setEnd().
Referenced by clang::Sema::CorrectTypo().
void clang::TypoCorrection::setCorrectionSpecifier | ( | NestedNameSpecifier * | NNS | ) | [inline] |
Definition at line 83 of file TypoCorrection.h.
void clang::TypoCorrection::setQualifierDistance | ( | unsigned | ED | ) | [inline] |
Definition at line 96 of file TypoCorrection.h.
void clang::TypoCorrection::setRequiresImport | ( | bool | Req | ) | [inline] |
Definition at line 226 of file TypoCorrection.h.
Referenced by checkCorrectionVisibility().
void clang::TypoCorrection::WillReplaceSpecifier | ( | bool | ForceReplacement | ) | [inline] |
Definition at line 88 of file TypoCorrection.h.
Referenced by clang::Sema::DiagnoseEmptyLookup(), and LookupMemberExprInRecord().
bool clang::TypoCorrection::WillReplaceSpecifier | ( | ) | const [inline] |
Definition at line 92 of file TypoCorrection.h.
const unsigned clang::TypoCorrection::CallbackDistanceWeight = 150U [static] |
Definition at line 40 of file TypoCorrection.h.
Referenced by getEditDistance().
const unsigned clang::TypoCorrection::CharDistanceWeight = 100U [static] |
Definition at line 38 of file TypoCorrection.h.
Referenced by getEditDistance(), and NormalizeEditDistance().
const unsigned clang::TypoCorrection::InvalidDistance = ~0U [static] |
Definition at line 29 of file TypoCorrection.h.
Referenced by getEditDistance(), isCandidateViable(), and NormalizeEditDistance().
const unsigned clang::TypoCorrection::MaximumDistance = 10000U [static] |
Definition at line 32 of file TypoCorrection.h.
Referenced by getEditDistance(), and NormalizeEditDistance().
const unsigned clang::TypoCorrection::QualifierDistanceWeight = 110U [static] |
Definition at line 39 of file TypoCorrection.h.
Referenced by getEditDistance().