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(Loc, FromUnq, ToUnq)) ) &&
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)) {
107 if (UO->getOpcode() == UO_AddrOf) {
112 }
else if (NeedParen) {
128 if (isa<PointerType>(ToQTy)) {
129 bool CanConvert =
false;
140 if (
const UnaryOperator *UO = dyn_cast<UnaryOperator>(Expr)) {
141 if (UO->getOpcode() == UO_Deref) {
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.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool isBlockPointerType() const
bool isMemberPointerType() const
bool isRealFloatingType() const
Floating point categories.
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)
The base class of the type hierarchy.
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
bool isEnumeralType() const
bool isChar32Type() const
bool hasDefinition() 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
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
bool isWideCharType() const
FullExpr - Represents a "full-expression" node.
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
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
IgnoreParenCasts - Ignore parentheses and casts.
bool isScalarType() const
An ordinary object is located at an address in memory.
const LangOptions & LangOpts
std::string getFixItZeroLiteralForType(QualType T, SourceLocation Loc) const
bool hasUserProvidedDefaultConstructor() const
Whether this class has a user-provided default constructor per C++11.
Sema - This implements semantic analysis and AST building for C.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
This represents one expression.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isChar16Type() const
Defines the clang::Preprocessor interface.
bool isAtLeastAsQualifiedAs(CanQual< T > Other) const
Determines whether this canonical type is at least as qualified as the Other canonical type...
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
TypeComparisonFuncTy CompareTypes
The type comparison function used to decide if expression FromExpr of type FromTy can be converted to...
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
ASTContext & getASTContext() const
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
bool isObjCObjectPointerType() const
MacroDefinition getMacroDefinitionAtLoc(const IdentifierInfo *II, SourceLocation Loc)
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
std::string getFixItZeroInitializerForType(QualType T, SourceLocation Loc) const
Get a string to suggest for zero-initialization of a type.
Dataflow Directional Tag Classes.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
bool isBooleanType() const
CanQual< Type > getNonReferenceType() const
If the canonical type is a reference type, returns the type that it refers to; otherwise, returns the type itself.
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.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Represents a C++ struct/union/class.
static bool isMacroDefined(const Sema &S, SourceLocation Loc, StringRef Name)
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool isPointerType() const
An l-value expression is a reference to an object with independent storage.
bool isAggregate() const
Determine whether this class is an aggregate (C++ [dcl.init.aggr]), which is a class with no user-dec...
SourceLocation getBegin() const
unsigned NumConversionsFixed
The number of Conversions fixed.