diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Sema/TreeTransform.h')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Sema/TreeTransform.h | 732 |
1 files changed, 609 insertions, 123 deletions
diff --git a/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h b/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h index 6e193a3..e0a9653 100644 --- a/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h +++ b/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h @@ -21,6 +21,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/AST/ExprObjC.h" +#include "clang/AST/ExprOpenMP.h" #include "clang/AST/Stmt.h" #include "clang/AST/StmtCXX.h" #include "clang/AST/StmtObjC.h" @@ -390,7 +391,7 @@ public: /// due to transformation. /// /// \returns true if an error occurred, false otherwise. - bool TransformExprs(Expr **Inputs, unsigned NumInputs, bool IsCall, + bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, SmallVectorImpl<Expr *> &Outputs, bool *ArgChanged = nullptr); @@ -503,7 +504,8 @@ public: /// /// Returns true if there was an error. bool TransformTemplateArgument(const TemplateArgumentLoc &Input, - TemplateArgumentLoc &Output); + TemplateArgumentLoc &Output, + bool Uneval = false); /// \brief Transform the given set of template arguments. /// @@ -525,8 +527,10 @@ public: /// Returns true if an error occurred. bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, unsigned NumInputs, - TemplateArgumentListInfo &Outputs) { - return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs); + TemplateArgumentListInfo &Outputs, + bool Uneval = false) { + return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs, + Uneval); } /// \brief Transform the given set of template arguments. @@ -546,7 +550,8 @@ public: template<typename InputIterator> bool TransformTemplateArguments(InputIterator First, InputIterator Last, - TemplateArgumentListInfo &Outputs); + TemplateArgumentListInfo &Outputs, + bool Uneval = false); /// \brief Fakes up a TemplateArgumentLoc for a given TemplateArgument. void InventTemplateArgumentLoc(const TemplateArgument &Arg, @@ -843,11 +848,11 @@ public: /// \brief Build a new C++11 auto type. /// /// By default, builds a new AutoType with the given deduced type. - QualType RebuildAutoType(QualType Deduced, bool IsDecltypeAuto) { + QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword) { // Note, IsDependent is always false here: we implicitly convert an 'auto' // which has been deduced to a dependent type into an undeduced 'auto', so // that we'll retry deduction after the transformation. - return SemaRef.Context.getAutoType(Deduced, IsDecltypeAuto, + return SemaRef.Context.getAutoType(Deduced, Keyword, /*IsDependent*/ false); } @@ -1282,6 +1287,30 @@ public: Constraints, Clobbers, Exprs, EndLoc); } + /// \brief Build a new co_return statement. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result) { + return getSema().BuildCoreturnStmt(CoreturnLoc, Result); + } + + /// \brief Build a new co_await expression. + /// + /// By default, performs semantic analysis to build the new expression. + /// Subclasses may override this routine to provide different behavior. + ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result) { + return getSema().BuildCoawaitExpr(CoawaitLoc, Result); + } + + /// \brief Build a new co_yield expression. + /// + /// By default, performs semantic analysis to build the new expression. + /// Subclasses may override this routine to provide different behavior. + ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result) { + return getSema().BuildCoyieldExpr(CoyieldLoc, Result); + } + /// \brief Build a new Objective-C \@try statement. /// /// By default, performs semantic analysis to build the new statement. @@ -1354,12 +1383,15 @@ public: /// /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. - OMPClause *RebuildOMPIfClause(Expr *Condition, - SourceLocation StartLoc, + OMPClause *RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, + Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation NameModifierLoc, + SourceLocation ColonLoc, SourceLocation EndLoc) { - return getSema().ActOnOpenMPIfClause(Condition, StartLoc, - LParenLoc, EndLoc); + return getSema().ActOnOpenMPIfClause(NameModifier, Condition, StartLoc, + LParenLoc, NameModifierLoc, ColonLoc, + EndLoc); } /// \brief Build a new OpenMP 'final' clause. @@ -1395,6 +1427,16 @@ public: return getSema().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc, EndLoc); } + /// \brief Build a new OpenMP 'simdlen' clause. + /// + /// By default, performs semantic analysis to build the new OpenMP clause. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc, EndLoc); + } + /// \brief Build a new OpenMP 'collapse' clause. /// /// By default, performs semantic analysis to build the new OpenMP clause. @@ -1436,15 +1478,24 @@ public: /// /// By default, performs semantic analysis to build the new OpenMP clause. /// Subclasses may override this routine to provide different behavior. - OMPClause *RebuildOMPScheduleClause(OpenMPScheduleClauseKind Kind, - Expr *ChunkSize, - SourceLocation StartLoc, - SourceLocation LParenLoc, - SourceLocation KindLoc, - SourceLocation CommaLoc, - SourceLocation EndLoc) { + OMPClause *RebuildOMPScheduleClause( + OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, + OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, + SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, + SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) { return getSema().ActOnOpenMPScheduleClause( - Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc); + M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc, + CommaLoc, EndLoc); + } + + /// \brief Build a new OpenMP 'ordered' clause. + /// + /// By default, performs semantic analysis to build the new OpenMP clause. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPOrderedClause(SourceLocation StartLoc, + SourceLocation EndLoc, + SourceLocation LParenLoc, Expr *Num) { + return getSema().ActOnOpenMPOrderedClause(StartLoc, EndLoc, LParenLoc, Num); } /// \brief Build a new OpenMP 'private' clause. @@ -1518,10 +1569,13 @@ public: OMPClause *RebuildOMPLinearClause(ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, + OpenMPLinearClauseKind Modifier, + SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc) { return getSema().ActOnOpenMPLinearClause(VarList, Step, StartLoc, LParenLoc, - ColonLoc, EndLoc); + Modifier, ModifierLoc, ColonLoc, + EndLoc); } /// \brief Build a new OpenMP 'aligned' clause. @@ -1586,6 +1640,97 @@ public: StartLoc, LParenLoc, EndLoc); } + /// \brief Build a new OpenMP 'device' clause. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPDeviceClause(Expr *Device, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPDeviceClause(Device, StartLoc, LParenLoc, + EndLoc); + } + + /// \brief Build a new OpenMP 'map' clause. + /// + /// By default, performs semantic analysis to build the new OpenMP clause. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPMapClause( + OpenMPMapClauseKind MapTypeModifier, OpenMPMapClauseKind MapType, + SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, + SourceLocation StartLoc, SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType, MapLoc, + ColonLoc, VarList,StartLoc, + LParenLoc, EndLoc); + } + + /// \brief Build a new OpenMP 'num_teams' clause. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc, LParenLoc, + EndLoc); + } + + /// \brief Build a new OpenMP 'thread_limit' clause. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPThreadLimitClause(Expr *ThreadLimit, + SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPThreadLimitClause(ThreadLimit, StartLoc, + LParenLoc, EndLoc); + } + + /// \brief Build a new OpenMP 'priority' clause. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPPriorityClause(Priority, StartLoc, LParenLoc, + EndLoc); + } + + /// \brief Build a new OpenMP 'grainsize' clause. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPGrainsizeClause(Expr *Grainsize, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPGrainsizeClause(Grainsize, StartLoc, LParenLoc, + EndLoc); + } + + /// \brief Build a new OpenMP 'num_tasks' clause. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPNumTasksClause(Expr *NumTasks, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPNumTasksClause(NumTasks, StartLoc, LParenLoc, + EndLoc); + } + + /// \brief Build a new OpenMP 'hint' clause. + /// + /// By default, performs semantic analysis to build the new statement. + /// Subclasses may override this routine to provide different behavior. + OMPClause *RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, + SourceLocation LParenLoc, + SourceLocation EndLoc) { + return getSema().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc, EndLoc); + } + /// \brief Rebuild the operand to an Objective-C \@synchronized statement. /// /// By default, performs semantic analysis to build the new statement. @@ -1673,6 +1818,7 @@ public: /// By default, performs semantic analysis to build the new statement. /// Subclasses may override this routine to provide different behavior. StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc, + SourceLocation CoawaitLoc, SourceLocation ColonLoc, Stmt *Range, Stmt *BeginEnd, Expr *Cond, Expr *Inc, @@ -1695,7 +1841,8 @@ public: } } - return getSema().BuildCXXForRangeStmt(ForLoc, ColonLoc, Range, BeginEnd, + return getSema().BuildCXXForRangeStmt(ForLoc, CoawaitLoc, ColonLoc, + Range, BeginEnd, Cond, Inc, LoopVar, RParenLoc, Sema::BFRK_Rebuild); } @@ -1808,12 +1955,11 @@ public: /// By default, performs semantic analysis to build the new expression. /// Subclasses may override this routine to provide different behavior. ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, - TypeSourceInfo *Type, - Sema::OffsetOfComponent *Components, - unsigned NumComponents, - SourceLocation RParenLoc) { + TypeSourceInfo *Type, + ArrayRef<Sema::OffsetOfComponent> Components, + SourceLocation RParenLoc) { return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components, - NumComponents, RParenLoc); + RParenLoc); } /// \brief Build a new sizeof, alignof or vec_step expression with a @@ -1857,6 +2003,18 @@ public: RBracketLoc); } + /// \brief Build a new array section expression. + /// + /// By default, performs semantic analysis to build the new expression. + /// Subclasses may override this routine to provide different behavior. + ExprResult RebuildOMPArraySectionExpr(Expr *Base, SourceLocation LBracketLoc, + Expr *LowerBound, + SourceLocation ColonLoc, Expr *Length, + SourceLocation RBracketLoc) { + return getSema().ActOnOMPArraySectionExpr(Base, LBracketLoc, LowerBound, + ColonLoc, Length, RBracketLoc); + } + /// \brief Build a new call expression. /// /// By default, performs semantic analysis to build the new expression. @@ -1921,7 +2079,8 @@ public: return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow, SS, TemplateKWLoc, FirstQualifierInScope, - R, ExplicitTemplateArgs); + R, ExplicitTemplateArgs, + /*S*/nullptr); } /// \brief Build a new binary operator expression. @@ -1987,7 +2146,8 @@ public: SS, SourceLocation(), /*FirstQualifierInScope*/ nullptr, NameInfo, - /* TemplateArgs */ nullptr); + /* TemplateArgs */ nullptr, + /*S*/ nullptr); } /// \brief Build a new initializer list expression. @@ -2435,7 +2595,7 @@ public: TemplateArgs); return getSema().BuildQualifiedDeclarationNameExpr( - SS, NameInfo, IsAddressOfOperand, RecoveryTSI); + SS, NameInfo, IsAddressOfOperand, /*S*/nullptr, RecoveryTSI); } /// \brief Build a new template-id expression. @@ -2529,7 +2689,7 @@ public: SS, TemplateKWLoc, FirstQualifierInScope, MemberNameInfo, - TemplateArgs); + TemplateArgs, /*S*/nullptr); } /// \brief Build a new member reference expression. @@ -2551,7 +2711,7 @@ public: OperatorLoc, IsArrow, SS, TemplateKWLoc, FirstQualifierInScope, - R, TemplateArgs); + R, TemplateArgs, /*S*/nullptr); } /// \brief Build a new noexcept expression. @@ -2563,18 +2723,14 @@ public: } /// \brief Build a new expression to compute the length of a parameter pack. - ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, + ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, + NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, - Optional<unsigned> Length) { - if (Length) - return new (SemaRef.Context) SizeOfPackExpr(SemaRef.Context.getSizeType(), - OperatorLoc, Pack, PackLoc, - RParenLoc, *Length); - - return new (SemaRef.Context) SizeOfPackExpr(SemaRef.Context.getSizeType(), - OperatorLoc, Pack, PackLoc, - RParenLoc); + Optional<unsigned> Length, + ArrayRef<TemplateArgument> PartialArgs) { + return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc, + RParenLoc, Length, PartialArgs); } /// \brief Build a new Objective-C boxed expression. @@ -2608,9 +2764,8 @@ public: /// By default, performs semantic analysis to build the new expression. /// Subclasses may override this routine to provide different behavior. ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, - ObjCDictionaryElement *Elements, - unsigned NumElements) { - return getSema().BuildObjCDictionaryLiteral(Range, Elements, NumElements); + MutableArrayRef<ObjCDictionaryElement> Elements) { + return getSema().BuildObjCDictionaryLiteral(Range, Elements); } /// \brief Build a new Objective-C \@encode expression. @@ -2657,20 +2812,18 @@ public: ExprResult RebuildObjCMessageExpr(SourceLocation SuperLoc, Selector Sel, ArrayRef<SourceLocation> SelectorLocs, + QualType SuperType, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc) { - ObjCInterfaceDecl *Class = Method->getClassInterface(); - QualType ReceiverTy = SemaRef.Context.getObjCInterfaceType(Class); - return Method->isInstanceMethod() ? SemaRef.BuildInstanceMessage(nullptr, - ReceiverTy, + SuperType, SuperLoc, Sel, Method, LBracLoc, SelectorLocs, RBracLoc, Args) : SemaRef.BuildClassMessage(nullptr, - ReceiverTy, + SuperType, SuperLoc, Sel, Method, LBracLoc, SelectorLocs, RBracLoc, Args); @@ -2693,7 +2846,8 @@ public: SS, SourceLocation(), /*FirstQualifierInScope=*/nullptr, NameInfo, - /*TemplateArgs=*/nullptr); + /*TemplateArgs=*/nullptr, + /*S=*/nullptr); } /// \brief Build a new Objective-C property reference expression. @@ -2711,7 +2865,8 @@ public: SS, SourceLocation(), /*FirstQualifierInScope=*/nullptr, NameInfo, - /*TemplateArgs=*/nullptr); + /*TemplateArgs=*/nullptr, + /*S=*/nullptr); } /// \brief Build a new Objective-C property reference expression. @@ -2743,7 +2898,8 @@ public: SS, SourceLocation(), /*FirstQualifierInScope=*/nullptr, NameInfo, - /*TemplateArgs=*/nullptr); + /*TemplateArgs=*/nullptr, + /*S=*/nullptr); } /// \brief Build a new shuffle vector expression. @@ -3043,7 +3199,7 @@ ExprResult TreeTransform<Derived>::TransformInitializer(Expr *Init, } template<typename Derived> -bool TreeTransform<Derived>::TransformExprs(Expr **Inputs, +bool TreeTransform<Derived>::TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, SmallVectorImpl<Expr *> &Outputs, @@ -3458,7 +3614,7 @@ void TreeTransform<Derived>::InventTemplateArgumentLoc( template<typename Derived> bool TreeTransform<Derived>::TransformTemplateArgument( const TemplateArgumentLoc &Input, - TemplateArgumentLoc &Output) { + TemplateArgumentLoc &Output, bool Uneval) { const TemplateArgument &Arg = Input.getArgument(); switch (Arg.getKind()) { case TemplateArgument::Null: @@ -3506,8 +3662,8 @@ bool TreeTransform<Derived>::TransformTemplateArgument( case TemplateArgument::Expression: { // Template argument expressions are constant expressions. - EnterExpressionEvaluationContext Unevaluated(getSema(), - Sema::ConstantEvaluated); + EnterExpressionEvaluationContext Unevaluated( + getSema(), Uneval ? Sema::Unevaluated : Sema::ConstantEvaluated); Expr *InputExpr = Input.getSourceExpression(); if (!InputExpr) InputExpr = Input.getArgument().getAsExpr(); @@ -3585,9 +3741,9 @@ public: template<typename Derived> template<typename InputIterator> -bool TreeTransform<Derived>::TransformTemplateArguments(InputIterator First, - InputIterator Last, - TemplateArgumentListInfo &Outputs) { +bool TreeTransform<Derived>::TransformTemplateArguments( + InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, + bool Uneval) { for (; First != Last; ++First) { TemplateArgumentLoc Out; TemplateArgumentLoc In = *First; @@ -3605,7 +3761,7 @@ bool TreeTransform<Derived>::TransformTemplateArguments(InputIterator First, In.getArgument().pack_begin()), PackLocIterator(*this, In.getArgument().pack_end()), - Outputs)) + Outputs, Uneval)) return true; continue; @@ -3643,7 +3799,7 @@ bool TreeTransform<Derived>::TransformTemplateArguments(InputIterator First, // expansion. TemplateArgumentLoc OutPattern; Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); - if (getDerived().TransformTemplateArgument(Pattern, OutPattern)) + if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval)) return true; Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis, @@ -3660,7 +3816,7 @@ bool TreeTransform<Derived>::TransformTemplateArguments(InputIterator First, for (unsigned I = 0; I != *NumExpansions; ++I) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); - if (getDerived().TransformTemplateArgument(Pattern, Out)) + if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval)) return true; if (Out.getArgument().containsUnexpandedParameterPack()) { @@ -3678,7 +3834,7 @@ bool TreeTransform<Derived>::TransformTemplateArguments(InputIterator First, if (RetainExpansion) { ForgetPartiallySubstitutedPackRAII Forget(getDerived()); - if (getDerived().TransformTemplateArgument(Pattern, Out)) + if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval)) return true; Out = getDerived().RebuildPackExpansion(Out, Ellipsis, @@ -3693,7 +3849,7 @@ bool TreeTransform<Derived>::TransformTemplateArguments(InputIterator First, } // The simple case: - if (getDerived().TransformTemplateArgument(In, Out)) + if (getDerived().TransformTemplateArgument(In, Out, Uneval)) return true; Outputs.addArgument(Out); @@ -3810,7 +3966,7 @@ TreeTransform<Derived>::TransformQualifiedType(TypeLocBuilder &TLB, Qs.removeObjCLifetime(); Deduced = SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs); - Result = SemaRef.Context.getAutoType(Deduced, AutoTy->isDecltypeAuto(), + Result = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(), AutoTy->isDependentType()); TLB.TypeWasModifiedSafely(Result); } else { @@ -4700,9 +4856,7 @@ QualType TreeTransform<Derived>::TransformFunctionProtoType( QualType Result = TL.getType(); if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() || - T->getNumParams() != ParamTypes.size() || - !std::equal(T->param_type_begin(), T->param_type_end(), - ParamTypes.begin()) || EPIChanged) { + T->getParamTypes() != llvm::makeArrayRef(ParamTypes) || EPIChanged) { Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI); if (Result.isNull()) return QualType(); @@ -5015,7 +5169,7 @@ QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB, QualType Result = TL.getType(); if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced || T->isDependentType()) { - Result = getDerived().RebuildAutoType(NewDeduced, T->isDecltypeAuto()); + Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword()); if (Result.isNull()) return QualType(); } @@ -6119,6 +6273,11 @@ TreeTransform<Derived>::TransformForStmt(ForStmt *S) { if (Init.isInvalid()) return StmtError(); + // In OpenMP loop region loop control variable must be captured and be + // private. Perform analysis of first part (if any). + if (getSema().getLangOpts().OpenMP && Init.isUsable()) + getSema().ActOnOpenMPLoopInitialization(S->getForLoc(), Init.get()); + // Transform the condition ExprResult Cond; VarDecl *ConditionVar = nullptr; @@ -6351,6 +6510,56 @@ TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) { TransformedExprs, S->getEndLoc()); } +// C++ Coroutines TS + +template<typename Derived> +StmtResult +TreeTransform<Derived>::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) { + // The coroutine body should be re-formed by the caller if necessary. + return getDerived().TransformStmt(S->getBody()); +} + +template<typename Derived> +StmtResult +TreeTransform<Derived>::TransformCoreturnStmt(CoreturnStmt *S) { + ExprResult Result = getDerived().TransformInitializer(S->getOperand(), + /*NotCopyInit*/false); + if (Result.isInvalid()) + return StmtError(); + + // Always rebuild; we don't know if this needs to be injected into a new + // context or if the promise type has changed. + return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get()); +} + +template<typename Derived> +ExprResult +TreeTransform<Derived>::TransformCoawaitExpr(CoawaitExpr *E) { + ExprResult Result = getDerived().TransformInitializer(E->getOperand(), + /*NotCopyInit*/false); + if (Result.isInvalid()) + return ExprError(); + + // Always rebuild; we don't know if this needs to be injected into a new + // context or if the promise type has changed. + return getDerived().RebuildCoawaitExpr(E->getKeywordLoc(), Result.get()); +} + +template<typename Derived> +ExprResult +TreeTransform<Derived>::TransformCoyieldExpr(CoyieldExpr *E) { + ExprResult Result = getDerived().TransformInitializer(E->getOperand(), + /*NotCopyInit*/false); + if (Result.isInvalid()) + return ExprError(); + + // Always rebuild; we don't know if this needs to be injected into a new + // context or if the promise type has changed. + return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get()); +} + +// Objective-C Statements. + template<typename Derived> StmtResult TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) { @@ -6640,6 +6849,7 @@ TreeTransform<Derived>::TransformCXXForRangeStmt(CXXForRangeStmt *S) { Inc.get() != S->getInc() || LoopVar.get() != S->getLoopVarStmt()) { NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(), + S->getCoawaitLoc(), S->getColonLoc(), Range.get(), BeginEnd.get(), Cond.get(), Inc.get(), LoopVar.get(), @@ -6656,6 +6866,7 @@ TreeTransform<Derived>::TransformCXXForRangeStmt(CXXForRangeStmt *S) { // it now so we have a new statement to attach the body to. if (Body.get() != S->getBody() && NewStmt.get() == S) { NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(), + S->getCoawaitLoc(), S->getColonLoc(), Range.get(), BeginEnd.get(), Cond.get(), Inc.get(), LoopVar.get(), @@ -6766,6 +6977,25 @@ TreeTransform<Derived>::TransformMSPropertyRefExpr(MSPropertyRefExpr *E) { } template <typename Derived> +ExprResult TreeTransform<Derived>::TransformMSPropertySubscriptExpr( + MSPropertySubscriptExpr *E) { + auto BaseRes = getDerived().TransformExpr(E->getBase()); + if (BaseRes.isInvalid()) + return ExprError(); + auto IdxRes = getDerived().TransformExpr(E->getIdx()); + if (IdxRes.isInvalid()) + return ExprError(); + + if (!getDerived().AlwaysRebuild() && + BaseRes.get() == E->getBase() && + IdxRes.get() == E->getIdx()) + return E; + + return getDerived().RebuildArraySubscriptExpr( + BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc()); +} + +template <typename Derived> StmtResult TreeTransform<Derived>::TransformSEHTryStmt(SEHTryStmt *S) { StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock()); if (TryBlock.isInvalid()) @@ -6844,10 +7074,7 @@ StmtResult TreeTransform<Derived>::TransformOMPExecutableDirective( } } StmtResult AssociatedStmt; - if (D->hasAssociatedStmt()) { - if (!D->getAssociatedStmt()) { - return StmtError(); - } + if (D->hasAssociatedStmt() && D->getAssociatedStmt()) { getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(), /*CurScope=*/nullptr); StmtResult Body; @@ -7115,6 +7342,17 @@ TreeTransform<Derived>::TransformOMPTargetDirective(OMPTargetDirective *D) { } template <typename Derived> +StmtResult TreeTransform<Derived>::TransformOMPTargetDataDirective( + OMPTargetDataDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_target_data, DirName, nullptr, + D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + +template <typename Derived> StmtResult TreeTransform<Derived>::TransformOMPTeamsDirective(OMPTeamsDirective *D) { DeclarationNameInfo DirName; @@ -7147,6 +7385,39 @@ TreeTransform<Derived>::TransformOMPCancelDirective(OMPCancelDirective *D) { return Res; } +template <typename Derived> +StmtResult +TreeTransform<Derived>::TransformOMPTaskLoopDirective(OMPTaskLoopDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop, DirName, nullptr, + D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + +template <typename Derived> +StmtResult TreeTransform<Derived>::TransformOMPTaskLoopSimdDirective( + OMPTaskLoopSimdDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop_simd, DirName, + nullptr, D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + +template <typename Derived> +StmtResult TreeTransform<Derived>::TransformOMPDistributeDirective( + OMPDistributeDirective *D) { + DeclarationNameInfo DirName; + getDerived().getSema().StartOpenMPDSABlock(OMPD_distribute, DirName, nullptr, + D->getLocStart()); + StmtResult Res = getDerived().TransformOMPExecutableDirective(D); + getDerived().getSema().EndOpenMPDSABlock(Res.get()); + return Res; +} + //===----------------------------------------------------------------------===// // OpenMP clause transformation //===----------------------------------------------------------------------===// @@ -7155,8 +7426,9 @@ OMPClause *TreeTransform<Derived>::TransformOMPIfClause(OMPIfClause *C) { ExprResult Cond = getDerived().TransformExpr(C->getCondition()); if (Cond.isInvalid()) return nullptr; - return getDerived().RebuildOMPIfClause(Cond.get(), C->getLocStart(), - C->getLParenLoc(), C->getLocEnd()); + return getDerived().RebuildOMPIfClause( + C->getNameModifier(), Cond.get(), C->getLocStart(), C->getLParenLoc(), + C->getNameModifierLoc(), C->getColonLoc(), C->getLocEnd()); } template <typename Derived> @@ -7190,10 +7462,20 @@ TreeTransform<Derived>::TransformOMPSafelenClause(OMPSafelenClause *C) { template <typename Derived> OMPClause * +TreeTransform<Derived>::TransformOMPSimdlenClause(OMPSimdlenClause *C) { + ExprResult E = getDerived().TransformExpr(C->getSimdlen()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPSimdlenClause( + E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); +} + +template <typename Derived> +OMPClause * TreeTransform<Derived>::TransformOMPCollapseClause(OMPCollapseClause *C) { ExprResult E = getDerived().TransformExpr(C->getNumForLoops()); if (E.isInvalid()) - return 0; + return nullptr; return getDerived().RebuildOMPCollapseClause( E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } @@ -7221,15 +7503,23 @@ TreeTransform<Derived>::TransformOMPScheduleClause(OMPScheduleClause *C) { if (E.isInvalid()) return nullptr; return getDerived().RebuildOMPScheduleClause( + C->getFirstScheduleModifier(), C->getSecondScheduleModifier(), C->getScheduleKind(), E.get(), C->getLocStart(), C->getLParenLoc(), + C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(), C->getScheduleKindLoc(), C->getCommaLoc(), C->getLocEnd()); } template <typename Derived> OMPClause * TreeTransform<Derived>::TransformOMPOrderedClause(OMPOrderedClause *C) { - // No need to rebuild this clause, no template-dependent parameters. - return C; + ExprResult E; + if (auto *Num = C->getNumForLoops()) { + E = getDerived().TransformExpr(Num); + if (E.isInvalid()) + return nullptr; + } + return getDerived().RebuildOMPOrderedClause(C->getLocStart(), C->getLocEnd(), + C->getLParenLoc(), E.get()); } template <typename Derived> @@ -7288,6 +7578,26 @@ TreeTransform<Derived>::TransformOMPSeqCstClause(OMPSeqCstClause *C) { template <typename Derived> OMPClause * +TreeTransform<Derived>::TransformOMPThreadsClause(OMPThreadsClause *C) { + // No need to rebuild this clause, no template-dependent parameters. + return C; +} + +template <typename Derived> +OMPClause *TreeTransform<Derived>::TransformOMPSIMDClause(OMPSIMDClause *C) { + // No need to rebuild this clause, no template-dependent parameters. + return C; +} + +template <typename Derived> +OMPClause * +TreeTransform<Derived>::TransformOMPNogroupClause(OMPNogroupClause *C) { + // No need to rebuild this clause, no template-dependent parameters. + return C; +} + +template <typename Derived> +OMPClause * TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) { llvm::SmallVector<Expr *, 16> Vars; Vars.reserve(C->varlist_size()); @@ -7385,9 +7695,9 @@ TreeTransform<Derived>::TransformOMPLinearClause(OMPLinearClause *C) { ExprResult Step = getDerived().TransformExpr(C->getStep()); if (Step.isInvalid()) return nullptr; - return getDerived().RebuildOMPLinearClause(Vars, Step.get(), C->getLocStart(), - C->getLParenLoc(), - C->getColonLoc(), C->getLocEnd()); + return getDerived().RebuildOMPLinearClause( + Vars, Step.get(), C->getLocStart(), C->getLParenLoc(), C->getModifier(), + C->getModifierLoc(), C->getColonLoc(), C->getLocEnd()); } template <typename Derived> @@ -7469,6 +7779,91 @@ TreeTransform<Derived>::TransformOMPDependClause(OMPDependClause *C) { C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); } +template <typename Derived> +OMPClause * +TreeTransform<Derived>::TransformOMPDeviceClause(OMPDeviceClause *C) { + ExprResult E = getDerived().TransformExpr(C->getDevice()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPDeviceClause( + E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); +} + +template <typename Derived> +OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) { + llvm::SmallVector<Expr *, 16> Vars; + Vars.reserve(C->varlist_size()); + for (auto *VE : C->varlists()) { + ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE)); + if (EVar.isInvalid()) + return nullptr; + Vars.push_back(EVar.get()); + } + return getDerived().RebuildOMPMapClause( + C->getMapTypeModifier(), C->getMapType(), C->getMapLoc(), + C->getColonLoc(), Vars, C->getLocStart(), C->getLParenLoc(), + C->getLocEnd()); +} + +template <typename Derived> +OMPClause * +TreeTransform<Derived>::TransformOMPNumTeamsClause(OMPNumTeamsClause *C) { + ExprResult E = getDerived().TransformExpr(C->getNumTeams()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPNumTeamsClause( + E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); +} + +template <typename Derived> +OMPClause * +TreeTransform<Derived>::TransformOMPThreadLimitClause(OMPThreadLimitClause *C) { + ExprResult E = getDerived().TransformExpr(C->getThreadLimit()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPThreadLimitClause( + E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); +} + +template <typename Derived> +OMPClause * +TreeTransform<Derived>::TransformOMPPriorityClause(OMPPriorityClause *C) { + ExprResult E = getDerived().TransformExpr(C->getPriority()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPPriorityClause( + E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); +} + +template <typename Derived> +OMPClause * +TreeTransform<Derived>::TransformOMPGrainsizeClause(OMPGrainsizeClause *C) { + ExprResult E = getDerived().TransformExpr(C->getGrainsize()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPGrainsizeClause( + E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); +} + +template <typename Derived> +OMPClause * +TreeTransform<Derived>::TransformOMPNumTasksClause(OMPNumTasksClause *C) { + ExprResult E = getDerived().TransformExpr(C->getNumTasks()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPNumTasksClause( + E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd()); +} + +template <typename Derived> +OMPClause *TreeTransform<Derived>::TransformOMPHintClause(OMPHintClause *C) { + ExprResult E = getDerived().TransformExpr(C->getHint()); + if (E.isInvalid()) + return nullptr; + return getDerived().RebuildOMPHintClause(E.get(), C->getLocStart(), + C->getLParenLoc(), C->getLocEnd()); +} + //===----------------------------------------------------------------------===// // Expression transformation //===----------------------------------------------------------------------===// @@ -7668,16 +8063,15 @@ TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) { // template code that we don't care. bool ExprChanged = false; typedef Sema::OffsetOfComponent Component; - typedef OffsetOfExpr::OffsetOfNode Node; SmallVector<Component, 4> Components; for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { - const Node &ON = E->getComponent(I); + const OffsetOfNode &ON = E->getComponent(I); Component Comp; Comp.isBrackets = true; Comp.LocStart = ON.getSourceRange().getBegin(); Comp.LocEnd = ON.getSourceRange().getEnd(); switch (ON.getKind()) { - case Node::Array: { + case OffsetOfNode::Array: { Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex()); ExprResult Index = getDerived().TransformExpr(FromIndex); if (Index.isInvalid()) @@ -7689,8 +8083,8 @@ TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) { break; } - case Node::Field: - case Node::Identifier: + case OffsetOfNode::Field: + case OffsetOfNode::Identifier: Comp.isBrackets = false; Comp.U.IdentInfo = ON.getFieldName(); if (!Comp.U.IdentInfo) @@ -7698,7 +8092,7 @@ TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) { break; - case Node::Base: + case OffsetOfNode::Base: // Will be recomputed during the rebuild. continue; } @@ -7714,14 +8108,13 @@ TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) { // Build a new offsetof expression. return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type, - Components.data(), Components.size(), - E->getRParenLoc()); + Components, E->getRParenLoc()); } template<typename Derived> ExprResult TreeTransform<Derived>::TransformOpaqueValueExpr(OpaqueValueExpr *E) { - assert(getDerived().AlreadyTransformed(E->getType()) && + assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) && "opaque value expression requires transformation"); return E; } @@ -7829,6 +8222,36 @@ TreeTransform<Derived>::TransformArraySubscriptExpr(ArraySubscriptExpr *E) { E->getRBracketLoc()); } +template <typename Derived> +ExprResult +TreeTransform<Derived>::TransformOMPArraySectionExpr(OMPArraySectionExpr *E) { + ExprResult Base = getDerived().TransformExpr(E->getBase()); + if (Base.isInvalid()) + return ExprError(); + + ExprResult LowerBound; + if (E->getLowerBound()) { + LowerBound = getDerived().TransformExpr(E->getLowerBound()); + if (LowerBound.isInvalid()) + return ExprError(); + } + + ExprResult Length; + if (E->getLength()) { + Length = getDerived().TransformExpr(E->getLength()); + if (Length.isInvalid()) + return ExprError(); + } + + if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() && + LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength()) + return E; + + return getDerived().RebuildOMPArraySectionExpr( + Base.get(), E->getBase()->getLocEnd(), LowerBound.get(), E->getColonLoc(), + Length.get(), E->getRBracketLoc()); +} + template<typename Derived> ExprResult TreeTransform<Derived>::TransformCallExpr(CallExpr *E) { @@ -8995,9 +9418,20 @@ TreeTransform<Derived>::TransformUnresolvedLookupExpr( SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc(); // If we have neither explicit template arguments, nor the template keyword, - // it's a normal declaration name. - if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) + // it's a normal declaration name or member reference. + if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) { + NamedDecl *D = R.getAsSingle<NamedDecl>(); + // In a C++11 unevaluated context, an UnresolvedLookupExpr might refer to an + // instance member. In other contexts, BuildPossibleImplicitMemberExpr will + // give a good diagnostic. + if (D && D->isCXXInstanceMember()) { + return SemaRef.BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R, + /*TemplateArgs=*/nullptr, + /*Scope=*/nullptr); + } + return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL()); + } // If we have template arguments, rebuild them, then rebuild the // templateid expression. @@ -9404,9 +9838,10 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) { VarDecl *OldVD = C->getCapturedVar(); QualType NewInitCaptureType = - getSema().performLambdaInitCaptureInitialization(C->getLocation(), - OldVD->getType()->isReferenceType(), OldVD->getIdentifier(), - NewExprInit); + getSema().buildLambdaInitCaptureInitialization( + C->getLocation(), OldVD->getType()->isReferenceType(), + OldVD->getIdentifier(), + C->getCapturedVar()->getInitStyle() != VarDecl::CInit, NewExprInit); NewExprInitResult = NewExprInit; InitCaptureExprsAndTypes[C - E->capture_begin()] = std::make_pair(NewExprInitResult, NewInitCaptureType); @@ -9513,8 +9948,8 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) { } VarDecl *OldVD = C->getCapturedVar(); VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl( - OldVD->getLocation(), InitExprTypePair.second, - OldVD->getIdentifier(), Init.get()); + OldVD->getLocation(), InitExprTypePair.second, OldVD->getIdentifier(), + OldVD->getInitStyle(), Init.get()); if (!NewVD) Invalid = true; else { @@ -9886,36 +10321,86 @@ TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) { if (!E->isValueDependent()) return E; - // Note: None of the implementations of TryExpandParameterPacks can ever - // produce a diagnostic when given only a single unexpanded parameter pack, - // so - UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc()); - bool ShouldExpand = false; - bool RetainExpansion = false; - Optional<unsigned> NumExpansions; - if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(), - Unexpanded, - ShouldExpand, RetainExpansion, - NumExpansions)) - return ExprError(); + EnterExpressionEvaluationContext Unevaluated(getSema(), Sema::Unevaluated); - if (RetainExpansion) - return E; + ArrayRef<TemplateArgument> PackArgs; + TemplateArgument ArgStorage; - NamedDecl *Pack = E->getPack(); - if (!ShouldExpand) { - Pack = cast_or_null<NamedDecl>(getDerived().TransformDecl(E->getPackLoc(), - Pack)); + // Find the argument list to transform. + if (E->isPartiallySubstituted()) { + PackArgs = E->getPartialArguments(); + } else if (E->isValueDependent()) { + UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc()); + bool ShouldExpand = false; + bool RetainExpansion = false; + Optional<unsigned> NumExpansions; + if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(), + Unexpanded, + ShouldExpand, RetainExpansion, + NumExpansions)) + return ExprError(); + + // If we need to expand the pack, build a template argument from it and + // expand that. + if (ShouldExpand) { + auto *Pack = E->getPack(); + if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) { + ArgStorage = getSema().Context.getPackExpansionType( + getSema().Context.getTypeDeclType(TTPD), None); + } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) { + ArgStorage = TemplateArgument(TemplateName(TTPD), None); + } else { + auto *VD = cast<ValueDecl>(Pack); + ExprResult DRE = getSema().BuildDeclRefExpr(VD, VD->getType(), + VK_RValue, E->getPackLoc()); + if (DRE.isInvalid()) + return ExprError(); + ArgStorage = new (getSema().Context) PackExpansionExpr( + getSema().Context.DependentTy, DRE.get(), E->getPackLoc(), None); + } + PackArgs = ArgStorage; + } + } + + // If we're not expanding the pack, just transform the decl. + if (!PackArgs.size()) { + auto *Pack = cast_or_null<NamedDecl>( + getDerived().TransformDecl(E->getPackLoc(), E->getPack())); if (!Pack) return ExprError(); + return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack, + E->getPackLoc(), + E->getRParenLoc(), None, None); } + TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(), + E->getPackLoc()); + { + TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity()); + typedef TemplateArgumentLocInventIterator< + Derived, const TemplateArgument*> PackLocIterator; + if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()), + PackLocIterator(*this, PackArgs.end()), + TransformedPackArgs, /*Uneval*/true)) + return ExprError(); + } - // We now know the length of the parameter pack, so build a new expression - // that stores that length. - return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack, + SmallVector<TemplateArgument, 8> Args; + bool PartialSubstitution = false; + for (auto &Loc : TransformedPackArgs.arguments()) { + Args.push_back(Loc.getArgument()); + if (Loc.getArgument().isPackExpansion()) + PartialSubstitution = true; + } + + if (PartialSubstitution) + return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(), + E->getPackLoc(), + E->getRParenLoc(), None, Args); + + return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(), - NumExpansions); + Args.size(), None); } template<typename Derived> @@ -10242,8 +10727,7 @@ TreeTransform<Derived>::TransformObjCDictionaryLiteral( return SemaRef.MaybeBindToTemporary(E); return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(), - Elements.data(), - Elements.size()); + Elements); } template<typename Derived> @@ -10337,6 +10821,7 @@ TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) { return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(), E->getSelector(), SelLocs, + E->getReceiverType(), E->getMethodDecl(), E->getLeftLoc(), Args, @@ -11075,7 +11560,8 @@ TreeTransform<Derived>::RebuildCXXPseudoDestructorExpr(Expr *Base, SS, TemplateKWLoc, /*FIXME: FirstQualifier*/ nullptr, NameInfo, - /*TemplateArgs*/ nullptr); + /*TemplateArgs*/ nullptr, + /*S*/nullptr); } template<typename Derived> @@ -11114,4 +11600,4 @@ TreeTransform<Derived>::TransformCapturedStmt(CapturedStmt *S) { } // end namespace clang -#endif +#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H |