本文整理汇总了C++中ASTContext::Allocate方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTContext::Allocate方法的具体用法?C++ ASTContext::Allocate怎么用?C++ ASTContext::Allocate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTContext
的用法示例。
在下文中一共展示了ASTContext::Allocate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setClassList
void ObjCClassDecl::setClassList(ASTContext &C, ObjCInterfaceDecl*const*List,
const SourceLocation *Locs, unsigned Num) {
ForwardDecls = (ObjCClassRef*) C.Allocate(sizeof(ObjCClassRef)*Num,
llvm::alignOf<ObjCClassRef>());
for (unsigned i = 0; i < Num; ++i)
new (&ForwardDecls[i]) ObjCClassRef(List[i], Locs[i]);
NumDecls = Num;
}
示例2: setParams
void BlockDecl::setParams(ASTContext& C, ParmVarDecl **NewParamInfo,
unsigned NParms) {
assert(ParamInfo == 0 && "Already has param info!");
// Zero params -> null pointer.
if (NParms) {
NumParams = NParms;
void *Mem = C.Allocate(sizeof(ParmVarDecl*)*NumParams);
ParamInfo = new (Mem) ParmVarDecl*[NumParams];
memcpy(ParamInfo, NewParamInfo, sizeof(ParmVarDecl*)*NumParams);
}
}
示例3: initializeResults
void OverloadExpr::initializeResults(ASTContext &C,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End) {
assert(Results == 0 && "Results already initialized!");
NumResults = End - Begin;
if (NumResults) {
Results = static_cast<DeclAccessPair *>(
C.Allocate(sizeof(DeclAccessPair) * NumResults,
llvm::alignOf<DeclAccessPair>()));
memcpy(Results, &*Begin.getIterator(),
NumResults * sizeof(DeclAccessPair));
}
}
示例4: setParamsAndSelLocs
void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
ArrayRef<ParmVarDecl*> Params,
ArrayRef<SourceLocation> SelLocs) {
ParamsAndSelLocs = 0;
NumParams = Params.size();
if (Params.empty() && SelLocs.empty())
return;
unsigned Size = sizeof(ParmVarDecl *) * NumParams +
sizeof(SourceLocation) * SelLocs.size();
ParamsAndSelLocs = C.Allocate(Size);
std::copy(Params.begin(), Params.end(), getParams());
std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
}
示例5: NestedNameSpecifierLoc
NestedNameSpecifierLoc
NestedNameSpecifierLocBuilder::getWithLocInContext(ASTContext &Context) const {
if (!Representation)
return NestedNameSpecifierLoc();
// If we adopted our data pointer from elsewhere in the AST context, there's
// no need to copy the memory.
if (BufferCapacity == 0)
return NestedNameSpecifierLoc(Representation, Buffer);
// FIXME: After copying the source-location information, should we free
// our (temporary) buffer and adopt the ASTContext-allocated memory?
// Doing so would optimize repeated calls to getWithLocInContext().
void *Mem = Context.Allocate(BufferSize, llvm::alignOf<void *>());
memcpy(Mem, Buffer, BufferSize);
return NestedNameSpecifierLoc(Representation, Mem);
}
示例6: sizeof
TemplateArgument::TemplateArgument(ASTContext &Ctx, const llvm::APSInt &Value,
QualType Type) {
Integer.Kind = Integral;
// Copy the APSInt value into our decomposed form.
Integer.BitWidth = Value.getBitWidth();
Integer.IsUnsigned = Value.isUnsigned();
// If the value is large, we have to get additional memory from the ASTContext
unsigned NumWords = Value.getNumWords();
if (NumWords > 1) {
void *Mem = Ctx.Allocate(NumWords * sizeof(uint64_t));
std::memcpy(Mem, Value.getRawData(), NumWords * sizeof(uint64_t));
Integer.pVal = static_cast<uint64_t *>(Mem);
} else {
Integer.VAL = Value.getZExtValue();
}
Integer.Type = Type.getAsOpaquePtr();
}
示例7: setCaptures
void ScriptDefn::setCaptures(ASTContext &Context,
const Capture *begin,
const Capture *end) {
if (begin == end) {
NumCaptures = 0;
Captures = 0;
return;
}
NumCaptures = end - begin;
// Avoid new Capture[] because we don't want to provide a default
// constructor.
size_t allocationSize = NumCaptures * sizeof(Capture);
void *buffer = Context.Allocate(allocationSize, /*alignment*/sizeof(void*));
memcpy(buffer, begin, allocationSize);
Captures = static_cast<Capture*>(buffer);
}
示例8: Create
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->temps_begin());
return E;
}
示例9: Expr
OverloadExpr::OverloadExpr(StmtClass K, ASTContext &C,
NestedNameSpecifierLoc QualifierLoc,
const DeclarationNameInfo &NameInfo,
const TemplateArgumentListInfo *TemplateArgs,
UnresolvedSetIterator Begin,
UnresolvedSetIterator End,
bool KnownDependent,
bool KnownInstantiationDependent,
bool KnownContainsUnexpandedParameterPack)
: Expr(K, C.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent,
KnownDependent,
(KnownInstantiationDependent ||
NameInfo.isInstantiationDependent() ||
(QualifierLoc &&
QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())),
(KnownContainsUnexpandedParameterPack ||
NameInfo.containsUnexpandedParameterPack() ||
(QualifierLoc &&
QualifierLoc.getNestedNameSpecifier()
->containsUnexpandedParameterPack()))),
Results(0), NumResults(End - Begin), NameInfo(NameInfo),
QualifierLoc(QualifierLoc), HasExplicitTemplateArgs(TemplateArgs != 0)
{
NumResults = End - Begin;
if (NumResults) {
// Determine whether this expression is type-dependent.
for (UnresolvedSetImpl::const_iterator I = Begin; I != End; ++I) {
if ((*I)->getDeclContext()->isDependentContext() ||
isa<UnresolvedUsingValueDecl>(*I)) {
ExprBits.TypeDependent = true;
ExprBits.ValueDependent = true;
}
}
Results = static_cast<DeclAccessPair *>(
C.Allocate(sizeof(DeclAccessPair) * NumResults,
llvm::alignOf<DeclAccessPair>()));
memcpy(Results, &*Begin.getIterator(),
NumResults * sizeof(DeclAccessPair));
}
// If we have explicit template arguments, check for dependent
// template arguments and whether they contain any unexpanded pack
// expansions.
if (TemplateArgs) {
bool Dependent = false;
bool InstantiationDependent = false;
bool ContainsUnexpandedParameterPack = false;
getExplicitTemplateArgs().initializeFrom(*TemplateArgs, Dependent,
InstantiationDependent,
ContainsUnexpandedParameterPack);
if (Dependent) {
ExprBits.TypeDependent = true;
ExprBits.ValueDependent = true;
}
if (InstantiationDependent)
ExprBits.InstantiationDependent = true;
if (ContainsUnexpandedParameterPack)
ExprBits.ContainsUnexpandedParameterPack = true;
}
if (isTypeDependent())
setType(C.DependentTy);
}