diff options
author | dim <dim@FreeBSD.org> | 2016-01-06 20:20:48 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-01-06 20:20:48 +0000 |
commit | e13d34a8ff8cbd5565582c4efc3c00d9d2aab26f (patch) | |
tree | 7ea42cf427bda317125421123460445eb3c7075f /contrib/llvm/tools/clang/lib/AST | |
parent | e06c171d67ab436f270b15f7e364a8d8f77c01f2 (diff) | |
parent | fc74ff5a0792641885551a63d9ddf8cbfdf76e3c (diff) | |
download | FreeBSD-src-e13d34a8ff8cbd5565582c4efc3c00d9d2aab26f.zip FreeBSD-src-e13d34a8ff8cbd5565582c4efc3c00d9d2aab26f.tar.gz |
Update clang to trunk r256945.
Diffstat (limited to 'contrib/llvm/tools/clang/lib/AST')
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/ASTContext.cpp | 10 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/Expr.cpp | 25 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp | 122 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/ExprObjC.cpp | 43 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/MicrosoftMangle.cpp | 21 | ||||
-rw-r--r-- | contrib/llvm/tools/clang/lib/AST/OpenMPClause.cpp | 96 |
6 files changed, 105 insertions, 212 deletions
diff --git a/contrib/llvm/tools/clang/lib/AST/ASTContext.cpp b/contrib/llvm/tools/clang/lib/AST/ASTContext.cpp index 108677a..d4abbe4 100644 --- a/contrib/llvm/tools/clang/lib/AST/ASTContext.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ASTContext.cpp @@ -3658,14 +3658,13 @@ static int CmpProtocolNames(ObjCProtocolDecl *const *LHS, return DeclarationName::compare((*LHS)->getDeclName(), (*RHS)->getDeclName()); } -static bool areSortedAndUniqued(ObjCProtocolDecl * const *Protocols, - unsigned NumProtocols) { - if (NumProtocols == 0) return true; +static bool areSortedAndUniqued(ArrayRef<ObjCProtocolDecl *> Protocols) { + if (Protocols.empty()) return true; if (Protocols[0]->getCanonicalDecl() != Protocols[0]) return false; - for (unsigned i = 1; i != NumProtocols; ++i) + for (unsigned i = 1; i != Protocols.size(); ++i) if (CmpProtocolNames(&Protocols[i - 1], &Protocols[i]) >= 0 || Protocols[i]->getCanonicalDecl() != Protocols[i]) return false; @@ -3730,8 +3729,7 @@ QualType ASTContext::getObjCObjectType( [&](QualType type) { return type.isCanonical(); }); - bool protocolsSorted = areSortedAndUniqued(protocols.data(), - protocols.size()); + bool protocolsSorted = areSortedAndUniqued(protocols); if (!typeArgsAreCanonical || !protocolsSorted || !baseType.isCanonical()) { // Determine the canonical type arguments. ArrayRef<QualType> canonTypeArgs; diff --git a/contrib/llvm/tools/clang/lib/AST/Expr.cpp b/contrib/llvm/tools/clang/lib/AST/Expr.cpp index bdd7a45..f9757b2 100644 --- a/contrib/llvm/tools/clang/lib/AST/Expr.cpp +++ b/contrib/llvm/tools/clang/lib/AST/Expr.cpp @@ -3711,8 +3711,7 @@ DesignatedInitExpr::Create(const ASTContext &C, Designator *Designators, ArrayRef<Expr*> IndexExprs, SourceLocation ColonOrEqualLoc, bool UsesColonSyntax, Expr *Init) { - void *Mem = C.Allocate(sizeof(DesignatedInitExpr) + - sizeof(Stmt *) * (IndexExprs.size() + 1), + void *Mem = C.Allocate(totalSizeToAlloc<Stmt *>(IndexExprs.size() + 1), llvm::alignOf<DesignatedInitExpr>()); return new (Mem) DesignatedInitExpr(C, C.VoidTy, NumDesignators, Designators, ColonOrEqualLoc, UsesColonSyntax, @@ -3721,8 +3720,8 @@ DesignatedInitExpr::Create(const ASTContext &C, Designator *Designators, DesignatedInitExpr *DesignatedInitExpr::CreateEmpty(const ASTContext &C, unsigned NumIndexExprs) { - void *Mem = C.Allocate(sizeof(DesignatedInitExpr) + - sizeof(Stmt *) * (NumIndexExprs + 1), 8); + void *Mem = C.Allocate(totalSizeToAlloc<Stmt *>(NumIndexExprs + 1), + llvm::alignOf<DesignatedInitExpr>()); return new (Mem) DesignatedInitExpr(NumIndexExprs + 1); } @@ -3764,22 +3763,19 @@ SourceLocation DesignatedInitExpr::getLocEnd() const { Expr *DesignatedInitExpr::getArrayIndex(const Designator& D) const { assert(D.Kind == Designator::ArrayDesignator && "Requires array designator"); - Stmt *const *SubExprs = reinterpret_cast<Stmt *const *>(this + 1); - return cast<Expr>(*(SubExprs + D.ArrayOrRange.Index + 1)); + return getSubExpr(D.ArrayOrRange.Index + 1); } Expr *DesignatedInitExpr::getArrayRangeStart(const Designator &D) const { assert(D.Kind == Designator::ArrayRangeDesignator && "Requires array range designator"); - Stmt *const *SubExprs = reinterpret_cast<Stmt *const *>(this + 1); - return cast<Expr>(*(SubExprs + D.ArrayOrRange.Index + 1)); + return getSubExpr(D.ArrayOrRange.Index + 1); } Expr *DesignatedInitExpr::getArrayRangeEnd(const Designator &D) const { assert(D.Kind == Designator::ArrayRangeDesignator && "Requires array range designator"); - Stmt *const *SubExprs = reinterpret_cast<Stmt *const *>(this + 1); - return cast<Expr>(*(SubExprs + D.ArrayOrRange.Index + 2)); + return getSubExpr(D.ArrayOrRange.Index + 2); } /// \brief Replaces the designator at index @p Idx with the series @@ -3863,9 +3859,9 @@ const OpaqueValueExpr *OpaqueValueExpr::findInCopyConstruct(const Expr *e) { PseudoObjectExpr *PseudoObjectExpr::Create(const ASTContext &Context, EmptyShell sh, unsigned numSemanticExprs) { - void *buffer = Context.Allocate(sizeof(PseudoObjectExpr) + - (1 + numSemanticExprs) * sizeof(Expr*), - llvm::alignOf<PseudoObjectExpr>()); + void *buffer = + Context.Allocate(totalSizeToAlloc<Expr *>(1 + numSemanticExprs), + llvm::alignOf<PseudoObjectExpr>()); return new(buffer) PseudoObjectExpr(sh, numSemanticExprs); } @@ -3892,8 +3888,7 @@ PseudoObjectExpr *PseudoObjectExpr::Create(const ASTContext &C, Expr *syntax, assert(semantics[resultIndex]->getObjectKind() == OK_Ordinary); } - void *buffer = C.Allocate(sizeof(PseudoObjectExpr) + - (1 + semantics.size()) * sizeof(Expr*), + void *buffer = C.Allocate(totalSizeToAlloc<Expr *>(semantics.size() + 1), llvm::alignOf<PseudoObjectExpr>()); return new(buffer) PseudoObjectExpr(type, VK, syntax, semantics, resultIndex); diff --git a/contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp b/contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp index 4bb4b50..d35efcb 100644 --- a/contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ExprCXX.cpp @@ -766,7 +766,7 @@ const IdentifierInfo *UserDefinedLiteral::getUDSuffix() const { CXXDefaultArgExpr * CXXDefaultArgExpr::Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *SubExpr) { - void *Mem = C.Allocate(sizeof(CXXDefaultArgExpr) + sizeof(Stmt *)); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(1)); return new (Mem) CXXDefaultArgExpr(CXXDefaultArgExprClass, Loc, Param, SubExpr); } @@ -924,29 +924,22 @@ LambdaCaptureKind LambdaCapture::getCaptureKind() const { return CapByCopy ? LCK_ByCopy : LCK_ByRef; } -LambdaExpr::LambdaExpr(QualType T, - SourceRange IntroducerRange, +LambdaExpr::LambdaExpr(QualType T, SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, SourceLocation CaptureDefaultLoc, - ArrayRef<Capture> Captures, - bool ExplicitParams, - bool ExplicitResultType, - ArrayRef<Expr *> CaptureInits, + ArrayRef<LambdaCapture> Captures, bool ExplicitParams, + bool ExplicitResultType, ArrayRef<Expr *> CaptureInits, ArrayRef<VarDecl *> ArrayIndexVars, ArrayRef<unsigned> ArrayIndexStarts, SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack) - : Expr(LambdaExprClass, T, VK_RValue, OK_Ordinary, - T->isDependentType(), T->isDependentType(), T->isDependentType(), - ContainsUnexpandedParameterPack), - IntroducerRange(IntroducerRange), - CaptureDefaultLoc(CaptureDefaultLoc), - NumCaptures(Captures.size()), - CaptureDefault(CaptureDefault), - ExplicitParams(ExplicitParams), - ExplicitResultType(ExplicitResultType), - ClosingBrace(ClosingBrace) -{ + : Expr(LambdaExprClass, T, VK_RValue, OK_Ordinary, T->isDependentType(), + T->isDependentType(), T->isDependentType(), + ContainsUnexpandedParameterPack), + IntroducerRange(IntroducerRange), CaptureDefaultLoc(CaptureDefaultLoc), + NumCaptures(Captures.size()), CaptureDefault(CaptureDefault), + ExplicitParams(ExplicitParams), ExplicitResultType(ExplicitResultType), + ClosingBrace(ClosingBrace) { assert(CaptureInits.size() == Captures.size() && "Wrong number of arguments"); CXXRecordDecl *Class = getLambdaClass(); CXXRecordDecl::LambdaDefinitionData &Data = Class->getLambdaData(); @@ -957,8 +950,9 @@ LambdaExpr::LambdaExpr(QualType T, const ASTContext &Context = Class->getASTContext(); Data.NumCaptures = NumCaptures; Data.NumExplicitCaptures = 0; - Data.Captures = (Capture *)Context.Allocate(sizeof(Capture) * NumCaptures); - Capture *ToCapture = Data.Captures; + Data.Captures = + (LambdaCapture *)Context.Allocate(sizeof(LambdaCapture) * NumCaptures); + LambdaCapture *ToCapture = Data.Captures; for (unsigned I = 0, N = Captures.size(); I != N; ++I) { if (Captures[I].isExplicit()) ++Data.NumExplicitCaptures; @@ -986,30 +980,20 @@ LambdaExpr::LambdaExpr(QualType T, } } -LambdaExpr *LambdaExpr::Create(const ASTContext &Context, - CXXRecordDecl *Class, - SourceRange IntroducerRange, - LambdaCaptureDefault CaptureDefault, - SourceLocation CaptureDefaultLoc, - ArrayRef<Capture> Captures, - bool ExplicitParams, - bool ExplicitResultType, - ArrayRef<Expr *> CaptureInits, - ArrayRef<VarDecl *> ArrayIndexVars, - ArrayRef<unsigned> ArrayIndexStarts, - SourceLocation ClosingBrace, - bool ContainsUnexpandedParameterPack) { +LambdaExpr *LambdaExpr::Create( + const ASTContext &Context, CXXRecordDecl *Class, + SourceRange IntroducerRange, LambdaCaptureDefault CaptureDefault, + SourceLocation CaptureDefaultLoc, ArrayRef<LambdaCapture> Captures, + bool ExplicitParams, bool ExplicitResultType, ArrayRef<Expr *> CaptureInits, + ArrayRef<VarDecl *> ArrayIndexVars, ArrayRef<unsigned> ArrayIndexStarts, + SourceLocation ClosingBrace, bool ContainsUnexpandedParameterPack) { // Determine the type of the expression (i.e., the type of the // function object we're creating). QualType T = Context.getTypeDeclType(Class); - unsigned Size = sizeof(LambdaExpr) + sizeof(Stmt *) * (Captures.size() + 1); - if (!ArrayIndexVars.empty()) { - Size += sizeof(unsigned) * (Captures.size() + 1); - // Realign for following VarDecl array. - Size = llvm::RoundUpToAlignment(Size, llvm::alignOf<VarDecl*>()); - Size += sizeof(VarDecl *) * ArrayIndexVars.size(); - } + unsigned Size = totalSizeToAlloc<Stmt *, unsigned, VarDecl *>( + Captures.size() + 1, ArrayIndexVars.empty() ? 0 : Captures.size() + 1, + ArrayIndexVars.size()); void *Mem = Context.Allocate(Size); return new (Mem) LambdaExpr(T, IntroducerRange, CaptureDefault, CaptureDefaultLoc, Captures, @@ -1021,10 +1005,9 @@ LambdaExpr *LambdaExpr::Create(const ASTContext &Context, LambdaExpr *LambdaExpr::CreateDeserialized(const ASTContext &C, unsigned NumCaptures, unsigned NumArrayIndexVars) { - unsigned Size = sizeof(LambdaExpr) + sizeof(Stmt *) * (NumCaptures + 1); - if (NumArrayIndexVars) - Size += sizeof(VarDecl) * NumArrayIndexVars - + sizeof(unsigned) * (NumCaptures + 1); + unsigned Size = totalSizeToAlloc<Stmt *, unsigned, VarDecl *>( + NumCaptures + 1, NumArrayIndexVars ? NumCaptures + 1 : 0, + NumArrayIndexVars); void *Mem = C.Allocate(Size); return new (Mem) LambdaExpr(EmptyShell(), NumCaptures, NumArrayIndexVars > 0); } @@ -1108,7 +1091,7 @@ CompoundStmt *LambdaExpr::getBody() const { *const_cast<clang::Stmt **>(&getStoredStmts()[NumCaptures]) = getCallOperator()->getBody(); - return reinterpret_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]); + return static_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]); } bool LambdaExpr::isMutable() const { @@ -1125,14 +1108,13 @@ ExprWithCleanups::ExprWithCleanups(Expr *subexpr, SubExpr(subexpr) { ExprWithCleanupsBits.NumObjects = objects.size(); for (unsigned i = 0, e = objects.size(); i != e; ++i) - getObjectsBuffer()[i] = objects[i]; + getTrailingObjects<CleanupObject>()[i] = objects[i]; } ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, Expr *subexpr, ArrayRef<CleanupObject> objects) { - size_t size = sizeof(ExprWithCleanups) - + objects.size() * sizeof(CleanupObject); - void *buffer = C.Allocate(size, llvm::alignOf<ExprWithCleanups>()); + void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(objects.size()), + llvm::alignOf<ExprWithCleanups>()); return new (buffer) ExprWithCleanups(subexpr, objects); } @@ -1144,8 +1126,8 @@ ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects) ExprWithCleanups *ExprWithCleanups::Create(const ASTContext &C, EmptyShell empty, unsigned numObjects) { - size_t size = sizeof(ExprWithCleanups) + numObjects * sizeof(CleanupObject); - void *buffer = C.Allocate(size, llvm::alignOf<ExprWithCleanups>()); + void *buffer = C.Allocate(totalSizeToAlloc<CleanupObject>(numObjects), + llvm::alignOf<ExprWithCleanups>()); return new (buffer) ExprWithCleanups(empty, numObjects); } @@ -1165,7 +1147,7 @@ CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(TypeSourceInfo *Type, LParenLoc(LParenLoc), RParenLoc(RParenLoc), NumArgs(Args.size()) { - Stmt **StoredArgs = reinterpret_cast<Stmt **>(this + 1); + Expr **StoredArgs = getTrailingObjects<Expr *>(); for (unsigned I = 0; I != Args.size(); ++I) { if (Args[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; @@ -1180,16 +1162,14 @@ CXXUnresolvedConstructExpr::Create(const ASTContext &C, SourceLocation LParenLoc, ArrayRef<Expr*> Args, SourceLocation RParenLoc) { - void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + - sizeof(Expr *) * Args.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Args.size())); return new (Mem) CXXUnresolvedConstructExpr(Type, LParenLoc, Args, RParenLoc); } CXXUnresolvedConstructExpr * CXXUnresolvedConstructExpr::CreateEmpty(const ASTContext &C, unsigned NumArgs) { Stmt::EmptyShell Empty; - void *Mem = C.Allocate(sizeof(CXXUnresolvedConstructExpr) + - sizeof(Expr *) * NumArgs); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumArgs)); return new (Mem) CXXUnresolvedConstructExpr(Empty, NumArgs); } @@ -1404,16 +1384,16 @@ SizeOfPackExpr::Create(ASTContext &Context, SourceLocation OperatorLoc, SourceLocation RParenLoc, Optional<unsigned> Length, ArrayRef<TemplateArgument> PartialArgs) { - void *Storage = Context.Allocate( - sizeof(SizeOfPackExpr) + sizeof(TemplateArgument) * PartialArgs.size()); + void *Storage = + Context.Allocate(totalSizeToAlloc<TemplateArgument>(PartialArgs.size())); return new (Storage) SizeOfPackExpr(Context.getSizeType(), OperatorLoc, Pack, PackLoc, RParenLoc, Length, PartialArgs); } SizeOfPackExpr *SizeOfPackExpr::CreateDeserialized(ASTContext &Context, unsigned NumPartialArgs) { - void *Storage = Context.Allocate( - sizeof(SizeOfPackExpr) + sizeof(TemplateArgument) * NumPartialArgs); + void *Storage = + Context.Allocate(totalSizeToAlloc<TemplateArgument>(NumPartialArgs)); return new (Storage) SizeOfPackExpr(EmptyShell(), NumPartialArgs); } @@ -1440,24 +1420,22 @@ FunctionParmPackExpr::FunctionParmPackExpr(QualType T, ParmVarDecl *ParamPack, ParamPack(ParamPack), NameLoc(NameLoc), NumParameters(NumParams) { if (Params) std::uninitialized_copy(Params, Params + NumParams, - reinterpret_cast<ParmVarDecl **>(this + 1)); + getTrailingObjects<ParmVarDecl *>()); } FunctionParmPackExpr * FunctionParmPackExpr::Create(const ASTContext &Context, QualType T, ParmVarDecl *ParamPack, SourceLocation NameLoc, ArrayRef<ParmVarDecl *> Params) { - return new (Context.Allocate(sizeof(FunctionParmPackExpr) + - sizeof(ParmVarDecl*) * Params.size())) - FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data()); + return new (Context.Allocate(totalSizeToAlloc<ParmVarDecl *>(Params.size()))) + FunctionParmPackExpr(T, ParamPack, NameLoc, Params.size(), Params.data()); } FunctionParmPackExpr * FunctionParmPackExpr::CreateEmpty(const ASTContext &Context, unsigned NumParams) { - return new (Context.Allocate(sizeof(FunctionParmPackExpr) + - sizeof(ParmVarDecl*) * NumParams)) - FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr); + return new (Context.Allocate(totalSizeToAlloc<ParmVarDecl *>(NumParams))) + FunctionParmPackExpr(QualType(), nullptr, SourceLocation(), 0, nullptr); } void MaterializeTemporaryExpr::setExtendingDecl(const ValueDecl *ExtendedBy, @@ -1494,8 +1472,8 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind, TypeTraitExprBits.Value = Value; TypeTraitExprBits.NumArgs = Args.size(); - TypeSourceInfo **ToArgs = getTypeSourceInfos(); - + TypeSourceInfo **ToArgs = getTrailingObjects<TypeSourceInfo *>(); + for (unsigned I = 0, N = Args.size(); I != N; ++I) { if (Args[I]->getType()->isDependentType()) setValueDependent(true); @@ -1514,15 +1492,13 @@ TypeTraitExpr *TypeTraitExpr::Create(const ASTContext &C, QualType T, ArrayRef<TypeSourceInfo *> Args, SourceLocation RParenLoc, bool Value) { - unsigned Size = sizeof(TypeTraitExpr) + sizeof(TypeSourceInfo*) * Args.size(); - void *Mem = C.Allocate(Size); + void *Mem = C.Allocate(totalSizeToAlloc<TypeSourceInfo *>(Args.size())); return new (Mem) TypeTraitExpr(T, Loc, Kind, Args, RParenLoc, Value); } TypeTraitExpr *TypeTraitExpr::CreateDeserialized(const ASTContext &C, unsigned NumArgs) { - unsigned Size = sizeof(TypeTraitExpr) + sizeof(TypeSourceInfo*) * NumArgs; - void *Mem = C.Allocate(Size); + void *Mem = C.Allocate(totalSizeToAlloc<TypeSourceInfo *>(NumArgs)); return new (Mem) TypeTraitExpr(EmptyShell()); } diff --git a/contrib/llvm/tools/clang/lib/AST/ExprObjC.cpp b/contrib/llvm/tools/clang/lib/AST/ExprObjC.cpp index 46298c7..0936a81 100644 --- a/contrib/llvm/tools/clang/lib/AST/ExprObjC.cpp +++ b/contrib/llvm/tools/clang/lib/AST/ExprObjC.cpp @@ -39,16 +39,14 @@ ObjCArrayLiteral *ObjCArrayLiteral::Create(const ASTContext &C, ArrayRef<Expr *> Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR) { - void *Mem = - C.Allocate(sizeof(ObjCArrayLiteral) + Elements.size() * sizeof(Expr *)); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(Elements.size())); return new (Mem) ObjCArrayLiteral(Elements, T, Method, SR); } ObjCArrayLiteral *ObjCArrayLiteral::CreateEmpty(const ASTContext &C, unsigned NumElements) { - void *Mem = - C.Allocate(sizeof(ObjCArrayLiteral) + NumElements * sizeof(Expr *)); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumElements)); return new (Mem) ObjCArrayLiteral(EmptyShell(), NumElements); } @@ -60,8 +58,9 @@ ObjCDictionaryLiteral::ObjCDictionaryLiteral(ArrayRef<ObjCDictionaryElement> VK, false, false), NumElements(VK.size()), HasPackExpansions(HasPackExpansions), Range(SR), DictWithObjectsMethod(method) { - KeyValuePair *KeyValues = getKeyValues(); - ExpansionData *Expansions = getExpansionData(); + KeyValuePair *KeyValues = getTrailingObjects<KeyValuePair>(); + ExpansionData *Expansions = + HasPackExpansions ? getTrailingObjects<ExpansionData>() : nullptr; for (unsigned I = 0; I < NumElements; I++) { if (VK[I].Key->isTypeDependent() || VK[I].Key->isValueDependent() || VK[I].Value->isTypeDependent() || VK[I].Value->isValueDependent()) @@ -91,23 +90,16 @@ ObjCDictionaryLiteral::Create(const ASTContext &C, ArrayRef<ObjCDictionaryElement> VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR) { - unsigned ExpansionsSize = 0; - if (HasPackExpansions) - ExpansionsSize = sizeof(ExpansionData) * VK.size(); - - void *Mem = C.Allocate(sizeof(ObjCDictionaryLiteral) + - sizeof(KeyValuePair) * VK.size() + ExpansionsSize); + void *Mem = C.Allocate(totalSizeToAlloc<KeyValuePair, ExpansionData>( + VK.size(), HasPackExpansions ? VK.size() : 0)); return new (Mem) ObjCDictionaryLiteral(VK, HasPackExpansions, T, method, SR); } ObjCDictionaryLiteral * ObjCDictionaryLiteral::CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions) { - unsigned ExpansionsSize = 0; - if (HasPackExpansions) - ExpansionsSize = sizeof(ExpansionData) * NumElements; - void *Mem = C.Allocate(sizeof(ObjCDictionaryLiteral) + - sizeof(KeyValuePair) * NumElements + ExpansionsSize); + void *Mem = C.Allocate(totalSizeToAlloc<KeyValuePair, ExpansionData>( + NumElements, HasPackExpansions ? NumElements : 0)); return new (Mem) ObjCDictionaryLiteral(EmptyShell(), NumElements, HasPackExpansions); } @@ -122,15 +114,6 @@ QualType ObjCPropertyRefExpr::getReceiverType(const ASTContext &ctx) const { return getBase()->getType(); } -ObjCSubscriptRefExpr * -ObjCSubscriptRefExpr::Create(const ASTContext &C, Expr *base, Expr *key, - QualType T, ObjCMethodDecl *getMethod, - ObjCMethodDecl *setMethod, SourceLocation RB) { - void *Mem = C.Allocate(sizeof(ObjCSubscriptRefExpr)); - return new (Mem) ObjCSubscriptRefExpr( - base, key, T, VK_LValue, OK_ObjCSubscript, getMethod, setMethod, RB); -} - ObjCMessageExpr::ObjCMessageExpr(QualType T, ExprValueKind VK, SourceLocation LBracLoc, SourceLocation SuperLoc, bool IsInstanceSuper, @@ -293,11 +276,9 @@ ObjCMessageExpr *ObjCMessageExpr::alloc(const ASTContext &C, ObjCMessageExpr *ObjCMessageExpr::alloc(const ASTContext &C, unsigned NumArgs, unsigned NumStoredSelLocs) { - unsigned Size = sizeof(ObjCMessageExpr) + sizeof(void *) + - NumArgs * sizeof(Expr *) + - NumStoredSelLocs * sizeof(SourceLocation); return (ObjCMessageExpr *)C.Allocate( - Size, llvm::AlignOf<ObjCMessageExpr>::Alignment); + totalSizeToAlloc<void *, SourceLocation>(NumArgs + 1, NumStoredSelLocs), + llvm::AlignOf<ObjCMessageExpr>::Alignment); } void ObjCMessageExpr::getSelectorLocs( @@ -358,7 +339,7 @@ ObjCInterfaceDecl *ObjCMessageExpr::getReceiverInterface() const { Stmt::child_range ObjCMessageExpr::children() { Stmt **begin; if (getReceiverKind() == Instance) - begin = reinterpret_cast<Stmt **>(this + 1); + begin = reinterpret_cast<Stmt **>(getTrailingObjects<void *>()); else begin = reinterpret_cast<Stmt **>(getArgs()); return child_range(begin, diff --git a/contrib/llvm/tools/clang/lib/AST/MicrosoftMangle.cpp b/contrib/llvm/tools/clang/lib/AST/MicrosoftMangle.cpp index 136a43b..d45232b 100644 --- a/contrib/llvm/tools/clang/lib/AST/MicrosoftMangle.cpp +++ b/contrib/llvm/tools/clang/lib/AST/MicrosoftMangle.cpp @@ -127,8 +127,6 @@ public: CXXCtorType CT, uint32_t Size, uint32_t NVOffset, int32_t VBPtrOffset, uint32_t VBIndex, raw_ostream &Out) override; - void mangleCXXCatchHandlerType(QualType T, uint32_t Flags, - raw_ostream &Out) override; void mangleCXXRTTI(QualType T, raw_ostream &Out) override; void mangleCXXRTTIName(QualType T, raw_ostream &Out) override; void mangleCXXRTTIBaseClassDescriptor(const CXXRecordDecl *Derived, @@ -221,7 +219,7 @@ class MicrosoftCXXNameMangler { typedef llvm::SmallVector<std::string, 10> BackRefVec; BackRefVec NameBackReferences; - typedef llvm::DenseMap<void *, unsigned> ArgBackRefMap; + typedef llvm::DenseMap<const void *, unsigned> ArgBackRefMap; ArgBackRefMap TypeBackReferences; typedef std::set<int> PassObjectSizeArgsSet; @@ -1489,7 +1487,7 @@ void MicrosoftCXXNameMangler::manglePassObjectSizeArg( int Type = POSA->getType(); auto Iter = PassObjectSizeArgs.insert(Type).first; - void *TypePtr = (void *)&*Iter; + auto *TypePtr = (const void *)&*Iter; ArgBackRefMap::iterator Found = TypeBackReferences.find(TypePtr); if (Found == TypeBackReferences.end()) { @@ -2215,7 +2213,8 @@ void MicrosoftCXXNameMangler::mangleType(const ObjCObjectPointerType *T, void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T, Qualifiers Quals, SourceRange Range) { QualType PointeeType = T->getPointeeType(); - Out << (Quals.hasVolatile() ? 'B' : 'A'); + assert(!Quals.hasConst() && !Quals.hasVolatile() && "unexpected qualifier!"); + Out << 'A'; manglePointerExtQualifiers(Quals, PointeeType); mangleType(PointeeType, Range); } @@ -2226,7 +2225,8 @@ void MicrosoftCXXNameMangler::mangleType(const LValueReferenceType *T, void MicrosoftCXXNameMangler::mangleType(const RValueReferenceType *T, Qualifiers Quals, SourceRange Range) { QualType PointeeType = T->getPointeeType(); - Out << (Quals.hasVolatile() ? "$$R" : "$$Q"); + assert(!Quals.hasConst() && !Quals.hasVolatile() && "unexpected qualifier!"); + Out << "$$Q"; manglePointerExtQualifiers(Quals, PointeeType); mangleType(PointeeType, Range); } @@ -2620,15 +2620,6 @@ void MicrosoftMangleContextImpl::mangleCXXRTTIName(QualType T, Mangler.mangleType(T, SourceRange(), MicrosoftCXXNameMangler::QMM_Result); } -void MicrosoftMangleContextImpl::mangleCXXCatchHandlerType(QualType T, - uint32_t Flags, - raw_ostream &Out) { - MicrosoftCXXNameMangler Mangler(*this, Out); - Mangler.getStream() << "llvm.eh.handlertype."; - Mangler.mangleType(T, SourceRange(), MicrosoftCXXNameMangler::QMM_Result); - Mangler.getStream() << '.' << Flags; -} - void MicrosoftMangleContextImpl::mangleCXXVirtualDisplacementMap( const CXXRecordDecl *SrcRD, const CXXRecordDecl *DstRD, raw_ostream &Out) { MicrosoftCXXNameMangler Mangler(*this, Out); diff --git a/contrib/llvm/tools/clang/lib/AST/OpenMPClause.cpp b/contrib/llvm/tools/clang/lib/AST/OpenMPClause.cpp index cd60d37..1ef43f7 100644 --- a/contrib/llvm/tools/clang/lib/AST/OpenMPClause.cpp +++ b/contrib/llvm/tools/clang/lib/AST/OpenMPClause.cpp @@ -40,9 +40,7 @@ OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL) { // Allocate space for private variables and initializer expressions. - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPPrivateClause), - llvm::alignOf<Expr *>()) + - 2 * sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * VL.size())); OMPPrivateClause *Clause = new (Mem) OMPPrivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -52,9 +50,7 @@ OMPPrivateClause::Create(const ASTContext &C, SourceLocation StartLoc, OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPPrivateClause), - llvm::alignOf<Expr *>()) + - 2 * sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(2 * N)); return new (Mem) OMPPrivateClause(N); } @@ -75,9 +71,7 @@ OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> PrivateVL, ArrayRef<Expr *> InitVL) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFirstprivateClause), - llvm::alignOf<Expr *>()) + - 3 * sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * VL.size())); OMPFirstprivateClause *Clause = new (Mem) OMPFirstprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -88,9 +82,7 @@ OMPFirstprivateClause::Create(const ASTContext &C, SourceLocation StartLoc, OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFirstprivateClause), - llvm::alignOf<Expr *>()) + - 3 * sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(3 * N)); return new (Mem) OMPFirstprivateClause(N); } @@ -126,9 +118,7 @@ OMPLastprivateClause *OMPLastprivateClause::Create( const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLastprivateClause), - llvm::alignOf<Expr *>()) + - 5 * sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); OMPLastprivateClause *Clause = new (Mem) OMPLastprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -140,9 +130,7 @@ OMPLastprivateClause *OMPLastprivateClause::Create( OMPLastprivateClause *OMPLastprivateClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLastprivateClause), - llvm::alignOf<Expr *>()) + - 5 * sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); return new (Mem) OMPLastprivateClause(N); } @@ -151,9 +139,7 @@ OMPSharedClause *OMPSharedClause::Create(const ASTContext &C, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPSharedClause), - llvm::alignOf<Expr *>()) + - sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); OMPSharedClause *Clause = new (Mem) OMPSharedClause(StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -161,9 +147,7 @@ OMPSharedClause *OMPSharedClause::Create(const ASTContext &C, } OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPSharedClause), - llvm::alignOf<Expr *>()) + - sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); return new (Mem) OMPSharedClause(N); } @@ -198,9 +182,7 @@ OMPLinearClause *OMPLinearClause::Create( ArrayRef<Expr *> PL, ArrayRef<Expr *> IL, Expr *Step, Expr *CalcStep) { // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions // (Step and CalcStep). - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLinearClause), - llvm::alignOf<Expr *>()) + - (5 * VL.size() + 2) * sizeof(Expr *)); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size() + 2)); OMPLinearClause *Clause = new (Mem) OMPLinearClause( StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -221,9 +203,7 @@ OMPLinearClause *OMPLinearClause::CreateEmpty(const ASTContext &C, unsigned NumVars) { // Allocate space for 4 lists (Vars, Inits, Updates, Finals) and 2 expressions // (Step and CalcStep). - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPLinearClause), - llvm::alignOf<Expr *>()) + - (5 * NumVars + 2) * sizeof(Expr *)); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * NumVars + 2)); return new (Mem) OMPLinearClause(NumVars); } @@ -231,9 +211,7 @@ OMPAlignedClause * OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, Expr *A) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPAlignedClause), - llvm::alignOf<Expr *>()) + - sizeof(Expr *) * (VL.size() + 1)); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size() + 1)); OMPAlignedClause *Clause = new (Mem) OMPAlignedClause(StartLoc, LParenLoc, ColonLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -243,9 +221,7 @@ OMPAlignedClause::Create(const ASTContext &C, SourceLocation StartLoc, OMPAlignedClause *OMPAlignedClause::CreateEmpty(const ASTContext &C, unsigned NumVars) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPAlignedClause), - llvm::alignOf<Expr *>()) + - sizeof(Expr *) * (NumVars + 1)); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(NumVars + 1)); return new (Mem) OMPAlignedClause(NumVars); } @@ -275,9 +251,7 @@ OMPCopyinClause *OMPCopyinClause::Create( const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyinClause), - llvm::alignOf<Expr *>()) + - 4 * sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size())); OMPCopyinClause *Clause = new (Mem) OMPCopyinClause(StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -288,9 +262,7 @@ OMPCopyinClause *OMPCopyinClause::Create( } OMPCopyinClause *OMPCopyinClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyinClause), - llvm::alignOf<Expr *>()) + - 4 * sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N)); return new (Mem) OMPCopyinClause(N); } @@ -320,9 +292,7 @@ OMPCopyprivateClause *OMPCopyprivateClause::Create( const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs, ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyprivateClause), - llvm::alignOf<Expr *>()) + - 4 * sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * VL.size())); OMPCopyprivateClause *Clause = new (Mem) OMPCopyprivateClause(StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -334,9 +304,7 @@ OMPCopyprivateClause *OMPCopyprivateClause::Create( OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPCopyprivateClause), - llvm::alignOf<Expr *>()) + - 4 * sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(4 * N)); return new (Mem) OMPCopyprivateClause(N); } @@ -373,9 +341,7 @@ OMPReductionClause *OMPReductionClause::Create( NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, ArrayRef<Expr *> Privates, ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs, ArrayRef<Expr *> ReductionOps) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPReductionClause), - llvm::alignOf<Expr *>()) + - 5 * sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * VL.size())); OMPReductionClause *Clause = new (Mem) OMPReductionClause( StartLoc, LParenLoc, EndLoc, ColonLoc, VL.size(), QualifierLoc, NameInfo); Clause->setVarRefs(VL); @@ -388,9 +354,7 @@ OMPReductionClause *OMPReductionClause::Create( OMPReductionClause *OMPReductionClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPReductionClause), - llvm::alignOf<Expr *>()) + - 5 * sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(5 * N)); return new (Mem) OMPReductionClause(N); } @@ -399,9 +363,7 @@ OMPFlushClause *OMPFlushClause::Create(const ASTContext &C, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef<Expr *> VL) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFlushClause), - llvm::alignOf<Expr *>()) + - sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); OMPFlushClause *Clause = new (Mem) OMPFlushClause(StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -409,9 +371,7 @@ OMPFlushClause *OMPFlushClause::Create(const ASTContext &C, } OMPFlushClause *OMPFlushClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPFlushClause), - llvm::alignOf<Expr *>()) + - sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); return new (Mem) OMPFlushClause(N); } @@ -420,9 +380,7 @@ OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPDependClauseKind DepKind, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VL) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPDependClause), - llvm::alignOf<Expr *>()) + - sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); OMPDependClause *Clause = new (Mem) OMPDependClause(StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -433,9 +391,7 @@ OMPDependClause::Create(const ASTContext &C, SourceLocation StartLoc, } OMPDependClause *OMPDependClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate(llvm::RoundUpToAlignment(sizeof(OMPDependClause), - llvm::alignOf<Expr *>()) + - sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); return new (Mem) OMPDependClause(N); } @@ -445,9 +401,7 @@ OMPMapClause *OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc, OpenMPMapClauseKind TypeModifier, OpenMPMapClauseKind Type, SourceLocation TypeLoc) { - void *Mem = C.Allocate( - llvm::RoundUpToAlignment(sizeof(OMPMapClause), llvm::alignOf<Expr *>()) + - sizeof(Expr *) * VL.size()); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(VL.size())); OMPMapClause *Clause = new (Mem) OMPMapClause( TypeModifier, Type, TypeLoc, StartLoc, LParenLoc, EndLoc, VL.size()); Clause->setVarRefs(VL); @@ -458,8 +412,6 @@ OMPMapClause *OMPMapClause::Create(const ASTContext &C, SourceLocation StartLoc, } OMPMapClause *OMPMapClause::CreateEmpty(const ASTContext &C, unsigned N) { - void *Mem = C.Allocate( - llvm::RoundUpToAlignment(sizeof(OMPMapClause), llvm::alignOf<Expr *>()) + - sizeof(Expr *) * N); + void *Mem = C.Allocate(totalSizeToAlloc<Expr *>(N)); return new (Mem) OMPMapClause(N); } |