forked from OSchip/llvm-project
parent
7fbe6cb429
commit
27db23948c
|
@ -2752,11 +2752,13 @@ public:
|
|||
/// VAArgExpr, used for the builtin function __builtin_va_arg.
|
||||
class VAArgExpr : public Expr {
|
||||
Stmt *Val;
|
||||
TypeSourceInfo *TInfo;
|
||||
SourceLocation BuiltinLoc, RParenLoc;
|
||||
public:
|
||||
VAArgExpr(SourceLocation BLoc, Expr* e, QualType t, SourceLocation RPLoc)
|
||||
VAArgExpr(SourceLocation BLoc, Expr* e, TypeSourceInfo *TInfo,
|
||||
SourceLocation RPLoc, QualType t)
|
||||
: Expr(VAArgExprClass, t, t->isDependentType(), false),
|
||||
Val(e),
|
||||
Val(e), TInfo(TInfo),
|
||||
BuiltinLoc(BLoc),
|
||||
RParenLoc(RPLoc) { }
|
||||
|
||||
|
@ -2767,6 +2769,9 @@ public:
|
|||
Expr *getSubExpr() { return cast<Expr>(Val); }
|
||||
void setSubExpr(Expr *E) { Val = E; }
|
||||
|
||||
TypeSourceInfo *getWrittenTypeInfo() const { return TInfo; }
|
||||
void setWrittenTypeInfo(TypeSourceInfo *TI) { TInfo = TI; }
|
||||
|
||||
SourceLocation getBuiltinLoc() const { return BuiltinLoc; }
|
||||
void setBuiltinLoc(SourceLocation L) { BuiltinLoc = L; }
|
||||
|
||||
|
|
|
@ -1680,7 +1680,10 @@ DEF_TRAVERSE_STMT(ShuffleVectorExpr, { })
|
|||
DEF_TRAVERSE_STMT(StmtExpr, { })
|
||||
DEF_TRAVERSE_STMT(UnresolvedLookupExpr, { })
|
||||
DEF_TRAVERSE_STMT(UnresolvedMemberExpr, { })
|
||||
DEF_TRAVERSE_STMT(VAArgExpr, { })
|
||||
DEF_TRAVERSE_STMT(VAArgExpr, {
|
||||
// The child-iterator will pick up the expression argument.
|
||||
TRY_TO(TraverseTypeLoc(S->getWrittenTypeInfo()->getTypeLoc()));
|
||||
})
|
||||
DEF_TRAVERSE_STMT(CXXConstructExpr, { })
|
||||
|
||||
DEF_TRAVERSE_STMT(CXXTemporaryObjectExpr, {
|
||||
|
|
|
@ -710,6 +710,7 @@ void PCHStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
|
|||
void PCHStmtReader::VisitVAArgExpr(VAArgExpr *E) {
|
||||
VisitExpr(E);
|
||||
E->setSubExpr(Reader.ReadSubExpr());
|
||||
E->setWrittenTypeInfo(Reader.GetTypeSourceInfo(DeclsCursor, Record, Idx));
|
||||
E->setBuiltinLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||
E->setRParenLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||
}
|
||||
|
|
|
@ -695,6 +695,7 @@ void PCHStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
|
|||
void PCHStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
|
||||
VisitExpr(E);
|
||||
Writer.AddStmt(E->getSubExpr());
|
||||
Writer.AddTypeSourceInfo(E->getWrittenTypeInfo(), Record);
|
||||
Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
|
||||
Writer.AddSourceLocation(E->getRParenLoc(), Record);
|
||||
Code = pch::EXPR_VA_ARG;
|
||||
|
|
|
@ -2168,6 +2168,9 @@ public:
|
|||
virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc,
|
||||
ExprArg expr, TypeTy *type,
|
||||
SourceLocation RPLoc);
|
||||
OwningExprResult BuildVAArgExpr(SourceLocation BuiltinLoc,
|
||||
ExprArg expr, TypeSourceInfo *TInfo,
|
||||
SourceLocation RPLoc);
|
||||
|
||||
// __null
|
||||
virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
|
||||
|
|
|
@ -7314,7 +7314,14 @@ Sema::OwningExprResult Sema::ActOnBlockStmtExpr(SourceLocation CaretLoc,
|
|||
Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
|
||||
ExprArg expr, TypeTy *type,
|
||||
SourceLocation RPLoc) {
|
||||
QualType T = GetTypeFromParser(type);
|
||||
TypeSourceInfo *TInfo;
|
||||
QualType T = GetTypeFromParser(type, &TInfo);
|
||||
return BuildVAArgExpr(BuiltinLoc, move(expr), TInfo, RPLoc);
|
||||
}
|
||||
|
||||
Sema::OwningExprResult Sema::BuildVAArgExpr(SourceLocation BuiltinLoc,
|
||||
ExprArg expr, TypeSourceInfo *TInfo,
|
||||
SourceLocation RPLoc) {
|
||||
Expr *E = static_cast<Expr*>(expr.get());
|
||||
Expr *OrigExpr = E;
|
||||
|
||||
|
@ -7348,9 +7355,8 @@ Sema::OwningExprResult Sema::ActOnVAArg(SourceLocation BuiltinLoc,
|
|||
// FIXME: Warn if a non-POD type is passed in.
|
||||
|
||||
expr.release();
|
||||
return Owned(new (Context) VAArgExpr(BuiltinLoc, E,
|
||||
T.getNonLValueExprType(Context),
|
||||
RPLoc));
|
||||
QualType T = TInfo->getType().getNonLValueExprType(Context);
|
||||
return Owned(new (Context) VAArgExpr(BuiltinLoc, E, TInfo, RPLoc, T));
|
||||
}
|
||||
|
||||
Sema::OwningExprResult Sema::ActOnGNUNullExpr(SourceLocation TokenLoc) {
|
||||
|
|
|
@ -1311,10 +1311,12 @@ public:
|
|||
///
|
||||
/// By default, performs semantic analysis to build the new expression.
|
||||
/// Subclasses may override this routine to provide different behavior.
|
||||
OwningExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, ExprArg SubExpr,
|
||||
QualType T, SourceLocation RParenLoc) {
|
||||
return getSema().ActOnVAArg(BuiltinLoc, move(SubExpr), T.getAsOpaquePtr(),
|
||||
RParenLoc);
|
||||
OwningExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc,
|
||||
ExprArg SubExpr, TypeSourceInfo *TInfo,
|
||||
SourceLocation RParenLoc) {
|
||||
return getSema().BuildVAArgExpr(BuiltinLoc,
|
||||
move(SubExpr), TInfo,
|
||||
RParenLoc);
|
||||
}
|
||||
|
||||
/// \brief Build a new expression list in parentheses.
|
||||
|
@ -4780,14 +4782,12 @@ TreeTransform<Derived>::TransformImplicitValueInitExpr(
|
|||
template<typename Derived>
|
||||
Sema::OwningExprResult
|
||||
TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) {
|
||||
// FIXME: Do we want the type as written?
|
||||
QualType T;
|
||||
|
||||
TypeSourceInfo *TInfo;
|
||||
{
|
||||
// FIXME: Source location isn't quite accurate.
|
||||
TemporaryBase Rebase(*this, E->getBuiltinLoc(), DeclarationName());
|
||||
T = getDerived().TransformType(E->getType());
|
||||
if (T.isNull())
|
||||
TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
|
||||
if (!TInfo)
|
||||
return SemaRef.ExprError();
|
||||
}
|
||||
|
||||
|
@ -4796,12 +4796,12 @@ TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) {
|
|||
return SemaRef.ExprError();
|
||||
|
||||
if (!getDerived().AlwaysRebuild() &&
|
||||
T == E->getType() &&
|
||||
TInfo == E->getWrittenTypeInfo() &&
|
||||
SubExpr.get() == E->getSubExpr())
|
||||
return SemaRef.Owned(E->Retain());
|
||||
|
||||
return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), move(SubExpr),
|
||||
T, E->getRParenLoc());
|
||||
TInfo, E->getRParenLoc());
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
|
|
Loading…
Reference in New Issue