forked from OSchip/llvm-project
parent
13a5ecc6ff
commit
9826733963
|
@ -387,6 +387,11 @@ public:
|
|||
Type->isDependentType(), Type->isDependentType()),
|
||||
Loc(L), Implicit(isImplicit) { }
|
||||
|
||||
CXXThisExpr(EmptyShell Empty) : Expr(CXXThisExprClass, Empty) {}
|
||||
|
||||
SourceLocation getLocation() const { return Loc; }
|
||||
void setLocation(SourceLocation L) { Loc = L; }
|
||||
|
||||
virtual SourceRange getSourceRange() const { return SourceRange(Loc); }
|
||||
|
||||
bool isImplicit() const { return Implicit; }
|
||||
|
@ -415,6 +420,8 @@ public:
|
|||
// can by null, if the optional expression to throw isn't present.
|
||||
CXXThrowExpr(Expr *expr, QualType Ty, SourceLocation l) :
|
||||
Expr(CXXThrowExprClass, Ty, false, false), Op(expr), ThrowLoc(l) {}
|
||||
CXXThrowExpr(EmptyShell Empty) : Expr(CXXThrowExprClass, Empty) {}
|
||||
|
||||
const Expr *getSubExpr() const { return cast_or_null<Expr>(Op); }
|
||||
Expr *getSubExpr() { return cast_or_null<Expr>(Op); }
|
||||
void setSubExpr(Expr *E) { Op = E; }
|
||||
|
|
|
@ -748,7 +748,9 @@ namespace clang {
|
|||
EXPR_CXX_BOOL_LITERAL,
|
||||
EXPR_CXX_NULL_PTR_LITERAL, // CXXNullPtrLiteralExpr
|
||||
EXPR_CXX_TYPEID_EXPR, // CXXTypeidExpr (of expr).
|
||||
EXPR_CXX_TYPEID_TYPE // CXXTypeidExpr (of type).
|
||||
EXPR_CXX_TYPEID_TYPE, // CXXTypeidExpr (of type).
|
||||
EXPR_CXX_THIS, // CXXThisExpr
|
||||
EXPR_CXX_THROW // CXXThrowExpr
|
||||
};
|
||||
|
||||
/// \brief The kinds of designators that can occur in a
|
||||
|
|
|
@ -127,6 +127,8 @@ namespace {
|
|||
unsigned VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
|
||||
unsigned VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
|
||||
unsigned VisitCXXTypeidExpr(CXXTypeidExpr *E);
|
||||
unsigned VisitCXXThisExpr(CXXThisExpr *E);
|
||||
unsigned VisitCXXThrowExpr(CXXThrowExpr *E);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1005,6 +1007,18 @@ unsigned PCHStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
unsigned PCHStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
|
||||
VisitExpr(E);
|
||||
E->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||
E->setImplicit(Record[Idx++]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned PCHStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
|
||||
VisitExpr(E);
|
||||
E->setThrowLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Within the bitstream, expressions are stored in Reverse Polish
|
||||
// Notation, with each of the subexpressions preceding the
|
||||
|
@ -1361,6 +1375,12 @@ Stmt *PCHReader::ReadStmt(llvm::BitstreamCursor &Cursor) {
|
|||
case pch::EXPR_CXX_TYPEID_TYPE:
|
||||
S = new (Context) CXXTypeidExpr(Empty, false);
|
||||
break;
|
||||
case pch::EXPR_CXX_THIS:
|
||||
S = new (Context) CXXThisExpr(Empty);
|
||||
break;
|
||||
case pch::EXPR_CXX_THROW:
|
||||
S = new (Context) CXXThrowExpr(Empty);
|
||||
break;
|
||||
}
|
||||
|
||||
// We hit a STMT_STOP, so we're done with this expression.
|
||||
|
|
|
@ -123,6 +123,8 @@ namespace {
|
|||
void VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
|
||||
void VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
|
||||
void VisitCXXTypeidExpr(CXXTypeidExpr *E);
|
||||
void VisitCXXThisExpr(CXXThisExpr *E);
|
||||
void VisitCXXThrowExpr(CXXThrowExpr *E);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -924,6 +926,20 @@ void PCHStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
|
|||
}
|
||||
}
|
||||
|
||||
void PCHStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
|
||||
VisitExpr(E);
|
||||
Writer.AddSourceLocation(E->getLocation(), Record);
|
||||
Record.push_back(E->isImplicit());
|
||||
Code = pch::EXPR_CXX_THIS;
|
||||
}
|
||||
|
||||
void PCHStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
|
||||
Writer.AddSourceLocation(E->getThrowLoc(), Record);
|
||||
Writer.WriteSubStmt(E->getSubExpr());
|
||||
Code = pch::EXPR_CXX_THROW;
|
||||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PCHWriter Implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -6,7 +6,7 @@ typedef __typeof__(static_cast<void *>(0)) static_cast_result;
|
|||
|
||||
// CXXDynamicCastExpr
|
||||
struct Base { virtual void f(); };
|
||||
struct Derived : Base { };
|
||||
struct Derived : Base { void g(); };
|
||||
Base *base_ptr;
|
||||
typedef __typeof__(dynamic_cast<Derived *>(base_ptr)) dynamic_cast_result;
|
||||
|
||||
|
@ -43,3 +43,13 @@ namespace std {
|
|||
// CXXTypeidExpr - Both expr and type forms.
|
||||
typedef __typeof__(typeid(int))* typeid_result1;
|
||||
typedef __typeof__(typeid(2))* typeid_result2;
|
||||
|
||||
void Derived::g() {
|
||||
// CXXThisExpr
|
||||
f(); // Implicit
|
||||
this->f(); // Explicit
|
||||
|
||||
// CXXThrowExpr
|
||||
throw;
|
||||
throw 42;
|
||||
}
|
Loading…
Reference in New Issue