21 using namespace clang;
35 if (isa<PointerType>(From) && isa<PointerType>(To)) {
37 (cast<PointerType>(From))->getPointeeType());
39 (cast<PointerType>(To))->getPointeeType());
45 if ((FromUnq == ToUnq || (S.
IsDerivedFrom(FromUnq, ToUnq)) ) &&
60 const SourceLocation Begin = FullExpr->getSourceRange().getBegin();
68 bool NeedParen =
true;
69 if (isa<ArraySubscriptExpr>(Expr) ||
70 isa<CallExpr>(Expr) ||
71 isa<DeclRefExpr>(Expr) ||
72 isa<CastExpr>(Expr) ||
73 isa<CXXNewExpr>(Expr) ||
74 isa<CXXConstructExpr>(Expr) ||
75 isa<CXXDeleteExpr>(Expr) ||
76 isa<CXXNoexceptExpr>(Expr) ||
77 isa<CXXPseudoDestructorExpr>(Expr) ||
78 isa<CXXScalarValueInitExpr>(Expr) ||
79 isa<CXXThisExpr>(Expr) ||
80 isa<CXXTypeidExpr>(Expr) ||
81 isa<CXXUnresolvedConstructExpr>(Expr) ||
82 isa<ObjCMessageExpr>(Expr) ||
83 isa<ObjCPropertyRefExpr>(Expr) ||
84 isa<ObjCProtocolExpr>(Expr) ||
85 isa<MemberExpr>(Expr) ||
86 isa<ParenExpr>(FullExpr) ||
87 isa<ParenListExpr>(Expr) ||
88 isa<SizeOfPackExpr>(Expr) ||
89 isa<UnaryOperator>(Expr))
94 if (
const PointerType *FromPtrTy = dyn_cast<PointerType>(FromQTy)) {
106 if (
const UnaryOperator *UO = dyn_cast<UnaryOperator>(Expr)) {
112 }
else if (NeedParen) {
128 if (isa<PointerType>(ToQTy)) {
129 bool CanConvert =
false;
140 if (
const UnaryOperator *UO = dyn_cast<UnaryOperator>(Expr)) {
146 }
else if (NeedParen) {
174 return std::string();
211 return std::string();
216 return std::string();
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.
Defines the clang::ASTContext interface.
ExprObjectKind getObjectKind() const
bool isMemberPointerType() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
static CharSourceRange getTokenRange(SourceRange R)
bool isChar16Type() const
bool isEnumeralType() const
bool hasDefinition() const
bool isBooleanType() const
bool isBlockPointerType() const
std::vector< FixItHint > Hints
The list of Hints generated so far.
Defines the clang::Expr interface and subclasses for C++ expressions.
Expr * IgnoreImpCasts() LLVM_READONLY
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool isScalarType() const
bool isChar32Type() const
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static std::string getScalarZeroExpressionForType(const Type &T, SourceLocation Loc, const Sema &S)
Expr * IgnoreParenCasts() LLVM_READONLY
An ordinary object is located at an address in memory.
const LangOptions & LangOpts
Sema - This implements semantic analysis and AST building for C.
std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const
bool isRealFloatingType() const
Floating point categories.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Defines the clang::Preprocessor interface.
bool IsDerivedFrom(QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type...
TypeComparisonFuncTy CompareTypes
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ASTContext & getASTContext() const
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
MacroDefinition getMacroDefinitionAtLoc(const IdentifierInfo *II, SourceLocation Loc)
CanQual< Type > getNonReferenceType() const
If the canonical type is a reference type, returns the type that it refers to; otherwise, returns the type itself.
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isWideCharType() const
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
Represents a C++ struct/union/class.
bool isObjCObjectPointerType() const
static bool isMacroDefined(const Sema &S, SourceLocation Loc, StringRef Name)
An l-value expression is a reference to an object with independent storage.
bool isPointerType() const
unsigned NumConversionsFixed