}
}
+const char *DeclContext::getDeclKindName() const {
+ switch (DeclKind) {
+ default: assert(0 && "Unknown decl kind!");
+ case Decl::TranslationUnit: return "TranslationUnit";
+ case Decl::Namespace: return "Namespace";
+ case Decl::OverloadedFunction: return "OverloadedFunction";
+ case Decl::Typedef: return "Typedef";
+ case Decl::Function: return "Function";
+ case Decl::Var: return "Var";
+ case Decl::ParmVar: return "ParmVar";
+ case Decl::OriginalParmVar: return "OriginalParmVar";
+ case Decl::EnumConstant: return "EnumConstant";
+ case Decl::ObjCIvar: return "ObjCIvar";
+ case Decl::ObjCInterface: return "ObjCInterface";
+ case Decl::ObjCImplementation: return "ObjCImplementation";
+ case Decl::ObjCClass: return "ObjCClass";
+ case Decl::ObjCMethod: return "ObjCMethod";
+ case Decl::ObjCProtocol: return "ObjCProtocol";
+ case Decl::ObjCProperty: return "ObjCProperty";
+ case Decl::ObjCPropertyImpl: return "ObjCPropertyImpl";
+ case Decl::ObjCForwardProtocol: return "ObjCForwardProtocol";
+ case Decl::Record: return "Record";
+ case Decl::CXXRecord: return "CXXRecord";
+ case Decl::Enum: return "Enum";
+ case Decl::Block: return "Block";
+ case Decl::Field: return "Field";
+ }
+}
+
bool Decl::CollectingStats(bool Enable) {
if (Enable)
StatSwitch = true;
DeclRefExpr *Sema::BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc,
bool TypeDependent, bool ValueDependent,
const CXXScopeSpec *SS) {
- if (SS && !SS->isEmpty())
- return new QualifiedDeclRefExpr(D, Ty, Loc, TypeDependent, ValueDependent,
- SS->getRange().getBegin());
- else
- return new DeclRefExpr(D, Ty, Loc, TypeDependent, ValueDependent);
+ if (SS && !SS->isEmpty()) {
+ void *Mem = Context.getAllocator().Allocate<QualifiedDeclRefExpr>();
+ return new (Mem) QualifiedDeclRefExpr(D, Ty, Loc, TypeDependent,
+ ValueDependent, SS->getRange().getBegin());
+ } else {
+ void *Mem = Context.getAllocator().Allocate<DeclRefExpr>();
+ return new (Mem) DeclRefExpr(D, Ty, Loc, TypeDependent, ValueDependent);
+ }
}
/// getObjectForAnonymousRecordDecl - Retrieve the (unnamed) field or
// to represent this name. Then, if it turns out that none of the
// arguments are type-dependent, we'll force the resolution of the
// dependent name at that point.
- return Owned(new CXXDependentNameExpr(Name.getAsIdentifierInfo(),
- Context.DependentTy, Loc));
+ void *Mem = Context.getAllocator().Allocate<CXXDependentNameExpr>();
+ return Owned(new (Mem) CXXDependentNameExpr(Name.getAsIdentifierInfo(),
+ Context.DependentTy, Loc));
}
// Could be enum-constant, value decl, instance variable, etc.
//
if (CurBlock && ShouldSnapshotBlockValueReference(CurBlock, VD)) {
// The BlocksAttr indicates the variable is bound by-reference.
+ void *Mem = Context.getAllocator().Allocate<BlockDeclRefExpr>();
if (VD->getAttr<BlocksAttr>())
- return Owned(new BlockDeclRefExpr(VD, VD->getType().getNonReferenceType(),
- Loc, true));
+ return Owned(new (Mem) BlockDeclRefExpr(VD,
+ VD->getType().getNonReferenceType(), Loc, true));
// Variable will be bound by-copy, make it const within the closure.
VD->getType().addConst();
- return Owned(new BlockDeclRefExpr(VD, VD->getType().getNonReferenceType(),
- Loc, false));
+ return Owned(new (Mem) BlockDeclRefExpr(VD,
+ VD->getType().getNonReferenceType(), Loc, false));
}
// If this reference is not in a block or if the referenced variable is
// within the block, create a normal DeclRefExpr.
QualType type = getLangOptions().CPlusPlus ? Context.CharTy : Context.IntTy;
- return Owned(new CharacterLiteral(Literal.getValue(), Literal.isWide(), type,
- Tok.getLocation()));
+ void *Mem = Context.getAllocator().Allocate<CharacterLiteral>();
+ return Owned(new (Mem) CharacterLiteral(Literal.getValue(), Literal.isWide(),
+ type, Tok.getLocation()));
}
Action::OwningExprResult Sema::ActOnNumericConstant(const Token &Tok) {
if (Tok.getLength() == 1) {
const char Val = PP.getSpelledCharacterAt(Tok.getLocation());
unsigned IntSize = Context.Target.getIntWidth();
- return Owned(new IntegerLiteral(llvm::APInt(IntSize, Val-'0'),
- Context.IntTy, Tok.getLocation()));
+ void *Mem = Context.getAllocator().Allocate<IntegerLiteral>();
+ return Owned(new (Mem) IntegerLiteral(llvm::APInt(IntSize, Val-'0'),
+ Context.IntTy, Tok.getLocation()));
}
llvm::SmallString<512> IntegerBuffer;
// isExact will be set by GetFloatValue().
bool isExact = false;
- Res = new FloatingLiteral(Literal.GetFloatValue(Format, &isExact), &isExact,
- Ty, Tok.getLocation());
+ void *Mem = Context.getAllocator().Allocate<FloatingLiteral>();
+ Res = new (Mem) FloatingLiteral(Literal.GetFloatValue(Format, &isExact),
+ &isExact, Ty, Tok.getLocation());
} else if (!Literal.isIntegerLiteral()) {
return ExprError();
if (ResultVal.getBitWidth() != Width)
ResultVal.trunc(Width);
}
-
- Res = new IntegerLiteral(ResultVal, Ty, Tok.getLocation());
+ void *Mem = Context.getAllocator().Allocate<IntegerLiteral>();
+ Res = new (Mem) IntegerLiteral(ResultVal, Ty, Tok.getLocation());
}
// If this is an imaginary literal, create the ImaginaryLiteral wrapper.
SourceLocation R, ExprArg Val) {
Expr *E = (Expr *)Val.release();
assert((E != 0) && "ActOnParenExpr() missing expr");
- return Owned(new ParenExpr(L, R, E));
+ void *Mem = Context.getAllocator().Allocate<ParenExpr>();
+ return Owned(new (Mem) ParenExpr(L, R, E));
}
/// The UsualUnaryConversions() function is *not* called by this routine.
return ExprError();
// C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
- return Owned(new SizeOfAlignOfExpr(isSizeof, isType, TyOrEx,
+ void *Mem = Context.getAllocator().Allocate<SizeOfAlignOfExpr>();
+ return Owned(new (Mem) SizeOfAlignOfExpr(isSizeof, isType, TyOrEx,
Context.getSizeType(), OpLoc,
Range.getEnd()));
}
ResultTy = ResultTy.getNonReferenceType();
// Build the actual expression node.
- Expr *FnExpr = new DeclRefExpr(FnDecl, FnDecl->getType(),
+ void *Mem = Context.getAllocator().Allocate<DeclRefExpr>();
+ Expr *FnExpr = new (Mem) DeclRefExpr(FnDecl, FnDecl->getType(),
SourceLocation());
UsualUnaryConversions(FnExpr);
Input.release();
- return Owned(new CXXOperatorCallExpr(FnExpr, Args, 2, ResultTy, OpLoc));
+ Mem = Context.getAllocator().Allocate<CXXOperatorCallExpr>();
+ return Owned(new (Mem) CXXOperatorCallExpr(FnExpr, Args, 2, ResultTy,
+ OpLoc));
} else {
// We matched a built-in operator. Convert the arguments, then
// break out so that we will build the appropriate built-in