| //===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===// |
| // |
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| // See https://llvm.org/LICENSE.txt for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| //===----------------------------------------------------------------------===// |
| // |
| // This file implements a semantic tree transformation that takes a given |
| // AST and rebuilds it, possibly transforming some nodes in the process. |
| // |
| //===----------------------------------------------------------------------===// |
| |
| #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H |
| #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H |
| |
| #include "CoroutineStmtBuilder.h" |
| #include "TypeLocBuilder.h" |
| #include "clang/AST/Decl.h" |
| #include "clang/AST/DeclObjC.h" |
| #include "clang/AST/DeclTemplate.h" |
| #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" |
| #include "clang/AST/StmtOpenMP.h" |
| #include "clang/Sema/Designator.h" |
| #include "clang/Sema/Lookup.h" |
| #include "clang/Sema/Ownership.h" |
| #include "clang/Sema/ParsedTemplate.h" |
| #include "clang/Sema/ScopeInfo.h" |
| #include "clang/Sema/SemaDiagnostic.h" |
| #include "clang/Sema/SemaInternal.h" |
| #include "llvm/ADT/ArrayRef.h" |
| #include "llvm/Support/ErrorHandling.h" |
| #include <algorithm> |
| |
| namespace clang { |
| using namespace sema; |
| |
| /// A semantic tree transformation that allows one to transform one |
| /// abstract syntax tree into another. |
| /// |
| /// A new tree transformation is defined by creating a new subclass \c X of |
| /// \c TreeTransform<X> and then overriding certain operations to provide |
| /// behavior specific to that transformation. For example, template |
| /// instantiation is implemented as a tree transformation where the |
| /// transformation of TemplateTypeParmType nodes involves substituting the |
| /// template arguments for their corresponding template parameters; a similar |
| /// transformation is performed for non-type template parameters and |
| /// template template parameters. |
| /// |
| /// This tree-transformation template uses static polymorphism to allow |
| /// subclasses to customize any of its operations. Thus, a subclass can |
| /// override any of the transformation or rebuild operators by providing an |
| /// operation with the same signature as the default implementation. The |
| /// overriding function should not be virtual. |
| /// |
| /// Semantic tree transformations are split into two stages, either of which |
| /// can be replaced by a subclass. The "transform" step transforms an AST node |
| /// or the parts of an AST node using the various transformation functions, |
| /// then passes the pieces on to the "rebuild" step, which constructs a new AST |
| /// node of the appropriate kind from the pieces. The default transformation |
| /// routines recursively transform the operands to composite AST nodes (e.g., |
| /// the pointee type of a PointerType node) and, if any of those operand nodes |
| /// were changed by the transformation, invokes the rebuild operation to create |
| /// a new AST node. |
| /// |
| /// Subclasses can customize the transformation at various levels. The |
| /// most coarse-grained transformations involve replacing TransformType(), |
| /// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(), |
| /// TransformTemplateName(), or TransformTemplateArgument() with entirely |
| /// new implementations. |
| /// |
| /// For more fine-grained transformations, subclasses can replace any of the |
| /// \c TransformXXX functions (where XXX is the name of an AST node, e.g., |
| /// PointerType, StmtExpr) to alter the transformation. As mentioned previously, |
| /// replacing TransformTemplateTypeParmType() allows template instantiation |
| /// to substitute template arguments for their corresponding template |
| /// parameters. Additionally, subclasses can override the \c RebuildXXX |
| /// functions to control how AST nodes are rebuilt when their operands change. |
| /// By default, \c TreeTransform will invoke semantic analysis to rebuild |
| /// AST nodes. However, certain other tree transformations (e.g, cloning) may |
| /// be able to use more efficient rebuild steps. |
| /// |
| /// There are a handful of other functions that can be overridden, allowing one |
| /// to avoid traversing nodes that don't need any transformation |
| /// (\c AlreadyTransformed()), force rebuilding AST nodes even when their |
| /// operands have not changed (\c AlwaysRebuild()), and customize the |
| /// default locations and entity names used for type-checking |
| /// (\c getBaseLocation(), \c getBaseEntity()). |
| template<typename Derived> |
| class TreeTransform { |
| /// Private RAII object that helps us forget and then re-remember |
| /// the template argument corresponding to a partially-substituted parameter |
| /// pack. |
| class ForgetPartiallySubstitutedPackRAII { |
| Derived &Self; |
| TemplateArgument Old; |
| |
| public: |
| ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) { |
| Old = Self.ForgetPartiallySubstitutedPack(); |
| } |
| |
| ~ForgetPartiallySubstitutedPackRAII() { |
| Self.RememberPartiallySubstitutedPack(Old); |
| } |
| }; |
| |
| protected: |
| Sema &SemaRef; |
| |
| /// The set of local declarations that have been transformed, for |
| /// cases where we are forced to build new declarations within the transformer |
| /// rather than in the subclass (e.g., lambda closure types). |
| llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls; |
| |
| public: |
| /// Initializes a new tree transformer. |
| TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { } |
| |
| /// Retrieves a reference to the derived class. |
| Derived &getDerived() { return static_cast<Derived&>(*this); } |
| |
| /// Retrieves a reference to the derived class. |
| const Derived &getDerived() const { |
| return static_cast<const Derived&>(*this); |
| } |
| |
| static inline ExprResult Owned(Expr *E) { return E; } |
| static inline StmtResult Owned(Stmt *S) { return S; } |
| |
| /// Retrieves a reference to the semantic analysis object used for |
| /// this tree transform. |
| Sema &getSema() const { return SemaRef; } |
| |
| /// Whether the transformation should always rebuild AST nodes, even |
| /// if none of the children have changed. |
| /// |
| /// Subclasses may override this function to specify when the transformation |
| /// should rebuild all AST nodes. |
| /// |
| /// We must always rebuild all AST nodes when performing variadic template |
| /// pack expansion, in order to avoid violating the AST invariant that each |
| /// statement node appears at most once in its containing declaration. |
| bool AlwaysRebuild() { return SemaRef.ArgumentPackSubstitutionIndex != -1; } |
| |
| /// Whether the transformation is forming an expression or statement that |
| /// replaces the original. In this case, we'll reuse mangling numbers from |
| /// existing lambdas. |
| bool ReplacingOriginal() { return false; } |
| |
| /// Returns the location of the entity being transformed, if that |
| /// information was not available elsewhere in the AST. |
| /// |
| /// By default, returns no source-location information. Subclasses can |
| /// provide an alternative implementation that provides better location |
| /// information. |
| SourceLocation getBaseLocation() { return SourceLocation(); } |
| |
| /// Returns the name of the entity being transformed, if that |
| /// information was not available elsewhere in the AST. |
| /// |
| /// By default, returns an empty name. Subclasses can provide an alternative |
| /// implementation with a more precise name. |
| DeclarationName getBaseEntity() { return DeclarationName(); } |
| |
| /// Sets the "base" location and entity when that |
| /// information is known based on another transformation. |
| /// |
| /// By default, the source location and entity are ignored. Subclasses can |
| /// override this function to provide a customized implementation. |
| void setBase(SourceLocation Loc, DeclarationName Entity) { } |
| |
| /// RAII object that temporarily sets the base location and entity |
| /// used for reporting diagnostics in types. |
| class TemporaryBase { |
| TreeTransform &Self; |
| SourceLocation OldLocation; |
| DeclarationName OldEntity; |
| |
| public: |
| TemporaryBase(TreeTransform &Self, SourceLocation Location, |
| DeclarationName Entity) : Self(Self) { |
| OldLocation = Self.getDerived().getBaseLocation(); |
| OldEntity = Self.getDerived().getBaseEntity(); |
| |
| if (Location.isValid()) |
| Self.getDerived().setBase(Location, Entity); |
| } |
| |
| ~TemporaryBase() { |
| Self.getDerived().setBase(OldLocation, OldEntity); |
| } |
| }; |
| |
| /// Determine whether the given type \p T has already been |
| /// transformed. |
| /// |
| /// Subclasses can provide an alternative implementation of this routine |
| /// to short-circuit evaluation when it is known that a given type will |
| /// not change. For example, template instantiation need not traverse |
| /// non-dependent types. |
| bool AlreadyTransformed(QualType T) { |
| return T.isNull(); |
| } |
| |
| /// Determine whether the given call argument should be dropped, e.g., |
| /// because it is a default argument. |
| /// |
| /// Subclasses can provide an alternative implementation of this routine to |
| /// determine which kinds of call arguments get dropped. By default, |
| /// CXXDefaultArgument nodes are dropped (prior to transformation). |
| bool DropCallArgument(Expr *E) { |
| return E->isDefaultArgument(); |
| } |
| |
| /// Determine whether we should expand a pack expansion with the |
| /// given set of parameter packs into separate arguments by repeatedly |
| /// transforming the pattern. |
| /// |
| /// By default, the transformer never tries to expand pack expansions. |
| /// Subclasses can override this routine to provide different behavior. |
| /// |
| /// \param EllipsisLoc The location of the ellipsis that identifies the |
| /// pack expansion. |
| /// |
| /// \param PatternRange The source range that covers the entire pattern of |
| /// the pack expansion. |
| /// |
| /// \param Unexpanded The set of unexpanded parameter packs within the |
| /// pattern. |
| /// |
| /// \param ShouldExpand Will be set to \c true if the transformer should |
| /// expand the corresponding pack expansions into separate arguments. When |
| /// set, \c NumExpansions must also be set. |
| /// |
| /// \param RetainExpansion Whether the caller should add an unexpanded |
| /// pack expansion after all of the expanded arguments. This is used |
| /// when extending explicitly-specified template argument packs per |
| /// C++0x [temp.arg.explicit]p9. |
| /// |
| /// \param NumExpansions The number of separate arguments that will be in |
| /// the expanded form of the corresponding pack expansion. This is both an |
| /// input and an output parameter, which can be set by the caller if the |
| /// number of expansions is known a priori (e.g., due to a prior substitution) |
| /// and will be set by the callee when the number of expansions is known. |
| /// The callee must set this value when \c ShouldExpand is \c true; it may |
| /// set this value in other cases. |
| /// |
| /// \returns true if an error occurred (e.g., because the parameter packs |
| /// are to be instantiated with arguments of different lengths), false |
| /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions) |
| /// must be set. |
| bool TryExpandParameterPacks(SourceLocation EllipsisLoc, |
| SourceRange PatternRange, |
| ArrayRef<UnexpandedParameterPack> Unexpanded, |
| bool &ShouldExpand, |
| bool &RetainExpansion, |
| Optional<unsigned> &NumExpansions) { |
| ShouldExpand = false; |
| return false; |
| } |
| |
| /// "Forget" about the partially-substituted pack template argument, |
| /// when performing an instantiation that must preserve the parameter pack |
| /// use. |
| /// |
| /// This routine is meant to be overridden by the template instantiator. |
| TemplateArgument ForgetPartiallySubstitutedPack() { |
| return TemplateArgument(); |
| } |
| |
| /// "Remember" the partially-substituted pack template argument |
| /// after performing an instantiation that must preserve the parameter pack |
| /// use. |
| /// |
| /// This routine is meant to be overridden by the template instantiator. |
| void RememberPartiallySubstitutedPack(TemplateArgument Arg) { } |
| |
| /// Note to the derived class when a function parameter pack is |
| /// being expanded. |
| void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { } |
| |
| /// Transforms the given type into another type. |
| /// |
| /// By default, this routine transforms a type by creating a |
| /// TypeSourceInfo for it and delegating to the appropriate |
| /// function. This is expensive, but we don't mind, because |
| /// this method is deprecated anyway; all users should be |
| /// switched to storing TypeSourceInfos. |
| /// |
| /// \returns the transformed type. |
| QualType TransformType(QualType T); |
| |
| /// Transforms the given type-with-location into a new |
| /// type-with-location. |
| /// |
| /// By default, this routine transforms a type by delegating to the |
| /// appropriate TransformXXXType to build a new type. Subclasses |
| /// may override this function (to take over all type |
| /// transformations) or some set of the TransformXXXType functions |
| /// to alter the transformation. |
| TypeSourceInfo *TransformType(TypeSourceInfo *DI); |
| |
| /// Transform the given type-with-location into a new |
| /// type, collecting location information in the given builder |
| /// as necessary. |
| /// |
| QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL); |
| |
| /// Transform a type that is permitted to produce a |
| /// DeducedTemplateSpecializationType. |
| /// |
| /// This is used in the (relatively rare) contexts where it is acceptable |
| /// for transformation to produce a class template type with deduced |
| /// template arguments. |
| /// @{ |
| QualType TransformTypeWithDeducedTST(QualType T); |
| TypeSourceInfo *TransformTypeWithDeducedTST(TypeSourceInfo *DI); |
| /// @} |
| |
| /// The reason why the value of a statement is not discarded, if any. |
| enum StmtDiscardKind { |
| SDK_Discarded, |
| SDK_NotDiscarded, |
| SDK_StmtExprResult, |
| }; |
| |
| /// Transform the given statement. |
| /// |
| /// By default, this routine transforms a statement by delegating to the |
| /// appropriate TransformXXXStmt function to transform a specific kind of |
| /// statement or the TransformExpr() function to transform an expression. |
| /// Subclasses may override this function to transform statements using some |
| /// other mechanism. |
| /// |
| /// \returns the transformed statement. |
| StmtResult TransformStmt(Stmt *S, StmtDiscardKind SDK = SDK_Discarded); |
| |
| /// Transform the given statement. |
| /// |
| /// By default, this routine transforms a statement by delegating to the |
| /// appropriate TransformOMPXXXClause function to transform a specific kind |
| /// of clause. Subclasses may override this function to transform statements |
| /// using some other mechanism. |
| /// |
| /// \returns the transformed OpenMP clause. |
| OMPClause *TransformOMPClause(OMPClause *S); |
| |
| /// Transform the given attribute. |
| /// |
| /// By default, this routine transforms a statement by delegating to the |
| /// appropriate TransformXXXAttr function to transform a specific kind |
| /// of attribute. Subclasses may override this function to transform |
| /// attributed statements using some other mechanism. |
| /// |
| /// \returns the transformed attribute |
| const Attr *TransformAttr(const Attr *S); |
| |
| /// Transform the specified attribute. |
| /// |
| /// Subclasses should override the transformation of attributes with a pragma |
| /// spelling to transform expressions stored within the attribute. |
| /// |
| /// \returns the transformed attribute. |
| #define ATTR(X) |
| #define PRAGMA_SPELLING_ATTR(X) \ |
| const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; } |
| #include "clang/Basic/AttrList.inc" |
| |
| /// Transform the given expression. |
| /// |
| /// By default, this routine transforms an expression by delegating to the |
| /// appropriate TransformXXXExpr function to build a new expression. |
| /// Subclasses may override this function to transform expressions using some |
| /// other mechanism. |
| /// |
| /// \returns the transformed expression. |
| ExprResult TransformExpr(Expr *E); |
| |
| /// Transform the given initializer. |
| /// |
| /// By default, this routine transforms an initializer by stripping off the |
| /// semantic nodes added by initialization, then passing the result to |
| /// TransformExpr or TransformExprs. |
| /// |
| /// \returns the transformed initializer. |
| ExprResult TransformInitializer(Expr *Init, bool NotCopyInit); |
| |
| /// Transform the given list of expressions. |
| /// |
| /// This routine transforms a list of expressions by invoking |
| /// \c TransformExpr() for each subexpression. However, it also provides |
| /// support for variadic templates by expanding any pack expansions (if the |
| /// derived class permits such expansion) along the way. When pack expansions |
| /// are present, the number of outputs may not equal the number of inputs. |
| /// |
| /// \param Inputs The set of expressions to be transformed. |
| /// |
| /// \param NumInputs The number of expressions in \c Inputs. |
| /// |
| /// \param IsCall If \c true, then this transform is being performed on |
| /// function-call arguments, and any arguments that should be dropped, will |
| /// be. |
| /// |
| /// \param Outputs The transformed input expressions will be added to this |
| /// vector. |
| /// |
| /// \param ArgChanged If non-NULL, will be set \c true if any argument changed |
| /// due to transformation. |
| /// |
| /// \returns true if an error occurred, false otherwise. |
| bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, |
| SmallVectorImpl<Expr *> &Outputs, |
| bool *ArgChanged = nullptr); |
| |
| /// Transform the given declaration, which is referenced from a type |
| /// or expression. |
| /// |
| /// By default, acts as the identity function on declarations, unless the |
| /// transformer has had to transform the declaration itself. Subclasses |
| /// may override this function to provide alternate behavior. |
| Decl *TransformDecl(SourceLocation Loc, Decl *D) { |
| llvm::DenseMap<Decl *, Decl *>::iterator Known |
| = TransformedLocalDecls.find(D); |
| if (Known != TransformedLocalDecls.end()) |
| return Known->second; |
| |
| return D; |
| } |
| |
| /// Transform the specified condition. |
| /// |
| /// By default, this transforms the variable and expression and rebuilds |
| /// the condition. |
| Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, |
| Expr *Expr, |
| Sema::ConditionKind Kind); |
| |
| /// Transform the attributes associated with the given declaration and |
| /// place them on the new declaration. |
| /// |
| /// By default, this operation does nothing. Subclasses may override this |
| /// behavior to transform attributes. |
| void transformAttrs(Decl *Old, Decl *New) { } |
| |
| /// Note that a local declaration has been transformed by this |
| /// transformer. |
| /// |
| /// Local declarations are typically transformed via a call to |
| /// TransformDefinition. However, in some cases (e.g., lambda expressions), |
| /// the transformer itself has to transform the declarations. This routine |
| /// can be overridden by a subclass that keeps track of such mappings. |
| void transformedLocalDecl(Decl *Old, ArrayRef<Decl *> New) { |
| assert(New.size() == 1 && |
| "must override transformedLocalDecl if performing pack expansion"); |
| TransformedLocalDecls[Old] = New.front(); |
| } |
| |
| /// Transform the definition of the given declaration. |
| /// |
| /// By default, invokes TransformDecl() to transform the declaration. |
| /// Subclasses may override this function to provide alternate behavior. |
| Decl *TransformDefinition(SourceLocation Loc, Decl *D) { |
| return getDerived().TransformDecl(Loc, D); |
| } |
| |
| /// Transform the given declaration, which was the first part of a |
| /// nested-name-specifier in a member access expression. |
| /// |
| /// This specific declaration transformation only applies to the first |
| /// identifier in a nested-name-specifier of a member access expression, e.g., |
| /// the \c T in \c x->T::member |
| /// |
| /// By default, invokes TransformDecl() to transform the declaration. |
| /// Subclasses may override this function to provide alternate behavior. |
| NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) { |
| return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D)); |
| } |
| |
| /// Transform the set of declarations in an OverloadExpr. |
| bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL, |
| LookupResult &R); |
| |
| /// Transform the given nested-name-specifier with source-location |
| /// information. |
| /// |
| /// By default, transforms all of the types and declarations within the |
| /// nested-name-specifier. Subclasses may override this function to provide |
| /// alternate behavior. |
| NestedNameSpecifierLoc |
| TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, |
| QualType ObjectType = QualType(), |
| NamedDecl *FirstQualifierInScope = nullptr); |
| |
| /// Transform the given declaration name. |
| /// |
| /// By default, transforms the types of conversion function, constructor, |
| /// and destructor names and then (if needed) rebuilds the declaration name. |
| /// Identifiers and selectors are returned unmodified. Sublcasses may |
| /// override this function to provide alternate behavior. |
| DeclarationNameInfo |
| TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo); |
| |
| /// Transform the given template name. |
| /// |
| /// \param SS The nested-name-specifier that qualifies the template |
| /// name. This nested-name-specifier must already have been transformed. |
| /// |
| /// \param Name The template name to transform. |
| /// |
| /// \param NameLoc The source location of the template name. |
| /// |
| /// \param ObjectType If we're translating a template name within a member |
| /// access expression, this is the type of the object whose member template |
| /// is being referenced. |
| /// |
| /// \param FirstQualifierInScope If the first part of a nested-name-specifier |
| /// also refers to a name within the current (lexical) scope, this is the |
| /// declaration it refers to. |
| /// |
| /// By default, transforms the template name by transforming the declarations |
| /// and nested-name-specifiers that occur within the template name. |
| /// Subclasses may override this function to provide alternate behavior. |
| TemplateName |
| TransformTemplateName(CXXScopeSpec &SS, TemplateName Name, |
| SourceLocation NameLoc, |
| QualType ObjectType = QualType(), |
| NamedDecl *FirstQualifierInScope = nullptr, |
| bool AllowInjectedClassName = false); |
| |
| /// Transform the given template argument. |
| /// |
| /// By default, this operation transforms the type, expression, or |
| /// declaration stored within the template argument and constructs a |
| /// new template argument from the transformed result. Subclasses may |
| /// override this function to provide alternate behavior. |
| /// |
| /// Returns true if there was an error. |
| bool TransformTemplateArgument(const TemplateArgumentLoc &Input, |
| TemplateArgumentLoc &Output, |
| bool Uneval = false); |
| |
| /// Transform the given set of template arguments. |
| /// |
| /// By default, this operation transforms all of the template arguments |
| /// in the input set using \c TransformTemplateArgument(), and appends |
| /// the transformed arguments to the output list. |
| /// |
| /// Note that this overload of \c TransformTemplateArguments() is merely |
| /// a convenience function. Subclasses that wish to override this behavior |
| /// should override the iterator-based member template version. |
| /// |
| /// \param Inputs The set of template arguments to be transformed. |
| /// |
| /// \param NumInputs The number of template arguments in \p Inputs. |
| /// |
| /// \param Outputs The set of transformed template arguments output by this |
| /// routine. |
| /// |
| /// Returns true if an error occurred. |
| bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, |
| unsigned NumInputs, |
| TemplateArgumentListInfo &Outputs, |
| bool Uneval = false) { |
| return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs, |
| Uneval); |
| } |
| |
| /// Transform the given set of template arguments. |
| /// |
| /// By default, this operation transforms all of the template arguments |
| /// in the input set using \c TransformTemplateArgument(), and appends |
| /// the transformed arguments to the output list. |
| /// |
| /// \param First An iterator to the first template argument. |
| /// |
| /// \param Last An iterator one step past the last template argument. |
| /// |
| /// \param Outputs The set of transformed template arguments output by this |
| /// routine. |
| /// |
| /// Returns true if an error occurred. |
| template<typename InputIterator> |
| bool TransformTemplateArguments(InputIterator First, |
| InputIterator Last, |
| TemplateArgumentListInfo &Outputs, |
| bool Uneval = false); |
| |
| /// Fakes up a TemplateArgumentLoc for a given TemplateArgument. |
| void InventTemplateArgumentLoc(const TemplateArgument &Arg, |
| TemplateArgumentLoc &ArgLoc); |
| |
| /// Fakes up a TypeSourceInfo for a type. |
| TypeSourceInfo *InventTypeSourceInfo(QualType T) { |
| return SemaRef.Context.getTrivialTypeSourceInfo(T, |
| getDerived().getBaseLocation()); |
| } |
| |
| #define ABSTRACT_TYPELOC(CLASS, PARENT) |
| #define TYPELOC(CLASS, PARENT) \ |
| QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T); |
| #include "clang/AST/TypeLocNodes.def" |
| |
| template<typename Fn> |
| QualType TransformFunctionProtoType(TypeLocBuilder &TLB, |
| FunctionProtoTypeLoc TL, |
| CXXRecordDecl *ThisContext, |
| Qualifiers ThisTypeQuals, |
| Fn TransformExceptionSpec); |
| |
| bool TransformExceptionSpec(SourceLocation Loc, |
| FunctionProtoType::ExceptionSpecInfo &ESI, |
| SmallVectorImpl<QualType> &Exceptions, |
| bool &Changed); |
| |
| StmtResult TransformSEHHandler(Stmt *Handler); |
| |
| QualType |
| TransformTemplateSpecializationType(TypeLocBuilder &TLB, |
| TemplateSpecializationTypeLoc TL, |
| TemplateName Template); |
| |
| QualType |
| TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, |
| DependentTemplateSpecializationTypeLoc TL, |
| TemplateName Template, |
| CXXScopeSpec &SS); |
| |
| QualType TransformDependentTemplateSpecializationType( |
| TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL, |
| NestedNameSpecifierLoc QualifierLoc); |
| |
| /// Transforms the parameters of a function type into the |
| /// given vectors. |
| /// |
| /// The result vectors should be kept in sync; null entries in the |
| /// variables vector are acceptable. |
| /// |
| /// Return true on error. |
| bool TransformFunctionTypeParams( |
| SourceLocation Loc, ArrayRef<ParmVarDecl *> Params, |
| const QualType *ParamTypes, |
| const FunctionProtoType::ExtParameterInfo *ParamInfos, |
| SmallVectorImpl<QualType> &PTypes, SmallVectorImpl<ParmVarDecl *> *PVars, |
| Sema::ExtParameterInfoBuilder &PInfos); |
| |
| /// Transforms a single function-type parameter. Return null |
| /// on error. |
| /// |
| /// \param indexAdjustment - A number to add to the parameter's |
| /// scope index; can be negative |
| ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm, |
| int indexAdjustment, |
| Optional<unsigned> NumExpansions, |
| bool ExpectParameterPack); |
| |
| /// Transform the body of a lambda-expression. |
| StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body); |
| /// Alternative implementation of TransformLambdaBody that skips transforming |
| /// the body. |
| StmtResult SkipLambdaBody(LambdaExpr *E, Stmt *Body); |
| |
| QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL); |
| |
| StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr); |
| ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E); |
| |
| TemplateParameterList *TransformTemplateParameterList( |
| TemplateParameterList *TPL) { |
| return TPL; |
| } |
| |
| ExprResult TransformAddressOfOperand(Expr *E); |
| |
| ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, |
| bool IsAddressOfOperand, |
| TypeSourceInfo **RecoveryTSI); |
| |
| ExprResult TransformParenDependentScopeDeclRefExpr( |
| ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand, |
| TypeSourceInfo **RecoveryTSI); |
| |
| StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S); |
| |
| // FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous |
| // amount of stack usage with clang. |
| #define STMT(Node, Parent) \ |
| LLVM_ATTRIBUTE_NOINLINE \ |
| StmtResult Transform##Node(Node *S); |
| #define VALUESTMT(Node, Parent) \ |
| LLVM_ATTRIBUTE_NOINLINE \ |
| StmtResult Transform##Node(Node *S, StmtDiscardKind SDK); |
| #define EXPR(Node, Parent) \ |
| LLVM_ATTRIBUTE_NOINLINE \ |
| ExprResult Transform##Node(Node *E); |
| #define ABSTRACT_STMT(Stmt) |
| #include "clang/AST/StmtNodes.inc" |
| |
| #define OPENMP_CLAUSE(Name, Class) \ |
| LLVM_ATTRIBUTE_NOINLINE \ |
| OMPClause *Transform ## Class(Class *S); |
| #include "clang/Basic/OpenMPKinds.def" |
| |
| /// Build a new qualified type given its unqualified type and type location. |
| /// |
| /// By default, this routine adds type qualifiers only to types that can |
| /// have qualifiers, and silently suppresses those qualifiers that are not |
| /// permitted. Subclasses may override this routine to provide different |
| /// behavior. |
| QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL); |
| |
| /// Build a new pointer type given its pointee type. |
| /// |
| /// By default, performs semantic analysis when building the pointer type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil); |
| |
| /// Build a new block pointer type given its pointee type. |
| /// |
| /// By default, performs semantic analysis when building the block pointer |
| /// type. Subclasses may override this routine to provide different behavior. |
| QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil); |
| |
| /// Build a new reference type given the type it references. |
| /// |
| /// By default, performs semantic analysis when building the |
| /// reference type. Subclasses may override this routine to provide |
| /// different behavior. |
| /// |
| /// \param LValue whether the type was written with an lvalue sigil |
| /// or an rvalue sigil. |
| QualType RebuildReferenceType(QualType ReferentType, |
| bool LValue, |
| SourceLocation Sigil); |
| |
| /// Build a new member pointer type given the pointee type and the |
| /// class type it refers into. |
| /// |
| /// By default, performs semantic analysis when building the member pointer |
| /// type. Subclasses may override this routine to provide different behavior. |
| QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType, |
| SourceLocation Sigil); |
| |
| QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, |
| SourceLocation ProtocolLAngleLoc, |
| ArrayRef<ObjCProtocolDecl *> Protocols, |
| ArrayRef<SourceLocation> ProtocolLocs, |
| SourceLocation ProtocolRAngleLoc); |
| |
| /// Build an Objective-C object type. |
| /// |
| /// By default, performs semantic analysis when building the object type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildObjCObjectType(QualType BaseType, |
| SourceLocation Loc, |
| SourceLocation TypeArgsLAngleLoc, |
| ArrayRef<TypeSourceInfo *> TypeArgs, |
| SourceLocation TypeArgsRAngleLoc, |
| SourceLocation ProtocolLAngleLoc, |
| ArrayRef<ObjCProtocolDecl *> Protocols, |
| ArrayRef<SourceLocation> ProtocolLocs, |
| SourceLocation ProtocolRAngleLoc); |
| |
| /// Build a new Objective-C object pointer type given the pointee type. |
| /// |
| /// By default, directly builds the pointer type, with no additional semantic |
| /// analysis. |
| QualType RebuildObjCObjectPointerType(QualType PointeeType, |
| SourceLocation Star); |
| |
| /// Build a new array type given the element type, size |
| /// modifier, size of the array (if known), size expression, and index type |
| /// qualifiers. |
| /// |
| /// By default, performs semantic analysis when building the array type. |
| /// Subclasses may override this routine to provide different behavior. |
| /// Also by default, all of the other Rebuild*Array |
| QualType RebuildArrayType(QualType ElementType, |
| ArrayType::ArraySizeModifier SizeMod, |
| const llvm::APInt *Size, |
| Expr *SizeExpr, |
| unsigned IndexTypeQuals, |
| SourceRange BracketsRange); |
| |
| /// Build a new constant array type given the element type, size |
| /// modifier, (known) size of the array, and index type qualifiers. |
| /// |
| /// By default, performs semantic analysis when building the array type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildConstantArrayType(QualType ElementType, |
| ArrayType::ArraySizeModifier SizeMod, |
| const llvm::APInt &Size, |
| Expr *SizeExpr, |
| unsigned IndexTypeQuals, |
| SourceRange BracketsRange); |
| |
| /// Build a new incomplete array type given the element type, size |
| /// modifier, and index type qualifiers. |
| /// |
| /// By default, performs semantic analysis when building the array type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildIncompleteArrayType(QualType ElementType, |
| ArrayType::ArraySizeModifier SizeMod, |
| unsigned IndexTypeQuals, |
| SourceRange BracketsRange); |
| |
| /// Build a new variable-length array type given the element type, |
| /// size modifier, size expression, and index type qualifiers. |
| /// |
| /// By default, performs semantic analysis when building the array type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildVariableArrayType(QualType ElementType, |
| ArrayType::ArraySizeModifier SizeMod, |
| Expr *SizeExpr, |
| unsigned IndexTypeQuals, |
| SourceRange BracketsRange); |
| |
| /// Build a new dependent-sized array type given the element type, |
| /// size modifier, size expression, and index type qualifiers. |
| /// |
| /// By default, performs semantic analysis when building the array type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildDependentSizedArrayType(QualType ElementType, |
| ArrayType::ArraySizeModifier SizeMod, |
| Expr *SizeExpr, |
| unsigned IndexTypeQuals, |
| SourceRange BracketsRange); |
| |
| /// Build a new vector type given the element type and |
| /// number of elements. |
| /// |
| /// By default, performs semantic analysis when building the vector type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildVectorType(QualType ElementType, unsigned NumElements, |
| VectorType::VectorKind VecKind); |
| |
| /// Build a new potentially dependently-sized extended vector type |
| /// given the element type and number of elements. |
| /// |
| /// By default, performs semantic analysis when building the vector type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, |
| SourceLocation AttributeLoc, |
| VectorType::VectorKind); |
| |
| /// Build a new extended vector type given the element type and |
| /// number of elements. |
| /// |
| /// By default, performs semantic analysis when building the vector type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements, |
| SourceLocation AttributeLoc); |
| |
| /// Build a new potentially dependently-sized extended vector type |
| /// given the element type and number of elements. |
| /// |
| /// By default, performs semantic analysis when building the vector type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildDependentSizedExtVectorType(QualType ElementType, |
| Expr *SizeExpr, |
| SourceLocation AttributeLoc); |
| |
| /// Build a new DependentAddressSpaceType or return the pointee |
| /// type variable with the correct address space (retrieved from |
| /// AddrSpaceExpr) applied to it. The former will be returned in cases |
| /// where the address space remains dependent. |
| /// |
| /// By default, performs semantic analysis when building the type with address |
| /// space applied. Subclasses may override this routine to provide different |
| /// behavior. |
| QualType RebuildDependentAddressSpaceType(QualType PointeeType, |
| Expr *AddrSpaceExpr, |
| SourceLocation AttributeLoc); |
| |
| /// Build a new function type. |
| /// |
| /// By default, performs semantic analysis when building the function type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildFunctionProtoType(QualType T, |
| MutableArrayRef<QualType> ParamTypes, |
| const FunctionProtoType::ExtProtoInfo &EPI); |
| |
| /// Build a new unprototyped function type. |
| QualType RebuildFunctionNoProtoType(QualType ResultType); |
| |
| /// Rebuild an unresolved typename type, given the decl that |
| /// the UnresolvedUsingTypenameDecl was transformed to. |
| QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D); |
| |
| /// Build a new typedef type. |
| QualType RebuildTypedefType(TypedefNameDecl *Typedef) { |
| return SemaRef.Context.getTypeDeclType(Typedef); |
| } |
| |
| /// Build a new MacroDefined type. |
| QualType RebuildMacroQualifiedType(QualType T, |
| const IdentifierInfo *MacroII) { |
| return SemaRef.Context.getMacroQualifiedType(T, MacroII); |
| } |
| |
| /// Build a new class/struct/union type. |
| QualType RebuildRecordType(RecordDecl *Record) { |
| return SemaRef.Context.getTypeDeclType(Record); |
| } |
| |
| /// Build a new Enum type. |
| QualType RebuildEnumType(EnumDecl *Enum) { |
| return SemaRef.Context.getTypeDeclType(Enum); |
| } |
| |
| /// Build a new typeof(expr) type. |
| /// |
| /// By default, performs semantic analysis when building the typeof type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc); |
| |
| /// Build a new typeof(type) type. |
| /// |
| /// By default, builds a new TypeOfType with the given underlying type. |
| QualType RebuildTypeOfType(QualType Underlying); |
| |
| /// Build a new unary transform type. |
| QualType RebuildUnaryTransformType(QualType BaseType, |
| UnaryTransformType::UTTKind UKind, |
| SourceLocation Loc); |
| |
| /// Build a new C++11 decltype type. |
| /// |
| /// By default, performs semantic analysis when building the decltype type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc); |
| |
| /// Build a new C++11 auto type. |
| /// |
| /// By default, builds a new AutoType with the given deduced type. |
| 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, Keyword, |
| /*IsDependent*/ false); |
| } |
| |
| /// By default, builds a new DeducedTemplateSpecializationType with the given |
| /// deduced type. |
| QualType RebuildDeducedTemplateSpecializationType(TemplateName Template, |
| QualType Deduced) { |
| return SemaRef.Context.getDeducedTemplateSpecializationType( |
| Template, Deduced, /*IsDependent*/ false); |
| } |
| |
| /// Build a new template specialization type. |
| /// |
| /// By default, performs semantic analysis when building the template |
| /// specialization type. Subclasses may override this routine to provide |
| /// different behavior. |
| QualType RebuildTemplateSpecializationType(TemplateName Template, |
| SourceLocation TemplateLoc, |
| TemplateArgumentListInfo &Args); |
| |
| /// Build a new parenthesized type. |
| /// |
| /// By default, builds a new ParenType type from the inner type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildParenType(QualType InnerType) { |
| return SemaRef.BuildParenType(InnerType); |
| } |
| |
| /// Build a new qualified name type. |
| /// |
| /// By default, builds a new ElaboratedType type from the keyword, |
| /// the nested-name-specifier and the named type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildElaboratedType(SourceLocation KeywordLoc, |
| ElaboratedTypeKeyword Keyword, |
| NestedNameSpecifierLoc QualifierLoc, |
| QualType Named) { |
| return SemaRef.Context.getElaboratedType(Keyword, |
| QualifierLoc.getNestedNameSpecifier(), |
| Named); |
| } |
| |
| /// Build a new typename type that refers to a template-id. |
| /// |
| /// By default, builds a new DependentNameType type from the |
| /// nested-name-specifier and the given type. Subclasses may override |
| /// this routine to provide different behavior. |
| QualType RebuildDependentTemplateSpecializationType( |
| ElaboratedTypeKeyword Keyword, |
| NestedNameSpecifierLoc QualifierLoc, |
| SourceLocation TemplateKWLoc, |
| const IdentifierInfo *Name, |
| SourceLocation NameLoc, |
| TemplateArgumentListInfo &Args, |
| bool AllowInjectedClassName) { |
| // Rebuild the template name. |
| // TODO: avoid TemplateName abstraction |
| CXXScopeSpec SS; |
| SS.Adopt(QualifierLoc); |
| TemplateName InstName = getDerived().RebuildTemplateName( |
| SS, TemplateKWLoc, *Name, NameLoc, QualType(), nullptr, |
| AllowInjectedClassName); |
| |
| if (InstName.isNull()) |
| return QualType(); |
| |
| // If it's still dependent, make a dependent specialization. |
| if (InstName.getAsDependentTemplateName()) |
| return SemaRef.Context.getDependentTemplateSpecializationType(Keyword, |
| QualifierLoc.getNestedNameSpecifier(), |
| Name, |
| Args); |
| |
| // Otherwise, make an elaborated type wrapping a non-dependent |
| // specialization. |
| QualType T = |
| getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args); |
| if (T.isNull()) return QualType(); |
| |
| if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == nullptr) |
| return T; |
| |
| return SemaRef.Context.getElaboratedType(Keyword, |
| QualifierLoc.getNestedNameSpecifier(), |
| T); |
| } |
| |
| /// Build a new typename type that refers to an identifier. |
| /// |
| /// By default, performs semantic analysis when building the typename type |
| /// (or elaborated type). Subclasses may override this routine to provide |
| /// different behavior. |
| QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, |
| SourceLocation KeywordLoc, |
| NestedNameSpecifierLoc QualifierLoc, |
| const IdentifierInfo *Id, |
| SourceLocation IdLoc, |
| bool DeducedTSTContext) { |
| CXXScopeSpec SS; |
| SS.Adopt(QualifierLoc); |
| |
| if (QualifierLoc.getNestedNameSpecifier()->isDependent()) { |
| // If the name is still dependent, just build a new dependent name type. |
| if (!SemaRef.computeDeclContext(SS)) |
| return SemaRef.Context.getDependentNameType(Keyword, |
| QualifierLoc.getNestedNameSpecifier(), |
| Id); |
| } |
| |
| if (Keyword == ETK_None || Keyword == ETK_Typename) { |
| QualType T = SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc, |
| *Id, IdLoc); |
| // If a dependent name resolves to a deduced template specialization type, |
| // check that we're in one of the syntactic contexts permitting it. |
| if (!DeducedTSTContext) { |
| if (auto *Deduced = dyn_cast_or_null<DeducedTemplateSpecializationType>( |
| T.isNull() ? nullptr : T->getContainedDeducedType())) { |
| SemaRef.Diag(IdLoc, diag::err_dependent_deduced_tst) |
| << (int)SemaRef.getTemplateNameKindForDiagnostics( |
| Deduced->getTemplateName()) |
| << QualType(QualifierLoc.getNestedNameSpecifier()->getAsType(), 0); |
| if (auto *TD = Deduced->getTemplateName().getAsTemplateDecl()) |
| SemaRef.Diag(TD->getLocation(), diag::note_template_decl_here); |
| return QualType(); |
| } |
| } |
| return T; |
| } |
| |
| TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForKeyword(Keyword); |
| |
| // We had a dependent elaborated-type-specifier that has been transformed |
| // into a non-dependent elaborated-type-specifier. Find the tag we're |
| // referring to. |
| LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName); |
| DeclContext *DC = SemaRef.computeDeclContext(SS, false); |
| if (!DC) |
| return QualType(); |
| |
| if (SemaRef.RequireCompleteDeclContext(SS, DC)) |
| return QualType(); |
| |
| TagDecl *Tag = nullptr; |
| SemaRef.LookupQualifiedName(Result, DC); |
| switch (Result.getResultKind()) { |
| case LookupResult::NotFound: |
| case LookupResult::NotFoundInCurrentInstantiation: |
| break; |
| |
| case LookupResult::Found: |
| Tag = Result.getAsSingle<TagDecl>(); |
| break; |
| |
| case LookupResult::FoundOverloaded: |
| case LookupResult::FoundUnresolvedValue: |
| llvm_unreachable("Tag lookup cannot find non-tags"); |
| |
| case LookupResult::Ambiguous: |
| // Let the LookupResult structure handle ambiguities. |
| return QualType(); |
| } |
| |
| if (!Tag) { |
| // Check where the name exists but isn't a tag type and use that to emit |
| // better diagnostics. |
| LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName); |
| SemaRef.LookupQualifiedName(Result, DC); |
| switch (Result.getResultKind()) { |
| case LookupResult::Found: |
| case LookupResult::FoundOverloaded: |
| case LookupResult::FoundUnresolvedValue: { |
| NamedDecl *SomeDecl = Result.getRepresentativeDecl(); |
| Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind); |
| SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << SomeDecl |
| << NTK << Kind; |
| SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at); |
| break; |
| } |
| default: |
| SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope) |
| << Kind << Id << DC << QualifierLoc.getSourceRange(); |
| break; |
| } |
| return QualType(); |
| } |
| |
| if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false, |
| IdLoc, Id)) { |
| SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id; |
| SemaRef.Diag(Tag->getLocation(), diag::note_previous_use); |
| return QualType(); |
| } |
| |
| // Build the elaborated-type-specifier type. |
| QualType T = SemaRef.Context.getTypeDeclType(Tag); |
| return SemaRef.Context.getElaboratedType(Keyword, |
| QualifierLoc.getNestedNameSpecifier(), |
| T); |
| } |
| |
| /// Build a new pack expansion type. |
| /// |
| /// By default, builds a new PackExpansionType type from the given pattern. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildPackExpansionType(QualType Pattern, |
| SourceRange PatternRange, |
| SourceLocation EllipsisLoc, |
| Optional<unsigned> NumExpansions) { |
| return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc, |
| NumExpansions); |
| } |
| |
| /// Build a new atomic type given its value type. |
| /// |
| /// By default, performs semantic analysis when building the atomic type. |
| /// Subclasses may override this routine to provide different behavior. |
| QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc); |
| |
| /// Build a new pipe type given its value type. |
| QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, |
| bool isReadPipe); |
| |
| /// Build a new template name given a nested name specifier, a flag |
| /// indicating whether the "template" keyword was provided, and the template |
| /// that the template name refers to. |
| /// |
| /// By default, builds the new template name directly. Subclasses may override |
| /// this routine to provide different behavior. |
| TemplateName RebuildTemplateName(CXXScopeSpec &SS, |
| bool TemplateKW, |
| TemplateDecl *Template); |
| |
| /// Build a new template name given a nested name specifier and the |
| /// name that is referred to as a template. |
| /// |
| /// By default, performs semantic analysis to determine whether the name can |
| /// be resolved to a specific template, then builds the appropriate kind of |
| /// template name. Subclasses may override this routine to provide different |
| /// behavior. |
| TemplateName RebuildTemplateName(CXXScopeSpec &SS, |
| SourceLocation TemplateKWLoc, |
| const IdentifierInfo &Name, |
| SourceLocation NameLoc, QualType ObjectType, |
| NamedDecl *FirstQualifierInScope, |
| bool AllowInjectedClassName); |
| |
| /// Build a new template name given a nested name specifier and the |
| /// overloaded operator name that is referred to as a template. |
| /// |
| /// By default, performs semantic analysis to determine whether the name can |
| /// be resolved to a specific template, then builds the appropriate kind of |
| /// template name. Subclasses may override this routine to provide different |
| /// behavior. |
| TemplateName RebuildTemplateName(CXXScopeSpec &SS, |
| SourceLocation TemplateKWLoc, |
| OverloadedOperatorKind Operator, |
| SourceLocation NameLoc, QualType ObjectType, |
| bool AllowInjectedClassName); |
| |
| /// Build a new template name given a template template parameter pack |
| /// and the |
| /// |
| /// By default, performs semantic analysis to determine whether the name can |
| /// be resolved to a specific template, then builds the appropriate kind of |
| /// template name. Subclasses may override this routine to provide different |
| /// behavior. |
| TemplateName RebuildTemplateName(TemplateTemplateParmDecl *Param, |
| const TemplateArgument &ArgPack) { |
| return getSema().Context.getSubstTemplateTemplateParmPack(Param, ArgPack); |
| } |
| |
| /// Build a new compound statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, |
| MultiStmtArg Statements, |
| SourceLocation RBraceLoc, |
| bool IsStmtExpr) { |
| return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements, |
| IsStmtExpr); |
| } |
| |
| /// Build a new case statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildCaseStmt(SourceLocation CaseLoc, |
| Expr *LHS, |
| SourceLocation EllipsisLoc, |
| Expr *RHS, |
| SourceLocation ColonLoc) { |
| return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS, |
| ColonLoc); |
| } |
| |
| /// Attach the body to a new case statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body) { |
| getSema().ActOnCaseStmtBody(S, Body); |
| return S; |
| } |
| |
| /// Build a new default statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, |
| SourceLocation ColonLoc, |
| Stmt *SubStmt) { |
| return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt, |
| /*CurScope=*/nullptr); |
| } |
| |
| /// Build a new label statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, |
| SourceLocation ColonLoc, Stmt *SubStmt) { |
| return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt); |
| } |
| |
| /// Build a new label statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildAttributedStmt(SourceLocation AttrLoc, |
| ArrayRef<const Attr*> Attrs, |
| Stmt *SubStmt) { |
| return SemaRef.ActOnAttributedStmt(AttrLoc, Attrs, SubStmt); |
| } |
| |
| /// Build a new "if" statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildIfStmt(SourceLocation IfLoc, bool IsConstexpr, |
| Sema::ConditionResult Cond, Stmt *Init, Stmt *Then, |
| SourceLocation ElseLoc, Stmt *Else) { |
| return getSema().ActOnIfStmt(IfLoc, IsConstexpr, Init, Cond, Then, |
| ElseLoc, Else); |
| } |
| |
| /// Start building a new switch statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, Stmt *Init, |
| Sema::ConditionResult Cond) { |
| return getSema().ActOnStartOfSwitchStmt(SwitchLoc, Init, Cond); |
| } |
| |
| /// Attach the body to the switch statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, |
| Stmt *Switch, Stmt *Body) { |
| return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body); |
| } |
| |
| /// Build a new while statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildWhileStmt(SourceLocation WhileLoc, |
| Sema::ConditionResult Cond, Stmt *Body) { |
| return getSema().ActOnWhileStmt(WhileLoc, Cond, Body); |
| } |
| |
| /// Build a new do-while statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, |
| SourceLocation WhileLoc, SourceLocation LParenLoc, |
| Expr *Cond, SourceLocation RParenLoc) { |
| return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc, |
| Cond, RParenLoc); |
| } |
| |
| /// Build a new for statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, |
| Stmt *Init, Sema::ConditionResult Cond, |
| Sema::FullExprArg Inc, SourceLocation RParenLoc, |
| Stmt *Body) { |
| return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond, |
| Inc, RParenLoc, Body); |
| } |
| |
| /// Build a new goto statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, |
| LabelDecl *Label) { |
| return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label); |
| } |
| |
| /// Build a new indirect goto statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc, |
| SourceLocation StarLoc, |
| Expr *Target) { |
| return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target); |
| } |
| |
| /// Build a new return statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result) { |
| return getSema().BuildReturnStmt(ReturnLoc, Result); |
| } |
| |
| /// Build a new declaration statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildDeclStmt(MutableArrayRef<Decl *> Decls, |
| SourceLocation StartLoc, SourceLocation EndLoc) { |
| Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls); |
| return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc); |
| } |
| |
| /// Build a new inline asm statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, |
| bool IsVolatile, unsigned NumOutputs, |
| unsigned NumInputs, IdentifierInfo **Names, |
| MultiExprArg Constraints, MultiExprArg Exprs, |
| Expr *AsmString, MultiExprArg Clobbers, |
| unsigned NumLabels, |
| SourceLocation RParenLoc) { |
| return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, |
| NumInputs, Names, Constraints, Exprs, |
| AsmString, Clobbers, NumLabels, RParenLoc); |
| } |
| |
| /// Build a new MS style inline asm statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, |
| ArrayRef<Token> AsmToks, |
| StringRef AsmString, |
| unsigned NumOutputs, unsigned NumInputs, |
| ArrayRef<StringRef> Constraints, |
| ArrayRef<StringRef> Clobbers, |
| ArrayRef<Expr*> Exprs, |
| SourceLocation EndLoc) { |
| return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString, |
| NumOutputs, NumInputs, |
| Constraints, Clobbers, Exprs, EndLoc); |
| } |
| |
| /// 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, |
| bool IsImplicit) { |
| return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit); |
| } |
| |
| /// 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, |
| bool IsImplicit) { |
| return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Result, IsImplicit); |
| } |
| |
| /// 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 RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, |
| Expr *Result, |
| UnresolvedLookupExpr *Lookup) { |
| return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup); |
| } |
| |
| /// 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); |
| } |
| |
| StmtResult RebuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args) { |
| return getSema().BuildCoroutineBodyStmt(Args); |
| } |
| |
| /// Build a new Objective-C \@try statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, |
| Stmt *TryBody, |
| MultiStmtArg CatchStmts, |
| Stmt *Finally) { |
| return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts, |
| Finally); |
| } |
| |
| /// Rebuild an Objective-C exception declaration. |
| /// |
| /// By default, performs semantic analysis to build the new declaration. |
| /// Subclasses may override this routine to provide different behavior. |
| VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, |
| TypeSourceInfo *TInfo, QualType T) { |
| return getSema().BuildObjCExceptionDecl(TInfo, T, |
| ExceptionDecl->getInnerLocStart(), |
| ExceptionDecl->getLocation(), |
| ExceptionDecl->getIdentifier()); |
| } |
| |
| /// Build a new Objective-C \@catch statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, |
| SourceLocation RParenLoc, |
| VarDecl *Var, |
| Stmt *Body) { |
| return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, |
| Var, Body); |
| } |
| |
| /// Build a new Objective-C \@finally statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc, |
| Stmt *Body) { |
| return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body); |
| } |
| |
| /// Build a new Objective-C \@throw statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc, |
| Expr *Operand) { |
| return getSema().BuildObjCAtThrowStmt(AtLoc, Operand); |
| } |
| |
| /// Build a new OpenMP executable directive. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, |
| DeclarationNameInfo DirName, |
| OpenMPDirectiveKind CancelRegion, |
| ArrayRef<OMPClause *> Clauses, |
| Stmt *AStmt, SourceLocation StartLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPExecutableDirective( |
| Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc); |
| } |
| |
| /// Build a new OpenMP 'if' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, |
| Expr *Condition, SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation NameModifierLoc, |
| SourceLocation ColonLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPIfClause(NameModifier, Condition, StartLoc, |
| LParenLoc, NameModifierLoc, ColonLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'final' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPFinalClause(Expr *Condition, SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPFinalClause(Condition, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'num_threads' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPNumThreadsClause(Expr *NumThreads, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPNumThreadsClause(NumThreads, StartLoc, |
| LParenLoc, EndLoc); |
| } |
| |
| /// Build a new OpenMP 'safelen' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc, EndLoc); |
| } |
| |
| /// 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); |
| } |
| |
| /// Build a new OpenMP 'allocator' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc, EndLoc); |
| } |
| |
| /// Build a new OpenMP 'collapse' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPCollapseClause(Num, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'default' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPDefaultClause(OpenMPDefaultClauseKind Kind, |
| SourceLocation KindKwLoc, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPDefaultClause(Kind, KindKwLoc, |
| StartLoc, LParenLoc, EndLoc); |
| } |
| |
| /// Build a new OpenMP 'proc_bind' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPProcBindClause(OpenMPProcBindClauseKind Kind, |
| SourceLocation KindKwLoc, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPProcBindClause(Kind, KindKwLoc, |
| StartLoc, LParenLoc, EndLoc); |
| } |
| |
| /// Build a new OpenMP 'schedule' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| 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( |
| M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc, |
| CommaLoc, EndLoc); |
| } |
| |
| /// 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); |
| } |
| |
| /// Build a new OpenMP 'private' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPPrivateClause(ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPPrivateClause(VarList, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'firstprivate' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPFirstprivateClause(ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPFirstprivateClause(VarList, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'lastprivate' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPLastprivateClause(ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPLastprivateClause(VarList, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'shared' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPSharedClause(ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPSharedClause(VarList, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'reduction' clause. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPReductionClause(ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation ColonLoc, |
| SourceLocation EndLoc, |
| CXXScopeSpec &ReductionIdScopeSpec, |
| const DeclarationNameInfo &ReductionId, |
| ArrayRef<Expr *> UnresolvedReductions) { |
| return getSema().ActOnOpenMPReductionClause( |
| VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, |
| ReductionId, UnresolvedReductions); |
| } |
| |
| /// Build a new OpenMP 'task_reduction' clause. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPTaskReductionClause( |
| ArrayRef<Expr *> VarList, SourceLocation StartLoc, |
| SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, |
| CXXScopeSpec &ReductionIdScopeSpec, |
| const DeclarationNameInfo &ReductionId, |
| ArrayRef<Expr *> UnresolvedReductions) { |
| return getSema().ActOnOpenMPTaskReductionClause( |
| VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, |
| ReductionId, UnresolvedReductions); |
| } |
| |
| /// Build a new OpenMP 'in_reduction' clause. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause * |
| RebuildOMPInReductionClause(ArrayRef<Expr *> VarList, SourceLocation StartLoc, |
| SourceLocation LParenLoc, SourceLocation ColonLoc, |
| SourceLocation EndLoc, |
| CXXScopeSpec &ReductionIdScopeSpec, |
| const DeclarationNameInfo &ReductionId, |
| ArrayRef<Expr *> UnresolvedReductions) { |
| return getSema().ActOnOpenMPInReductionClause( |
| VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec, |
| ReductionId, UnresolvedReductions); |
| } |
| |
| /// Build a new OpenMP 'linear' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| 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, |
| Modifier, ModifierLoc, ColonLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'aligned' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPAlignedClause(ArrayRef<Expr *> VarList, Expr *Alignment, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation ColonLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPAlignedClause(VarList, Alignment, StartLoc, |
| LParenLoc, ColonLoc, EndLoc); |
| } |
| |
| /// Build a new OpenMP 'copyin' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPCopyinClause(ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPCopyinClause(VarList, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'copyprivate' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPCopyprivateClause(ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPCopyprivateClause(VarList, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'flush' pseudo clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPFlushClause(ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPFlushClause(VarList, StartLoc, LParenLoc, |
| EndLoc); |
| } |
| |
| /// Build a new OpenMP 'depend' pseudo clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause * |
| RebuildOMPDependClause(OpenMPDependClauseKind DepKind, SourceLocation DepLoc, |
| SourceLocation ColonLoc, ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, SourceLocation LParenLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPDependClause(DepKind, DepLoc, ColonLoc, VarList, |
| StartLoc, LParenLoc, EndLoc); |
| } |
| |
| /// 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); |
| } |
| |
| /// 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( |
| ArrayRef<OpenMPMapModifierKind> MapTypeModifiers, |
| ArrayRef<SourceLocation> MapTypeModifiersLoc, |
| CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId, |
| OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, |
| SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList, |
| const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) { |
| return getSema().ActOnOpenMPMapClause(MapTypeModifiers, MapTypeModifiersLoc, |
| MapperIdScopeSpec, MapperId, MapType, |
| IsMapTypeImplicit, MapLoc, ColonLoc, |
| VarList, Locs, UnresolvedMappers); |
| } |
| |
| /// Build a new OpenMP 'allocate' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPAllocateClause(Expr *Allocate, ArrayRef<Expr *> VarList, |
| SourceLocation StartLoc, |
| SourceLocation LParenLoc, |
| SourceLocation ColonLoc, |
| SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPAllocateClause(Allocate, VarList, StartLoc, |
| LParenLoc, ColonLoc, EndLoc); |
| } |
| |
| /// 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); |
| } |
| |
| /// 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); |
| } |
| |
| /// 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); |
| } |
| |
| /// 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); |
| } |
| |
| /// 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); |
| } |
| |
| /// 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); |
| } |
| |
| /// Build a new OpenMP 'dist_schedule' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause * |
| RebuildOMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, |
| Expr *ChunkSize, SourceLocation StartLoc, |
| SourceLocation LParenLoc, SourceLocation KindLoc, |
| SourceLocation CommaLoc, SourceLocation EndLoc) { |
| return getSema().ActOnOpenMPDistScheduleClause( |
| Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc); |
| } |
| |
| /// Build a new OpenMP 'to' clause. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPToClause(ArrayRef<Expr *> VarList, |
| CXXScopeSpec &MapperIdScopeSpec, |
| DeclarationNameInfo &MapperId, |
| const OMPVarListLocTy &Locs, |
| ArrayRef<Expr *> UnresolvedMappers) { |
| return getSema().ActOnOpenMPToClause(VarList, MapperIdScopeSpec, MapperId, |
| Locs, UnresolvedMappers); |
| } |
| |
| /// Build a new OpenMP 'from' clause. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPFromClause(ArrayRef<Expr *> VarList, |
| CXXScopeSpec &MapperIdScopeSpec, |
| DeclarationNameInfo &MapperId, |
| const OMPVarListLocTy &Locs, |
| ArrayRef<Expr *> UnresolvedMappers) { |
| return getSema().ActOnOpenMPFromClause(VarList, MapperIdScopeSpec, MapperId, |
| Locs, UnresolvedMappers); |
| } |
| |
| /// Build a new OpenMP 'use_device_ptr' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPUseDevicePtrClause(ArrayRef<Expr *> VarList, |
| const OMPVarListLocTy &Locs) { |
| return getSema().ActOnOpenMPUseDevicePtrClause(VarList, Locs); |
| } |
| |
| /// Build a new OpenMP 'is_device_ptr' clause. |
| /// |
| /// By default, performs semantic analysis to build the new OpenMP clause. |
| /// Subclasses may override this routine to provide different behavior. |
| OMPClause *RebuildOMPIsDevicePtrClause(ArrayRef<Expr *> VarList, |
| const OMPVarListLocTy &Locs) { |
| return getSema().ActOnOpenMPIsDevicePtrClause(VarList, Locs); |
| } |
| |
| /// Rebuild the operand to an Objective-C \@synchronized statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc, |
| Expr *object) { |
| return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object); |
| } |
| |
| /// Build a new Objective-C \@synchronized statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, |
| Expr *Object, Stmt *Body) { |
| return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body); |
| } |
| |
| /// Build a new Objective-C \@autoreleasepool statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, |
| Stmt *Body) { |
| return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body); |
| } |
| |
| /// Build a new Objective-C fast enumeration statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc, |
| Stmt *Element, |
| Expr *Collection, |
| SourceLocation RParenLoc, |
| Stmt *Body) { |
| StmtResult ForEachStmt = getSema().ActOnObjCForCollectionStmt(ForLoc, |
| Element, |
| Collection, |
| RParenLoc); |
| if (ForEachStmt.isInvalid()) |
| return StmtError(); |
| |
| return getSema().FinishObjCForCollectionStmt(ForEachStmt.get(), Body); |
| } |
| |
| /// Build a new C++ exception declaration. |
| /// |
| /// By default, performs semantic analysis to build the new decaration. |
| /// Subclasses may override this routine to provide different behavior. |
| VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, |
| TypeSourceInfo *Declarator, |
| SourceLocation StartLoc, |
| SourceLocation IdLoc, |
| IdentifierInfo *Id) { |
| VarDecl *Var = getSema().BuildExceptionDeclaration(nullptr, Declarator, |
| StartLoc, IdLoc, Id); |
| if (Var) |
| getSema().CurContext->addDecl(Var); |
| return Var; |
| } |
| |
| /// Build a new C++ catch statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, |
| VarDecl *ExceptionDecl, |
| Stmt *Handler) { |
| return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl, |
| Handler)); |
| } |
| |
| /// Build a new C++ try statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, |
| ArrayRef<Stmt *> Handlers) { |
| return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers); |
| } |
| |
| /// Build a new C++0x range-based for statement. |
| /// |
| /// 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, Stmt *Init, |
| SourceLocation ColonLoc, Stmt *Range, |
| Stmt *Begin, Stmt *End, Expr *Cond, |
| Expr *Inc, Stmt *LoopVar, |
| SourceLocation RParenLoc) { |
| // If we've just learned that the range is actually an Objective-C |
| // collection, treat this as an Objective-C fast enumeration loop. |
| if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) { |
| if (RangeStmt->isSingleDecl()) { |
| if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) { |
| if (RangeVar->isInvalidDecl()) |
| return StmtError(); |
| |
| Expr *RangeExpr = RangeVar->getInit(); |
| if (!RangeExpr->isTypeDependent() && |
| RangeExpr->getType()->isObjCObjectPointerType()) { |
| // FIXME: Support init-statements in Objective-C++20 ranged for |
| // statement. |
| if (Init) { |
| return SemaRef.Diag(Init->getBeginLoc(), |
| diag::err_objc_for_range_init_stmt) |
| << Init->getSourceRange(); |
| } |
| return getSema().ActOnObjCForCollectionStmt(ForLoc, LoopVar, |
| RangeExpr, RParenLoc); |
| } |
| } |
| } |
| } |
| |
| return getSema().BuildCXXForRangeStmt(ForLoc, CoawaitLoc, Init, ColonLoc, |
| Range, Begin, End, Cond, Inc, LoopVar, |
| RParenLoc, Sema::BFRK_Rebuild); |
| } |
| |
| /// Build a new C++0x range-based for statement. |
| /// |
| /// By default, performs semantic analysis to build the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc, |
| bool IsIfExists, |
| NestedNameSpecifierLoc QualifierLoc, |
| DeclarationNameInfo NameInfo, |
| Stmt *Nested) { |
| return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists, |
| QualifierLoc, NameInfo, Nested); |
| } |
| |
| /// Attach body to a C++0x range-based for statement. |
| /// |
| /// By default, performs semantic analysis to finish the new statement. |
| /// Subclasses may override this routine to provide different behavior. |
| StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body) { |
| return getSema().FinishCXXForRangeStmt(ForRange, Body); |
| } |
| |
| StmtResult RebuildSEHTryStmt(bool IsCXXTry, SourceLocation TryLoc, |
| Stmt *TryBlock, Stmt *Handler) { |
| return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler); |
| } |
| |
| StmtResult RebuildSEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, |
| Stmt *Block) { |
| return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block); |
| } |
| |
| StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block) { |
| return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block); |
| } |
| |
| /// Build a new predefined expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildPredefinedExpr(SourceLocation Loc, |
| PredefinedExpr::IdentKind IK) { |
| return getSema().BuildPredefinedExpr(Loc, IK); |
| } |
| |
| /// Build a new expression that references a declaration. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, |
| LookupResult &R, |
| bool RequiresADL) { |
| return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL); |
| } |
| |
| |
| /// Build a new expression that references a declaration. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, |
| ValueDecl *VD, |
| const DeclarationNameInfo &NameInfo, |
| NamedDecl *Found, |
| TemplateArgumentListInfo *TemplateArgs) { |
| CXXScopeSpec SS; |
| SS.Adopt(QualifierLoc); |
| return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found, |
| TemplateArgs); |
| } |
| |
| /// Build a new expression in parentheses. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildParenExpr(Expr *SubExpr, SourceLocation LParen, |
| SourceLocation RParen) { |
| return getSema().ActOnParenExpr(LParen, RParen, SubExpr); |
| } |
| |
| /// Build a new pseudo-destructor expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, |
| SourceLocation OperatorLoc, |
| bool isArrow, |
| CXXScopeSpec &SS, |
| TypeSourceInfo *ScopeType, |
| SourceLocation CCLoc, |
| SourceLocation TildeLoc, |
| PseudoDestructorTypeStorage Destroyed); |
| |
| /// Build a new unary operator expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildUnaryOperator(SourceLocation OpLoc, |
| UnaryOperatorKind Opc, |
| Expr *SubExpr) { |
| return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr); |
| } |
| |
| /// Build a new builtin offsetof expression. |
| /// |
| /// 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, |
| ArrayRef<Sema::OffsetOfComponent> Components, |
| SourceLocation RParenLoc) { |
| return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components, |
| RParenLoc); |
| } |
| |
| /// Build a new sizeof, alignof or vec_step expression with a |
| /// type argument. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo, |
| SourceLocation OpLoc, |
| UnaryExprOrTypeTrait ExprKind, |
| SourceRange R) { |
| return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R); |
| } |
| |
| /// Build a new sizeof, alignof or vec step expression with an |
| /// expression argument. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc, |
| UnaryExprOrTypeTrait ExprKind, |
| SourceRange R) { |
| ExprResult Result |
| = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind); |
| if (Result.isInvalid()) |
| return ExprError(); |
| |
| return Result; |
| } |
| |
| /// Build a new array subscript expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildArraySubscriptExpr(Expr *LHS, |
| SourceLocation LBracketLoc, |
| Expr *RHS, |
| SourceLocation RBracketLoc) { |
| return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS, |
| LBracketLoc, RHS, |
| RBracketLoc); |
| } |
| |
| /// 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); |
| } |
| |
| /// Build a new call expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, |
| MultiExprArg Args, |
| SourceLocation RParenLoc, |
| Expr *ExecConfig = nullptr) { |
| return getSema().BuildCallExpr(/*Scope=*/nullptr, Callee, LParenLoc, Args, |
| RParenLoc, ExecConfig); |
| } |
| |
| /// Build a new member access expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildMemberExpr(Expr *Base, SourceLocation OpLoc, |
| bool isArrow, |
| NestedNameSpecifierLoc QualifierLoc, |
| SourceLocation TemplateKWLoc, |
| const DeclarationNameInfo &MemberNameInfo, |
| ValueDecl *Member, |
| NamedDecl *FoundDecl, |
| const TemplateArgumentListInfo *ExplicitTemplateArgs, |
| NamedDecl *FirstQualifierInScope) { |
| ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base, |
| isArrow); |
| if (!Member->getDeclName()) { |
| // We have a reference to an unnamed field. This is always the |
| // base of an anonymous struct/union member access, i.e. the |
| // field is always of record type. |
| assert(Member->getType()->isRecordType() && |
| "unnamed member not of record type?"); |
| |
| BaseResult = |
| getSema().PerformObjectMemberConversion(BaseResult.get(), |
| QualifierLoc.getNestedNameSpecifier(), |
| FoundDecl, Member); |
| if (BaseResult.isInvalid()) |
| return ExprError(); |
| Base = BaseResult.get(); |
| |
| CXXScopeSpec EmptySS; |
| return getSema().BuildFieldReferenceExpr( |
| Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member), |
| DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), MemberNameInfo); |
| } |
| |
| CXXScopeSpec SS; |
| SS.Adopt(QualifierLoc); |
| |
| Base = BaseResult.get(); |
| QualType BaseType = Base->getType(); |
| |
| if (isArrow && !BaseType->isPointerType()) |
| return ExprError(); |
| |
| // FIXME: this involves duplicating earlier analysis in a lot of |
| // cases; we should avoid this when possible. |
| LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName); |
| R.addDecl(FoundDecl); |
| R.resolveKind(); |
| |
| return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow, |
| SS, TemplateKWLoc, |
| FirstQualifierInScope, |
| R, ExplicitTemplateArgs, |
| /*S*/nullptr); |
| } |
| |
| /// Build a new binary operator expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildBinaryOperator(SourceLocation OpLoc, |
| BinaryOperatorKind Opc, |
| Expr *LHS, Expr *RHS) { |
| return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS); |
| } |
| |
| /// Build a new conditional operator expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildConditionalOperator(Expr *Cond, |
| SourceLocation QuestionLoc, |
| Expr *LHS, |
| SourceLocation ColonLoc, |
| Expr *RHS) { |
| return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond, |
| LHS, RHS); |
| } |
| |
| /// Build a new C-style cast expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, |
| TypeSourceInfo *TInfo, |
| SourceLocation RParenLoc, |
| Expr *SubExpr) { |
| return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, |
| SubExpr); |
| } |
| |
| /// Build a new compound literal expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, |
| TypeSourceInfo *TInfo, |
| SourceLocation RParenLoc, |
| Expr *Init) { |
| return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, |
| Init); |
| } |
| |
| /// Build a new extended vector element access expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildExtVectorElementExpr(Expr *Base, |
| SourceLocation OpLoc, |
| SourceLocation AccessorLoc, |
| IdentifierInfo &Accessor) { |
| |
| CXXScopeSpec SS; |
| DeclarationNameInfo NameInfo(&Accessor, AccessorLoc); |
| return getSema().BuildMemberReferenceExpr(Base, Base->getType(), |
| OpLoc, /*IsArrow*/ false, |
| SS, SourceLocation(), |
| /*FirstQualifierInScope*/ nullptr, |
| NameInfo, |
| /* TemplateArgs */ nullptr, |
| /*S*/ nullptr); |
| } |
| |
| /// Build a new initializer list expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildInitList(SourceLocation LBraceLoc, |
| MultiExprArg Inits, |
| SourceLocation RBraceLoc) { |
| return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc); |
| } |
| |
| /// Build a new designated initializer expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildDesignatedInitExpr(Designation &Desig, |
| MultiExprArg ArrayExprs, |
| SourceLocation EqualOrColonLoc, |
| bool GNUSyntax, |
| Expr *Init) { |
| ExprResult Result |
| = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax, |
| Init); |
| if (Result.isInvalid()) |
| return ExprError(); |
| |
| return Result; |
| } |
| |
| /// Build a new value-initialized expression. |
| /// |
| /// By default, builds the implicit value initialization without performing |
| /// any semantic analysis. Subclasses may override this routine to provide |
| /// different behavior. |
| ExprResult RebuildImplicitValueInitExpr(QualType T) { |
| return new (SemaRef.Context) ImplicitValueInitExpr(T); |
| } |
| |
| /// Build a new \c va_arg expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, |
| Expr *SubExpr, TypeSourceInfo *TInfo, |
| SourceLocation RParenLoc) { |
| return getSema().BuildVAArgExpr(BuiltinLoc, |
| SubExpr, TInfo, |
| RParenLoc); |
| } |
| |
| /// Build a new expression list in parentheses. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildParenListExpr(SourceLocation LParenLoc, |
| MultiExprArg SubExprs, |
| SourceLocation RParenLoc) { |
| return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs); |
| } |
| |
| /// Build a new address-of-label expression. |
| /// |
| /// By default, performs semantic analysis, using the name of the label |
| /// rather than attempting to map the label statement itself. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, |
| SourceLocation LabelLoc, LabelDecl *Label) { |
| return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label); |
| } |
| |
| /// Build a new GNU statement expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildStmtExpr(SourceLocation LParenLoc, |
| Stmt *SubStmt, |
| SourceLocation RParenLoc) { |
| return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc); |
| } |
| |
| /// Build a new __builtin_choose_expr expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc, |
| Expr *Cond, Expr *LHS, Expr *RHS, |
| SourceLocation RParenLoc) { |
| return SemaRef.ActOnChooseExpr(BuiltinLoc, |
| Cond, LHS, RHS, |
| RParenLoc); |
| } |
| |
| /// Build a new generic selection expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, |
| SourceLocation DefaultLoc, |
| SourceLocation RParenLoc, |
| Expr *ControllingExpr, |
| ArrayRef<TypeSourceInfo *> Types, |
| ArrayRef<Expr *> Exprs) { |
| return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc, |
| ControllingExpr, Types, Exprs); |
| } |
| |
| /// Build a new overloaded operator call expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// The semantic analysis provides the behavior of template instantiation, |
| /// copying with transformations that turn what looks like an overloaded |
| /// operator call into a use of a builtin operator, performing |
| /// argument-dependent lookup, etc. Subclasses may override this routine to |
| /// provide different behavior. |
| ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, |
| SourceLocation OpLoc, |
| Expr *Callee, |
| Expr *First, |
| Expr *Second); |
| |
| /// Build a new C++ "named" cast expression, such as static_cast or |
| /// reinterpret_cast. |
| /// |
| /// By default, this routine dispatches to one of the more-specific routines |
| /// for a particular named case, e.g., RebuildCXXStaticCastExpr(). |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc, |
| Stmt::StmtClass Class, |
| SourceLocation LAngleLoc, |
| TypeSourceInfo *TInfo, |
| SourceLocation RAngleLoc, |
| SourceLocation LParenLoc, |
| Expr *SubExpr, |
| SourceLocation RParenLoc) { |
| switch (Class) { |
| case Stmt::CXXStaticCastExprClass: |
| return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo, |
| RAngleLoc, LParenLoc, |
| SubExpr, RParenLoc); |
| |
| case Stmt::CXXDynamicCastExprClass: |
| return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo, |
| RAngleLoc, LParenLoc, |
| SubExpr, RParenLoc); |
| |
| case Stmt::CXXReinterpretCastExprClass: |
| return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo, |
| RAngleLoc, LParenLoc, |
| SubExpr, |
| RParenLoc); |
| |
| case Stmt::CXXConstCastExprClass: |
| return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo, |
| RAngleLoc, LParenLoc, |
| SubExpr, RParenLoc); |
| |
| default: |
| llvm_unreachable("Invalid C++ named cast"); |
| } |
| } |
| |
| /// Build a new C++ static_cast expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc, |
| SourceLocation LAngleLoc, |
| TypeSourceInfo *TInfo, |
| SourceLocation RAngleLoc, |
| SourceLocation LParenLoc, |
| Expr *SubExpr, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast, |
| TInfo, SubExpr, |
| SourceRange(LAngleLoc, RAngleLoc), |
| SourceRange(LParenLoc, RParenLoc)); |
| } |
| |
| /// Build a new C++ dynamic_cast expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, |
| SourceLocation LAngleLoc, |
| TypeSourceInfo *TInfo, |
| SourceLocation RAngleLoc, |
| SourceLocation LParenLoc, |
| Expr *SubExpr, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast, |
| TInfo, SubExpr, |
| SourceRange(LAngleLoc, RAngleLoc), |
| SourceRange(LParenLoc, RParenLoc)); |
| } |
| |
| /// Build a new C++ reinterpret_cast expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, |
| SourceLocation LAngleLoc, |
| TypeSourceInfo *TInfo, |
| SourceLocation RAngleLoc, |
| SourceLocation LParenLoc, |
| Expr *SubExpr, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast, |
| TInfo, SubExpr, |
| SourceRange(LAngleLoc, RAngleLoc), |
| SourceRange(LParenLoc, RParenLoc)); |
| } |
| |
| /// Build a new C++ const_cast expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, |
| SourceLocation LAngleLoc, |
| TypeSourceInfo *TInfo, |
| SourceLocation RAngleLoc, |
| SourceLocation LParenLoc, |
| Expr *SubExpr, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast, |
| TInfo, SubExpr, |
| SourceRange(LAngleLoc, RAngleLoc), |
| SourceRange(LParenLoc, RParenLoc)); |
| } |
| |
| /// Build a new C++ functional-style cast expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, |
| SourceLocation LParenLoc, |
| Expr *Sub, |
| SourceLocation RParenLoc, |
| bool ListInitialization) { |
| return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc, |
| MultiExprArg(&Sub, 1), RParenLoc, |
| ListInitialization); |
| } |
| |
| /// Build a new C++ __builtin_bit_cast expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildBuiltinBitCastExpr(SourceLocation KWLoc, |
| TypeSourceInfo *TSI, Expr *Sub, |
| SourceLocation RParenLoc) { |
| return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc); |
| } |
| |
| /// Build a new C++ typeid(type) expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, |
| SourceLocation TypeidLoc, |
| TypeSourceInfo *Operand, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand, |
| RParenLoc); |
| } |
| |
| |
| /// Build a new C++ typeid(expr) expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, |
| SourceLocation TypeidLoc, |
| Expr *Operand, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand, |
| RParenLoc); |
| } |
| |
| /// Build a new C++ __uuidof(type) expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, |
| SourceLocation TypeidLoc, |
| TypeSourceInfo *Operand, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand, |
| RParenLoc); |
| } |
| |
| /// Build a new C++ __uuidof(expr) expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, |
| SourceLocation TypeidLoc, |
| Expr *Operand, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand, |
| RParenLoc); |
| } |
| |
| /// Build a new C++ "this" expression. |
| /// |
| /// By default, builds a new "this" expression without performing any |
| /// semantic analysis. Subclasses may override this routine to provide |
| /// different behavior. |
| ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, |
| QualType ThisType, |
| bool isImplicit) { |
| return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit); |
| } |
| |
| /// Build a new C++ throw expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, |
| bool IsThrownVariableInScope) { |
| return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope); |
| } |
| |
| /// Build a new C++ default-argument expression. |
| /// |
| /// By default, builds a new default-argument expression, which does not |
| /// require any semantic analysis. Subclasses may override this routine to |
| /// provide different behavior. |
| ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, ParmVarDecl *Param) { |
| return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param, |
| getSema().CurContext); |
| } |
| |
| /// Build a new C++11 default-initialization expression. |
| /// |
| /// By default, builds a new default field initialization expression, which |
| /// does not require any semantic analysis. Subclasses may override this |
| /// routine to provide different behavior. |
| ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, |
| FieldDecl *Field) { |
| return CXXDefaultInitExpr::Create(getSema().Context, Loc, Field, |
| getSema().CurContext); |
| } |
| |
| /// Build a new C++ zero-initialization expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, |
| SourceLocation LParenLoc, |
| SourceLocation RParenLoc) { |
| return getSema().BuildCXXTypeConstructExpr( |
| TSInfo, LParenLoc, None, RParenLoc, /*ListInitialization=*/false); |
| } |
| |
| /// Build a new C++ "new" expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, |
| bool UseGlobal, |
| SourceLocation PlacementLParen, |
| MultiExprArg PlacementArgs, |
| SourceLocation PlacementRParen, |
| SourceRange TypeIdParens, |
| QualType AllocatedType, |
| TypeSourceInfo *AllocatedTypeInfo, |
| Optional<Expr *> ArraySize, |
| SourceRange DirectInitRange, |
| Expr *Initializer) { |
| return getSema().BuildCXXNew(StartLoc, UseGlobal, |
| PlacementLParen, |
| PlacementArgs, |
| PlacementRParen, |
| TypeIdParens, |
| AllocatedType, |
| AllocatedTypeInfo, |
| ArraySize, |
| DirectInitRange, |
| Initializer); |
| } |
| |
| /// Build a new C++ "delete" expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, |
| bool IsGlobalDelete, |
| bool IsArrayForm, |
| Expr *Operand) { |
| return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm, |
| Operand); |
| } |
| |
| /// Build a new type trait expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildTypeTrait(TypeTrait Trait, |
| SourceLocation StartLoc, |
| ArrayRef<TypeSourceInfo *> Args, |
| SourceLocation RParenLoc) { |
| return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc); |
| } |
| |
| /// Build a new array type trait expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, |
| SourceLocation StartLoc, |
| TypeSourceInfo *TSInfo, |
| Expr *DimExpr, |
| SourceLocation RParenLoc) { |
| return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc); |
| } |
| |
| /// Build a new expression trait expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildExpressionTrait(ExpressionTrait Trait, |
| SourceLocation StartLoc, |
| Expr *Queried, |
| SourceLocation RParenLoc) { |
| return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc); |
| } |
| |
| /// Build a new (previously unresolved) declaration reference |
| /// expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildDependentScopeDeclRefExpr( |
| NestedNameSpecifierLoc QualifierLoc, |
| SourceLocation TemplateKWLoc, |
| const DeclarationNameInfo &NameInfo, |
| const TemplateArgumentListInfo *TemplateArgs, |
| bool IsAddressOfOperand, |
| TypeSourceInfo **RecoveryTSI) { |
| CXXScopeSpec SS; |
| SS.Adopt(QualifierLoc); |
| |
| if (TemplateArgs || TemplateKWLoc.isValid()) |
| return getSema().BuildQualifiedTemplateIdExpr(SS, TemplateKWLoc, NameInfo, |
| TemplateArgs); |
| |
| return getSema().BuildQualifiedDeclarationNameExpr( |
| SS, NameInfo, IsAddressOfOperand, /*S*/nullptr, RecoveryTSI); |
| } |
| |
| /// Build a new template-id expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, |
| SourceLocation TemplateKWLoc, |
| LookupResult &R, |
| bool RequiresADL, |
| const TemplateArgumentListInfo *TemplateArgs) { |
| return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL, |
| TemplateArgs); |
| } |
| |
| /// Build a new object-construction expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXConstructExpr(QualType T, |
| SourceLocation Loc, |
| CXXConstructorDecl *Constructor, |
| bool IsElidable, |
| MultiExprArg Args, |
| bool HadMultipleCandidates, |
| bool ListInitialization, |
| bool StdInitListInitialization, |
| bool RequiresZeroInit, |
| CXXConstructExpr::ConstructionKind ConstructKind, |
| SourceRange ParenRange) { |
| SmallVector<Expr*, 8> ConvertedArgs; |
| if (getSema().CompleteConstructorCall(Constructor, Args, Loc, |
| ConvertedArgs)) |
| return ExprError(); |
| |
| return getSema().BuildCXXConstructExpr(Loc, T, Constructor, |
| IsElidable, |
| ConvertedArgs, |
| HadMultipleCandidates, |
| ListInitialization, |
| StdInitListInitialization, |
| RequiresZeroInit, ConstructKind, |
| ParenRange); |
| } |
| |
| /// Build a new implicit construction via inherited constructor |
| /// expression. |
| ExprResult RebuildCXXInheritedCtorInitExpr(QualType T, SourceLocation Loc, |
| CXXConstructorDecl *Constructor, |
| bool ConstructsVBase, |
| bool InheritedFromVBase) { |
| return new (getSema().Context) CXXInheritedCtorInitExpr( |
| Loc, T, Constructor, ConstructsVBase, InheritedFromVBase); |
| } |
| |
| /// Build a new object-construction expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, |
| SourceLocation LParenOrBraceLoc, |
| MultiExprArg Args, |
| SourceLocation RParenOrBraceLoc, |
| bool ListInitialization) { |
| return getSema().BuildCXXTypeConstructExpr( |
| TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization); |
| } |
| |
| /// Build a new object-construction expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, |
| SourceLocation LParenLoc, |
| MultiExprArg Args, |
| SourceLocation RParenLoc, |
| bool ListInitialization) { |
| return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args, |
| RParenLoc, ListInitialization); |
| } |
| |
| /// Build a new member reference expression. |
| /// |
| /// By default, performs semantic analysis to build the new expression. |
| /// Subclasses may override this routine to provide different behavior. |
| ExprResult RebuildCXXDependentScopeMemberExpr(Expr *BaseE, |
| QualType BaseType, |
| bool IsArrow, |
| SourceLocation OperatorLoc, |
| NestedNameSpecifierLoc QualifierLoc, |
| SourceLocation TemplateKWLoc, |
| NamedDecl *FirstQualifierInScope, |
| const DeclarationNameInfo &MemberNameInfo, |
| const TemplateArgumentListInfo *TemplateArgs) { |
| CXXScopeSpec SS; |
| SS.Adopt(QualifierLoc); |
| |
| return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType, |
| OperatorLoc, IsArrow, |
| SS, TemplateKWLoc, |
| FirstQualifierInScope, |
| MemberNameInfo, |
| TemplateArgs, /*S*/nullptr); |
| } |
| |
| /// Build a new member reference expression. |
| /// |
| /// By defau
|