Add a CastKind enum to CastExpr. Right now it's not used for much but it will be :)

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77650 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Anders Carlsson 2009-07-31 00:48:10 +00:00
Родитель 82ec2e9908
Коммит cdef2b75aa
13 изменённых файлов: 128 добавлений и 57 удалений

Просмотреть файл

@ -94,7 +94,7 @@
35D55B270D81D8C60092E734 /* BasicValueFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35D55B240D81D8C60092E734 /* BasicValueFactory.cpp */; };
35D55B280D81D8C60092E734 /* CFRefCount.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35D55B250D81D8C60092E734 /* CFRefCount.cpp */; };
35E194690ECB82FB00F21733 /* SemaCXXScopeSpec.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35E194670ECB82FB00F21733 /* SemaCXXScopeSpec.cpp */; };
35E1946A0ECB82FB00F21733 /* SemaNamedCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35E194680ECB82FB00F21733 /* SemaNamedCast.cpp */; };
35E1946A0ECB82FB00F21733 /* SemaCXXCast.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35E194680ECB82FB00F21733 /* SemaCXXCast.cpp */; };
35E1946D0ECB83C100F21733 /* PTHLexer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35E1946C0ECB83C100F21733 /* PTHLexer.cpp */; };
35EE48B10E0C4CCA00715C54 /* DeclCXX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35EE48AF0E0C4CCA00715C54 /* DeclCXX.cpp */; };
35EE48B20E0C4CCA00715C54 /* ParentMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 35EE48B00E0C4CCA00715C54 /* ParentMap.cpp */; };
@ -337,7 +337,7 @@
1A2A54AE0FD1DD1C00F4CE45 /* PrintPreprocessedOutput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PrintPreprocessedOutput.cpp; path = lib/Frontend/PrintPreprocessedOutput.cpp; sourceTree = "<group>"; };
1A2A54AF0FD1DD1C00F4CE45 /* RewriteBlocks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RewriteBlocks.cpp; path = lib/Frontend/RewriteBlocks.cpp; sourceTree = "<group>"; };
1A2A54B00FD1DD1C00F4CE45 /* RewriteMacros.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RewriteMacros.cpp; path = lib/Frontend/RewriteMacros.cpp; sourceTree = "<group>"; };
1A2A54B10FD1DD1C00F4CE45 /* RewriteObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RewriteObjC.cpp; path = lib/Frontend/RewriteObjC.cpp; sourceTree = "<group>"; };
1A2A54B10FD1DD1C00F4CE45 /* RewriteObjC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = RewriteObjC.cpp; path = lib/Frontend/RewriteObjC.cpp; sourceTree = "<group>"; tabWidth = 2; };
1A2A54B20FD1DD1C00F4CE45 /* RewriteTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RewriteTest.cpp; path = lib/Frontend/RewriteTest.cpp; sourceTree = "<group>"; };
1A2A54B30FD1DD1C00F4CE45 /* StmtXML.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StmtXML.cpp; path = lib/Frontend/StmtXML.cpp; sourceTree = "<group>"; };
1A2A54B40FD1DD1C00F4CE45 /* Warnings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Warnings.cpp; path = lib/Frontend/Warnings.cpp; sourceTree = "<group>"; };
@ -458,7 +458,7 @@
35D55B250D81D8C60092E734 /* CFRefCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CFRefCount.cpp; path = lib/Analysis/CFRefCount.cpp; sourceTree = "<group>"; };
35D55B290D81D8E50092E734 /* BasicValueFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BasicValueFactory.h; path = clang/Analysis/PathSensitive/BasicValueFactory.h; sourceTree = "<group>"; };
35E194670ECB82FB00F21733 /* SemaCXXScopeSpec.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = SemaCXXScopeSpec.cpp; path = lib/Sema/SemaCXXScopeSpec.cpp; sourceTree = "<group>"; tabWidth = 2; };
35E194680ECB82FB00F21733 /* SemaNamedCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = SemaNamedCast.cpp; path = lib/Sema/SemaNamedCast.cpp; sourceTree = "<group>"; tabWidth = 2; };
35E194680ECB82FB00F21733 /* SemaCXXCast.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = SemaCXXCast.cpp; path = lib/Sema/SemaCXXCast.cpp; sourceTree = "<group>"; tabWidth = 2; };
35E1946C0ECB83C100F21733 /* PTHLexer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PTHLexer.cpp; sourceTree = "<group>"; };
35EE48AD0E0C4CB200715C54 /* DeclCXX.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = DeclCXX.h; path = clang/AST/DeclCXX.h; sourceTree = "<group>"; tabWidth = 2; };
35EE48AE0E0C4CB200715C54 /* ParentMap.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = ParentMap.h; path = clang/AST/ParentMap.h; sourceTree = "<group>"; tabWidth = 2; };
@ -1062,7 +1062,7 @@
DE67E70E0C020ECF00F66BC5 /* SemaExprCXX.cpp */,
3599299A0DE2425300A8A33E /* SemaInit.cpp */,
357EA27C0F2526F300439B60 /* SemaLookup.cpp */,
35E194680ECB82FB00F21733 /* SemaNamedCast.cpp */,
35E194680ECB82FB00F21733 /* SemaCXXCast.cpp */,
35585DBE0EAFBC4500D0A97A /* SemaOverload.cpp */,
35585DBF0EAFBC4500D0A97A /* SemaOverload.h */,
DE67E70C0C020ECA00F66BC5 /* SemaStmt.cpp */,
@ -1625,7 +1625,7 @@
3557D1A90EB136B100C59739 /* InheritViz.cpp in Sources */,
3557D1F00EB13BB700C59739 /* SemaInherit.cpp in Sources */,
35E194690ECB82FB00F21733 /* SemaCXXScopeSpec.cpp in Sources */,
35E1946A0ECB82FB00F21733 /* SemaNamedCast.cpp in Sources */,
35E1946A0ECB82FB00F21733 /* SemaCXXCast.cpp in Sources */,
35E1946D0ECB83C100F21733 /* PTHLexer.cpp in Sources */,
3537AA0E0ECD08A4008F7CDC /* PreprocessorLexer.cpp in Sources */,
DE8823CB0ED0046600CBC30A /* APValue.cpp in Sources */,

Просмотреть файл

@ -1154,9 +1154,27 @@ public:
/// representation in the source code (ExplicitCastExpr's derived
/// classes).
class CastExpr : public Expr {
public:
/// CastKind - the kind of cast this represents.
enum CastKind {
/// CK_Unknown - Unknown cast kind.
/// FIXME: The goal is to get rid of this and make all casts have a
/// kind so that the AST client doesn't have to try to figure out what's
/// going on.
CK_Unknown,
/// CK_BitCast - Used for reinterpret_cast.
CK_BitCast,
/// CK_NoOp - Used for const_cast.
CK_NoOp
};
private:
CastKind Kind;
Stmt *Op;
protected:
CastExpr(StmtClass SC, QualType ty, Expr *op) :
CastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op) :
Expr(SC, ty,
// Cast expressions are type-dependent if the type is
// dependent (C++ [temp.dep.expr]p3).
@ -1164,13 +1182,16 @@ protected:
// Cast expressions are value-dependent if the type is
// dependent or if the subexpression is value-dependent.
ty->isDependentType() || (op && op->isValueDependent())),
Op(op) {}
Kind(kind), Op(op) {}
/// \brief Construct an empty cast.
CastExpr(StmtClass SC, EmptyShell Empty)
: Expr(SC, Empty) { }
public:
CastKind getCastKind() const { return Kind; }
void setCastKind(CastKind K) { Kind = K; }
Expr *getSubExpr() { return cast<Expr>(Op); }
const Expr *getSubExpr() const { return cast<Expr>(Op); }
void setSubExpr(Expr *E) { Op = E; }
@ -1213,8 +1234,8 @@ class ImplicitCastExpr : public CastExpr {
bool LvalueCast;
public:
ImplicitCastExpr(QualType ty, Expr *op, bool Lvalue) :
CastExpr(ImplicitCastExprClass, ty, op), LvalueCast(Lvalue) { }
ImplicitCastExpr(QualType ty, CastKind kind, Expr *op, bool Lvalue) :
CastExpr(ImplicitCastExprClass, ty, kind, op), LvalueCast(Lvalue) { }
/// \brief Construct an empty implicit cast.
explicit ImplicitCastExpr(EmptyShell Shell)
@ -1259,8 +1280,9 @@ class ExplicitCastExpr : public CastExpr {
QualType TypeAsWritten;
protected:
ExplicitCastExpr(StmtClass SC, QualType exprTy, Expr *op, QualType writtenTy)
: CastExpr(SC, exprTy, op), TypeAsWritten(writtenTy) {}
ExplicitCastExpr(StmtClass SC, QualType exprTy, CastKind kind, Expr *op,
QualType writtenTy)
: CastExpr(SC, exprTy, kind, op), TypeAsWritten(writtenTy) {}
/// \brief Construct an empty explicit cast.
ExplicitCastExpr(StmtClass SC, EmptyShell Shell)
@ -1291,9 +1313,9 @@ class CStyleCastExpr : public ExplicitCastExpr {
SourceLocation LPLoc; // the location of the left paren
SourceLocation RPLoc; // the location of the right paren
public:
CStyleCastExpr(QualType exprTy, Expr *op, QualType writtenTy,
CStyleCastExpr(QualType exprTy, CastKind kind, Expr *op, QualType writtenTy,
SourceLocation l, SourceLocation r) :
ExplicitCastExpr(CStyleCastExprClass, exprTy, op, writtenTy),
ExplicitCastExpr(CStyleCastExprClass, exprTy, kind, op, writtenTy),
LPLoc(l), RPLoc(r) {}
/// \brief Construct an empty C-style explicit cast.

Просмотреть файл

@ -112,9 +112,9 @@ private:
SourceLocation Loc; // the location of the casting op
protected:
CXXNamedCastExpr(StmtClass SC, QualType ty, Expr *op, QualType writtenTy,
SourceLocation l)
: ExplicitCastExpr(SC, ty, op, writtenTy), Loc(l) {}
CXXNamedCastExpr(StmtClass SC, QualType ty, CastKind kind, Expr *op,
QualType writtenTy, SourceLocation l)
: ExplicitCastExpr(SC, ty, kind, op, writtenTy), Loc(l) {}
public:
const char *getCastName() const;
@ -148,8 +148,9 @@ public:
/// @c static_cast<int>(1.0).
class CXXStaticCastExpr : public CXXNamedCastExpr {
public:
CXXStaticCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l)
: CXXNamedCastExpr(CXXStaticCastExprClass, ty, op, writtenTy, l) {}
CXXStaticCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy,
SourceLocation l)
: CXXNamedCastExpr(CXXStaticCastExprClass, ty, kind, op, writtenTy, l) {}
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXStaticCastExprClass;
@ -165,8 +166,9 @@ public:
/// @c dynamic_cast<Derived*>(BasePtr).
class CXXDynamicCastExpr : public CXXNamedCastExpr {
public:
CXXDynamicCastExpr(QualType ty, Expr *op, QualType writtenTy, SourceLocation l)
: CXXNamedCastExpr(CXXDynamicCastExprClass, ty, op, writtenTy, l) {}
CXXDynamicCastExpr(QualType ty, CastKind kind, Expr *op, QualType writtenTy,
SourceLocation l)
: CXXNamedCastExpr(CXXDynamicCastExprClass, ty, kind, op, writtenTy, l) {}
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDynamicCastExprClass;
@ -184,7 +186,8 @@ class CXXReinterpretCastExpr : public CXXNamedCastExpr {
public:
CXXReinterpretCastExpr(QualType ty, Expr *op, QualType writtenTy,
SourceLocation l)
: CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, op, writtenTy, l) {}
: CXXNamedCastExpr(CXXReinterpretCastExprClass, ty, CK_BitCast, op,
writtenTy, l) {}
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXReinterpretCastExprClass;
@ -201,7 +204,7 @@ class CXXConstCastExpr : public CXXNamedCastExpr {
public:
CXXConstCastExpr(QualType ty, Expr *op, QualType writtenTy,
SourceLocation l)
: CXXNamedCastExpr(CXXConstCastExprClass, ty, op, writtenTy, l) {}
: CXXNamedCastExpr(CXXConstCastExprClass, ty, CK_NoOp, op, writtenTy, l) {}
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXConstCastExprClass;
@ -529,9 +532,9 @@ class CXXFunctionalCastExpr : public ExplicitCastExpr {
SourceLocation RParenLoc;
public:
CXXFunctionalCastExpr(QualType ty, QualType writtenTy,
SourceLocation tyBeginLoc, Expr *castExpr,
SourceLocation rParenLoc) :
ExplicitCastExpr(CXXFunctionalCastExprClass, ty, castExpr, writtenTy),
SourceLocation tyBeginLoc, CastKind kind,
Expr *castExpr, SourceLocation rParenLoc) :
ExplicitCastExpr(CXXFunctionalCastExprClass, ty, kind, castExpr, writtenTy),
TyBeginLoc(tyBeginLoc), RParenLoc(rParenLoc) {}
SourceLocation getTypeBeginLoc() const { return TyBeginLoc; }

Просмотреть файл

@ -460,6 +460,8 @@ unsigned PCHStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
unsigned PCHStmtReader::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
E->setSubExpr(cast<Expr>(StmtStack.back()));
E->setCastKind((CastExpr::CastKind)Record[Idx++]);
return 1;
}

Просмотреть файл

@ -428,6 +428,7 @@ void PCHStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
void PCHStmtWriter::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
Writer.WriteSubStmt(E->getSubExpr());
Record.push_back(E->getCastKind()); // FIXME: stable encoding
}
void PCHStmtWriter::VisitBinaryOperator(BinaryOperator *E) {

Просмотреть файл

@ -1155,9 +1155,11 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
CastExpr *castExpr = new (Context) CStyleCastExpr(castT, IV->getBase(),
castT,SourceLocation(),
SourceLocation());
CastExpr *castExpr = new (Context) CStyleCastExpr(castT,
CastExpr::CK_Unknown,
IV->getBase(),
castT,SourceLocation(),
SourceLocation());
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(IV->getBase()->getLocStart(),
IV->getBase()->getLocEnd(),
@ -1200,7 +1202,9 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
CastExpr *castExpr = new (Context) CStyleCastExpr(castT, IV->getBase(),
CastExpr *castExpr = new (Context) CStyleCastExpr(castT,
CastExpr::CK_Unknown,
IV->getBase(),
castT, SourceLocation(),
SourceLocation());
// Don't forget the parens to enforce the proper binding.
@ -1500,6 +1504,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
buf += " if (!_rethrow) objc_exception_try_exit(&_stack);\n";
buf += " objc_sync_exit(";
Expr *syncExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
S->getSynchExpr(),
Context->getObjCIdType(),
SourceLocation(),
@ -1781,7 +1786,9 @@ CallExpr *RewriteObjC::SynthesizeCallToFunctionDecl(
// Now, we cast the reference to a pointer to the objc_msgSend type.
QualType pToFunc = Context->getPointerType(msgSendType);
ImplicitCastExpr *ICE = new (Context) ImplicitCastExpr(pToFunc, DRE,
ImplicitCastExpr *ICE = new (Context) ImplicitCastExpr(pToFunc,
CastExpr::CK_Unknown,
DRE,
/*isLvalue=*/false);
const FunctionType *FT = msgSendType->getAsFunctionType();
@ -2142,8 +2149,11 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
Context->getPointerType(DRE->getType()),
SourceLocation());
// cast to NSConstantString *
CastExpr *cast = new (Context) CStyleCastExpr(Exp->getType(), Unop,
Exp->getType(), SourceLocation(), SourceLocation());
CastExpr *cast = new (Context) CStyleCastExpr(Exp->getType(),
CastExpr::CK_Unknown,
Unop, Exp->getType(),
SourceLocation(),
SourceLocation());
ReplaceStmt(Exp, cast);
// delete Exp; leak for now, see RewritePropertySetter() usage for more info.
return cast;
@ -2272,6 +2282,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// set the receiver to self, the first argument to all methods.
InitExprs.push_back(
new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
Context->getObjCIdType(),
SourceLocation()),
@ -2290,6 +2301,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// To turn off a warning, type-cast to 'id'
InitExprs.push_back( // set 'super class', using objc_getClass().
new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
Cls, Context->getObjCIdType(),
SourceLocation(), SourceLocation()));
// struct objc_super
@ -2314,7 +2326,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
Context->getPointerType(SuperRep->getType()),
SourceLocation());
SuperRep = new (Context) CStyleCastExpr(Context->getPointerType(superType),
SuperRep, Context->getPointerType(superType),
CastExpr::CK_Unknown, SuperRep,
Context->getPointerType(superType),
SourceLocation(), SourceLocation());
} else {
// (struct objc_super) { <exprs from above> }
@ -2355,6 +2368,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
InitExprs.push_back(
new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
new (Context) DeclRefExpr(CurMethodDef->getSelfDecl(),
Context->getObjCIdType(),
SourceLocation()),
@ -2374,6 +2388,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
InitExprs.push_back(
// set 'super class', using objc_getClass().
new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
Cls, Context->getObjCIdType(), SourceLocation(), SourceLocation()));
// struct objc_super
QualType superType = getSuperStructType();
@ -2397,6 +2412,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
Context->getPointerType(SuperRep->getType()),
SourceLocation());
SuperRep = new (Context) CStyleCastExpr(Context->getPointerType(superType),
CastExpr::CK_Unknown,
SuperRep, Context->getPointerType(superType),
SourceLocation(), SourceLocation());
} else {
@ -2412,7 +2428,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// Foo<Proto> *.
while (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(recExpr))
recExpr = CE->getSubExpr();
recExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(), recExpr,
recExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown, recExpr,
Context->getObjCIdType(),
SourceLocation(), SourceLocation());
MsgExprs.push_back(recExpr);
@ -2438,7 +2455,9 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
QualType type = ICE->getType()->isObjCQualifiedIdType()
? Context->getObjCIdType()
: ICE->getType();
userExpr = new (Context) CStyleCastExpr(type, userExpr, type, SourceLocation(), SourceLocation());
userExpr = new (Context) CStyleCastExpr(type, CastExpr::CK_Unknown,
userExpr, type, SourceLocation(),
SourceLocation());
}
// Make id<P...> cast into an 'id' cast.
else if (CStyleCastExpr *CE = dyn_cast<CStyleCastExpr>(userExpr)) {
@ -2446,6 +2465,7 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
while ((CE = dyn_cast<CStyleCastExpr>(userExpr)))
userExpr = CE->getSubExpr();
userExpr = new (Context) CStyleCastExpr(Context->getObjCIdType(),
CastExpr::CK_Unknown,
userExpr, Context->getObjCIdType(),
SourceLocation(), SourceLocation());
}
@ -2497,7 +2517,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// If we don't do this cast, we get the following bizarre warning/note:
// xx.m:13: warning: function called through a non-compatible type
// xx.m:13: note: if this code is reached, the program will abort
cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy), DRE,
cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy),
CastExpr::CK_Unknown, DRE,
Context->getPointerType(Context->VoidTy),
SourceLocation(), SourceLocation());
@ -2507,7 +2528,9 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
// If we don't have a method decl, force a variadic cast.
Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : true, 0);
castType = Context->getPointerType(castType);
cast = new (Context) CStyleCastExpr(castType, cast, castType, SourceLocation(), SourceLocation());
cast = new (Context) CStyleCastExpr(castType, CastExpr::CK_Unknown, cast,
castType, SourceLocation(),
SourceLocation());
// Don't forget the parens to enforce the proper binding.
ParenExpr *PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
@ -2527,7 +2550,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
DeclRefExpr *STDRE = new (Context) DeclRefExpr(MsgSendStretFlavor, msgSendType,
SourceLocation());
// Need to cast objc_msgSend_stret to "void *" (see above comment).
cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy), STDRE,
cast = new (Context) CStyleCastExpr(Context->getPointerType(Context->VoidTy),
CastExpr::CK_Unknown, STDRE,
Context->getPointerType(Context->VoidTy),
SourceLocation(), SourceLocation());
// Now do the "normal" pointer to function cast.
@ -2535,7 +2559,8 @@ Stmt *RewriteObjC::SynthMessageExpr(ObjCMessageExpr *Exp) {
&ArgTypes[0], ArgTypes.size(),
Exp->getMethodDecl() ? Exp->getMethodDecl()->isVariadic() : false, 0);
castType = Context->getPointerType(castType);
cast = new (Context) CStyleCastExpr(castType, cast, castType, SourceLocation(), SourceLocation());
cast = new (Context) CStyleCastExpr(castType, CastExpr::CK_Unknown,
cast, castType, SourceLocation(), SourceLocation());
// Don't forget the parens to enforce the proper binding.
PE = new (Context) ParenExpr(SourceLocation(), SourceLocation(), cast);
@ -2606,8 +2631,9 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
Expr *DerefExpr = new (Context) UnaryOperator(DRE, UnaryOperator::AddrOf,
Context->getPointerType(DRE->getType()),
SourceLocation());
CastExpr *castExpr = new (Context) CStyleCastExpr(DerefExpr->getType(), DerefExpr,
DerefExpr->getType(),
CastExpr *castExpr = new (Context) CStyleCastExpr(DerefExpr->getType(),
CastExpr::CK_Unknown,
DerefExpr, DerefExpr->getType(),
SourceLocation(), SourceLocation());
ReplaceStmt(Exp, castExpr);
ProtocolExprDecls.insert(Exp->getProtocol());
@ -3925,7 +3951,9 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
PtrToFuncCastType = Context->getPointerType(PtrToFuncCastType);
CastExpr *BlkCast = new (Context) CStyleCastExpr(PtrBlock, Exp->getCallee(),
CastExpr *BlkCast = new (Context) CStyleCastExpr(PtrBlock,
CastExpr::CK_Unknown,
Exp->getCallee(),
PtrBlock, SourceLocation(),
SourceLocation());
// Don't forget the parens to enforce the proper binding.
@ -3939,7 +3967,8 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
MemberExpr *ME = new (Context) MemberExpr(PE, true, FD, SourceLocation(),
FD->getType());
CastExpr *FunkCast = new (Context) CStyleCastExpr(PtrToFuncCastType, ME,
CastExpr *FunkCast = new (Context) CStyleCastExpr(PtrToFuncCastType,
CastExpr::CK_Unknown, ME,
PtrToFuncCastType,
SourceLocation(),
SourceLocation());
@ -4207,7 +4236,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
FD = SynthBlockInitFunctionDecl(Func.c_str());
DeclRefExpr *Arg = new (Context) DeclRefExpr(FD, FD->getType(),
SourceLocation());
CastExpr *castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy, Arg,
CastExpr *castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
CastExpr::CK_Unknown, Arg,
Context->VoidPtrTy, SourceLocation(),
SourceLocation());
InitExprs.push_back(castExpr);
@ -4216,7 +4246,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
std::string Buf = "__" + FuncName + "_block_copy_" + BlockNumber;
FD = SynthBlockInitFunctionDecl(Buf.c_str());
Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy, Arg,
castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
CastExpr::CK_Unknown, Arg,
Context->VoidPtrTy, SourceLocation(),
SourceLocation());
InitExprs.push_back(castExpr);
@ -4224,7 +4255,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
Buf = "__" + FuncName + "_block_dispose_" + BlockNumber;
FD = SynthBlockInitFunctionDecl(Buf.c_str());
Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy, Arg,
castExpr = new (Context) CStyleCastExpr(Context->VoidPtrTy,
CastExpr::CK_Unknown, Arg,
Context->VoidPtrTy, SourceLocation(),
SourceLocation());
InitExprs.push_back(castExpr);
@ -4242,8 +4274,10 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
} else if (isTopLevelBlockPointerType((*I)->getType())) {
FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
Arg = new (Context) DeclRefExpr(FD, FD->getType(), SourceLocation());
Exp = new (Context) CStyleCastExpr(Context->VoidPtrTy, Arg,
Context->VoidPtrTy, SourceLocation(),
Exp = new (Context) CStyleCastExpr(Context->VoidPtrTy,
CastExpr::CK_Unknown, Arg,
Context->VoidPtrTy,
SourceLocation(),
SourceLocation());
} else {
FD = SynthBlockInitFunctionDecl((*I)->getNameAsCString());
@ -4267,7 +4301,8 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
NewRep = new (Context) UnaryOperator(NewRep, UnaryOperator::AddrOf,
Context->getPointerType(NewRep->getType()),
SourceLocation());
NewRep = new (Context) CStyleCastExpr(FType, NewRep, FType, SourceLocation(),
NewRep = new (Context) CStyleCastExpr(FType, CastExpr::CK_Unknown, NewRep,
FType, SourceLocation(),
SourceLocation());
BlockDeclRefs.clear();
BlockByRefDecls.clear();

Просмотреть файл

@ -217,7 +217,8 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, bool isLvalue) {
ImpCast->setType(Ty);
ImpCast->setLvalueCast(isLvalue);
} else
Expr = new (Context) ImplicitCastExpr(Ty, Expr, isLvalue);
Expr = new (Context) ImplicitCastExpr(Ty, CastExpr::CK_Unknown, Expr,
isLvalue);
}
void Sema::DeleteExpr(ExprTy *E) {

Просмотреть файл

@ -123,7 +123,8 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
if (!TypeDependent)
CheckDynamicCast(*this, Ex, DestType, OpRange, DestRange);
return Owned(new (Context)CXXDynamicCastExpr(DestType.getNonReferenceType(),
Ex, DestType, OpLoc));
CastExpr::CK_Unknown, Ex,
DestType, OpLoc));
case tok::kw_reinterpret_cast:
if (!TypeDependent)
@ -136,7 +137,8 @@ Sema::ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind,
if (!TypeDependent)
CheckStaticCast(*this, Ex, DestType, OpRange);
return Owned(new (Context) CXXStaticCastExpr(DestType.getNonReferenceType(),
Ex, DestType, OpLoc));
CastExpr::CK_Unknown, Ex,
DestType, OpLoc));
}
return ExprError();

Просмотреть файл

@ -5169,7 +5169,9 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
// Adjust the Expr initializer and type.
if (ECD->getInitExpr())
ECD->setInitExpr(new (Context) ImplicitCastExpr(NewTy, ECD->getInitExpr(),
ECD->setInitExpr(new (Context) ImplicitCastExpr(NewTy,
CastExpr::CK_Unknown,
ECD->getInitExpr(),
/*isLvalue=*/false));
if (getLangOptions().CPlusPlus)
// C++ [dcl.enum]p4: Following the closing brace of an

Просмотреть файл

@ -3075,8 +3075,8 @@ Sema::ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty,
if (CheckCastTypes(SourceRange(LParenLoc, RParenLoc), castType, castExpr))
return ExprError();
return Owned(new (Context) CStyleCastExpr(castType.getNonReferenceType(),
castExpr, castType,
LParenLoc, RParenLoc));
CastExpr::CK_Unknown, castExpr,
castType, LParenLoc, RParenLoc));
}
/// Note that lhs is not null here, even if this is the gnu "x ?: y" extension.

Просмотреть файл

@ -207,8 +207,9 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep,
return ExprError();
exprs.release();
return Owned(new (Context) CXXFunctionalCastExpr(Ty.getNonReferenceType(),
Ty, TyBeginLoc, Exprs[0],
RParenLoc));
Ty, TyBeginLoc,
CastExpr::CK_Unknown,
Exprs[0], RParenLoc));
}
if (const RecordType *RT = Ty->getAs<RecordType>()) {

Просмотреть файл

@ -2335,6 +2335,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion,
DeclRefExpr ConversionRef(Conversion, Conversion->getType(),
SourceLocation());
ImplicitCastExpr ConversionFn(Context.getPointerType(Conversion->getType()),
CastExpr::CK_Unknown,
&ConversionRef, false);
// Note that it is safe to allocate CallExpr on the stack here because

Просмотреть файл

@ -856,6 +856,7 @@ Sema::OwningExprResult TemplateExprInstantiator::VisitImplicitCastExpr(
ImplicitCastExpr *ICE =
new (SemaRef.Context) ImplicitCastExpr(E->getType(),
E->getCastKind(),
(Expr *)SubExpr.release(),
E->isLvalueCast());
return SemaRef.Owned(ICE);