clang 20.0.0git
|
The class facilities generation and storage of conversion FixIts. More...
#include "clang/Sema/SemaFixItUtils.h"
Public Types | |
typedef bool(* | TypeComparisonFuncTy) (const CanQualType FromTy, const CanQualType ToTy, Sema &S, SourceLocation Loc, ExprValueKind FromVK) |
Public Member Functions | |
ConversionFixItGenerator (TypeComparisonFuncTy Foo) | |
ConversionFixItGenerator () | |
void | setConversionChecker (TypeComparisonFuncTy Foo) |
Resets the default conversion checker method. | |
bool | tryToFixConversion (const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S) |
If possible, generates and stores a fix for the given conversion. | |
void | clear () |
bool | isNull () |
Static Public Member Functions | |
static bool | compareTypesSimple (CanQualType From, CanQualType To, Sema &S, SourceLocation Loc, ExprValueKind FromVK) |
Performs a simple check to see if From type can be converted to To type. | |
Public Attributes | |
std::vector< FixItHint > | Hints |
The list of Hints generated so far. | |
unsigned | NumConversionsFixed |
The number of Conversions fixed. | |
OverloadFixItKind | Kind |
The type of fix applied. | |
TypeComparisonFuncTy | CompareTypes |
The type comparison function used to decide if expression FromExpr of type FromTy can be converted to ToTy. | |
The class facilities generation and storage of conversion FixIts.
Hints for new conversions are added using TryToFixConversion method. The default type conversion checker can be reset.
Definition at line 32 of file SemaFixItUtils.h.
typedef bool(* clang::ConversionFixItGenerator::TypeComparisonFuncTy) (const CanQualType FromTy, const CanQualType ToTy, Sema &S, SourceLocation Loc, ExprValueKind FromVK) |
Definition at line 51 of file SemaFixItUtils.h.
|
inline |
Definition at line 61 of file SemaFixItUtils.h.
|
inline |
Definition at line 65 of file SemaFixItUtils.h.
|
inline |
Definition at line 79 of file SemaFixItUtils.h.
References Hints, and NumConversionsFixed.
Referenced by clang::OverloadCandidate::TryToFixBadConversion().
|
static |
Performs a simple check to see if From type can be converted to To type.
Definition at line 22 of file SemaFixItUtils.cpp.
References clang::Sema::Context, clang::Sema::getASTContext(), clang::ASTContext::getCanonicalType(), clang::CanQual< T >::getNonReferenceType(), getPointeeType(), clang::CanQual< T >::getUnqualifiedType(), clang::CanQual< T >::isAtLeastAsQualifiedAs(), clang::Sema::IsDerivedFrom(), and Loc.
|
inline |
Definition at line 84 of file SemaFixItUtils.h.
References NumConversionsFixed.
Referenced by clang::Sema::DiagnoseAssignmentResult().
|
inline |
Resets the default conversion checker method.
Definition at line 70 of file SemaFixItUtils.h.
References CompareTypes.
Referenced by CompleteNonViableCandidate().
bool ConversionFixItGenerator::tryToFixConversion | ( | const Expr * | FromExpr, |
const QualType | FromQTy, | ||
const QualType | ToQTy, | ||
Sema & | S | ||
) |
If possible, generates and stores a fix for the given conversion.
Definition at line 50 of file SemaFixItUtils.cpp.
References Begin, CompareTypes, clang::Sema::Context, clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateRemoval(), clang::SourceRange::getBegin(), clang::ASTContext::getCanonicalType(), clang::SourceRange::getEnd(), clang::Sema::getLocForEndOfToken(), clang::Expr::getObjectKind(), clang::ASTContext::getPointerType(), clang::Stmt::getSourceRange(), clang::CharSourceRange::getTokenRange(), Hints, clang::Expr::IgnoreImpCasts(), clang::Expr::IgnoreParenCasts(), clang::Expr::isLValue(), Kind, clang::Expr::NPC_ValueDependentIsNotNull, NumConversionsFixed, clang::OFIK_Dereference, clang::OFIK_RemoveDereference, clang::OFIK_RemoveTakeAddress, clang::OFIK_TakeAddress, clang::OK_Ordinary, clang::VK_LValue, and clang::VK_PRValue.
Referenced by clang::Sema::DiagnoseAssignmentResult(), and clang::OverloadCandidate::TryToFixBadConversion().
TypeComparisonFuncTy clang::ConversionFixItGenerator::CompareTypes |
The type comparison function used to decide if expression FromExpr of type FromTy can be converted to ToTy.
For example, one could check if an implicit conversion exists. Returns true if comparison exists.
Definition at line 59 of file SemaFixItUtils.h.
Referenced by setConversionChecker(), and tryToFixConversion().
std::vector<FixItHint> clang::ConversionFixItGenerator::Hints |
The list of Hints generated so far.
Definition at line 41 of file SemaFixItUtils.h.
Referenced by clear(), clang::Sema::DiagnoseAssignmentResult(), DiagnoseBadConversion(), and tryToFixConversion().
OverloadFixItKind clang::ConversionFixItGenerator::Kind |
The type of fix applied.
If multiple conversions are fixed, corresponds to the kid of the very first conversion.
Definition at line 49 of file SemaFixItUtils.h.
Referenced by clang::Sema::DiagnoseAssignmentResult(), DiagnoseBadConversion(), and tryToFixConversion().
unsigned clang::ConversionFixItGenerator::NumConversionsFixed |
The number of Conversions fixed.
This can be different from the size of the Hints vector since we allow multiple FixIts per conversion.
Definition at line 45 of file SemaFixItUtils.h.
Referenced by clear(), isNull(), and tryToFixConversion().