[cfe-commits] r110666 - in /cfe/trunk: include/clang/AST/Expr.h include/clang/AST/RecursiveASTVisitor.h lib/Frontend/PCHReaderStmt.cpp lib/Frontend/PCHWriterStmt.cpp lib/Sema/Sema.h lib/Sema/SemaExpr.cpp lib/Sema/TreeTransform.h
Abramo Bagnara
abramo.bagnara at gmail.com
Tue Aug 10 03:06:15 PDT 2010
Author: abramo
Date: Tue Aug 10 05:06:15 2010
New Revision: 110666
URL: http://llvm.org/viewvc/llvm-project?rev=110666&view=rev
Log:
Added TypeLocs to VAArgExpr node.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/TreeTransform.h
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=110666&r1=110665&r2=110666&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Tue Aug 10 05:06:15 2010
@@ -2752,11 +2752,13 @@
/// 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 @@
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; }
Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=110666&r1=110665&r2=110666&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Aug 10 05:06:15 2010
@@ -1680,7 +1680,10 @@
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, {
Modified: cfe/trunk/lib/Frontend/PCHReaderStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderStmt.cpp?rev=110666&r1=110665&r2=110666&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderStmt.cpp Tue Aug 10 05:06:15 2010
@@ -710,6 +710,7 @@
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++]));
}
Modified: cfe/trunk/lib/Frontend/PCHWriterStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterStmt.cpp?rev=110666&r1=110665&r2=110666&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterStmt.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterStmt.cpp Tue Aug 10 05:06:15 2010
@@ -695,6 +695,7 @@
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;
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=110666&r1=110665&r2=110666&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Tue Aug 10 05:06:15 2010
@@ -2168,6 +2168,9 @@
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);
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=110666&r1=110665&r2=110666&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 10 05:06:15 2010
@@ -7314,7 +7314,14 @@
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 @@
// 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) {
Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=110666&r1=110665&r2=110666&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Tue Aug 10 05:06:15 2010
@@ -1311,10 +1311,12 @@
///
/// 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 @@
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 @@
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>
More information about the cfe-commits
mailing list