1AA1D91610125DE30078DEBC /* RecordLayoutBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = RecordLayoutBuilder.cpp; path = lib/AST/RecordLayoutBuilder.cpp; sourceTree = "<group>"; tabWidth = 2; };
1AA1D91710125DE30078DEBC /* RecordLayoutBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = RecordLayoutBuilder.h; path = lib/AST/RecordLayoutBuilder.h; sourceTree = "<group>"; tabWidth = 2; };
1AA963AB10D8576800786C86 /* FullExpr.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; name = FullExpr.h; path = clang/AST/FullExpr.h; sourceTree = "<group>"; tabWidth = 2; };
- 1AA963C310D85A7300786C86 /* FullExpr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FullExpr.cpp; path = lib/AST/FullExpr.cpp; sourceTree = "<group>"; };
+ 1AA963C310D85A7300786C86 /* FullExpr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = FullExpr.cpp; path = lib/AST/FullExpr.cpp; sourceTree = "<group>"; tabWidth = 2; };
1AB290021045858B00FE33D8 /* PartialDiagnostic.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = PartialDiagnostic.h; sourceTree = "<group>"; tabWidth = 2; };
1ABC36930C7A4BDC006DB0AB /* CGBuiltin.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.cpp.cpp; name = CGBuiltin.cpp; path = lib/CodeGen/CGBuiltin.cpp; sourceTree = "<group>"; tabWidth = 2; };
1ADD795110A90C6100741BBA /* TypePrinter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TypePrinter.cpp; path = lib/AST/TypePrinter.cpp; sourceTree = "<group>"; };
unsigned NumTemps;
- typedef CXXTemporary** iterator;
+ typedef CXXTemporary** temps_iterator;
- iterator begin() { return reinterpret_cast<CXXTemporary **>(this + 1); }
- iterator end() { return begin() + NumTemps; }
-
+ temps_iterator temps_begin() {
+ return reinterpret_cast<CXXTemporary **>(this + 1);
+ }
+ temps_iterator temps_end() {
+ return temps_begin() + NumTemps;
+ }
};
llvm::PointerUnion<Expr *, ExprAndTemporaries *> SubExpr;
public:
static FullExpr Create(ASTContext &Context, Expr *SubExpr,
CXXTemporary **Temps, unsigned NumTemps);
+ void Destroy(ASTContext &Context);
+
+ Expr *getExpr() {
+ if (Expr *E = SubExpr.dyn_cast<Expr *>())
+ return E;
+
+ return SubExpr.get<ExprAndTemporaries *>()->SubExpr;
+ }
+
+ const Expr *getExpr() const {
+ return const_cast<FullExpr*>(this)->getExpr();
+ }
+
+ typedef CXXTemporary** temps_iterator;
+
+ temps_iterator temps_begin() {
+ if (ExprAndTemporaries *ET = SubExpr.dyn_cast<ExprAndTemporaries *>())
+ return ET->temps_begin();
+
+ return 0;
+ }
+ temps_iterator temps_end() {
+ if (ExprAndTemporaries *ET = SubExpr.dyn_cast<ExprAndTemporaries *>())
+ return ET->temps_end();
+
+ return 0;
+ }
};
#include "clang/AST/ASTContext.h"
#include "clang/AST/FullExpr.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
#include "llvm/Support/AlignOf.h"
using namespace clang;
-FullExpr FullExpr::Create(ASTContext &Context, Expr *SubExpr,
+FullExpr FullExpr::Create(ASTContext &Context, Expr *SubExpr,
CXXTemporary **Temporaries, unsigned NumTemporaries) {
- FullExpr E;
-
- if (!NumTemporaries) {
- E.SubExpr = SubExpr;
- return E;
- }
-
- unsigned Size = sizeof(FullExpr)
- + sizeof(CXXTemporary *) * NumTemporaries;
-
- unsigned Align = llvm::AlignOf<ExprAndTemporaries>::Alignment;
- ExprAndTemporaries *ET =
- static_cast<ExprAndTemporaries *>(Context.Allocate(Size, Align));
-
- ET->SubExpr = SubExpr;
- std::copy(Temporaries, Temporaries + NumTemporaries, ET->begin());
+ FullExpr E;
+
+ if (!NumTemporaries) {
+ E.SubExpr = SubExpr;
+ return E;
+ }
+
+ unsigned Size = sizeof(FullExpr)
+ + sizeof(CXXTemporary *) * NumTemporaries;
+
+ unsigned Align = llvm::AlignOf<ExprAndTemporaries>::Alignment;
+ ExprAndTemporaries *ET =
+ static_cast<ExprAndTemporaries *>(Context.Allocate(Size, Align));
+
+ ET->SubExpr = SubExpr;
+ std::copy(Temporaries, Temporaries + NumTemporaries, ET->temps_begin());
- return E;
+ return E;
+}
+
+void FullExpr::Destroy(ASTContext &Context) {
+ if (Expr *E = SubExpr.dyn_cast<Expr *>()) {
+ E->Destroy(Context);
+ return;
+ }
+
+ ExprAndTemporaries *ET = SubExpr.get<ExprAndTemporaries *>();
+ for (ExprAndTemporaries::temps_iterator i = ET->temps_begin(),
+ e = ET->temps_end(); i != e; ++i)
+ (*i)->Destroy(Context);
+
+ Context.Deallocate(ET);
}