clang 19.0.0git
TreeTransform.h
Go to the documentation of this file.
1//===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//===----------------------------------------------------------------------===//
7//
8// This file implements a semantic tree transformation that takes a given
9// AST and rebuilds it, possibly transforming some nodes in the process.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
14#define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
15
17#include "TypeLocBuilder.h"
18#include "clang/AST/Decl.h"
19#include "clang/AST/DeclObjC.h"
21#include "clang/AST/Expr.h"
22#include "clang/AST/ExprCXX.h"
24#include "clang/AST/ExprObjC.h"
27#include "clang/AST/Stmt.h"
28#include "clang/AST/StmtCXX.h"
29#include "clang/AST/StmtObjC.h"
36#include "clang/Sema/Lookup.h"
44#include "clang/Sema/SemaSYCL.h"
45#include "llvm/ADT/ArrayRef.h"
46#include "llvm/Support/ErrorHandling.h"
47#include <algorithm>
48#include <optional>
49
50using namespace llvm::omp;
51
52namespace clang {
53using namespace sema;
54
55/// A semantic tree transformation that allows one to transform one
56/// abstract syntax tree into another.
57///
58/// A new tree transformation is defined by creating a new subclass \c X of
59/// \c TreeTransform<X> and then overriding certain operations to provide
60/// behavior specific to that transformation. For example, template
61/// instantiation is implemented as a tree transformation where the
62/// transformation of TemplateTypeParmType nodes involves substituting the
63/// template arguments for their corresponding template parameters; a similar
64/// transformation is performed for non-type template parameters and
65/// template template parameters.
66///
67/// This tree-transformation template uses static polymorphism to allow
68/// subclasses to customize any of its operations. Thus, a subclass can
69/// override any of the transformation or rebuild operators by providing an
70/// operation with the same signature as the default implementation. The
71/// overriding function should not be virtual.
72///
73/// Semantic tree transformations are split into two stages, either of which
74/// can be replaced by a subclass. The "transform" step transforms an AST node
75/// or the parts of an AST node using the various transformation functions,
76/// then passes the pieces on to the "rebuild" step, which constructs a new AST
77/// node of the appropriate kind from the pieces. The default transformation
78/// routines recursively transform the operands to composite AST nodes (e.g.,
79/// the pointee type of a PointerType node) and, if any of those operand nodes
80/// were changed by the transformation, invokes the rebuild operation to create
81/// a new AST node.
82///
83/// Subclasses can customize the transformation at various levels. The
84/// most coarse-grained transformations involve replacing TransformType(),
85/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
86/// TransformTemplateName(), or TransformTemplateArgument() with entirely
87/// new implementations.
88///
89/// For more fine-grained transformations, subclasses can replace any of the
90/// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
91/// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
92/// replacing TransformTemplateTypeParmType() allows template instantiation
93/// to substitute template arguments for their corresponding template
94/// parameters. Additionally, subclasses can override the \c RebuildXXX
95/// functions to control how AST nodes are rebuilt when their operands change.
96/// By default, \c TreeTransform will invoke semantic analysis to rebuild
97/// AST nodes. However, certain other tree transformations (e.g, cloning) may
98/// be able to use more efficient rebuild steps.
99///
100/// There are a handful of other functions that can be overridden, allowing one
101/// to avoid traversing nodes that don't need any transformation
102/// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
103/// operands have not changed (\c AlwaysRebuild()), and customize the
104/// default locations and entity names used for type-checking
105/// (\c getBaseLocation(), \c getBaseEntity()).
106template<typename Derived>
108 /// Private RAII object that helps us forget and then re-remember
109 /// the template argument corresponding to a partially-substituted parameter
110 /// pack.
111 class ForgetPartiallySubstitutedPackRAII {
112 Derived &Self;
114
115 public:
116 ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
117 Old = Self.ForgetPartiallySubstitutedPack();
118 }
119
120 ~ForgetPartiallySubstitutedPackRAII() {
121 Self.RememberPartiallySubstitutedPack(Old);
122 }
123 };
124
125protected:
127
128 /// The set of local declarations that have been transformed, for
129 /// cases where we are forced to build new declarations within the transformer
130 /// rather than in the subclass (e.g., lambda closure types).
131 llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
132
133public:
134 /// Initializes a new tree transformer.
136
137 /// Retrieves a reference to the derived class.
138 Derived &getDerived() { return static_cast<Derived&>(*this); }
139
140 /// Retrieves a reference to the derived class.
141 const Derived &getDerived() const {
142 return static_cast<const Derived&>(*this);
143 }
144
145 static inline ExprResult Owned(Expr *E) { return E; }
146 static inline StmtResult Owned(Stmt *S) { return S; }
147
148 /// Retrieves a reference to the semantic analysis object used for
149 /// this tree transform.
150 Sema &getSema() const { return SemaRef; }
151
152 /// Whether the transformation should always rebuild AST nodes, even
153 /// if none of the children have changed.
154 ///
155 /// Subclasses may override this function to specify when the transformation
156 /// should rebuild all AST nodes.
157 ///
158 /// We must always rebuild all AST nodes when performing variadic template
159 /// pack expansion, in order to avoid violating the AST invariant that each
160 /// statement node appears at most once in its containing declaration.
162
163 /// Whether the transformation is forming an expression or statement that
164 /// replaces the original. In this case, we'll reuse mangling numbers from
165 /// existing lambdas.
166 bool ReplacingOriginal() { return false; }
167
168 /// Wether CXXConstructExpr can be skipped when they are implicit.
169 /// They will be reconstructed when used if needed.
170 /// This is useful when the user that cause rebuilding of the
171 /// CXXConstructExpr is outside of the expression at which the TreeTransform
172 /// started.
173 bool AllowSkippingCXXConstructExpr() { return true; }
174
175 /// Returns the location of the entity being transformed, if that
176 /// information was not available elsewhere in the AST.
177 ///
178 /// By default, returns no source-location information. Subclasses can
179 /// provide an alternative implementation that provides better location
180 /// information.
182
183 /// Returns the name of the entity being transformed, if that
184 /// information was not available elsewhere in the AST.
185 ///
186 /// By default, returns an empty name. Subclasses can provide an alternative
187 /// implementation with a more precise name.
189
190 /// Sets the "base" location and entity when that
191 /// information is known based on another transformation.
192 ///
193 /// By default, the source location and entity are ignored. Subclasses can
194 /// override this function to provide a customized implementation.
196
197 /// RAII object that temporarily sets the base location and entity
198 /// used for reporting diagnostics in types.
200 TreeTransform &Self;
201 SourceLocation OldLocation;
202 DeclarationName OldEntity;
203
204 public:
206 DeclarationName Entity) : Self(Self) {
207 OldLocation = Self.getDerived().getBaseLocation();
208 OldEntity = Self.getDerived().getBaseEntity();
209
210 if (Location.isValid())
211 Self.getDerived().setBase(Location, Entity);
212 }
213
215 Self.getDerived().setBase(OldLocation, OldEntity);
216 }
217 };
218
219 /// Determine whether the given type \p T has already been
220 /// transformed.
221 ///
222 /// Subclasses can provide an alternative implementation of this routine
223 /// to short-circuit evaluation when it is known that a given type will
224 /// not change. For example, template instantiation need not traverse
225 /// non-dependent types.
227 return T.isNull();
228 }
229
230 /// Transform a template parameter depth level.
231 ///
232 /// During a transformation that transforms template parameters, this maps
233 /// an old template parameter depth to a new depth.
234 unsigned TransformTemplateDepth(unsigned Depth) {
235 return Depth;
236 }
237
238 /// Determine whether the given call argument should be dropped, e.g.,
239 /// because it is a default argument.
240 ///
241 /// Subclasses can provide an alternative implementation of this routine to
242 /// determine which kinds of call arguments get dropped. By default,
243 /// CXXDefaultArgument nodes are dropped (prior to transformation).
245 return E->isDefaultArgument();
246 }
247
248 /// Determine whether we should expand a pack expansion with the
249 /// given set of parameter packs into separate arguments by repeatedly
250 /// transforming the pattern.
251 ///
252 /// By default, the transformer never tries to expand pack expansions.
253 /// Subclasses can override this routine to provide different behavior.
254 ///
255 /// \param EllipsisLoc The location of the ellipsis that identifies the
256 /// pack expansion.
257 ///
258 /// \param PatternRange The source range that covers the entire pattern of
259 /// the pack expansion.
260 ///
261 /// \param Unexpanded The set of unexpanded parameter packs within the
262 /// pattern.
263 ///
264 /// \param ShouldExpand Will be set to \c true if the transformer should
265 /// expand the corresponding pack expansions into separate arguments. When
266 /// set, \c NumExpansions must also be set.
267 ///
268 /// \param RetainExpansion Whether the caller should add an unexpanded
269 /// pack expansion after all of the expanded arguments. This is used
270 /// when extending explicitly-specified template argument packs per
271 /// C++0x [temp.arg.explicit]p9.
272 ///
273 /// \param NumExpansions The number of separate arguments that will be in
274 /// the expanded form of the corresponding pack expansion. This is both an
275 /// input and an output parameter, which can be set by the caller if the
276 /// number of expansions is known a priori (e.g., due to a prior substitution)
277 /// and will be set by the callee when the number of expansions is known.
278 /// The callee must set this value when \c ShouldExpand is \c true; it may
279 /// set this value in other cases.
280 ///
281 /// \returns true if an error occurred (e.g., because the parameter packs
282 /// are to be instantiated with arguments of different lengths), false
283 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
284 /// must be set.
286 SourceRange PatternRange,
288 bool &ShouldExpand, bool &RetainExpansion,
289 std::optional<unsigned> &NumExpansions) {
290 ShouldExpand = false;
291 return false;
292 }
293
294 /// "Forget" about the partially-substituted pack template argument,
295 /// when performing an instantiation that must preserve the parameter pack
296 /// use.
297 ///
298 /// This routine is meant to be overridden by the template instantiator.
300 return TemplateArgument();
301 }
302
303 /// "Remember" the partially-substituted pack template argument
304 /// after performing an instantiation that must preserve the parameter pack
305 /// use.
306 ///
307 /// This routine is meant to be overridden by the template instantiator.
309
310 /// Note to the derived class when a function parameter pack is
311 /// being expanded.
313
314 /// Transforms the given type into another type.
315 ///
316 /// By default, this routine transforms a type by creating a
317 /// TypeSourceInfo for it and delegating to the appropriate
318 /// function. This is expensive, but we don't mind, because
319 /// this method is deprecated anyway; all users should be
320 /// switched to storing TypeSourceInfos.
321 ///
322 /// \returns the transformed type.
324
325 /// Transforms the given type-with-location into a new
326 /// type-with-location.
327 ///
328 /// By default, this routine transforms a type by delegating to the
329 /// appropriate TransformXXXType to build a new type. Subclasses
330 /// may override this function (to take over all type
331 /// transformations) or some set of the TransformXXXType functions
332 /// to alter the transformation.
334
335 /// Transform the given type-with-location into a new
336 /// type, collecting location information in the given builder
337 /// as necessary.
338 ///
340
341 /// Transform a type that is permitted to produce a
342 /// DeducedTemplateSpecializationType.
343 ///
344 /// This is used in the (relatively rare) contexts where it is acceptable
345 /// for transformation to produce a class template type with deduced
346 /// template arguments.
347 /// @{
350 /// @}
351
352 /// The reason why the value of a statement is not discarded, if any.
357 };
358
359 /// Transform the given statement.
360 ///
361 /// By default, this routine transforms a statement by delegating to the
362 /// appropriate TransformXXXStmt function to transform a specific kind of
363 /// statement or the TransformExpr() function to transform an expression.
364 /// Subclasses may override this function to transform statements using some
365 /// other mechanism.
366 ///
367 /// \returns the transformed statement.
369
370 /// Transform the given statement.
371 ///
372 /// By default, this routine transforms a statement by delegating to the
373 /// appropriate TransformOMPXXXClause function to transform a specific kind
374 /// of clause. Subclasses may override this function to transform statements
375 /// using some other mechanism.
376 ///
377 /// \returns the transformed OpenMP clause.
379
380 /// Transform the given attribute.
381 ///
382 /// By default, this routine transforms a statement by delegating to the
383 /// appropriate TransformXXXAttr function to transform a specific kind
384 /// of attribute. Subclasses may override this function to transform
385 /// attributed statements/types using some other mechanism.
386 ///
387 /// \returns the transformed attribute
388 const Attr *TransformAttr(const Attr *S);
389
390 // Transform the given statement attribute.
391 //
392 // Delegates to the appropriate TransformXXXAttr function to transform a
393 // specific kind of statement attribute. Unlike the non-statement taking
394 // version of this, this implements all attributes, not just pragmas.
395 const Attr *TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS,
396 const Attr *A);
397
398 // Transform the specified attribute.
399 //
400 // Subclasses should override the transformation of attributes with a pragma
401 // spelling to transform expressions stored within the attribute.
402 //
403 // \returns the transformed attribute.
404#define ATTR(X) \
405 const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
406#include "clang/Basic/AttrList.inc"
407
408 // Transform the specified attribute.
409 //
410 // Subclasses should override the transformation of attributes to do
411 // transformation and checking of statement attributes. By default, this
412 // delegates to the non-statement taking version.
413 //
414 // \returns the transformed attribute.
415#define ATTR(X) \
416 const X##Attr *TransformStmt##X##Attr(const Stmt *, const Stmt *, \
417 const X##Attr *A) { \
418 return getDerived().Transform##X##Attr(A); \
419 }
420#include "clang/Basic/AttrList.inc"
421
422 /// Transform the given expression.
423 ///
424 /// By default, this routine transforms an expression by delegating to the
425 /// appropriate TransformXXXExpr function to build a new expression.
426 /// Subclasses may override this function to transform expressions using some
427 /// other mechanism.
428 ///
429 /// \returns the transformed expression.
431
432 /// Transform the given initializer.
433 ///
434 /// By default, this routine transforms an initializer by stripping off the
435 /// semantic nodes added by initialization, then passing the result to
436 /// TransformExpr or TransformExprs.
437 ///
438 /// \returns the transformed initializer.
440
441 /// Transform the given list of expressions.
442 ///
443 /// This routine transforms a list of expressions by invoking
444 /// \c TransformExpr() for each subexpression. However, it also provides
445 /// support for variadic templates by expanding any pack expansions (if the
446 /// derived class permits such expansion) along the way. When pack expansions
447 /// are present, the number of outputs may not equal the number of inputs.
448 ///
449 /// \param Inputs The set of expressions to be transformed.
450 ///
451 /// \param NumInputs The number of expressions in \c Inputs.
452 ///
453 /// \param IsCall If \c true, then this transform is being performed on
454 /// function-call arguments, and any arguments that should be dropped, will
455 /// be.
456 ///
457 /// \param Outputs The transformed input expressions will be added to this
458 /// vector.
459 ///
460 /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
461 /// due to transformation.
462 ///
463 /// \returns true if an error occurred, false otherwise.
464 bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
466 bool *ArgChanged = nullptr);
467
468 /// Transform the given declaration, which is referenced from a type
469 /// or expression.
470 ///
471 /// By default, acts as the identity function on declarations, unless the
472 /// transformer has had to transform the declaration itself. Subclasses
473 /// may override this function to provide alternate behavior.
475 llvm::DenseMap<Decl *, Decl *>::iterator Known
476 = TransformedLocalDecls.find(D);
477 if (Known != TransformedLocalDecls.end())
478 return Known->second;
479
480 return D;
481 }
482
483 /// Transform the specified condition.
484 ///
485 /// By default, this transforms the variable and expression and rebuilds
486 /// the condition.
488 Expr *Expr,
490
491 /// Transform the attributes associated with the given declaration and
492 /// place them on the new declaration.
493 ///
494 /// By default, this operation does nothing. Subclasses may override this
495 /// behavior to transform attributes.
496 void transformAttrs(Decl *Old, Decl *New) { }
497
498 /// Note that a local declaration has been transformed by this
499 /// transformer.
500 ///
501 /// Local declarations are typically transformed via a call to
502 /// TransformDefinition. However, in some cases (e.g., lambda expressions),
503 /// the transformer itself has to transform the declarations. This routine
504 /// can be overridden by a subclass that keeps track of such mappings.
506 assert(New.size() == 1 &&
507 "must override transformedLocalDecl if performing pack expansion");
508 TransformedLocalDecls[Old] = New.front();
509 }
510
511 /// Transform the definition of the given declaration.
512 ///
513 /// By default, invokes TransformDecl() to transform the declaration.
514 /// Subclasses may override this function to provide alternate behavior.
516 return getDerived().TransformDecl(Loc, D);
517 }
518
519 /// Transform the given declaration, which was the first part of a
520 /// nested-name-specifier in a member access expression.
521 ///
522 /// This specific declaration transformation only applies to the first
523 /// identifier in a nested-name-specifier of a member access expression, e.g.,
524 /// the \c T in \c x->T::member
525 ///
526 /// By default, invokes TransformDecl() to transform the declaration.
527 /// Subclasses may override this function to provide alternate behavior.
529 return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
530 }
531
532 /// Transform the set of declarations in an OverloadExpr.
533 bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
534 LookupResult &R);
535
536 /// Transform the given nested-name-specifier with source-location
537 /// information.
538 ///
539 /// By default, transforms all of the types and declarations within the
540 /// nested-name-specifier. Subclasses may override this function to provide
541 /// alternate behavior.
544 QualType ObjectType = QualType(),
545 NamedDecl *FirstQualifierInScope = nullptr);
546
547 /// Transform the given declaration name.
548 ///
549 /// By default, transforms the types of conversion function, constructor,
550 /// and destructor names and then (if needed) rebuilds the declaration name.
551 /// Identifiers and selectors are returned unmodified. Subclasses may
552 /// override this function to provide alternate behavior.
555
565
566 /// Transform the given template name.
567 ///
568 /// \param SS The nested-name-specifier that qualifies the template
569 /// name. This nested-name-specifier must already have been transformed.
570 ///
571 /// \param Name The template name to transform.
572 ///
573 /// \param NameLoc The source location of the template name.
574 ///
575 /// \param ObjectType If we're translating a template name within a member
576 /// access expression, this is the type of the object whose member template
577 /// is being referenced.
578 ///
579 /// \param FirstQualifierInScope If the first part of a nested-name-specifier
580 /// also refers to a name within the current (lexical) scope, this is the
581 /// declaration it refers to.
582 ///
583 /// By default, transforms the template name by transforming the declarations
584 /// and nested-name-specifiers that occur within the template name.
585 /// Subclasses may override this function to provide alternate behavior.
588 SourceLocation NameLoc,
589 QualType ObjectType = QualType(),
590 NamedDecl *FirstQualifierInScope = nullptr,
591 bool AllowInjectedClassName = false);
592
593 /// Transform the given template argument.
594 ///
595 /// By default, this operation transforms the type, expression, or
596 /// declaration stored within the template argument and constructs a
597 /// new template argument from the transformed result. Subclasses may
598 /// override this function to provide alternate behavior.
599 ///
600 /// Returns true if there was an error.
602 TemplateArgumentLoc &Output,
603 bool Uneval = false);
604
605 /// Transform the given set of template arguments.
606 ///
607 /// By default, this operation transforms all of the template arguments
608 /// in the input set using \c TransformTemplateArgument(), and appends
609 /// the transformed arguments to the output list.
610 ///
611 /// Note that this overload of \c TransformTemplateArguments() is merely
612 /// a convenience function. Subclasses that wish to override this behavior
613 /// should override the iterator-based member template version.
614 ///
615 /// \param Inputs The set of template arguments to be transformed.
616 ///
617 /// \param NumInputs The number of template arguments in \p Inputs.
618 ///
619 /// \param Outputs The set of transformed template arguments output by this
620 /// routine.
621 ///
622 /// Returns true if an error occurred.
624 unsigned NumInputs,
626 bool Uneval = false) {
627 return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
628 Uneval);
629 }
630
631 /// Transform the given set of template arguments.
632 ///
633 /// By default, this operation transforms all of the template arguments
634 /// in the input set using \c TransformTemplateArgument(), and appends
635 /// the transformed arguments to the output list.
636 ///
637 /// \param First An iterator to the first template argument.
638 ///
639 /// \param Last An iterator one step past the last template argument.
640 ///
641 /// \param Outputs The set of transformed template arguments output by this
642 /// routine.
643 ///
644 /// Returns true if an error occurred.
645 template<typename InputIterator>
647 InputIterator Last,
649 bool Uneval = false);
650
651 /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
653 TemplateArgumentLoc &ArgLoc);
654
655 /// Fakes up a TypeSourceInfo for a type.
659 }
660
661#define ABSTRACT_TYPELOC(CLASS, PARENT)
662#define TYPELOC(CLASS, PARENT) \
663 QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
664#include "clang/AST/TypeLocNodes.def"
665
668 bool SuppressObjCLifetime);
672 bool SuppressObjCLifetime);
673
674 template<typename Fn>
677 CXXRecordDecl *ThisContext,
678 Qualifiers ThisTypeQuals,
680
681 template <typename Fn>
683 Fn TransformModifiedType);
684
687 SmallVectorImpl<QualType> &Exceptions,
688 bool &Changed);
689
691
695 TemplateName Template);
696
700 TemplateName Template,
701 CXXScopeSpec &SS);
702
705 NestedNameSpecifierLoc QualifierLoc);
706
707 /// Transforms the parameters of a function type into the
708 /// given vectors.
709 ///
710 /// The result vectors should be kept in sync; null entries in the
711 /// variables vector are acceptable.
712 ///
713 /// LastParamTransformed, if non-null, will be set to the index of the last
714 /// parameter on which transfromation was started. In the event of an error,
715 /// this will contain the parameter which failed to instantiate.
716 ///
717 /// Return true on error.
720 const QualType *ParamTypes,
721 const FunctionProtoType::ExtParameterInfo *ParamInfos,
723 Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed);
724
727 const QualType *ParamTypes,
728 const FunctionProtoType::ExtParameterInfo *ParamInfos,
731 return getDerived().TransformFunctionTypeParams(
732 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos, nullptr);
733 }
734
735 /// Transforms the parameters of a requires expresison into the given vectors.
736 ///
737 /// The result vectors should be kept in sync; null entries in the
738 /// variables vector are acceptable.
739 ///
740 /// Returns an unset ExprResult on success. Returns an ExprResult the 'not
741 /// satisfied' RequiresExpr if subsitution failed, OR an ExprError, both of
742 /// which are cases where transformation shouldn't continue.
744 SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
750 KWLoc, Params, /*ParamTypes=*/nullptr,
751 /*ParamInfos=*/nullptr, PTypes, &TransParams, PInfos))
752 return ExprError();
753
754 return ExprResult{};
755 }
756
757 /// Transforms a single function-type parameter. Return null
758 /// on error.
759 ///
760 /// \param indexAdjustment - A number to add to the parameter's
761 /// scope index; can be negative
763 int indexAdjustment,
764 std::optional<unsigned> NumExpansions,
765 bool ExpectParameterPack);
766
767 /// Transform the body of a lambda-expression.
769 /// Alternative implementation of TransformLambdaBody that skips transforming
770 /// the body.
772
775 return static_cast<CXXRecordDecl::LambdaDependencyKind>(
777 }
778
780
783
786 return TPL;
787 }
788
790
792 bool IsAddressOfOperand,
793 TypeSourceInfo **RecoveryTSI);
794
796 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
797 TypeSourceInfo **RecoveryTSI);
798
800 bool IsAddressOfOperand);
801
803
804// FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
805// amount of stack usage with clang.
806#define STMT(Node, Parent) \
807 LLVM_ATTRIBUTE_NOINLINE \
808 StmtResult Transform##Node(Node *S);
809#define VALUESTMT(Node, Parent) \
810 LLVM_ATTRIBUTE_NOINLINE \
811 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
812#define EXPR(Node, Parent) \
813 LLVM_ATTRIBUTE_NOINLINE \
814 ExprResult Transform##Node(Node *E);
815#define ABSTRACT_STMT(Stmt)
816#include "clang/AST/StmtNodes.inc"
817
818#define GEN_CLANG_CLAUSE_CLASS
819#define CLAUSE_CLASS(Enum, Str, Class) \
820 LLVM_ATTRIBUTE_NOINLINE \
821 OMPClause *Transform##Class(Class *S);
822#include "llvm/Frontend/OpenMP/OMP.inc"
823
824 /// Build a new qualified type given its unqualified type and type location.
825 ///
826 /// By default, this routine adds type qualifiers only to types that can
827 /// have qualifiers, and silently suppresses those qualifiers that are not
828 /// permitted. Subclasses may override this routine to provide different
829 /// behavior.
831
832 /// Build a new pointer type given its pointee type.
833 ///
834 /// By default, performs semantic analysis when building the pointer type.
835 /// Subclasses may override this routine to provide different behavior.
837
838 /// Build a new block pointer type given its pointee type.
839 ///
840 /// By default, performs semantic analysis when building the block pointer
841 /// type. Subclasses may override this routine to provide different behavior.
843
844 /// Build a new reference type given the type it references.
845 ///
846 /// By default, performs semantic analysis when building the
847 /// reference type. Subclasses may override this routine to provide
848 /// different behavior.
849 ///
850 /// \param LValue whether the type was written with an lvalue sigil
851 /// or an rvalue sigil.
853 bool LValue,
854 SourceLocation Sigil);
855
856 /// Build a new member pointer type given the pointee type and the
857 /// class type it refers into.
858 ///
859 /// By default, performs semantic analysis when building the member pointer
860 /// type. Subclasses may override this routine to provide different behavior.
862 SourceLocation Sigil);
863
865 SourceLocation ProtocolLAngleLoc,
867 ArrayRef<SourceLocation> ProtocolLocs,
868 SourceLocation ProtocolRAngleLoc);
869
870 /// Build an Objective-C object type.
871 ///
872 /// By default, performs semantic analysis when building the object type.
873 /// Subclasses may override this routine to provide different behavior.
875 SourceLocation Loc,
876 SourceLocation TypeArgsLAngleLoc,
878 SourceLocation TypeArgsRAngleLoc,
879 SourceLocation ProtocolLAngleLoc,
881 ArrayRef<SourceLocation> ProtocolLocs,
882 SourceLocation ProtocolRAngleLoc);
883
884 /// Build a new Objective-C object pointer type given the pointee type.
885 ///
886 /// By default, directly builds the pointer type, with no additional semantic
887 /// analysis.
890
891 /// Build a new array type given the element type, size
892 /// modifier, size of the array (if known), size expression, and index type
893 /// qualifiers.
894 ///
895 /// By default, performs semantic analysis when building the array type.
896 /// Subclasses may override this routine to provide different behavior.
897 /// Also by default, all of the other Rebuild*Array
899 const llvm::APInt *Size, Expr *SizeExpr,
900 unsigned IndexTypeQuals, SourceRange BracketsRange);
901
902 /// Build a new constant array type given the element type, size
903 /// modifier, (known) size of the array, and index type qualifiers.
904 ///
905 /// By default, performs semantic analysis when building the array type.
906 /// Subclasses may override this routine to provide different behavior.
908 ArraySizeModifier SizeMod,
909 const llvm::APInt &Size, Expr *SizeExpr,
910 unsigned IndexTypeQuals,
911 SourceRange BracketsRange);
912
913 /// Build a new incomplete array type given the element type, size
914 /// modifier, and index type qualifiers.
915 ///
916 /// By default, performs semantic analysis when building the array type.
917 /// Subclasses may override this routine to provide different behavior.
919 ArraySizeModifier SizeMod,
920 unsigned IndexTypeQuals,
921 SourceRange BracketsRange);
922
923 /// Build a new variable-length array type given the element type,
924 /// size modifier, size expression, and index type qualifiers.
925 ///
926 /// By default, performs semantic analysis when building the array type.
927 /// Subclasses may override this routine to provide different behavior.
929 ArraySizeModifier SizeMod, Expr *SizeExpr,
930 unsigned IndexTypeQuals,
931 SourceRange BracketsRange);
932
933 /// Build a new dependent-sized array type given the element type,
934 /// size modifier, size expression, and index type qualifiers.
935 ///
936 /// By default, performs semantic analysis when building the array type.
937 /// Subclasses may override this routine to provide different behavior.
939 ArraySizeModifier SizeMod,
940 Expr *SizeExpr,
941 unsigned IndexTypeQuals,
942 SourceRange BracketsRange);
943
944 /// Build a new vector type given the element type and
945 /// number of elements.
946 ///
947 /// By default, performs semantic analysis when building the vector type.
948 /// Subclasses may override this routine to provide different behavior.
949 QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
950 VectorKind VecKind);
951
952 /// Build a new potentially dependently-sized extended vector type
953 /// given the element type and number of elements.
954 ///
955 /// By default, performs semantic analysis when building the vector type.
956 /// Subclasses may override this routine to provide different behavior.
958 SourceLocation AttributeLoc, VectorKind);
959
960 /// Build a new extended vector type given the element type and
961 /// number of elements.
962 ///
963 /// By default, performs semantic analysis when building the vector type.
964 /// Subclasses may override this routine to provide different behavior.
965 QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
966 SourceLocation AttributeLoc);
967
968 /// Build a new potentially dependently-sized extended vector type
969 /// given the element type and number of elements.
970 ///
971 /// By default, performs semantic analysis when building the vector type.
972 /// Subclasses may override this routine to provide different behavior.
974 Expr *SizeExpr,
975 SourceLocation AttributeLoc);
976
977 /// Build a new matrix type given the element type and dimensions.
978 QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows,
979 unsigned NumColumns);
980
981 /// Build a new matrix type given the type and dependently-defined
982 /// dimensions.
984 Expr *ColumnExpr,
985 SourceLocation AttributeLoc);
986
987 /// Build a new DependentAddressSpaceType or return the pointee
988 /// type variable with the correct address space (retrieved from
989 /// AddrSpaceExpr) applied to it. The former will be returned in cases
990 /// where the address space remains dependent.
991 ///
992 /// By default, performs semantic analysis when building the type with address
993 /// space applied. Subclasses may override this routine to provide different
994 /// behavior.
996 Expr *AddrSpaceExpr,
997 SourceLocation AttributeLoc);
998
999 /// Build a new function type.
1000 ///
1001 /// By default, performs semantic analysis when building the function type.
1002 /// Subclasses may override this routine to provide different behavior.
1004 MutableArrayRef<QualType> ParamTypes,
1006
1007 /// Build a new unprototyped function type.
1009
1010 /// Rebuild an unresolved typename type, given the decl that
1011 /// the UnresolvedUsingTypenameDecl was transformed to.
1013
1014 /// Build a new type found via an alias.
1016 return SemaRef.Context.getUsingType(Found, Underlying);
1017 }
1018
1019 /// Build a new typedef type.
1021 return SemaRef.Context.getTypeDeclType(Typedef);
1022 }
1023
1024 /// Build a new MacroDefined type.
1026 const IdentifierInfo *MacroII) {
1027 return SemaRef.Context.getMacroQualifiedType(T, MacroII);
1028 }
1029
1030 /// Build a new class/struct/union type.
1033 }
1034
1035 /// Build a new Enum type.
1038 }
1039
1040 /// Build a new typeof(expr) type.
1041 ///
1042 /// By default, performs semantic analysis when building the typeof type.
1043 /// Subclasses may override this routine to provide different behavior.
1045 TypeOfKind Kind);
1046
1047 /// Build a new typeof(type) type.
1048 ///
1049 /// By default, builds a new TypeOfType with the given underlying type.
1051
1052 /// Build a new unary transform type.
1055 SourceLocation Loc);
1056
1057 /// Build a new C++11 decltype type.
1058 ///
1059 /// By default, performs semantic analysis when building the decltype type.
1060 /// Subclasses may override this routine to provide different behavior.
1062
1064 SourceLocation Loc,
1065 SourceLocation EllipsisLoc,
1066 bool FullySubstituted,
1067 ArrayRef<QualType> Expansions = {});
1068
1069 /// Build a new C++11 auto type.
1070 ///
1071 /// By default, builds a new AutoType with the given deduced type.
1073 ConceptDecl *TypeConstraintConcept,
1074 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1075 // Note, IsDependent is always false here: we implicitly convert an 'auto'
1076 // which has been deduced to a dependent type into an undeduced 'auto', so
1077 // that we'll retry deduction after the transformation.
1078 return SemaRef.Context.getAutoType(Deduced, Keyword,
1079 /*IsDependent*/ false, /*IsPack=*/false,
1080 TypeConstraintConcept,
1081 TypeConstraintArgs);
1082 }
1083
1084 /// By default, builds a new DeducedTemplateSpecializationType with the given
1085 /// deduced type.
1087 QualType Deduced) {
1089 Template, Deduced, /*IsDependent*/ false);
1090 }
1091
1092 /// Build a new template specialization type.
1093 ///
1094 /// By default, performs semantic analysis when building the template
1095 /// specialization type. Subclasses may override this routine to provide
1096 /// different behavior.
1098 SourceLocation TemplateLoc,
1100
1101 /// Build a new parenthesized type.
1102 ///
1103 /// By default, builds a new ParenType type from the inner type.
1104 /// Subclasses may override this routine to provide different behavior.
1106 return SemaRef.BuildParenType(InnerType);
1107 }
1108
1109 /// Build a new qualified name type.
1110 ///
1111 /// By default, builds a new ElaboratedType type from the keyword,
1112 /// the nested-name-specifier and the named type.
1113 /// Subclasses may override this routine to provide different behavior.
1115 ElaboratedTypeKeyword Keyword,
1116 NestedNameSpecifierLoc QualifierLoc,
1117 QualType Named) {
1118 return SemaRef.Context.getElaboratedType(Keyword,
1119 QualifierLoc.getNestedNameSpecifier(),
1120 Named);
1121 }
1122
1123 /// Build a new typename type that refers to a template-id.
1124 ///
1125 /// By default, builds a new DependentNameType type from the
1126 /// nested-name-specifier and the given type. Subclasses may override
1127 /// this routine to provide different behavior.
1129 ElaboratedTypeKeyword Keyword,
1130 NestedNameSpecifierLoc QualifierLoc,
1131 SourceLocation TemplateKWLoc,
1132 const IdentifierInfo *Name,
1133 SourceLocation NameLoc,
1135 bool AllowInjectedClassName) {
1136 // Rebuild the template name.
1137 // TODO: avoid TemplateName abstraction
1138 CXXScopeSpec SS;
1139 SS.Adopt(QualifierLoc);
1140 TemplateName InstName = getDerived().RebuildTemplateName(
1141 SS, TemplateKWLoc, *Name, NameLoc, QualType(), nullptr,
1142 AllowInjectedClassName);
1143
1144 if (InstName.isNull())
1145 return QualType();
1146
1147 // If it's still dependent, make a dependent specialization.
1148 if (InstName.getAsDependentTemplateName())
1150 Keyword, QualifierLoc.getNestedNameSpecifier(), Name,
1151 Args.arguments());
1152
1153 // Otherwise, make an elaborated type wrapping a non-dependent
1154 // specialization.
1155 QualType T =
1156 getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
1157 if (T.isNull())
1158 return QualType();
1160 Keyword, QualifierLoc.getNestedNameSpecifier(), T);
1161 }
1162
1163 /// Build a new typename type that refers to an identifier.
1164 ///
1165 /// By default, performs semantic analysis when building the typename type
1166 /// (or elaborated type). Subclasses may override this routine to provide
1167 /// different behavior.
1169 SourceLocation KeywordLoc,
1170 NestedNameSpecifierLoc QualifierLoc,
1171 const IdentifierInfo *Id,
1172 SourceLocation IdLoc,
1173 bool DeducedTSTContext) {
1174 CXXScopeSpec SS;
1175 SS.Adopt(QualifierLoc);
1176
1177 if (QualifierLoc.getNestedNameSpecifier()->isDependent()) {
1178 // If the name is still dependent, just build a new dependent name type.
1179 if (!SemaRef.computeDeclContext(SS))
1180 return SemaRef.Context.getDependentNameType(Keyword,
1181 QualifierLoc.getNestedNameSpecifier(),
1182 Id);
1183 }
1184
1185 if (Keyword == ElaboratedTypeKeyword::None ||
1187 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1188 *Id, IdLoc, DeducedTSTContext);
1189 }
1190
1192
1193 // We had a dependent elaborated-type-specifier that has been transformed
1194 // into a non-dependent elaborated-type-specifier. Find the tag we're
1195 // referring to.
1197 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1198 if (!DC)
1199 return QualType();
1200
1202 return QualType();
1203
1204 TagDecl *Tag = nullptr;
1206 switch (Result.getResultKind()) {
1209 break;
1210
1212 Tag = Result.getAsSingle<TagDecl>();
1213 break;
1214
1217 llvm_unreachable("Tag lookup cannot find non-tags");
1218
1220 // Let the LookupResult structure handle ambiguities.
1221 return QualType();
1222 }
1223
1224 if (!Tag) {
1225 // Check where the name exists but isn't a tag type and use that to emit
1226 // better diagnostics.
1229 switch (Result.getResultKind()) {
1233 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1234 Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1235 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1236 << SomeDecl << NTK << llvm::to_underlying(Kind);
1237 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1238 break;
1239 }
1240 default:
1241 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1242 << llvm::to_underlying(Kind) << Id << DC
1243 << QualifierLoc.getSourceRange();
1244 break;
1245 }
1246 return QualType();
1247 }
1248
1249 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1250 IdLoc, Id)) {
1251 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1252 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1253 return QualType();
1254 }
1255
1256 // Build the elaborated-type-specifier type.
1258 return SemaRef.Context.getElaboratedType(Keyword,
1259 QualifierLoc.getNestedNameSpecifier(),
1260 T);
1261 }
1262
1263 /// Build a new pack expansion type.
1264 ///
1265 /// By default, builds a new PackExpansionType type from the given pattern.
1266 /// Subclasses may override this routine to provide different behavior.
1268 SourceLocation EllipsisLoc,
1269 std::optional<unsigned> NumExpansions) {
1270 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1271 NumExpansions);
1272 }
1273
1274 /// Build a new atomic type given its value type.
1275 ///
1276 /// By default, performs semantic analysis when building the atomic type.
1277 /// Subclasses may override this routine to provide different behavior.
1279
1280 /// Build a new pipe type given its value type.
1282 bool isReadPipe);
1283
1284 /// Build a bit-precise int given its value type.
1285 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1286 SourceLocation Loc);
1287
1288 /// Build a dependent bit-precise int given its value type.
1289 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1290 SourceLocation Loc);
1291
1292 /// Build a new template name given a nested name specifier, a flag
1293 /// indicating whether the "template" keyword was provided, and the template
1294 /// that the template name refers to.
1295 ///
1296 /// By default, builds the new template name directly. Subclasses may override
1297 /// this routine to provide different behavior.
1299 bool TemplateKW,
1300 TemplateDecl *Template);
1301
1302 /// Build a new template name given a nested name specifier and the
1303 /// name that is referred to as a template.
1304 ///
1305 /// By default, performs semantic analysis to determine whether the name can
1306 /// be resolved to a specific template, then builds the appropriate kind of
1307 /// template name. Subclasses may override this routine to provide different
1308 /// behavior.
1310 SourceLocation TemplateKWLoc,
1311 const IdentifierInfo &Name,
1312 SourceLocation NameLoc, QualType ObjectType,
1313 NamedDecl *FirstQualifierInScope,
1314 bool AllowInjectedClassName);
1315
1316 /// Build a new template name given a nested name specifier and the
1317 /// overloaded operator name that is referred to as a template.
1318 ///
1319 /// By default, performs semantic analysis to determine whether the name can
1320 /// be resolved to a specific template, then builds the appropriate kind of
1321 /// template name. Subclasses may override this routine to provide different
1322 /// behavior.
1324 SourceLocation TemplateKWLoc,
1325 OverloadedOperatorKind Operator,
1326 SourceLocation NameLoc, QualType ObjectType,
1327 bool AllowInjectedClassName);
1328
1329 /// Build a new template name given a template template parameter pack
1330 /// and the
1331 ///
1332 /// By default, performs semantic analysis to determine whether the name can
1333 /// be resolved to a specific template, then builds the appropriate kind of
1334 /// template name. Subclasses may override this routine to provide different
1335 /// behavior.
1337 Decl *AssociatedDecl, unsigned Index,
1338 bool Final) {
1340 ArgPack, AssociatedDecl, Index, Final);
1341 }
1342
1343 /// Build a new compound statement.
1344 ///
1345 /// By default, performs semantic analysis to build the new statement.
1346 /// Subclasses may override this routine to provide different behavior.
1348 MultiStmtArg Statements,
1349 SourceLocation RBraceLoc,
1350 bool IsStmtExpr) {
1351 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1352 IsStmtExpr);
1353 }
1354
1355 /// Build a new case statement.
1356 ///
1357 /// By default, performs semantic analysis to build the new statement.
1358 /// Subclasses may override this routine to provide different behavior.
1360 Expr *LHS,
1361 SourceLocation EllipsisLoc,
1362 Expr *RHS,
1363 SourceLocation ColonLoc) {
1364 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1365 ColonLoc);
1366 }
1367
1368 /// Attach the body to a new case statement.
1369 ///
1370 /// By default, performs semantic analysis to build the new statement.
1371 /// Subclasses may override this routine to provide different behavior.
1373 getSema().ActOnCaseStmtBody(S, Body);
1374 return S;
1375 }
1376
1377 /// Build a new default statement.
1378 ///
1379 /// By default, performs semantic analysis to build the new statement.
1380 /// Subclasses may override this routine to provide different behavior.
1382 SourceLocation ColonLoc,
1383 Stmt *SubStmt) {
1384 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1385 /*CurScope=*/nullptr);
1386 }
1387
1388 /// Build a new label statement.
1389 ///
1390 /// By default, performs semantic analysis to build the new statement.
1391 /// Subclasses may override this routine to provide different behavior.
1393 SourceLocation ColonLoc, Stmt *SubStmt) {
1394 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1395 }
1396
1397 /// Build a new attributed statement.
1398 ///
1399 /// By default, performs semantic analysis to build the new statement.
1400 /// Subclasses may override this routine to provide different behavior.
1403 Stmt *SubStmt) {
1405 return StmtError();
1406 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1407 }
1408
1409 /// Build a new "if" statement.
1410 ///
1411 /// By default, performs semantic analysis to build the new statement.
1412 /// Subclasses may override this routine to provide different behavior.
1414 SourceLocation LParenLoc, Sema::ConditionResult Cond,
1415 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1416 SourceLocation ElseLoc, Stmt *Else) {
1417 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1418 Then, ElseLoc, Else);
1419 }
1420
1421 /// Start building a new switch statement.
1422 ///
1423 /// By default, performs semantic analysis to build the new statement.
1424 /// Subclasses may override this routine to provide different behavior.
1426 SourceLocation LParenLoc, Stmt *Init,
1428 SourceLocation RParenLoc) {
1429 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1430 RParenLoc);
1431 }
1432
1433 /// Attach the body to the switch statement.
1434 ///
1435 /// By default, performs semantic analysis to build the new statement.
1436 /// Subclasses may override this routine to provide different behavior.
1438 Stmt *Switch, Stmt *Body) {
1439 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1440 }
1441
1442 /// Build a new while statement.
1443 ///
1444 /// By default, performs semantic analysis to build the new statement.
1445 /// Subclasses may override this routine to provide different behavior.
1448 SourceLocation RParenLoc, Stmt *Body) {
1449 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1450 }
1451
1452 /// Build a new do-while statement.
1453 ///
1454 /// By default, performs semantic analysis to build the new statement.
1455 /// Subclasses may override this routine to provide different behavior.
1457 SourceLocation WhileLoc, SourceLocation LParenLoc,
1458 Expr *Cond, SourceLocation RParenLoc) {
1459 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1460 Cond, RParenLoc);
1461 }
1462
1463 /// Build a new for statement.
1464 ///
1465 /// By default, performs semantic analysis to build the new statement.
1466 /// Subclasses may override this routine to provide different behavior.
1469 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1470 Stmt *Body) {
1471 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1472 Inc, RParenLoc, Body);
1473 }
1474
1475 /// Build a new goto statement.
1476 ///
1477 /// By default, performs semantic analysis to build the new statement.
1478 /// Subclasses may override this routine to provide different behavior.
1480 LabelDecl *Label) {
1481 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1482 }
1483
1484 /// Build a new indirect goto statement.
1485 ///
1486 /// By default, performs semantic analysis to build the new statement.
1487 /// Subclasses may override this routine to provide different behavior.
1489 SourceLocation StarLoc,
1490 Expr *Target) {
1491 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1492 }
1493
1494 /// Build a new return statement.
1495 ///
1496 /// By default, performs semantic analysis to build the new statement.
1497 /// Subclasses may override this routine to provide different behavior.
1499 return getSema().BuildReturnStmt(ReturnLoc, Result);
1500 }
1501
1502 /// Build a new declaration statement.
1503 ///
1504 /// By default, performs semantic analysis to build the new statement.
1505 /// Subclasses may override this routine to provide different behavior.
1507 SourceLocation StartLoc, SourceLocation EndLoc) {
1509 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1510 }
1511
1512 /// Build a new inline asm statement.
1513 ///
1514 /// By default, performs semantic analysis to build the new statement.
1515 /// Subclasses may override this routine to provide different behavior.
1517 bool IsVolatile, unsigned NumOutputs,
1518 unsigned NumInputs, IdentifierInfo **Names,
1519 MultiExprArg Constraints, MultiExprArg Exprs,
1520 Expr *AsmString, MultiExprArg Clobbers,
1521 unsigned NumLabels,
1522 SourceLocation RParenLoc) {
1523 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1524 NumInputs, Names, Constraints, Exprs,
1525 AsmString, Clobbers, NumLabels, RParenLoc);
1526 }
1527
1528 /// Build a new MS style inline asm statement.
1529 ///
1530 /// By default, performs semantic analysis to build the new statement.
1531 /// Subclasses may override this routine to provide different behavior.
1533 ArrayRef<Token> AsmToks,
1534 StringRef AsmString,
1535 unsigned NumOutputs, unsigned NumInputs,
1536 ArrayRef<StringRef> Constraints,
1537 ArrayRef<StringRef> Clobbers,
1538 ArrayRef<Expr*> Exprs,
1539 SourceLocation EndLoc) {
1540 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1541 NumOutputs, NumInputs,
1542 Constraints, Clobbers, Exprs, EndLoc);
1543 }
1544
1545 /// Build a new co_return statement.
1546 ///
1547 /// By default, performs semantic analysis to build the new statement.
1548 /// Subclasses may override this routine to provide different behavior.
1550 bool IsImplicit) {
1551 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1552 }
1553
1554 /// Build a new co_await expression.
1555 ///
1556 /// By default, performs semantic analysis to build the new expression.
1557 /// Subclasses may override this routine to provide different behavior.
1559 UnresolvedLookupExpr *OpCoawaitLookup,
1560 bool IsImplicit) {
1561 // This function rebuilds a coawait-expr given its operator.
1562 // For an explicit coawait-expr, the rebuild involves the full set
1563 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1564 // including calling await_transform().
1565 // For an implicit coawait-expr, we need to rebuild the "operator
1566 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1567 // This mirrors how the implicit CoawaitExpr is originally created
1568 // in Sema::ActOnCoroutineBodyStart().
1569 if (IsImplicit) {
1571 CoawaitLoc, Operand, OpCoawaitLookup);
1572 if (Suspend.isInvalid())
1573 return ExprError();
1574 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1575 Suspend.get(), true);
1576 }
1577
1578 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1579 OpCoawaitLookup);
1580 }
1581
1582 /// Build a new co_await expression.
1583 ///
1584 /// By default, performs semantic analysis to build the new expression.
1585 /// Subclasses may override this routine to provide different behavior.
1587 Expr *Result,
1588 UnresolvedLookupExpr *Lookup) {
1589 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1590 }
1591
1592 /// Build a new co_yield expression.
1593 ///
1594 /// By default, performs semantic analysis to build the new expression.
1595 /// Subclasses may override this routine to provide different behavior.
1597 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1598 }
1599
1601 return getSema().BuildCoroutineBodyStmt(Args);
1602 }
1603
1604 /// Build a new Objective-C \@try statement.
1605 ///
1606 /// By default, performs semantic analysis to build the new statement.
1607 /// Subclasses may override this routine to provide different behavior.
1609 Stmt *TryBody,
1610 MultiStmtArg CatchStmts,
1611 Stmt *Finally) {
1612 return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1613 Finally);
1614 }
1615
1616 /// Rebuild an Objective-C exception declaration.
1617 ///
1618 /// By default, performs semantic analysis to build the new declaration.
1619 /// Subclasses may override this routine to provide different behavior.
1621 TypeSourceInfo *TInfo, QualType T) {
1622 return getSema().BuildObjCExceptionDecl(TInfo, T,
1623 ExceptionDecl->getInnerLocStart(),
1624 ExceptionDecl->getLocation(),
1625 ExceptionDecl->getIdentifier());
1626 }
1627
1628 /// Build a new Objective-C \@catch statement.
1629 ///
1630 /// By default, performs semantic analysis to build the new statement.
1631 /// Subclasses may override this routine to provide different behavior.
1633 SourceLocation RParenLoc,
1634 VarDecl *Var,
1635 Stmt *Body) {
1636 return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc,
1637 Var, Body);
1638 }
1639
1640 /// Build a new Objective-C \@finally statement.
1641 ///
1642 /// By default, performs semantic analysis to build the new statement.
1643 /// Subclasses may override this routine to provide different behavior.
1645 Stmt *Body) {
1646 return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body);
1647 }
1648
1649 /// Build a new Objective-C \@throw statement.
1650 ///
1651 /// By default, performs semantic analysis to build the new statement.
1652 /// Subclasses may override this routine to provide different behavior.
1654 Expr *Operand) {
1655 return getSema().BuildObjCAtThrowStmt(AtLoc, Operand);
1656 }
1657
1658 /// Build a new OpenMP Canonical loop.
1659 ///
1660 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1661 /// OMPCanonicalLoop.
1663 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1664 }
1665
1666 /// Build a new OpenMP executable directive.
1667 ///
1668 /// By default, performs semantic analysis to build the new statement.
1669 /// Subclasses may override this routine to provide different behavior.
1672 OpenMPDirectiveKind CancelRegion, ArrayRef<OMPClause *> Clauses,
1673 Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc,
1674 OpenMPDirectiveKind PrevMappedDirective = OMPD_unknown) {
1675
1677 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc,
1678 PrevMappedDirective);
1679 }
1680
1681 /// Build a new OpenMP 'if' clause.
1682 ///
1683 /// By default, performs semantic analysis to build the new OpenMP clause.
1684 /// Subclasses may override this routine to provide different behavior.
1686 Expr *Condition, SourceLocation StartLoc,
1687 SourceLocation LParenLoc,
1688 SourceLocation NameModifierLoc,
1689 SourceLocation ColonLoc,
1690 SourceLocation EndLoc) {
1692 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1693 EndLoc);
1694 }
1695
1696 /// Build a new OpenMP 'final' clause.
1697 ///
1698 /// By default, performs semantic analysis to build the new OpenMP clause.
1699 /// Subclasses may override this routine to provide different behavior.
1701 SourceLocation LParenLoc,
1702 SourceLocation EndLoc) {
1703 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1704 LParenLoc, EndLoc);
1705 }
1706
1707 /// Build a new OpenMP 'num_threads' clause.
1708 ///
1709 /// By default, performs semantic analysis to build the new OpenMP clause.
1710 /// Subclasses may override this routine to provide different behavior.
1712 SourceLocation StartLoc,
1713 SourceLocation LParenLoc,
1714 SourceLocation EndLoc) {
1715 return getSema().OpenMP().ActOnOpenMPNumThreadsClause(NumThreads, StartLoc,
1716 LParenLoc, EndLoc);
1717 }
1718
1719 /// Build a new OpenMP 'safelen' clause.
1720 ///
1721 /// By default, performs semantic analysis to build the new OpenMP clause.
1722 /// Subclasses may override this routine to provide different behavior.
1724 SourceLocation LParenLoc,
1725 SourceLocation EndLoc) {
1726 return getSema().OpenMP().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1727 EndLoc);
1728 }
1729
1730 /// Build a new OpenMP 'simdlen' clause.
1731 ///
1732 /// By default, performs semantic analysis to build the new OpenMP clause.
1733 /// Subclasses may override this routine to provide different behavior.
1735 SourceLocation LParenLoc,
1736 SourceLocation EndLoc) {
1737 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1738 EndLoc);
1739 }
1740
1742 SourceLocation StartLoc,
1743 SourceLocation LParenLoc,
1744 SourceLocation EndLoc) {
1745 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1746 EndLoc);
1747 }
1748
1749 /// Build a new OpenMP 'full' clause.
1751 SourceLocation EndLoc) {
1752 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1753 }
1754
1755 /// Build a new OpenMP 'partial' clause.
1757 SourceLocation LParenLoc,
1758 SourceLocation EndLoc) {
1759 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1760 LParenLoc, EndLoc);
1761 }
1762
1763 /// Build a new OpenMP 'allocator' clause.
1764 ///
1765 /// By default, performs semantic analysis to build the new OpenMP clause.
1766 /// Subclasses may override this routine to provide different behavior.
1768 SourceLocation LParenLoc,
1769 SourceLocation EndLoc) {
1770 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1771 EndLoc);
1772 }
1773
1774 /// Build a new OpenMP 'collapse' clause.
1775 ///
1776 /// By default, performs semantic analysis to build the new OpenMP clause.
1777 /// Subclasses may override this routine to provide different behavior.
1779 SourceLocation LParenLoc,
1780 SourceLocation EndLoc) {
1781 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1782 LParenLoc, EndLoc);
1783 }
1784
1785 /// Build a new OpenMP 'default' clause.
1786 ///
1787 /// By default, performs semantic analysis to build the new OpenMP clause.
1788 /// Subclasses may override this routine to provide different behavior.
1790 SourceLocation StartLoc,
1791 SourceLocation LParenLoc,
1792 SourceLocation EndLoc) {
1794 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1795 }
1796
1797 /// Build a new OpenMP 'proc_bind' clause.
1798 ///
1799 /// By default, performs semantic analysis to build the new OpenMP clause.
1800 /// Subclasses may override this routine to provide different behavior.
1802 SourceLocation KindKwLoc,
1803 SourceLocation StartLoc,
1804 SourceLocation LParenLoc,
1805 SourceLocation EndLoc) {
1807 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1808 }
1809
1810 /// Build a new OpenMP 'schedule' clause.
1811 ///
1812 /// By default, performs semantic analysis to build the new OpenMP clause.
1813 /// Subclasses may override this routine to provide different behavior.
1816 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1817 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1818 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1820 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1821 CommaLoc, EndLoc);
1822 }
1823
1824 /// Build a new OpenMP 'ordered' clause.
1825 ///
1826 /// By default, performs semantic analysis to build the new OpenMP clause.
1827 /// Subclasses may override this routine to provide different behavior.
1829 SourceLocation EndLoc,
1830 SourceLocation LParenLoc, Expr *Num) {
1831 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1832 LParenLoc, Num);
1833 }
1834
1835 /// Build a new OpenMP 'private' clause.
1836 ///
1837 /// By default, performs semantic analysis to build the new OpenMP clause.
1838 /// Subclasses may override this routine to provide different behavior.
1840 SourceLocation StartLoc,
1841 SourceLocation LParenLoc,
1842 SourceLocation EndLoc) {
1843 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1844 LParenLoc, EndLoc);
1845 }
1846
1847 /// Build a new OpenMP 'firstprivate' clause.
1848 ///
1849 /// By default, performs semantic analysis to build the new OpenMP clause.
1850 /// Subclasses may override this routine to provide different behavior.
1852 SourceLocation StartLoc,
1853 SourceLocation LParenLoc,
1854 SourceLocation EndLoc) {
1855 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1856 LParenLoc, EndLoc);
1857 }
1858
1859 /// Build a new OpenMP 'lastprivate' clause.
1860 ///
1861 /// By default, performs semantic analysis to build the new OpenMP clause.
1862 /// Subclasses may override this routine to provide different behavior.
1865 SourceLocation LPKindLoc,
1866 SourceLocation ColonLoc,
1867 SourceLocation StartLoc,
1868 SourceLocation LParenLoc,
1869 SourceLocation EndLoc) {
1871 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1872 }
1873
1874 /// Build a new OpenMP 'shared' clause.
1875 ///
1876 /// By default, performs semantic analysis to build the new OpenMP clause.
1877 /// Subclasses may override this routine to provide different behavior.
1879 SourceLocation StartLoc,
1880 SourceLocation LParenLoc,
1881 SourceLocation EndLoc) {
1882 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1883 LParenLoc, EndLoc);
1884 }
1885
1886 /// Build a new OpenMP 'reduction' clause.
1887 ///
1888 /// By default, performs semantic analysis to build the new statement.
1889 /// Subclasses may override this routine to provide different behavior.
1892 SourceLocation StartLoc, SourceLocation LParenLoc,
1893 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1894 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1895 const DeclarationNameInfo &ReductionId,
1896 ArrayRef<Expr *> UnresolvedReductions) {
1898 VarList, Modifier, StartLoc, LParenLoc, ModifierLoc, ColonLoc, EndLoc,
1899 ReductionIdScopeSpec, ReductionId, UnresolvedReductions);
1900 }
1901
1902 /// Build a new OpenMP 'task_reduction' clause.
1903 ///
1904 /// By default, performs semantic analysis to build the new statement.
1905 /// Subclasses may override this routine to provide different behavior.
1907 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1908 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
1909 CXXScopeSpec &ReductionIdScopeSpec,
1910 const DeclarationNameInfo &ReductionId,
1911 ArrayRef<Expr *> UnresolvedReductions) {
1913 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1914 ReductionId, UnresolvedReductions);
1915 }
1916
1917 /// Build a new OpenMP 'in_reduction' clause.
1918 ///
1919 /// By default, performs semantic analysis to build the new statement.
1920 /// Subclasses may override this routine to provide different behavior.
1921 OMPClause *
1923 SourceLocation LParenLoc, SourceLocation ColonLoc,
1924 SourceLocation EndLoc,
1925 CXXScopeSpec &ReductionIdScopeSpec,
1926 const DeclarationNameInfo &ReductionId,
1927 ArrayRef<Expr *> UnresolvedReductions) {
1929 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1930 ReductionId, UnresolvedReductions);
1931 }
1932
1933 /// Build a new OpenMP 'linear' clause.
1934 ///
1935 /// By default, performs semantic analysis to build the new OpenMP clause.
1936 /// Subclasses may override this routine to provide different behavior.
1938 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
1939 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
1940 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1941 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
1943 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
1944 StepModifierLoc, EndLoc);
1945 }
1946
1947 /// Build a new OpenMP 'aligned' clause.
1948 ///
1949 /// By default, performs semantic analysis to build the new OpenMP clause.
1950 /// Subclasses may override this routine to provide different behavior.
1952 SourceLocation StartLoc,
1953 SourceLocation LParenLoc,
1954 SourceLocation ColonLoc,
1955 SourceLocation EndLoc) {
1957 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
1958 }
1959
1960 /// Build a new OpenMP 'copyin' clause.
1961 ///
1962 /// By default, performs semantic analysis to build the new OpenMP clause.
1963 /// Subclasses may override this routine to provide different behavior.
1965 SourceLocation StartLoc,
1966 SourceLocation LParenLoc,
1967 SourceLocation EndLoc) {
1968 return getSema().OpenMP().ActOnOpenMPCopyinClause(VarList, StartLoc,
1969 LParenLoc, EndLoc);
1970 }
1971
1972 /// Build a new OpenMP 'copyprivate' clause.
1973 ///
1974 /// By default, performs semantic analysis to build the new OpenMP clause.
1975 /// Subclasses may override this routine to provide different behavior.
1977 SourceLocation StartLoc,
1978 SourceLocation LParenLoc,
1979 SourceLocation EndLoc) {
1980 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
1981 LParenLoc, EndLoc);
1982 }
1983
1984 /// Build a new OpenMP 'flush' pseudo clause.
1985 ///
1986 /// By default, performs semantic analysis to build the new OpenMP clause.
1987 /// Subclasses may override this routine to provide different behavior.
1989 SourceLocation StartLoc,
1990 SourceLocation LParenLoc,
1991 SourceLocation EndLoc) {
1992 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
1993 LParenLoc, EndLoc);
1994 }
1995
1996 /// Build a new OpenMP 'depobj' pseudo clause.
1997 ///
1998 /// By default, performs semantic analysis to build the new OpenMP clause.
1999 /// Subclasses may override this routine to provide different behavior.
2001 SourceLocation LParenLoc,
2002 SourceLocation EndLoc) {
2003 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2004 LParenLoc, EndLoc);
2005 }
2006
2007 /// Build a new OpenMP 'depend' pseudo clause.
2008 ///
2009 /// By default, performs semantic analysis to build the new OpenMP clause.
2010 /// Subclasses may override this routine to provide different behavior.
2012 Expr *DepModifier, ArrayRef<Expr *> VarList,
2013 SourceLocation StartLoc,
2014 SourceLocation LParenLoc,
2015 SourceLocation EndLoc) {
2017 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2018 }
2019
2020 /// Build a new OpenMP 'device' clause.
2021 ///
2022 /// By default, performs semantic analysis to build the new statement.
2023 /// Subclasses may override this routine to provide different behavior.
2025 Expr *Device, SourceLocation StartLoc,
2026 SourceLocation LParenLoc,
2027 SourceLocation ModifierLoc,
2028 SourceLocation EndLoc) {
2030 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2031 }
2032
2033 /// Build a new OpenMP 'map' clause.
2034 ///
2035 /// By default, performs semantic analysis to build the new OpenMP clause.
2036 /// Subclasses may override this routine to provide different behavior.
2038 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2039 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2040 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2041 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2042 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2043 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2045 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2046 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2047 ColonLoc, VarList, Locs,
2048 /*NoDiagnose=*/false, UnresolvedMappers);
2049 }
2050
2051 /// Build a new OpenMP 'allocate' clause.
2052 ///
2053 /// By default, performs semantic analysis to build the new OpenMP clause.
2054 /// Subclasses may override this routine to provide different behavior.
2056 SourceLocation StartLoc,
2057 SourceLocation LParenLoc,
2058 SourceLocation ColonLoc,
2059 SourceLocation EndLoc) {
2061 Allocate, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2062 }
2063
2064 /// Build a new OpenMP 'num_teams' clause.
2065 ///
2066 /// By default, performs semantic analysis to build the new statement.
2067 /// Subclasses may override this routine to provide different behavior.
2069 SourceLocation LParenLoc,
2070 SourceLocation EndLoc) {
2071 return getSema().OpenMP().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc,
2072 LParenLoc, EndLoc);
2073 }
2074
2075 /// Build a new OpenMP 'thread_limit' clause.
2076 ///
2077 /// By default, performs semantic analysis to build the new statement.
2078 /// Subclasses may override this routine to provide different behavior.
2080 SourceLocation StartLoc,
2081 SourceLocation LParenLoc,
2082 SourceLocation EndLoc) {
2084 ThreadLimit, StartLoc, LParenLoc, EndLoc);
2085 }
2086
2087 /// Build a new OpenMP 'priority' clause.
2088 ///
2089 /// By default, performs semantic analysis to build the new statement.
2090 /// Subclasses may override this routine to provide different behavior.
2092 SourceLocation LParenLoc,
2093 SourceLocation EndLoc) {
2094 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2095 LParenLoc, EndLoc);
2096 }
2097
2098 /// Build a new OpenMP 'grainsize' clause.
2099 ///
2100 /// By default, performs semantic analysis to build the new statement.
2101 /// Subclasses may override this routine to provide different behavior.
2103 Expr *Device, SourceLocation StartLoc,
2104 SourceLocation LParenLoc,
2105 SourceLocation ModifierLoc,
2106 SourceLocation EndLoc) {
2108 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2109 }
2110
2111 /// Build a new OpenMP 'num_tasks' clause.
2112 ///
2113 /// By default, performs semantic analysis to build the new statement.
2114 /// Subclasses may override this routine to provide different behavior.
2116 Expr *NumTasks, SourceLocation StartLoc,
2117 SourceLocation LParenLoc,
2118 SourceLocation ModifierLoc,
2119 SourceLocation EndLoc) {
2121 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2122 }
2123
2124 /// Build a new OpenMP 'hint' clause.
2125 ///
2126 /// By default, performs semantic analysis to build the new statement.
2127 /// Subclasses may override this routine to provide different behavior.
2129 SourceLocation LParenLoc,
2130 SourceLocation EndLoc) {
2131 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2132 EndLoc);
2133 }
2134
2135 /// Build a new OpenMP 'detach' clause.
2136 ///
2137 /// By default, performs semantic analysis to build the new statement.
2138 /// Subclasses may override this routine to provide different behavior.
2140 SourceLocation LParenLoc,
2141 SourceLocation EndLoc) {
2142 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2143 EndLoc);
2144 }
2145
2146 /// Build a new OpenMP 'dist_schedule' clause.
2147 ///
2148 /// By default, performs semantic analysis to build the new OpenMP clause.
2149 /// Subclasses may override this routine to provide different behavior.
2150 OMPClause *
2152 Expr *ChunkSize, SourceLocation StartLoc,
2153 SourceLocation LParenLoc, SourceLocation KindLoc,
2154 SourceLocation CommaLoc, SourceLocation EndLoc) {
2156 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2157 }
2158
2159 /// Build a new OpenMP 'to' clause.
2160 ///
2161 /// By default, performs semantic analysis to build the new statement.
2162 /// Subclasses may override this routine to provide different behavior.
2163 OMPClause *
2165 ArrayRef<SourceLocation> MotionModifiersLoc,
2166 CXXScopeSpec &MapperIdScopeSpec,
2167 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2168 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2169 ArrayRef<Expr *> UnresolvedMappers) {
2171 MotionModifiers, MotionModifiersLoc, MapperIdScopeSpec, MapperId,
2172 ColonLoc, VarList, Locs, UnresolvedMappers);
2173 }
2174
2175 /// Build a new OpenMP 'from' clause.
2176 ///
2177 /// By default, performs semantic analysis to build the new statement.
2178 /// Subclasses may override this routine to provide different behavior.
2179 OMPClause *
2181 ArrayRef<SourceLocation> MotionModifiersLoc,
2182 CXXScopeSpec &MapperIdScopeSpec,
2183 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2184 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2185 ArrayRef<Expr *> UnresolvedMappers) {
2187 MotionModifiers, MotionModifiersLoc, MapperIdScopeSpec, MapperId,
2188 ColonLoc, VarList, Locs, UnresolvedMappers);
2189 }
2190
2191 /// Build a new OpenMP 'use_device_ptr' clause.
2192 ///
2193 /// By default, performs semantic analysis to build the new OpenMP clause.
2194 /// Subclasses may override this routine to provide different behavior.
2196 const OMPVarListLocTy &Locs) {
2197 return getSema().OpenMP().ActOnOpenMPUseDevicePtrClause(VarList, Locs);
2198 }
2199
2200 /// Build a new OpenMP 'use_device_addr' clause.
2201 ///
2202 /// By default, performs semantic analysis to build the new OpenMP clause.
2203 /// Subclasses may override this routine to provide different behavior.
2205 const OMPVarListLocTy &Locs) {
2206 return getSema().OpenMP().ActOnOpenMPUseDeviceAddrClause(VarList, Locs);
2207 }
2208
2209 /// Build a new OpenMP 'is_device_ptr' clause.
2210 ///
2211 /// By default, performs semantic analysis to build the new OpenMP clause.
2212 /// Subclasses may override this routine to provide different behavior.
2214 const OMPVarListLocTy &Locs) {
2215 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2216 }
2217
2218 /// Build a new OpenMP 'has_device_addr' clause.
2219 ///
2220 /// By default, performs semantic analysis to build the new OpenMP clause.
2221 /// Subclasses may override this routine to provide different behavior.
2223 const OMPVarListLocTy &Locs) {
2224 return getSema().OpenMP().ActOnOpenMPHasDeviceAddrClause(VarList, Locs);
2225 }
2226
2227 /// Build a new OpenMP 'defaultmap' clause.
2228 ///
2229 /// By default, performs semantic analysis to build the new OpenMP clause.
2230 /// Subclasses may override this routine to provide different behavior.
2233 SourceLocation StartLoc,
2234 SourceLocation LParenLoc,
2235 SourceLocation MLoc,
2236 SourceLocation KindLoc,
2237 SourceLocation EndLoc) {
2239 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2240 }
2241
2242 /// Build a new OpenMP 'nontemporal' clause.
2243 ///
2244 /// By default, performs semantic analysis to build the new OpenMP clause.
2245 /// Subclasses may override this routine to provide different behavior.
2247 SourceLocation StartLoc,
2248 SourceLocation LParenLoc,
2249 SourceLocation EndLoc) {
2250 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2251 LParenLoc, EndLoc);
2252 }
2253
2254 /// Build a new OpenMP 'inclusive' clause.
2255 ///
2256 /// By default, performs semantic analysis to build the new OpenMP clause.
2257 /// Subclasses may override this routine to provide different behavior.
2259 SourceLocation StartLoc,
2260 SourceLocation LParenLoc,
2261 SourceLocation EndLoc) {
2262 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2263 LParenLoc, EndLoc);
2264 }
2265
2266 /// Build a new OpenMP 'exclusive' clause.
2267 ///
2268 /// By default, performs semantic analysis to build the new OpenMP clause.
2269 /// Subclasses may override this routine to provide different behavior.
2271 SourceLocation StartLoc,
2272 SourceLocation LParenLoc,
2273 SourceLocation EndLoc) {
2274 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2275 LParenLoc, EndLoc);
2276 }
2277
2278 /// Build a new OpenMP 'uses_allocators' clause.
2279 ///
2280 /// By default, performs semantic analysis to build the new OpenMP clause.
2281 /// Subclasses may override this routine to provide different behavior.
2284 SourceLocation LParenLoc, SourceLocation EndLoc) {
2286 StartLoc, LParenLoc, EndLoc, Data);
2287 }
2288
2289 /// Build a new OpenMP 'affinity' clause.
2290 ///
2291 /// By default, performs semantic analysis to build the new OpenMP clause.
2292 /// Subclasses may override this routine to provide different behavior.
2294 SourceLocation LParenLoc,
2295 SourceLocation ColonLoc,
2296 SourceLocation EndLoc, Expr *Modifier,
2297 ArrayRef<Expr *> Locators) {
2299 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2300 }
2301
2302 /// Build a new OpenMP 'order' clause.
2303 ///
2304 /// By default, performs semantic analysis to build the new OpenMP clause.
2305 /// Subclasses may override this routine to provide different behavior.
2307 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2308 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2309 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2311 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2312 }
2313
2314 /// Build a new OpenMP 'init' clause.
2315 ///
2316 /// By default, performs semantic analysis to build the new OpenMP clause.
2317 /// Subclasses may override this routine to provide different behavior.
2319 SourceLocation StartLoc,
2320 SourceLocation LParenLoc,
2321 SourceLocation VarLoc,
2322 SourceLocation EndLoc) {
2324 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2325 }
2326
2327 /// Build a new OpenMP 'use' clause.
2328 ///
2329 /// By default, performs semantic analysis to build the new OpenMP clause.
2330 /// Subclasses may override this routine to provide different behavior.
2332 SourceLocation LParenLoc,
2333 SourceLocation VarLoc, SourceLocation EndLoc) {
2334 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2335 LParenLoc, VarLoc, EndLoc);
2336 }
2337
2338 /// Build a new OpenMP 'destroy' clause.
2339 ///
2340 /// By default, performs semantic analysis to build the new OpenMP clause.
2341 /// Subclasses may override this routine to provide different behavior.
2343 SourceLocation LParenLoc,
2344 SourceLocation VarLoc,
2345 SourceLocation EndLoc) {
2347 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2348 }
2349
2350 /// Build a new OpenMP 'novariants' clause.
2351 ///
2352 /// By default, performs semantic analysis to build the new OpenMP clause.
2353 /// Subclasses may override this routine to provide different behavior.
2355 SourceLocation StartLoc,
2356 SourceLocation LParenLoc,
2357 SourceLocation EndLoc) {
2359 LParenLoc, EndLoc);
2360 }
2361
2362 /// Build a new OpenMP 'nocontext' clause.
2363 ///
2364 /// By default, performs semantic analysis to build the new OpenMP clause.
2365 /// Subclasses may override this routine to provide different behavior.
2367 SourceLocation LParenLoc,
2368 SourceLocation EndLoc) {
2370 LParenLoc, EndLoc);
2371 }
2372
2373 /// Build a new OpenMP 'filter' clause.
2374 ///
2375 /// By default, performs semantic analysis to build the new OpenMP clause.
2376 /// Subclasses may override this routine to provide different behavior.
2378 SourceLocation LParenLoc,
2379 SourceLocation EndLoc) {
2380 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2381 LParenLoc, EndLoc);
2382 }
2383
2384 /// Build a new OpenMP 'bind' clause.
2385 ///
2386 /// By default, performs semantic analysis to build the new OpenMP clause.
2387 /// Subclasses may override this routine to provide different behavior.
2389 SourceLocation KindLoc,
2390 SourceLocation StartLoc,
2391 SourceLocation LParenLoc,
2392 SourceLocation EndLoc) {
2393 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2394 LParenLoc, EndLoc);
2395 }
2396
2397 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2398 ///
2399 /// By default, performs semantic analysis to build the new OpenMP clause.
2400 /// Subclasses may override this routine to provide different behavior.
2402 SourceLocation LParenLoc,
2403 SourceLocation EndLoc) {
2404 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2405 LParenLoc, EndLoc);
2406 }
2407
2408 /// Build a new OpenMP 'ompx_attribute' clause.
2409 ///
2410 /// By default, performs semantic analysis to build the new OpenMP clause.
2411 /// Subclasses may override this routine to provide different behavior.
2413 SourceLocation StartLoc,
2414 SourceLocation LParenLoc,
2415 SourceLocation EndLoc) {
2416 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2417 LParenLoc, EndLoc);
2418 }
2419
2420 /// Build a new OpenMP 'ompx_bare' clause.
2421 ///
2422 /// By default, performs semantic analysis to build the new OpenMP clause.
2423 /// Subclasses may override this routine to provide different behavior.
2425 SourceLocation EndLoc) {
2426 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2427 }
2428
2429 /// Build a new OpenMP 'align' clause.
2430 ///
2431 /// By default, performs semantic analysis to build the new OpenMP clause.
2432 /// Subclasses may override this routine to provide different behavior.
2434 SourceLocation LParenLoc,
2435 SourceLocation EndLoc) {
2436 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2437 EndLoc);
2438 }
2439
2440 /// Build a new OpenMP 'at' clause.
2441 ///
2442 /// By default, performs semantic analysis to build the new OpenMP clause.
2443 /// Subclasses may override this routine to provide different behavior.
2445 SourceLocation StartLoc,
2446 SourceLocation LParenLoc,
2447 SourceLocation EndLoc) {
2448 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2449 LParenLoc, EndLoc);
2450 }
2451
2452 /// Build a new OpenMP 'severity' clause.
2453 ///
2454 /// By default, performs semantic analysis to build the new OpenMP clause.
2455 /// Subclasses may override this routine to provide different behavior.
2457 SourceLocation KwLoc,
2458 SourceLocation StartLoc,
2459 SourceLocation LParenLoc,
2460 SourceLocation EndLoc) {
2461 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2462 LParenLoc, EndLoc);
2463 }
2464
2465 /// Build a new OpenMP 'message' clause.
2466 ///
2467 /// By default, performs semantic analysis to build the new OpenMP clause.
2468 /// Subclasses may override this routine to provide different behavior.
2470 SourceLocation LParenLoc,
2471 SourceLocation EndLoc) {
2472 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2473 EndLoc);
2474 }
2475
2476 /// Build a new OpenMP 'doacross' clause.
2477 ///
2478 /// By default, performs semantic analysis to build the new OpenMP clause.
2479 /// Subclasses may override this routine to provide different behavior.
2480 OMPClause *
2482 SourceLocation DepLoc, SourceLocation ColonLoc,
2483 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2484 SourceLocation LParenLoc, SourceLocation EndLoc) {
2486 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2487 }
2488
2489 /// Rebuild the operand to an Objective-C \@synchronized statement.
2490 ///
2491 /// By default, performs semantic analysis to build the new statement.
2492 /// Subclasses may override this routine to provide different behavior.
2494 Expr *object) {
2495 return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object);
2496 }
2497
2498 /// Build a new Objective-C \@synchronized statement.
2499 ///
2500 /// By default, performs semantic analysis to build the new statement.
2501 /// Subclasses may override this routine to provide different behavior.
2503 Expr *Object, Stmt *Body) {
2504 return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
2505 }
2506
2507 /// Build a new Objective-C \@autoreleasepool statement.
2508 ///
2509 /// By default, performs semantic analysis to build the new statement.
2510 /// Subclasses may override this routine to provide different behavior.
2512 Stmt *Body) {
2513 return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body);
2514 }
2515
2516 /// Build a new Objective-C fast enumeration statement.
2517 ///
2518 /// By default, performs semantic analysis to build the new statement.
2519 /// Subclasses may override this routine to provide different behavior.
2521 Stmt *Element,
2522 Expr *Collection,
2523 SourceLocation RParenLoc,
2524 Stmt *Body) {
2525 StmtResult ForEachStmt = getSema().ActOnObjCForCollectionStmt(ForLoc,
2526 Element,
2527 Collection,
2528 RParenLoc);
2529 if (ForEachStmt.isInvalid())
2530 return StmtError();
2531
2532 return getSema().FinishObjCForCollectionStmt(ForEachStmt.get(), Body);
2533 }
2534
2535 /// Build a new C++ exception declaration.
2536 ///
2537 /// By default, performs semantic analysis to build the new decaration.
2538 /// Subclasses may override this routine to provide different behavior.
2541 SourceLocation StartLoc,
2542 SourceLocation IdLoc,
2543 IdentifierInfo *Id) {
2545 StartLoc, IdLoc, Id);
2546 if (Var)
2547 getSema().CurContext->addDecl(Var);
2548 return Var;
2549 }
2550
2551 /// Build a new C++ catch statement.
2552 ///
2553 /// By default, performs semantic analysis to build the new statement.
2554 /// Subclasses may override this routine to provide different behavior.
2556 VarDecl *ExceptionDecl,
2557 Stmt *Handler) {
2558 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2559 Handler));
2560 }
2561
2562 /// Build a new C++ try statement.
2563 ///
2564 /// By default, performs semantic analysis to build the new statement.
2565 /// Subclasses may override this routine to provide different behavior.
2567 ArrayRef<Stmt *> Handlers) {
2568 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2569 }
2570
2571 /// Build a new C++0x range-based for statement.
2572 ///
2573 /// By default, performs semantic analysis to build the new statement.
2574 /// Subclasses may override this routine to provide different behavior.
2576 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2577 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2578 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2579 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2580 // If we've just learned that the range is actually an Objective-C
2581 // collection, treat this as an Objective-C fast enumeration loop.
2582 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2583 if (RangeStmt->isSingleDecl()) {
2584 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2585 if (RangeVar->isInvalidDecl())
2586 return StmtError();
2587
2588 Expr *RangeExpr = RangeVar->getInit();
2589 if (!RangeExpr->isTypeDependent() &&
2590 RangeExpr->getType()->isObjCObjectPointerType()) {
2591 // FIXME: Support init-statements in Objective-C++20 ranged for
2592 // statement.
2593 if (Init) {
2594 return SemaRef.Diag(Init->getBeginLoc(),
2595 diag::err_objc_for_range_init_stmt)
2596 << Init->getSourceRange();
2597 }
2598 return getSema().ActOnObjCForCollectionStmt(ForLoc, LoopVar,
2599 RangeExpr, RParenLoc);
2600 }
2601 }
2602 }
2603 }
2604
2606 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2607 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2608 }
2609
2610 /// Build a new C++0x range-based for statement.
2611 ///
2612 /// By default, performs semantic analysis to build the new statement.
2613 /// Subclasses may override this routine to provide different behavior.
2615 bool IsIfExists,
2616 NestedNameSpecifierLoc QualifierLoc,
2617 DeclarationNameInfo NameInfo,
2618 Stmt *Nested) {
2619 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2620 QualifierLoc, NameInfo, Nested);
2621 }
2622
2623 /// Attach body to a C++0x range-based for statement.
2624 ///
2625 /// By default, performs semantic analysis to finish the new statement.
2626 /// Subclasses may override this routine to provide different behavior.
2628 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2629 }
2630
2632 Stmt *TryBlock, Stmt *Handler) {
2633 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2634 }
2635
2637 Stmt *Block) {
2638 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2639 }
2640
2642 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2643 }
2644
2646 SourceLocation LParen,
2647 SourceLocation RParen,
2648 TypeSourceInfo *TSI) {
2649 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2650 TSI);
2651 }
2652
2653 /// Build a new predefined expression.
2654 ///
2655 /// By default, performs semantic analysis to build the new expression.
2656 /// Subclasses may override this routine to provide different behavior.
2658 return getSema().BuildPredefinedExpr(Loc, IK);
2659 }
2660
2661 /// Build a new expression that references a declaration.
2662 ///
2663 /// By default, performs semantic analysis to build the new expression.
2664 /// Subclasses may override this routine to provide different behavior.
2666 LookupResult &R,
2667 bool RequiresADL) {
2668 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2669 }
2670
2671
2672 /// Build a new expression that references a declaration.
2673 ///
2674 /// By default, performs semantic analysis to build the new expression.
2675 /// Subclasses may override this routine to provide different behavior.
2677 ValueDecl *VD,
2678 const DeclarationNameInfo &NameInfo,
2679 NamedDecl *Found,
2680 TemplateArgumentListInfo *TemplateArgs) {
2681 CXXScopeSpec SS;
2682 SS.Adopt(QualifierLoc);
2683 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2684 TemplateArgs);
2685 }
2686
2687 /// Build a new expression in parentheses.
2688 ///
2689 /// By default, performs semantic analysis to build the new expression.
2690 /// Subclasses may override this routine to provide different behavior.
2692 SourceLocation RParen) {
2693 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2694 }
2695
2696 /// Build a new pseudo-destructor expression.
2697 ///
2698 /// By default, performs semantic analysis to build the new expression.
2699 /// Subclasses may override this routine to provide different behavior.
2701 SourceLocation OperatorLoc,
2702 bool isArrow,
2703 CXXScopeSpec &SS,
2704 TypeSourceInfo *ScopeType,
2705 SourceLocation CCLoc,
2706 SourceLocation TildeLoc,
2707 PseudoDestructorTypeStorage Destroyed);
2708
2709 /// Build a new unary operator expression.
2710 ///
2711 /// By default, performs semantic analysis to build the new expression.
2712 /// Subclasses may override this routine to provide different behavior.
2715 Expr *SubExpr) {
2716 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2717 }
2718
2719 /// Build a new builtin offsetof expression.
2720 ///
2721 /// By default, performs semantic analysis to build the new expression.
2722 /// Subclasses may override this routine to provide different behavior.
2726 SourceLocation RParenLoc) {
2727 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2728 RParenLoc);
2729 }
2730
2731 /// Build a new sizeof, alignof or vec_step expression with a
2732 /// type argument.
2733 ///
2734 /// By default, performs semantic analysis to build the new expression.
2735 /// Subclasses may override this routine to provide different behavior.
2737 SourceLocation OpLoc,
2738 UnaryExprOrTypeTrait ExprKind,
2739 SourceRange R) {
2740 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2741 }
2742
2743 /// Build a new sizeof, alignof or vec step expression with an
2744 /// expression argument.
2745 ///
2746 /// By default, performs semantic analysis to build the new expression.
2747 /// Subclasses may override this routine to provide different behavior.
2749 UnaryExprOrTypeTrait ExprKind,
2750 SourceRange R) {
2752 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2753 if (Result.isInvalid())
2754 return ExprError();
2755
2756 return Result;
2757 }
2758
2759 /// Build a new array subscript expression.
2760 ///
2761 /// By default, performs semantic analysis to build the new expression.
2762 /// Subclasses may override this routine to provide different behavior.
2764 SourceLocation LBracketLoc,
2765 Expr *RHS,
2766 SourceLocation RBracketLoc) {
2767 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2768 LBracketLoc, RHS,
2769 RBracketLoc);
2770 }
2771
2772 /// Build a new matrix subscript expression.
2773 ///
2774 /// By default, performs semantic analysis to build the new expression.
2775 /// Subclasses may override this routine to provide different behavior.
2777 Expr *ColumnIdx,
2778 SourceLocation RBracketLoc) {
2779 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2780 RBracketLoc);
2781 }
2782
2783 /// Build a new array section expression.
2784 ///
2785 /// By default, performs semantic analysis to build the new expression.
2786 /// Subclasses may override this routine to provide different behavior.
2788 SourceLocation LBracketLoc,
2789 Expr *LowerBound,
2790 SourceLocation ColonLocFirst,
2791 SourceLocation ColonLocSecond,
2792 Expr *Length, Expr *Stride,
2793 SourceLocation RBracketLoc) {
2794 if (IsOMPArraySection)
2796 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2797 Stride, RBracketLoc);
2798
2799 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2800 "Stride/second colon not allowed for OpenACC");
2801
2803 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2804 }
2805
2806 /// Build a new array shaping expression.
2807 ///
2808 /// By default, performs semantic analysis to build the new expression.
2809 /// Subclasses may override this routine to provide different behavior.
2811 SourceLocation RParenLoc,
2812 ArrayRef<Expr *> Dims,
2813 ArrayRef<SourceRange> BracketsRanges) {
2815 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2816 }
2817
2818 /// Build a new iterator expression.
2819 ///
2820 /// By default, performs semantic analysis to build the new expression.
2821 /// Subclasses may override this routine to provide different behavior.
2824 SourceLocation RLoc,
2827 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2828 }
2829
2830 /// Build a new call expression.
2831 ///
2832 /// By default, performs semantic analysis to build the new expression.
2833 /// Subclasses may override this routine to provide different behavior.
2835 MultiExprArg Args,
2836 SourceLocation RParenLoc,
2837 Expr *ExecConfig = nullptr) {
2838 return getSema().ActOnCallExpr(
2839 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2840 }
2841
2843 MultiExprArg Args,
2844 SourceLocation RParenLoc) {
2846 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2847 }
2848
2849 /// Build a new member access expression.
2850 ///
2851 /// By default, performs semantic analysis to build the new expression.
2852 /// Subclasses may override this routine to provide different behavior.
2854 bool isArrow,
2855 NestedNameSpecifierLoc QualifierLoc,
2856 SourceLocation TemplateKWLoc,
2857 const DeclarationNameInfo &MemberNameInfo,
2859 NamedDecl *FoundDecl,
2860 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2861 NamedDecl *FirstQualifierInScope) {
2863 isArrow);
2864 if (!Member->getDeclName()) {
2865 // We have a reference to an unnamed field. This is always the
2866 // base of an anonymous struct/union member access, i.e. the
2867 // field is always of record type.
2868 assert(Member->getType()->isRecordType() &&
2869 "unnamed member not of record type?");
2870
2871 BaseResult =
2873 QualifierLoc.getNestedNameSpecifier(),
2874 FoundDecl, Member);
2875 if (BaseResult.isInvalid())
2876 return ExprError();
2877 Base = BaseResult.get();
2878
2879 CXXScopeSpec EmptySS;
2881 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2882 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), MemberNameInfo);
2883 }
2884
2885 CXXScopeSpec SS;
2886 SS.Adopt(QualifierLoc);
2887
2888 Base = BaseResult.get();
2889 QualType BaseType = Base->getType();
2890
2891 if (isArrow && !BaseType->isPointerType())
2892 return ExprError();
2893
2894 // FIXME: this involves duplicating earlier analysis in a lot of
2895 // cases; we should avoid this when possible.
2896 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
2897 R.addDecl(FoundDecl);
2898 R.resolveKind();
2899
2900 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
2901 isa<FieldDecl, IndirectFieldDecl, MSPropertyDecl>(Member)) {
2902 if (auto *ThisClass = cast<CXXThisExpr>(Base)
2903 ->getType()
2904 ->getPointeeType()
2905 ->getAsCXXRecordDecl()) {
2906 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
2907 // In unevaluated contexts, an expression supposed to be a member access
2908 // might reference a member in an unrelated class.
2909 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
2910 return getSema().BuildDeclRefExpr(Member, Member->getType(),
2911 VK_LValue, Member->getLocation());
2912 }
2913 }
2914
2915 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
2916 SS, TemplateKWLoc,
2917 FirstQualifierInScope,
2918 R, ExplicitTemplateArgs,
2919 /*S*/nullptr);
2920 }
2921
2922 /// Build a new binary operator expression.
2923 ///
2924 /// By default, performs semantic analysis to build the new expression.
2925 /// Subclasses may override this routine to provide different behavior.
2928 Expr *LHS, Expr *RHS) {
2929 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS);
2930 }
2931
2932 /// Build a new rewritten operator expression.
2933 ///
2934 /// By default, performs semantic analysis to build the new expression.
2935 /// Subclasses may override this routine to provide different behavior.
2937 SourceLocation OpLoc, BinaryOperatorKind Opcode,
2938 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
2939 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
2940 RHS, /*RequiresADL*/false);
2941 }
2942
2943 /// Build a new conditional operator expression.
2944 ///
2945 /// By default, performs semantic analysis to build the new expression.
2946 /// Subclasses may override this routine to provide different behavior.
2948 SourceLocation QuestionLoc,
2949 Expr *LHS,
2950 SourceLocation ColonLoc,
2951 Expr *RHS) {
2952 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
2953 LHS, RHS);
2954 }
2955
2956 /// Build a new C-style cast expression.
2957 ///
2958 /// By default, performs semantic analysis to build the new expression.
2959 /// Subclasses may override this routine to provide different behavior.
2961 TypeSourceInfo *TInfo,
2962 SourceLocation RParenLoc,
2963 Expr *SubExpr) {
2964 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
2965 SubExpr);
2966 }
2967
2968 /// Build a new compound literal expression.
2969 ///
2970 /// By default, performs semantic analysis to build the new expression.
2971 /// Subclasses may override this routine to provide different behavior.
2973 TypeSourceInfo *TInfo,
2974 SourceLocation RParenLoc,
2975 Expr *Init) {
2976 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
2977 Init);
2978 }
2979
2980 /// Build a new extended vector element access expression.
2981 ///
2982 /// By default, performs semantic analysis to build the new expression.
2983 /// Subclasses may override this routine to provide different behavior.
2985 bool IsArrow,
2986 SourceLocation AccessorLoc,
2987 IdentifierInfo &Accessor) {
2988
2989 CXXScopeSpec SS;
2990 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
2992 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
2993 /*FirstQualifierInScope*/ nullptr, NameInfo,
2994 /* TemplateArgs */ nullptr,
2995 /*S*/ nullptr);
2996 }
2997
2998 /// Build a new initializer list expression.
2999 ///
3000 /// By default, performs semantic analysis to build the new expression.
3001 /// Subclasses may override this routine to provide different behavior.
3003 MultiExprArg Inits,
3004 SourceLocation RBraceLoc) {
3005 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3006 }
3007
3008 /// Build a new designated initializer expression.
3009 ///
3010 /// By default, performs semantic analysis to build the new expression.
3011 /// Subclasses may override this routine to provide different behavior.
3013 MultiExprArg ArrayExprs,
3014 SourceLocation EqualOrColonLoc,
3015 bool GNUSyntax,
3016 Expr *Init) {
3018 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3019 Init);
3020 if (Result.isInvalid())
3021 return ExprError();
3022
3023 return Result;
3024 }
3025
3026 /// Build a new value-initialized expression.
3027 ///
3028 /// By default, builds the implicit value initialization without performing
3029 /// any semantic analysis. Subclasses may override this routine to provide
3030 /// different behavior.
3032 return new (SemaRef.Context) ImplicitValueInitExpr(T);
3033 }
3034
3035 /// Build a new \c va_arg expression.
3036 ///
3037 /// By default, performs semantic analysis to build the new expression.
3038 /// Subclasses may override this routine to provide different behavior.
3040 Expr *SubExpr, TypeSourceInfo *TInfo,
3041 SourceLocation RParenLoc) {
3042 return getSema().BuildVAArgExpr(BuiltinLoc,
3043 SubExpr, TInfo,
3044 RParenLoc);
3045 }
3046
3047 /// Build a new expression list in parentheses.
3048 ///
3049 /// By default, performs semantic analysis to build the new expression.
3050 /// Subclasses may override this routine to provide different behavior.
3052 MultiExprArg SubExprs,
3053 SourceLocation RParenLoc) {
3054 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3055 }
3056
3057 /// Build a new address-of-label expression.
3058 ///
3059 /// By default, performs semantic analysis, using the name of the label
3060 /// rather than attempting to map the label statement itself.
3061 /// Subclasses may override this routine to provide different behavior.
3063 SourceLocation LabelLoc, LabelDecl *Label) {
3064 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3065 }
3066
3067 /// Build a new GNU statement expression.
3068 ///
3069 /// By default, performs semantic analysis to build the new expression.
3070 /// Subclasses may override this routine to provide different behavior.
3072 SourceLocation RParenLoc, unsigned TemplateDepth) {
3073 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3074 TemplateDepth);
3075 }
3076
3077 /// Build a new __builtin_choose_expr expression.
3078 ///
3079 /// By default, performs semantic analysis to build the new expression.
3080 /// Subclasses may override this routine to provide different behavior.
3082 Expr *Cond, Expr *LHS, Expr *RHS,
3083 SourceLocation RParenLoc) {
3084 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3085 Cond, LHS, RHS,
3086 RParenLoc);
3087 }
3088
3089 /// Build a new generic selection expression with an expression predicate.
3090 ///
3091 /// By default, performs semantic analysis to build the new expression.
3092 /// Subclasses may override this routine to provide different behavior.
3094 SourceLocation DefaultLoc,
3095 SourceLocation RParenLoc,
3096 Expr *ControllingExpr,
3098 ArrayRef<Expr *> Exprs) {
3099 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3100 /*PredicateIsExpr=*/true,
3101 ControllingExpr, Types, Exprs);
3102 }
3103
3104 /// Build a new generic selection expression with a type predicate.
3105 ///
3106 /// By default, performs semantic analysis to build the new expression.
3107 /// Subclasses may override this routine to provide different behavior.
3109 SourceLocation DefaultLoc,
3110 SourceLocation RParenLoc,
3111 TypeSourceInfo *ControllingType,
3113 ArrayRef<Expr *> Exprs) {
3114 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3115 /*PredicateIsExpr=*/false,
3116 ControllingType, Types, Exprs);
3117 }
3118
3119 /// Build a new overloaded operator call expression.
3120 ///
3121 /// By default, performs semantic analysis to build the new expression.
3122 /// The semantic analysis provides the behavior of template instantiation,
3123 /// copying with transformations that turn what looks like an overloaded
3124 /// operator call into a use of a builtin operator, performing
3125 /// argument-dependent lookup, etc. Subclasses may override this routine to
3126 /// provide different behavior.
3128 SourceLocation OpLoc,
3129 SourceLocation CalleeLoc,
3130 bool RequiresADL,
3131 const UnresolvedSetImpl &Functions,
3132 Expr *First, Expr *Second);
3133
3134 /// Build a new C++ "named" cast expression, such as static_cast or
3135 /// reinterpret_cast.
3136 ///
3137 /// By default, this routine dispatches to one of the more-specific routines
3138 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3139 /// Subclasses may override this routine to provide different behavior.
3142 SourceLocation LAngleLoc,
3143 TypeSourceInfo *TInfo,
3144 SourceLocation RAngleLoc,
3145 SourceLocation LParenLoc,
3146 Expr *SubExpr,
3147 SourceLocation RParenLoc) {
3148 switch (Class) {
3149 case Stmt::CXXStaticCastExprClass:
3150 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3151 RAngleLoc, LParenLoc,
3152 SubExpr, RParenLoc);
3153
3154 case Stmt::CXXDynamicCastExprClass:
3155 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3156 RAngleLoc, LParenLoc,
3157 SubExpr, RParenLoc);
3158
3159 case Stmt::CXXReinterpretCastExprClass:
3160 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3161 RAngleLoc, LParenLoc,
3162 SubExpr,
3163 RParenLoc);
3164
3165 case Stmt::CXXConstCastExprClass:
3166 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3167 RAngleLoc, LParenLoc,
3168 SubExpr, RParenLoc);
3169
3170 case Stmt::CXXAddrspaceCastExprClass:
3171 return getDerived().RebuildCXXAddrspaceCastExpr(
3172 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3173
3174 default:
3175 llvm_unreachable("Invalid C++ named cast");
3176 }
3177 }
3178
3179 /// Build a new C++ static_cast expression.
3180 ///
3181 /// By default, performs semantic analysis to build the new expression.
3182 /// Subclasses may override this routine to provide different behavior.
3184 SourceLocation LAngleLoc,
3185 TypeSourceInfo *TInfo,
3186 SourceLocation RAngleLoc,
3187 SourceLocation LParenLoc,
3188 Expr *SubExpr,
3189 SourceLocation RParenLoc) {
3190 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
3191 TInfo, SubExpr,
3192 SourceRange(LAngleLoc, RAngleLoc),
3193 SourceRange(LParenLoc, RParenLoc));
3194 }
3195
3196 /// Build a new C++ dynamic_cast expression.
3197 ///
3198 /// By default, performs semantic analysis to build the new expression.
3199 /// Subclasses may override this routine to provide different behavior.
3201 SourceLocation LAngleLoc,
3202 TypeSourceInfo *TInfo,
3203 SourceLocation RAngleLoc,
3204 SourceLocation LParenLoc,
3205 Expr *SubExpr,
3206 SourceLocation RParenLoc) {
3207 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3208 TInfo, SubExpr,
3209 SourceRange(LAngleLoc, RAngleLoc),
3210 SourceRange(LParenLoc, RParenLoc));
3211 }
3212
3213 /// Build a new C++ reinterpret_cast expression.
3214 ///
3215 /// By default, performs semantic analysis to build the new expression.
3216 /// Subclasses may override this routine to provide different behavior.
3218 SourceLocation LAngleLoc,
3219 TypeSourceInfo *TInfo,
3220 SourceLocation RAngleLoc,
3221 SourceLocation LParenLoc,
3222 Expr *SubExpr,
3223 SourceLocation RParenLoc) {
3224 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3225 TInfo, SubExpr,
3226 SourceRange(LAngleLoc, RAngleLoc),
3227 SourceRange(LParenLoc, RParenLoc));
3228 }
3229
3230 /// Build a new C++ const_cast expression.
3231 ///
3232 /// By default, performs semantic analysis to build the new expression.
3233 /// Subclasses may override this routine to provide different behavior.
3235 SourceLocation LAngleLoc,
3236 TypeSourceInfo *TInfo,
3237 SourceLocation RAngleLoc,
3238 SourceLocation LParenLoc,
3239 Expr *SubExpr,
3240 SourceLocation RParenLoc) {
3241 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3242 TInfo, SubExpr,
3243 SourceRange(LAngleLoc, RAngleLoc),
3244 SourceRange(LParenLoc, RParenLoc));
3245 }
3246
3249 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3250 SourceLocation LParenLoc, Expr *SubExpr,
3251 SourceLocation RParenLoc) {
3252 return getSema().BuildCXXNamedCast(
3253 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3254 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3255 }
3256
3257 /// Build a new C++ functional-style cast expression.
3258 ///
3259 /// By default, performs semantic analysis to build the new expression.
3260 /// Subclasses may override this routine to provide different behavior.
3262 SourceLocation LParenLoc,
3263 Expr *Sub,
3264 SourceLocation RParenLoc,
3265 bool ListInitialization) {
3266 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3267 // CXXParenListInitExpr. Pass its expanded arguments so that the
3268 // CXXParenListInitExpr can be rebuilt.
3269 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3271 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3272 RParenLoc, ListInitialization);
3273 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3274 MultiExprArg(&Sub, 1), RParenLoc,
3275 ListInitialization);
3276 }
3277
3278 /// Build a new C++ __builtin_bit_cast expression.
3279 ///
3280 /// By default, performs semantic analysis to build the new expression.
3281 /// Subclasses may override this routine to provide different behavior.
3283 TypeSourceInfo *TSI, Expr *Sub,
3284 SourceLocation RParenLoc) {
3285 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3286 }
3287
3288 /// Build a new C++ typeid(type) expression.
3289 ///
3290 /// By default, performs semantic analysis to build the new expression.
3291 /// Subclasses may override this routine to provide different behavior.
3293 SourceLocation TypeidLoc,
3294 TypeSourceInfo *Operand,
3295 SourceLocation RParenLoc) {
3296 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3297 RParenLoc);
3298 }
3299
3300
3301 /// Build a new C++ typeid(expr) expression.
3302 ///
3303 /// By default, performs semantic analysis to build the new expression.
3304 /// Subclasses may override this routine to provide different behavior.
3306 SourceLocation TypeidLoc,
3307 Expr *Operand,
3308 SourceLocation RParenLoc) {
3309 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3310 RParenLoc);
3311 }
3312
3313 /// Build a new C++ __uuidof(type) expression.
3314 ///
3315 /// By default, performs semantic analysis to build the new expression.
3316 /// Subclasses may override this routine to provide different behavior.
3318 TypeSourceInfo *Operand,
3319 SourceLocation RParenLoc) {
3320 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3321 }
3322
3323 /// Build a new C++ __uuidof(expr) expression.
3324 ///
3325 /// By default, performs semantic analysis to build the new expression.
3326 /// Subclasses may override this routine to provide different behavior.
3328 Expr *Operand, SourceLocation RParenLoc) {
3329 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3330 }
3331
3332 /// Build a new C++ "this" expression.
3333 ///
3334 /// By default, performs semantic analysis to build a new "this" expression.
3335 /// Subclasses may override this routine to provide different behavior.
3337 QualType ThisType,
3338 bool isImplicit) {
3339 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3340 return ExprError();
3341 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3342 }
3343
3344 /// Build a new C++ throw expression.
3345 ///
3346 /// By default, performs semantic analysis to build the new expression.
3347 /// Subclasses may override this routine to provide different behavior.
3349 bool IsThrownVariableInScope) {
3350 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3351 }
3352
3353 /// Build a new C++ default-argument expression.
3354 ///
3355 /// By default, builds a new default-argument expression, which does not
3356 /// require any semantic analysis. Subclasses may override this routine to
3357 /// provide different behavior.
3359 Expr *RewrittenExpr) {
3360 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3361 RewrittenExpr, getSema().CurContext);
3362 }
3363
3364 /// Build a new C++11 default-initialization expression.
3365 ///
3366 /// By default, builds a new default field initialization expression, which
3367 /// does not require any semantic analysis. Subclasses may override this
3368 /// routine to provide different behavior.
3370 FieldDecl *Field) {
3371 return getSema().BuildCXXDefaultInitExpr(Loc, Field);
3372 }
3373
3374 /// Build a new C++ zero-initialization expression.
3375 ///
3376 /// By default, performs semantic analysis to build the new expression.
3377 /// Subclasses may override this routine to provide different behavior.
3379 SourceLocation LParenLoc,
3380 SourceLocation RParenLoc) {
3381 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, std::nullopt,
3382 RParenLoc,
3383 /*ListInitialization=*/false);
3384 }
3385
3386 /// Build a new C++ "new" expression.
3387 ///
3388 /// By default, performs semantic analysis to build the new expression.
3389 /// Subclasses may override this routine to provide different behavior.
3391 SourceLocation PlacementLParen,
3392 MultiExprArg PlacementArgs,
3393 SourceLocation PlacementRParen,
3394 SourceRange TypeIdParens, QualType AllocatedType,
3395 TypeSourceInfo *AllocatedTypeInfo,
3396 std::optional<Expr *> ArraySize,
3397 SourceRange DirectInitRange, Expr *Initializer) {
3398 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3399 PlacementLParen,
3400 PlacementArgs,
3401 PlacementRParen,
3402 TypeIdParens,
3403 AllocatedType,
3404 AllocatedTypeInfo,
3405 ArraySize,
3406 DirectInitRange,
3407 Initializer);
3408 }
3409
3410 /// Build a new C++ "delete" expression.
3411 ///
3412 /// By default, performs semantic analysis to build the new expression.
3413 /// Subclasses may override this routine to provide different behavior.
3415 bool IsGlobalDelete,
3416 bool IsArrayForm,
3417 Expr *Operand) {
3418 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3419 Operand);
3420 }
3421
3422 /// Build a new type trait expression.
3423 ///
3424 /// By default, performs semantic analysis to build the new expression.
3425 /// Subclasses may override this routine to provide different behavior.
3427 SourceLocation StartLoc,
3429 SourceLocation RParenLoc) {
3430 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3431 }
3432
3433 /// Build a new array type trait expression.
3434 ///
3435 /// By default, performs semantic analysis to build the new expression.
3436 /// Subclasses may override this routine to provide different behavior.
3438 SourceLocation StartLoc,
3439 TypeSourceInfo *TSInfo,
3440 Expr *DimExpr,
3441 SourceLocation RParenLoc) {
3442 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3443 }
3444
3445 /// Build a new expression trait expression.
3446 ///
3447 /// By default, performs semantic analysis to build the new expression.
3448 /// Subclasses may override this routine to provide different behavior.
3450 SourceLocation StartLoc,
3451 Expr *Queried,
3452 SourceLocation RParenLoc) {
3453 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3454 }
3455
3456 /// Build a new (previously unresolved) declaration reference
3457 /// expression.
3458 ///
3459 /// By default, performs semantic analysis to build the new expression.
3460 /// Subclasses may override this routine to provide different behavior.
3462 NestedNameSpecifierLoc QualifierLoc,
3463 SourceLocation TemplateKWLoc,
3464 const DeclarationNameInfo &NameInfo,
3465 const TemplateArgumentListInfo *TemplateArgs,
3466 bool IsAddressOfOperand,
3467 TypeSourceInfo **RecoveryTSI) {
3468 CXXScopeSpec SS;
3469 SS.Adopt(QualifierLoc);
3470
3471 if (TemplateArgs || TemplateKWLoc.isValid())
3472 return getSema().BuildQualifiedTemplateIdExpr(SS, TemplateKWLoc, NameInfo,
3473 TemplateArgs);
3474
3476 SS, NameInfo, IsAddressOfOperand, /*S*/nullptr, RecoveryTSI);
3477 }
3478
3479 /// Build a new template-id expression.
3480 ///
3481 /// By default, performs semantic analysis to build the new expression.
3482 /// Subclasses may override this routine to provide different behavior.
3484 SourceLocation TemplateKWLoc,
3485 LookupResult &R,
3486 bool RequiresADL,
3487 const TemplateArgumentListInfo *TemplateArgs) {
3488 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3489 TemplateArgs);
3490 }
3491
3492 /// Build a new object-construction expression.
3493 ///
3494 /// By default, performs semantic analysis to build the new expression.
3495 /// Subclasses may override this routine to provide different behavior.
3497 QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor,
3498 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3499 bool ListInitialization, bool StdInitListInitialization,
3500 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3501 SourceRange ParenRange) {
3502 // Reconstruct the constructor we originally found, which might be
3503 // different if this is a call to an inherited constructor.
3504 CXXConstructorDecl *FoundCtor = Constructor;
3505 if (Constructor->isInheritingConstructor())
3506 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3507
3508 SmallVector<Expr *, 8> ConvertedArgs;
3509 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3510 ConvertedArgs))
3511 return ExprError();
3512
3513 return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
3514 IsElidable,
3515 ConvertedArgs,
3516 HadMultipleCandidates,
3517 ListInitialization,
3518 StdInitListInitialization,
3519 RequiresZeroInit, ConstructKind,
3520 ParenRange);
3521 }
3522
3523 /// Build a new implicit construction via inherited constructor
3524 /// expression.
3526 CXXConstructorDecl *Constructor,
3527 bool ConstructsVBase,
3528 bool InheritedFromVBase) {
3530 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3531 }
3532
3533 /// Build a new object-construction expression.
3534 ///
3535 /// By default, performs semantic analysis to build the new expression.
3536 /// Subclasses may override this routine to provide different behavior.
3538 SourceLocation LParenOrBraceLoc,
3539 MultiExprArg Args,
3540 SourceLocation RParenOrBraceLoc,
3541 bool ListInitialization) {
3543 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3544 }
3545
3546 /// Build a new object-construction expression.
3547 ///
3548 /// By default, performs semantic analysis to build the new expression.
3549 /// Subclasses may override this routine to provide different behavior.
3551 SourceLocation LParenLoc,
3552 MultiExprArg Args,
3553 SourceLocation RParenLoc,
3554 bool ListInitialization) {
3555 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3556 RParenLoc, ListInitialization);
3557 }
3558
3559 /// Build a new member reference expression.
3560 ///
3561 /// By default, performs semantic analysis to build the new expression.
3562 /// Subclasses may override this routine to provide different behavior.
3564 QualType BaseType,
3565 bool IsArrow,
3566 SourceLocation OperatorLoc,
3567 NestedNameSpecifierLoc QualifierLoc,
3568 SourceLocation TemplateKWLoc,
3569 NamedDecl *FirstQualifierInScope,
3570 const DeclarationNameInfo &MemberNameInfo,
3571 const TemplateArgumentListInfo *TemplateArgs) {
3572 CXXScopeSpec SS;
3573 SS.Adopt(QualifierLoc);
3574
3575 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3576 OperatorLoc, IsArrow,
3577 SS, TemplateKWLoc,
3578 FirstQualifierInScope,
3579 MemberNameInfo,
3580 TemplateArgs, /*S*/nullptr);
3581 }
3582
3583 /// Build a new member reference expression.
3584 ///
3585 /// By default, performs semantic analysis to build the new expression.
3586 /// Subclasses may override this routine to provide different behavior.
3588 SourceLocation OperatorLoc,
3589 bool IsArrow,
3590 NestedNameSpecifierLoc QualifierLoc,
3591 SourceLocation TemplateKWLoc,
3592 NamedDecl *FirstQualifierInScope,
3593 LookupResult &R,
3594 const TemplateArgumentListInfo *TemplateArgs) {
3595 CXXScopeSpec SS;
3596 SS.Adopt(QualifierLoc);
3597
3598 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3599 OperatorLoc, IsArrow,
3600 SS, TemplateKWLoc,
3601 FirstQualifierInScope,
3602 R, TemplateArgs, /*S*/nullptr);
3603 }
3604
3605 /// Build a new noexcept expression.
3606 ///
3607 /// By default, performs semantic analysis to build the new expression.
3608 /// Subclasses may override this routine to provide different behavior.
3610 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3611 }
3612
3613 /// Build a new expression to compute the length of a parameter pack.
3615 SourceLocation PackLoc,
3616 SourceLocation RParenLoc,
3617 std::optional<unsigned> Length,
3618 ArrayRef<TemplateArgument> PartialArgs) {
3619 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3620 RParenLoc, Length, PartialArgs);
3621 }
3622
3624 SourceLocation RSquareLoc,
3625 Expr *PackIdExpression, Expr *IndexExpr,
3626 ArrayRef<Expr *> ExpandedExprs,
3627 bool EmptyPack = false) {
3628 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3629 IndexExpr, RSquareLoc, ExpandedExprs,
3630 EmptyPack);
3631 }
3632
3633 /// Build a new expression representing a call to a source location
3634 /// builtin.
3635 ///
3636 /// By default, performs semantic analysis to build the new expression.
3637 /// Subclasses may override this routine to provide different behavior.
3639 SourceLocation BuiltinLoc,
3640 SourceLocation RPLoc,
3641 DeclContext *ParentContext) {
3642 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3643 ParentContext);
3644 }
3645
3646 /// Build a new Objective-C boxed expression.
3647 ///
3648 /// By default, performs semantic analysis to build the new expression.
3649 /// Subclasses may override this routine to provide different behavior.
3651 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3652 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3654 CXXScopeSpec SS;
3655 SS.Adopt(NNS);
3656 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3657 ConceptNameInfo,
3658 FoundDecl,
3659 NamedConcept, TALI);
3660 if (Result.isInvalid())
3661 return ExprError();
3662 return Result;
3663 }
3664
3665 /// \brief Build a new requires expression.
3666 ///
3667 /// By default, performs semantic analysis to build the new expression.
3668 /// Subclasses may override this routine to provide different behavior.
3671 SourceLocation LParenLoc,
3672 ArrayRef<ParmVarDecl *> LocalParameters,
3673 SourceLocation RParenLoc,
3675 SourceLocation ClosingBraceLoc) {
3676 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3677 LocalParameters, RParenLoc, Requirements,
3678 ClosingBraceLoc);
3679 }
3680
3684 return SemaRef.BuildTypeRequirement(SubstDiag);
3685 }
3686
3689 }
3690
3693 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3694 SourceLocation NoexceptLoc,
3696 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3697 std::move(Ret));
3698 }
3699
3701 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3703 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3704 std::move(Ret));
3705 }
3706
3708 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3709 const ASTConstraintSatisfaction &Satisfaction) {
3710 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3711 Satisfaction);
3712 }
3713
3715 return SemaRef.BuildNestedRequirement(Constraint);
3716 }
3717
3718 /// \brief Build a new Objective-C boxed expression.
3719 ///
3720 /// By default, performs semantic analysis to build the new expression.
3721 /// Subclasses may override this routine to provide different behavior.
3723 return getSema().BuildObjCBoxedExpr(SR, ValueExpr);
3724 }
3725
3726 /// Build a new Objective-C array literal.
3727 ///
3728 /// By default, performs semantic analysis to build the new expression.
3729 /// Subclasses may override this routine to provide different behavior.
3731 Expr **Elements, unsigned NumElements) {
3732 return getSema().BuildObjCArrayLiteral(Range,
3733 MultiExprArg(Elements, NumElements));
3734 }
3735
3737 Expr *Base, Expr *Key,
3738 ObjCMethodDecl *getterMethod,
3739 ObjCMethodDecl *setterMethod) {
3740 return getSema().BuildObjCSubscriptExpression(RB, Base, Key,
3741 getterMethod, setterMethod);
3742 }
3743
3744 /// Build a new Objective-C dictionary literal.
3745 ///
3746 /// By default, performs semantic analysis to build the new expression.
3747 /// Subclasses may override this routine to provide different behavior.
3750 return getSema().BuildObjCDictionaryLiteral(Range, Elements);
3751 }
3752
3753 /// Build a new Objective-C \@encode expression.
3754 ///
3755 /// By default, performs semantic analysis to build the new expression.
3756 /// Subclasses may override this routine to provide different behavior.
3758 TypeSourceInfo *EncodeTypeInfo,
3759 SourceLocation RParenLoc) {
3760 return SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, RParenLoc);
3761 }
3762
3763 /// Build a new Objective-C class message.
3765 Selector Sel,
3766 ArrayRef<SourceLocation> SelectorLocs,
3767 ObjCMethodDecl *Method,
3768 SourceLocation LBracLoc,
3769 MultiExprArg Args,
3770 SourceLocation RBracLoc) {
3771 return SemaRef.BuildClassMessage(ReceiverTypeInfo,
3772 ReceiverTypeInfo->getType(),
3773 /*SuperLoc=*/SourceLocation(),
3774 Sel, Method, LBracLoc, SelectorLocs,
3775 RBracLoc, Args);
3776 }
3777
3778 /// Build a new Objective-C instance message.
3780 Selector Sel,
3781 ArrayRef<SourceLocation> SelectorLocs,
3782 ObjCMethodDecl *Method,
3783 SourceLocation LBracLoc,
3784 MultiExprArg Args,
3785 SourceLocation RBracLoc) {
3786 return SemaRef.BuildInstanceMessage(Receiver,
3787 Receiver->getType(),
3788 /*SuperLoc=*/SourceLocation(),
3789 Sel, Method, LBracLoc, SelectorLocs,
3790 RBracLoc, Args);
3791 }
3792
3793 /// Build a new Objective-C instance/class message to 'super'.
3795 Selector Sel,
3796 ArrayRef<SourceLocation> SelectorLocs,
3797 QualType SuperType,
3798 ObjCMethodDecl *Method,
3799 SourceLocation LBracLoc,
3800 MultiExprArg Args,
3801 SourceLocation RBracLoc) {
3802 return Method->isInstanceMethod() ? SemaRef.BuildInstanceMessage(nullptr,
3803 SuperType,
3804 SuperLoc,
3805 Sel, Method, LBracLoc, SelectorLocs,
3806 RBracLoc, Args)
3807 : SemaRef.BuildClassMessage(nullptr,
3808 SuperType,
3809 SuperLoc,
3810 Sel, Method, LBracLoc, SelectorLocs,
3811 RBracLoc, Args);
3812
3813
3814 }
3815
3816 /// Build a new Objective-C ivar reference expression.
3817 ///
3818 /// By default, performs semantic analysis to build the new expression.
3819 /// Subclasses may override this routine to provide different behavior.
3821 SourceLocation IvarLoc,
3822 bool IsArrow, bool IsFreeIvar) {
3823 CXXScopeSpec SS;
3824 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3826 BaseArg, BaseArg->getType(),
3827 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3828 /*FirstQualifierInScope=*/nullptr, NameInfo,
3829 /*TemplateArgs=*/nullptr,
3830 /*S=*/nullptr);
3831 if (IsFreeIvar && Result.isUsable())
3832 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3833 return Result;
3834 }
3835
3836 /// Build a new Objective-C property reference expression.
3837 ///
3838 /// By default, performs semantic analysis to build the new expression.
3839 /// Subclasses may override this routine to provide different behavior.
3842 SourceLocation PropertyLoc) {
3843 CXXScopeSpec SS;
3844 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3845 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3846 /*FIXME:*/PropertyLoc,
3847 /*IsArrow=*/false,
3848 SS, SourceLocation(),
3849 /*FirstQualifierInScope=*/nullptr,
3850 NameInfo,
3851 /*TemplateArgs=*/nullptr,
3852 /*S=*/nullptr);
3853 }
3854
3855 /// Build a new Objective-C property reference expression.
3856 ///
3857 /// By default, performs semantic analysis to build the new expression.
3858 /// Subclasses may override this routine to provide different behavior.
3860 ObjCMethodDecl *Getter,
3861 ObjCMethodDecl *Setter,
3862 SourceLocation PropertyLoc) {
3863 // Since these expressions can only be value-dependent, we do not
3864 // need to perform semantic analysis again.
3865 return Owned(
3866 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3868 PropertyLoc, Base));
3869 }
3870
3871 /// Build a new Objective-C "isa" expression.
3872 ///
3873 /// By default, performs semantic analysis to build the new expression.
3874 /// Subclasses may override this routine to provide different behavior.
3876 SourceLocation OpLoc, bool IsArrow) {
3877 CXXScopeSpec SS;
3878 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3879 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3880 OpLoc, IsArrow,
3881 SS, SourceLocation(),
3882 /*FirstQualifierInScope=*/nullptr,
3883 NameInfo,
3884 /*TemplateArgs=*/nullptr,
3885 /*S=*/nullptr);
3886 }
3887
3888 /// Build a new shuffle vector expression.
3889 ///
3890 /// By default, performs semantic analysis to build the new expression.
3891 /// Subclasses may override this routine to provide different behavior.
3893 MultiExprArg SubExprs,
3894 SourceLocation RParenLoc) {
3895 // Find the declaration for __builtin_shufflevector
3896 const IdentifierInfo &Name
3897 = SemaRef.Context.Idents.get("__builtin_shufflevector");
3899 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
3900 assert(!Lookup.empty() && "No __builtin_shufflevector?");
3901
3902 // Build a reference to the __builtin_shufflevector builtin
3903 FunctionDecl *Builtin = cast<FunctionDecl>(Lookup.front());
3904 Expr *Callee = new (SemaRef.Context)
3905 DeclRefExpr(SemaRef.Context, Builtin, false,
3906 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
3907 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
3908 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
3909 CK_BuiltinFnToFnPtr).get();
3910
3911 // Build the CallExpr
3912 ExprResult TheCall = CallExpr::Create(
3913 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
3914 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
3916
3917 // Type-check the __builtin_shufflevector expression.
3918 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
3919 }
3920
3921 /// Build a new convert vector expression.
3923 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
3924 SourceLocation RParenLoc) {
3925 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
3926 }
3927
3928 /// Build a new template argument pack expansion.
3929 ///
3930 /// By default, performs semantic analysis to build a new pack expansion
3931 /// for a template argument. Subclasses may override this routine to provide
3932 /// different behavior.
3935 std::optional<unsigned> NumExpansions) {
3936 switch (Pattern.getArgument().getKind()) {
3940 EllipsisLoc, NumExpansions);
3941 if (Result.isInvalid())
3942 return TemplateArgumentLoc();
3943
3944 return TemplateArgumentLoc(Result.get(), Result.get());
3945 }
3946
3948 return TemplateArgumentLoc(
3951 NumExpansions),
3952 Pattern.getTemplateQualifierLoc(), Pattern.getTemplateNameLoc(),
3953 EllipsisLoc);
3954
3962 llvm_unreachable("Pack expansion pattern has no parameter packs");
3963
3965 if (TypeSourceInfo *Expansion
3966 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
3967 EllipsisLoc,
3968 NumExpansions))
3969 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
3970 Expansion);
3971 break;
3972 }
3973
3974 return TemplateArgumentLoc();
3975 }
3976
3977 /// Build a new expression pack expansion.
3978 ///
3979 /// By default, performs semantic analysis to build a new pack expansion
3980 /// for an expression. Subclasses may override this routine to provide
3981 /// different behavior.
3983 std::optional<unsigned> NumExpansions) {
3984 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
3985 }
3986
3987 /// Build a new C++1z fold-expression.
3988 ///
3989 /// By default, performs semantic analysis in order to build a new fold
3990 /// expression.
3992 SourceLocation LParenLoc, Expr *LHS,
3993 BinaryOperatorKind Operator,
3994 SourceLocation EllipsisLoc, Expr *RHS,
3995 SourceLocation RParenLoc,
3996 std::optional<unsigned> NumExpansions) {
3997 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
3998 EllipsisLoc, RHS, RParenLoc,
3999 NumExpansions);
4000 }
4001
4002 /// Build an empty C++1z fold-expression with the given operator.
4003 ///
4004 /// By default, produces the fallback value for the fold-expression, or
4005 /// produce an error if there is no fallback value.
4007 BinaryOperatorKind Operator) {
4008 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4009 }
4010
4011 /// Build a new atomic operation expression.
4012 ///
4013 /// By default, performs semantic analysis to build the new expression.
4014 /// Subclasses may override this routine to provide different behavior.
4017 SourceLocation RParenLoc) {
4018 // Use this for all of the locations, since we don't know the difference
4019 // between the call and the expr at this point.
4020 SourceRange Range{BuiltinLoc, RParenLoc};
4021 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4023 }
4024
4026 ArrayRef<Expr *> SubExprs, QualType Type) {
4027 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4028 }
4029
4031 SourceLocation BeginLoc,
4032 SourceLocation EndLoc,
4034 StmtResult StrBlock) {
4035 return getSema().OpenACC().ActOnEndStmtDirective(K, BeginLoc, EndLoc,
4036 Clauses, StrBlock);
4037 }
4038
4039private:
4040 TypeLoc TransformTypeInObjectScope(TypeLoc TL,
4041 QualType ObjectType,
4042 NamedDecl *FirstQualifierInScope,
4043 CXXScopeSpec &SS);
4044
4045 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4046 QualType ObjectType,
4047 NamedDecl *FirstQualifierInScope,
4048 CXXScopeSpec &SS);
4049
4050 TypeSourceInfo *TransformTSIInObjectScope(TypeLoc TL, QualType ObjectType,
4051 NamedDecl *FirstQualifierInScope,
4052 CXXScopeSpec &SS);
4053
4054 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4056 bool DeducibleTSTContext);
4057
4059 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4061
4063 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4064 OpenACCDirectiveKind DirKind,
4065 const OpenACCClause *OldClause);
4066};
4067
4068template <typename Derived>
4070 if (!S)
4071 return S;
4072
4073 switch (S->getStmtClass()) {
4074 case Stmt::NoStmtClass: break;
4075
4076 // Transform individual statement nodes
4077 // Pass SDK into statements that can produce a value
4078#define STMT(Node, Parent) \
4079 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4080#define VALUESTMT(Node, Parent) \
4081 case Stmt::Node##Class: \
4082 return getDerived().Transform##Node(cast<Node>(S), SDK);
4083#define ABSTRACT_STMT(Node)
4084#define EXPR(Node, Parent)
4085#include "clang/AST/StmtNodes.inc"
4086
4087 // Transform expressions by calling TransformExpr.
4088#define STMT(Node, Parent)
4089#define ABSTRACT_STMT(Stmt)
4090#define EXPR(Node, Parent) case Stmt::Node##Class:
4091#include "clang/AST/StmtNodes.inc"
4092 {
4093 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4094
4095 if (SDK == SDK_StmtExprResult)
4096 E = getSema().ActOnStmtExprResult(E);
4097 return getSema().ActOnExprStmt(E, SDK == SDK_Discarded);
4098 }
4099 }
4100
4101 return S;
4102}
4103
4104template<typename Derived>
4106 if (!S)
4107 return S;
4108
4109 switch (S->getClauseKind()) {
4110 default: break;
4111 // Transform individual clause nodes
4112#define GEN_CLANG_CLAUSE_CLASS
4113#define CLAUSE_CLASS(Enum, Str, Class) \
4114 case Enum: \
4115 return getDerived().Transform##Class(cast<Class>(S));
4116#include "llvm/Frontend/OpenMP/OMP.inc"
4117 }
4118
4119 return S;
4120}
4121
4122
4123template<typename Derived>
4125 if (!E)
4126 return E;
4127
4128 switch (E->getStmtClass()) {
4129 case Stmt::NoStmtClass: break;
4130#define STMT(Node, Parent) case Stmt::Node##Class: break;
4131#define ABSTRACT_STMT(Stmt)
4132#define EXPR(Node, Parent) \
4133 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4134#include "clang/AST/StmtNodes.inc"
4135 }
4136
4137 return E;
4138}
4139
4140template<typename Derived>
4142 bool NotCopyInit) {
4143 // Initializers are instantiated like expressions, except that various outer
4144 // layers are stripped.
4145 if (!Init)
4146 return Init;
4147
4148 if (auto *FE = dyn_cast<FullExpr>(Init))
4149 Init = FE->getSubExpr();
4150
4151 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4152 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4153 Init = OVE->getSourceExpr();
4154 }
4155
4156 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4157 Init = MTE->getSubExpr();
4158
4159 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4160 Init = Binder->getSubExpr();
4161
4162 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4163 Init = ICE->getSubExprAsWritten();
4164
4165 if (CXXStdInitializerListExpr *ILE =
4166 dyn_cast<CXXStdInitializerListExpr>(Init))
4167 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4168
4169 // If this is copy-initialization, we only need to reconstruct
4170 // InitListExprs. Other forms of copy-initialization will be a no-op if
4171 // the initializer is already the right type.
4172 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4173 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4174 return getDerived().TransformExpr(Init);
4175
4176 // Revert value-initialization back to empty parens.
4177 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4178 SourceRange Parens = VIE->getSourceRange();
4179 return getDerived().RebuildParenListExpr(Parens.getBegin(), std::nullopt,
4180 Parens.getEnd());
4181 }
4182
4183 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4184 if (isa<ImplicitValueInitExpr>(Init))
4185 return getDerived().RebuildParenListExpr(SourceLocation(), std::nullopt,
4186 SourceLocation());
4187
4188 // Revert initialization by constructor back to a parenthesized or braced list
4189 // of expressions. Any other form of initializer can just be reused directly.
4190 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4191 return getDerived().TransformExpr(Init);
4192
4193 // If the initialization implicitly converted an initializer list to a
4194 // std::initializer_list object, unwrap the std::initializer_list too.
4195 if (Construct && Construct->isStdInitListInitialization())
4196 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4197
4198 // Enter a list-init context if this was list initialization.
4201 Construct->isListInitialization());
4202
4203 getSema().keepInLifetimeExtendingContext();
4204 SmallVector<Expr*, 8> NewArgs;
4205 bool ArgChanged = false;
4206 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4207 /*IsCall*/true, NewArgs, &ArgChanged))
4208 return ExprError();
4209
4210 // If this was list initialization, revert to syntactic list form.
4211 if (Construct->isListInitialization())
4212 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4213 Construct->getEndLoc());
4214
4215 // Build a ParenListExpr to represent anything else.
4217 if (Parens.isInvalid()) {
4218 // This was a variable declaration's initialization for which no initializer
4219 // was specified.
4220 assert(NewArgs.empty() &&
4221 "no parens or braces but have direct init with arguments?");
4222 return ExprEmpty();
4223 }
4224 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4225 Parens.getEnd());
4226}
4227
4228template<typename Derived>
4230 unsigned NumInputs,
4231 bool IsCall,
4232 SmallVectorImpl<Expr *> &Outputs,
4233 bool *ArgChanged) {
4234 for (unsigned I = 0; I != NumInputs; ++I) {
4235 // If requested, drop call arguments that need to be dropped.
4236 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4237 if (ArgChanged)
4238 *ArgChanged = true;
4239
4240 break;
4241 }
4242
4243 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4244 Expr *Pattern = Expansion->getPattern();
4245
4247 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4248 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4249
4250 // Determine whether the set of unexpanded parameter packs can and should
4251 // be expanded.
4252 bool Expand = true;
4253 bool RetainExpansion = false;
4254 std::optional<unsigned> OrigNumExpansions = Expansion->getNumExpansions();
4255 std::optional<unsigned> NumExpansions = OrigNumExpansions;
4256 if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(),
4257 Pattern->getSourceRange(),
4258 Unexpanded,
4259 Expand, RetainExpansion,
4260 NumExpansions))
4261 return true;
4262
4263 if (!Expand) {
4264 // The transform has determined that we should perform a simple
4265 // transformation on the pack expansion, producing another pack
4266 // expansion.
4267 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
4268 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4269 if (OutPattern.isInvalid())
4270 return true;
4271
4272 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4273 Expansion->getEllipsisLoc(),
4274 NumExpansions);
4275 if (Out.isInvalid())
4276 return true;
4277
4278 if (ArgChanged)
4279 *ArgChanged = true;
4280 Outputs.push_back(Out.get());
4281 continue;
4282 }
4283
4284 // Record right away that the argument was changed. This needs
4285 // to happen even if the array expands to nothing.
4286 if (ArgChanged) *ArgChanged = true;
4287
4288 // The transform has determined that we should perform an elementwise
4289 // expansion of the pattern. Do so.
4290 for (unsigned I = 0; I != *NumExpansions; ++I) {
4291 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
4292 ExprResult Out = getDerived().TransformExpr(Pattern);
4293 if (Out.isInvalid())
4294 return true;
4295
4296 if (Out.get()->containsUnexpandedParameterPack()) {
4297 Out = getDerived().RebuildPackExpansion(
4298 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4299 if (Out.isInvalid())
4300 return true;
4301 }
4302
4303 Outputs.push_back(Out.get());
4304 }
4305
4306 // If we're supposed to retain a pack expansion, do so by temporarily
4307 // forgetting the partially-substituted parameter pack.
4308 if (RetainExpansion) {
4309 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4310
4311 ExprResult Out = getDerived().TransformExpr(Pattern);
4312 if (Out.isInvalid())
4313 return true;
4314
4315 Out = getDerived().RebuildPackExpansion(
4316 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4317 if (Out.isInvalid())
4318 return true;
4319
4320 Outputs.push_back(Out.get());
4321 }
4322
4323 continue;
4324 }
4325
4327 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4328 : getDerived().TransformExpr(Inputs[I]);
4329 if (Result.isInvalid())
4330 return true;
4331
4332 if (Result.get() != Inputs[I] && ArgChanged)
4333 *ArgChanged = true;
4334
4335 Outputs.push_back(Result.get());
4336 }
4337
4338 return false;
4339}
4340
4341template <typename Derived>
4344 if (Var) {
4345 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4346 getDerived().TransformDefinition(Var->getLocation(), Var));
4347
4348 if (!ConditionVar)
4349 return Sema::ConditionError();
4350
4351 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4352 }
4353
4354 if (Expr) {
4355 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4356
4357 if (CondExpr.isInvalid())
4358 return Sema::ConditionError();
4359
4360 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4361 /*MissingOK=*/true);
4362 }
4363
4364 return Sema::ConditionResult();
4365}
4366
4367template <typename Derived>
4369 NestedNameSpecifierLoc NNS, QualType ObjectType,
4370 NamedDecl *FirstQualifierInScope) {
4372
4373 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4374 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4375 Qualifier = Qualifier.getPrefix())
4376 Qualifiers.push_back(Qualifier);
4377 };
4378 insertNNS(NNS);
4379
4380 CXXScopeSpec SS;
4381 while (!Qualifiers.empty()) {
4382 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4384
4385 switch (QNNS->getKind()) {
4389 ObjectType);
4390 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo, false,
4391 SS, FirstQualifierInScope, false))
4392 return NestedNameSpecifierLoc();
4393 break;
4394 }
4395
4397 NamespaceDecl *NS =
4398 cast_or_null<NamespaceDecl>(getDerived().TransformDecl(
4399 Q.getLocalBeginLoc(), QNNS->getAsNamespace()));
4400 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4401 break;
4402 }
4403
4405 NamespaceAliasDecl *Alias =
4406 cast_or_null<NamespaceAliasDecl>(getDerived().TransformDecl(
4408 SS.Extend(SemaRef.Context, Alias, Q.getLocalBeginLoc(),
4409 Q.getLocalEndLoc());
4410 break;
4411 }
4412
4414 // There is no meaningful transformation that one could perform on the
4415 // global scope.
4416 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4417 break;
4418
4420 CXXRecordDecl *RD =
4421 cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
4422 SourceLocation(), QNNS->getAsRecordDecl()));
4423 SS.MakeSuper(SemaRef.Context, RD, Q.getBeginLoc(), Q.getEndLoc());
4424 break;
4425 }
4426
4429 TypeLoc TL = TransformTypeInObjectScope(Q.getTypeLoc(), ObjectType,
4430 FirstQualifierInScope, SS);
4431
4432 if (!TL)
4433 return NestedNameSpecifierLoc();
4434
4435 QualType T = TL.getType();
4436 if (T->isDependentType() || T->isRecordType() ||
4437 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4438 if (T->isEnumeralType())
4439 SemaRef.Diag(TL.getBeginLoc(),
4440 diag::warn_cxx98_compat_enum_nested_name_spec);
4441
4442 if (const auto ETL = TL.getAs<ElaboratedTypeLoc>()) {
4443 SS.Adopt(ETL.getQualifierLoc());
4444 TL = ETL.getNamedTypeLoc();
4445 }
4446
4447 SS.Extend(SemaRef.Context, TL.getTemplateKeywordLoc(), TL,
4448 Q.getLocalEndLoc());
4449 break;
4450 }
4451 // If the nested-name-specifier is an invalid type def, don't emit an
4452 // error because a previous error should have already been emitted.
4454 if (!TTL || !TTL.getTypedefNameDecl()->isInvalidDecl()) {
4455 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4456 << T << SS.getRange();
4457 }
4458 return NestedNameSpecifierLoc();
4459 }
4460 }
4461
4462 // The qualifier-in-scope and object type only apply to the leftmost entity.
4463 FirstQualifierInScope = nullptr;
4464 ObjectType = QualType();
4465 }
4466
4467 // Don't rebuild the nested-name-specifier if we don't have to.
4468 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4469 !getDerived().AlwaysRebuild())
4470 return NNS;
4471
4472 // If we can re-use the source-location data from the original
4473 // nested-name-specifier, do so.
4474 if (SS.location_size() == NNS.getDataLength() &&
4475 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4477
4478 // Allocate new nested-name-specifier location information.
4479 return SS.getWithLocInContext(SemaRef.Context);
4480}
4481
4482template<typename Derived>
4486 DeclarationName Name = NameInfo.getName();
4487 if (!Name)
4488 return DeclarationNameInfo();
4489
4490 switch (Name.getNameKind()) {
4498 return NameInfo;
4499
4501 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4502 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4503 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4504 if (!NewTemplate)
4505 return DeclarationNameInfo();
4506
4507 DeclarationNameInfo NewNameInfo(NameInfo);
4508 NewNameInfo.setName(
4510 return NewNameInfo;
4511 }
4512
4516 TypeSourceInfo *NewTInfo;
4517 CanQualType NewCanTy;
4518 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4519 NewTInfo = getDerived().TransformType(OldTInfo);
4520 if (!NewTInfo)
4521 return DeclarationNameInfo();
4522 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4523 }
4524 else {
4525 NewTInfo = nullptr;
4526 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4527 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4528 if (NewT.isNull())
4529 return DeclarationNameInfo();
4530 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4531 }
4532
4533 DeclarationName NewName
4534 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4535 NewCanTy);
4536 DeclarationNameInfo NewNameInfo(NameInfo);
4537 NewNameInfo.setName(NewName);
4538 NewNameInfo.setNamedTypeInfo(NewTInfo);
4539 return NewNameInfo;
4540 }
4541 }
4542
4543 llvm_unreachable("Unknown name kind.");
4544}
4545
4546template<typename Derived>
4549 TemplateName Name,
4550 SourceLocation NameLoc,
4551 QualType ObjectType,
4552 NamedDecl *FirstQualifierInScope,
4553 bool AllowInjectedClassName) {
4554 if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) {
4555 TemplateDecl *Template = QTN->getUnderlyingTemplate().getAsTemplateDecl();
4556 assert(Template && "qualified template name must refer to a template");
4557
4558 TemplateDecl *TransTemplate
4559 = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
4560 Template));
4561 if (!TransTemplate)
4562 return TemplateName();
4563
4564 if (!getDerived().AlwaysRebuild() &&
4565 SS.getScopeRep() == QTN->getQualifier() &&
4566 TransTemplate == Template)
4567 return Name;
4568
4569 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4570 TransTemplate);
4571 }
4572
4573 if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) {
4574 if (SS.getScopeRep()) {
4575 // These apply to the scope specifier, not the template.
4576 ObjectType = QualType();
4577 FirstQualifierInScope = nullptr;
4578 }
4579
4580 if (!getDerived().AlwaysRebuild() &&
4581 SS.getScopeRep() == DTN->getQualifier() &&
4582 ObjectType.isNull())
4583 return Name;
4584
4585 // FIXME: Preserve the location of the "template" keyword.
4586 SourceLocation TemplateKWLoc = NameLoc;
4587
4588 if (DTN->isIdentifier()) {
4589 return getDerived().RebuildTemplateName(SS,
4590 TemplateKWLoc,
4591 *DTN->getIdentifier(),
4592 NameLoc,
4593 ObjectType,
4594 FirstQualifierInScope,
4595 AllowInjectedClassName);
4596 }
4597
4598 return getDerived().RebuildTemplateName(SS, TemplateKWLoc,
4599 DTN->getOperator(), NameLoc,
4600 ObjectType, AllowInjectedClassName);
4601 }
4602
4603 if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
4604 TemplateDecl *TransTemplate
4605 = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
4606 Template));
4607 if (!TransTemplate)
4608 return TemplateName();
4609
4610 if (!getDerived().AlwaysRebuild() &&
4611 TransTemplate == Template)
4612 return Name;
4613
4614 return TemplateName(TransTemplate);
4615 }
4616
4618 = Name.getAsSubstTemplateTemplateParmPack()) {
4619 return getDerived().RebuildTemplateName(
4620 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4621 SubstPack->getIndex(), SubstPack->getFinal());
4622 }
4623
4624 // These should be getting filtered out before they reach the AST.
4625 llvm_unreachable("overloaded function decl survived to here");
4626}
4627
4628template<typename Derived>
4630 const TemplateArgument &Arg,
4631 TemplateArgumentLoc &Output) {
4632 Output = getSema().getTrivialTemplateArgumentLoc(
4633 Arg, QualType(), getDerived().getBaseLocation());
4634}
4635
4636template <typename Derived>
4638 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
4639 bool Uneval) {
4640 const TemplateArgument &Arg = Input.getArgument();
4641 switch (Arg.getKind()) {
4644 llvm_unreachable("Unexpected TemplateArgument");
4645
4650 // Transform a resolved template argument straight to a resolved template
4651 // argument. We get here when substituting into an already-substituted
4652 // template type argument during concept satisfaction checking.
4654 QualType NewT = getDerived().TransformType(T);
4655 if (NewT.isNull())
4656 return true;
4657
4659 ? Arg.getAsDecl()
4660 : nullptr;
4661 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
4662 getDerived().getBaseLocation(), D))
4663 : nullptr;
4664 if (D && !NewD)
4665 return true;
4666
4667 if (NewT == T && D == NewD)
4668 Output = Input;
4669 else if (Arg.getKind() == TemplateArgument::Integral)
4670 Output = TemplateArgumentLoc(
4671 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
4673 else if (Arg.getKind() == TemplateArgument::NullPtr)
4674 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
4676 else if (Arg.getKind() == TemplateArgument::Declaration)
4677 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
4680 Output = TemplateArgumentLoc(
4681 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
4683 else
4684 llvm_unreachable("unexpected template argument kind");
4685
4686 return false;
4687 }
4688
4690 TypeSourceInfo *DI = Input.getTypeSourceInfo();
4691 if (!DI)
4692 DI = InventTypeSourceInfo(Input.getArgument().getAsType());
4693
4694 DI = getDerived().TransformType(DI);
4695 if (!DI)
4696 return true;
4697
4698 Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
4699 return false;
4700 }
4701
4703 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
4704 if (QualifierLoc) {
4705 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
4706 if (!QualifierLoc)
4707 return true;
4708 }
4709
4710 CXXScopeSpec SS;
4711 SS.Adopt(QualifierLoc);
4712 TemplateName Template = getDerived().TransformTemplateName(
4713 SS, Arg.getAsTemplate(), Input.getTemplateNameLoc());
4714 if (Template.isNull())
4715 return true;
4716
4717 Output = TemplateArgumentLoc(SemaRef.Context, TemplateArgument(Template),
4718 QualifierLoc, Input.getTemplateNameLoc());
4719 return false;
4720 }
4721
4723 llvm_unreachable("Caller should expand pack expansions");
4724
4726 // Template argument expressions are constant expressions.
4728 getSema(),
4731 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
4733
4734 Expr *InputExpr = Input.getSourceExpression();
4735 if (!InputExpr)
4736 InputExpr = Input.getArgument().getAsExpr();
4737
4738 ExprResult E = getDerived().TransformExpr(InputExpr);
4739 E = SemaRef.ActOnConstantExpression(E);
4740 if (E.isInvalid())
4741 return true;
4742 Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get());
4743 return false;
4744 }
4745 }
4746
4747 // Work around bogus GCC warning
4748 return true;
4749}
4750
4751/// Iterator adaptor that invents template argument location information
4752/// for each of the template arguments in its underlying iterator.
4753template<typename Derived, typename InputIterator>
4756 InputIterator Iter;
4757
4758public:
4761 typedef typename std::iterator_traits<InputIterator>::difference_type
4763 typedef std::input_iterator_tag iterator_category;
4764
4765 class pointer {
4767
4768 public:
4769 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
4770
4771 const TemplateArgumentLoc *operator->() const { return &Arg; }
4772 };
4773
4775 InputIterator Iter)
4776 : Self(Self), Iter(Iter) { }
4777
4779 ++Iter;
4780 return *this;
4781 }
4782
4785 ++(*this);
4786 return Old;
4787 }
4788
4791 Self.InventTemplateArgumentLoc(*Iter, Result);
4792 return Result;
4793 }
4794
4795 pointer operator->() const { return pointer(**this); }
4796
4799 return X.Iter == Y.Iter;
4800 }
4801
4804 return X.Iter != Y.Iter;
4805 }
4806};
4807
4808template<typename Derived>
4809template<typename InputIterator>
4811 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
4812 bool Uneval) {
4813 for (; First != Last; ++First) {
4816
4817 if (In.getArgument().getKind() == TemplateArgument::Pack) {
4818 // When building the deduction guides, we rewrite the argument packs
4819 // instead of unpacking.
4820 if (getSema().CodeSynthesisContexts.back().Kind ==
4822 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
4823 return true;
4824 continue;
4825 }
4826 // Unpack argument packs, which we translate them into separate
4827 // arguments.
4828 // FIXME: We could do much better if we could guarantee that the
4829 // TemplateArgumentLocInfo for the pack expansion would be usable for
4830 // all of the template arguments in the argument pack.
4831 typedef TemplateArgumentLocInventIterator<Derived,
4833 PackLocIterator;
4834 if (TransformTemplateArguments(PackLocIterator(*this,
4835 In.getArgument().pack_begin()),
4836 PackLocIterator(*this,
4837 In.getArgument().pack_end()),
4838 Outputs, Uneval))
4839 return true;
4840
4841 continue;
4842 }
4843
4844 if (In.getArgument().isPackExpansion()) {
4845 // We have a pack expansion, for which we will be substituting into
4846 // the pattern.
4847 SourceLocation Ellipsis;
4848 std::optional<unsigned> OrigNumExpansions;
4849 TemplateArgumentLoc Pattern
4850 = getSema().getTemplateArgumentPackExpansionPattern(
4851 In, Ellipsis, OrigNumExpansions);
4852
4854 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4855 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4856
4857 // Determine whether the set of unexpanded parameter packs can and should
4858 // be expanded.
4859 bool Expand = true;
4860 bool RetainExpansion = false;
4861 std::optional<unsigned> NumExpansions = OrigNumExpansions;
4862 if (getDerived().TryExpandParameterPacks(Ellipsis,
4863 Pattern.getSourceRange(),
4864 Unexpanded,
4865 Expand,
4866 RetainExpansion,
4867 NumExpansions))
4868 return true;
4869
4870 if (!Expand) {
4871 // The transform has determined that we should perform a simple
4872 // transformation on the pack expansion, producing another pack
4873 // expansion.
4874 TemplateArgumentLoc OutPattern;
4875 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
4876 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
4877 return true;
4878
4879 Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis,
4880 NumExpansions);
4881 if (Out.getArgument().isNull())
4882 return true;
4883
4884 Outputs.addArgument(Out);
4885 continue;
4886 }
4887
4888 // The transform has determined that we should perform an elementwise
4889 // expansion of the pattern. Do so.
4890 for (unsigned I = 0; I != *NumExpansions; ++I) {
4891 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
4892
4893 if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4894 return true;
4895
4896 if (Out.getArgument().containsUnexpandedParameterPack()) {
4897 Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4898 OrigNumExpansions);
4899 if (Out.getArgument().isNull())
4900 return true;
4901 }
4902
4903 Outputs.addArgument(Out);
4904 }
4905
4906 // If we're supposed to retain a pack expansion, do so by temporarily
4907 // forgetting the partially-substituted parameter pack.
4908 if (RetainExpansion) {
4909 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4910
4911 if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4912 return true;
4913
4914 Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4915 OrigNumExpansions);
4916 if (Out.getArgument().isNull())
4917 return true;
4918
4919 Outputs.addArgument(Out);
4920 }
4921
4922 continue;
4923 }
4924
4925 // The simple case:
4926 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
4927 return true;
4928
4929 Outputs.addArgument(Out);
4930 }
4931
4932 return false;
4933
4934}
4935
4936//===----------------------------------------------------------------------===//
4937// Type transformation
4938//===----------------------------------------------------------------------===//
4939
4940template<typename Derived>
4942 if (getDerived().AlreadyTransformed(T))
4943 return T;
4944
4945 // Temporary workaround. All of these transformations should
4946 // eventually turn into transformations on TypeLocs.
4947 TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4948 getDerived().getBaseLocation());
4949
4950 TypeSourceInfo *NewDI = getDerived().TransformType(DI);
4951
4952 if (!NewDI)
4953 return QualType();
4954
4955 return NewDI->getType();
4956}
4957
4958template<typename Derived>
4960 // Refine the base location to the type's location.
4961 TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4962 getDerived().getBaseEntity());
4963 if (getDerived().AlreadyTransformed(DI->getType()))
4964 return DI;
4965
4966 TypeLocBuilder TLB;
4967
4968 TypeLoc TL = DI->getTypeLoc();
4969 TLB.reserve(TL.getFullDataSize());
4970
4971 QualType Result = getDerived().TransformType(TLB, TL);
4972 if (Result.isNull())
4973 return nullptr;
4974
4975 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4976}
4977
4978template<typename Derived>
4981 switch (T.getTypeLocClass()) {
4982#define ABSTRACT_TYPELOC(CLASS, PARENT)
4983#define TYPELOC(CLASS, PARENT) \
4984 case TypeLoc::CLASS: \
4985 return getDerived().Transform##CLASS##Type(TLB, \
4986 T.castAs<CLASS##TypeLoc>());
4987#include "clang/AST/TypeLocNodes.def"
4988 }
4989
4990 llvm_unreachable("unhandled type loc!");
4991}
4992
4993template<typename Derived>
4995 if (!isa<DependentNameType>(T))
4996 return TransformType(T);
4997
4998 if (getDerived().AlreadyTransformed(T))
4999 return T;
5000 TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
5001 getDerived().getBaseLocation());
5002 TypeSourceInfo *NewDI = getDerived().TransformTypeWithDeducedTST(DI);
5003 return NewDI ? NewDI->getType() : QualType();
5004}
5005
5006template<typename Derived>
5009 if (!isa<DependentNameType>(DI->getType()))
5010 return TransformType(DI);
5011
5012 // Refine the base location to the type's location.
5013 TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
5014 getDerived().getBaseEntity());
5015 if (getDerived().AlreadyTransformed(DI->getType()))
5016 return DI;
5017
5018 TypeLocBuilder TLB;
5019
5020 TypeLoc TL = DI->getTypeLoc();
5021 TLB.reserve(TL.getFullDataSize());
5022
5023 auto QTL = TL.getAs<QualifiedTypeLoc>();
5024 if (QTL)
5025 TL = QTL.getUnqualifiedLoc();
5026
5027 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5028
5029 QualType Result = getDerived().TransformDependentNameType(
5030 TLB, DNTL, /*DeducedTSTContext*/true);
5031 if (Result.isNull())
5032 return nullptr;
5033
5034 if (QTL) {
5035 Result = getDerived().RebuildQualifiedType(Result, QTL);
5036 if (Result.isNull())
5037 return nullptr;
5039 }
5040
5041 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5042}
5043
5044template<typename Derived>
5049 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5050 auto SuppressObjCLifetime =
5051 T.getType().getLocalQualifiers().hasObjCLifetime();
5052 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5053 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5054 SuppressObjCLifetime);
5055 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5056 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5057 TLB, STTP, SuppressObjCLifetime);
5058 } else {
5059 Result = getDerived().TransformType(TLB, UnqualTL);
5060 }
5061
5062 if (Result.isNull())
5063 return QualType();
5064
5065 Result = getDerived().RebuildQualifiedType(Result, T);
5066
5067 if (Result.isNull())
5068 return QualType();
5069
5070 // RebuildQualifiedType might have updated the type, but not in a way
5071 // that invalidates the TypeLoc. (There's no location information for
5072 // qualifiers.)
5074
5075 return Result;
5076}
5077
5078template <typename Derived>
5080 QualifiedTypeLoc TL) {
5081
5082 SourceLocation Loc = TL.getBeginLoc();
5083 Qualifiers Quals = TL.getType().getLocalQualifiers();
5084
5085 if ((T.getAddressSpace() != LangAS::Default &&
5086 Quals.getAddressSpace() != LangAS::Default) &&
5087 T.getAddressSpace() != Quals.getAddressSpace()) {
5088 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5089 << TL.getType() << T;
5090 return QualType();
5091 }
5092
5093 // C++ [dcl.fct]p7:
5094 // [When] adding cv-qualifications on top of the function type [...] the
5095 // cv-qualifiers are ignored.
5096 if (T->isFunctionType()) {
5098 Quals.getAddressSpace());
5099 return T;
5100 }
5101
5102 // C++ [dcl.ref]p1:
5103 // when the cv-qualifiers are introduced through the use of a typedef-name
5104 // or decltype-specifier [...] the cv-qualifiers are ignored.
5105 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5106 // applied to a reference type.
5107 if (T->isReferenceType()) {
5108 // The only qualifier that applies to a reference type is restrict.
5109 if (!Quals.hasRestrict())
5110 return T;
5112 }
5113
5114 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5115 // resulting type.
5116 if (Quals.hasObjCLifetime()) {
5117 if (!T->isObjCLifetimeType() && !T->isDependentType())
5118 Quals.removeObjCLifetime();
5119 else if (T.getObjCLifetime()) {
5120 // Objective-C ARC:
5121 // A lifetime qualifier applied to a substituted template parameter
5122 // overrides the lifetime qualifier from the template argument.
5123 const AutoType *AutoTy;
5124 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5125 // 'auto' types behave the same way as template parameters.
5126 QualType Deduced = AutoTy->getDeducedType();
5127 Qualifiers Qs = Deduced.getQualifiers();
5128 Qs.removeObjCLifetime();
5129 Deduced =
5130 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5131 T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
5132 AutoTy->isDependentType(),
5133 /*isPack=*/false,
5134 AutoTy->getTypeConstraintConcept(),
5135 AutoTy->getTypeConstraintArguments());
5136 } else {
5137 // Otherwise, complain about the addition of a qualifier to an
5138 // already-qualified type.
5139 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5140 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5141 Quals.removeObjCLifetime();
5142 }
5143 }
5144 }
5145
5146 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5147}
5148
5149template<typename Derived>
5150TypeLoc
5152 QualType ObjectType,
5153 NamedDecl *UnqualLookup,
5154 CXXScopeSpec &SS) {
5155 if (getDerived().AlreadyTransformed(TL.getType()))
5156 return TL;
5157
5158 TypeSourceInfo *TSI =
5159 TransformTSIInObjectScope(TL, ObjectType, UnqualLookup, SS);
5160 if (TSI)
5161 return TSI->getTypeLoc();
5162 return TypeLoc();
5163}
5164
5165template<typename Derived>
5166TypeSourceInfo *
5167TreeTransform<Derived>::TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
5168 QualType ObjectType,
5169 NamedDecl *UnqualLookup,
5170 CXXScopeSpec &SS) {
5171 if (getDerived().AlreadyTransformed(TSInfo->getType()))
5172 return TSInfo;
5173
5174 return TransformTSIInObjectScope(TSInfo->getTypeLoc(), ObjectType,
5175 UnqualLookup, SS);
5176}
5177
5178template <typename Derived>
5179TypeSourceInfo *TreeTransform<Derived>::TransformTSIInObjectScope(
5180 TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup,
5181 CXXScopeSpec &SS) {
5182 QualType T = TL.getType();
5183 assert(!getDerived().AlreadyTransformed(T));
5184
5185 TypeLocBuilder TLB;
5186 QualType Result;
5187
5188 if (isa<TemplateSpecializationType>(T)) {
5189 TemplateSpecializationTypeLoc SpecTL =
5190 TL.castAs<TemplateSpecializationTypeLoc>();
5191
5192 TemplateName Template = getDerived().TransformTemplateName(
5193 SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(),
5194 ObjectType, UnqualLookup, /*AllowInjectedClassName*/true);
5195 if (Template.isNull())
5196 return nullptr;
5197
5198 Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
5199 Template);
5200 } else if (isa<DependentTemplateSpecializationType>(T)) {
5201 DependentTemplateSpecializationTypeLoc SpecTL =
5202 TL.castAs<DependentTemplateSpecializationTypeLoc>();
5203
5204 TemplateName Template
5205 = getDerived().RebuildTemplateName(SS,
5206 SpecTL.getTemplateKeywordLoc(),
5207 *SpecTL.getTypePtr()->getIdentifier(),
5208 SpecTL.getTemplateNameLoc(),
5209 ObjectType, UnqualLookup,
5210 /*AllowInjectedClassName*/true);
5211 if (Template.isNull())
5212 return nullptr;
5213
5214 Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
5215 SpecTL,
5216 Template,
5217 SS);
5218 } else {
5219 // Nothing special needs to be done for these.
5220 Result = getDerived().TransformType(TLB, TL);
5221 }
5222
5223 if (Result.isNull())
5224 return nullptr;
5225
5226 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5227}
5228
5229template <class TyLoc> static inline
5231 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5232 NewT.setNameLoc(T.getNameLoc());
5233 return T.getType();
5234}
5235
5236template<typename Derived>
5237QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5238 BuiltinTypeLoc T) {
5239 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5240 NewT.setBuiltinLoc(T.getBuiltinLoc());
5241 if (T.needsExtraLocalData())
5242 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5243 return T.getType();
5244}
5245
5246template<typename Derived>
5247QualType TreeTransform<Derived>::TransformComplexType(TypeLocBuilder &TLB,
5248 ComplexTypeLoc T) {
5249 // FIXME: recurse?
5250 return TransformTypeSpecType(TLB, T);
5251}
5252
5253template <typename Derived>
5254QualType TreeTransform<Derived>::TransformAdjustedType(TypeLocBuilder &TLB,
5255 AdjustedTypeLoc TL) {
5256 // Adjustments applied during transformation are handled elsewhere.
5257 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5258}
5259
5260template<typename Derived>
5261QualType TreeTransform<Derived>::TransformDecayedType(TypeLocBuilder &TLB,
5262 DecayedTypeLoc TL) {
5263 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5264 if (OriginalType.isNull())
5265 return QualType();
5266
5267 QualType Result = TL.getType();
5268 if (getDerived().AlwaysRebuild() ||
5269 OriginalType != TL.getOriginalLoc().getType())
5270 Result = SemaRef.Context.getDecayedType(OriginalType);
5271 TLB.push<DecayedTypeLoc>(Result);
5272 // Nothing to set for DecayedTypeLoc.
5273 return Result;
5274}
5275
5276template <typename Derived>
5277QualType
5278TreeTransform<Derived>::TransformArrayParameterType(TypeLocBuilder &TLB,
5279 ArrayParameterTypeLoc TL) {
5280 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5281 if (OriginalType.isNull())
5282 return QualType();
5283
5284 QualType Result = TL.getType();
5285 if (getDerived().AlwaysRebuild() ||
5286 OriginalType != TL.getElementLoc().getType())
5287 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5288 TLB.push<ArrayParameterTypeLoc>(Result);
5289 // Nothing to set for ArrayParameterTypeLoc.
5290 return Result;
5291}
5292
5293template<typename Derived>
5294QualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB,
5295 PointerTypeLoc TL) {
5296 QualType PointeeType
5297 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5298 if (PointeeType.isNull())
5299 return QualType();
5300
5301 QualType Result = TL.getType();
5302 if (PointeeType->getAs<ObjCObjectType>()) {
5303 // A dependent pointer type 'T *' has is being transformed such
5304 // that an Objective-C class type is being replaced for 'T'. The
5305 // resulting pointer type is an ObjCObjectPointerType, not a
5306 // PointerType.
5307 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5308
5309 ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);
5310 NewT.setStarLoc(TL.getStarLoc());
5311 return Result;
5312 }
5313
5314 if (getDerived().AlwaysRebuild() ||
5315 PointeeType != TL.getPointeeLoc().getType()) {
5316 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5317 if (Result.isNull())
5318 return QualType();
5319 }
5320
5321 // Objective-C ARC can add lifetime qualifiers to the type that we're
5322 // pointing to.
5323 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5324
5325 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5326 NewT.setSigilLoc(TL.getSigilLoc());
5327 return Result;
5328}
5329
5330template<typename Derived>
5331QualType
5332TreeTransform<Derived>::TransformBlockPointerType(TypeLocBuilder &TLB,
5333 BlockPointerTypeLoc TL) {
5334 QualType PointeeType
5335 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5336 if (PointeeType.isNull())
5337 return QualType();
5338
5339 QualType Result = TL.getType();
5340 if (getDerived().AlwaysRebuild() ||
5341 PointeeType != TL.getPointeeLoc().getType()) {
5342 Result = getDerived().RebuildBlockPointerType(PointeeType,
5343 TL.getSigilLoc());
5344 if (Result.isNull())
5345 return QualType();
5346 }
5347
5348 BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result);
5349 NewT.setSigilLoc(TL.getSigilLoc());
5350 return Result;
5351}
5352
5353/// Transforms a reference type. Note that somewhat paradoxically we
5354/// don't care whether the type itself is an l-value type or an r-value
5355/// type; we only care if the type was *written* as an l-value type
5356/// or an r-value type.
5357template<typename Derived>
5358QualType
5360 ReferenceTypeLoc TL) {
5361 const ReferenceType *T = TL.getTypePtr();
5362
5363 // Note that this works with the pointee-as-written.
5364 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5365 if (PointeeType.isNull())
5366 return QualType();
5367
5368 QualType Result = TL.getType();
5369 if (getDerived().AlwaysRebuild() ||
5370 PointeeType != T->getPointeeTypeAsWritten()) {
5371 Result = getDerived().RebuildReferenceType(PointeeType,
5372 T->isSpelledAsLValue(),
5373 TL.getSigilLoc());
5374 if (Result.isNull())
5375 return QualType();
5376 }
5377
5378 // Objective-C ARC can add lifetime qualifiers to the type that we're
5379 // referring to.
5382
5383 // r-value references can be rebuilt as l-value references.
5384 ReferenceTypeLoc NewTL;
5385 if (isa<LValueReferenceType>(Result))
5386 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5387 else
5388 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5389 NewTL.setSigilLoc(TL.getSigilLoc());
5390
5391 return Result;
5392}
5393
5394template<typename Derived>
5398 return TransformReferenceType(TLB, TL);
5399}
5400
5401template<typename Derived>
5402QualType
5403TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5404 RValueReferenceTypeLoc TL) {
5405 return TransformReferenceType(TLB, TL);
5406}
5407
5408template<typename Derived>
5409QualType
5410TreeTransform<Derived>::TransformMemberPointerType(TypeLocBuilder &TLB,
5411 MemberPointerTypeLoc TL) {
5412 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5413 if (PointeeType.isNull())
5414 return QualType();
5415
5416 TypeSourceInfo* OldClsTInfo = TL.getClassTInfo();
5417 TypeSourceInfo *NewClsTInfo = nullptr;
5418 if (OldClsTInfo) {
5419 NewClsTInfo = getDerived().TransformType(OldClsTInfo);
5420 if (!NewClsTInfo)
5421 return QualType();
5422 }
5423
5424 const MemberPointerType *T = TL.getTypePtr();
5425 QualType OldClsType = QualType(T->getClass(), 0);
5426 QualType NewClsType;
5427 if (NewClsTInfo)
5428 NewClsType = NewClsTInfo->getType();
5429 else {
5430 NewClsType = getDerived().TransformType(OldClsType);
5431 if (NewClsType.isNull())
5432 return QualType();
5433 }
5434
5435 QualType Result = TL.getType();
5436 if (getDerived().AlwaysRebuild() ||
5437 PointeeType != T->getPointeeType() ||
5438 NewClsType != OldClsType) {
5439 Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType,
5440 TL.getStarLoc());
5441 if (Result.isNull())
5442 return QualType();
5443 }
5444
5445 // If we had to adjust the pointee type when building a member pointer, make
5446 // sure to push TypeLoc info for it.
5447 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5448 if (MPT && PointeeType != MPT->getPointeeType()) {
5449 assert(isa<AdjustedType>(MPT->getPointeeType()));
5450 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5451 }
5452
5453 MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result);
5454 NewTL.setSigilLoc(TL.getSigilLoc());
5455 NewTL.setClassTInfo(NewClsTInfo);
5456
5457 return Result;
5458}
5459
5460template<typename Derived>
5461QualType
5462TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB,
5463 ConstantArrayTypeLoc TL) {
5464 const ConstantArrayType *T = TL.getTypePtr();
5465 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5466 if (ElementType.isNull())
5467 return QualType();
5468
5469 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5470 Expr *OldSize = TL.getSizeExpr();
5471 if (!OldSize)
5472 OldSize = const_cast<Expr*>(T->getSizeExpr());
5473 Expr *NewSize = nullptr;
5474 if (OldSize) {
5475 EnterExpressionEvaluationContext Unevaluated(
5477 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5478 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5479 }
5480
5481 QualType Result = TL.getType();
5482 if (getDerived().AlwaysRebuild() ||
5483 ElementType != T->getElementType() ||
5484 (T->getSizeExpr() && NewSize != OldSize)) {
5485 Result = getDerived().RebuildConstantArrayType(ElementType,
5486 T->getSizeModifier(),
5487 T->getSize(), NewSize,
5488 T->getIndexTypeCVRQualifiers(),
5489 TL.getBracketsRange());
5490 if (Result.isNull())
5491 return QualType();
5492 }
5493
5494 // We might have either a ConstantArrayType or a VariableArrayType now:
5495 // a ConstantArrayType is allowed to have an element type which is a
5496 // VariableArrayType if the type is dependent. Fortunately, all array
5497 // types have the same location layout.
5498 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5499 NewTL.setLBracketLoc(TL.getLBracketLoc());
5500 NewTL.setRBracketLoc(TL.getRBracketLoc());
5501 NewTL.setSizeExpr(NewSize);
5502
5503 return Result;
5504}
5505
5506template<typename Derived>
5507QualType TreeTransform<Derived>::TransformIncompleteArrayType(
5508 TypeLocBuilder &TLB,
5509 IncompleteArrayTypeLoc TL) {
5510 const IncompleteArrayType *T = TL.getTypePtr();
5511 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5512 if (ElementType.isNull())
5513 return QualType();
5514
5515 QualType Result = TL.getType();
5516 if (getDerived().AlwaysRebuild() ||
5517 ElementType != T->getElementType()) {
5518 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5519 T->getSizeModifier(),
5520 T->getIndexTypeCVRQualifiers(),
5521 TL.getBracketsRange());
5522 if (Result.isNull())
5523 return QualType();
5524 }
5525
5526 IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result);
5527 NewTL.setLBracketLoc(TL.getLBracketLoc());
5528 NewTL.setRBracketLoc(TL.getRBracketLoc());
5529 NewTL.setSizeExpr(nullptr);
5530
5531 return Result;
5532}
5533
5534template<typename Derived>
5535QualType
5536TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB,
5537 VariableArrayTypeLoc TL) {
5538 const VariableArrayType *T = TL.getTypePtr();
5539 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5540 if (ElementType.isNull())
5541 return QualType();
5542
5543 ExprResult SizeResult;
5544 {
5545 EnterExpressionEvaluationContext Context(
5547 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5548 }
5549 if (SizeResult.isInvalid())
5550 return QualType();
5551 SizeResult =
5552 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5553 if (SizeResult.isInvalid())
5554 return QualType();
5555
5556 Expr *Size = SizeResult.get();
5557
5558 QualType Result = TL.getType();
5559 if (getDerived().AlwaysRebuild() ||
5560 ElementType != T->getElementType() ||
5561 Size != T->getSizeExpr()) {
5562 Result = getDerived().RebuildVariableArrayType(ElementType,
5563 T->getSizeModifier(),
5564 Size,
5565 T->getIndexTypeCVRQualifiers(),
5566 TL.getBracketsRange());
5567 if (Result.isNull())
5568 return QualType();
5569 }
5570
5571 // We might have constant size array now, but fortunately it has the same
5572 // location layout.
5573 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5574 NewTL.setLBracketLoc(TL.getLBracketLoc());
5575 NewTL.setRBracketLoc(TL.getRBracketLoc());
5576 NewTL.setSizeExpr(Size);
5577
5578 return Result;
5579}
5580
5581template<typename Derived>
5582QualType
5583TreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB,
5584 DependentSizedArrayTypeLoc TL) {
5585 const DependentSizedArrayType *T = TL.getTypePtr();
5586 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5587 if (ElementType.isNull())
5588 return QualType();
5589
5590 // Array bounds are constant expressions.
5591 EnterExpressionEvaluationContext Unevaluated(
5593
5594 // If we have a VLA then it won't be a constant.
5595 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
5596
5597 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5598 Expr *origSize = TL.getSizeExpr();
5599 if (!origSize) origSize = T->getSizeExpr();
5600
5601 ExprResult sizeResult
5602 = getDerived().TransformExpr(origSize);
5603 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
5604 if (sizeResult.isInvalid())
5605 return QualType();
5606
5607 Expr *size = sizeResult.get();
5608
5609 QualType Result = TL.getType();
5610 if (getDerived().AlwaysRebuild() ||
5611 ElementType != T->getElementType() ||
5612 size != origSize) {
5613 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
5614 T->getSizeModifier(),
5615 size,
5616 T->getIndexTypeCVRQualifiers(),
5617 TL.getBracketsRange());
5618 if (Result.isNull())
5619 return QualType();
5620 }
5621
5622 // We might have any sort of array type now, but fortunately they
5623 // all have the same location layout.
5624 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5625 NewTL.setLBracketLoc(TL.getLBracketLoc());
5626 NewTL.setRBracketLoc(TL.getRBracketLoc());
5627 NewTL.setSizeExpr(size);
5628
5629 return Result;
5630}
5631
5632template <typename Derived>
5633QualType TreeTransform<Derived>::TransformDependentVectorType(
5634 TypeLocBuilder &TLB, DependentVectorTypeLoc TL) {
5635 const DependentVectorType *T = TL.getTypePtr();
5636 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5637 if (ElementType.isNull())
5638 return QualType();
5639
5640 EnterExpressionEvaluationContext Unevaluated(
5642
5643 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
5644 Size = SemaRef.ActOnConstantExpression(Size);
5645 if (Size.isInvalid())
5646 return QualType();
5647
5648 QualType Result = TL.getType();
5649 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
5650 Size.get() != T->getSizeExpr()) {
5651 Result = getDerived().RebuildDependentVectorType(
5652 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
5653 if (Result.isNull())
5654 return QualType();
5655 }
5656
5657 // Result might be dependent or not.
5658 if (isa<DependentVectorType>(Result)) {
5659 DependentVectorTypeLoc NewTL =
5660 TLB.push<DependentVectorTypeLoc>(Result);
5661 NewTL.setNameLoc(TL.getNameLoc());
5662 } else {
5663 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
5664 NewTL.setNameLoc(TL.getNameLoc());
5665 }
5666
5667 return Result;
5668}
5669
5670template<typename Derived>
5671QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
5672 TypeLocBuilder &TLB,
5673 DependentSizedExtVectorTypeLoc TL) {
5674 const DependentSizedExtVectorType *T = TL.getTypePtr();
5675
5676 // FIXME: ext vector locs should be nested
5677 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5678 if (ElementType.isNull())
5679 return QualType();
5680
5681 // Vector sizes are constant expressions.
5682 EnterExpressionEvaluationContext Unevaluated(
5684
5685 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
5686 Size = SemaRef.ActOnConstantExpression(Size);
5687 if (Size.isInvalid())
5688 return QualType();
5689
5690 QualType Result = TL.getType();
5691 if (getDerived().AlwaysRebuild() ||
5692 ElementType != T->getElementType() ||
5693 Size.get() != T->getSizeExpr()) {
5694 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
5695 Size.get(),
5696 T->getAttributeLoc());
5697 if (Result.isNull())
5698 return QualType();
5699 }
5700
5701 // Result might be dependent or not.
5702 if (isa<DependentSizedExtVectorType>(Result)) {
5703 DependentSizedExtVectorTypeLoc NewTL
5704 = TLB.push<DependentSizedExtVectorTypeLoc>(Result);
5705 NewTL.setNameLoc(TL.getNameLoc());
5706 } else {
5707 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
5708 NewTL.setNameLoc(TL.getNameLoc());
5709 }
5710
5711 return Result;
5712}
5713
5714template <typename Derived>
5715QualType
5716TreeTransform<Derived>::TransformConstantMatrixType(TypeLocBuilder &TLB,
5717 ConstantMatrixTypeLoc TL) {
5718 const ConstantMatrixType *T = TL.getTypePtr();
5719 QualType ElementType = getDerived().TransformType(T->getElementType());
5720 if (ElementType.isNull())
5721 return QualType();
5722
5723 QualType Result = TL.getType();
5724 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
5725 Result = getDerived().RebuildConstantMatrixType(
5726 ElementType, T->getNumRows(), T->getNumColumns());
5727 if (Result.isNull())
5728 return QualType();
5729 }
5730
5731 ConstantMatrixTypeLoc NewTL = TLB.push<ConstantMatrixTypeLoc>(Result);
5732 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5733 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
5734 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
5735 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
5736
5737 return Result;
5738}
5739
5740template <typename Derived>
5741QualType TreeTransform<Derived>::TransformDependentSizedMatrixType(
5742 TypeLocBuilder &TLB, DependentSizedMatrixTypeLoc TL) {
5743 const DependentSizedMatrixType *T = TL.getTypePtr();
5744
5745 QualType ElementType = getDerived().TransformType(T->getElementType());
5746 if (ElementType.isNull()) {
5747 return QualType();
5748 }
5749
5750 // Matrix dimensions are constant expressions.
5751 EnterExpressionEvaluationContext Unevaluated(
5753
5754 Expr *origRows = TL.getAttrRowOperand();
5755 if (!origRows)
5756 origRows = T->getRowExpr();
5757 Expr *origColumns = TL.getAttrColumnOperand();
5758 if (!origColumns)
5759 origColumns = T->getColumnExpr();
5760
5761 ExprResult rowResult = getDerived().TransformExpr(origRows);
5762 rowResult = SemaRef.ActOnConstantExpression(rowResult);
5763 if (rowResult.isInvalid())
5764 return QualType();
5765
5766 ExprResult columnResult = getDerived().TransformExpr(origColumns);
5767 columnResult = SemaRef.ActOnConstantExpression(columnResult);
5768 if (columnResult.isInvalid())
5769 return QualType();
5770
5771 Expr *rows = rowResult.get();
5772 Expr *columns = columnResult.get();
5773
5774 QualType Result = TL.getType();
5775 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
5776 rows != origRows || columns != origColumns) {
5777 Result = getDerived().RebuildDependentSizedMatrixType(
5778 ElementType, rows, columns, T->getAttributeLoc());
5779
5780 if (Result.isNull())
5781 return QualType();
5782 }
5783
5784 // We might have any sort of matrix type now, but fortunately they
5785 // all have the same location layout.
5786 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
5787 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5788 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
5789 NewTL.setAttrRowOperand(rows);
5790 NewTL.setAttrColumnOperand(columns);
5791 return Result;
5792}
5793
5794template <typename Derived>
5795QualType TreeTransform<Derived>::TransformDependentAddressSpaceType(
5796 TypeLocBuilder &TLB, DependentAddressSpaceTypeLoc TL) {
5797 const DependentAddressSpaceType *T = TL.getTypePtr();
5798
5799 QualType pointeeType = getDerived().TransformType(T->getPointeeType());
5800
5801 if (pointeeType.isNull())
5802 return QualType();
5803
5804 // Address spaces are constant expressions.
5805 EnterExpressionEvaluationContext Unevaluated(
5807
5808 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
5809 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
5810 if (AddrSpace.isInvalid())
5811 return QualType();
5812
5813 QualType Result = TL.getType();
5814 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
5815 AddrSpace.get() != T->getAddrSpaceExpr()) {
5816 Result = getDerived().RebuildDependentAddressSpaceType(
5817 pointeeType, AddrSpace.get(), T->getAttributeLoc());
5818 if (Result.isNull())
5819 return QualType();
5820 }
5821
5822 // Result might be dependent or not.
5823 if (isa<DependentAddressSpaceType>(Result)) {
5824 DependentAddressSpaceTypeLoc NewTL =
5825 TLB.push<DependentAddressSpaceTypeLoc>(Result);
5826
5827 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
5828 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
5829 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5830
5831 } else {
5832 TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(
5833 Result, getDerived().getBaseLocation());
5834 TransformType(TLB, DI->getTypeLoc());
5835 }
5836
5837 return Result;
5838}
5839
5840template <typename Derived>
5841QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
5842 VectorTypeLoc TL) {
5843 const VectorType *T = TL.getTypePtr();
5844 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5845 if (ElementType.isNull())
5846 return QualType();
5847
5848 QualType Result = TL.getType();
5849 if (getDerived().AlwaysRebuild() ||
5850 ElementType != T->getElementType()) {
5851 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
5852 T->getVectorKind());
5853 if (Result.isNull())
5854 return QualType();
5855 }
5856
5857 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
5858 NewTL.setNameLoc(TL.getNameLoc());
5859
5860 return Result;
5861}
5862
5863template<typename Derived>
5864QualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB,
5865 ExtVectorTypeLoc TL) {
5866 const VectorType *T = TL.getTypePtr();
5867 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5868 if (ElementType.isNull())
5869 return QualType();
5870
5871 QualType Result = TL.getType();
5872 if (getDerived().AlwaysRebuild() ||
5873 ElementType != T->getElementType()) {
5874 Result = getDerived().RebuildExtVectorType(ElementType,
5875 T->getNumElements(),
5876 /*FIXME*/ SourceLocation());
5877 if (Result.isNull())
5878 return QualType();
5879 }
5880
5881 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
5882 NewTL.setNameLoc(TL.getNameLoc());
5883
5884 return Result;
5885}
5886
5887template <typename Derived>
5889 ParmVarDecl *OldParm, int indexAdjustment,
5890 std::optional<unsigned> NumExpansions, bool ExpectParameterPack) {
5891 TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
5892 TypeSourceInfo *NewDI = nullptr;
5893
5894 if (NumExpansions && isa<PackExpansionType>(OldDI->getType())) {
5895 // If we're substituting into a pack expansion type and we know the
5896 // length we want to expand to, just substitute for the pattern.
5897 TypeLoc OldTL = OldDI->getTypeLoc();
5898 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
5899
5900 TypeLocBuilder TLB;
5901 TypeLoc NewTL = OldDI->getTypeLoc();
5902 TLB.reserve(NewTL.getFullDataSize());
5903
5904 QualType Result = getDerived().TransformType(TLB,
5905 OldExpansionTL.getPatternLoc());
5906 if (Result.isNull())
5907 return nullptr;
5908
5909 Result = RebuildPackExpansionType(Result,
5910 OldExpansionTL.getPatternLoc().getSourceRange(),
5911 OldExpansionTL.getEllipsisLoc(),
5912 NumExpansions);
5913 if (Result.isNull())
5914 return nullptr;
5915
5916 PackExpansionTypeLoc NewExpansionTL
5917 = TLB.push<PackExpansionTypeLoc>(Result);
5918 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
5919 NewDI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
5920 } else
5921 NewDI = getDerived().TransformType(OldDI);
5922 if (!NewDI)
5923 return nullptr;
5924
5925 if (NewDI == OldDI && indexAdjustment == 0)
5926 return OldParm;
5927
5928 ParmVarDecl *newParm = ParmVarDecl::Create(SemaRef.Context,
5929 OldParm->getDeclContext(),
5930 OldParm->getInnerLocStart(),
5931 OldParm->getLocation(),
5932 OldParm->getIdentifier(),
5933 NewDI->getType(),
5934 NewDI,
5935 OldParm->getStorageClass(),
5936 /* DefArg */ nullptr);
5937 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
5938 OldParm->getFunctionScopeIndex() + indexAdjustment);
5939 transformedLocalDecl(OldParm, {newParm});
5940 return newParm;
5941}
5942
5943template <typename Derived>
5946 const QualType *ParamTypes,
5947 const FunctionProtoType::ExtParameterInfo *ParamInfos,
5948 SmallVectorImpl<QualType> &OutParamTypes,
5951 unsigned *LastParamTransformed) {
5952 int indexAdjustment = 0;
5953
5954 unsigned NumParams = Params.size();
5955 for (unsigned i = 0; i != NumParams; ++i) {
5956 if (LastParamTransformed)
5957 *LastParamTransformed = i;
5958 if (ParmVarDecl *OldParm = Params[i]) {
5959 assert(OldParm->getFunctionScopeIndex() == i);
5960
5961 std::optional<unsigned> NumExpansions;
5962 ParmVarDecl *NewParm = nullptr;
5963 if (OldParm->isParameterPack()) {
5964 // We have a function parameter pack that may need to be expanded.
5966
5967 // Find the parameter packs that could be expanded.
5968 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
5970 TypeLoc Pattern = ExpansionTL.getPatternLoc();
5971 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
5972
5973 // Determine whether we should expand the parameter packs.
5974 bool ShouldExpand = false;
5975 bool RetainExpansion = false;
5976 std::optional<unsigned> OrigNumExpansions;
5977 if (Unexpanded.size() > 0) {
5978 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
5979 NumExpansions = OrigNumExpansions;
5980 if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
5981 Pattern.getSourceRange(),
5982 Unexpanded,
5983 ShouldExpand,
5984 RetainExpansion,
5985 NumExpansions)) {
5986 return true;
5987 }
5988 } else {
5989#ifndef NDEBUG
5990 const AutoType *AT =
5991 Pattern.getType().getTypePtr()->getContainedAutoType();
5992 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
5993 "Could not find parameter packs or undeduced auto type!");
5994#endif
5995 }
5996
5997 if (ShouldExpand) {
5998 // Expand the function parameter pack into multiple, separate
5999 // parameters.
6000 getDerived().ExpandingFunctionParameterPack(OldParm);
6001 for (unsigned I = 0; I != *NumExpansions; ++I) {
6002 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
6003 ParmVarDecl *NewParm
6004 = getDerived().TransformFunctionTypeParam(OldParm,
6005 indexAdjustment++,
6006 OrigNumExpansions,
6007 /*ExpectParameterPack=*/false);
6008 if (!NewParm)
6009 return true;
6010
6011 if (ParamInfos)
6012 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6013 OutParamTypes.push_back(NewParm->getType());
6014 if (PVars)
6015 PVars->push_back(NewParm);
6016 }
6017
6018 // If we're supposed to retain a pack expansion, do so by temporarily
6019 // forgetting the partially-substituted parameter pack.
6020 if (RetainExpansion) {
6021 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6022 ParmVarDecl *NewParm
6023 = getDerived().TransformFunctionTypeParam(OldParm,
6024 indexAdjustment++,
6025 OrigNumExpansions,
6026 /*ExpectParameterPack=*/false);
6027 if (!NewParm)
6028 return true;
6029
6030 if (ParamInfos)
6031 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6032 OutParamTypes.push_back(NewParm->getType());
6033 if (PVars)
6034 PVars->push_back(NewParm);
6035 }
6036
6037 // The next parameter should have the same adjustment as the
6038 // last thing we pushed, but we post-incremented indexAdjustment
6039 // on every push. Also, if we push nothing, the adjustment should
6040 // go down by one.
6041 indexAdjustment--;
6042
6043 // We're done with the pack expansion.
6044 continue;
6045 }
6046
6047 // We'll substitute the parameter now without expanding the pack
6048 // expansion.
6049 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6050 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6051 indexAdjustment,
6052 NumExpansions,
6053 /*ExpectParameterPack=*/true);
6054 assert(NewParm->isParameterPack() &&
6055 "Parameter pack no longer a parameter pack after "
6056 "transformation.");
6057 } else {
6058 NewParm = getDerived().TransformFunctionTypeParam(
6059 OldParm, indexAdjustment, std::nullopt,
6060 /*ExpectParameterPack=*/false);
6061 }
6062
6063 if (!NewParm)
6064 return true;
6065
6066 if (ParamInfos)
6067 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6068 OutParamTypes.push_back(NewParm->getType());
6069 if (PVars)
6070 PVars->push_back(NewParm);
6071 continue;
6072 }
6073
6074 // Deal with the possibility that we don't have a parameter
6075 // declaration for this parameter.
6076 assert(ParamTypes);
6077 QualType OldType = ParamTypes[i];
6078 bool IsPackExpansion = false;
6079 std::optional<unsigned> NumExpansions;
6080 QualType NewType;
6081 if (const PackExpansionType *Expansion
6082 = dyn_cast<PackExpansionType>(OldType)) {
6083 // We have a function parameter pack that may need to be expanded.
6084 QualType Pattern = Expansion->getPattern();
6086 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6087
6088 // Determine whether we should expand the parameter packs.
6089 bool ShouldExpand = false;
6090 bool RetainExpansion = false;
6091 if (getDerived().TryExpandParameterPacks(Loc, SourceRange(),
6092 Unexpanded,
6093 ShouldExpand,
6094 RetainExpansion,
6095 NumExpansions)) {
6096 return true;
6097 }
6098
6099 if (ShouldExpand) {
6100 // Expand the function parameter pack into multiple, separate
6101 // parameters.
6102 for (unsigned I = 0; I != *NumExpansions; ++I) {
6103 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
6104 QualType NewType = getDerived().TransformType(Pattern);
6105 if (NewType.isNull())
6106 return true;
6107
6108 if (NewType->containsUnexpandedParameterPack()) {
6109 NewType = getSema().getASTContext().getPackExpansionType(
6110 NewType, std::nullopt);
6111
6112 if (NewType.isNull())
6113 return true;
6114 }
6115
6116 if (ParamInfos)
6117 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6118 OutParamTypes.push_back(NewType);
6119 if (PVars)
6120 PVars->push_back(nullptr);
6121 }
6122
6123 // We're done with the pack expansion.
6124 continue;
6125 }
6126
6127 // If we're supposed to retain a pack expansion, do so by temporarily
6128 // forgetting the partially-substituted parameter pack.
6129 if (RetainExpansion) {
6130 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6131 QualType NewType = getDerived().TransformType(Pattern);
6132 if (NewType.isNull())
6133 return true;
6134
6135 if (ParamInfos)
6136 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6137 OutParamTypes.push_back(NewType);
6138 if (PVars)
6139 PVars->push_back(nullptr);
6140 }
6141
6142 // We'll substitute the parameter now without expanding the pack
6143 // expansion.
6144 OldType = Expansion->getPattern();
6145 IsPackExpansion = true;
6146 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6147 NewType = getDerived().TransformType(OldType);
6148 } else {
6149 NewType = getDerived().TransformType(OldType);
6150 }
6151
6152 if (NewType.isNull())
6153 return true;
6154
6155 if (IsPackExpansion)
6156 NewType = getSema().Context.getPackExpansionType(NewType,
6157 NumExpansions);
6158
6159 if (ParamInfos)
6160 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6161 OutParamTypes.push_back(NewType);
6162 if (PVars)
6163 PVars->push_back(nullptr);
6164 }
6165
6166#ifndef NDEBUG
6167 if (PVars) {
6168 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6169 if (ParmVarDecl *parm = (*PVars)[i])
6170 assert(parm->getFunctionScopeIndex() == i);
6171 }
6172#endif
6173
6174 return false;
6175}
6176
6177template<typename Derived>
6181 SmallVector<QualType, 4> ExceptionStorage;
6182 return getDerived().TransformFunctionProtoType(
6183 TLB, TL, nullptr, Qualifiers(),
6184 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6185 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6186 ExceptionStorage, Changed);
6187 });
6188}
6189
6190template<typename Derived> template<typename Fn>
6192 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6193 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6194
6195 // Transform the parameters and return type.
6196 //
6197 // We are required to instantiate the params and return type in source order.
6198 // When the function has a trailing return type, we instantiate the
6199 // parameters before the return type, since the return type can then refer
6200 // to the parameters themselves (via decltype, sizeof, etc.).
6201 //
6202 SmallVector<QualType, 4> ParamTypes;
6204 Sema::ExtParameterInfoBuilder ExtParamInfos;
6205 const FunctionProtoType *T = TL.getTypePtr();
6206
6207 QualType ResultType;
6208
6209 if (T->hasTrailingReturn()) {
6210 if (getDerived().TransformFunctionTypeParams(
6211 TL.getBeginLoc(), TL.getParams(),
6214 ParamTypes, &ParamDecls, ExtParamInfos))
6215 return QualType();
6216
6217 {
6218 // C++11 [expr.prim.general]p3:
6219 // If a declaration declares a member function or member function
6220 // template of a class X, the expression this is a prvalue of type
6221 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6222 // and the end of the function-definition, member-declarator, or
6223 // declarator.
6224 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6225 Sema::CXXThisScopeRAII ThisScope(
6226 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6227
6228 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6229 if (ResultType.isNull())
6230 return QualType();
6231 }
6232 }
6233 else {
6234 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6235 if (ResultType.isNull())
6236 return QualType();
6237
6238 if (getDerived().TransformFunctionTypeParams(
6239 TL.getBeginLoc(), TL.getParams(),
6242 ParamTypes, &ParamDecls, ExtParamInfos))
6243 return QualType();
6244 }
6245
6247
6248 bool EPIChanged = false;
6249 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6250 return QualType();
6251
6252 // Handle extended parameter information.
6253 if (auto NewExtParamInfos =
6254 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6255 if (!EPI.ExtParameterInfos ||
6257 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6258 EPIChanged = true;
6259 }
6260 EPI.ExtParameterInfos = NewExtParamInfos;
6261 } else if (EPI.ExtParameterInfos) {
6262 EPIChanged = true;
6263 EPI.ExtParameterInfos = nullptr;
6264 }
6265
6266 QualType Result = TL.getType();
6267 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6268 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6269 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6270 if (Result.isNull())
6271 return QualType();
6272 }
6273
6276 NewTL.setLParenLoc(TL.getLParenLoc());
6277 NewTL.setRParenLoc(TL.getRParenLoc());
6280 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6281 NewTL.setParam(i, ParamDecls[i]);
6282
6283 return Result;
6284}
6285
6286template<typename Derived>
6289 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6290 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6291
6292 // Instantiate a dynamic noexcept expression, if any.
6293 if (isComputedNoexcept(ESI.Type)) {
6294 // Update this scrope because ContextDecl in Sema will be used in
6295 // TransformExpr.
6296 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6297 Sema::CXXThisScopeRAII ThisScope(
6298 SemaRef, Method ? Method->getParent() : nullptr,
6299 Method ? Method->getMethodQualifiers() : Qualifiers{},
6300 Method != nullptr);
6303 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6304 if (NoexceptExpr.isInvalid())
6305 return true;
6306
6308 NoexceptExpr =
6309 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6310 if (NoexceptExpr.isInvalid())
6311 return true;
6312
6313 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6314 Changed = true;
6315 ESI.NoexceptExpr = NoexceptExpr.get();
6316 ESI.Type = EST;
6317 }
6318
6319 if (ESI.Type != EST_Dynamic)
6320 return false;
6321
6322 // Instantiate a dynamic exception specification's type.
6323 for (QualType T : ESI.Exceptions) {
6324 if (const PackExpansionType *PackExpansion =
6326 Changed = true;
6327
6328 // We have a pack expansion. Instantiate it.
6330 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6331 Unexpanded);
6332 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6333
6334 // Determine whether the set of unexpanded parameter packs can and
6335 // should
6336 // be expanded.
6337 bool Expand = false;
6338 bool RetainExpansion = false;
6339 std::optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
6340 // FIXME: Track the location of the ellipsis (and track source location
6341 // information for the types in the exception specification in general).
6342 if (getDerived().TryExpandParameterPacks(
6343 Loc, SourceRange(), Unexpanded, Expand,
6344 RetainExpansion, NumExpansions))
6345 return true;
6346
6347 if (!Expand) {
6348 // We can't expand this pack expansion into separate arguments yet;
6349 // just substitute into the pattern and create a new pack expansion
6350 // type.
6351 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6352 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6353 if (U.isNull())
6354 return true;
6355
6356 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6357 Exceptions.push_back(U);
6358 continue;
6359 }
6360
6361 // Substitute into the pack expansion pattern for each slice of the
6362 // pack.
6363 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6364 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
6365
6366 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6367 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6368 return true;
6369
6370 Exceptions.push_back(U);
6371 }
6372 } else {
6373 QualType U = getDerived().TransformType(T);
6374 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6375 return true;
6376 if (T != U)
6377 Changed = true;
6378
6379 Exceptions.push_back(U);
6380 }
6381 }
6382
6383 ESI.Exceptions = Exceptions;
6384 if (ESI.Exceptions.empty())
6385 ESI.Type = EST_DynamicNone;
6386 return false;
6387}
6388
6389template<typename Derived>
6391 TypeLocBuilder &TLB,
6393 const FunctionNoProtoType *T = TL.getTypePtr();
6394 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6395 if (ResultType.isNull())
6396 return QualType();
6397
6398 QualType Result = TL.getType();
6399 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6400 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6401
6404 NewTL.setLParenLoc(TL.getLParenLoc());
6405 NewTL.setRParenLoc(TL.getRParenLoc());
6407
6408 return Result;
6409}
6410
6411template <typename Derived>
6412QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6413 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6414 const UnresolvedUsingType *T = TL.getTypePtr();
6415 Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6416 if (!D)
6417 return QualType();
6418
6419 QualType Result = TL.getType();
6420 if (getDerived().AlwaysRebuild() || D != T->getDecl()) {
6421 Result = getDerived().RebuildUnresolvedUsingType(TL.getNameLoc(), D);
6422 if (Result.isNull())
6423 return QualType();
6424 }
6425
6426 // We might get an arbitrary type spec type back. We should at
6427 // least always get a type spec type, though.
6428 TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result);
6429 NewTL.setNameLoc(TL.getNameLoc());
6430
6431 return Result;
6432}
6433
6434template <typename Derived>
6435QualType TreeTransform<Derived>::TransformUsingType(TypeLocBuilder &TLB,
6436 UsingTypeLoc TL) {
6437 const UsingType *T = TL.getTypePtr();
6438
6439 auto *Found = cast_or_null<UsingShadowDecl>(getDerived().TransformDecl(
6440 TL.getLocalSourceRange().getBegin(), T->getFoundDecl()));
6441 if (!Found)
6442 return QualType();
6443
6444 QualType Underlying = getDerived().TransformType(T->desugar());
6445 if (Underlying.isNull())
6446 return QualType();
6447
6448 QualType Result = TL.getType();
6449 if (getDerived().AlwaysRebuild() || Found != T->getFoundDecl() ||
6450 Underlying != T->getUnderlyingType()) {
6451 Result = getDerived().RebuildUsingType(Found, Underlying);
6452 if (Result.isNull())
6453 return QualType();
6454 }
6455
6456 TLB.pushTypeSpec(Result).setNameLoc(TL.getNameLoc());
6457 return Result;
6458}
6459
6460template<typename Derived>
6461QualType TreeTransform<Derived>::TransformTypedefType(TypeLocBuilder &TLB,
6462 TypedefTypeLoc TL) {
6463 const TypedefType *T = TL.getTypePtr();
6464 TypedefNameDecl *Typedef
6465 = cast_or_null<TypedefNameDecl>(getDerived().TransformDecl(TL.getNameLoc(),
6466 T->getDecl()));
6467 if (!Typedef)
6468 return QualType();
6469
6470 QualType Result = TL.getType();
6471 if (getDerived().AlwaysRebuild() ||
6472 Typedef != T->getDecl()) {
6473 Result = getDerived().RebuildTypedefType(Typedef);
6474 if (Result.isNull())
6475 return QualType();
6476 }
6477
6478 TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result);
6479 NewTL.setNameLoc(TL.getNameLoc());
6480
6481 return Result;
6482}
6483
6484template<typename Derived>
6485QualType TreeTransform<Derived>::TransformTypeOfExprType(TypeLocBuilder &TLB,
6486 TypeOfExprTypeLoc TL) {
6487 // typeof expressions are not potentially evaluated contexts
6488 EnterExpressionEvaluationContext Unevaluated(
6491
6492 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
6493 if (E.isInvalid())
6494 return QualType();
6495
6496 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
6497 if (E.isInvalid())
6498 return QualType();
6499
6500 QualType Result = TL.getType();
6501 TypeOfKind Kind = Result->getAs<TypeOfExprType>()->getKind();
6502 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
6503 Result =
6504 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
6505 if (Result.isNull())
6506 return QualType();
6507 }
6508
6509 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
6510 NewTL.setTypeofLoc(TL.getTypeofLoc());
6511 NewTL.setLParenLoc(TL.getLParenLoc());
6512 NewTL.setRParenLoc(TL.getRParenLoc());
6513
6514 return Result;
6515}
6516
6517template<typename Derived>
6518QualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB,
6519 TypeOfTypeLoc TL) {
6520 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
6521 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
6522 if (!New_Under_TI)
6523 return QualType();
6524
6525 QualType Result = TL.getType();
6526 TypeOfKind Kind = Result->getAs<TypeOfType>()->getKind();
6527 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
6528 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
6529 if (Result.isNull())
6530 return QualType();
6531 }
6532
6533 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
6534 NewTL.setTypeofLoc(TL.getTypeofLoc());
6535 NewTL.setLParenLoc(TL.getLParenLoc());
6536 NewTL.setRParenLoc(TL.getRParenLoc());
6537 NewTL.setUnmodifiedTInfo(New_Under_TI);
6538
6539 return Result;
6540}
6541
6542template<typename Derived>
6543QualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB,
6544 DecltypeTypeLoc TL) {
6545 const DecltypeType *T = TL.getTypePtr();
6546
6547 // decltype expressions are not potentially evaluated contexts
6548 EnterExpressionEvaluationContext Unevaluated(
6551
6552 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
6553 if (E.isInvalid())
6554 return QualType();
6555
6556 E = getSema().ActOnDecltypeExpression(E.get());
6557 if (E.isInvalid())
6558 return QualType();
6559
6560 QualType Result = TL.getType();
6561 if (getDerived().AlwaysRebuild() ||
6562 E.get() != T->getUnderlyingExpr()) {
6563 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
6564 if (Result.isNull())
6565 return QualType();
6566 }
6567 else E.get();
6568
6569 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
6570 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
6571 NewTL.setRParenLoc(TL.getRParenLoc());
6572 return Result;
6573}
6574
6575template <typename Derived>
6576QualType
6577TreeTransform<Derived>::TransformPackIndexingType(TypeLocBuilder &TLB,
6578 PackIndexingTypeLoc TL) {
6579 // Transform the index
6580 ExprResult IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
6581 if (IndexExpr.isInvalid())
6582 return QualType();
6583 QualType Pattern = TL.getPattern();
6584
6585 const PackIndexingType *PIT = TL.getTypePtr();
6586 SmallVector<QualType, 5> SubtitutedTypes;
6587 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
6588
6589 bool NotYetExpanded = Types.empty();
6590 bool FullySubstituted = true;
6591
6592 if (Types.empty())
6593 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
6594
6595 for (const QualType &T : Types) {
6597 QualType Transformed = getDerived().TransformType(T);
6598 if (Transformed.isNull())
6599 return QualType();
6600 SubtitutedTypes.push_back(Transformed);
6601 continue;
6602 }
6603
6605 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
6606 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6607 // Determine whether the set of unexpanded parameter packs can and should
6608 // be expanded.
6609 bool ShouldExpand = true;
6610 bool RetainExpansion = false;
6611 std::optional<unsigned> OrigNumExpansions;
6612 std::optional<unsigned> NumExpansions = OrigNumExpansions;
6613 if (getDerived().TryExpandParameterPacks(TL.getEllipsisLoc(), SourceRange(),
6614 Unexpanded, ShouldExpand,
6615 RetainExpansion, NumExpansions))
6616 return QualType();
6617 if (!ShouldExpand) {
6618 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6619 // FIXME: should we keep TypeLoc for individual expansions in
6620 // PackIndexingTypeLoc?
6621 TypeSourceInfo *TI =
6622 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
6623 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
6624 if (Pack.isNull())
6625 return QualType();
6626 if (NotYetExpanded) {
6627 FullySubstituted = false;
6628 QualType Out = getDerived().RebuildPackIndexingType(
6629 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
6630 FullySubstituted);
6631 if (Out.isNull())
6632 return QualType();
6633
6634 PackIndexingTypeLoc Loc = TLB.push<PackIndexingTypeLoc>(Out);
6635 Loc.setEllipsisLoc(TL.getEllipsisLoc());
6636 return Out;
6637 }
6638 SubtitutedTypes.push_back(Pack);
6639 continue;
6640 }
6641 for (unsigned I = 0; I != *NumExpansions; ++I) {
6642 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
6643 QualType Out = getDerived().TransformType(T);
6644 if (Out.isNull())
6645 return QualType();
6646 SubtitutedTypes.push_back(Out);
6647 }
6648 // If we're supposed to retain a pack expansion, do so by temporarily
6649 // forgetting the partially-substituted parameter pack.
6650 if (RetainExpansion) {
6651 FullySubstituted = false;
6652 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6653 QualType Out = getDerived().TransformType(T);
6654 if (Out.isNull())
6655 return QualType();
6656 SubtitutedTypes.push_back(Out);
6657 }
6658 }
6659
6660 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
6661
6662 QualType Out = getDerived().RebuildPackIndexingType(
6663 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
6664 FullySubstituted, SubtitutedTypes);
6665 if (Out.isNull())
6666 return Out;
6667
6668 PackIndexingTypeLoc Loc = TLB.push<PackIndexingTypeLoc>(Out);
6669 Loc.setEllipsisLoc(TL.getEllipsisLoc());
6670 return Out;
6671}
6672
6673template<typename Derived>
6674QualType TreeTransform<Derived>::TransformUnaryTransformType(
6675 TypeLocBuilder &TLB,
6676 UnaryTransformTypeLoc TL) {
6677 QualType Result = TL.getType();
6678 if (Result->isDependentType()) {
6679 const UnaryTransformType *T = TL.getTypePtr();
6680 QualType NewBase =
6681 getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
6682 Result = getDerived().RebuildUnaryTransformType(NewBase,
6683 T->getUTTKind(),
6684 TL.getKWLoc());
6685 if (Result.isNull())
6686 return QualType();
6687 }
6688
6689 UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(Result);
6690 NewTL.setKWLoc(TL.getKWLoc());
6691 NewTL.setParensRange(TL.getParensRange());
6692 NewTL.setUnderlyingTInfo(TL.getUnderlyingTInfo());
6693 return Result;
6694}
6695
6696template<typename Derived>
6697QualType TreeTransform<Derived>::TransformDeducedTemplateSpecializationType(
6698 TypeLocBuilder &TLB, DeducedTemplateSpecializationTypeLoc TL) {
6699 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
6700
6701 CXXScopeSpec SS;
6702 TemplateName TemplateName = getDerived().TransformTemplateName(
6703 SS, T->getTemplateName(), TL.getTemplateNameLoc());
6704 if (TemplateName.isNull())
6705 return QualType();
6706
6707 QualType OldDeduced = T->getDeducedType();
6708 QualType NewDeduced;
6709 if (!OldDeduced.isNull()) {
6710 NewDeduced = getDerived().TransformType(OldDeduced);
6711 if (NewDeduced.isNull())
6712 return QualType();
6713 }
6714
6715 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
6716 TemplateName, NewDeduced);
6717 if (Result.isNull())
6718 return QualType();
6719
6720 DeducedTemplateSpecializationTypeLoc NewTL =
6721 TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
6722 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
6723
6724 return Result;
6725}
6726
6727template<typename Derived>
6728QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
6729 RecordTypeLoc TL) {
6730 const RecordType *T = TL.getTypePtr();
6731 RecordDecl *Record
6732 = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
6733 T->getDecl()));
6734 if (!Record)
6735 return QualType();
6736
6737 QualType Result = TL.getType();
6738 if (getDerived().AlwaysRebuild() ||
6739 Record != T->getDecl()) {
6740 Result = getDerived().RebuildRecordType(Record);
6741 if (Result.isNull())
6742 return QualType();
6743 }
6744
6745 RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result);
6746 NewTL.setNameLoc(TL.getNameLoc());
6747
6748 return Result;
6749}
6750
6751template<typename Derived>
6752QualType TreeTransform<Derived>::TransformEnumType(TypeLocBuilder &TLB,
6753 EnumTypeLoc TL) {
6754 const EnumType *T = TL.getTypePtr();
6755 EnumDecl *Enum
6756 = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
6757 T->getDecl()));
6758 if (!Enum)
6759 return QualType();
6760
6761 QualType Result = TL.getType();
6762 if (getDerived().AlwaysRebuild() ||
6763 Enum != T->getDecl()) {
6764 Result = getDerived().RebuildEnumType(Enum);
6765 if (Result.isNull())
6766 return QualType();
6767 }
6768
6769 EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result);
6770 NewTL.setNameLoc(TL.getNameLoc());
6771
6772 return Result;
6773}
6774
6775template<typename Derived>
6776QualType TreeTransform<Derived>::TransformInjectedClassNameType(
6777 TypeLocBuilder &TLB,
6778 InjectedClassNameTypeLoc TL) {
6779 Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
6780 TL.getTypePtr()->getDecl());
6781 if (!D) return QualType();
6782
6783 QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D));
6784 TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc());
6785 return T;
6786}
6787
6788template<typename Derived>
6790 TypeLocBuilder &TLB,
6792 return getDerived().TransformTemplateTypeParmType(
6793 TLB, TL,
6794 /*SuppressObjCLifetime=*/false);
6795}
6796
6797template <typename Derived>
6799 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
6800 return TransformTypeSpecType(TLB, TL);
6801}
6802
6803template<typename Derived>
6804QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
6805 TypeLocBuilder &TLB,
6806 SubstTemplateTypeParmTypeLoc TL) {
6807 const SubstTemplateTypeParmType *T = TL.getTypePtr();
6808
6809 Decl *NewReplaced =
6810 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
6811
6812 // Substitute into the replacement type, which itself might involve something
6813 // that needs to be transformed. This only tends to occur with default
6814 // template arguments of template template parameters.
6815 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
6816 QualType Replacement = getDerived().TransformType(T->getReplacementType());
6817 if (Replacement.isNull())
6818 return QualType();
6819
6820 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
6821 Replacement, NewReplaced, T->getIndex(), T->getPackIndex());
6822
6823 // Propagate type-source information.
6824 SubstTemplateTypeParmTypeLoc NewTL
6825 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
6826 NewTL.setNameLoc(TL.getNameLoc());
6827 return Result;
6828
6829}
6830
6831template<typename Derived>
6833 TypeLocBuilder &TLB,
6835 return getDerived().TransformSubstTemplateTypeParmPackType(
6836 TLB, TL, /*SuppressObjCLifetime=*/false);
6837}
6838
6839template <typename Derived>
6842 return TransformTypeSpecType(TLB, TL);
6843}
6844
6845template<typename Derived>
6847 TypeLocBuilder &TLB,
6850
6851 // The nested-name-specifier never matters in a TemplateSpecializationType,
6852 // because we can't have a dependent nested-name-specifier anyway.
6853 CXXScopeSpec SS;
6854 TemplateName Template
6855 = getDerived().TransformTemplateName(SS, T->getTemplateName(),
6856 TL.getTemplateNameLoc());
6857 if (Template.isNull())
6858 return QualType();
6859
6860 return getDerived().TransformTemplateSpecializationType(TLB, TL, Template);
6861}
6862
6863template<typename Derived>
6865 AtomicTypeLoc TL) {
6866 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
6867 if (ValueType.isNull())
6868 return QualType();
6869
6870 QualType Result = TL.getType();
6871 if (getDerived().AlwaysRebuild() ||
6872 ValueType != TL.getValueLoc().getType()) {
6873 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
6874 if (Result.isNull())
6875 return QualType();
6876 }
6877
6878 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
6879 NewTL.setKWLoc(TL.getKWLoc());
6880 NewTL.setLParenLoc(TL.getLParenLoc());
6881 NewTL.setRParenLoc(TL.getRParenLoc());
6882
6883 return Result;
6884}
6885
6886template <typename Derived>
6887QualType TreeTransform<Derived>::TransformPipeType(TypeLocBuilder &TLB,
6888 PipeTypeLoc TL) {
6889 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
6890 if (ValueType.isNull())
6891 return QualType();
6892
6893 QualType Result = TL.getType();
6894 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
6895 const PipeType *PT = Result->castAs<PipeType>();
6896 bool isReadPipe = PT->isReadOnly();
6897 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
6898 if (Result.isNull())
6899 return QualType();
6900 }
6901
6902 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
6903 NewTL.setKWLoc(TL.getKWLoc());
6904
6905 return Result;
6906}
6907
6908template <typename Derived>
6909QualType TreeTransform<Derived>::TransformBitIntType(TypeLocBuilder &TLB,
6910 BitIntTypeLoc TL) {
6911 const BitIntType *EIT = TL.getTypePtr();
6912 QualType Result = TL.getType();
6913
6914 if (getDerived().AlwaysRebuild()) {
6915 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
6916 EIT->getNumBits(), TL.getNameLoc());
6917 if (Result.isNull())
6918 return QualType();
6919 }
6920
6921 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
6922 NewTL.setNameLoc(TL.getNameLoc());
6923 return Result;
6924}
6925
6926template <typename Derived>
6927QualType TreeTransform<Derived>::TransformDependentBitIntType(
6928 TypeLocBuilder &TLB, DependentBitIntTypeLoc TL) {
6929 const DependentBitIntType *EIT = TL.getTypePtr();
6930
6931 EnterExpressionEvaluationContext Unevaluated(
6933 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
6934 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
6935
6936 if (BitsExpr.isInvalid())
6937 return QualType();
6938
6939 QualType Result = TL.getType();
6940
6941 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
6942 Result = getDerived().RebuildDependentBitIntType(
6943 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
6944
6945 if (Result.isNull())
6946 return QualType();
6947 }
6948
6949 if (isa<DependentBitIntType>(Result)) {
6950 DependentBitIntTypeLoc NewTL = TLB.push<DependentBitIntTypeLoc>(Result);
6951 NewTL.setNameLoc(TL.getNameLoc());
6952 } else {
6953 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
6954 NewTL.setNameLoc(TL.getNameLoc());
6955 }
6956 return Result;
6957}
6958
6959 /// Simple iterator that traverses the template arguments in a
6960 /// container that provides a \c getArgLoc() member function.
6961 ///
6962 /// This iterator is intended to be used with the iterator form of
6963 /// \c TreeTransform<Derived>::TransformTemplateArguments().
6964 template<typename ArgLocContainer>
6966 ArgLocContainer *Container;
6967 unsigned Index;
6968
6969 public:
6972 typedef int difference_type;
6973 typedef std::input_iterator_tag iterator_category;
6974
6975 class pointer {
6977
6978 public:
6979 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
6980
6982 return &Arg;
6983 }
6984 };
6985
6986
6988
6989 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
6990 unsigned Index)
6991 : Container(&Container), Index(Index) { }
6992
6994 ++Index;
6995 return *this;
6996 }
6997
7000 ++(*this);
7001 return Old;
7002 }
7003
7005 return Container->getArgLoc(Index);
7006 }
7007
7009 return pointer(Container->getArgLoc(Index));
7010 }
7011
7014 return X.Container == Y.Container && X.Index == Y.Index;
7015 }
7016
7019 return !(X == Y);
7020 }
7021 };
7022
7023template<typename Derived>
7024QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7025 AutoTypeLoc TL) {
7026 const AutoType *T = TL.getTypePtr();
7027 QualType OldDeduced = T->getDeducedType();
7028 QualType NewDeduced;
7029 if (!OldDeduced.isNull()) {
7030 NewDeduced = getDerived().TransformType(OldDeduced);
7031 if (NewDeduced.isNull())
7032 return QualType();
7033 }
7034
7035 ConceptDecl *NewCD = nullptr;
7036 TemplateArgumentListInfo NewTemplateArgs;
7037 NestedNameSpecifierLoc NewNestedNameSpec;
7038 if (T->isConstrained()) {
7039 assert(TL.getConceptReference());
7040 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7041 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7042
7043 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7044 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7045 typedef TemplateArgumentLocContainerIterator<AutoTypeLoc> ArgIterator;
7046 if (getDerived().TransformTemplateArguments(
7047 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7048 NewTemplateArgs))
7049 return QualType();
7050
7051 if (TL.getNestedNameSpecifierLoc()) {
7052 NewNestedNameSpec
7053 = getDerived().TransformNestedNameSpecifierLoc(
7054 TL.getNestedNameSpecifierLoc());
7055 if (!NewNestedNameSpec)
7056 return QualType();
7057 }
7058 }
7059
7060 QualType Result = TL.getType();
7061 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7062 T->isDependentType() || T->isConstrained()) {
7063 // FIXME: Maybe don't rebuild if all template arguments are the same.
7065 NewArgList.reserve(NewTemplateArgs.size());
7066 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7067 NewArgList.push_back(ArgLoc.getArgument());
7068 Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
7069 NewArgList);
7070 if (Result.isNull())
7071 return QualType();
7072 }
7073
7074 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7075 NewTL.setNameLoc(TL.getNameLoc());
7076 NewTL.setRParenLoc(TL.getRParenLoc());
7077 NewTL.setConceptReference(nullptr);
7078
7079 if (T->isConstrained()) {
7080 DeclarationNameInfo DNI = DeclarationNameInfo(
7081 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7082 TL.getConceptNameLoc(),
7083 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7084 auto *CR = ConceptReference::Create(
7085 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7086 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7087 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7088 NewTL.setConceptReference(CR);
7089 }
7090
7091 return Result;
7092}
7093
7094template <typename Derived>
7096 TypeLocBuilder &TLB,
7097 TemplateSpecializationTypeLoc TL,
7098 TemplateName Template) {
7099 TemplateArgumentListInfo NewTemplateArgs;
7100 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7101 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7102 typedef TemplateArgumentLocContainerIterator<TemplateSpecializationTypeLoc>
7103 ArgIterator;
7104 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7105 ArgIterator(TL, TL.getNumArgs()),
7106 NewTemplateArgs))
7107 return QualType();
7108
7109 // FIXME: maybe don't rebuild if all the template arguments are the same.
7110
7111 QualType Result =
7112 getDerived().RebuildTemplateSpecializationType(Template,
7113 TL.getTemplateNameLoc(),
7114 NewTemplateArgs);
7115
7116 if (!Result.isNull()) {
7117 // Specializations of template template parameters are represented as
7118 // TemplateSpecializationTypes, and substitution of type alias templates
7119 // within a dependent context can transform them into
7120 // DependentTemplateSpecializationTypes.
7121 if (isa<DependentTemplateSpecializationType>(Result)) {
7122 DependentTemplateSpecializationTypeLoc NewTL
7123 = TLB.push<DependentTemplateSpecializationTypeLoc>(Result);
7124 NewTL.setElaboratedKeywordLoc(SourceLocation());
7125 NewTL.setQualifierLoc(NestedNameSpecifierLoc());
7126 NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc());
7127 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7128 NewTL.setLAngleLoc(TL.getLAngleLoc());
7129 NewTL.setRAngleLoc(TL.getRAngleLoc());
7130 for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7131 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7132 return Result;
7133 }
7134
7135 TemplateSpecializationTypeLoc NewTL
7136 = TLB.push<TemplateSpecializationTypeLoc>(Result);
7137 NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc());
7138 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7139 NewTL.setLAngleLoc(TL.getLAngleLoc());
7140 NewTL.setRAngleLoc(TL.getRAngleLoc());
7141 for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7142 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7143 }
7144
7145 return Result;
7146}
7147
7148template <typename Derived>
7150 TypeLocBuilder &TLB,
7152 TemplateName Template,
7153 CXXScopeSpec &SS) {
7154 TemplateArgumentListInfo NewTemplateArgs;
7155 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7156 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7159 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7160 ArgIterator(TL, TL.getNumArgs()),
7161 NewTemplateArgs))
7162 return QualType();
7163
7164 // FIXME: maybe don't rebuild if all the template arguments are the same.
7165
7166 if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
7167 QualType Result = getSema().Context.getDependentTemplateSpecializationType(
7168 TL.getTypePtr()->getKeyword(), DTN->getQualifier(),
7169 DTN->getIdentifier(), NewTemplateArgs.arguments());
7170
7174 NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context));
7177 NewTL.setLAngleLoc(TL.getLAngleLoc());
7178 NewTL.setRAngleLoc(TL.getRAngleLoc());
7179 for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7180 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7181 return Result;
7182 }
7183
7185 = getDerived().RebuildTemplateSpecializationType(Template,
7186 TL.getTemplateNameLoc(),
7187 NewTemplateArgs);
7188
7189 if (!Result.isNull()) {
7190 /// FIXME: Wrap this in an elaborated-type-specifier?
7195 NewTL.setLAngleLoc(TL.getLAngleLoc());
7196 NewTL.setRAngleLoc(TL.getRAngleLoc());
7197 for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7198 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7199 }
7200
7201 return Result;
7202}
7203
7204template<typename Derived>
7207 ElaboratedTypeLoc TL) {
7208 const ElaboratedType *T = TL.getTypePtr();
7209
7210 NestedNameSpecifierLoc QualifierLoc;
7211 // NOTE: the qualifier in an ElaboratedType is optional.
7212 if (TL.getQualifierLoc()) {
7213 QualifierLoc
7214 = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
7215 if (!QualifierLoc)
7216 return QualType();
7217 }
7218
7219 QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
7220 if (NamedT.isNull())
7221 return QualType();
7222
7223 // C++0x [dcl.type.elab]p2:
7224 // If the identifier resolves to a typedef-name or the simple-template-id
7225 // resolves to an alias template specialization, the
7226 // elaborated-type-specifier is ill-formed.
7227 if (T->getKeyword() != ElaboratedTypeKeyword::None &&
7228 T->getKeyword() != ElaboratedTypeKeyword::Typename) {
7229 if (const TemplateSpecializationType *TST =
7230 NamedT->getAs<TemplateSpecializationType>()) {
7231 TemplateName Template = TST->getTemplateName();
7232 if (TypeAliasTemplateDecl *TAT = dyn_cast_or_null<TypeAliasTemplateDecl>(
7233 Template.getAsTemplateDecl())) {
7234 SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
7235 diag::err_tag_reference_non_tag)
7237 << llvm::to_underlying(
7239 SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
7240 }
7241 }
7242 }
7243
7244 QualType Result = TL.getType();
7245 if (getDerived().AlwaysRebuild() ||
7246 QualifierLoc != TL.getQualifierLoc() ||
7247 NamedT != T->getNamedType()) {
7248 Result = getDerived().RebuildElaboratedType(TL.getElaboratedKeywordLoc(),
7249 T->getKeyword(),
7250 QualifierLoc, NamedT);
7251 if (Result.isNull())
7252 return QualType();
7253 }
7254
7255 ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
7256 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7257 NewTL.setQualifierLoc(QualifierLoc);
7258 return Result;
7259}
7260
7261template <typename Derived>
7262template <typename Fn>
7264 TypeLocBuilder &TLB, AttributedTypeLoc TL, Fn TransformModifiedTypeFn) {
7265 const AttributedType *oldType = TL.getTypePtr();
7266 QualType modifiedType = TransformModifiedTypeFn(TLB, TL.getModifiedLoc());
7267 if (modifiedType.isNull())
7268 return QualType();
7269
7270 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7271 const Attr *oldAttr = TL.getAttr();
7272 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7273 if (oldAttr && !newAttr)
7274 return QualType();
7275
7276 QualType result = TL.getType();
7277
7278 // FIXME: dependent operand expressions?
7279 if (getDerived().AlwaysRebuild() ||
7280 modifiedType != oldType->getModifiedType()) {
7281 TypeLocBuilder AuxiliaryTLB;
7282 AuxiliaryTLB.reserve(TL.getFullDataSize());
7283 QualType equivalentType =
7284 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7285 if (equivalentType.isNull())
7286 return QualType();
7287
7288 // Check whether we can add nullability; it is only represented as
7289 // type sugar, and therefore cannot be diagnosed in any other way.
7290 if (auto nullability = oldType->getImmediateNullability()) {
7291 if (!modifiedType->canHaveNullability()) {
7292 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7293 : TL.getModifiedLoc().getBeginLoc()),
7294 diag::err_nullability_nonpointer)
7295 << DiagNullabilityKind(*nullability, false) << modifiedType;
7296 return QualType();
7297 }
7298 }
7299
7300 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7301 modifiedType,
7302 equivalentType);
7303 }
7304
7305 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7306 newTL.setAttr(newAttr);
7307 return result;
7308}
7309
7310template <typename Derived>
7312 AttributedTypeLoc TL) {
7313 return getDerived().TransformAttributedType(
7314 TLB, TL, [&](TypeLocBuilder &TLB, TypeLoc ModifiedLoc) -> QualType {
7315 return getDerived().TransformType(TLB, ModifiedLoc);
7316 });
7317}
7318
7319template <typename Derived>
7322 const CountAttributedType *OldTy = TL.getTypePtr();
7323 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7324 if (InnerTy.isNull())
7325 return QualType();
7326
7327 Expr *OldCount = TL.getCountExpr();
7328 Expr *NewCount = nullptr;
7329 if (OldCount) {
7330 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7331 if (CountResult.isInvalid())
7332 return QualType();
7333 NewCount = CountResult.get();
7334 }
7335
7336 QualType Result = TL.getType();
7337 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7338 OldCount != NewCount) {
7339 // Currently, CountAttributedType can only wrap incomplete array types.
7340 Result = SemaRef.BuildCountAttributedArrayType(InnerTy, NewCount);
7341 }
7342
7343 TLB.push<CountAttributedTypeLoc>(Result);
7344 return Result;
7345}
7346
7347template <typename Derived>
7348QualType TreeTransform<Derived>::TransformBTFTagAttributedType(
7349 TypeLocBuilder &TLB, BTFTagAttributedTypeLoc TL) {
7350 // The BTFTagAttributedType is available for C only.
7351 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7352}
7353
7354template<typename Derived>
7355QualType
7356TreeTransform<Derived>::TransformParenType(TypeLocBuilder &TLB,
7357 ParenTypeLoc TL) {
7358 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7359 if (Inner.isNull())
7360 return QualType();
7361
7362 QualType Result = TL.getType();
7363 if (getDerived().AlwaysRebuild() ||
7364 Inner != TL.getInnerLoc().getType()) {
7365 Result = getDerived().RebuildParenType(Inner);
7366 if (Result.isNull())
7367 return QualType();
7368 }
7369
7370 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7371 NewTL.setLParenLoc(TL.getLParenLoc());
7372 NewTL.setRParenLoc(TL.getRParenLoc());
7373 return Result;
7374}
7375
7376template <typename Derived>
7377QualType
7378TreeTransform<Derived>::TransformMacroQualifiedType(TypeLocBuilder &TLB,
7379 MacroQualifiedTypeLoc TL) {
7380 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7381 if (Inner.isNull())
7382 return QualType();
7383
7384 QualType Result = TL.getType();
7385 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7386 Result =
7387 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7388 if (Result.isNull())
7389 return QualType();
7390 }
7391
7392 MacroQualifiedTypeLoc NewTL = TLB.push<MacroQualifiedTypeLoc>(Result);
7393 NewTL.setExpansionLoc(TL.getExpansionLoc());
7394 return Result;
7395}
7396
7397template<typename Derived>
7398QualType TreeTransform<Derived>::TransformDependentNameType(
7399 TypeLocBuilder &TLB, DependentNameTypeLoc TL) {
7400 return TransformDependentNameType(TLB, TL, false);
7401}
7402
7403template<typename Derived>
7404QualType TreeTransform<Derived>::TransformDependentNameType(
7405 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext) {
7406 const DependentNameType *T = TL.getTypePtr();
7407
7408 NestedNameSpecifierLoc QualifierLoc
7409 = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
7410 if (!QualifierLoc)
7411 return QualType();
7412
7413 QualType Result
7414 = getDerived().RebuildDependentNameType(T->getKeyword(),
7415 TL.getElaboratedKeywordLoc(),
7416 QualifierLoc,
7417 T->getIdentifier(),
7418 TL.getNameLoc(),
7419 DeducedTSTContext);
7420 if (Result.isNull())
7421 return QualType();
7422
7423 if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
7424 QualType NamedT = ElabT->getNamedType();
7425 TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc());
7426
7427 ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
7428 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7429 NewTL.setQualifierLoc(QualifierLoc);
7430 } else {
7431 DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
7432 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7433 NewTL.setQualifierLoc(QualifierLoc);
7434 NewTL.setNameLoc(TL.getNameLoc());
7435 }
7436 return Result;
7437}
7438
7439template<typename Derived>
7442 DependentTemplateSpecializationTypeLoc TL) {
7443 NestedNameSpecifierLoc QualifierLoc;
7444 if (TL.getQualifierLoc()) {
7445 QualifierLoc
7446 = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
7447 if (!QualifierLoc)
7448 return QualType();
7449 }
7450
7451 return getDerived()
7452 .TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc);
7453}
7454
7455template<typename Derived>
7459 NestedNameSpecifierLoc QualifierLoc) {
7461
7462 TemplateArgumentListInfo NewTemplateArgs;
7463 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7464 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7465
7468 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7469 ArgIterator(TL, TL.getNumArgs()),
7470 NewTemplateArgs))
7471 return QualType();
7472
7473 QualType Result = getDerived().RebuildDependentTemplateSpecializationType(
7474 T->getKeyword(), QualifierLoc, TL.getTemplateKeywordLoc(),
7475 T->getIdentifier(), TL.getTemplateNameLoc(), NewTemplateArgs,
7476 /*AllowInjectedClassName*/ false);
7477 if (Result.isNull())
7478 return QualType();
7479
7480 if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) {
7481 QualType NamedT = ElabT->getNamedType();
7482
7483 // Copy information relevant to the template specialization.
7485 = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
7488 NamedTL.setLAngleLoc(TL.getLAngleLoc());
7489 NamedTL.setRAngleLoc(TL.getRAngleLoc());
7490 for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
7491 NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
7492
7493 // Copy information relevant to the elaborated type.
7496 NewTL.setQualifierLoc(QualifierLoc);
7497 } else if (isa<DependentTemplateSpecializationType>(Result)) {
7501 SpecTL.setQualifierLoc(QualifierLoc);
7504 SpecTL.setLAngleLoc(TL.getLAngleLoc());
7505 SpecTL.setRAngleLoc(TL.getRAngleLoc());
7506 for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
7507 SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
7508 } else {
7513 SpecTL.setLAngleLoc(TL.getLAngleLoc());
7514 SpecTL.setRAngleLoc(TL.getRAngleLoc());
7515 for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
7516 SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
7517 }
7518 return Result;
7519}
7520
7521template<typename Derived>
7524 QualType Pattern
7525 = getDerived().TransformType(TLB, TL.getPatternLoc());
7526 if (Pattern.isNull())
7527 return QualType();
7528
7529 QualType Result = TL.getType();
7530 if (getDerived().AlwaysRebuild() ||
7531 Pattern != TL.getPatternLoc().getType()) {
7532 Result = getDerived().RebuildPackExpansionType(Pattern,
7534 TL.getEllipsisLoc(),
7536 if (Result.isNull())
7537 return QualType();
7538 }
7539
7540 PackExpansionTypeLoc NewT = TLB.push<PackExpansionTypeLoc>(Result);
7541 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7542 return Result;
7543}
7544
7545template<typename Derived>
7546QualType
7547TreeTransform<Derived>::TransformObjCInterfaceType(TypeLocBuilder &TLB,
7548 ObjCInterfaceTypeLoc TL) {
7549 // ObjCInterfaceType is never dependent.
7550 TLB.pushFullCopy(TL);
7551 return TL.getType();
7552}
7553
7554template<typename Derived>
7555QualType
7556TreeTransform<Derived>::TransformObjCTypeParamType(TypeLocBuilder &TLB,
7557 ObjCTypeParamTypeLoc TL) {
7558 const ObjCTypeParamType *T = TL.getTypePtr();
7559 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7560 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7561 if (!OTP)
7562 return QualType();
7563
7564 QualType Result = TL.getType();
7565 if (getDerived().AlwaysRebuild() ||
7566 OTP != T->getDecl()) {
7567 Result = getDerived().RebuildObjCTypeParamType(
7568 OTP, TL.getProtocolLAngleLoc(),
7569 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7570 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7571 if (Result.isNull())
7572 return QualType();
7573 }
7574
7575 ObjCTypeParamTypeLoc NewTL = TLB.push<ObjCTypeParamTypeLoc>(Result);
7576 if (TL.getNumProtocols()) {
7577 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7578 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7579 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7580 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7581 }
7582 return Result;
7583}
7584
7585template<typename Derived>
7586QualType
7587TreeTransform<Derived>::TransformObjCObjectType(TypeLocBuilder &TLB,
7588 ObjCObjectTypeLoc TL) {
7589 // Transform base type.
7590 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7591 if (BaseType.isNull())
7592 return QualType();
7593
7594 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
7595
7596 // Transform type arguments.
7597 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
7598 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
7599 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
7600 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
7601 QualType TypeArg = TypeArgInfo->getType();
7602 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
7603 AnyChanged = true;
7604
7605 // We have a pack expansion. Instantiate it.
7606 const auto *PackExpansion = PackExpansionLoc.getType()
7607 ->castAs<PackExpansionType>();
7609 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
7610 Unexpanded);
7611 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7612
7613 // Determine whether the set of unexpanded parameter packs can
7614 // and should be expanded.
7615 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
7616 bool Expand = false;
7617 bool RetainExpansion = false;
7618 std::optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
7619 if (getDerived().TryExpandParameterPacks(
7620 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
7621 Unexpanded, Expand, RetainExpansion, NumExpansions))
7622 return QualType();
7623
7624 if (!Expand) {
7625 // We can't expand this pack expansion into separate arguments yet;
7626 // just substitute into the pattern and create a new pack expansion
7627 // type.
7628 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
7629
7630 TypeLocBuilder TypeArgBuilder;
7631 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7632 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
7633 PatternLoc);
7634 if (NewPatternType.isNull())
7635 return QualType();
7636
7637 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
7638 NewPatternType, NumExpansions);
7639 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
7640 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
7641 NewTypeArgInfos.push_back(
7642 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
7643 continue;
7644 }
7645
7646 // Substitute into the pack expansion pattern for each slice of the
7647 // pack.
7648 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
7649 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
7650
7651 TypeLocBuilder TypeArgBuilder;
7652 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7653
7654 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
7655 PatternLoc);
7656 if (NewTypeArg.isNull())
7657 return QualType();
7658
7659 NewTypeArgInfos.push_back(
7660 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
7661 }
7662
7663 continue;
7664 }
7665
7666 TypeLocBuilder TypeArgBuilder;
7667 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
7668 QualType NewTypeArg =
7669 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
7670 if (NewTypeArg.isNull())
7671 return QualType();
7672
7673 // If nothing changed, just keep the old TypeSourceInfo.
7674 if (NewTypeArg == TypeArg) {
7675 NewTypeArgInfos.push_back(TypeArgInfo);
7676 continue;
7677 }
7678
7679 NewTypeArgInfos.push_back(
7680 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
7681 AnyChanged = true;
7682 }
7683
7684 QualType Result = TL.getType();
7685 if (getDerived().AlwaysRebuild() || AnyChanged) {
7686 // Rebuild the type.
7687 Result = getDerived().RebuildObjCObjectType(
7688 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
7689 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
7690 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7691 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7692
7693 if (Result.isNull())
7694 return QualType();
7695 }
7696
7697 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
7698 NewT.setHasBaseTypeAsWritten(true);
7699 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
7700 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
7701 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
7702 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
7703 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7704 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7705 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
7706 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7707 return Result;
7708}
7709
7710template<typename Derived>
7711QualType
7712TreeTransform<Derived>::TransformObjCObjectPointerType(TypeLocBuilder &TLB,
7713 ObjCObjectPointerTypeLoc TL) {
7714 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
7715 if (PointeeType.isNull())
7716 return QualType();
7717
7718 QualType Result = TL.getType();
7719 if (getDerived().AlwaysRebuild() ||
7720 PointeeType != TL.getPointeeLoc().getType()) {
7721 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
7722 TL.getStarLoc());
7723 if (Result.isNull())
7724 return QualType();
7725 }
7726
7727 ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);
7728 NewT.setStarLoc(TL.getStarLoc());
7729 return Result;
7730}
7731
7732//===----------------------------------------------------------------------===//
7733// Statement transformation
7734//===----------------------------------------------------------------------===//
7735template<typename Derived>
7737TreeTransform<Derived>::TransformNullStmt(NullStmt *S) {
7738 return S;
7739}
7740
7741template<typename Derived>
7744 return getDerived().TransformCompoundStmt(S, false);
7745}
7746
7747template<typename Derived>
7750 bool IsStmtExpr) {
7751 Sema::CompoundScopeRAII CompoundScope(getSema());
7752 Sema::FPFeaturesStateRAII FPSave(getSema());
7753 if (S->hasStoredFPFeatures())
7754 getSema().resetFPOptions(
7755 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
7756
7757 const Stmt *ExprResult = S->getStmtExprResult();
7758 bool SubStmtInvalid = false;
7759 bool SubStmtChanged = false;
7760 SmallVector<Stmt*, 8> Statements;
7761 for (auto *B : S->body()) {
7762 StmtResult Result = getDerived().TransformStmt(
7763 B, IsStmtExpr && B == ExprResult ? SDK_StmtExprResult : SDK_Discarded);
7764
7765 if (Result.isInvalid()) {
7766 // Immediately fail if this was a DeclStmt, since it's very
7767 // likely that this will cause problems for future statements.
7768 if (isa<DeclStmt>(B))
7769 return StmtError();
7770
7771 // Otherwise, just keep processing substatements and fail later.
7772 SubStmtInvalid = true;
7773 continue;
7774 }
7775
7776 SubStmtChanged = SubStmtChanged || Result.get() != B;
7777 Statements.push_back(Result.getAs<Stmt>());
7778 }
7779
7780 if (SubStmtInvalid)
7781 return StmtError();
7782
7783 if (!getDerived().AlwaysRebuild() &&
7784 !SubStmtChanged)
7785 return S;
7786
7787 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
7788 Statements,
7789 S->getRBracLoc(),
7790 IsStmtExpr);
7791}
7792
7793template<typename Derived>
7795TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
7796 ExprResult LHS, RHS;
7797 {
7798 EnterExpressionEvaluationContext Unevaluated(
7800
7801 // Transform the left-hand case value.
7802 LHS = getDerived().TransformExpr(S->getLHS());
7803 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
7804 if (LHS.isInvalid())
7805 return StmtError();
7806
7807 // Transform the right-hand case value (for the GNU case-range extension).
7808 RHS = getDerived().TransformExpr(S->getRHS());
7809 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
7810 if (RHS.isInvalid())
7811 return StmtError();
7812 }
7813
7814 // Build the case statement.
7815 // Case statements are always rebuilt so that they will attached to their
7816 // transformed switch statement.
7817 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
7818 LHS.get(),
7819 S->getEllipsisLoc(),
7820 RHS.get(),
7821 S->getColonLoc());
7822 if (Case.isInvalid())
7823 return StmtError();
7824
7825 // Transform the statement following the case
7826 StmtResult SubStmt =
7827 getDerived().TransformStmt(S->getSubStmt());
7828 if (SubStmt.isInvalid())
7829 return StmtError();
7830
7831 // Attach the body to the case statement
7832 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
7833}
7834
7835template <typename Derived>
7836StmtResult TreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) {
7837 // Transform the statement following the default case
7838 StmtResult SubStmt =
7839 getDerived().TransformStmt(S->getSubStmt());
7840 if (SubStmt.isInvalid())
7841 return StmtError();
7842
7843 // Default statements are always rebuilt
7844 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
7845 SubStmt.get());
7846}
7847
7848template<typename Derived>
7850TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S, StmtDiscardKind SDK) {
7851 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
7852 if (SubStmt.isInvalid())
7853 return StmtError();
7854
7855 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
7856 S->getDecl());
7857 if (!LD)
7858 return StmtError();
7859
7860 // If we're transforming "in-place" (we're not creating new local
7861 // declarations), assume we're replacing the old label statement
7862 // and clear out the reference to it.
7863 if (LD == S->getDecl())
7864 S->getDecl()->setStmt(nullptr);
7865
7866 // FIXME: Pass the real colon location in.
7867 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
7868 cast<LabelDecl>(LD), SourceLocation(),
7869 SubStmt.get());
7870}
7871
7872template <typename Derived>
7874 if (!R)
7875 return R;
7876
7877 switch (R->getKind()) {
7878// Transform attributes by calling TransformXXXAttr.
7879#define ATTR(X) \
7880 case attr::X: \
7881 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
7882#include "clang/Basic/AttrList.inc"
7883 }
7884 return R;
7885}
7886
7887template <typename Derived>
7889 const Stmt *InstS,
7890 const Attr *R) {
7891 if (!R)
7892 return R;
7893
7894 switch (R->getKind()) {
7895// Transform attributes by calling TransformStmtXXXAttr.
7896#define ATTR(X) \
7897 case attr::X: \
7898 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
7899#include "clang/Basic/AttrList.inc"
7900 }
7901 return TransformAttr(R);
7902}
7903
7904template <typename Derived>
7907 StmtDiscardKind SDK) {
7908 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
7909 if (SubStmt.isInvalid())
7910 return StmtError();
7911
7912 bool AttrsChanged = false;
7914
7915 // Visit attributes and keep track if any are transformed.
7916 for (const auto *I : S->getAttrs()) {
7917 const Attr *R =
7918 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
7919 AttrsChanged |= (I != R);
7920 if (R)
7921 Attrs.push_back(R);
7922 }
7923
7924 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
7925 return S;
7926
7927 // If transforming the attributes failed for all of the attributes in the
7928 // statement, don't make an AttributedStmt without attributes.
7929 if (Attrs.empty())
7930 return SubStmt;
7931
7932 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
7933 SubStmt.get());
7934}
7935
7936template<typename Derived>
7938TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
7939 // Transform the initialization statement
7940 StmtResult Init = getDerived().TransformStmt(S->getInit());
7941 if (Init.isInvalid())
7942 return StmtError();
7943
7944 Sema::ConditionResult Cond;
7945 if (!S->isConsteval()) {
7946 // Transform the condition
7947 Cond = getDerived().TransformCondition(
7948 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
7949 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
7951 if (Cond.isInvalid())
7952 return StmtError();
7953 }
7954
7955 // If this is a constexpr if, determine which arm we should instantiate.
7956 std::optional<bool> ConstexprConditionValue;
7957 if (S->isConstexpr())
7958 ConstexprConditionValue = Cond.getKnownValue();
7959
7960 // Transform the "then" branch.
7961 StmtResult Then;
7962 if (!ConstexprConditionValue || *ConstexprConditionValue) {
7963 Then = getDerived().TransformStmt(S->getThen());
7964 if (Then.isInvalid())
7965 return StmtError();
7966 } else {
7967 // Discarded branch is replaced with empty CompoundStmt so we can keep
7968 // proper source location for start and end of original branch, so
7969 // subsequent transformations like CoverageMapping work properly
7970 Then = new (getSema().Context)
7971 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
7972 }
7973
7974 // Transform the "else" branch.
7975 StmtResult Else;
7976 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
7977 Else = getDerived().TransformStmt(S->getElse());
7978 if (Else.isInvalid())
7979 return StmtError();
7980 } else if (S->getElse() && ConstexprConditionValue &&
7981 *ConstexprConditionValue) {
7982 // Same thing here as with <then> branch, we are discarding it, we can't
7983 // replace it with NULL nor NullStmt as we need to keep for source location
7984 // range, for CoverageMapping
7985 Else = new (getSema().Context)
7986 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
7987 }
7988
7989 if (!getDerived().AlwaysRebuild() &&
7990 Init.get() == S->getInit() &&
7991 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
7992 Then.get() == S->getThen() &&
7993 Else.get() == S->getElse())
7994 return S;
7995
7996 return getDerived().RebuildIfStmt(
7997 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
7998 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
7999}
8000
8001template<typename Derived>
8003TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) {
8004 // Transform the initialization statement
8005 StmtResult Init = getDerived().TransformStmt(S->getInit());
8006 if (Init.isInvalid())
8007 return StmtError();
8008
8009 // Transform the condition.
8010 Sema::ConditionResult Cond = getDerived().TransformCondition(
8011 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8013 if (Cond.isInvalid())
8014 return StmtError();
8015
8016 // Rebuild the switch statement.
8018 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8019 Init.get(), Cond, S->getRParenLoc());
8020 if (Switch.isInvalid())
8021 return StmtError();
8022
8023 // Transform the body of the switch statement.
8024 StmtResult Body = getDerived().TransformStmt(S->getBody());
8025 if (Body.isInvalid())
8026 return StmtError();
8027
8028 // Complete the switch statement.
8029 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8030 Body.get());
8031}
8032
8033template<typename Derived>
8035TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
8036 // Transform the condition
8037 Sema::ConditionResult Cond = getDerived().TransformCondition(
8038 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8040 if (Cond.isInvalid())
8041 return StmtError();
8042
8043 // Transform the body
8044 StmtResult Body = getDerived().TransformStmt(S->getBody());
8045 if (Body.isInvalid())
8046 return StmtError();
8047
8048 if (!getDerived().AlwaysRebuild() &&
8049 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8050 Body.get() == S->getBody())
8051 return Owned(S);
8052
8053 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8054 Cond, S->getRParenLoc(), Body.get());
8055}
8056
8057template<typename Derived>
8059TreeTransform<Derived>::TransformDoStmt(DoStmt *S) {
8060 // Transform the body
8061 StmtResult Body = getDerived().TransformStmt(S->getBody());
8062 if (Body.isInvalid())
8063 return StmtError();
8064
8065 // Transform the condition
8066 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8067 if (Cond.isInvalid())
8068 return StmtError();
8069
8070 if (!getDerived().AlwaysRebuild() &&
8071 Cond.get() == S->getCond() &&
8072 Body.get() == S->getBody())
8073 return S;
8074
8075 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8076 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8077 S->getRParenLoc());
8078}
8079
8080template<typename Derived>
8082TreeTransform<Derived>::TransformForStmt(ForStmt *S) {
8083 if (getSema().getLangOpts().OpenMP)
8084 getSema().OpenMP().startOpenMPLoop();
8085
8086 // Transform the initialization statement
8087 StmtResult Init = getDerived().TransformStmt(S->getInit());
8088 if (Init.isInvalid())
8089 return StmtError();
8090
8091 // In OpenMP loop region loop control variable must be captured and be
8092 // private. Perform analysis of first part (if any).
8093 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8094 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8095 Init.get());
8096
8097 // Transform the condition
8098 Sema::ConditionResult Cond = getDerived().TransformCondition(
8099 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8101 if (Cond.isInvalid())
8102 return StmtError();
8103
8104 // Transform the increment
8105 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8106 if (Inc.isInvalid())
8107 return StmtError();
8108
8109 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8110 if (S->getInc() && !FullInc.get())
8111 return StmtError();
8112
8113 // Transform the body
8114 StmtResult Body = getDerived().TransformStmt(S->getBody());
8115 if (Body.isInvalid())
8116 return StmtError();
8117
8118 if (!getDerived().AlwaysRebuild() &&
8119 Init.get() == S->getInit() &&
8120 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8121 Inc.get() == S->getInc() &&
8122 Body.get() == S->getBody())
8123 return S;
8124
8125 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8126 Init.get(), Cond, FullInc,
8127 S->getRParenLoc(), Body.get());
8128}
8129
8130template<typename Derived>
8132TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
8133 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8134 S->getLabel());
8135 if (!LD)
8136 return StmtError();
8137
8138 // Goto statements must always be rebuilt, to resolve the label.
8139 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8140 cast<LabelDecl>(LD));
8141}
8142
8143template<typename Derived>
8145TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
8146 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8147 if (Target.isInvalid())
8148 return StmtError();
8149 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8150
8151 if (!getDerived().AlwaysRebuild() &&
8152 Target.get() == S->getTarget())
8153 return S;
8154
8155 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8156 Target.get());
8157}
8158
8159template<typename Derived>
8161TreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) {
8162 return S;
8163}
8164
8165template<typename Derived>
8167TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) {
8168 return S;
8169}
8170
8171template<typename Derived>
8173TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) {
8174 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8175 /*NotCopyInit*/false);
8176 if (Result.isInvalid())
8177 return StmtError();
8178
8179 // FIXME: We always rebuild the return statement because there is no way
8180 // to tell whether the return type of the function has changed.
8181 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8182}
8183
8184template<typename Derived>
8186TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
8187 bool DeclChanged = false;
8189 for (auto *D : S->decls()) {
8190 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8191 if (!Transformed)
8192 return StmtError();
8193
8194 if (Transformed != D)
8195 DeclChanged = true;
8196
8197 Decls.push_back(Transformed);
8198 }
8199
8200 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8201 return S;
8202
8203 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8204}
8205
8206template<typename Derived>
8208TreeTransform<Derived>::TransformGCCAsmStmt(GCCAsmStmt *S) {
8209
8210 SmallVector<Expr*, 8> Constraints;
8213
8214 ExprResult AsmString;
8215 SmallVector<Expr*, 8> Clobbers;
8216
8217 bool ExprsChanged = false;
8218
8219 // Go through the outputs.
8220 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8221 Names.push_back(S->getOutputIdentifier(I));
8222
8223 // No need to transform the constraint literal.
8224 Constraints.push_back(S->getOutputConstraintLiteral(I));
8225
8226 // Transform the output expr.
8227 Expr *OutputExpr = S->getOutputExpr(I);
8228 ExprResult Result = getDerived().TransformExpr(OutputExpr);
8229 if (Result.isInvalid())
8230 return StmtError();
8231
8232 ExprsChanged |= Result.get() != OutputExpr;
8233
8234 Exprs.push_back(Result.get());
8235 }
8236
8237 // Go through the inputs.
8238 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8239 Names.push_back(S->getInputIdentifier(I));
8240
8241 // No need to transform the constraint literal.
8242 Constraints.push_back(S->getInputConstraintLiteral(I));
8243
8244 // Transform the input expr.
8245 Expr *InputExpr = S->getInputExpr(I);
8246 ExprResult Result = getDerived().TransformExpr(InputExpr);
8247 if (Result.isInvalid())
8248 return StmtError();
8249
8250 ExprsChanged |= Result.get() != InputExpr;
8251
8252 Exprs.push_back(Result.get());
8253 }
8254
8255 // Go through the Labels.
8256 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8257 Names.push_back(S->getLabelIdentifier(I));
8258
8259 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8260 if (Result.isInvalid())
8261 return StmtError();
8262 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8263 Exprs.push_back(Result.get());
8264 }
8265 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8266 return S;
8267
8268 // Go through the clobbers.
8269 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
8270 Clobbers.push_back(S->getClobberStringLiteral(I));
8271
8272 // No need to transform the asm string literal.
8273 AsmString = S->getAsmString();
8274 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8275 S->isVolatile(), S->getNumOutputs(),
8276 S->getNumInputs(), Names.data(),
8277 Constraints, Exprs, AsmString.get(),
8278 Clobbers, S->getNumLabels(),
8279 S->getRParenLoc());
8280}
8281
8282template<typename Derived>
8284TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) {
8285 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8286
8287 bool HadError = false, HadChange = false;
8288
8289 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8290 SmallVector<Expr*, 8> TransformedExprs;
8291 TransformedExprs.reserve(SrcExprs.size());
8292 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8293 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8294 if (!Result.isUsable()) {
8295 HadError = true;
8296 } else {
8297 HadChange |= (Result.get() != SrcExprs[i]);
8298 TransformedExprs.push_back(Result.get());
8299 }
8300 }
8301
8302 if (HadError) return StmtError();
8303 if (!HadChange && !getDerived().AlwaysRebuild())
8304 return Owned(S);
8305
8306 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8307 AsmToks, S->getAsmString(),
8308 S->getNumOutputs(), S->getNumInputs(),
8309 S->getAllConstraints(), S->getClobbers(),
8310 TransformedExprs, S->getEndLoc());
8311}
8312
8313// C++ Coroutines
8314template<typename Derived>
8316TreeTransform<Derived>::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
8317 auto *ScopeInfo = SemaRef.getCurFunction();
8318 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8319 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8320 ScopeInfo->NeedsCoroutineSuspends &&
8321 ScopeInfo->CoroutineSuspends.first == nullptr &&
8322 ScopeInfo->CoroutineSuspends.second == nullptr &&
8323 "expected clean scope info");
8324
8325 // Set that we have (possibly-invalid) suspend points before we do anything
8326 // that may fail.
8327 ScopeInfo->setNeedsCoroutineSuspends(false);
8328
8329 // We re-build the coroutine promise object (and the coroutine parameters its
8330 // type and constructor depend on) based on the types used in our current
8331 // function. We must do so, and set it on the current FunctionScopeInfo,
8332 // before attempting to transform the other parts of the coroutine body
8333 // statement, such as the implicit suspend statements (because those
8334 // statements reference the FunctionScopeInfo::CoroutinePromise).
8335 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8336 return StmtError();
8337 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8338 if (!Promise)
8339 return StmtError();
8340 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8341 ScopeInfo->CoroutinePromise = Promise;
8342
8343 // Transform the implicit coroutine statements constructed using dependent
8344 // types during the previous parse: initial and final suspensions, the return
8345 // object, and others. We also transform the coroutine function's body.
8346 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8347 if (InitSuspend.isInvalid())
8348 return StmtError();
8349 StmtResult FinalSuspend =
8350 getDerived().TransformStmt(S->getFinalSuspendStmt());
8351 if (FinalSuspend.isInvalid() ||
8352 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8353 return StmtError();
8354 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8355 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8356
8357 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8358 if (BodyRes.isInvalid())
8359 return StmtError();
8360
8361 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8362 if (Builder.isInvalid())
8363 return StmtError();
8364
8365 Expr *ReturnObject = S->getReturnValueInit();
8366 assert(ReturnObject && "the return object is expected to be valid");
8367 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8368 /*NoCopyInit*/ false);
8369 if (Res.isInvalid())
8370 return StmtError();
8371 Builder.ReturnValue = Res.get();
8372
8373 // If during the previous parse the coroutine still had a dependent promise
8374 // statement, we may need to build some implicit coroutine statements
8375 // (such as exception and fallthrough handlers) for the first time.
8376 if (S->hasDependentPromiseType()) {
8377 // We can only build these statements, however, if the current promise type
8378 // is not dependent.
8379 if (!Promise->getType()->isDependentType()) {
8380 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8381 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8382 "these nodes should not have been built yet");
8383 if (!Builder.buildDependentStatements())
8384 return StmtError();
8385 }
8386 } else {
8387 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8388 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8389 if (Res.isInvalid())
8390 return StmtError();
8391 Builder.OnFallthrough = Res.get();
8392 }
8393
8394 if (auto *OnException = S->getExceptionHandler()) {
8395 StmtResult Res = getDerived().TransformStmt(OnException);
8396 if (Res.isInvalid())
8397 return StmtError();
8398 Builder.OnException = Res.get();
8399 }
8400
8401 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8402 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8403 if (Res.isInvalid())
8404 return StmtError();
8405 Builder.ReturnStmtOnAllocFailure = Res.get();
8406 }
8407
8408 // Transform any additional statements we may have already built
8409 assert(S->getAllocate() && S->getDeallocate() &&
8410 "allocation and deallocation calls must already be built");
8411 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8412 if (AllocRes.isInvalid())
8413 return StmtError();
8414 Builder.Allocate = AllocRes.get();
8415
8416 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8417 if (DeallocRes.isInvalid())
8418 return StmtError();
8419 Builder.Deallocate = DeallocRes.get();
8420
8421 if (auto *ResultDecl = S->getResultDecl()) {
8422 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8423 if (Res.isInvalid())
8424 return StmtError();
8425 Builder.ResultDecl = Res.get();
8426 }
8427
8428 if (auto *ReturnStmt = S->getReturnStmt()) {
8429 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8430 if (Res.isInvalid())
8431 return StmtError();
8432 Builder.ReturnStmt = Res.get();
8433 }
8434 }
8435
8436 return getDerived().RebuildCoroutineBodyStmt(Builder);
8437}
8438
8439template<typename Derived>
8441TreeTransform<Derived>::TransformCoreturnStmt(CoreturnStmt *S) {
8442 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8443 /*NotCopyInit*/false);
8444 if (Result.isInvalid())
8445 return StmtError();
8446
8447 // Always rebuild; we don't know if this needs to be injected into a new
8448 // context or if the promise type has changed.
8449 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8450 S->isImplicit());
8451}
8452
8453template <typename Derived>
8454ExprResult TreeTransform<Derived>::TransformCoawaitExpr(CoawaitExpr *E) {
8455 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8456 /*NotCopyInit*/ false);
8457 if (Operand.isInvalid())
8458 return ExprError();
8459
8460 // Rebuild the common-expr from the operand rather than transforming it
8461 // separately.
8462
8463 // FIXME: getCurScope() should not be used during template instantiation.
8464 // We should pick up the set of unqualified lookup results for operator
8465 // co_await during the initial parse.
8466 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8467 getSema().getCurScope(), E->getKeywordLoc());
8468
8469 // Always rebuild; we don't know if this needs to be injected into a new
8470 // context or if the promise type has changed.
8471 return getDerived().RebuildCoawaitExpr(
8472 E->getKeywordLoc(), Operand.get(),
8473 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8474}
8475
8476template <typename Derived>
8478TreeTransform<Derived>::TransformDependentCoawaitExpr(DependentCoawaitExpr *E) {
8479 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8480 /*NotCopyInit*/ false);
8481 if (OperandResult.isInvalid())
8482 return ExprError();
8483
8484 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8485 E->getOperatorCoawaitLookup());
8486
8487 if (LookupResult.isInvalid())
8488 return ExprError();
8489
8490 // Always rebuild; we don't know if this needs to be injected into a new
8491 // context or if the promise type has changed.
8492 return getDerived().RebuildDependentCoawaitExpr(
8493 E->getKeywordLoc(), OperandResult.get(),
8494 cast<UnresolvedLookupExpr>(LookupResult.get()));
8495}
8496
8497template<typename Derived>
8499TreeTransform<Derived>::TransformCoyieldExpr(CoyieldExpr *E) {
8500 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
8501 /*NotCopyInit*/false);
8502 if (Result.isInvalid())
8503 return ExprError();
8504
8505 // Always rebuild; we don't know if this needs to be injected into a new
8506 // context or if the promise type has changed.
8507 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
8508}
8509
8510// Objective-C Statements.
8511
8512template<typename Derived>
8514TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
8515 // Transform the body of the @try.
8516 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
8517 if (TryBody.isInvalid())
8518 return StmtError();
8519
8520 // Transform the @catch statements (if present).
8521 bool AnyCatchChanged = false;
8522 SmallVector<Stmt*, 8> CatchStmts;
8523 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
8524 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
8525 if (Catch.isInvalid())
8526 return StmtError();
8527 if (Catch.get() != S->getCatchStmt(I))
8528 AnyCatchChanged = true;
8529 CatchStmts.push_back(Catch.get());
8530 }
8531
8532 // Transform the @finally statement (if present).
8533 StmtResult Finally;
8534 if (S->getFinallyStmt()) {
8535 Finally = getDerived().TransformStmt(S->getFinallyStmt());
8536 if (Finally.isInvalid())
8537 return StmtError();
8538 }
8539
8540 // If nothing changed, just retain this statement.
8541 if (!getDerived().AlwaysRebuild() &&
8542 TryBody.get() == S->getTryBody() &&
8543 !AnyCatchChanged &&
8544 Finally.get() == S->getFinallyStmt())
8545 return S;
8546
8547 // Build a new statement.
8548 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
8549 CatchStmts, Finally.get());
8550}
8551
8552template<typename Derived>
8554TreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) {
8555 // Transform the @catch parameter, if there is one.
8556 VarDecl *Var = nullptr;
8557 if (VarDecl *FromVar = S->getCatchParamDecl()) {
8558 TypeSourceInfo *TSInfo = nullptr;
8559 if (FromVar->getTypeSourceInfo()) {
8560 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
8561 if (!TSInfo)
8562 return StmtError();
8563 }
8564
8565 QualType T;
8566 if (TSInfo)
8567 T = TSInfo->getType();
8568 else {
8569 T = getDerived().TransformType(FromVar->getType());
8570 if (T.isNull())
8571 return StmtError();
8572 }
8573
8574 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
8575 if (!Var)
8576 return StmtError();
8577 }
8578
8579 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
8580 if (Body.isInvalid())
8581 return StmtError();
8582
8583 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
8584 S->getRParenLoc(),
8585 Var, Body.get());
8586}
8587
8588template<typename Derived>
8590TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
8591 // Transform the body.
8592 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
8593 if (Body.isInvalid())
8594 return StmtError();
8595
8596 // If nothing changed, just retain this statement.
8597 if (!getDerived().AlwaysRebuild() &&
8598 Body.get() == S->getFinallyBody())
8599 return S;
8600
8601 // Build a new statement.
8602 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
8603 Body.get());
8604}
8605
8606template<typename Derived>
8608TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) {
8610 if (S->getThrowExpr()) {
8611 Operand = getDerived().TransformExpr(S->getThrowExpr());
8612 if (Operand.isInvalid())
8613 return StmtError();
8614 }
8615
8616 if (!getDerived().AlwaysRebuild() &&
8617 Operand.get() == S->getThrowExpr())
8618 return S;
8619
8620 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
8621}
8622
8623template<typename Derived>
8625TreeTransform<Derived>::TransformObjCAtSynchronizedStmt(
8626 ObjCAtSynchronizedStmt *S) {
8627 // Transform the object we are locking.
8628 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
8629 if (Object.isInvalid())
8630 return StmtError();
8631 Object =
8632 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
8633 Object.get());
8634 if (Object.isInvalid())
8635 return StmtError();
8636
8637 // Transform the body.
8638 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
8639 if (Body.isInvalid())
8640 return StmtError();
8641
8642 // If nothing change, just retain the current statement.
8643 if (!getDerived().AlwaysRebuild() &&
8644 Object.get() == S->getSynchExpr() &&
8645 Body.get() == S->getSynchBody())
8646 return S;
8647
8648 // Build a new statement.
8649 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
8650 Object.get(), Body.get());
8651}
8652
8653template<typename Derived>
8655TreeTransform<Derived>::TransformObjCAutoreleasePoolStmt(
8656 ObjCAutoreleasePoolStmt *S) {
8657 // Transform the body.
8658 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
8659 if (Body.isInvalid())
8660 return StmtError();
8661
8662 // If nothing changed, just retain this statement.
8663 if (!getDerived().AlwaysRebuild() &&
8664 Body.get() == S->getSubStmt())
8665 return S;
8666
8667 // Build a new statement.
8668 return getDerived().RebuildObjCAutoreleasePoolStmt(
8669 S->getAtLoc(), Body.get());
8670}
8671
8672template<typename Derived>
8674TreeTransform<Derived>::TransformObjCForCollectionStmt(
8675 ObjCForCollectionStmt *S) {
8676 // Transform the element statement.
8677 StmtResult Element =
8678 getDerived().TransformStmt(S->getElement(), SDK_NotDiscarded);
8679 if (Element.isInvalid())
8680 return StmtError();
8681
8682 // Transform the collection expression.
8683 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
8684 if (Collection.isInvalid())
8685 return StmtError();
8686
8687 // Transform the body.
8688 StmtResult Body = getDerived().TransformStmt(S->getBody());
8689 if (Body.isInvalid())
8690 return StmtError();
8691
8692 // If nothing changed, just retain this statement.
8693 if (!getDerived().AlwaysRebuild() &&
8694 Element.get() == S->getElement() &&
8695 Collection.get() == S->getCollection() &&
8696 Body.get() == S->getBody())
8697 return S;
8698
8699 // Build a new statement.
8700 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
8701 Element.get(),
8702 Collection.get(),
8703 S->getRParenLoc(),
8704 Body.get());
8705}
8706
8707template <typename Derived>
8708StmtResult TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) {
8709 // Transform the exception declaration, if any.
8710 VarDecl *Var = nullptr;
8711 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
8712 TypeSourceInfo *T =
8713 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
8714 if (!T)
8715 return StmtError();
8716
8717 Var = getDerived().RebuildExceptionDecl(
8718 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
8719 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
8720 if (!Var || Var->isInvalidDecl())
8721 return StmtError();
8722 }
8723
8724 // Transform the actual exception handler.
8725 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
8726 if (Handler.isInvalid())
8727 return StmtError();
8728
8729 if (!getDerived().AlwaysRebuild() && !Var &&
8730 Handler.get() == S->getHandlerBlock())
8731 return S;
8732
8733 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
8734}
8735
8736template <typename Derived>
8737StmtResult TreeTransform<Derived>::TransformCXXTryStmt(CXXTryStmt *S) {
8738 // Transform the try block itself.
8739 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
8740 if (TryBlock.isInvalid())
8741 return StmtError();
8742
8743 // Transform the handlers.
8744 bool HandlerChanged = false;
8745 SmallVector<Stmt *, 8> Handlers;
8746 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
8747 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
8748 if (Handler.isInvalid())
8749 return StmtError();
8750
8751 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
8752 Handlers.push_back(Handler.getAs<Stmt>());
8753 }
8754
8755 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
8756 !HandlerChanged)
8757 return S;
8758
8759 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
8760 Handlers);
8761}
8762
8763template<typename Derived>
8765TreeTransform<Derived>::TransformCXXForRangeStmt(CXXForRangeStmt *S) {
8766 EnterExpressionEvaluationContext ForRangeInitContext(
8768 /*LambdaContextDecl=*/nullptr,
8770 getSema().getLangOpts().CPlusPlus23);
8771
8772 // P2718R0 - Lifetime extension in range-based for loops.
8773 if (getSema().getLangOpts().CPlusPlus23) {
8774 auto &LastRecord = getSema().ExprEvalContexts.back();
8775 LastRecord.InLifetimeExtendingContext = true;
8776 }
8778 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
8779 if (Init.isInvalid())
8780 return StmtError();
8781
8782 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
8783 if (Range.isInvalid())
8784 return StmtError();
8785
8786 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
8787 assert(getSema().getLangOpts().CPlusPlus23 ||
8788 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
8789 auto ForRangeLifetimeExtendTemps =
8790 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
8791
8792 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
8793 if (Begin.isInvalid())
8794 return StmtError();
8795 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
8796 if (End.isInvalid())
8797 return StmtError();
8798
8799 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8800 if (Cond.isInvalid())
8801 return StmtError();
8802 if (Cond.get())
8803 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
8804 if (Cond.isInvalid())
8805 return StmtError();
8806 if (Cond.get())
8807 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
8808
8809 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8810 if (Inc.isInvalid())
8811 return StmtError();
8812 if (Inc.get())
8813 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
8814
8815 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
8816 if (LoopVar.isInvalid())
8817 return StmtError();
8818
8819 StmtResult NewStmt = S;
8820 if (getDerived().AlwaysRebuild() ||
8821 Init.get() != S->getInit() ||
8822 Range.get() != S->getRangeStmt() ||
8823 Begin.get() != S->getBeginStmt() ||
8824 End.get() != S->getEndStmt() ||
8825 Cond.get() != S->getCond() ||
8826 Inc.get() != S->getInc() ||
8827 LoopVar.get() != S->getLoopVarStmt()) {
8828 NewStmt = getDerived().RebuildCXXForRangeStmt(
8829 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
8830 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
8831 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
8832 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
8833 // Might not have attached any initializer to the loop variable.
8834 getSema().ActOnInitializerError(
8835 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
8836 return StmtError();
8837 }
8838 }
8839
8840 StmtResult Body = getDerived().TransformStmt(S->getBody());
8841 if (Body.isInvalid())
8842 return StmtError();
8843
8844 // Body has changed but we didn't rebuild the for-range statement. Rebuild
8845 // it now so we have a new statement to attach the body to.
8846 if (Body.get() != S->getBody() && NewStmt.get() == S) {
8847 NewStmt = getDerived().RebuildCXXForRangeStmt(
8848 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
8849 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
8850 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
8851 if (NewStmt.isInvalid())
8852 return StmtError();
8853 }
8854
8855 if (NewStmt.get() == S)
8856 return S;
8857
8858 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
8859}
8860
8861template<typename Derived>
8863TreeTransform<Derived>::TransformMSDependentExistsStmt(
8864 MSDependentExistsStmt *S) {
8865 // Transform the nested-name-specifier, if any.
8866 NestedNameSpecifierLoc QualifierLoc;
8867 if (S->getQualifierLoc()) {
8868 QualifierLoc
8869 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
8870 if (!QualifierLoc)
8871 return StmtError();
8872 }
8873
8874 // Transform the declaration name.
8875 DeclarationNameInfo NameInfo = S->getNameInfo();
8876 if (NameInfo.getName()) {
8877 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8878 if (!NameInfo.getName())
8879 return StmtError();
8880 }
8881
8882 // Check whether anything changed.
8883 if (!getDerived().AlwaysRebuild() &&
8884 QualifierLoc == S->getQualifierLoc() &&
8885 NameInfo.getName() == S->getNameInfo().getName())
8886 return S;
8887
8888 // Determine whether this name exists, if we can.
8889 CXXScopeSpec SS;
8890 SS.Adopt(QualifierLoc);
8891 bool Dependent = false;
8892 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
8893 case Sema::IER_Exists:
8894 if (S->isIfExists())
8895 break;
8896
8897 return new (getSema().Context) NullStmt(S->getKeywordLoc());
8898
8900 if (S->isIfNotExists())
8901 break;
8902
8903 return new (getSema().Context) NullStmt(S->getKeywordLoc());
8904
8906 Dependent = true;
8907 break;
8908
8909 case Sema::IER_Error:
8910 return StmtError();
8911 }
8912
8913 // We need to continue with the instantiation, so do so now.
8914 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
8915 if (SubStmt.isInvalid())
8916 return StmtError();
8917
8918 // If we have resolved the name, just transform to the substatement.
8919 if (!Dependent)
8920 return SubStmt;
8921
8922 // The name is still dependent, so build a dependent expression again.
8923 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
8924 S->isIfExists(),
8925 QualifierLoc,
8926 NameInfo,
8927 SubStmt.get());
8928}
8929
8930template<typename Derived>
8932TreeTransform<Derived>::TransformMSPropertyRefExpr(MSPropertyRefExpr *E) {
8933 NestedNameSpecifierLoc QualifierLoc;
8934 if (E->getQualifierLoc()) {
8935 QualifierLoc
8936 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
8937 if (!QualifierLoc)
8938 return ExprError();
8939 }
8940
8941 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
8942 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
8943 if (!PD)
8944 return ExprError();
8945
8946 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
8947 if (Base.isInvalid())
8948 return ExprError();
8949
8950 return new (SemaRef.getASTContext())
8951 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
8953 QualifierLoc, E->getMemberLoc());
8954}
8955
8956template <typename Derived>
8957ExprResult TreeTransform<Derived>::TransformMSPropertySubscriptExpr(
8958 MSPropertySubscriptExpr *E) {
8959 auto BaseRes = getDerived().TransformExpr(E->getBase());
8960 if (BaseRes.isInvalid())
8961 return ExprError();
8962 auto IdxRes = getDerived().TransformExpr(E->getIdx());
8963 if (IdxRes.isInvalid())
8964 return ExprError();
8965
8966 if (!getDerived().AlwaysRebuild() &&
8967 BaseRes.get() == E->getBase() &&
8968 IdxRes.get() == E->getIdx())
8969 return E;
8970
8971 return getDerived().RebuildArraySubscriptExpr(
8972 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
8973}
8974
8975template <typename Derived>
8976StmtResult TreeTransform<Derived>::TransformSEHTryStmt(SEHTryStmt *S) {
8977 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
8978 if (TryBlock.isInvalid())
8979 return StmtError();
8980
8981 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
8982 if (Handler.isInvalid())
8983 return StmtError();
8984
8985 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
8986 Handler.get() == S->getHandler())
8987 return S;
8988
8989 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
8990 TryBlock.get(), Handler.get());
8991}
8992
8993template <typename Derived>
8994StmtResult TreeTransform<Derived>::TransformSEHFinallyStmt(SEHFinallyStmt *S) {
8995 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
8996 if (Block.isInvalid())
8997 return StmtError();
8998
8999 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9000}
9001
9002template <typename Derived>
9003StmtResult TreeTransform<Derived>::TransformSEHExceptStmt(SEHExceptStmt *S) {
9004 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9005 if (FilterExpr.isInvalid())
9006 return StmtError();
9007
9008 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9009 if (Block.isInvalid())
9010 return StmtError();
9011
9012 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9013 Block.get());
9014}
9015
9016template <typename Derived>
9018 if (isa<SEHFinallyStmt>(Handler))
9019 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9020 else
9021 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9022}
9023
9024template<typename Derived>
9027 return S;
9028}
9029
9030//===----------------------------------------------------------------------===//
9031// OpenMP directive transformation
9032//===----------------------------------------------------------------------===//
9033
9034template <typename Derived>
9036TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9037 // OMPCanonicalLoops are eliminated during transformation, since they will be
9038 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9039 // after transformation.
9040 return getDerived().TransformStmt(L->getLoopStmt());
9041}
9042
9043template <typename Derived>
9046
9047 // Transform the clauses
9049 ArrayRef<OMPClause *> Clauses = D->clauses();
9050 TClauses.reserve(Clauses.size());
9051 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9052 I != E; ++I) {
9053 if (*I) {
9054 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9055 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9056 getDerived().getSema().OpenMP().EndOpenMPClause();
9057 if (Clause)
9058 TClauses.push_back(Clause);
9059 } else {
9060 TClauses.push_back(nullptr);
9061 }
9062 }
9063 StmtResult AssociatedStmt;
9064 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9065 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9066 D->getDirectiveKind(),
9067 /*CurScope=*/nullptr);
9068 StmtResult Body;
9069 {
9070 Sema::CompoundScopeRAII CompoundScope(getSema());
9071 Stmt *CS;
9072 if (D->getDirectiveKind() == OMPD_atomic ||
9073 D->getDirectiveKind() == OMPD_critical ||
9074 D->getDirectiveKind() == OMPD_section ||
9075 D->getDirectiveKind() == OMPD_master)
9076 CS = D->getAssociatedStmt();
9077 else
9078 CS = D->getRawStmt();
9079 Body = getDerived().TransformStmt(CS);
9080 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9081 getSema().getLangOpts().OpenMPIRBuilder)
9082 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9083 }
9084 AssociatedStmt =
9085 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9086 if (AssociatedStmt.isInvalid()) {
9087 return StmtError();
9088 }
9089 }
9090 if (TClauses.size() != Clauses.size()) {
9091 return StmtError();
9092 }
9093
9094 // Transform directive name for 'omp critical' directive.
9095 DeclarationNameInfo DirName;
9096 if (D->getDirectiveKind() == OMPD_critical) {
9097 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9098 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9099 }
9100 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9101 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9102 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9103 } else if (D->getDirectiveKind() == OMPD_cancel) {
9104 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9105 }
9106
9107 return getDerived().RebuildOMPExecutableDirective(
9108 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9109 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc(),
9110 D->getMappedDirective());
9111}
9112
9113template <typename Derived>
9116 // TODO: Fix This
9117 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9118 << getOpenMPDirectiveName(D->getDirectiveKind());
9119 return StmtError();
9120}
9121
9122template <typename Derived>
9124TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9125 DeclarationNameInfo DirName;
9126 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9127 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9128 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9129 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9130 return Res;
9131}
9132
9133template <typename Derived>
9135TreeTransform<Derived>::TransformOMPSimdDirective(OMPSimdDirective *D) {
9136 DeclarationNameInfo DirName;
9137 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9138 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9139 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9140 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9141 return Res;
9142}
9143
9144template <typename Derived>
9146TreeTransform<Derived>::TransformOMPTileDirective(OMPTileDirective *D) {
9147 DeclarationNameInfo DirName;
9148 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9149 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9150 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9151 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9152 return Res;
9153}
9154
9155template <typename Derived>
9157TreeTransform<Derived>::TransformOMPUnrollDirective(OMPUnrollDirective *D) {
9158 DeclarationNameInfo DirName;
9159 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9160 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9161 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9162 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9163 return Res;
9164}
9165
9166template <typename Derived>
9168TreeTransform<Derived>::TransformOMPForDirective(OMPForDirective *D) {
9169 DeclarationNameInfo DirName;
9170 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9171 OMPD_for, DirName, nullptr, D->getBeginLoc());
9172 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9173 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9174 return Res;
9175}
9176
9177template <typename Derived>
9179TreeTransform<Derived>::TransformOMPForSimdDirective(OMPForSimdDirective *D) {
9180 DeclarationNameInfo DirName;
9181 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9182 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9183 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9184 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9185 return Res;
9186}
9187
9188template <typename Derived>
9190TreeTransform<Derived>::TransformOMPSectionsDirective(OMPSectionsDirective *D) {
9191 DeclarationNameInfo DirName;
9192 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9193 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9194 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9195 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9196 return Res;
9197}
9198
9199template <typename Derived>
9201TreeTransform<Derived>::TransformOMPSectionDirective(OMPSectionDirective *D) {
9202 DeclarationNameInfo DirName;
9203 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9204 OMPD_section, DirName, nullptr, D->getBeginLoc());
9205 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9206 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9207 return Res;
9208}
9209
9210template <typename Derived>
9212TreeTransform<Derived>::TransformOMPScopeDirective(OMPScopeDirective *D) {
9213 DeclarationNameInfo DirName;
9214 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9215 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9216 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9217 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9218 return Res;
9219}
9220
9221template <typename Derived>
9223TreeTransform<Derived>::TransformOMPSingleDirective(OMPSingleDirective *D) {
9224 DeclarationNameInfo DirName;
9225 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9226 OMPD_single, DirName, nullptr, D->getBeginLoc());
9227 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9228 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9229 return Res;
9230}
9231
9232template <typename Derived>
9234TreeTransform<Derived>::TransformOMPMasterDirective(OMPMasterDirective *D) {
9235 DeclarationNameInfo DirName;
9236 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9237 OMPD_master, DirName, nullptr, D->getBeginLoc());
9238 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9239 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9240 return Res;
9241}
9242
9243template <typename Derived>
9245TreeTransform<Derived>::TransformOMPCriticalDirective(OMPCriticalDirective *D) {
9246 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9247 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9248 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9249 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9250 return Res;
9251}
9252
9253template <typename Derived>
9254StmtResult TreeTransform<Derived>::TransformOMPParallelForDirective(
9255 OMPParallelForDirective *D) {
9256 DeclarationNameInfo DirName;
9257 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9258 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9259 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9260 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9261 return Res;
9262}
9263
9264template <typename Derived>
9265StmtResult TreeTransform<Derived>::TransformOMPParallelForSimdDirective(
9266 OMPParallelForSimdDirective *D) {
9267 DeclarationNameInfo DirName;
9268 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9269 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9270 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9271 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9272 return Res;
9273}
9274
9275template <typename Derived>
9276StmtResult TreeTransform<Derived>::TransformOMPParallelMasterDirective(
9277 OMPParallelMasterDirective *D) {
9278 DeclarationNameInfo DirName;
9279 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9280 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9281 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9282 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9283 return Res;
9284}
9285
9286template <typename Derived>
9287StmtResult TreeTransform<Derived>::TransformOMPParallelMaskedDirective(
9288 OMPParallelMaskedDirective *D) {
9289 DeclarationNameInfo DirName;
9290 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9291 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9292 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9293 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9294 return Res;
9295}
9296
9297template <typename Derived>
9298StmtResult TreeTransform<Derived>::TransformOMPParallelSectionsDirective(
9299 OMPParallelSectionsDirective *D) {
9300 DeclarationNameInfo DirName;
9301 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9302 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9303 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9304 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9305 return Res;
9306}
9307
9308template <typename Derived>
9310TreeTransform<Derived>::TransformOMPTaskDirective(OMPTaskDirective *D) {
9311 DeclarationNameInfo DirName;
9312 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9313 OMPD_task, DirName, nullptr, D->getBeginLoc());
9314 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9315 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9316 return Res;
9317}
9318
9319template <typename Derived>
9320StmtResult TreeTransform<Derived>::TransformOMPTaskyieldDirective(
9321 OMPTaskyieldDirective *D) {
9322 DeclarationNameInfo DirName;
9323 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9324 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9325 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9326 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9327 return Res;
9328}
9329
9330template <typename Derived>
9332TreeTransform<Derived>::TransformOMPBarrierDirective(OMPBarrierDirective *D) {
9333 DeclarationNameInfo DirName;
9334 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9335 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9336 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9337 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9338 return Res;
9339}
9340
9341template <typename Derived>
9343TreeTransform<Derived>::TransformOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
9344 DeclarationNameInfo DirName;
9345 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9346 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9347 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9348 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9349 return Res;
9350}
9351
9352template <typename Derived>
9354TreeTransform<Derived>::TransformOMPErrorDirective(OMPErrorDirective *D) {
9355 DeclarationNameInfo DirName;
9356 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9357 OMPD_error, DirName, nullptr, D->getBeginLoc());
9358 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9359 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9360 return Res;
9361}
9362
9363template <typename Derived>
9364StmtResult TreeTransform<Derived>::TransformOMPTaskgroupDirective(
9365 OMPTaskgroupDirective *D) {
9366 DeclarationNameInfo DirName;
9367 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9368 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
9369 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9370 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9371 return Res;
9372}
9373
9374template <typename Derived>
9376TreeTransform<Derived>::TransformOMPFlushDirective(OMPFlushDirective *D) {
9377 DeclarationNameInfo DirName;
9378 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9379 OMPD_flush, DirName, nullptr, D->getBeginLoc());
9380 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9381 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9382 return Res;
9383}
9384
9385template <typename Derived>
9387TreeTransform<Derived>::TransformOMPDepobjDirective(OMPDepobjDirective *D) {
9388 DeclarationNameInfo DirName;
9389 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9390 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
9391 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9392 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9393 return Res;
9394}
9395
9396template <typename Derived>
9398TreeTransform<Derived>::TransformOMPScanDirective(OMPScanDirective *D) {
9399 DeclarationNameInfo DirName;
9400 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9401 OMPD_scan, DirName, nullptr, D->getBeginLoc());
9402 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9403 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9404 return Res;
9405}
9406
9407template <typename Derived>
9409TreeTransform<Derived>::TransformOMPOrderedDirective(OMPOrderedDirective *D) {
9410 DeclarationNameInfo DirName;
9411 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9412 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
9413 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9414 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9415 return Res;
9416}
9417
9418template <typename Derived>
9420TreeTransform<Derived>::TransformOMPAtomicDirective(OMPAtomicDirective *D) {
9421 DeclarationNameInfo DirName;
9422 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9423 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
9424 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9425 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9426 return Res;
9427}
9428
9429template <typename Derived>
9431TreeTransform<Derived>::TransformOMPTargetDirective(OMPTargetDirective *D) {
9432 DeclarationNameInfo DirName;
9433 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9434 OMPD_target, DirName, nullptr, D->getBeginLoc());
9435 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9436 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9437 return Res;
9438}
9439
9440template <typename Derived>
9441StmtResult TreeTransform<Derived>::TransformOMPTargetDataDirective(
9442 OMPTargetDataDirective *D) {
9443 DeclarationNameInfo DirName;
9444 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9445 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
9446 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9447 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9448 return Res;
9449}
9450
9451template <typename Derived>
9452StmtResult TreeTransform<Derived>::TransformOMPTargetEnterDataDirective(
9453 OMPTargetEnterDataDirective *D) {
9454 DeclarationNameInfo DirName;
9455 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9456 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
9457 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9458 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9459 return Res;
9460}
9461
9462template <typename Derived>
9463StmtResult TreeTransform<Derived>::TransformOMPTargetExitDataDirective(
9464 OMPTargetExitDataDirective *D) {
9465 DeclarationNameInfo DirName;
9466 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9467 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
9468 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9469 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9470 return Res;
9471}
9472
9473template <typename Derived>
9474StmtResult TreeTransform<Derived>::TransformOMPTargetParallelDirective(
9475 OMPTargetParallelDirective *D) {
9476 DeclarationNameInfo DirName;
9477 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9478 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
9479 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9480 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9481 return Res;
9482}
9483
9484template <typename Derived>
9485StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForDirective(
9486 OMPTargetParallelForDirective *D) {
9487 DeclarationNameInfo DirName;
9488 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9489 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
9490 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9491 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9492 return Res;
9493}
9494
9495template <typename Derived>
9496StmtResult TreeTransform<Derived>::TransformOMPTargetUpdateDirective(
9497 OMPTargetUpdateDirective *D) {
9498 DeclarationNameInfo DirName;
9499 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9500 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
9501 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9502 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9503 return Res;
9504}
9505
9506template <typename Derived>
9508TreeTransform<Derived>::TransformOMPTeamsDirective(OMPTeamsDirective *D) {
9509 DeclarationNameInfo DirName;
9510 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9511 OMPD_teams, DirName, nullptr, D->getBeginLoc());
9512 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9513 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9514 return Res;
9515}
9516
9517template <typename Derived>
9518StmtResult TreeTransform<Derived>::TransformOMPCancellationPointDirective(
9519 OMPCancellationPointDirective *D) {
9520 DeclarationNameInfo DirName;
9521 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9522 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
9523 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9524 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9525 return Res;
9526}
9527
9528template <typename Derived>
9530TreeTransform<Derived>::TransformOMPCancelDirective(OMPCancelDirective *D) {
9531 DeclarationNameInfo DirName;
9532 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9533 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
9534 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9535 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9536 return Res;
9537}
9538
9539template <typename Derived>
9541TreeTransform<Derived>::TransformOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
9542 DeclarationNameInfo DirName;
9543 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9544 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
9545 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9546 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9547 return Res;
9548}
9549
9550template <typename Derived>
9551StmtResult TreeTransform<Derived>::TransformOMPTaskLoopSimdDirective(
9552 OMPTaskLoopSimdDirective *D) {
9553 DeclarationNameInfo DirName;
9554 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9555 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
9556 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9557 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9558 return Res;
9559}
9560
9561template <typename Derived>
9562StmtResult TreeTransform<Derived>::TransformOMPMasterTaskLoopDirective(
9563 OMPMasterTaskLoopDirective *D) {
9564 DeclarationNameInfo DirName;
9565 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9566 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
9567 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9568 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9569 return Res;
9570}
9571
9572template <typename Derived>
9573StmtResult TreeTransform<Derived>::TransformOMPMaskedTaskLoopDirective(
9574 OMPMaskedTaskLoopDirective *D) {
9575 DeclarationNameInfo DirName;
9576 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9577 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
9578 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9579 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9580 return Res;
9581}
9582
9583template <typename Derived>
9584StmtResult TreeTransform<Derived>::TransformOMPMasterTaskLoopSimdDirective(
9585 OMPMasterTaskLoopSimdDirective *D) {
9586 DeclarationNameInfo DirName;
9587 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9588 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
9589 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9590 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9591 return Res;
9592}
9593
9594template <typename Derived>
9595StmtResult TreeTransform<Derived>::TransformOMPMaskedTaskLoopSimdDirective(
9596 OMPMaskedTaskLoopSimdDirective *D) {
9597 DeclarationNameInfo DirName;
9598 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9599 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
9600 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9601 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9602 return Res;
9603}
9604
9605template <typename Derived>
9606StmtResult TreeTransform<Derived>::TransformOMPParallelMasterTaskLoopDirective(
9607 OMPParallelMasterTaskLoopDirective *D) {
9608 DeclarationNameInfo DirName;
9609 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9610 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
9611 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9612 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9613 return Res;
9614}
9615
9616template <typename Derived>
9617StmtResult TreeTransform<Derived>::TransformOMPParallelMaskedTaskLoopDirective(
9618 OMPParallelMaskedTaskLoopDirective *D) {
9619 DeclarationNameInfo DirName;
9620 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9621 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
9622 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9623 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9624 return Res;
9625}
9626
9627template <typename Derived>
9629TreeTransform<Derived>::TransformOMPParallelMasterTaskLoopSimdDirective(
9630 OMPParallelMasterTaskLoopSimdDirective *D) {
9631 DeclarationNameInfo DirName;
9632 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9633 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
9634 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9635 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9636 return Res;
9637}
9638
9639template <typename Derived>
9641TreeTransform<Derived>::TransformOMPParallelMaskedTaskLoopSimdDirective(
9642 OMPParallelMaskedTaskLoopSimdDirective *D) {
9643 DeclarationNameInfo DirName;
9644 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9645 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
9646 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9647 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9648 return Res;
9649}
9650
9651template <typename Derived>
9652StmtResult TreeTransform<Derived>::TransformOMPDistributeDirective(
9653 OMPDistributeDirective *D) {
9654 DeclarationNameInfo DirName;
9655 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9656 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
9657 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9658 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9659 return Res;
9660}
9661
9662template <typename Derived>
9663StmtResult TreeTransform<Derived>::TransformOMPDistributeParallelForDirective(
9664 OMPDistributeParallelForDirective *D) {
9665 DeclarationNameInfo DirName;
9666 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9667 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
9668 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9669 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9670 return Res;
9671}
9672
9673template <typename Derived>
9675TreeTransform<Derived>::TransformOMPDistributeParallelForSimdDirective(
9676 OMPDistributeParallelForSimdDirective *D) {
9677 DeclarationNameInfo DirName;
9678 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9679 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9680 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9681 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9682 return Res;
9683}
9684
9685template <typename Derived>
9686StmtResult TreeTransform<Derived>::TransformOMPDistributeSimdDirective(
9687 OMPDistributeSimdDirective *D) {
9688 DeclarationNameInfo DirName;
9689 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9690 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
9691 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9692 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9693 return Res;
9694}
9695
9696template <typename Derived>
9697StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForSimdDirective(
9698 OMPTargetParallelForSimdDirective *D) {
9699 DeclarationNameInfo DirName;
9700 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9701 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9702 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9703 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9704 return Res;
9705}
9706
9707template <typename Derived>
9708StmtResult TreeTransform<Derived>::TransformOMPTargetSimdDirective(
9709 OMPTargetSimdDirective *D) {
9710 DeclarationNameInfo DirName;
9711 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9712 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
9713 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9714 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9715 return Res;
9716}
9717
9718template <typename Derived>
9719StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeDirective(
9720 OMPTeamsDistributeDirective *D) {
9721 DeclarationNameInfo DirName;
9722 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9723 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
9724 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9725 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9726 return Res;
9727}
9728
9729template <typename Derived>
9730StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeSimdDirective(
9731 OMPTeamsDistributeSimdDirective *D) {
9732 DeclarationNameInfo DirName;
9733 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9734 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
9735 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9736 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9737 return Res;
9738}
9739
9740template <typename Derived>
9741StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeParallelForSimdDirective(
9742 OMPTeamsDistributeParallelForSimdDirective *D) {
9743 DeclarationNameInfo DirName;
9744 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9745 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
9746 D->getBeginLoc());
9747 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9748 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9749 return Res;
9750}
9751
9752template <typename Derived>
9753StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeParallelForDirective(
9754 OMPTeamsDistributeParallelForDirective *D) {
9755 DeclarationNameInfo DirName;
9756 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9757 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
9758 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9759 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9760 return Res;
9761}
9762
9763template <typename Derived>
9764StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsDirective(
9765 OMPTargetTeamsDirective *D) {
9766 DeclarationNameInfo DirName;
9767 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9768 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
9769 auto Res = getDerived().TransformOMPExecutableDirective(D);
9770 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9771 return Res;
9772}
9773
9774template <typename Derived>
9775StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsDistributeDirective(
9776 OMPTargetTeamsDistributeDirective *D) {
9777 DeclarationNameInfo DirName;
9778 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9779 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
9780 auto Res = getDerived().TransformOMPExecutableDirective(D);
9781 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9782 return Res;
9783}
9784
9785template <typename Derived>
9787TreeTransform<Derived>::TransformOMPTargetTeamsDistributeParallelForDirective(
9788 OMPTargetTeamsDistributeParallelForDirective *D) {
9789 DeclarationNameInfo DirName;
9790 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9791 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
9792 D->getBeginLoc());
9793 auto Res = getDerived().TransformOMPExecutableDirective(D);
9794 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9795 return Res;
9796}
9797
9798template <typename Derived>
9799StmtResult TreeTransform<Derived>::
9800 TransformOMPTargetTeamsDistributeParallelForSimdDirective(
9801 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
9802 DeclarationNameInfo DirName;
9803 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9804 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
9805 D->getBeginLoc());
9806 auto Res = getDerived().TransformOMPExecutableDirective(D);
9807 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9808 return Res;
9809}
9810
9811template <typename Derived>
9813TreeTransform<Derived>::TransformOMPTargetTeamsDistributeSimdDirective(
9814 OMPTargetTeamsDistributeSimdDirective *D) {
9815 DeclarationNameInfo DirName;
9816 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9817 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
9818 auto Res = getDerived().TransformOMPExecutableDirective(D);
9819 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9820 return Res;
9821}
9822
9823template <typename Derived>
9825TreeTransform<Derived>::TransformOMPInteropDirective(OMPInteropDirective *D) {
9826 DeclarationNameInfo DirName;
9827 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9828 OMPD_interop, DirName, nullptr, D->getBeginLoc());
9829 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9830 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9831 return Res;
9832}
9833
9834template <typename Derived>
9836TreeTransform<Derived>::TransformOMPDispatchDirective(OMPDispatchDirective *D) {
9837 DeclarationNameInfo DirName;
9838 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9839 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
9840 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9841 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9842 return Res;
9843}
9844
9845template <typename Derived>
9847TreeTransform<Derived>::TransformOMPMaskedDirective(OMPMaskedDirective *D) {
9848 DeclarationNameInfo DirName;
9849 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9850 OMPD_masked, DirName, nullptr, D->getBeginLoc());
9851 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9852 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9853 return Res;
9854}
9855
9856template <typename Derived>
9857StmtResult TreeTransform<Derived>::TransformOMPGenericLoopDirective(
9858 OMPGenericLoopDirective *D) {
9859 DeclarationNameInfo DirName;
9860 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9861 OMPD_loop, DirName, nullptr, D->getBeginLoc());
9862 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9863 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9864 return Res;
9865}
9866
9867template <typename Derived>
9868StmtResult TreeTransform<Derived>::TransformOMPTeamsGenericLoopDirective(
9869 OMPTeamsGenericLoopDirective *D) {
9870 DeclarationNameInfo DirName;
9871 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9872 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
9873 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9874 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9875 return Res;
9876}
9877
9878template <typename Derived>
9879StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsGenericLoopDirective(
9880 OMPTargetTeamsGenericLoopDirective *D) {
9881 DeclarationNameInfo DirName;
9882 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9883 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
9884 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9885 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9886 return Res;
9887}
9888
9889template <typename Derived>
9890StmtResult TreeTransform<Derived>::TransformOMPParallelGenericLoopDirective(
9891 OMPParallelGenericLoopDirective *D) {
9892 DeclarationNameInfo DirName;
9893 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9894 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
9895 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9896 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9897 return Res;
9898}
9899
9900template <typename Derived>
9902TreeTransform<Derived>::TransformOMPTargetParallelGenericLoopDirective(
9903 OMPTargetParallelGenericLoopDirective *D) {
9904 DeclarationNameInfo DirName;
9905 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9906 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
9907 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9908 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9909 return Res;
9910}
9911
9912//===----------------------------------------------------------------------===//
9913// OpenMP clause transformation
9914//===----------------------------------------------------------------------===//
9915template <typename Derived>
9916OMPClause *TreeTransform<Derived>::TransformOMPIfClause(OMPIfClause *C) {
9917 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
9918 if (Cond.isInvalid())
9919 return nullptr;
9920 return getDerived().RebuildOMPIfClause(
9921 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
9922 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
9923}
9924
9925template <typename Derived>
9926OMPClause *TreeTransform<Derived>::TransformOMPFinalClause(OMPFinalClause *C) {
9927 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
9928 if (Cond.isInvalid())
9929 return nullptr;
9930 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
9931 C->getLParenLoc(), C->getEndLoc());
9932}
9933
9934template <typename Derived>
9935OMPClause *
9936TreeTransform<Derived>::TransformOMPNumThreadsClause(OMPNumThreadsClause *C) {
9937 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
9938 if (NumThreads.isInvalid())
9939 return nullptr;
9940 return getDerived().RebuildOMPNumThreadsClause(
9941 NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9942}
9943
9944template <typename Derived>
9945OMPClause *
9946TreeTransform<Derived>::TransformOMPSafelenClause(OMPSafelenClause *C) {
9947 ExprResult E = getDerived().TransformExpr(C->getSafelen());
9948 if (E.isInvalid())
9949 return nullptr;
9950 return getDerived().RebuildOMPSafelenClause(
9951 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9952}
9953
9954template <typename Derived>
9955OMPClause *
9956TreeTransform<Derived>::TransformOMPAllocatorClause(OMPAllocatorClause *C) {
9957 ExprResult E = getDerived().TransformExpr(C->getAllocator());
9958 if (E.isInvalid())
9959 return nullptr;
9960 return getDerived().RebuildOMPAllocatorClause(
9961 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9962}
9963
9964template <typename Derived>
9965OMPClause *
9966TreeTransform<Derived>::TransformOMPSimdlenClause(OMPSimdlenClause *C) {
9967 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
9968 if (E.isInvalid())
9969 return nullptr;
9970 return getDerived().RebuildOMPSimdlenClause(
9971 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
9972}
9973
9974template <typename Derived>
9975OMPClause *TreeTransform<Derived>::TransformOMPSizesClause(OMPSizesClause *C) {
9976 SmallVector<Expr *, 4> TransformedSizes;
9977 TransformedSizes.reserve(C->getNumSizes());
9978 bool Changed = false;
9979 for (Expr *E : C->getSizesRefs()) {
9980 if (!E) {
9981 TransformedSizes.push_back(nullptr);
9982 continue;
9983 }
9984
9985 ExprResult T = getDerived().TransformExpr(E);
9986 if (T.isInvalid())
9987 return nullptr;
9988 if (E != T.get())
9989 Changed = true;
9990 TransformedSizes.push_back(T.get());
9991 }
9992
9993 if (!Changed && !getDerived().AlwaysRebuild())
9994 return C;
9995 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
9996 C->getLParenLoc(), C->getEndLoc());
9997}
9998
9999template <typename Derived>
10000OMPClause *TreeTransform<Derived>::TransformOMPFullClause(OMPFullClause *C) {
10001 if (!getDerived().AlwaysRebuild())
10002 return C;
10003 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10004}
10005
10006template <typename Derived>
10007OMPClause *
10008TreeTransform<Derived>::TransformOMPPartialClause(OMPPartialClause *C) {
10009 ExprResult T = getDerived().TransformExpr(C->getFactor());
10010 if (T.isInvalid())
10011 return nullptr;
10012 Expr *Factor = T.get();
10013 bool Changed = Factor != C->getFactor();
10014
10015 if (!Changed && !getDerived().AlwaysRebuild())
10016 return C;
10017 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10018 C->getEndLoc());
10019}
10020
10021template <typename Derived>
10022OMPClause *
10023TreeTransform<Derived>::TransformOMPCollapseClause(OMPCollapseClause *C) {
10024 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10025 if (E.isInvalid())
10026 return nullptr;
10027 return getDerived().RebuildOMPCollapseClause(
10028 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10029}
10030
10031template <typename Derived>
10032OMPClause *
10033TreeTransform<Derived>::TransformOMPDefaultClause(OMPDefaultClause *C) {
10034 return getDerived().RebuildOMPDefaultClause(
10035 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getBeginLoc(),
10036 C->getLParenLoc(), C->getEndLoc());
10037}
10038
10039template <typename Derived>
10040OMPClause *
10041TreeTransform<Derived>::TransformOMPProcBindClause(OMPProcBindClause *C) {
10042 return getDerived().RebuildOMPProcBindClause(
10043 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10044 C->getLParenLoc(), C->getEndLoc());
10045}
10046
10047template <typename Derived>
10048OMPClause *
10049TreeTransform<Derived>::TransformOMPScheduleClause(OMPScheduleClause *C) {
10050 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10051 if (E.isInvalid())
10052 return nullptr;
10053 return getDerived().RebuildOMPScheduleClause(
10054 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10055 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10056 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10057 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10058}
10059
10060template <typename Derived>
10061OMPClause *
10062TreeTransform<Derived>::TransformOMPOrderedClause(OMPOrderedClause *C) {
10063 ExprResult E;
10064 if (auto *Num = C->getNumForLoops()) {
10065 E = getDerived().TransformExpr(Num);
10066 if (E.isInvalid())
10067 return nullptr;
10068 }
10069 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10070 C->getLParenLoc(), E.get());
10071}
10072
10073template <typename Derived>
10074OMPClause *
10075TreeTransform<Derived>::TransformOMPDetachClause(OMPDetachClause *C) {
10076 ExprResult E;
10077 if (Expr *Evt = C->getEventHandler()) {
10078 E = getDerived().TransformExpr(Evt);
10079 if (E.isInvalid())
10080 return nullptr;
10081 }
10082 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10083 C->getLParenLoc(), C->getEndLoc());
10084}
10085
10086template <typename Derived>
10087OMPClause *
10088TreeTransform<Derived>::TransformOMPNowaitClause(OMPNowaitClause *C) {
10089 // No need to rebuild this clause, no template-dependent parameters.
10090 return C;
10091}
10092
10093template <typename Derived>
10094OMPClause *
10095TreeTransform<Derived>::TransformOMPUntiedClause(OMPUntiedClause *C) {
10096 // No need to rebuild this clause, no template-dependent parameters.
10097 return C;
10098}
10099
10100template <typename Derived>
10101OMPClause *
10102TreeTransform<Derived>::TransformOMPMergeableClause(OMPMergeableClause *C) {
10103 // No need to rebuild this clause, no template-dependent parameters.
10104 return C;
10105}
10106
10107template <typename Derived>
10108OMPClause *TreeTransform<Derived>::TransformOMPReadClause(OMPReadClause *C) {
10109 // No need to rebuild this clause, no template-dependent parameters.
10110 return C;
10111}
10112
10113template <typename Derived>
10114OMPClause *TreeTransform<Derived>::TransformOMPWriteClause(OMPWriteClause *C) {
10115 // No need to rebuild this clause, no template-dependent parameters.
10116 return C;
10117}
10118
10119template <typename Derived>
10120OMPClause *
10121TreeTransform<Derived>::TransformOMPUpdateClause(OMPUpdateClause *C) {
10122 // No need to rebuild this clause, no template-dependent parameters.
10123 return C;
10124}
10125
10126template <typename Derived>
10127OMPClause *
10128TreeTransform<Derived>::TransformOMPCaptureClause(OMPCaptureClause *C) {
10129 // No need to rebuild this clause, no template-dependent parameters.
10130 return C;
10131}
10132
10133template <typename Derived>
10134OMPClause *
10135TreeTransform<Derived>::TransformOMPCompareClause(OMPCompareClause *C) {
10136 // No need to rebuild this clause, no template-dependent parameters.
10137 return C;
10138}
10139
10140template <typename Derived>
10141OMPClause *TreeTransform<Derived>::TransformOMPFailClause(OMPFailClause *C) {
10142 // No need to rebuild this clause, no template-dependent parameters.
10143 return C;
10144}
10145
10146template <typename Derived>
10147OMPClause *
10148TreeTransform<Derived>::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
10149 // No need to rebuild this clause, no template-dependent parameters.
10150 return C;
10151}
10152
10153template <typename Derived>
10154OMPClause *
10155TreeTransform<Derived>::TransformOMPAcqRelClause(OMPAcqRelClause *C) {
10156 // No need to rebuild this clause, no template-dependent parameters.
10157 return C;
10158}
10159
10160template <typename Derived>
10161OMPClause *
10162TreeTransform<Derived>::TransformOMPAcquireClause(OMPAcquireClause *C) {
10163 // No need to rebuild this clause, no template-dependent parameters.
10164 return C;
10165}
10166
10167template <typename Derived>
10168OMPClause *
10169TreeTransform<Derived>::TransformOMPReleaseClause(OMPReleaseClause *C) {
10170 // No need to rebuild this clause, no template-dependent parameters.
10171 return C;
10172}
10173
10174template <typename Derived>
10175OMPClause *
10176TreeTransform<Derived>::TransformOMPRelaxedClause(OMPRelaxedClause *C) {
10177 // No need to rebuild this clause, no template-dependent parameters.
10178 return C;
10179}
10180
10181template <typename Derived>
10182OMPClause *TreeTransform<Derived>::TransformOMPWeakClause(OMPWeakClause *C) {
10183 // No need to rebuild this clause, no template-dependent parameters.
10184 return C;
10185}
10186
10187template <typename Derived>
10188OMPClause *
10189TreeTransform<Derived>::TransformOMPThreadsClause(OMPThreadsClause *C) {
10190 // No need to rebuild this clause, no template-dependent parameters.
10191 return C;
10192}
10193
10194template <typename Derived>
10195OMPClause *TreeTransform<Derived>::TransformOMPSIMDClause(OMPSIMDClause *C) {
10196 // No need to rebuild this clause, no template-dependent parameters.
10197 return C;
10198}
10199
10200template <typename Derived>
10201OMPClause *
10202TreeTransform<Derived>::TransformOMPNogroupClause(OMPNogroupClause *C) {
10203 // No need to rebuild this clause, no template-dependent parameters.
10204 return C;
10205}
10206
10207template <typename Derived>
10208OMPClause *TreeTransform<Derived>::TransformOMPInitClause(OMPInitClause *C) {
10209 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10210 if (IVR.isInvalid())
10211 return nullptr;
10212
10213 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10214 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10215 for (Expr *E : llvm::drop_begin(C->varlists())) {
10216 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10217 if (ER.isInvalid())
10218 return nullptr;
10219 InteropInfo.PreferTypes.push_back(ER.get());
10220 }
10221 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10222 C->getBeginLoc(), C->getLParenLoc(),
10223 C->getVarLoc(), C->getEndLoc());
10224}
10225
10226template <typename Derived>
10227OMPClause *TreeTransform<Derived>::TransformOMPUseClause(OMPUseClause *C) {
10228 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
10229 if (ER.isInvalid())
10230 return nullptr;
10231 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
10232 C->getLParenLoc(), C->getVarLoc(),
10233 C->getEndLoc());
10234}
10235
10236template <typename Derived>
10237OMPClause *
10238TreeTransform<Derived>::TransformOMPDestroyClause(OMPDestroyClause *C) {
10239 ExprResult ER;
10240 if (Expr *IV = C->getInteropVar()) {
10241 ER = getDerived().TransformExpr(IV);
10242 if (ER.isInvalid())
10243 return nullptr;
10244 }
10245 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
10246 C->getLParenLoc(), C->getVarLoc(),
10247 C->getEndLoc());
10248}
10249
10250template <typename Derived>
10251OMPClause *
10252TreeTransform<Derived>::TransformOMPNovariantsClause(OMPNovariantsClause *C) {
10253 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10254 if (Cond.isInvalid())
10255 return nullptr;
10256 return getDerived().RebuildOMPNovariantsClause(
10257 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10258}
10259
10260template <typename Derived>
10261OMPClause *
10262TreeTransform<Derived>::TransformOMPNocontextClause(OMPNocontextClause *C) {
10263 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10264 if (Cond.isInvalid())
10265 return nullptr;
10266 return getDerived().RebuildOMPNocontextClause(
10267 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10268}
10269
10270template <typename Derived>
10271OMPClause *
10272TreeTransform<Derived>::TransformOMPFilterClause(OMPFilterClause *C) {
10273 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
10274 if (ThreadID.isInvalid())
10275 return nullptr;
10276 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
10277 C->getLParenLoc(), C->getEndLoc());
10278}
10279
10280template <typename Derived>
10281OMPClause *TreeTransform<Derived>::TransformOMPAlignClause(OMPAlignClause *C) {
10282 ExprResult E = getDerived().TransformExpr(C->getAlignment());
10283 if (E.isInvalid())
10284 return nullptr;
10285 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
10286 C->getLParenLoc(), C->getEndLoc());
10287}
10288
10289template <typename Derived>
10290OMPClause *TreeTransform<Derived>::TransformOMPUnifiedAddressClause(
10291 OMPUnifiedAddressClause *C) {
10292 llvm_unreachable("unified_address clause cannot appear in dependent context");
10293}
10294
10295template <typename Derived>
10296OMPClause *TreeTransform<Derived>::TransformOMPUnifiedSharedMemoryClause(
10297 OMPUnifiedSharedMemoryClause *C) {
10298 llvm_unreachable(
10299 "unified_shared_memory clause cannot appear in dependent context");
10300}
10301
10302template <typename Derived>
10303OMPClause *TreeTransform<Derived>::TransformOMPReverseOffloadClause(
10304 OMPReverseOffloadClause *C) {
10305 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
10306}
10307
10308template <typename Derived>
10309OMPClause *TreeTransform<Derived>::TransformOMPDynamicAllocatorsClause(
10310 OMPDynamicAllocatorsClause *C) {
10311 llvm_unreachable(
10312 "dynamic_allocators clause cannot appear in dependent context");
10313}
10314
10315template <typename Derived>
10316OMPClause *TreeTransform<Derived>::TransformOMPAtomicDefaultMemOrderClause(
10317 OMPAtomicDefaultMemOrderClause *C) {
10318 llvm_unreachable(
10319 "atomic_default_mem_order clause cannot appear in dependent context");
10320}
10321
10322template <typename Derived>
10323OMPClause *TreeTransform<Derived>::TransformOMPAtClause(OMPAtClause *C) {
10324 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
10325 C->getBeginLoc(), C->getLParenLoc(),
10326 C->getEndLoc());
10327}
10328
10329template <typename Derived>
10330OMPClause *
10331TreeTransform<Derived>::TransformOMPSeverityClause(OMPSeverityClause *C) {
10332 return getDerived().RebuildOMPSeverityClause(
10333 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
10334 C->getLParenLoc(), C->getEndLoc());
10335}
10336
10337template <typename Derived>
10338OMPClause *
10339TreeTransform<Derived>::TransformOMPMessageClause(OMPMessageClause *C) {
10340 ExprResult E = getDerived().TransformExpr(C->getMessageString());
10341 if (E.isInvalid())
10342 return nullptr;
10343 return getDerived().RebuildOMPMessageClause(
10344 C->getMessageString(), C->getBeginLoc(), C->getLParenLoc(),
10345 C->getEndLoc());
10346}
10347
10348template <typename Derived>
10349OMPClause *
10350TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
10352 Vars.reserve(C->varlist_size());
10353 for (auto *VE : C->varlists()) {
10354 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10355 if (EVar.isInvalid())
10356 return nullptr;
10357 Vars.push_back(EVar.get());
10358 }
10359 return getDerived().RebuildOMPPrivateClause(
10360 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10361}
10362
10363template <typename Derived>
10364OMPClause *TreeTransform<Derived>::TransformOMPFirstprivateClause(
10365 OMPFirstprivateClause *C) {
10367 Vars.reserve(C->varlist_size());
10368 for (auto *VE : C->varlists()) {
10369 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10370 if (EVar.isInvalid())
10371 return nullptr;
10372 Vars.push_back(EVar.get());
10373 }
10374 return getDerived().RebuildOMPFirstprivateClause(
10375 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10376}
10377
10378template <typename Derived>
10379OMPClause *
10380TreeTransform<Derived>::TransformOMPLastprivateClause(OMPLastprivateClause *C) {
10382 Vars.reserve(C->varlist_size());
10383 for (auto *VE : C->varlists()) {
10384 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10385 if (EVar.isInvalid())
10386 return nullptr;
10387 Vars.push_back(EVar.get());
10388 }
10389 return getDerived().RebuildOMPLastprivateClause(
10390 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
10391 C->getLParenLoc(), C->getEndLoc());
10392}
10393
10394template <typename Derived>
10395OMPClause *
10396TreeTransform<Derived>::TransformOMPSharedClause(OMPSharedClause *C) {
10398 Vars.reserve(C->varlist_size());
10399 for (auto *VE : C->varlists()) {
10400 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10401 if (EVar.isInvalid())
10402 return nullptr;
10403 Vars.push_back(EVar.get());
10404 }
10405 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
10406 C->getLParenLoc(), C->getEndLoc());
10407}
10408
10409template <typename Derived>
10410OMPClause *
10411TreeTransform<Derived>::TransformOMPReductionClause(OMPReductionClause *C) {
10413 Vars.reserve(C->varlist_size());
10414 for (auto *VE : C->varlists()) {
10415 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10416 if (EVar.isInvalid())
10417 return nullptr;
10418 Vars.push_back(EVar.get());
10419 }
10420 CXXScopeSpec ReductionIdScopeSpec;
10421 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
10422
10423 DeclarationNameInfo NameInfo = C->getNameInfo();
10424 if (NameInfo.getName()) {
10425 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
10426 if (!NameInfo.getName())
10427 return nullptr;
10428 }
10429 // Build a list of all UDR decls with the same names ranged by the Scopes.
10430 // The Scope boundary is a duplication of the previous decl.
10431 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
10432 for (auto *E : C->reduction_ops()) {
10433 // Transform all the decls.
10434 if (E) {
10435 auto *ULE = cast<UnresolvedLookupExpr>(E);
10436 UnresolvedSet<8> Decls;
10437 for (auto *D : ULE->decls()) {
10438 NamedDecl *InstD =
10439 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
10440 Decls.addDecl(InstD, InstD->getAccess());
10441 }
10442 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
10443 SemaRef.Context, /*NamingClass=*/nullptr,
10444 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
10445 /*ADL=*/true, Decls.begin(), Decls.end(),
10446 /*KnownDependent=*/false));
10447 } else
10448 UnresolvedReductions.push_back(nullptr);
10449 }
10450 return getDerived().RebuildOMPReductionClause(
10451 Vars, C->getModifier(), C->getBeginLoc(), C->getLParenLoc(),
10452 C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
10453 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
10454}
10455
10456template <typename Derived>
10457OMPClause *TreeTransform<Derived>::TransformOMPTaskReductionClause(
10458 OMPTaskReductionClause *C) {
10460 Vars.reserve(C->varlist_size());
10461 for (auto *VE : C->varlists()) {
10462 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10463 if (EVar.isInvalid())
10464 return nullptr;
10465 Vars.push_back(EVar.get());
10466 }
10467 CXXScopeSpec ReductionIdScopeSpec;
10468 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
10469
10470 DeclarationNameInfo NameInfo = C->getNameInfo();
10471 if (NameInfo.getName()) {
10472 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
10473 if (!NameInfo.getName())
10474 return nullptr;
10475 }
10476 // Build a list of all UDR decls with the same names ranged by the Scopes.
10477 // The Scope boundary is a duplication of the previous decl.
10478 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
10479 for (auto *E : C->reduction_ops()) {
10480 // Transform all the decls.
10481 if (E) {
10482 auto *ULE = cast<UnresolvedLookupExpr>(E);
10483 UnresolvedSet<8> Decls;
10484 for (auto *D : ULE->decls()) {
10485 NamedDecl *InstD =
10486 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
10487 Decls.addDecl(InstD, InstD->getAccess());
10488 }
10489 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
10490 SemaRef.Context, /*NamingClass=*/nullptr,
10491 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
10492 /*ADL=*/true, Decls.begin(), Decls.end(),
10493 /*KnownDependent=*/false));
10494 } else
10495 UnresolvedReductions.push_back(nullptr);
10496 }
10497 return getDerived().RebuildOMPTaskReductionClause(
10498 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
10499 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
10500}
10501
10502template <typename Derived>
10503OMPClause *
10504TreeTransform<Derived>::TransformOMPInReductionClause(OMPInReductionClause *C) {
10506 Vars.reserve(C->varlist_size());
10507 for (auto *VE : C->varlists()) {
10508 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10509 if (EVar.isInvalid())
10510 return nullptr;
10511 Vars.push_back(EVar.get());
10512 }
10513 CXXScopeSpec ReductionIdScopeSpec;
10514 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
10515
10516 DeclarationNameInfo NameInfo = C->getNameInfo();
10517 if (NameInfo.getName()) {
10518 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
10519 if (!NameInfo.getName())
10520 return nullptr;
10521 }
10522 // Build a list of all UDR decls with the same names ranged by the Scopes.
10523 // The Scope boundary is a duplication of the previous decl.
10524 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
10525 for (auto *E : C->reduction_ops()) {
10526 // Transform all the decls.
10527 if (E) {
10528 auto *ULE = cast<UnresolvedLookupExpr>(E);
10529 UnresolvedSet<8> Decls;
10530 for (auto *D : ULE->decls()) {
10531 NamedDecl *InstD =
10532 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
10533 Decls.addDecl(InstD, InstD->getAccess());
10534 }
10535 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
10536 SemaRef.Context, /*NamingClass=*/nullptr,
10537 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
10538 /*ADL=*/true, Decls.begin(), Decls.end(),
10539 /*KnownDependent=*/false));
10540 } else
10541 UnresolvedReductions.push_back(nullptr);
10542 }
10543 return getDerived().RebuildOMPInReductionClause(
10544 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
10545 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
10546}
10547
10548template <typename Derived>
10549OMPClause *
10550TreeTransform<Derived>::TransformOMPLinearClause(OMPLinearClause *C) {
10552 Vars.reserve(C->varlist_size());
10553 for (auto *VE : C->varlists()) {
10554 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10555 if (EVar.isInvalid())
10556 return nullptr;
10557 Vars.push_back(EVar.get());
10558 }
10559 ExprResult Step = getDerived().TransformExpr(C->getStep());
10560 if (Step.isInvalid())
10561 return nullptr;
10562 return getDerived().RebuildOMPLinearClause(
10563 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
10564 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
10565 C->getEndLoc());
10566}
10567
10568template <typename Derived>
10569OMPClause *
10570TreeTransform<Derived>::TransformOMPAlignedClause(OMPAlignedClause *C) {
10572 Vars.reserve(C->varlist_size());
10573 for (auto *VE : C->varlists()) {
10574 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10575 if (EVar.isInvalid())
10576 return nullptr;
10577 Vars.push_back(EVar.get());
10578 }
10579 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
10580 if (Alignment.isInvalid())
10581 return nullptr;
10582 return getDerived().RebuildOMPAlignedClause(
10583 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
10584 C->getColonLoc(), C->getEndLoc());
10585}
10586
10587template <typename Derived>
10588OMPClause *
10589TreeTransform<Derived>::TransformOMPCopyinClause(OMPCopyinClause *C) {
10591 Vars.reserve(C->varlist_size());
10592 for (auto *VE : C->varlists()) {
10593 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10594 if (EVar.isInvalid())
10595 return nullptr;
10596 Vars.push_back(EVar.get());
10597 }
10598 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
10599 C->getLParenLoc(), C->getEndLoc());
10600}
10601
10602template <typename Derived>
10603OMPClause *
10604TreeTransform<Derived>::TransformOMPCopyprivateClause(OMPCopyprivateClause *C) {
10606 Vars.reserve(C->varlist_size());
10607 for (auto *VE : C->varlists()) {
10608 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10609 if (EVar.isInvalid())
10610 return nullptr;
10611 Vars.push_back(EVar.get());
10612 }
10613 return getDerived().RebuildOMPCopyprivateClause(
10614 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10615}
10616
10617template <typename Derived>
10618OMPClause *TreeTransform<Derived>::TransformOMPFlushClause(OMPFlushClause *C) {
10620 Vars.reserve(C->varlist_size());
10621 for (auto *VE : C->varlists()) {
10622 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10623 if (EVar.isInvalid())
10624 return nullptr;
10625 Vars.push_back(EVar.get());
10626 }
10627 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
10628 C->getLParenLoc(), C->getEndLoc());
10629}
10630
10631template <typename Derived>
10632OMPClause *
10633TreeTransform<Derived>::TransformOMPDepobjClause(OMPDepobjClause *C) {
10634 ExprResult E = getDerived().TransformExpr(C->getDepobj());
10635 if (E.isInvalid())
10636 return nullptr;
10637 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
10638 C->getLParenLoc(), C->getEndLoc());
10639}
10640
10641template <typename Derived>
10642OMPClause *
10643TreeTransform<Derived>::TransformOMPDependClause(OMPDependClause *C) {
10645 Expr *DepModifier = C->getModifier();
10646 if (DepModifier) {
10647 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
10648 if (DepModRes.isInvalid())
10649 return nullptr;
10650 DepModifier = DepModRes.get();
10651 }
10652 Vars.reserve(C->varlist_size());
10653 for (auto *VE : C->varlists()) {
10654 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10655 if (EVar.isInvalid())
10656 return nullptr;
10657 Vars.push_back(EVar.get());
10658 }
10659 return getDerived().RebuildOMPDependClause(
10660 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
10661 C->getOmpAllMemoryLoc()},
10662 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10663}
10664
10665template <typename Derived>
10666OMPClause *
10667TreeTransform<Derived>::TransformOMPDeviceClause(OMPDeviceClause *C) {
10668 ExprResult E = getDerived().TransformExpr(C->getDevice());
10669 if (E.isInvalid())
10670 return nullptr;
10671 return getDerived().RebuildOMPDeviceClause(
10672 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10673 C->getModifierLoc(), C->getEndLoc());
10674}
10675
10676template <typename Derived, class T>
10679 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
10680 DeclarationNameInfo &MapperIdInfo,
10681 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
10682 // Transform expressions in the list.
10683 Vars.reserve(C->varlist_size());
10684 for (auto *VE : C->varlists()) {
10685 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
10686 if (EVar.isInvalid())
10687 return true;
10688 Vars.push_back(EVar.get());
10689 }
10690 // Transform mapper scope specifier and identifier.
10691 NestedNameSpecifierLoc QualifierLoc;
10692 if (C->getMapperQualifierLoc()) {
10693 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
10694 C->getMapperQualifierLoc());
10695 if (!QualifierLoc)
10696 return true;
10697 }
10698 MapperIdScopeSpec.Adopt(QualifierLoc);
10699 MapperIdInfo = C->getMapperIdInfo();
10700 if (MapperIdInfo.getName()) {
10701 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
10702 if (!MapperIdInfo.getName())
10703 return true;
10704 }
10705 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
10706 // the previous user-defined mapper lookup in dependent environment.
10707 for (auto *E : C->mapperlists()) {
10708 // Transform all the decls.
10709 if (E) {
10710 auto *ULE = cast<UnresolvedLookupExpr>(E);
10711 UnresolvedSet<8> Decls;
10712 for (auto *D : ULE->decls()) {
10713 NamedDecl *InstD =
10714 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
10715 Decls.addDecl(InstD, InstD->getAccess());
10716 }
10717 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
10718 TT.getSema().Context, /*NamingClass=*/nullptr,
10719 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
10720 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
10721 /*KnownDependent=*/false));
10722 } else {
10723 UnresolvedMappers.push_back(nullptr);
10724 }
10725 }
10726 return false;
10727}
10728
10729template <typename Derived>
10730OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
10731 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10733 Expr *IteratorModifier = C->getIteratorModifier();
10734 if (IteratorModifier) {
10735 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
10736 if (MapModRes.isInvalid())
10737 return nullptr;
10738 IteratorModifier = MapModRes.get();
10739 }
10740 CXXScopeSpec MapperIdScopeSpec;
10741 DeclarationNameInfo MapperIdInfo;
10742 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
10743 if (transformOMPMappableExprListClause<Derived, OMPMapClause>(
10744 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
10745 return nullptr;
10746 return getDerived().RebuildOMPMapClause(
10747 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
10748 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
10749 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
10750}
10751
10752template <typename Derived>
10753OMPClause *
10754TreeTransform<Derived>::TransformOMPAllocateClause(OMPAllocateClause *C) {
10755 Expr *Allocator = C->getAllocator();
10756 if (Allocator) {
10757 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
10758 if (AllocatorRes.isInvalid())
10759 return nullptr;
10760 Allocator = AllocatorRes.get();
10761 }
10763 Vars.reserve(C->varlist_size());
10764 for (auto *VE : C->varlists()) {
10765 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10766 if (EVar.isInvalid())
10767 return nullptr;
10768 Vars.push_back(EVar.get());
10769 }
10770 return getDerived().RebuildOMPAllocateClause(
10771 Allocator, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
10772 C->getEndLoc());
10773}
10774
10775template <typename Derived>
10776OMPClause *
10777TreeTransform<Derived>::TransformOMPNumTeamsClause(OMPNumTeamsClause *C) {
10778 ExprResult E = getDerived().TransformExpr(C->getNumTeams());
10779 if (E.isInvalid())
10780 return nullptr;
10781 return getDerived().RebuildOMPNumTeamsClause(
10782 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10783}
10784
10785template <typename Derived>
10786OMPClause *
10787TreeTransform<Derived>::TransformOMPThreadLimitClause(OMPThreadLimitClause *C) {
10788 ExprResult E = getDerived().TransformExpr(C->getThreadLimit());
10789 if (E.isInvalid())
10790 return nullptr;
10791 return getDerived().RebuildOMPThreadLimitClause(
10792 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10793}
10794
10795template <typename Derived>
10796OMPClause *
10797TreeTransform<Derived>::TransformOMPPriorityClause(OMPPriorityClause *C) {
10798 ExprResult E = getDerived().TransformExpr(C->getPriority());
10799 if (E.isInvalid())
10800 return nullptr;
10801 return getDerived().RebuildOMPPriorityClause(
10802 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10803}
10804
10805template <typename Derived>
10806OMPClause *
10807TreeTransform<Derived>::TransformOMPGrainsizeClause(OMPGrainsizeClause *C) {
10808 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
10809 if (E.isInvalid())
10810 return nullptr;
10811 return getDerived().RebuildOMPGrainsizeClause(
10812 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10813 C->getModifierLoc(), C->getEndLoc());
10814}
10815
10816template <typename Derived>
10817OMPClause *
10818TreeTransform<Derived>::TransformOMPNumTasksClause(OMPNumTasksClause *C) {
10819 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
10820 if (E.isInvalid())
10821 return nullptr;
10822 return getDerived().RebuildOMPNumTasksClause(
10823 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10824 C->getModifierLoc(), C->getEndLoc());
10825}
10826
10827template <typename Derived>
10828OMPClause *TreeTransform<Derived>::TransformOMPHintClause(OMPHintClause *C) {
10829 ExprResult E = getDerived().TransformExpr(C->getHint());
10830 if (E.isInvalid())
10831 return nullptr;
10832 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
10833 C->getLParenLoc(), C->getEndLoc());
10834}
10835
10836template <typename Derived>
10837OMPClause *TreeTransform<Derived>::TransformOMPDistScheduleClause(
10838 OMPDistScheduleClause *C) {
10839 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10840 if (E.isInvalid())
10841 return nullptr;
10842 return getDerived().RebuildOMPDistScheduleClause(
10843 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10844 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10845}
10846
10847template <typename Derived>
10848OMPClause *
10849TreeTransform<Derived>::TransformOMPDefaultmapClause(OMPDefaultmapClause *C) {
10850 // Rebuild Defaultmap Clause since we need to invoke the checking of
10851 // defaultmap(none:variable-category) after template initialization.
10852 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
10853 C->getDefaultmapKind(),
10854 C->getBeginLoc(),
10855 C->getLParenLoc(),
10856 C->getDefaultmapModifierLoc(),
10857 C->getDefaultmapKindLoc(),
10858 C->getEndLoc());
10859}
10860
10861template <typename Derived>
10862OMPClause *TreeTransform<Derived>::TransformOMPToClause(OMPToClause *C) {
10863 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10865 CXXScopeSpec MapperIdScopeSpec;
10866 DeclarationNameInfo MapperIdInfo;
10867 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
10868 if (transformOMPMappableExprListClause<Derived, OMPToClause>(
10869 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
10870 return nullptr;
10871 return getDerived().RebuildOMPToClause(
10872 C->getMotionModifiers(), C->getMotionModifiersLoc(), MapperIdScopeSpec,
10873 MapperIdInfo, C->getColonLoc(), Vars, Locs, UnresolvedMappers);
10874}
10875
10876template <typename Derived>
10877OMPClause *TreeTransform<Derived>::TransformOMPFromClause(OMPFromClause *C) {
10878 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10880 CXXScopeSpec MapperIdScopeSpec;
10881 DeclarationNameInfo MapperIdInfo;
10882 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
10883 if (transformOMPMappableExprListClause<Derived, OMPFromClause>(
10884 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
10885 return nullptr;
10886 return getDerived().RebuildOMPFromClause(
10887 C->getMotionModifiers(), C->getMotionModifiersLoc(), MapperIdScopeSpec,
10888 MapperIdInfo, C->getColonLoc(), Vars, Locs, UnresolvedMappers);
10889}
10890
10891template <typename Derived>
10892OMPClause *TreeTransform<Derived>::TransformOMPUseDevicePtrClause(
10893 OMPUseDevicePtrClause *C) {
10895 Vars.reserve(C->varlist_size());
10896 for (auto *VE : C->varlists()) {
10897 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10898 if (EVar.isInvalid())
10899 return nullptr;
10900 Vars.push_back(EVar.get());
10901 }
10902 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10903 return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs);
10904}
10905
10906template <typename Derived>
10907OMPClause *TreeTransform<Derived>::TransformOMPUseDeviceAddrClause(
10908 OMPUseDeviceAddrClause *C) {
10910 Vars.reserve(C->varlist_size());
10911 for (auto *VE : C->varlists()) {
10912 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10913 if (EVar.isInvalid())
10914 return nullptr;
10915 Vars.push_back(EVar.get());
10916 }
10917 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10918 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
10919}
10920
10921template <typename Derived>
10922OMPClause *
10923TreeTransform<Derived>::TransformOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
10925 Vars.reserve(C->varlist_size());
10926 for (auto *VE : C->varlists()) {
10927 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10928 if (EVar.isInvalid())
10929 return nullptr;
10930 Vars.push_back(EVar.get());
10931 }
10932 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10933 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
10934}
10935
10936template <typename Derived>
10937OMPClause *TreeTransform<Derived>::TransformOMPHasDeviceAddrClause(
10938 OMPHasDeviceAddrClause *C) {
10940 Vars.reserve(C->varlist_size());
10941 for (auto *VE : C->varlists()) {
10942 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10943 if (EVar.isInvalid())
10944 return nullptr;
10945 Vars.push_back(EVar.get());
10946 }
10947 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10948 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
10949}
10950
10951template <typename Derived>
10952OMPClause *
10953TreeTransform<Derived>::TransformOMPNontemporalClause(OMPNontemporalClause *C) {
10955 Vars.reserve(C->varlist_size());
10956 for (auto *VE : C->varlists()) {
10957 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10958 if (EVar.isInvalid())
10959 return nullptr;
10960 Vars.push_back(EVar.get());
10961 }
10962 return getDerived().RebuildOMPNontemporalClause(
10963 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10964}
10965
10966template <typename Derived>
10967OMPClause *
10968TreeTransform<Derived>::TransformOMPInclusiveClause(OMPInclusiveClause *C) {
10970 Vars.reserve(C->varlist_size());
10971 for (auto *VE : C->varlists()) {
10972 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10973 if (EVar.isInvalid())
10974 return nullptr;
10975 Vars.push_back(EVar.get());
10976 }
10977 return getDerived().RebuildOMPInclusiveClause(
10978 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10979}
10980
10981template <typename Derived>
10982OMPClause *
10983TreeTransform<Derived>::TransformOMPExclusiveClause(OMPExclusiveClause *C) {
10985 Vars.reserve(C->varlist_size());
10986 for (auto *VE : C->varlists()) {
10987 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10988 if (EVar.isInvalid())
10989 return nullptr;
10990 Vars.push_back(EVar.get());
10991 }
10992 return getDerived().RebuildOMPExclusiveClause(
10993 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10994}
10995
10996template <typename Derived>
10997OMPClause *TreeTransform<Derived>::TransformOMPUsesAllocatorsClause(
10998 OMPUsesAllocatorsClause *C) {
11000 Data.reserve(C->getNumberOfAllocators());
11001 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11002 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11003 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11004 if (Allocator.isInvalid())
11005 continue;
11006 ExprResult AllocatorTraits;
11007 if (Expr *AT = D.AllocatorTraits) {
11008 AllocatorTraits = getDerived().TransformExpr(AT);
11009 if (AllocatorTraits.isInvalid())
11010 continue;
11011 }
11012 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11013 NewD.Allocator = Allocator.get();
11014 NewD.AllocatorTraits = AllocatorTraits.get();
11015 NewD.LParenLoc = D.LParenLoc;
11016 NewD.RParenLoc = D.RParenLoc;
11017 }
11018 return getDerived().RebuildOMPUsesAllocatorsClause(
11019 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11020}
11021
11022template <typename Derived>
11023OMPClause *
11024TreeTransform<Derived>::TransformOMPAffinityClause(OMPAffinityClause *C) {
11025 SmallVector<Expr *, 4> Locators;
11026 Locators.reserve(C->varlist_size());
11027 ExprResult ModifierRes;
11028 if (Expr *Modifier = C->getModifier()) {
11029 ModifierRes = getDerived().TransformExpr(Modifier);
11030 if (ModifierRes.isInvalid())
11031 return nullptr;
11032 }
11033 for (Expr *E : C->varlists()) {
11034 ExprResult Locator = getDerived().TransformExpr(E);
11035 if (Locator.isInvalid())
11036 continue;
11037 Locators.push_back(Locator.get());
11038 }
11039 return getDerived().RebuildOMPAffinityClause(
11040 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11041 ModifierRes.get(), Locators);
11042}
11043
11044template <typename Derived>
11045OMPClause *TreeTransform<Derived>::TransformOMPOrderClause(OMPOrderClause *C) {
11046 return getDerived().RebuildOMPOrderClause(
11047 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11048 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11049}
11050
11051template <typename Derived>
11052OMPClause *TreeTransform<Derived>::TransformOMPBindClause(OMPBindClause *C) {
11053 return getDerived().RebuildOMPBindClause(
11054 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11055 C->getLParenLoc(), C->getEndLoc());
11056}
11057
11058template <typename Derived>
11059OMPClause *TreeTransform<Derived>::TransformOMPXDynCGroupMemClause(
11060 OMPXDynCGroupMemClause *C) {
11061 ExprResult Size = getDerived().TransformExpr(C->getSize());
11062 if (Size.isInvalid())
11063 return nullptr;
11064 return getDerived().RebuildOMPXDynCGroupMemClause(
11065 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11066}
11067
11068template <typename Derived>
11069OMPClause *
11070TreeTransform<Derived>::TransformOMPDoacrossClause(OMPDoacrossClause *C) {
11072 Vars.reserve(C->varlist_size());
11073 for (auto *VE : C->varlists()) {
11074 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11075 if (EVar.isInvalid())
11076 return nullptr;
11077 Vars.push_back(EVar.get());
11078 }
11079 return getDerived().RebuildOMPDoacrossClause(
11080 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11081 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11082}
11083
11084template <typename Derived>
11085OMPClause *
11086TreeTransform<Derived>::TransformOMPXAttributeClause(OMPXAttributeClause *C) {
11088 for (auto *A : C->getAttrs())
11089 NewAttrs.push_back(getDerived().TransformAttr(A));
11090 return getDerived().RebuildOMPXAttributeClause(
11091 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11092}
11093
11094template <typename Derived>
11095OMPClause *TreeTransform<Derived>::TransformOMPXBareClause(OMPXBareClause *C) {
11096 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11097}
11098
11099//===----------------------------------------------------------------------===//
11100// OpenACC transformation
11101//===----------------------------------------------------------------------===//
11102namespace {
11103template <typename Derived>
11104class OpenACCClauseTransform final
11105 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11106 TreeTransform<Derived> &Self;
11107 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11108 OpenACCClause *NewClause = nullptr;
11109
11110public:
11111 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11112 SemaOpenACC::OpenACCParsedClause &PC)
11113 : Self(Self), ParsedClause(PC) {}
11114
11115 OpenACCClause *CreatedClause() const { return NewClause; }
11116
11117#define VISIT_CLAUSE(CLAUSE_NAME) \
11118 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11119#include "clang/Basic/OpenACCClauses.def"
11120};
11121
11122template <typename Derived>
11123void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11124 const OpenACCDefaultClause &C) {
11125 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11126
11127 NewClause = OpenACCDefaultClause::Create(
11128 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11129 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11130 ParsedClause.getEndLoc());
11131}
11132
11133template <typename Derived>
11134void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
11135 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11136 assert(Cond && "If constructed with invalid Condition");
11137 Sema::ConditionResult Res = Self.TransformCondition(
11138 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
11139
11140 if (Res.isInvalid() || !Res.get().second)
11141 return;
11142
11143 ParsedClause.setConditionDetails(Res.get().second);
11144
11145 NewClause = OpenACCIfClause::Create(
11146 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11147 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11148 ParsedClause.getEndLoc());
11149}
11150
11151template <typename Derived>
11152void OpenACCClauseTransform<Derived>::VisitSelfClause(
11153 const OpenACCSelfClause &C) {
11154
11155 if (C.hasConditionExpr()) {
11156 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11157 Sema::ConditionResult Res =
11158 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
11160
11161 if (Res.isInvalid() || !Res.get().second)
11162 return;
11163
11164 ParsedClause.setConditionDetails(Res.get().second);
11165 }
11166
11167 NewClause = OpenACCSelfClause::Create(
11168 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11169 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11170 ParsedClause.getEndLoc());
11171}
11172
11173template <typename Derived>
11174void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
11175 const OpenACCNumGangsClause &C) {
11176 llvm::SmallVector<Expr *> InstantiatedIntExprs;
11177
11178 for (Expr *CurIntExpr : C.getIntExprs()) {
11179 ExprResult Res = Self.TransformExpr(CurIntExpr);
11180
11181 if (!Res.isUsable())
11182 return;
11183
11184 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11185 C.getClauseKind(),
11186 C.getBeginLoc(), Res.get());
11187 if (!Res.isUsable())
11188 return;
11189
11190 InstantiatedIntExprs.push_back(Res.get());
11191 }
11192
11193 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
11195 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11196 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
11197 ParsedClause.getEndLoc());
11198}
11199template <typename Derived>
11200void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
11201 const OpenACCNumWorkersClause &C) {
11202 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
11203 assert(IntExpr && "num_workers clause constructed with invalid int expr");
11204
11205 ExprResult Res = Self.TransformExpr(IntExpr);
11206 if (!Res.isUsable())
11207 return;
11208
11209 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11210 C.getClauseKind(),
11211 C.getBeginLoc(), Res.get());
11212 if (!Res.isUsable())
11213 return;
11214
11215 ParsedClause.setIntExprDetails(Res.get());
11217 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11218 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
11219 ParsedClause.getEndLoc());
11220}
11221
11222template <typename Derived>
11223void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
11224 const OpenACCVectorLengthClause &C) {
11225 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
11226 assert(IntExpr && "vector_length clause constructed with invalid int expr");
11227
11228 ExprResult Res = Self.TransformExpr(IntExpr);
11229 if (!Res.isUsable())
11230 return;
11231
11232 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11233 C.getClauseKind(),
11234 C.getBeginLoc(), Res.get());
11235 if (!Res.isUsable())
11236 return;
11237
11238 ParsedClause.setIntExprDetails(Res.get());
11240 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11241 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
11242 ParsedClause.getEndLoc());
11243}
11244} // namespace
11245template <typename Derived>
11246OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
11247 ArrayRef<const OpenACCClause *> ExistingClauses,
11248 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
11249
11250 SemaOpenACC::OpenACCParsedClause ParsedClause(
11251 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
11252 ParsedClause.setEndLoc(OldClause->getEndLoc());
11253
11254 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
11255 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
11256
11257 OpenACCClauseTransform<Derived> Transform{*this, ParsedClause};
11258 Transform.Visit(OldClause);
11259
11260 return Transform.CreatedClause();
11261}
11262
11263template <typename Derived>
11265TreeTransform<Derived>::TransformOpenACCClauseList(
11267 llvm::SmallVector<OpenACCClause *> TransformedClauses;
11268 for (const auto *Clause : OldClauses) {
11269 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
11270 TransformedClauses, DirKind, Clause))
11271 TransformedClauses.push_back(TransformedClause);
11272 }
11273 return TransformedClauses;
11274}
11275
11276template <typename Derived>
11277StmtResult TreeTransform<Derived>::TransformOpenACCComputeConstruct(
11278 OpenACCComputeConstruct *C) {
11279 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
11280 // FIXME: When implementing this for constructs that can take arguments, we
11281 // should do Sema for them here.
11282
11283 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
11284 C->getBeginLoc()))
11285 return StmtError();
11286
11287 llvm::SmallVector<OpenACCClause *> TransformedClauses =
11288 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
11289 C->clauses());
11290
11291 // Transform Structured Block.
11292 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
11293 StrBlock =
11294 getSema().OpenACC().ActOnAssociatedStmt(C->getDirectiveKind(), StrBlock);
11295
11296 return getDerived().RebuildOpenACCComputeConstruct(
11297 C->getDirectiveKind(), C->getBeginLoc(), C->getEndLoc(),
11298 TransformedClauses, StrBlock);
11299}
11300
11301//===----------------------------------------------------------------------===//
11302// Expression transformation
11303//===----------------------------------------------------------------------===//
11304template<typename Derived>
11306TreeTransform<Derived>::TransformConstantExpr(ConstantExpr *E) {
11307 return TransformExpr(E->getSubExpr());
11308}
11309
11310template <typename Derived>
11311ExprResult TreeTransform<Derived>::TransformSYCLUniqueStableNameExpr(
11312 SYCLUniqueStableNameExpr *E) {
11313 if (!E->isTypeDependent())
11314 return E;
11315
11316 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
11317
11318 if (!NewT)
11319 return ExprError();
11320
11321 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
11322 return E;
11323
11324 return getDerived().RebuildSYCLUniqueStableNameExpr(
11325 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
11326}
11327
11328template<typename Derived>
11330TreeTransform<Derived>::TransformPredefinedExpr(PredefinedExpr *E) {
11331 if (!E->isTypeDependent())
11332 return E;
11333
11334 return getDerived().RebuildPredefinedExpr(E->getLocation(),
11335 E->getIdentKind());
11336}
11337
11338template<typename Derived>
11340TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
11341 NestedNameSpecifierLoc QualifierLoc;
11342 if (E->getQualifierLoc()) {
11343 QualifierLoc
11344 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
11345 if (!QualifierLoc)
11346 return ExprError();
11347 }
11348
11349 ValueDecl *ND
11350 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
11351 E->getDecl()));
11352 if (!ND)
11353 return ExprError();
11354
11355 NamedDecl *Found = ND;
11356 if (E->getFoundDecl() != E->getDecl()) {
11357 Found = cast_or_null<NamedDecl>(
11358 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
11359 if (!Found)
11360 return ExprError();
11361 }
11362
11363 DeclarationNameInfo NameInfo = E->getNameInfo();
11364 if (NameInfo.getName()) {
11365 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11366 if (!NameInfo.getName())
11367 return ExprError();
11368 }
11369
11370 if (!getDerived().AlwaysRebuild() &&
11371 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
11372 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
11373 Found == E->getFoundDecl() &&
11374 NameInfo.getName() == E->getDecl()->getDeclName() &&
11375 !E->hasExplicitTemplateArgs()) {
11376
11377 // Mark it referenced in the new context regardless.
11378 // FIXME: this is a bit instantiation-specific.
11379 SemaRef.MarkDeclRefReferenced(E);
11380
11381 return E;
11382 }
11383
11384 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
11385 if (E->hasExplicitTemplateArgs()) {
11386 TemplateArgs = &TransArgs;
11387 TransArgs.setLAngleLoc(E->getLAngleLoc());
11388 TransArgs.setRAngleLoc(E->getRAngleLoc());
11389 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
11390 E->getNumTemplateArgs(),
11391 TransArgs))
11392 return ExprError();
11393 }
11394
11395 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
11396 Found, TemplateArgs);
11397}
11398
11399template<typename Derived>
11401TreeTransform<Derived>::TransformIntegerLiteral(IntegerLiteral *E) {
11402 return E;
11403}
11404
11405template <typename Derived>
11406ExprResult TreeTransform<Derived>::TransformFixedPointLiteral(
11407 FixedPointLiteral *E) {
11408 return E;
11409}
11410
11411template<typename Derived>
11413TreeTransform<Derived>::TransformFloatingLiteral(FloatingLiteral *E) {
11414 return E;
11415}
11416
11417template<typename Derived>
11419TreeTransform<Derived>::TransformImaginaryLiteral(ImaginaryLiteral *E) {
11420 return E;
11421}
11422
11423template<typename Derived>
11425TreeTransform<Derived>::TransformStringLiteral(StringLiteral *E) {
11426 return E;
11427}
11428
11429template<typename Derived>
11431TreeTransform<Derived>::TransformCharacterLiteral(CharacterLiteral *E) {
11432 return E;
11433}
11434
11435template<typename Derived>
11437TreeTransform<Derived>::TransformUserDefinedLiteral(UserDefinedLiteral *E) {
11438 return getDerived().TransformCallExpr(E);
11439}
11440
11441template<typename Derived>
11443TreeTransform<Derived>::TransformGenericSelectionExpr(GenericSelectionExpr *E) {
11444 ExprResult ControllingExpr;
11445 TypeSourceInfo *ControllingType = nullptr;
11446 if (E->isExprPredicate())
11447 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
11448 else
11449 ControllingType = getDerived().TransformType(E->getControllingType());
11450
11451 if (ControllingExpr.isInvalid() && !ControllingType)
11452 return ExprError();
11453
11454 SmallVector<Expr *, 4> AssocExprs;
11456 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
11457 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
11458 if (TSI) {
11459 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
11460 if (!AssocType)
11461 return ExprError();
11462 AssocTypes.push_back(AssocType);
11463 } else {
11464 AssocTypes.push_back(nullptr);
11465 }
11466
11467 ExprResult AssocExpr =
11468 getDerived().TransformExpr(Assoc.getAssociationExpr());
11469 if (AssocExpr.isInvalid())
11470 return ExprError();
11471 AssocExprs.push_back(AssocExpr.get());
11472 }
11473
11474 if (!ControllingType)
11475 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
11476 E->getDefaultLoc(),
11477 E->getRParenLoc(),
11478 ControllingExpr.get(),
11479 AssocTypes,
11480 AssocExprs);
11481 return getDerived().RebuildGenericSelectionExpr(
11482 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
11483 ControllingType, AssocTypes, AssocExprs);
11484}
11485
11486template<typename Derived>
11488TreeTransform<Derived>::TransformParenExpr(ParenExpr *E) {
11489 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
11490 if (SubExpr.isInvalid())
11491 return ExprError();
11492
11493 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
11494 return E;
11495
11496 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
11497 E->getRParen());
11498}
11499
11500/// The operand of a unary address-of operator has special rules: it's
11501/// allowed to refer to a non-static member of a class even if there's no 'this'
11502/// object available.
11503template<typename Derived>
11506 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
11507 return getDerived().TransformDependentScopeDeclRefExpr(
11508 DRE, /*IsAddressOfOperand=*/true, nullptr);
11509 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
11510 return getDerived().TransformUnresolvedLookupExpr(
11511 ULE, /*IsAddressOfOperand=*/true);
11512 else
11513 return getDerived().TransformExpr(E);
11514}
11515
11516template<typename Derived>
11519 ExprResult SubExpr;
11520 if (E->getOpcode() == UO_AddrOf)
11521 SubExpr = TransformAddressOfOperand(E->getSubExpr());
11522 else
11523 SubExpr = TransformExpr(E->getSubExpr());
11524 if (SubExpr.isInvalid())
11525 return ExprError();
11526
11527 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
11528 return E;
11529
11530 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
11531 E->getOpcode(),
11532 SubExpr.get());
11533}
11534
11535template<typename Derived>
11537TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
11538 // Transform the type.
11539 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
11540 if (!Type)
11541 return ExprError();
11542
11543 // Transform all of the components into components similar to what the
11544 // parser uses.
11545 // FIXME: It would be slightly more efficient in the non-dependent case to
11546 // just map FieldDecls, rather than requiring the rebuilder to look for
11547 // the fields again. However, __builtin_offsetof is rare enough in
11548 // template code that we don't care.
11549 bool ExprChanged = false;
11550 typedef Sema::OffsetOfComponent Component;
11551 SmallVector<Component, 4> Components;
11552 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
11553 const OffsetOfNode &ON = E->getComponent(I);
11554 Component Comp;
11555 Comp.isBrackets = true;
11556 Comp.LocStart = ON.getSourceRange().getBegin();
11557 Comp.LocEnd = ON.getSourceRange().getEnd();
11558 switch (ON.getKind()) {
11559 case OffsetOfNode::Array: {
11560 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
11561 ExprResult Index = getDerived().TransformExpr(FromIndex);
11562 if (Index.isInvalid())
11563 return ExprError();
11564
11565 ExprChanged = ExprChanged || Index.get() != FromIndex;
11566 Comp.isBrackets = true;
11567 Comp.U.E = Index.get();
11568 break;
11569 }
11570
11573 Comp.isBrackets = false;
11574 Comp.U.IdentInfo = ON.getFieldName();
11575 if (!Comp.U.IdentInfo)
11576 continue;
11577
11578 break;
11579
11580 case OffsetOfNode::Base:
11581 // Will be recomputed during the rebuild.
11582 continue;
11583 }
11584
11585 Components.push_back(Comp);
11586 }
11587
11588 // If nothing changed, retain the existing expression.
11589 if (!getDerived().AlwaysRebuild() &&
11590 Type == E->getTypeSourceInfo() &&
11591 !ExprChanged)
11592 return E;
11593
11594 // Build a new offsetof expression.
11595 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
11596 Components, E->getRParenLoc());
11597}
11598
11599template<typename Derived>
11601TreeTransform<Derived>::TransformOpaqueValueExpr(OpaqueValueExpr *E) {
11602 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
11603 "opaque value expression requires transformation");
11604 return E;
11605}
11606
11607template<typename Derived>
11609TreeTransform<Derived>::TransformTypoExpr(TypoExpr *E) {
11610 return E;
11611}
11612
11613template <typename Derived>
11614ExprResult TreeTransform<Derived>::TransformRecoveryExpr(RecoveryExpr *E) {
11616 bool Changed = false;
11617 for (Expr *C : E->subExpressions()) {
11618 ExprResult NewC = getDerived().TransformExpr(C);
11619 if (NewC.isInvalid())
11620 return ExprError();
11621 Children.push_back(NewC.get());
11622
11623 Changed |= NewC.get() != C;
11624 }
11625 if (!getDerived().AlwaysRebuild() && !Changed)
11626 return E;
11627 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
11628 Children, E->getType());
11629}
11630
11631template<typename Derived>
11633TreeTransform<Derived>::TransformPseudoObjectExpr(PseudoObjectExpr *E) {
11634 // Rebuild the syntactic form. The original syntactic form has
11635 // opaque-value expressions in it, so strip those away and rebuild
11636 // the result. This is a really awful way of doing this, but the
11637 // better solution (rebuilding the semantic expressions and
11638 // rebinding OVEs as necessary) doesn't work; we'd need
11639 // TreeTransform to not strip away implicit conversions.
11640 Expr *newSyntacticForm = SemaRef.recreateSyntacticForm(E);
11641 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
11642 if (result.isInvalid()) return ExprError();
11643
11644 // If that gives us a pseudo-object result back, the pseudo-object
11645 // expression must have been an lvalue-to-rvalue conversion which we
11646 // should reapply.
11647 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
11648 result = SemaRef.checkPseudoObjectRValue(result.get());
11649
11650 return result;
11651}
11652
11653template<typename Derived>
11655TreeTransform<Derived>::TransformUnaryExprOrTypeTraitExpr(
11656 UnaryExprOrTypeTraitExpr *E) {
11657 if (E->isArgumentType()) {
11658 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
11659
11660 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
11661 if (!NewT)
11662 return ExprError();
11663
11664 if (!getDerived().AlwaysRebuild() && OldT == NewT)
11665 return E;
11666
11667 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
11668 E->getKind(),
11669 E->getSourceRange());
11670 }
11671
11672 // C++0x [expr.sizeof]p1:
11673 // The operand is either an expression, which is an unevaluated operand
11674 // [...]
11675 EnterExpressionEvaluationContext Unevaluated(
11678
11679 // Try to recover if we have something like sizeof(T::X) where X is a type.
11680 // Notably, there must be *exactly* one set of parens if X is a type.
11681 TypeSourceInfo *RecoveryTSI = nullptr;
11682 ExprResult SubExpr;
11683 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
11684 if (auto *DRE =
11685 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
11686 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
11687 PE, DRE, false, &RecoveryTSI);
11688 else
11689 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
11690
11691 if (RecoveryTSI) {
11692 return getDerived().RebuildUnaryExprOrTypeTrait(
11693 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
11694 } else if (SubExpr.isInvalid())
11695 return ExprError();
11696
11697 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
11698 return E;
11699
11700 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
11701 E->getOperatorLoc(),
11702 E->getKind(),
11703 E->getSourceRange());
11704}
11705
11706template<typename Derived>
11708TreeTransform<Derived>::TransformArraySubscriptExpr(ArraySubscriptExpr *E) {
11709 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
11710 if (LHS.isInvalid())
11711 return ExprError();
11712
11713 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
11714 if (RHS.isInvalid())
11715 return ExprError();
11716
11717
11718 if (!getDerived().AlwaysRebuild() &&
11719 LHS.get() == E->getLHS() &&
11720 RHS.get() == E->getRHS())
11721 return E;
11722
11723 return getDerived().RebuildArraySubscriptExpr(
11724 LHS.get(),
11725 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
11726}
11727
11728template <typename Derived>
11730TreeTransform<Derived>::TransformMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
11731 ExprResult Base = getDerived().TransformExpr(E->getBase());
11732 if (Base.isInvalid())
11733 return ExprError();
11734
11735 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
11736 if (RowIdx.isInvalid())
11737 return ExprError();
11738
11739 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
11740 if (ColumnIdx.isInvalid())
11741 return ExprError();
11742
11743 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
11744 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
11745 return E;
11746
11747 return getDerived().RebuildMatrixSubscriptExpr(
11748 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
11749}
11750
11751template <typename Derived>
11753TreeTransform<Derived>::TransformArraySectionExpr(ArraySectionExpr *E) {
11754 ExprResult Base = getDerived().TransformExpr(E->getBase());
11755 if (Base.isInvalid())
11756 return ExprError();
11757
11758 ExprResult LowerBound;
11759 if (E->getLowerBound()) {
11760 LowerBound = getDerived().TransformExpr(E->getLowerBound());
11761 if (LowerBound.isInvalid())
11762 return ExprError();
11763 }
11764
11765 ExprResult Length;
11766 if (E->getLength()) {
11767 Length = getDerived().TransformExpr(E->getLength());
11768 if (Length.isInvalid())
11769 return ExprError();
11770 }
11771
11772 ExprResult Stride;
11773 if (E->isOMPArraySection()) {
11774 if (Expr *Str = E->getStride()) {
11775 Stride = getDerived().TransformExpr(Str);
11776 if (Stride.isInvalid())
11777 return ExprError();
11778 }
11779 }
11780
11781 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
11782 LowerBound.get() == E->getLowerBound() &&
11783 Length.get() == E->getLength() &&
11784 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
11785 return E;
11786
11787 return getDerived().RebuildArraySectionExpr(
11788 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
11789 LowerBound.get(), E->getColonLocFirst(),
11790 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
11791 Length.get(), Stride.get(), E->getRBracketLoc());
11792}
11793
11794template <typename Derived>
11796TreeTransform<Derived>::TransformOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
11797 ExprResult Base = getDerived().TransformExpr(E->getBase());
11798 if (Base.isInvalid())
11799 return ExprError();
11800
11802 bool ErrorFound = false;
11803 for (Expr *Dim : E->getDimensions()) {
11804 ExprResult DimRes = getDerived().TransformExpr(Dim);
11805 if (DimRes.isInvalid()) {
11806 ErrorFound = true;
11807 continue;
11808 }
11809 Dims.push_back(DimRes.get());
11810 }
11811
11812 if (ErrorFound)
11813 return ExprError();
11814 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
11815 E->getRParenLoc(), Dims,
11816 E->getBracketsRanges());
11817}
11818
11819template <typename Derived>
11821TreeTransform<Derived>::TransformOMPIteratorExpr(OMPIteratorExpr *E) {
11822 unsigned NumIterators = E->numOfIterators();
11824
11825 bool ErrorFound = false;
11826 bool NeedToRebuild = getDerived().AlwaysRebuild();
11827 for (unsigned I = 0; I < NumIterators; ++I) {
11828 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
11829 Data[I].DeclIdent = D->getIdentifier();
11830 Data[I].DeclIdentLoc = D->getLocation();
11831 if (D->getLocation() == D->getBeginLoc()) {
11832 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
11833 "Implicit type must be int.");
11834 } else {
11835 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
11836 QualType DeclTy = getDerived().TransformType(D->getType());
11837 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
11838 }
11839 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
11840 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
11841 ExprResult End = getDerived().TransformExpr(Range.End);
11842 ExprResult Step = getDerived().TransformExpr(Range.Step);
11843 ErrorFound = ErrorFound ||
11844 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
11845 !Data[I].Type.get().isNull())) ||
11846 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
11847 if (ErrorFound)
11848 continue;
11849 Data[I].Range.Begin = Begin.get();
11850 Data[I].Range.End = End.get();
11851 Data[I].Range.Step = Step.get();
11852 Data[I].AssignLoc = E->getAssignLoc(I);
11853 Data[I].ColonLoc = E->getColonLoc(I);
11854 Data[I].SecColonLoc = E->getSecondColonLoc(I);
11855 NeedToRebuild =
11856 NeedToRebuild ||
11857 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
11858 D->getType().getTypePtrOrNull()) ||
11859 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
11860 Range.Step != Data[I].Range.Step;
11861 }
11862 if (ErrorFound)
11863 return ExprError();
11864 if (!NeedToRebuild)
11865 return E;
11866
11867 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
11868 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
11869 if (!Res.isUsable())
11870 return Res;
11871 auto *IE = cast<OMPIteratorExpr>(Res.get());
11872 for (unsigned I = 0; I < NumIterators; ++I)
11873 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
11874 IE->getIteratorDecl(I));
11875 return Res;
11876}
11877
11878template<typename Derived>
11880TreeTransform<Derived>::TransformCallExpr(CallExpr *E) {
11881 // Transform the callee.
11882 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
11883 if (Callee.isInvalid())
11884 return ExprError();
11885
11886 // Transform arguments.
11887 bool ArgChanged = false;
11889 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
11890 &ArgChanged))
11891 return ExprError();
11892
11893 if (!getDerived().AlwaysRebuild() &&
11894 Callee.get() == E->getCallee() &&
11895 !ArgChanged)
11896 return SemaRef.MaybeBindToTemporary(E);
11897
11898 // FIXME: Wrong source location information for the '('.
11899 SourceLocation FakeLParenLoc
11900 = ((Expr *)Callee.get())->getSourceRange().getBegin();
11901
11902 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
11903 if (E->hasStoredFPFeatures()) {
11904 FPOptionsOverride NewOverrides = E->getFPFeatures();
11905 getSema().CurFPFeatures =
11906 NewOverrides.applyOverrides(getSema().getLangOpts());
11907 getSema().FpPragmaStack.CurrentValue = NewOverrides;
11908 }
11909
11910 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
11911 Args,
11912 E->getRParenLoc());
11913}
11914
11915template<typename Derived>
11917TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
11918 ExprResult Base = getDerived().TransformExpr(E->getBase());
11919 if (Base.isInvalid())
11920 return ExprError();
11921
11922 NestedNameSpecifierLoc QualifierLoc;
11923 if (E->hasQualifier()) {
11924 QualifierLoc
11925 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
11926
11927 if (!QualifierLoc)
11928 return ExprError();
11929 }
11930 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
11931
11932 ValueDecl *Member
11933 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
11934 E->getMemberDecl()));
11935 if (!Member)
11936 return ExprError();
11937
11938 NamedDecl *FoundDecl = E->getFoundDecl();
11939 if (FoundDecl == E->getMemberDecl()) {
11940 FoundDecl = Member;
11941 } else {
11942 FoundDecl = cast_or_null<NamedDecl>(
11943 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
11944 if (!FoundDecl)
11945 return ExprError();
11946 }
11947
11948 if (!getDerived().AlwaysRebuild() &&
11949 Base.get() == E->getBase() &&
11950 QualifierLoc == E->getQualifierLoc() &&
11951 Member == E->getMemberDecl() &&
11952 FoundDecl == E->getFoundDecl() &&
11953 !E->hasExplicitTemplateArgs()) {
11954
11955 // Skip for member expression of (this->f), rebuilt thisi->f is needed
11956 // for Openmp where the field need to be privatizized in the case.
11957 if (!(isa<CXXThisExpr>(E->getBase()) &&
11958 getSema().OpenMP().isOpenMPRebuildMemberExpr(
11959 cast<ValueDecl>(Member)))) {
11960 // Mark it referenced in the new context regardless.
11961 // FIXME: this is a bit instantiation-specific.
11962 SemaRef.MarkMemberReferenced(E);
11963 return E;
11964 }
11965 }
11966
11967 TemplateArgumentListInfo TransArgs;
11968 if (E->hasExplicitTemplateArgs()) {
11969 TransArgs.setLAngleLoc(E->getLAngleLoc());
11970 TransArgs.setRAngleLoc(E->getRAngleLoc());
11971 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
11972 E->getNumTemplateArgs(),
11973 TransArgs))
11974 return ExprError();
11975 }
11976
11977 // FIXME: Bogus source location for the operator
11978 SourceLocation FakeOperatorLoc =
11979 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
11980
11981 // FIXME: to do this check properly, we will need to preserve the
11982 // first-qualifier-in-scope here, just in case we had a dependent
11983 // base (and therefore couldn't do the check) and a
11984 // nested-name-qualifier (and therefore could do the lookup).
11985 NamedDecl *FirstQualifierInScope = nullptr;
11986 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
11987 if (MemberNameInfo.getName()) {
11988 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
11989 if (!MemberNameInfo.getName())
11990 return ExprError();
11991 }
11992
11993 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
11994 E->isArrow(),
11995 QualifierLoc,
11996 TemplateKWLoc,
11997 MemberNameInfo,
11998 Member,
11999 FoundDecl,
12000 (E->hasExplicitTemplateArgs()
12001 ? &TransArgs : nullptr),
12002 FirstQualifierInScope);
12003}
12004
12005template<typename Derived>
12007TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) {
12008 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
12009 if (LHS.isInvalid())
12010 return ExprError();
12011
12012 ExprResult RHS =
12013 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
12014 if (RHS.isInvalid())
12015 return ExprError();
12016
12017 if (!getDerived().AlwaysRebuild() &&
12018 LHS.get() == E->getLHS() &&
12019 RHS.get() == E->getRHS())
12020 return E;
12021
12022 if (E->isCompoundAssignmentOp())
12023 // FPFeatures has already been established from trailing storage
12024 return getDerived().RebuildBinaryOperator(
12025 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
12026 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
12027 FPOptionsOverride NewOverrides(E->getFPFeatures());
12028 getSema().CurFPFeatures =
12029 NewOverrides.applyOverrides(getSema().getLangOpts());
12030 getSema().FpPragmaStack.CurrentValue = NewOverrides;
12031 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
12032 LHS.get(), RHS.get());
12033}
12034
12035template <typename Derived>
12036ExprResult TreeTransform<Derived>::TransformCXXRewrittenBinaryOperator(
12037 CXXRewrittenBinaryOperator *E) {
12038 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
12039
12040 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
12041 if (LHS.isInvalid())
12042 return ExprError();
12043
12044 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
12045 if (RHS.isInvalid())
12046 return ExprError();
12047
12048 // Extract the already-resolved callee declarations so that we can restrict
12049 // ourselves to using them as the unqualified lookup results when rebuilding.
12050 UnresolvedSet<2> UnqualLookups;
12051 bool ChangedAnyLookups = false;
12052 Expr *PossibleBinOps[] = {E->getSemanticForm(),
12053 const_cast<Expr *>(Decomp.InnerBinOp)};
12054 for (Expr *PossibleBinOp : PossibleBinOps) {
12055 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
12056 if (!Op)
12057 continue;
12058 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
12059 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
12060 continue;
12061
12062 // Transform the callee in case we built a call to a local extern
12063 // declaration.
12064 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
12065 E->getOperatorLoc(), Callee->getFoundDecl()));
12066 if (!Found)
12067 return ExprError();
12068 if (Found != Callee->getFoundDecl())
12069 ChangedAnyLookups = true;
12070 UnqualLookups.addDecl(Found);
12071 }
12072
12073 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
12074 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
12075 // Mark all functions used in the rewrite as referenced. Note that when
12076 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
12077 // function calls, and/or there might be a user-defined conversion sequence
12078 // applied to the operands of the <.
12079 // FIXME: this is a bit instantiation-specific.
12080 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
12081 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
12082 return E;
12083 }
12084
12085 return getDerived().RebuildCXXRewrittenBinaryOperator(
12086 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
12087}
12088
12089template<typename Derived>
12091TreeTransform<Derived>::TransformCompoundAssignOperator(
12092 CompoundAssignOperator *E) {
12093 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
12094 FPOptionsOverride NewOverrides(E->getFPFeatures());
12095 getSema().CurFPFeatures =
12096 NewOverrides.applyOverrides(getSema().getLangOpts());
12097 getSema().FpPragmaStack.CurrentValue = NewOverrides;
12098 return getDerived().TransformBinaryOperator(E);
12099}
12100
12101template<typename Derived>
12102ExprResult TreeTransform<Derived>::
12103TransformBinaryConditionalOperator(BinaryConditionalOperator *e) {
12104 // Just rebuild the common and RHS expressions and see whether we
12105 // get any changes.
12106
12107 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
12108 if (commonExpr.isInvalid())
12109 return ExprError();
12110
12111 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
12112 if (rhs.isInvalid())
12113 return ExprError();
12114
12115 if (!getDerived().AlwaysRebuild() &&
12116 commonExpr.get() == e->getCommon() &&
12117 rhs.get() == e->getFalseExpr())
12118 return e;
12119
12120 return getDerived().RebuildConditionalOperator(commonExpr.get(),
12121 e->getQuestionLoc(),
12122 nullptr,
12123 e->getColonLoc(),
12124 rhs.get());
12125}
12126
12127template<typename Derived>
12129TreeTransform<Derived>::TransformConditionalOperator(ConditionalOperator *E) {
12130 ExprResult Cond = getDerived().TransformExpr(E->getCond());
12131 if (Cond.isInvalid())
12132 return ExprError();
12133
12134 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
12135 if (LHS.isInvalid())
12136 return ExprError();
12137
12138 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
12139 if (RHS.isInvalid())
12140 return ExprError();
12141
12142 if (!getDerived().AlwaysRebuild() &&
12143 Cond.get() == E->getCond() &&
12144 LHS.get() == E->getLHS() &&
12145 RHS.get() == E->getRHS())
12146 return E;
12147
12148 return getDerived().RebuildConditionalOperator(Cond.get(),
12149 E->getQuestionLoc(),
12150 LHS.get(),
12151 E->getColonLoc(),
12152 RHS.get());
12153}
12154
12155template<typename Derived>
12157TreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) {
12158 // Implicit casts are eliminated during transformation, since they
12159 // will be recomputed by semantic analysis after transformation.
12160 return getDerived().TransformExpr(E->getSubExprAsWritten());
12161}
12162
12163template<typename Derived>
12165TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) {
12166 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
12167 if (!Type)
12168 return ExprError();
12169
12170 ExprResult SubExpr
12171 = getDerived().TransformExpr(E->getSubExprAsWritten());
12172 if (SubExpr.isInvalid())
12173 return ExprError();
12174
12175 if (!getDerived().AlwaysRebuild() &&
12176 Type == E->getTypeInfoAsWritten() &&
12177 SubExpr.get() == E->getSubExpr())
12178 return E;
12179
12180 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
12181 Type,
12182 E->getRParenLoc(),
12183 SubExpr.get());
12184}
12185
12186template<typename Derived>
12188TreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) {
12189 TypeSourceInfo *OldT = E->getTypeSourceInfo();
12190 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
12191 if (!NewT)
12192 return ExprError();
12193
12194 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
12195 if (Init.isInvalid())
12196 return ExprError();
12197
12198 if (!getDerived().AlwaysRebuild() &&
12199 OldT == NewT &&
12200 Init.get() == E->getInitializer())
12201 return SemaRef.MaybeBindToTemporary(E);
12202
12203 // Note: the expression type doesn't necessarily match the
12204 // type-as-written, but that's okay, because it should always be
12205 // derivable from the initializer.
12206
12207 return getDerived().RebuildCompoundLiteralExpr(
12208 E->getLParenLoc(), NewT,
12209 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
12210}
12211
12212template<typename Derived>
12214TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) {
12215 ExprResult Base = getDerived().TransformExpr(E->getBase());
12216 if (Base.isInvalid())
12217 return ExprError();
12218
12219 if (!getDerived().AlwaysRebuild() &&
12220 Base.get() == E->getBase())
12221 return E;
12222
12223 // FIXME: Bad source location
12224 SourceLocation FakeOperatorLoc =
12225 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
12226 return getDerived().RebuildExtVectorElementExpr(
12227 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
12228 E->getAccessor());
12229}
12230
12231template<typename Derived>
12233TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) {
12234 if (InitListExpr *Syntactic = E->getSyntacticForm())
12235 E = Syntactic;
12236
12237 bool InitChanged = false;
12238
12239 EnterExpressionEvaluationContext Context(
12241
12243 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
12244 Inits, &InitChanged))
12245 return ExprError();
12246
12247 if (!getDerived().AlwaysRebuild() && !InitChanged) {
12248 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
12249 // in some cases. We can't reuse it in general, because the syntactic and
12250 // semantic forms are linked, and we can't know that semantic form will
12251 // match even if the syntactic form does.
12252 }
12253
12254 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
12255 E->getRBraceLoc());
12256}
12257
12258template<typename Derived>
12260TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
12261 Designation Desig;
12262
12263 // transform the initializer value
12264 ExprResult Init = getDerived().TransformExpr(E->getInit());
12265 if (Init.isInvalid())
12266 return ExprError();
12267
12268 // transform the designators.
12269 SmallVector<Expr*, 4> ArrayExprs;
12270 bool ExprChanged = false;
12271 for (const DesignatedInitExpr::Designator &D : E->designators()) {
12272 if (D.isFieldDesignator()) {
12273 if (D.getFieldDecl()) {
12274 FieldDecl *Field = cast_or_null<FieldDecl>(
12275 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
12276 if (Field != D.getFieldDecl())
12277 // Rebuild the expression when the transformed FieldDecl is
12278 // different to the already assigned FieldDecl.
12279 ExprChanged = true;
12280 if (Field->isAnonymousStructOrUnion())
12281 continue;
12282 } else {
12283 // Ensure that the designator expression is rebuilt when there isn't
12284 // a resolved FieldDecl in the designator as we don't want to assign
12285 // a FieldDecl to a pattern designator that will be instantiated again.
12286 ExprChanged = true;
12287 }
12288 Desig.AddDesignator(Designator::CreateFieldDesignator(
12289 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
12290 continue;
12291 }
12292
12293 if (D.isArrayDesignator()) {
12294 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
12295 if (Index.isInvalid())
12296 return ExprError();
12297
12298 Desig.AddDesignator(
12299 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
12300
12301 ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D);
12302 ArrayExprs.push_back(Index.get());
12303 continue;
12304 }
12305
12306 assert(D.isArrayRangeDesignator() && "New kind of designator?");
12307 ExprResult Start
12308 = getDerived().TransformExpr(E->getArrayRangeStart(D));
12309 if (Start.isInvalid())
12310 return ExprError();
12311
12312 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
12313 if (End.isInvalid())
12314 return ExprError();
12315
12316 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
12317 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
12318
12319 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
12320 End.get() != E->getArrayRangeEnd(D);
12321
12322 ArrayExprs.push_back(Start.get());
12323 ArrayExprs.push_back(End.get());
12324 }
12325
12326 if (!getDerived().AlwaysRebuild() &&
12327 Init.get() == E->getInit() &&
12328 !ExprChanged)
12329 return E;
12330
12331 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
12332 E->getEqualOrColonLoc(),
12333 E->usesGNUSyntax(), Init.get());
12334}
12335
12336// Seems that if TransformInitListExpr() only works on the syntactic form of an
12337// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
12338template<typename Derived>
12340TreeTransform<Derived>::TransformDesignatedInitUpdateExpr(
12341 DesignatedInitUpdateExpr *E) {
12342 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
12343 "initializer");
12344 return ExprError();
12345}
12346
12347template<typename Derived>
12349TreeTransform<Derived>::TransformNoInitExpr(
12350 NoInitExpr *E) {
12351 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
12352 return ExprError();
12353}
12354
12355template<typename Derived>
12357TreeTransform<Derived>::TransformArrayInitLoopExpr(ArrayInitLoopExpr *E) {
12358 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
12359 return ExprError();
12360}
12361
12362template<typename Derived>
12364TreeTransform<Derived>::TransformArrayInitIndexExpr(ArrayInitIndexExpr *E) {
12365 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
12366 return ExprError();
12367}
12368
12369template<typename Derived>
12371TreeTransform<Derived>::TransformImplicitValueInitExpr(
12372 ImplicitValueInitExpr *E) {
12373 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
12374
12375 // FIXME: Will we ever have proper type location here? Will we actually
12376 // need to transform the type?
12377 QualType T = getDerived().TransformType(E->getType());
12378 if (T.isNull())
12379 return ExprError();
12380
12381 if (!getDerived().AlwaysRebuild() &&
12382 T == E->getType())
12383 return E;
12384
12385 return getDerived().RebuildImplicitValueInitExpr(T);
12386}
12387
12388template<typename Derived>
12390TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) {
12391 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
12392 if (!TInfo)
12393 return ExprError();
12394
12395 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
12396 if (SubExpr.isInvalid())
12397 return ExprError();
12398
12399 if (!getDerived().AlwaysRebuild() &&
12400 TInfo == E->getWrittenTypeInfo() &&
12401 SubExpr.get() == E->getSubExpr())
12402 return E;
12403
12404 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
12405 TInfo, E->getRParenLoc());
12406}
12407
12408template<typename Derived>
12410TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) {
12411 bool ArgumentChanged = false;
12413 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
12414 &ArgumentChanged))
12415 return ExprError();
12416
12417 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
12418 Inits,
12419 E->getRParenLoc());
12420}
12421
12422/// Transform an address-of-label expression.
12423///
12424/// By default, the transformation of an address-of-label expression always
12425/// rebuilds the expression, so that the label identifier can be resolved to
12426/// the corresponding label statement by semantic analysis.
12427template<typename Derived>
12429TreeTransform<Derived>::TransformAddrLabelExpr(AddrLabelExpr *E) {
12430 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
12431 E->getLabel());
12432 if (!LD)
12433 return ExprError();
12434
12435 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
12436 cast<LabelDecl>(LD));
12437}
12438
12439template<typename Derived>
12441TreeTransform<Derived>::TransformStmtExpr(StmtExpr *E) {
12442 SemaRef.ActOnStartStmtExpr();
12443 StmtResult SubStmt
12444 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
12445 if (SubStmt.isInvalid()) {
12446 SemaRef.ActOnStmtExprError();
12447 return ExprError();
12448 }
12449
12450 unsigned OldDepth = E->getTemplateDepth();
12451 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
12452
12453 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
12454 SubStmt.get() == E->getSubStmt()) {
12455 // Calling this an 'error' is unintuitive, but it does the right thing.
12456 SemaRef.ActOnStmtExprError();
12457 return SemaRef.MaybeBindToTemporary(E);
12458 }
12459
12460 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
12461 E->getRParenLoc(), NewDepth);
12462}
12463
12464template<typename Derived>
12466TreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) {
12467 ExprResult Cond = getDerived().TransformExpr(E->getCond());
12468 if (Cond.isInvalid())
12469 return ExprError();
12470
12471 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
12472 if (LHS.isInvalid())
12473 return ExprError();
12474
12475 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
12476 if (RHS.isInvalid())
12477 return ExprError();
12478
12479 if (!getDerived().AlwaysRebuild() &&
12480 Cond.get() == E->getCond() &&
12481 LHS.get() == E->getLHS() &&
12482 RHS.get() == E->getRHS())
12483 return E;
12484
12485 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
12486 Cond.get(), LHS.get(), RHS.get(),
12487 E->getRParenLoc());
12488}
12489
12490template<typename Derived>
12492TreeTransform<Derived>::TransformGNUNullExpr(GNUNullExpr *E) {
12493 return E;
12494}
12495
12496template<typename Derived>
12498TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
12499 switch (E->getOperator()) {
12500 case OO_New:
12501 case OO_Delete:
12502 case OO_Array_New:
12503 case OO_Array_Delete:
12504 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
12505
12506 case OO_Subscript:
12507 case OO_Call: {
12508 // This is a call to an object's operator().
12509 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
12510
12511 // Transform the object itself.
12512 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
12513 if (Object.isInvalid())
12514 return ExprError();
12515
12516 // FIXME: Poor location information
12517 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(
12518 static_cast<Expr *>(Object.get())->getEndLoc());
12519
12520 // Transform the call arguments.
12522 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
12523 Args))
12524 return ExprError();
12525
12526 if (E->getOperator() == OO_Subscript)
12527 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
12528 Args, E->getEndLoc());
12529
12530 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
12531 E->getEndLoc());
12532 }
12533
12534#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
12535 case OO_##Name: \
12536 break;
12537
12538#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
12539#include "clang/Basic/OperatorKinds.def"
12540
12541 case OO_Conditional:
12542 llvm_unreachable("conditional operator is not actually overloadable");
12543
12544 case OO_None:
12546 llvm_unreachable("not an overloaded operator?");
12547 }
12548
12550 if (E->getOperator() == OO_Amp)
12551 First = getDerived().TransformAddressOfOperand(E->getArg(0));
12552 else
12553 First = getDerived().TransformExpr(E->getArg(0));
12554 if (First.isInvalid())
12555 return ExprError();
12556
12557 ExprResult Second;
12558 if (E->getNumArgs() == 2) {
12559 Second =
12560 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
12561 if (Second.isInvalid())
12562 return ExprError();
12563 }
12564
12565 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
12566 FPOptionsOverride NewOverrides(E->getFPFeatures());
12567 getSema().CurFPFeatures =
12568 NewOverrides.applyOverrides(getSema().getLangOpts());
12569 getSema().FpPragmaStack.CurrentValue = NewOverrides;
12570
12571 Expr *Callee = E->getCallee();
12572 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
12573 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
12575 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
12576 return ExprError();
12577
12578 return getDerived().RebuildCXXOperatorCallExpr(
12579 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
12580 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
12581 }
12582
12583 UnresolvedSet<1> Functions;
12584 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
12585 Callee = ICE->getSubExprAsWritten();
12586 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
12587 ValueDecl *VD = cast_or_null<ValueDecl>(
12588 getDerived().TransformDecl(DR->getLocation(), DR));
12589 if (!VD)
12590 return ExprError();
12591
12592 if (!isa<CXXMethodDecl>(VD))
12593 Functions.addDecl(VD);
12594
12595 return getDerived().RebuildCXXOperatorCallExpr(
12596 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
12597 /*RequiresADL=*/false, Functions, First.get(), Second.get());
12598}
12599
12600template<typename Derived>
12602TreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) {
12603 return getDerived().TransformCallExpr(E);
12604}
12605
12606template <typename Derived>
12607ExprResult TreeTransform<Derived>::TransformSourceLocExpr(SourceLocExpr *E) {
12608 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
12609 getSema().CurContext != E->getParentContext();
12610
12611 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
12612 return E;
12613
12614 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
12615 E->getBeginLoc(), E->getEndLoc(),
12616 getSema().CurContext);
12617}
12618
12619template<typename Derived>
12621TreeTransform<Derived>::TransformCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
12622 // Transform the callee.
12623 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
12624 if (Callee.isInvalid())
12625 return ExprError();
12626
12627 // Transform exec config.
12628 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
12629 if (EC.isInvalid())
12630 return ExprError();
12631
12632 // Transform arguments.
12633 bool ArgChanged = false;
12635 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
12636 &ArgChanged))
12637 return ExprError();
12638
12639 if (!getDerived().AlwaysRebuild() &&
12640 Callee.get() == E->getCallee() &&
12641 !ArgChanged)
12642 return SemaRef.MaybeBindToTemporary(E);
12643
12644 // FIXME: Wrong source location information for the '('.
12645 SourceLocation FakeLParenLoc
12646 = ((Expr *)Callee.get())->getSourceRange().getBegin();
12647 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
12648 Args,
12649 E->getRParenLoc(), EC.get());
12650}
12651
12652template<typename Derived>
12655 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
12656 if (!Type)
12657 return ExprError();
12658
12659 ExprResult SubExpr
12660 = getDerived().TransformExpr(E->getSubExprAsWritten());
12661 if (SubExpr.isInvalid())
12662 return ExprError();
12663
12664 if (!getDerived().AlwaysRebuild() &&
12665 Type == E->getTypeInfoAsWritten() &&
12666 SubExpr.get() == E->getSubExpr())
12667 return E;
12668 return getDerived().RebuildCXXNamedCastExpr(
12671 // FIXME. this should be '(' location
12672 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
12673}
12674
12675template<typename Derived>
12678 TypeSourceInfo *TSI =
12679 getDerived().TransformType(BCE->getTypeInfoAsWritten());
12680 if (!TSI)
12681 return ExprError();
12682
12683 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
12684 if (Sub.isInvalid())
12685 return ExprError();
12686
12687 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
12688 Sub.get(), BCE->getEndLoc());
12689}
12690
12691template<typename Derived>
12693TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
12694 return getDerived().TransformCXXNamedCastExpr(E);
12695}
12696
12697template<typename Derived>
12699TreeTransform<Derived>::TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
12700 return getDerived().TransformCXXNamedCastExpr(E);
12701}
12702
12703template<typename Derived>
12705TreeTransform<Derived>::TransformCXXReinterpretCastExpr(
12706 CXXReinterpretCastExpr *E) {
12707 return getDerived().TransformCXXNamedCastExpr(E);
12708}
12709
12710template<typename Derived>
12712TreeTransform<Derived>::TransformCXXConstCastExpr(CXXConstCastExpr *E) {
12713 return getDerived().TransformCXXNamedCastExpr(E);
12714}
12715
12716template<typename Derived>
12718TreeTransform<Derived>::TransformCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
12719 return getDerived().TransformCXXNamedCastExpr(E);
12720}
12721
12722template<typename Derived>
12724TreeTransform<Derived>::TransformCXXFunctionalCastExpr(
12725 CXXFunctionalCastExpr *E) {
12726 TypeSourceInfo *Type =
12727 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
12728 if (!Type)
12729 return ExprError();
12730
12731 ExprResult SubExpr
12732 = getDerived().TransformExpr(E->getSubExprAsWritten());
12733 if (SubExpr.isInvalid())
12734 return ExprError();
12735
12736 if (!getDerived().AlwaysRebuild() &&
12737 Type == E->getTypeInfoAsWritten() &&
12738 SubExpr.get() == E->getSubExpr())
12739 return E;
12740
12741 return getDerived().RebuildCXXFunctionalCastExpr(Type,
12742 E->getLParenLoc(),
12743 SubExpr.get(),
12744 E->getRParenLoc(),
12745 E->isListInitialization());
12746}
12747
12748template<typename Derived>
12750TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
12751 if (E->isTypeOperand()) {
12752 TypeSourceInfo *TInfo
12753 = getDerived().TransformType(E->getTypeOperandSourceInfo());
12754 if (!TInfo)
12755 return ExprError();
12756
12757 if (!getDerived().AlwaysRebuild() &&
12758 TInfo == E->getTypeOperandSourceInfo())
12759 return E;
12760
12761 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
12762 TInfo, E->getEndLoc());
12763 }
12764
12765 // Typeid's operand is an unevaluated context, unless it's a polymorphic
12766 // type. We must not unilaterally enter unevaluated context here, as then
12767 // semantic processing can re-transform an already transformed operand.
12768 Expr *Op = E->getExprOperand();
12770 if (E->isGLValue())
12771 if (auto *RecordT = Op->getType()->getAs<RecordType>())
12772 if (cast<CXXRecordDecl>(RecordT->getDecl())->isPolymorphic())
12773 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
12774
12775 EnterExpressionEvaluationContext Unevaluated(SemaRef, EvalCtx,
12777
12778 ExprResult SubExpr = getDerived().TransformExpr(Op);
12779 if (SubExpr.isInvalid())
12780 return ExprError();
12781
12782 if (!getDerived().AlwaysRebuild() &&
12783 SubExpr.get() == E->getExprOperand())
12784 return E;
12785
12786 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
12787 SubExpr.get(), E->getEndLoc());
12788}
12789
12790template<typename Derived>
12792TreeTransform<Derived>::TransformCXXUuidofExpr(CXXUuidofExpr *E) {
12793 if (E->isTypeOperand()) {
12794 TypeSourceInfo *TInfo
12795 = getDerived().TransformType(E->getTypeOperandSourceInfo());
12796 if (!TInfo)
12797 return ExprError();
12798
12799 if (!getDerived().AlwaysRebuild() &&
12800 TInfo == E->getTypeOperandSourceInfo())
12801 return E;
12802
12803 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
12804 TInfo, E->getEndLoc());
12805 }
12806
12807 EnterExpressionEvaluationContext Unevaluated(
12809
12810 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
12811 if (SubExpr.isInvalid())
12812 return ExprError();
12813
12814 if (!getDerived().AlwaysRebuild() &&
12815 SubExpr.get() == E->getExprOperand())
12816 return E;
12817
12818 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
12819 SubExpr.get(), E->getEndLoc());
12820}
12821
12822template<typename Derived>
12824TreeTransform<Derived>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
12825 return E;
12826}
12827
12828template<typename Derived>
12830TreeTransform<Derived>::TransformCXXNullPtrLiteralExpr(
12831 CXXNullPtrLiteralExpr *E) {
12832 return E;
12833}
12834
12835template<typename Derived>
12837TreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) {
12838
12839 // In lambdas, the qualifiers of the type depends of where in
12840 // the call operator `this` appear, and we do not have a good way to
12841 // rebuild this information, so we transform the type.
12842 //
12843 // In other contexts, the type of `this` may be overrided
12844 // for type deduction, so we need to recompute it.
12845 //
12846 // Always recompute the type if we're in the body of a lambda, and
12847 // 'this' is dependent on a lambda's explicit object parameter.
12848 QualType T = [&]() {
12849 auto &S = getSema();
12850 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
12851 return S.getCurrentThisType();
12852 if (S.getCurLambda())
12853 return getDerived().TransformType(E->getType());
12854 return S.getCurrentThisType();
12855 }();
12856
12857 if (!getDerived().AlwaysRebuild() && T == E->getType()) {
12858 // Mark it referenced in the new context regardless.
12859 // FIXME: this is a bit instantiation-specific.
12860 getSema().MarkThisReferenced(E);
12861 return E;
12862 }
12863
12864 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
12865}
12866
12867template<typename Derived>
12869TreeTransform<Derived>::TransformCXXThrowExpr(CXXThrowExpr *E) {
12870 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
12871 if (SubExpr.isInvalid())
12872 return ExprError();
12873
12874 if (!getDerived().AlwaysRebuild() &&
12875 SubExpr.get() == E->getSubExpr())
12876 return E;
12877
12878 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
12879 E->isThrownVariableInScope());
12880}
12881
12882template<typename Derived>
12884TreeTransform<Derived>::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
12885 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
12886 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
12887 if (!Param)
12888 return ExprError();
12889
12890 ExprResult InitRes;
12891 if (E->hasRewrittenInit()) {
12892 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
12893 if (InitRes.isInvalid())
12894 return ExprError();
12895 }
12896
12897 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
12898 E->getUsedContext() == SemaRef.CurContext &&
12899 InitRes.get() == E->getRewrittenExpr())
12900 return E;
12901
12902 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
12903 InitRes.get());
12904}
12905
12906template<typename Derived>
12908TreeTransform<Derived>::TransformCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
12909 FieldDecl *Field = cast_or_null<FieldDecl>(
12910 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
12911 if (!Field)
12912 return ExprError();
12913
12914 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
12915 E->getUsedContext() == SemaRef.CurContext)
12916 return E;
12917
12918 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
12919}
12920
12921template<typename Derived>
12923TreeTransform<Derived>::TransformCXXScalarValueInitExpr(
12924 CXXScalarValueInitExpr *E) {
12925 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
12926 if (!T)
12927 return ExprError();
12928
12929 if (!getDerived().AlwaysRebuild() &&
12930 T == E->getTypeSourceInfo())
12931 return E;
12932
12933 return getDerived().RebuildCXXScalarValueInitExpr(T,
12934 /*FIXME:*/T->getTypeLoc().getEndLoc(),
12935 E->getRParenLoc());
12936}
12937
12938template<typename Derived>
12940TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
12941 // Transform the type that we're allocating
12942 TypeSourceInfo *AllocTypeInfo =
12943 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
12944 if (!AllocTypeInfo)
12945 return ExprError();
12946
12947 // Transform the size of the array we're allocating (if any).
12948 std::optional<Expr *> ArraySize;
12949 if (E->isArray()) {
12950 ExprResult NewArraySize;
12951 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
12952 NewArraySize = getDerived().TransformExpr(*OldArraySize);
12953 if (NewArraySize.isInvalid())
12954 return ExprError();
12955 }
12956 ArraySize = NewArraySize.get();
12957 }
12958
12959 // Transform the placement arguments (if any).
12960 bool ArgumentChanged = false;
12961 SmallVector<Expr*, 8> PlacementArgs;
12962 if (getDerived().TransformExprs(E->getPlacementArgs(),
12963 E->getNumPlacementArgs(), true,
12964 PlacementArgs, &ArgumentChanged))
12965 return ExprError();
12966
12967 // Transform the initializer (if any).
12968 Expr *OldInit = E->getInitializer();
12969 ExprResult NewInit;
12970 if (OldInit)
12971 NewInit = getDerived().TransformInitializer(OldInit, true);
12972 if (NewInit.isInvalid())
12973 return ExprError();
12974
12975 // Transform new operator and delete operator.
12976 FunctionDecl *OperatorNew = nullptr;
12977 if (E->getOperatorNew()) {
12978 OperatorNew = cast_or_null<FunctionDecl>(
12979 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
12980 if (!OperatorNew)
12981 return ExprError();
12982 }
12983
12984 FunctionDecl *OperatorDelete = nullptr;
12985 if (E->getOperatorDelete()) {
12986 OperatorDelete = cast_or_null<FunctionDecl>(
12987 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
12988 if (!OperatorDelete)
12989 return ExprError();
12990 }
12991
12992 if (!getDerived().AlwaysRebuild() &&
12993 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
12994 ArraySize == E->getArraySize() &&
12995 NewInit.get() == OldInit &&
12996 OperatorNew == E->getOperatorNew() &&
12997 OperatorDelete == E->getOperatorDelete() &&
12998 !ArgumentChanged) {
12999 // Mark any declarations we need as referenced.
13000 // FIXME: instantiation-specific.
13001 if (OperatorNew)
13002 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
13003 if (OperatorDelete)
13004 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
13005
13006 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
13007 QualType ElementType
13008 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
13009 if (const RecordType *RecordT = ElementType->getAs<RecordType>()) {
13010 CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl());
13011 if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) {
13012 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Destructor);
13013 }
13014 }
13015 }
13016
13017 return E;
13018 }
13019
13020 QualType AllocType = AllocTypeInfo->getType();
13021 if (!ArraySize) {
13022 // If no array size was specified, but the new expression was
13023 // instantiated with an array type (e.g., "new T" where T is
13024 // instantiated with "int[4]"), extract the outer bound from the
13025 // array type as our array size. We do this with constant and
13026 // dependently-sized array types.
13027 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
13028 if (!ArrayT) {
13029 // Do nothing
13030 } else if (const ConstantArrayType *ConsArrayT
13031 = dyn_cast<ConstantArrayType>(ArrayT)) {
13032 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
13033 SemaRef.Context.getSizeType(),
13034 /*FIXME:*/ E->getBeginLoc());
13035 AllocType = ConsArrayT->getElementType();
13036 } else if (const DependentSizedArrayType *DepArrayT
13037 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
13038 if (DepArrayT->getSizeExpr()) {
13039 ArraySize = DepArrayT->getSizeExpr();
13040 AllocType = DepArrayT->getElementType();
13041 }
13042 }
13043 }
13044
13045 return getDerived().RebuildCXXNewExpr(
13046 E->getBeginLoc(), E->isGlobalNew(),
13047 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
13048 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
13049 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
13050}
13051
13052template<typename Derived>
13054TreeTransform<Derived>::TransformCXXDeleteExpr(CXXDeleteExpr *E) {
13055 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
13056 if (Operand.isInvalid())
13057 return ExprError();
13058
13059 // Transform the delete operator, if known.
13060 FunctionDecl *OperatorDelete = nullptr;
13061 if (E->getOperatorDelete()) {
13062 OperatorDelete = cast_or_null<FunctionDecl>(
13063 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
13064 if (!OperatorDelete)
13065 return ExprError();
13066 }
13067
13068 if (!getDerived().AlwaysRebuild() &&
13069 Operand.get() == E->getArgument() &&
13070 OperatorDelete == E->getOperatorDelete()) {
13071 // Mark any declarations we need as referenced.
13072 // FIXME: instantiation-specific.
13073 if (OperatorDelete)
13074 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
13075
13076 if (!E->getArgument()->isTypeDependent()) {
13077 QualType Destroyed = SemaRef.Context.getBaseElementType(
13078 E->getDestroyedType());
13079 if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
13080 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
13081 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
13082 SemaRef.LookupDestructor(Record));
13083 }
13084 }
13085
13086 return E;
13087 }
13088
13089 return getDerived().RebuildCXXDeleteExpr(
13090 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
13091}
13092
13093template<typename Derived>
13095TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
13096 CXXPseudoDestructorExpr *E) {
13097 ExprResult Base = getDerived().TransformExpr(E->getBase());
13098 if (Base.isInvalid())
13099 return ExprError();
13100
13101 ParsedType ObjectTypePtr;
13102 bool MayBePseudoDestructor = false;
13103 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
13104 E->getOperatorLoc(),
13105 E->isArrow()? tok::arrow : tok::period,
13106 ObjectTypePtr,
13107 MayBePseudoDestructor);
13108 if (Base.isInvalid())
13109 return ExprError();
13110
13111 QualType ObjectType = ObjectTypePtr.get();
13112 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
13113 if (QualifierLoc) {
13114 QualifierLoc
13115 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
13116 if (!QualifierLoc)
13117 return ExprError();
13118 }
13119 CXXScopeSpec SS;
13120 SS.Adopt(QualifierLoc);
13121
13122 PseudoDestructorTypeStorage Destroyed;
13123 if (E->getDestroyedTypeInfo()) {
13124 TypeSourceInfo *DestroyedTypeInfo
13125 = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
13126 ObjectType, nullptr, SS);
13127 if (!DestroyedTypeInfo)
13128 return ExprError();
13129 Destroyed = DestroyedTypeInfo;
13130 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
13131 // We aren't likely to be able to resolve the identifier down to a type
13132 // now anyway, so just retain the identifier.
13133 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
13134 E->getDestroyedTypeLoc());
13135 } else {
13136 // Look for a destructor known with the given name.
13137 ParsedType T = SemaRef.getDestructorName(
13138 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
13139 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
13140 if (!T)
13141 return ExprError();
13142
13143 Destroyed
13145 E->getDestroyedTypeLoc());
13146 }
13147
13148 TypeSourceInfo *ScopeTypeInfo = nullptr;
13149 if (E->getScopeTypeInfo()) {
13150 CXXScopeSpec EmptySS;
13151 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
13152 E->getScopeTypeInfo(), ObjectType, nullptr, EmptySS);
13153 if (!ScopeTypeInfo)
13154 return ExprError();
13155 }
13156
13157 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
13158 E->getOperatorLoc(),
13159 E->isArrow(),
13160 SS,
13161 ScopeTypeInfo,
13162 E->getColonColonLoc(),
13163 E->getTildeLoc(),
13164 Destroyed);
13165}
13166
13167template <typename Derived>
13169 bool RequiresADL,
13170 LookupResult &R) {
13171 // Transform all the decls.
13172 bool AllEmptyPacks = true;
13173 for (auto *OldD : Old->decls()) {
13174 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
13175 if (!InstD) {
13176 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
13177 // This can happen because of dependent hiding.
13178 if (isa<UsingShadowDecl>(OldD))
13179 continue;
13180 else {
13181 R.clear();
13182 return true;
13183 }
13184 }
13185
13186 // Expand using pack declarations.
13187 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
13188 ArrayRef<NamedDecl*> Decls = SingleDecl;
13189 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
13190 Decls = UPD->expansions();
13191
13192 // Expand using declarations.
13193 for (auto *D : Decls) {
13194 if (auto *UD = dyn_cast<UsingDecl>(D)) {
13195 for (auto *SD : UD->shadows())
13196 R.addDecl(SD);
13197 } else {
13198 R.addDecl(D);
13199 }
13200 }
13201
13202 AllEmptyPacks &= Decls.empty();
13203 };
13204
13205 // C++ [temp.res]/8.4.2:
13206 // The program is ill-formed, no diagnostic required, if [...] lookup for
13207 // a name in the template definition found a using-declaration, but the
13208 // lookup in the corresponding scope in the instantiation odoes not find
13209 // any declarations because the using-declaration was a pack expansion and
13210 // the corresponding pack is empty
13211 if (AllEmptyPacks && !RequiresADL) {
13212 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
13213 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
13214 return true;
13215 }
13216
13217 // Resolve a kind, but don't do any further analysis. If it's
13218 // ambiguous, the callee needs to deal with it.
13219 R.resolveKind();
13220 return false;
13221}
13222
13223template <typename Derived>
13225 UnresolvedLookupExpr *Old) {
13226 return TransformUnresolvedLookupExpr(Old, /*IsAddressOfOperand=*/false);
13227}
13228
13229template <typename Derived>
13232 bool IsAddressOfOperand) {
13233 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
13235
13236 // Transform the declaration set.
13237 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
13238 return ExprError();
13239
13240 // Rebuild the nested-name qualifier, if present.
13241 CXXScopeSpec SS;
13242 if (Old->getQualifierLoc()) {
13243 NestedNameSpecifierLoc QualifierLoc
13244 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
13245 if (!QualifierLoc)
13246 return ExprError();
13247
13248 SS.Adopt(QualifierLoc);
13249 }
13250
13251 if (Old->getNamingClass()) {
13252 CXXRecordDecl *NamingClass
13253 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
13254 Old->getNameLoc(),
13255 Old->getNamingClass()));
13256 if (!NamingClass) {
13257 R.clear();
13258 return ExprError();
13259 }
13260
13261 R.setNamingClass(NamingClass);
13262 }
13263
13264 // Rebuild the template arguments, if any.
13265 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
13266 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
13267 if (Old->hasExplicitTemplateArgs() &&
13268 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
13269 Old->getNumTemplateArgs(),
13270 TransArgs)) {
13271 R.clear();
13272 return ExprError();
13273 }
13274
13275 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
13276 // a non-static data member is named in an unevaluated operand, or when
13277 // a member is named in a dependent class scope function template explicit
13278 // specialization that is neither declared static nor with an explicit object
13279 // parameter.
13280 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
13281 return SemaRef.BuildPossibleImplicitMemberExpr(
13282 SS, TemplateKWLoc, R,
13283 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
13284 /*S=*/nullptr);
13285
13286 // If we have neither explicit template arguments, nor the template keyword,
13287 // it's a normal declaration name or member reference.
13288 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
13289 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
13290
13291 // If we have template arguments, then rebuild the template-id expression.
13292 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
13293 Old->requiresADL(), &TransArgs);
13294}
13295
13296template<typename Derived>
13298TreeTransform<Derived>::TransformTypeTraitExpr(TypeTraitExpr *E) {
13299 bool ArgChanged = false;
13301 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
13302 TypeSourceInfo *From = E->getArg(I);
13303 TypeLoc FromTL = From->getTypeLoc();
13304 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
13305 TypeLocBuilder TLB;
13306 TLB.reserve(FromTL.getFullDataSize());
13307 QualType To = getDerived().TransformType(TLB, FromTL);
13308 if (To.isNull())
13309 return ExprError();
13310
13311 if (To == From->getType())
13312 Args.push_back(From);
13313 else {
13314 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
13315 ArgChanged = true;
13316 }
13317 continue;
13318 }
13319
13320 ArgChanged = true;
13321
13322 // We have a pack expansion. Instantiate it.
13323 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
13324 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
13326 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
13327
13328 // Determine whether the set of unexpanded parameter packs can and should
13329 // be expanded.
13330 bool Expand = true;
13331 bool RetainExpansion = false;
13332 std::optional<unsigned> OrigNumExpansions =
13333 ExpansionTL.getTypePtr()->getNumExpansions();
13334 std::optional<unsigned> NumExpansions = OrigNumExpansions;
13335 if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
13336 PatternTL.getSourceRange(),
13337 Unexpanded,
13338 Expand, RetainExpansion,
13339 NumExpansions))
13340 return ExprError();
13341
13342 if (!Expand) {
13343 // The transform has determined that we should perform a simple
13344 // transformation on the pack expansion, producing another pack
13345 // expansion.
13346 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
13347
13348 TypeLocBuilder TLB;
13349 TLB.reserve(From->getTypeLoc().getFullDataSize());
13350
13351 QualType To = getDerived().TransformType(TLB, PatternTL);
13352 if (To.isNull())
13353 return ExprError();
13354
13355 To = getDerived().RebuildPackExpansionType(To,
13356 PatternTL.getSourceRange(),
13357 ExpansionTL.getEllipsisLoc(),
13358 NumExpansions);
13359 if (To.isNull())
13360 return ExprError();
13361
13362 PackExpansionTypeLoc ToExpansionTL
13363 = TLB.push<PackExpansionTypeLoc>(To);
13364 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
13365 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
13366 continue;
13367 }
13368
13369 // Expand the pack expansion by substituting for each argument in the
13370 // pack(s).
13371 for (unsigned I = 0; I != *NumExpansions; ++I) {
13372 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I);
13373 TypeLocBuilder TLB;
13374 TLB.reserve(PatternTL.getFullDataSize());
13375 QualType To = getDerived().TransformType(TLB, PatternTL);
13376 if (To.isNull())
13377 return ExprError();
13378
13379 if (To->containsUnexpandedParameterPack()) {
13380 To = getDerived().RebuildPackExpansionType(To,
13381 PatternTL.getSourceRange(),
13382 ExpansionTL.getEllipsisLoc(),
13383 NumExpansions);
13384 if (To.isNull())
13385 return ExprError();
13386
13387 PackExpansionTypeLoc ToExpansionTL
13388 = TLB.push<PackExpansionTypeLoc>(To);
13389 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
13390 }
13391
13392 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
13393 }
13394
13395 if (!RetainExpansion)
13396 continue;
13397
13398 // If we're supposed to retain a pack expansion, do so by temporarily
13399 // forgetting the partially-substituted parameter pack.
13400 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
13401
13402 TypeLocBuilder TLB;
13403 TLB.reserve(From->getTypeLoc().getFullDataSize());
13404
13405 QualType To = getDerived().TransformType(TLB, PatternTL);
13406 if (To.isNull())
13407 return ExprError();
13408
13409 To = getDerived().RebuildPackExpansionType(To,
13410 PatternTL.getSourceRange(),
13411 ExpansionTL.getEllipsisLoc(),
13412 NumExpansions);
13413 if (To.isNull())
13414 return ExprError();
13415
13416 PackExpansionTypeLoc ToExpansionTL
13417 = TLB.push<PackExpansionTypeLoc>(To);
13418 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
13419 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
13420 }
13421
13422 if (!getDerived().AlwaysRebuild() && !ArgChanged)
13423 return E;
13424
13425 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
13426 E->getEndLoc());
13427}
13428
13429template<typename Derived>
13431TreeTransform<Derived>::TransformConceptSpecializationExpr(
13432 ConceptSpecializationExpr *E) {
13433 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
13434 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
13435 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
13436 Old->NumTemplateArgs, TransArgs))
13437 return ExprError();
13438
13439 return getDerived().RebuildConceptSpecializationExpr(
13440 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
13441 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
13442 &TransArgs);
13443}
13444
13445template<typename Derived>
13447TreeTransform<Derived>::TransformRequiresExpr(RequiresExpr *E) {
13448 SmallVector<ParmVarDecl*, 4> TransParams;
13449 SmallVector<QualType, 4> TransParamTypes;
13450 Sema::ExtParameterInfoBuilder ExtParamInfos;
13451
13452 // C++2a [expr.prim.req]p2
13453 // Expressions appearing within a requirement-body are unevaluated operands.
13454 EnterExpressionEvaluationContext Ctx(
13457
13458 RequiresExprBodyDecl *Body = RequiresExprBodyDecl::Create(
13459 getSema().Context, getSema().CurContext,
13460 E->getBody()->getBeginLoc());
13461
13462 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
13463
13464 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
13465 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
13466 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
13467
13468 for (ParmVarDecl *Param : TransParams)
13469 if (Param)
13470 Param->setDeclContext(Body);
13471
13472 // On failure to transform, TransformRequiresTypeParams returns an expression
13473 // in the event that the transformation of the type params failed in some way.
13474 // It is expected that this will result in a 'not satisfied' Requires clause
13475 // when instantiating.
13476 if (!TypeParamResult.isUnset())
13477 return TypeParamResult;
13478
13480 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
13481 TransReqs))
13482 return ExprError();
13483
13484 for (concepts::Requirement *Req : TransReqs) {
13485 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
13486 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
13487 ER->getReturnTypeRequirement()
13488 .getTypeConstraintTemplateParameterList()->getParam(0)
13489 ->setDeclContext(Body);
13490 }
13491 }
13492 }
13493
13494 return getDerived().RebuildRequiresExpr(
13495 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
13496 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
13497}
13498
13499template<typename Derived>
13503 for (concepts::Requirement *Req : Reqs) {
13504 concepts::Requirement *TransReq = nullptr;
13505 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
13506 TransReq = getDerived().TransformTypeRequirement(TypeReq);
13507 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
13508 TransReq = getDerived().TransformExprRequirement(ExprReq);
13509 else
13510 TransReq = getDerived().TransformNestedRequirement(
13511 cast<concepts::NestedRequirement>(Req));
13512 if (!TransReq)
13513 return true;
13514 Transformed.push_back(TransReq);
13515 }
13516 return false;
13517}
13518
13519template<typename Derived>
13523 if (Req->isSubstitutionFailure()) {
13524 if (getDerived().AlwaysRebuild())
13525 return getDerived().RebuildTypeRequirement(
13527 return Req;
13528 }
13529 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
13530 if (!TransType)
13531 return nullptr;
13532 return getDerived().RebuildTypeRequirement(TransType);
13533}
13534
13535template<typename Derived>
13538 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
13539 if (Req->isExprSubstitutionFailure())
13540 TransExpr = Req->getExprSubstitutionDiagnostic();
13541 else {
13542 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
13543 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
13544 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
13545 if (TransExprRes.isInvalid())
13546 return nullptr;
13547 TransExpr = TransExprRes.get();
13548 }
13549
13550 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
13551 const auto &RetReq = Req->getReturnTypeRequirement();
13552 if (RetReq.isEmpty())
13553 TransRetReq.emplace();
13554 else if (RetReq.isSubstitutionFailure())
13555 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
13556 else if (RetReq.isTypeConstraint()) {
13557 TemplateParameterList *OrigTPL =
13558 RetReq.getTypeConstraintTemplateParameterList();
13560 getDerived().TransformTemplateParameterList(OrigTPL);
13561 if (!TPL)
13562 return nullptr;
13563 TransRetReq.emplace(TPL);
13564 }
13565 assert(TransRetReq && "All code paths leading here must set TransRetReq");
13566 if (Expr *E = TransExpr.dyn_cast<Expr *>())
13567 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
13568 Req->getNoexceptLoc(),
13569 std::move(*TransRetReq));
13570 return getDerived().RebuildExprRequirement(
13572 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
13573}
13574
13575template<typename Derived>
13579 if (Req->hasInvalidConstraint()) {
13580 if (getDerived().AlwaysRebuild())
13581 return getDerived().RebuildNestedRequirement(
13583 return Req;
13584 }
13585 ExprResult TransConstraint =
13586 getDerived().TransformExpr(Req->getConstraintExpr());
13587 if (TransConstraint.isInvalid())
13588 return nullptr;
13589 return getDerived().RebuildNestedRequirement(TransConstraint.get());
13590}
13591
13592template<typename Derived>
13595 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
13596 if (!T)
13597 return ExprError();
13598
13599 if (!getDerived().AlwaysRebuild() &&
13601 return E;
13602
13603 ExprResult SubExpr;
13604 {
13607 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
13608 if (SubExpr.isInvalid())
13609 return ExprError();
13610
13611 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression())
13612 return E;
13613 }
13614
13615 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
13616 SubExpr.get(), E->getEndLoc());
13617}
13618
13619template<typename Derived>
13621TreeTransform<Derived>::TransformExpressionTraitExpr(ExpressionTraitExpr *E) {
13622 ExprResult SubExpr;
13623 {
13624 EnterExpressionEvaluationContext Unevaluated(
13626 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
13627 if (SubExpr.isInvalid())
13628 return ExprError();
13629
13630 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
13631 return E;
13632 }
13633
13634 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
13635 SubExpr.get(), E->getEndLoc());
13636}
13637
13638template <typename Derived>
13640 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
13641 TypeSourceInfo **RecoveryTSI) {
13642 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
13643 DRE, AddrTaken, RecoveryTSI);
13644
13645 // Propagate both errors and recovered types, which return ExprEmpty.
13646 if (!NewDRE.isUsable())
13647 return NewDRE;
13648
13649 // We got an expr, wrap it up in parens.
13650 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
13651 return PE;
13652 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
13653 PE->getRParen());
13654}
13655
13656template <typename Derived>
13659 return TransformDependentScopeDeclRefExpr(E, /*IsAddressOfOperand=*/false,
13660 nullptr);
13661}
13662
13663template <typename Derived>
13665 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
13666 TypeSourceInfo **RecoveryTSI) {
13667 assert(E->getQualifierLoc());
13668 NestedNameSpecifierLoc QualifierLoc =
13669 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13670 if (!QualifierLoc)
13671 return ExprError();
13672 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13673
13674 // TODO: If this is a conversion-function-id, verify that the
13675 // destination type name (if present) resolves the same way after
13676 // instantiation as it did in the local scope.
13677
13678 DeclarationNameInfo NameInfo =
13679 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
13680 if (!NameInfo.getName())
13681 return ExprError();
13682
13683 if (!E->hasExplicitTemplateArgs()) {
13684 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
13685 // Note: it is sufficient to compare the Name component of NameInfo:
13686 // if name has not changed, DNLoc has not changed either.
13687 NameInfo.getName() == E->getDeclName())
13688 return E;
13689
13690 return getDerived().RebuildDependentScopeDeclRefExpr(
13691 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
13692 IsAddressOfOperand, RecoveryTSI);
13693 }
13694
13695 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
13696 if (getDerived().TransformTemplateArguments(
13697 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
13698 return ExprError();
13699
13700 return getDerived().RebuildDependentScopeDeclRefExpr(
13701 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
13702 RecoveryTSI);
13703}
13704
13705template<typename Derived>
13707TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
13708 // CXXConstructExprs other than for list-initialization and
13709 // CXXTemporaryObjectExpr are always implicit, so when we have
13710 // a 1-argument construction we just transform that argument.
13711 if (getDerived().AllowSkippingCXXConstructExpr() &&
13712 ((E->getNumArgs() == 1 ||
13713 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
13714 (!getDerived().DropCallArgument(E->getArg(0))) &&
13715 !E->isListInitialization()))
13716 return getDerived().TransformInitializer(E->getArg(0),
13717 /*DirectInit*/ false);
13718
13719 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
13720
13721 QualType T = getDerived().TransformType(E->getType());
13722 if (T.isNull())
13723 return ExprError();
13724
13725 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
13726 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
13727 if (!Constructor)
13728 return ExprError();
13729
13730 bool ArgumentChanged = false;
13732 {
13733 EnterExpressionEvaluationContext Context(
13735 E->isListInitialization());
13736 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13737 &ArgumentChanged))
13738 return ExprError();
13739 }
13740
13741 if (!getDerived().AlwaysRebuild() &&
13742 T == E->getType() &&
13743 Constructor == E->getConstructor() &&
13744 !ArgumentChanged) {
13745 // Mark the constructor as referenced.
13746 // FIXME: Instantiation-specific
13747 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
13748 return E;
13749 }
13750
13751 return getDerived().RebuildCXXConstructExpr(
13752 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
13753 E->hadMultipleCandidates(), E->isListInitialization(),
13754 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
13755 E->getConstructionKind(), E->getParenOrBraceRange());
13756}
13757
13758template<typename Derived>
13759ExprResult TreeTransform<Derived>::TransformCXXInheritedCtorInitExpr(
13760 CXXInheritedCtorInitExpr *E) {
13761 QualType T = getDerived().TransformType(E->getType());
13762 if (T.isNull())
13763 return ExprError();
13764
13765 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
13766 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
13767 if (!Constructor)
13768 return ExprError();
13769
13770 if (!getDerived().AlwaysRebuild() &&
13771 T == E->getType() &&
13772 Constructor == E->getConstructor()) {
13773 // Mark the constructor as referenced.
13774 // FIXME: Instantiation-specific
13775 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
13776 return E;
13777 }
13778
13779 return getDerived().RebuildCXXInheritedCtorInitExpr(
13780 T, E->getLocation(), Constructor,
13781 E->constructsVBase(), E->inheritedFromVBase());
13782}
13783
13784/// Transform a C++ temporary-binding expression.
13785///
13786/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
13787/// transform the subexpression and return that.
13788template<typename Derived>
13790TreeTransform<Derived>::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
13791 if (auto *Dtor = E->getTemporary()->getDestructor())
13792 SemaRef.MarkFunctionReferenced(E->getBeginLoc(),
13793 const_cast<CXXDestructorDecl *>(Dtor));
13794 return getDerived().TransformExpr(E->getSubExpr());
13795}
13796
13797/// Transform a C++ expression that contains cleanups that should
13798/// be run after the expression is evaluated.
13799///
13800/// Since ExprWithCleanups nodes are implicitly generated, we
13801/// just transform the subexpression and return that.
13802template<typename Derived>
13804TreeTransform<Derived>::TransformExprWithCleanups(ExprWithCleanups *E) {
13805 return getDerived().TransformExpr(E->getSubExpr());
13806}
13807
13808template<typename Derived>
13810TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
13811 CXXTemporaryObjectExpr *E) {
13812 TypeSourceInfo *T =
13813 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
13814 if (!T)
13815 return ExprError();
13816
13817 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
13818 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
13819 if (!Constructor)
13820 return ExprError();
13821
13822 bool ArgumentChanged = false;
13824 Args.reserve(E->getNumArgs());
13825 {
13826 EnterExpressionEvaluationContext Context(
13828 E->isListInitialization());
13829 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13830 &ArgumentChanged))
13831 return ExprError();
13832 }
13833
13834 if (!getDerived().AlwaysRebuild() &&
13835 T == E->getTypeSourceInfo() &&
13836 Constructor == E->getConstructor() &&
13837 !ArgumentChanged) {
13838 // FIXME: Instantiation-specific
13839 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
13840 return SemaRef.MaybeBindToTemporary(E);
13841 }
13842
13843 // FIXME: We should just pass E->isListInitialization(), but we're not
13844 // prepared to handle list-initialization without a child InitListExpr.
13845 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
13846 return getDerived().RebuildCXXTemporaryObjectExpr(
13847 T, LParenLoc, Args, E->getEndLoc(),
13848 /*ListInitialization=*/LParenLoc.isInvalid());
13849}
13850
13851template<typename Derived>
13853TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
13854 // Transform any init-capture expressions before entering the scope of the
13855 // lambda body, because they are not semantically within that scope.
13856 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
13857 struct TransformedInitCapture {
13858 // The location of the ... if the result is retaining a pack expansion.
13859 SourceLocation EllipsisLoc;
13860 // Zero or more expansions of the init-capture.
13862 };
13864 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
13865 for (LambdaExpr::capture_iterator C = E->capture_begin(),
13866 CEnd = E->capture_end();
13867 C != CEnd; ++C) {
13868 if (!E->isInitCapture(C))
13869 continue;
13870
13871 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
13872 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
13873
13874 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
13875 std::optional<unsigned> NumExpansions) {
13876 ExprResult NewExprInitResult = getDerived().TransformInitializer(
13877 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
13878
13879 if (NewExprInitResult.isInvalid()) {
13880 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
13881 return;
13882 }
13883 Expr *NewExprInit = NewExprInitResult.get();
13884
13885 QualType NewInitCaptureType =
13886 getSema().buildLambdaInitCaptureInitialization(
13887 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
13888 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
13889 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
13891 NewExprInit);
13892 Result.Expansions.push_back(
13893 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
13894 };
13895
13896 // If this is an init-capture pack, consider expanding the pack now.
13897 if (OldVD->isParameterPack()) {
13898 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
13899 ->getTypeLoc()
13900 .castAs<PackExpansionTypeLoc>();
13902 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
13903
13904 // Determine whether the set of unexpanded parameter packs can and should
13905 // be expanded.
13906 bool Expand = true;
13907 bool RetainExpansion = false;
13908 std::optional<unsigned> OrigNumExpansions =
13909 ExpansionTL.getTypePtr()->getNumExpansions();
13910 std::optional<unsigned> NumExpansions = OrigNumExpansions;
13911 if (getDerived().TryExpandParameterPacks(
13912 ExpansionTL.getEllipsisLoc(),
13913 OldVD->getInit()->getSourceRange(), Unexpanded, Expand,
13914 RetainExpansion, NumExpansions))
13915 return ExprError();
13916 if (Expand) {
13917 for (unsigned I = 0; I != *NumExpansions; ++I) {
13918 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
13919 SubstInitCapture(SourceLocation(), std::nullopt);
13920 }
13921 }
13922 if (!Expand || RetainExpansion) {
13923 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
13924 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
13925 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
13926 }
13927 } else {
13928 SubstInitCapture(SourceLocation(), std::nullopt);
13929 }
13930 }
13931
13932 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
13933 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
13934
13935 // Create the local class that will describe the lambda.
13936
13937 // FIXME: DependencyKind below is wrong when substituting inside a templated
13938 // context that isn't a DeclContext (such as a variable template), or when
13939 // substituting an unevaluated lambda inside of a function's parameter's type
13940 // - as parameter types are not instantiated from within a function's DC. We
13941 // use evaluation contexts to distinguish the function parameter case.
13944 DeclContext *DC = getSema().CurContext;
13945 // A RequiresExprBodyDecl is not interesting for dependencies.
13946 // For the following case,
13947 //
13948 // template <typename>
13949 // concept C = requires { [] {}; };
13950 //
13951 // template <class F>
13952 // struct Widget;
13953 //
13954 // template <C F>
13955 // struct Widget<F> {};
13956 //
13957 // While we are substituting Widget<F>, the parent of DC would be
13958 // the template specialization itself. Thus, the lambda expression
13959 // will be deemed as dependent even if there are no dependent template
13960 // arguments.
13961 // (A ClassTemplateSpecializationDecl is always a dependent context.)
13962 while (DC->getDeclKind() == Decl::Kind::RequiresExprBody)
13963 DC = DC->getParent();
13964 if ((getSema().isUnevaluatedContext() ||
13965 getSema().isConstantEvaluatedContext()) &&
13966 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
13967 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
13968
13969 CXXRecordDecl *OldClass = E->getLambdaClass();
13970 CXXRecordDecl *Class = getSema().createLambdaClosureType(
13971 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
13972 E->getCaptureDefault());
13973 getDerived().transformedLocalDecl(OldClass, {Class});
13974
13975 CXXMethodDecl *NewCallOperator =
13976 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
13977 NewCallOperator->setLexicalDeclContext(getSema().CurContext);
13978
13979 // Enter the scope of the lambda.
13980 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
13981 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
13982 E->hasExplicitParameters(), E->isMutable());
13983
13984 // Introduce the context of the call operator.
13985 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
13986 /*NewThisContext*/false);
13987
13988 bool Invalid = false;
13989
13990 // Transform captures.
13991 for (LambdaExpr::capture_iterator C = E->capture_begin(),
13992 CEnd = E->capture_end();
13993 C != CEnd; ++C) {
13994 // When we hit the first implicit capture, tell Sema that we've finished
13995 // the list of explicit captures.
13996 if (C->isImplicit())
13997 break;
13998
13999 // Capturing 'this' is trivial.
14000 if (C->capturesThis()) {
14001 // If this is a lambda that is part of a default member initialiser
14002 // and which we're instantiating outside the class that 'this' is
14003 // supposed to refer to, adjust the type of 'this' accordingly.
14004 //
14005 // Otherwise, leave the type of 'this' as-is.
14006 Sema::CXXThisScopeRAII ThisScope(
14007 getSema(),
14008 dyn_cast_if_present<CXXRecordDecl>(
14009 getSema().getFunctionLevelDeclContext()),
14010 Qualifiers());
14011 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
14012 /*BuildAndDiagnose*/ true, nullptr,
14013 C->getCaptureKind() == LCK_StarThis);
14014 continue;
14015 }
14016 // Captured expression will be recaptured during captured variables
14017 // rebuilding.
14018 if (C->capturesVLAType())
14019 continue;
14020
14021 // Rebuild init-captures, including the implied field declaration.
14022 if (E->isInitCapture(C)) {
14023 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
14024
14025 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
14027
14028 for (InitCaptureInfoTy &Info : NewC.Expansions) {
14029 ExprResult Init = Info.first;
14030 QualType InitQualType = Info.second;
14031 if (Init.isInvalid() || InitQualType.isNull()) {
14032 Invalid = true;
14033 break;
14034 }
14035 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
14036 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
14037 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
14038 getSema().CurContext);
14039 if (!NewVD) {
14040 Invalid = true;
14041 break;
14042 }
14043 NewVDs.push_back(NewVD);
14044 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
14045 }
14046
14047 if (Invalid)
14048 break;
14049
14050 getDerived().transformedLocalDecl(OldVD, NewVDs);
14051 continue;
14052 }
14053
14054 assert(C->capturesVariable() && "unexpected kind of lambda capture");
14055
14056 // Determine the capture kind for Sema.
14058 = C->isImplicit()? Sema::TryCapture_Implicit
14059 : C->getCaptureKind() == LCK_ByCopy
14062 SourceLocation EllipsisLoc;
14063 if (C->isPackExpansion()) {
14064 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
14065 bool ShouldExpand = false;
14066 bool RetainExpansion = false;
14067 std::optional<unsigned> NumExpansions;
14068 if (getDerived().TryExpandParameterPacks(C->getEllipsisLoc(),
14069 C->getLocation(),
14070 Unexpanded,
14071 ShouldExpand, RetainExpansion,
14072 NumExpansions)) {
14073 Invalid = true;
14074 continue;
14075 }
14076
14077 if (ShouldExpand) {
14078 // The transform has determined that we should perform an expansion;
14079 // transform and capture each of the arguments.
14080 // expansion of the pattern. Do so.
14081 auto *Pack = cast<VarDecl>(C->getCapturedVar());
14082 for (unsigned I = 0; I != *NumExpansions; ++I) {
14083 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
14084 VarDecl *CapturedVar
14085 = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
14086 Pack));
14087 if (!CapturedVar) {
14088 Invalid = true;
14089 continue;
14090 }
14091
14092 // Capture the transformed variable.
14093 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
14094 }
14095
14096 // FIXME: Retain a pack expansion if RetainExpansion is true.
14097
14098 continue;
14099 }
14100
14101 EllipsisLoc = C->getEllipsisLoc();
14102 }
14103
14104 // Transform the captured variable.
14105 auto *CapturedVar = cast_or_null<ValueDecl>(
14106 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
14107 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
14108 Invalid = true;
14109 continue;
14110 }
14111
14112 // Capture the transformed variable.
14113 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
14114 EllipsisLoc);
14115 }
14116 getSema().finishLambdaExplicitCaptures(LSI);
14117
14118 // Transform the template parameters, and add them to the current
14119 // instantiation scope. The null case is handled correctly.
14120 auto TPL = getDerived().TransformTemplateParameterList(
14121 E->getTemplateParameterList());
14122 LSI->GLTemplateParameterList = TPL;
14123 if (TPL)
14124 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
14125 TPL);
14126
14127 // Transform the type of the original lambda's call operator.
14128 // The transformation MUST be done in the CurrentInstantiationScope since
14129 // it introduces a mapping of the original to the newly created
14130 // transformed parameters.
14131 TypeSourceInfo *NewCallOpTSI = nullptr;
14132 {
14133 auto OldCallOpTypeLoc =
14134 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
14135
14136 auto TransformFunctionProtoTypeLoc =
14137 [this](TypeLocBuilder &TLB, FunctionProtoTypeLoc FPTL) -> QualType {
14138 SmallVector<QualType, 4> ExceptionStorage;
14139 return this->TransformFunctionProtoType(
14140 TLB, FPTL, nullptr, Qualifiers(),
14141 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
14142 return TransformExceptionSpec(FPTL.getBeginLoc(), ESI,
14143 ExceptionStorage, Changed);
14144 });
14145 };
14146
14147 QualType NewCallOpType;
14148 TypeLocBuilder NewCallOpTLBuilder;
14149
14150 if (auto ATL = OldCallOpTypeLoc.getAs<AttributedTypeLoc>()) {
14151 NewCallOpType = this->TransformAttributedType(
14152 NewCallOpTLBuilder, ATL,
14153 [&](TypeLocBuilder &TLB, TypeLoc TL) -> QualType {
14154 return TransformFunctionProtoTypeLoc(
14155 TLB, TL.castAs<FunctionProtoTypeLoc>());
14156 });
14157 } else {
14158 auto FPTL = OldCallOpTypeLoc.castAs<FunctionProtoTypeLoc>();
14159 NewCallOpType = TransformFunctionProtoTypeLoc(NewCallOpTLBuilder, FPTL);
14160 }
14161
14162 if (NewCallOpType.isNull())
14163 return ExprError();
14164 NewCallOpTSI =
14165 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
14166 }
14167
14169 if (auto ATL = NewCallOpTSI->getTypeLoc().getAs<AttributedTypeLoc>()) {
14170 Params = ATL.getModifiedLoc().castAs<FunctionProtoTypeLoc>().getParams();
14171 } else {
14172 auto FPTL = NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>();
14173 Params = FPTL.getParams();
14174 }
14175
14176 getSema().CompleteLambdaCallOperator(
14177 NewCallOperator, E->getCallOperator()->getLocation(),
14178 E->getCallOperator()->getInnerLocStart(),
14179 E->getCallOperator()->getTrailingRequiresClause(), NewCallOpTSI,
14180 E->getCallOperator()->getConstexprKind(),
14181 E->getCallOperator()->getStorageClass(), Params,
14182 E->hasExplicitResultType());
14183
14184 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
14185 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
14186
14187 {
14188 // Number the lambda for linkage purposes if necessary.
14189 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
14190
14191 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
14192 if (getDerived().ReplacingOriginal()) {
14193 Numbering = OldClass->getLambdaNumbering();
14194 }
14195
14196 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
14197 }
14198
14199 // FIXME: Sema's lambda-building mechanism expects us to push an expression
14200 // evaluation context even if we're not transforming the function body.
14201 getSema().PushExpressionEvaluationContext(
14202 E->getCallOperator()->isConsteval() ?
14205
14206 Sema::CodeSynthesisContext C;
14208 C.PointOfInstantiation = E->getBody()->getBeginLoc();
14209 getSema().pushCodeSynthesisContext(C);
14210
14211 // Instantiate the body of the lambda expression.
14212 StmtResult Body =
14213 Invalid ? StmtError() : getDerived().TransformLambdaBody(E, E->getBody());
14214
14215 getSema().popCodeSynthesisContext();
14216
14217 // ActOnLambda* will pop the function scope for us.
14218 FuncScopeCleanup.disable();
14219
14220 if (Body.isInvalid()) {
14221 SavedContext.pop();
14222 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
14223 /*IsInstantiation=*/true);
14224 return ExprError();
14225 }
14226
14227 // Copy the LSI before ActOnFinishFunctionBody removes it.
14228 // FIXME: This is dumb. Store the lambda information somewhere that outlives
14229 // the call operator.
14230 auto LSICopy = *LSI;
14231 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
14232 /*IsInstantiation*/ true);
14233 SavedContext.pop();
14234
14235 // Recompute the dependency of the lambda so that we can defer the lambda call
14236 // construction until after we have all the necessary template arguments. For
14237 // example, given
14238 //
14239 // template <class> struct S {
14240 // template <class U>
14241 // using Type = decltype([](U){}(42.0));
14242 // };
14243 // void foo() {
14244 // using T = S<int>::Type<float>;
14245 // ^~~~~~
14246 // }
14247 //
14248 // We would end up here from instantiating S<int> when ensuring its
14249 // completeness. That would transform the lambda call expression regardless of
14250 // the absence of the corresponding argument for U.
14251 //
14252 // Going ahead with unsubstituted type U makes things worse: we would soon
14253 // compare the argument type (which is float) against the parameter U
14254 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
14255 // error suggesting unmatched types 'U' and 'float'!
14256 //
14257 // That said, everything will be fine if we defer that semantic checking.
14258 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
14259 // dependent. Since the CallExpr's dependency boils down to the lambda's
14260 // dependency in this case, we can harness that by recomputing the dependency
14261 // from the instantiation arguments.
14262 //
14263 // FIXME: Creating the type of a lambda requires us to have a dependency
14264 // value, which happens before its substitution. We update its dependency
14265 // *after* the substitution in case we can't decide the dependency
14266 // so early, e.g. because we want to see if any of the *substituted*
14267 // parameters are dependent.
14268 DependencyKind = getDerived().ComputeLambdaDependency(&LSICopy);
14269 Class->setLambdaDependencyKind(DependencyKind);
14270 // Clean up the type cache created previously. Then, we re-create a type for
14271 // such Decl with the new DependencyKind.
14272 Class->setTypeForDecl(nullptr);
14273 getSema().Context.getTypeDeclType(Class);
14274
14275 return getSema().BuildLambdaExpr(E->getBeginLoc(), Body.get()->getEndLoc(),
14276 &LSICopy);
14277}
14278
14279template<typename Derived>
14282 return TransformStmt(S);
14283}
14284
14285template<typename Derived>
14288 // Transform captures.
14290 CEnd = E->capture_end();
14291 C != CEnd; ++C) {
14292 // When we hit the first implicit capture, tell Sema that we've finished
14293 // the list of explicit captures.
14294 if (!C->isImplicit())
14295 continue;
14296
14297 // Capturing 'this' is trivial.
14298 if (C->capturesThis()) {
14299 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
14300 /*BuildAndDiagnose*/ true, nullptr,
14301 C->getCaptureKind() == LCK_StarThis);
14302 continue;
14303 }
14304 // Captured expression will be recaptured during captured variables
14305 // rebuilding.
14306 if (C->capturesVLAType())
14307 continue;
14308
14309 assert(C->capturesVariable() && "unexpected kind of lambda capture");
14310 assert(!E->isInitCapture(C) && "implicit init-capture?");
14311
14312 // Transform the captured variable.
14313 VarDecl *CapturedVar = cast_or_null<VarDecl>(
14314 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
14315 if (!CapturedVar || CapturedVar->isInvalidDecl())
14316 return StmtError();
14317
14318 // Capture the transformed variable.
14319 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
14320 }
14321
14322 return S;
14323}
14324
14325template<typename Derived>
14329 TypeSourceInfo *T =
14330 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
14331 if (!T)
14332 return ExprError();
14333
14334 bool ArgumentChanged = false;
14336 Args.reserve(E->getNumArgs());
14337 {
14341 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
14342 &ArgumentChanged))
14343 return ExprError();
14344 }
14345
14346 if (!getDerived().AlwaysRebuild() &&
14347 T == E->getTypeSourceInfo() &&
14348 !ArgumentChanged)
14349 return E;
14350
14351 // FIXME: we're faking the locations of the commas
14352 return getDerived().RebuildCXXUnresolvedConstructExpr(
14353 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
14354}
14355
14356template<typename Derived>
14358TreeTransform<Derived>::TransformCXXDependentScopeMemberExpr(
14359 CXXDependentScopeMemberExpr *E) {
14360 // Transform the base of the expression.
14361 ExprResult Base((Expr*) nullptr);
14362 Expr *OldBase;
14363 QualType BaseType;
14364 QualType ObjectType;
14365 if (!E->isImplicitAccess()) {
14366 OldBase = E->getBase();
14367 Base = getDerived().TransformExpr(OldBase);
14368 if (Base.isInvalid())
14369 return ExprError();
14370
14371 // Start the member reference and compute the object's type.
14372 ParsedType ObjectTy;
14373 bool MayBePseudoDestructor = false;
14374 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14375 E->getOperatorLoc(),
14376 E->isArrow()? tok::arrow : tok::period,
14377 ObjectTy,
14378 MayBePseudoDestructor);
14379 if (Base.isInvalid())
14380 return ExprError();
14381
14382 ObjectType = ObjectTy.get();
14383 BaseType = ((Expr*) Base.get())->getType();
14384 } else {
14385 OldBase = nullptr;
14386 BaseType = getDerived().TransformType(E->getBaseType());
14387 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
14388 }
14389
14390 // Transform the first part of the nested-name-specifier that qualifies
14391 // the member name.
14392 NamedDecl *FirstQualifierInScope
14393 = getDerived().TransformFirstQualifierInScope(
14394 E->getFirstQualifierFoundInScope(),
14395 E->getQualifierLoc().getBeginLoc());
14396
14397 NestedNameSpecifierLoc QualifierLoc;
14398 if (E->getQualifier()) {
14399 QualifierLoc
14400 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
14401 ObjectType,
14402 FirstQualifierInScope);
14403 if (!QualifierLoc)
14404 return ExprError();
14405 }
14406
14407 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
14408
14409 // TODO: If this is a conversion-function-id, verify that the
14410 // destination type name (if present) resolves the same way after
14411 // instantiation as it did in the local scope.
14412
14413 DeclarationNameInfo NameInfo
14414 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
14415 if (!NameInfo.getName())
14416 return ExprError();
14417
14418 if (!E->hasExplicitTemplateArgs()) {
14419 // This is a reference to a member without an explicitly-specified
14420 // template argument list. Optimize for this common case.
14421 if (!getDerived().AlwaysRebuild() &&
14422 Base.get() == OldBase &&
14423 BaseType == E->getBaseType() &&
14424 QualifierLoc == E->getQualifierLoc() &&
14425 NameInfo.getName() == E->getMember() &&
14426 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
14427 return E;
14428
14429 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
14430 BaseType,
14431 E->isArrow(),
14432 E->getOperatorLoc(),
14433 QualifierLoc,
14434 TemplateKWLoc,
14435 FirstQualifierInScope,
14436 NameInfo,
14437 /*TemplateArgs*/nullptr);
14438 }
14439
14440 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
14441 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
14442 E->getNumTemplateArgs(),
14443 TransArgs))
14444 return ExprError();
14445
14446 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
14447 BaseType,
14448 E->isArrow(),
14449 E->getOperatorLoc(),
14450 QualifierLoc,
14451 TemplateKWLoc,
14452 FirstQualifierInScope,
14453 NameInfo,
14454 &TransArgs);
14455}
14456
14457template <typename Derived>
14458ExprResult TreeTransform<Derived>::TransformUnresolvedMemberExpr(
14459 UnresolvedMemberExpr *Old) {
14460 // Transform the base of the expression.
14461 ExprResult Base((Expr *)nullptr);
14462 QualType BaseType;
14463 if (!Old->isImplicitAccess()) {
14464 Base = getDerived().TransformExpr(Old->getBase());
14465 if (Base.isInvalid())
14466 return ExprError();
14467 Base =
14468 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
14469 if (Base.isInvalid())
14470 return ExprError();
14471 BaseType = Base.get()->getType();
14472 } else {
14473 BaseType = getDerived().TransformType(Old->getBaseType());
14474 }
14475
14476 NestedNameSpecifierLoc QualifierLoc;
14477 if (Old->getQualifierLoc()) {
14478 QualifierLoc =
14479 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
14480 if (!QualifierLoc)
14481 return ExprError();
14482 }
14483
14484 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
14485
14486 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
14487
14488 // Transform the declaration set.
14489 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
14490 return ExprError();
14491
14492 // Determine the naming class.
14493 if (Old->getNamingClass()) {
14494 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
14495 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
14496 if (!NamingClass)
14497 return ExprError();
14498
14499 R.setNamingClass(NamingClass);
14500 }
14501
14502 TemplateArgumentListInfo TransArgs;
14503 if (Old->hasExplicitTemplateArgs()) {
14504 TransArgs.setLAngleLoc(Old->getLAngleLoc());
14505 TransArgs.setRAngleLoc(Old->getRAngleLoc());
14506 if (getDerived().TransformTemplateArguments(
14507 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
14508 return ExprError();
14509 }
14510
14511 // FIXME: to do this check properly, we will need to preserve the
14512 // first-qualifier-in-scope here, just in case we had a dependent
14513 // base (and therefore couldn't do the check) and a
14514 // nested-name-qualifier (and therefore could do the lookup).
14515 NamedDecl *FirstQualifierInScope = nullptr;
14516
14517 return getDerived().RebuildUnresolvedMemberExpr(
14518 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
14519 TemplateKWLoc, FirstQualifierInScope, R,
14520 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
14521}
14522
14523template<typename Derived>
14525TreeTransform<Derived>::TransformCXXNoexceptExpr(CXXNoexceptExpr *E) {
14526 EnterExpressionEvaluationContext Unevaluated(
14528 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
14529 if (SubExpr.isInvalid())
14530 return ExprError();
14531
14532 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
14533 return E;
14534
14535 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
14536}
14537
14538template<typename Derived>
14540TreeTransform<Derived>::TransformPackExpansionExpr(PackExpansionExpr *E) {
14541 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
14542 if (Pattern.isInvalid())
14543 return ExprError();
14544
14545 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
14546 return E;
14547
14548 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
14549 E->getNumExpansions());
14550}
14551
14552template<typename Derived>
14554TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
14555 // If E is not value-dependent, then nothing will change when we transform it.
14556 // Note: This is an instantiation-centric view.
14557 if (!E->isValueDependent())
14558 return E;
14559
14560 EnterExpressionEvaluationContext Unevaluated(
14562
14564 TemplateArgument ArgStorage;
14565
14566 // Find the argument list to transform.
14567 if (E->isPartiallySubstituted()) {
14568 PackArgs = E->getPartialArguments();
14569 } else if (E->isValueDependent()) {
14570 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
14571 bool ShouldExpand = false;
14572 bool RetainExpansion = false;
14573 std::optional<unsigned> NumExpansions;
14574 if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(),
14575 Unexpanded,
14576 ShouldExpand, RetainExpansion,
14577 NumExpansions))
14578 return ExprError();
14579
14580 // If we need to expand the pack, build a template argument from it and
14581 // expand that.
14582 if (ShouldExpand) {
14583 auto *Pack = E->getPack();
14584 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
14585 ArgStorage = getSema().Context.getPackExpansionType(
14586 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
14587 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
14588 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
14589 } else {
14590 auto *VD = cast<ValueDecl>(Pack);
14591 ExprResult DRE = getSema().BuildDeclRefExpr(
14592 VD, VD->getType().getNonLValueExprType(getSema().Context),
14593 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
14594 E->getPackLoc());
14595 if (DRE.isInvalid())
14596 return ExprError();
14597 ArgStorage = new (getSema().Context)
14598 PackExpansionExpr(getSema().Context.DependentTy, DRE.get(),
14599 E->getPackLoc(), std::nullopt);
14600 }
14601 PackArgs = ArgStorage;
14602 }
14603 }
14604
14605 // If we're not expanding the pack, just transform the decl.
14606 if (!PackArgs.size()) {
14607 auto *Pack = cast_or_null<NamedDecl>(
14608 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
14609 if (!Pack)
14610 return ExprError();
14611 return getDerived().RebuildSizeOfPackExpr(
14612 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
14613 std::nullopt, std::nullopt);
14614 }
14615
14616 // Try to compute the result without performing a partial substitution.
14617 std::optional<unsigned> Result = 0;
14618 for (const TemplateArgument &Arg : PackArgs) {
14619 if (!Arg.isPackExpansion()) {
14620 Result = *Result + 1;
14621 continue;
14622 }
14623
14624 TemplateArgumentLoc ArgLoc;
14625 InventTemplateArgumentLoc(Arg, ArgLoc);
14626
14627 // Find the pattern of the pack expansion.
14628 SourceLocation Ellipsis;
14629 std::optional<unsigned> OrigNumExpansions;
14630 TemplateArgumentLoc Pattern =
14631 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
14632 OrigNumExpansions);
14633
14634 // Substitute under the pack expansion. Do not expand the pack (yet).
14635 TemplateArgumentLoc OutPattern;
14636 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
14637 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
14638 /*Uneval*/ true))
14639 return true;
14640
14641 // See if we can determine the number of arguments from the result.
14642 std::optional<unsigned> NumExpansions =
14643 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
14644 if (!NumExpansions) {
14645 // No: we must be in an alias template expansion, and we're going to need
14646 // to actually expand the packs.
14647 Result = std::nullopt;
14648 break;
14649 }
14650
14651 Result = *Result + *NumExpansions;
14652 }
14653
14654 // Common case: we could determine the number of expansions without
14655 // substituting.
14656 if (Result)
14657 return getDerived().RebuildSizeOfPackExpr(
14658 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
14659 *Result, std::nullopt);
14660
14661 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
14662 E->getPackLoc());
14663 {
14664 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
14665 typedef TemplateArgumentLocInventIterator<
14666 Derived, const TemplateArgument*> PackLocIterator;
14667 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
14668 PackLocIterator(*this, PackArgs.end()),
14669 TransformedPackArgs, /*Uneval*/true))
14670 return ExprError();
14671 }
14672
14673 // Check whether we managed to fully-expand the pack.
14674 // FIXME: Is it possible for us to do so and not hit the early exit path?
14676 bool PartialSubstitution = false;
14677 for (auto &Loc : TransformedPackArgs.arguments()) {
14678 Args.push_back(Loc.getArgument());
14679 if (Loc.getArgument().isPackExpansion())
14680 PartialSubstitution = true;
14681 }
14682
14683 if (PartialSubstitution)
14684 return getDerived().RebuildSizeOfPackExpr(
14685 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
14686 std::nullopt, Args);
14687
14688 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
14689 E->getPackLoc(), E->getRParenLoc(),
14690 Args.size(), std::nullopt);
14691}
14692
14693template <typename Derived>
14695TreeTransform<Derived>::TransformPackIndexingExpr(PackIndexingExpr *E) {
14696 if (!E->isValueDependent())
14697 return E;
14698
14699 // Transform the index
14700 ExprResult IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
14701 if (IndexExpr.isInvalid())
14702 return ExprError();
14703
14704 SmallVector<Expr *, 5> ExpandedExprs;
14705 if (E->getExpressions().empty()) {
14706 Expr *Pattern = E->getPackIdExpression();
14708 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
14709 Unexpanded);
14710 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
14711
14712 // Determine whether the set of unexpanded parameter packs can and should
14713 // be expanded.
14714 bool ShouldExpand = true;
14715 bool RetainExpansion = false;
14716 std::optional<unsigned> OrigNumExpansions;
14717 std::optional<unsigned> NumExpansions = OrigNumExpansions;
14718 if (getDerived().TryExpandParameterPacks(
14719 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
14720 ShouldExpand, RetainExpansion, NumExpansions))
14721 return true;
14722 if (!ShouldExpand) {
14723 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
14724 ExprResult Pack = getDerived().TransformExpr(Pattern);
14725 if (Pack.isInvalid())
14726 return ExprError();
14727 return getDerived().RebuildPackIndexingExpr(
14728 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
14729 std::nullopt);
14730 }
14731 for (unsigned I = 0; I != *NumExpansions; ++I) {
14732 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
14733 ExprResult Out = getDerived().TransformExpr(Pattern);
14734 if (Out.isInvalid())
14735 return true;
14736 if (Out.get()->containsUnexpandedParameterPack()) {
14737 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
14738 OrigNumExpansions);
14739 if (Out.isInvalid())
14740 return true;
14741 }
14742 ExpandedExprs.push_back(Out.get());
14743 }
14744 // If we're supposed to retain a pack expansion, do so by temporarily
14745 // forgetting the partially-substituted parameter pack.
14746 if (RetainExpansion) {
14747 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
14748
14749 ExprResult Out = getDerived().TransformExpr(Pattern);
14750 if (Out.isInvalid())
14751 return true;
14752
14753 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
14754 OrigNumExpansions);
14755 if (Out.isInvalid())
14756 return true;
14757 ExpandedExprs.push_back(Out.get());
14758 }
14759 }
14760
14761 else {
14762 if (getDerived().TransformExprs(E->getExpressions().data(),
14763 E->getExpressions().size(), false,
14764 ExpandedExprs))
14765 return ExprError();
14766 }
14767
14768 return getDerived().RebuildPackIndexingExpr(
14769 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
14770 IndexExpr.get(), ExpandedExprs,
14771 /*EmptyPack=*/ExpandedExprs.size() == 0);
14772}
14773
14774template<typename Derived>
14776TreeTransform<Derived>::TransformSubstNonTypeTemplateParmPackExpr(
14777 SubstNonTypeTemplateParmPackExpr *E) {
14778 // Default behavior is to do nothing with this transformation.
14779 return E;
14780}
14781
14782template<typename Derived>
14784TreeTransform<Derived>::TransformSubstNonTypeTemplateParmExpr(
14785 SubstNonTypeTemplateParmExpr *E) {
14786 // Default behavior is to do nothing with this transformation.
14787 return E;
14788}
14789
14790template<typename Derived>
14792TreeTransform<Derived>::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
14793 // Default behavior is to do nothing with this transformation.
14794 return E;
14795}
14796
14797template<typename Derived>
14799TreeTransform<Derived>::TransformMaterializeTemporaryExpr(
14800 MaterializeTemporaryExpr *E) {
14801 return getDerived().TransformExpr(E->getSubExpr());
14802}
14803
14804template<typename Derived>
14806TreeTransform<Derived>::TransformCXXFoldExpr(CXXFoldExpr *E) {
14807 UnresolvedLookupExpr *Callee = nullptr;
14808 if (Expr *OldCallee = E->getCallee()) {
14809 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
14810 if (CalleeResult.isInvalid())
14811 return ExprError();
14812 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
14813 }
14814
14815 Expr *Pattern = E->getPattern();
14816
14818 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
14819 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
14820
14821 // Determine whether the set of unexpanded parameter packs can and should
14822 // be expanded.
14823 bool Expand = true;
14824 bool RetainExpansion = false;
14825 std::optional<unsigned> OrigNumExpansions = E->getNumExpansions(),
14826 NumExpansions = OrigNumExpansions;
14827 if (getDerived().TryExpandParameterPacks(E->getEllipsisLoc(),
14828 Pattern->getSourceRange(),
14829 Unexpanded,
14830 Expand, RetainExpansion,
14831 NumExpansions))
14832 return true;
14833
14834 if (!Expand) {
14835 // Do not expand any packs here, just transform and rebuild a fold
14836 // expression.
14837 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
14838
14839 ExprResult LHS =
14840 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
14841 if (LHS.isInvalid())
14842 return true;
14843
14844 ExprResult RHS =
14845 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
14846 if (RHS.isInvalid())
14847 return true;
14848
14849 if (!getDerived().AlwaysRebuild() &&
14850 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
14851 return E;
14852
14853 return getDerived().RebuildCXXFoldExpr(
14854 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
14855 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
14856 }
14857
14858 // Formally a fold expression expands to nested parenthesized expressions.
14859 // Enforce this limit to avoid creating trees so deep we can't safely traverse
14860 // them.
14861 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < NumExpansions) {
14862 SemaRef.Diag(E->getEllipsisLoc(),
14863 clang::diag::err_fold_expression_limit_exceeded)
14864 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
14865 << E->getSourceRange();
14866 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
14867 return ExprError();
14868 }
14869
14870 // The transform has determined that we should perform an elementwise
14871 // expansion of the pattern. Do so.
14872 ExprResult Result = getDerived().TransformExpr(E->getInit());
14873 if (Result.isInvalid())
14874 return true;
14875 bool LeftFold = E->isLeftFold();
14876
14877 // If we're retaining an expansion for a right fold, it is the innermost
14878 // component and takes the init (if any).
14879 if (!LeftFold && RetainExpansion) {
14880 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
14881
14882 ExprResult Out = getDerived().TransformExpr(Pattern);
14883 if (Out.isInvalid())
14884 return true;
14885
14886 Result = getDerived().RebuildCXXFoldExpr(
14887 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
14888 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
14889 if (Result.isInvalid())
14890 return true;
14891 }
14892
14893 for (unsigned I = 0; I != *NumExpansions; ++I) {
14894 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(
14895 getSema(), LeftFold ? I : *NumExpansions - I - 1);
14896 ExprResult Out = getDerived().TransformExpr(Pattern);
14897 if (Out.isInvalid())
14898 return true;
14899
14900 if (Out.get()->containsUnexpandedParameterPack()) {
14901 // We still have a pack; retain a pack expansion for this slice.
14902 Result = getDerived().RebuildCXXFoldExpr(
14903 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
14904 E->getOperator(), E->getEllipsisLoc(),
14905 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
14906 OrigNumExpansions);
14907 } else if (Result.isUsable()) {
14908 // We've got down to a single element; build a binary operator.
14909 Expr *LHS = LeftFold ? Result.get() : Out.get();
14910 Expr *RHS = LeftFold ? Out.get() : Result.get();
14911 if (Callee) {
14912 UnresolvedSet<16> Functions;
14913 Functions.append(Callee->decls_begin(), Callee->decls_end());
14914 Result = getDerived().RebuildCXXOperatorCallExpr(
14915 BinaryOperator::getOverloadedOperator(E->getOperator()),
14916 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
14917 Functions, LHS, RHS);
14918 } else {
14919 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
14920 E->getOperator(), LHS, RHS);
14921 }
14922 } else
14923 Result = Out;
14924
14925 if (Result.isInvalid())
14926 return true;
14927 }
14928
14929 // If we're retaining an expansion for a left fold, it is the outermost
14930 // component and takes the complete expansion so far as its init (if any).
14931 if (LeftFold && RetainExpansion) {
14932 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
14933
14934 ExprResult Out = getDerived().TransformExpr(Pattern);
14935 if (Out.isInvalid())
14936 return true;
14937
14938 Result = getDerived().RebuildCXXFoldExpr(
14939 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
14940 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
14941 if (Result.isInvalid())
14942 return true;
14943 }
14944
14945 // If we had no init and an empty pack, and we're not retaining an expansion,
14946 // then produce a fallback value or error.
14947 if (Result.isUnset())
14948 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
14949 E->getOperator());
14950
14951 return Result;
14952}
14953
14954template <typename Derived>
14956TreeTransform<Derived>::TransformCXXParenListInitExpr(CXXParenListInitExpr *E) {
14957 SmallVector<Expr *, 4> TransformedInits;
14958 ArrayRef<Expr *> InitExprs = E->getInitExprs();
14959 if (TransformExprs(InitExprs.data(), InitExprs.size(), true,
14960 TransformedInits))
14961 return ExprError();
14962
14963 return getDerived().RebuildParenListExpr(E->getBeginLoc(), TransformedInits,
14964 E->getEndLoc());
14965}
14966
14967template<typename Derived>
14969TreeTransform<Derived>::TransformCXXStdInitializerListExpr(
14970 CXXStdInitializerListExpr *E) {
14971 return getDerived().TransformExpr(E->getSubExpr());
14972}
14973
14974template<typename Derived>
14976TreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) {
14977 return SemaRef.MaybeBindToTemporary(E);
14978}
14979
14980template<typename Derived>
14982TreeTransform<Derived>::TransformObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
14983 return E;
14984}
14985
14986template<typename Derived>
14988TreeTransform<Derived>::TransformObjCBoxedExpr(ObjCBoxedExpr *E) {
14989 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14990 if (SubExpr.isInvalid())
14991 return ExprError();
14992
14993 if (!getDerived().AlwaysRebuild() &&
14994 SubExpr.get() == E->getSubExpr())
14995 return E;
14996
14997 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
14998}
14999
15000template<typename Derived>
15002TreeTransform<Derived>::TransformObjCArrayLiteral(ObjCArrayLiteral *E) {
15003 // Transform each of the elements.
15004 SmallVector<Expr *, 8> Elements;
15005 bool ArgChanged = false;
15006 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
15007 /*IsCall=*/false, Elements, &ArgChanged))
15008 return ExprError();
15009
15010 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15011 return SemaRef.MaybeBindToTemporary(E);
15012
15013 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
15014 Elements.data(),
15015 Elements.size());
15016}
15017
15018template<typename Derived>
15020TreeTransform<Derived>::TransformObjCDictionaryLiteral(
15021 ObjCDictionaryLiteral *E) {
15022 // Transform each of the elements.
15024 bool ArgChanged = false;
15025 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
15026 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
15027
15028 if (OrigElement.isPackExpansion()) {
15029 // This key/value element is a pack expansion.
15031 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
15032 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
15033 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
15034
15035 // Determine whether the set of unexpanded parameter packs can
15036 // and should be expanded.
15037 bool Expand = true;
15038 bool RetainExpansion = false;
15039 std::optional<unsigned> OrigNumExpansions = OrigElement.NumExpansions;
15040 std::optional<unsigned> NumExpansions = OrigNumExpansions;
15041 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
15042 OrigElement.Value->getEndLoc());
15043 if (getDerived().TryExpandParameterPacks(OrigElement.EllipsisLoc,
15044 PatternRange, Unexpanded, Expand,
15045 RetainExpansion, NumExpansions))
15046 return ExprError();
15047
15048 if (!Expand) {
15049 // The transform has determined that we should perform a simple
15050 // transformation on the pack expansion, producing another pack
15051 // expansion.
15052 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
15053 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
15054 if (Key.isInvalid())
15055 return ExprError();
15056
15057 if (Key.get() != OrigElement.Key)
15058 ArgChanged = true;
15059
15060 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
15061 if (Value.isInvalid())
15062 return ExprError();
15063
15064 if (Value.get() != OrigElement.Value)
15065 ArgChanged = true;
15066
15067 ObjCDictionaryElement Expansion = {
15068 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
15069 };
15070 Elements.push_back(Expansion);
15071 continue;
15072 }
15073
15074 // Record right away that the argument was changed. This needs
15075 // to happen even if the array expands to nothing.
15076 ArgChanged = true;
15077
15078 // The transform has determined that we should perform an elementwise
15079 // expansion of the pattern. Do so.
15080 for (unsigned I = 0; I != *NumExpansions; ++I) {
15081 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
15082 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
15083 if (Key.isInvalid())
15084 return ExprError();
15085
15086 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
15087 if (Value.isInvalid())
15088 return ExprError();
15089
15090 ObjCDictionaryElement Element = {
15091 Key.get(), Value.get(), SourceLocation(), NumExpansions
15092 };
15093
15094 // If any unexpanded parameter packs remain, we still have a
15095 // pack expansion.
15096 // FIXME: Can this really happen?
15097 if (Key.get()->containsUnexpandedParameterPack() ||
15098 Value.get()->containsUnexpandedParameterPack())
15099 Element.EllipsisLoc = OrigElement.EllipsisLoc;
15100
15101 Elements.push_back(Element);
15102 }
15103
15104 // FIXME: Retain a pack expansion if RetainExpansion is true.
15105
15106 // We've finished with this pack expansion.
15107 continue;
15108 }
15109
15110 // Transform and check key.
15111 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
15112 if (Key.isInvalid())
15113 return ExprError();
15114
15115 if (Key.get() != OrigElement.Key)
15116 ArgChanged = true;
15117
15118 // Transform and check value.
15120 = getDerived().TransformExpr(OrigElement.Value);
15121 if (Value.isInvalid())
15122 return ExprError();
15123
15124 if (Value.get() != OrigElement.Value)
15125 ArgChanged = true;
15126
15127 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
15128 std::nullopt};
15129 Elements.push_back(Element);
15130 }
15131
15132 if (!getDerived().AlwaysRebuild() && !ArgChanged)
15133 return SemaRef.MaybeBindToTemporary(E);
15134
15135 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
15136 Elements);
15137}
15138
15139template<typename Derived>
15141TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) {
15142 TypeSourceInfo *EncodedTypeInfo
15143 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
15144 if (!EncodedTypeInfo)
15145 return ExprError();
15146
15147 if (!getDerived().AlwaysRebuild() &&
15148 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
15149 return E;
15150
15151 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
15152 EncodedTypeInfo,
15153 E->getRParenLoc());
15154}
15155
15156template<typename Derived>
15157ExprResult TreeTransform<Derived>::
15158TransformObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
15159 // This is a kind of implicit conversion, and it needs to get dropped
15160 // and recomputed for the same general reasons that ImplicitCastExprs
15161 // do, as well a more specific one: this expression is only valid when
15162 // it appears *immediately* as an argument expression.
15163 return getDerived().TransformExpr(E->getSubExpr());
15164}
15165
15166template<typename Derived>
15167ExprResult TreeTransform<Derived>::
15168TransformObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
15169 TypeSourceInfo *TSInfo
15170 = getDerived().TransformType(E->getTypeInfoAsWritten());
15171 if (!TSInfo)
15172 return ExprError();
15173
15174 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
15175 if (Result.isInvalid())
15176 return ExprError();
15177
15178 if (!getDerived().AlwaysRebuild() &&
15179 TSInfo == E->getTypeInfoAsWritten() &&
15180 Result.get() == E->getSubExpr())
15181 return E;
15182
15183 return SemaRef.BuildObjCBridgedCast(E->getLParenLoc(), E->getBridgeKind(),
15184 E->getBridgeKeywordLoc(), TSInfo,
15185 Result.get());
15186}
15187
15188template <typename Derived>
15189ExprResult TreeTransform<Derived>::TransformObjCAvailabilityCheckExpr(
15190 ObjCAvailabilityCheckExpr *E) {
15191 return E;
15192}
15193
15194template<typename Derived>
15196TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
15197 // Transform arguments.
15198 bool ArgChanged = false;
15200 Args.reserve(E->getNumArgs());
15201 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
15202 &ArgChanged))
15203 return ExprError();
15204
15205 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
15206 // Class message: transform the receiver type.
15207 TypeSourceInfo *ReceiverTypeInfo
15208 = getDerived().TransformType(E->getClassReceiverTypeInfo());
15209 if (!ReceiverTypeInfo)
15210 return ExprError();
15211
15212 // If nothing changed, just retain the existing message send.
15213 if (!getDerived().AlwaysRebuild() &&
15214 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
15215 return SemaRef.MaybeBindToTemporary(E);
15216
15217 // Build a new class message send.
15219 E->getSelectorLocs(SelLocs);
15220 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
15221 E->getSelector(),
15222 SelLocs,
15223 E->getMethodDecl(),
15224 E->getLeftLoc(),
15225 Args,
15226 E->getRightLoc());
15227 }
15228 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
15229 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
15230 if (!E->getMethodDecl())
15231 return ExprError();
15232
15233 // Build a new class message send to 'super'.
15235 E->getSelectorLocs(SelLocs);
15236 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
15237 E->getSelector(),
15238 SelLocs,
15239 E->getReceiverType(),
15240 E->getMethodDecl(),
15241 E->getLeftLoc(),
15242 Args,
15243 E->getRightLoc());
15244 }
15245
15246 // Instance message: transform the receiver
15247 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
15248 "Only class and instance messages may be instantiated");
15249 ExprResult Receiver
15250 = getDerived().TransformExpr(E->getInstanceReceiver());
15251 if (Receiver.isInvalid())
15252 return ExprError();
15253
15254 // If nothing changed, just retain the existing message send.
15255 if (!getDerived().AlwaysRebuild() &&
15256 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
15257 return SemaRef.MaybeBindToTemporary(E);
15258
15259 // Build a new instance message send.
15261 E->getSelectorLocs(SelLocs);
15262 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
15263 E->getSelector(),
15264 SelLocs,
15265 E->getMethodDecl(),
15266 E->getLeftLoc(),
15267 Args,
15268 E->getRightLoc());
15269}
15270
15271template<typename Derived>
15273TreeTransform<Derived>::TransformObjCSelectorExpr(ObjCSelectorExpr *E) {
15274 return E;
15275}
15276
15277template<typename Derived>
15279TreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) {
15280 return E;
15281}
15282
15283template<typename Derived>
15285TreeTransform<Derived>::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
15286 // Transform the base expression.
15287 ExprResult Base = getDerived().TransformExpr(E->getBase());
15288 if (Base.isInvalid())
15289 return ExprError();
15290
15291 // We don't need to transform the ivar; it will never change.
15292
15293 // If nothing changed, just retain the existing expression.
15294 if (!getDerived().AlwaysRebuild() &&
15295 Base.get() == E->getBase())
15296 return E;
15297
15298 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
15299 E->getLocation(),
15300 E->isArrow(), E->isFreeIvar());
15301}
15302
15303template<typename Derived>
15305TreeTransform<Derived>::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
15306 // 'super' and types never change. Property never changes. Just
15307 // retain the existing expression.
15308 if (!E->isObjectReceiver())
15309 return E;
15310
15311 // Transform the base expression.
15312 ExprResult Base = getDerived().TransformExpr(E->getBase());
15313 if (Base.isInvalid())
15314 return ExprError();
15315
15316 // We don't need to transform the property; it will never change.
15317
15318 // If nothing changed, just retain the existing expression.
15319 if (!getDerived().AlwaysRebuild() &&
15320 Base.get() == E->getBase())
15321 return E;
15322
15323 if (E->isExplicitProperty())
15324 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
15325 E->getExplicitProperty(),
15326 E->getLocation());
15327
15328 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
15329 SemaRef.Context.PseudoObjectTy,
15330 E->getImplicitPropertyGetter(),
15331 E->getImplicitPropertySetter(),
15332 E->getLocation());
15333}
15334
15335template<typename Derived>
15337TreeTransform<Derived>::TransformObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
15338 // Transform the base expression.
15339 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
15340 if (Base.isInvalid())
15341 return ExprError();
15342
15343 // Transform the key expression.
15344 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
15345 if (Key.isInvalid())
15346 return ExprError();
15347
15348 // If nothing changed, just retain the existing expression.
15349 if (!getDerived().AlwaysRebuild() &&
15350 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
15351 return E;
15352
15353 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
15354 Base.get(), Key.get(),
15355 E->getAtIndexMethodDecl(),
15356 E->setAtIndexMethodDecl());
15357}
15358
15359template<typename Derived>
15361TreeTransform<Derived>::TransformObjCIsaExpr(ObjCIsaExpr *E) {
15362 // Transform the base expression.
15363 ExprResult Base = getDerived().TransformExpr(E->getBase());
15364 if (Base.isInvalid())
15365 return ExprError();
15366
15367 // If nothing changed, just retain the existing expression.
15368 if (!getDerived().AlwaysRebuild() &&
15369 Base.get() == E->getBase())
15370 return E;
15371
15372 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
15373 E->getOpLoc(),
15374 E->isArrow());
15375}
15376
15377template<typename Derived>
15379TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) {
15380 bool ArgumentChanged = false;
15381 SmallVector<Expr*, 8> SubExprs;
15382 SubExprs.reserve(E->getNumSubExprs());
15383 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
15384 SubExprs, &ArgumentChanged))
15385 return ExprError();
15386
15387 if (!getDerived().AlwaysRebuild() &&
15388 !ArgumentChanged)
15389 return E;
15390
15391 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
15392 SubExprs,
15393 E->getRParenLoc());
15394}
15395
15396template<typename Derived>
15398TreeTransform<Derived>::TransformConvertVectorExpr(ConvertVectorExpr *E) {
15399 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
15400 if (SrcExpr.isInvalid())
15401 return ExprError();
15402
15403 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
15404 if (!Type)
15405 return ExprError();
15406
15407 if (!getDerived().AlwaysRebuild() &&
15408 Type == E->getTypeSourceInfo() &&
15409 SrcExpr.get() == E->getSrcExpr())
15410 return E;
15411
15412 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
15413 SrcExpr.get(), Type,
15414 E->getRParenLoc());
15415}
15416
15417template<typename Derived>
15419TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) {
15420 BlockDecl *oldBlock = E->getBlockDecl();
15421
15422 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
15423 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
15424
15425 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
15426 blockScope->TheDecl->setBlockMissingReturnType(
15427 oldBlock->blockMissingReturnType());
15428
15430 SmallVector<QualType, 4> paramTypes;
15431
15432 const FunctionProtoType *exprFunctionType = E->getFunctionType();
15433
15434 // Parameter substitution.
15435 Sema::ExtParameterInfoBuilder extParamInfos;
15436 if (getDerived().TransformFunctionTypeParams(
15437 E->getCaretLocation(), oldBlock->parameters(), nullptr,
15438 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
15439 extParamInfos)) {
15440 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
15441 return ExprError();
15442 }
15443
15444 QualType exprResultType =
15445 getDerived().TransformType(exprFunctionType->getReturnType());
15446
15447 auto epi = exprFunctionType->getExtProtoInfo();
15448 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
15449
15450 QualType functionType =
15451 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
15452 blockScope->FunctionType = functionType;
15453
15454 // Set the parameters on the block decl.
15455 if (!params.empty())
15456 blockScope->TheDecl->setParams(params);
15457
15458 if (!oldBlock->blockMissingReturnType()) {
15459 blockScope->HasImplicitReturnType = false;
15460 blockScope->ReturnType = exprResultType;
15461 }
15462
15463 // Transform the body
15464 StmtResult body = getDerived().TransformStmt(E->getBody());
15465 if (body.isInvalid()) {
15466 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
15467 return ExprError();
15468 }
15469
15470#ifndef NDEBUG
15471 // In builds with assertions, make sure that we captured everything we
15472 // captured before.
15473 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
15474 for (const auto &I : oldBlock->captures()) {
15475 VarDecl *oldCapture = I.getVariable();
15476
15477 // Ignore parameter packs.
15478 if (oldCapture->isParameterPack())
15479 continue;
15480
15481 VarDecl *newCapture =
15482 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
15483 oldCapture));
15484 assert(blockScope->CaptureMap.count(newCapture));
15485 }
15486
15487 // The this pointer may not be captured by the instantiated block, even when
15488 // it's captured by the original block, if the expression causing the
15489 // capture is in the discarded branch of a constexpr if statement.
15490 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
15491 "this pointer isn't captured in the old block");
15492 }
15493#endif
15494
15495 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
15496 /*Scope=*/nullptr);
15497}
15498
15499template<typename Derived>
15501TreeTransform<Derived>::TransformAsTypeExpr(AsTypeExpr *E) {
15502 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
15503 if (SrcExpr.isInvalid())
15504 return ExprError();
15505
15506 QualType Type = getDerived().TransformType(E->getType());
15507
15508 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
15509 E->getRParenLoc());
15510}
15511
15512template<typename Derived>
15514TreeTransform<Derived>::TransformAtomicExpr(AtomicExpr *E) {
15515 bool ArgumentChanged = false;
15516 SmallVector<Expr*, 8> SubExprs;
15517 SubExprs.reserve(E->getNumSubExprs());
15518 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
15519 SubExprs, &ArgumentChanged))
15520 return ExprError();
15521
15522 if (!getDerived().AlwaysRebuild() &&
15523 !ArgumentChanged)
15524 return E;
15525
15526 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
15527 E->getOp(), E->getRParenLoc());
15528}
15529
15530//===----------------------------------------------------------------------===//
15531// Type reconstruction
15532//===----------------------------------------------------------------------===//
15533
15534template<typename Derived>
15537 return SemaRef.BuildPointerType(PointeeType, Star,
15538 getDerived().getBaseEntity());
15539}
15540
15541template<typename Derived>
15544 return SemaRef.BuildBlockPointerType(PointeeType, Star,
15545 getDerived().getBaseEntity());
15546}
15547
15548template<typename Derived>
15551 bool WrittenAsLValue,
15552 SourceLocation Sigil) {
15553 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
15554 Sigil, getDerived().getBaseEntity());
15555}
15556
15557template<typename Derived>
15560 QualType ClassType,
15561 SourceLocation Sigil) {
15562 return SemaRef.BuildMemberPointerType(PointeeType, ClassType, Sigil,
15563 getDerived().getBaseEntity());
15564}
15565
15566template<typename Derived>
15568 const ObjCTypeParamDecl *Decl,
15569 SourceLocation ProtocolLAngleLoc,
15571 ArrayRef<SourceLocation> ProtocolLocs,
15572 SourceLocation ProtocolRAngleLoc) {
15573 return SemaRef.BuildObjCTypeParamType(Decl,
15574 ProtocolLAngleLoc, Protocols,
15575 ProtocolLocs, ProtocolRAngleLoc,
15576 /*FailOnError=*/true);
15577}
15578
15579template<typename Derived>
15581 QualType BaseType,
15582 SourceLocation Loc,
15583 SourceLocation TypeArgsLAngleLoc,
15585 SourceLocation TypeArgsRAngleLoc,
15586 SourceLocation ProtocolLAngleLoc,
15588 ArrayRef<SourceLocation> ProtocolLocs,
15589 SourceLocation ProtocolRAngleLoc) {
15590 return SemaRef.BuildObjCObjectType(BaseType, Loc, TypeArgsLAngleLoc, TypeArgs,
15591 TypeArgsRAngleLoc, ProtocolLAngleLoc,
15592 Protocols, ProtocolLocs, ProtocolRAngleLoc,
15593 /*FailOnError=*/true,
15594 /*Rebuilding=*/true);
15595}
15596
15597template<typename Derived>
15599 QualType PointeeType,
15601 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
15602}
15603
15604template <typename Derived>
15606 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
15607 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
15608 if (SizeExpr || !Size)
15609 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
15610 IndexTypeQuals, BracketsRange,
15611 getDerived().getBaseEntity());
15612
15613 QualType Types[] = {
15617 };
15618 QualType SizeType;
15619 for (const auto &T : Types)
15620 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
15621 SizeType = T;
15622 break;
15623 }
15624
15625 // Note that we can return a VariableArrayType here in the case where
15626 // the element type was a dependent VariableArrayType.
15627 IntegerLiteral *ArraySize
15628 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
15629 /*FIXME*/BracketsRange.getBegin());
15630 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
15631 IndexTypeQuals, BracketsRange,
15632 getDerived().getBaseEntity());
15633}
15634
15635template <typename Derived>
15637 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
15638 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
15639 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
15640 IndexTypeQuals, BracketsRange);
15641}
15642
15643template <typename Derived>
15645 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
15646 SourceRange BracketsRange) {
15647 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
15648 IndexTypeQuals, BracketsRange);
15649}
15650
15651template <typename Derived>
15653 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
15654 unsigned IndexTypeQuals, SourceRange BracketsRange) {
15655 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
15656 SizeExpr,
15657 IndexTypeQuals, BracketsRange);
15658}
15659
15660template <typename Derived>
15662 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
15663 unsigned IndexTypeQuals, SourceRange BracketsRange) {
15664 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
15665 SizeExpr,
15666 IndexTypeQuals, BracketsRange);
15667}
15668
15669template <typename Derived>
15671 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
15672 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
15673 AttributeLoc);
15674}
15675
15676template <typename Derived>
15678 unsigned NumElements,
15679 VectorKind VecKind) {
15680 // FIXME: semantic checking!
15681 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
15682}
15683
15684template <typename Derived>
15686 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
15687 VectorKind VecKind) {
15688 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
15689}
15690
15691template<typename Derived>
15693 unsigned NumElements,
15694 SourceLocation AttributeLoc) {
15695 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
15696 NumElements, true);
15697 IntegerLiteral *VectorSize
15698 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
15699 AttributeLoc);
15700 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
15701}
15702
15703template<typename Derived>
15706 Expr *SizeExpr,
15707 SourceLocation AttributeLoc) {
15708 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
15709}
15710
15711template <typename Derived>
15713 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
15714 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
15715 NumColumns);
15716}
15717
15718template <typename Derived>
15720 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
15721 SourceLocation AttributeLoc) {
15722 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
15723 AttributeLoc);
15724}
15725
15726template<typename Derived>
15728 QualType T,
15729 MutableArrayRef<QualType> ParamTypes,
15731 return SemaRef.BuildFunctionType(T, ParamTypes,
15732 getDerived().getBaseLocation(),
15733 getDerived().getBaseEntity(),
15734 EPI);
15735}
15736
15737template<typename Derived>
15739 return SemaRef.Context.getFunctionNoProtoType(T);
15740}
15741
15742template<typename Derived>
15744 Decl *D) {
15745 assert(D && "no decl found");
15746 if (D->isInvalidDecl()) return QualType();
15747
15748 // FIXME: Doesn't account for ObjCInterfaceDecl!
15749 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
15750 // A valid resolved using typename pack expansion decl can have multiple
15751 // UsingDecls, but they must each have exactly one type, and it must be
15752 // the same type in every case. But we must have at least one expansion!
15753 if (UPD->expansions().empty()) {
15754 getSema().Diag(Loc, diag::err_using_pack_expansion_empty)
15755 << UPD->isCXXClassMember() << UPD;
15756 return QualType();
15757 }
15758
15759 // We might still have some unresolved types. Try to pick a resolved type
15760 // if we can. The final instantiation will check that the remaining
15761 // unresolved types instantiate to the type we pick.
15762 QualType FallbackT;
15763 QualType T;
15764 for (auto *E : UPD->expansions()) {
15765 QualType ThisT = RebuildUnresolvedUsingType(Loc, E);
15766 if (ThisT.isNull())
15767 continue;
15768 else if (ThisT->getAs<UnresolvedUsingType>())
15769 FallbackT = ThisT;
15770 else if (T.isNull())
15771 T = ThisT;
15772 else
15773 assert(getSema().Context.hasSameType(ThisT, T) &&
15774 "mismatched resolved types in using pack expansion");
15775 }
15776 return T.isNull() ? FallbackT : T;
15777 } else if (auto *Using = dyn_cast<UsingDecl>(D)) {
15778 assert(Using->hasTypename() &&
15779 "UnresolvedUsingTypenameDecl transformed to non-typename using");
15780
15781 // A valid resolved using typename decl points to exactly one type decl.
15782 assert(++Using->shadow_begin() == Using->shadow_end());
15783
15784 UsingShadowDecl *Shadow = *Using->shadow_begin();
15785 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), Loc))
15786 return QualType();
15787 return SemaRef.Context.getUsingType(
15788 Shadow, SemaRef.Context.getTypeDeclType(
15789 cast<TypeDecl>(Shadow->getTargetDecl())));
15790 } else {
15791 assert(isa<UnresolvedUsingTypenameDecl>(D) &&
15792 "UnresolvedUsingTypenameDecl transformed to non-using decl");
15793 return SemaRef.Context.getTypeDeclType(
15794 cast<UnresolvedUsingTypenameDecl>(D));
15795 }
15796}
15797
15798template <typename Derived>
15800 TypeOfKind Kind) {
15801 return SemaRef.BuildTypeofExprType(E, Kind);
15802}
15803
15804template<typename Derived>
15806 TypeOfKind Kind) {
15807 return SemaRef.Context.getTypeOfType(Underlying, Kind);
15808}
15809
15810template <typename Derived>
15812 return SemaRef.BuildDecltypeType(E);
15813}
15814
15815template <typename Derived>
15817 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
15818 SourceLocation EllipsisLoc, bool FullySubstituted,
15819 ArrayRef<QualType> Expansions) {
15820 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
15821 FullySubstituted, Expansions);
15822}
15823
15824template<typename Derived>
15827 SourceLocation Loc) {
15828 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
15829}
15830
15831template<typename Derived>
15833 TemplateName Template,
15834 SourceLocation TemplateNameLoc,
15835 TemplateArgumentListInfo &TemplateArgs) {
15836 return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
15837}
15838
15839template<typename Derived>
15841 SourceLocation KWLoc) {
15842 return SemaRef.BuildAtomicType(ValueType, KWLoc);
15843}
15844
15845template<typename Derived>
15847 SourceLocation KWLoc,
15848 bool isReadPipe) {
15849 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
15850 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
15851}
15852
15853template <typename Derived>
15855 unsigned NumBits,
15856 SourceLocation Loc) {
15857 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
15858 NumBits, true);
15859 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
15860 SemaRef.Context.IntTy, Loc);
15861 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
15862}
15863
15864template <typename Derived>
15866 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
15867 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
15868}
15869
15870template<typename Derived>
15873 bool TemplateKW,
15874 TemplateDecl *Template) {
15875 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
15876 TemplateName(Template));
15877}
15878
15879template<typename Derived>
15882 SourceLocation TemplateKWLoc,
15883 const IdentifierInfo &Name,
15884 SourceLocation NameLoc,
15885 QualType ObjectType,
15886 NamedDecl *FirstQualifierInScope,
15887 bool AllowInjectedClassName) {
15889 TemplateName.setIdentifier(&Name, NameLoc);
15890 Sema::TemplateTy Template;
15891 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
15892 TemplateName, ParsedType::make(ObjectType),
15893 /*EnteringContext=*/false, Template,
15894 AllowInjectedClassName);
15895 return Template.get();
15896}
15897
15898template<typename Derived>
15901 SourceLocation TemplateKWLoc,
15902 OverloadedOperatorKind Operator,
15903 SourceLocation NameLoc,
15904 QualType ObjectType,
15905 bool AllowInjectedClassName) {
15906 UnqualifiedId Name;
15907 // FIXME: Bogus location information.
15908 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
15909 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
15910 Sema::TemplateTy Template;
15911 getSema().ActOnTemplateName(
15912 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
15913 /*EnteringContext=*/false, Template, AllowInjectedClassName);
15914 return Template.get();
15915}
15916
15917template <typename Derived>
15920 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
15921 Expr *Second) {
15922 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
15923
15924 if (First->getObjectKind() == OK_ObjCProperty) {
15927 return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc,
15928 First, Second);
15930 if (Result.isInvalid())
15931 return ExprError();
15932 First = Result.get();
15933 }
15934
15935 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
15936 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
15937 if (Result.isInvalid())
15938 return ExprError();
15939 Second = Result.get();
15940 }
15941
15942 // Determine whether this should be a builtin operation.
15943 if (Op == OO_Subscript) {
15944 if (!First->getType()->isOverloadableType() &&
15945 !Second->getType()->isOverloadableType())
15946 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
15947 OpLoc);
15948 } else if (Op == OO_Arrow) {
15949 // It is possible that the type refers to a RecoveryExpr created earlier
15950 // in the tree transformation.
15951 if (First->getType()->isDependentType())
15952 return ExprError();
15953 // -> is never a builtin operation.
15954 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
15955 } else if (Second == nullptr || isPostIncDec) {
15956 if (!First->getType()->isOverloadableType() ||
15957 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
15958 // The argument is not of overloadable type, or this is an expression
15959 // of the form &Class::member, so try to create a built-in unary
15960 // operation.
15962 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
15963
15964 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
15965 }
15966 } else {
15967 if (!First->getType()->isOverloadableType() &&
15968 !Second->getType()->isOverloadableType()) {
15969 // Neither of the arguments is an overloadable type, so try to
15970 // create a built-in binary operation.
15973 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
15974 if (Result.isInvalid())
15975 return ExprError();
15976
15977 return Result;
15978 }
15979 }
15980
15981 // Add any functions found via argument-dependent lookup.
15982 Expr *Args[2] = { First, Second };
15983 unsigned NumArgs = 1 + (Second != nullptr);
15984
15985 // Create the overloaded operator invocation for unary operators.
15986 if (NumArgs == 1 || isPostIncDec) {
15988 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
15989 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
15990 RequiresADL);
15991 }
15992
15993 // Create the overloaded operator invocation for binary operators.
15996 OpLoc, Opc, Functions, Args[0], Args[1], RequiresADL);
15997 if (Result.isInvalid())
15998 return ExprError();
15999
16000 return Result;
16001}
16002
16003template<typename Derived>
16006 SourceLocation OperatorLoc,
16007 bool isArrow,
16008 CXXScopeSpec &SS,
16009 TypeSourceInfo *ScopeType,
16010 SourceLocation CCLoc,
16011 SourceLocation TildeLoc,
16012 PseudoDestructorTypeStorage Destroyed) {
16013 QualType BaseType = Base->getType();
16014 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
16015 (!isArrow && !BaseType->getAs<RecordType>()) ||
16016 (isArrow && BaseType->getAs<PointerType>() &&
16017 !BaseType->castAs<PointerType>()->getPointeeType()
16018 ->template getAs<RecordType>())){
16019 // This pseudo-destructor expression is still a pseudo-destructor.
16020 return SemaRef.BuildPseudoDestructorExpr(
16021 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
16022 CCLoc, TildeLoc, Destroyed);
16023 }
16024
16025 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
16027 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
16028 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
16029 NameInfo.setNamedTypeInfo(DestroyedType);
16030
16031 // The scope type is now known to be a valid nested name specifier
16032 // component. Tack it on to the end of the nested name specifier.
16033 if (ScopeType) {
16034 if (!ScopeType->getType()->getAs<TagType>()) {
16035 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
16036 diag::err_expected_class_or_namespace)
16037 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
16038 return ExprError();
16039 }
16040 SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(),
16041 CCLoc);
16042 }
16043
16044 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
16045 return getSema().BuildMemberReferenceExpr(Base, BaseType,
16046 OperatorLoc, isArrow,
16047 SS, TemplateKWLoc,
16048 /*FIXME: FirstQualifier*/ nullptr,
16049 NameInfo,
16050 /*TemplateArgs*/ nullptr,
16051 /*S*/nullptr);
16052}
16053
16054template<typename Derived>
16057 SourceLocation Loc = S->getBeginLoc();
16058 CapturedDecl *CD = S->getCapturedDecl();
16059 unsigned NumParams = CD->getNumParams();
16060 unsigned ContextParamPos = CD->getContextParamPosition();
16062 for (unsigned I = 0; I < NumParams; ++I) {
16063 if (I != ContextParamPos) {
16064 Params.push_back(
16065 std::make_pair(
16066 CD->getParam(I)->getName(),
16067 getDerived().TransformType(CD->getParam(I)->getType())));
16068 } else {
16069 Params.push_back(std::make_pair(StringRef(), QualType()));
16070 }
16071 }
16072 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
16073 S->getCapturedRegionKind(), Params);
16074 StmtResult Body;
16075 {
16076 Sema::CompoundScopeRAII CompoundScope(getSema());
16077 Body = getDerived().TransformStmt(S->getCapturedStmt());
16078 }
16079
16080 if (Body.isInvalid()) {
16081 getSema().ActOnCapturedRegionError();
16082 return StmtError();
16083 }
16084
16085 return getSema().ActOnCapturedRegionEnd(Body.get());
16086}
16087
16088} // end namespace clang
16089
16090#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
int Id
Definition: ASTDiff.cpp:190
MatchType Type
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:1109
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
int Priority
Definition: Format.cpp:2975
unsigned Iter
Definition: HTMLLogger.cpp:154
#define X(type, name)
Definition: Value.h:143
llvm::MachO::Target Target
Definition: MachO.h:48
llvm::MachO::Record Record
Definition: MachO.h:31
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
This file declares semantic analysis for OpenACC constructs and clauses.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for SYCL constructs.
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
SourceLocation Begin
std::string Label
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1073
unsigned getIntWidth(QualType T) const
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType) const
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent, bool IsPack=false, ConceptDecl *TypeConstraintConcept=nullptr, ArrayRef< TemplateArgument > TypeConstraintArgs={}) const
C++11 deduced auto type.
QualType getDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, ArrayRef< TemplateArgumentLoc > Args) const
DeclarationNameTable DeclarationNames
Definition: ASTContext.h:648
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
QualType getArrayParameterType(QualType Ty) const
Return the uniqued reference to a specified array parameter type from the original array type.
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true)
Form a pack expansion type with the given pattern.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2574
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2590
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateName Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
Definition: ASTContext.h:1590
IdentifierTable & Idents
Definition: ASTContext.h:644
QualType getMacroQualifiedType(QualType UnderlyingTy, const IdentifierInfo *MacroII) const
QualType getDecayedType(QualType T) const
Return the uniqued reference to the decayed version of the given type.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
CanQualType UnsignedLongTy
Definition: ASTContext.h:1101
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CanQualType IntTy
Definition: ASTContext.h:1100
CanQualType PseudoObjectTy
Definition: ASTContext.h:1121
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:2156
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
CanQualType UnsignedInt128Ty
Definition: ASTContext.h:1102
CanQualType BuiltinFnTy
Definition: ASTContext.h:1120
CanQualType UnsignedCharTy
Definition: ASTContext.h:1101
CanQualType UnsignedIntTy
Definition: ASTContext.h:1101
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:1102
CanQualType UnsignedShortTy
Definition: ASTContext.h:1101
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
TemplateName getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final) const
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getTypeOfType(QualType QT, TypeOfKind Kind) const
getTypeOfType - Unlike many "get<Type>" functions, we don't unique TypeOfType nodes.
QualType getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex) const
Retrieve a substitution-result type.
QualType getConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns) const
Return the unique reference to the matrix type of the specified element type and size.
PtrTy get() const
Definition: Ownership.h:170
bool isInvalid() const
Definition: Ownership.h:166
bool isUsable() const
Definition: Ownership.h:168
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
Definition: ExprCXX.h:2846
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:2884
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2886
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2894
TypeSourceInfo * getQueriedTypeSourceInfo() const
Definition: ExprCXX.h:2890
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:2883
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2634
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2610
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2618
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2626
Attr - This represents one attribute.
Definition: Attr.h:42
attr::Kind getKind() const
Definition: Attr.h:88
SourceLocation getLocation() const
Definition: Attr.h:95
Represents an attribute applied to a statement.
Definition: Stmt.h:2080
Type source information for an attributed type.
Definition: TypeLoc.h:875
const Attr * getAttr() const
The type attribute.
Definition: TypeLoc.h:898
TypeLoc getModifiedLoc() const
The modified type, which is generally canonically different from the attribute type.
Definition: TypeLoc.h:889
TypeLoc getEquivalentTypeLoc() const
Definition: TypeLoc.h:893
void setAttr(const Attr *A)
Definition: TypeLoc.h:901
attr::Kind getAttrKind() const
Definition: TypeLoc.h:877
An attributed type is a type to which a type attribute has been applied.
Definition: Type.h:5600
QualType getModifiedType() const
Definition: Type.h:5622
std::optional< NullabilityKind > getImmediateNullability() const
Definition: Type.cpp:4764
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:5977
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
Definition: Type.h:5987
ConceptDecl * getTypeConstraintConcept() const
Definition: Type.h:5992
AutoTypeKeyword getKeyword() const
Definition: Type.h:6008
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition: Expr.cpp:2181
bool isAssignmentOp() const
Definition: Expr.h:3978
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:2143
void setIsVariadic(bool value)
Definition: Decl.h:4571
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1128
QualType desugar() const
Definition: Type.h:3205
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:5258
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5277
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5276
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1485
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:28
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1540
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1708
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1683
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1633
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:519
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:513
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1622
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1680
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2535
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition: ExprCXX.cpp:969
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1731
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:372
SourceLocation getOperatorLoc() const
Retrieve the location of the cast operator keyword, e.g., static_cast.
Definition: ExprCXX.h:403
SourceRange getAngleBrackets() const LLVM_READONLY
Definition: ExprCXX.h:410
SourceLocation getRParenLoc() const
Retrieve the location of the closing parenthesis.
Definition: ExprCXX.h:406
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition: DeclCXX.h:1856
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
Definition: ExprCXX.h:2175
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:73
char * location_data() const
Retrieve the data associated with the source-location information.
Definition: DeclSpec.h:235
SourceRange getRange() const
Definition: DeclSpec.h:79
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: DeclSpec.cpp:104
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition: DeclSpec.cpp:152
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:94
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition: DeclSpec.h:239
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition: DeclSpec.cpp:114
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form 'type...
Definition: DeclSpec.cpp:54
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:132
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:797
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3526
SourceLocation getLParenLoc() const
Retrieve the location of the left parentheses ('(') that precedes the argument list.
Definition: ExprCXX.h:3570
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3581
TypeSourceInfo * getTypeSourceInfo() const
Retrieve the type source information for the type being constructed.
Definition: ExprCXX.h:3564
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (')') that follows the argument list.
Definition: ExprCXX.h:3575
unsigned getNumArgs() const
Retrieve the number of arguments.
Definition: ExprCXX.h:3584
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
Definition: Expr.cpp:1494
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4687
unsigned getNumParams() const
Definition: Decl.h:4729
unsigned getContextParamPosition() const
Definition: Decl.h:4758
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4731
This captures a statement into a function.
Definition: Stmt.h:3757
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition: Expr.cpp:1981
Expr * getSubExpr()
Definition: Expr.h:3533
SourceLocation getBegin() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1606
Declaration of a C++20 concept.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Definition: ASTConcept.cpp:93
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:421
Expr * getCountExpr() const
Definition: TypeLoc.h:1142
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Definition: Type.h:3243
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1369
reference front() const
Definition: DeclBase.h:1392
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1436
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1784
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1698
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1260
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1497
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
bool isInvalidDecl() const
Definition: DeclBase.h:594
SourceLocation getLocation() const
Definition: DeclBase.h:445
DeclContext * getDeclContext()
Definition: DeclBase.h:454
AccessSpecifier getAccess() const
Definition: DeclBase.h:513
DeclarationName getCXXDestructorName(CanQualType Ty)
Returns the name of a C++ destructor for the given Type.
DeclarationName getCXXSpecialName(DeclarationName::NameKind Kind, CanQualType Ty)
Returns a declaration name for special kind of C++ name, e.g., for a constructor, destructor,...
DeclarationName getCXXDeductionGuideName(TemplateDecl *TD)
Returns the name of a C++ deduction guide for the given template.
The name of a declaration.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition: Decl.h:813
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:799
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1898
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
Definition: Type.h:5964
bool isDeduced() const
Definition: Type.h:5965
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3292
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3366
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the name, with source location information.
Definition: ExprCXX.h:3340
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3358
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:3376
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3350
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3393
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3331
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3386
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:3328
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:488
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2472
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2496
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2492
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2488
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2460
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2516
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2456
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2508
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2524
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2500
Represents a template specialization type whose template cannot be resolved, e.g.
Definition: Type.h:6500
Designation - Represent a full designation, which is a sequence of designators.
Definition: Designator.h:208
static Designator CreateArrayRangeDesignator(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Creates a GNU array-range designator.
Definition: Designator.h:172
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
Definition: Designator.h:142
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
Definition: Designator.h:115
bool hasErrorOccurred() const
Definition: Diagnostic.h:843
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2319
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2331
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2323
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2361
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2337
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Definition: Type.h:6367
RAII object that enters a new expression evaluation context.
Represents an enum.
Definition: Decl.h:3868
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition: Expr.h:3752
This represents one expression.
Definition: Expr.h:110
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Definition: Expr.h:192
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
Definition: Expr.h:444
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition: Expr.cpp:3154
QualType getType() const
Definition: Expr.h:142
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
Definition: Expr.h:516
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
Definition: Expr.h:427
Represents difference between two FPOptions values.
Definition: LangOptions.h:915
Represents a member of a struct/union/class.
Definition: Decl.h:3058
Represents a function declaration or definition.
Definition: Decl.h:1971
QualType getReturnType() const
Definition: Decl.h:2755
QualType getCallResultType() const
Determine the type of an expression that calls this function.
Definition: Decl.h:2791
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition: Type.h:4607
Represents a prototype with parameter type info, e.g.
Definition: Type.h:4652
QualType desugar() const
Definition: Type.h:5119
param_type_iterator param_type_begin() const
Definition: Type.h:5044
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present,...
Definition: Type.h:5082
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:5024
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:4896
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:4892
unsigned getNumParams() const
Definition: TypeLoc.h:1500
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1452
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1448
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1464
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1480
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1507
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1491
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1472
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1456
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1486
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1509
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1444
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1460
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1468
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition: Type.h:4278
QualType getReturnType() const
Definition: Type.h:4569
AssociationTy< false > Association
Definition: Expr.h:5956
One of these records is kept for each identifier that is lexed.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:3655
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5600
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:514
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition: Expr.cpp:977
Represents the declaration of a label.
Definition: Decl.h:499
Describes the capture of a variable or of this, or of a C++1y init-capture.
Definition: LambdaCapture.h:25
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1948
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:1295
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda's captures is an init-capture.
Definition: ExprCXX.cpp:1290
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:1299
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition: ExprCXX.h:2013
Represents the results of name lookup.
Definition: Lookup.h:46
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
Definition: Lookup.h:63
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
Definition: Lookup.h:68
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
Definition: Lookup.h:73
@ NotFound
No entity found met the criteria.
Definition: Lookup.h:50
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition: Lookup.h:55
@ Found
Name lookup found a single declaration that met the criteria.
Definition: Lookup.h:59
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
Definition: Lookup.h:603
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition: Lookup.h:475
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Definition: SemaLookup.cpp:484
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4686
This represents a decl that may have a name.
Definition: Decl.h:249
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:270
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:276
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:315
Represents a C++ namespace alias.
Definition: DeclCXX.h:3120
Represent a C++ namespace.
Definition: Decl.h:547
A C++ nested-name-specifier augmented with source location information.
SourceLocation getBeginLoc() const
Retrieve the location of the beginning of this nested-name-specifier.
SourceLocation getLocalEndLoc() const
Retrieve the location of the end of this component of the nested-name-specifier.
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
TypeLoc getTypeLoc() const
For a nested-name-specifier that refers to a type, retrieve the type with source-location information...
void * getOpaqueData() const
Retrieve the opaque pointer that refers to source-location data.
NestedNameSpecifier * getNestedNameSpecifier() const
Retrieve the nested-name-specifier to which this instance refers.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
@ NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
@ TypeSpec
A type, stored as a Type*.
@ TypeSpecWithTemplate
A type that was preceded by the 'template' keyword, stored as a Type*.
@ Super
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Identifier
An identifier, stored as an IdentifierInfo*.
@ Global
The global specifier '::'. There is no stored value.
@ Namespace
A namespace, stored as a NamespaceDecl*.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:55
This is a basic class for representing single OpenMP executable directive.
Definition: StmtOpenMP.h:266
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
Definition: StmtOpenMP.h:531
OpenMPDirectiveKind getDirectiveKind() const
Definition: StmtOpenMP.h:569
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
Definition: StmtOpenMP.h:534
SourceLocation getBeginLoc() const
Returns starting location of directive kind.
Definition: StmtOpenMP.h:502
const Stmt * getRawStmt() const
Definition: StmtOpenMP.h:606
ArrayRef< OMPClause * > clauses() const
Definition: StmtOpenMP.h:586
OpenMPDirectiveKind getMappedDirective() const
Definition: StmtOpenMP.h:615
SourceLocation getEndLoc() const
Returns ending location of directive.
Definition: StmtOpenMP.h:504
This represents clauses with a list of expressions that are mappable.
This represents '#pragma omp metadirective' directive.
Definition: StmtOpenMP.h:5943
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1950
@ SuperInstance
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:959
@ Instance
The receiver is an object instance.
Definition: ExprObjC.h:953
@ SuperClass
The receiver is a superclass.
Definition: ExprObjC.h:956
@ Class
The receiver is a class.
Definition: ExprObjC.h:950
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
bool isInstanceMethod() const
Definition: DeclObjC.h:426
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:730
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:617
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:578
@ Array
An index into an array.
Definition: Expr.h:2364
@ Identifier
A field in a dependent type, known only by its name.
Definition: Expr.h:2368
@ Field
A field.
Definition: Expr.h:2366
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition: Expr.h:2371
Wrapper for void* pointer.
Definition: Ownership.h:50
PtrTy get() const
Definition: Ownership.h:80
static OpaquePtr make(QualType P)
Definition: Ownership.h:60
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
Definition: Expr.h:1168
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1218
This is the base type for all OpenACC Clauses.
Definition: OpenACCClause.h:22
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCNumGangsClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > IntExprs, SourceLocation EndLoc)
static OpenACCNumWorkersClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition: ExprCXX.h:2976
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:3127
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3109
SourceLocation getNameLoc() const
Gets the location of the name.
Definition: ExprCXX.h:3088
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3101
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition: ExprCXX.h:3097
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3129
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:3074
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3135
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:3085
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3117
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4149
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2582
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2578
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2594
Represents a pack expansion of types.
Definition: Type.h:6565
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:6590
ParenExpr - This represents a parethesized expression, e.g.
Definition: Expr.h:2130
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition: Expr.h:2153
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition: Expr.h:2157
Represents a parameter to a function.
Definition: Decl.h:1761
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1821
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1794
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition: Decl.cpp:2915
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1811
void setSigilLoc(SourceLocation Loc)
Definition: TypeLoc.h:1278
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1282
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1274
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:3135
QualType getPointeeType() const
Definition: Type.h:3145
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2559
const IdentifierInfo * getIdentifier() const
Definition: ExprCXX.h:2579
SourceLocation getLocation() const
Definition: ExprCXX.h:2583
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2575
A (possibly-)qualified type.
Definition: Type.h:940
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:1007
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:7395
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:7449
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition: Type.h:7387
Represents a template name that was expressed as a qualified name.
Definition: TemplateName.h:431
Wrapper of type source information for a type with non-trivial direct qualifiers.
Definition: TypeLoc.h:289
The collection of all-type qualifiers we support.
Definition: Type.h:318
void removeObjCLifetime()
Definition: Type.h:537
bool hasRestrict() const
Definition: Type.h:463
static Qualifiers fromCVRMask(unsigned CVR)
Definition: Type.h:421
bool hasObjCLifetime() const
Definition: Type.h:530
bool empty() const
Definition: Type.h:633
LangAS getAddressSpace() const
Definition: Type.h:557
Represents a struct/union/class.
Definition: Decl.h:4169
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:5545
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:3376
QualType getPointeeTypeAsWritten() const
Definition: Type.h:3392
Represents the body of a requires-expression.
Definition: DeclCXX.h:2029
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition: DeclCXX.cpp:2174
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:510
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition: Stmt.cpp:1275
Represents a __leave statement.
Definition: Stmt.h:3718
Smart pointer class that efficiently represents Objective-C method names.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
Definition: SemaBase.cpp:56
SourceLocation getEndLoc() const
Definition: SemaOpenACC.h:68
void setLParenLoc(SourceLocation EndLoc)
Definition: SemaOpenACC.h:115
void setConditionDetails(Expr *ConditionExpr)
Definition: SemaOpenACC.h:124
const Expr * getConditionExpr() const
Definition: SemaOpenACC.h:76
SourceLocation getLParenLoc() const
Definition: SemaOpenACC.h:66
SourceLocation getBeginLoc() const
Definition: SemaOpenACC.h:64
void setDefaultDetails(OpenACCDefaultClauseKind DefKind)
Definition: SemaOpenACC.h:118
void setEndLoc(SourceLocation EndLoc)
Definition: SemaOpenACC.h:116
void setIntExprDetails(ArrayRef< Expr * > IntExprs)
Definition: SemaOpenACC.h:138
OpenACCDefaultClauseKind getDefaultClauseKind() const
Definition: SemaOpenACC.h:70
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
OMPClause * ActOnOpenMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nocontext' clause.
OMPClause * ActOnOpenMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_dyn_cgroup_mem' clause.
OMPClause * ActOnOpenMPSafelenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'safelen' clause.
OMPClause * ActOnOpenMPDefaultClause(llvm::omp::DefaultKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'default' clause.
OMPClause * ActOnOpenMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'filter' clause.
OMPClause * ActOnOpenMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on well-form 'full' clauses.
OMPClause * ActOnOpenMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'detach' clause.
OMPClause * ActOnOpenMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'use' clause.
OMPClause * ActOnOpenMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'private' clause.
OMPClause * ActOnOpenMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc=SourceLocation(), Expr *NumForLoops=nullptr)
Called on well-formed 'ordered' clause.
OMPClause * ActOnOpenMPReductionClause(ArrayRef< Expr * > VarList, OpenMPReductionClauseModifier Modifier, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions=std::nullopt)
Called on well-formed 'reduction' clause.
OMPClause * ActOnOpenMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'is_device_ptr' clause.
OMPClause * ActOnOpenMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'has_device_addr' clause.
OMPClause * ActOnOpenMPPartialClause(Expr *FactorExpr, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'partial' clauses.
OMPClause * ActOnOpenMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'lastprivate' clause.
OMPClause * ActOnOpenMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'firstprivate' clause.
OMPClause * ActOnOpenMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'priority' clause.
OMPClause * ActOnOpenMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'dist_schedule' clause.
OMPClause * ActOnOpenMPAllocateClause(Expr *Allocator, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nontemporal' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'shared' clause.
OMPClause * ActOnOpenMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyin' clause.
OMPClause * ActOnOpenMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'destroy' clause.
OMPClause * ActOnOpenMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Called on well-formed 'affinity' clause.
OMPClause * ActOnOpenMPDependClause(const OMPDependClause::DependDataTy &Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depend' clause.
OMPClause * ActOnOpenMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'doacross' clause.
OMPClause * ActOnOpenMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'grainsize' clause.
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
OMPClause * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers=std::nullopt)
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers=std::nullopt)
Called on well-formed 'to' clause.
ExprResult ActOnOMPIteratorExpr(Scope *S, SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< OMPIteratorData > Data)
OMPClause * ActOnOpenMPUsesAllocatorClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, ArrayRef< UsesAllocatorsData > Data)
Called on well-formed 'uses_allocators' clause.
OMPClause * ActOnOpenMPAllocatorClause(Expr *Allocator, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocator' clause.
OMPClause * ActOnOpenMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'inclusive' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' clause.
OMPClause * ActOnOpenMPSizesClause(ArrayRef< Expr * > SizeExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'sizes' clause.
OMPClause * ActOnOpenMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'device' clause.
OMPClause * ActOnOpenMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_threads' clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, OpenMPDirectiveKind PrevMappedDirective=llvm::omp::OMPD_unknown)
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
OMPClause * ActOnOpenMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' clause.
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' clause.
OMPClause * ActOnOpenMPMapClause(Expr *IteratorModifier, ArrayRef< OpenMPMapModifierKind > MapTypeModifiers, ArrayRef< SourceLocation > MapTypeModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, OpenMPMapClauseKind MapType, bool IsMapTypeImplicit, SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, bool NoDiagnose=false, ArrayRef< Expr * > UnresolvedMappers=std::nullopt)
Called on well-formed 'map' clause.
OMPClause * ActOnOpenMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions=std::nullopt)
Called on well-formed 'task_reduction' clause.
OMPClause * ActOnOpenMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Called on well-formed 'schedule' clause.
OMPClause * ActOnOpenMPSimdlenClause(Expr *Length, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'simdlen' clause.
OMPClause * ActOnOpenMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_ptr' clause.
OMPClause * ActOnOpenMPProcBindClause(llvm::omp::ProcBindKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'proc_bind' clause.
OMPClause * ActOnOpenMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_bare' clause.
StmtResult ActOnOpenMPCanonicalLoop(Stmt *AStmt)
Called for syntactical loops (ForStmt or CXXForRangeStmt) associated to an OpenMP loop directive.
OMPClause * ActOnOpenMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'hint' clause.
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
OMPClause * ActOnOpenMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'at' clause.
OMPClause * ActOnOpenMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Called on well-formed 'init' clause.
OMPClause * ActOnOpenMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Called on well-formed 'use_device_addr' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' clause.
OMPClause * ActOnOpenMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Called on well-formed 'num_tasks' clause.
OMPClause * ActOnOpenMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'severity' clause.
OMPClause * ActOnOpenMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind LinKind, SourceLocation LinLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Called on well-formed 'linear' clause.
OMPClause * ActOnOpenMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'defaultmap' clause.
OMPClause * ActOnOpenMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'aligned' clause.
OMPClause * ActOnOpenMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'depobj' pseudo clause.
OMPClause * ActOnOpenMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'novariants' clause.
OMPClause * ActOnOpenMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'copyprivate' clause.
OMPClause * ActOnOpenMPCollapseClause(Expr *NumForLoops, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'collapse' clause.
OMPClause * ActOnOpenMPAlignClause(Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'align' clause.
OMPClause * ActOnOpenMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'ompx_attribute' clause.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions=std::nullopt)
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPThreadLimitClause(Expr *ThreadLimit, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition: SemaSYCL.cpp:137
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:10305
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:6552
A RAII object to enter scope of a compound statement.
Definition: Sema.h:865
A helper class for building up ExtParameterInfos.
Definition: Sema.h:9758
const FunctionProtoType::ExtParameterInfo * getPointerOrNull(unsigned numParams)
Return a pointer (suitable for setting in an ExtProtoInfo) to the ExtParameterInfo array we've built ...
Definition: Sema.h:9777
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:9765
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:10556
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:457
QualType BuildParenType(QualType T)
Build a paren type including T.
Definition: SemaType.cpp:2065
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6794
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
bool CheckSpecifiedExceptionType(QualType &T, SourceRange Range)
CheckSpecifiedExceptionType - Check if the given type is valid in an exception specification.
ExprResult BuildOperatorCoawaitCall(SourceLocation Loc, Expr *E, UnresolvedLookupExpr *Lookup)
Build a call to 'operator co_await' if there is a suitable operator for the given expression.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
StmtResult BuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Definition: SemaStmt.cpp:4748
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:7376
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:7384
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:7379
bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend)
Check that the expression co_await promise.final_suspend() shall not be potentially-throwing.
QualType BuildAddressSpaceAttr(QualType &T, LangAS ASIdx, Expr *AddrSpace, SourceLocation AttrLoc)
BuildAddressSpaceAttr - Builds a DependentAddressSpaceType if an expression is uninstantiated.
Definition: SemaType.cpp:6903
ExprResult ActOnConstantExpression(ExprResult Res)
Definition: SemaExpr.cpp:19890
StmtResult ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation LBraceLoc, ArrayRef< Token > AsmToks, StringRef AsmString, unsigned NumOutputs, unsigned NumInputs, ArrayRef< StringRef > Constraints, ArrayRef< StringRef > Clobbers, ArrayRef< Expr * > Exprs, SourceLocation EndLoc)
StmtResult BuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs)
ExprResult BuildCoyieldExpr(SourceLocation KwLoc, Expr *E)
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition: SemaStmt.cpp:4383
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
Definition: SemaType.cpp:2771
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:606
SemaOpenMP & OpenMP()
Definition: Sema.h:1013
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:6877
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:6881
@ IER_Error
An error occurred.
Definition: Sema.h:6884
@ IER_Exists
The symbol exists.
Definition: Sema.h:6874
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:16097
void ActOnStmtExprError()
Definition: SemaExpr.cpp:16103
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:2313
VarDecl * buildCoroutinePromise(SourceLocation Loc)
QualType BuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError, bool Rebuilding)
Build an Objective-C object pointer type.
Definition: SemaType.cpp:1089
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
Definition: SemaExpr.cpp:20639
ConditionKind
Definition: Sema.h:5898
@ Boolean
A boolean condition, from 'if', 'while', 'for', or 'do'.
@ Switch
An integral condition for a 'switch' statement.
@ ConstexprIf
A constant boolean condition from 'if constexpr'.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
ExprResult BuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Operand, SourceLocation RParenLoc)
Definition: SemaCast.cpp:395
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3323
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor,...
StmtResult BuildCoreturnStmt(SourceLocation KwLoc, Expr *E, bool IsImplicit=false)
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
Definition: SemaStmt.cpp:463
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Definition: SemaType.cpp:2845
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3368
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt=std::nullopt)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
Definition: SemaExpr.cpp:20424
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
Definition: SemaExpr.cpp:16116
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists),...
ExprResult BuildResolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, Expr *Awaiter, bool IsImplicit=false)
SemaSYCL & SYCL()
Definition: Sema.h:1018
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16769
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition: SemaStmt.cpp:4339
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression.
ASTContext & Context
Definition: Sema.h:858
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
QualType BuildFunctionType(QualType T, MutableArrayRef< QualType > ParamTypes, SourceLocation Loc, DeclarationName Entity, const FunctionProtoType::ExtProtoInfo &EPI)
Build a function type.
Definition: SemaType.cpp:3084
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
Definition: SemaExpr.cpp:2946
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:524
concepts::TypeRequirement * BuildTypeRequirement(TypeSourceInfo *Type)
TypeSourceInfo * CheckPackExpansion(TypeSourceInfo *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Construct a pack expansion type from the pattern of the pack expansion.
ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition: SemaStmt.cpp:4439
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
ASTContext & getASTContext() const
Definition: Sema.h:527
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input, bool IsAfterAmp=false)
Definition: SemaExpr.cpp:16032
ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C class message expression.
ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
StmtResult ActOnSEHTryBlock(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
Definition: SemaStmt.cpp:4672
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
Definition: Sema.cpp:645
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Definition: SemaExpr.cpp:3736
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
Definition: SemaExpr.cpp:7244
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:16084
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
Definition: SemaExpr.cpp:8151
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
Definition: SemaDecl.cpp:17127
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
Definition: SemaExpr.cpp:2206
QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc)
Build a bit-precise integer type.
Definition: SemaType.cpp:2380
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16372
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
ControllingExprOrType is either a TypeSourceInfo * or an Expr *.
Definition: SemaExpr.cpp:1675
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
Definition: SemaType.cpp:1970
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Definition: SemaStmt.cpp:1245
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:63
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition: SemaStmt.cpp:4321
const LangOptions & getLangOpts() const
Definition: Sema.h:520
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:1719
SemaOpenACC & OpenACC()
Definition: Sema.h:1008
@ ReuseLambdaContextDecl
Definition: Sema.h:5233
ExprResult BuildCXXFoldExpr(UnresolvedLookupExpr *Callee, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
bool isPotentialImplicitMemberAccess(const CXXScopeSpec &SS, LookupResult &R, bool IsAddressOfOperand)
Check whether an expression might be an implicit class member access.
void collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument.
ExprResult BuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
Definition: SemaExpr.cpp:17043
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition: SemaStmt.cpp:3112
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
Definition: SemaExpr.cpp:16186
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2360
ExprResult ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ConvertVectorExpr - Handle __builtin_convertvector.
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo &II, SourceLocation IILoc, TypeSourceInfo **TSI, bool DeducedTSTContext)
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
DeclContext * getCurLexicalContext() const
Definition: Sema.h:702
ExprResult BuildUnresolvedCoawaitExpr(SourceLocation KwLoc, Expr *Operand, UnresolvedLookupExpr *Lookup)
NonTagKind getNonTagTypeDeclKind(const Decl *D, TagTypeKind TTK)
Given a non-tag type declaration, returns an enum useful for indicating what kind of non-tag type thi...
Definition: SemaDecl.cpp:17098
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
bool buildCoroutineParameterMoves(SourceLocation Loc)
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
Definition: SemaCast.cpp:3340
ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a Microsoft __uuidof expression with a type operand.
sema::FunctionScopeInfo * getCurFunction() const
Definition: Sema.h:892
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Definition: SemaDecl.cpp:15030
Expr * BuildCXXThisExpr(SourceLocation Loc, QualType Type, bool IsImplicit)
Build a CXXThisExpr and mark it referenced in the current context.
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
Definition: SemaType.cpp:2273
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input, bool RequiresADL=true)
Create a unary operation that may resolve to an overloaded operator.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:10299
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
Definition: SemaExpr.cpp:3432
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition: Sema.cpp:2316
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:996
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
bool BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, NamedDecl *ScopeLookupResult, bool ErrorRecoveryLookup, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
Build a new nested-name-specifier for "identifier::", as described by ActOnCXXNestedNameSpecifier.
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool EmptyPack=false)
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
Definition: SemaExpr.cpp:20258
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen)
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:2164
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
Definition: SemaStmt.cpp:3338
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
Definition: SemaExpr.cpp:4339
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:21227
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:3161
@ NTK_TypeAliasTemplate
Definition: Sema.h:3169
TryCaptureKind
Definition: Sema.h:5275
@ TryCapture_Implicit
Definition: Sema.h:5276
@ TryCapture_ExplicitByVal
Definition: Sema.h:5277
@ TryCapture_ExplicitByRef
Definition: Sema.h:5278
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
Definition: SemaExpr.cpp:6886
ExprResult checkPseudoObjectRValue(Expr *E)
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
bool CheckRebuiltStmtAttributes(ArrayRef< const Attr * > Attrs)
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
Definition: SemaExpr.cpp:9166
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Definition: SemaType.cpp:9908
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
concepts::ExprRequirement * BuildExprRequirement(Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement)
QualType BuildAtomicType(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:10191
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
Definition: SemaDecl.cpp:14020
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReciever=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
Definition: SemaExpr.cpp:227
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition: SemaStmt.cpp:4316
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
Definition: SemaStmt.cpp:4018
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
ExprResult BuildPseudoDestructorExpr(Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
QualType BuildPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a pointer type.
Definition: SemaType.cpp:2208
StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, SourceLocation ColonLoc, Stmt *RangeDecl, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVarDecl, SourceLocation RParenLoc, BuildForRangeKind Kind, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps={})
BuildCXXForRangeStmt - Build or instantiate a C++11 for-range statement.
Definition: SemaStmt.cpp:2774
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
Definition: SemaStmt.cpp:1740
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:1121
ExprResult BuiltinShuffleVector(CallExpr *TheCall)
BuiltinShuffleVector - Handle __builtin_shufflevector.
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ ImmediateFunctionContext
In addition of being constant evaluated, the current expression occurs in an immediate function conte...
QualType BuildDecltypeType(Expr *E, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
Definition: SemaType.cpp:9876
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:10135
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4710
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
Definition: SemaExpr.cpp:4842
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition: SemaStmt.cpp:78
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:6438
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
ExprResult BuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
QualType BuildArrayType(QualType T, ArraySizeModifier ASM, Expr *ArraySize, unsigned Quals, SourceRange Brackets, DeclarationName Entity)
Build an array type.
Definition: SemaType.cpp:2503
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5788
QualType BuildReadPipeType(QualType T, SourceLocation Loc)
Build a Read-only Pipe type.
Definition: SemaType.cpp:2356
concepts::NestedRequirement * BuildNestedRequirement(Expr *E)
QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError=false)
Build an Objective-C type parameter type.
Definition: SemaType.cpp:1066
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
Definition: SemaType.cpp:2368
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:8580
ExprResult CheckConceptTemplateId(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, const TemplateArgumentListInfo *TemplateArgs)
void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt)
ActOnCaseStmtBody - This installs a statement as the body of a case.
Definition: SemaStmt.cpp:547
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
Definition: SemaExpr.cpp:16573
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
Definition: SemaType.cpp:9770
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Definition: SemaExpr.cpp:20281
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition: SemaCast.cpp:297
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
Definition: SemaExpr.cpp:18360
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
Definition: SemaType.cpp:2905
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
Definition: SemaExpr.cpp:21454
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15596
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition: SemaStmt.cpp:4305
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:3212
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:908
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7437
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:16411
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
Definition: SemaExpr.cpp:5066
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
Definition: SemaExpr.cpp:15065
ExprResult BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange, SourceLocation RParenLoc, MultiExprArg Args, AtomicExpr::AtomicOp Op, AtomicArgumentOrder ArgOrder=AtomicArgumentOrder::API)
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
Definition: SemaExpr.cpp:6618
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
Definition: SemaType.cpp:3222
static ConditionResult ConditionError()
Definition: Sema.h:5885
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition: SemaStmt.cpp:414
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition: SemaStmt.cpp:4421
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:572
StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
ActOnCXXTryBlock - Takes a try compound-statement and a number of handlers and creates a try statemen...
Definition: SemaStmt.cpp:4559
QualType BuildCountAttributedArrayType(QualType WrappedTy, Expr *CountExpr)
Definition: SemaType.cpp:9793
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition: SemaStmt.cpp:552
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
Definition: SemaExpr.cpp:18185
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition: SemaStmt.cpp:515
ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C instance message expression.
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
Definition: SemaType.cpp:3142
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Definition: SemaType.cpp:3205
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3305
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Definition: Sema.h:6733
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
Definition: SemaExpr.cpp:5241
StmtResult ActOnGCCAsmStmt(SourceLocation AsmLoc, bool IsSimple, bool IsVolatile, unsigned NumOutputs, unsigned NumInputs, IdentifierInfo **Names, MultiExprArg Constraints, MultiExprArg Exprs, Expr *AsmString, MultiExprArg Clobbers, unsigned NumLabels, SourceLocation RParenLoc)
static SizeOfPackExpr * Create(ASTContext &Context, SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, std::optional< unsigned > Length=std::nullopt, ArrayRef< TemplateArgument > PartialArgs=std::nullopt)
Definition: ExprCXX.cpp:1644
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition: Expr.h:4787
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
Definition: Stmt.h:84
StmtClass
Definition: Stmt.h:86
@ NoStmtClass
Definition: Stmt.h:87
StmtClass getStmtClass() const
Definition: Stmt.h:1358
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:326
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:141
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:864
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3585
A convenient class for passing around template argument information.
Definition: TemplateBase.h:632
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:650
void setRAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:651
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:667
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Definition: TemplateBase.h:659
const TemplateArgumentLoc * operator->() const
Simple iterator that traverses the template arguments in a container that provides a getArgLoc() memb...
TemplateArgumentLocContainerIterator operator++(int)
friend bool operator!=(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator(ArgLocContainer &Container, unsigned Index)
friend bool operator==(const TemplateArgumentLocContainerIterator &X, const TemplateArgumentLocContainerIterator &Y)
TemplateArgumentLocContainerIterator & operator++()
const TemplateArgumentLoc * operator->() const
Iterator adaptor that invents template argument location information for each of the template argumen...
TemplateArgumentLocInventIterator & operator++()
std::iterator_traits< InputIterator >::difference_type difference_type
TemplateArgumentLocInventIterator operator++(int)
friend bool operator==(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
TemplateArgumentLocInventIterator(TreeTransform< Derived > &Self, InputIterator Iter)
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
std::input_iterator_tag iterator_category
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:524
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:574
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:616
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:578
SourceRange getSourceRange() const LLVM_READONLY
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:609
Expr * getSourceExpression() const
Definition: TemplateBase.h:584
Represents a template argument.
Definition: TemplateBase.h:61
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:408
QualType getNonTypeTemplateArgumentType() const
If this is a non-type template argument, get its type.
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:319
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
Definition: TemplateBase.h:363
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
Definition: TemplateBase.h:343
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
Definition: TemplateBase.h:326
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
Definition: TemplateBase.h:74
@ Template
The template argument is a template name that was provided for a template template parameter.
Definition: TemplateBase.h:93
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
Definition: TemplateBase.h:89
@ Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:107
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:97
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:78
@ Type
The template argument is a type.
Definition: TemplateBase.h:70
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:67
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:82
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
Definition: TemplateBase.h:103
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:295
const APValue & getAsStructuralValue() const
Get the value of a StructuralValue.
Definition: TemplateBase.h:396
The base class of all kinds of template declarations (e.g., class, function, etc.).
Definition: DeclTemplate.h:394
Represents a C++ template name within the type system.
Definition: TemplateName.h:202
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:73
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:1687
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1663
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1704
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1671
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1700
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1679
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:6085
Wrapper for template type parameters.
Definition: TypeLoc.h:758
The top declaration context.
Definition: Decl.h:84
RAII object that temporarily sets the base location and entity used for reporting diagnostics in type...
TemporaryBase(TreeTransform &Self, SourceLocation Location, DeclarationName Entity)
A semantic tree transformation that allows one to transform one abstract syntax tree into another.
ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *object)
Rebuild the operand to an Objective-C @synchronized statement.
OMPClause * RebuildOMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nontemporal' clause.
ExprResult TransformInitializer(Expr *Init, bool NotCopyInit)
Transform the given initializer.
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
StmtResult RebuildCoroutineBodyStmt(CoroutineBodyStmt::CtorArgs Args)
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
OMPClause * RebuildOMPDistScheduleClause(OpenMPDistScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'dist_schedule' clause.
ExprResult RebuildUnaryOperator(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *SubExpr)
Build a new unary operator expression.
OMPClause * RebuildOMPProcBindClause(ProcBindKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'proc_bind' clause.
ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Build a new C++11 default-initialization expression.
OMPClause * RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'priority' clause.
ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, TypeSourceInfo *EncodeTypeInfo, SourceLocation RParenLoc)
Build a new Objective-C @encode expression.
StmtResult SkipLambdaBody(LambdaExpr *E, Stmt *Body)
Alternative implementation of TransformLambdaBody that skips transforming the body.
QualType TransformAttributedType(TypeLocBuilder &TLB, AttributedTypeLoc TL, Fn TransformModifiedType)
ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc, SourceLocation OpLoc, bool IsArrow)
Build a new Objective-C "isa" expression.
StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @finally statement.
SourceLocation getBaseLocation()
Returns the location of the entity being transformed, if that information was not available elsewhere...
ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
Build a new call expression.
ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar, SourceLocation IvarLoc, bool IsArrow, bool IsFreeIvar)
Build a new Objective-C ivar reference expression.
OMPClause * RebuildOMPAtClause(OpenMPAtClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'at' clause.
StmtResult RebuildCoreturnStmt(SourceLocation CoreturnLoc, Expr *Result, bool IsImplicit)
Build a new co_return statement.
OMPClause * RebuildOMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'in_reduction' clause.
ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *Init)
Build a new compound literal expression.
ExprResult TransformAddressOfOperand(Expr *E)
The operand of a unary address-of operator has special rules: it's allowed to refer to a non-static m...
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, QualType ThisType, bool isImplicit)
Build a new C++ "this" expression.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(expr) expression.
TreeTransform(Sema &SemaRef)
Initializes a new tree transformer.
QualType RebuildDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const IdentifierInfo *Name, SourceLocation NameLoc, TemplateArgumentListInfo &Args, bool AllowInjectedClassName)
Build a new typename type that refers to a template-id.
QualType RebuildDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttributeLoc)
Build a new matrix type given the type and dependently-defined dimensions.
QualType RebuildUnaryTransformType(QualType BaseType, UnaryTransformType::UTTKind UKind, SourceLocation Loc)
Build a new unary transform type.
ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg, ObjCPropertyDecl *Property, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
void InventTemplateArgumentLoc(const TemplateArgument &Arg, TemplateArgumentLoc &ArgLoc)
Fakes up a TemplateArgumentLoc for a given TemplateArgument.
OMPClause * RebuildOMPUseClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'use' clause.
QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL)
Transform the given type-with-location into a new type, collecting location information in the given ...
ExprResult RebuildCXXRewrittenBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opcode, const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS)
Build a new rewritten operator expression.
ExprResult TransformUnresolvedLookupExpr(UnresolvedLookupExpr *E, bool IsAddressOfOperand)
ExprResult RebuildSourceLocExpr(SourceLocIdentKind Kind, QualType ResultTy, SourceLocation BuiltinLoc, SourceLocation RPLoc, DeclContext *ParentContext)
Build a new expression representing a call to a source location builtin.
QualType RebuildEnumType(EnumDecl *Enum)
Build a new Enum type.
TemplateName RebuildTemplateName(const TemplateArgument &ArgPack, Decl *AssociatedDecl, unsigned Index, bool Final)
Build a new template name given a template template parameter pack and the.
ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Build a new expression pack expansion.
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL)
Transforms a reference type.
OMPClause * RebuildOMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'message' clause.
ExprResult RebuildCXXAddrspaceCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
QualType RebuildTypeOfType(QualType Underlying, TypeOfKind Kind)
Build a new typeof(type) type.
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, SourceLocation RParenLoc)
Build a new C++ zero-initialization expression.
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc, Stmt *Block)
OMPClause * RebuildOMPSimdlenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'simdlen' clause.
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt * > Handlers)
Build a new C++ try statement.
StmtDiscardKind
The reason why the value of a statement is not discarded, if any.
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, UnresolvedLookupExpr *OpCoawaitLookup, bool IsImplicit)
Build a new co_await expression.
bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, unsigned NumInputs, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
ExprResult RebuildDesignatedInitExpr(Designation &Desig, MultiExprArg ArrayExprs, SourceLocation EqualOrColonLoc, bool GNUSyntax, Expr *Init)
Build a new designated initializer expression.
OMPClause * RebuildOMPSizesClause(ArrayRef< Expr * > Sizes, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
ExprResult RebuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Build a new predefined expression.
QualType RebuildElaboratedType(SourceLocation KeywordLoc, ElaboratedTypeKeyword Keyword, NestedNameSpecifierLoc QualifierLoc, QualType Named)
Build a new qualified name type.
ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ static_cast expression.
StmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, Sema::FullExprArg Inc, SourceLocation RParenLoc, Stmt *Body)
Build a new for statement.
StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Build a new C++0x range-based for statement.
ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt, SourceLocation RParenLoc, unsigned TemplateDepth)
Build a new GNU statement expression.
QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo *Id, SourceLocation IdLoc, bool DeducedTSTContext)
Build a new typename type that refers to an identifier.
QualType RebuildTemplateSpecializationType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &Args)
Build a new template specialization type.
bool TryExpandParameterPacks(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, bool &ShouldExpand, bool &RetainExpansion, std::optional< unsigned > &NumExpansions)
Determine whether we should expand a pack expansion with the given set of parameter packs into separa...
Sema & getSema() const
Retrieves a reference to the semantic analysis object used for this tree transform.
ExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new shuffle vector expression.
QualType TransformType(QualType T)
Transforms the given type into another type.
OMPClause * RebuildOMPOrderClause(OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc, OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc)
Build a new OpenMP 'order' clause.
QualType RebuildReferenceType(QualType ReferentType, bool LValue, SourceLocation Sigil)
Build a new reference type given the type it references.
ExprResult TransformRequiresTypeParams(SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl * > Params, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > &TransParams, Sema::ExtParameterInfoBuilder &PInfos)
Transforms the parameters of a requires expresison into the given vectors.
ExprResult RebuildInitList(SourceLocation LBraceLoc, MultiExprArg Inits, SourceLocation RBraceLoc)
Build a new initializer list expression.
QualType RebuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Operand)
Build a new Objective-C @throw statement.
OMPClause * RebuildOMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'task_reduction' clause.
OMPClause * RebuildOMPCopyinClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyin' clause.
QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, bool isReadPipe)
Build a new pipe type given its value type.
StmtResult RebuildCaseStmt(SourceLocation CaseLoc, Expr *LHS, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation ColonLoc)
Build a new case statement.
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Build a new template-id expression.
StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, VarDecl *ExceptionDecl, Stmt *Handler)
Build a new C++ catch statement.
OMPClause * RebuildOMPDestroyClause(Expr *InteropVar, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'destroy' clause.
ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec step expression with an expression argument.
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new address-of-label expression.
ExprResult RebuildCxxSubscriptExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
TemplateName TransformTemplateName(CXXScopeSpec &SS, TemplateName Name, SourceLocation NameLoc, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr, bool AllowInjectedClassName=false)
Transform the given template name.
OMPClause * RebuildOMPXBareClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_bare' clause.
const Attr * TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS, const Attr *A)
ExprResult RebuildConditionalOperator(Expr *Cond, SourceLocation QuestionLoc, Expr *LHS, SourceLocation ColonLoc, Expr *RHS)
Build a new conditional operator expression.
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
Attach body to a C++0x range-based for statement.
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *Object, Stmt *Body)
Build a new Objective-C @synchronized statement.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, bool TemplateKW, TemplateDecl *Template)
Build a new template name given a nested name specifier, a flag indicating whether the "template" key...
OMPClause * RebuildOMPDeviceClause(OpenMPDeviceClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'device' clause.
QualType TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL, TemplateName Template, CXXScopeSpec &SS)
OMPClause * RebuildOMPHasDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'has_device_addr' clause.
QualType RebuildDependentSizedExtVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
void RememberPartiallySubstitutedPack(TemplateArgument Arg)
"Remember" the partially-substituted pack template argument after performing an instantiation that mu...
Decl * TransformDefinition(SourceLocation Loc, Decl *D)
Transform the definition of the given declaration.
OMPClause * RebuildOMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'from' clause.
StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc, OpenMPDirectiveKind PrevMappedDirective=OMPD_unknown)
Build a new OpenMP executable directive.
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
QualType RebuildTypedefType(TypedefNameDecl *Typedef)
Build a new typedef type.
StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result)
Build a new return statement.
TemplateArgument ForgetPartiallySubstitutedPack()
"Forget" about the partially-substituted pack template argument, when performing an instantiation tha...
OMPClause * RebuildOMPNocontextClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'nocontext' clause.
ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ reinterpret_cast expression.
QualType RebuildVectorType(QualType ElementType, unsigned NumElements, VectorKind VecKind)
Build a new vector type given the element type and number of elements.
ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, TypeSourceInfo *Type, ArrayRef< Sema::OffsetOfComponent > Components, SourceLocation RParenLoc)
Build a new builtin offsetof expression.
StmtResult RebuildOpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
QualType RebuildParenType(QualType InnerType)
Build a new parenthesized type.
QualType RebuildRecordType(RecordDecl *Record)
Build a new class/struct/union type.
static StmtResult Owned(Stmt *S)
OMPClause * RebuildOMPReductionClause(ArrayRef< Expr * > VarList, OpenMPReductionClauseModifier Modifier, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions)
Build a new OpenMP 'reduction' clause.
OMPClause * RebuildOMPPartialClause(Expr *Factor, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'partial' clause.
OMPClause * RebuildOMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP 'schedule' clause.
StmtResult TransformLambdaBody(LambdaExpr *E, Stmt *Body)
Transform the body of a lambda-expression.
StmtResult RebuildSEHTryStmt(bool IsCXXTry, SourceLocation TryLoc, Stmt *TryBlock, Stmt *Handler)
OMPClause * RebuildOMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'exclusive' clause.
QualType RebuildDependentAddressSpaceType(QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc)
Build a new DependentAddressSpaceType or return the pointee type variable with the correct address sp...
StmtResult RebuildAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Build a new attributed statement.
ExprResult RebuildConceptSpecializationExpr(NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, ConceptDecl *NamedConcept, TemplateArgumentListInfo *TALI)
Build a new Objective-C boxed expression.
OMPClause * RebuildOMPDefaultmapClause(OpenMPDefaultmapClauseModifier M, OpenMPDefaultmapClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Build a new OpenMP 'defaultmap' clause.
ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr)
Build a new C++ default-argument expression.
StmtResult RebuildWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, Sema::ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Build a new while statement.
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > *PVars, Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed)
Transforms the parameters of a function type into the given vectors.
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)
Build a new inline asm statement.
StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S)
ExprResult RebuildObjCMessageExpr(Expr *Receiver, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance message.
QualType TransformSubstTemplateTypeParmPackType(TypeLocBuilder &TLB, SubstTemplateTypeParmPackTypeLoc TL, bool SuppressObjCLifetime)
ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool RequiresADL)
Build a new expression that references a declaration.
bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall, SmallVectorImpl< Expr * > &Outputs, bool *ArgChanged=nullptr)
Transform the given list of expressions.
StmtResult TransformSEHHandler(Stmt *Handler)
NestedNameSpecifierLoc TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, QualType ObjectType=QualType(), NamedDecl *FirstQualifierInScope=nullptr)
Transform the given nested-name-specifier with source-location information.
TemplateName RebuildTemplateName(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, OverloadedOperatorKind Operator, SourceLocation NameLoc, QualType ObjectType, bool AllowInjectedClassName)
Build a new template name given a nested name specifier and the overloaded operator name that is refe...
QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc)
Build a new C++11 decltype type.
OMPClause * RebuildOMPUseDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'use_device_ptr' clause.
QualType TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, DependentTemplateSpecializationTypeLoc TL, NestedNameSpecifierLoc QualifierLoc)
void ExpandingFunctionParameterPack(ParmVarDecl *Pack)
Note to the derived class when a function parameter pack is being expanded.
void setBase(SourceLocation Loc, DeclarationName Entity)
Sets the "base" location and entity when that information is known based on another transformation.
concepts::TypeRequirement * TransformTypeRequirement(concepts::TypeRequirement *Req)
const Derived & getDerived() const
Retrieves a reference to the derived class.
OMPClause * RebuildOMPAllocateClause(Expr *Allocate, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocate' clause.
ExprResult RebuildParenExpr(Expr *SubExpr, SourceLocation LParen, SourceLocation RParen)
Build a new expression in parentheses.
OMPClause * RebuildOMPNumThreadsClause(Expr *NumThreads, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_threads' clause.
QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new block pointer type given its pointee type.
ExprResult RebuildMemberExpr(Expr *Base, SourceLocation OpLoc, bool isArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, ValueDecl *Member, NamedDecl *FoundDecl, const TemplateArgumentListInfo *ExplicitTemplateArgs, NamedDecl *FirstQualifierInScope)
Build a new member access expression.
OMPClause * RebuildOMPSharedClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'shared' clause.
ExprResult RebuildCXXConstructExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool RequiresZeroInit, CXXConstructionKind ConstructKind, SourceRange ParenRange)
Build a new object-construction expression.
bool TransformFunctionTypeParams(SourceLocation Loc, ArrayRef< ParmVarDecl * > Params, const QualType *ParamTypes, const FunctionProtoType::ExtParameterInfo *ParamInfos, SmallVectorImpl< QualType > &PTypes, SmallVectorImpl< ParmVarDecl * > *PVars, Sema::ExtParameterInfoBuilder &PInfos)
OMPClause * RebuildOMPLinearClause(ArrayRef< Expr * > VarList, Expr *Step, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation StepModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'linear' clause.
VarDecl * RebuildExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *Declarator, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Build a new C++ exception declaration.
ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg)
Build a new noexcept expression.
QualType RebuildFunctionProtoType(QualType T, MutableArrayRef< QualType > ParamTypes, const FunctionProtoType::ExtProtoInfo &EPI)
Build a new function type.
ExprResult RebuildObjCSubscriptRefExpr(SourceLocation RB, Expr *Base, Expr *Key, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
ExprResult RebuildRecoveryExpr(SourceLocation BeginLoc, SourceLocation EndLoc, ArrayRef< Expr * > SubExprs, QualType Type)
QualType RebuildIncompleteArrayType(QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new incomplete array type given the element type, size modifier, and index type qualifiers.
TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Build a new template argument pack expansion.
CXXRecordDecl::LambdaDependencyKind ComputeLambdaDependency(LambdaScopeInfo *LSI)
ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *Sub, SourceLocation RParenLoc, bool ListInitialization)
Build a new C++ functional-style cast expression.
TypeSourceInfo * TransformType(TypeSourceInfo *DI)
Transforms the given type-with-location into a new type-with-location.
ExprResult RebuildObjCDictionaryLiteral(SourceRange Range, MutableArrayRef< ObjCDictionaryElement > Elements)
Build a new Objective-C dictionary literal.
StmtResult TransformStmt(Stmt *S, StmtDiscardKind SDK=SDK_Discarded)
Transform the given statement.
StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *Target)
Build a new indirect goto statement.
ExprResult RebuildExtVectorElementExpr(Expr *Base, SourceLocation OpLoc, bool IsArrow, SourceLocation AccessorLoc, IdentifierInfo &Accessor)
Build a new extended vector element access expression.
ExprResult RebuildParenListExpr(SourceLocation LParenLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new expression list in parentheses.
OMPClause * RebuildOMPAllocatorClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocator' clause.
QualType RebuildDependentSizedArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new dependent-sized array type given the element type, size modifier, size expression,...
NamedDecl * TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc)
Transform the given declaration, which was the first part of a nested-name-specifier in a member acce...
OMPClause * RebuildOMPInclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'inclusive' clause.
concepts::ExprRequirement * RebuildExprRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
OMPClause * TransformOMPClause(OMPClause *S)
Transform the given statement.
QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc)
Build a new atomic type given its value type.
ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build a new binary operator expression.
ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *SubExpr)
Build a new C-style cast expression.
OMPClause * RebuildOMPDefaultClause(DefaultKind Kind, SourceLocation KindKwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'default' clause.
QualType RebuildObjCObjectPointerType(QualType PointeeType, SourceLocation Star)
Build a new Objective-C object pointer type given the pointee type.
ExprResult TransformExpr(Expr *E)
Transform the given expression.
bool AlreadyTransformed(QualType T)
Determine whether the given type T has already been transformed.
concepts::TypeRequirement * RebuildTypeRequirement(TypeSourceInfo *T)
ExprResult RebuildOMPIteratorExpr(SourceLocation IteratorKwLoc, SourceLocation LLoc, SourceLocation RLoc, ArrayRef< SemaOpenMP::OMPIteratorData > Data)
Build a new iterator expression.
ExprResult RebuildSYCLUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
OMPClause * RebuildOMPGrainsizeClause(OpenMPGrainsizeClauseModifier Modifier, Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'grainsize' clause.
OMPClause * RebuildOMPXDynCGroupMemClause(Expr *Size, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
bool TransformTemplateArguments(InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs, bool Uneval=false)
Transform the given set of template arguments.
OMPClause * RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'collapse' clause.
static ExprResult Owned(Expr *E)
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, Expr *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(expr) expression.
OMPClause * RebuildOMPNumTasksClause(OpenMPNumTasksClauseModifier Modifier, Expr *NumTasks, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ModifierLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_tasks' clause.
OMPClause * RebuildOMPDepobjClause(Expr *Depobj, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depobj' pseudo clause.
ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc, Expr *Cond, Expr *LHS, Expr *RHS, SourceLocation RParenLoc)
Build a new __builtin_choose_expr expression.
OMPClause * RebuildOMPAlignClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'align' clause.
ExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C class message.
bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL, LookupResult &R)
Transform the set of declarations in an OverloadExpr.
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, SourceLocation LParenOrBraceLoc, MultiExprArg Args, SourceLocation RParenOrBraceLoc, bool ListInitialization)
Build a new object-construction expression.
StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init, SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond, Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc, ArrayRef< MaterializeTemporaryExpr * > LifetimeExtendTemps)
Build a new C++0x range-based for statement.
OMPClause * RebuildOMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Num)
Build a new OpenMP 'ordered' clause.
ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result)
Build a new co_yield expression.
QualType RebuildObjCObjectType(QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc, ArrayRef< TypeSourceInfo * > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build an Objective-C object type.
llvm::DenseMap< Decl *, Decl * > TransformedLocalDecls
The set of local declarations that have been transformed, for cases where we are forced to build new ...
OMPClause * RebuildOMPNovariantsClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'novariants' clause.
ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E)
OMPClause * RebuildOMPNumTeamsClause(Expr *NumTeams, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_teams' clause.
ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocatedType, TypeSourceInfo *AllocatedTypeInfo, std::optional< Expr * > ArraySize, SourceRange DirectInitRange, Expr *Initializer)
Build a new C++ "new" expression.
OMPClause * RebuildOMPThreadLimitClause(Expr *ThreadLimit, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'thread_limit' clause.
StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc, Stmt *Element, Expr *Collection, SourceLocation RParenLoc, Stmt *Body)
Build a new Objective-C fast enumeration statement.
ExprResult RebuildDependentScopeDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
Build a new (previously unresolved) declaration reference expression.
StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, Stmt *TryBody, MultiStmtArg CatchStmts, Stmt *Finally)
Build a new Objective-C @try statement.
DeclarationName getBaseEntity()
Returns the name of the entity being transformed, if that information was not available elsewhere in ...
ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, bool ListInitialization)
Build a new object-construction expression.
ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, SourceLocation PackLoc, SourceLocation RParenLoc, std::optional< unsigned > Length, ArrayRef< TemplateArgument > PartialArgs)
Build a new expression to compute the length of a parameter pack.
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, SourceLocation OpLoc, SourceLocation CalleeLoc, bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First, Expr *Second)
Build a new overloaded operator call expression.
OMPClause * RebuildOMPUseDeviceAddrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'use_device_addr' clause.
QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc)
Build a dependent bit-precise int given its value type.
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'hint' clause.
Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind)
Transform the specified condition.
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 name that is referred to as a templat...
OMPClause * RebuildOMPSeverityClause(OpenMPSeverityClauseKind Kind, SourceLocation KwLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'severity' clause.
OMPClause * RebuildOMPFirstprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'firstprivate' clause.
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)
Build a new MS style inline asm statement.
QualType TransformTemplateSpecializationType(TypeLocBuilder &TLB, TemplateSpecializationTypeLoc TL, TemplateName Template)
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
concepts::NestedRequirement * TransformNestedRequirement(concepts::NestedRequirement *Req)
QualType RebuildConstantArrayType(QualType ElementType, 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,...
ExprResult RebuildOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > BracketsRanges)
Build a new array shaping expression.
ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, bool IsGlobalDelete, bool IsArrayForm, Expr *Operand)
Build a new C++ "delete" expression.
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D)
Rebuild an unresolved typename type, given the decl that the UnresolvedUsingTypenameDecl was transfor...
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait, SourceLocation StartLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParenLoc)
Build a new array type trait expression.
OMPClause * RebuildOMPIsDevicePtrClause(ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs)
Build a new OpenMP 'is_device_ptr' clause.
QualType RebuildMacroQualifiedType(QualType T, const IdentifierInfo *MacroII)
Build a new MacroDefined type.
concepts::NestedRequirement * RebuildNestedRequirement(Expr *Constraint)
ExprResult RebuildMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBracketLoc)
Build a new matrix subscript expression.
ExprResult TransformParenDependentScopeDeclRefExpr(ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
TemplateParameterList * TransformTemplateParameterList(TemplateParameterList *TPL)
QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType, SourceLocation Sigil)
Build a new member pointer type given the pointee type and the class type it refers into.
void transformAttrs(Decl *Old, Decl *New)
Transform the attributes associated with the given declaration and place them on the new declaration.
Decl * TransformDecl(SourceLocation Loc, Decl *D)
Transform the given declaration, which is referenced from a type or expression.
bool AlwaysRebuild()
Whether the transformation should always rebuild AST nodes, even if none of the children have changed...
ExprResult RebuildObjCMessageExpr(SourceLocation SuperLoc, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, QualType SuperType, ObjCMethodDecl *Method, SourceLocation LBracLoc, MultiExprArg Args, SourceLocation RBracLoc)
Build a new Objective-C instance/class message to 'super'.
OMPClause * RebuildOMPLastprivateClause(ArrayRef< Expr * > VarList, OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc, SourceLocation ColonLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'lastprivate' clause.
QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc, VectorKind)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
bool AllowSkippingCXXConstructExpr()
Wether CXXConstructExpr can be skipped when they are implicit.
OMPClause * RebuildOMPSafelenClause(Expr *Len, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'safelen' clause.
StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *Init, Sema::ConditionResult Cond, SourceLocation RParenLoc)
Start building a new switch statement.
StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new default statement.
StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParenLoc, VarDecl *Var, Stmt *Body)
Build a new Objective-C @catch statement.
OMPClause * RebuildOMPFilterClause(Expr *ThreadID, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'filter' clause.
ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, SourceLocation OperatorLoc, bool isArrow, CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage Destroyed)
Build a new pseudo-destructor expression.
QualType RebuildPackExpansionType(QualType Pattern, SourceRange PatternRange, SourceLocation EllipsisLoc, std::optional< unsigned > NumExpansions)
Build a new pack expansion type.
QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc)
Build a bit-precise int given its value type.
ExprResult RebuildObjCArrayLiteral(SourceRange Range, Expr **Elements, unsigned NumElements)
Build a new Objective-C array literal.
ExprResult RebuildCXXUuidofExpr(QualType Type, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ __uuidof(type) expression.
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType, SourceLocation OperatorLoc, bool IsArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
OMPClause * RebuildOMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'bind' clause.
concepts::NestedRequirement * RebuildNestedRequirement(StringRef InvalidConstraintEntity, const ASTConstraintSatisfaction &Satisfaction)
OMPClause * RebuildOMPCopyprivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'copyprivate' clause.
QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword, ConceptDecl *TypeConstraintConcept, ArrayRef< TemplateArgument > TypeConstraintArgs)
Build a new C++11 auto type.
ExprResult RebuildPackIndexingExpr(SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpression, Expr *IndexExpr, ArrayRef< Expr * > ExpandedExprs, bool EmptyPack=false)
QualType RebuildVariableArrayType(QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new variable-length array type given the element type, size modifier, size expression,...
ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ dynamic_cast expression.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, TypeSourceInfo *ControllingType, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with a type predicate.
QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new pointer type given its pointee type.
concepts::TypeRequirement * RebuildTypeRequirement(concepts::Requirement::SubstitutionDiagnostic *SubstDiag)
OMPClause * RebuildOMPUsesAllocatorsClause(ArrayRef< SemaOpenMP::UsesAllocatorsData > Data, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'uses_allocators' clause.
ExprResult RebuildCXXInheritedCtorInitExpr(QualType T, SourceLocation Loc, CXXConstructorDecl *Constructor, bool ConstructsVBase, bool InheritedFromVBase)
Build a new implicit construction via inherited constructor expression.
ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ const_cast expression.
ExprResult RebuildAtomicExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, AtomicExpr::AtomicOp Op, SourceLocation RParenLoc)
Build a new atomic operation expression.
DeclarationNameInfo TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
Transform the given declaration name.
OMPClause * RebuildOMPXAttributeClause(ArrayRef< const Attr * > Attrs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'ompx_attribute' clause.
ExprResult RebuildCXXFoldExpr(UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, Expr *LHS, BinaryOperatorKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc, std::optional< unsigned > NumExpansions)
Build a new C++1z fold-expression.
OMPClause * RebuildOMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers)
Build a new OpenMP 'to' clause.
StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation LParenLoc, Expr *Cond, SourceLocation RParenLoc)
Build a new do-while statement.
OMPClause * RebuildOMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'if' clause.
StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body)
Attach the body to a new case statement.
ExprResult RebuildTypeTrait(TypeTrait Trait, SourceLocation StartLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
Build a new type trait expression.
ExprResult RebuildEmptyCXXFoldExpr(SourceLocation EllipsisLoc, BinaryOperatorKind Operator)
Build an empty C++1z fold-expression with the given operator.
QualType TransformTypeWithDeducedTST(QualType T)
Transform a type that is permitted to produce a DeducedTemplateSpecializationType.
OMPClause * RebuildOMPInitClause(Expr *InteropVar, OMPInteropInfo &InteropInfo, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation VarLoc, SourceLocation EndLoc)
Build a new OpenMP 'init' clause.
OMPClause * RebuildOMPDetachClause(Expr *Evt, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'detach' clause.
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc, ValueDecl *VD, const DeclarationNameInfo &NameInfo, NamedDecl *Found, TemplateArgumentListInfo *TemplateArgs)
Build a new expression that references a declaration.
QualType RebuildArrayType(QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new array type given the element type, size modifier, size of the array (if known),...
StmtResult RebuildDeclStmt(MutableArrayRef< Decl * > Decls, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new declaration statement.
QualType RebuildUsingType(UsingShadowDecl *Found, QualType Underlying)
Build a new type found via an alias.
ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, Expr *SrcExpr, TypeSourceInfo *DstTInfo, SourceLocation RParenLoc)
Build a new convert vector expression.
QualType RebuildQualifiedType(QualType T, QualifiedTypeLoc TL)
Build a new qualified type given its unqualified type and type location.
OMPClause * RebuildOMPDependClause(OMPDependClause::DependDataTy Data, Expr *DepModifier, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'depend' pseudo clause.
OMPClause * RebuildOMPAlignedClause(ArrayRef< Expr * > VarList, Expr *Alignment, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'aligned' clause.
unsigned TransformTemplateDepth(unsigned Depth)
Transform a template parameter depth level.
QualType RebuildFunctionNoProtoType(QualType ResultType)
Build a new unprototyped function type.
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, Qualifiers ThisTypeQuals, Fn TransformExceptionSpec)
const Attr * TransformAttr(const Attr *S)
Transform the given attribute.
QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows, unsigned NumColumns)
Build a new matrix type given the element type and dimensions.
OMPClause * RebuildOMPMapClause(Expr *IteratorModifier, 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)
Build a new OpenMP 'map' clause.
ExprResult RebuildBuiltinBitCastExpr(SourceLocation KWLoc, TypeSourceInfo *TSI, Expr *Sub, SourceLocation RParenLoc)
Build a new C++ __builtin_bit_cast expression.
QualType RebuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted, ArrayRef< QualType > Expansions={})
StmtResult RebuildOMPCanonicalLoop(Stmt *LoopStmt)
Build a new OpenMP Canonical loop.
concepts::ExprRequirement * RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement Ret)
ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI)
OMPClause * RebuildOMPFullClause(SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP 'full' clause.
StmtResult RebuildSEHExceptStmt(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
OMPClause * RebuildOMPAffinityClause(SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, Expr *Modifier, ArrayRef< Expr * > Locators)
Build a new OpenMP 'affinity' clause.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(type) expression.
TypeSourceInfo * TransformTypeWithDeducedTST(TypeSourceInfo *DI)
ExprResult RebuildCXXDependentScopeMemberExpr(Expr *BaseE, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
ExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc, Stmt::StmtClass Class, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ "named" cast expression, such as static_cast or reinterpret_cast.
StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Attach the body to the switch statement.
TypeSourceInfo * InventTypeSourceInfo(QualType T)
Fakes up a TypeSourceInfo for a type.
ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec_step expression with a type argument.
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
Build a new generic selection expression with an expression predicate.
QualType TransformTemplateTypeParmType(TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool SuppressObjCLifetime)
Derived & getDerived()
Retrieves a reference to the derived class.
ExprResult RebuildArraySectionExpr(bool IsOMPArraySection, Expr *Base, SourceLocation LBracketLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBracketLoc)
Build a new array section expression.
concepts::ExprRequirement * TransformExprRequirement(concepts::ExprRequirement *Req)
QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc, TypeOfKind Kind)
Build a new typeof(expr) type.
ParmVarDecl * TransformFunctionTypeParam(ParmVarDecl *OldParm, int indexAdjustment, std::optional< unsigned > NumExpansions, bool ExpectParameterPack)
Transforms a single function-type parameter.
bool ReplacingOriginal()
Whether the transformation is forming an expression or statement that replaces the original.
OMPClause * RebuildOMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'flush' pseudo clause.
bool TransformTemplateArgument(const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output, bool Uneval=false)
Transform the given template argument.
QualType RebuildDeducedTemplateSpecializationType(TemplateName Template, QualType Deduced)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type.
ExprResult RebuildArraySubscriptExpr(Expr *LHS, SourceLocation LBracketLoc, Expr *RHS, SourceLocation RBracketLoc)
Build a new array subscript expression.
QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements, SourceLocation AttributeLoc)
Build a new extended vector type given the element type and number of elements.
void transformedLocalDecl(Decl *Old, ArrayRef< Decl * > New)
Note that a local declaration has been transformed by this transformer.
ExprResult RebuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
Build a new Objective-C boxed expression.
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, bool IsThrownVariableInScope)
Build a new C++ throw expression.
bool TransformRequiresExprRequirements(ArrayRef< concepts::Requirement * > Reqs, llvm::SmallVectorImpl< concepts::Requirement * > &Transformed)
bool DropCallArgument(Expr *E)
Determine whether the given call argument should be dropped, e.g., because it is a default argument.
StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *Label)
Build a new goto statement.
OMPClause * RebuildOMPPrivateClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'private' clause.
ExprResult RebuildObjCPropertyRefExpr(Expr *Base, QualType T, ObjCMethodDecl *Getter, ObjCMethodDecl *Setter, SourceLocation PropertyLoc)
Build a new Objective-C property reference expression.
ExprResult RebuildRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation ClosingBraceLoc)
Build a new requires expression.
ExprResult RebuildExpressionTrait(ExpressionTrait Trait, SourceLocation StartLoc, Expr *Queried, SourceLocation RParenLoc)
Build a new expression trait expression.
OMPClause * RebuildOMPDoacrossClause(OpenMPDoacrossClauseModifier DepType, SourceLocation DepLoc, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'doacross' clause.
OMPClause * RebuildOMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'final' clause.
StmtResult RebuildIfStmt(SourceLocation IfLoc, IfStatementKind Kind, SourceLocation LParenLoc, Sema::ConditionResult Cond, SourceLocation RParenLoc, Stmt *Init, Stmt *Then, SourceLocation ElseLoc, Stmt *Else)
Build a new "if" statement.
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
void TypeWasModifiedSafely(QualType T)
Tell the TypeLocBuilder that the type it is storing has been modified in some safe way that doesn't a...
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:59
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
Definition: TypeLoc.h:338
QualType getType() const
Get the type for which this source info wrapper provides information.
Definition: TypeLoc.h:133
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:89
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
Definition: TypeLoc.h:78
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Definition: TypeLoc.h:153
unsigned getFullDataSize() const
Returns the size of the type source info data block.
Definition: TypeLoc.h:164
SourceLocation getTemplateKeywordLoc() const
Get the SourceLocation of the template keyword (if any).
Definition: TypeLoc.cpp:746
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:2684
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:192
A container of type source information.
Definition: Type.h:7326
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:256
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:7337
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition: Type.cpp:3156
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:6325
The base class of the type hierarchy.
Definition: Type.h:1813
bool isPointerType() const
Definition: Type.h:7608
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8186
bool isReferenceType() const
Definition: Type.h:7620
bool isEnumeralType() const
Definition: Type.h:7706
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:694
bool canHaveNullability(bool ResultIfUnknown=true) const
Determine whether the given type can have a nullability specifier applied to it, i....
Definition: Type.cpp:4623
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.h:2754
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2649
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:2320
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition: Type.h:8042
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Definition: Type.cpp:4882
bool isFunctionType() const
Definition: Type.h:7604
bool isObjCObjectPointerType() const
Definition: Type.h:7740
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8119
bool isRecordType() const
Definition: Type.h:7702
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3433
Wrapper for source info for typedefs.
Definition: TypeLoc.h:693
TypedefNameDecl * getTypedefNameDecl() const
Definition: TypeLoc.h:695
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2183
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:2232
Expr * getSubExpr() const
Definition: Expr.h:2228
Opcode getOpcode() const
Definition: Expr.h:2223
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:1414
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:1024
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3173
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent)
Definition: ExprCXX.cpp:372
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition: ExprCXX.h:3246
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:3241
A set of unresolved declarations.
Definition: UnresolvedSet.h:61
void addDecl(NamedDecl *D)
Definition: UnresolvedSet.h:91
A set of unresolved declarations.
Represents the dependent type named by a dependently-scoped typename using declaration,...
Definition: Type.h:5140
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3320
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3384
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:706
QualType getType() const
Definition: Decl.h:717
Represents a variable declaration or definition.
Definition: Decl.h:918
@ CInit
C-style initialization with assignment.
Definition: Decl.h:923
@ CallInit
Call-style initialization (C++98)
Definition: Decl.h:926
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1155
bool isParameterPack() const
Determine whether this variable is actually a function parameter pack or init-capture pack.
Definition: Decl.cpp:2663
A requires-expression requirement which queries the validity and properties of an expression ('simple...
Definition: ExprConcepts.h:280
SubstitutionDiagnostic * getExprSubstitutionDiagnostic() const
Definition: ExprConcepts.h:408
const ReturnTypeRequirement & getReturnTypeRequirement() const
Definition: ExprConcepts.h:398
SourceLocation getNoexceptLoc() const
Definition: ExprConcepts.h:390
A requires-expression requirement which is satisfied when a general constraint expression is satisfie...
Definition: ExprConcepts.h:429
const ASTConstraintSatisfaction & getConstraintSatisfaction() const
Definition: ExprConcepts.h:484
A static requirement that can be used in a requires-expression to check properties of types and expre...
Definition: ExprConcepts.h:168
A requires-expression requirement which queries the existence of a type name or type template special...
Definition: ExprConcepts.h:225
SubstitutionDiagnostic * getSubstitutionDiagnostic() const
Definition: ExprConcepts.h:260
TypeSourceInfo * getType() const
Definition: ExprConcepts.h:267
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition: ScopeInfo.h:865
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const AstTypeMatcher< FunctionType > functionType
Matches FunctionType nodes.
bool Inc(InterpState &S, CodePtr OpPC)
1) Pops a pointer from the stack 2) Load the value from the pointer 3) Writes the value increased by ...
Definition: Interp.h:589
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
Definition: Interp.h:708
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition: Descriptor.h:27
CharSourceRange getSourceRange(const SourceRange &Range)
Returns the token CharSourceRange corresponding to Range.
Definition: FixIt.h:32
The JSON file list parser is used to communicate input to InstallAPI.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
@ OO_None
Not an overloaded operator.
Definition: OperatorKinds.h:22
@ NUM_OVERLOADED_OPERATORS
Definition: OperatorKinds.h:26
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:42
@ CPlusPlus23
Definition: LangStandard.h:60
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition: Type.h:1772
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:24
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
Definition: OpenMPKinds.h:118
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
Definition: OpenMPKinds.h:171
IfStatementKind
In an if statement, this denotes whether the statement is a constexpr or consteval if statement.
Definition: Specifiers.h:39
CXXConstructionKind
Definition: ExprCXX.h:1532
@ OK_ObjCProperty
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition: Specifiers.h:158
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
Definition: OpenMPKinds.h:135
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
Definition: Lambda.h:36
@ LCK_ByRef
Capturing by reference.
Definition: Lambda.h:37
@ LCK_StarThis
Capturing the *this object by copy.
Definition: Lambda.h:35
OpenMPReductionClauseModifier
OpenMP modifiers for 'reduction' clause.
Definition: OpenMPKinds.h:186
BinaryOperatorKind
TypeOfKind
The kind of 'typeof' expression we're after.
Definition: Type.h:921
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition: OpenMPKinds.h:38
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Definition: OpenMPKinds.h:103
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
Definition: OpenMPKinds.h:219
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:51
ExprResult ExprEmpty()
Definition: Ownership.h:271
StmtResult StmtError()
Definition: Ownership.h:265
@ Property
The type of a property.
@ Result
The result type of a method or function.
OpenMPBindClauseKind
OpenMP bindings for the 'bind' clause.
Definition: OpenMPKinds.h:200
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:3511
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
Definition: OpenMPKinds.h:157
OpenMPGrainsizeClauseModifier
Definition: OpenMPKinds.h:206
OpenMPNumTasksClauseModifier
Definition: OpenMPKinds.h:212
UnaryOperatorKind
ActionResult< Expr * > ExprResult
Definition: Ownership.h:248
TagTypeKind
The kind of a tag type.
Definition: Type.h:6295
bool transformOMPMappableExprListClause(TreeTransform< Derived > &TT, OMPMappableExprListClause< T > *C, llvm::SmallVectorImpl< Expr * > &Vars, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperIdInfo, llvm::SmallVectorImpl< Expr * > &UnresolvedMappers)
OpenACCDirectiveKind
Definition: OpenACCKinds.h:25
ExprResult ExprError()
Definition: Ownership.h:264
bool isOpenMPLoopDirective(OpenMPDirectiveKind DKind)
Checks if the specified directive is a directive with an associated loop construct.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
Definition: Diagnostic.h:1542
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
Definition: OpenMPKinds.h:142
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:249
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
Definition: OpenMPKinds.h:110
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition: OpenMPKinds.h:62
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:132
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:136
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition: Ownership.h:229
const FunctionProtoType * T
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:244
VectorKind
Definition: Type.h:3928
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition: OpenMPKinds.h:47
SourceLocIdentKind
Definition: Expr.h:4714
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:6270
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Enum
The "enum" keyword introduces the elaborated-type-specifier.
@ Typename
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
OpenMPOrderClauseKind
OpenMP attributes for 'order' clause.
Definition: OpenMPKinds.h:164
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
@ Parens
New-expression has a C++98 paren-delimited initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DynamicNone
throw()
@ EST_Uninstantiated
not instantiated yet
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_Dynamic
throw(T1, T2)
PredefinedIdentKind
Definition: Expr.h:1970
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition: OpenMPKinds.h:30
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
MutableArrayRef< Expr * > MultiExprArg
Definition: Ownership.h:258
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition: OpenMPKinds.h:70
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:93
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
TypeSourceInfo * getNamedTypeInfo() const
getNamedTypeInfo - Returns the source type info associated to the name.
Holds information about the various types of exception specification.
Definition: Type.h:4703
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition: Type.h:4719
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:4705
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:4708
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:4711
Extra information about a function prototype.
Definition: Type.h:4731
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:4738
const ExtParameterInfo * ExtParameterInfos
Definition: Type.h:4739
This structure contains most locations needed for by an OMPVarListClause.
Definition: OpenMPClause.h:259
@ LambdaExpressionSubstitution
We are substituting into a lambda expression.
Definition: Sema.h:9835
@ BuildingDeductionGuides
We are building deduction guides for a class.
Definition: Sema.h:9911
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2381
Location information for a TemplateArgument.
Definition: TemplateBase.h:472