clang 21.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"
32#include "clang/AST/StmtSYCL.h"
37#include "clang/Sema/Lookup.h"
43#include "clang/Sema/SemaObjC.h"
47#include "clang/Sema/SemaSYCL.h"
48#include "llvm/ADT/ArrayRef.h"
49#include "llvm/Support/ErrorHandling.h"
50#include <algorithm>
51#include <optional>
52
53using namespace llvm::omp;
54
55namespace clang {
56using namespace sema;
57
58/// A semantic tree transformation that allows one to transform one
59/// abstract syntax tree into another.
60///
61/// A new tree transformation is defined by creating a new subclass \c X of
62/// \c TreeTransform<X> and then overriding certain operations to provide
63/// behavior specific to that transformation. For example, template
64/// instantiation is implemented as a tree transformation where the
65/// transformation of TemplateTypeParmType nodes involves substituting the
66/// template arguments for their corresponding template parameters; a similar
67/// transformation is performed for non-type template parameters and
68/// template template parameters.
69///
70/// This tree-transformation template uses static polymorphism to allow
71/// subclasses to customize any of its operations. Thus, a subclass can
72/// override any of the transformation or rebuild operators by providing an
73/// operation with the same signature as the default implementation. The
74/// overriding function should not be virtual.
75///
76/// Semantic tree transformations are split into two stages, either of which
77/// can be replaced by a subclass. The "transform" step transforms an AST node
78/// or the parts of an AST node using the various transformation functions,
79/// then passes the pieces on to the "rebuild" step, which constructs a new AST
80/// node of the appropriate kind from the pieces. The default transformation
81/// routines recursively transform the operands to composite AST nodes (e.g.,
82/// the pointee type of a PointerType node) and, if any of those operand nodes
83/// were changed by the transformation, invokes the rebuild operation to create
84/// a new AST node.
85///
86/// Subclasses can customize the transformation at various levels. The
87/// most coarse-grained transformations involve replacing TransformType(),
88/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
89/// TransformTemplateName(), or TransformTemplateArgument() with entirely
90/// new implementations.
91///
92/// For more fine-grained transformations, subclasses can replace any of the
93/// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
94/// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
95/// replacing TransformTemplateTypeParmType() allows template instantiation
96/// to substitute template arguments for their corresponding template
97/// parameters. Additionally, subclasses can override the \c RebuildXXX
98/// functions to control how AST nodes are rebuilt when their operands change.
99/// By default, \c TreeTransform will invoke semantic analysis to rebuild
100/// AST nodes. However, certain other tree transformations (e.g, cloning) may
101/// be able to use more efficient rebuild steps.
102///
103/// There are a handful of other functions that can be overridden, allowing one
104/// to avoid traversing nodes that don't need any transformation
105/// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
106/// operands have not changed (\c AlwaysRebuild()), and customize the
107/// default locations and entity names used for type-checking
108/// (\c getBaseLocation(), \c getBaseEntity()).
109template<typename Derived>
111 /// Private RAII object that helps us forget and then re-remember
112 /// the template argument corresponding to a partially-substituted parameter
113 /// pack.
114 class ForgetPartiallySubstitutedPackRAII {
115 Derived &Self;
117 // Set the pack expansion index to -1 to avoid pack substitution and
118 // indicate that parameter packs should be instantiated as themselves.
119 Sema::ArgumentPackSubstitutionIndexRAII ResetPackSubstIndex;
120
121 public:
122 ForgetPartiallySubstitutedPackRAII(Derived &Self)
123 : Self(Self), ResetPackSubstIndex(Self.getSema(), -1) {
124 Old = Self.ForgetPartiallySubstitutedPack();
125 }
126
127 ~ForgetPartiallySubstitutedPackRAII() {
128 Self.RememberPartiallySubstitutedPack(Old);
129 }
130 };
131
132protected:
134
135 /// The set of local declarations that have been transformed, for
136 /// cases where we are forced to build new declarations within the transformer
137 /// rather than in the subclass (e.g., lambda closure types).
138 llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
139
140public:
141 /// Initializes a new tree transformer.
143
144 /// Retrieves a reference to the derived class.
145 Derived &getDerived() { return static_cast<Derived&>(*this); }
146
147 /// Retrieves a reference to the derived class.
148 const Derived &getDerived() const {
149 return static_cast<const Derived&>(*this);
150 }
151
152 static inline ExprResult Owned(Expr *E) { return E; }
153 static inline StmtResult Owned(Stmt *S) { return S; }
154
155 /// Retrieves a reference to the semantic analysis object used for
156 /// this tree transform.
157 Sema &getSema() const { return SemaRef; }
158
159 /// Whether the transformation should always rebuild AST nodes, even
160 /// if none of the children have changed.
161 ///
162 /// Subclasses may override this function to specify when the transformation
163 /// should rebuild all AST nodes.
164 ///
165 /// We must always rebuild all AST nodes when performing variadic template
166 /// pack expansion, in order to avoid violating the AST invariant that each
167 /// statement node appears at most once in its containing declaration.
169
170 /// Whether the transformation is forming an expression or statement that
171 /// replaces the original. In this case, we'll reuse mangling numbers from
172 /// existing lambdas.
173 bool ReplacingOriginal() { return false; }
174
175 /// Wether CXXConstructExpr can be skipped when they are implicit.
176 /// They will be reconstructed when used if needed.
177 /// This is useful when the user that cause rebuilding of the
178 /// CXXConstructExpr is outside of the expression at which the TreeTransform
179 /// started.
180 bool AllowSkippingCXXConstructExpr() { return true; }
181
182 /// Returns the location of the entity being transformed, if that
183 /// information was not available elsewhere in the AST.
184 ///
185 /// By default, returns no source-location information. Subclasses can
186 /// provide an alternative implementation that provides better location
187 /// information.
189
190 /// Returns the name of the entity being transformed, if that
191 /// information was not available elsewhere in the AST.
192 ///
193 /// By default, returns an empty name. Subclasses can provide an alternative
194 /// implementation with a more precise name.
196
197 /// Sets the "base" location and entity when that
198 /// information is known based on another transformation.
199 ///
200 /// By default, the source location and entity are ignored. Subclasses can
201 /// override this function to provide a customized implementation.
203
204 /// RAII object that temporarily sets the base location and entity
205 /// used for reporting diagnostics in types.
207 TreeTransform &Self;
208 SourceLocation OldLocation;
209 DeclarationName OldEntity;
210
211 public:
213 DeclarationName Entity) : Self(Self) {
214 OldLocation = Self.getDerived().getBaseLocation();
215 OldEntity = Self.getDerived().getBaseEntity();
216
217 if (Location.isValid())
218 Self.getDerived().setBase(Location, Entity);
219 }
220
222 Self.getDerived().setBase(OldLocation, OldEntity);
223 }
224 };
225
226 /// Determine whether the given type \p T has already been
227 /// transformed.
228 ///
229 /// Subclasses can provide an alternative implementation of this routine
230 /// to short-circuit evaluation when it is known that a given type will
231 /// not change. For example, template instantiation need not traverse
232 /// non-dependent types.
234 return T.isNull();
235 }
236
237 /// Transform a template parameter depth level.
238 ///
239 /// During a transformation that transforms template parameters, this maps
240 /// an old template parameter depth to a new depth.
241 unsigned TransformTemplateDepth(unsigned Depth) {
242 return Depth;
243 }
244
245 /// Determine whether the given call argument should be dropped, e.g.,
246 /// because it is a default argument.
247 ///
248 /// Subclasses can provide an alternative implementation of this routine to
249 /// determine which kinds of call arguments get dropped. By default,
250 /// CXXDefaultArgument nodes are dropped (prior to transformation).
252 return E->isDefaultArgument();
253 }
254
255 /// Determine whether we should expand a pack expansion with the
256 /// given set of parameter packs into separate arguments by repeatedly
257 /// transforming the pattern.
258 ///
259 /// By default, the transformer never tries to expand pack expansions.
260 /// Subclasses can override this routine to provide different behavior.
261 ///
262 /// \param EllipsisLoc The location of the ellipsis that identifies the
263 /// pack expansion.
264 ///
265 /// \param PatternRange The source range that covers the entire pattern of
266 /// the pack expansion.
267 ///
268 /// \param Unexpanded The set of unexpanded parameter packs within the
269 /// pattern.
270 ///
271 /// \param ShouldExpand Will be set to \c true if the transformer should
272 /// expand the corresponding pack expansions into separate arguments. When
273 /// set, \c NumExpansions must also be set.
274 ///
275 /// \param RetainExpansion Whether the caller should add an unexpanded
276 /// pack expansion after all of the expanded arguments. This is used
277 /// when extending explicitly-specified template argument packs per
278 /// C++0x [temp.arg.explicit]p9.
279 ///
280 /// \param NumExpansions The number of separate arguments that will be in
281 /// the expanded form of the corresponding pack expansion. This is both an
282 /// input and an output parameter, which can be set by the caller if the
283 /// number of expansions is known a priori (e.g., due to a prior substitution)
284 /// and will be set by the callee when the number of expansions is known.
285 /// The callee must set this value when \c ShouldExpand is \c true; it may
286 /// set this value in other cases.
287 ///
288 /// \returns true if an error occurred (e.g., because the parameter packs
289 /// are to be instantiated with arguments of different lengths), false
290 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
291 /// must be set.
293 SourceRange PatternRange,
295 bool &ShouldExpand, bool &RetainExpansion,
296 std::optional<unsigned> &NumExpansions) {
297 ShouldExpand = false;
298 return false;
299 }
300
301 /// "Forget" about the partially-substituted pack template argument,
302 /// when performing an instantiation that must preserve the parameter pack
303 /// use.
304 ///
305 /// This routine is meant to be overridden by the template instantiator.
307 return TemplateArgument();
308 }
309
310 /// "Remember" the partially-substituted pack template argument
311 /// after performing an instantiation that must preserve the parameter pack
312 /// use.
313 ///
314 /// This routine is meant to be overridden by the template instantiator.
316
317 /// Note to the derived class when a function parameter pack is
318 /// being expanded.
320
321 /// Transforms the given type into another type.
322 ///
323 /// By default, this routine transforms a type by creating a
324 /// TypeSourceInfo for it and delegating to the appropriate
325 /// function. This is expensive, but we don't mind, because
326 /// this method is deprecated anyway; all users should be
327 /// switched to storing TypeSourceInfos.
328 ///
329 /// \returns the transformed type.
331
332 /// Transforms the given type-with-location into a new
333 /// type-with-location.
334 ///
335 /// By default, this routine transforms a type by delegating to the
336 /// appropriate TransformXXXType to build a new type. Subclasses
337 /// may override this function (to take over all type
338 /// transformations) or some set of the TransformXXXType functions
339 /// to alter the transformation.
341
342 /// Transform the given type-with-location into a new
343 /// type, collecting location information in the given builder
344 /// as necessary.
345 ///
347
348 /// Transform a type that is permitted to produce a
349 /// DeducedTemplateSpecializationType.
350 ///
351 /// This is used in the (relatively rare) contexts where it is acceptable
352 /// for transformation to produce a class template type with deduced
353 /// template arguments.
354 /// @{
357 /// @}
358
359 /// The reason why the value of a statement is not discarded, if any.
364 };
365
366 /// Transform the given statement.
367 ///
368 /// By default, this routine transforms a statement by delegating to the
369 /// appropriate TransformXXXStmt function to transform a specific kind of
370 /// statement or the TransformExpr() function to transform an expression.
371 /// Subclasses may override this function to transform statements using some
372 /// other mechanism.
373 ///
374 /// \returns the transformed statement.
376
377 /// Transform the given statement.
378 ///
379 /// By default, this routine transforms a statement by delegating to the
380 /// appropriate TransformOMPXXXClause function to transform a specific kind
381 /// of clause. Subclasses may override this function to transform statements
382 /// using some other mechanism.
383 ///
384 /// \returns the transformed OpenMP clause.
386
387 /// Transform the given attribute.
388 ///
389 /// By default, this routine transforms a statement by delegating to the
390 /// appropriate TransformXXXAttr function to transform a specific kind
391 /// of attribute. Subclasses may override this function to transform
392 /// attributed statements/types using some other mechanism.
393 ///
394 /// \returns the transformed attribute
395 const Attr *TransformAttr(const Attr *S);
396
397 // Transform the given statement attribute.
398 //
399 // Delegates to the appropriate TransformXXXAttr function to transform a
400 // specific kind of statement attribute. Unlike the non-statement taking
401 // version of this, this implements all attributes, not just pragmas.
402 const Attr *TransformStmtAttr(const Stmt *OrigS, const Stmt *InstS,
403 const Attr *A);
404
405 // Transform the specified attribute.
406 //
407 // Subclasses should override the transformation of attributes with a pragma
408 // spelling to transform expressions stored within the attribute.
409 //
410 // \returns the transformed attribute.
411#define ATTR(X) \
412 const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
413#include "clang/Basic/AttrList.inc"
414
415 // Transform the specified attribute.
416 //
417 // Subclasses should override the transformation of attributes to do
418 // transformation and checking of statement attributes. By default, this
419 // delegates to the non-statement taking version.
420 //
421 // \returns the transformed attribute.
422#define ATTR(X) \
423 const X##Attr *TransformStmt##X##Attr(const Stmt *, const Stmt *, \
424 const X##Attr *A) { \
425 return getDerived().Transform##X##Attr(A); \
426 }
427#include "clang/Basic/AttrList.inc"
428
429 /// Transform the given expression.
430 ///
431 /// By default, this routine transforms an expression by delegating to the
432 /// appropriate TransformXXXExpr function to build a new expression.
433 /// Subclasses may override this function to transform expressions using some
434 /// other mechanism.
435 ///
436 /// \returns the transformed expression.
438
439 /// Transform the given initializer.
440 ///
441 /// By default, this routine transforms an initializer by stripping off the
442 /// semantic nodes added by initialization, then passing the result to
443 /// TransformExpr or TransformExprs.
444 ///
445 /// \returns the transformed initializer.
447
448 /// Transform the given list of expressions.
449 ///
450 /// This routine transforms a list of expressions by invoking
451 /// \c TransformExpr() for each subexpression. However, it also provides
452 /// support for variadic templates by expanding any pack expansions (if the
453 /// derived class permits such expansion) along the way. When pack expansions
454 /// are present, the number of outputs may not equal the number of inputs.
455 ///
456 /// \param Inputs The set of expressions to be transformed.
457 ///
458 /// \param NumInputs The number of expressions in \c Inputs.
459 ///
460 /// \param IsCall If \c true, then this transform is being performed on
461 /// function-call arguments, and any arguments that should be dropped, will
462 /// be.
463 ///
464 /// \param Outputs The transformed input expressions will be added to this
465 /// vector.
466 ///
467 /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
468 /// due to transformation.
469 ///
470 /// \returns true if an error occurred, false otherwise.
471 bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
473 bool *ArgChanged = nullptr);
474
475 /// Transform the given declaration, which is referenced from a type
476 /// or expression.
477 ///
478 /// By default, acts as the identity function on declarations, unless the
479 /// transformer has had to transform the declaration itself. Subclasses
480 /// may override this function to provide alternate behavior.
482 llvm::DenseMap<Decl *, Decl *>::iterator Known
483 = TransformedLocalDecls.find(D);
484 if (Known != TransformedLocalDecls.end())
485 return Known->second;
486
487 return D;
488 }
489
490 /// Transform the specified condition.
491 ///
492 /// By default, this transforms the variable and expression and rebuilds
493 /// the condition.
495 Expr *Expr,
497
498 /// Transform the attributes associated with the given declaration and
499 /// place them on the new declaration.
500 ///
501 /// By default, this operation does nothing. Subclasses may override this
502 /// behavior to transform attributes.
503 void transformAttrs(Decl *Old, Decl *New) { }
504
505 /// Note that a local declaration has been transformed by this
506 /// transformer.
507 ///
508 /// Local declarations are typically transformed via a call to
509 /// TransformDefinition. However, in some cases (e.g., lambda expressions),
510 /// the transformer itself has to transform the declarations. This routine
511 /// can be overridden by a subclass that keeps track of such mappings.
513 assert(New.size() == 1 &&
514 "must override transformedLocalDecl if performing pack expansion");
515 TransformedLocalDecls[Old] = New.front();
516 }
517
518 /// Transform the definition of the given declaration.
519 ///
520 /// By default, invokes TransformDecl() to transform the declaration.
521 /// Subclasses may override this function to provide alternate behavior.
523 return getDerived().TransformDecl(Loc, D);
524 }
525
526 /// Transform the given declaration, which was the first part of a
527 /// nested-name-specifier in a member access expression.
528 ///
529 /// This specific declaration transformation only applies to the first
530 /// identifier in a nested-name-specifier of a member access expression, e.g.,
531 /// the \c T in \c x->T::member
532 ///
533 /// By default, invokes TransformDecl() to transform the declaration.
534 /// Subclasses may override this function to provide alternate behavior.
536 return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
537 }
538
539 /// Transform the set of declarations in an OverloadExpr.
540 bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
541 LookupResult &R);
542
543 /// Transform the given nested-name-specifier with source-location
544 /// information.
545 ///
546 /// By default, transforms all of the types and declarations within the
547 /// nested-name-specifier. Subclasses may override this function to provide
548 /// alternate behavior.
551 QualType ObjectType = QualType(),
552 NamedDecl *FirstQualifierInScope = nullptr);
553
554 /// Transform the given declaration name.
555 ///
556 /// By default, transforms the types of conversion function, constructor,
557 /// and destructor names and then (if needed) rebuilds the declaration name.
558 /// Identifiers and selectors are returned unmodified. Subclasses may
559 /// override this function to provide alternate behavior.
562
572
573 /// Transform the given template name.
574 ///
575 /// \param SS The nested-name-specifier that qualifies the template
576 /// name. This nested-name-specifier must already have been transformed.
577 ///
578 /// \param Name The template name to transform.
579 ///
580 /// \param NameLoc The source location of the template name.
581 ///
582 /// \param ObjectType If we're translating a template name within a member
583 /// access expression, this is the type of the object whose member template
584 /// is being referenced.
585 ///
586 /// \param FirstQualifierInScope If the first part of a nested-name-specifier
587 /// also refers to a name within the current (lexical) scope, this is the
588 /// declaration it refers to.
589 ///
590 /// By default, transforms the template name by transforming the declarations
591 /// and nested-name-specifiers that occur within the template name.
592 /// Subclasses may override this function to provide alternate behavior.
595 SourceLocation NameLoc,
596 QualType ObjectType = QualType(),
597 NamedDecl *FirstQualifierInScope = nullptr,
598 bool AllowInjectedClassName = false);
599
600 /// Transform the given template argument.
601 ///
602 /// By default, this operation transforms the type, expression, or
603 /// declaration stored within the template argument and constructs a
604 /// new template argument from the transformed result. Subclasses may
605 /// override this function to provide alternate behavior.
606 ///
607 /// Returns true if there was an error.
609 TemplateArgumentLoc &Output,
610 bool Uneval = false);
611
612 /// Transform the given set of template arguments.
613 ///
614 /// By default, this operation transforms all of the template arguments
615 /// in the input set using \c TransformTemplateArgument(), and appends
616 /// the transformed arguments to the output list.
617 ///
618 /// Note that this overload of \c TransformTemplateArguments() is merely
619 /// a convenience function. Subclasses that wish to override this behavior
620 /// should override the iterator-based member template version.
621 ///
622 /// \param Inputs The set of template arguments to be transformed.
623 ///
624 /// \param NumInputs The number of template arguments in \p Inputs.
625 ///
626 /// \param Outputs The set of transformed template arguments output by this
627 /// routine.
628 ///
629 /// Returns true if an error occurred.
631 unsigned NumInputs,
633 bool Uneval = false) {
634 return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
635 Uneval);
636 }
637
638 /// Transform the given set of template arguments.
639 ///
640 /// By default, this operation transforms all of the template arguments
641 /// in the input set using \c TransformTemplateArgument(), and appends
642 /// the transformed arguments to the output list.
643 ///
644 /// \param First An iterator to the first template argument.
645 ///
646 /// \param Last An iterator one step past the last template argument.
647 ///
648 /// \param Outputs The set of transformed template arguments output by this
649 /// routine.
650 ///
651 /// Returns true if an error occurred.
652 template<typename InputIterator>
654 InputIterator Last,
656 bool Uneval = false);
657
658 /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
660 TemplateArgumentLoc &ArgLoc);
661
662 /// Fakes up a TypeSourceInfo for a type.
666 }
667
668#define ABSTRACT_TYPELOC(CLASS, PARENT)
669#define TYPELOC(CLASS, PARENT) \
670 QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
671#include "clang/AST/TypeLocNodes.def"
672
675 bool SuppressObjCLifetime);
679 bool SuppressObjCLifetime);
680
681 template<typename Fn>
684 CXXRecordDecl *ThisContext,
685 Qualifiers ThisTypeQuals,
687
690 SmallVectorImpl<QualType> &Exceptions,
691 bool &Changed);
692
694
698 TemplateName Template);
699
703 TemplateName Template,
704 CXXScopeSpec &SS);
705
708 NestedNameSpecifierLoc QualifierLoc);
709
710 /// Transforms the parameters of a function type into the
711 /// given vectors.
712 ///
713 /// The result vectors should be kept in sync; null entries in the
714 /// variables vector are acceptable.
715 ///
716 /// LastParamTransformed, if non-null, will be set to the index of the last
717 /// parameter on which transfromation was started. In the event of an error,
718 /// this will contain the parameter which failed to instantiate.
719 ///
720 /// Return true on error.
723 const QualType *ParamTypes,
724 const FunctionProtoType::ExtParameterInfo *ParamInfos,
726 Sema::ExtParameterInfoBuilder &PInfos, unsigned *LastParamTransformed);
727
730 const QualType *ParamTypes,
731 const FunctionProtoType::ExtParameterInfo *ParamInfos,
734 return getDerived().TransformFunctionTypeParams(
735 Loc, Params, ParamTypes, ParamInfos, PTypes, PVars, PInfos, nullptr);
736 }
737
738 /// Transforms the parameters of a requires expresison into the given vectors.
739 ///
740 /// The result vectors should be kept in sync; null entries in the
741 /// variables vector are acceptable.
742 ///
743 /// Returns an unset ExprResult on success. Returns an ExprResult the 'not
744 /// satisfied' RequiresExpr if subsitution failed, OR an ExprError, both of
745 /// which are cases where transformation shouldn't continue.
747 SourceLocation KWLoc, SourceLocation RBraceLoc, const RequiresExpr *RE,
753 KWLoc, Params, /*ParamTypes=*/nullptr,
754 /*ParamInfos=*/nullptr, PTypes, &TransParams, PInfos))
755 return ExprError();
756
757 return ExprResult{};
758 }
759
760 /// Transforms a single function-type parameter. Return null
761 /// on error.
762 ///
763 /// \param indexAdjustment - A number to add to the parameter's
764 /// scope index; can be negative
766 int indexAdjustment,
767 std::optional<unsigned> NumExpansions,
768 bool ExpectParameterPack);
769
770 /// Transform the body of a lambda-expression.
772 /// Alternative implementation of TransformLambdaBody that skips transforming
773 /// the body.
775
778 return static_cast<CXXRecordDecl::LambdaDependencyKind>(
780 }
781
783
786
789 return TPL;
790 }
791
793
795 bool IsAddressOfOperand,
796 TypeSourceInfo **RecoveryTSI);
797
799 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
800 TypeSourceInfo **RecoveryTSI);
801
803 bool IsAddressOfOperand);
804
806
808
809// FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
810// amount of stack usage with clang.
811#define STMT(Node, Parent) \
812 LLVM_ATTRIBUTE_NOINLINE \
813 StmtResult Transform##Node(Node *S);
814#define VALUESTMT(Node, Parent) \
815 LLVM_ATTRIBUTE_NOINLINE \
816 StmtResult Transform##Node(Node *S, StmtDiscardKind SDK);
817#define EXPR(Node, Parent) \
818 LLVM_ATTRIBUTE_NOINLINE \
819 ExprResult Transform##Node(Node *E);
820#define ABSTRACT_STMT(Stmt)
821#include "clang/AST/StmtNodes.inc"
822
823#define GEN_CLANG_CLAUSE_CLASS
824#define CLAUSE_CLASS(Enum, Str, Class) \
825 LLVM_ATTRIBUTE_NOINLINE \
826 OMPClause *Transform##Class(Class *S);
827#include "llvm/Frontend/OpenMP/OMP.inc"
828
829 /// Build a new qualified type given its unqualified type and type location.
830 ///
831 /// By default, this routine adds type qualifiers only to types that can
832 /// have qualifiers, and silently suppresses those qualifiers that are not
833 /// permitted. Subclasses may override this routine to provide different
834 /// behavior.
836
837 /// Build a new pointer type given its pointee type.
838 ///
839 /// By default, performs semantic analysis when building the pointer type.
840 /// Subclasses may override this routine to provide different behavior.
842
843 /// Build a new block pointer type given its pointee type.
844 ///
845 /// By default, performs semantic analysis when building the block pointer
846 /// type. Subclasses may override this routine to provide different behavior.
848
849 /// Build a new reference type given the type it references.
850 ///
851 /// By default, performs semantic analysis when building the
852 /// reference type. Subclasses may override this routine to provide
853 /// different behavior.
854 ///
855 /// \param LValue whether the type was written with an lvalue sigil
856 /// or an rvalue sigil.
858 bool LValue,
859 SourceLocation Sigil);
860
861 /// Build a new member pointer type given the pointee type and the
862 /// class type it refers into.
863 ///
864 /// By default, performs semantic analysis when building the member pointer
865 /// type. Subclasses may override this routine to provide different behavior.
867 SourceLocation Sigil);
868
870 SourceLocation ProtocolLAngleLoc,
872 ArrayRef<SourceLocation> ProtocolLocs,
873 SourceLocation ProtocolRAngleLoc);
874
875 /// Build an Objective-C object type.
876 ///
877 /// By default, performs semantic analysis when building the object type.
878 /// Subclasses may override this routine to provide different behavior.
881 SourceLocation TypeArgsLAngleLoc,
883 SourceLocation TypeArgsRAngleLoc,
884 SourceLocation ProtocolLAngleLoc,
886 ArrayRef<SourceLocation> ProtocolLocs,
887 SourceLocation ProtocolRAngleLoc);
888
889 /// Build a new Objective-C object pointer type given the pointee type.
890 ///
891 /// By default, directly builds the pointer type, with no additional semantic
892 /// analysis.
895
896 /// Build a new array type given the element type, size
897 /// modifier, size of the array (if known), size expression, and index type
898 /// qualifiers.
899 ///
900 /// By default, performs semantic analysis when building the array type.
901 /// Subclasses may override this routine to provide different behavior.
902 /// Also by default, all of the other Rebuild*Array
904 const llvm::APInt *Size, Expr *SizeExpr,
905 unsigned IndexTypeQuals, SourceRange BracketsRange);
906
907 /// Build a new constant array type given the element type, size
908 /// modifier, (known) size of the array, and index type qualifiers.
909 ///
910 /// By default, performs semantic analysis when building the array type.
911 /// Subclasses may override this routine to provide different behavior.
913 ArraySizeModifier SizeMod,
914 const llvm::APInt &Size, Expr *SizeExpr,
915 unsigned IndexTypeQuals,
916 SourceRange BracketsRange);
917
918 /// Build a new incomplete array type given the element type, size
919 /// modifier, and index type qualifiers.
920 ///
921 /// By default, performs semantic analysis when building the array type.
922 /// Subclasses may override this routine to provide different behavior.
924 ArraySizeModifier SizeMod,
925 unsigned IndexTypeQuals,
926 SourceRange BracketsRange);
927
928 /// Build a new variable-length array type given the element type,
929 /// size modifier, size expression, and index type qualifiers.
930 ///
931 /// By default, performs semantic analysis when building the array type.
932 /// Subclasses may override this routine to provide different behavior.
934 ArraySizeModifier SizeMod, Expr *SizeExpr,
935 unsigned IndexTypeQuals,
936 SourceRange BracketsRange);
937
938 /// Build a new dependent-sized array type given the element type,
939 /// size modifier, size expression, and index type qualifiers.
940 ///
941 /// By default, performs semantic analysis when building the array type.
942 /// Subclasses may override this routine to provide different behavior.
944 ArraySizeModifier SizeMod,
945 Expr *SizeExpr,
946 unsigned IndexTypeQuals,
947 SourceRange BracketsRange);
948
949 /// Build a new vector type given the element type and
950 /// number of elements.
951 ///
952 /// By default, performs semantic analysis when building the vector type.
953 /// Subclasses may override this routine to provide different behavior.
954 QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
955 VectorKind VecKind);
956
957 /// Build a new potentially dependently-sized extended vector type
958 /// given the element type and number of elements.
959 ///
960 /// By default, performs semantic analysis when building the vector type.
961 /// Subclasses may override this routine to provide different behavior.
963 SourceLocation AttributeLoc, VectorKind);
964
965 /// Build a new extended vector type given the element type and
966 /// number of elements.
967 ///
968 /// By default, performs semantic analysis when building the vector type.
969 /// Subclasses may override this routine to provide different behavior.
970 QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
971 SourceLocation AttributeLoc);
972
973 /// Build a new potentially dependently-sized extended vector type
974 /// given the element type and number of elements.
975 ///
976 /// By default, performs semantic analysis when building the vector type.
977 /// Subclasses may override this routine to provide different behavior.
979 Expr *SizeExpr,
980 SourceLocation AttributeLoc);
981
982 /// Build a new matrix type given the element type and dimensions.
983 QualType RebuildConstantMatrixType(QualType ElementType, unsigned NumRows,
984 unsigned NumColumns);
985
986 /// Build a new matrix type given the type and dependently-defined
987 /// dimensions.
989 Expr *ColumnExpr,
990 SourceLocation AttributeLoc);
991
992 /// Build a new DependentAddressSpaceType or return the pointee
993 /// type variable with the correct address space (retrieved from
994 /// AddrSpaceExpr) applied to it. The former will be returned in cases
995 /// where the address space remains dependent.
996 ///
997 /// By default, performs semantic analysis when building the type with address
998 /// space applied. Subclasses may override this routine to provide different
999 /// behavior.
1001 Expr *AddrSpaceExpr,
1002 SourceLocation AttributeLoc);
1003
1004 /// Build a new function type.
1005 ///
1006 /// By default, performs semantic analysis when building the function type.
1007 /// Subclasses may override this routine to provide different behavior.
1009 MutableArrayRef<QualType> ParamTypes,
1011
1012 /// Build a new unprototyped function type.
1014
1015 /// Rebuild an unresolved typename type, given the decl that
1016 /// the UnresolvedUsingTypenameDecl was transformed to.
1018
1019 /// Build a new type found via an alias.
1021 return SemaRef.Context.getUsingType(Found, Underlying);
1022 }
1023
1024 /// Build a new typedef type.
1026 return SemaRef.Context.getTypeDeclType(Typedef);
1027 }
1028
1029 /// Build a new MacroDefined type.
1031 const IdentifierInfo *MacroII) {
1032 return SemaRef.Context.getMacroQualifiedType(T, MacroII);
1033 }
1034
1035 /// Build a new class/struct/union type.
1038 }
1039
1040 /// Build a new Enum type.
1043 }
1044
1045 /// Build a new typeof(expr) type.
1046 ///
1047 /// By default, performs semantic analysis when building the typeof type.
1048 /// Subclasses may override this routine to provide different behavior.
1050 TypeOfKind Kind);
1051
1052 /// Build a new typeof(type) type.
1053 ///
1054 /// By default, builds a new TypeOfType with the given underlying type.
1056
1057 /// Build a new unary transform type.
1061
1062 /// Build a new C++11 decltype type.
1063 ///
1064 /// By default, performs semantic analysis when building the decltype type.
1065 /// Subclasses may override this routine to provide different behavior.
1067
1070 SourceLocation EllipsisLoc,
1071 bool FullySubstituted,
1072 ArrayRef<QualType> Expansions = {});
1073
1074 /// Build a new C++11 auto type.
1075 ///
1076 /// By default, builds a new AutoType with the given deduced type.
1078 ConceptDecl *TypeConstraintConcept,
1079 ArrayRef<TemplateArgument> TypeConstraintArgs) {
1080 // Note, IsDependent is always false here: we implicitly convert an 'auto'
1081 // which has been deduced to a dependent type into an undeduced 'auto', so
1082 // that we'll retry deduction after the transformation.
1083 return SemaRef.Context.getAutoType(Deduced, Keyword,
1084 /*IsDependent*/ false, /*IsPack=*/false,
1085 TypeConstraintConcept,
1086 TypeConstraintArgs);
1087 }
1088
1089 /// By default, builds a new DeducedTemplateSpecializationType with the given
1090 /// deduced type.
1092 QualType Deduced) {
1094 Template, Deduced, /*IsDependent*/ false);
1095 }
1096
1097 /// Build a new template specialization type.
1098 ///
1099 /// By default, performs semantic analysis when building the template
1100 /// specialization type. Subclasses may override this routine to provide
1101 /// different behavior.
1103 SourceLocation TemplateLoc,
1105
1106 /// Build a new parenthesized type.
1107 ///
1108 /// By default, builds a new ParenType type from the inner type.
1109 /// Subclasses may override this routine to provide different behavior.
1111 return SemaRef.BuildParenType(InnerType);
1112 }
1113
1114 /// Build a new qualified name type.
1115 ///
1116 /// By default, builds a new ElaboratedType type from the keyword,
1117 /// the nested-name-specifier and the named type.
1118 /// Subclasses may override this routine to provide different behavior.
1120 ElaboratedTypeKeyword Keyword,
1121 NestedNameSpecifierLoc QualifierLoc,
1122 QualType Named) {
1123 return SemaRef.Context.getElaboratedType(Keyword,
1124 QualifierLoc.getNestedNameSpecifier(),
1125 Named);
1126 }
1127
1128 /// Build a new typename type that refers to a template-id.
1129 ///
1130 /// By default, builds a new DependentNameType type from the
1131 /// nested-name-specifier and the given type. Subclasses may override
1132 /// this routine to provide different behavior.
1134 ElaboratedTypeKeyword Keyword,
1135 NestedNameSpecifierLoc QualifierLoc,
1136 SourceLocation TemplateKWLoc,
1137 const IdentifierInfo *Name,
1138 SourceLocation NameLoc,
1140 bool AllowInjectedClassName) {
1141 // Rebuild the template name.
1142 // TODO: avoid TemplateName abstraction
1143 CXXScopeSpec SS;
1144 SS.Adopt(QualifierLoc);
1145 TemplateName InstName = getDerived().RebuildTemplateName(
1146 SS, TemplateKWLoc, *Name, NameLoc, QualType(), nullptr,
1147 AllowInjectedClassName);
1148
1149 if (InstName.isNull())
1150 return QualType();
1151
1152 // If it's still dependent, make a dependent specialization.
1153 if (InstName.getAsDependentTemplateName())
1155 Keyword, QualifierLoc.getNestedNameSpecifier(), Name,
1156 Args.arguments());
1157
1158 // Otherwise, make an elaborated type wrapping a non-dependent
1159 // specialization.
1160 QualType T =
1161 getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
1162 if (T.isNull())
1163 return QualType();
1165 Keyword, QualifierLoc.getNestedNameSpecifier(), T);
1166 }
1167
1168 /// Build a new typename type that refers to an identifier.
1169 ///
1170 /// By default, performs semantic analysis when building the typename type
1171 /// (or elaborated type). Subclasses may override this routine to provide
1172 /// different behavior.
1174 SourceLocation KeywordLoc,
1175 NestedNameSpecifierLoc QualifierLoc,
1176 const IdentifierInfo *Id,
1177 SourceLocation IdLoc,
1178 bool DeducedTSTContext) {
1179 CXXScopeSpec SS;
1180 SS.Adopt(QualifierLoc);
1181
1182 if (QualifierLoc.getNestedNameSpecifier()->isDependent()) {
1183 // If the name is still dependent, just build a new dependent name type.
1184 if (!SemaRef.computeDeclContext(SS))
1185 return SemaRef.Context.getDependentNameType(Keyword,
1186 QualifierLoc.getNestedNameSpecifier(),
1187 Id);
1188 }
1189
1190 if (Keyword == ElaboratedTypeKeyword::None ||
1192 return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1193 *Id, IdLoc, DeducedTSTContext);
1194 }
1195
1197
1198 // We had a dependent elaborated-type-specifier that has been transformed
1199 // into a non-dependent elaborated-type-specifier. Find the tag we're
1200 // referring to.
1202 DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1203 if (!DC)
1204 return QualType();
1205
1207 return QualType();
1208
1209 TagDecl *Tag = nullptr;
1211 switch (Result.getResultKind()) {
1214 break;
1215
1217 Tag = Result.getAsSingle<TagDecl>();
1218 break;
1219
1222 llvm_unreachable("Tag lookup cannot find non-tags");
1223
1225 // Let the LookupResult structure handle ambiguities.
1226 return QualType();
1227 }
1228
1229 if (!Tag) {
1230 // Check where the name exists but isn't a tag type and use that to emit
1231 // better diagnostics.
1234 switch (Result.getResultKind()) {
1238 NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1239 Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1240 SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
1241 << SomeDecl << NTK << llvm::to_underlying(Kind);
1242 SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1243 break;
1244 }
1245 default:
1246 SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1247 << llvm::to_underlying(Kind) << Id << DC
1248 << QualifierLoc.getSourceRange();
1249 break;
1250 }
1251 return QualType();
1252 }
1253
1254 if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1255 IdLoc, Id)) {
1256 SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1257 SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1258 return QualType();
1259 }
1260
1261 // Build the elaborated-type-specifier type.
1263 return SemaRef.Context.getElaboratedType(Keyword,
1264 QualifierLoc.getNestedNameSpecifier(),
1265 T);
1266 }
1267
1268 /// Build a new pack expansion type.
1269 ///
1270 /// By default, builds a new PackExpansionType type from the given pattern.
1271 /// Subclasses may override this routine to provide different behavior.
1273 SourceLocation EllipsisLoc,
1274 std::optional<unsigned> NumExpansions) {
1275 return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1276 NumExpansions);
1277 }
1278
1279 /// Build a new atomic type given its value type.
1280 ///
1281 /// By default, performs semantic analysis when building the atomic type.
1282 /// Subclasses may override this routine to provide different behavior.
1284
1285 /// Build a new pipe type given its value type.
1287 bool isReadPipe);
1288
1289 /// Build a bit-precise int given its value type.
1290 QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits,
1292
1293 /// Build a dependent bit-precise int given its value type.
1294 QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
1296
1297 /// Build a new template name given a nested name specifier, a flag
1298 /// indicating whether the "template" keyword was provided, and the template
1299 /// that the template name refers to.
1300 ///
1301 /// By default, builds the new template name directly. Subclasses may override
1302 /// this routine to provide different behavior.
1304 bool TemplateKW,
1305 TemplateDecl *Template);
1306
1307 /// Build a new template name given a nested name specifier and the
1308 /// name that is referred to as a template.
1309 ///
1310 /// By default, performs semantic analysis to determine whether the name can
1311 /// be resolved to a specific template, then builds the appropriate kind of
1312 /// template name. Subclasses may override this routine to provide different
1313 /// behavior.
1315 SourceLocation TemplateKWLoc,
1316 const IdentifierInfo &Name,
1317 SourceLocation NameLoc, QualType ObjectType,
1318 NamedDecl *FirstQualifierInScope,
1319 bool AllowInjectedClassName);
1320
1321 /// Build a new template name given a nested name specifier and the
1322 /// overloaded operator name that is referred to as a template.
1323 ///
1324 /// By default, performs semantic analysis to determine whether the name can
1325 /// be resolved to a specific template, then builds the appropriate kind of
1326 /// template name. Subclasses may override this routine to provide different
1327 /// behavior.
1329 SourceLocation TemplateKWLoc,
1330 OverloadedOperatorKind Operator,
1331 SourceLocation NameLoc, QualType ObjectType,
1332 bool AllowInjectedClassName);
1333
1334 /// Build a new template name given a template template parameter pack
1335 /// and the
1336 ///
1337 /// By default, performs semantic analysis to determine whether the name can
1338 /// be resolved to a specific template, then builds the appropriate kind of
1339 /// template name. Subclasses may override this routine to provide different
1340 /// behavior.
1342 Decl *AssociatedDecl, unsigned Index,
1343 bool Final) {
1345 ArgPack, AssociatedDecl, Index, Final);
1346 }
1347
1348 /// Build a new compound statement.
1349 ///
1350 /// By default, performs semantic analysis to build the new statement.
1351 /// Subclasses may override this routine to provide different behavior.
1353 MultiStmtArg Statements,
1354 SourceLocation RBraceLoc,
1355 bool IsStmtExpr) {
1356 return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1357 IsStmtExpr);
1358 }
1359
1360 /// Build a new case statement.
1361 ///
1362 /// By default, performs semantic analysis to build the new statement.
1363 /// Subclasses may override this routine to provide different behavior.
1365 Expr *LHS,
1366 SourceLocation EllipsisLoc,
1367 Expr *RHS,
1368 SourceLocation ColonLoc) {
1369 return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1370 ColonLoc);
1371 }
1372
1373 /// Attach the body to a new case statement.
1374 ///
1375 /// By default, performs semantic analysis to build the new statement.
1376 /// Subclasses may override this routine to provide different behavior.
1378 getSema().ActOnCaseStmtBody(S, Body);
1379 return S;
1380 }
1381
1382 /// Build a new default statement.
1383 ///
1384 /// By default, performs semantic analysis to build the new statement.
1385 /// Subclasses may override this routine to provide different behavior.
1387 SourceLocation ColonLoc,
1388 Stmt *SubStmt) {
1389 return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1390 /*CurScope=*/nullptr);
1391 }
1392
1393 /// Build a new label statement.
1394 ///
1395 /// By default, performs semantic analysis to build the new statement.
1396 /// Subclasses may override this routine to provide different behavior.
1398 SourceLocation ColonLoc, Stmt *SubStmt) {
1399 return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1400 }
1401
1402 /// Build a new attributed statement.
1403 ///
1404 /// By default, performs semantic analysis to build the new statement.
1405 /// Subclasses may override this routine to provide different behavior.
1408 Stmt *SubStmt) {
1410 return StmtError();
1411 return SemaRef.BuildAttributedStmt(AttrLoc, Attrs, SubStmt);
1412 }
1413
1414 /// Build a new "if" statement.
1415 ///
1416 /// By default, performs semantic analysis to build the new statement.
1417 /// Subclasses may override this routine to provide different behavior.
1419 SourceLocation LParenLoc, Sema::ConditionResult Cond,
1420 SourceLocation RParenLoc, Stmt *Init, Stmt *Then,
1421 SourceLocation ElseLoc, Stmt *Else) {
1422 return getSema().ActOnIfStmt(IfLoc, Kind, LParenLoc, Init, Cond, RParenLoc,
1423 Then, ElseLoc, Else);
1424 }
1425
1426 /// Start building a new switch statement.
1427 ///
1428 /// By default, performs semantic analysis to build the new statement.
1429 /// Subclasses may override this routine to provide different behavior.
1431 SourceLocation LParenLoc, Stmt *Init,
1433 SourceLocation RParenLoc) {
1434 return getSema().ActOnStartOfSwitchStmt(SwitchLoc, LParenLoc, Init, Cond,
1435 RParenLoc);
1436 }
1437
1438 /// Attach the body to the switch statement.
1439 ///
1440 /// By default, performs semantic analysis to build the new statement.
1441 /// Subclasses may override this routine to provide different behavior.
1443 Stmt *Switch, Stmt *Body) {
1444 return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1445 }
1446
1447 /// Build a new while statement.
1448 ///
1449 /// By default, performs semantic analysis to build the new statement.
1450 /// Subclasses may override this routine to provide different behavior.
1453 SourceLocation RParenLoc, Stmt *Body) {
1454 return getSema().ActOnWhileStmt(WhileLoc, LParenLoc, Cond, RParenLoc, Body);
1455 }
1456
1457 /// Build a new do-while statement.
1458 ///
1459 /// By default, performs semantic analysis to build the new statement.
1460 /// Subclasses may override this routine to provide different behavior.
1462 SourceLocation WhileLoc, SourceLocation LParenLoc,
1463 Expr *Cond, SourceLocation RParenLoc) {
1464 return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1465 Cond, RParenLoc);
1466 }
1467
1468 /// Build a new for statement.
1469 ///
1470 /// By default, performs semantic analysis to build the new statement.
1471 /// Subclasses may override this routine to provide different behavior.
1474 Sema::FullExprArg Inc, SourceLocation RParenLoc,
1475 Stmt *Body) {
1476 return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1477 Inc, RParenLoc, Body);
1478 }
1479
1480 /// Build a new goto statement.
1481 ///
1482 /// By default, performs semantic analysis to build the new statement.
1483 /// Subclasses may override this routine to provide different behavior.
1485 LabelDecl *Label) {
1486 return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1487 }
1488
1489 /// Build a new indirect goto statement.
1490 ///
1491 /// By default, performs semantic analysis to build the new statement.
1492 /// Subclasses may override this routine to provide different behavior.
1494 SourceLocation StarLoc,
1495 Expr *Target) {
1496 return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1497 }
1498
1499 /// Build a new return statement.
1500 ///
1501 /// By default, performs semantic analysis to build the new statement.
1502 /// Subclasses may override this routine to provide different behavior.
1504 return getSema().BuildReturnStmt(ReturnLoc, Result);
1505 }
1506
1507 /// Build a new declaration statement.
1508 ///
1509 /// By default, performs semantic analysis to build the new statement.
1510 /// Subclasses may override this routine to provide different behavior.
1512 SourceLocation StartLoc, SourceLocation EndLoc) {
1514 return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1515 }
1516
1517 /// Build a new inline asm statement.
1518 ///
1519 /// By default, performs semantic analysis to build the new statement.
1520 /// Subclasses may override this routine to provide different behavior.
1522 bool IsVolatile, unsigned NumOutputs,
1523 unsigned NumInputs, IdentifierInfo **Names,
1524 MultiExprArg Constraints, MultiExprArg Exprs,
1525 Expr *AsmString, MultiExprArg Clobbers,
1526 unsigned NumLabels,
1527 SourceLocation RParenLoc) {
1528 return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1529 NumInputs, Names, Constraints, Exprs,
1530 AsmString, Clobbers, NumLabels, RParenLoc);
1531 }
1532
1533 /// Build a new MS style inline asm statement.
1534 ///
1535 /// By default, performs semantic analysis to build the new statement.
1536 /// Subclasses may override this routine to provide different behavior.
1538 ArrayRef<Token> AsmToks,
1539 StringRef AsmString,
1540 unsigned NumOutputs, unsigned NumInputs,
1541 ArrayRef<StringRef> Constraints,
1542 ArrayRef<StringRef> Clobbers,
1543 ArrayRef<Expr*> Exprs,
1544 SourceLocation EndLoc) {
1545 return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1546 NumOutputs, NumInputs,
1547 Constraints, Clobbers, Exprs, EndLoc);
1548 }
1549
1550 /// Build a new co_return statement.
1551 ///
1552 /// By default, performs semantic analysis to build the new statement.
1553 /// Subclasses may override this routine to provide different behavior.
1555 bool IsImplicit) {
1556 return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1557 }
1558
1559 /// Build a new co_await expression.
1560 ///
1561 /// By default, performs semantic analysis to build the new expression.
1562 /// Subclasses may override this routine to provide different behavior.
1564 UnresolvedLookupExpr *OpCoawaitLookup,
1565 bool IsImplicit) {
1566 // This function rebuilds a coawait-expr given its operator.
1567 // For an explicit coawait-expr, the rebuild involves the full set
1568 // of transformations performed by BuildUnresolvedCoawaitExpr(),
1569 // including calling await_transform().
1570 // For an implicit coawait-expr, we need to rebuild the "operator
1571 // coawait" but not await_transform(), so use BuildResolvedCoawaitExpr().
1572 // This mirrors how the implicit CoawaitExpr is originally created
1573 // in Sema::ActOnCoroutineBodyStart().
1574 if (IsImplicit) {
1576 CoawaitLoc, Operand, OpCoawaitLookup);
1577 if (Suspend.isInvalid())
1578 return ExprError();
1579 return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Operand,
1580 Suspend.get(), true);
1581 }
1582
1583 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Operand,
1584 OpCoawaitLookup);
1585 }
1586
1587 /// Build a new co_await expression.
1588 ///
1589 /// By default, performs semantic analysis to build the new expression.
1590 /// Subclasses may override this routine to provide different behavior.
1592 Expr *Result,
1593 UnresolvedLookupExpr *Lookup) {
1594 return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1595 }
1596
1597 /// Build a new co_yield expression.
1598 ///
1599 /// By default, performs semantic analysis to build the new expression.
1600 /// Subclasses may override this routine to provide different behavior.
1602 return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1603 }
1604
1606 return getSema().BuildCoroutineBodyStmt(Args);
1607 }
1608
1609 /// Build a new Objective-C \@try statement.
1610 ///
1611 /// By default, performs semantic analysis to build the new statement.
1612 /// Subclasses may override this routine to provide different behavior.
1614 Stmt *TryBody,
1615 MultiStmtArg CatchStmts,
1616 Stmt *Finally) {
1617 return getSema().ObjC().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1618 Finally);
1619 }
1620
1621 /// Rebuild an Objective-C exception declaration.
1622 ///
1623 /// By default, performs semantic analysis to build the new declaration.
1624 /// Subclasses may override this routine to provide different behavior.
1626 TypeSourceInfo *TInfo, QualType T) {
1628 TInfo, T, ExceptionDecl->getInnerLocStart(),
1629 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
1630 }
1631
1632 /// Build a new Objective-C \@catch statement.
1633 ///
1634 /// By default, performs semantic analysis to build the new statement.
1635 /// Subclasses may override this routine to provide different behavior.
1637 SourceLocation RParenLoc,
1638 VarDecl *Var,
1639 Stmt *Body) {
1640 return getSema().ObjC().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, Var, Body);
1641 }
1642
1643 /// Build a new Objective-C \@finally statement.
1644 ///
1645 /// By default, performs semantic analysis to build the new statement.
1646 /// Subclasses may override this routine to provide different behavior.
1648 Stmt *Body) {
1649 return getSema().ObjC().ActOnObjCAtFinallyStmt(AtLoc, Body);
1650 }
1651
1652 /// Build a new Objective-C \@throw statement.
1653 ///
1654 /// By default, performs semantic analysis to build the new statement.
1655 /// Subclasses may override this routine to provide different behavior.
1657 Expr *Operand) {
1658 return getSema().ObjC().BuildObjCAtThrowStmt(AtLoc, Operand);
1659 }
1660
1661 /// Build a new OpenMP Canonical loop.
1662 ///
1663 /// Ensures that the outermost loop in @p LoopStmt is wrapped by a
1664 /// OMPCanonicalLoop.
1666 return getSema().OpenMP().ActOnOpenMPCanonicalLoop(LoopStmt);
1667 }
1668
1669 /// Build a new OpenMP executable directive.
1670 ///
1671 /// By default, performs semantic analysis to build the new statement.
1672 /// Subclasses may override this routine to provide different behavior.
1674 DeclarationNameInfo DirName,
1675 OpenMPDirectiveKind CancelRegion,
1676 ArrayRef<OMPClause *> Clauses,
1677 Stmt *AStmt, SourceLocation StartLoc,
1678 SourceLocation EndLoc) {
1679
1681 Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1682 }
1683
1684 /// Build a new OpenMP informational directive.
1686 DeclarationNameInfo DirName,
1687 ArrayRef<OMPClause *> Clauses,
1688 Stmt *AStmt,
1689 SourceLocation StartLoc,
1690 SourceLocation EndLoc) {
1691
1693 Kind, DirName, Clauses, AStmt, StartLoc, EndLoc);
1694 }
1695
1696 /// Build a new OpenMP 'if' 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 Expr *Condition, SourceLocation StartLoc,
1702 SourceLocation LParenLoc,
1703 SourceLocation NameModifierLoc,
1704 SourceLocation ColonLoc,
1705 SourceLocation EndLoc) {
1707 NameModifier, Condition, StartLoc, LParenLoc, NameModifierLoc, ColonLoc,
1708 EndLoc);
1709 }
1710
1711 /// Build a new OpenMP 'final' clause.
1712 ///
1713 /// By default, performs semantic analysis to build the new OpenMP clause.
1714 /// Subclasses may override this routine to provide different behavior.
1716 SourceLocation LParenLoc,
1717 SourceLocation EndLoc) {
1718 return getSema().OpenMP().ActOnOpenMPFinalClause(Condition, StartLoc,
1719 LParenLoc, EndLoc);
1720 }
1721
1722 /// Build a new OpenMP 'num_threads' clause.
1723 ///
1724 /// By default, performs semantic analysis to build the new OpenMP clause.
1725 /// Subclasses may override this routine to provide different behavior.
1727 SourceLocation StartLoc,
1728 SourceLocation LParenLoc,
1729 SourceLocation EndLoc) {
1730 return getSema().OpenMP().ActOnOpenMPNumThreadsClause(NumThreads, StartLoc,
1731 LParenLoc, EndLoc);
1732 }
1733
1734 /// Build a new OpenMP 'safelen' clause.
1735 ///
1736 /// By default, performs semantic analysis to build the new OpenMP clause.
1737 /// Subclasses may override this routine to provide different behavior.
1739 SourceLocation LParenLoc,
1740 SourceLocation EndLoc) {
1741 return getSema().OpenMP().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc,
1742 EndLoc);
1743 }
1744
1745 /// Build a new OpenMP 'simdlen' clause.
1746 ///
1747 /// By default, performs semantic analysis to build the new OpenMP clause.
1748 /// Subclasses may override this routine to provide different behavior.
1750 SourceLocation LParenLoc,
1751 SourceLocation EndLoc) {
1752 return getSema().OpenMP().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc,
1753 EndLoc);
1754 }
1755
1757 SourceLocation StartLoc,
1758 SourceLocation LParenLoc,
1759 SourceLocation EndLoc) {
1760 return getSema().OpenMP().ActOnOpenMPSizesClause(Sizes, StartLoc, LParenLoc,
1761 EndLoc);
1762 }
1763
1764 /// Build a new OpenMP 'permutation' clause.
1766 SourceLocation StartLoc,
1767 SourceLocation LParenLoc,
1768 SourceLocation EndLoc) {
1769 return getSema().OpenMP().ActOnOpenMPPermutationClause(PermExprs, StartLoc,
1770 LParenLoc, EndLoc);
1771 }
1772
1773 /// Build a new OpenMP 'full' clause.
1775 SourceLocation EndLoc) {
1776 return getSema().OpenMP().ActOnOpenMPFullClause(StartLoc, EndLoc);
1777 }
1778
1779 /// Build a new OpenMP 'partial' clause.
1781 SourceLocation LParenLoc,
1782 SourceLocation EndLoc) {
1783 return getSema().OpenMP().ActOnOpenMPPartialClause(Factor, StartLoc,
1784 LParenLoc, EndLoc);
1785 }
1786
1787 /// Build a new OpenMP 'allocator' clause.
1788 ///
1789 /// By default, performs semantic analysis to build the new OpenMP clause.
1790 /// Subclasses may override this routine to provide different behavior.
1792 SourceLocation LParenLoc,
1793 SourceLocation EndLoc) {
1794 return getSema().OpenMP().ActOnOpenMPAllocatorClause(A, StartLoc, LParenLoc,
1795 EndLoc);
1796 }
1797
1798 /// Build a new OpenMP 'collapse' clause.
1799 ///
1800 /// By default, performs semantic analysis to build the new OpenMP clause.
1801 /// Subclasses may override this routine to provide different behavior.
1803 SourceLocation LParenLoc,
1804 SourceLocation EndLoc) {
1805 return getSema().OpenMP().ActOnOpenMPCollapseClause(Num, StartLoc,
1806 LParenLoc, EndLoc);
1807 }
1808
1809 /// Build a new OpenMP 'default' clause.
1810 ///
1811 /// By default, performs semantic analysis to build the new OpenMP clause.
1812 /// Subclasses may override this routine to provide different behavior.
1814 SourceLocation StartLoc,
1815 SourceLocation LParenLoc,
1816 SourceLocation EndLoc) {
1818 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1819 }
1820
1821 /// Build a new OpenMP 'proc_bind' clause.
1822 ///
1823 /// By default, performs semantic analysis to build the new OpenMP clause.
1824 /// Subclasses may override this routine to provide different behavior.
1826 SourceLocation KindKwLoc,
1827 SourceLocation StartLoc,
1828 SourceLocation LParenLoc,
1829 SourceLocation EndLoc) {
1831 Kind, KindKwLoc, StartLoc, LParenLoc, EndLoc);
1832 }
1833
1834 /// Build a new OpenMP 'schedule' clause.
1835 ///
1836 /// By default, performs semantic analysis to build the new OpenMP clause.
1837 /// Subclasses may override this routine to provide different behavior.
1840 OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1841 SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1842 SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1844 M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1845 CommaLoc, EndLoc);
1846 }
1847
1848 /// Build a new OpenMP 'ordered' clause.
1849 ///
1850 /// By default, performs semantic analysis to build the new OpenMP clause.
1851 /// Subclasses may override this routine to provide different behavior.
1853 SourceLocation EndLoc,
1854 SourceLocation LParenLoc, Expr *Num) {
1855 return getSema().OpenMP().ActOnOpenMPOrderedClause(StartLoc, EndLoc,
1856 LParenLoc, Num);
1857 }
1858
1859 /// Build a new OpenMP 'private' clause.
1860 ///
1861 /// By default, performs semantic analysis to build the new OpenMP clause.
1862 /// Subclasses may override this routine to provide different behavior.
1864 SourceLocation StartLoc,
1865 SourceLocation LParenLoc,
1866 SourceLocation EndLoc) {
1867 return getSema().OpenMP().ActOnOpenMPPrivateClause(VarList, StartLoc,
1868 LParenLoc, EndLoc);
1869 }
1870
1871 /// Build a new OpenMP 'firstprivate' clause.
1872 ///
1873 /// By default, performs semantic analysis to build the new OpenMP clause.
1874 /// Subclasses may override this routine to provide different behavior.
1876 SourceLocation StartLoc,
1877 SourceLocation LParenLoc,
1878 SourceLocation EndLoc) {
1879 return getSema().OpenMP().ActOnOpenMPFirstprivateClause(VarList, StartLoc,
1880 LParenLoc, EndLoc);
1881 }
1882
1883 /// Build a new OpenMP 'lastprivate' clause.
1884 ///
1885 /// By default, performs semantic analysis to build the new OpenMP clause.
1886 /// Subclasses may override this routine to provide different behavior.
1889 SourceLocation LPKindLoc,
1890 SourceLocation ColonLoc,
1891 SourceLocation StartLoc,
1892 SourceLocation LParenLoc,
1893 SourceLocation EndLoc) {
1895 VarList, LPKind, LPKindLoc, ColonLoc, StartLoc, LParenLoc, EndLoc);
1896 }
1897
1898 /// Build a new OpenMP 'shared' clause.
1899 ///
1900 /// By default, performs semantic analysis to build the new OpenMP clause.
1901 /// Subclasses may override this routine to provide different behavior.
1903 SourceLocation StartLoc,
1904 SourceLocation LParenLoc,
1905 SourceLocation EndLoc) {
1906 return getSema().OpenMP().ActOnOpenMPSharedClause(VarList, StartLoc,
1907 LParenLoc, EndLoc);
1908 }
1909
1910 /// Build a new OpenMP 'reduction' clause.
1911 ///
1912 /// By default, performs semantic analysis to build the new statement.
1913 /// Subclasses may override this routine to provide different behavior.
1916 SourceLocation StartLoc, SourceLocation LParenLoc,
1917 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1918 SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec,
1919 const DeclarationNameInfo &ReductionId,
1920 ArrayRef<Expr *> UnresolvedReductions) {
1922 VarList, Modifier, StartLoc, LParenLoc, ModifierLoc, ColonLoc, EndLoc,
1923 ReductionIdScopeSpec, ReductionId, UnresolvedReductions);
1924 }
1925
1926 /// Build a new OpenMP 'task_reduction' clause.
1927 ///
1928 /// By default, performs semantic analysis to build the new statement.
1929 /// Subclasses may override this routine to provide different behavior.
1931 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1932 SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc,
1933 CXXScopeSpec &ReductionIdScopeSpec,
1934 const DeclarationNameInfo &ReductionId,
1935 ArrayRef<Expr *> UnresolvedReductions) {
1937 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1938 ReductionId, UnresolvedReductions);
1939 }
1940
1941 /// Build a new OpenMP 'in_reduction' clause.
1942 ///
1943 /// By default, performs semantic analysis to build the new statement.
1944 /// Subclasses may override this routine to provide different behavior.
1945 OMPClause *
1947 SourceLocation LParenLoc, SourceLocation ColonLoc,
1948 SourceLocation EndLoc,
1949 CXXScopeSpec &ReductionIdScopeSpec,
1950 const DeclarationNameInfo &ReductionId,
1951 ArrayRef<Expr *> UnresolvedReductions) {
1953 VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1954 ReductionId, UnresolvedReductions);
1955 }
1956
1957 /// Build a new OpenMP 'linear' clause.
1958 ///
1959 /// By default, performs semantic analysis to build the new OpenMP clause.
1960 /// Subclasses may override this routine to provide different behavior.
1962 ArrayRef<Expr *> VarList, Expr *Step, SourceLocation StartLoc,
1963 SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier,
1964 SourceLocation ModifierLoc, SourceLocation ColonLoc,
1965 SourceLocation StepModifierLoc, SourceLocation EndLoc) {
1967 VarList, Step, StartLoc, LParenLoc, Modifier, ModifierLoc, ColonLoc,
1968 StepModifierLoc, EndLoc);
1969 }
1970
1971 /// Build a new OpenMP 'aligned' clause.
1972 ///
1973 /// By default, performs semantic analysis to build the new OpenMP clause.
1974 /// Subclasses may override this routine to provide different behavior.
1976 SourceLocation StartLoc,
1977 SourceLocation LParenLoc,
1978 SourceLocation ColonLoc,
1979 SourceLocation EndLoc) {
1981 VarList, Alignment, StartLoc, LParenLoc, ColonLoc, EndLoc);
1982 }
1983
1984 /// Build a new OpenMP 'copyin' 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().ActOnOpenMPCopyinClause(VarList, StartLoc,
1993 LParenLoc, EndLoc);
1994 }
1995
1996 /// Build a new OpenMP 'copyprivate' 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 StartLoc,
2002 SourceLocation LParenLoc,
2003 SourceLocation EndLoc) {
2004 return getSema().OpenMP().ActOnOpenMPCopyprivateClause(VarList, StartLoc,
2005 LParenLoc, EndLoc);
2006 }
2007
2008 /// Build a new OpenMP 'flush' pseudo clause.
2009 ///
2010 /// By default, performs semantic analysis to build the new OpenMP clause.
2011 /// Subclasses may override this routine to provide different behavior.
2013 SourceLocation StartLoc,
2014 SourceLocation LParenLoc,
2015 SourceLocation EndLoc) {
2016 return getSema().OpenMP().ActOnOpenMPFlushClause(VarList, StartLoc,
2017 LParenLoc, EndLoc);
2018 }
2019
2020 /// Build a new OpenMP 'depobj' pseudo clause.
2021 ///
2022 /// By default, performs semantic analysis to build the new OpenMP clause.
2023 /// Subclasses may override this routine to provide different behavior.
2025 SourceLocation LParenLoc,
2026 SourceLocation EndLoc) {
2027 return getSema().OpenMP().ActOnOpenMPDepobjClause(Depobj, StartLoc,
2028 LParenLoc, EndLoc);
2029 }
2030
2031 /// Build a new OpenMP 'depend' pseudo clause.
2032 ///
2033 /// By default, performs semantic analysis to build the new OpenMP clause.
2034 /// Subclasses may override this routine to provide different behavior.
2036 Expr *DepModifier, ArrayRef<Expr *> VarList,
2037 SourceLocation StartLoc,
2038 SourceLocation LParenLoc,
2039 SourceLocation EndLoc) {
2041 Data, DepModifier, VarList, StartLoc, LParenLoc, EndLoc);
2042 }
2043
2044 /// Build a new OpenMP 'device' clause.
2045 ///
2046 /// By default, performs semantic analysis to build the new statement.
2047 /// Subclasses may override this routine to provide different behavior.
2049 Expr *Device, SourceLocation StartLoc,
2050 SourceLocation LParenLoc,
2051 SourceLocation ModifierLoc,
2052 SourceLocation EndLoc) {
2054 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2055 }
2056
2057 /// Build a new OpenMP 'map' clause.
2058 ///
2059 /// By default, performs semantic analysis to build the new OpenMP clause.
2060 /// Subclasses may override this routine to provide different behavior.
2062 Expr *IteratorModifier, ArrayRef<OpenMPMapModifierKind> MapTypeModifiers,
2063 ArrayRef<SourceLocation> MapTypeModifiersLoc,
2064 CXXScopeSpec MapperIdScopeSpec, DeclarationNameInfo MapperId,
2065 OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
2066 SourceLocation MapLoc, SourceLocation ColonLoc, ArrayRef<Expr *> VarList,
2067 const OMPVarListLocTy &Locs, ArrayRef<Expr *> UnresolvedMappers) {
2069 IteratorModifier, MapTypeModifiers, MapTypeModifiersLoc,
2070 MapperIdScopeSpec, MapperId, MapType, IsMapTypeImplicit, MapLoc,
2071 ColonLoc, VarList, Locs,
2072 /*NoDiagnose=*/false, UnresolvedMappers);
2073 }
2074
2075 /// Build a new OpenMP 'allocate' clause.
2076 ///
2077 /// By default, performs semantic analysis to build the new OpenMP clause.
2078 /// Subclasses may override this routine to provide different behavior.
2079 OMPClause *
2080 RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment,
2081 OpenMPAllocateClauseModifier FirstModifier,
2082 SourceLocation FirstModifierLoc,
2083 OpenMPAllocateClauseModifier SecondModifier,
2084 SourceLocation SecondModifierLoc,
2085 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2086 SourceLocation LParenLoc, SourceLocation ColonLoc,
2087 SourceLocation EndLoc) {
2089 Allocate, Alignment, FirstModifier, FirstModifierLoc, SecondModifier,
2090 SecondModifierLoc, VarList, StartLoc, LParenLoc, ColonLoc, EndLoc);
2091 }
2092
2093 /// Build a new OpenMP 'num_teams' clause.
2094 ///
2095 /// By default, performs semantic analysis to build the new statement.
2096 /// Subclasses may override this routine to provide different behavior.
2098 SourceLocation StartLoc,
2099 SourceLocation LParenLoc,
2100 SourceLocation EndLoc) {
2101 return getSema().OpenMP().ActOnOpenMPNumTeamsClause(VarList, StartLoc,
2102 LParenLoc, EndLoc);
2103 }
2104
2105 /// Build a new OpenMP 'thread_limit' clause.
2106 ///
2107 /// By default, performs semantic analysis to build the new statement.
2108 /// Subclasses may override this routine to provide different behavior.
2110 SourceLocation StartLoc,
2111 SourceLocation LParenLoc,
2112 SourceLocation EndLoc) {
2113 return getSema().OpenMP().ActOnOpenMPThreadLimitClause(VarList, StartLoc,
2114 LParenLoc, EndLoc);
2115 }
2116
2117 /// Build a new OpenMP 'priority' clause.
2118 ///
2119 /// By default, performs semantic analysis to build the new statement.
2120 /// Subclasses may override this routine to provide different behavior.
2122 SourceLocation LParenLoc,
2123 SourceLocation EndLoc) {
2124 return getSema().OpenMP().ActOnOpenMPPriorityClause(Priority, StartLoc,
2125 LParenLoc, EndLoc);
2126 }
2127
2128 /// Build a new OpenMP 'grainsize' clause.
2129 ///
2130 /// By default, performs semantic analysis to build the new statement.
2131 /// Subclasses may override this routine to provide different behavior.
2133 Expr *Device, SourceLocation StartLoc,
2134 SourceLocation LParenLoc,
2135 SourceLocation ModifierLoc,
2136 SourceLocation EndLoc) {
2138 Modifier, Device, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2139 }
2140
2141 /// Build a new OpenMP 'num_tasks' clause.
2142 ///
2143 /// By default, performs semantic analysis to build the new statement.
2144 /// Subclasses may override this routine to provide different behavior.
2146 Expr *NumTasks, SourceLocation StartLoc,
2147 SourceLocation LParenLoc,
2148 SourceLocation ModifierLoc,
2149 SourceLocation EndLoc) {
2151 Modifier, NumTasks, StartLoc, LParenLoc, ModifierLoc, EndLoc);
2152 }
2153
2154 /// Build a new OpenMP 'hint' clause.
2155 ///
2156 /// By default, performs semantic analysis to build the new statement.
2157 /// Subclasses may override this routine to provide different behavior.
2159 SourceLocation LParenLoc,
2160 SourceLocation EndLoc) {
2161 return getSema().OpenMP().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc,
2162 EndLoc);
2163 }
2164
2165 /// Build a new OpenMP 'detach' clause.
2166 ///
2167 /// By default, performs semantic analysis to build the new statement.
2168 /// Subclasses may override this routine to provide different behavior.
2170 SourceLocation LParenLoc,
2171 SourceLocation EndLoc) {
2172 return getSema().OpenMP().ActOnOpenMPDetachClause(Evt, StartLoc, LParenLoc,
2173 EndLoc);
2174 }
2175
2176 /// Build a new OpenMP 'dist_schedule' clause.
2177 ///
2178 /// By default, performs semantic analysis to build the new OpenMP clause.
2179 /// Subclasses may override this routine to provide different behavior.
2180 OMPClause *
2182 Expr *ChunkSize, SourceLocation StartLoc,
2183 SourceLocation LParenLoc, SourceLocation KindLoc,
2184 SourceLocation CommaLoc, SourceLocation EndLoc) {
2186 Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
2187 }
2188
2189 /// Build a new OpenMP 'to' clause.
2190 ///
2191 /// By default, performs semantic analysis to build the new statement.
2192 /// Subclasses may override this routine to provide different behavior.
2193 OMPClause *
2195 ArrayRef<SourceLocation> MotionModifiersLoc,
2196 CXXScopeSpec &MapperIdScopeSpec,
2197 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2198 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2199 ArrayRef<Expr *> UnresolvedMappers) {
2201 MotionModifiers, MotionModifiersLoc, MapperIdScopeSpec, MapperId,
2202 ColonLoc, VarList, Locs, UnresolvedMappers);
2203 }
2204
2205 /// Build a new OpenMP 'from' clause.
2206 ///
2207 /// By default, performs semantic analysis to build the new statement.
2208 /// Subclasses may override this routine to provide different behavior.
2209 OMPClause *
2211 ArrayRef<SourceLocation> MotionModifiersLoc,
2212 CXXScopeSpec &MapperIdScopeSpec,
2213 DeclarationNameInfo &MapperId, SourceLocation ColonLoc,
2214 ArrayRef<Expr *> VarList, const OMPVarListLocTy &Locs,
2215 ArrayRef<Expr *> UnresolvedMappers) {
2217 MotionModifiers, MotionModifiersLoc, MapperIdScopeSpec, MapperId,
2218 ColonLoc, VarList, Locs, UnresolvedMappers);
2219 }
2220
2221 /// Build a new OpenMP 'use_device_ptr' clause.
2222 ///
2223 /// By default, performs semantic analysis to build the new OpenMP clause.
2224 /// Subclasses may override this routine to provide different behavior.
2226 const OMPVarListLocTy &Locs) {
2227 return getSema().OpenMP().ActOnOpenMPUseDevicePtrClause(VarList, Locs);
2228 }
2229
2230 /// Build a new OpenMP 'use_device_addr' clause.
2231 ///
2232 /// By default, performs semantic analysis to build the new OpenMP clause.
2233 /// Subclasses may override this routine to provide different behavior.
2235 const OMPVarListLocTy &Locs) {
2236 return getSema().OpenMP().ActOnOpenMPUseDeviceAddrClause(VarList, Locs);
2237 }
2238
2239 /// Build a new OpenMP 'is_device_ptr' clause.
2240 ///
2241 /// By default, performs semantic analysis to build the new OpenMP clause.
2242 /// Subclasses may override this routine to provide different behavior.
2244 const OMPVarListLocTy &Locs) {
2245 return getSema().OpenMP().ActOnOpenMPIsDevicePtrClause(VarList, Locs);
2246 }
2247
2248 /// Build a new OpenMP 'has_device_addr' clause.
2249 ///
2250 /// By default, performs semantic analysis to build the new OpenMP clause.
2251 /// Subclasses may override this routine to provide different behavior.
2253 const OMPVarListLocTy &Locs) {
2254 return getSema().OpenMP().ActOnOpenMPHasDeviceAddrClause(VarList, Locs);
2255 }
2256
2257 /// Build a new OpenMP 'defaultmap' clause.
2258 ///
2259 /// By default, performs semantic analysis to build the new OpenMP clause.
2260 /// Subclasses may override this routine to provide different behavior.
2263 SourceLocation StartLoc,
2264 SourceLocation LParenLoc,
2265 SourceLocation MLoc,
2266 SourceLocation KindLoc,
2267 SourceLocation EndLoc) {
2269 M, Kind, StartLoc, LParenLoc, MLoc, KindLoc, EndLoc);
2270 }
2271
2272 /// Build a new OpenMP 'nontemporal' clause.
2273 ///
2274 /// By default, performs semantic analysis to build the new OpenMP clause.
2275 /// Subclasses may override this routine to provide different behavior.
2277 SourceLocation StartLoc,
2278 SourceLocation LParenLoc,
2279 SourceLocation EndLoc) {
2280 return getSema().OpenMP().ActOnOpenMPNontemporalClause(VarList, StartLoc,
2281 LParenLoc, EndLoc);
2282 }
2283
2284 /// Build a new OpenMP 'inclusive' clause.
2285 ///
2286 /// By default, performs semantic analysis to build the new OpenMP clause.
2287 /// Subclasses may override this routine to provide different behavior.
2289 SourceLocation StartLoc,
2290 SourceLocation LParenLoc,
2291 SourceLocation EndLoc) {
2292 return getSema().OpenMP().ActOnOpenMPInclusiveClause(VarList, StartLoc,
2293 LParenLoc, EndLoc);
2294 }
2295
2296 /// Build a new OpenMP 'exclusive' clause.
2297 ///
2298 /// By default, performs semantic analysis to build the new OpenMP clause.
2299 /// Subclasses may override this routine to provide different behavior.
2301 SourceLocation StartLoc,
2302 SourceLocation LParenLoc,
2303 SourceLocation EndLoc) {
2304 return getSema().OpenMP().ActOnOpenMPExclusiveClause(VarList, StartLoc,
2305 LParenLoc, EndLoc);
2306 }
2307
2308 /// Build a new OpenMP 'uses_allocators' clause.
2309 ///
2310 /// By default, performs semantic analysis to build the new OpenMP clause.
2311 /// Subclasses may override this routine to provide different behavior.
2314 SourceLocation LParenLoc, SourceLocation EndLoc) {
2316 StartLoc, LParenLoc, EndLoc, Data);
2317 }
2318
2319 /// Build a new OpenMP 'affinity' clause.
2320 ///
2321 /// By default, performs semantic analysis to build the new OpenMP clause.
2322 /// Subclasses may override this routine to provide different behavior.
2324 SourceLocation LParenLoc,
2325 SourceLocation ColonLoc,
2326 SourceLocation EndLoc, Expr *Modifier,
2327 ArrayRef<Expr *> Locators) {
2329 StartLoc, LParenLoc, ColonLoc, EndLoc, Modifier, Locators);
2330 }
2331
2332 /// Build a new OpenMP 'order' clause.
2333 ///
2334 /// By default, performs semantic analysis to build the new OpenMP clause.
2335 /// Subclasses may override this routine to provide different behavior.
2337 OpenMPOrderClauseKind Kind, SourceLocation KindKwLoc,
2338 SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc,
2339 OpenMPOrderClauseModifier Modifier, SourceLocation ModifierKwLoc) {
2341 Modifier, Kind, StartLoc, LParenLoc, ModifierKwLoc, KindKwLoc, EndLoc);
2342 }
2343
2344 /// Build a new OpenMP 'init' clause.
2345 ///
2346 /// By default, performs semantic analysis to build the new OpenMP clause.
2347 /// Subclasses may override this routine to provide different behavior.
2349 SourceLocation StartLoc,
2350 SourceLocation LParenLoc,
2351 SourceLocation VarLoc,
2352 SourceLocation EndLoc) {
2354 InteropVar, InteropInfo, StartLoc, LParenLoc, VarLoc, EndLoc);
2355 }
2356
2357 /// Build a new OpenMP 'use' clause.
2358 ///
2359 /// By default, performs semantic analysis to build the new OpenMP clause.
2360 /// Subclasses may override this routine to provide different behavior.
2362 SourceLocation LParenLoc,
2363 SourceLocation VarLoc, SourceLocation EndLoc) {
2364 return getSema().OpenMP().ActOnOpenMPUseClause(InteropVar, StartLoc,
2365 LParenLoc, VarLoc, EndLoc);
2366 }
2367
2368 /// Build a new OpenMP 'destroy' clause.
2369 ///
2370 /// By default, performs semantic analysis to build the new OpenMP clause.
2371 /// Subclasses may override this routine to provide different behavior.
2373 SourceLocation LParenLoc,
2374 SourceLocation VarLoc,
2375 SourceLocation EndLoc) {
2377 InteropVar, StartLoc, LParenLoc, VarLoc, EndLoc);
2378 }
2379
2380 /// Build a new OpenMP 'novariants' clause.
2381 ///
2382 /// By default, performs semantic analysis to build the new OpenMP clause.
2383 /// Subclasses may override this routine to provide different behavior.
2385 SourceLocation StartLoc,
2386 SourceLocation LParenLoc,
2387 SourceLocation EndLoc) {
2389 LParenLoc, EndLoc);
2390 }
2391
2392 /// Build a new OpenMP 'nocontext' clause.
2393 ///
2394 /// By default, performs semantic analysis to build the new OpenMP clause.
2395 /// Subclasses may override this routine to provide different behavior.
2397 SourceLocation LParenLoc,
2398 SourceLocation EndLoc) {
2400 LParenLoc, EndLoc);
2401 }
2402
2403 /// Build a new OpenMP 'filter' clause.
2404 ///
2405 /// By default, performs semantic analysis to build the new OpenMP clause.
2406 /// Subclasses may override this routine to provide different behavior.
2408 SourceLocation LParenLoc,
2409 SourceLocation EndLoc) {
2410 return getSema().OpenMP().ActOnOpenMPFilterClause(ThreadID, StartLoc,
2411 LParenLoc, EndLoc);
2412 }
2413
2414 /// Build a new OpenMP 'bind' clause.
2415 ///
2416 /// By default, performs semantic analysis to build the new OpenMP clause.
2417 /// Subclasses may override this routine to provide different behavior.
2419 SourceLocation KindLoc,
2420 SourceLocation StartLoc,
2421 SourceLocation LParenLoc,
2422 SourceLocation EndLoc) {
2423 return getSema().OpenMP().ActOnOpenMPBindClause(Kind, KindLoc, StartLoc,
2424 LParenLoc, EndLoc);
2425 }
2426
2427 /// Build a new OpenMP 'ompx_dyn_cgroup_mem' clause.
2428 ///
2429 /// By default, performs semantic analysis to build the new OpenMP clause.
2430 /// Subclasses may override this routine to provide different behavior.
2432 SourceLocation LParenLoc,
2433 SourceLocation EndLoc) {
2434 return getSema().OpenMP().ActOnOpenMPXDynCGroupMemClause(Size, StartLoc,
2435 LParenLoc, EndLoc);
2436 }
2437
2438 /// Build a new OpenMP 'ompx_attribute' clause.
2439 ///
2440 /// By default, performs semantic analysis to build the new OpenMP clause.
2441 /// Subclasses may override this routine to provide different behavior.
2443 SourceLocation StartLoc,
2444 SourceLocation LParenLoc,
2445 SourceLocation EndLoc) {
2446 return getSema().OpenMP().ActOnOpenMPXAttributeClause(Attrs, StartLoc,
2447 LParenLoc, EndLoc);
2448 }
2449
2450 /// Build a new OpenMP 'ompx_bare' clause.
2451 ///
2452 /// By default, performs semantic analysis to build the new OpenMP clause.
2453 /// Subclasses may override this routine to provide different behavior.
2455 SourceLocation EndLoc) {
2456 return getSema().OpenMP().ActOnOpenMPXBareClause(StartLoc, EndLoc);
2457 }
2458
2459 /// Build a new OpenMP 'align' clause.
2460 ///
2461 /// By default, performs semantic analysis to build the new OpenMP clause.
2462 /// Subclasses may override this routine to provide different behavior.
2464 SourceLocation LParenLoc,
2465 SourceLocation EndLoc) {
2466 return getSema().OpenMP().ActOnOpenMPAlignClause(A, StartLoc, LParenLoc,
2467 EndLoc);
2468 }
2469
2470 /// Build a new OpenMP 'at' clause.
2471 ///
2472 /// By default, performs semantic analysis to build the new OpenMP clause.
2473 /// Subclasses may override this routine to provide different behavior.
2475 SourceLocation StartLoc,
2476 SourceLocation LParenLoc,
2477 SourceLocation EndLoc) {
2478 return getSema().OpenMP().ActOnOpenMPAtClause(Kind, KwLoc, StartLoc,
2479 LParenLoc, EndLoc);
2480 }
2481
2482 /// Build a new OpenMP 'severity' clause.
2483 ///
2484 /// By default, performs semantic analysis to build the new OpenMP clause.
2485 /// Subclasses may override this routine to provide different behavior.
2487 SourceLocation KwLoc,
2488 SourceLocation StartLoc,
2489 SourceLocation LParenLoc,
2490 SourceLocation EndLoc) {
2491 return getSema().OpenMP().ActOnOpenMPSeverityClause(Kind, KwLoc, StartLoc,
2492 LParenLoc, EndLoc);
2493 }
2494
2495 /// Build a new OpenMP 'message' clause.
2496 ///
2497 /// By default, performs semantic analysis to build the new OpenMP clause.
2498 /// Subclasses may override this routine to provide different behavior.
2500 SourceLocation LParenLoc,
2501 SourceLocation EndLoc) {
2502 return getSema().OpenMP().ActOnOpenMPMessageClause(MS, StartLoc, LParenLoc,
2503 EndLoc);
2504 }
2505
2506 /// Build a new OpenMP 'doacross' clause.
2507 ///
2508 /// By default, performs semantic analysis to build the new OpenMP clause.
2509 /// Subclasses may override this routine to provide different behavior.
2510 OMPClause *
2512 SourceLocation DepLoc, SourceLocation ColonLoc,
2513 ArrayRef<Expr *> VarList, SourceLocation StartLoc,
2514 SourceLocation LParenLoc, SourceLocation EndLoc) {
2516 DepType, DepLoc, ColonLoc, VarList, StartLoc, LParenLoc, EndLoc);
2517 }
2518
2519 /// Build a new OpenMP 'holds' clause.
2521 SourceLocation LParenLoc,
2522 SourceLocation EndLoc) {
2523 return getSema().OpenMP().ActOnOpenMPHoldsClause(A, StartLoc, LParenLoc,
2524 EndLoc);
2525 }
2526
2527 /// Rebuild the operand to an Objective-C \@synchronized statement.
2528 ///
2529 /// By default, performs semantic analysis to build the new statement.
2530 /// Subclasses may override this routine to provide different behavior.
2532 Expr *object) {
2533 return getSema().ObjC().ActOnObjCAtSynchronizedOperand(atLoc, object);
2534 }
2535
2536 /// Build a new Objective-C \@synchronized statement.
2537 ///
2538 /// By default, performs semantic analysis to build the new statement.
2539 /// Subclasses may override this routine to provide different behavior.
2541 Expr *Object, Stmt *Body) {
2542 return getSema().ObjC().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
2543 }
2544
2545 /// Build a new Objective-C \@autoreleasepool statement.
2546 ///
2547 /// By default, performs semantic analysis to build the new statement.
2548 /// Subclasses may override this routine to provide different behavior.
2550 Stmt *Body) {
2551 return getSema().ObjC().ActOnObjCAutoreleasePoolStmt(AtLoc, Body);
2552 }
2553
2554 /// Build a new Objective-C fast enumeration statement.
2555 ///
2556 /// By default, performs semantic analysis to build the new statement.
2557 /// Subclasses may override this routine to provide different behavior.
2559 Stmt *Element,
2560 Expr *Collection,
2561 SourceLocation RParenLoc,
2562 Stmt *Body) {
2564 ForLoc, Element, Collection, RParenLoc);
2565 if (ForEachStmt.isInvalid())
2566 return StmtError();
2567
2568 return getSema().ObjC().FinishObjCForCollectionStmt(ForEachStmt.get(),
2569 Body);
2570 }
2571
2572 /// Build a new C++ exception declaration.
2573 ///
2574 /// By default, performs semantic analysis to build the new decaration.
2575 /// Subclasses may override this routine to provide different behavior.
2578 SourceLocation StartLoc,
2579 SourceLocation IdLoc,
2580 IdentifierInfo *Id) {
2582 StartLoc, IdLoc, Id);
2583 if (Var)
2584 getSema().CurContext->addDecl(Var);
2585 return Var;
2586 }
2587
2588 /// Build a new C++ catch statement.
2589 ///
2590 /// By default, performs semantic analysis to build the new statement.
2591 /// Subclasses may override this routine to provide different behavior.
2593 VarDecl *ExceptionDecl,
2594 Stmt *Handler) {
2595 return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2596 Handler));
2597 }
2598
2599 /// Build a new C++ try statement.
2600 ///
2601 /// By default, performs semantic analysis to build the new statement.
2602 /// Subclasses may override this routine to provide different behavior.
2604 ArrayRef<Stmt *> Handlers) {
2605 return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2606 }
2607
2608 /// Build a new C++0x range-based for statement.
2609 ///
2610 /// By default, performs semantic analysis to build the new statement.
2611 /// Subclasses may override this routine to provide different behavior.
2613 SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *Init,
2614 SourceLocation ColonLoc, Stmt *Range, Stmt *Begin, Stmt *End, Expr *Cond,
2615 Expr *Inc, Stmt *LoopVar, SourceLocation RParenLoc,
2616 ArrayRef<MaterializeTemporaryExpr *> LifetimeExtendTemps) {
2617 // If we've just learned that the range is actually an Objective-C
2618 // collection, treat this as an Objective-C fast enumeration loop.
2619 if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2620 if (RangeStmt->isSingleDecl()) {
2621 if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2622 if (RangeVar->isInvalidDecl())
2623 return StmtError();
2624
2625 Expr *RangeExpr = RangeVar->getInit();
2626 if (!RangeExpr->isTypeDependent() &&
2627 RangeExpr->getType()->isObjCObjectPointerType()) {
2628 // FIXME: Support init-statements in Objective-C++20 ranged for
2629 // statement.
2630 if (Init) {
2631 return SemaRef.Diag(Init->getBeginLoc(),
2632 diag::err_objc_for_range_init_stmt)
2633 << Init->getSourceRange();
2634 }
2636 ForLoc, LoopVar, RangeExpr, RParenLoc);
2637 }
2638 }
2639 }
2640 }
2641
2643 ForLoc, CoawaitLoc, Init, ColonLoc, Range, Begin, End, Cond, Inc,
2644 LoopVar, RParenLoc, Sema::BFRK_Rebuild, LifetimeExtendTemps);
2645 }
2646
2647 /// Build a new C++0x range-based for statement.
2648 ///
2649 /// By default, performs semantic analysis to build the new statement.
2650 /// Subclasses may override this routine to provide different behavior.
2652 bool IsIfExists,
2653 NestedNameSpecifierLoc QualifierLoc,
2654 DeclarationNameInfo NameInfo,
2655 Stmt *Nested) {
2656 return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2657 QualifierLoc, NameInfo, Nested);
2658 }
2659
2660 /// Attach body to a C++0x range-based for statement.
2661 ///
2662 /// By default, performs semantic analysis to finish the new statement.
2663 /// Subclasses may override this routine to provide different behavior.
2665 return getSema().FinishCXXForRangeStmt(ForRange, Body);
2666 }
2667
2669 Stmt *TryBlock, Stmt *Handler) {
2670 return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2671 }
2672
2674 Stmt *Block) {
2675 return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2676 }
2677
2679 return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2680 }
2681
2683 SourceLocation LParen,
2684 SourceLocation RParen,
2685 TypeSourceInfo *TSI) {
2686 return getSema().SYCL().BuildUniqueStableNameExpr(OpLoc, LParen, RParen,
2687 TSI);
2688 }
2689
2690 /// Build a new predefined expression.
2691 ///
2692 /// By default, performs semantic analysis to build the new expression.
2693 /// Subclasses may override this routine to provide different behavior.
2695 return getSema().BuildPredefinedExpr(Loc, IK);
2696 }
2697
2698 /// Build a new expression that references a declaration.
2699 ///
2700 /// By default, performs semantic analysis to build the new expression.
2701 /// Subclasses may override this routine to provide different behavior.
2703 LookupResult &R,
2704 bool RequiresADL) {
2705 return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2706 }
2707
2708
2709 /// Build a new expression that references a declaration.
2710 ///
2711 /// By default, performs semantic analysis to build the new expression.
2712 /// Subclasses may override this routine to provide different behavior.
2714 ValueDecl *VD,
2715 const DeclarationNameInfo &NameInfo,
2717 TemplateArgumentListInfo *TemplateArgs) {
2718 CXXScopeSpec SS;
2719 SS.Adopt(QualifierLoc);
2720 return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD, Found,
2721 TemplateArgs);
2722 }
2723
2724 /// Build a new expression in parentheses.
2725 ///
2726 /// By default, performs semantic analysis to build the new expression.
2727 /// Subclasses may override this routine to provide different behavior.
2729 SourceLocation RParen) {
2730 return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2731 }
2732
2733 /// Build a new pseudo-destructor expression.
2734 ///
2735 /// By default, performs semantic analysis to build the new expression.
2736 /// Subclasses may override this routine to provide different behavior.
2738 SourceLocation OperatorLoc,
2739 bool isArrow,
2740 CXXScopeSpec &SS,
2741 TypeSourceInfo *ScopeType,
2742 SourceLocation CCLoc,
2743 SourceLocation TildeLoc,
2744 PseudoDestructorTypeStorage Destroyed);
2745
2746 /// Build a new unary operator expression.
2747 ///
2748 /// By default, performs semantic analysis to build the new expression.
2749 /// Subclasses may override this routine to provide different behavior.
2752 Expr *SubExpr) {
2753 return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2754 }
2755
2756 /// Build a new builtin offsetof expression.
2757 ///
2758 /// By default, performs semantic analysis to build the new expression.
2759 /// Subclasses may override this routine to provide different behavior.
2763 SourceLocation RParenLoc) {
2764 return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2765 RParenLoc);
2766 }
2767
2768 /// Build a new sizeof, alignof or vec_step expression with a
2769 /// type argument.
2770 ///
2771 /// By default, performs semantic analysis to build the new expression.
2772 /// Subclasses may override this routine to provide different behavior.
2774 SourceLocation OpLoc,
2775 UnaryExprOrTypeTrait ExprKind,
2776 SourceRange R) {
2777 return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2778 }
2779
2780 /// Build a new sizeof, alignof or vec step expression with an
2781 /// expression argument.
2782 ///
2783 /// By default, performs semantic analysis to build the new expression.
2784 /// Subclasses may override this routine to provide different behavior.
2786 UnaryExprOrTypeTrait ExprKind,
2787 SourceRange R) {
2789 = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2790 if (Result.isInvalid())
2791 return ExprError();
2792
2793 return Result;
2794 }
2795
2796 /// Build a new array subscript expression.
2797 ///
2798 /// By default, performs semantic analysis to build the new expression.
2799 /// Subclasses may override this routine to provide different behavior.
2801 SourceLocation LBracketLoc,
2802 Expr *RHS,
2803 SourceLocation RBracketLoc) {
2804 return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2805 LBracketLoc, RHS,
2806 RBracketLoc);
2807 }
2808
2809 /// Build a new matrix subscript expression.
2810 ///
2811 /// By default, performs semantic analysis to build the new expression.
2812 /// Subclasses may override this routine to provide different behavior.
2814 Expr *ColumnIdx,
2815 SourceLocation RBracketLoc) {
2816 return getSema().CreateBuiltinMatrixSubscriptExpr(Base, RowIdx, ColumnIdx,
2817 RBracketLoc);
2818 }
2819
2820 /// Build a new array section expression.
2821 ///
2822 /// By default, performs semantic analysis to build the new expression.
2823 /// Subclasses may override this routine to provide different behavior.
2825 SourceLocation LBracketLoc,
2826 Expr *LowerBound,
2827 SourceLocation ColonLocFirst,
2828 SourceLocation ColonLocSecond,
2829 Expr *Length, Expr *Stride,
2830 SourceLocation RBracketLoc) {
2831 if (IsOMPArraySection)
2833 Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
2834 Stride, RBracketLoc);
2835
2836 assert(Stride == nullptr && !ColonLocSecond.isValid() &&
2837 "Stride/second colon not allowed for OpenACC");
2838
2840 Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
2841 }
2842
2843 /// Build a new array shaping expression.
2844 ///
2845 /// By default, performs semantic analysis to build the new expression.
2846 /// Subclasses may override this routine to provide different behavior.
2848 SourceLocation RParenLoc,
2849 ArrayRef<Expr *> Dims,
2850 ArrayRef<SourceRange> BracketsRanges) {
2852 Base, LParenLoc, RParenLoc, Dims, BracketsRanges);
2853 }
2854
2855 /// Build a new iterator expression.
2856 ///
2857 /// By default, performs semantic analysis to build the new expression.
2858 /// Subclasses may override this routine to provide different behavior.
2861 SourceLocation RLoc,
2864 /*Scope=*/nullptr, IteratorKwLoc, LLoc, RLoc, Data);
2865 }
2866
2867 /// Build a new call expression.
2868 ///
2869 /// By default, performs semantic analysis to build the new expression.
2870 /// Subclasses may override this routine to provide different behavior.
2872 MultiExprArg Args,
2873 SourceLocation RParenLoc,
2874 Expr *ExecConfig = nullptr) {
2875 return getSema().ActOnCallExpr(
2876 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc, ExecConfig);
2877 }
2878
2880 MultiExprArg Args,
2881 SourceLocation RParenLoc) {
2883 /*Scope=*/nullptr, Callee, LParenLoc, Args, RParenLoc);
2884 }
2885
2886 /// Build a new member access expression.
2887 ///
2888 /// By default, performs semantic analysis to build the new expression.
2889 /// Subclasses may override this routine to provide different behavior.
2891 bool isArrow,
2892 NestedNameSpecifierLoc QualifierLoc,
2893 SourceLocation TemplateKWLoc,
2894 const DeclarationNameInfo &MemberNameInfo,
2896 NamedDecl *FoundDecl,
2897 const TemplateArgumentListInfo *ExplicitTemplateArgs,
2898 NamedDecl *FirstQualifierInScope) {
2900 isArrow);
2901 if (!Member->getDeclName()) {
2902 // We have a reference to an unnamed field. This is always the
2903 // base of an anonymous struct/union member access, i.e. the
2904 // field is always of record type.
2905 assert(Member->getType()->isRecordType() &&
2906 "unnamed member not of record type?");
2907
2908 BaseResult =
2910 QualifierLoc.getNestedNameSpecifier(),
2911 FoundDecl, Member);
2912 if (BaseResult.isInvalid())
2913 return ExprError();
2914 Base = BaseResult.get();
2915
2916 // `TranformMaterializeTemporaryExpr()` removes materialized temporaries
2917 // from the AST, so we need to re-insert them if needed (since
2918 // `BuildFieldRefereneExpr()` doesn't do this).
2919 if (!isArrow && Base->isPRValue()) {
2921 if (BaseResult.isInvalid())
2922 return ExprError();
2923 Base = BaseResult.get();
2924 }
2925
2926 CXXScopeSpec EmptySS;
2928 Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2929 DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()),
2930 MemberNameInfo);
2931 }
2932
2933 CXXScopeSpec SS;
2934 SS.Adopt(QualifierLoc);
2935
2936 Base = BaseResult.get();
2937 if (Base->containsErrors())
2938 return ExprError();
2939
2940 QualType BaseType = Base->getType();
2941
2942 if (isArrow && !BaseType->isPointerType())
2943 return ExprError();
2944
2945 // FIXME: this involves duplicating earlier analysis in a lot of
2946 // cases; we should avoid this when possible.
2947 LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
2948 R.addDecl(FoundDecl);
2949 R.resolveKind();
2950
2951 if (getSema().isUnevaluatedContext() && Base->isImplicitCXXThis() &&
2952 isa<FieldDecl, IndirectFieldDecl, MSPropertyDecl>(Member)) {
2953 if (auto *ThisClass = cast<CXXThisExpr>(Base)
2954 ->getType()
2955 ->getPointeeType()
2956 ->getAsCXXRecordDecl()) {
2957 auto *Class = cast<CXXRecordDecl>(Member->getDeclContext());
2958 // In unevaluated contexts, an expression supposed to be a member access
2959 // might reference a member in an unrelated class.
2960 if (!ThisClass->Equals(Class) && !ThisClass->isDerivedFrom(Class))
2961 return getSema().BuildDeclRefExpr(Member, Member->getType(),
2962 VK_LValue, Member->getLocation());
2963 }
2964 }
2965
2966 return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
2967 SS, TemplateKWLoc,
2968 FirstQualifierInScope,
2969 R, ExplicitTemplateArgs,
2970 /*S*/nullptr);
2971 }
2972
2973 /// Build a new binary operator expression.
2974 ///
2975 /// By default, performs semantic analysis to build the new expression.
2976 /// Subclasses may override this routine to provide different behavior.
2979 Expr *LHS, Expr *RHS) {
2980 return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS);
2981 }
2982
2983 /// Build a new rewritten operator expression.
2984 ///
2985 /// By default, performs semantic analysis to build the new expression.
2986 /// Subclasses may override this routine to provide different behavior.
2988 SourceLocation OpLoc, BinaryOperatorKind Opcode,
2989 const UnresolvedSetImpl &UnqualLookups, Expr *LHS, Expr *RHS) {
2990 return getSema().CreateOverloadedBinOp(OpLoc, Opcode, UnqualLookups, LHS,
2991 RHS, /*RequiresADL*/false);
2992 }
2993
2994 /// Build a new conditional operator expression.
2995 ///
2996 /// By default, performs semantic analysis to build the new expression.
2997 /// Subclasses may override this routine to provide different behavior.
2999 SourceLocation QuestionLoc,
3000 Expr *LHS,
3001 SourceLocation ColonLoc,
3002 Expr *RHS) {
3003 return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
3004 LHS, RHS);
3005 }
3006
3007 /// Build a new C-style cast expression.
3008 ///
3009 /// By default, performs semantic analysis to build the new expression.
3010 /// Subclasses may override this routine to provide different behavior.
3012 TypeSourceInfo *TInfo,
3013 SourceLocation RParenLoc,
3014 Expr *SubExpr) {
3015 return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
3016 SubExpr);
3017 }
3018
3019 /// Build a new compound literal expression.
3020 ///
3021 /// By default, performs semantic analysis to build the new expression.
3022 /// Subclasses may override this routine to provide different behavior.
3024 TypeSourceInfo *TInfo,
3025 SourceLocation RParenLoc,
3026 Expr *Init) {
3027 return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
3028 Init);
3029 }
3030
3031 /// Build a new extended vector element access expression.
3032 ///
3033 /// By default, performs semantic analysis to build the new expression.
3034 /// Subclasses may override this routine to provide different behavior.
3036 bool IsArrow,
3037 SourceLocation AccessorLoc,
3038 IdentifierInfo &Accessor) {
3039
3040 CXXScopeSpec SS;
3041 DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
3043 Base, Base->getType(), OpLoc, IsArrow, SS, SourceLocation(),
3044 /*FirstQualifierInScope*/ nullptr, NameInfo,
3045 /* TemplateArgs */ nullptr,
3046 /*S*/ nullptr);
3047 }
3048
3049 /// Build a new initializer list expression.
3050 ///
3051 /// By default, performs semantic analysis to build the new expression.
3052 /// Subclasses may override this routine to provide different behavior.
3054 MultiExprArg Inits,
3055 SourceLocation RBraceLoc) {
3056 return SemaRef.BuildInitList(LBraceLoc, Inits, RBraceLoc);
3057 }
3058
3059 /// Build a new designated initializer expression.
3060 ///
3061 /// By default, performs semantic analysis to build the new expression.
3062 /// Subclasses may override this routine to provide different behavior.
3064 MultiExprArg ArrayExprs,
3065 SourceLocation EqualOrColonLoc,
3066 bool GNUSyntax,
3067 Expr *Init) {
3069 = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
3070 Init);
3071 if (Result.isInvalid())
3072 return ExprError();
3073
3074 return Result;
3075 }
3076
3077 /// Build a new value-initialized expression.
3078 ///
3079 /// By default, builds the implicit value initialization without performing
3080 /// any semantic analysis. Subclasses may override this routine to provide
3081 /// different behavior.
3083 return new (SemaRef.Context) ImplicitValueInitExpr(T);
3084 }
3085
3086 /// Build a new \c va_arg expression.
3087 ///
3088 /// By default, performs semantic analysis to build the new expression.
3089 /// Subclasses may override this routine to provide different behavior.
3091 Expr *SubExpr, TypeSourceInfo *TInfo,
3092 SourceLocation RParenLoc) {
3093 return getSema().BuildVAArgExpr(BuiltinLoc,
3094 SubExpr, TInfo,
3095 RParenLoc);
3096 }
3097
3098 /// Build a new expression list in parentheses.
3099 ///
3100 /// By default, performs semantic analysis to build the new expression.
3101 /// Subclasses may override this routine to provide different behavior.
3103 MultiExprArg SubExprs,
3104 SourceLocation RParenLoc) {
3105 return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
3106 }
3107
3108 /// Build a new address-of-label expression.
3109 ///
3110 /// By default, performs semantic analysis, using the name of the label
3111 /// rather than attempting to map the label statement itself.
3112 /// Subclasses may override this routine to provide different behavior.
3114 SourceLocation LabelLoc, LabelDecl *Label) {
3115 return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
3116 }
3117
3118 /// Build a new GNU statement expression.
3119 ///
3120 /// By default, performs semantic analysis to build the new expression.
3121 /// Subclasses may override this routine to provide different behavior.
3123 SourceLocation RParenLoc, unsigned TemplateDepth) {
3124 return getSema().BuildStmtExpr(LParenLoc, SubStmt, RParenLoc,
3125 TemplateDepth);
3126 }
3127
3128 /// Build a new __builtin_choose_expr expression.
3129 ///
3130 /// By default, performs semantic analysis to build the new expression.
3131 /// Subclasses may override this routine to provide different behavior.
3133 Expr *Cond, Expr *LHS, Expr *RHS,
3134 SourceLocation RParenLoc) {
3135 return SemaRef.ActOnChooseExpr(BuiltinLoc,
3136 Cond, LHS, RHS,
3137 RParenLoc);
3138 }
3139
3140 /// Build a new generic selection expression with an expression predicate.
3141 ///
3142 /// By default, performs semantic analysis to build the new expression.
3143 /// Subclasses may override this routine to provide different behavior.
3145 SourceLocation DefaultLoc,
3146 SourceLocation RParenLoc,
3147 Expr *ControllingExpr,
3149 ArrayRef<Expr *> Exprs) {
3150 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3151 /*PredicateIsExpr=*/true,
3152 ControllingExpr, Types, Exprs);
3153 }
3154
3155 /// Build a new generic selection expression with a type predicate.
3156 ///
3157 /// By default, performs semantic analysis to build the new expression.
3158 /// Subclasses may override this routine to provide different behavior.
3160 SourceLocation DefaultLoc,
3161 SourceLocation RParenLoc,
3162 TypeSourceInfo *ControllingType,
3164 ArrayRef<Expr *> Exprs) {
3165 return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
3166 /*PredicateIsExpr=*/false,
3167 ControllingType, Types, Exprs);
3168 }
3169
3170 /// Build a new overloaded operator call expression.
3171 ///
3172 /// By default, performs semantic analysis to build the new expression.
3173 /// The semantic analysis provides the behavior of template instantiation,
3174 /// copying with transformations that turn what looks like an overloaded
3175 /// operator call into a use of a builtin operator, performing
3176 /// argument-dependent lookup, etc. Subclasses may override this routine to
3177 /// provide different behavior.
3179 SourceLocation OpLoc,
3180 SourceLocation CalleeLoc,
3181 bool RequiresADL,
3182 const UnresolvedSetImpl &Functions,
3183 Expr *First, Expr *Second);
3184
3185 /// Build a new C++ "named" cast expression, such as static_cast or
3186 /// reinterpret_cast.
3187 ///
3188 /// By default, this routine dispatches to one of the more-specific routines
3189 /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
3190 /// Subclasses may override this routine to provide different behavior.
3193 SourceLocation LAngleLoc,
3194 TypeSourceInfo *TInfo,
3195 SourceLocation RAngleLoc,
3196 SourceLocation LParenLoc,
3197 Expr *SubExpr,
3198 SourceLocation RParenLoc) {
3199 switch (Class) {
3200 case Stmt::CXXStaticCastExprClass:
3201 return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
3202 RAngleLoc, LParenLoc,
3203 SubExpr, RParenLoc);
3204
3205 case Stmt::CXXDynamicCastExprClass:
3206 return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
3207 RAngleLoc, LParenLoc,
3208 SubExpr, RParenLoc);
3209
3210 case Stmt::CXXReinterpretCastExprClass:
3211 return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
3212 RAngleLoc, LParenLoc,
3213 SubExpr,
3214 RParenLoc);
3215
3216 case Stmt::CXXConstCastExprClass:
3217 return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
3218 RAngleLoc, LParenLoc,
3219 SubExpr, RParenLoc);
3220
3221 case Stmt::CXXAddrspaceCastExprClass:
3222 return getDerived().RebuildCXXAddrspaceCastExpr(
3223 OpLoc, LAngleLoc, TInfo, RAngleLoc, LParenLoc, SubExpr, RParenLoc);
3224
3225 default:
3226 llvm_unreachable("Invalid C++ named cast");
3227 }
3228 }
3229
3230 /// Build a new C++ static_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_static_cast,
3242 TInfo, SubExpr,
3243 SourceRange(LAngleLoc, RAngleLoc),
3244 SourceRange(LParenLoc, RParenLoc));
3245 }
3246
3247 /// Build a new C++ dynamic_cast expression.
3248 ///
3249 /// By default, performs semantic analysis to build the new expression.
3250 /// Subclasses may override this routine to provide different behavior.
3252 SourceLocation LAngleLoc,
3253 TypeSourceInfo *TInfo,
3254 SourceLocation RAngleLoc,
3255 SourceLocation LParenLoc,
3256 Expr *SubExpr,
3257 SourceLocation RParenLoc) {
3258 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
3259 TInfo, SubExpr,
3260 SourceRange(LAngleLoc, RAngleLoc),
3261 SourceRange(LParenLoc, RParenLoc));
3262 }
3263
3264 /// Build a new C++ reinterpret_cast expression.
3265 ///
3266 /// By default, performs semantic analysis to build the new expression.
3267 /// Subclasses may override this routine to provide different behavior.
3269 SourceLocation LAngleLoc,
3270 TypeSourceInfo *TInfo,
3271 SourceLocation RAngleLoc,
3272 SourceLocation LParenLoc,
3273 Expr *SubExpr,
3274 SourceLocation RParenLoc) {
3275 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
3276 TInfo, SubExpr,
3277 SourceRange(LAngleLoc, RAngleLoc),
3278 SourceRange(LParenLoc, RParenLoc));
3279 }
3280
3281 /// Build a new C++ const_cast expression.
3282 ///
3283 /// By default, performs semantic analysis to build the new expression.
3284 /// Subclasses may override this routine to provide different behavior.
3286 SourceLocation LAngleLoc,
3287 TypeSourceInfo *TInfo,
3288 SourceLocation RAngleLoc,
3289 SourceLocation LParenLoc,
3290 Expr *SubExpr,
3291 SourceLocation RParenLoc) {
3292 return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
3293 TInfo, SubExpr,
3294 SourceRange(LAngleLoc, RAngleLoc),
3295 SourceRange(LParenLoc, RParenLoc));
3296 }
3297
3300 TypeSourceInfo *TInfo, SourceLocation RAngleLoc,
3301 SourceLocation LParenLoc, Expr *SubExpr,
3302 SourceLocation RParenLoc) {
3303 return getSema().BuildCXXNamedCast(
3304 OpLoc, tok::kw_addrspace_cast, TInfo, SubExpr,
3305 SourceRange(LAngleLoc, RAngleLoc), SourceRange(LParenLoc, RParenLoc));
3306 }
3307
3308 /// Build a new C++ functional-style cast expression.
3309 ///
3310 /// By default, performs semantic analysis to build the new expression.
3311 /// Subclasses may override this routine to provide different behavior.
3313 SourceLocation LParenLoc,
3314 Expr *Sub,
3315 SourceLocation RParenLoc,
3316 bool ListInitialization) {
3317 // If Sub is a ParenListExpr, then Sub is the syntatic form of a
3318 // CXXParenListInitExpr. Pass its expanded arguments so that the
3319 // CXXParenListInitExpr can be rebuilt.
3320 if (auto *PLE = dyn_cast<ParenListExpr>(Sub))
3322 TInfo, LParenLoc, MultiExprArg(PLE->getExprs(), PLE->getNumExprs()),
3323 RParenLoc, ListInitialization);
3324 return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
3325 MultiExprArg(&Sub, 1), RParenLoc,
3326 ListInitialization);
3327 }
3328
3329 /// Build a new C++ __builtin_bit_cast expression.
3330 ///
3331 /// By default, performs semantic analysis to build the new expression.
3332 /// Subclasses may override this routine to provide different behavior.
3334 TypeSourceInfo *TSI, Expr *Sub,
3335 SourceLocation RParenLoc) {
3336 return getSema().BuildBuiltinBitCastExpr(KWLoc, TSI, Sub, RParenLoc);
3337 }
3338
3339 /// Build a new C++ typeid(type) expression.
3340 ///
3341 /// By default, performs semantic analysis to build the new expression.
3342 /// Subclasses may override this routine to provide different behavior.
3344 SourceLocation TypeidLoc,
3345 TypeSourceInfo *Operand,
3346 SourceLocation RParenLoc) {
3347 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3348 RParenLoc);
3349 }
3350
3351
3352 /// Build a new C++ typeid(expr) expression.
3353 ///
3354 /// By default, performs semantic analysis to build the new expression.
3355 /// Subclasses may override this routine to provide different behavior.
3357 SourceLocation TypeidLoc,
3358 Expr *Operand,
3359 SourceLocation RParenLoc) {
3360 return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
3361 RParenLoc);
3362 }
3363
3364 /// Build a new C++ __uuidof(type) expression.
3365 ///
3366 /// By default, performs semantic analysis to build the new expression.
3367 /// Subclasses may override this routine to provide different behavior.
3369 TypeSourceInfo *Operand,
3370 SourceLocation RParenLoc) {
3371 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3372 }
3373
3374 /// Build a new C++ __uuidof(expr) expression.
3375 ///
3376 /// By default, performs semantic analysis to build the new expression.
3377 /// Subclasses may override this routine to provide different behavior.
3379 Expr *Operand, SourceLocation RParenLoc) {
3380 return getSema().BuildCXXUuidof(Type, TypeidLoc, Operand, RParenLoc);
3381 }
3382
3383 /// Build a new C++ "this" expression.
3384 ///
3385 /// By default, performs semantic analysis to build a new "this" expression.
3386 /// Subclasses may override this routine to provide different behavior.
3388 QualType ThisType,
3389 bool isImplicit) {
3390 if (getSema().CheckCXXThisType(ThisLoc, ThisType))
3391 return ExprError();
3392 return getSema().BuildCXXThisExpr(ThisLoc, ThisType, isImplicit);
3393 }
3394
3395 /// Build a new C++ throw expression.
3396 ///
3397 /// By default, performs semantic analysis to build the new expression.
3398 /// Subclasses may override this routine to provide different behavior.
3400 bool IsThrownVariableInScope) {
3401 return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
3402 }
3403
3404 /// Build a new C++ default-argument expression.
3405 ///
3406 /// By default, builds a new default-argument expression, which does not
3407 /// require any semantic analysis. Subclasses may override this routine to
3408 /// provide different behavior.
3410 Expr *RewrittenExpr) {
3411 return CXXDefaultArgExpr::Create(getSema().Context, Loc, Param,
3412 RewrittenExpr, getSema().CurContext);
3413 }
3414
3415 /// Build a new C++11 default-initialization expression.
3416 ///
3417 /// By default, builds a new default field initialization expression, which
3418 /// does not require any semantic analysis. Subclasses may override this
3419 /// routine to provide different behavior.
3421 FieldDecl *Field) {
3422 return getSema().BuildCXXDefaultInitExpr(Loc, Field);
3423 }
3424
3425 /// Build a new C++ zero-initialization expression.
3426 ///
3427 /// By default, performs semantic analysis to build the new expression.
3428 /// Subclasses may override this routine to provide different behavior.
3430 SourceLocation LParenLoc,
3431 SourceLocation RParenLoc) {
3432 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, {}, RParenLoc,
3433 /*ListInitialization=*/false);
3434 }
3435
3436 /// Build a new C++ "new" expression.
3437 ///
3438 /// By default, performs semantic analysis to build the new expression.
3439 /// Subclasses may override this routine to provide different behavior.
3441 SourceLocation PlacementLParen,
3442 MultiExprArg PlacementArgs,
3443 SourceLocation PlacementRParen,
3444 SourceRange TypeIdParens, QualType AllocatedType,
3445 TypeSourceInfo *AllocatedTypeInfo,
3446 std::optional<Expr *> ArraySize,
3447 SourceRange DirectInitRange, Expr *Initializer) {
3448 return getSema().BuildCXXNew(StartLoc, UseGlobal,
3449 PlacementLParen,
3450 PlacementArgs,
3451 PlacementRParen,
3452 TypeIdParens,
3453 AllocatedType,
3454 AllocatedTypeInfo,
3455 ArraySize,
3456 DirectInitRange,
3457 Initializer);
3458 }
3459
3460 /// Build a new C++ "delete" expression.
3461 ///
3462 /// By default, performs semantic analysis to build the new expression.
3463 /// Subclasses may override this routine to provide different behavior.
3465 bool IsGlobalDelete,
3466 bool IsArrayForm,
3467 Expr *Operand) {
3468 return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
3469 Operand);
3470 }
3471
3472 /// Build a new type trait expression.
3473 ///
3474 /// By default, performs semantic analysis to build the new expression.
3475 /// Subclasses may override this routine to provide different behavior.
3477 SourceLocation StartLoc,
3479 SourceLocation RParenLoc) {
3480 return getSema().BuildTypeTrait(Trait, StartLoc, Args, RParenLoc);
3481 }
3482
3483 /// Build a new array type trait expression.
3484 ///
3485 /// By default, performs semantic analysis to build the new expression.
3486 /// Subclasses may override this routine to provide different behavior.
3488 SourceLocation StartLoc,
3489 TypeSourceInfo *TSInfo,
3490 Expr *DimExpr,
3491 SourceLocation RParenLoc) {
3492 return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
3493 }
3494
3495 /// Build a new expression trait expression.
3496 ///
3497 /// By default, performs semantic analysis to build the new expression.
3498 /// Subclasses may override this routine to provide different behavior.
3500 SourceLocation StartLoc,
3501 Expr *Queried,
3502 SourceLocation RParenLoc) {
3503 return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
3504 }
3505
3506 /// Build a new (previously unresolved) declaration reference
3507 /// expression.
3508 ///
3509 /// By default, performs semantic analysis to build the new expression.
3510 /// Subclasses may override this routine to provide different behavior.
3512 NestedNameSpecifierLoc QualifierLoc,
3513 SourceLocation TemplateKWLoc,
3514 const DeclarationNameInfo &NameInfo,
3515 const TemplateArgumentListInfo *TemplateArgs,
3516 bool IsAddressOfOperand,
3517 TypeSourceInfo **RecoveryTSI) {
3518 CXXScopeSpec SS;
3519 SS.Adopt(QualifierLoc);
3520
3521 if (TemplateArgs || TemplateKWLoc.isValid())
3523 SS, TemplateKWLoc, NameInfo, TemplateArgs, IsAddressOfOperand);
3524
3526 SS, NameInfo, IsAddressOfOperand, RecoveryTSI);
3527 }
3528
3529 /// Build a new template-id expression.
3530 ///
3531 /// By default, performs semantic analysis to build the new expression.
3532 /// Subclasses may override this routine to provide different behavior.
3534 SourceLocation TemplateKWLoc,
3535 LookupResult &R,
3536 bool RequiresADL,
3537 const TemplateArgumentListInfo *TemplateArgs) {
3538 return getSema().BuildTemplateIdExpr(SS, TemplateKWLoc, R, RequiresADL,
3539 TemplateArgs);
3540 }
3541
3542 /// Build a new object-construction expression.
3543 ///
3544 /// By default, performs semantic analysis to build the new expression.
3545 /// Subclasses may override this routine to provide different behavior.
3548 bool IsElidable, MultiExprArg Args, bool HadMultipleCandidates,
3549 bool ListInitialization, bool StdInitListInitialization,
3550 bool RequiresZeroInit, CXXConstructionKind ConstructKind,
3551 SourceRange ParenRange) {
3552 // Reconstruct the constructor we originally found, which might be
3553 // different if this is a call to an inherited constructor.
3554 CXXConstructorDecl *FoundCtor = Constructor;
3555 if (Constructor->isInheritingConstructor())
3556 FoundCtor = Constructor->getInheritedConstructor().getConstructor();
3557
3558 SmallVector<Expr *, 8> ConvertedArgs;
3559 if (getSema().CompleteConstructorCall(FoundCtor, T, Args, Loc,
3560 ConvertedArgs))
3561 return ExprError();
3562
3563 return getSema().BuildCXXConstructExpr(Loc, T, Constructor,
3564 IsElidable,
3565 ConvertedArgs,
3566 HadMultipleCandidates,
3567 ListInitialization,
3568 StdInitListInitialization,
3569 RequiresZeroInit, ConstructKind,
3570 ParenRange);
3571 }
3572
3573 /// Build a new implicit construction via inherited constructor
3574 /// expression.
3576 CXXConstructorDecl *Constructor,
3577 bool ConstructsVBase,
3578 bool InheritedFromVBase) {
3580 Loc, T, Constructor, ConstructsVBase, InheritedFromVBase);
3581 }
3582
3583 /// Build a new object-construction 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 LParenOrBraceLoc,
3589 MultiExprArg Args,
3590 SourceLocation RParenOrBraceLoc,
3591 bool ListInitialization) {
3593 TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
3594 }
3595
3596 /// Build a new object-construction expression.
3597 ///
3598 /// By default, performs semantic analysis to build the new expression.
3599 /// Subclasses may override this routine to provide different behavior.
3601 SourceLocation LParenLoc,
3602 MultiExprArg Args,
3603 SourceLocation RParenLoc,
3604 bool ListInitialization) {
3605 return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
3606 RParenLoc, ListInitialization);
3607 }
3608
3609 /// Build a new member reference expression.
3610 ///
3611 /// By default, performs semantic analysis to build the new expression.
3612 /// Subclasses may override this routine to provide different behavior.
3614 QualType BaseType,
3615 bool IsArrow,
3616 SourceLocation OperatorLoc,
3617 NestedNameSpecifierLoc QualifierLoc,
3618 SourceLocation TemplateKWLoc,
3619 NamedDecl *FirstQualifierInScope,
3620 const DeclarationNameInfo &MemberNameInfo,
3621 const TemplateArgumentListInfo *TemplateArgs) {
3622 CXXScopeSpec SS;
3623 SS.Adopt(QualifierLoc);
3624
3625 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3626 OperatorLoc, IsArrow,
3627 SS, TemplateKWLoc,
3628 FirstQualifierInScope,
3629 MemberNameInfo,
3630 TemplateArgs, /*S*/nullptr);
3631 }
3632
3633 /// Build a new member reference expression.
3634 ///
3635 /// By default, performs semantic analysis to build the new expression.
3636 /// Subclasses may override this routine to provide different behavior.
3638 SourceLocation OperatorLoc,
3639 bool IsArrow,
3640 NestedNameSpecifierLoc QualifierLoc,
3641 SourceLocation TemplateKWLoc,
3642 NamedDecl *FirstQualifierInScope,
3643 LookupResult &R,
3644 const TemplateArgumentListInfo *TemplateArgs) {
3645 CXXScopeSpec SS;
3646 SS.Adopt(QualifierLoc);
3647
3648 return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
3649 OperatorLoc, IsArrow,
3650 SS, TemplateKWLoc,
3651 FirstQualifierInScope,
3652 R, TemplateArgs, /*S*/nullptr);
3653 }
3654
3655 /// Build a new noexcept expression.
3656 ///
3657 /// By default, performs semantic analysis to build the new expression.
3658 /// Subclasses may override this routine to provide different behavior.
3660 return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
3661 }
3662
3663 /// Build a new expression to compute the length of a parameter pack.
3665 SourceLocation PackLoc,
3666 SourceLocation RParenLoc,
3667 std::optional<unsigned> Length,
3668 ArrayRef<TemplateArgument> PartialArgs) {
3669 return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
3670 RParenLoc, Length, PartialArgs);
3671 }
3672
3674 SourceLocation RSquareLoc,
3675 Expr *PackIdExpression, Expr *IndexExpr,
3676 ArrayRef<Expr *> ExpandedExprs,
3677 bool FullySubstituted = false) {
3678 return getSema().BuildPackIndexingExpr(PackIdExpression, EllipsisLoc,
3679 IndexExpr, RSquareLoc, ExpandedExprs,
3680 FullySubstituted);
3681 }
3682
3684 QualType T,
3685 ArrayRef<Expr *> Exprs) {
3687 Exprs);
3688 }
3689
3690 /// Build a new expression representing a call to a source location
3691 /// builtin.
3692 ///
3693 /// By default, performs semantic analysis to build the new expression.
3694 /// Subclasses may override this routine to provide different behavior.
3696 SourceLocation BuiltinLoc,
3697 SourceLocation RPLoc,
3698 DeclContext *ParentContext) {
3699 return getSema().BuildSourceLocExpr(Kind, ResultTy, BuiltinLoc, RPLoc,
3700 ParentContext);
3701 }
3702
3703 /// Build a new Objective-C boxed expression.
3704 ///
3705 /// By default, performs semantic analysis to build the new expression.
3706 /// Subclasses may override this routine to provide different behavior.
3708 SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo,
3709 NamedDecl *FoundDecl, ConceptDecl *NamedConcept,
3711 CXXScopeSpec SS;
3712 SS.Adopt(NNS);
3713 ExprResult Result = getSema().CheckConceptTemplateId(SS, TemplateKWLoc,
3714 ConceptNameInfo,
3715 FoundDecl,
3716 NamedConcept, TALI);
3717 if (Result.isInvalid())
3718 return ExprError();
3719 return Result;
3720 }
3721
3722 /// \brief Build a new requires expression.
3723 ///
3724 /// By default, performs semantic analysis to build the new expression.
3725 /// Subclasses may override this routine to provide different behavior.
3728 SourceLocation LParenLoc,
3729 ArrayRef<ParmVarDecl *> LocalParameters,
3730 SourceLocation RParenLoc,
3732 SourceLocation ClosingBraceLoc) {
3733 return RequiresExpr::Create(SemaRef.Context, RequiresKWLoc, Body, LParenLoc,
3734 LocalParameters, RParenLoc, Requirements,
3735 ClosingBraceLoc);
3736 }
3737
3741 return SemaRef.BuildTypeRequirement(SubstDiag);
3742 }
3743
3746 }
3747
3750 concepts::Requirement::SubstitutionDiagnostic *SubstDiag, bool IsSimple,
3751 SourceLocation NoexceptLoc,
3753 return SemaRef.BuildExprRequirement(SubstDiag, IsSimple, NoexceptLoc,
3754 std::move(Ret));
3755 }
3756
3758 RebuildExprRequirement(Expr *E, bool IsSimple, SourceLocation NoexceptLoc,
3760 return SemaRef.BuildExprRequirement(E, IsSimple, NoexceptLoc,
3761 std::move(Ret));
3762 }
3763
3765 RebuildNestedRequirement(StringRef InvalidConstraintEntity,
3766 const ASTConstraintSatisfaction &Satisfaction) {
3767 return SemaRef.BuildNestedRequirement(InvalidConstraintEntity,
3768 Satisfaction);
3769 }
3770
3772 return SemaRef.BuildNestedRequirement(Constraint);
3773 }
3774
3775 /// \brief Build a new Objective-C boxed expression.
3776 ///
3777 /// By default, performs semantic analysis to build the new expression.
3778 /// Subclasses may override this routine to provide different behavior.
3780 return getSema().ObjC().BuildObjCBoxedExpr(SR, ValueExpr);
3781 }
3782
3783 /// Build a new Objective-C array literal.
3784 ///
3785 /// By default, performs semantic analysis to build the new expression.
3786 /// Subclasses may override this routine to provide different behavior.
3788 Expr **Elements, unsigned NumElements) {
3790 Range, MultiExprArg(Elements, NumElements));
3791 }
3792
3794 Expr *Base, Expr *Key,
3795 ObjCMethodDecl *getterMethod,
3796 ObjCMethodDecl *setterMethod) {
3798 RB, Base, Key, getterMethod, setterMethod);
3799 }
3800
3801 /// Build a new Objective-C dictionary literal.
3802 ///
3803 /// By default, performs semantic analysis to build the new expression.
3804 /// Subclasses may override this routine to provide different behavior.
3807 return getSema().ObjC().BuildObjCDictionaryLiteral(Range, Elements);
3808 }
3809
3810 /// Build a new Objective-C \@encode expression.
3811 ///
3812 /// By default, performs semantic analysis to build the new expression.
3813 /// Subclasses may override this routine to provide different behavior.
3815 TypeSourceInfo *EncodeTypeInfo,
3816 SourceLocation RParenLoc) {
3817 return SemaRef.ObjC().BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
3818 RParenLoc);
3819 }
3820
3821 /// Build a new Objective-C class message.
3823 Selector Sel,
3824 ArrayRef<SourceLocation> SelectorLocs,
3825 ObjCMethodDecl *Method,
3826 SourceLocation LBracLoc,
3827 MultiExprArg Args,
3828 SourceLocation RBracLoc) {
3830 ReceiverTypeInfo, ReceiverTypeInfo->getType(),
3831 /*SuperLoc=*/SourceLocation(), Sel, Method, LBracLoc, SelectorLocs,
3832 RBracLoc, Args);
3833 }
3834
3835 /// Build a new Objective-C instance message.
3837 Selector Sel,
3838 ArrayRef<SourceLocation> SelectorLocs,
3839 ObjCMethodDecl *Method,
3840 SourceLocation LBracLoc,
3841 MultiExprArg Args,
3842 SourceLocation RBracLoc) {
3843 return SemaRef.ObjC().BuildInstanceMessage(Receiver, Receiver->getType(),
3844 /*SuperLoc=*/SourceLocation(),
3845 Sel, Method, LBracLoc,
3846 SelectorLocs, RBracLoc, Args);
3847 }
3848
3849 /// Build a new Objective-C instance/class message to 'super'.
3851 Selector Sel,
3852 ArrayRef<SourceLocation> SelectorLocs,
3853 QualType SuperType,
3854 ObjCMethodDecl *Method,
3855 SourceLocation LBracLoc,
3856 MultiExprArg Args,
3857 SourceLocation RBracLoc) {
3858 return Method->isInstanceMethod()
3860 nullptr, SuperType, SuperLoc, Sel, Method, LBracLoc,
3861 SelectorLocs, RBracLoc, Args)
3862 : SemaRef.ObjC().BuildClassMessage(nullptr, SuperType, SuperLoc,
3863 Sel, Method, LBracLoc,
3864 SelectorLocs, RBracLoc, Args);
3865 }
3866
3867 /// Build a new Objective-C ivar reference expression.
3868 ///
3869 /// By default, performs semantic analysis to build the new expression.
3870 /// Subclasses may override this routine to provide different behavior.
3872 SourceLocation IvarLoc,
3873 bool IsArrow, bool IsFreeIvar) {
3874 CXXScopeSpec SS;
3875 DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3877 BaseArg, BaseArg->getType(),
3878 /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3879 /*FirstQualifierInScope=*/nullptr, NameInfo,
3880 /*TemplateArgs=*/nullptr,
3881 /*S=*/nullptr);
3882 if (IsFreeIvar && Result.isUsable())
3883 cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3884 return Result;
3885 }
3886
3887 /// Build a new Objective-C property reference expression.
3888 ///
3889 /// By default, performs semantic analysis to build the new expression.
3890 /// Subclasses may override this routine to provide different behavior.
3893 SourceLocation PropertyLoc) {
3894 CXXScopeSpec SS;
3895 DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3896 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3897 /*FIXME:*/PropertyLoc,
3898 /*IsArrow=*/false,
3899 SS, SourceLocation(),
3900 /*FirstQualifierInScope=*/nullptr,
3901 NameInfo,
3902 /*TemplateArgs=*/nullptr,
3903 /*S=*/nullptr);
3904 }
3905
3906 /// Build a new Objective-C property reference expression.
3907 ///
3908 /// By default, performs semantic analysis to build the new expression.
3909 /// Subclasses may override this routine to provide different behavior.
3911 ObjCMethodDecl *Getter,
3912 ObjCMethodDecl *Setter,
3913 SourceLocation PropertyLoc) {
3914 // Since these expressions can only be value-dependent, we do not
3915 // need to perform semantic analysis again.
3916 return Owned(
3917 new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3919 PropertyLoc, Base));
3920 }
3921
3922 /// Build a new Objective-C "isa" expression.
3923 ///
3924 /// By default, performs semantic analysis to build the new expression.
3925 /// Subclasses may override this routine to provide different behavior.
3927 SourceLocation OpLoc, bool IsArrow) {
3928 CXXScopeSpec SS;
3929 DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3930 return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3931 OpLoc, IsArrow,
3932 SS, SourceLocation(),
3933 /*FirstQualifierInScope=*/nullptr,
3934 NameInfo,
3935 /*TemplateArgs=*/nullptr,
3936 /*S=*/nullptr);
3937 }
3938
3939 /// Build a new shuffle vector expression.
3940 ///
3941 /// By default, performs semantic analysis to build the new expression.
3942 /// Subclasses may override this routine to provide different behavior.
3944 MultiExprArg SubExprs,
3945 SourceLocation RParenLoc) {
3946 // Find the declaration for __builtin_shufflevector
3947 const IdentifierInfo &Name
3948 = SemaRef.Context.Idents.get("__builtin_shufflevector");
3950 DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
3951 assert(!Lookup.empty() && "No __builtin_shufflevector?");
3952
3953 // Build a reference to the __builtin_shufflevector builtin
3954 FunctionDecl *Builtin = cast<FunctionDecl>(Lookup.front());
3955 Expr *Callee = new (SemaRef.Context)
3956 DeclRefExpr(SemaRef.Context, Builtin, false,
3957 SemaRef.Context.BuiltinFnTy, VK_PRValue, BuiltinLoc);
3958 QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
3959 Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
3960 CK_BuiltinFnToFnPtr).get();
3961
3962 // Build the CallExpr
3963 ExprResult TheCall = CallExpr::Create(
3964 SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
3965 Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc,
3967
3968 // Type-check the __builtin_shufflevector expression.
3969 return SemaRef.BuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
3970 }
3971
3972 /// Build a new convert vector expression.
3974 Expr *SrcExpr, TypeSourceInfo *DstTInfo,
3975 SourceLocation RParenLoc) {
3976 return SemaRef.ConvertVectorExpr(SrcExpr, DstTInfo, BuiltinLoc, RParenLoc);
3977 }
3978
3979 /// Build a new template argument pack expansion.
3980 ///
3981 /// By default, performs semantic analysis to build a new pack expansion
3982 /// for a template argument. Subclasses may override this routine to provide
3983 /// different behavior.
3986 std::optional<unsigned> NumExpansions) {
3987 switch (Pattern.getArgument().getKind()) {
3991 EllipsisLoc, NumExpansions);
3992 if (Result.isInvalid())
3993 return TemplateArgumentLoc();
3994
3995 return TemplateArgumentLoc(Result.get(), Result.get());
3996 }
3997
3999 return TemplateArgumentLoc(
4002 NumExpansions),
4003 Pattern.getTemplateQualifierLoc(), Pattern.getTemplateNameLoc(),
4004 EllipsisLoc);
4005
4013 llvm_unreachable("Pack expansion pattern has no parameter packs");
4014
4016 if (TypeSourceInfo *Expansion
4017 = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
4018 EllipsisLoc,
4019 NumExpansions))
4020 return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
4021 Expansion);
4022 break;
4023 }
4024
4025 return TemplateArgumentLoc();
4026 }
4027
4028 /// Build a new expression pack expansion.
4029 ///
4030 /// By default, performs semantic analysis to build a new pack expansion
4031 /// for an expression. Subclasses may override this routine to provide
4032 /// different behavior.
4034 std::optional<unsigned> NumExpansions) {
4035 return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
4036 }
4037
4038 /// Build a new C++1z fold-expression.
4039 ///
4040 /// By default, performs semantic analysis in order to build a new fold
4041 /// expression.
4043 SourceLocation LParenLoc, Expr *LHS,
4044 BinaryOperatorKind Operator,
4045 SourceLocation EllipsisLoc, Expr *RHS,
4046 SourceLocation RParenLoc,
4047 std::optional<unsigned> NumExpansions) {
4048 return getSema().BuildCXXFoldExpr(ULE, LParenLoc, LHS, Operator,
4049 EllipsisLoc, RHS, RParenLoc,
4050 NumExpansions);
4051 }
4052
4054 LambdaScopeInfo *LSI) {
4055 for (ParmVarDecl *PVD : LSI->CallOperator->parameters()) {
4056 if (Expr *Init = PVD->getInit())
4058 Init->containsUnexpandedParameterPack();
4059 else if (PVD->hasUninstantiatedDefaultArg())
4061 PVD->getUninstantiatedDefaultArg()
4062 ->containsUnexpandedParameterPack();
4063 }
4064 return getSema().BuildLambdaExpr(StartLoc, EndLoc, LSI);
4065 }
4066
4067 /// Build an empty C++1z fold-expression with the given operator.
4068 ///
4069 /// By default, produces the fallback value for the fold-expression, or
4070 /// produce an error if there is no fallback value.
4072 BinaryOperatorKind Operator) {
4073 return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
4074 }
4075
4076 /// Build a new atomic operation expression.
4077 ///
4078 /// By default, performs semantic analysis to build the new expression.
4079 /// Subclasses may override this routine to provide different behavior.
4082 SourceLocation RParenLoc) {
4083 // Use this for all of the locations, since we don't know the difference
4084 // between the call and the expr at this point.
4085 SourceRange Range{BuiltinLoc, RParenLoc};
4086 return getSema().BuildAtomicExpr(Range, Range, RParenLoc, SubExprs, Op,
4088 }
4089
4091 ArrayRef<Expr *> SubExprs, QualType Type) {
4092 return getSema().CreateRecoveryExpr(BeginLoc, EndLoc, SubExprs, Type);
4093 }
4094
4096 SourceLocation BeginLoc,
4097 SourceLocation DirLoc,
4098 SourceLocation EndLoc,
4100 StmtResult StrBlock) {
4102 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4103 SourceLocation{}, EndLoc, Clauses, StrBlock);
4104 }
4105
4107 SourceLocation DirLoc,
4108 SourceLocation EndLoc,
4110 StmtResult Loop) {
4112 OpenACCDirectiveKind::Loop, BeginLoc, DirLoc, SourceLocation{},
4113 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, Loop);
4114 }
4115
4117 SourceLocation BeginLoc,
4118 SourceLocation DirLoc,
4119 SourceLocation EndLoc,
4121 StmtResult Loop) {
4123 K, BeginLoc, DirLoc, SourceLocation{}, SourceLocation{}, {},
4124 SourceLocation{}, EndLoc, Clauses, Loop);
4125 }
4126
4128 SourceLocation DirLoc,
4129 SourceLocation EndLoc,
4131 StmtResult StrBlock) {
4133 OpenACCDirectiveKind::Data, BeginLoc, DirLoc, SourceLocation{},
4134 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, StrBlock);
4135 }
4136
4139 SourceLocation DirLoc, SourceLocation EndLoc,
4140 ArrayRef<OpenACCClause *> Clauses) {
4143 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, {});
4144 }
4145
4148 SourceLocation DirLoc, SourceLocation EndLoc,
4149 ArrayRef<OpenACCClause *> Clauses) {
4152 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, {});
4153 }
4154
4156 SourceLocation DirLoc,
4157 SourceLocation EndLoc,
4159 StmtResult StrBlock) {
4162 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, StrBlock);
4163 }
4164
4166 SourceLocation DirLoc,
4167 SourceLocation EndLoc,
4168 ArrayRef<OpenACCClause *> Clauses) {
4170 OpenACCDirectiveKind::Init, BeginLoc, DirLoc, SourceLocation{},
4171 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, {});
4172 }
4173
4176 SourceLocation DirLoc, SourceLocation EndLoc,
4177 ArrayRef<OpenACCClause *> Clauses) {
4180 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, {});
4181 }
4182
4184 SourceLocation DirLoc,
4185 SourceLocation EndLoc,
4186 ArrayRef<OpenACCClause *> Clauses) {
4188 OpenACCDirectiveKind::Set, BeginLoc, DirLoc, SourceLocation{},
4189 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, {});
4190 }
4191
4193 SourceLocation DirLoc,
4194 SourceLocation EndLoc,
4195 ArrayRef<OpenACCClause *> Clauses) {
4197 OpenACCDirectiveKind::Update, BeginLoc, DirLoc, SourceLocation{},
4198 SourceLocation{}, {}, SourceLocation{}, EndLoc, Clauses, {});
4199 }
4200
4202 SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc,
4203 Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
4204 SourceLocation RParenLoc, SourceLocation EndLoc,
4205 ArrayRef<OpenACCClause *> Clauses) {
4207 Exprs.push_back(DevNumExpr);
4208 Exprs.insert(Exprs.end(), QueueIdExprs.begin(), QueueIdExprs.end());
4210 OpenACCDirectiveKind::Wait, BeginLoc, DirLoc, LParenLoc, QueuesLoc,
4211 Exprs, RParenLoc, EndLoc, Clauses, {});
4212 }
4213
4215 SourceLocation DirLoc,
4216 OpenACCAtomicKind AtKind,
4217 SourceLocation EndLoc,
4218 StmtResult AssociatedStmt) {
4220 OpenACCDirectiveKind::Atomic, BeginLoc, DirLoc, SourceLocation{},
4221 SourceLocation{}, {}, AtKind, SourceLocation{}, EndLoc, {},
4222 AssociatedStmt);
4223 }
4224
4226 return getSema().OpenACC().ActOnOpenACCAsteriskSizeExpr(AsteriskLoc);
4227 }
4228
4229private:
4230 TypeLoc TransformTypeInObjectScope(TypeLoc TL,
4231 QualType ObjectType,
4232 NamedDecl *FirstQualifierInScope,
4233 CXXScopeSpec &SS);
4234
4235 TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
4236 QualType ObjectType,
4237 NamedDecl *FirstQualifierInScope,
4238 CXXScopeSpec &SS);
4239
4240 TypeSourceInfo *TransformTSIInObjectScope(TypeLoc TL, QualType ObjectType,
4241 NamedDecl *FirstQualifierInScope,
4242 CXXScopeSpec &SS);
4243
4244 QualType TransformDependentNameType(TypeLocBuilder &TLB,
4246 bool DeducibleTSTContext);
4247
4249 TransformOpenACCClauseList(OpenACCDirectiveKind DirKind,
4251
4253 TransformOpenACCClause(ArrayRef<const OpenACCClause *> ExistingClauses,
4254 OpenACCDirectiveKind DirKind,
4255 const OpenACCClause *OldClause);
4256};
4257
4258template <typename Derived>
4260 if (!S)
4261 return S;
4262
4263 switch (S->getStmtClass()) {
4264 case Stmt::NoStmtClass: break;
4265
4266 // Transform individual statement nodes
4267 // Pass SDK into statements that can produce a value
4268#define STMT(Node, Parent) \
4269 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
4270#define VALUESTMT(Node, Parent) \
4271 case Stmt::Node##Class: \
4272 return getDerived().Transform##Node(cast<Node>(S), SDK);
4273#define ABSTRACT_STMT(Node)
4274#define EXPR(Node, Parent)
4275#include "clang/AST/StmtNodes.inc"
4276
4277 // Transform expressions by calling TransformExpr.
4278#define STMT(Node, Parent)
4279#define ABSTRACT_STMT(Stmt)
4280#define EXPR(Node, Parent) case Stmt::Node##Class:
4281#include "clang/AST/StmtNodes.inc"
4282 {
4283 ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
4284
4285 if (SDK == SDK_StmtExprResult)
4286 E = getSema().ActOnStmtExprResult(E);
4287 return getSema().ActOnExprStmt(E, SDK == SDK_Discarded);
4288 }
4289 }
4290
4291 return S;
4292}
4293
4294template<typename Derived>
4296 if (!S)
4297 return S;
4298
4299 switch (S->getClauseKind()) {
4300 default: break;
4301 // Transform individual clause nodes
4302#define GEN_CLANG_CLAUSE_CLASS
4303#define CLAUSE_CLASS(Enum, Str, Class) \
4304 case Enum: \
4305 return getDerived().Transform##Class(cast<Class>(S));
4306#include "llvm/Frontend/OpenMP/OMP.inc"
4307 }
4308
4309 return S;
4310}
4311
4312
4313template<typename Derived>
4315 if (!E)
4316 return E;
4317
4318 switch (E->getStmtClass()) {
4319 case Stmt::NoStmtClass: break;
4320#define STMT(Node, Parent) case Stmt::Node##Class: break;
4321#define ABSTRACT_STMT(Stmt)
4322#define EXPR(Node, Parent) \
4323 case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
4324#include "clang/AST/StmtNodes.inc"
4325 }
4326
4327 return E;
4328}
4329
4330template<typename Derived>
4332 bool NotCopyInit) {
4333 // Initializers are instantiated like expressions, except that various outer
4334 // layers are stripped.
4335 if (!Init)
4336 return Init;
4337
4338 if (auto *FE = dyn_cast<FullExpr>(Init))
4339 Init = FE->getSubExpr();
4340
4341 if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init)) {
4342 OpaqueValueExpr *OVE = AIL->getCommonExpr();
4343 Init = OVE->getSourceExpr();
4344 }
4345
4346 if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
4347 Init = MTE->getSubExpr();
4348
4349 while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
4350 Init = Binder->getSubExpr();
4351
4352 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
4353 Init = ICE->getSubExprAsWritten();
4354
4355 if (CXXStdInitializerListExpr *ILE =
4356 dyn_cast<CXXStdInitializerListExpr>(Init))
4357 return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
4358
4359 // If this is copy-initialization, we only need to reconstruct
4360 // InitListExprs. Other forms of copy-initialization will be a no-op if
4361 // the initializer is already the right type.
4362 CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
4363 if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
4364 return getDerived().TransformExpr(Init);
4365
4366 // Revert value-initialization back to empty parens.
4367 if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
4368 SourceRange Parens = VIE->getSourceRange();
4369 return getDerived().RebuildParenListExpr(Parens.getBegin(), {},
4370 Parens.getEnd());
4371 }
4372
4373 // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
4374 if (isa<ImplicitValueInitExpr>(Init))
4375 return getDerived().RebuildParenListExpr(SourceLocation(), {},
4376 SourceLocation());
4377
4378 // Revert initialization by constructor back to a parenthesized or braced list
4379 // of expressions. Any other form of initializer can just be reused directly.
4380 if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
4381 return getDerived().TransformExpr(Init);
4382
4383 // If the initialization implicitly converted an initializer list to a
4384 // std::initializer_list object, unwrap the std::initializer_list too.
4385 if (Construct && Construct->isStdInitListInitialization())
4386 return TransformInitializer(Construct->getArg(0), NotCopyInit);
4387
4388 // Enter a list-init context if this was list initialization.
4391 Construct->isListInitialization());
4392
4393 getSema().currentEvaluationContext().InLifetimeExtendingContext =
4394 getSema().parentEvaluationContext().InLifetimeExtendingContext;
4395 getSema().currentEvaluationContext().RebuildDefaultArgOrDefaultInit =
4396 getSema().parentEvaluationContext().RebuildDefaultArgOrDefaultInit;
4397 SmallVector<Expr*, 8> NewArgs;
4398 bool ArgChanged = false;
4399 if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
4400 /*IsCall*/true, NewArgs, &ArgChanged))
4401 return ExprError();
4402
4403 // If this was list initialization, revert to syntactic list form.
4404 if (Construct->isListInitialization())
4405 return getDerived().RebuildInitList(Construct->getBeginLoc(), NewArgs,
4406 Construct->getEndLoc());
4407
4408 // Build a ParenListExpr to represent anything else.
4410 if (Parens.isInvalid()) {
4411 // This was a variable declaration's initialization for which no initializer
4412 // was specified.
4413 assert(NewArgs.empty() &&
4414 "no parens or braces but have direct init with arguments?");
4415 return ExprEmpty();
4416 }
4417 return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
4418 Parens.getEnd());
4419}
4420
4421template<typename Derived>
4423 unsigned NumInputs,
4424 bool IsCall,
4425 SmallVectorImpl<Expr *> &Outputs,
4426 bool *ArgChanged) {
4427 for (unsigned I = 0; I != NumInputs; ++I) {
4428 // If requested, drop call arguments that need to be dropped.
4429 if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
4430 if (ArgChanged)
4431 *ArgChanged = true;
4432
4433 break;
4434 }
4435
4436 if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
4437 Expr *Pattern = Expansion->getPattern();
4438
4440 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4441 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4442
4443 // Determine whether the set of unexpanded parameter packs can and should
4444 // be expanded.
4445 bool Expand = true;
4446 bool RetainExpansion = false;
4447 std::optional<unsigned> OrigNumExpansions = Expansion->getNumExpansions();
4448 std::optional<unsigned> NumExpansions = OrigNumExpansions;
4449 if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(),
4450 Pattern->getSourceRange(),
4451 Unexpanded,
4452 Expand, RetainExpansion,
4453 NumExpansions))
4454 return true;
4455
4456 if (!Expand) {
4457 // The transform has determined that we should perform a simple
4458 // transformation on the pack expansion, producing another pack
4459 // expansion.
4460 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
4461 ExprResult OutPattern = getDerived().TransformExpr(Pattern);
4462 if (OutPattern.isInvalid())
4463 return true;
4464
4465 ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
4466 Expansion->getEllipsisLoc(),
4467 NumExpansions);
4468 if (Out.isInvalid())
4469 return true;
4470
4471 if (ArgChanged)
4472 *ArgChanged = true;
4473 Outputs.push_back(Out.get());
4474 continue;
4475 }
4476
4477 // Record right away that the argument was changed. This needs
4478 // to happen even if the array expands to nothing.
4479 if (ArgChanged) *ArgChanged = true;
4480
4481 // The transform has determined that we should perform an elementwise
4482 // expansion of the pattern. Do so.
4483 for (unsigned I = 0; I != *NumExpansions; ++I) {
4484 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
4485 ExprResult Out = getDerived().TransformExpr(Pattern);
4486 if (Out.isInvalid())
4487 return true;
4488
4489 if (Out.get()->containsUnexpandedParameterPack()) {
4490 Out = getDerived().RebuildPackExpansion(
4491 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4492 if (Out.isInvalid())
4493 return true;
4494 }
4495
4496 Outputs.push_back(Out.get());
4497 }
4498
4499 // If we're supposed to retain a pack expansion, do so by temporarily
4500 // forgetting the partially-substituted parameter pack.
4501 if (RetainExpansion) {
4502 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4503
4504 ExprResult Out = getDerived().TransformExpr(Pattern);
4505 if (Out.isInvalid())
4506 return true;
4507
4508 Out = getDerived().RebuildPackExpansion(
4509 Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
4510 if (Out.isInvalid())
4511 return true;
4512
4513 Outputs.push_back(Out.get());
4514 }
4515
4516 continue;
4517 }
4518
4520 IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
4521 : getDerived().TransformExpr(Inputs[I]);
4522 if (Result.isInvalid())
4523 return true;
4524
4525 if (Result.get() != Inputs[I] && ArgChanged)
4526 *ArgChanged = true;
4527
4528 Outputs.push_back(Result.get());
4529 }
4530
4531 return false;
4532}
4533
4534template <typename Derived>
4537 if (Var) {
4538 VarDecl *ConditionVar = cast_or_null<VarDecl>(
4539 getDerived().TransformDefinition(Var->getLocation(), Var));
4540
4541 if (!ConditionVar)
4542 return Sema::ConditionError();
4543
4544 return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
4545 }
4546
4547 if (Expr) {
4548 ExprResult CondExpr = getDerived().TransformExpr(Expr);
4549
4550 if (CondExpr.isInvalid())
4551 return Sema::ConditionError();
4552
4553 return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind,
4554 /*MissingOK=*/true);
4555 }
4556
4557 return Sema::ConditionResult();
4558}
4559
4560template <typename Derived>
4562 NestedNameSpecifierLoc NNS, QualType ObjectType,
4563 NamedDecl *FirstQualifierInScope) {
4565
4566 auto insertNNS = [&Qualifiers](NestedNameSpecifierLoc NNS) {
4567 for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
4568 Qualifier = Qualifier.getPrefix())
4569 Qualifiers.push_back(Qualifier);
4570 };
4571 insertNNS(NNS);
4572
4573 CXXScopeSpec SS;
4574 while (!Qualifiers.empty()) {
4575 NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
4577
4578 switch (QNNS->getKind()) {
4582 ObjectType);
4583 if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo, false,
4584 SS, FirstQualifierInScope, false))
4585 return NestedNameSpecifierLoc();
4586 break;
4587 }
4588
4590 NamespaceDecl *NS =
4591 cast_or_null<NamespaceDecl>(getDerived().TransformDecl(
4592 Q.getLocalBeginLoc(), QNNS->getAsNamespace()));
4593 SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
4594 break;
4595 }
4596
4598 NamespaceAliasDecl *Alias =
4599 cast_or_null<NamespaceAliasDecl>(getDerived().TransformDecl(
4601 SS.Extend(SemaRef.Context, Alias, Q.getLocalBeginLoc(),
4602 Q.getLocalEndLoc());
4603 break;
4604 }
4605
4607 // There is no meaningful transformation that one could perform on the
4608 // global scope.
4609 SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
4610 break;
4611
4613 CXXRecordDecl *RD =
4614 cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
4615 SourceLocation(), QNNS->getAsRecordDecl()));
4616 SS.MakeSuper(SemaRef.Context, RD, Q.getBeginLoc(), Q.getEndLoc());
4617 break;
4618 }
4619
4622 TypeLoc TL = TransformTypeInObjectScope(Q.getTypeLoc(), ObjectType,
4623 FirstQualifierInScope, SS);
4624
4625 if (!TL)
4626 return NestedNameSpecifierLoc();
4627
4628 QualType T = TL.getType();
4629 if (T->isDependentType() || T->isRecordType() ||
4630 (SemaRef.getLangOpts().CPlusPlus11 && T->isEnumeralType())) {
4631 if (T->isEnumeralType())
4632 SemaRef.Diag(TL.getBeginLoc(),
4633 diag::warn_cxx98_compat_enum_nested_name_spec);
4634
4635 if (const auto ETL = TL.getAs<ElaboratedTypeLoc>()) {
4636 SS.Adopt(ETL.getQualifierLoc());
4637 TL = ETL.getNamedTypeLoc();
4638 }
4639
4640 SS.Extend(SemaRef.Context, TL.getTemplateKeywordLoc(), TL,
4641 Q.getLocalEndLoc());
4642 break;
4643 }
4644 // If the nested-name-specifier is an invalid type def, don't emit an
4645 // error because a previous error should have already been emitted.
4647 if (!TTL || !TTL.getTypedefNameDecl()->isInvalidDecl()) {
4648 SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
4649 << T << SS.getRange();
4650 }
4651 return NestedNameSpecifierLoc();
4652 }
4653 }
4654
4655 // The qualifier-in-scope and object type only apply to the leftmost entity.
4656 FirstQualifierInScope = nullptr;
4657 ObjectType = QualType();
4658 }
4659
4660 // Don't rebuild the nested-name-specifier if we don't have to.
4661 if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
4662 !getDerived().AlwaysRebuild())
4663 return NNS;
4664
4665 // If we can re-use the source-location data from the original
4666 // nested-name-specifier, do so.
4667 if (SS.location_size() == NNS.getDataLength() &&
4668 memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
4670
4671 // Allocate new nested-name-specifier location information.
4672 return SS.getWithLocInContext(SemaRef.Context);
4673}
4674
4675template<typename Derived>
4679 DeclarationName Name = NameInfo.getName();
4680 if (!Name)
4681 return DeclarationNameInfo();
4682
4683 switch (Name.getNameKind()) {
4691 return NameInfo;
4692
4694 TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
4695 TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
4696 getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
4697 if (!NewTemplate)
4698 return DeclarationNameInfo();
4699
4700 DeclarationNameInfo NewNameInfo(NameInfo);
4701 NewNameInfo.setName(
4703 return NewNameInfo;
4704 }
4705
4709 TypeSourceInfo *NewTInfo;
4710 CanQualType NewCanTy;
4711 if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
4712 NewTInfo = getDerived().TransformType(OldTInfo);
4713 if (!NewTInfo)
4714 return DeclarationNameInfo();
4715 NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
4716 }
4717 else {
4718 NewTInfo = nullptr;
4719 TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
4720 QualType NewT = getDerived().TransformType(Name.getCXXNameType());
4721 if (NewT.isNull())
4722 return DeclarationNameInfo();
4723 NewCanTy = SemaRef.Context.getCanonicalType(NewT);
4724 }
4725
4726 DeclarationName NewName
4727 = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
4728 NewCanTy);
4729 DeclarationNameInfo NewNameInfo(NameInfo);
4730 NewNameInfo.setName(NewName);
4731 NewNameInfo.setNamedTypeInfo(NewTInfo);
4732 return NewNameInfo;
4733 }
4734 }
4735
4736 llvm_unreachable("Unknown name kind.");
4737}
4738
4739template<typename Derived>
4742 TemplateName Name,
4743 SourceLocation NameLoc,
4744 QualType ObjectType,
4745 NamedDecl *FirstQualifierInScope,
4746 bool AllowInjectedClassName) {
4747 if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) {
4748 TemplateDecl *Template = QTN->getUnderlyingTemplate().getAsTemplateDecl();
4749 assert(Template && "qualified template name must refer to a template");
4750
4751 TemplateDecl *TransTemplate
4752 = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
4753 Template));
4754 if (!TransTemplate)
4755 return TemplateName();
4756
4757 if (!getDerived().AlwaysRebuild() &&
4758 SS.getScopeRep() == QTN->getQualifier() &&
4759 TransTemplate == Template)
4760 return Name;
4761
4762 return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
4763 TransTemplate);
4764 }
4765
4766 if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) {
4767 if (SS.getScopeRep()) {
4768 // These apply to the scope specifier, not the template.
4769 ObjectType = QualType();
4770 FirstQualifierInScope = nullptr;
4771 }
4772
4773 if (!getDerived().AlwaysRebuild() &&
4774 SS.getScopeRep() == DTN->getQualifier() &&
4775 ObjectType.isNull())
4776 return Name;
4777
4778 // FIXME: Preserve the location of the "template" keyword.
4779 SourceLocation TemplateKWLoc = NameLoc;
4780
4781 if (DTN->isIdentifier()) {
4782 return getDerived().RebuildTemplateName(SS,
4783 TemplateKWLoc,
4784 *DTN->getIdentifier(),
4785 NameLoc,
4786 ObjectType,
4787 FirstQualifierInScope,
4788 AllowInjectedClassName);
4789 }
4790
4791 return getDerived().RebuildTemplateName(SS, TemplateKWLoc,
4792 DTN->getOperator(), NameLoc,
4793 ObjectType, AllowInjectedClassName);
4794 }
4795
4796 // FIXME: Try to preserve more of the TemplateName.
4797 if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
4798 TemplateDecl *TransTemplate
4799 = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
4800 Template));
4801 if (!TransTemplate)
4802 return TemplateName();
4803
4804 return getDerived().RebuildTemplateName(SS, /*TemplateKeyword=*/false,
4805 TransTemplate);
4806 }
4807
4809 = Name.getAsSubstTemplateTemplateParmPack()) {
4810 return getDerived().RebuildTemplateName(
4811 SubstPack->getArgumentPack(), SubstPack->getAssociatedDecl(),
4812 SubstPack->getIndex(), SubstPack->getFinal());
4813 }
4814
4815 // These should be getting filtered out before they reach the AST.
4816 llvm_unreachable("overloaded function decl survived to here");
4817}
4818
4819template<typename Derived>
4821 const TemplateArgument &Arg,
4822 TemplateArgumentLoc &Output) {
4823 Output = getSema().getTrivialTemplateArgumentLoc(
4824 Arg, QualType(), getDerived().getBaseLocation());
4825}
4826
4827template <typename Derived>
4829 const TemplateArgumentLoc &Input, TemplateArgumentLoc &Output,
4830 bool Uneval) {
4831 const TemplateArgument &Arg = Input.getArgument();
4832 switch (Arg.getKind()) {
4835 llvm_unreachable("Unexpected TemplateArgument");
4836
4841 // Transform a resolved template argument straight to a resolved template
4842 // argument. We get here when substituting into an already-substituted
4843 // template type argument during concept satisfaction checking.
4845 QualType NewT = getDerived().TransformType(T);
4846 if (NewT.isNull())
4847 return true;
4848
4850 ? Arg.getAsDecl()
4851 : nullptr;
4852 ValueDecl *NewD = D ? cast_or_null<ValueDecl>(getDerived().TransformDecl(
4853 getDerived().getBaseLocation(), D))
4854 : nullptr;
4855 if (D && !NewD)
4856 return true;
4857
4858 if (NewT == T && D == NewD)
4859 Output = Input;
4860 else if (Arg.getKind() == TemplateArgument::Integral)
4861 Output = TemplateArgumentLoc(
4862 TemplateArgument(getSema().Context, Arg.getAsIntegral(), NewT),
4864 else if (Arg.getKind() == TemplateArgument::NullPtr)
4865 Output = TemplateArgumentLoc(TemplateArgument(NewT, /*IsNullPtr=*/true),
4867 else if (Arg.getKind() == TemplateArgument::Declaration)
4868 Output = TemplateArgumentLoc(TemplateArgument(NewD, NewT),
4871 Output = TemplateArgumentLoc(
4872 TemplateArgument(getSema().Context, NewT, Arg.getAsStructuralValue()),
4874 else
4875 llvm_unreachable("unexpected template argument kind");
4876
4877 return false;
4878 }
4879
4881 TypeSourceInfo *DI = Input.getTypeSourceInfo();
4882 if (!DI)
4883 DI = InventTypeSourceInfo(Input.getArgument().getAsType());
4884
4885 DI = getDerived().TransformType(DI);
4886 if (!DI)
4887 return true;
4888
4889 Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
4890 return false;
4891 }
4892
4894 NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
4895 if (QualifierLoc) {
4896 QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
4897 if (!QualifierLoc)
4898 return true;
4899 }
4900
4901 CXXScopeSpec SS;
4902 SS.Adopt(QualifierLoc);
4903 TemplateName Template = getDerived().TransformTemplateName(
4904 SS, Arg.getAsTemplate(), Input.getTemplateNameLoc());
4905 if (Template.isNull())
4906 return true;
4907
4908 Output = TemplateArgumentLoc(SemaRef.Context, TemplateArgument(Template),
4909 QualifierLoc, Input.getTemplateNameLoc());
4910 return false;
4911 }
4912
4914 llvm_unreachable("Caller should expand pack expansions");
4915
4917 // Template argument expressions are constant expressions.
4919 getSema(),
4922 Sema::ReuseLambdaContextDecl, /*ExprContext=*/
4924
4925 Expr *InputExpr = Input.getSourceExpression();
4926 if (!InputExpr)
4927 InputExpr = Input.getArgument().getAsExpr();
4928
4929 ExprResult E = getDerived().TransformExpr(InputExpr);
4930 E = SemaRef.ActOnConstantExpression(E);
4931 if (E.isInvalid())
4932 return true;
4933 Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get());
4934 return false;
4935 }
4936 }
4937
4938 // Work around bogus GCC warning
4939 return true;
4940}
4941
4942/// Iterator adaptor that invents template argument location information
4943/// for each of the template arguments in its underlying iterator.
4944template<typename Derived, typename InputIterator>
4947 InputIterator Iter;
4948
4949public:
4952 typedef typename std::iterator_traits<InputIterator>::difference_type
4954 typedef std::input_iterator_tag iterator_category;
4955
4956 class pointer {
4958
4959 public:
4960 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
4961
4962 const TemplateArgumentLoc *operator->() const { return &Arg; }
4963 };
4964
4966 InputIterator Iter)
4967 : Self(Self), Iter(Iter) { }
4968
4970 ++Iter;
4971 return *this;
4972 }
4973
4976 ++(*this);
4977 return Old;
4978 }
4979
4982 Self.InventTemplateArgumentLoc(*Iter, Result);
4983 return Result;
4984 }
4985
4986 pointer operator->() const { return pointer(**this); }
4987
4990 return X.Iter == Y.Iter;
4991 }
4992
4995 return X.Iter != Y.Iter;
4996 }
4997};
4998
4999template<typename Derived>
5000template<typename InputIterator>
5002 InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
5003 bool Uneval) {
5004 for (; First != Last; ++First) {
5007
5008 if (In.getArgument().getKind() == TemplateArgument::Pack) {
5009 // Unpack argument packs, which we translate them into separate
5010 // arguments.
5011 // FIXME: We could do much better if we could guarantee that the
5012 // TemplateArgumentLocInfo for the pack expansion would be usable for
5013 // all of the template arguments in the argument pack.
5014 typedef TemplateArgumentLocInventIterator<Derived,
5016 PackLocIterator;
5017 if (TransformTemplateArguments(PackLocIterator(*this,
5018 In.getArgument().pack_begin()),
5019 PackLocIterator(*this,
5020 In.getArgument().pack_end()),
5021 Outputs, Uneval))
5022 return true;
5023
5024 continue;
5025 }
5026
5027 if (In.getArgument().isPackExpansion()) {
5028 // We have a pack expansion, for which we will be substituting into
5029 // the pattern.
5030 SourceLocation Ellipsis;
5031 std::optional<unsigned> OrigNumExpansions;
5032 TemplateArgumentLoc Pattern
5033 = getSema().getTemplateArgumentPackExpansionPattern(
5034 In, Ellipsis, OrigNumExpansions);
5035
5037 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5038 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5039
5040 // Determine whether the set of unexpanded parameter packs can and should
5041 // be expanded.
5042 bool Expand = true;
5043 bool RetainExpansion = false;
5044 std::optional<unsigned> NumExpansions = OrigNumExpansions;
5045 if (getDerived().TryExpandParameterPacks(Ellipsis,
5046 Pattern.getSourceRange(),
5047 Unexpanded,
5048 Expand,
5049 RetainExpansion,
5050 NumExpansions))
5051 return true;
5052
5053 if (!Expand) {
5054 // The transform has determined that we should perform a simple
5055 // transformation on the pack expansion, producing another pack
5056 // expansion.
5057 TemplateArgumentLoc OutPattern;
5058 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5059 if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
5060 return true;
5061
5062 Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis,
5063 NumExpansions);
5064 if (Out.getArgument().isNull())
5065 return true;
5066
5067 Outputs.addArgument(Out);
5068 continue;
5069 }
5070
5071 // The transform has determined that we should perform an elementwise
5072 // expansion of the pattern. Do so.
5073 for (unsigned I = 0; I != *NumExpansions; ++I) {
5074 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
5075
5076 if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
5077 return true;
5078
5079 if (Out.getArgument().containsUnexpandedParameterPack()) {
5080 Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
5081 OrigNumExpansions);
5082 if (Out.getArgument().isNull())
5083 return true;
5084 }
5085
5086 Outputs.addArgument(Out);
5087 }
5088
5089 // If we're supposed to retain a pack expansion, do so by temporarily
5090 // forgetting the partially-substituted parameter pack.
5091 if (RetainExpansion) {
5092 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5093
5094 if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
5095 return true;
5096
5097 Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
5098 OrigNumExpansions);
5099 if (Out.getArgument().isNull())
5100 return true;
5101
5102 Outputs.addArgument(Out);
5103 }
5104
5105 continue;
5106 }
5107
5108 // The simple case:
5109 if (getDerived().TransformTemplateArgument(In, Out, Uneval))
5110 return true;
5111
5112 Outputs.addArgument(Out);
5113 }
5114
5115 return false;
5116
5117}
5118
5119//===----------------------------------------------------------------------===//
5120// Type transformation
5121//===----------------------------------------------------------------------===//
5122
5123template<typename Derived>
5125 if (getDerived().AlreadyTransformed(T))
5126 return T;
5127
5128 // Temporary workaround. All of these transformations should
5129 // eventually turn into transformations on TypeLocs.
5130 TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
5131 getDerived().getBaseLocation());
5132
5133 TypeSourceInfo *NewDI = getDerived().TransformType(DI);
5134
5135 if (!NewDI)
5136 return QualType();
5137
5138 return NewDI->getType();
5139}
5140
5141template<typename Derived>
5143 // Refine the base location to the type's location.
5144 TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
5145 getDerived().getBaseEntity());
5146 if (getDerived().AlreadyTransformed(DI->getType()))
5147 return DI;
5148
5149 TypeLocBuilder TLB;
5150
5151 TypeLoc TL = DI->getTypeLoc();
5152 TLB.reserve(TL.getFullDataSize());
5153
5154 QualType Result = getDerived().TransformType(TLB, TL);
5155 if (Result.isNull())
5156 return nullptr;
5157
5158 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5159}
5160
5161template<typename Derived>
5164 switch (T.getTypeLocClass()) {
5165#define ABSTRACT_TYPELOC(CLASS, PARENT)
5166#define TYPELOC(CLASS, PARENT) \
5167 case TypeLoc::CLASS: \
5168 return getDerived().Transform##CLASS##Type(TLB, \
5169 T.castAs<CLASS##TypeLoc>());
5170#include "clang/AST/TypeLocNodes.def"
5171 }
5172
5173 llvm_unreachable("unhandled type loc!");
5174}
5175
5176template<typename Derived>
5178 if (!isa<DependentNameType>(T))
5179 return TransformType(T);
5180
5181 if (getDerived().AlreadyTransformed(T))
5182 return T;
5183 TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
5184 getDerived().getBaseLocation());
5185 TypeSourceInfo *NewDI = getDerived().TransformTypeWithDeducedTST(DI);
5186 return NewDI ? NewDI->getType() : QualType();
5187}
5188
5189template<typename Derived>
5192 if (!isa<DependentNameType>(DI->getType()))
5193 return TransformType(DI);
5194
5195 // Refine the base location to the type's location.
5196 TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
5197 getDerived().getBaseEntity());
5198 if (getDerived().AlreadyTransformed(DI->getType()))
5199 return DI;
5200
5201 TypeLocBuilder TLB;
5202
5203 TypeLoc TL = DI->getTypeLoc();
5204 TLB.reserve(TL.getFullDataSize());
5205
5206 auto QTL = TL.getAs<QualifiedTypeLoc>();
5207 if (QTL)
5208 TL = QTL.getUnqualifiedLoc();
5209
5210 auto DNTL = TL.castAs<DependentNameTypeLoc>();
5211
5212 QualType Result = getDerived().TransformDependentNameType(
5213 TLB, DNTL, /*DeducedTSTContext*/true);
5214 if (Result.isNull())
5215 return nullptr;
5216
5217 if (QTL) {
5218 Result = getDerived().RebuildQualifiedType(Result, QTL);
5219 if (Result.isNull())
5220 return nullptr;
5222 }
5223
5224 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5225}
5226
5227template<typename Derived>
5232 TypeLoc UnqualTL = T.getUnqualifiedLoc();
5233 auto SuppressObjCLifetime =
5234 T.getType().getLocalQualifiers().hasObjCLifetime();
5235 if (auto TTP = UnqualTL.getAs<TemplateTypeParmTypeLoc>()) {
5236 Result = getDerived().TransformTemplateTypeParmType(TLB, TTP,
5237 SuppressObjCLifetime);
5238 } else if (auto STTP = UnqualTL.getAs<SubstTemplateTypeParmPackTypeLoc>()) {
5239 Result = getDerived().TransformSubstTemplateTypeParmPackType(
5240 TLB, STTP, SuppressObjCLifetime);
5241 } else {
5242 Result = getDerived().TransformType(TLB, UnqualTL);
5243 }
5244
5245 if (Result.isNull())
5246 return QualType();
5247
5248 Result = getDerived().RebuildQualifiedType(Result, T);
5249
5250 if (Result.isNull())
5251 return QualType();
5252
5253 // RebuildQualifiedType might have updated the type, but not in a way
5254 // that invalidates the TypeLoc. (There's no location information for
5255 // qualifiers.)
5257
5258 return Result;
5259}
5260
5261template <typename Derived>
5263 QualifiedTypeLoc TL) {
5264
5266 Qualifiers Quals = TL.getType().getLocalQualifiers();
5267
5268 if ((T.getAddressSpace() != LangAS::Default &&
5269 Quals.getAddressSpace() != LangAS::Default) &&
5270 T.getAddressSpace() != Quals.getAddressSpace()) {
5271 SemaRef.Diag(Loc, diag::err_address_space_mismatch_templ_inst)
5272 << TL.getType() << T;
5273 return QualType();
5274 }
5275
5276 // C++ [dcl.fct]p7:
5277 // [When] adding cv-qualifications on top of the function type [...] the
5278 // cv-qualifiers are ignored.
5279 if (T->isFunctionType()) {
5281 Quals.getAddressSpace());
5282 return T;
5283 }
5284
5285 // C++ [dcl.ref]p1:
5286 // when the cv-qualifiers are introduced through the use of a typedef-name
5287 // or decltype-specifier [...] the cv-qualifiers are ignored.
5288 // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
5289 // applied to a reference type.
5290 if (T->isReferenceType()) {
5291 // The only qualifier that applies to a reference type is restrict.
5292 if (!Quals.hasRestrict())
5293 return T;
5295 }
5296
5297 // Suppress Objective-C lifetime qualifiers if they don't make sense for the
5298 // resulting type.
5299 if (Quals.hasObjCLifetime()) {
5300 if (!T->isObjCLifetimeType() && !T->isDependentType())
5301 Quals.removeObjCLifetime();
5302 else if (T.getObjCLifetime()) {
5303 // Objective-C ARC:
5304 // A lifetime qualifier applied to a substituted template parameter
5305 // overrides the lifetime qualifier from the template argument.
5306 const AutoType *AutoTy;
5307 if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
5308 // 'auto' types behave the same way as template parameters.
5309 QualType Deduced = AutoTy->getDeducedType();
5310 Qualifiers Qs = Deduced.getQualifiers();
5311 Qs.removeObjCLifetime();
5312 Deduced =
5313 SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
5314 T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
5315 AutoTy->isDependentType(),
5316 /*isPack=*/false,
5317 AutoTy->getTypeConstraintConcept(),
5318 AutoTy->getTypeConstraintArguments());
5319 } else {
5320 // Otherwise, complain about the addition of a qualifier to an
5321 // already-qualified type.
5322 // FIXME: Why is this check not in Sema::BuildQualifiedType?
5323 SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
5324 Quals.removeObjCLifetime();
5325 }
5326 }
5327 }
5328
5329 return SemaRef.BuildQualifiedType(T, Loc, Quals);
5330}
5331
5332template<typename Derived>
5333TypeLoc
5335 QualType ObjectType,
5336 NamedDecl *UnqualLookup,
5337 CXXScopeSpec &SS) {
5338 if (getDerived().AlreadyTransformed(TL.getType()))
5339 return TL;
5340
5341 TypeSourceInfo *TSI =
5342 TransformTSIInObjectScope(TL, ObjectType, UnqualLookup, SS);
5343 if (TSI)
5344 return TSI->getTypeLoc();
5345 return TypeLoc();
5346}
5347
5348template<typename Derived>
5349TypeSourceInfo *
5350TreeTransform<Derived>::TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
5351 QualType ObjectType,
5352 NamedDecl *UnqualLookup,
5353 CXXScopeSpec &SS) {
5354 if (getDerived().AlreadyTransformed(TSInfo->getType()))
5355 return TSInfo;
5356
5357 return TransformTSIInObjectScope(TSInfo->getTypeLoc(), ObjectType,
5358 UnqualLookup, SS);
5359}
5360
5361template <typename Derived>
5362TypeSourceInfo *TreeTransform<Derived>::TransformTSIInObjectScope(
5363 TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup,
5364 CXXScopeSpec &SS) {
5365 QualType T = TL.getType();
5366 assert(!getDerived().AlreadyTransformed(T));
5367
5368 TypeLocBuilder TLB;
5369 QualType Result;
5370
5371 if (isa<TemplateSpecializationType>(T)) {
5372 TemplateSpecializationTypeLoc SpecTL =
5373 TL.castAs<TemplateSpecializationTypeLoc>();
5374
5375 TemplateName Template = getDerived().TransformTemplateName(
5376 SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(),
5377 ObjectType, UnqualLookup, /*AllowInjectedClassName*/true);
5378 if (Template.isNull())
5379 return nullptr;
5380
5381 Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
5382 Template);
5383 } else if (isa<DependentTemplateSpecializationType>(T)) {
5384 DependentTemplateSpecializationTypeLoc SpecTL =
5385 TL.castAs<DependentTemplateSpecializationTypeLoc>();
5386
5387 TemplateName Template
5388 = getDerived().RebuildTemplateName(SS,
5389 SpecTL.getTemplateKeywordLoc(),
5390 *SpecTL.getTypePtr()->getIdentifier(),
5391 SpecTL.getTemplateNameLoc(),
5392 ObjectType, UnqualLookup,
5393 /*AllowInjectedClassName*/true);
5394 if (Template.isNull())
5395 return nullptr;
5396
5397 Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
5398 SpecTL,
5399 Template,
5400 SS);
5401 } else {
5402 // Nothing special needs to be done for these.
5403 Result = getDerived().TransformType(TLB, TL);
5404 }
5405
5406 if (Result.isNull())
5407 return nullptr;
5408
5409 return TLB.getTypeSourceInfo(SemaRef.Context, Result);
5410}
5411
5412template <class TyLoc> static inline
5414 TyLoc NewT = TLB.push<TyLoc>(T.getType());
5415 NewT.setNameLoc(T.getNameLoc());
5416 return T.getType();
5417}
5418
5419template<typename Derived>
5420QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
5421 BuiltinTypeLoc T) {
5422 BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
5423 NewT.setBuiltinLoc(T.getBuiltinLoc());
5424 if (T.needsExtraLocalData())
5425 NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
5426 return T.getType();
5427}
5428
5429template<typename Derived>
5430QualType TreeTransform<Derived>::TransformComplexType(TypeLocBuilder &TLB,
5431 ComplexTypeLoc T) {
5432 // FIXME: recurse?
5433 return TransformTypeSpecType(TLB, T);
5434}
5435
5436template <typename Derived>
5437QualType TreeTransform<Derived>::TransformAdjustedType(TypeLocBuilder &TLB,
5438 AdjustedTypeLoc TL) {
5439 // Adjustments applied during transformation are handled elsewhere.
5440 return getDerived().TransformType(TLB, TL.getOriginalLoc());
5441}
5442
5443template<typename Derived>
5444QualType TreeTransform<Derived>::TransformDecayedType(TypeLocBuilder &TLB,
5445 DecayedTypeLoc TL) {
5446 QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
5447 if (OriginalType.isNull())
5448 return QualType();
5449
5450 QualType Result = TL.getType();
5451 if (getDerived().AlwaysRebuild() ||
5452 OriginalType != TL.getOriginalLoc().getType())
5453 Result = SemaRef.Context.getDecayedType(OriginalType);
5454 TLB.push<DecayedTypeLoc>(Result);
5455 // Nothing to set for DecayedTypeLoc.
5456 return Result;
5457}
5458
5459template <typename Derived>
5460QualType
5461TreeTransform<Derived>::TransformArrayParameterType(TypeLocBuilder &TLB,
5462 ArrayParameterTypeLoc TL) {
5463 QualType OriginalType = getDerived().TransformType(TLB, TL.getElementLoc());
5464 if (OriginalType.isNull())
5465 return QualType();
5466
5467 QualType Result = TL.getType();
5468 if (getDerived().AlwaysRebuild() ||
5469 OriginalType != TL.getElementLoc().getType())
5470 Result = SemaRef.Context.getArrayParameterType(OriginalType);
5471 TLB.push<ArrayParameterTypeLoc>(Result);
5472 // Nothing to set for ArrayParameterTypeLoc.
5473 return Result;
5474}
5475
5476template<typename Derived>
5477QualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB,
5478 PointerTypeLoc TL) {
5479 QualType PointeeType
5480 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5481 if (PointeeType.isNull())
5482 return QualType();
5483
5484 QualType Result = TL.getType();
5485 if (PointeeType->getAs<ObjCObjectType>()) {
5486 // A dependent pointer type 'T *' has is being transformed such
5487 // that an Objective-C class type is being replaced for 'T'. The
5488 // resulting pointer type is an ObjCObjectPointerType, not a
5489 // PointerType.
5490 Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
5491
5492 ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);
5493 NewT.setStarLoc(TL.getStarLoc());
5494 return Result;
5495 }
5496
5497 if (getDerived().AlwaysRebuild() ||
5498 PointeeType != TL.getPointeeLoc().getType()) {
5499 Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
5500 if (Result.isNull())
5501 return QualType();
5502 }
5503
5504 // Objective-C ARC can add lifetime qualifiers to the type that we're
5505 // pointing to.
5506 TLB.TypeWasModifiedSafely(Result->getPointeeType());
5507
5508 PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
5509 NewT.setSigilLoc(TL.getSigilLoc());
5510 return Result;
5511}
5512
5513template<typename Derived>
5514QualType
5515TreeTransform<Derived>::TransformBlockPointerType(TypeLocBuilder &TLB,
5516 BlockPointerTypeLoc TL) {
5517 QualType PointeeType
5518 = getDerived().TransformType(TLB, TL.getPointeeLoc());
5519 if (PointeeType.isNull())
5520 return QualType();
5521
5522 QualType Result = TL.getType();
5523 if (getDerived().AlwaysRebuild() ||
5524 PointeeType != TL.getPointeeLoc().getType()) {
5525 Result = getDerived().RebuildBlockPointerType(PointeeType,
5526 TL.getSigilLoc());
5527 if (Result.isNull())
5528 return QualType();
5529 }
5530
5531 BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result);
5532 NewT.setSigilLoc(TL.getSigilLoc());
5533 return Result;
5534}
5535
5536/// Transforms a reference type. Note that somewhat paradoxically we
5537/// don't care whether the type itself is an l-value type or an r-value
5538/// type; we only care if the type was *written* as an l-value type
5539/// or an r-value type.
5540template<typename Derived>
5541QualType
5543 ReferenceTypeLoc TL) {
5544 const ReferenceType *T = TL.getTypePtr();
5545
5546 // Note that this works with the pointee-as-written.
5547 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5548 if (PointeeType.isNull())
5549 return QualType();
5550
5551 QualType Result = TL.getType();
5552 if (getDerived().AlwaysRebuild() ||
5553 PointeeType != T->getPointeeTypeAsWritten()) {
5554 Result = getDerived().RebuildReferenceType(PointeeType,
5555 T->isSpelledAsLValue(),
5556 TL.getSigilLoc());
5557 if (Result.isNull())
5558 return QualType();
5559 }
5560
5561 // Objective-C ARC can add lifetime qualifiers to the type that we're
5562 // referring to.
5565
5566 // r-value references can be rebuilt as l-value references.
5567 ReferenceTypeLoc NewTL;
5568 if (isa<LValueReferenceType>(Result))
5569 NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
5570 else
5571 NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
5572 NewTL.setSigilLoc(TL.getSigilLoc());
5573
5574 return Result;
5575}
5576
5577template<typename Derived>
5581 return TransformReferenceType(TLB, TL);
5582}
5583
5584template<typename Derived>
5585QualType
5586TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
5587 RValueReferenceTypeLoc TL) {
5588 return TransformReferenceType(TLB, TL);
5589}
5590
5591template<typename Derived>
5592QualType
5593TreeTransform<Derived>::TransformMemberPointerType(TypeLocBuilder &TLB,
5594 MemberPointerTypeLoc TL) {
5595 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
5596 if (PointeeType.isNull())
5597 return QualType();
5598
5599 TypeSourceInfo* OldClsTInfo = TL.getClassTInfo();
5600 TypeSourceInfo *NewClsTInfo = nullptr;
5601 if (OldClsTInfo) {
5602 NewClsTInfo = getDerived().TransformType(OldClsTInfo);
5603 if (!NewClsTInfo)
5604 return QualType();
5605 }
5606
5607 const MemberPointerType *T = TL.getTypePtr();
5608 QualType OldClsType = QualType(T->getClass(), 0);
5609 QualType NewClsType;
5610 if (NewClsTInfo)
5611 NewClsType = NewClsTInfo->getType();
5612 else {
5613 NewClsType = getDerived().TransformType(OldClsType);
5614 if (NewClsType.isNull())
5615 return QualType();
5616 }
5617
5618 QualType Result = TL.getType();
5619 if (getDerived().AlwaysRebuild() ||
5620 PointeeType != T->getPointeeType() ||
5621 NewClsType != OldClsType) {
5622 Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType,
5623 TL.getStarLoc());
5624 if (Result.isNull())
5625 return QualType();
5626 }
5627
5628 // If we had to adjust the pointee type when building a member pointer, make
5629 // sure to push TypeLoc info for it.
5630 const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
5631 if (MPT && PointeeType != MPT->getPointeeType()) {
5632 assert(isa<AdjustedType>(MPT->getPointeeType()));
5633 TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
5634 }
5635
5636 MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result);
5637 NewTL.setSigilLoc(TL.getSigilLoc());
5638 NewTL.setClassTInfo(NewClsTInfo);
5639
5640 return Result;
5641}
5642
5643template<typename Derived>
5644QualType
5645TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB,
5646 ConstantArrayTypeLoc TL) {
5647 const ConstantArrayType *T = TL.getTypePtr();
5648 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5649 if (ElementType.isNull())
5650 return QualType();
5651
5652 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5653 Expr *OldSize = TL.getSizeExpr();
5654 if (!OldSize)
5655 OldSize = const_cast<Expr*>(T->getSizeExpr());
5656 Expr *NewSize = nullptr;
5657 if (OldSize) {
5658 EnterExpressionEvaluationContext Unevaluated(
5660 NewSize = getDerived().TransformExpr(OldSize).template getAs<Expr>();
5661 NewSize = SemaRef.ActOnConstantExpression(NewSize).get();
5662 }
5663
5664 QualType Result = TL.getType();
5665 if (getDerived().AlwaysRebuild() ||
5666 ElementType != T->getElementType() ||
5667 (T->getSizeExpr() && NewSize != OldSize)) {
5668 Result = getDerived().RebuildConstantArrayType(ElementType,
5669 T->getSizeModifier(),
5670 T->getSize(), NewSize,
5671 T->getIndexTypeCVRQualifiers(),
5672 TL.getBracketsRange());
5673 if (Result.isNull())
5674 return QualType();
5675 }
5676
5677 // We might have either a ConstantArrayType or a VariableArrayType now:
5678 // a ConstantArrayType is allowed to have an element type which is a
5679 // VariableArrayType if the type is dependent. Fortunately, all array
5680 // types have the same location layout.
5681 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5682 NewTL.setLBracketLoc(TL.getLBracketLoc());
5683 NewTL.setRBracketLoc(TL.getRBracketLoc());
5684 NewTL.setSizeExpr(NewSize);
5685
5686 return Result;
5687}
5688
5689template<typename Derived>
5690QualType TreeTransform<Derived>::TransformIncompleteArrayType(
5691 TypeLocBuilder &TLB,
5692 IncompleteArrayTypeLoc TL) {
5693 const IncompleteArrayType *T = TL.getTypePtr();
5694 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5695 if (ElementType.isNull())
5696 return QualType();
5697
5698 QualType Result = TL.getType();
5699 if (getDerived().AlwaysRebuild() ||
5700 ElementType != T->getElementType()) {
5701 Result = getDerived().RebuildIncompleteArrayType(ElementType,
5702 T->getSizeModifier(),
5703 T->getIndexTypeCVRQualifiers(),
5704 TL.getBracketsRange());
5705 if (Result.isNull())
5706 return QualType();
5707 }
5708
5709 IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result);
5710 NewTL.setLBracketLoc(TL.getLBracketLoc());
5711 NewTL.setRBracketLoc(TL.getRBracketLoc());
5712 NewTL.setSizeExpr(nullptr);
5713
5714 return Result;
5715}
5716
5717template<typename Derived>
5718QualType
5719TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB,
5720 VariableArrayTypeLoc TL) {
5721 const VariableArrayType *T = TL.getTypePtr();
5722 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5723 if (ElementType.isNull())
5724 return QualType();
5725
5726 ExprResult SizeResult;
5727 {
5728 EnterExpressionEvaluationContext Context(
5730 SizeResult = getDerived().TransformExpr(T->getSizeExpr());
5731 }
5732 if (SizeResult.isInvalid())
5733 return QualType();
5734 SizeResult =
5735 SemaRef.ActOnFinishFullExpr(SizeResult.get(), /*DiscardedValue*/ false);
5736 if (SizeResult.isInvalid())
5737 return QualType();
5738
5739 Expr *Size = SizeResult.get();
5740
5741 QualType Result = TL.getType();
5742 if (getDerived().AlwaysRebuild() ||
5743 ElementType != T->getElementType() ||
5744 Size != T->getSizeExpr()) {
5745 Result = getDerived().RebuildVariableArrayType(ElementType,
5746 T->getSizeModifier(),
5747 Size,
5748 T->getIndexTypeCVRQualifiers(),
5749 TL.getBracketsRange());
5750 if (Result.isNull())
5751 return QualType();
5752 }
5753
5754 // We might have constant size array now, but fortunately it has the same
5755 // location layout.
5756 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5757 NewTL.setLBracketLoc(TL.getLBracketLoc());
5758 NewTL.setRBracketLoc(TL.getRBracketLoc());
5759 NewTL.setSizeExpr(Size);
5760
5761 return Result;
5762}
5763
5764template<typename Derived>
5765QualType
5766TreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB,
5767 DependentSizedArrayTypeLoc TL) {
5768 const DependentSizedArrayType *T = TL.getTypePtr();
5769 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5770 if (ElementType.isNull())
5771 return QualType();
5772
5773 // Array bounds are constant expressions.
5774 EnterExpressionEvaluationContext Unevaluated(
5776
5777 // If we have a VLA then it won't be a constant.
5778 SemaRef.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
5779
5780 // Prefer the expression from the TypeLoc; the other may have been uniqued.
5781 Expr *origSize = TL.getSizeExpr();
5782 if (!origSize) origSize = T->getSizeExpr();
5783
5784 ExprResult sizeResult
5785 = getDerived().TransformExpr(origSize);
5786 sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
5787 if (sizeResult.isInvalid())
5788 return QualType();
5789
5790 Expr *size = sizeResult.get();
5791
5792 QualType Result = TL.getType();
5793 if (getDerived().AlwaysRebuild() ||
5794 ElementType != T->getElementType() ||
5795 size != origSize) {
5796 Result = getDerived().RebuildDependentSizedArrayType(ElementType,
5797 T->getSizeModifier(),
5798 size,
5799 T->getIndexTypeCVRQualifiers(),
5800 TL.getBracketsRange());
5801 if (Result.isNull())
5802 return QualType();
5803 }
5804
5805 // We might have any sort of array type now, but fortunately they
5806 // all have the same location layout.
5807 ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
5808 NewTL.setLBracketLoc(TL.getLBracketLoc());
5809 NewTL.setRBracketLoc(TL.getRBracketLoc());
5810 NewTL.setSizeExpr(size);
5811
5812 return Result;
5813}
5814
5815template <typename Derived>
5816QualType TreeTransform<Derived>::TransformDependentVectorType(
5817 TypeLocBuilder &TLB, DependentVectorTypeLoc TL) {
5818 const DependentVectorType *T = TL.getTypePtr();
5819 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5820 if (ElementType.isNull())
5821 return QualType();
5822
5823 EnterExpressionEvaluationContext Unevaluated(
5825
5826 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
5827 Size = SemaRef.ActOnConstantExpression(Size);
5828 if (Size.isInvalid())
5829 return QualType();
5830
5831 QualType Result = TL.getType();
5832 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
5833 Size.get() != T->getSizeExpr()) {
5834 Result = getDerived().RebuildDependentVectorType(
5835 ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
5836 if (Result.isNull())
5837 return QualType();
5838 }
5839
5840 // Result might be dependent or not.
5841 if (isa<DependentVectorType>(Result)) {
5842 DependentVectorTypeLoc NewTL =
5843 TLB.push<DependentVectorTypeLoc>(Result);
5844 NewTL.setNameLoc(TL.getNameLoc());
5845 } else {
5846 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
5847 NewTL.setNameLoc(TL.getNameLoc());
5848 }
5849
5850 return Result;
5851}
5852
5853template<typename Derived>
5854QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
5855 TypeLocBuilder &TLB,
5856 DependentSizedExtVectorTypeLoc TL) {
5857 const DependentSizedExtVectorType *T = TL.getTypePtr();
5858
5859 // FIXME: ext vector locs should be nested
5860 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
5861 if (ElementType.isNull())
5862 return QualType();
5863
5864 // Vector sizes are constant expressions.
5865 EnterExpressionEvaluationContext Unevaluated(
5867
5868 ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
5869 Size = SemaRef.ActOnConstantExpression(Size);
5870 if (Size.isInvalid())
5871 return QualType();
5872
5873 QualType Result = TL.getType();
5874 if (getDerived().AlwaysRebuild() ||
5875 ElementType != T->getElementType() ||
5876 Size.get() != T->getSizeExpr()) {
5877 Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
5878 Size.get(),
5879 T->getAttributeLoc());
5880 if (Result.isNull())
5881 return QualType();
5882 }
5883
5884 // Result might be dependent or not.
5885 if (isa<DependentSizedExtVectorType>(Result)) {
5886 DependentSizedExtVectorTypeLoc NewTL
5887 = TLB.push<DependentSizedExtVectorTypeLoc>(Result);
5888 NewTL.setNameLoc(TL.getNameLoc());
5889 } else {
5890 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
5891 NewTL.setNameLoc(TL.getNameLoc());
5892 }
5893
5894 return Result;
5895}
5896
5897template <typename Derived>
5898QualType
5899TreeTransform<Derived>::TransformConstantMatrixType(TypeLocBuilder &TLB,
5900 ConstantMatrixTypeLoc TL) {
5901 const ConstantMatrixType *T = TL.getTypePtr();
5902 QualType ElementType = getDerived().TransformType(T->getElementType());
5903 if (ElementType.isNull())
5904 return QualType();
5905
5906 QualType Result = TL.getType();
5907 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType()) {
5908 Result = getDerived().RebuildConstantMatrixType(
5909 ElementType, T->getNumRows(), T->getNumColumns());
5910 if (Result.isNull())
5911 return QualType();
5912 }
5913
5914 ConstantMatrixTypeLoc NewTL = TLB.push<ConstantMatrixTypeLoc>(Result);
5915 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5916 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
5917 NewTL.setAttrRowOperand(TL.getAttrRowOperand());
5918 NewTL.setAttrColumnOperand(TL.getAttrColumnOperand());
5919
5920 return Result;
5921}
5922
5923template <typename Derived>
5924QualType TreeTransform<Derived>::TransformDependentSizedMatrixType(
5925 TypeLocBuilder &TLB, DependentSizedMatrixTypeLoc TL) {
5926 const DependentSizedMatrixType *T = TL.getTypePtr();
5927
5928 QualType ElementType = getDerived().TransformType(T->getElementType());
5929 if (ElementType.isNull()) {
5930 return QualType();
5931 }
5932
5933 // Matrix dimensions are constant expressions.
5934 EnterExpressionEvaluationContext Unevaluated(
5936
5937 Expr *origRows = TL.getAttrRowOperand();
5938 if (!origRows)
5939 origRows = T->getRowExpr();
5940 Expr *origColumns = TL.getAttrColumnOperand();
5941 if (!origColumns)
5942 origColumns = T->getColumnExpr();
5943
5944 ExprResult rowResult = getDerived().TransformExpr(origRows);
5945 rowResult = SemaRef.ActOnConstantExpression(rowResult);
5946 if (rowResult.isInvalid())
5947 return QualType();
5948
5949 ExprResult columnResult = getDerived().TransformExpr(origColumns);
5950 columnResult = SemaRef.ActOnConstantExpression(columnResult);
5951 if (columnResult.isInvalid())
5952 return QualType();
5953
5954 Expr *rows = rowResult.get();
5955 Expr *columns = columnResult.get();
5956
5957 QualType Result = TL.getType();
5958 if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
5959 rows != origRows || columns != origColumns) {
5960 Result = getDerived().RebuildDependentSizedMatrixType(
5961 ElementType, rows, columns, T->getAttributeLoc());
5962
5963 if (Result.isNull())
5964 return QualType();
5965 }
5966
5967 // We might have any sort of matrix type now, but fortunately they
5968 // all have the same location layout.
5969 MatrixTypeLoc NewTL = TLB.push<MatrixTypeLoc>(Result);
5970 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
5971 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
5972 NewTL.setAttrRowOperand(rows);
5973 NewTL.setAttrColumnOperand(columns);
5974 return Result;
5975}
5976
5977template <typename Derived>
5978QualType TreeTransform<Derived>::TransformDependentAddressSpaceType(
5979 TypeLocBuilder &TLB, DependentAddressSpaceTypeLoc TL) {
5980 const DependentAddressSpaceType *T = TL.getTypePtr();
5981
5982 QualType pointeeType =
5983 getDerived().TransformType(TLB, TL.getPointeeTypeLoc());
5984
5985 if (pointeeType.isNull())
5986 return QualType();
5987
5988 // Address spaces are constant expressions.
5989 EnterExpressionEvaluationContext Unevaluated(
5991
5992 ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
5993 AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
5994 if (AddrSpace.isInvalid())
5995 return QualType();
5996
5997 QualType Result = TL.getType();
5998 if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
5999 AddrSpace.get() != T->getAddrSpaceExpr()) {
6000 Result = getDerived().RebuildDependentAddressSpaceType(
6001 pointeeType, AddrSpace.get(), T->getAttributeLoc());
6002 if (Result.isNull())
6003 return QualType();
6004 }
6005
6006 // Result might be dependent or not.
6007 if (isa<DependentAddressSpaceType>(Result)) {
6008 DependentAddressSpaceTypeLoc NewTL =
6009 TLB.push<DependentAddressSpaceTypeLoc>(Result);
6010
6011 NewTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
6012 NewTL.setAttrExprOperand(TL.getAttrExprOperand());
6013 NewTL.setAttrNameLoc(TL.getAttrNameLoc());
6014
6015 } else {
6016 TLB.TypeWasModifiedSafely(Result);
6017 }
6018
6019 return Result;
6020}
6021
6022template <typename Derived>
6023QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
6024 VectorTypeLoc TL) {
6025 const VectorType *T = TL.getTypePtr();
6026 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6027 if (ElementType.isNull())
6028 return QualType();
6029
6030 QualType Result = TL.getType();
6031 if (getDerived().AlwaysRebuild() ||
6032 ElementType != T->getElementType()) {
6033 Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
6034 T->getVectorKind());
6035 if (Result.isNull())
6036 return QualType();
6037 }
6038
6039 VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
6040 NewTL.setNameLoc(TL.getNameLoc());
6041
6042 return Result;
6043}
6044
6045template<typename Derived>
6046QualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB,
6047 ExtVectorTypeLoc TL) {
6048 const VectorType *T = TL.getTypePtr();
6049 QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
6050 if (ElementType.isNull())
6051 return QualType();
6052
6053 QualType Result = TL.getType();
6054 if (getDerived().AlwaysRebuild() ||
6055 ElementType != T->getElementType()) {
6056 Result = getDerived().RebuildExtVectorType(ElementType,
6057 T->getNumElements(),
6058 /*FIXME*/ SourceLocation());
6059 if (Result.isNull())
6060 return QualType();
6061 }
6062
6063 ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
6064 NewTL.setNameLoc(TL.getNameLoc());
6065
6066 return Result;
6067}
6068
6069template <typename Derived>
6071 ParmVarDecl *OldParm, int indexAdjustment,
6072 std::optional<unsigned> NumExpansions, bool ExpectParameterPack) {
6073 TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
6074 TypeSourceInfo *NewDI = nullptr;
6075
6076 if (NumExpansions && isa<PackExpansionType>(OldDI->getType())) {
6077 // If we're substituting into a pack expansion type and we know the
6078 // length we want to expand to, just substitute for the pattern.
6079 TypeLoc OldTL = OldDI->getTypeLoc();
6080 PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
6081
6082 TypeLocBuilder TLB;
6083 TypeLoc NewTL = OldDI->getTypeLoc();
6084 TLB.reserve(NewTL.getFullDataSize());
6085
6086 QualType Result = getDerived().TransformType(TLB,
6087 OldExpansionTL.getPatternLoc());
6088 if (Result.isNull())
6089 return nullptr;
6090
6091 Result = RebuildPackExpansionType(Result,
6092 OldExpansionTL.getPatternLoc().getSourceRange(),
6093 OldExpansionTL.getEllipsisLoc(),
6094 NumExpansions);
6095 if (Result.isNull())
6096 return nullptr;
6097
6098 PackExpansionTypeLoc NewExpansionTL
6099 = TLB.push<PackExpansionTypeLoc>(Result);
6100 NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
6101 NewDI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
6102 } else
6103 NewDI = getDerived().TransformType(OldDI);
6104 if (!NewDI)
6105 return nullptr;
6106
6107 if (NewDI == OldDI && indexAdjustment == 0)
6108 return OldParm;
6109
6110 ParmVarDecl *newParm = ParmVarDecl::Create(SemaRef.Context,
6111 OldParm->getDeclContext(),
6112 OldParm->getInnerLocStart(),
6113 OldParm->getLocation(),
6114 OldParm->getIdentifier(),
6115 NewDI->getType(),
6116 NewDI,
6117 OldParm->getStorageClass(),
6118 /* DefArg */ nullptr);
6119 newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
6120 OldParm->getFunctionScopeIndex() + indexAdjustment);
6121 transformedLocalDecl(OldParm, {newParm});
6122 return newParm;
6123}
6124
6125template <typename Derived>
6128 const QualType *ParamTypes,
6129 const FunctionProtoType::ExtParameterInfo *ParamInfos,
6130 SmallVectorImpl<QualType> &OutParamTypes,
6133 unsigned *LastParamTransformed) {
6134 int indexAdjustment = 0;
6135
6136 unsigned NumParams = Params.size();
6137 for (unsigned i = 0; i != NumParams; ++i) {
6138 if (LastParamTransformed)
6139 *LastParamTransformed = i;
6140 if (ParmVarDecl *OldParm = Params[i]) {
6141 assert(OldParm->getFunctionScopeIndex() == i);
6142
6143 std::optional<unsigned> NumExpansions;
6144 ParmVarDecl *NewParm = nullptr;
6145 if (OldParm->isParameterPack()) {
6146 // We have a function parameter pack that may need to be expanded.
6148
6149 // Find the parameter packs that could be expanded.
6150 TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
6152 TypeLoc Pattern = ExpansionTL.getPatternLoc();
6153 SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
6154
6155 // Determine whether we should expand the parameter packs.
6156 bool ShouldExpand = false;
6157 bool RetainExpansion = false;
6158 std::optional<unsigned> OrigNumExpansions;
6159 if (Unexpanded.size() > 0) {
6160 OrigNumExpansions = ExpansionTL.getTypePtr()->getNumExpansions();
6161 NumExpansions = OrigNumExpansions;
6162 if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
6163 Pattern.getSourceRange(),
6164 Unexpanded,
6165 ShouldExpand,
6166 RetainExpansion,
6167 NumExpansions)) {
6168 return true;
6169 }
6170 } else {
6171#ifndef NDEBUG
6172 const AutoType *AT =
6173 Pattern.getType().getTypePtr()->getContainedAutoType();
6174 assert((AT && (!AT->isDeduced() || AT->getDeducedType().isNull())) &&
6175 "Could not find parameter packs or undeduced auto type!");
6176#endif
6177 }
6178
6179 if (ShouldExpand) {
6180 // Expand the function parameter pack into multiple, separate
6181 // parameters.
6182 getDerived().ExpandingFunctionParameterPack(OldParm);
6183 for (unsigned I = 0; I != *NumExpansions; ++I) {
6184 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
6185 ParmVarDecl *NewParm
6186 = getDerived().TransformFunctionTypeParam(OldParm,
6187 indexAdjustment++,
6188 OrigNumExpansions,
6189 /*ExpectParameterPack=*/false);
6190 if (!NewParm)
6191 return true;
6192
6193 if (ParamInfos)
6194 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6195 OutParamTypes.push_back(NewParm->getType());
6196 if (PVars)
6197 PVars->push_back(NewParm);
6198 }
6199
6200 // If we're supposed to retain a pack expansion, do so by temporarily
6201 // forgetting the partially-substituted parameter pack.
6202 if (RetainExpansion) {
6203 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6204 ParmVarDecl *NewParm
6205 = getDerived().TransformFunctionTypeParam(OldParm,
6206 indexAdjustment++,
6207 OrigNumExpansions,
6208 /*ExpectParameterPack=*/false);
6209 if (!NewParm)
6210 return true;
6211
6212 if (ParamInfos)
6213 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6214 OutParamTypes.push_back(NewParm->getType());
6215 if (PVars)
6216 PVars->push_back(NewParm);
6217 }
6218
6219 // The next parameter should have the same adjustment as the
6220 // last thing we pushed, but we post-incremented indexAdjustment
6221 // on every push. Also, if we push nothing, the adjustment should
6222 // go down by one.
6223 indexAdjustment--;
6224
6225 // We're done with the pack expansion.
6226 continue;
6227 }
6228
6229 // We'll substitute the parameter now without expanding the pack
6230 // expansion.
6231 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6232 NewParm = getDerived().TransformFunctionTypeParam(OldParm,
6233 indexAdjustment,
6234 NumExpansions,
6235 /*ExpectParameterPack=*/true);
6236 assert(NewParm->isParameterPack() &&
6237 "Parameter pack no longer a parameter pack after "
6238 "transformation.");
6239 } else {
6240 NewParm = getDerived().TransformFunctionTypeParam(
6241 OldParm, indexAdjustment, std::nullopt,
6242 /*ExpectParameterPack=*/false);
6243 }
6244
6245 if (!NewParm)
6246 return true;
6247
6248 if (ParamInfos)
6249 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6250 OutParamTypes.push_back(NewParm->getType());
6251 if (PVars)
6252 PVars->push_back(NewParm);
6253 continue;
6254 }
6255
6256 // Deal with the possibility that we don't have a parameter
6257 // declaration for this parameter.
6258 assert(ParamTypes);
6259 QualType OldType = ParamTypes[i];
6260 bool IsPackExpansion = false;
6261 std::optional<unsigned> NumExpansions;
6262 QualType NewType;
6263 if (const PackExpansionType *Expansion
6264 = dyn_cast<PackExpansionType>(OldType)) {
6265 // We have a function parameter pack that may need to be expanded.
6266 QualType Pattern = Expansion->getPattern();
6268 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
6269
6270 // Determine whether we should expand the parameter packs.
6271 bool ShouldExpand = false;
6272 bool RetainExpansion = false;
6273 if (getDerived().TryExpandParameterPacks(Loc, SourceRange(),
6274 Unexpanded,
6275 ShouldExpand,
6276 RetainExpansion,
6277 NumExpansions)) {
6278 return true;
6279 }
6280
6281 if (ShouldExpand) {
6282 // Expand the function parameter pack into multiple, separate
6283 // parameters.
6284 for (unsigned I = 0; I != *NumExpansions; ++I) {
6285 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
6286 QualType NewType = getDerived().TransformType(Pattern);
6287 if (NewType.isNull())
6288 return true;
6289
6290 if (NewType->containsUnexpandedParameterPack()) {
6291 NewType = getSema().getASTContext().getPackExpansionType(
6292 NewType, std::nullopt);
6293
6294 if (NewType.isNull())
6295 return true;
6296 }
6297
6298 if (ParamInfos)
6299 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6300 OutParamTypes.push_back(NewType);
6301 if (PVars)
6302 PVars->push_back(nullptr);
6303 }
6304
6305 // We're done with the pack expansion.
6306 continue;
6307 }
6308
6309 // If we're supposed to retain a pack expansion, do so by temporarily
6310 // forgetting the partially-substituted parameter pack.
6311 if (RetainExpansion) {
6312 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6313 QualType NewType = getDerived().TransformType(Pattern);
6314 if (NewType.isNull())
6315 return true;
6316
6317 if (ParamInfos)
6318 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6319 OutParamTypes.push_back(NewType);
6320 if (PVars)
6321 PVars->push_back(nullptr);
6322 }
6323
6324 // We'll substitute the parameter now without expanding the pack
6325 // expansion.
6326 OldType = Expansion->getPattern();
6327 IsPackExpansion = true;
6328 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6329 NewType = getDerived().TransformType(OldType);
6330 } else {
6331 NewType = getDerived().TransformType(OldType);
6332 }
6333
6334 if (NewType.isNull())
6335 return true;
6336
6337 if (IsPackExpansion)
6338 NewType = getSema().Context.getPackExpansionType(NewType,
6339 NumExpansions);
6340
6341 if (ParamInfos)
6342 PInfos.set(OutParamTypes.size(), ParamInfos[i]);
6343 OutParamTypes.push_back(NewType);
6344 if (PVars)
6345 PVars->push_back(nullptr);
6346 }
6347
6348#ifndef NDEBUG
6349 if (PVars) {
6350 for (unsigned i = 0, e = PVars->size(); i != e; ++i)
6351 if (ParmVarDecl *parm = (*PVars)[i])
6352 assert(parm->getFunctionScopeIndex() == i);
6353 }
6354#endif
6355
6356 return false;
6357}
6358
6359template<typename Derived>
6363 SmallVector<QualType, 4> ExceptionStorage;
6364 return getDerived().TransformFunctionProtoType(
6365 TLB, TL, nullptr, Qualifiers(),
6366 [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
6367 return getDerived().TransformExceptionSpec(TL.getBeginLoc(), ESI,
6368 ExceptionStorage, Changed);
6369 });
6370}
6371
6372template<typename Derived> template<typename Fn>
6374 TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
6375 Qualifiers ThisTypeQuals, Fn TransformExceptionSpec) {
6376
6377 // Transform the parameters and return type.
6378 //
6379 // We are required to instantiate the params and return type in source order.
6380 // When the function has a trailing return type, we instantiate the
6381 // parameters before the return type, since the return type can then refer
6382 // to the parameters themselves (via decltype, sizeof, etc.).
6383 //
6384 SmallVector<QualType, 4> ParamTypes;
6386 Sema::ExtParameterInfoBuilder ExtParamInfos;
6387 const FunctionProtoType *T = TL.getTypePtr();
6388
6389 QualType ResultType;
6390
6391 if (T->hasTrailingReturn()) {
6392 if (getDerived().TransformFunctionTypeParams(
6393 TL.getBeginLoc(), TL.getParams(),
6396 ParamTypes, &ParamDecls, ExtParamInfos))
6397 return QualType();
6398
6399 {
6400 // C++11 [expr.prim.general]p3:
6401 // If a declaration declares a member function or member function
6402 // template of a class X, the expression this is a prvalue of type
6403 // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
6404 // and the end of the function-definition, member-declarator, or
6405 // declarator.
6406 auto *RD = dyn_cast<CXXRecordDecl>(SemaRef.getCurLexicalContext());
6407 Sema::CXXThisScopeRAII ThisScope(
6408 SemaRef, !ThisContext && RD ? RD : ThisContext, ThisTypeQuals);
6409
6410 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6411 if (ResultType.isNull())
6412 return QualType();
6413 }
6414 }
6415 else {
6416 ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6417 if (ResultType.isNull())
6418 return QualType();
6419
6420 if (getDerived().TransformFunctionTypeParams(
6421 TL.getBeginLoc(), TL.getParams(),
6424 ParamTypes, &ParamDecls, ExtParamInfos))
6425 return QualType();
6426 }
6427
6429
6430 bool EPIChanged = false;
6431 if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
6432 return QualType();
6433
6434 // Handle extended parameter information.
6435 if (auto NewExtParamInfos =
6436 ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
6437 if (!EPI.ExtParameterInfos ||
6439 llvm::ArrayRef(NewExtParamInfos, ParamTypes.size())) {
6440 EPIChanged = true;
6441 }
6442 EPI.ExtParameterInfos = NewExtParamInfos;
6443 } else if (EPI.ExtParameterInfos) {
6444 EPIChanged = true;
6445 EPI.ExtParameterInfos = nullptr;
6446 }
6447
6448 // Transform any function effects with unevaluated conditions.
6449 // Hold this set in a local for the rest of this function, since EPI
6450 // may need to hold a FunctionEffectsRef pointing into it.
6451 std::optional<FunctionEffectSet> NewFX;
6452 if (ArrayRef FXConds = EPI.FunctionEffects.conditions(); !FXConds.empty()) {
6453 NewFX.emplace();
6456
6457 for (const FunctionEffectWithCondition &PrevEC : EPI.FunctionEffects) {
6458 FunctionEffectWithCondition NewEC = PrevEC;
6459 if (Expr *CondExpr = PrevEC.Cond.getCondition()) {
6460 ExprResult NewExpr = getDerived().TransformExpr(CondExpr);
6461 if (NewExpr.isInvalid())
6462 return QualType();
6463 std::optional<FunctionEffectMode> Mode =
6464 SemaRef.ActOnEffectExpression(NewExpr.get(), PrevEC.Effect.name());
6465 if (!Mode)
6466 return QualType();
6467
6468 // The condition expression has been transformed, and re-evaluated.
6469 // It may or may not have become constant.
6470 switch (*Mode) {
6472 NewEC.Cond = {};
6473 break;
6475 NewEC.Effect = FunctionEffect(PrevEC.Effect.oppositeKind());
6476 NewEC.Cond = {};
6477 break;
6479 NewEC.Cond = EffectConditionExpr(NewExpr.get());
6480 break;
6482 llvm_unreachable(
6483 "FunctionEffectMode::None shouldn't be possible here");
6484 }
6485 }
6486 if (!SemaRef.diagnoseConflictingFunctionEffect(*NewFX, NewEC,
6487 TL.getBeginLoc())) {
6489 NewFX->insert(NewEC, Errs);
6490 assert(Errs.empty());
6491 }
6492 }
6493 EPI.FunctionEffects = *NewFX;
6494 EPIChanged = true;
6495 }
6496
6497 QualType Result = TL.getType();
6498 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
6499 T->getParamTypes() != llvm::ArrayRef(ParamTypes) || EPIChanged) {
6500 Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
6501 if (Result.isNull())
6502 return QualType();
6503 }
6504
6507 NewTL.setLParenLoc(TL.getLParenLoc());
6508 NewTL.setRParenLoc(TL.getRParenLoc());
6511 for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
6512 NewTL.setParam(i, ParamDecls[i]);
6513
6514 return Result;
6515}
6516
6517template<typename Derived>
6520 SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
6521 assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
6522
6523 // Instantiate a dynamic noexcept expression, if any.
6524 if (isComputedNoexcept(ESI.Type)) {
6525 // Update this scrope because ContextDecl in Sema will be used in
6526 // TransformExpr.
6527 auto *Method = dyn_cast_if_present<CXXMethodDecl>(ESI.SourceTemplate);
6528 Sema::CXXThisScopeRAII ThisScope(
6529 SemaRef, Method ? Method->getParent() : nullptr,
6530 Method ? Method->getMethodQualifiers() : Qualifiers{},
6531 Method != nullptr);
6534 ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
6535 if (NoexceptExpr.isInvalid())
6536 return true;
6537
6539 NoexceptExpr =
6540 getSema().ActOnNoexceptSpec(NoexceptExpr.get(), EST);
6541 if (NoexceptExpr.isInvalid())
6542 return true;
6543
6544 if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
6545 Changed = true;
6546 ESI.NoexceptExpr = NoexceptExpr.get();
6547 ESI.Type = EST;
6548 }
6549
6550 if (ESI.Type != EST_Dynamic)
6551 return false;
6552
6553 // Instantiate a dynamic exception specification's type.
6554 for (QualType T : ESI.Exceptions) {
6555 if (const PackExpansionType *PackExpansion =
6557 Changed = true;
6558
6559 // We have a pack expansion. Instantiate it.
6561 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6562 Unexpanded);
6563 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6564
6565 // Determine whether the set of unexpanded parameter packs can and
6566 // should
6567 // be expanded.
6568 bool Expand = false;
6569 bool RetainExpansion = false;
6570 std::optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
6571 // FIXME: Track the location of the ellipsis (and track source location
6572 // information for the types in the exception specification in general).
6573 if (getDerived().TryExpandParameterPacks(
6574 Loc, SourceRange(), Unexpanded, Expand,
6575 RetainExpansion, NumExpansions))
6576 return true;
6577
6578 if (!Expand) {
6579 // We can't expand this pack expansion into separate arguments yet;
6580 // just substitute into the pattern and create a new pack expansion
6581 // type.
6582 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6583 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6584 if (U.isNull())
6585 return true;
6586
6587 U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
6588 Exceptions.push_back(U);
6589 continue;
6590 }
6591
6592 // Substitute into the pack expansion pattern for each slice of the
6593 // pack.
6594 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6595 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
6596
6597 QualType U = getDerived().TransformType(PackExpansion->getPattern());
6598 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6599 return true;
6600
6601 Exceptions.push_back(U);
6602 }
6603 } else {
6604 QualType U = getDerived().TransformType(T);
6605 if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
6606 return true;
6607 if (T != U)
6608 Changed = true;
6609
6610 Exceptions.push_back(U);
6611 }
6612 }
6613
6614 ESI.Exceptions = Exceptions;
6615 if (ESI.Exceptions.empty())
6616 ESI.Type = EST_DynamicNone;
6617 return false;
6618}
6619
6620template<typename Derived>
6622 TypeLocBuilder &TLB,
6624 const FunctionNoProtoType *T = TL.getTypePtr();
6625 QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
6626 if (ResultType.isNull())
6627 return QualType();
6628
6629 QualType Result = TL.getType();
6630 if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
6631 Result = getDerived().RebuildFunctionNoProtoType(ResultType);
6632
6635 NewTL.setLParenLoc(TL.getLParenLoc());
6636 NewTL.setRParenLoc(TL.getRParenLoc());
6638
6639 return Result;
6640}
6641
6642template <typename Derived>
6643QualType TreeTransform<Derived>::TransformUnresolvedUsingType(
6644 TypeLocBuilder &TLB, UnresolvedUsingTypeLoc TL) {
6645 const UnresolvedUsingType *T = TL.getTypePtr();
6646 Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
6647 if (!D)
6648 return QualType();
6649
6650 QualType Result = TL.getType();
6651 if (getDerived().AlwaysRebuild() || D != T->getDecl()) {
6652 Result = getDerived().RebuildUnresolvedUsingType(TL.getNameLoc(), D);
6653 if (Result.isNull())
6654 return QualType();
6655 }
6656
6657 // We might get an arbitrary type spec type back. We should at
6658 // least always get a type spec type, though.
6659 TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result);
6660 NewTL.setNameLoc(TL.getNameLoc());
6661
6662 return Result;
6663}
6664
6665template <typename Derived>
6666QualType TreeTransform<Derived>::TransformUsingType(TypeLocBuilder &TLB,
6667 UsingTypeLoc TL) {
6668 const UsingType *T = TL.getTypePtr();
6669
6670 auto *Found = cast_or_null<UsingShadowDecl>(getDerived().TransformDecl(
6671 TL.getLocalSourceRange().getBegin(), T->getFoundDecl()));
6672 if (!Found)
6673 return QualType();
6674
6675 QualType Underlying = getDerived().TransformType(T->desugar());
6676 if (Underlying.isNull())
6677 return QualType();
6678
6679 QualType Result = TL.getType();
6680 if (getDerived().AlwaysRebuild() || Found != T->getFoundDecl() ||
6681 Underlying != T->getUnderlyingType()) {
6682 Result = getDerived().RebuildUsingType(Found, Underlying);
6683 if (Result.isNull())
6684 return QualType();
6685 }
6686
6687 TLB.pushTypeSpec(Result).setNameLoc(TL.getNameLoc());
6688 return Result;
6689}
6690
6691template<typename Derived>
6692QualType TreeTransform<Derived>::TransformTypedefType(TypeLocBuilder &TLB,
6693 TypedefTypeLoc TL) {
6694 const TypedefType *T = TL.getTypePtr();
6695 TypedefNameDecl *Typedef
6696 = cast_or_null<TypedefNameDecl>(getDerived().TransformDecl(TL.getNameLoc(),
6697 T->getDecl()));
6698 if (!Typedef)
6699 return QualType();
6700
6701 QualType Result = TL.getType();
6702 if (getDerived().AlwaysRebuild() ||
6703 Typedef != T->getDecl()) {
6704 Result = getDerived().RebuildTypedefType(Typedef);
6705 if (Result.isNull())
6706 return QualType();
6707 }
6708
6709 TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result);
6710 NewTL.setNameLoc(TL.getNameLoc());
6711
6712 return Result;
6713}
6714
6715template<typename Derived>
6716QualType TreeTransform<Derived>::TransformTypeOfExprType(TypeLocBuilder &TLB,
6717 TypeOfExprTypeLoc TL) {
6718 // typeof expressions are not potentially evaluated contexts
6719 EnterExpressionEvaluationContext Unevaluated(
6722
6723 ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
6724 if (E.isInvalid())
6725 return QualType();
6726
6727 E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
6728 if (E.isInvalid())
6729 return QualType();
6730
6731 QualType Result = TL.getType();
6732 TypeOfKind Kind = Result->castAs<TypeOfExprType>()->getKind();
6733 if (getDerived().AlwaysRebuild() || E.get() != TL.getUnderlyingExpr()) {
6734 Result =
6735 getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc(), Kind);
6736 if (Result.isNull())
6737 return QualType();
6738 }
6739
6740 TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
6741 NewTL.setTypeofLoc(TL.getTypeofLoc());
6742 NewTL.setLParenLoc(TL.getLParenLoc());
6743 NewTL.setRParenLoc(TL.getRParenLoc());
6744
6745 return Result;
6746}
6747
6748template<typename Derived>
6749QualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB,
6750 TypeOfTypeLoc TL) {
6751 TypeSourceInfo* Old_Under_TI = TL.getUnmodifiedTInfo();
6752 TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
6753 if (!New_Under_TI)
6754 return QualType();
6755
6756 QualType Result = TL.getType();
6757 TypeOfKind Kind = Result->castAs<TypeOfType>()->getKind();
6758 if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
6759 Result = getDerived().RebuildTypeOfType(New_Under_TI->getType(), Kind);
6760 if (Result.isNull())
6761 return QualType();
6762 }
6763
6764 TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
6765 NewTL.setTypeofLoc(TL.getTypeofLoc());
6766 NewTL.setLParenLoc(TL.getLParenLoc());
6767 NewTL.setRParenLoc(TL.getRParenLoc());
6768 NewTL.setUnmodifiedTInfo(New_Under_TI);
6769
6770 return Result;
6771}
6772
6773template<typename Derived>
6774QualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB,
6775 DecltypeTypeLoc TL) {
6776 const DecltypeType *T = TL.getTypePtr();
6777
6778 // decltype expressions are not potentially evaluated contexts
6779 EnterExpressionEvaluationContext Unevaluated(
6782
6783 ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
6784 if (E.isInvalid())
6785 return QualType();
6786
6787 E = getSema().ActOnDecltypeExpression(E.get());
6788 if (E.isInvalid())
6789 return QualType();
6790
6791 QualType Result = TL.getType();
6792 if (getDerived().AlwaysRebuild() ||
6793 E.get() != T->getUnderlyingExpr()) {
6794 Result = getDerived().RebuildDecltypeType(E.get(), TL.getDecltypeLoc());
6795 if (Result.isNull())
6796 return QualType();
6797 }
6798 else E.get();
6799
6800 DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
6801 NewTL.setDecltypeLoc(TL.getDecltypeLoc());
6802 NewTL.setRParenLoc(TL.getRParenLoc());
6803 return Result;
6804}
6805
6806template <typename Derived>
6807QualType
6808TreeTransform<Derived>::TransformPackIndexingType(TypeLocBuilder &TLB,
6809 PackIndexingTypeLoc TL) {
6810 // Transform the index
6811 ExprResult IndexExpr;
6812 {
6813 EnterExpressionEvaluationContext ConstantContext(
6815
6816 IndexExpr = getDerived().TransformExpr(TL.getIndexExpr());
6817 if (IndexExpr.isInvalid())
6818 return QualType();
6819 }
6820 QualType Pattern = TL.getPattern();
6821
6822 const PackIndexingType *PIT = TL.getTypePtr();
6823 SmallVector<QualType, 5> SubtitutedTypes;
6824 llvm::ArrayRef<QualType> Types = PIT->getExpansions();
6825
6826 bool NotYetExpanded = Types.empty();
6827 bool FullySubstituted = true;
6828
6829 if (Types.empty() && !PIT->expandsToEmptyPack())
6830 Types = llvm::ArrayRef<QualType>(&Pattern, 1);
6831
6832 for (QualType T : Types) {
6834 QualType Transformed = getDerived().TransformType(T);
6835 if (Transformed.isNull())
6836 return QualType();
6837 SubtitutedTypes.push_back(Transformed);
6838 continue;
6839 }
6840
6842 getSema().collectUnexpandedParameterPacks(T, Unexpanded);
6843 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6844 // Determine whether the set of unexpanded parameter packs can and should
6845 // be expanded.
6846 bool ShouldExpand = true;
6847 bool RetainExpansion = false;
6848 std::optional<unsigned> OrigNumExpansions;
6849 std::optional<unsigned> NumExpansions = OrigNumExpansions;
6850 if (getDerived().TryExpandParameterPacks(TL.getEllipsisLoc(), SourceRange(),
6851 Unexpanded, ShouldExpand,
6852 RetainExpansion, NumExpansions))
6853 return QualType();
6854 if (!ShouldExpand) {
6855 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6856 // FIXME: should we keep TypeLoc for individual expansions in
6857 // PackIndexingTypeLoc?
6858 TypeSourceInfo *TI =
6859 SemaRef.getASTContext().getTrivialTypeSourceInfo(T, TL.getBeginLoc());
6860 QualType Pack = getDerived().TransformType(TLB, TI->getTypeLoc());
6861 if (Pack.isNull())
6862 return QualType();
6863 if (NotYetExpanded) {
6864 FullySubstituted = false;
6865 QualType Out = getDerived().RebuildPackIndexingType(
6866 Pack, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
6867 FullySubstituted);
6868 if (Out.isNull())
6869 return QualType();
6870
6871 PackIndexingTypeLoc Loc = TLB.push<PackIndexingTypeLoc>(Out);
6872 Loc.setEllipsisLoc(TL.getEllipsisLoc());
6873 return Out;
6874 }
6875 SubtitutedTypes.push_back(Pack);
6876 continue;
6877 }
6878 for (unsigned I = 0; I != *NumExpansions; ++I) {
6879 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
6880 QualType Out = getDerived().TransformType(T);
6881 if (Out.isNull())
6882 return QualType();
6883 SubtitutedTypes.push_back(Out);
6884 FullySubstituted &= !Out->containsUnexpandedParameterPack();
6885 }
6886 // If we're supposed to retain a pack expansion, do so by temporarily
6887 // forgetting the partially-substituted parameter pack.
6888 if (RetainExpansion) {
6889 FullySubstituted = false;
6890 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
6891 QualType Out = getDerived().TransformType(T);
6892 if (Out.isNull())
6893 return QualType();
6894 SubtitutedTypes.push_back(Out);
6895 }
6896 }
6897
6898 // A pack indexing type can appear in a larger pack expansion,
6899 // e.g. `Pack...[pack_of_indexes]...`
6900 // so we need to temporarily disable substitution of pack elements
6901 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6902 QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
6903
6904 QualType Out = getDerived().RebuildPackIndexingType(
6905 Result, IndexExpr.get(), SourceLocation(), TL.getEllipsisLoc(),
6906 FullySubstituted, SubtitutedTypes);
6907 if (Out.isNull())
6908 return Out;
6909
6910 PackIndexingTypeLoc Loc = TLB.push<PackIndexingTypeLoc>(Out);
6911 Loc.setEllipsisLoc(TL.getEllipsisLoc());
6912 return Out;
6913}
6914
6915template<typename Derived>
6916QualType TreeTransform<Derived>::TransformUnaryTransformType(
6917 TypeLocBuilder &TLB,
6918 UnaryTransformTypeLoc TL) {
6919 QualType Result = TL.getType();
6920 if (Result->isDependentType()) {
6921 const UnaryTransformType *T = TL.getTypePtr();
6922
6923 TypeSourceInfo *NewBaseTSI =
6924 getDerived().TransformType(TL.getUnderlyingTInfo());
6925 if (!NewBaseTSI)
6926 return QualType();
6927 QualType NewBase = NewBaseTSI->getType();
6928
6929 Result = getDerived().RebuildUnaryTransformType(NewBase,
6930 T->getUTTKind(),
6931 TL.getKWLoc());
6932 if (Result.isNull())
6933 return QualType();
6934 }
6935
6936 UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(Result);
6937 NewTL.setKWLoc(TL.getKWLoc());
6938 NewTL.setParensRange(TL.getParensRange());
6939 NewTL.setUnderlyingTInfo(TL.getUnderlyingTInfo());
6940 return Result;
6941}
6942
6943template<typename Derived>
6944QualType TreeTransform<Derived>::TransformDeducedTemplateSpecializationType(
6945 TypeLocBuilder &TLB, DeducedTemplateSpecializationTypeLoc TL) {
6946 const DeducedTemplateSpecializationType *T = TL.getTypePtr();
6947
6948 CXXScopeSpec SS;
6949 TemplateName TemplateName = getDerived().TransformTemplateName(
6950 SS, T->getTemplateName(), TL.getTemplateNameLoc());
6951 if (TemplateName.isNull())
6952 return QualType();
6953
6954 QualType OldDeduced = T->getDeducedType();
6955 QualType NewDeduced;
6956 if (!OldDeduced.isNull()) {
6957 NewDeduced = getDerived().TransformType(OldDeduced);
6958 if (NewDeduced.isNull())
6959 return QualType();
6960 }
6961
6962 QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
6963 TemplateName, NewDeduced);
6964 if (Result.isNull())
6965 return QualType();
6966
6967 DeducedTemplateSpecializationTypeLoc NewTL =
6968 TLB.push<DeducedTemplateSpecializationTypeLoc>(Result);
6969 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
6970
6971 return Result;
6972}
6973
6974template<typename Derived>
6975QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
6976 RecordTypeLoc TL) {
6977 const RecordType *T = TL.getTypePtr();
6978 RecordDecl *Record
6979 = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
6980 T->getDecl()));
6981 if (!Record)
6982 return QualType();
6983
6984 QualType Result = TL.getType();
6985 if (getDerived().AlwaysRebuild() ||
6986 Record != T->getDecl()) {
6987 Result = getDerived().RebuildRecordType(Record);
6988 if (Result.isNull())
6989 return QualType();
6990 }
6991
6992 RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result);
6993 NewTL.setNameLoc(TL.getNameLoc());
6994
6995 return Result;
6996}
6997
6998template<typename Derived>
6999QualType TreeTransform<Derived>::TransformEnumType(TypeLocBuilder &TLB,
7000 EnumTypeLoc TL) {
7001 const EnumType *T = TL.getTypePtr();
7002 EnumDecl *Enum
7003 = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
7004 T->getDecl()));
7005 if (!Enum)
7006 return QualType();
7007
7008 QualType Result = TL.getType();
7009 if (getDerived().AlwaysRebuild() ||
7010 Enum != T->getDecl()) {
7011 Result = getDerived().RebuildEnumType(Enum);
7012 if (Result.isNull())
7013 return QualType();
7014 }
7015
7016 EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result);
7017 NewTL.setNameLoc(TL.getNameLoc());
7018
7019 return Result;
7020}
7021
7022template<typename Derived>
7023QualType TreeTransform<Derived>::TransformInjectedClassNameType(
7024 TypeLocBuilder &TLB,
7025 InjectedClassNameTypeLoc TL) {
7026 Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
7027 TL.getTypePtr()->getDecl());
7028 if (!D) return QualType();
7029
7030 QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D));
7031 TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc());
7032 return T;
7033}
7034
7035template<typename Derived>
7037 TypeLocBuilder &TLB,
7039 return getDerived().TransformTemplateTypeParmType(
7040 TLB, TL,
7041 /*SuppressObjCLifetime=*/false);
7042}
7043
7044template <typename Derived>
7046 TypeLocBuilder &TLB, TemplateTypeParmTypeLoc TL, bool) {
7047 return TransformTypeSpecType(TLB, TL);
7048}
7049
7050template<typename Derived>
7051QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
7052 TypeLocBuilder &TLB,
7053 SubstTemplateTypeParmTypeLoc TL) {
7054 const SubstTemplateTypeParmType *T = TL.getTypePtr();
7055
7056 Decl *NewReplaced =
7057 getDerived().TransformDecl(TL.getNameLoc(), T->getAssociatedDecl());
7058
7059 // Substitute into the replacement type, which itself might involve something
7060 // that needs to be transformed. This only tends to occur with default
7061 // template arguments of template template parameters.
7062 TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
7063 QualType Replacement = getDerived().TransformType(T->getReplacementType());
7064 if (Replacement.isNull())
7065 return QualType();
7066
7067 QualType Result = SemaRef.Context.getSubstTemplateTypeParmType(
7068 Replacement, NewReplaced, T->getIndex(), T->getPackIndex());
7069
7070 // Propagate type-source information.
7071 SubstTemplateTypeParmTypeLoc NewTL
7072 = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
7073 NewTL.setNameLoc(TL.getNameLoc());
7074 return Result;
7075
7076}
7077
7078template<typename Derived>
7080 TypeLocBuilder &TLB,
7082 return getDerived().TransformSubstTemplateTypeParmPackType(
7083 TLB, TL, /*SuppressObjCLifetime=*/false);
7084}
7085
7086template <typename Derived>
7089 return TransformTypeSpecType(TLB, TL);
7090}
7091
7092template<typename Derived>
7094 TypeLocBuilder &TLB,
7097
7098 // The nested-name-specifier never matters in a TemplateSpecializationType,
7099 // because we can't have a dependent nested-name-specifier anyway.
7100 CXXScopeSpec SS;
7101 TemplateName Template
7102 = getDerived().TransformTemplateName(SS, T->getTemplateName(),
7103 TL.getTemplateNameLoc());
7104 if (Template.isNull())
7105 return QualType();
7106
7107 return getDerived().TransformTemplateSpecializationType(TLB, TL, Template);
7108}
7109
7110template<typename Derived>
7112 AtomicTypeLoc TL) {
7113 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7114 if (ValueType.isNull())
7115 return QualType();
7116
7117 QualType Result = TL.getType();
7118 if (getDerived().AlwaysRebuild() ||
7119 ValueType != TL.getValueLoc().getType()) {
7120 Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
7121 if (Result.isNull())
7122 return QualType();
7123 }
7124
7125 AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
7126 NewTL.setKWLoc(TL.getKWLoc());
7127 NewTL.setLParenLoc(TL.getLParenLoc());
7128 NewTL.setRParenLoc(TL.getRParenLoc());
7129
7130 return Result;
7131}
7132
7133template <typename Derived>
7134QualType TreeTransform<Derived>::TransformPipeType(TypeLocBuilder &TLB,
7135 PipeTypeLoc TL) {
7136 QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
7137 if (ValueType.isNull())
7138 return QualType();
7139
7140 QualType Result = TL.getType();
7141 if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
7142 const PipeType *PT = Result->castAs<PipeType>();
7143 bool isReadPipe = PT->isReadOnly();
7144 Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
7145 if (Result.isNull())
7146 return QualType();
7147 }
7148
7149 PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
7150 NewTL.setKWLoc(TL.getKWLoc());
7151
7152 return Result;
7153}
7154
7155template <typename Derived>
7156QualType TreeTransform<Derived>::TransformBitIntType(TypeLocBuilder &TLB,
7157 BitIntTypeLoc TL) {
7158 const BitIntType *EIT = TL.getTypePtr();
7159 QualType Result = TL.getType();
7160
7161 if (getDerived().AlwaysRebuild()) {
7162 Result = getDerived().RebuildBitIntType(EIT->isUnsigned(),
7163 EIT->getNumBits(), TL.getNameLoc());
7164 if (Result.isNull())
7165 return QualType();
7166 }
7167
7168 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7169 NewTL.setNameLoc(TL.getNameLoc());
7170 return Result;
7171}
7172
7173template <typename Derived>
7174QualType TreeTransform<Derived>::TransformDependentBitIntType(
7175 TypeLocBuilder &TLB, DependentBitIntTypeLoc TL) {
7176 const DependentBitIntType *EIT = TL.getTypePtr();
7177
7178 EnterExpressionEvaluationContext Unevaluated(
7180 ExprResult BitsExpr = getDerived().TransformExpr(EIT->getNumBitsExpr());
7181 BitsExpr = SemaRef.ActOnConstantExpression(BitsExpr);
7182
7183 if (BitsExpr.isInvalid())
7184 return QualType();
7185
7186 QualType Result = TL.getType();
7187
7188 if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) {
7189 Result = getDerived().RebuildDependentBitIntType(
7190 EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc());
7191
7192 if (Result.isNull())
7193 return QualType();
7194 }
7195
7196 if (isa<DependentBitIntType>(Result)) {
7197 DependentBitIntTypeLoc NewTL = TLB.push<DependentBitIntTypeLoc>(Result);
7198 NewTL.setNameLoc(TL.getNameLoc());
7199 } else {
7200 BitIntTypeLoc NewTL = TLB.push<BitIntTypeLoc>(Result);
7201 NewTL.setNameLoc(TL.getNameLoc());
7202 }
7203 return Result;
7204}
7205
7206 /// Simple iterator that traverses the template arguments in a
7207 /// container that provides a \c getArgLoc() member function.
7208 ///
7209 /// This iterator is intended to be used with the iterator form of
7210 /// \c TreeTransform<Derived>::TransformTemplateArguments().
7211 template<typename ArgLocContainer>
7213 ArgLocContainer *Container;
7214 unsigned Index;
7215
7216 public:
7219 typedef int difference_type;
7220 typedef std::input_iterator_tag iterator_category;
7221
7222 class pointer {
7224
7225 public:
7226 explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
7227
7229 return &Arg;
7230 }
7231 };
7232
7233
7235
7236 TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
7237 unsigned Index)
7238 : Container(&Container), Index(Index) { }
7239
7241 ++Index;
7242 return *this;
7243 }
7244
7247 ++(*this);
7248 return Old;
7249 }
7250
7252 return Container->getArgLoc(Index);
7253 }
7254
7256 return pointer(Container->getArgLoc(Index));
7257 }
7258
7261 return X.Container == Y.Container && X.Index == Y.Index;
7262 }
7263
7266 return !(X == Y);
7267 }
7268 };
7269
7270template<typename Derived>
7271QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
7272 AutoTypeLoc TL) {
7273 const AutoType *T = TL.getTypePtr();
7274 QualType OldDeduced = T->getDeducedType();
7275 QualType NewDeduced;
7276 if (!OldDeduced.isNull()) {
7277 NewDeduced = getDerived().TransformType(OldDeduced);
7278 if (NewDeduced.isNull())
7279 return QualType();
7280 }
7281
7282 ConceptDecl *NewCD = nullptr;
7283 TemplateArgumentListInfo NewTemplateArgs;
7284 NestedNameSpecifierLoc NewNestedNameSpec;
7285 if (T->isConstrained()) {
7286 assert(TL.getConceptReference());
7287 NewCD = cast_or_null<ConceptDecl>(getDerived().TransformDecl(
7288 TL.getConceptNameLoc(), T->getTypeConstraintConcept()));
7289
7290 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7291 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7292 typedef TemplateArgumentLocContainerIterator<AutoTypeLoc> ArgIterator;
7293 if (getDerived().TransformTemplateArguments(
7294 ArgIterator(TL, 0), ArgIterator(TL, TL.getNumArgs()),
7295 NewTemplateArgs))
7296 return QualType();
7297
7298 if (TL.getNestedNameSpecifierLoc()) {
7299 NewNestedNameSpec
7300 = getDerived().TransformNestedNameSpecifierLoc(
7301 TL.getNestedNameSpecifierLoc());
7302 if (!NewNestedNameSpec)
7303 return QualType();
7304 }
7305 }
7306
7307 QualType Result = TL.getType();
7308 if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
7309 T->isDependentType() || T->isConstrained()) {
7310 // FIXME: Maybe don't rebuild if all template arguments are the same.
7312 NewArgList.reserve(NewTemplateArgs.size());
7313 for (const auto &ArgLoc : NewTemplateArgs.arguments())
7314 NewArgList.push_back(ArgLoc.getArgument());
7315 Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword(), NewCD,
7316 NewArgList);
7317 if (Result.isNull())
7318 return QualType();
7319 }
7320
7321 AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
7322 NewTL.setNameLoc(TL.getNameLoc());
7323 NewTL.setRParenLoc(TL.getRParenLoc());
7324 NewTL.setConceptReference(nullptr);
7325
7326 if (T->isConstrained()) {
7327 DeclarationNameInfo DNI = DeclarationNameInfo(
7328 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName(),
7329 TL.getConceptNameLoc(),
7330 TL.getTypePtr()->getTypeConstraintConcept()->getDeclName());
7331 auto *CR = ConceptReference::Create(
7332 SemaRef.Context, NewNestedNameSpec, TL.getTemplateKWLoc(), DNI,
7333 TL.getFoundDecl(), TL.getTypePtr()->getTypeConstraintConcept(),
7334 ASTTemplateArgumentListInfo::Create(SemaRef.Context, NewTemplateArgs));
7335 NewTL.setConceptReference(CR);
7336 }
7337
7338 return Result;
7339}
7340
7341template <typename Derived>
7343 TypeLocBuilder &TLB,
7344 TemplateSpecializationTypeLoc TL,
7345 TemplateName Template) {
7346 TemplateArgumentListInfo NewTemplateArgs;
7347 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7348 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7349 typedef TemplateArgumentLocContainerIterator<TemplateSpecializationTypeLoc>
7350 ArgIterator;
7351 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7352 ArgIterator(TL, TL.getNumArgs()),
7353 NewTemplateArgs))
7354 return QualType();
7355
7356 // This needs to be rebuilt if either the arguments changed, or if the
7357 // original template changed. If the template changed, and even if the
7358 // arguments didn't change, these arguments might not correspond to their
7359 // respective parameters, therefore needing conversions.
7360 QualType Result =
7361 getDerived().RebuildTemplateSpecializationType(Template,
7362 TL.getTemplateNameLoc(),
7363 NewTemplateArgs);
7364
7365 if (!Result.isNull()) {
7366 // Specializations of template template parameters are represented as
7367 // TemplateSpecializationTypes, and substitution of type alias templates
7368 // within a dependent context can transform them into
7369 // DependentTemplateSpecializationTypes.
7370 if (isa<DependentTemplateSpecializationType>(Result)) {
7371 DependentTemplateSpecializationTypeLoc NewTL
7372 = TLB.push<DependentTemplateSpecializationTypeLoc>(Result);
7373 NewTL.setElaboratedKeywordLoc(SourceLocation());
7374 NewTL.setQualifierLoc(NestedNameSpecifierLoc());
7375 NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc());
7376 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7377 NewTL.setLAngleLoc(TL.getLAngleLoc());
7378 NewTL.setRAngleLoc(TL.getRAngleLoc());
7379 for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7380 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7381 return Result;
7382 }
7383
7384 TemplateSpecializationTypeLoc NewTL
7385 = TLB.push<TemplateSpecializationTypeLoc>(Result);
7386 NewTL.setTemplateKeywordLoc(TL.getTemplateKeywordLoc());
7387 NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
7388 NewTL.setLAngleLoc(TL.getLAngleLoc());
7389 NewTL.setRAngleLoc(TL.getRAngleLoc());
7390 for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7391 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7392 }
7393
7394 return Result;
7395}
7396
7397template <typename Derived>
7399 TypeLocBuilder &TLB,
7401 TemplateName Template,
7402 CXXScopeSpec &SS) {
7403 TemplateArgumentListInfo NewTemplateArgs;
7404 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7405 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7408 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7409 ArgIterator(TL, TL.getNumArgs()),
7410 NewTemplateArgs))
7411 return QualType();
7412
7413 // FIXME: maybe don't rebuild if all the template arguments are the same.
7414
7415 if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
7416 QualType Result = getSema().Context.getDependentTemplateSpecializationType(
7417 TL.getTypePtr()->getKeyword(), DTN->getQualifier(),
7418 DTN->getIdentifier(), NewTemplateArgs.arguments());
7419
7423 NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context));
7426 NewTL.setLAngleLoc(TL.getLAngleLoc());
7427 NewTL.setRAngleLoc(TL.getRAngleLoc());
7428 for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7429 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7430 return Result;
7431 }
7432
7434 = getDerived().RebuildTemplateSpecializationType(Template,
7435 TL.getTemplateNameLoc(),
7436 NewTemplateArgs);
7437
7438 if (!Result.isNull()) {
7439 /// FIXME: Wrap this in an elaborated-type-specifier?
7444 NewTL.setLAngleLoc(TL.getLAngleLoc());
7445 NewTL.setRAngleLoc(TL.getRAngleLoc());
7446 for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
7447 NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
7448 }
7449
7450 return Result;
7451}
7452
7453template<typename Derived>
7456 ElaboratedTypeLoc TL) {
7457 const ElaboratedType *T = TL.getTypePtr();
7458
7459 NestedNameSpecifierLoc QualifierLoc;
7460 // NOTE: the qualifier in an ElaboratedType is optional.
7461 if (TL.getQualifierLoc()) {
7462 QualifierLoc
7463 = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
7464 if (!QualifierLoc)
7465 return QualType();
7466 }
7467
7468 QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
7469 if (NamedT.isNull())
7470 return QualType();
7471
7472 // C++0x [dcl.type.elab]p2:
7473 // If the identifier resolves to a typedef-name or the simple-template-id
7474 // resolves to an alias template specialization, the
7475 // elaborated-type-specifier is ill-formed.
7476 if (T->getKeyword() != ElaboratedTypeKeyword::None &&
7477 T->getKeyword() != ElaboratedTypeKeyword::Typename) {
7478 if (const TemplateSpecializationType *TST =
7479 NamedT->getAs<TemplateSpecializationType>()) {
7480 TemplateName Template = TST->getTemplateName();
7481 if (TypeAliasTemplateDecl *TAT = dyn_cast_or_null<TypeAliasTemplateDecl>(
7482 Template.getAsTemplateDecl())) {
7483 SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
7484 diag::err_tag_reference_non_tag)
7486 << llvm::to_underlying(
7488 SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
7489 }
7490 }
7491 }
7492
7493 QualType Result = TL.getType();
7494 if (getDerived().AlwaysRebuild() ||
7495 QualifierLoc != TL.getQualifierLoc() ||
7496 NamedT != T->getNamedType()) {
7497 Result = getDerived().RebuildElaboratedType(TL.getElaboratedKeywordLoc(),
7498 T->getKeyword(),
7499 QualifierLoc, NamedT);
7500 if (Result.isNull())
7501 return QualType();
7502 }
7503
7504 ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
7505 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7506 NewTL.setQualifierLoc(QualifierLoc);
7507 return Result;
7508}
7509
7510template <typename Derived>
7511QualType TreeTransform<Derived>::TransformAttributedType(TypeLocBuilder &TLB,
7512 AttributedTypeLoc TL) {
7513 const AttributedType *oldType = TL.getTypePtr();
7514 QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
7515 if (modifiedType.isNull())
7516 return QualType();
7517
7518 // oldAttr can be null if we started with a QualType rather than a TypeLoc.
7519 const Attr *oldAttr = TL.getAttr();
7520 const Attr *newAttr = oldAttr ? getDerived().TransformAttr(oldAttr) : nullptr;
7521 if (oldAttr && !newAttr)
7522 return QualType();
7523
7524 QualType result = TL.getType();
7525
7526 // FIXME: dependent operand expressions?
7527 if (getDerived().AlwaysRebuild() ||
7528 modifiedType != oldType->getModifiedType()) {
7529 // If the equivalent type is equal to the modified type, we don't want to
7530 // transform it as well because:
7531 //
7532 // 1. The transformation would yield the same result and is therefore
7533 // superfluous, and
7534 //
7535 // 2. Transforming the same type twice can cause problems, e.g. if it
7536 // is a FunctionProtoType, we may end up instantiating the function
7537 // parameters twice, which causes an assertion since the parameters
7538 // are already bound to their counterparts in the template for this
7539 // instantiation.
7540 //
7541 QualType equivalentType = modifiedType;
7542 if (TL.getModifiedLoc().getType() != TL.getEquivalentTypeLoc().getType()) {
7543 TypeLocBuilder AuxiliaryTLB;
7544 AuxiliaryTLB.reserve(TL.getFullDataSize());
7545 equivalentType =
7546 getDerived().TransformType(AuxiliaryTLB, TL.getEquivalentTypeLoc());
7547 if (equivalentType.isNull())
7548 return QualType();
7549 }
7550
7551 // Check whether we can add nullability; it is only represented as
7552 // type sugar, and therefore cannot be diagnosed in any other way.
7553 if (auto nullability = oldType->getImmediateNullability()) {
7554 if (!modifiedType->canHaveNullability()) {
7555 SemaRef.Diag((TL.getAttr() ? TL.getAttr()->getLocation()
7556 : TL.getModifiedLoc().getBeginLoc()),
7557 diag::err_nullability_nonpointer)
7558 << DiagNullabilityKind(*nullability, false) << modifiedType;
7559 return QualType();
7560 }
7561 }
7562
7563 result = SemaRef.Context.getAttributedType(TL.getAttrKind(),
7564 modifiedType,
7565 equivalentType,
7566 TL.getAttr());
7567 }
7568
7569 AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
7570 newTL.setAttr(newAttr);
7571 return result;
7572}
7573
7574template <typename Derived>
7575QualType TreeTransform<Derived>::TransformCountAttributedType(
7576 TypeLocBuilder &TLB, CountAttributedTypeLoc TL) {
7577 const CountAttributedType *OldTy = TL.getTypePtr();
7578 QualType InnerTy = getDerived().TransformType(TLB, TL.getInnerLoc());
7579 if (InnerTy.isNull())
7580 return QualType();
7581
7582 Expr *OldCount = TL.getCountExpr();
7583 Expr *NewCount = nullptr;
7584 if (OldCount) {
7585 ExprResult CountResult = getDerived().TransformExpr(OldCount);
7586 if (CountResult.isInvalid())
7587 return QualType();
7588 NewCount = CountResult.get();
7589 }
7590
7591 QualType Result = TL.getType();
7592 if (getDerived().AlwaysRebuild() || InnerTy != OldTy->desugar() ||
7593 OldCount != NewCount) {
7594 // Currently, CountAttributedType can only wrap incomplete array types.
7596 InnerTy, NewCount, OldTy->isCountInBytes(), OldTy->isOrNull());
7597 }
7598
7599 TLB.push<CountAttributedTypeLoc>(Result);
7600 return Result;
7601}
7602
7603template <typename Derived>
7604QualType TreeTransform<Derived>::TransformBTFTagAttributedType(
7605 TypeLocBuilder &TLB, BTFTagAttributedTypeLoc TL) {
7606 // The BTFTagAttributedType is available for C only.
7607 llvm_unreachable("Unexpected TreeTransform for BTFTagAttributedType");
7608}
7609
7610template <typename Derived>
7611QualType TreeTransform<Derived>::TransformHLSLAttributedResourceType(
7612 TypeLocBuilder &TLB, HLSLAttributedResourceTypeLoc TL) {
7613
7614 const HLSLAttributedResourceType *oldType = TL.getTypePtr();
7615
7616 QualType WrappedTy = getDerived().TransformType(TLB, TL.getWrappedLoc());
7617 if (WrappedTy.isNull())
7618 return QualType();
7619
7620 QualType ContainedTy = QualType();
7621 QualType OldContainedTy = oldType->getContainedType();
7622 if (!OldContainedTy.isNull()) {
7623 TypeSourceInfo *oldContainedTSI = TL.getContainedTypeSourceInfo();
7624 if (!oldContainedTSI)
7625 oldContainedTSI = getSema().getASTContext().getTrivialTypeSourceInfo(
7626 OldContainedTy, SourceLocation());
7627 TypeSourceInfo *ContainedTSI = getDerived().TransformType(oldContainedTSI);
7628 if (!ContainedTSI)
7629 return QualType();
7630 ContainedTy = ContainedTSI->getType();
7631 }
7632
7633 QualType Result = TL.getType();
7634 if (getDerived().AlwaysRebuild() || WrappedTy != oldType->getWrappedType() ||
7635 ContainedTy != oldType->getContainedType()) {
7637 WrappedTy, ContainedTy, oldType->getAttrs());
7638 }
7639
7640 TLB.push<HLSLAttributedResourceTypeLoc>(Result);
7641 return Result;
7642}
7643
7644template<typename Derived>
7645QualType
7646TreeTransform<Derived>::TransformParenType(TypeLocBuilder &TLB,
7647 ParenTypeLoc TL) {
7648 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7649 if (Inner.isNull())
7650 return QualType();
7651
7652 QualType Result = TL.getType();
7653 if (getDerived().AlwaysRebuild() ||
7654 Inner != TL.getInnerLoc().getType()) {
7655 Result = getDerived().RebuildParenType(Inner);
7656 if (Result.isNull())
7657 return QualType();
7658 }
7659
7660 ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
7661 NewTL.setLParenLoc(TL.getLParenLoc());
7662 NewTL.setRParenLoc(TL.getRParenLoc());
7663 return Result;
7664}
7665
7666template <typename Derived>
7667QualType
7668TreeTransform<Derived>::TransformMacroQualifiedType(TypeLocBuilder &TLB,
7669 MacroQualifiedTypeLoc TL) {
7670 QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
7671 if (Inner.isNull())
7672 return QualType();
7673
7674 QualType Result = TL.getType();
7675 if (getDerived().AlwaysRebuild() || Inner != TL.getInnerLoc().getType()) {
7676 Result =
7677 getDerived().RebuildMacroQualifiedType(Inner, TL.getMacroIdentifier());
7678 if (Result.isNull())
7679 return QualType();
7680 }
7681
7682 MacroQualifiedTypeLoc NewTL = TLB.push<MacroQualifiedTypeLoc>(Result);
7683 NewTL.setExpansionLoc(TL.getExpansionLoc());
7684 return Result;
7685}
7686
7687template<typename Derived>
7688QualType TreeTransform<Derived>::TransformDependentNameType(
7689 TypeLocBuilder &TLB, DependentNameTypeLoc TL) {
7690 return TransformDependentNameType(TLB, TL, false);
7691}
7692
7693template<typename Derived>
7694QualType TreeTransform<Derived>::TransformDependentNameType(
7695 TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext) {
7696 const DependentNameType *T = TL.getTypePtr();
7697
7698 NestedNameSpecifierLoc QualifierLoc
7699 = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
7700 if (!QualifierLoc)
7701 return QualType();
7702
7703 QualType Result
7704 = getDerived().RebuildDependentNameType(T->getKeyword(),
7705 TL.getElaboratedKeywordLoc(),
7706 QualifierLoc,
7707 T->getIdentifier(),
7708 TL.getNameLoc(),
7709 DeducedTSTContext);
7710 if (Result.isNull())
7711 return QualType();
7712
7713 if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
7714 QualType NamedT = ElabT->getNamedType();
7715 TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc());
7716
7717 ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
7718 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7719 NewTL.setQualifierLoc(QualifierLoc);
7720 } else {
7721 DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
7722 NewTL.setElaboratedKeywordLoc(TL.getElaboratedKeywordLoc());
7723 NewTL.setQualifierLoc(QualifierLoc);
7724 NewTL.setNameLoc(TL.getNameLoc());
7725 }
7726 return Result;
7727}
7728
7729template<typename Derived>
7732 DependentTemplateSpecializationTypeLoc TL) {
7733 NestedNameSpecifierLoc QualifierLoc;
7734 if (TL.getQualifierLoc()) {
7735 QualifierLoc
7736 = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
7737 if (!QualifierLoc)
7738 return QualType();
7739 }
7740
7741 return getDerived()
7742 .TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc);
7743}
7744
7745template<typename Derived>
7749 NestedNameSpecifierLoc QualifierLoc) {
7751
7752 TemplateArgumentListInfo NewTemplateArgs;
7753 NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
7754 NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
7755
7758 if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
7759 ArgIterator(TL, TL.getNumArgs()),
7760 NewTemplateArgs))
7761 return QualType();
7762
7763 QualType Result = getDerived().RebuildDependentTemplateSpecializationType(
7764 T->getKeyword(), QualifierLoc, TL.getTemplateKeywordLoc(),
7765 T->getIdentifier(), TL.getTemplateNameLoc(), NewTemplateArgs,
7766 /*AllowInjectedClassName*/ false);
7767 if (Result.isNull())
7768 return QualType();
7769
7770 if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) {
7771 QualType NamedT = ElabT->getNamedType();
7772
7773 // Copy information relevant to the template specialization.
7775 = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
7778 NamedTL.setLAngleLoc(TL.getLAngleLoc());
7779 NamedTL.setRAngleLoc(TL.getRAngleLoc());
7780 for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
7781 NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
7782
7783 // Copy information relevant to the elaborated type.
7786 NewTL.setQualifierLoc(QualifierLoc);
7787 } else if (isa<DependentTemplateSpecializationType>(Result)) {
7791 SpecTL.setQualifierLoc(QualifierLoc);
7794 SpecTL.setLAngleLoc(TL.getLAngleLoc());
7795 SpecTL.setRAngleLoc(TL.getRAngleLoc());
7796 for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
7797 SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
7798 } else {
7803 SpecTL.setLAngleLoc(TL.getLAngleLoc());
7804 SpecTL.setRAngleLoc(TL.getRAngleLoc());
7805 for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
7806 SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
7807 }
7808 return Result;
7809}
7810
7811template<typename Derived>
7814 QualType Pattern
7815 = getDerived().TransformType(TLB, TL.getPatternLoc());
7816 if (Pattern.isNull())
7817 return QualType();
7818
7819 QualType Result = TL.getType();
7820 if (getDerived().AlwaysRebuild() ||
7821 Pattern != TL.getPatternLoc().getType()) {
7822 Result = getDerived().RebuildPackExpansionType(Pattern,
7824 TL.getEllipsisLoc(),
7826 if (Result.isNull())
7827 return QualType();
7828 }
7829
7830 PackExpansionTypeLoc NewT = TLB.push<PackExpansionTypeLoc>(Result);
7831 NewT.setEllipsisLoc(TL.getEllipsisLoc());
7832 return Result;
7833}
7834
7835template<typename Derived>
7836QualType
7837TreeTransform<Derived>::TransformObjCInterfaceType(TypeLocBuilder &TLB,
7838 ObjCInterfaceTypeLoc TL) {
7839 // ObjCInterfaceType is never dependent.
7840 TLB.pushFullCopy(TL);
7841 return TL.getType();
7842}
7843
7844template<typename Derived>
7845QualType
7846TreeTransform<Derived>::TransformObjCTypeParamType(TypeLocBuilder &TLB,
7847 ObjCTypeParamTypeLoc TL) {
7848 const ObjCTypeParamType *T = TL.getTypePtr();
7849 ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
7850 getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
7851 if (!OTP)
7852 return QualType();
7853
7854 QualType Result = TL.getType();
7855 if (getDerived().AlwaysRebuild() ||
7856 OTP != T->getDecl()) {
7857 Result = getDerived().RebuildObjCTypeParamType(
7858 OTP, TL.getProtocolLAngleLoc(),
7859 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7860 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7861 if (Result.isNull())
7862 return QualType();
7863 }
7864
7865 ObjCTypeParamTypeLoc NewTL = TLB.push<ObjCTypeParamTypeLoc>(Result);
7866 if (TL.getNumProtocols()) {
7867 NewTL.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7868 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7869 NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
7870 NewTL.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7871 }
7872 return Result;
7873}
7874
7875template<typename Derived>
7876QualType
7877TreeTransform<Derived>::TransformObjCObjectType(TypeLocBuilder &TLB,
7878 ObjCObjectTypeLoc TL) {
7879 // Transform base type.
7880 QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
7881 if (BaseType.isNull())
7882 return QualType();
7883
7884 bool AnyChanged = BaseType != TL.getBaseLoc().getType();
7885
7886 // Transform type arguments.
7887 SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
7888 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
7889 TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
7890 TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
7891 QualType TypeArg = TypeArgInfo->getType();
7892 if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
7893 AnyChanged = true;
7894
7895 // We have a pack expansion. Instantiate it.
7896 const auto *PackExpansion = PackExpansionLoc.getType()
7897 ->castAs<PackExpansionType>();
7899 SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
7900 Unexpanded);
7901 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
7902
7903 // Determine whether the set of unexpanded parameter packs can
7904 // and should be expanded.
7905 TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
7906 bool Expand = false;
7907 bool RetainExpansion = false;
7908 std::optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
7909 if (getDerived().TryExpandParameterPacks(
7910 PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
7911 Unexpanded, Expand, RetainExpansion, NumExpansions))
7912 return QualType();
7913
7914 if (!Expand) {
7915 // We can't expand this pack expansion into separate arguments yet;
7916 // just substitute into the pattern and create a new pack expansion
7917 // type.
7918 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
7919
7920 TypeLocBuilder TypeArgBuilder;
7921 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7922 QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
7923 PatternLoc);
7924 if (NewPatternType.isNull())
7925 return QualType();
7926
7927 QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
7928 NewPatternType, NumExpansions);
7929 auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
7930 NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
7931 NewTypeArgInfos.push_back(
7932 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
7933 continue;
7934 }
7935
7936 // Substitute into the pack expansion pattern for each slice of the
7937 // pack.
7938 for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
7939 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
7940
7941 TypeLocBuilder TypeArgBuilder;
7942 TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
7943
7944 QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
7945 PatternLoc);
7946 if (NewTypeArg.isNull())
7947 return QualType();
7948
7949 NewTypeArgInfos.push_back(
7950 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
7951 }
7952
7953 continue;
7954 }
7955
7956 TypeLocBuilder TypeArgBuilder;
7957 TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
7958 QualType NewTypeArg =
7959 getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
7960 if (NewTypeArg.isNull())
7961 return QualType();
7962
7963 // If nothing changed, just keep the old TypeSourceInfo.
7964 if (NewTypeArg == TypeArg) {
7965 NewTypeArgInfos.push_back(TypeArgInfo);
7966 continue;
7967 }
7968
7969 NewTypeArgInfos.push_back(
7970 TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
7971 AnyChanged = true;
7972 }
7973
7974 QualType Result = TL.getType();
7975 if (getDerived().AlwaysRebuild() || AnyChanged) {
7976 // Rebuild the type.
7977 Result = getDerived().RebuildObjCObjectType(
7978 BaseType, TL.getBeginLoc(), TL.getTypeArgsLAngleLoc(), NewTypeArgInfos,
7979 TL.getTypeArgsRAngleLoc(), TL.getProtocolLAngleLoc(),
7980 llvm::ArrayRef(TL.getTypePtr()->qual_begin(), TL.getNumProtocols()),
7981 TL.getProtocolLocs(), TL.getProtocolRAngleLoc());
7982
7983 if (Result.isNull())
7984 return QualType();
7985 }
7986
7987 ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
7988 NewT.setHasBaseTypeAsWritten(true);
7989 NewT.setTypeArgsLAngleLoc(TL.getTypeArgsLAngleLoc());
7990 for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
7991 NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
7992 NewT.setTypeArgsRAngleLoc(TL.getTypeArgsRAngleLoc());
7993 NewT.setProtocolLAngleLoc(TL.getProtocolLAngleLoc());
7994 for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
7995 NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
7996 NewT.setProtocolRAngleLoc(TL.getProtocolRAngleLoc());
7997 return Result;
7998}
7999
8000template<typename Derived>
8001QualType
8002TreeTransform<Derived>::TransformObjCObjectPointerType(TypeLocBuilder &TLB,
8003 ObjCObjectPointerTypeLoc TL) {
8004 QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
8005 if (PointeeType.isNull())
8006 return QualType();
8007
8008 QualType Result = TL.getType();
8009 if (getDerived().AlwaysRebuild() ||
8010 PointeeType != TL.getPointeeLoc().getType()) {
8011 Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
8012 TL.getStarLoc());
8013 if (Result.isNull())
8014 return QualType();
8015 }
8016
8017 ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);
8018 NewT.setStarLoc(TL.getStarLoc());
8019 return Result;
8020}
8021
8022//===----------------------------------------------------------------------===//
8023// Statement transformation
8024//===----------------------------------------------------------------------===//
8025template<typename Derived>
8027TreeTransform<Derived>::TransformNullStmt(NullStmt *S) {
8028 return S;
8029}
8030
8031template<typename Derived>
8034 return getDerived().TransformCompoundStmt(S, false);
8035}
8036
8037template<typename Derived>
8040 bool IsStmtExpr) {
8041 Sema::CompoundScopeRAII CompoundScope(getSema());
8042 Sema::FPFeaturesStateRAII FPSave(getSema());
8043 if (S->hasStoredFPFeatures())
8044 getSema().resetFPOptions(
8045 S->getStoredFPFeatures().applyOverrides(getSema().getLangOpts()));
8046
8047 const Stmt *ExprResult = S->getStmtExprResult();
8048 bool SubStmtInvalid = false;
8049 bool SubStmtChanged = false;
8050 SmallVector<Stmt*, 8> Statements;
8051 for (auto *B : S->body()) {
8052 StmtResult Result = getDerived().TransformStmt(
8053 B, IsStmtExpr && B == ExprResult ? SDK_StmtExprResult : SDK_Discarded);
8054
8055 if (Result.isInvalid()) {
8056 // Immediately fail if this was a DeclStmt, since it's very
8057 // likely that this will cause problems for future statements.
8058 if (isa<DeclStmt>(B))
8059 return StmtError();
8060
8061 // Otherwise, just keep processing substatements and fail later.
8062 SubStmtInvalid = true;
8063 continue;
8064 }
8065
8066 SubStmtChanged = SubStmtChanged || Result.get() != B;
8067 Statements.push_back(Result.getAs<Stmt>());
8068 }
8069
8070 if (SubStmtInvalid)
8071 return StmtError();
8072
8073 if (!getDerived().AlwaysRebuild() &&
8074 !SubStmtChanged)
8075 return S;
8076
8077 return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
8078 Statements,
8079 S->getRBracLoc(),
8080 IsStmtExpr);
8081}
8082
8083template<typename Derived>
8085TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
8086 ExprResult LHS, RHS;
8087 {
8088 EnterExpressionEvaluationContext Unevaluated(
8090
8091 // Transform the left-hand case value.
8092 LHS = getDerived().TransformExpr(S->getLHS());
8093 LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
8094 if (LHS.isInvalid())
8095 return StmtError();
8096
8097 // Transform the right-hand case value (for the GNU case-range extension).
8098 RHS = getDerived().TransformExpr(S->getRHS());
8099 RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
8100 if (RHS.isInvalid())
8101 return StmtError();
8102 }
8103
8104 // Build the case statement.
8105 // Case statements are always rebuilt so that they will attached to their
8106 // transformed switch statement.
8107 StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
8108 LHS.get(),
8109 S->getEllipsisLoc(),
8110 RHS.get(),
8111 S->getColonLoc());
8112 if (Case.isInvalid())
8113 return StmtError();
8114
8115 // Transform the statement following the case
8116 StmtResult SubStmt =
8117 getDerived().TransformStmt(S->getSubStmt());
8118 if (SubStmt.isInvalid())
8119 return StmtError();
8120
8121 // Attach the body to the case statement
8122 return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
8123}
8124
8125template <typename Derived>
8126StmtResult TreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) {
8127 // Transform the statement following the default case
8128 StmtResult SubStmt =
8129 getDerived().TransformStmt(S->getSubStmt());
8130 if (SubStmt.isInvalid())
8131 return StmtError();
8132
8133 // Default statements are always rebuilt
8134 return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
8135 SubStmt.get());
8136}
8137
8138template<typename Derived>
8140TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S, StmtDiscardKind SDK) {
8141 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8142 if (SubStmt.isInvalid())
8143 return StmtError();
8144
8145 Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
8146 S->getDecl());
8147 if (!LD)
8148 return StmtError();
8149
8150 // If we're transforming "in-place" (we're not creating new local
8151 // declarations), assume we're replacing the old label statement
8152 // and clear out the reference to it.
8153 if (LD == S->getDecl())
8154 S->getDecl()->setStmt(nullptr);
8155
8156 // FIXME: Pass the real colon location in.
8157 return getDerived().RebuildLabelStmt(S->getIdentLoc(),
8158 cast<LabelDecl>(LD), SourceLocation(),
8159 SubStmt.get());
8160}
8161
8162template <typename Derived>
8164 if (!R)
8165 return R;
8166
8167 switch (R->getKind()) {
8168// Transform attributes by calling TransformXXXAttr.
8169#define ATTR(X) \
8170 case attr::X: \
8171 return getDerived().Transform##X##Attr(cast<X##Attr>(R));
8172#include "clang/Basic/AttrList.inc"
8173 }
8174 return R;
8175}
8176
8177template <typename Derived>
8179 const Stmt *InstS,
8180 const Attr *R) {
8181 if (!R)
8182 return R;
8183
8184 switch (R->getKind()) {
8185// Transform attributes by calling TransformStmtXXXAttr.
8186#define ATTR(X) \
8187 case attr::X: \
8188 return getDerived().TransformStmt##X##Attr(OrigS, InstS, cast<X##Attr>(R));
8189#include "clang/Basic/AttrList.inc"
8190 }
8191 return TransformAttr(R);
8192}
8193
8194template <typename Derived>
8197 StmtDiscardKind SDK) {
8198 StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt(), SDK);
8199 if (SubStmt.isInvalid())
8200 return StmtError();
8201
8202 bool AttrsChanged = false;
8204
8205 // Visit attributes and keep track if any are transformed.
8206 for (const auto *I : S->getAttrs()) {
8207 const Attr *R =
8208 getDerived().TransformStmtAttr(S->getSubStmt(), SubStmt.get(), I);
8209 AttrsChanged |= (I != R);
8210 if (R)
8211 Attrs.push_back(R);
8212 }
8213
8214 if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
8215 return S;
8216
8217 // If transforming the attributes failed for all of the attributes in the
8218 // statement, don't make an AttributedStmt without attributes.
8219 if (Attrs.empty())
8220 return SubStmt;
8221
8222 return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
8223 SubStmt.get());
8224}
8225
8226template<typename Derived>
8228TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
8229 // Transform the initialization statement
8230 StmtResult Init = getDerived().TransformStmt(S->getInit());
8231 if (Init.isInvalid())
8232 return StmtError();
8233
8234 Sema::ConditionResult Cond;
8235 if (!S->isConsteval()) {
8236 // Transform the condition
8237 Cond = getDerived().TransformCondition(
8238 S->getIfLoc(), S->getConditionVariable(), S->getCond(),
8239 S->isConstexpr() ? Sema::ConditionKind::ConstexprIf
8241 if (Cond.isInvalid())
8242 return StmtError();
8243 }
8244
8245 // If this is a constexpr if, determine which arm we should instantiate.
8246 std::optional<bool> ConstexprConditionValue;
8247 if (S->isConstexpr())
8248 ConstexprConditionValue = Cond.getKnownValue();
8249
8250 // Transform the "then" branch.
8251 StmtResult Then;
8252 if (!ConstexprConditionValue || *ConstexprConditionValue) {
8253 EnterExpressionEvaluationContext Ctx(
8256 S->isNonNegatedConsteval());
8257
8258 Then = getDerived().TransformStmt(S->getThen());
8259 if (Then.isInvalid())
8260 return StmtError();
8261 } else {
8262 // Discarded branch is replaced with empty CompoundStmt so we can keep
8263 // proper source location for start and end of original branch, so
8264 // subsequent transformations like CoverageMapping work properly
8265 Then = new (getSema().Context)
8266 CompoundStmt(S->getThen()->getBeginLoc(), S->getThen()->getEndLoc());
8267 }
8268
8269 // Transform the "else" branch.
8270 StmtResult Else;
8271 if (!ConstexprConditionValue || !*ConstexprConditionValue) {
8272 EnterExpressionEvaluationContext Ctx(
8275 S->isNegatedConsteval());
8276
8277 Else = getDerived().TransformStmt(S->getElse());
8278 if (Else.isInvalid())
8279 return StmtError();
8280 } else if (S->getElse() && ConstexprConditionValue &&
8281 *ConstexprConditionValue) {
8282 // Same thing here as with <then> branch, we are discarding it, we can't
8283 // replace it with NULL nor NullStmt as we need to keep for source location
8284 // range, for CoverageMapping
8285 Else = new (getSema().Context)
8286 CompoundStmt(S->getElse()->getBeginLoc(), S->getElse()->getEndLoc());
8287 }
8288
8289 if (!getDerived().AlwaysRebuild() &&
8290 Init.get() == S->getInit() &&
8291 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8292 Then.get() == S->getThen() &&
8293 Else.get() == S->getElse())
8294 return S;
8295
8296 return getDerived().RebuildIfStmt(
8297 S->getIfLoc(), S->getStatementKind(), S->getLParenLoc(), Cond,
8298 S->getRParenLoc(), Init.get(), Then.get(), S->getElseLoc(), Else.get());
8299}
8300
8301template<typename Derived>
8303TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) {
8304 // Transform the initialization statement
8305 StmtResult Init = getDerived().TransformStmt(S->getInit());
8306 if (Init.isInvalid())
8307 return StmtError();
8308
8309 // Transform the condition.
8310 Sema::ConditionResult Cond = getDerived().TransformCondition(
8311 S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
8313 if (Cond.isInvalid())
8314 return StmtError();
8315
8316 // Rebuild the switch statement.
8318 getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), S->getLParenLoc(),
8319 Init.get(), Cond, S->getRParenLoc());
8320 if (Switch.isInvalid())
8321 return StmtError();
8322
8323 // Transform the body of the switch statement.
8324 StmtResult Body = getDerived().TransformStmt(S->getBody());
8325 if (Body.isInvalid())
8326 return StmtError();
8327
8328 // Complete the switch statement.
8329 return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
8330 Body.get());
8331}
8332
8333template<typename Derived>
8335TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
8336 // Transform the condition
8337 Sema::ConditionResult Cond = getDerived().TransformCondition(
8338 S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
8340 if (Cond.isInvalid())
8341 return StmtError();
8342
8343 // OpenACC Restricts a while-loop inside of certain construct/clause
8344 // combinations, so diagnose that here in OpenACC mode.
8345 SemaOpenACC::LoopInConstructRAII LCR{SemaRef.OpenACC()};
8346 SemaRef.OpenACC().ActOnWhileStmt(S->getBeginLoc());
8347
8348 // Transform the body
8349 StmtResult Body = getDerived().TransformStmt(S->getBody());
8350 if (Body.isInvalid())
8351 return StmtError();
8352
8353 if (!getDerived().AlwaysRebuild() &&
8354 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8355 Body.get() == S->getBody())
8356 return Owned(S);
8357
8358 return getDerived().RebuildWhileStmt(S->getWhileLoc(), S->getLParenLoc(),
8359 Cond, S->getRParenLoc(), Body.get());
8360}
8361
8362template<typename Derived>
8364TreeTransform<Derived>::TransformDoStmt(DoStmt *S) {
8365 // OpenACC Restricts a do-loop inside of certain construct/clause
8366 // combinations, so diagnose that here in OpenACC mode.
8367 SemaOpenACC::LoopInConstructRAII LCR{SemaRef.OpenACC()};
8368 SemaRef.OpenACC().ActOnDoStmt(S->getBeginLoc());
8369
8370 // Transform the body
8371 StmtResult Body = getDerived().TransformStmt(S->getBody());
8372 if (Body.isInvalid())
8373 return StmtError();
8374
8375 // Transform the condition
8376 ExprResult Cond = getDerived().TransformExpr(S->getCond());
8377 if (Cond.isInvalid())
8378 return StmtError();
8379
8380 if (!getDerived().AlwaysRebuild() &&
8381 Cond.get() == S->getCond() &&
8382 Body.get() == S->getBody())
8383 return S;
8384
8385 return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
8386 /*FIXME:*/S->getWhileLoc(), Cond.get(),
8387 S->getRParenLoc());
8388}
8389
8390template<typename Derived>
8392TreeTransform<Derived>::TransformForStmt(ForStmt *S) {
8393 if (getSema().getLangOpts().OpenMP)
8394 getSema().OpenMP().startOpenMPLoop();
8395
8396 // Transform the initialization statement
8397 StmtResult Init = getDerived().TransformStmt(S->getInit());
8398 if (Init.isInvalid())
8399 return StmtError();
8400
8401 // In OpenMP loop region loop control variable must be captured and be
8402 // private. Perform analysis of first part (if any).
8403 if (getSema().getLangOpts().OpenMP && Init.isUsable())
8404 getSema().OpenMP().ActOnOpenMPLoopInitialization(S->getForLoc(),
8405 Init.get());
8406
8407 // Transform the condition
8408 Sema::ConditionResult Cond = getDerived().TransformCondition(
8409 S->getForLoc(), S->getConditionVariable(), S->getCond(),
8411 if (Cond.isInvalid())
8412 return StmtError();
8413
8414 // Transform the increment
8415 ExprResult Inc = getDerived().TransformExpr(S->getInc());
8416 if (Inc.isInvalid())
8417 return StmtError();
8418
8419 Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
8420 if (S->getInc() && !FullInc.get())
8421 return StmtError();
8422
8423 // OpenACC Restricts a for-loop inside of certain construct/clause
8424 // combinations, so diagnose that here in OpenACC mode.
8425 SemaOpenACC::LoopInConstructRAII LCR{SemaRef.OpenACC()};
8426 SemaRef.OpenACC().ActOnForStmtBegin(
8427 S->getBeginLoc(), S->getInit(), Init.get(), S->getCond(),
8428 Cond.get().second, S->getInc(), Inc.get());
8429
8430 // Transform the body
8431 StmtResult Body = getDerived().TransformStmt(S->getBody());
8432 if (Body.isInvalid())
8433 return StmtError();
8434
8435 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
8436
8437 if (!getDerived().AlwaysRebuild() &&
8438 Init.get() == S->getInit() &&
8439 Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
8440 Inc.get() == S->getInc() &&
8441 Body.get() == S->getBody())
8442 return S;
8443
8444 return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
8445 Init.get(), Cond, FullInc,
8446 S->getRParenLoc(), Body.get());
8447}
8448
8449template<typename Derived>
8451TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
8452 Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
8453 S->getLabel());
8454 if (!LD)
8455 return StmtError();
8456
8457 // Goto statements must always be rebuilt, to resolve the label.
8458 return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
8459 cast<LabelDecl>(LD));
8460}
8461
8462template<typename Derived>
8464TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
8465 ExprResult Target = getDerived().TransformExpr(S->getTarget());
8466 if (Target.isInvalid())
8467 return StmtError();
8468 Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
8469
8470 if (!getDerived().AlwaysRebuild() &&
8471 Target.get() == S->getTarget())
8472 return S;
8473
8474 return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
8475 Target.get());
8476}
8477
8478template<typename Derived>
8480TreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) {
8481 return S;
8482}
8483
8484template<typename Derived>
8486TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) {
8487 return S;
8488}
8489
8490template<typename Derived>
8492TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) {
8493 ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
8494 /*NotCopyInit*/false);
8495 if (Result.isInvalid())
8496 return StmtError();
8497
8498 // FIXME: We always rebuild the return statement because there is no way
8499 // to tell whether the return type of the function has changed.
8500 return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
8501}
8502
8503template<typename Derived>
8505TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
8506 bool DeclChanged = false;
8508 LambdaScopeInfo *LSI = getSema().getCurLambda();
8509 for (auto *D : S->decls()) {
8510 Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
8511 if (!Transformed)
8512 return StmtError();
8513
8514 if (Transformed != D)
8515 DeclChanged = true;
8516
8517 if (LSI) {
8518 if (auto *TD = dyn_cast<TypeDecl>(Transformed))
8519 LSI->ContainsUnexpandedParameterPack |=
8520 getSema()
8521 .getASTContext()
8522 .getTypeDeclType(TD)
8523 .getSingleStepDesugaredType(getSema().getASTContext())
8524 ->containsUnexpandedParameterPack();
8525
8526 if (auto *VD = dyn_cast<VarDecl>(Transformed))
8527 LSI->ContainsUnexpandedParameterPack |=
8528 VD->getType()->containsUnexpandedParameterPack();
8529 }
8530
8531 Decls.push_back(Transformed);
8532 }
8533
8534 if (!getDerived().AlwaysRebuild() && !DeclChanged)
8535 return S;
8536
8537 return getDerived().RebuildDeclStmt(Decls, S->getBeginLoc(), S->getEndLoc());
8538}
8539
8540template<typename Derived>
8542TreeTransform<Derived>::TransformGCCAsmStmt(GCCAsmStmt *S) {
8543
8544 SmallVector<Expr*, 8> Constraints;
8547
8548 ExprResult AsmString;
8549 SmallVector<Expr*, 8> Clobbers;
8550
8551 bool ExprsChanged = false;
8552
8553 // Go through the outputs.
8554 for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
8555 Names.push_back(S->getOutputIdentifier(I));
8556
8557 // No need to transform the constraint literal.
8558 Constraints.push_back(S->getOutputConstraintLiteral(I));
8559
8560 // Transform the output expr.
8561 Expr *OutputExpr = S->getOutputExpr(I);
8562 ExprResult Result = getDerived().TransformExpr(OutputExpr);
8563 if (Result.isInvalid())
8564 return StmtError();
8565
8566 ExprsChanged |= Result.get() != OutputExpr;
8567
8568 Exprs.push_back(Result.get());
8569 }
8570
8571 // Go through the inputs.
8572 for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
8573 Names.push_back(S->getInputIdentifier(I));
8574
8575 // No need to transform the constraint literal.
8576 Constraints.push_back(S->getInputConstraintLiteral(I));
8577
8578 // Transform the input expr.
8579 Expr *InputExpr = S->getInputExpr(I);
8580 ExprResult Result = getDerived().TransformExpr(InputExpr);
8581 if (Result.isInvalid())
8582 return StmtError();
8583
8584 ExprsChanged |= Result.get() != InputExpr;
8585
8586 Exprs.push_back(Result.get());
8587 }
8588
8589 // Go through the Labels.
8590 for (unsigned I = 0, E = S->getNumLabels(); I != E; ++I) {
8591 Names.push_back(S->getLabelIdentifier(I));
8592
8593 ExprResult Result = getDerived().TransformExpr(S->getLabelExpr(I));
8594 if (Result.isInvalid())
8595 return StmtError();
8596 ExprsChanged |= Result.get() != S->getLabelExpr(I);
8597 Exprs.push_back(Result.get());
8598 }
8599 if (!getDerived().AlwaysRebuild() && !ExprsChanged)
8600 return S;
8601
8602 // Go through the clobbers.
8603 for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
8604 Clobbers.push_back(S->getClobberStringLiteral(I));
8605
8606 // No need to transform the asm string literal.
8607 AsmString = S->getAsmString();
8608 return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
8609 S->isVolatile(), S->getNumOutputs(),
8610 S->getNumInputs(), Names.data(),
8611 Constraints, Exprs, AsmString.get(),
8612 Clobbers, S->getNumLabels(),
8613 S->getRParenLoc());
8614}
8615
8616template<typename Derived>
8618TreeTransform<Derived>::TransformMSAsmStmt(MSAsmStmt *S) {
8619 ArrayRef<Token> AsmToks = llvm::ArrayRef(S->getAsmToks(), S->getNumAsmToks());
8620
8621 bool HadError = false, HadChange = false;
8622
8623 ArrayRef<Expr*> SrcExprs = S->getAllExprs();
8624 SmallVector<Expr*, 8> TransformedExprs;
8625 TransformedExprs.reserve(SrcExprs.size());
8626 for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
8627 ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
8628 if (!Result.isUsable()) {
8629 HadError = true;
8630 } else {
8631 HadChange |= (Result.get() != SrcExprs[i]);
8632 TransformedExprs.push_back(Result.get());
8633 }
8634 }
8635
8636 if (HadError) return StmtError();
8637 if (!HadChange && !getDerived().AlwaysRebuild())
8638 return Owned(S);
8639
8640 return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
8641 AsmToks, S->getAsmString(),
8642 S->getNumOutputs(), S->getNumInputs(),
8643 S->getAllConstraints(), S->getClobbers(),
8644 TransformedExprs, S->getEndLoc());
8645}
8646
8647// C++ Coroutines
8648template<typename Derived>
8650TreeTransform<Derived>::TransformCoroutineBodyStmt(CoroutineBodyStmt *S) {
8651 auto *ScopeInfo = SemaRef.getCurFunction();
8652 auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
8653 assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
8654 ScopeInfo->NeedsCoroutineSuspends &&
8655 ScopeInfo->CoroutineSuspends.first == nullptr &&
8656 ScopeInfo->CoroutineSuspends.second == nullptr &&
8657 "expected clean scope info");
8658
8659 // Set that we have (possibly-invalid) suspend points before we do anything
8660 // that may fail.
8661 ScopeInfo->setNeedsCoroutineSuspends(false);
8662
8663 // We re-build the coroutine promise object (and the coroutine parameters its
8664 // type and constructor depend on) based on the types used in our current
8665 // function. We must do so, and set it on the current FunctionScopeInfo,
8666 // before attempting to transform the other parts of the coroutine body
8667 // statement, such as the implicit suspend statements (because those
8668 // statements reference the FunctionScopeInfo::CoroutinePromise).
8669 if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
8670 return StmtError();
8671 auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
8672 if (!Promise)
8673 return StmtError();
8674 getDerived().transformedLocalDecl(S->getPromiseDecl(), {Promise});
8675 ScopeInfo->CoroutinePromise = Promise;
8676
8677 // Transform the implicit coroutine statements constructed using dependent
8678 // types during the previous parse: initial and final suspensions, the return
8679 // object, and others. We also transform the coroutine function's body.
8680 StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
8681 if (InitSuspend.isInvalid())
8682 return StmtError();
8683 StmtResult FinalSuspend =
8684 getDerived().TransformStmt(S->getFinalSuspendStmt());
8685 if (FinalSuspend.isInvalid() ||
8686 !SemaRef.checkFinalSuspendNoThrow(FinalSuspend.get()))
8687 return StmtError();
8688 ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
8689 assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
8690
8691 StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
8692 if (BodyRes.isInvalid())
8693 return StmtError();
8694
8695 CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
8696 if (Builder.isInvalid())
8697 return StmtError();
8698
8699 Expr *ReturnObject = S->getReturnValueInit();
8700 assert(ReturnObject && "the return object is expected to be valid");
8701 ExprResult Res = getDerived().TransformInitializer(ReturnObject,
8702 /*NoCopyInit*/ false);
8703 if (Res.isInvalid())
8704 return StmtError();
8705 Builder.ReturnValue = Res.get();
8706
8707 // If during the previous parse the coroutine still had a dependent promise
8708 // statement, we may need to build some implicit coroutine statements
8709 // (such as exception and fallthrough handlers) for the first time.
8710 if (S->hasDependentPromiseType()) {
8711 // We can only build these statements, however, if the current promise type
8712 // is not dependent.
8713 if (!Promise->getType()->isDependentType()) {
8714 assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
8715 !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
8716 "these nodes should not have been built yet");
8717 if (!Builder.buildDependentStatements())
8718 return StmtError();
8719 }
8720 } else {
8721 if (auto *OnFallthrough = S->getFallthroughHandler()) {
8722 StmtResult Res = getDerived().TransformStmt(OnFallthrough);
8723 if (Res.isInvalid())
8724 return StmtError();
8725 Builder.OnFallthrough = Res.get();
8726 }
8727
8728 if (auto *OnException = S->getExceptionHandler()) {
8729 StmtResult Res = getDerived().TransformStmt(OnException);
8730 if (Res.isInvalid())
8731 return StmtError();
8732 Builder.OnException = Res.get();
8733 }
8734
8735 if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
8736 StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
8737 if (Res.isInvalid())
8738 return StmtError();
8739 Builder.ReturnStmtOnAllocFailure = Res.get();
8740 }
8741
8742 // Transform any additional statements we may have already built
8743 assert(S->getAllocate() && S->getDeallocate() &&
8744 "allocation and deallocation calls must already be built");
8745 ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
8746 if (AllocRes.isInvalid())
8747 return StmtError();
8748 Builder.Allocate = AllocRes.get();
8749
8750 ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
8751 if (DeallocRes.isInvalid())
8752 return StmtError();
8753 Builder.Deallocate = DeallocRes.get();
8754
8755 if (auto *ResultDecl = S->getResultDecl()) {
8756 StmtResult Res = getDerived().TransformStmt(ResultDecl);
8757 if (Res.isInvalid())
8758 return StmtError();
8759 Builder.ResultDecl = Res.get();
8760 }
8761
8762 if (auto *ReturnStmt = S->getReturnStmt()) {
8763 StmtResult Res = getDerived().TransformStmt(ReturnStmt);
8764 if (Res.isInvalid())
8765 return StmtError();
8766 Builder.ReturnStmt = Res.get();
8767 }
8768 }
8769
8770 return getDerived().RebuildCoroutineBodyStmt(Builder);
8771}
8772
8773template<typename Derived>
8775TreeTransform<Derived>::TransformCoreturnStmt(CoreturnStmt *S) {
8776 ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
8777 /*NotCopyInit*/false);
8778 if (Result.isInvalid())
8779 return StmtError();
8780
8781 // Always rebuild; we don't know if this needs to be injected into a new
8782 // context or if the promise type has changed.
8783 return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
8784 S->isImplicit());
8785}
8786
8787template <typename Derived>
8788ExprResult TreeTransform<Derived>::TransformCoawaitExpr(CoawaitExpr *E) {
8789 ExprResult Operand = getDerived().TransformInitializer(E->getOperand(),
8790 /*NotCopyInit*/ false);
8791 if (Operand.isInvalid())
8792 return ExprError();
8793
8794 // Rebuild the common-expr from the operand rather than transforming it
8795 // separately.
8796
8797 // FIXME: getCurScope() should not be used during template instantiation.
8798 // We should pick up the set of unqualified lookup results for operator
8799 // co_await during the initial parse.
8800 ExprResult Lookup = getSema().BuildOperatorCoawaitLookupExpr(
8801 getSema().getCurScope(), E->getKeywordLoc());
8802
8803 // Always rebuild; we don't know if this needs to be injected into a new
8804 // context or if the promise type has changed.
8805 return getDerived().RebuildCoawaitExpr(
8806 E->getKeywordLoc(), Operand.get(),
8807 cast<UnresolvedLookupExpr>(Lookup.get()), E->isImplicit());
8808}
8809
8810template <typename Derived>
8812TreeTransform<Derived>::TransformDependentCoawaitExpr(DependentCoawaitExpr *E) {
8813 ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
8814 /*NotCopyInit*/ false);
8815 if (OperandResult.isInvalid())
8816 return ExprError();
8817
8818 ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
8819 E->getOperatorCoawaitLookup());
8820
8821 if (LookupResult.isInvalid())
8822 return ExprError();
8823
8824 // Always rebuild; we don't know if this needs to be injected into a new
8825 // context or if the promise type has changed.
8826 return getDerived().RebuildDependentCoawaitExpr(
8827 E->getKeywordLoc(), OperandResult.get(),
8828 cast<UnresolvedLookupExpr>(LookupResult.get()));
8829}
8830
8831template<typename Derived>
8833TreeTransform<Derived>::TransformCoyieldExpr(CoyieldExpr *E) {
8834 ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
8835 /*NotCopyInit*/false);
8836 if (Result.isInvalid())
8837 return ExprError();
8838
8839 // Always rebuild; we don't know if this needs to be injected into a new
8840 // context or if the promise type has changed.
8841 return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
8842}
8843
8844// Objective-C Statements.
8845
8846template<typename Derived>
8848TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
8849 // Transform the body of the @try.
8850 StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
8851 if (TryBody.isInvalid())
8852 return StmtError();
8853
8854 // Transform the @catch statements (if present).
8855 bool AnyCatchChanged = false;
8856 SmallVector<Stmt*, 8> CatchStmts;
8857 for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
8858 StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
8859 if (Catch.isInvalid())
8860 return StmtError();
8861 if (Catch.get() != S->getCatchStmt(I))
8862 AnyCatchChanged = true;
8863 CatchStmts.push_back(Catch.get());
8864 }
8865
8866 // Transform the @finally statement (if present).
8867 StmtResult Finally;
8868 if (S->getFinallyStmt()) {
8869 Finally = getDerived().TransformStmt(S->getFinallyStmt());
8870 if (Finally.isInvalid())
8871 return StmtError();
8872 }
8873
8874 // If nothing changed, just retain this statement.
8875 if (!getDerived().AlwaysRebuild() &&
8876 TryBody.get() == S->getTryBody() &&
8877 !AnyCatchChanged &&
8878 Finally.get() == S->getFinallyStmt())
8879 return S;
8880
8881 // Build a new statement.
8882 return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
8883 CatchStmts, Finally.get());
8884}
8885
8886template<typename Derived>
8888TreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) {
8889 // Transform the @catch parameter, if there is one.
8890 VarDecl *Var = nullptr;
8891 if (VarDecl *FromVar = S->getCatchParamDecl()) {
8892 TypeSourceInfo *TSInfo = nullptr;
8893 if (FromVar->getTypeSourceInfo()) {
8894 TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
8895 if (!TSInfo)
8896 return StmtError();
8897 }
8898
8899 QualType T;
8900 if (TSInfo)
8901 T = TSInfo->getType();
8902 else {
8903 T = getDerived().TransformType(FromVar->getType());
8904 if (T.isNull())
8905 return StmtError();
8906 }
8907
8908 Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
8909 if (!Var)
8910 return StmtError();
8911 }
8912
8913 StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
8914 if (Body.isInvalid())
8915 return StmtError();
8916
8917 return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
8918 S->getRParenLoc(),
8919 Var, Body.get());
8920}
8921
8922template<typename Derived>
8924TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
8925 // Transform the body.
8926 StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
8927 if (Body.isInvalid())
8928 return StmtError();
8929
8930 // If nothing changed, just retain this statement.
8931 if (!getDerived().AlwaysRebuild() &&
8932 Body.get() == S->getFinallyBody())
8933 return S;
8934
8935 // Build a new statement.
8936 return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
8937 Body.get());
8938}
8939
8940template<typename Derived>
8942TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) {
8944 if (S->getThrowExpr()) {
8945 Operand = getDerived().TransformExpr(S->getThrowExpr());
8946 if (Operand.isInvalid())
8947 return StmtError();
8948 }
8949
8950 if (!getDerived().AlwaysRebuild() &&
8951 Operand.get() == S->getThrowExpr())
8952 return S;
8953
8954 return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
8955}
8956
8957template<typename Derived>
8959TreeTransform<Derived>::TransformObjCAtSynchronizedStmt(
8960 ObjCAtSynchronizedStmt *S) {
8961 // Transform the object we are locking.
8962 ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
8963 if (Object.isInvalid())
8964 return StmtError();
8965 Object =
8966 getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
8967 Object.get());
8968 if (Object.isInvalid())
8969 return StmtError();
8970
8971 // Transform the body.
8972 StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
8973 if (Body.isInvalid())
8974 return StmtError();
8975
8976 // If nothing change, just retain the current statement.
8977 if (!getDerived().AlwaysRebuild() &&
8978 Object.get() == S->getSynchExpr() &&
8979 Body.get() == S->getSynchBody())
8980 return S;
8981
8982 // Build a new statement.
8983 return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
8984 Object.get(), Body.get());
8985}
8986
8987template<typename Derived>
8989TreeTransform<Derived>::TransformObjCAutoreleasePoolStmt(
8990 ObjCAutoreleasePoolStmt *S) {
8991 // Transform the body.
8992 StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
8993 if (Body.isInvalid())
8994 return StmtError();
8995
8996 // If nothing changed, just retain this statement.
8997 if (!getDerived().AlwaysRebuild() &&
8998 Body.get() == S->getSubStmt())
8999 return S;
9000
9001 // Build a new statement.
9002 return getDerived().RebuildObjCAutoreleasePoolStmt(
9003 S->getAtLoc(), Body.get());
9004}
9005
9006template<typename Derived>
9008TreeTransform<Derived>::TransformObjCForCollectionStmt(
9009 ObjCForCollectionStmt *S) {
9010 // Transform the element statement.
9011 StmtResult Element =
9012 getDerived().TransformStmt(S->getElement(), SDK_NotDiscarded);
9013 if (Element.isInvalid())
9014 return StmtError();
9015
9016 // Transform the collection expression.
9017 ExprResult Collection = getDerived().TransformExpr(S->getCollection());
9018 if (Collection.isInvalid())
9019 return StmtError();
9020
9021 // Transform the body.
9022 StmtResult Body = getDerived().TransformStmt(S->getBody());
9023 if (Body.isInvalid())
9024 return StmtError();
9025
9026 // If nothing changed, just retain this statement.
9027 if (!getDerived().AlwaysRebuild() &&
9028 Element.get() == S->getElement() &&
9029 Collection.get() == S->getCollection() &&
9030 Body.get() == S->getBody())
9031 return S;
9032
9033 // Build a new statement.
9034 return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
9035 Element.get(),
9036 Collection.get(),
9037 S->getRParenLoc(),
9038 Body.get());
9039}
9040
9041template <typename Derived>
9042StmtResult TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) {
9043 // Transform the exception declaration, if any.
9044 VarDecl *Var = nullptr;
9045 if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
9046 TypeSourceInfo *T =
9047 getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
9048 if (!T)
9049 return StmtError();
9050
9051 Var = getDerived().RebuildExceptionDecl(
9052 ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
9053 ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
9054 if (!Var || Var->isInvalidDecl())
9055 return StmtError();
9056 }
9057
9058 // Transform the actual exception handler.
9059 StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
9060 if (Handler.isInvalid())
9061 return StmtError();
9062
9063 if (!getDerived().AlwaysRebuild() && !Var &&
9064 Handler.get() == S->getHandlerBlock())
9065 return S;
9066
9067 return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
9068}
9069
9070template <typename Derived>
9071StmtResult TreeTransform<Derived>::TransformCXXTryStmt(CXXTryStmt *S) {
9072 // Transform the try block itself.
9073 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9074 if (TryBlock.isInvalid())
9075 return StmtError();
9076
9077 // Transform the handlers.
9078 bool HandlerChanged = false;
9079 SmallVector<Stmt *, 8> Handlers;
9080 for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
9081 StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
9082 if (Handler.isInvalid())
9083 return StmtError();
9084
9085 HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
9086 Handlers.push_back(Handler.getAs<Stmt>());
9087 }
9088
9089 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9090 !HandlerChanged)
9091 return S;
9092
9093 return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
9094 Handlers);
9095}
9096
9097template<typename Derived>
9099TreeTransform<Derived>::TransformCXXForRangeStmt(CXXForRangeStmt *S) {
9100 EnterExpressionEvaluationContext ForRangeInitContext(
9102 /*LambdaContextDecl=*/nullptr,
9104 getSema().getLangOpts().CPlusPlus23);
9105
9106 // P2718R0 - Lifetime extension in range-based for loops.
9107 if (getSema().getLangOpts().CPlusPlus23) {
9108 auto &LastRecord = getSema().currentEvaluationContext();
9109 LastRecord.InLifetimeExtendingContext = true;
9110 LastRecord.RebuildDefaultArgOrDefaultInit = true;
9111 }
9113 S->getInit() ? getDerived().TransformStmt(S->getInit()) : StmtResult();
9114 if (Init.isInvalid())
9115 return StmtError();
9116
9117 StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
9118 if (Range.isInvalid())
9119 return StmtError();
9120
9121 // Before c++23, ForRangeLifetimeExtendTemps should be empty.
9122 assert(getSema().getLangOpts().CPlusPlus23 ||
9123 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps.empty());
9124 auto ForRangeLifetimeExtendTemps =
9125 getSema().ExprEvalContexts.back().ForRangeLifetimeExtendTemps;
9126
9127 StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
9128 if (Begin.isInvalid())
9129 return StmtError();
9130 StmtResult End = getDerived().TransformStmt(S->getEndStmt());
9131 if (End.isInvalid())
9132 return StmtError();
9133
9134 ExprResult Cond = getDerived().TransformExpr(S->getCond());
9135 if (Cond.isInvalid())
9136 return StmtError();
9137 if (Cond.get())
9138 Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
9139 if (Cond.isInvalid())
9140 return StmtError();
9141 if (Cond.get())
9142 Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
9143
9144 ExprResult Inc = getDerived().TransformExpr(S->getInc());
9145 if (Inc.isInvalid())
9146 return StmtError();
9147 if (Inc.get())
9148 Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
9149
9150 StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
9151 if (LoopVar.isInvalid())
9152 return StmtError();
9153
9154 StmtResult NewStmt = S;
9155 if (getDerived().AlwaysRebuild() ||
9156 Init.get() != S->getInit() ||
9157 Range.get() != S->getRangeStmt() ||
9158 Begin.get() != S->getBeginStmt() ||
9159 End.get() != S->getEndStmt() ||
9160 Cond.get() != S->getCond() ||
9161 Inc.get() != S->getInc() ||
9162 LoopVar.get() != S->getLoopVarStmt()) {
9163 NewStmt = getDerived().RebuildCXXForRangeStmt(
9164 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9165 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9166 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9167 if (NewStmt.isInvalid() && LoopVar.get() != S->getLoopVarStmt()) {
9168 // Might not have attached any initializer to the loop variable.
9169 getSema().ActOnInitializerError(
9170 cast<DeclStmt>(LoopVar.get())->getSingleDecl());
9171 return StmtError();
9172 }
9173 }
9174
9175 // OpenACC Restricts a while-loop inside of certain construct/clause
9176 // combinations, so diagnose that here in OpenACC mode.
9177 SemaOpenACC::LoopInConstructRAII LCR{SemaRef.OpenACC()};
9178 SemaRef.OpenACC().ActOnRangeForStmtBegin(S->getBeginLoc(), S, NewStmt.get());
9179
9180 StmtResult Body = getDerived().TransformStmt(S->getBody());
9181 if (Body.isInvalid())
9182 return StmtError();
9183
9184 SemaRef.OpenACC().ActOnForStmtEnd(S->getBeginLoc(), Body);
9185
9186 // Body has changed but we didn't rebuild the for-range statement. Rebuild
9187 // it now so we have a new statement to attach the body to.
9188 if (Body.get() != S->getBody() && NewStmt.get() == S) {
9189 NewStmt = getDerived().RebuildCXXForRangeStmt(
9190 S->getForLoc(), S->getCoawaitLoc(), Init.get(), S->getColonLoc(),
9191 Range.get(), Begin.get(), End.get(), Cond.get(), Inc.get(),
9192 LoopVar.get(), S->getRParenLoc(), ForRangeLifetimeExtendTemps);
9193 if (NewStmt.isInvalid())
9194 return StmtError();
9195 }
9196
9197 if (NewStmt.get() == S)
9198 return S;
9199
9200 return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
9201}
9202
9203template<typename Derived>
9205TreeTransform<Derived>::TransformMSDependentExistsStmt(
9206 MSDependentExistsStmt *S) {
9207 // Transform the nested-name-specifier, if any.
9208 NestedNameSpecifierLoc QualifierLoc;
9209 if (S->getQualifierLoc()) {
9210 QualifierLoc
9211 = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
9212 if (!QualifierLoc)
9213 return StmtError();
9214 }
9215
9216 // Transform the declaration name.
9217 DeclarationNameInfo NameInfo = S->getNameInfo();
9218 if (NameInfo.getName()) {
9219 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
9220 if (!NameInfo.getName())
9221 return StmtError();
9222 }
9223
9224 // Check whether anything changed.
9225 if (!getDerived().AlwaysRebuild() &&
9226 QualifierLoc == S->getQualifierLoc() &&
9227 NameInfo.getName() == S->getNameInfo().getName())
9228 return S;
9229
9230 // Determine whether this name exists, if we can.
9231 CXXScopeSpec SS;
9232 SS.Adopt(QualifierLoc);
9233 bool Dependent = false;
9234 switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
9235 case Sema::IER_Exists:
9236 if (S->isIfExists())
9237 break;
9238
9239 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9240
9242 if (S->isIfNotExists())
9243 break;
9244
9245 return new (getSema().Context) NullStmt(S->getKeywordLoc());
9246
9248 Dependent = true;
9249 break;
9250
9251 case Sema::IER_Error:
9252 return StmtError();
9253 }
9254
9255 // We need to continue with the instantiation, so do so now.
9256 StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
9257 if (SubStmt.isInvalid())
9258 return StmtError();
9259
9260 // If we have resolved the name, just transform to the substatement.
9261 if (!Dependent)
9262 return SubStmt;
9263
9264 // The name is still dependent, so build a dependent expression again.
9265 return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
9266 S->isIfExists(),
9267 QualifierLoc,
9268 NameInfo,
9269 SubStmt.get());
9270}
9271
9272template<typename Derived>
9274TreeTransform<Derived>::TransformMSPropertyRefExpr(MSPropertyRefExpr *E) {
9275 NestedNameSpecifierLoc QualifierLoc;
9276 if (E->getQualifierLoc()) {
9277 QualifierLoc
9278 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9279 if (!QualifierLoc)
9280 return ExprError();
9281 }
9282
9283 MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
9284 getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
9285 if (!PD)
9286 return ExprError();
9287
9288 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
9289 if (Base.isInvalid())
9290 return ExprError();
9291
9292 return new (SemaRef.getASTContext())
9293 MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
9295 QualifierLoc, E->getMemberLoc());
9296}
9297
9298template <typename Derived>
9299ExprResult TreeTransform<Derived>::TransformMSPropertySubscriptExpr(
9300 MSPropertySubscriptExpr *E) {
9301 auto BaseRes = getDerived().TransformExpr(E->getBase());
9302 if (BaseRes.isInvalid())
9303 return ExprError();
9304 auto IdxRes = getDerived().TransformExpr(E->getIdx());
9305 if (IdxRes.isInvalid())
9306 return ExprError();
9307
9308 if (!getDerived().AlwaysRebuild() &&
9309 BaseRes.get() == E->getBase() &&
9310 IdxRes.get() == E->getIdx())
9311 return E;
9312
9313 return getDerived().RebuildArraySubscriptExpr(
9314 BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
9315}
9316
9317template <typename Derived>
9318StmtResult TreeTransform<Derived>::TransformSEHTryStmt(SEHTryStmt *S) {
9319 StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
9320 if (TryBlock.isInvalid())
9321 return StmtError();
9322
9323 StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
9324 if (Handler.isInvalid())
9325 return StmtError();
9326
9327 if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
9328 Handler.get() == S->getHandler())
9329 return S;
9330
9331 return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
9332 TryBlock.get(), Handler.get());
9333}
9334
9335template <typename Derived>
9336StmtResult TreeTransform<Derived>::TransformSEHFinallyStmt(SEHFinallyStmt *S) {
9337 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9338 if (Block.isInvalid())
9339 return StmtError();
9340
9341 return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
9342}
9343
9344template <typename Derived>
9345StmtResult TreeTransform<Derived>::TransformSEHExceptStmt(SEHExceptStmt *S) {
9346 ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
9347 if (FilterExpr.isInvalid())
9348 return StmtError();
9349
9350 StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
9351 if (Block.isInvalid())
9352 return StmtError();
9353
9354 return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
9355 Block.get());
9356}
9357
9358template <typename Derived>
9360 if (isa<SEHFinallyStmt>(Handler))
9361 return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
9362 else
9363 return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
9364}
9365
9366template<typename Derived>
9369 return S;
9370}
9371
9372//===----------------------------------------------------------------------===//
9373// OpenMP directive transformation
9374//===----------------------------------------------------------------------===//
9375
9376template <typename Derived>
9378TreeTransform<Derived>::TransformOMPCanonicalLoop(OMPCanonicalLoop *L) {
9379 // OMPCanonicalLoops are eliminated during transformation, since they will be
9380 // recomputed by semantic analysis of the associated OMPLoopBasedDirective
9381 // after transformation.
9382 return getDerived().TransformStmt(L->getLoopStmt());
9383}
9384
9385template <typename Derived>
9388
9389 // Transform the clauses
9391 ArrayRef<OMPClause *> Clauses = D->clauses();
9392 TClauses.reserve(Clauses.size());
9393 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
9394 I != E; ++I) {
9395 if (*I) {
9396 getDerived().getSema().OpenMP().StartOpenMPClause((*I)->getClauseKind());
9397 OMPClause *Clause = getDerived().TransformOMPClause(*I);
9398 getDerived().getSema().OpenMP().EndOpenMPClause();
9399 if (Clause)
9400 TClauses.push_back(Clause);
9401 } else {
9402 TClauses.push_back(nullptr);
9403 }
9404 }
9405 StmtResult AssociatedStmt;
9406 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9407 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9408 D->getDirectiveKind(),
9409 /*CurScope=*/nullptr);
9410 StmtResult Body;
9411 {
9412 Sema::CompoundScopeRAII CompoundScope(getSema());
9413 Stmt *CS;
9414 if (D->getDirectiveKind() == OMPD_atomic ||
9415 D->getDirectiveKind() == OMPD_critical ||
9416 D->getDirectiveKind() == OMPD_section ||
9417 D->getDirectiveKind() == OMPD_master)
9418 CS = D->getAssociatedStmt();
9419 else
9420 CS = D->getRawStmt();
9421 Body = getDerived().TransformStmt(CS);
9422 if (Body.isUsable() && isOpenMPLoopDirective(D->getDirectiveKind()) &&
9423 getSema().getLangOpts().OpenMPIRBuilder)
9424 Body = getDerived().RebuildOMPCanonicalLoop(Body.get());
9425 }
9426 AssociatedStmt =
9427 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9428 if (AssociatedStmt.isInvalid()) {
9429 return StmtError();
9430 }
9431 }
9432 if (TClauses.size() != Clauses.size()) {
9433 return StmtError();
9434 }
9435
9436 // Transform directive name for 'omp critical' directive.
9437 DeclarationNameInfo DirName;
9438 if (D->getDirectiveKind() == OMPD_critical) {
9439 DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
9440 DirName = getDerived().TransformDeclarationNameInfo(DirName);
9441 }
9442 OpenMPDirectiveKind CancelRegion = OMPD_unknown;
9443 if (D->getDirectiveKind() == OMPD_cancellation_point) {
9444 CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
9445 } else if (D->getDirectiveKind() == OMPD_cancel) {
9446 CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
9447 }
9448
9449 return getDerived().RebuildOMPExecutableDirective(
9450 D->getDirectiveKind(), DirName, CancelRegion, TClauses,
9451 AssociatedStmt.get(), D->getBeginLoc(), D->getEndLoc());
9452}
9453
9454/// This is mostly the same as above, but allows 'informational' class
9455/// directives when rebuilding the stmt. It still takes an
9456/// OMPExecutableDirective-type argument because we're reusing that as the
9457/// superclass for the 'assume' directive at present, instead of defining a
9458/// mostly-identical OMPInformationalDirective parent class.
9459template <typename Derived>
9462
9463 // Transform the clauses
9465 ArrayRef<OMPClause *> Clauses = D->clauses();
9466 TClauses.reserve(Clauses.size());
9467 for (OMPClause *C : Clauses) {
9468 if (C) {
9469 getDerived().getSema().OpenMP().StartOpenMPClause(C->getClauseKind());
9470 OMPClause *Clause = getDerived().TransformOMPClause(C);
9471 getDerived().getSema().OpenMP().EndOpenMPClause();
9472 if (Clause)
9473 TClauses.push_back(Clause);
9474 } else {
9475 TClauses.push_back(nullptr);
9476 }
9477 }
9478 StmtResult AssociatedStmt;
9479 if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
9480 getDerived().getSema().OpenMP().ActOnOpenMPRegionStart(
9481 D->getDirectiveKind(),
9482 /*CurScope=*/nullptr);
9483 StmtResult Body;
9484 {
9485 Sema::CompoundScopeRAII CompoundScope(getSema());
9486 assert(D->getDirectiveKind() == OMPD_assume &&
9487 "Unexpected informational directive");
9488 Stmt *CS = D->getAssociatedStmt();
9489 Body = getDerived().TransformStmt(CS);
9490 }
9491 AssociatedStmt =
9492 getDerived().getSema().OpenMP().ActOnOpenMPRegionEnd(Body, TClauses);
9493 if (AssociatedStmt.isInvalid())
9494 return StmtError();
9495 }
9496 if (TClauses.size() != Clauses.size())
9497 return StmtError();
9498
9499 DeclarationNameInfo DirName;
9500
9501 return getDerived().RebuildOMPInformationalDirective(
9502 D->getDirectiveKind(), DirName, TClauses, AssociatedStmt.get(),
9503 D->getBeginLoc(), D->getEndLoc());
9504}
9505
9506template <typename Derived>
9509 // TODO: Fix This
9510 SemaRef.Diag(D->getBeginLoc(), diag::err_omp_instantiation_not_supported)
9511 << getOpenMPDirectiveName(D->getDirectiveKind());
9512 return StmtError();
9513}
9514
9515template <typename Derived>
9517TreeTransform<Derived>::TransformOMPParallelDirective(OMPParallelDirective *D) {
9518 DeclarationNameInfo DirName;
9519 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9520 OMPD_parallel, DirName, nullptr, D->getBeginLoc());
9521 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9522 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9523 return Res;
9524}
9525
9526template <typename Derived>
9528TreeTransform<Derived>::TransformOMPSimdDirective(OMPSimdDirective *D) {
9529 DeclarationNameInfo DirName;
9530 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9531 OMPD_simd, DirName, nullptr, D->getBeginLoc());
9532 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9533 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9534 return Res;
9535}
9536
9537template <typename Derived>
9539TreeTransform<Derived>::TransformOMPTileDirective(OMPTileDirective *D) {
9540 DeclarationNameInfo DirName;
9541 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9542 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9543 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9544 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9545 return Res;
9546}
9547
9548template <typename Derived>
9550TreeTransform<Derived>::TransformOMPUnrollDirective(OMPUnrollDirective *D) {
9551 DeclarationNameInfo DirName;
9552 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9553 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9554 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9555 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9556 return Res;
9557}
9558
9559template <typename Derived>
9561TreeTransform<Derived>::TransformOMPReverseDirective(OMPReverseDirective *D) {
9562 DeclarationNameInfo DirName;
9563 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9564 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9565 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9566 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9567 return Res;
9568}
9569
9570template <typename Derived>
9571StmtResult TreeTransform<Derived>::TransformOMPInterchangeDirective(
9572 OMPInterchangeDirective *D) {
9573 DeclarationNameInfo DirName;
9574 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9575 D->getDirectiveKind(), DirName, nullptr, D->getBeginLoc());
9576 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9577 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9578 return Res;
9579}
9580
9581template <typename Derived>
9583TreeTransform<Derived>::TransformOMPForDirective(OMPForDirective *D) {
9584 DeclarationNameInfo DirName;
9585 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9586 OMPD_for, DirName, nullptr, D->getBeginLoc());
9587 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9588 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9589 return Res;
9590}
9591
9592template <typename Derived>
9594TreeTransform<Derived>::TransformOMPForSimdDirective(OMPForSimdDirective *D) {
9595 DeclarationNameInfo DirName;
9596 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9597 OMPD_for_simd, DirName, nullptr, D->getBeginLoc());
9598 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9599 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9600 return Res;
9601}
9602
9603template <typename Derived>
9605TreeTransform<Derived>::TransformOMPSectionsDirective(OMPSectionsDirective *D) {
9606 DeclarationNameInfo DirName;
9607 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9608 OMPD_sections, DirName, nullptr, D->getBeginLoc());
9609 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9610 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9611 return Res;
9612}
9613
9614template <typename Derived>
9616TreeTransform<Derived>::TransformOMPSectionDirective(OMPSectionDirective *D) {
9617 DeclarationNameInfo DirName;
9618 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9619 OMPD_section, DirName, nullptr, D->getBeginLoc());
9620 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9621 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9622 return Res;
9623}
9624
9625template <typename Derived>
9627TreeTransform<Derived>::TransformOMPScopeDirective(OMPScopeDirective *D) {
9628 DeclarationNameInfo DirName;
9629 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9630 OMPD_scope, DirName, nullptr, D->getBeginLoc());
9631 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9632 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9633 return Res;
9634}
9635
9636template <typename Derived>
9638TreeTransform<Derived>::TransformOMPSingleDirective(OMPSingleDirective *D) {
9639 DeclarationNameInfo DirName;
9640 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9641 OMPD_single, DirName, nullptr, D->getBeginLoc());
9642 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9643 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9644 return Res;
9645}
9646
9647template <typename Derived>
9649TreeTransform<Derived>::TransformOMPMasterDirective(OMPMasterDirective *D) {
9650 DeclarationNameInfo DirName;
9651 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9652 OMPD_master, DirName, nullptr, D->getBeginLoc());
9653 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9654 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9655 return Res;
9656}
9657
9658template <typename Derived>
9660TreeTransform<Derived>::TransformOMPCriticalDirective(OMPCriticalDirective *D) {
9661 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9662 OMPD_critical, D->getDirectiveName(), nullptr, D->getBeginLoc());
9663 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9664 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9665 return Res;
9666}
9667
9668template <typename Derived>
9669StmtResult TreeTransform<Derived>::TransformOMPParallelForDirective(
9670 OMPParallelForDirective *D) {
9671 DeclarationNameInfo DirName;
9672 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9673 OMPD_parallel_for, DirName, nullptr, D->getBeginLoc());
9674 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9675 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9676 return Res;
9677}
9678
9679template <typename Derived>
9680StmtResult TreeTransform<Derived>::TransformOMPParallelForSimdDirective(
9681 OMPParallelForSimdDirective *D) {
9682 DeclarationNameInfo DirName;
9683 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9684 OMPD_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
9685 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9686 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9687 return Res;
9688}
9689
9690template <typename Derived>
9691StmtResult TreeTransform<Derived>::TransformOMPParallelMasterDirective(
9692 OMPParallelMasterDirective *D) {
9693 DeclarationNameInfo DirName;
9694 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9695 OMPD_parallel_master, DirName, nullptr, D->getBeginLoc());
9696 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9697 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9698 return Res;
9699}
9700
9701template <typename Derived>
9702StmtResult TreeTransform<Derived>::TransformOMPParallelMaskedDirective(
9703 OMPParallelMaskedDirective *D) {
9704 DeclarationNameInfo DirName;
9705 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9706 OMPD_parallel_masked, DirName, nullptr, D->getBeginLoc());
9707 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9708 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9709 return Res;
9710}
9711
9712template <typename Derived>
9713StmtResult TreeTransform<Derived>::TransformOMPParallelSectionsDirective(
9714 OMPParallelSectionsDirective *D) {
9715 DeclarationNameInfo DirName;
9716 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9717 OMPD_parallel_sections, DirName, nullptr, D->getBeginLoc());
9718 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9719 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9720 return Res;
9721}
9722
9723template <typename Derived>
9725TreeTransform<Derived>::TransformOMPTaskDirective(OMPTaskDirective *D) {
9726 DeclarationNameInfo DirName;
9727 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9728 OMPD_task, DirName, nullptr, D->getBeginLoc());
9729 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9730 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9731 return Res;
9732}
9733
9734template <typename Derived>
9735StmtResult TreeTransform<Derived>::TransformOMPTaskyieldDirective(
9736 OMPTaskyieldDirective *D) {
9737 DeclarationNameInfo DirName;
9738 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9739 OMPD_taskyield, DirName, nullptr, D->getBeginLoc());
9740 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9741 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9742 return Res;
9743}
9744
9745template <typename Derived>
9747TreeTransform<Derived>::TransformOMPBarrierDirective(OMPBarrierDirective *D) {
9748 DeclarationNameInfo DirName;
9749 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9750 OMPD_barrier, DirName, nullptr, D->getBeginLoc());
9751 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9752 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9753 return Res;
9754}
9755
9756template <typename Derived>
9758TreeTransform<Derived>::TransformOMPTaskwaitDirective(OMPTaskwaitDirective *D) {
9759 DeclarationNameInfo DirName;
9760 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9761 OMPD_taskwait, DirName, nullptr, D->getBeginLoc());
9762 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9763 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9764 return Res;
9765}
9766
9767template <typename Derived>
9769TreeTransform<Derived>::TransformOMPAssumeDirective(OMPAssumeDirective *D) {
9770 DeclarationNameInfo DirName;
9771 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9772 OMPD_assume, DirName, nullptr, D->getBeginLoc());
9773 StmtResult Res = getDerived().TransformOMPInformationalDirective(D);
9774 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9775 return Res;
9776}
9777
9778template <typename Derived>
9780TreeTransform<Derived>::TransformOMPErrorDirective(OMPErrorDirective *D) {
9781 DeclarationNameInfo DirName;
9782 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9783 OMPD_error, DirName, nullptr, D->getBeginLoc());
9784 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9785 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9786 return Res;
9787}
9788
9789template <typename Derived>
9790StmtResult TreeTransform<Derived>::TransformOMPTaskgroupDirective(
9791 OMPTaskgroupDirective *D) {
9792 DeclarationNameInfo DirName;
9793 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9794 OMPD_taskgroup, DirName, nullptr, D->getBeginLoc());
9795 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9796 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9797 return Res;
9798}
9799
9800template <typename Derived>
9802TreeTransform<Derived>::TransformOMPFlushDirective(OMPFlushDirective *D) {
9803 DeclarationNameInfo DirName;
9804 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9805 OMPD_flush, DirName, nullptr, D->getBeginLoc());
9806 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9807 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9808 return Res;
9809}
9810
9811template <typename Derived>
9813TreeTransform<Derived>::TransformOMPDepobjDirective(OMPDepobjDirective *D) {
9814 DeclarationNameInfo DirName;
9815 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9816 OMPD_depobj, DirName, nullptr, D->getBeginLoc());
9817 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9818 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9819 return Res;
9820}
9821
9822template <typename Derived>
9824TreeTransform<Derived>::TransformOMPScanDirective(OMPScanDirective *D) {
9825 DeclarationNameInfo DirName;
9826 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9827 OMPD_scan, DirName, nullptr, D->getBeginLoc());
9828 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9829 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9830 return Res;
9831}
9832
9833template <typename Derived>
9835TreeTransform<Derived>::TransformOMPOrderedDirective(OMPOrderedDirective *D) {
9836 DeclarationNameInfo DirName;
9837 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9838 OMPD_ordered, DirName, nullptr, D->getBeginLoc());
9839 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9840 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9841 return Res;
9842}
9843
9844template <typename Derived>
9846TreeTransform<Derived>::TransformOMPAtomicDirective(OMPAtomicDirective *D) {
9847 DeclarationNameInfo DirName;
9848 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9849 OMPD_atomic, DirName, nullptr, D->getBeginLoc());
9850 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9851 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9852 return Res;
9853}
9854
9855template <typename Derived>
9857TreeTransform<Derived>::TransformOMPTargetDirective(OMPTargetDirective *D) {
9858 DeclarationNameInfo DirName;
9859 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9860 OMPD_target, DirName, nullptr, D->getBeginLoc());
9861 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9862 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9863 return Res;
9864}
9865
9866template <typename Derived>
9867StmtResult TreeTransform<Derived>::TransformOMPTargetDataDirective(
9868 OMPTargetDataDirective *D) {
9869 DeclarationNameInfo DirName;
9870 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9871 OMPD_target_data, DirName, nullptr, D->getBeginLoc());
9872 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9873 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9874 return Res;
9875}
9876
9877template <typename Derived>
9878StmtResult TreeTransform<Derived>::TransformOMPTargetEnterDataDirective(
9879 OMPTargetEnterDataDirective *D) {
9880 DeclarationNameInfo DirName;
9881 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9882 OMPD_target_enter_data, DirName, nullptr, D->getBeginLoc());
9883 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9884 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9885 return Res;
9886}
9887
9888template <typename Derived>
9889StmtResult TreeTransform<Derived>::TransformOMPTargetExitDataDirective(
9890 OMPTargetExitDataDirective *D) {
9891 DeclarationNameInfo DirName;
9892 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9893 OMPD_target_exit_data, DirName, nullptr, D->getBeginLoc());
9894 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9895 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9896 return Res;
9897}
9898
9899template <typename Derived>
9900StmtResult TreeTransform<Derived>::TransformOMPTargetParallelDirective(
9901 OMPTargetParallelDirective *D) {
9902 DeclarationNameInfo DirName;
9903 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9904 OMPD_target_parallel, DirName, nullptr, D->getBeginLoc());
9905 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9906 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9907 return Res;
9908}
9909
9910template <typename Derived>
9911StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForDirective(
9912 OMPTargetParallelForDirective *D) {
9913 DeclarationNameInfo DirName;
9914 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9915 OMPD_target_parallel_for, DirName, nullptr, D->getBeginLoc());
9916 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9917 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9918 return Res;
9919}
9920
9921template <typename Derived>
9922StmtResult TreeTransform<Derived>::TransformOMPTargetUpdateDirective(
9923 OMPTargetUpdateDirective *D) {
9924 DeclarationNameInfo DirName;
9925 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9926 OMPD_target_update, DirName, nullptr, D->getBeginLoc());
9927 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9928 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9929 return Res;
9930}
9931
9932template <typename Derived>
9934TreeTransform<Derived>::TransformOMPTeamsDirective(OMPTeamsDirective *D) {
9935 DeclarationNameInfo DirName;
9936 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9937 OMPD_teams, DirName, nullptr, D->getBeginLoc());
9938 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9939 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9940 return Res;
9941}
9942
9943template <typename Derived>
9944StmtResult TreeTransform<Derived>::TransformOMPCancellationPointDirective(
9945 OMPCancellationPointDirective *D) {
9946 DeclarationNameInfo DirName;
9947 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9948 OMPD_cancellation_point, DirName, nullptr, D->getBeginLoc());
9949 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9950 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9951 return Res;
9952}
9953
9954template <typename Derived>
9956TreeTransform<Derived>::TransformOMPCancelDirective(OMPCancelDirective *D) {
9957 DeclarationNameInfo DirName;
9958 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9959 OMPD_cancel, DirName, nullptr, D->getBeginLoc());
9960 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9961 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9962 return Res;
9963}
9964
9965template <typename Derived>
9967TreeTransform<Derived>::TransformOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
9968 DeclarationNameInfo DirName;
9969 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9970 OMPD_taskloop, DirName, nullptr, D->getBeginLoc());
9971 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9972 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9973 return Res;
9974}
9975
9976template <typename Derived>
9977StmtResult TreeTransform<Derived>::TransformOMPTaskLoopSimdDirective(
9978 OMPTaskLoopSimdDirective *D) {
9979 DeclarationNameInfo DirName;
9980 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9981 OMPD_taskloop_simd, DirName, nullptr, D->getBeginLoc());
9982 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9983 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9984 return Res;
9985}
9986
9987template <typename Derived>
9988StmtResult TreeTransform<Derived>::TransformOMPMasterTaskLoopDirective(
9989 OMPMasterTaskLoopDirective *D) {
9990 DeclarationNameInfo DirName;
9991 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
9992 OMPD_master_taskloop, DirName, nullptr, D->getBeginLoc());
9993 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
9994 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
9995 return Res;
9996}
9997
9998template <typename Derived>
9999StmtResult TreeTransform<Derived>::TransformOMPMaskedTaskLoopDirective(
10000 OMPMaskedTaskLoopDirective *D) {
10001 DeclarationNameInfo DirName;
10002 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10003 OMPD_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10004 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10005 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10006 return Res;
10007}
10008
10009template <typename Derived>
10010StmtResult TreeTransform<Derived>::TransformOMPMasterTaskLoopSimdDirective(
10011 OMPMasterTaskLoopSimdDirective *D) {
10012 DeclarationNameInfo DirName;
10013 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10014 OMPD_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10015 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10016 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10017 return Res;
10018}
10019
10020template <typename Derived>
10021StmtResult TreeTransform<Derived>::TransformOMPMaskedTaskLoopSimdDirective(
10022 OMPMaskedTaskLoopSimdDirective *D) {
10023 DeclarationNameInfo DirName;
10024 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10025 OMPD_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10026 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10027 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10028 return Res;
10029}
10030
10031template <typename Derived>
10032StmtResult TreeTransform<Derived>::TransformOMPParallelMasterTaskLoopDirective(
10033 OMPParallelMasterTaskLoopDirective *D) {
10034 DeclarationNameInfo DirName;
10035 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10036 OMPD_parallel_master_taskloop, DirName, nullptr, D->getBeginLoc());
10037 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10038 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10039 return Res;
10040}
10041
10042template <typename Derived>
10043StmtResult TreeTransform<Derived>::TransformOMPParallelMaskedTaskLoopDirective(
10044 OMPParallelMaskedTaskLoopDirective *D) {
10045 DeclarationNameInfo DirName;
10046 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10047 OMPD_parallel_masked_taskloop, DirName, nullptr, D->getBeginLoc());
10048 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10049 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10050 return Res;
10051}
10052
10053template <typename Derived>
10055TreeTransform<Derived>::TransformOMPParallelMasterTaskLoopSimdDirective(
10056 OMPParallelMasterTaskLoopSimdDirective *D) {
10057 DeclarationNameInfo DirName;
10058 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10059 OMPD_parallel_master_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10060 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10061 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10062 return Res;
10063}
10064
10065template <typename Derived>
10067TreeTransform<Derived>::TransformOMPParallelMaskedTaskLoopSimdDirective(
10068 OMPParallelMaskedTaskLoopSimdDirective *D) {
10069 DeclarationNameInfo DirName;
10070 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10071 OMPD_parallel_masked_taskloop_simd, DirName, nullptr, D->getBeginLoc());
10072 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10073 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10074 return Res;
10075}
10076
10077template <typename Derived>
10078StmtResult TreeTransform<Derived>::TransformOMPDistributeDirective(
10079 OMPDistributeDirective *D) {
10080 DeclarationNameInfo DirName;
10081 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10082 OMPD_distribute, DirName, nullptr, D->getBeginLoc());
10083 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10084 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10085 return Res;
10086}
10087
10088template <typename Derived>
10089StmtResult TreeTransform<Derived>::TransformOMPDistributeParallelForDirective(
10090 OMPDistributeParallelForDirective *D) {
10091 DeclarationNameInfo DirName;
10092 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10093 OMPD_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10094 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10095 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10096 return Res;
10097}
10098
10099template <typename Derived>
10101TreeTransform<Derived>::TransformOMPDistributeParallelForSimdDirective(
10102 OMPDistributeParallelForSimdDirective *D) {
10103 DeclarationNameInfo DirName;
10104 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10105 OMPD_distribute_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10106 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10107 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10108 return Res;
10109}
10110
10111template <typename Derived>
10112StmtResult TreeTransform<Derived>::TransformOMPDistributeSimdDirective(
10113 OMPDistributeSimdDirective *D) {
10114 DeclarationNameInfo DirName;
10115 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10116 OMPD_distribute_simd, DirName, nullptr, D->getBeginLoc());
10117 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10118 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10119 return Res;
10120}
10121
10122template <typename Derived>
10123StmtResult TreeTransform<Derived>::TransformOMPTargetParallelForSimdDirective(
10124 OMPTargetParallelForSimdDirective *D) {
10125 DeclarationNameInfo DirName;
10126 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10127 OMPD_target_parallel_for_simd, DirName, nullptr, D->getBeginLoc());
10128 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10129 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10130 return Res;
10131}
10132
10133template <typename Derived>
10134StmtResult TreeTransform<Derived>::TransformOMPTargetSimdDirective(
10135 OMPTargetSimdDirective *D) {
10136 DeclarationNameInfo DirName;
10137 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10138 OMPD_target_simd, DirName, nullptr, D->getBeginLoc());
10139 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10140 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10141 return Res;
10142}
10143
10144template <typename Derived>
10145StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeDirective(
10146 OMPTeamsDistributeDirective *D) {
10147 DeclarationNameInfo DirName;
10148 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10149 OMPD_teams_distribute, DirName, nullptr, D->getBeginLoc());
10150 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10151 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10152 return Res;
10153}
10154
10155template <typename Derived>
10156StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeSimdDirective(
10157 OMPTeamsDistributeSimdDirective *D) {
10158 DeclarationNameInfo DirName;
10159 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10160 OMPD_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10161 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10162 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10163 return Res;
10164}
10165
10166template <typename Derived>
10167StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeParallelForSimdDirective(
10168 OMPTeamsDistributeParallelForSimdDirective *D) {
10169 DeclarationNameInfo DirName;
10170 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10171 OMPD_teams_distribute_parallel_for_simd, DirName, nullptr,
10172 D->getBeginLoc());
10173 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10174 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10175 return Res;
10176}
10177
10178template <typename Derived>
10179StmtResult TreeTransform<Derived>::TransformOMPTeamsDistributeParallelForDirective(
10180 OMPTeamsDistributeParallelForDirective *D) {
10181 DeclarationNameInfo DirName;
10182 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10183 OMPD_teams_distribute_parallel_for, DirName, nullptr, D->getBeginLoc());
10184 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10185 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10186 return Res;
10187}
10188
10189template <typename Derived>
10190StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsDirective(
10191 OMPTargetTeamsDirective *D) {
10192 DeclarationNameInfo DirName;
10193 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10194 OMPD_target_teams, DirName, nullptr, D->getBeginLoc());
10195 auto Res = getDerived().TransformOMPExecutableDirective(D);
10196 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10197 return Res;
10198}
10199
10200template <typename Derived>
10201StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsDistributeDirective(
10202 OMPTargetTeamsDistributeDirective *D) {
10203 DeclarationNameInfo DirName;
10204 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10205 OMPD_target_teams_distribute, DirName, nullptr, D->getBeginLoc());
10206 auto Res = getDerived().TransformOMPExecutableDirective(D);
10207 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10208 return Res;
10209}
10210
10211template <typename Derived>
10213TreeTransform<Derived>::TransformOMPTargetTeamsDistributeParallelForDirective(
10214 OMPTargetTeamsDistributeParallelForDirective *D) {
10215 DeclarationNameInfo DirName;
10216 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10217 OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
10218 D->getBeginLoc());
10219 auto Res = getDerived().TransformOMPExecutableDirective(D);
10220 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10221 return Res;
10222}
10223
10224template <typename Derived>
10225StmtResult TreeTransform<Derived>::
10226 TransformOMPTargetTeamsDistributeParallelForSimdDirective(
10227 OMPTargetTeamsDistributeParallelForSimdDirective *D) {
10228 DeclarationNameInfo DirName;
10229 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10230 OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
10231 D->getBeginLoc());
10232 auto Res = getDerived().TransformOMPExecutableDirective(D);
10233 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10234 return Res;
10235}
10236
10237template <typename Derived>
10239TreeTransform<Derived>::TransformOMPTargetTeamsDistributeSimdDirective(
10240 OMPTargetTeamsDistributeSimdDirective *D) {
10241 DeclarationNameInfo DirName;
10242 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10243 OMPD_target_teams_distribute_simd, DirName, nullptr, D->getBeginLoc());
10244 auto Res = getDerived().TransformOMPExecutableDirective(D);
10245 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10246 return Res;
10247}
10248
10249template <typename Derived>
10251TreeTransform<Derived>::TransformOMPInteropDirective(OMPInteropDirective *D) {
10252 DeclarationNameInfo DirName;
10253 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10254 OMPD_interop, DirName, nullptr, D->getBeginLoc());
10255 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10256 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10257 return Res;
10258}
10259
10260template <typename Derived>
10262TreeTransform<Derived>::TransformOMPDispatchDirective(OMPDispatchDirective *D) {
10263 DeclarationNameInfo DirName;
10264 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10265 OMPD_dispatch, DirName, nullptr, D->getBeginLoc());
10266 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10267 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10268 return Res;
10269}
10270
10271template <typename Derived>
10273TreeTransform<Derived>::TransformOMPMaskedDirective(OMPMaskedDirective *D) {
10274 DeclarationNameInfo DirName;
10275 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10276 OMPD_masked, DirName, nullptr, D->getBeginLoc());
10277 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10278 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10279 return Res;
10280}
10281
10282template <typename Derived>
10283StmtResult TreeTransform<Derived>::TransformOMPGenericLoopDirective(
10284 OMPGenericLoopDirective *D) {
10285 DeclarationNameInfo DirName;
10286 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10287 OMPD_loop, DirName, nullptr, D->getBeginLoc());
10288 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10289 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10290 return Res;
10291}
10292
10293template <typename Derived>
10294StmtResult TreeTransform<Derived>::TransformOMPTeamsGenericLoopDirective(
10295 OMPTeamsGenericLoopDirective *D) {
10296 DeclarationNameInfo DirName;
10297 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10298 OMPD_teams_loop, DirName, nullptr, D->getBeginLoc());
10299 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10300 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10301 return Res;
10302}
10303
10304template <typename Derived>
10305StmtResult TreeTransform<Derived>::TransformOMPTargetTeamsGenericLoopDirective(
10306 OMPTargetTeamsGenericLoopDirective *D) {
10307 DeclarationNameInfo DirName;
10308 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10309 OMPD_target_teams_loop, DirName, nullptr, D->getBeginLoc());
10310 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10311 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10312 return Res;
10313}
10314
10315template <typename Derived>
10316StmtResult TreeTransform<Derived>::TransformOMPParallelGenericLoopDirective(
10317 OMPParallelGenericLoopDirective *D) {
10318 DeclarationNameInfo DirName;
10319 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10320 OMPD_parallel_loop, DirName, nullptr, D->getBeginLoc());
10321 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10322 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10323 return Res;
10324}
10325
10326template <typename Derived>
10328TreeTransform<Derived>::TransformOMPTargetParallelGenericLoopDirective(
10329 OMPTargetParallelGenericLoopDirective *D) {
10330 DeclarationNameInfo DirName;
10331 getDerived().getSema().OpenMP().StartOpenMPDSABlock(
10332 OMPD_target_parallel_loop, DirName, nullptr, D->getBeginLoc());
10333 StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
10334 getDerived().getSema().OpenMP().EndOpenMPDSABlock(Res.get());
10335 return Res;
10336}
10337
10338//===----------------------------------------------------------------------===//
10339// OpenMP clause transformation
10340//===----------------------------------------------------------------------===//
10341template <typename Derived>
10342OMPClause *TreeTransform<Derived>::TransformOMPIfClause(OMPIfClause *C) {
10343 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10344 if (Cond.isInvalid())
10345 return nullptr;
10346 return getDerived().RebuildOMPIfClause(
10347 C->getNameModifier(), Cond.get(), C->getBeginLoc(), C->getLParenLoc(),
10348 C->getNameModifierLoc(), C->getColonLoc(), C->getEndLoc());
10349}
10350
10351template <typename Derived>
10352OMPClause *TreeTransform<Derived>::TransformOMPFinalClause(OMPFinalClause *C) {
10353 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10354 if (Cond.isInvalid())
10355 return nullptr;
10356 return getDerived().RebuildOMPFinalClause(Cond.get(), C->getBeginLoc(),
10357 C->getLParenLoc(), C->getEndLoc());
10358}
10359
10360template <typename Derived>
10361OMPClause *
10362TreeTransform<Derived>::TransformOMPNumThreadsClause(OMPNumThreadsClause *C) {
10363 ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
10364 if (NumThreads.isInvalid())
10365 return nullptr;
10366 return getDerived().RebuildOMPNumThreadsClause(
10367 NumThreads.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10368}
10369
10370template <typename Derived>
10371OMPClause *
10372TreeTransform<Derived>::TransformOMPSafelenClause(OMPSafelenClause *C) {
10373 ExprResult E = getDerived().TransformExpr(C->getSafelen());
10374 if (E.isInvalid())
10375 return nullptr;
10376 return getDerived().RebuildOMPSafelenClause(
10377 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10378}
10379
10380template <typename Derived>
10381OMPClause *
10382TreeTransform<Derived>::TransformOMPAllocatorClause(OMPAllocatorClause *C) {
10383 ExprResult E = getDerived().TransformExpr(C->getAllocator());
10384 if (E.isInvalid())
10385 return nullptr;
10386 return getDerived().RebuildOMPAllocatorClause(
10387 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10388}
10389
10390template <typename Derived>
10391OMPClause *
10392TreeTransform<Derived>::TransformOMPSimdlenClause(OMPSimdlenClause *C) {
10393 ExprResult E = getDerived().TransformExpr(C->getSimdlen());
10394 if (E.isInvalid())
10395 return nullptr;
10396 return getDerived().RebuildOMPSimdlenClause(
10397 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10398}
10399
10400template <typename Derived>
10401OMPClause *TreeTransform<Derived>::TransformOMPSizesClause(OMPSizesClause *C) {
10402 SmallVector<Expr *, 4> TransformedSizes;
10403 TransformedSizes.reserve(C->getNumSizes());
10404 bool Changed = false;
10405 for (Expr *E : C->getSizesRefs()) {
10406 if (!E) {
10407 TransformedSizes.push_back(nullptr);
10408 continue;
10409 }
10410
10411 ExprResult T = getDerived().TransformExpr(E);
10412 if (T.isInvalid())
10413 return nullptr;
10414 if (E != T.get())
10415 Changed = true;
10416 TransformedSizes.push_back(T.get());
10417 }
10418
10419 if (!Changed && !getDerived().AlwaysRebuild())
10420 return C;
10421 return RebuildOMPSizesClause(TransformedSizes, C->getBeginLoc(),
10422 C->getLParenLoc(), C->getEndLoc());
10423}
10424
10425template <typename Derived>
10426OMPClause *
10427TreeTransform<Derived>::TransformOMPPermutationClause(OMPPermutationClause *C) {
10428 SmallVector<Expr *> TransformedArgs;
10429 TransformedArgs.reserve(C->getNumLoops());
10430 bool Changed = false;
10431 for (Expr *E : C->getArgsRefs()) {
10432 if (!E) {
10433 TransformedArgs.push_back(nullptr);
10434 continue;
10435 }
10436
10437 ExprResult T = getDerived().TransformExpr(E);
10438 if (T.isInvalid())
10439 return nullptr;
10440 if (E != T.get())
10441 Changed = true;
10442 TransformedArgs.push_back(T.get());
10443 }
10444
10445 if (!Changed && !getDerived().AlwaysRebuild())
10446 return C;
10447 return RebuildOMPPermutationClause(TransformedArgs, C->getBeginLoc(),
10448 C->getLParenLoc(), C->getEndLoc());
10449}
10450
10451template <typename Derived>
10452OMPClause *TreeTransform<Derived>::TransformOMPFullClause(OMPFullClause *C) {
10453 if (!getDerived().AlwaysRebuild())
10454 return C;
10455 return RebuildOMPFullClause(C->getBeginLoc(), C->getEndLoc());
10456}
10457
10458template <typename Derived>
10459OMPClause *
10460TreeTransform<Derived>::TransformOMPPartialClause(OMPPartialClause *C) {
10461 ExprResult T = getDerived().TransformExpr(C->getFactor());
10462 if (T.isInvalid())
10463 return nullptr;
10464 Expr *Factor = T.get();
10465 bool Changed = Factor != C->getFactor();
10466
10467 if (!Changed && !getDerived().AlwaysRebuild())
10468 return C;
10469 return RebuildOMPPartialClause(Factor, C->getBeginLoc(), C->getLParenLoc(),
10470 C->getEndLoc());
10471}
10472
10473template <typename Derived>
10474OMPClause *
10475TreeTransform<Derived>::TransformOMPCollapseClause(OMPCollapseClause *C) {
10476 ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
10477 if (E.isInvalid())
10478 return nullptr;
10479 return getDerived().RebuildOMPCollapseClause(
10480 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10481}
10482
10483template <typename Derived>
10484OMPClause *
10485TreeTransform<Derived>::TransformOMPDefaultClause(OMPDefaultClause *C) {
10486 return getDerived().RebuildOMPDefaultClause(
10487 C->getDefaultKind(), C->getDefaultKindKwLoc(), C->getBeginLoc(),
10488 C->getLParenLoc(), C->getEndLoc());
10489}
10490
10491template <typename Derived>
10492OMPClause *
10493TreeTransform<Derived>::TransformOMPProcBindClause(OMPProcBindClause *C) {
10494 return getDerived().RebuildOMPProcBindClause(
10495 C->getProcBindKind(), C->getProcBindKindKwLoc(), C->getBeginLoc(),
10496 C->getLParenLoc(), C->getEndLoc());
10497}
10498
10499template <typename Derived>
10500OMPClause *
10501TreeTransform<Derived>::TransformOMPScheduleClause(OMPScheduleClause *C) {
10502 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
10503 if (E.isInvalid())
10504 return nullptr;
10505 return getDerived().RebuildOMPScheduleClause(
10506 C->getFirstScheduleModifier(), C->getSecondScheduleModifier(),
10507 C->getScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
10508 C->getFirstScheduleModifierLoc(), C->getSecondScheduleModifierLoc(),
10509 C->getScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
10510}
10511
10512template <typename Derived>
10513OMPClause *
10514TreeTransform<Derived>::TransformOMPOrderedClause(OMPOrderedClause *C) {
10515 ExprResult E;
10516 if (auto *Num = C->getNumForLoops()) {
10517 E = getDerived().TransformExpr(Num);
10518 if (E.isInvalid())
10519 return nullptr;
10520 }
10521 return getDerived().RebuildOMPOrderedClause(C->getBeginLoc(), C->getEndLoc(),
10522 C->getLParenLoc(), E.get());
10523}
10524
10525template <typename Derived>
10526OMPClause *
10527TreeTransform<Derived>::TransformOMPDetachClause(OMPDetachClause *C) {
10528 ExprResult E;
10529 if (Expr *Evt = C->getEventHandler()) {
10530 E = getDerived().TransformExpr(Evt);
10531 if (E.isInvalid())
10532 return nullptr;
10533 }
10534 return getDerived().RebuildOMPDetachClause(E.get(), C->getBeginLoc(),
10535 C->getLParenLoc(), C->getEndLoc());
10536}
10537
10538template <typename Derived>
10539OMPClause *
10540TreeTransform<Derived>::TransformOMPNowaitClause(OMPNowaitClause *C) {
10541 // No need to rebuild this clause, no template-dependent parameters.
10542 return C;
10543}
10544
10545template <typename Derived>
10546OMPClause *
10547TreeTransform<Derived>::TransformOMPUntiedClause(OMPUntiedClause *C) {
10548 // No need to rebuild this clause, no template-dependent parameters.
10549 return C;
10550}
10551
10552template <typename Derived>
10553OMPClause *
10554TreeTransform<Derived>::TransformOMPMergeableClause(OMPMergeableClause *C) {
10555 // No need to rebuild this clause, no template-dependent parameters.
10556 return C;
10557}
10558
10559template <typename Derived>
10560OMPClause *TreeTransform<Derived>::TransformOMPReadClause(OMPReadClause *C) {
10561 // No need to rebuild this clause, no template-dependent parameters.
10562 return C;
10563}
10564
10565template <typename Derived>
10566OMPClause *TreeTransform<Derived>::TransformOMPWriteClause(OMPWriteClause *C) {
10567 // No need to rebuild this clause, no template-dependent parameters.
10568 return C;
10569}
10570
10571template <typename Derived>
10572OMPClause *
10573TreeTransform<Derived>::TransformOMPUpdateClause(OMPUpdateClause *C) {
10574 // No need to rebuild this clause, no template-dependent parameters.
10575 return C;
10576}
10577
10578template <typename Derived>
10579OMPClause *
10580TreeTransform<Derived>::TransformOMPCaptureClause(OMPCaptureClause *C) {
10581 // No need to rebuild this clause, no template-dependent parameters.
10582 return C;
10583}
10584
10585template <typename Derived>
10586OMPClause *
10587TreeTransform<Derived>::TransformOMPCompareClause(OMPCompareClause *C) {
10588 // No need to rebuild this clause, no template-dependent parameters.
10589 return C;
10590}
10591
10592template <typename Derived>
10593OMPClause *TreeTransform<Derived>::TransformOMPFailClause(OMPFailClause *C) {
10594 // No need to rebuild this clause, no template-dependent parameters.
10595 return C;
10596}
10597
10598template <typename Derived>
10599OMPClause *
10600TreeTransform<Derived>::TransformOMPAbsentClause(OMPAbsentClause *C) {
10601 return C;
10602}
10603
10604template <typename Derived>
10605OMPClause *TreeTransform<Derived>::TransformOMPHoldsClause(OMPHoldsClause *C) {
10606 ExprResult E = getDerived().TransformExpr(C->getExpr());
10607 if (E.isInvalid())
10608 return nullptr;
10609 return getDerived().RebuildOMPHoldsClause(E.get(), C->getBeginLoc(),
10610 C->getLParenLoc(), C->getEndLoc());
10611}
10612
10613template <typename Derived>
10614OMPClause *
10615TreeTransform<Derived>::TransformOMPContainsClause(OMPContainsClause *C) {
10616 return C;
10617}
10618
10619template <typename Derived>
10620OMPClause *
10621TreeTransform<Derived>::TransformOMPNoOpenMPClause(OMPNoOpenMPClause *C) {
10622 return C;
10623}
10624template <typename Derived>
10625OMPClause *TreeTransform<Derived>::TransformOMPNoOpenMPRoutinesClause(
10626 OMPNoOpenMPRoutinesClause *C) {
10627 return C;
10628}
10629template <typename Derived>
10630OMPClause *TreeTransform<Derived>::TransformOMPNoParallelismClause(
10631 OMPNoParallelismClause *C) {
10632 return C;
10633}
10634
10635template <typename Derived>
10636OMPClause *
10637TreeTransform<Derived>::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
10638 // No need to rebuild this clause, no template-dependent parameters.
10639 return C;
10640}
10641
10642template <typename Derived>
10643OMPClause *
10644TreeTransform<Derived>::TransformOMPAcqRelClause(OMPAcqRelClause *C) {
10645 // No need to rebuild this clause, no template-dependent parameters.
10646 return C;
10647}
10648
10649template <typename Derived>
10650OMPClause *
10651TreeTransform<Derived>::TransformOMPAcquireClause(OMPAcquireClause *C) {
10652 // No need to rebuild this clause, no template-dependent parameters.
10653 return C;
10654}
10655
10656template <typename Derived>
10657OMPClause *
10658TreeTransform<Derived>::TransformOMPReleaseClause(OMPReleaseClause *C) {
10659 // No need to rebuild this clause, no template-dependent parameters.
10660 return C;
10661}
10662
10663template <typename Derived>
10664OMPClause *
10665TreeTransform<Derived>::TransformOMPRelaxedClause(OMPRelaxedClause *C) {
10666 // No need to rebuild this clause, no template-dependent parameters.
10667 return C;
10668}
10669
10670template <typename Derived>
10671OMPClause *TreeTransform<Derived>::TransformOMPWeakClause(OMPWeakClause *C) {
10672 // No need to rebuild this clause, no template-dependent parameters.
10673 return C;
10674}
10675
10676template <typename Derived>
10677OMPClause *
10678TreeTransform<Derived>::TransformOMPThreadsClause(OMPThreadsClause *C) {
10679 // No need to rebuild this clause, no template-dependent parameters.
10680 return C;
10681}
10682
10683template <typename Derived>
10684OMPClause *TreeTransform<Derived>::TransformOMPSIMDClause(OMPSIMDClause *C) {
10685 // No need to rebuild this clause, no template-dependent parameters.
10686 return C;
10687}
10688
10689template <typename Derived>
10690OMPClause *
10691TreeTransform<Derived>::TransformOMPNogroupClause(OMPNogroupClause *C) {
10692 // No need to rebuild this clause, no template-dependent parameters.
10693 return C;
10694}
10695
10696template <typename Derived>
10697OMPClause *TreeTransform<Derived>::TransformOMPInitClause(OMPInitClause *C) {
10698 ExprResult IVR = getDerived().TransformExpr(C->getInteropVar());
10699 if (IVR.isInvalid())
10700 return nullptr;
10701
10702 OMPInteropInfo InteropInfo(C->getIsTarget(), C->getIsTargetSync());
10703 InteropInfo.PreferTypes.reserve(C->varlist_size() - 1);
10704 for (Expr *E : llvm::drop_begin(C->varlist())) {
10705 ExprResult ER = getDerived().TransformExpr(cast<Expr>(E));
10706 if (ER.isInvalid())
10707 return nullptr;
10708 InteropInfo.PreferTypes.push_back(ER.get());
10709 }
10710 return getDerived().RebuildOMPInitClause(IVR.get(), InteropInfo,
10711 C->getBeginLoc(), C->getLParenLoc(),
10712 C->getVarLoc(), C->getEndLoc());
10713}
10714
10715template <typename Derived>
10716OMPClause *TreeTransform<Derived>::TransformOMPUseClause(OMPUseClause *C) {
10717 ExprResult ER = getDerived().TransformExpr(C->getInteropVar());
10718 if (ER.isInvalid())
10719 return nullptr;
10720 return getDerived().RebuildOMPUseClause(ER.get(), C->getBeginLoc(),
10721 C->getLParenLoc(), C->getVarLoc(),
10722 C->getEndLoc());
10723}
10724
10725template <typename Derived>
10726OMPClause *
10727TreeTransform<Derived>::TransformOMPDestroyClause(OMPDestroyClause *C) {
10728 ExprResult ER;
10729 if (Expr *IV = C->getInteropVar()) {
10730 ER = getDerived().TransformExpr(IV);
10731 if (ER.isInvalid())
10732 return nullptr;
10733 }
10734 return getDerived().RebuildOMPDestroyClause(ER.get(), C->getBeginLoc(),
10735 C->getLParenLoc(), C->getVarLoc(),
10736 C->getEndLoc());
10737}
10738
10739template <typename Derived>
10740OMPClause *
10741TreeTransform<Derived>::TransformOMPNovariantsClause(OMPNovariantsClause *C) {
10742 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10743 if (Cond.isInvalid())
10744 return nullptr;
10745 return getDerived().RebuildOMPNovariantsClause(
10746 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10747}
10748
10749template <typename Derived>
10750OMPClause *
10751TreeTransform<Derived>::TransformOMPNocontextClause(OMPNocontextClause *C) {
10752 ExprResult Cond = getDerived().TransformExpr(C->getCondition());
10753 if (Cond.isInvalid())
10754 return nullptr;
10755 return getDerived().RebuildOMPNocontextClause(
10756 Cond.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10757}
10758
10759template <typename Derived>
10760OMPClause *
10761TreeTransform<Derived>::TransformOMPFilterClause(OMPFilterClause *C) {
10762 ExprResult ThreadID = getDerived().TransformExpr(C->getThreadID());
10763 if (ThreadID.isInvalid())
10764 return nullptr;
10765 return getDerived().RebuildOMPFilterClause(ThreadID.get(), C->getBeginLoc(),
10766 C->getLParenLoc(), C->getEndLoc());
10767}
10768
10769template <typename Derived>
10770OMPClause *TreeTransform<Derived>::TransformOMPAlignClause(OMPAlignClause *C) {
10771 ExprResult E = getDerived().TransformExpr(C->getAlignment());
10772 if (E.isInvalid())
10773 return nullptr;
10774 return getDerived().RebuildOMPAlignClause(E.get(), C->getBeginLoc(),
10775 C->getLParenLoc(), C->getEndLoc());
10776}
10777
10778template <typename Derived>
10779OMPClause *TreeTransform<Derived>::TransformOMPUnifiedAddressClause(
10780 OMPUnifiedAddressClause *C) {
10781 llvm_unreachable("unified_address clause cannot appear in dependent context");
10782}
10783
10784template <typename Derived>
10785OMPClause *TreeTransform<Derived>::TransformOMPUnifiedSharedMemoryClause(
10786 OMPUnifiedSharedMemoryClause *C) {
10787 llvm_unreachable(
10788 "unified_shared_memory clause cannot appear in dependent context");
10789}
10790
10791template <typename Derived>
10792OMPClause *TreeTransform<Derived>::TransformOMPReverseOffloadClause(
10793 OMPReverseOffloadClause *C) {
10794 llvm_unreachable("reverse_offload clause cannot appear in dependent context");
10795}
10796
10797template <typename Derived>
10798OMPClause *TreeTransform<Derived>::TransformOMPDynamicAllocatorsClause(
10799 OMPDynamicAllocatorsClause *C) {
10800 llvm_unreachable(
10801 "dynamic_allocators clause cannot appear in dependent context");
10802}
10803
10804template <typename Derived>
10805OMPClause *TreeTransform<Derived>::TransformOMPAtomicDefaultMemOrderClause(
10806 OMPAtomicDefaultMemOrderClause *C) {
10807 llvm_unreachable(
10808 "atomic_default_mem_order clause cannot appear in dependent context");
10809}
10810
10811template <typename Derived>
10812OMPClause *TreeTransform<Derived>::TransformOMPAtClause(OMPAtClause *C) {
10813 return getDerived().RebuildOMPAtClause(C->getAtKind(), C->getAtKindKwLoc(),
10814 C->getBeginLoc(), C->getLParenLoc(),
10815 C->getEndLoc());
10816}
10817
10818template <typename Derived>
10819OMPClause *
10820TreeTransform<Derived>::TransformOMPSeverityClause(OMPSeverityClause *C) {
10821 return getDerived().RebuildOMPSeverityClause(
10822 C->getSeverityKind(), C->getSeverityKindKwLoc(), C->getBeginLoc(),
10823 C->getLParenLoc(), C->getEndLoc());
10824}
10825
10826template <typename Derived>
10827OMPClause *
10828TreeTransform<Derived>::TransformOMPMessageClause(OMPMessageClause *C) {
10829 ExprResult E = getDerived().TransformExpr(C->getMessageString());
10830 if (E.isInvalid())
10831 return nullptr;
10832 return getDerived().RebuildOMPMessageClause(
10833 C->getMessageString(), C->getBeginLoc(), C->getLParenLoc(),
10834 C->getEndLoc());
10835}
10836
10837template <typename Derived>
10838OMPClause *
10839TreeTransform<Derived>::TransformOMPPrivateClause(OMPPrivateClause *C) {
10841 Vars.reserve(C->varlist_size());
10842 for (auto *VE : C->varlist()) {
10843 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10844 if (EVar.isInvalid())
10845 return nullptr;
10846 Vars.push_back(EVar.get());
10847 }
10848 return getDerived().RebuildOMPPrivateClause(
10849 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10850}
10851
10852template <typename Derived>
10853OMPClause *TreeTransform<Derived>::TransformOMPFirstprivateClause(
10854 OMPFirstprivateClause *C) {
10856 Vars.reserve(C->varlist_size());
10857 for (auto *VE : C->varlist()) {
10858 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10859 if (EVar.isInvalid())
10860 return nullptr;
10861 Vars.push_back(EVar.get());
10862 }
10863 return getDerived().RebuildOMPFirstprivateClause(
10864 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
10865}
10866
10867template <typename Derived>
10868OMPClause *
10869TreeTransform<Derived>::TransformOMPLastprivateClause(OMPLastprivateClause *C) {
10871 Vars.reserve(C->varlist_size());
10872 for (auto *VE : C->varlist()) {
10873 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10874 if (EVar.isInvalid())
10875 return nullptr;
10876 Vars.push_back(EVar.get());
10877 }
10878 return getDerived().RebuildOMPLastprivateClause(
10879 Vars, C->getKind(), C->getKindLoc(), C->getColonLoc(), C->getBeginLoc(),
10880 C->getLParenLoc(), C->getEndLoc());
10881}
10882
10883template <typename Derived>
10884OMPClause *
10885TreeTransform<Derived>::TransformOMPSharedClause(OMPSharedClause *C) {
10887 Vars.reserve(C->varlist_size());
10888 for (auto *VE : C->varlist()) {
10889 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10890 if (EVar.isInvalid())
10891 return nullptr;
10892 Vars.push_back(EVar.get());
10893 }
10894 return getDerived().RebuildOMPSharedClause(Vars, C->getBeginLoc(),
10895 C->getLParenLoc(), C->getEndLoc());
10896}
10897
10898template <typename Derived>
10899OMPClause *
10900TreeTransform<Derived>::TransformOMPReductionClause(OMPReductionClause *C) {
10902 Vars.reserve(C->varlist_size());
10903 for (auto *VE : C->varlist()) {
10904 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10905 if (EVar.isInvalid())
10906 return nullptr;
10907 Vars.push_back(EVar.get());
10908 }
10909 CXXScopeSpec ReductionIdScopeSpec;
10910 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
10911
10912 DeclarationNameInfo NameInfo = C->getNameInfo();
10913 if (NameInfo.getName()) {
10914 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
10915 if (!NameInfo.getName())
10916 return nullptr;
10917 }
10918 // Build a list of all UDR decls with the same names ranged by the Scopes.
10919 // The Scope boundary is a duplication of the previous decl.
10920 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
10921 for (auto *E : C->reduction_ops()) {
10922 // Transform all the decls.
10923 if (E) {
10924 auto *ULE = cast<UnresolvedLookupExpr>(E);
10925 UnresolvedSet<8> Decls;
10926 for (auto *D : ULE->decls()) {
10927 NamedDecl *InstD =
10928 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
10929 Decls.addDecl(InstD, InstD->getAccess());
10930 }
10931 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
10932 SemaRef.Context, /*NamingClass=*/nullptr,
10933 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
10934 /*ADL=*/true, Decls.begin(), Decls.end(),
10935 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
10936 } else
10937 UnresolvedReductions.push_back(nullptr);
10938 }
10939 return getDerived().RebuildOMPReductionClause(
10940 Vars, C->getModifier(), C->getBeginLoc(), C->getLParenLoc(),
10941 C->getModifierLoc(), C->getColonLoc(), C->getEndLoc(),
10942 ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
10943}
10944
10945template <typename Derived>
10946OMPClause *TreeTransform<Derived>::TransformOMPTaskReductionClause(
10947 OMPTaskReductionClause *C) {
10949 Vars.reserve(C->varlist_size());
10950 for (auto *VE : C->varlist()) {
10951 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10952 if (EVar.isInvalid())
10953 return nullptr;
10954 Vars.push_back(EVar.get());
10955 }
10956 CXXScopeSpec ReductionIdScopeSpec;
10957 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
10958
10959 DeclarationNameInfo NameInfo = C->getNameInfo();
10960 if (NameInfo.getName()) {
10961 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
10962 if (!NameInfo.getName())
10963 return nullptr;
10964 }
10965 // Build a list of all UDR decls with the same names ranged by the Scopes.
10966 // The Scope boundary is a duplication of the previous decl.
10967 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
10968 for (auto *E : C->reduction_ops()) {
10969 // Transform all the decls.
10970 if (E) {
10971 auto *ULE = cast<UnresolvedLookupExpr>(E);
10972 UnresolvedSet<8> Decls;
10973 for (auto *D : ULE->decls()) {
10974 NamedDecl *InstD =
10975 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
10976 Decls.addDecl(InstD, InstD->getAccess());
10977 }
10978 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
10979 SemaRef.Context, /*NamingClass=*/nullptr,
10980 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
10981 /*ADL=*/true, Decls.begin(), Decls.end(),
10982 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
10983 } else
10984 UnresolvedReductions.push_back(nullptr);
10985 }
10986 return getDerived().RebuildOMPTaskReductionClause(
10987 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
10988 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
10989}
10990
10991template <typename Derived>
10992OMPClause *
10993TreeTransform<Derived>::TransformOMPInReductionClause(OMPInReductionClause *C) {
10995 Vars.reserve(C->varlist_size());
10996 for (auto *VE : C->varlist()) {
10997 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
10998 if (EVar.isInvalid())
10999 return nullptr;
11000 Vars.push_back(EVar.get());
11001 }
11002 CXXScopeSpec ReductionIdScopeSpec;
11003 ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
11004
11005 DeclarationNameInfo NameInfo = C->getNameInfo();
11006 if (NameInfo.getName()) {
11007 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
11008 if (!NameInfo.getName())
11009 return nullptr;
11010 }
11011 // Build a list of all UDR decls with the same names ranged by the Scopes.
11012 // The Scope boundary is a duplication of the previous decl.
11013 llvm::SmallVector<Expr *, 16> UnresolvedReductions;
11014 for (auto *E : C->reduction_ops()) {
11015 // Transform all the decls.
11016 if (E) {
11017 auto *ULE = cast<UnresolvedLookupExpr>(E);
11018 UnresolvedSet<8> Decls;
11019 for (auto *D : ULE->decls()) {
11020 NamedDecl *InstD =
11021 cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
11022 Decls.addDecl(InstD, InstD->getAccess());
11023 }
11024 UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
11025 SemaRef.Context, /*NamingClass=*/nullptr,
11026 ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
11027 /*ADL=*/true, Decls.begin(), Decls.end(),
11028 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11029 } else
11030 UnresolvedReductions.push_back(nullptr);
11031 }
11032 return getDerived().RebuildOMPInReductionClause(
11033 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(),
11034 C->getEndLoc(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
11035}
11036
11037template <typename Derived>
11038OMPClause *
11039TreeTransform<Derived>::TransformOMPLinearClause(OMPLinearClause *C) {
11041 Vars.reserve(C->varlist_size());
11042 for (auto *VE : C->varlist()) {
11043 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11044 if (EVar.isInvalid())
11045 return nullptr;
11046 Vars.push_back(EVar.get());
11047 }
11048 ExprResult Step = getDerived().TransformExpr(C->getStep());
11049 if (Step.isInvalid())
11050 return nullptr;
11051 return getDerived().RebuildOMPLinearClause(
11052 Vars, Step.get(), C->getBeginLoc(), C->getLParenLoc(), C->getModifier(),
11053 C->getModifierLoc(), C->getColonLoc(), C->getStepModifierLoc(),
11054 C->getEndLoc());
11055}
11056
11057template <typename Derived>
11058OMPClause *
11059TreeTransform<Derived>::TransformOMPAlignedClause(OMPAlignedClause *C) {
11061 Vars.reserve(C->varlist_size());
11062 for (auto *VE : C->varlist()) {
11063 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11064 if (EVar.isInvalid())
11065 return nullptr;
11066 Vars.push_back(EVar.get());
11067 }
11068 ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
11069 if (Alignment.isInvalid())
11070 return nullptr;
11071 return getDerived().RebuildOMPAlignedClause(
11072 Vars, Alignment.get(), C->getBeginLoc(), C->getLParenLoc(),
11073 C->getColonLoc(), C->getEndLoc());
11074}
11075
11076template <typename Derived>
11077OMPClause *
11078TreeTransform<Derived>::TransformOMPCopyinClause(OMPCopyinClause *C) {
11080 Vars.reserve(C->varlist_size());
11081 for (auto *VE : C->varlist()) {
11082 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11083 if (EVar.isInvalid())
11084 return nullptr;
11085 Vars.push_back(EVar.get());
11086 }
11087 return getDerived().RebuildOMPCopyinClause(Vars, C->getBeginLoc(),
11088 C->getLParenLoc(), C->getEndLoc());
11089}
11090
11091template <typename Derived>
11092OMPClause *
11093TreeTransform<Derived>::TransformOMPCopyprivateClause(OMPCopyprivateClause *C) {
11095 Vars.reserve(C->varlist_size());
11096 for (auto *VE : C->varlist()) {
11097 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11098 if (EVar.isInvalid())
11099 return nullptr;
11100 Vars.push_back(EVar.get());
11101 }
11102 return getDerived().RebuildOMPCopyprivateClause(
11103 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11104}
11105
11106template <typename Derived>
11107OMPClause *TreeTransform<Derived>::TransformOMPFlushClause(OMPFlushClause *C) {
11109 Vars.reserve(C->varlist_size());
11110 for (auto *VE : C->varlist()) {
11111 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11112 if (EVar.isInvalid())
11113 return nullptr;
11114 Vars.push_back(EVar.get());
11115 }
11116 return getDerived().RebuildOMPFlushClause(Vars, C->getBeginLoc(),
11117 C->getLParenLoc(), C->getEndLoc());
11118}
11119
11120template <typename Derived>
11121OMPClause *
11122TreeTransform<Derived>::TransformOMPDepobjClause(OMPDepobjClause *C) {
11123 ExprResult E = getDerived().TransformExpr(C->getDepobj());
11124 if (E.isInvalid())
11125 return nullptr;
11126 return getDerived().RebuildOMPDepobjClause(E.get(), C->getBeginLoc(),
11127 C->getLParenLoc(), C->getEndLoc());
11128}
11129
11130template <typename Derived>
11131OMPClause *
11132TreeTransform<Derived>::TransformOMPDependClause(OMPDependClause *C) {
11134 Expr *DepModifier = C->getModifier();
11135 if (DepModifier) {
11136 ExprResult DepModRes = getDerived().TransformExpr(DepModifier);
11137 if (DepModRes.isInvalid())
11138 return nullptr;
11139 DepModifier = DepModRes.get();
11140 }
11141 Vars.reserve(C->varlist_size());
11142 for (auto *VE : C->varlist()) {
11143 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11144 if (EVar.isInvalid())
11145 return nullptr;
11146 Vars.push_back(EVar.get());
11147 }
11148 return getDerived().RebuildOMPDependClause(
11149 {C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(),
11150 C->getOmpAllMemoryLoc()},
11151 DepModifier, Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11152}
11153
11154template <typename Derived>
11155OMPClause *
11156TreeTransform<Derived>::TransformOMPDeviceClause(OMPDeviceClause *C) {
11157 ExprResult E = getDerived().TransformExpr(C->getDevice());
11158 if (E.isInvalid())
11159 return nullptr;
11160 return getDerived().RebuildOMPDeviceClause(
11161 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11162 C->getModifierLoc(), C->getEndLoc());
11163}
11164
11165template <typename Derived, class T>
11168 llvm::SmallVectorImpl<Expr *> &Vars, CXXScopeSpec &MapperIdScopeSpec,
11169 DeclarationNameInfo &MapperIdInfo,
11170 llvm::SmallVectorImpl<Expr *> &UnresolvedMappers) {
11171 // Transform expressions in the list.
11172 Vars.reserve(C->varlist_size());
11173 for (auto *VE : C->varlist()) {
11174 ExprResult EVar = TT.getDerived().TransformExpr(cast<Expr>(VE));
11175 if (EVar.isInvalid())
11176 return true;
11177 Vars.push_back(EVar.get());
11178 }
11179 // Transform mapper scope specifier and identifier.
11180 NestedNameSpecifierLoc QualifierLoc;
11181 if (C->getMapperQualifierLoc()) {
11182 QualifierLoc = TT.getDerived().TransformNestedNameSpecifierLoc(
11183 C->getMapperQualifierLoc());
11184 if (!QualifierLoc)
11185 return true;
11186 }
11187 MapperIdScopeSpec.Adopt(QualifierLoc);
11188 MapperIdInfo = C->getMapperIdInfo();
11189 if (MapperIdInfo.getName()) {
11190 MapperIdInfo = TT.getDerived().TransformDeclarationNameInfo(MapperIdInfo);
11191 if (!MapperIdInfo.getName())
11192 return true;
11193 }
11194 // Build a list of all candidate OMPDeclareMapperDecls, which is provided by
11195 // the previous user-defined mapper lookup in dependent environment.
11196 for (auto *E : C->mapperlists()) {
11197 // Transform all the decls.
11198 if (E) {
11199 auto *ULE = cast<UnresolvedLookupExpr>(E);
11200 UnresolvedSet<8> Decls;
11201 for (auto *D : ULE->decls()) {
11202 NamedDecl *InstD =
11203 cast<NamedDecl>(TT.getDerived().TransformDecl(E->getExprLoc(), D));
11204 Decls.addDecl(InstD, InstD->getAccess());
11205 }
11206 UnresolvedMappers.push_back(UnresolvedLookupExpr::Create(
11207 TT.getSema().Context, /*NamingClass=*/nullptr,
11208 MapperIdScopeSpec.getWithLocInContext(TT.getSema().Context),
11209 MapperIdInfo, /*ADL=*/true, Decls.begin(), Decls.end(),
11210 /*KnownDependent=*/false, /*KnownInstantiationDependent=*/false));
11211 } else {
11212 UnresolvedMappers.push_back(nullptr);
11213 }
11214 }
11215 return false;
11216}
11217
11218template <typename Derived>
11219OMPClause *TreeTransform<Derived>::TransformOMPMapClause(OMPMapClause *C) {
11220 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11222 Expr *IteratorModifier = C->getIteratorModifier();
11223 if (IteratorModifier) {
11224 ExprResult MapModRes = getDerived().TransformExpr(IteratorModifier);
11225 if (MapModRes.isInvalid())
11226 return nullptr;
11227 IteratorModifier = MapModRes.get();
11228 }
11229 CXXScopeSpec MapperIdScopeSpec;
11230 DeclarationNameInfo MapperIdInfo;
11231 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11232 if (transformOMPMappableExprListClause<Derived, OMPMapClause>(
11233 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11234 return nullptr;
11235 return getDerived().RebuildOMPMapClause(
11236 IteratorModifier, C->getMapTypeModifiers(), C->getMapTypeModifiersLoc(),
11237 MapperIdScopeSpec, MapperIdInfo, C->getMapType(), C->isImplicitMapType(),
11238 C->getMapLoc(), C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11239}
11240
11241template <typename Derived>
11242OMPClause *
11243TreeTransform<Derived>::TransformOMPAllocateClause(OMPAllocateClause *C) {
11244 Expr *Allocator = C->getAllocator();
11245 if (Allocator) {
11246 ExprResult AllocatorRes = getDerived().TransformExpr(Allocator);
11247 if (AllocatorRes.isInvalid())
11248 return nullptr;
11249 Allocator = AllocatorRes.get();
11250 }
11251 Expr *Alignment = C->getAlignment();
11252 if (Alignment) {
11253 ExprResult AlignmentRes = getDerived().TransformExpr(Alignment);
11254 if (AlignmentRes.isInvalid())
11255 return nullptr;
11256 Alignment = AlignmentRes.get();
11257 }
11259 Vars.reserve(C->varlist_size());
11260 for (auto *VE : C->varlist()) {
11261 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11262 if (EVar.isInvalid())
11263 return nullptr;
11264 Vars.push_back(EVar.get());
11265 }
11266 return getDerived().RebuildOMPAllocateClause(
11267 Allocator, Alignment, C->getFirstAllocateModifier(),
11268 C->getFirstAllocateModifierLoc(), C->getSecondAllocateModifier(),
11269 C->getSecondAllocateModifierLoc(), Vars, C->getBeginLoc(),
11270 C->getLParenLoc(), C->getColonLoc(), C->getEndLoc());
11271}
11272
11273template <typename Derived>
11274OMPClause *
11275TreeTransform<Derived>::TransformOMPNumTeamsClause(OMPNumTeamsClause *C) {
11277 Vars.reserve(C->varlist_size());
11278 for (auto *VE : C->varlist()) {
11279 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11280 if (EVar.isInvalid())
11281 return nullptr;
11282 Vars.push_back(EVar.get());
11283 }
11284 return getDerived().RebuildOMPNumTeamsClause(
11285 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11286}
11287
11288template <typename Derived>
11289OMPClause *
11290TreeTransform<Derived>::TransformOMPThreadLimitClause(OMPThreadLimitClause *C) {
11292 Vars.reserve(C->varlist_size());
11293 for (auto *VE : C->varlist()) {
11294 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11295 if (EVar.isInvalid())
11296 return nullptr;
11297 Vars.push_back(EVar.get());
11298 }
11299 return getDerived().RebuildOMPThreadLimitClause(
11300 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11301}
11302
11303template <typename Derived>
11304OMPClause *
11305TreeTransform<Derived>::TransformOMPPriorityClause(OMPPriorityClause *C) {
11306 ExprResult E = getDerived().TransformExpr(C->getPriority());
11307 if (E.isInvalid())
11308 return nullptr;
11309 return getDerived().RebuildOMPPriorityClause(
11310 E.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11311}
11312
11313template <typename Derived>
11314OMPClause *
11315TreeTransform<Derived>::TransformOMPGrainsizeClause(OMPGrainsizeClause *C) {
11316 ExprResult E = getDerived().TransformExpr(C->getGrainsize());
11317 if (E.isInvalid())
11318 return nullptr;
11319 return getDerived().RebuildOMPGrainsizeClause(
11320 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11321 C->getModifierLoc(), C->getEndLoc());
11322}
11323
11324template <typename Derived>
11325OMPClause *
11326TreeTransform<Derived>::TransformOMPNumTasksClause(OMPNumTasksClause *C) {
11327 ExprResult E = getDerived().TransformExpr(C->getNumTasks());
11328 if (E.isInvalid())
11329 return nullptr;
11330 return getDerived().RebuildOMPNumTasksClause(
11331 C->getModifier(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11332 C->getModifierLoc(), C->getEndLoc());
11333}
11334
11335template <typename Derived>
11336OMPClause *TreeTransform<Derived>::TransformOMPHintClause(OMPHintClause *C) {
11337 ExprResult E = getDerived().TransformExpr(C->getHint());
11338 if (E.isInvalid())
11339 return nullptr;
11340 return getDerived().RebuildOMPHintClause(E.get(), C->getBeginLoc(),
11341 C->getLParenLoc(), C->getEndLoc());
11342}
11343
11344template <typename Derived>
11345OMPClause *TreeTransform<Derived>::TransformOMPDistScheduleClause(
11346 OMPDistScheduleClause *C) {
11347 ExprResult E = getDerived().TransformExpr(C->getChunkSize());
11348 if (E.isInvalid())
11349 return nullptr;
11350 return getDerived().RebuildOMPDistScheduleClause(
11351 C->getDistScheduleKind(), E.get(), C->getBeginLoc(), C->getLParenLoc(),
11352 C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getEndLoc());
11353}
11354
11355template <typename Derived>
11356OMPClause *
11357TreeTransform<Derived>::TransformOMPDefaultmapClause(OMPDefaultmapClause *C) {
11358 // Rebuild Defaultmap Clause since we need to invoke the checking of
11359 // defaultmap(none:variable-category) after template initialization.
11360 return getDerived().RebuildOMPDefaultmapClause(C->getDefaultmapModifier(),
11361 C->getDefaultmapKind(),
11362 C->getBeginLoc(),
11363 C->getLParenLoc(),
11364 C->getDefaultmapModifierLoc(),
11365 C->getDefaultmapKindLoc(),
11366 C->getEndLoc());
11367}
11368
11369template <typename Derived>
11370OMPClause *TreeTransform<Derived>::TransformOMPToClause(OMPToClause *C) {
11371 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11373 CXXScopeSpec MapperIdScopeSpec;
11374 DeclarationNameInfo MapperIdInfo;
11375 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11376 if (transformOMPMappableExprListClause<Derived, OMPToClause>(
11377 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11378 return nullptr;
11379 return getDerived().RebuildOMPToClause(
11380 C->getMotionModifiers(), C->getMotionModifiersLoc(), MapperIdScopeSpec,
11381 MapperIdInfo, C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11382}
11383
11384template <typename Derived>
11385OMPClause *TreeTransform<Derived>::TransformOMPFromClause(OMPFromClause *C) {
11386 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11388 CXXScopeSpec MapperIdScopeSpec;
11389 DeclarationNameInfo MapperIdInfo;
11390 llvm::SmallVector<Expr *, 16> UnresolvedMappers;
11391 if (transformOMPMappableExprListClause<Derived, OMPFromClause>(
11392 *this, C, Vars, MapperIdScopeSpec, MapperIdInfo, UnresolvedMappers))
11393 return nullptr;
11394 return getDerived().RebuildOMPFromClause(
11395 C->getMotionModifiers(), C->getMotionModifiersLoc(), MapperIdScopeSpec,
11396 MapperIdInfo, C->getColonLoc(), Vars, Locs, UnresolvedMappers);
11397}
11398
11399template <typename Derived>
11400OMPClause *TreeTransform<Derived>::TransformOMPUseDevicePtrClause(
11401 OMPUseDevicePtrClause *C) {
11403 Vars.reserve(C->varlist_size());
11404 for (auto *VE : C->varlist()) {
11405 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11406 if (EVar.isInvalid())
11407 return nullptr;
11408 Vars.push_back(EVar.get());
11409 }
11410 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11411 return getDerived().RebuildOMPUseDevicePtrClause(Vars, Locs);
11412}
11413
11414template <typename Derived>
11415OMPClause *TreeTransform<Derived>::TransformOMPUseDeviceAddrClause(
11416 OMPUseDeviceAddrClause *C) {
11418 Vars.reserve(C->varlist_size());
11419 for (auto *VE : C->varlist()) {
11420 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11421 if (EVar.isInvalid())
11422 return nullptr;
11423 Vars.push_back(EVar.get());
11424 }
11425 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11426 return getDerived().RebuildOMPUseDeviceAddrClause(Vars, Locs);
11427}
11428
11429template <typename Derived>
11430OMPClause *
11431TreeTransform<Derived>::TransformOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
11433 Vars.reserve(C->varlist_size());
11434 for (auto *VE : C->varlist()) {
11435 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11436 if (EVar.isInvalid())
11437 return nullptr;
11438 Vars.push_back(EVar.get());
11439 }
11440 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11441 return getDerived().RebuildOMPIsDevicePtrClause(Vars, Locs);
11442}
11443
11444template <typename Derived>
11445OMPClause *TreeTransform<Derived>::TransformOMPHasDeviceAddrClause(
11446 OMPHasDeviceAddrClause *C) {
11448 Vars.reserve(C->varlist_size());
11449 for (auto *VE : C->varlist()) {
11450 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11451 if (EVar.isInvalid())
11452 return nullptr;
11453 Vars.push_back(EVar.get());
11454 }
11455 OMPVarListLocTy Locs(C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11456 return getDerived().RebuildOMPHasDeviceAddrClause(Vars, Locs);
11457}
11458
11459template <typename Derived>
11460OMPClause *
11461TreeTransform<Derived>::TransformOMPNontemporalClause(OMPNontemporalClause *C) {
11463 Vars.reserve(C->varlist_size());
11464 for (auto *VE : C->varlist()) {
11465 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11466 if (EVar.isInvalid())
11467 return nullptr;
11468 Vars.push_back(EVar.get());
11469 }
11470 return getDerived().RebuildOMPNontemporalClause(
11471 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11472}
11473
11474template <typename Derived>
11475OMPClause *
11476TreeTransform<Derived>::TransformOMPInclusiveClause(OMPInclusiveClause *C) {
11478 Vars.reserve(C->varlist_size());
11479 for (auto *VE : C->varlist()) {
11480 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11481 if (EVar.isInvalid())
11482 return nullptr;
11483 Vars.push_back(EVar.get());
11484 }
11485 return getDerived().RebuildOMPInclusiveClause(
11486 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11487}
11488
11489template <typename Derived>
11490OMPClause *
11491TreeTransform<Derived>::TransformOMPExclusiveClause(OMPExclusiveClause *C) {
11493 Vars.reserve(C->varlist_size());
11494 for (auto *VE : C->varlist()) {
11495 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11496 if (EVar.isInvalid())
11497 return nullptr;
11498 Vars.push_back(EVar.get());
11499 }
11500 return getDerived().RebuildOMPExclusiveClause(
11501 Vars, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11502}
11503
11504template <typename Derived>
11505OMPClause *TreeTransform<Derived>::TransformOMPUsesAllocatorsClause(
11506 OMPUsesAllocatorsClause *C) {
11508 Data.reserve(C->getNumberOfAllocators());
11509 for (unsigned I = 0, E = C->getNumberOfAllocators(); I < E; ++I) {
11510 OMPUsesAllocatorsClause::Data D = C->getAllocatorData(I);
11511 ExprResult Allocator = getDerived().TransformExpr(D.Allocator);
11512 if (Allocator.isInvalid())
11513 continue;
11514 ExprResult AllocatorTraits;
11515 if (Expr *AT = D.AllocatorTraits) {
11516 AllocatorTraits = getDerived().TransformExpr(AT);
11517 if (AllocatorTraits.isInvalid())
11518 continue;
11519 }
11520 SemaOpenMP::UsesAllocatorsData &NewD = Data.emplace_back();
11521 NewD.Allocator = Allocator.get();
11522 NewD.AllocatorTraits = AllocatorTraits.get();
11523 NewD.LParenLoc = D.LParenLoc;
11524 NewD.RParenLoc = D.RParenLoc;
11525 }
11526 return getDerived().RebuildOMPUsesAllocatorsClause(
11527 Data, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11528}
11529
11530template <typename Derived>
11531OMPClause *
11532TreeTransform<Derived>::TransformOMPAffinityClause(OMPAffinityClause *C) {
11533 SmallVector<Expr *, 4> Locators;
11534 Locators.reserve(C->varlist_size());
11535 ExprResult ModifierRes;
11536 if (Expr *Modifier = C->getModifier()) {
11537 ModifierRes = getDerived().TransformExpr(Modifier);
11538 if (ModifierRes.isInvalid())
11539 return nullptr;
11540 }
11541 for (Expr *E : C->varlist()) {
11542 ExprResult Locator = getDerived().TransformExpr(E);
11543 if (Locator.isInvalid())
11544 continue;
11545 Locators.push_back(Locator.get());
11546 }
11547 return getDerived().RebuildOMPAffinityClause(
11548 C->getBeginLoc(), C->getLParenLoc(), C->getColonLoc(), C->getEndLoc(),
11549 ModifierRes.get(), Locators);
11550}
11551
11552template <typename Derived>
11553OMPClause *TreeTransform<Derived>::TransformOMPOrderClause(OMPOrderClause *C) {
11554 return getDerived().RebuildOMPOrderClause(
11555 C->getKind(), C->getKindKwLoc(), C->getBeginLoc(), C->getLParenLoc(),
11556 C->getEndLoc(), C->getModifier(), C->getModifierKwLoc());
11557}
11558
11559template <typename Derived>
11560OMPClause *TreeTransform<Derived>::TransformOMPBindClause(OMPBindClause *C) {
11561 return getDerived().RebuildOMPBindClause(
11562 C->getBindKind(), C->getBindKindLoc(), C->getBeginLoc(),
11563 C->getLParenLoc(), C->getEndLoc());
11564}
11565
11566template <typename Derived>
11567OMPClause *TreeTransform<Derived>::TransformOMPXDynCGroupMemClause(
11568 OMPXDynCGroupMemClause *C) {
11569 ExprResult Size = getDerived().TransformExpr(C->getSize());
11570 if (Size.isInvalid())
11571 return nullptr;
11572 return getDerived().RebuildOMPXDynCGroupMemClause(
11573 Size.get(), C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11574}
11575
11576template <typename Derived>
11577OMPClause *
11578TreeTransform<Derived>::TransformOMPDoacrossClause(OMPDoacrossClause *C) {
11580 Vars.reserve(C->varlist_size());
11581 for (auto *VE : C->varlist()) {
11582 ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
11583 if (EVar.isInvalid())
11584 return nullptr;
11585 Vars.push_back(EVar.get());
11586 }
11587 return getDerived().RebuildOMPDoacrossClause(
11588 C->getDependenceType(), C->getDependenceLoc(), C->getColonLoc(), Vars,
11589 C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11590}
11591
11592template <typename Derived>
11593OMPClause *
11594TreeTransform<Derived>::TransformOMPXAttributeClause(OMPXAttributeClause *C) {
11596 for (auto *A : C->getAttrs())
11597 NewAttrs.push_back(getDerived().TransformAttr(A));
11598 return getDerived().RebuildOMPXAttributeClause(
11599 NewAttrs, C->getBeginLoc(), C->getLParenLoc(), C->getEndLoc());
11600}
11601
11602template <typename Derived>
11603OMPClause *TreeTransform<Derived>::TransformOMPXBareClause(OMPXBareClause *C) {
11604 return getDerived().RebuildOMPXBareClause(C->getBeginLoc(), C->getEndLoc());
11605}
11606
11607//===----------------------------------------------------------------------===//
11608// OpenACC transformation
11609//===----------------------------------------------------------------------===//
11610namespace {
11611template <typename Derived>
11612class OpenACCClauseTransform final
11613 : public OpenACCClauseVisitor<OpenACCClauseTransform<Derived>> {
11614 TreeTransform<Derived> &Self;
11615 ArrayRef<const OpenACCClause *> ExistingClauses;
11616 SemaOpenACC::OpenACCParsedClause &ParsedClause;
11617 OpenACCClause *NewClause = nullptr;
11618
11619 llvm::SmallVector<Expr *> VisitVarList(ArrayRef<Expr *> VarList) {
11620 llvm::SmallVector<Expr *> InstantiatedVarList;
11621 for (Expr *CurVar : VarList) {
11622 ExprResult Res = Self.TransformExpr(CurVar);
11623
11624 if (!Res.isUsable())
11625 continue;
11626
11627 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getClauseKind(),
11628 Res.get());
11629
11630 if (Res.isUsable())
11631 InstantiatedVarList.push_back(Res.get());
11632 }
11633
11634 return InstantiatedVarList;
11635 }
11636
11637public:
11638 OpenACCClauseTransform(TreeTransform<Derived> &Self,
11639 ArrayRef<const OpenACCClause *> ExistingClauses,
11640 SemaOpenACC::OpenACCParsedClause &PC)
11641 : Self(Self), ExistingClauses(ExistingClauses), ParsedClause(PC) {}
11642
11643 OpenACCClause *CreatedClause() const { return NewClause; }
11644
11645#define VISIT_CLAUSE(CLAUSE_NAME) \
11646 void Visit##CLAUSE_NAME##Clause(const OpenACC##CLAUSE_NAME##Clause &Clause);
11647#include "clang/Basic/OpenACCClauses.def"
11648};
11649
11650template <typename Derived>
11651void OpenACCClauseTransform<Derived>::VisitDefaultClause(
11652 const OpenACCDefaultClause &C) {
11653 ParsedClause.setDefaultDetails(C.getDefaultClauseKind());
11654
11655 NewClause = OpenACCDefaultClause::Create(
11656 Self.getSema().getASTContext(), ParsedClause.getDefaultClauseKind(),
11657 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11658 ParsedClause.getEndLoc());
11659}
11660
11661template <typename Derived>
11662void OpenACCClauseTransform<Derived>::VisitIfClause(const OpenACCIfClause &C) {
11663 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11664 assert(Cond && "If constructed with invalid Condition");
11665 Sema::ConditionResult Res = Self.TransformCondition(
11666 Cond->getExprLoc(), /*Var=*/nullptr, Cond, Sema::ConditionKind::Boolean);
11667
11668 if (Res.isInvalid() || !Res.get().second)
11669 return;
11670
11671 ParsedClause.setConditionDetails(Res.get().second);
11672
11673 NewClause = OpenACCIfClause::Create(
11674 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11675 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11676 ParsedClause.getEndLoc());
11677}
11678
11679template <typename Derived>
11680void OpenACCClauseTransform<Derived>::VisitSelfClause(
11681 const OpenACCSelfClause &C) {
11682
11683 // If this is an 'update' 'self' clause, this is actually a var list instead.
11684 if (ParsedClause.getDirectiveKind() == OpenACCDirectiveKind::Update) {
11685 llvm::SmallVector<Expr *> InstantiatedVarList;
11686 for (Expr *CurVar : C.getVarList()) {
11687 ExprResult Res = Self.TransformExpr(CurVar);
11688
11689 if (!Res.isUsable())
11690 continue;
11691
11692 Res = Self.getSema().OpenACC().ActOnVar(ParsedClause.getClauseKind(),
11693 Res.get());
11694
11695 if (Res.isUsable())
11696 InstantiatedVarList.push_back(Res.get());
11697 }
11698
11699 ParsedClause.setVarListDetails(InstantiatedVarList,
11700 /*IsReadOnly=*/false, /*IsZero=*/false);
11701
11702 NewClause = OpenACCSelfClause::Create(
11703 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11704 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11705 ParsedClause.getEndLoc());
11706 } else {
11707
11708 if (C.hasConditionExpr()) {
11709 Expr *Cond = const_cast<Expr *>(C.getConditionExpr());
11710 Sema::ConditionResult Res =
11711 Self.TransformCondition(Cond->getExprLoc(), /*Var=*/nullptr, Cond,
11713
11714 if (Res.isInvalid() || !Res.get().second)
11715 return;
11716
11717 ParsedClause.setConditionDetails(Res.get().second);
11718 }
11719
11720 NewClause = OpenACCSelfClause::Create(
11721 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11722 ParsedClause.getLParenLoc(), ParsedClause.getConditionExpr(),
11723 ParsedClause.getEndLoc());
11724 }
11725}
11726
11727template <typename Derived>
11728void OpenACCClauseTransform<Derived>::VisitNumGangsClause(
11729 const OpenACCNumGangsClause &C) {
11730 llvm::SmallVector<Expr *> InstantiatedIntExprs;
11731
11732 for (Expr *CurIntExpr : C.getIntExprs()) {
11733 ExprResult Res = Self.TransformExpr(CurIntExpr);
11734
11735 if (!Res.isUsable())
11736 return;
11737
11738 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11739 C.getClauseKind(),
11740 C.getBeginLoc(), Res.get());
11741 if (!Res.isUsable())
11742 return;
11743
11744 InstantiatedIntExprs.push_back(Res.get());
11745 }
11746
11747 ParsedClause.setIntExprDetails(InstantiatedIntExprs);
11749 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11750 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
11751 ParsedClause.getEndLoc());
11752}
11753
11754template <typename Derived>
11755void OpenACCClauseTransform<Derived>::VisitPrivateClause(
11756 const OpenACCPrivateClause &C) {
11757 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11758 /*IsReadOnly=*/false, /*IsZero=*/false);
11759
11760 NewClause = OpenACCPrivateClause::Create(
11761 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11762 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11763 ParsedClause.getEndLoc());
11764}
11765
11766template <typename Derived>
11767void OpenACCClauseTransform<Derived>::VisitHostClause(
11768 const OpenACCHostClause &C) {
11769 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11770 /*IsReadOnly=*/false, /*IsZero=*/false);
11771
11772 NewClause = OpenACCHostClause::Create(
11773 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11774 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11775 ParsedClause.getEndLoc());
11776}
11777
11778template <typename Derived>
11779void OpenACCClauseTransform<Derived>::VisitDeviceClause(
11780 const OpenACCDeviceClause &C) {
11781 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11782 /*IsReadOnly=*/false, /*IsZero=*/false);
11783
11784 NewClause = OpenACCDeviceClause::Create(
11785 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11786 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11787 ParsedClause.getEndLoc());
11788}
11789
11790template <typename Derived>
11791void OpenACCClauseTransform<Derived>::VisitFirstPrivateClause(
11792 const OpenACCFirstPrivateClause &C) {
11793 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11794 /*IsReadOnly=*/false, /*IsZero=*/false);
11795
11797 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11798 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11799 ParsedClause.getEndLoc());
11800}
11801
11802template <typename Derived>
11803void OpenACCClauseTransform<Derived>::VisitNoCreateClause(
11804 const OpenACCNoCreateClause &C) {
11805 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11806 /*IsReadOnly=*/false, /*IsZero=*/false);
11807
11809 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11810 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11811 ParsedClause.getEndLoc());
11812}
11813
11814template <typename Derived>
11815void OpenACCClauseTransform<Derived>::VisitPresentClause(
11816 const OpenACCPresentClause &C) {
11817 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11818 /*IsReadOnly=*/false, /*IsZero=*/false);
11819
11820 NewClause = OpenACCPresentClause::Create(
11821 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11822 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11823 ParsedClause.getEndLoc());
11824}
11825
11826template <typename Derived>
11827void OpenACCClauseTransform<Derived>::VisitCopyClause(
11828 const OpenACCCopyClause &C) {
11829 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11830 /*IsReadOnly=*/false, /*IsZero=*/false);
11831
11832 NewClause = OpenACCCopyClause::Create(
11833 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
11834 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11835 ParsedClause.getVarList(), ParsedClause.getEndLoc());
11836}
11837
11838template <typename Derived>
11839void OpenACCClauseTransform<Derived>::VisitCopyInClause(
11840 const OpenACCCopyInClause &C) {
11841 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()), C.isReadOnly(),
11842 /*IsZero=*/false);
11843
11844 NewClause = OpenACCCopyInClause::Create(
11845 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
11846 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11847 ParsedClause.isReadOnly(), ParsedClause.getVarList(),
11848 ParsedClause.getEndLoc());
11849}
11850
11851template <typename Derived>
11852void OpenACCClauseTransform<Derived>::VisitCopyOutClause(
11853 const OpenACCCopyOutClause &C) {
11854 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11855 /*IsReadOnly=*/false, C.isZero());
11856
11857 NewClause = OpenACCCopyOutClause::Create(
11858 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
11859 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11860 ParsedClause.isZero(), ParsedClause.getVarList(),
11861 ParsedClause.getEndLoc());
11862}
11863
11864template <typename Derived>
11865void OpenACCClauseTransform<Derived>::VisitCreateClause(
11866 const OpenACCCreateClause &C) {
11867 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11868 /*IsReadOnly=*/false, C.isZero());
11869
11870 NewClause = OpenACCCreateClause::Create(
11871 Self.getSema().getASTContext(), ParsedClause.getClauseKind(),
11872 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
11873 ParsedClause.isZero(), ParsedClause.getVarList(),
11874 ParsedClause.getEndLoc());
11875}
11876template <typename Derived>
11877void OpenACCClauseTransform<Derived>::VisitAttachClause(
11878 const OpenACCAttachClause &C) {
11879 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
11880
11881 // Ensure each var is a pointer type.
11882 VarList.erase(std::remove_if(VarList.begin(), VarList.end(), [&](Expr *E) {
11883 return Self.getSema().OpenACC().CheckVarIsPointerType(
11884 OpenACCClauseKind::Attach, E);
11885 }), VarList.end());
11886
11887 ParsedClause.setVarListDetails(VarList,
11888 /*IsReadOnly=*/false, /*IsZero=*/false);
11889 NewClause = OpenACCAttachClause::Create(
11890 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11891 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11892 ParsedClause.getEndLoc());
11893}
11894
11895template <typename Derived>
11896void OpenACCClauseTransform<Derived>::VisitDetachClause(
11897 const OpenACCDetachClause &C) {
11898 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
11899
11900 // Ensure each var is a pointer type.
11901 VarList.erase(
11902 std::remove_if(VarList.begin(), VarList.end(),
11903 [&](Expr *E) {
11904 return Self.getSema().OpenACC().CheckVarIsPointerType(
11905 OpenACCClauseKind::Detach, E);
11906 }),
11907 VarList.end());
11908
11909 ParsedClause.setVarListDetails(VarList,
11910 /*IsReadOnly=*/false, /*IsZero=*/false);
11911 NewClause = OpenACCDetachClause::Create(
11912 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11913 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11914 ParsedClause.getEndLoc());
11915}
11916
11917template <typename Derived>
11918void OpenACCClauseTransform<Derived>::VisitDeleteClause(
11919 const OpenACCDeleteClause &C) {
11920 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11921 /*IsReadOnly=*/false, /*IsZero=*/false);
11922 NewClause = OpenACCDeleteClause::Create(
11923 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11924 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11925 ParsedClause.getEndLoc());
11926}
11927
11928template <typename Derived>
11929void OpenACCClauseTransform<Derived>::VisitUseDeviceClause(
11930 const OpenACCUseDeviceClause &C) {
11931 ParsedClause.setVarListDetails(VisitVarList(C.getVarList()),
11932 /*IsReadOnly=*/false, /*IsZero=*/false);
11934 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11935 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11936 ParsedClause.getEndLoc());
11937}
11938
11939template <typename Derived>
11940void OpenACCClauseTransform<Derived>::VisitDevicePtrClause(
11941 const OpenACCDevicePtrClause &C) {
11942 llvm::SmallVector<Expr *> VarList = VisitVarList(C.getVarList());
11943
11944 // Ensure each var is a pointer type.
11945 VarList.erase(std::remove_if(VarList.begin(), VarList.end(), [&](Expr *E) {
11946 return Self.getSema().OpenACC().CheckVarIsPointerType(
11947 OpenACCClauseKind::DevicePtr, E);
11948 }), VarList.end());
11949
11950 ParsedClause.setVarListDetails(VarList,
11951 /*IsReadOnly=*/false, /*IsZero=*/false);
11953 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11954 ParsedClause.getLParenLoc(), ParsedClause.getVarList(),
11955 ParsedClause.getEndLoc());
11956}
11957
11958template <typename Derived>
11959void OpenACCClauseTransform<Derived>::VisitNumWorkersClause(
11960 const OpenACCNumWorkersClause &C) {
11961 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
11962 assert(IntExpr && "num_workers clause constructed with invalid int expr");
11963
11964 ExprResult Res = Self.TransformExpr(IntExpr);
11965 if (!Res.isUsable())
11966 return;
11967
11968 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11969 C.getClauseKind(),
11970 C.getBeginLoc(), Res.get());
11971 if (!Res.isUsable())
11972 return;
11973
11974 ParsedClause.setIntExprDetails(Res.get());
11976 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
11977 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
11978 ParsedClause.getEndLoc());
11979}
11980
11981template <typename Derived>
11982void OpenACCClauseTransform<Derived>::VisitDeviceNumClause (
11983 const OpenACCDeviceNumClause &C) {
11984 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
11985 assert(IntExpr && "device_num clause constructed with invalid int expr");
11986
11987 ExprResult Res = Self.TransformExpr(IntExpr);
11988 if (!Res.isUsable())
11989 return;
11990
11991 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
11992 C.getClauseKind(),
11993 C.getBeginLoc(), Res.get());
11994 if (!Res.isUsable())
11995 return;
11996
11997 ParsedClause.setIntExprDetails(Res.get());
11999 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12000 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12001 ParsedClause.getEndLoc());
12002}
12003
12004template <typename Derived>
12005void OpenACCClauseTransform<Derived>::VisitDefaultAsyncClause(
12006 const OpenACCDefaultAsyncClause &C) {
12007 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12008 assert(IntExpr && "default_async clause constructed with invalid int expr");
12009
12010 ExprResult Res = Self.TransformExpr(IntExpr);
12011 if (!Res.isUsable())
12012 return;
12013
12014 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12015 C.getClauseKind(),
12016 C.getBeginLoc(), Res.get());
12017 if (!Res.isUsable())
12018 return;
12019
12020 ParsedClause.setIntExprDetails(Res.get());
12022 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12023 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12024 ParsedClause.getEndLoc());
12025}
12026
12027template <typename Derived>
12028void OpenACCClauseTransform<Derived>::VisitVectorLengthClause(
12029 const OpenACCVectorLengthClause &C) {
12030 Expr *IntExpr = const_cast<Expr *>(C.getIntExpr());
12031 assert(IntExpr && "vector_length clause constructed with invalid int expr");
12032
12033 ExprResult Res = Self.TransformExpr(IntExpr);
12034 if (!Res.isUsable())
12035 return;
12036
12037 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12038 C.getClauseKind(),
12039 C.getBeginLoc(), Res.get());
12040 if (!Res.isUsable())
12041 return;
12042
12043 ParsedClause.setIntExprDetails(Res.get());
12045 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12046 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs()[0],
12047 ParsedClause.getEndLoc());
12048}
12049
12050template <typename Derived>
12051void OpenACCClauseTransform<Derived>::VisitAsyncClause(
12052 const OpenACCAsyncClause &C) {
12053 if (C.hasIntExpr()) {
12054 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12055 if (!Res.isUsable())
12056 return;
12057
12058 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12059 C.getClauseKind(),
12060 C.getBeginLoc(), Res.get());
12061 if (!Res.isUsable())
12062 return;
12063 ParsedClause.setIntExprDetails(Res.get());
12064 }
12065
12066 NewClause = OpenACCAsyncClause::Create(
12067 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12068 ParsedClause.getLParenLoc(),
12069 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12070 : nullptr,
12071 ParsedClause.getEndLoc());
12072}
12073
12074template <typename Derived>
12075void OpenACCClauseTransform<Derived>::VisitWorkerClause(
12076 const OpenACCWorkerClause &C) {
12077 if (C.hasIntExpr()) {
12078 // restrictions on this expression are all "does it exist in certain
12079 // situations" that are not possible to be dependent, so the only check we
12080 // have is that it transforms, and is an int expression.
12081 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12082 if (!Res.isUsable())
12083 return;
12084
12085 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12086 C.getClauseKind(),
12087 C.getBeginLoc(), Res.get());
12088 if (!Res.isUsable())
12089 return;
12090 ParsedClause.setIntExprDetails(Res.get());
12091 }
12092
12093 NewClause = OpenACCWorkerClause::Create(
12094 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12095 ParsedClause.getLParenLoc(),
12096 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12097 : nullptr,
12098 ParsedClause.getEndLoc());
12099}
12100
12101template <typename Derived>
12102void OpenACCClauseTransform<Derived>::VisitVectorClause(
12103 const OpenACCVectorClause &C) {
12104 if (C.hasIntExpr()) {
12105 // restrictions on this expression are all "does it exist in certain
12106 // situations" that are not possible to be dependent, so the only check we
12107 // have is that it transforms, and is an int expression.
12108 ExprResult Res = Self.TransformExpr(const_cast<Expr *>(C.getIntExpr()));
12109 if (!Res.isUsable())
12110 return;
12111
12112 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12113 C.getClauseKind(),
12114 C.getBeginLoc(), Res.get());
12115 if (!Res.isUsable())
12116 return;
12117 ParsedClause.setIntExprDetails(Res.get());
12118 }
12119
12120 NewClause = OpenACCVectorClause::Create(
12121 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12122 ParsedClause.getLParenLoc(),
12123 ParsedClause.getNumIntExprs() != 0 ? ParsedClause.getIntExprs()[0]
12124 : nullptr,
12125 ParsedClause.getEndLoc());
12126}
12127
12128template <typename Derived>
12129void OpenACCClauseTransform<Derived>::VisitWaitClause(
12130 const OpenACCWaitClause &C) {
12131 if (!C.getLParenLoc().isInvalid()) {
12132 Expr *DevNumExpr = nullptr;
12133 llvm::SmallVector<Expr *> InstantiatedQueueIdExprs;
12134
12135 // Instantiate devnum expr if it exists.
12136 if (C.getDevNumExpr()) {
12137 ExprResult Res = Self.TransformExpr(C.getDevNumExpr());
12138 if (!Res.isUsable())
12139 return;
12140 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12141 C.getClauseKind(),
12142 C.getBeginLoc(), Res.get());
12143 if (!Res.isUsable())
12144 return;
12145
12146 DevNumExpr = Res.get();
12147 }
12148
12149 // Instantiate queue ids.
12150 for (Expr *CurQueueIdExpr : C.getQueueIdExprs()) {
12151 ExprResult Res = Self.TransformExpr(CurQueueIdExpr);
12152 if (!Res.isUsable())
12153 return;
12154 Res = Self.getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Invalid,
12155 C.getClauseKind(),
12156 C.getBeginLoc(), Res.get());
12157 if (!Res.isUsable())
12158 return;
12159
12160 InstantiatedQueueIdExprs.push_back(Res.get());
12161 }
12162
12163 ParsedClause.setWaitDetails(DevNumExpr, C.getQueuesLoc(),
12164 std::move(InstantiatedQueueIdExprs));
12165 }
12166
12167 NewClause = OpenACCWaitClause::Create(
12168 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12169 ParsedClause.getLParenLoc(), ParsedClause.getDevNumExpr(),
12170 ParsedClause.getQueuesLoc(), ParsedClause.getQueueIdExprs(),
12171 ParsedClause.getEndLoc());
12172}
12173
12174template <typename Derived>
12175void OpenACCClauseTransform<Derived>::VisitDeviceTypeClause(
12176 const OpenACCDeviceTypeClause &C) {
12177 // Nothing to transform here, just create a new version of 'C'.
12179 Self.getSema().getASTContext(), C.getClauseKind(),
12180 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12181 C.getArchitectures(), ParsedClause.getEndLoc());
12182}
12183
12184template <typename Derived>
12185void OpenACCClauseTransform<Derived>::VisitAutoClause(
12186 const OpenACCAutoClause &C) {
12187 // Nothing to do, so just create a new node.
12188 NewClause = OpenACCAutoClause::Create(Self.getSema().getASTContext(),
12189 ParsedClause.getBeginLoc(),
12190 ParsedClause.getEndLoc());
12191}
12192
12193template <typename Derived>
12194void OpenACCClauseTransform<Derived>::VisitIndependentClause(
12195 const OpenACCIndependentClause &C) {
12196 NewClause = OpenACCIndependentClause::Create(Self.getSema().getASTContext(),
12197 ParsedClause.getBeginLoc(),
12198 ParsedClause.getEndLoc());
12199}
12200
12201template <typename Derived>
12202void OpenACCClauseTransform<Derived>::VisitSeqClause(
12203 const OpenACCSeqClause &C) {
12204 NewClause = OpenACCSeqClause::Create(Self.getSema().getASTContext(),
12205 ParsedClause.getBeginLoc(),
12206 ParsedClause.getEndLoc());
12207}
12208template <typename Derived>
12209void OpenACCClauseTransform<Derived>::VisitFinalizeClause(
12210 const OpenACCFinalizeClause &C) {
12211 NewClause = OpenACCFinalizeClause::Create(Self.getSema().getASTContext(),
12212 ParsedClause.getBeginLoc(),
12213 ParsedClause.getEndLoc());
12214}
12215
12216template <typename Derived>
12217void OpenACCClauseTransform<Derived>::VisitIfPresentClause(
12218 const OpenACCIfPresentClause &C) {
12219 NewClause = OpenACCIfPresentClause::Create(Self.getSema().getASTContext(),
12220 ParsedClause.getBeginLoc(),
12221 ParsedClause.getEndLoc());
12222}
12223
12224template <typename Derived>
12225void OpenACCClauseTransform<Derived>::VisitReductionClause(
12226 const OpenACCReductionClause &C) {
12227 SmallVector<Expr *> TransformedVars = VisitVarList(C.getVarList());
12228 SmallVector<Expr *> ValidVars;
12229
12230 for (Expr *Var : TransformedVars) {
12231 ExprResult Res = Self.getSema().OpenACC().CheckReductionVar(
12232 ParsedClause.getDirectiveKind(), C.getReductionOp(), Var);
12233 if (Res.isUsable())
12234 ValidVars.push_back(Res.get());
12235 }
12236
12237 NewClause = Self.getSema().OpenACC().CheckReductionClause(
12238 ExistingClauses, ParsedClause.getDirectiveKind(),
12239 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12240 C.getReductionOp(), ValidVars, ParsedClause.getEndLoc());
12241}
12242
12243template <typename Derived>
12244void OpenACCClauseTransform<Derived>::VisitCollapseClause(
12245 const OpenACCCollapseClause &C) {
12246 Expr *LoopCount = const_cast<Expr *>(C.getLoopCount());
12247 assert(LoopCount && "collapse clause constructed with invalid loop count");
12248
12249 ExprResult NewLoopCount = Self.TransformExpr(LoopCount);
12250
12251 NewLoopCount = Self.getSema().OpenACC().ActOnIntExpr(
12253 NewLoopCount.get()->getBeginLoc(), NewLoopCount.get());
12254
12255 NewLoopCount =
12256 Self.getSema().OpenACC().CheckCollapseLoopCount(NewLoopCount.get());
12257
12258 if (!NewLoopCount.isUsable())
12259 return;
12260
12261 ParsedClause.setCollapseDetails(C.hasForce(), NewLoopCount.get());
12263 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12264 ParsedClause.getLParenLoc(), ParsedClause.isForce(),
12265 ParsedClause.getLoopCount(), ParsedClause.getEndLoc());
12266}
12267
12268template <typename Derived>
12269void OpenACCClauseTransform<Derived>::VisitTileClause(
12270 const OpenACCTileClause &C) {
12271
12272 llvm::SmallVector<Expr *> TransformedExprs;
12273
12274 for (Expr *E : C.getSizeExprs()) {
12275 ExprResult NewSizeExpr = Self.TransformExpr(E);
12276
12277 if (!NewSizeExpr.isUsable())
12278 return;
12279
12280 NewSizeExpr = Self.getSema().OpenACC().ActOnIntExpr(
12282 NewSizeExpr.get()->getBeginLoc(), NewSizeExpr.get());
12283
12284 NewSizeExpr = Self.getSema().OpenACC().CheckTileSizeExpr(NewSizeExpr.get());
12285
12286 if (!NewSizeExpr.isUsable())
12287 return;
12288 TransformedExprs.push_back(NewSizeExpr.get());
12289 }
12290
12291 ParsedClause.setIntExprDetails(TransformedExprs);
12292 NewClause = OpenACCTileClause::Create(
12293 Self.getSema().getASTContext(), ParsedClause.getBeginLoc(),
12294 ParsedClause.getLParenLoc(), ParsedClause.getIntExprs(),
12295 ParsedClause.getEndLoc());
12296}
12297template <typename Derived>
12298void OpenACCClauseTransform<Derived>::VisitGangClause(
12299 const OpenACCGangClause &C) {
12300 llvm::SmallVector<OpenACCGangKind> TransformedGangKinds;
12301 llvm::SmallVector<Expr *> TransformedIntExprs;
12302
12303 for (unsigned I = 0; I < C.getNumExprs(); ++I) {
12304 ExprResult ER = Self.TransformExpr(const_cast<Expr *>(C.getExpr(I).second));
12305 if (!ER.isUsable())
12306 continue;
12307
12308 ER = Self.getSema().OpenACC().CheckGangExpr(ExistingClauses,
12309 ParsedClause.getDirectiveKind(),
12310 C.getExpr(I).first, ER.get());
12311 if (!ER.isUsable())
12312 continue;
12313 TransformedGangKinds.push_back(C.getExpr(I).first);
12314 TransformedIntExprs.push_back(ER.get());
12315 }
12316
12317 NewClause = Self.getSema().OpenACC().CheckGangClause(
12318 ParsedClause.getDirectiveKind(), ExistingClauses,
12319 ParsedClause.getBeginLoc(), ParsedClause.getLParenLoc(),
12320 TransformedGangKinds, TransformedIntExprs, ParsedClause.getEndLoc());
12321}
12322} // namespace
12323template <typename Derived>
12324OpenACCClause *TreeTransform<Derived>::TransformOpenACCClause(
12325 ArrayRef<const OpenACCClause *> ExistingClauses,
12326 OpenACCDirectiveKind DirKind, const OpenACCClause *OldClause) {
12327
12328 SemaOpenACC::OpenACCParsedClause ParsedClause(
12329 DirKind, OldClause->getClauseKind(), OldClause->getBeginLoc());
12330 ParsedClause.setEndLoc(OldClause->getEndLoc());
12331
12332 if (const auto *WithParms = dyn_cast<OpenACCClauseWithParams>(OldClause))
12333 ParsedClause.setLParenLoc(WithParms->getLParenLoc());
12334
12335 OpenACCClauseTransform<Derived> Transform{*this, ExistingClauses,
12336 ParsedClause};
12337 Transform.Visit(OldClause);
12338
12339 return Transform.CreatedClause();
12340}
12341
12342template <typename Derived>
12344TreeTransform<Derived>::TransformOpenACCClauseList(
12346 llvm::SmallVector<OpenACCClause *> TransformedClauses;
12347 for (const auto *Clause : OldClauses) {
12348 if (OpenACCClause *TransformedClause = getDerived().TransformOpenACCClause(
12349 TransformedClauses, DirKind, Clause))
12350 TransformedClauses.push_back(TransformedClause);
12351 }
12352 return TransformedClauses;
12353}
12354
12355template <typename Derived>
12356StmtResult TreeTransform<Derived>::TransformOpenACCComputeConstruct(
12357 OpenACCComputeConstruct *C) {
12358 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12359
12360 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12361 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12362 C->clauses());
12363
12364 if (getSema().OpenACC().ActOnStartStmtDirective(
12365 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12366 return StmtError();
12367
12368 // Transform Structured Block.
12369 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12370 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12371 C->clauses(), TransformedClauses);
12372 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12373 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12374 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12375
12376 return getDerived().RebuildOpenACCComputeConstruct(
12377 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12378 C->getEndLoc(), TransformedClauses, StrBlock);
12379}
12380
12381template <typename Derived>
12383TreeTransform<Derived>::TransformOpenACCLoopConstruct(OpenACCLoopConstruct *C) {
12384
12385 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12386
12387 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12388 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12389 C->clauses());
12390
12391 if (getSema().OpenACC().ActOnStartStmtDirective(
12392 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12393 return StmtError();
12394
12395 // Transform Loop.
12396 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12397 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12398 C->clauses(), TransformedClauses);
12399 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12400 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12401 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12402
12403 return getDerived().RebuildOpenACCLoopConstruct(
12404 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12405 TransformedClauses, Loop);
12406}
12407
12408template <typename Derived>
12409StmtResult TreeTransform<Derived>::TransformOpenACCCombinedConstruct(
12410 OpenACCCombinedConstruct *C) {
12411 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12412
12413 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12414 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12415 C->clauses());
12416
12417 if (getSema().OpenACC().ActOnStartStmtDirective(
12418 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12419 return StmtError();
12420
12421 // Transform Loop.
12422 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12423 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12424 C->clauses(), TransformedClauses);
12425 StmtResult Loop = getDerived().TransformStmt(C->getLoop());
12426 Loop = getSema().OpenACC().ActOnAssociatedStmt(
12427 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, Loop);
12428
12429 return getDerived().RebuildOpenACCCombinedConstruct(
12430 C->getDirectiveKind(), C->getBeginLoc(), C->getDirectiveLoc(),
12431 C->getEndLoc(), TransformedClauses, Loop);
12432}
12433
12434template <typename Derived>
12436TreeTransform<Derived>::TransformOpenACCDataConstruct(OpenACCDataConstruct *C) {
12437 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12438
12439 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12440 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12441 C->clauses());
12442 if (getSema().OpenACC().ActOnStartStmtDirective(
12443 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12444 return StmtError();
12445
12446 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12447 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12448 C->clauses(), TransformedClauses);
12449 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12450 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12451 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12452
12453 return getDerived().RebuildOpenACCDataConstruct(
12454 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12455 TransformedClauses, StrBlock);
12456}
12457
12458template <typename Derived>
12459StmtResult TreeTransform<Derived>::TransformOpenACCEnterDataConstruct(
12460 OpenACCEnterDataConstruct *C) {
12461 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12462
12463 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12464 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12465 C->clauses());
12466 if (getSema().OpenACC().ActOnStartStmtDirective(
12467 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12468 return StmtError();
12469
12470 return getDerived().RebuildOpenACCEnterDataConstruct(
12471 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12472 TransformedClauses);
12473}
12474
12475template <typename Derived>
12476StmtResult TreeTransform<Derived>::TransformOpenACCExitDataConstruct(
12477 OpenACCExitDataConstruct *C) {
12478 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12479
12480 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12481 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12482 C->clauses());
12483 if (getSema().OpenACC().ActOnStartStmtDirective(
12484 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12485 return StmtError();
12486
12487 return getDerived().RebuildOpenACCExitDataConstruct(
12488 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12489 TransformedClauses);
12490}
12491
12492template <typename Derived>
12493StmtResult TreeTransform<Derived>::TransformOpenACCHostDataConstruct(
12494 OpenACCHostDataConstruct *C) {
12495 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12496
12497 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12498 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12499 C->clauses());
12500 if (getSema().OpenACC().ActOnStartStmtDirective(
12501 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12502 return StmtError();
12503
12504 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12505 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(),
12506 C->clauses(), TransformedClauses);
12507 StmtResult StrBlock = getDerived().TransformStmt(C->getStructuredBlock());
12508 StrBlock = getSema().OpenACC().ActOnAssociatedStmt(
12509 C->getBeginLoc(), C->getDirectiveKind(), TransformedClauses, StrBlock);
12510
12511 return getDerived().RebuildOpenACCHostDataConstruct(
12512 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12513 TransformedClauses, StrBlock);
12514}
12515
12516template <typename Derived>
12518TreeTransform<Derived>::TransformOpenACCInitConstruct(OpenACCInitConstruct *C) {
12519 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12520
12521 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12522 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12523 C->clauses());
12524 if (getSema().OpenACC().ActOnStartStmtDirective(
12525 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12526 return StmtError();
12527
12528 return getDerived().RebuildOpenACCInitConstruct(
12529 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12530 TransformedClauses);
12531}
12532
12533template <typename Derived>
12534StmtResult TreeTransform<Derived>::TransformOpenACCShutdownConstruct(
12535 OpenACCShutdownConstruct *C) {
12536 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12537
12538 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12539 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12540 C->clauses());
12541 if (getSema().OpenACC().ActOnStartStmtDirective(
12542 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12543 return StmtError();
12544
12545 return getDerived().RebuildOpenACCShutdownConstruct(
12546 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12547 TransformedClauses);
12548}
12549template <typename Derived>
12551TreeTransform<Derived>::TransformOpenACCSetConstruct(OpenACCSetConstruct *C) {
12552 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12553
12554 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12555 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12556 C->clauses());
12557 if (getSema().OpenACC().ActOnStartStmtDirective(
12558 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12559 return StmtError();
12560
12561 return getDerived().RebuildOpenACCSetConstruct(
12562 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12563 TransformedClauses);
12564}
12565
12566template <typename Derived>
12567StmtResult TreeTransform<Derived>::TransformOpenACCUpdateConstruct(
12568 OpenACCUpdateConstruct *C) {
12569 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12570
12571 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12572 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12573 C->clauses());
12574 if (getSema().OpenACC().ActOnStartStmtDirective(
12575 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12576 return StmtError();
12577
12578 return getDerived().RebuildOpenACCUpdateConstruct(
12579 C->getBeginLoc(), C->getDirectiveLoc(), C->getEndLoc(),
12580 TransformedClauses);
12581}
12582
12583template <typename Derived>
12585TreeTransform<Derived>::TransformOpenACCWaitConstruct(OpenACCWaitConstruct *C) {
12586 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12587
12588 ExprResult DevNumExpr;
12589 if (C->hasDevNumExpr()) {
12590 DevNumExpr = getDerived().TransformExpr(C->getDevNumExpr());
12591
12592 if (DevNumExpr.isUsable())
12593 DevNumExpr = getSema().OpenACC().ActOnIntExpr(
12595 C->getBeginLoc(), DevNumExpr.get());
12596 }
12597
12598 llvm::SmallVector<Expr *> QueueIdExprs;
12599
12600 for (Expr *QE : C->getQueueIdExprs()) {
12601 assert(QE && "Null queue id expr?");
12602 ExprResult NewEQ = getDerived().TransformExpr(QE);
12603
12604 if (!NewEQ.isUsable())
12605 break;
12606 NewEQ = getSema().OpenACC().ActOnIntExpr(OpenACCDirectiveKind::Wait,
12608 C->getBeginLoc(), NewEQ.get());
12609 if (NewEQ.isUsable())
12610 QueueIdExprs.push_back(NewEQ.get());
12611 }
12612
12613 llvm::SmallVector<OpenACCClause *> TransformedClauses =
12614 getDerived().TransformOpenACCClauseList(C->getDirectiveKind(),
12615 C->clauses());
12616
12617 if (getSema().OpenACC().ActOnStartStmtDirective(
12618 C->getDirectiveKind(), C->getBeginLoc(), TransformedClauses))
12619 return StmtError();
12620
12621 return getDerived().RebuildOpenACCWaitConstruct(
12622 C->getBeginLoc(), C->getDirectiveLoc(), C->getLParenLoc(),
12623 DevNumExpr.isUsable() ? DevNumExpr.get() : nullptr, C->getQueuesLoc(),
12624 QueueIdExprs, C->getRParenLoc(), C->getEndLoc(), TransformedClauses);
12625}
12626
12627template <typename Derived>
12628StmtResult TreeTransform<Derived>::TransformOpenACCAtomicConstruct(
12629 OpenACCAtomicConstruct *C) {
12630 getSema().OpenACC().ActOnConstruct(C->getDirectiveKind(), C->getBeginLoc());
12631
12632 if (getSema().OpenACC().ActOnStartStmtDirective(C->getDirectiveKind(),
12633 C->getBeginLoc(), {}))
12634 return StmtError();
12635
12636 // Transform Associated Stmt.
12637 SemaOpenACC::AssociatedStmtRAII AssocStmtRAII(
12638 getSema().OpenACC(), C->getDirectiveKind(), C->getDirectiveLoc(), {}, {});
12639
12640 StmtResult AssocStmt = getDerived().TransformStmt(C->getAssociatedStmt());
12641 AssocStmt = getSema().OpenACC().ActOnAssociatedStmt(
12642 C->getBeginLoc(), C->getDirectiveKind(), C->getAtomicKind(), {},
12643 AssocStmt);
12644
12645 return getDerived().RebuildOpenACCAtomicConstruct(
12646 C->getBeginLoc(), C->getDirectiveLoc(), C->getAtomicKind(),
12647 C->getEndLoc(), AssocStmt);
12648}
12649
12650template <typename Derived>
12651ExprResult TreeTransform<Derived>::TransformOpenACCAsteriskSizeExpr(
12652 OpenACCAsteriskSizeExpr *E) {
12653 if (getDerived().AlwaysRebuild())
12654 return getDerived().RebuildOpenACCAsteriskSizeExpr(E->getLocation());
12655 // Nothing can ever change, so there is never anything to transform.
12656 return E;
12657}
12658
12659//===----------------------------------------------------------------------===//
12660// Expression transformation
12661//===----------------------------------------------------------------------===//
12662template<typename Derived>
12664TreeTransform<Derived>::TransformConstantExpr(ConstantExpr *E) {
12665 return TransformExpr(E->getSubExpr());
12666}
12667
12668template <typename Derived>
12669ExprResult TreeTransform<Derived>::TransformSYCLUniqueStableNameExpr(
12670 SYCLUniqueStableNameExpr *E) {
12671 if (!E->isTypeDependent())
12672 return E;
12673
12674 TypeSourceInfo *NewT = getDerived().TransformType(E->getTypeSourceInfo());
12675
12676 if (!NewT)
12677 return ExprError();
12678
12679 if (!getDerived().AlwaysRebuild() && E->getTypeSourceInfo() == NewT)
12680 return E;
12681
12682 return getDerived().RebuildSYCLUniqueStableNameExpr(
12683 E->getLocation(), E->getLParenLocation(), E->getRParenLocation(), NewT);
12684}
12685
12686template<typename Derived>
12688TreeTransform<Derived>::TransformPredefinedExpr(PredefinedExpr *E) {
12689 if (!E->isTypeDependent())
12690 return E;
12691
12692 return getDerived().RebuildPredefinedExpr(E->getLocation(),
12693 E->getIdentKind());
12694}
12695
12696template<typename Derived>
12698TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
12699 NestedNameSpecifierLoc QualifierLoc;
12700 if (E->getQualifierLoc()) {
12701 QualifierLoc
12702 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
12703 if (!QualifierLoc)
12704 return ExprError();
12705 }
12706
12707 ValueDecl *ND
12708 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
12709 E->getDecl()));
12710 if (!ND)
12711 return ExprError();
12712
12713 NamedDecl *Found = ND;
12714 if (E->getFoundDecl() != E->getDecl()) {
12715 Found = cast_or_null<NamedDecl>(
12716 getDerived().TransformDecl(E->getLocation(), E->getFoundDecl()));
12717 if (!Found)
12718 return ExprError();
12719 }
12720
12721 DeclarationNameInfo NameInfo = E->getNameInfo();
12722 if (NameInfo.getName()) {
12723 NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
12724 if (!NameInfo.getName())
12725 return ExprError();
12726 }
12727
12728 if (!getDerived().AlwaysRebuild() &&
12729 !E->isCapturedByCopyInLambdaWithExplicitObjectParameter() &&
12730 QualifierLoc == E->getQualifierLoc() && ND == E->getDecl() &&
12731 Found == E->getFoundDecl() &&
12732 NameInfo.getName() == E->getDecl()->getDeclName() &&
12733 !E->hasExplicitTemplateArgs()) {
12734
12735 // Mark it referenced in the new context regardless.
12736 // FIXME: this is a bit instantiation-specific.
12737 SemaRef.MarkDeclRefReferenced(E);
12738
12739 return E;
12740 }
12741
12742 TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
12743 if (E->hasExplicitTemplateArgs()) {
12744 TemplateArgs = &TransArgs;
12745 TransArgs.setLAngleLoc(E->getLAngleLoc());
12746 TransArgs.setRAngleLoc(E->getRAngleLoc());
12747 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
12748 E->getNumTemplateArgs(),
12749 TransArgs))
12750 return ExprError();
12751 }
12752
12753 return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
12754 Found, TemplateArgs);
12755}
12756
12757template<typename Derived>
12759TreeTransform<Derived>::TransformIntegerLiteral(IntegerLiteral *E) {
12760 return E;
12761}
12762
12763template <typename Derived>
12764ExprResult TreeTransform<Derived>::TransformFixedPointLiteral(
12765 FixedPointLiteral *E) {
12766 return E;
12767}
12768
12769template<typename Derived>
12771TreeTransform<Derived>::TransformFloatingLiteral(FloatingLiteral *E) {
12772 return E;
12773}
12774
12775template<typename Derived>
12777TreeTransform<Derived>::TransformImaginaryLiteral(ImaginaryLiteral *E) {
12778 return E;
12779}
12780
12781template<typename Derived>
12783TreeTransform<Derived>::TransformStringLiteral(StringLiteral *E) {
12784 return E;
12785}
12786
12787template<typename Derived>
12789TreeTransform<Derived>::TransformCharacterLiteral(CharacterLiteral *E) {
12790 return E;
12791}
12792
12793template<typename Derived>
12795TreeTransform<Derived>::TransformUserDefinedLiteral(UserDefinedLiteral *E) {
12796 return getDerived().TransformCallExpr(E);
12797}
12798
12799template<typename Derived>
12801TreeTransform<Derived>::TransformGenericSelectionExpr(GenericSelectionExpr *E) {
12802 ExprResult ControllingExpr;
12803 TypeSourceInfo *ControllingType = nullptr;
12804 if (E->isExprPredicate())
12805 ControllingExpr = getDerived().TransformExpr(E->getControllingExpr());
12806 else
12807 ControllingType = getDerived().TransformType(E->getControllingType());
12808
12809 if (ControllingExpr.isInvalid() && !ControllingType)
12810 return ExprError();
12811
12812 SmallVector<Expr *, 4> AssocExprs;
12814 for (const GenericSelectionExpr::Association Assoc : E->associations()) {
12815 TypeSourceInfo *TSI = Assoc.getTypeSourceInfo();
12816 if (TSI) {
12817 TypeSourceInfo *AssocType = getDerived().TransformType(TSI);
12818 if (!AssocType)
12819 return ExprError();
12820 AssocTypes.push_back(AssocType);
12821 } else {
12822 AssocTypes.push_back(nullptr);
12823 }
12824
12825 ExprResult AssocExpr =
12826 getDerived().TransformExpr(Assoc.getAssociationExpr());
12827 if (AssocExpr.isInvalid())
12828 return ExprError();
12829 AssocExprs.push_back(AssocExpr.get());
12830 }
12831
12832 if (!ControllingType)
12833 return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
12834 E->getDefaultLoc(),
12835 E->getRParenLoc(),
12836 ControllingExpr.get(),
12837 AssocTypes,
12838 AssocExprs);
12839 return getDerived().RebuildGenericSelectionExpr(
12840 E->getGenericLoc(), E->getDefaultLoc(), E->getRParenLoc(),
12841 ControllingType, AssocTypes, AssocExprs);
12842}
12843
12844template<typename Derived>
12846TreeTransform<Derived>::TransformParenExpr(ParenExpr *E) {
12847 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
12848 if (SubExpr.isInvalid())
12849 return ExprError();
12850
12851 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
12852 return E;
12853
12854 return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
12855 E->getRParen());
12856}
12857
12858/// The operand of a unary address-of operator has special rules: it's
12859/// allowed to refer to a non-static member of a class even if there's no 'this'
12860/// object available.
12861template<typename Derived>
12864 if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
12865 return getDerived().TransformDependentScopeDeclRefExpr(
12866 DRE, /*IsAddressOfOperand=*/true, nullptr);
12867 else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E))
12868 return getDerived().TransformUnresolvedLookupExpr(
12869 ULE, /*IsAddressOfOperand=*/true);
12870 else
12871 return getDerived().TransformExpr(E);
12872}
12873
12874template<typename Derived>
12877 ExprResult SubExpr;
12878 if (E->getOpcode() == UO_AddrOf)
12879 SubExpr = TransformAddressOfOperand(E->getSubExpr());
12880 else
12881 SubExpr = TransformExpr(E->getSubExpr());
12882 if (SubExpr.isInvalid())
12883 return ExprError();
12884
12885 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
12886 return E;
12887
12888 return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
12889 E->getOpcode(),
12890 SubExpr.get());
12891}
12892
12893template<typename Derived>
12895TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
12896 // Transform the type.
12897 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
12898 if (!Type)
12899 return ExprError();
12900
12901 // Transform all of the components into components similar to what the
12902 // parser uses.
12903 // FIXME: It would be slightly more efficient in the non-dependent case to
12904 // just map FieldDecls, rather than requiring the rebuilder to look for
12905 // the fields again. However, __builtin_offsetof is rare enough in
12906 // template code that we don't care.
12907 bool ExprChanged = false;
12908 typedef Sema::OffsetOfComponent Component;
12909 SmallVector<Component, 4> Components;
12910 for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
12911 const OffsetOfNode &ON = E->getComponent(I);
12912 Component Comp;
12913 Comp.isBrackets = true;
12914 Comp.LocStart = ON.getSourceRange().getBegin();
12915 Comp.LocEnd = ON.getSourceRange().getEnd();
12916 switch (ON.getKind()) {
12917 case OffsetOfNode::Array: {
12918 Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
12919 ExprResult Index = getDerived().TransformExpr(FromIndex);
12920 if (Index.isInvalid())
12921 return ExprError();
12922
12923 ExprChanged = ExprChanged || Index.get() != FromIndex;
12924 Comp.isBrackets = true;
12925 Comp.U.E = Index.get();
12926 break;
12927 }
12928
12931 Comp.isBrackets = false;
12932 Comp.U.IdentInfo = ON.getFieldName();
12933 if (!Comp.U.IdentInfo)
12934 continue;
12935
12936 break;
12937
12938 case OffsetOfNode::Base:
12939 // Will be recomputed during the rebuild.
12940 continue;
12941 }
12942
12943 Components.push_back(Comp);
12944 }
12945
12946 // If nothing changed, retain the existing expression.
12947 if (!getDerived().AlwaysRebuild() &&
12948 Type == E->getTypeSourceInfo() &&
12949 !ExprChanged)
12950 return E;
12951
12952 // Build a new offsetof expression.
12953 return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
12954 Components, E->getRParenLoc());
12955}
12956
12957template<typename Derived>
12959TreeTransform<Derived>::TransformOpaqueValueExpr(OpaqueValueExpr *E) {
12960 assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
12961 "opaque value expression requires transformation");
12962 return E;
12963}
12964
12965template<typename Derived>
12967TreeTransform<Derived>::TransformTypoExpr(TypoExpr *E) {
12968 return E;
12969}
12970
12971template <typename Derived>
12972ExprResult TreeTransform<Derived>::TransformRecoveryExpr(RecoveryExpr *E) {
12974 bool Changed = false;
12975 for (Expr *C : E->subExpressions()) {
12976 ExprResult NewC = getDerived().TransformExpr(C);
12977 if (NewC.isInvalid())
12978 return ExprError();
12979 Children.push_back(NewC.get());
12980
12981 Changed |= NewC.get() != C;
12982 }
12983 if (!getDerived().AlwaysRebuild() && !Changed)
12984 return E;
12985 return getDerived().RebuildRecoveryExpr(E->getBeginLoc(), E->getEndLoc(),
12986 Children, E->getType());
12987}
12988
12989template<typename Derived>
12991TreeTransform<Derived>::TransformPseudoObjectExpr(PseudoObjectExpr *E) {
12992 // Rebuild the syntactic form. The original syntactic form has
12993 // opaque-value expressions in it, so strip those away and rebuild
12994 // the result. This is a really awful way of doing this, but the
12995 // better solution (rebuilding the semantic expressions and
12996 // rebinding OVEs as necessary) doesn't work; we'd need
12997 // TreeTransform to not strip away implicit conversions.
12998 Expr *newSyntacticForm = SemaRef.PseudoObject().recreateSyntacticForm(E);
12999 ExprResult result = getDerived().TransformExpr(newSyntacticForm);
13000 if (result.isInvalid()) return ExprError();
13001
13002 // If that gives us a pseudo-object result back, the pseudo-object
13003 // expression must have been an lvalue-to-rvalue conversion which we
13004 // should reapply.
13005 if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
13006 result = SemaRef.PseudoObject().checkRValue(result.get());
13007
13008 return result;
13009}
13010
13011template<typename Derived>
13013TreeTransform<Derived>::TransformUnaryExprOrTypeTraitExpr(
13014 UnaryExprOrTypeTraitExpr *E) {
13015 if (E->isArgumentType()) {
13016 TypeSourceInfo *OldT = E->getArgumentTypeInfo();
13017
13018 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13019 if (!NewT)
13020 return ExprError();
13021
13022 if (!getDerived().AlwaysRebuild() && OldT == NewT)
13023 return E;
13024
13025 return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
13026 E->getKind(),
13027 E->getSourceRange());
13028 }
13029
13030 // C++0x [expr.sizeof]p1:
13031 // The operand is either an expression, which is an unevaluated operand
13032 // [...]
13033 EnterExpressionEvaluationContext Unevaluated(
13036
13037 // Try to recover if we have something like sizeof(T::X) where X is a type.
13038 // Notably, there must be *exactly* one set of parens if X is a type.
13039 TypeSourceInfo *RecoveryTSI = nullptr;
13040 ExprResult SubExpr;
13041 auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
13042 if (auto *DRE =
13043 PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
13044 SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
13045 PE, DRE, false, &RecoveryTSI);
13046 else
13047 SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
13048
13049 if (RecoveryTSI) {
13050 return getDerived().RebuildUnaryExprOrTypeTrait(
13051 RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
13052 } else if (SubExpr.isInvalid())
13053 return ExprError();
13054
13055 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
13056 return E;
13057
13058 return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
13059 E->getOperatorLoc(),
13060 E->getKind(),
13061 E->getSourceRange());
13062}
13063
13064template<typename Derived>
13066TreeTransform<Derived>::TransformArraySubscriptExpr(ArraySubscriptExpr *E) {
13067 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13068 if (LHS.isInvalid())
13069 return ExprError();
13070
13071 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13072 if (RHS.isInvalid())
13073 return ExprError();
13074
13075
13076 if (!getDerived().AlwaysRebuild() &&
13077 LHS.get() == E->getLHS() &&
13078 RHS.get() == E->getRHS())
13079 return E;
13080
13081 return getDerived().RebuildArraySubscriptExpr(
13082 LHS.get(),
13083 /*FIXME:*/ E->getLHS()->getBeginLoc(), RHS.get(), E->getRBracketLoc());
13084}
13085
13086template <typename Derived>
13088TreeTransform<Derived>::TransformMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
13089 ExprResult Base = getDerived().TransformExpr(E->getBase());
13090 if (Base.isInvalid())
13091 return ExprError();
13092
13093 ExprResult RowIdx = getDerived().TransformExpr(E->getRowIdx());
13094 if (RowIdx.isInvalid())
13095 return ExprError();
13096
13097 ExprResult ColumnIdx = getDerived().TransformExpr(E->getColumnIdx());
13098 if (ColumnIdx.isInvalid())
13099 return ExprError();
13100
13101 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13102 RowIdx.get() == E->getRowIdx() && ColumnIdx.get() == E->getColumnIdx())
13103 return E;
13104
13105 return getDerived().RebuildMatrixSubscriptExpr(
13106 Base.get(), RowIdx.get(), ColumnIdx.get(), E->getRBracketLoc());
13107}
13108
13109template <typename Derived>
13111TreeTransform<Derived>::TransformArraySectionExpr(ArraySectionExpr *E) {
13112 ExprResult Base = getDerived().TransformExpr(E->getBase());
13113 if (Base.isInvalid())
13114 return ExprError();
13115
13116 ExprResult LowerBound;
13117 if (E->getLowerBound()) {
13118 LowerBound = getDerived().TransformExpr(E->getLowerBound());
13119 if (LowerBound.isInvalid())
13120 return ExprError();
13121 }
13122
13123 ExprResult Length;
13124 if (E->getLength()) {
13125 Length = getDerived().TransformExpr(E->getLength());
13126 if (Length.isInvalid())
13127 return ExprError();
13128 }
13129
13130 ExprResult Stride;
13131 if (E->isOMPArraySection()) {
13132 if (Expr *Str = E->getStride()) {
13133 Stride = getDerived().TransformExpr(Str);
13134 if (Stride.isInvalid())
13135 return ExprError();
13136 }
13137 }
13138
13139 if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
13140 LowerBound.get() == E->getLowerBound() &&
13141 Length.get() == E->getLength() &&
13142 (E->isOpenACCArraySection() || Stride.get() == E->getStride()))
13143 return E;
13144
13145 return getDerived().RebuildArraySectionExpr(
13146 E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
13147 LowerBound.get(), E->getColonLocFirst(),
13148 E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
13149 Length.get(), Stride.get(), E->getRBracketLoc());
13150}
13151
13152template <typename Derived>
13154TreeTransform<Derived>::TransformOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
13155 ExprResult Base = getDerived().TransformExpr(E->getBase());
13156 if (Base.isInvalid())
13157 return ExprError();
13158
13160 bool ErrorFound = false;
13161 for (Expr *Dim : E->getDimensions()) {
13162 ExprResult DimRes = getDerived().TransformExpr(Dim);
13163 if (DimRes.isInvalid()) {
13164 ErrorFound = true;
13165 continue;
13166 }
13167 Dims.push_back(DimRes.get());
13168 }
13169
13170 if (ErrorFound)
13171 return ExprError();
13172 return getDerived().RebuildOMPArrayShapingExpr(Base.get(), E->getLParenLoc(),
13173 E->getRParenLoc(), Dims,
13174 E->getBracketsRanges());
13175}
13176
13177template <typename Derived>
13179TreeTransform<Derived>::TransformOMPIteratorExpr(OMPIteratorExpr *E) {
13180 unsigned NumIterators = E->numOfIterators();
13182
13183 bool ErrorFound = false;
13184 bool NeedToRebuild = getDerived().AlwaysRebuild();
13185 for (unsigned I = 0; I < NumIterators; ++I) {
13186 auto *D = cast<VarDecl>(E->getIteratorDecl(I));
13187 Data[I].DeclIdent = D->getIdentifier();
13188 Data[I].DeclIdentLoc = D->getLocation();
13189 if (D->getLocation() == D->getBeginLoc()) {
13190 assert(SemaRef.Context.hasSameType(D->getType(), SemaRef.Context.IntTy) &&
13191 "Implicit type must be int.");
13192 } else {
13193 TypeSourceInfo *TSI = getDerived().TransformType(D->getTypeSourceInfo());
13194 QualType DeclTy = getDerived().TransformType(D->getType());
13195 Data[I].Type = SemaRef.CreateParsedType(DeclTy, TSI);
13196 }
13197 OMPIteratorExpr::IteratorRange Range = E->getIteratorRange(I);
13198 ExprResult Begin = getDerived().TransformExpr(Range.Begin);
13199 ExprResult End = getDerived().TransformExpr(Range.End);
13200 ExprResult Step = getDerived().TransformExpr(Range.Step);
13201 ErrorFound = ErrorFound ||
13202 !(!D->getTypeSourceInfo() || (Data[I].Type.getAsOpaquePtr() &&
13203 !Data[I].Type.get().isNull())) ||
13204 Begin.isInvalid() || End.isInvalid() || Step.isInvalid();
13205 if (ErrorFound)
13206 continue;
13207 Data[I].Range.Begin = Begin.get();
13208 Data[I].Range.End = End.get();
13209 Data[I].Range.Step = Step.get();
13210 Data[I].AssignLoc = E->getAssignLoc(I);
13211 Data[I].ColonLoc = E->getColonLoc(I);
13212 Data[I].SecColonLoc = E->getSecondColonLoc(I);
13213 NeedToRebuild =
13214 NeedToRebuild ||
13215 (D->getTypeSourceInfo() && Data[I].Type.get().getTypePtrOrNull() !=
13216 D->getType().getTypePtrOrNull()) ||
13217 Range.Begin != Data[I].Range.Begin || Range.End != Data[I].Range.End ||
13218 Range.Step != Data[I].Range.Step;
13219 }
13220 if (ErrorFound)
13221 return ExprError();
13222 if (!NeedToRebuild)
13223 return E;
13224
13225 ExprResult Res = getDerived().RebuildOMPIteratorExpr(
13226 E->getIteratorKwLoc(), E->getLParenLoc(), E->getRParenLoc(), Data);
13227 if (!Res.isUsable())
13228 return Res;
13229 auto *IE = cast<OMPIteratorExpr>(Res.get());
13230 for (unsigned I = 0; I < NumIterators; ++I)
13231 getDerived().transformedLocalDecl(E->getIteratorDecl(I),
13232 IE->getIteratorDecl(I));
13233 return Res;
13234}
13235
13236template<typename Derived>
13238TreeTransform<Derived>::TransformCallExpr(CallExpr *E) {
13239 // Transform the callee.
13240 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13241 if (Callee.isInvalid())
13242 return ExprError();
13243
13244 // Transform arguments.
13245 bool ArgChanged = false;
13247 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13248 &ArgChanged))
13249 return ExprError();
13250
13251 if (!getDerived().AlwaysRebuild() &&
13252 Callee.get() == E->getCallee() &&
13253 !ArgChanged)
13254 return SemaRef.MaybeBindToTemporary(E);
13255
13256 // FIXME: Wrong source location information for the '('.
13257 SourceLocation FakeLParenLoc
13258 = ((Expr *)Callee.get())->getSourceRange().getBegin();
13259
13260 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13261 if (E->hasStoredFPFeatures()) {
13262 FPOptionsOverride NewOverrides = E->getFPFeatures();
13263 getSema().CurFPFeatures =
13264 NewOverrides.applyOverrides(getSema().getLangOpts());
13265 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13266 }
13267
13268 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
13269 Args,
13270 E->getRParenLoc());
13271}
13272
13273template<typename Derived>
13275TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
13276 ExprResult Base = getDerived().TransformExpr(E->getBase());
13277 if (Base.isInvalid())
13278 return ExprError();
13279
13280 NestedNameSpecifierLoc QualifierLoc;
13281 if (E->hasQualifier()) {
13282 QualifierLoc
13283 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
13284
13285 if (!QualifierLoc)
13286 return ExprError();
13287 }
13288 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
13289
13290 ValueDecl *Member
13291 = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
13292 E->getMemberDecl()));
13293 if (!Member)
13294 return ExprError();
13295
13296 NamedDecl *FoundDecl = E->getFoundDecl();
13297 if (FoundDecl == E->getMemberDecl()) {
13298 FoundDecl = Member;
13299 } else {
13300 FoundDecl = cast_or_null<NamedDecl>(
13301 getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
13302 if (!FoundDecl)
13303 return ExprError();
13304 }
13305
13306 if (!getDerived().AlwaysRebuild() &&
13307 Base.get() == E->getBase() &&
13308 QualifierLoc == E->getQualifierLoc() &&
13309 Member == E->getMemberDecl() &&
13310 FoundDecl == E->getFoundDecl() &&
13311 !E->hasExplicitTemplateArgs()) {
13312
13313 // Skip for member expression of (this->f), rebuilt thisi->f is needed
13314 // for Openmp where the field need to be privatizized in the case.
13315 if (!(isa<CXXThisExpr>(E->getBase()) &&
13316 getSema().OpenMP().isOpenMPRebuildMemberExpr(
13317 cast<ValueDecl>(Member)))) {
13318 // Mark it referenced in the new context regardless.
13319 // FIXME: this is a bit instantiation-specific.
13320 SemaRef.MarkMemberReferenced(E);
13321 return E;
13322 }
13323 }
13324
13325 TemplateArgumentListInfo TransArgs;
13326 if (E->hasExplicitTemplateArgs()) {
13327 TransArgs.setLAngleLoc(E->getLAngleLoc());
13328 TransArgs.setRAngleLoc(E->getRAngleLoc());
13329 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
13330 E->getNumTemplateArgs(),
13331 TransArgs))
13332 return ExprError();
13333 }
13334
13335 // FIXME: Bogus source location for the operator
13336 SourceLocation FakeOperatorLoc =
13337 SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
13338
13339 // FIXME: to do this check properly, we will need to preserve the
13340 // first-qualifier-in-scope here, just in case we had a dependent
13341 // base (and therefore couldn't do the check) and a
13342 // nested-name-qualifier (and therefore could do the lookup).
13343 NamedDecl *FirstQualifierInScope = nullptr;
13344 DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
13345 if (MemberNameInfo.getName()) {
13346 MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
13347 if (!MemberNameInfo.getName())
13348 return ExprError();
13349 }
13350
13351 return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
13352 E->isArrow(),
13353 QualifierLoc,
13354 TemplateKWLoc,
13355 MemberNameInfo,
13356 Member,
13357 FoundDecl,
13358 (E->hasExplicitTemplateArgs()
13359 ? &TransArgs : nullptr),
13360 FirstQualifierInScope);
13361}
13362
13363template<typename Derived>
13365TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) {
13366 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13367 if (LHS.isInvalid())
13368 return ExprError();
13369
13370 ExprResult RHS =
13371 getDerived().TransformInitializer(E->getRHS(), /*NotCopyInit=*/false);
13372 if (RHS.isInvalid())
13373 return ExprError();
13374
13375 if (!getDerived().AlwaysRebuild() &&
13376 LHS.get() == E->getLHS() &&
13377 RHS.get() == E->getRHS())
13378 return E;
13379
13380 if (E->isCompoundAssignmentOp())
13381 // FPFeatures has already been established from trailing storage
13382 return getDerived().RebuildBinaryOperator(
13383 E->getOperatorLoc(), E->getOpcode(), LHS.get(), RHS.get());
13384 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13385 FPOptionsOverride NewOverrides(E->getFPFeatures());
13386 getSema().CurFPFeatures =
13387 NewOverrides.applyOverrides(getSema().getLangOpts());
13388 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13389 return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
13390 LHS.get(), RHS.get());
13391}
13392
13393template <typename Derived>
13394ExprResult TreeTransform<Derived>::TransformCXXRewrittenBinaryOperator(
13395 CXXRewrittenBinaryOperator *E) {
13396 CXXRewrittenBinaryOperator::DecomposedForm Decomp = E->getDecomposedForm();
13397
13398 ExprResult LHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.LHS));
13399 if (LHS.isInvalid())
13400 return ExprError();
13401
13402 ExprResult RHS = getDerived().TransformExpr(const_cast<Expr*>(Decomp.RHS));
13403 if (RHS.isInvalid())
13404 return ExprError();
13405
13406 // Extract the already-resolved callee declarations so that we can restrict
13407 // ourselves to using them as the unqualified lookup results when rebuilding.
13408 UnresolvedSet<2> UnqualLookups;
13409 bool ChangedAnyLookups = false;
13410 Expr *PossibleBinOps[] = {E->getSemanticForm(),
13411 const_cast<Expr *>(Decomp.InnerBinOp)};
13412 for (Expr *PossibleBinOp : PossibleBinOps) {
13413 auto *Op = dyn_cast<CXXOperatorCallExpr>(PossibleBinOp->IgnoreImplicit());
13414 if (!Op)
13415 continue;
13416 auto *Callee = dyn_cast<DeclRefExpr>(Op->getCallee()->IgnoreImplicit());
13417 if (!Callee || isa<CXXMethodDecl>(Callee->getDecl()))
13418 continue;
13419
13420 // Transform the callee in case we built a call to a local extern
13421 // declaration.
13422 NamedDecl *Found = cast_or_null<NamedDecl>(getDerived().TransformDecl(
13423 E->getOperatorLoc(), Callee->getFoundDecl()));
13424 if (!Found)
13425 return ExprError();
13426 if (Found != Callee->getFoundDecl())
13427 ChangedAnyLookups = true;
13428 UnqualLookups.addDecl(Found);
13429 }
13430
13431 if (!getDerived().AlwaysRebuild() && !ChangedAnyLookups &&
13432 LHS.get() == Decomp.LHS && RHS.get() == Decomp.RHS) {
13433 // Mark all functions used in the rewrite as referenced. Note that when
13434 // a < b is rewritten to (a <=> b) < 0, both the <=> and the < might be
13435 // function calls, and/or there might be a user-defined conversion sequence
13436 // applied to the operands of the <.
13437 // FIXME: this is a bit instantiation-specific.
13438 const Expr *StopAt[] = {Decomp.LHS, Decomp.RHS};
13439 SemaRef.MarkDeclarationsReferencedInExpr(E, false, StopAt);
13440 return E;
13441 }
13442
13443 return getDerived().RebuildCXXRewrittenBinaryOperator(
13444 E->getOperatorLoc(), Decomp.Opcode, UnqualLookups, LHS.get(), RHS.get());
13445}
13446
13447template<typename Derived>
13449TreeTransform<Derived>::TransformCompoundAssignOperator(
13450 CompoundAssignOperator *E) {
13451 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13452 FPOptionsOverride NewOverrides(E->getFPFeatures());
13453 getSema().CurFPFeatures =
13454 NewOverrides.applyOverrides(getSema().getLangOpts());
13455 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13456 return getDerived().TransformBinaryOperator(E);
13457}
13458
13459template<typename Derived>
13460ExprResult TreeTransform<Derived>::
13461TransformBinaryConditionalOperator(BinaryConditionalOperator *e) {
13462 // Just rebuild the common and RHS expressions and see whether we
13463 // get any changes.
13464
13465 ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
13466 if (commonExpr.isInvalid())
13467 return ExprError();
13468
13469 ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
13470 if (rhs.isInvalid())
13471 return ExprError();
13472
13473 if (!getDerived().AlwaysRebuild() &&
13474 commonExpr.get() == e->getCommon() &&
13475 rhs.get() == e->getFalseExpr())
13476 return e;
13477
13478 return getDerived().RebuildConditionalOperator(commonExpr.get(),
13479 e->getQuestionLoc(),
13480 nullptr,
13481 e->getColonLoc(),
13482 rhs.get());
13483}
13484
13485template<typename Derived>
13487TreeTransform<Derived>::TransformConditionalOperator(ConditionalOperator *E) {
13488 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13489 if (Cond.isInvalid())
13490 return ExprError();
13491
13492 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13493 if (LHS.isInvalid())
13494 return ExprError();
13495
13496 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13497 if (RHS.isInvalid())
13498 return ExprError();
13499
13500 if (!getDerived().AlwaysRebuild() &&
13501 Cond.get() == E->getCond() &&
13502 LHS.get() == E->getLHS() &&
13503 RHS.get() == E->getRHS())
13504 return E;
13505
13506 return getDerived().RebuildConditionalOperator(Cond.get(),
13507 E->getQuestionLoc(),
13508 LHS.get(),
13509 E->getColonLoc(),
13510 RHS.get());
13511}
13512
13513template<typename Derived>
13515TreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) {
13516 // Implicit casts are eliminated during transformation, since they
13517 // will be recomputed by semantic analysis after transformation.
13518 return getDerived().TransformExpr(E->getSubExprAsWritten());
13519}
13520
13521template<typename Derived>
13523TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) {
13524 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
13525 if (!Type)
13526 return ExprError();
13527
13528 ExprResult SubExpr
13529 = getDerived().TransformExpr(E->getSubExprAsWritten());
13530 if (SubExpr.isInvalid())
13531 return ExprError();
13532
13533 if (!getDerived().AlwaysRebuild() &&
13534 Type == E->getTypeInfoAsWritten() &&
13535 SubExpr.get() == E->getSubExpr())
13536 return E;
13537
13538 return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
13539 Type,
13540 E->getRParenLoc(),
13541 SubExpr.get());
13542}
13543
13544template<typename Derived>
13546TreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) {
13547 TypeSourceInfo *OldT = E->getTypeSourceInfo();
13548 TypeSourceInfo *NewT = getDerived().TransformType(OldT);
13549 if (!NewT)
13550 return ExprError();
13551
13552 ExprResult Init = getDerived().TransformExpr(E->getInitializer());
13553 if (Init.isInvalid())
13554 return ExprError();
13555
13556 if (!getDerived().AlwaysRebuild() &&
13557 OldT == NewT &&
13558 Init.get() == E->getInitializer())
13559 return SemaRef.MaybeBindToTemporary(E);
13560
13561 // Note: the expression type doesn't necessarily match the
13562 // type-as-written, but that's okay, because it should always be
13563 // derivable from the initializer.
13564
13565 return getDerived().RebuildCompoundLiteralExpr(
13566 E->getLParenLoc(), NewT,
13567 /*FIXME:*/ E->getInitializer()->getEndLoc(), Init.get());
13568}
13569
13570template<typename Derived>
13572TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) {
13573 ExprResult Base = getDerived().TransformExpr(E->getBase());
13574 if (Base.isInvalid())
13575 return ExprError();
13576
13577 if (!getDerived().AlwaysRebuild() &&
13578 Base.get() == E->getBase())
13579 return E;
13580
13581 // FIXME: Bad source location
13582 SourceLocation FakeOperatorLoc =
13583 SemaRef.getLocForEndOfToken(E->getBase()->getEndLoc());
13584 return getDerived().RebuildExtVectorElementExpr(
13585 Base.get(), FakeOperatorLoc, E->isArrow(), E->getAccessorLoc(),
13586 E->getAccessor());
13587}
13588
13589template<typename Derived>
13591TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) {
13592 if (InitListExpr *Syntactic = E->getSyntacticForm())
13593 E = Syntactic;
13594
13595 bool InitChanged = false;
13596
13597 EnterExpressionEvaluationContext Context(
13599
13601 if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
13602 Inits, &InitChanged))
13603 return ExprError();
13604
13605 if (!getDerived().AlwaysRebuild() && !InitChanged) {
13606 // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
13607 // in some cases. We can't reuse it in general, because the syntactic and
13608 // semantic forms are linked, and we can't know that semantic form will
13609 // match even if the syntactic form does.
13610 }
13611
13612 return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
13613 E->getRBraceLoc());
13614}
13615
13616template<typename Derived>
13618TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
13619 Designation Desig;
13620
13621 // transform the initializer value
13622 ExprResult Init = getDerived().TransformExpr(E->getInit());
13623 if (Init.isInvalid())
13624 return ExprError();
13625
13626 // transform the designators.
13627 SmallVector<Expr*, 4> ArrayExprs;
13628 bool ExprChanged = false;
13629 for (const DesignatedInitExpr::Designator &D : E->designators()) {
13630 if (D.isFieldDesignator()) {
13631 if (D.getFieldDecl()) {
13632 FieldDecl *Field = cast_or_null<FieldDecl>(
13633 getDerived().TransformDecl(D.getFieldLoc(), D.getFieldDecl()));
13634 if (Field != D.getFieldDecl())
13635 // Rebuild the expression when the transformed FieldDecl is
13636 // different to the already assigned FieldDecl.
13637 ExprChanged = true;
13638 if (Field->isAnonymousStructOrUnion())
13639 continue;
13640 } else {
13641 // Ensure that the designator expression is rebuilt when there isn't
13642 // a resolved FieldDecl in the designator as we don't want to assign
13643 // a FieldDecl to a pattern designator that will be instantiated again.
13644 ExprChanged = true;
13645 }
13646 Desig.AddDesignator(Designator::CreateFieldDesignator(
13647 D.getFieldName(), D.getDotLoc(), D.getFieldLoc()));
13648 continue;
13649 }
13650
13651 if (D.isArrayDesignator()) {
13652 ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
13653 if (Index.isInvalid())
13654 return ExprError();
13655
13656 Desig.AddDesignator(
13657 Designator::CreateArrayDesignator(Index.get(), D.getLBracketLoc()));
13658
13659 ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D);
13660 ArrayExprs.push_back(Index.get());
13661 continue;
13662 }
13663
13664 assert(D.isArrayRangeDesignator() && "New kind of designator?");
13665 ExprResult Start
13666 = getDerived().TransformExpr(E->getArrayRangeStart(D));
13667 if (Start.isInvalid())
13668 return ExprError();
13669
13670 ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
13671 if (End.isInvalid())
13672 return ExprError();
13673
13674 Desig.AddDesignator(Designator::CreateArrayRangeDesignator(
13675 Start.get(), End.get(), D.getLBracketLoc(), D.getEllipsisLoc()));
13676
13677 ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
13678 End.get() != E->getArrayRangeEnd(D);
13679
13680 ArrayExprs.push_back(Start.get());
13681 ArrayExprs.push_back(End.get());
13682 }
13683
13684 if (!getDerived().AlwaysRebuild() &&
13685 Init.get() == E->getInit() &&
13686 !ExprChanged)
13687 return E;
13688
13689 return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
13690 E->getEqualOrColonLoc(),
13691 E->usesGNUSyntax(), Init.get());
13692}
13693
13694// Seems that if TransformInitListExpr() only works on the syntactic form of an
13695// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
13696template<typename Derived>
13698TreeTransform<Derived>::TransformDesignatedInitUpdateExpr(
13699 DesignatedInitUpdateExpr *E) {
13700 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
13701 "initializer");
13702 return ExprError();
13703}
13704
13705template<typename Derived>
13707TreeTransform<Derived>::TransformNoInitExpr(
13708 NoInitExpr *E) {
13709 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
13710 return ExprError();
13711}
13712
13713template<typename Derived>
13715TreeTransform<Derived>::TransformArrayInitLoopExpr(ArrayInitLoopExpr *E) {
13716 llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
13717 return ExprError();
13718}
13719
13720template<typename Derived>
13722TreeTransform<Derived>::TransformArrayInitIndexExpr(ArrayInitIndexExpr *E) {
13723 llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
13724 return ExprError();
13725}
13726
13727template<typename Derived>
13729TreeTransform<Derived>::TransformImplicitValueInitExpr(
13730 ImplicitValueInitExpr *E) {
13731 TemporaryBase Rebase(*this, E->getBeginLoc(), DeclarationName());
13732
13733 // FIXME: Will we ever have proper type location here? Will we actually
13734 // need to transform the type?
13735 QualType T = getDerived().TransformType(E->getType());
13736 if (T.isNull())
13737 return ExprError();
13738
13739 if (!getDerived().AlwaysRebuild() &&
13740 T == E->getType())
13741 return E;
13742
13743 return getDerived().RebuildImplicitValueInitExpr(T);
13744}
13745
13746template<typename Derived>
13748TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) {
13749 TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
13750 if (!TInfo)
13751 return ExprError();
13752
13753 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
13754 if (SubExpr.isInvalid())
13755 return ExprError();
13756
13757 if (!getDerived().AlwaysRebuild() &&
13758 TInfo == E->getWrittenTypeInfo() &&
13759 SubExpr.get() == E->getSubExpr())
13760 return E;
13761
13762 return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
13763 TInfo, E->getRParenLoc());
13764}
13765
13766template<typename Derived>
13768TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) {
13769 bool ArgumentChanged = false;
13771 if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
13772 &ArgumentChanged))
13773 return ExprError();
13774
13775 return getDerived().RebuildParenListExpr(E->getLParenLoc(),
13776 Inits,
13777 E->getRParenLoc());
13778}
13779
13780/// Transform an address-of-label expression.
13781///
13782/// By default, the transformation of an address-of-label expression always
13783/// rebuilds the expression, so that the label identifier can be resolved to
13784/// the corresponding label statement by semantic analysis.
13785template<typename Derived>
13787TreeTransform<Derived>::TransformAddrLabelExpr(AddrLabelExpr *E) {
13788 Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
13789 E->getLabel());
13790 if (!LD)
13791 return ExprError();
13792
13793 return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
13794 cast<LabelDecl>(LD));
13795}
13796
13797template<typename Derived>
13799TreeTransform<Derived>::TransformStmtExpr(StmtExpr *E) {
13800 SemaRef.ActOnStartStmtExpr();
13801 StmtResult SubStmt
13802 = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
13803 if (SubStmt.isInvalid()) {
13804 SemaRef.ActOnStmtExprError();
13805 return ExprError();
13806 }
13807
13808 unsigned OldDepth = E->getTemplateDepth();
13809 unsigned NewDepth = getDerived().TransformTemplateDepth(OldDepth);
13810
13811 if (!getDerived().AlwaysRebuild() && OldDepth == NewDepth &&
13812 SubStmt.get() == E->getSubStmt()) {
13813 // Calling this an 'error' is unintuitive, but it does the right thing.
13814 SemaRef.ActOnStmtExprError();
13815 return SemaRef.MaybeBindToTemporary(E);
13816 }
13817
13818 return getDerived().RebuildStmtExpr(E->getLParenLoc(), SubStmt.get(),
13819 E->getRParenLoc(), NewDepth);
13820}
13821
13822template<typename Derived>
13824TreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) {
13825 ExprResult Cond = getDerived().TransformExpr(E->getCond());
13826 if (Cond.isInvalid())
13827 return ExprError();
13828
13829 ExprResult LHS = getDerived().TransformExpr(E->getLHS());
13830 if (LHS.isInvalid())
13831 return ExprError();
13832
13833 ExprResult RHS = getDerived().TransformExpr(E->getRHS());
13834 if (RHS.isInvalid())
13835 return ExprError();
13836
13837 if (!getDerived().AlwaysRebuild() &&
13838 Cond.get() == E->getCond() &&
13839 LHS.get() == E->getLHS() &&
13840 RHS.get() == E->getRHS())
13841 return E;
13842
13843 return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
13844 Cond.get(), LHS.get(), RHS.get(),
13845 E->getRParenLoc());
13846}
13847
13848template<typename Derived>
13850TreeTransform<Derived>::TransformGNUNullExpr(GNUNullExpr *E) {
13851 return E;
13852}
13853
13854template<typename Derived>
13856TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
13857 switch (E->getOperator()) {
13858 case OO_New:
13859 case OO_Delete:
13860 case OO_Array_New:
13861 case OO_Array_Delete:
13862 llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
13863
13864 case OO_Subscript:
13865 case OO_Call: {
13866 // This is a call to an object's operator().
13867 assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
13868
13869 // Transform the object itself.
13870 ExprResult Object = getDerived().TransformExpr(E->getArg(0));
13871 if (Object.isInvalid())
13872 return ExprError();
13873
13874 // FIXME: Poor location information
13875 SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(
13876 static_cast<Expr *>(Object.get())->getEndLoc());
13877
13878 // Transform the call arguments.
13880 if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
13881 Args))
13882 return ExprError();
13883
13884 if (E->getOperator() == OO_Subscript)
13885 return getDerived().RebuildCxxSubscriptExpr(Object.get(), FakeLParenLoc,
13886 Args, E->getEndLoc());
13887
13888 return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, Args,
13889 E->getEndLoc());
13890 }
13891
13892#define OVERLOADED_OPERATOR(Name, Spelling, Token, Unary, Binary, MemberOnly) \
13893 case OO_##Name: \
13894 break;
13895
13896#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
13897#include "clang/Basic/OperatorKinds.def"
13898
13899 case OO_Conditional:
13900 llvm_unreachable("conditional operator is not actually overloadable");
13901
13902 case OO_None:
13904 llvm_unreachable("not an overloaded operator?");
13905 }
13906
13908 if (E->getNumArgs() == 1 && E->getOperator() == OO_Amp)
13909 First = getDerived().TransformAddressOfOperand(E->getArg(0));
13910 else
13911 First = getDerived().TransformExpr(E->getArg(0));
13912 if (First.isInvalid())
13913 return ExprError();
13914
13915 ExprResult Second;
13916 if (E->getNumArgs() == 2) {
13917 Second =
13918 getDerived().TransformInitializer(E->getArg(1), /*NotCopyInit=*/false);
13919 if (Second.isInvalid())
13920 return ExprError();
13921 }
13922
13923 Sema::FPFeaturesStateRAII FPFeaturesState(getSema());
13924 FPOptionsOverride NewOverrides(E->getFPFeatures());
13925 getSema().CurFPFeatures =
13926 NewOverrides.applyOverrides(getSema().getLangOpts());
13927 getSema().FpPragmaStack.CurrentValue = NewOverrides;
13928
13929 Expr *Callee = E->getCallee();
13930 if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
13931 LookupResult R(SemaRef, ULE->getName(), ULE->getNameLoc(),
13933 if (getDerived().TransformOverloadExprDecls(ULE, ULE->requiresADL(), R))
13934 return ExprError();
13935
13936 return getDerived().RebuildCXXOperatorCallExpr(
13937 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
13938 ULE->requiresADL(), R.asUnresolvedSet(), First.get(), Second.get());
13939 }
13940
13941 UnresolvedSet<1> Functions;
13942 if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Callee))
13943 Callee = ICE->getSubExprAsWritten();
13944 NamedDecl *DR = cast<DeclRefExpr>(Callee)->getDecl();
13945 ValueDecl *VD = cast_or_null<ValueDecl>(
13946 getDerived().TransformDecl(DR->getLocation(), DR));
13947 if (!VD)
13948 return ExprError();
13949
13950 if (!isa<CXXMethodDecl>(VD))
13951 Functions.addDecl(VD);
13952
13953 return getDerived().RebuildCXXOperatorCallExpr(
13954 E->getOperator(), E->getOperatorLoc(), Callee->getBeginLoc(),
13955 /*RequiresADL=*/false, Functions, First.get(), Second.get());
13956}
13957
13958template<typename Derived>
13960TreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) {
13961 return getDerived().TransformCallExpr(E);
13962}
13963
13964template <typename Derived>
13965ExprResult TreeTransform<Derived>::TransformSourceLocExpr(SourceLocExpr *E) {
13966 bool NeedRebuildFunc = SourceLocExpr::MayBeDependent(E->getIdentKind()) &&
13967 getSema().CurContext != E->getParentContext();
13968
13969 if (!getDerived().AlwaysRebuild() && !NeedRebuildFunc)
13970 return E;
13971
13972 return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
13973 E->getBeginLoc(), E->getEndLoc(),
13974 getSema().CurContext);
13975}
13976
13977template <typename Derived>
13978ExprResult TreeTransform<Derived>::TransformEmbedExpr(EmbedExpr *E) {
13979 return E;
13980}
13981
13982template<typename Derived>
13984TreeTransform<Derived>::TransformCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
13985 // Transform the callee.
13986 ExprResult Callee = getDerived().TransformExpr(E->getCallee());
13987 if (Callee.isInvalid())
13988 return ExprError();
13989
13990 // Transform exec config.
13991 ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
13992 if (EC.isInvalid())
13993 return ExprError();
13994
13995 // Transform arguments.
13996 bool ArgChanged = false;
13998 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
13999 &ArgChanged))
14000 return ExprError();
14001
14002 if (!getDerived().AlwaysRebuild() &&
14003 Callee.get() == E->getCallee() &&
14004 !ArgChanged)
14005 return SemaRef.MaybeBindToTemporary(E);
14006
14007 // FIXME: Wrong source location information for the '('.
14008 SourceLocation FakeLParenLoc
14009 = ((Expr *)Callee.get())->getSourceRange().getBegin();
14010 return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
14011 Args,
14012 E->getRParenLoc(), EC.get());
14013}
14014
14015template<typename Derived>
14018 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
14019 if (!Type)
14020 return ExprError();
14021
14022 ExprResult SubExpr
14023 = getDerived().TransformExpr(E->getSubExprAsWritten());
14024 if (SubExpr.isInvalid())
14025 return ExprError();
14026
14027 if (!getDerived().AlwaysRebuild() &&
14028 Type == E->getTypeInfoAsWritten() &&
14029 SubExpr.get() == E->getSubExpr())
14030 return E;
14031 return getDerived().RebuildCXXNamedCastExpr(
14032 E->getOperatorLoc(), E->getStmtClass(), E->getAngleBrackets().getBegin(),
14033 Type, E->getAngleBrackets().getEnd(),
14034 // FIXME. this should be '(' location
14035 E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
14036}
14037
14038template<typename Derived>
14041 TypeSourceInfo *TSI =
14042 getDerived().TransformType(BCE->getTypeInfoAsWritten());
14043 if (!TSI)
14044 return ExprError();
14045
14046 ExprResult Sub = getDerived().TransformExpr(BCE->getSubExpr());
14047 if (Sub.isInvalid())
14048 return ExprError();
14049
14050 return getDerived().RebuildBuiltinBitCastExpr(BCE->getBeginLoc(), TSI,
14051 Sub.get(), BCE->getEndLoc());
14052}
14053
14054template<typename Derived>
14056TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
14057 return getDerived().TransformCXXNamedCastExpr(E);
14058}
14059
14060template<typename Derived>
14062TreeTransform<Derived>::TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
14063 return getDerived().TransformCXXNamedCastExpr(E);
14064}
14065
14066template<typename Derived>
14068TreeTransform<Derived>::TransformCXXReinterpretCastExpr(
14069 CXXReinterpretCastExpr *E) {
14070 return getDerived().TransformCXXNamedCastExpr(E);
14071}
14072
14073template<typename Derived>
14075TreeTransform<Derived>::TransformCXXConstCastExpr(CXXConstCastExpr *E) {
14076 return getDerived().TransformCXXNamedCastExpr(E);
14077}
14078
14079template<typename Derived>
14081TreeTransform<Derived>::TransformCXXAddrspaceCastExpr(CXXAddrspaceCastExpr *E) {
14082 return getDerived().TransformCXXNamedCastExpr(E);
14083}
14084
14085template<typename Derived>
14087TreeTransform<Derived>::TransformCXXFunctionalCastExpr(
14088 CXXFunctionalCastExpr *E) {
14089 TypeSourceInfo *Type =
14090 getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
14091 if (!Type)
14092 return ExprError();
14093
14094 ExprResult SubExpr
14095 = getDerived().TransformExpr(E->getSubExprAsWritten());
14096 if (SubExpr.isInvalid())
14097 return ExprError();
14098
14099 if (!getDerived().AlwaysRebuild() &&
14100 Type == E->getTypeInfoAsWritten() &&
14101 SubExpr.get() == E->getSubExpr())
14102 return E;
14103
14104 return getDerived().RebuildCXXFunctionalCastExpr(Type,
14105 E->getLParenLoc(),
14106 SubExpr.get(),
14107 E->getRParenLoc(),
14108 E->isListInitialization());
14109}
14110
14111template<typename Derived>
14113TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
14114 if (E->isTypeOperand()) {
14115 TypeSourceInfo *TInfo
14116 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14117 if (!TInfo)
14118 return ExprError();
14119
14120 if (!getDerived().AlwaysRebuild() &&
14121 TInfo == E->getTypeOperandSourceInfo())
14122 return E;
14123
14124 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14125 TInfo, E->getEndLoc());
14126 }
14127
14128 // Typeid's operand is an unevaluated context, unless it's a polymorphic
14129 // type. We must not unilaterally enter unevaluated context here, as then
14130 // semantic processing can re-transform an already transformed operand.
14131 Expr *Op = E->getExprOperand();
14133 if (E->isGLValue())
14134 if (auto *RecordT = Op->getType()->getAs<RecordType>())
14135 if (cast<CXXRecordDecl>(RecordT->getDecl())->isPolymorphic())
14136 EvalCtx = SemaRef.ExprEvalContexts.back().Context;
14137
14138 EnterExpressionEvaluationContext Unevaluated(SemaRef, EvalCtx,
14140
14141 ExprResult SubExpr = getDerived().TransformExpr(Op);
14142 if (SubExpr.isInvalid())
14143 return ExprError();
14144
14145 if (!getDerived().AlwaysRebuild() &&
14146 SubExpr.get() == E->getExprOperand())
14147 return E;
14148
14149 return getDerived().RebuildCXXTypeidExpr(E->getType(), E->getBeginLoc(),
14150 SubExpr.get(), E->getEndLoc());
14151}
14152
14153template<typename Derived>
14155TreeTransform<Derived>::TransformCXXUuidofExpr(CXXUuidofExpr *E) {
14156 if (E->isTypeOperand()) {
14157 TypeSourceInfo *TInfo
14158 = getDerived().TransformType(E->getTypeOperandSourceInfo());
14159 if (!TInfo)
14160 return ExprError();
14161
14162 if (!getDerived().AlwaysRebuild() &&
14163 TInfo == E->getTypeOperandSourceInfo())
14164 return E;
14165
14166 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14167 TInfo, E->getEndLoc());
14168 }
14169
14170 EnterExpressionEvaluationContext Unevaluated(
14172
14173 ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
14174 if (SubExpr.isInvalid())
14175 return ExprError();
14176
14177 if (!getDerived().AlwaysRebuild() &&
14178 SubExpr.get() == E->getExprOperand())
14179 return E;
14180
14181 return getDerived().RebuildCXXUuidofExpr(E->getType(), E->getBeginLoc(),
14182 SubExpr.get(), E->getEndLoc());
14183}
14184
14185template<typename Derived>
14187TreeTransform<Derived>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
14188 return E;
14189}
14190
14191template<typename Derived>
14193TreeTransform<Derived>::TransformCXXNullPtrLiteralExpr(
14194 CXXNullPtrLiteralExpr *E) {
14195 return E;
14196}
14197
14198template<typename Derived>
14200TreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) {
14201
14202 // In lambdas, the qualifiers of the type depends of where in
14203 // the call operator `this` appear, and we do not have a good way to
14204 // rebuild this information, so we transform the type.
14205 //
14206 // In other contexts, the type of `this` may be overrided
14207 // for type deduction, so we need to recompute it.
14208 //
14209 // Always recompute the type if we're in the body of a lambda, and
14210 // 'this' is dependent on a lambda's explicit object parameter.
14211 QualType T = [&]() {
14212 auto &S = getSema();
14213 if (E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
14214 return S.getCurrentThisType();
14215 if (S.getCurLambda())
14216 return getDerived().TransformType(E->getType());
14217 return S.getCurrentThisType();
14218 }();
14219
14220 if (!getDerived().AlwaysRebuild() && T == E->getType()) {
14221 // Mark it referenced in the new context regardless.
14222 // FIXME: this is a bit instantiation-specific.
14223 getSema().MarkThisReferenced(E);
14224 return E;
14225 }
14226
14227 return getDerived().RebuildCXXThisExpr(E->getBeginLoc(), T, E->isImplicit());
14228}
14229
14230template<typename Derived>
14232TreeTransform<Derived>::TransformCXXThrowExpr(CXXThrowExpr *E) {
14233 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
14234 if (SubExpr.isInvalid())
14235 return ExprError();
14236
14237 if (!getDerived().AlwaysRebuild() &&
14238 SubExpr.get() == E->getSubExpr())
14239 return E;
14240
14241 return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
14242 E->isThrownVariableInScope());
14243}
14244
14245template<typename Derived>
14247TreeTransform<Derived>::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
14248 ParmVarDecl *Param = cast_or_null<ParmVarDecl>(
14249 getDerived().TransformDecl(E->getBeginLoc(), E->getParam()));
14250 if (!Param)
14251 return ExprError();
14252
14253 ExprResult InitRes;
14254 if (E->hasRewrittenInit()) {
14255 InitRes = getDerived().TransformExpr(E->getRewrittenExpr());
14256 if (InitRes.isInvalid())
14257 return ExprError();
14258 }
14259
14260 if (!getDerived().AlwaysRebuild() && Param == E->getParam() &&
14261 E->getUsedContext() == SemaRef.CurContext &&
14262 InitRes.get() == E->getRewrittenExpr())
14263 return E;
14264
14265 return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param,
14266 InitRes.get());
14267}
14268
14269template<typename Derived>
14271TreeTransform<Derived>::TransformCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
14272 FieldDecl *Field = cast_or_null<FieldDecl>(
14273 getDerived().TransformDecl(E->getBeginLoc(), E->getField()));
14274 if (!Field)
14275 return ExprError();
14276
14277 if (!getDerived().AlwaysRebuild() && Field == E->getField() &&
14278 E->getUsedContext() == SemaRef.CurContext)
14279 return E;
14280
14281 return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
14282}
14283
14284template<typename Derived>
14286TreeTransform<Derived>::TransformCXXScalarValueInitExpr(
14287 CXXScalarValueInitExpr *E) {
14288 TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
14289 if (!T)
14290 return ExprError();
14291
14292 if (!getDerived().AlwaysRebuild() &&
14293 T == E->getTypeSourceInfo())
14294 return E;
14295
14296 return getDerived().RebuildCXXScalarValueInitExpr(T,
14297 /*FIXME:*/T->getTypeLoc().getEndLoc(),
14298 E->getRParenLoc());
14299}
14300
14301template<typename Derived>
14303TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
14304 // Transform the type that we're allocating
14305 TypeSourceInfo *AllocTypeInfo =
14306 getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
14307 if (!AllocTypeInfo)
14308 return ExprError();
14309
14310 // Transform the size of the array we're allocating (if any).
14311 std::optional<Expr *> ArraySize;
14312 if (E->isArray()) {
14313 ExprResult NewArraySize;
14314 if (std::optional<Expr *> OldArraySize = E->getArraySize()) {
14315 NewArraySize = getDerived().TransformExpr(*OldArraySize);
14316 if (NewArraySize.isInvalid())
14317 return ExprError();
14318 }
14319 ArraySize = NewArraySize.get();
14320 }
14321
14322 // Transform the placement arguments (if any).
14323 bool ArgumentChanged = false;
14324 SmallVector<Expr*, 8> PlacementArgs;
14325 if (getDerived().TransformExprs(E->getPlacementArgs(),
14326 E->getNumPlacementArgs(), true,
14327 PlacementArgs, &ArgumentChanged))
14328 return ExprError();
14329
14330 // Transform the initializer (if any).
14331 Expr *OldInit = E->getInitializer();
14332 ExprResult NewInit;
14333 if (OldInit)
14334 NewInit = getDerived().TransformInitializer(OldInit, true);
14335 if (NewInit.isInvalid())
14336 return ExprError();
14337
14338 // Transform new operator and delete operator.
14339 FunctionDecl *OperatorNew = nullptr;
14340 if (E->getOperatorNew()) {
14341 OperatorNew = cast_or_null<FunctionDecl>(
14342 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorNew()));
14343 if (!OperatorNew)
14344 return ExprError();
14345 }
14346
14347 FunctionDecl *OperatorDelete = nullptr;
14348 if (E->getOperatorDelete()) {
14349 OperatorDelete = cast_or_null<FunctionDecl>(
14350 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14351 if (!OperatorDelete)
14352 return ExprError();
14353 }
14354
14355 if (!getDerived().AlwaysRebuild() &&
14356 AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
14357 ArraySize == E->getArraySize() &&
14358 NewInit.get() == OldInit &&
14359 OperatorNew == E->getOperatorNew() &&
14360 OperatorDelete == E->getOperatorDelete() &&
14361 !ArgumentChanged) {
14362 // Mark any declarations we need as referenced.
14363 // FIXME: instantiation-specific.
14364 if (OperatorNew)
14365 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorNew);
14366 if (OperatorDelete)
14367 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14368
14369 if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
14370 QualType ElementType
14371 = SemaRef.Context.getBaseElementType(E->getAllocatedType());
14372 if (const RecordType *RecordT = ElementType->getAs<RecordType>()) {
14373 CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl());
14374 if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) {
14376 }
14377 }
14378 }
14379
14380 return E;
14381 }
14382
14383 QualType AllocType = AllocTypeInfo->getType();
14384 if (!ArraySize) {
14385 // If no array size was specified, but the new expression was
14386 // instantiated with an array type (e.g., "new T" where T is
14387 // instantiated with "int[4]"), extract the outer bound from the
14388 // array type as our array size. We do this with constant and
14389 // dependently-sized array types.
14390 const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
14391 if (!ArrayT) {
14392 // Do nothing
14393 } else if (const ConstantArrayType *ConsArrayT
14394 = dyn_cast<ConstantArrayType>(ArrayT)) {
14395 ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
14396 SemaRef.Context.getSizeType(),
14397 /*FIXME:*/ E->getBeginLoc());
14398 AllocType = ConsArrayT->getElementType();
14399 } else if (const DependentSizedArrayType *DepArrayT
14400 = dyn_cast<DependentSizedArrayType>(ArrayT)) {
14401 if (DepArrayT->getSizeExpr()) {
14402 ArraySize = DepArrayT->getSizeExpr();
14403 AllocType = DepArrayT->getElementType();
14404 }
14405 }
14406 }
14407
14408 return getDerived().RebuildCXXNewExpr(
14409 E->getBeginLoc(), E->isGlobalNew(),
14410 /*FIXME:*/ E->getBeginLoc(), PlacementArgs,
14411 /*FIXME:*/ E->getBeginLoc(), E->getTypeIdParens(), AllocType,
14412 AllocTypeInfo, ArraySize, E->getDirectInitRange(), NewInit.get());
14413}
14414
14415template<typename Derived>
14417TreeTransform<Derived>::TransformCXXDeleteExpr(CXXDeleteExpr *E) {
14418 ExprResult Operand = getDerived().TransformExpr(E->getArgument());
14419 if (Operand.isInvalid())
14420 return ExprError();
14421
14422 // Transform the delete operator, if known.
14423 FunctionDecl *OperatorDelete = nullptr;
14424 if (E->getOperatorDelete()) {
14425 OperatorDelete = cast_or_null<FunctionDecl>(
14426 getDerived().TransformDecl(E->getBeginLoc(), E->getOperatorDelete()));
14427 if (!OperatorDelete)
14428 return ExprError();
14429 }
14430
14431 if (!getDerived().AlwaysRebuild() &&
14432 Operand.get() == E->getArgument() &&
14433 OperatorDelete == E->getOperatorDelete()) {
14434 // Mark any declarations we need as referenced.
14435 // FIXME: instantiation-specific.
14436 if (OperatorDelete)
14437 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), OperatorDelete);
14438
14439 if (!E->getArgument()->isTypeDependent()) {
14440 QualType Destroyed = SemaRef.Context.getBaseElementType(
14441 E->getDestroyedType());
14442 if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
14443 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
14445 SemaRef.LookupDestructor(Record));
14446 }
14447 }
14448
14449 return E;
14450 }
14451
14452 return getDerived().RebuildCXXDeleteExpr(
14453 E->getBeginLoc(), E->isGlobalDelete(), E->isArrayForm(), Operand.get());
14454}
14455
14456template<typename Derived>
14458TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
14459 CXXPseudoDestructorExpr *E) {
14460 ExprResult Base = getDerived().TransformExpr(E->getBase());
14461 if (Base.isInvalid())
14462 return ExprError();
14463
14464 ParsedType ObjectTypePtr;
14465 bool MayBePseudoDestructor = false;
14466 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
14467 E->getOperatorLoc(),
14468 E->isArrow()? tok::arrow : tok::period,
14469 ObjectTypePtr,
14470 MayBePseudoDestructor);
14471 if (Base.isInvalid())
14472 return ExprError();
14473
14474 QualType ObjectType = ObjectTypePtr.get();
14475 NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
14476 if (QualifierLoc) {
14477 QualifierLoc
14478 = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
14479 if (!QualifierLoc)
14480 return ExprError();
14481 }
14482 CXXScopeSpec SS;
14483 SS.Adopt(QualifierLoc);
14484
14485 PseudoDestructorTypeStorage Destroyed;
14486 if (E->getDestroyedTypeInfo()) {
14487 TypeSourceInfo *DestroyedTypeInfo
14488 = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
14489 ObjectType, nullptr, SS);
14490 if (!DestroyedTypeInfo)
14491 return ExprError();
14492 Destroyed = DestroyedTypeInfo;
14493 } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
14494 // We aren't likely to be able to resolve the identifier down to a type
14495 // now anyway, so just retain the identifier.
14496 Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
14497 E->getDestroyedTypeLoc());
14498 } else {
14499 // Look for a destructor known with the given name.
14500 ParsedType T = SemaRef.getDestructorName(
14501 *E->getDestroyedTypeIdentifier(), E->getDestroyedTypeLoc(),
14502 /*Scope=*/nullptr, SS, ObjectTypePtr, false);
14503 if (!T)
14504 return ExprError();
14505
14506 Destroyed
14508 E->getDestroyedTypeLoc());
14509 }
14510
14511 TypeSourceInfo *ScopeTypeInfo = nullptr;
14512 if (E->getScopeTypeInfo()) {
14513 CXXScopeSpec EmptySS;
14514 ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
14515 E->getScopeTypeInfo(), ObjectType, nullptr, EmptySS);
14516 if (!ScopeTypeInfo)
14517 return ExprError();
14518 }
14519
14520 return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
14521 E->getOperatorLoc(),
14522 E->isArrow(),
14523 SS,
14524 ScopeTypeInfo,
14525 E->getColonColonLoc(),
14526 E->getTildeLoc(),
14527 Destroyed);
14528}
14529
14530template <typename Derived>
14532 bool RequiresADL,
14533 LookupResult &R) {
14534 // Transform all the decls.
14535 bool AllEmptyPacks = true;
14536 for (auto *OldD : Old->decls()) {
14537 Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
14538 if (!InstD) {
14539 // Silently ignore these if a UsingShadowDecl instantiated to nothing.
14540 // This can happen because of dependent hiding.
14541 if (isa<UsingShadowDecl>(OldD))
14542 continue;
14543 else {
14544 R.clear();
14545 return true;
14546 }
14547 }
14548
14549 // Expand using pack declarations.
14550 NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
14551 ArrayRef<NamedDecl*> Decls = SingleDecl;
14552 if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
14553 Decls = UPD->expansions();
14554
14555 // Expand using declarations.
14556 for (auto *D : Decls) {
14557 if (auto *UD = dyn_cast<UsingDecl>(D)) {
14558 for (auto *SD : UD->shadows())
14559 R.addDecl(SD);
14560 } else {
14561 R.addDecl(D);
14562 }
14563 }
14564
14565 AllEmptyPacks &= Decls.empty();
14566 }
14567
14568 // C++ [temp.res]/8.4.2:
14569 // The program is ill-formed, no diagnostic required, if [...] lookup for
14570 // a name in the template definition found a using-declaration, but the
14571 // lookup in the corresponding scope in the instantiation odoes not find
14572 // any declarations because the using-declaration was a pack expansion and
14573 // the corresponding pack is empty
14574 if (AllEmptyPacks && !RequiresADL) {
14575 getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
14576 << isa<UnresolvedMemberExpr>(Old) << Old->getName();
14577 return true;
14578 }
14579
14580 // Resolve a kind, but don't do any further analysis. If it's
14581 // ambiguous, the callee needs to deal with it.
14582 R.resolveKind();
14583
14584 if (Old->hasTemplateKeyword() && !R.empty()) {
14586 getSema().FilterAcceptableTemplateNames(R,
14587 /*AllowFunctionTemplates=*/true,
14588 /*AllowDependent=*/true);
14589 if (R.empty()) {
14590 // If a 'template' keyword was used, a lookup that finds only non-template
14591 // names is an error.
14592 getSema().Diag(R.getNameLoc(),
14593 diag::err_template_kw_refers_to_non_template)
14595 << Old->hasTemplateKeyword() << Old->getTemplateKeywordLoc();
14596 getSema().Diag(FoundDecl->getLocation(),
14597 diag::note_template_kw_refers_to_non_template)
14598 << R.getLookupName();
14599 return true;
14600 }
14601 }
14602
14603 return false;
14604}
14605
14606template <typename Derived>
14608 UnresolvedLookupExpr *Old) {
14609 return TransformUnresolvedLookupExpr(Old, /*IsAddressOfOperand=*/false);
14610}
14611
14612template <typename Derived>
14615 bool IsAddressOfOperand) {
14616 LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
14618
14619 // Transform the declaration set.
14620 if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
14621 return ExprError();
14622
14623 // Rebuild the nested-name qualifier, if present.
14624 CXXScopeSpec SS;
14625 if (Old->getQualifierLoc()) {
14626 NestedNameSpecifierLoc QualifierLoc
14627 = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
14628 if (!QualifierLoc)
14629 return ExprError();
14630
14631 SS.Adopt(QualifierLoc);
14632 }
14633
14634 if (Old->getNamingClass()) {
14635 CXXRecordDecl *NamingClass
14636 = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
14637 Old->getNameLoc(),
14638 Old->getNamingClass()));
14639 if (!NamingClass) {
14640 R.clear();
14641 return ExprError();
14642 }
14643
14644 R.setNamingClass(NamingClass);
14645 }
14646
14647 // Rebuild the template arguments, if any.
14648 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
14649 TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
14650 if (Old->hasExplicitTemplateArgs() &&
14651 getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
14652 Old->getNumTemplateArgs(),
14653 TransArgs)) {
14654 R.clear();
14655 return ExprError();
14656 }
14657
14658 // An UnresolvedLookupExpr can refer to a class member. This occurs e.g. when
14659 // a non-static data member is named in an unevaluated operand, or when
14660 // a member is named in a dependent class scope function template explicit
14661 // specialization that is neither declared static nor with an explicit object
14662 // parameter.
14663 if (SemaRef.isPotentialImplicitMemberAccess(SS, R, IsAddressOfOperand))
14664 return SemaRef.BuildPossibleImplicitMemberExpr(
14665 SS, TemplateKWLoc, R,
14666 Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr,
14667 /*S=*/nullptr);
14668
14669 // If we have neither explicit template arguments, nor the template keyword,
14670 // it's a normal declaration name or member reference.
14671 if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid())
14672 return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
14673
14674 // If we have template arguments, then rebuild the template-id expression.
14675 return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
14676 Old->requiresADL(), &TransArgs);
14677}
14678
14679template<typename Derived>
14681TreeTransform<Derived>::TransformTypeTraitExpr(TypeTraitExpr *E) {
14682 bool ArgChanged = false;
14684 for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
14685 TypeSourceInfo *From = E->getArg(I);
14686 TypeLoc FromTL = From->getTypeLoc();
14687 if (!FromTL.getAs<PackExpansionTypeLoc>()) {
14688 TypeLocBuilder TLB;
14689 TLB.reserve(FromTL.getFullDataSize());
14690 QualType To = getDerived().TransformType(TLB, FromTL);
14691 if (To.isNull())
14692 return ExprError();
14693
14694 if (To == From->getType())
14695 Args.push_back(From);
14696 else {
14697 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
14698 ArgChanged = true;
14699 }
14700 continue;
14701 }
14702
14703 ArgChanged = true;
14704
14705 // We have a pack expansion. Instantiate it.
14706 PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
14707 TypeLoc PatternTL = ExpansionTL.getPatternLoc();
14709 SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
14710
14711 // Determine whether the set of unexpanded parameter packs can and should
14712 // be expanded.
14713 bool Expand = true;
14714 bool RetainExpansion = false;
14715 std::optional<unsigned> OrigNumExpansions =
14716 ExpansionTL.getTypePtr()->getNumExpansions();
14717 std::optional<unsigned> NumExpansions = OrigNumExpansions;
14718 if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
14719 PatternTL.getSourceRange(),
14720 Unexpanded,
14721 Expand, RetainExpansion,
14722 NumExpansions))
14723 return ExprError();
14724
14725 if (!Expand) {
14726 // The transform has determined that we should perform a simple
14727 // transformation on the pack expansion, producing another pack
14728 // expansion.
14729 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
14730
14731 TypeLocBuilder TLB;
14732 TLB.reserve(From->getTypeLoc().getFullDataSize());
14733
14734 QualType To = getDerived().TransformType(TLB, PatternTL);
14735 if (To.isNull())
14736 return ExprError();
14737
14738 To = getDerived().RebuildPackExpansionType(To,
14739 PatternTL.getSourceRange(),
14740 ExpansionTL.getEllipsisLoc(),
14741 NumExpansions);
14742 if (To.isNull())
14743 return ExprError();
14744
14745 PackExpansionTypeLoc ToExpansionTL
14746 = TLB.push<PackExpansionTypeLoc>(To);
14747 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
14748 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
14749 continue;
14750 }
14751
14752 // Expand the pack expansion by substituting for each argument in the
14753 // pack(s).
14754 for (unsigned I = 0; I != *NumExpansions; ++I) {
14755 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I);
14756 TypeLocBuilder TLB;
14757 TLB.reserve(PatternTL.getFullDataSize());
14758 QualType To = getDerived().TransformType(TLB, PatternTL);
14759 if (To.isNull())
14760 return ExprError();
14761
14762 if (To->containsUnexpandedParameterPack()) {
14763 To = getDerived().RebuildPackExpansionType(To,
14764 PatternTL.getSourceRange(),
14765 ExpansionTL.getEllipsisLoc(),
14766 NumExpansions);
14767 if (To.isNull())
14768 return ExprError();
14769
14770 PackExpansionTypeLoc ToExpansionTL
14771 = TLB.push<PackExpansionTypeLoc>(To);
14772 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
14773 }
14774
14775 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
14776 }
14777
14778 if (!RetainExpansion)
14779 continue;
14780
14781 // If we're supposed to retain a pack expansion, do so by temporarily
14782 // forgetting the partially-substituted parameter pack.
14783 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
14784
14785 TypeLocBuilder TLB;
14786 TLB.reserve(From->getTypeLoc().getFullDataSize());
14787
14788 QualType To = getDerived().TransformType(TLB, PatternTL);
14789 if (To.isNull())
14790 return ExprError();
14791
14792 To = getDerived().RebuildPackExpansionType(To,
14793 PatternTL.getSourceRange(),
14794 ExpansionTL.getEllipsisLoc(),
14795 NumExpansions);
14796 if (To.isNull())
14797 return ExprError();
14798
14799 PackExpansionTypeLoc ToExpansionTL
14800 = TLB.push<PackExpansionTypeLoc>(To);
14801 ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
14802 Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
14803 }
14804
14805 if (!getDerived().AlwaysRebuild() && !ArgChanged)
14806 return E;
14807
14808 return getDerived().RebuildTypeTrait(E->getTrait(), E->getBeginLoc(), Args,
14809 E->getEndLoc());
14810}
14811
14812template<typename Derived>
14814TreeTransform<Derived>::TransformConceptSpecializationExpr(
14815 ConceptSpecializationExpr *E) {
14816 const ASTTemplateArgumentListInfo *Old = E->getTemplateArgsAsWritten();
14817 TemplateArgumentListInfo TransArgs(Old->LAngleLoc, Old->RAngleLoc);
14818 if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
14819 Old->NumTemplateArgs, TransArgs))
14820 return ExprError();
14821
14822 return getDerived().RebuildConceptSpecializationExpr(
14823 E->getNestedNameSpecifierLoc(), E->getTemplateKWLoc(),
14824 E->getConceptNameInfo(), E->getFoundDecl(), E->getNamedConcept(),
14825 &TransArgs);
14826}
14827
14828template<typename Derived>
14830TreeTransform<Derived>::TransformRequiresExpr(RequiresExpr *E) {
14831 SmallVector<ParmVarDecl*, 4> TransParams;
14832 SmallVector<QualType, 4> TransParamTypes;
14833 Sema::ExtParameterInfoBuilder ExtParamInfos;
14834
14835 // C++2a [expr.prim.req]p2
14836 // Expressions appearing within a requirement-body are unevaluated operands.
14837 EnterExpressionEvaluationContext Ctx(
14840
14841 RequiresExprBodyDecl *Body = RequiresExprBodyDecl::Create(
14842 getSema().Context, getSema().CurContext,
14843 E->getBody()->getBeginLoc());
14844
14845 Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
14846
14847 ExprResult TypeParamResult = getDerived().TransformRequiresTypeParams(
14848 E->getRequiresKWLoc(), E->getRBraceLoc(), E, Body,
14849 E->getLocalParameters(), TransParamTypes, TransParams, ExtParamInfos);
14850
14851 for (ParmVarDecl *Param : TransParams)
14852 if (Param)
14853 Param->setDeclContext(Body);
14854
14855 // On failure to transform, TransformRequiresTypeParams returns an expression
14856 // in the event that the transformation of the type params failed in some way.
14857 // It is expected that this will result in a 'not satisfied' Requires clause
14858 // when instantiating.
14859 if (!TypeParamResult.isUnset())
14860 return TypeParamResult;
14861
14863 if (getDerived().TransformRequiresExprRequirements(E->getRequirements(),
14864 TransReqs))
14865 return ExprError();
14866
14867 for (concepts::Requirement *Req : TransReqs) {
14868 if (auto *ER = dyn_cast<concepts::ExprRequirement>(Req)) {
14869 if (ER->getReturnTypeRequirement().isTypeConstraint()) {
14870 ER->getReturnTypeRequirement()
14871 .getTypeConstraintTemplateParameterList()->getParam(0)
14872 ->setDeclContext(Body);
14873 }
14874 }
14875 }
14876
14877 return getDerived().RebuildRequiresExpr(
14878 E->getRequiresKWLoc(), Body, E->getLParenLoc(), TransParams,
14879 E->getRParenLoc(), TransReqs, E->getRBraceLoc());
14880}
14881
14882template<typename Derived>
14886 for (concepts::Requirement *Req : Reqs) {
14887 concepts::Requirement *TransReq = nullptr;
14888 if (auto *TypeReq = dyn_cast<concepts::TypeRequirement>(Req))
14889 TransReq = getDerived().TransformTypeRequirement(TypeReq);
14890 else if (auto *ExprReq = dyn_cast<concepts::ExprRequirement>(Req))
14891 TransReq = getDerived().TransformExprRequirement(ExprReq);
14892 else
14893 TransReq = getDerived().TransformNestedRequirement(
14894 cast<concepts::NestedRequirement>(Req));
14895 if (!TransReq)
14896 return true;
14897 Transformed.push_back(TransReq);
14898 }
14899 return false;
14900}
14901
14902template<typename Derived>
14906 if (Req->isSubstitutionFailure()) {
14907 if (getDerived().AlwaysRebuild())
14908 return getDerived().RebuildTypeRequirement(
14910 return Req;
14911 }
14912 TypeSourceInfo *TransType = getDerived().TransformType(Req->getType());
14913 if (!TransType)
14914 return nullptr;
14915 return getDerived().RebuildTypeRequirement(TransType);
14916}
14917
14918template<typename Derived>
14921 llvm::PointerUnion<Expr *, concepts::Requirement::SubstitutionDiagnostic *> TransExpr;
14922 if (Req->isExprSubstitutionFailure())
14923 TransExpr = Req->getExprSubstitutionDiagnostic();
14924 else {
14925 ExprResult TransExprRes = getDerived().TransformExpr(Req->getExpr());
14926 if (TransExprRes.isUsable() && TransExprRes.get()->hasPlaceholderType())
14927 TransExprRes = SemaRef.CheckPlaceholderExpr(TransExprRes.get());
14928 if (TransExprRes.isInvalid())
14929 return nullptr;
14930 TransExpr = TransExprRes.get();
14931 }
14932
14933 std::optional<concepts::ExprRequirement::ReturnTypeRequirement> TransRetReq;
14934 const auto &RetReq = Req->getReturnTypeRequirement();
14935 if (RetReq.isEmpty())
14936 TransRetReq.emplace();
14937 else if (RetReq.isSubstitutionFailure())
14938 TransRetReq.emplace(RetReq.getSubstitutionDiagnostic());
14939 else if (RetReq.isTypeConstraint()) {
14940 TemplateParameterList *OrigTPL =
14941 RetReq.getTypeConstraintTemplateParameterList();
14943 getDerived().TransformTemplateParameterList(OrigTPL);
14944 if (!TPL)
14945 return nullptr;
14946 TransRetReq.emplace(TPL);
14947 }
14948 assert(TransRetReq && "All code paths leading here must set TransRetReq");
14949 if (Expr *E = dyn_cast<Expr *>(TransExpr))
14950 return getDerived().RebuildExprRequirement(E, Req->isSimple(),
14951 Req->getNoexceptLoc(),
14952 std::move(*TransRetReq));
14953 return getDerived().RebuildExprRequirement(
14954 cast<concepts::Requirement::SubstitutionDiagnostic *>(TransExpr),
14955 Req->isSimple(), Req->getNoexceptLoc(), std::move(*TransRetReq));
14956}
14957
14958template<typename Derived>
14962 if (Req->hasInvalidConstraint()) {
14963 if (getDerived().AlwaysRebuild())
14964 return getDerived().RebuildNestedRequirement(
14966 return Req;
14967 }
14968 ExprResult TransConstraint =
14969 getDerived().TransformExpr(Req->getConstraintExpr());
14970 if (TransConstraint.isInvalid())
14971 return nullptr;
14972 return getDerived().RebuildNestedRequirement(TransConstraint.get());
14973}
14974
14975template<typename Derived>
14978 TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
14979 if (!T)
14980 return ExprError();
14981
14982 if (!getDerived().AlwaysRebuild() &&
14983 T == E->getQueriedTypeSourceInfo())
14984 return E;
14985
14986 ExprResult SubExpr;
14987 {
14990 SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
14991 if (SubExpr.isInvalid())
14992 return ExprError();
14993 }
14994
14995 return getDerived().RebuildArrayTypeTrait(E->getTrait(), E->getBeginLoc(), T,
14996 SubExpr.get(), E->getEndLoc());
14997}
14998
14999template<typename Derived>
15001TreeTransform<Derived>::TransformExpressionTraitExpr(ExpressionTraitExpr *E) {
15002 ExprResult SubExpr;
15003 {
15004 EnterExpressionEvaluationContext Unevaluated(
15006 SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
15007 if (SubExpr.isInvalid())
15008 return ExprError();
15009
15010 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
15011 return E;
15012 }
15013
15014 return getDerived().RebuildExpressionTrait(E->getTrait(), E->getBeginLoc(),
15015 SubExpr.get(), E->getEndLoc());
15016}
15017
15018template <typename Derived>
15020 ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
15021 TypeSourceInfo **RecoveryTSI) {
15022 ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
15023 DRE, AddrTaken, RecoveryTSI);
15024
15025 // Propagate both errors and recovered types, which return ExprEmpty.
15026 if (!NewDRE.isUsable())
15027 return NewDRE;
15028
15029 // We got an expr, wrap it up in parens.
15030 if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
15031 return PE;
15032 return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
15033 PE->getRParen());
15034}
15035
15036template <typename Derived>
15039 return TransformDependentScopeDeclRefExpr(E, /*IsAddressOfOperand=*/false,
15040 nullptr);
15041}
15042
15043template <typename Derived>
15045 DependentScopeDeclRefExpr *E, bool IsAddressOfOperand,
15046 TypeSourceInfo **RecoveryTSI) {
15047 assert(E->getQualifierLoc());
15048 NestedNameSpecifierLoc QualifierLoc =
15049 getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
15050 if (!QualifierLoc)
15051 return ExprError();
15052 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15053
15054 // TODO: If this is a conversion-function-id, verify that the
15055 // destination type name (if present) resolves the same way after
15056 // instantiation as it did in the local scope.
15057
15058 DeclarationNameInfo NameInfo =
15059 getDerived().TransformDeclarationNameInfo(E->getNameInfo());
15060 if (!NameInfo.getName())
15061 return ExprError();
15062
15063 if (!E->hasExplicitTemplateArgs()) {
15064 if (!getDerived().AlwaysRebuild() && QualifierLoc == E->getQualifierLoc() &&
15065 // Note: it is sufficient to compare the Name component of NameInfo:
15066 // if name has not changed, DNLoc has not changed either.
15067 NameInfo.getName() == E->getDeclName())
15068 return E;
15069
15070 return getDerived().RebuildDependentScopeDeclRefExpr(
15071 QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
15072 IsAddressOfOperand, RecoveryTSI);
15073 }
15074
15075 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15076 if (getDerived().TransformTemplateArguments(
15077 E->getTemplateArgs(), E->getNumTemplateArgs(), TransArgs))
15078 return ExprError();
15079
15080 return getDerived().RebuildDependentScopeDeclRefExpr(
15081 QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
15082 RecoveryTSI);
15083}
15084
15085template<typename Derived>
15087TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
15088 // CXXConstructExprs other than for list-initialization and
15089 // CXXTemporaryObjectExpr are always implicit, so when we have
15090 // a 1-argument construction we just transform that argument.
15091 if (getDerived().AllowSkippingCXXConstructExpr() &&
15092 ((E->getNumArgs() == 1 ||
15093 (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
15094 (!getDerived().DropCallArgument(E->getArg(0))) &&
15095 !E->isListInitialization()))
15096 return getDerived().TransformInitializer(E->getArg(0),
15097 /*DirectInit*/ false);
15098
15099 TemporaryBase Rebase(*this, /*FIXME*/ E->getBeginLoc(), DeclarationName());
15100
15101 QualType T = getDerived().TransformType(E->getType());
15102 if (T.isNull())
15103 return ExprError();
15104
15105 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15106 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15107 if (!Constructor)
15108 return ExprError();
15109
15110 bool ArgumentChanged = false;
15112 {
15113 EnterExpressionEvaluationContext Context(
15115 E->isListInitialization());
15116 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15117 &ArgumentChanged))
15118 return ExprError();
15119 }
15120
15121 if (!getDerived().AlwaysRebuild() &&
15122 T == E->getType() &&
15123 Constructor == E->getConstructor() &&
15124 !ArgumentChanged) {
15125 // Mark the constructor as referenced.
15126 // FIXME: Instantiation-specific
15127 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15128 return E;
15129 }
15130
15131 return getDerived().RebuildCXXConstructExpr(
15132 T, /*FIXME:*/ E->getBeginLoc(), Constructor, E->isElidable(), Args,
15133 E->hadMultipleCandidates(), E->isListInitialization(),
15134 E->isStdInitListInitialization(), E->requiresZeroInitialization(),
15135 E->getConstructionKind(), E->getParenOrBraceRange());
15136}
15137
15138template<typename Derived>
15139ExprResult TreeTransform<Derived>::TransformCXXInheritedCtorInitExpr(
15140 CXXInheritedCtorInitExpr *E) {
15141 QualType T = getDerived().TransformType(E->getType());
15142 if (T.isNull())
15143 return ExprError();
15144
15145 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15146 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15147 if (!Constructor)
15148 return ExprError();
15149
15150 if (!getDerived().AlwaysRebuild() &&
15151 T == E->getType() &&
15152 Constructor == E->getConstructor()) {
15153 // Mark the constructor as referenced.
15154 // FIXME: Instantiation-specific
15155 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15156 return E;
15157 }
15158
15159 return getDerived().RebuildCXXInheritedCtorInitExpr(
15160 T, E->getLocation(), Constructor,
15161 E->constructsVBase(), E->inheritedFromVBase());
15162}
15163
15164/// Transform a C++ temporary-binding expression.
15165///
15166/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
15167/// transform the subexpression and return that.
15168template<typename Derived>
15170TreeTransform<Derived>::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
15171 if (auto *Dtor = E->getTemporary()->getDestructor())
15173 const_cast<CXXDestructorDecl *>(Dtor));
15174 return getDerived().TransformExpr(E->getSubExpr());
15175}
15176
15177/// Transform a C++ expression that contains cleanups that should
15178/// be run after the expression is evaluated.
15179///
15180/// Since ExprWithCleanups nodes are implicitly generated, we
15181/// just transform the subexpression and return that.
15182template<typename Derived>
15184TreeTransform<Derived>::TransformExprWithCleanups(ExprWithCleanups *E) {
15185 return getDerived().TransformExpr(E->getSubExpr());
15186}
15187
15188template<typename Derived>
15190TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
15191 CXXTemporaryObjectExpr *E) {
15192 TypeSourceInfo *T =
15193 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15194 if (!T)
15195 return ExprError();
15196
15197 CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
15198 getDerived().TransformDecl(E->getBeginLoc(), E->getConstructor()));
15199 if (!Constructor)
15200 return ExprError();
15201
15202 bool ArgumentChanged = false;
15204 Args.reserve(E->getNumArgs());
15205 {
15206 EnterExpressionEvaluationContext Context(
15208 E->isListInitialization());
15209 if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
15210 &ArgumentChanged))
15211 return ExprError();
15212
15213 if (E->isListInitialization() && !E->isStdInitListInitialization()) {
15214 ExprResult Res = RebuildInitList(E->getBeginLoc(), Args, E->getEndLoc());
15215 if (Res.isInvalid())
15216 return ExprError();
15217 Args = {Res.get()};
15218 }
15219 }
15220
15221 if (!getDerived().AlwaysRebuild() &&
15222 T == E->getTypeSourceInfo() &&
15223 Constructor == E->getConstructor() &&
15224 !ArgumentChanged) {
15225 // FIXME: Instantiation-specific
15226 SemaRef.MarkFunctionReferenced(E->getBeginLoc(), Constructor);
15227 return SemaRef.MaybeBindToTemporary(E);
15228 }
15229
15230 SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
15231 return getDerived().RebuildCXXTemporaryObjectExpr(
15232 T, LParenLoc, Args, E->getEndLoc(), E->isListInitialization());
15233}
15234
15235template<typename Derived>
15237TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
15238 // Transform any init-capture expressions before entering the scope of the
15239 // lambda body, because they are not semantically within that scope.
15240 typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
15241 struct TransformedInitCapture {
15242 // The location of the ... if the result is retaining a pack expansion.
15243 SourceLocation EllipsisLoc;
15244 // Zero or more expansions of the init-capture.
15246 };
15248 InitCaptures.resize(E->explicit_capture_end() - E->explicit_capture_begin());
15249 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15250 CEnd = E->capture_end();
15251 C != CEnd; ++C) {
15252 if (!E->isInitCapture(C))
15253 continue;
15254
15255 TransformedInitCapture &Result = InitCaptures[C - E->capture_begin()];
15256 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15257
15258 auto SubstInitCapture = [&](SourceLocation EllipsisLoc,
15259 std::optional<unsigned> NumExpansions) {
15260 ExprResult NewExprInitResult = getDerived().TransformInitializer(
15261 OldVD->getInit(), OldVD->getInitStyle() == VarDecl::CallInit);
15262
15263 if (NewExprInitResult.isInvalid()) {
15264 Result.Expansions.push_back(InitCaptureInfoTy(ExprError(), QualType()));
15265 return;
15266 }
15267 Expr *NewExprInit = NewExprInitResult.get();
15268
15269 QualType NewInitCaptureType =
15270 getSema().buildLambdaInitCaptureInitialization(
15271 C->getLocation(), C->getCaptureKind() == LCK_ByRef,
15272 EllipsisLoc, NumExpansions, OldVD->getIdentifier(),
15273 cast<VarDecl>(C->getCapturedVar())->getInitStyle() !=
15275 NewExprInit);
15276 Result.Expansions.push_back(
15277 InitCaptureInfoTy(NewExprInit, NewInitCaptureType));
15278 };
15279
15280 // If this is an init-capture pack, consider expanding the pack now.
15281 if (OldVD->isParameterPack()) {
15282 PackExpansionTypeLoc ExpansionTL = OldVD->getTypeSourceInfo()
15283 ->getTypeLoc()
15284 .castAs<PackExpansionTypeLoc>();
15286 SemaRef.collectUnexpandedParameterPacks(OldVD->getInit(), Unexpanded);
15287
15288 // Determine whether the set of unexpanded parameter packs can and should
15289 // be expanded.
15290 bool Expand = true;
15291 bool RetainExpansion = false;
15292 std::optional<unsigned> OrigNumExpansions =
15293 ExpansionTL.getTypePtr()->getNumExpansions();
15294 std::optional<unsigned> NumExpansions = OrigNumExpansions;
15295 if (getDerived().TryExpandParameterPacks(
15296 ExpansionTL.getEllipsisLoc(),
15297 OldVD->getInit()->getSourceRange(), Unexpanded, Expand,
15298 RetainExpansion, NumExpansions))
15299 return ExprError();
15300 assert(!RetainExpansion && "Should not need to retain expansion after a "
15301 "capture since it cannot be extended");
15302 if (Expand) {
15303 for (unsigned I = 0; I != *NumExpansions; ++I) {
15304 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
15305 SubstInitCapture(SourceLocation(), std::nullopt);
15306 }
15307 } else {
15308 SubstInitCapture(ExpansionTL.getEllipsisLoc(), NumExpansions);
15309 Result.EllipsisLoc = ExpansionTL.getEllipsisLoc();
15310 }
15311 } else {
15312 SubstInitCapture(SourceLocation(), std::nullopt);
15313 }
15314 }
15315
15316 LambdaScopeInfo *LSI = getSema().PushLambdaScope();
15317 Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
15318
15319 // Create the local class that will describe the lambda.
15320
15321 // FIXME: DependencyKind below is wrong when substituting inside a templated
15322 // context that isn't a DeclContext (such as a variable template), or when
15323 // substituting an unevaluated lambda inside of a function's parameter's type
15324 // - as parameter types are not instantiated from within a function's DC. We
15325 // use evaluation contexts to distinguish the function parameter case.
15328 DeclContext *DC = getSema().CurContext;
15329 // A RequiresExprBodyDecl is not interesting for dependencies.
15330 // For the following case,
15331 //
15332 // template <typename>
15333 // concept C = requires { [] {}; };
15334 //
15335 // template <class F>
15336 // struct Widget;
15337 //
15338 // template <C F>
15339 // struct Widget<F> {};
15340 //
15341 // While we are substituting Widget<F>, the parent of DC would be
15342 // the template specialization itself. Thus, the lambda expression
15343 // will be deemed as dependent even if there are no dependent template
15344 // arguments.
15345 // (A ClassTemplateSpecializationDecl is always a dependent context.)
15346 while (DC->isRequiresExprBody())
15347 DC = DC->getParent();
15348 if ((getSema().isUnevaluatedContext() ||
15349 getSema().isConstantEvaluatedContext()) &&
15350 (DC->isFileContext() || !DC->getParent()->isDependentContext()))
15351 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
15352
15353 CXXRecordDecl *OldClass = E->getLambdaClass();
15354 CXXRecordDecl *Class = getSema().createLambdaClosureType(
15355 E->getIntroducerRange(), /*Info=*/nullptr, DependencyKind,
15356 E->getCaptureDefault());
15357 getDerived().transformedLocalDecl(OldClass, {Class});
15358
15359 CXXMethodDecl *NewCallOperator =
15360 getSema().CreateLambdaCallOperator(E->getIntroducerRange(), Class);
15361
15362 // Enter the scope of the lambda.
15363 getSema().buildLambdaScope(LSI, NewCallOperator, E->getIntroducerRange(),
15364 E->getCaptureDefault(), E->getCaptureDefaultLoc(),
15365 E->hasExplicitParameters(), E->isMutable());
15366
15367 // Introduce the context of the call operator.
15368 Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
15369 /*NewThisContext*/false);
15370
15371 bool Invalid = false;
15372
15373 // Transform captures.
15374 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15375 CEnd = E->capture_end();
15376 C != CEnd; ++C) {
15377 // When we hit the first implicit capture, tell Sema that we've finished
15378 // the list of explicit captures.
15379 if (C->isImplicit())
15380 break;
15381
15382 // Capturing 'this' is trivial.
15383 if (C->capturesThis()) {
15384 // If this is a lambda that is part of a default member initialiser
15385 // and which we're instantiating outside the class that 'this' is
15386 // supposed to refer to, adjust the type of 'this' accordingly.
15387 //
15388 // Otherwise, leave the type of 'this' as-is.
15389 Sema::CXXThisScopeRAII ThisScope(
15390 getSema(),
15391 dyn_cast_if_present<CXXRecordDecl>(
15392 getSema().getFunctionLevelDeclContext()),
15393 Qualifiers());
15394 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15395 /*BuildAndDiagnose*/ true, nullptr,
15396 C->getCaptureKind() == LCK_StarThis);
15397 continue;
15398 }
15399 // Captured expression will be recaptured during captured variables
15400 // rebuilding.
15401 if (C->capturesVLAType())
15402 continue;
15403
15404 // Rebuild init-captures, including the implied field declaration.
15405 if (E->isInitCapture(C)) {
15406 TransformedInitCapture &NewC = InitCaptures[C - E->capture_begin()];
15407
15408 auto *OldVD = cast<VarDecl>(C->getCapturedVar());
15410
15411 for (InitCaptureInfoTy &Info : NewC.Expansions) {
15412 ExprResult Init = Info.first;
15413 QualType InitQualType = Info.second;
15414 if (Init.isInvalid() || InitQualType.isNull()) {
15415 Invalid = true;
15416 break;
15417 }
15418 VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
15419 OldVD->getLocation(), InitQualType, NewC.EllipsisLoc,
15420 OldVD->getIdentifier(), OldVD->getInitStyle(), Init.get(),
15421 getSema().CurContext);
15422 if (!NewVD) {
15423 Invalid = true;
15424 break;
15425 }
15426 NewVDs.push_back(NewVD);
15427 getSema().addInitCapture(LSI, NewVD, C->getCaptureKind() == LCK_ByRef);
15428 // Cases we want to tackle:
15429 // ([C(Pack)] {}, ...)
15430 // But rule out cases e.g.
15431 // [...C = Pack()] {}
15432 if (NewC.EllipsisLoc.isInvalid())
15433 LSI->ContainsUnexpandedParameterPack |=
15434 Init.get()->containsUnexpandedParameterPack();
15435 }
15436
15437 if (Invalid)
15438 break;
15439
15440 getDerived().transformedLocalDecl(OldVD, NewVDs);
15441 continue;
15442 }
15443
15444 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15445
15446 // Determine the capture kind for Sema.
15448 = C->isImplicit()? Sema::TryCapture_Implicit
15449 : C->getCaptureKind() == LCK_ByCopy
15452 SourceLocation EllipsisLoc;
15453 if (C->isPackExpansion()) {
15454 UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
15455 bool ShouldExpand = false;
15456 bool RetainExpansion = false;
15457 std::optional<unsigned> NumExpansions;
15458 if (getDerived().TryExpandParameterPacks(C->getEllipsisLoc(),
15459 C->getLocation(),
15460 Unexpanded,
15461 ShouldExpand, RetainExpansion,
15462 NumExpansions)) {
15463 Invalid = true;
15464 continue;
15465 }
15466
15467 if (ShouldExpand) {
15468 // The transform has determined that we should perform an expansion;
15469 // transform and capture each of the arguments.
15470 // expansion of the pattern. Do so.
15471 auto *Pack = cast<ValueDecl>(C->getCapturedVar());
15472 for (unsigned I = 0; I != *NumExpansions; ++I) {
15473 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
15474 ValueDecl *CapturedVar = cast_if_present<ValueDecl>(
15475 getDerived().TransformDecl(C->getLocation(), Pack));
15476 if (!CapturedVar) {
15477 Invalid = true;
15478 continue;
15479 }
15480
15481 // Capture the transformed variable.
15482 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
15483 }
15484
15485 // FIXME: Retain a pack expansion if RetainExpansion is true.
15486
15487 continue;
15488 }
15489
15490 EllipsisLoc = C->getEllipsisLoc();
15491 }
15492
15493 // Transform the captured variable.
15494 auto *CapturedVar = cast_or_null<ValueDecl>(
15495 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15496 if (!CapturedVar || CapturedVar->isInvalidDecl()) {
15497 Invalid = true;
15498 continue;
15499 }
15500
15501 // This is not an init-capture; however it contains an unexpanded pack e.g.
15502 // ([Pack] {}(), ...)
15503 if (auto *VD = dyn_cast<VarDecl>(CapturedVar); VD && !C->isPackExpansion())
15504 LSI->ContainsUnexpandedParameterPack |= VD->isParameterPack();
15505
15506 // Capture the transformed variable.
15507 getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
15508 EllipsisLoc);
15509 }
15510 getSema().finishLambdaExplicitCaptures(LSI);
15511
15512 // Transform the template parameters, and add them to the current
15513 // instantiation scope. The null case is handled correctly.
15514 auto TPL = getDerived().TransformTemplateParameterList(
15515 E->getTemplateParameterList());
15516 LSI->GLTemplateParameterList = TPL;
15517 if (TPL) {
15518 getSema().AddTemplateParametersToLambdaCallOperator(NewCallOperator, Class,
15519 TPL);
15520 LSI->ContainsUnexpandedParameterPack |=
15521 TPL->containsUnexpandedParameterPack();
15522 }
15523
15524 TypeLocBuilder NewCallOpTLBuilder;
15525 TypeLoc OldCallOpTypeLoc =
15526 E->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
15527 QualType NewCallOpType =
15528 getDerived().TransformType(NewCallOpTLBuilder, OldCallOpTypeLoc);
15529 if (NewCallOpType.isNull())
15530 return ExprError();
15531 LSI->ContainsUnexpandedParameterPack |=
15532 NewCallOpType->containsUnexpandedParameterPack();
15533 TypeSourceInfo *NewCallOpTSI =
15534 NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context, NewCallOpType);
15535
15536 // The type may be an AttributedType or some other kind of sugar;
15537 // get the actual underlying FunctionProtoType.
15538 auto FPTL = NewCallOpTSI->getTypeLoc().getAsAdjusted<FunctionProtoTypeLoc>();
15539 assert(FPTL && "Not a FunctionProtoType?");
15540
15541 getSema().CompleteLambdaCallOperator(
15542 NewCallOperator, E->getCallOperator()->getLocation(),
15543 E->getCallOperator()->getInnerLocStart(),
15544 E->getCallOperator()->getTrailingRequiresClause(), NewCallOpTSI,
15545 E->getCallOperator()->getConstexprKind(),
15546 E->getCallOperator()->getStorageClass(), FPTL.getParams(),
15547 E->hasExplicitResultType());
15548
15549 getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
15550 getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
15551
15552 {
15553 // Number the lambda for linkage purposes if necessary.
15554 Sema::ContextRAII ManglingContext(getSema(), Class->getDeclContext());
15555
15556 std::optional<CXXRecordDecl::LambdaNumbering> Numbering;
15557 if (getDerived().ReplacingOriginal()) {
15558 Numbering = OldClass->getLambdaNumbering();
15559 }
15560
15561 getSema().handleLambdaNumbering(Class, NewCallOperator, Numbering);
15562 }
15563
15564 // FIXME: Sema's lambda-building mechanism expects us to push an expression
15565 // evaluation context even if we're not transforming the function body.
15566 getSema().PushExpressionEvaluationContext(
15567 E->getCallOperator()->isConsteval() ?
15570 getSema().currentEvaluationContext().InImmediateEscalatingFunctionContext =
15571 getSema().getLangOpts().CPlusPlus20 &&
15572 E->getCallOperator()->isImmediateEscalating();
15573
15574 Sema::CodeSynthesisContext C;
15576 C.PointOfInstantiation = E->getBody()->getBeginLoc();
15577 getSema().pushCodeSynthesisContext(C);
15578
15579 // Instantiate the body of the lambda expression.
15580 StmtResult Body =
15581 Invalid ? StmtError() : getDerived().TransformLambdaBody(E, E->getBody());
15582
15583 getSema().popCodeSynthesisContext();
15584
15585 // ActOnLambda* will pop the function scope for us.
15586 FuncScopeCleanup.disable();
15587
15588 if (Body.isInvalid()) {
15589 SavedContext.pop();
15590 getSema().ActOnLambdaError(E->getBeginLoc(), /*CurScope=*/nullptr,
15591 /*IsInstantiation=*/true);
15592 return ExprError();
15593 }
15594
15595 // Copy the LSI before ActOnFinishFunctionBody removes it.
15596 // FIXME: This is dumb. Store the lambda information somewhere that outlives
15597 // the call operator.
15598 auto LSICopy = *LSI;
15599 getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
15600 /*IsInstantiation*/ true);
15601 SavedContext.pop();
15602
15603 // Recompute the dependency of the lambda so that we can defer the lambda call
15604 // construction until after we have all the necessary template arguments. For
15605 // example, given
15606 //
15607 // template <class> struct S {
15608 // template <class U>
15609 // using Type = decltype([](U){}(42.0));
15610 // };
15611 // void foo() {
15612 // using T = S<int>::Type<float>;
15613 // ^~~~~~
15614 // }
15615 //
15616 // We would end up here from instantiating S<int> when ensuring its
15617 // completeness. That would transform the lambda call expression regardless of
15618 // the absence of the corresponding argument for U.
15619 //
15620 // Going ahead with unsubstituted type U makes things worse: we would soon
15621 // compare the argument type (which is float) against the parameter U
15622 // somewhere in Sema::BuildCallExpr. Then we would quickly run into a bogus
15623 // error suggesting unmatched types 'U' and 'float'!
15624 //
15625 // That said, everything will be fine if we defer that semantic checking.
15626 // Fortunately, we have such a mechanism that bypasses it if the CallExpr is
15627 // dependent. Since the CallExpr's dependency boils down to the lambda's
15628 // dependency in this case, we can harness that by recomputing the dependency
15629 // from the instantiation arguments.
15630 //
15631 // FIXME: Creating the type of a lambda requires us to have a dependency
15632 // value, which happens before its substitution. We update its dependency
15633 // *after* the substitution in case we can't decide the dependency
15634 // so early, e.g. because we want to see if any of the *substituted*
15635 // parameters are dependent.
15636 DependencyKind = getDerived().ComputeLambdaDependency(&LSICopy);
15637 Class->setLambdaDependencyKind(DependencyKind);
15638 // Clean up the type cache created previously. Then, we re-create a type for
15639 // such Decl with the new DependencyKind.
15640 Class->setTypeForDecl(nullptr);
15641 getSema().Context.getTypeDeclType(Class);
15642
15643 return getDerived().RebuildLambdaExpr(E->getBeginLoc(),
15644 Body.get()->getEndLoc(), &LSICopy);
15645}
15646
15647template<typename Derived>
15650 return TransformStmt(S);
15651}
15652
15653template<typename Derived>
15656 // Transform captures.
15657 for (LambdaExpr::capture_iterator C = E->capture_begin(),
15658 CEnd = E->capture_end();
15659 C != CEnd; ++C) {
15660 // When we hit the first implicit capture, tell Sema that we've finished
15661 // the list of explicit captures.
15662 if (!C->isImplicit())
15663 continue;
15664
15665 // Capturing 'this' is trivial.
15666 if (C->capturesThis()) {
15667 getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
15668 /*BuildAndDiagnose*/ true, nullptr,
15669 C->getCaptureKind() == LCK_StarThis);
15670 continue;
15671 }
15672 // Captured expression will be recaptured during captured variables
15673 // rebuilding.
15674 if (C->capturesVLAType())
15675 continue;
15676
15677 assert(C->capturesVariable() && "unexpected kind of lambda capture");
15678 assert(!E->isInitCapture(C) && "implicit init-capture?");
15679
15680 // Transform the captured variable.
15681 VarDecl *CapturedVar = cast_or_null<VarDecl>(
15682 getDerived().TransformDecl(C->getLocation(), C->getCapturedVar()));
15683 if (!CapturedVar || CapturedVar->isInvalidDecl())
15684 return StmtError();
15685
15686 // Capture the transformed variable.
15687 getSema().tryCaptureVariable(CapturedVar, C->getLocation());
15688 }
15689
15690 return S;
15691}
15692
15693template<typename Derived>
15697 TypeSourceInfo *T =
15698 getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
15699 if (!T)
15700 return ExprError();
15701
15702 bool ArgumentChanged = false;
15704 Args.reserve(E->getNumArgs());
15705 {
15708 E->isListInitialization());
15709 if (getDerived().TransformExprs(E->arg_begin(), E->getNumArgs(), true, Args,
15710 &ArgumentChanged))
15711 return ExprError();
15712 }
15713
15714 if (!getDerived().AlwaysRebuild() &&
15715 T == E->getTypeSourceInfo() &&
15716 !ArgumentChanged)
15717 return E;
15718
15719 // FIXME: we're faking the locations of the commas
15720 return getDerived().RebuildCXXUnresolvedConstructExpr(
15721 T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
15722}
15723
15724template<typename Derived>
15726TreeTransform<Derived>::TransformCXXDependentScopeMemberExpr(
15727 CXXDependentScopeMemberExpr *E) {
15728 // Transform the base of the expression.
15729 ExprResult Base((Expr*) nullptr);
15730 Expr *OldBase;
15731 QualType BaseType;
15732 QualType ObjectType;
15733 if (!E->isImplicitAccess()) {
15734 OldBase = E->getBase();
15735 Base = getDerived().TransformExpr(OldBase);
15736 if (Base.isInvalid())
15737 return ExprError();
15738
15739 // Start the member reference and compute the object's type.
15740 ParsedType ObjectTy;
15741 bool MayBePseudoDestructor = false;
15742 Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
15743 E->getOperatorLoc(),
15744 E->isArrow()? tok::arrow : tok::period,
15745 ObjectTy,
15746 MayBePseudoDestructor);
15747 if (Base.isInvalid())
15748 return ExprError();
15749
15750 ObjectType = ObjectTy.get();
15751 BaseType = ((Expr*) Base.get())->getType();
15752 } else {
15753 OldBase = nullptr;
15754 BaseType = getDerived().TransformType(E->getBaseType());
15755 ObjectType = BaseType->castAs<PointerType>()->getPointeeType();
15756 }
15757
15758 // Transform the first part of the nested-name-specifier that qualifies
15759 // the member name.
15760 NamedDecl *FirstQualifierInScope
15761 = getDerived().TransformFirstQualifierInScope(
15762 E->getFirstQualifierFoundInScope(),
15763 E->getQualifierLoc().getBeginLoc());
15764
15765 NestedNameSpecifierLoc QualifierLoc;
15766 if (E->getQualifier()) {
15767 QualifierLoc
15768 = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
15769 ObjectType,
15770 FirstQualifierInScope);
15771 if (!QualifierLoc)
15772 return ExprError();
15773 }
15774
15775 SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
15776
15777 // TODO: If this is a conversion-function-id, verify that the
15778 // destination type name (if present) resolves the same way after
15779 // instantiation as it did in the local scope.
15780
15781 DeclarationNameInfo NameInfo
15782 = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
15783 if (!NameInfo.getName())
15784 return ExprError();
15785
15786 if (!E->hasExplicitTemplateArgs()) {
15787 // This is a reference to a member without an explicitly-specified
15788 // template argument list. Optimize for this common case.
15789 if (!getDerived().AlwaysRebuild() &&
15790 Base.get() == OldBase &&
15791 BaseType == E->getBaseType() &&
15792 QualifierLoc == E->getQualifierLoc() &&
15793 NameInfo.getName() == E->getMember() &&
15794 FirstQualifierInScope == E->getFirstQualifierFoundInScope())
15795 return E;
15796
15797 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
15798 BaseType,
15799 E->isArrow(),
15800 E->getOperatorLoc(),
15801 QualifierLoc,
15802 TemplateKWLoc,
15803 FirstQualifierInScope,
15804 NameInfo,
15805 /*TemplateArgs*/nullptr);
15806 }
15807
15808 TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
15809 if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
15810 E->getNumTemplateArgs(),
15811 TransArgs))
15812 return ExprError();
15813
15814 return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
15815 BaseType,
15816 E->isArrow(),
15817 E->getOperatorLoc(),
15818 QualifierLoc,
15819 TemplateKWLoc,
15820 FirstQualifierInScope,
15821 NameInfo,
15822 &TransArgs);
15823}
15824
15825template <typename Derived>
15826ExprResult TreeTransform<Derived>::TransformUnresolvedMemberExpr(
15827 UnresolvedMemberExpr *Old) {
15828 // Transform the base of the expression.
15829 ExprResult Base((Expr *)nullptr);
15830 QualType BaseType;
15831 if (!Old->isImplicitAccess()) {
15832 Base = getDerived().TransformExpr(Old->getBase());
15833 if (Base.isInvalid())
15834 return ExprError();
15835 Base =
15836 getSema().PerformMemberExprBaseConversion(Base.get(), Old->isArrow());
15837 if (Base.isInvalid())
15838 return ExprError();
15839 BaseType = Base.get()->getType();
15840 } else {
15841 BaseType = getDerived().TransformType(Old->getBaseType());
15842 }
15843
15844 NestedNameSpecifierLoc QualifierLoc;
15845 if (Old->getQualifierLoc()) {
15846 QualifierLoc =
15847 getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
15848 if (!QualifierLoc)
15849 return ExprError();
15850 }
15851
15852 SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
15853
15854 LookupResult R(SemaRef, Old->getMemberNameInfo(), Sema::LookupOrdinaryName);
15855
15856 // Transform the declaration set.
15857 if (TransformOverloadExprDecls(Old, /*RequiresADL*/ false, R))
15858 return ExprError();
15859
15860 // Determine the naming class.
15861 if (Old->getNamingClass()) {
15862 CXXRecordDecl *NamingClass = cast_or_null<CXXRecordDecl>(
15863 getDerived().TransformDecl(Old->getMemberLoc(), Old->getNamingClass()));
15864 if (!NamingClass)
15865 return ExprError();
15866
15867 R.setNamingClass(NamingClass);
15868 }
15869
15870 TemplateArgumentListInfo TransArgs;
15871 if (Old->hasExplicitTemplateArgs()) {
15872 TransArgs.setLAngleLoc(Old->getLAngleLoc());
15873 TransArgs.setRAngleLoc(Old->getRAngleLoc());
15874 if (getDerived().TransformTemplateArguments(
15875 Old->getTemplateArgs(), Old->getNumTemplateArgs(), TransArgs))
15876 return ExprError();
15877 }
15878
15879 // FIXME: to do this check properly, we will need to preserve the
15880 // first-qualifier-in-scope here, just in case we had a dependent
15881 // base (and therefore couldn't do the check) and a
15882 // nested-name-qualifier (and therefore could do the lookup).
15883 NamedDecl *FirstQualifierInScope = nullptr;
15884
15885 return getDerived().RebuildUnresolvedMemberExpr(
15886 Base.get(), BaseType, Old->getOperatorLoc(), Old->isArrow(), QualifierLoc,
15887 TemplateKWLoc, FirstQualifierInScope, R,
15888 (Old->hasExplicitTemplateArgs() ? &TransArgs : nullptr));
15889}
15890
15891template<typename Derived>
15893TreeTransform<Derived>::TransformCXXNoexceptExpr(CXXNoexceptExpr *E) {
15894 EnterExpressionEvaluationContext Unevaluated(
15896 ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
15897 if (SubExpr.isInvalid())
15898 return ExprError();
15899
15900 if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
15901 return E;
15902
15903 return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
15904}
15905
15906template<typename Derived>
15908TreeTransform<Derived>::TransformPackExpansionExpr(PackExpansionExpr *E) {
15909 ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
15910 if (Pattern.isInvalid())
15911 return ExprError();
15912
15913 if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
15914 return E;
15915
15916 return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
15917 E->getNumExpansions());
15918}
15919
15920template<typename Derived>
15922TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
15923 // If E is not value-dependent, then nothing will change when we transform it.
15924 // Note: This is an instantiation-centric view.
15925 if (!E->isValueDependent())
15926 return E;
15927
15928 EnterExpressionEvaluationContext Unevaluated(
15930
15932 TemplateArgument ArgStorage;
15933
15934 // Find the argument list to transform.
15935 if (E->isPartiallySubstituted()) {
15936 PackArgs = E->getPartialArguments();
15937 } else if (E->isValueDependent()) {
15938 UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
15939 bool ShouldExpand = false;
15940 bool RetainExpansion = false;
15941 std::optional<unsigned> NumExpansions;
15942 if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(),
15943 Unexpanded,
15944 ShouldExpand, RetainExpansion,
15945 NumExpansions))
15946 return ExprError();
15947
15948 // If we need to expand the pack, build a template argument from it and
15949 // expand that.
15950 if (ShouldExpand) {
15951 auto *Pack = E->getPack();
15952 if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
15953 ArgStorage = getSema().Context.getPackExpansionType(
15954 getSema().Context.getTypeDeclType(TTPD), std::nullopt);
15955 } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
15956 ArgStorage = TemplateArgument(TemplateName(TTPD), std::nullopt);
15957 } else {
15958 auto *VD = cast<ValueDecl>(Pack);
15959 ExprResult DRE = getSema().BuildDeclRefExpr(
15960 VD, VD->getType().getNonLValueExprType(getSema().Context),
15961 VD->getType()->isReferenceType() ? VK_LValue : VK_PRValue,
15962 E->getPackLoc());
15963 if (DRE.isInvalid())
15964 return ExprError();
15965 ArgStorage = new (getSema().Context)
15966 PackExpansionExpr(getSema().Context.DependentTy, DRE.get(),
15967 E->getPackLoc(), std::nullopt);
15968 }
15969 PackArgs = ArgStorage;
15970 }
15971 }
15972
15973 // If we're not expanding the pack, just transform the decl.
15974 if (!PackArgs.size()) {
15975 auto *Pack = cast_or_null<NamedDecl>(
15976 getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
15977 if (!Pack)
15978 return ExprError();
15979 return getDerived().RebuildSizeOfPackExpr(
15980 E->getOperatorLoc(), Pack, E->getPackLoc(), E->getRParenLoc(),
15981 std::nullopt, {});
15982 }
15983
15984 // Try to compute the result without performing a partial substitution.
15985 std::optional<unsigned> Result = 0;
15986 for (const TemplateArgument &Arg : PackArgs) {
15987 if (!Arg.isPackExpansion()) {
15988 Result = *Result + 1;
15989 continue;
15990 }
15991
15992 TemplateArgumentLoc ArgLoc;
15993 InventTemplateArgumentLoc(Arg, ArgLoc);
15994
15995 // Find the pattern of the pack expansion.
15996 SourceLocation Ellipsis;
15997 std::optional<unsigned> OrigNumExpansions;
15998 TemplateArgumentLoc Pattern =
15999 getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
16000 OrigNumExpansions);
16001
16002 // Substitute under the pack expansion. Do not expand the pack (yet).
16003 TemplateArgumentLoc OutPattern;
16004 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
16005 if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
16006 /*Uneval*/ true))
16007 return true;
16008
16009 // See if we can determine the number of arguments from the result.
16010 std::optional<unsigned> NumExpansions =
16011 getSema().getFullyPackExpandedSize(OutPattern.getArgument());
16012 if (!NumExpansions) {
16013 // No: we must be in an alias template expansion, and we're going to need
16014 // to actually expand the packs.
16015 Result = std::nullopt;
16016 break;
16017 }
16018
16019 Result = *Result + *NumExpansions;
16020 }
16021
16022 // Common case: we could determine the number of expansions without
16023 // substituting.
16024 if (Result)
16025 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16026 E->getPackLoc(),
16027 E->getRParenLoc(), *Result, {});
16028
16029 TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
16030 E->getPackLoc());
16031 {
16032 TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
16033 typedef TemplateArgumentLocInventIterator<
16034 Derived, const TemplateArgument*> PackLocIterator;
16035 if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
16036 PackLocIterator(*this, PackArgs.end()),
16037 TransformedPackArgs, /*Uneval*/true))
16038 return ExprError();
16039 }
16040
16041 // Check whether we managed to fully-expand the pack.
16042 // FIXME: Is it possible for us to do so and not hit the early exit path?
16044 bool PartialSubstitution = false;
16045 for (auto &Loc : TransformedPackArgs.arguments()) {
16046 Args.push_back(Loc.getArgument());
16047 if (Loc.getArgument().isPackExpansion())
16048 PartialSubstitution = true;
16049 }
16050
16051 if (PartialSubstitution)
16052 return getDerived().RebuildSizeOfPackExpr(
16053 E->getOperatorLoc(), E->getPack(), E->getPackLoc(), E->getRParenLoc(),
16054 std::nullopt, Args);
16055
16056 return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
16057 E->getPackLoc(), E->getRParenLoc(),
16058 Args.size(), {});
16059}
16060
16061template <typename Derived>
16063TreeTransform<Derived>::TransformPackIndexingExpr(PackIndexingExpr *E) {
16064 if (!E->isValueDependent())
16065 return E;
16066
16067 // Transform the index
16068 ExprResult IndexExpr;
16069 {
16070 EnterExpressionEvaluationContext ConstantContext(
16072 IndexExpr = getDerived().TransformExpr(E->getIndexExpr());
16073 if (IndexExpr.isInvalid())
16074 return ExprError();
16075 }
16076
16077 SmallVector<Expr *, 5> ExpandedExprs;
16078 bool FullySubstituted = true;
16079 if (!E->expandsToEmptyPack() && E->getExpressions().empty()) {
16080 Expr *Pattern = E->getPackIdExpression();
16082 getSema().collectUnexpandedParameterPacks(E->getPackIdExpression(),
16083 Unexpanded);
16084 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16085
16086 // Determine whether the set of unexpanded parameter packs can and should
16087 // be expanded.
16088 bool ShouldExpand = true;
16089 bool RetainExpansion = false;
16090 std::optional<unsigned> OrigNumExpansions;
16091 std::optional<unsigned> NumExpansions = OrigNumExpansions;
16092 if (getDerived().TryExpandParameterPacks(
16093 E->getEllipsisLoc(), Pattern->getSourceRange(), Unexpanded,
16094 ShouldExpand, RetainExpansion, NumExpansions))
16095 return true;
16096 if (!ShouldExpand) {
16097 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
16098 ExprResult Pack = getDerived().TransformExpr(Pattern);
16099 if (Pack.isInvalid())
16100 return ExprError();
16101 return getDerived().RebuildPackIndexingExpr(
16102 E->getEllipsisLoc(), E->getRSquareLoc(), Pack.get(), IndexExpr.get(),
16103 {}, /*FullySubstituted=*/false);
16104 }
16105 for (unsigned I = 0; I != *NumExpansions; ++I) {
16106 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
16107 ExprResult Out = getDerived().TransformExpr(Pattern);
16108 if (Out.isInvalid())
16109 return true;
16110 if (Out.get()->containsUnexpandedParameterPack()) {
16111 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16112 OrigNumExpansions);
16113 if (Out.isInvalid())
16114 return true;
16115 FullySubstituted = false;
16116 }
16117 ExpandedExprs.push_back(Out.get());
16118 }
16119 // If we're supposed to retain a pack expansion, do so by temporarily
16120 // forgetting the partially-substituted parameter pack.
16121 if (RetainExpansion) {
16122 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16123
16124 ExprResult Out = getDerived().TransformExpr(Pattern);
16125 if (Out.isInvalid())
16126 return true;
16127
16128 Out = getDerived().RebuildPackExpansion(Out.get(), E->getEllipsisLoc(),
16129 OrigNumExpansions);
16130 if (Out.isInvalid())
16131 return true;
16132 FullySubstituted = false;
16133 ExpandedExprs.push_back(Out.get());
16134 }
16135 } else if (!E->expandsToEmptyPack()) {
16136 if (getDerived().TransformExprs(E->getExpressions().data(),
16137 E->getExpressions().size(), false,
16138 ExpandedExprs))
16139 return ExprError();
16140 }
16141
16142 return getDerived().RebuildPackIndexingExpr(
16143 E->getEllipsisLoc(), E->getRSquareLoc(), E->getPackIdExpression(),
16144 IndexExpr.get(), ExpandedExprs, FullySubstituted);
16145}
16146
16147template<typename Derived>
16149TreeTransform<Derived>::TransformSubstNonTypeTemplateParmPackExpr(
16150 SubstNonTypeTemplateParmPackExpr *E) {
16151 // Default behavior is to do nothing with this transformation.
16152 return E;
16153}
16154
16155template<typename Derived>
16157TreeTransform<Derived>::TransformSubstNonTypeTemplateParmExpr(
16158 SubstNonTypeTemplateParmExpr *E) {
16159 // Default behavior is to do nothing with this transformation.
16160 return E;
16161}
16162
16163template<typename Derived>
16165TreeTransform<Derived>::TransformFunctionParmPackExpr(FunctionParmPackExpr *E) {
16166 // Default behavior is to do nothing with this transformation.
16167 return E;
16168}
16169
16170template <typename Derived>
16171ExprResult TreeTransform<Derived>::TransformResolvedUnexpandedPackExpr(
16172 ResolvedUnexpandedPackExpr *E) {
16173 bool ArgumentChanged = false;
16174 SmallVector<Expr *, 12> NewExprs;
16175 if (TransformExprs(E->getExprs().begin(), E->getNumExprs(),
16176 /*IsCall=*/false, NewExprs, &ArgumentChanged))
16177 return ExprError();
16178
16179 if (!AlwaysRebuild() && !ArgumentChanged)
16180 return E;
16181
16182 // NOTE: The type is just a superficial PackExpansionType
16183 // that needs no substitution.
16184 return RebuildResolvedUnexpandedPackExpr(E->getBeginLoc(), E->getType(),
16185 NewExprs);
16186}
16187
16188template<typename Derived>
16190TreeTransform<Derived>::TransformMaterializeTemporaryExpr(
16191 MaterializeTemporaryExpr *E) {
16192 return getDerived().TransformExpr(E->getSubExpr());
16193}
16194
16195template<typename Derived>
16197TreeTransform<Derived>::TransformCXXFoldExpr(CXXFoldExpr *E) {
16198 UnresolvedLookupExpr *Callee = nullptr;
16199 if (Expr *OldCallee = E->getCallee()) {
16200 ExprResult CalleeResult = getDerived().TransformExpr(OldCallee);
16201 if (CalleeResult.isInvalid())
16202 return ExprError();
16203 Callee = cast<UnresolvedLookupExpr>(CalleeResult.get());
16204 }
16205
16206 Expr *Pattern = E->getPattern();
16207
16209 getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
16210 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16211
16212 // Determine whether the set of unexpanded parameter packs can and should
16213 // be expanded.
16214 bool Expand = true;
16215 bool RetainExpansion = false;
16216 std::optional<unsigned> OrigNumExpansions = E->getNumExpansions(),
16217 NumExpansions = OrigNumExpansions;
16218 if (getDerived().TryExpandParameterPacks(E->getEllipsisLoc(),
16219 Pattern->getSourceRange(),
16220 Unexpanded,
16221 Expand, RetainExpansion,
16222 NumExpansions))
16223 return true;
16224
16225 if (!Expand) {
16226 // Do not expand any packs here, just transform and rebuild a fold
16227 // expression.
16228 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
16229
16230 ExprResult LHS =
16231 E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
16232 if (LHS.isInvalid())
16233 return true;
16234
16235 ExprResult RHS =
16236 E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
16237 if (RHS.isInvalid())
16238 return true;
16239
16240 if (!getDerived().AlwaysRebuild() &&
16241 LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
16242 return E;
16243
16244 return getDerived().RebuildCXXFoldExpr(
16245 Callee, E->getBeginLoc(), LHS.get(), E->getOperator(),
16246 E->getEllipsisLoc(), RHS.get(), E->getEndLoc(), NumExpansions);
16247 }
16248
16249 // Formally a fold expression expands to nested parenthesized expressions.
16250 // Enforce this limit to avoid creating trees so deep we can't safely traverse
16251 // them.
16252 if (NumExpansions && SemaRef.getLangOpts().BracketDepth < NumExpansions) {
16253 SemaRef.Diag(E->getEllipsisLoc(),
16254 clang::diag::err_fold_expression_limit_exceeded)
16255 << *NumExpansions << SemaRef.getLangOpts().BracketDepth
16256 << E->getSourceRange();
16257 SemaRef.Diag(E->getEllipsisLoc(), diag::note_bracket_depth);
16258 return ExprError();
16259 }
16260
16261 // The transform has determined that we should perform an elementwise
16262 // expansion of the pattern. Do so.
16263 ExprResult Result = getDerived().TransformExpr(E->getInit());
16264 if (Result.isInvalid())
16265 return true;
16266 bool LeftFold = E->isLeftFold();
16267
16268 // If we're retaining an expansion for a right fold, it is the innermost
16269 // component and takes the init (if any).
16270 if (!LeftFold && RetainExpansion) {
16271 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16272
16273 ExprResult Out = getDerived().TransformExpr(Pattern);
16274 if (Out.isInvalid())
16275 return true;
16276
16277 Result = getDerived().RebuildCXXFoldExpr(
16278 Callee, E->getBeginLoc(), Out.get(), E->getOperator(),
16279 E->getEllipsisLoc(), Result.get(), E->getEndLoc(), OrigNumExpansions);
16280 if (Result.isInvalid())
16281 return true;
16282 }
16283
16284 for (unsigned I = 0; I != *NumExpansions; ++I) {
16285 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(
16286 getSema(), LeftFold ? I : *NumExpansions - I - 1);
16287 ExprResult Out = getDerived().TransformExpr(Pattern);
16288 if (Out.isInvalid())
16289 return true;
16290
16291 if (Out.get()->containsUnexpandedParameterPack()) {
16292 // We still have a pack; retain a pack expansion for this slice.
16293 Result = getDerived().RebuildCXXFoldExpr(
16294 Callee, E->getBeginLoc(), LeftFold ? Result.get() : Out.get(),
16295 E->getOperator(), E->getEllipsisLoc(),
16296 LeftFold ? Out.get() : Result.get(), E->getEndLoc(),
16297 OrigNumExpansions);
16298 } else if (Result.isUsable()) {
16299 // We've got down to a single element; build a binary operator.
16300 Expr *LHS = LeftFold ? Result.get() : Out.get();
16301 Expr *RHS = LeftFold ? Out.get() : Result.get();
16302 if (Callee) {
16303 UnresolvedSet<16> Functions;
16304 Functions.append(Callee->decls_begin(), Callee->decls_end());
16305 Result = getDerived().RebuildCXXOperatorCallExpr(
16307 E->getEllipsisLoc(), Callee->getBeginLoc(), Callee->requiresADL(),
16308 Functions, LHS, RHS);
16309 } else {
16310 Result = getDerived().RebuildBinaryOperator(E->getEllipsisLoc(),
16311 E->getOperator(), LHS, RHS);
16312 }
16313 } else
16314 Result = Out;
16315
16316 if (Result.isInvalid())
16317 return true;
16318 }
16319
16320 // If we're retaining an expansion for a left fold, it is the outermost
16321 // component and takes the complete expansion so far as its init (if any).
16322 if (LeftFold && RetainExpansion) {
16323 ForgetPartiallySubstitutedPackRAII Forget(getDerived());
16324
16325 ExprResult Out = getDerived().TransformExpr(Pattern);
16326 if (Out.isInvalid())
16327 return true;
16328
16329 Result = getDerived().RebuildCXXFoldExpr(
16330 Callee, E->getBeginLoc(), Result.get(), E->getOperator(),
16331 E->getEllipsisLoc(), Out.get(), E->getEndLoc(), OrigNumExpansions);
16332 if (Result.isInvalid())
16333 return true;
16334 }
16335
16336 if (ParenExpr *PE = dyn_cast_or_null<ParenExpr>(Result.get()))
16337 PE->setIsProducedByFoldExpansion();
16338
16339 // If we had no init and an empty pack, and we're not retaining an expansion,
16340 // then produce a fallback value or error.
16341 if (Result.isUnset())
16342 return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
16343 E->getOperator());
16344 return Result;
16345}
16346
16347template <typename Derived>
16349TreeTransform<Derived>::TransformCXXParenListInitExpr(CXXParenListInitExpr *E) {
16350 SmallVector<Expr *, 4> TransformedInits;
16351 ArrayRef<Expr *> InitExprs = E->getInitExprs();
16352 if (TransformExprs(InitExprs.data(), InitExprs.size(), true,
16353 TransformedInits))
16354 return ExprError();
16355
16356 return getDerived().RebuildParenListExpr(E->getBeginLoc(), TransformedInits,
16357 E->getEndLoc());
16358}
16359
16360template<typename Derived>
16362TreeTransform<Derived>::TransformCXXStdInitializerListExpr(
16363 CXXStdInitializerListExpr *E) {
16364 return getDerived().TransformExpr(E->getSubExpr());
16365}
16366
16367template<typename Derived>
16369TreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) {
16370 return SemaRef.MaybeBindToTemporary(E);
16371}
16372
16373template<typename Derived>
16375TreeTransform<Derived>::TransformObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
16376 return E;
16377}
16378
16379template<typename Derived>
16381TreeTransform<Derived>::TransformObjCBoxedExpr(ObjCBoxedExpr *E) {
16382 ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
16383 if (SubExpr.isInvalid())
16384 return ExprError();
16385
16386 if (!getDerived().AlwaysRebuild() &&
16387 SubExpr.get() == E->getSubExpr())
16388 return E;
16389
16390 return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
16391}
16392
16393template<typename Derived>
16395TreeTransform<Derived>::TransformObjCArrayLiteral(ObjCArrayLiteral *E) {
16396 // Transform each of the elements.
16397 SmallVector<Expr *, 8> Elements;
16398 bool ArgChanged = false;
16399 if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
16400 /*IsCall=*/false, Elements, &ArgChanged))
16401 return ExprError();
16402
16403 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16404 return SemaRef.MaybeBindToTemporary(E);
16405
16406 return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
16407 Elements.data(),
16408 Elements.size());
16409}
16410
16411template<typename Derived>
16413TreeTransform<Derived>::TransformObjCDictionaryLiteral(
16414 ObjCDictionaryLiteral *E) {
16415 // Transform each of the elements.
16417 bool ArgChanged = false;
16418 for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
16419 ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
16420
16421 if (OrigElement.isPackExpansion()) {
16422 // This key/value element is a pack expansion.
16424 getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
16425 getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
16426 assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
16427
16428 // Determine whether the set of unexpanded parameter packs can
16429 // and should be expanded.
16430 bool Expand = true;
16431 bool RetainExpansion = false;
16432 std::optional<unsigned> OrigNumExpansions = OrigElement.NumExpansions;
16433 std::optional<unsigned> NumExpansions = OrigNumExpansions;
16434 SourceRange PatternRange(OrigElement.Key->getBeginLoc(),
16435 OrigElement.Value->getEndLoc());
16436 if (getDerived().TryExpandParameterPacks(OrigElement.EllipsisLoc,
16437 PatternRange, Unexpanded, Expand,
16438 RetainExpansion, NumExpansions))
16439 return ExprError();
16440
16441 if (!Expand) {
16442 // The transform has determined that we should perform a simple
16443 // transformation on the pack expansion, producing another pack
16444 // expansion.
16445 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
16446 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16447 if (Key.isInvalid())
16448 return ExprError();
16449
16450 if (Key.get() != OrigElement.Key)
16451 ArgChanged = true;
16452
16453 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16454 if (Value.isInvalid())
16455 return ExprError();
16456
16457 if (Value.get() != OrigElement.Value)
16458 ArgChanged = true;
16459
16460 ObjCDictionaryElement Expansion = {
16461 Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
16462 };
16463 Elements.push_back(Expansion);
16464 continue;
16465 }
16466
16467 // Record right away that the argument was changed. This needs
16468 // to happen even if the array expands to nothing.
16469 ArgChanged = true;
16470
16471 // The transform has determined that we should perform an elementwise
16472 // expansion of the pattern. Do so.
16473 for (unsigned I = 0; I != *NumExpansions; ++I) {
16474 Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
16475 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16476 if (Key.isInvalid())
16477 return ExprError();
16478
16479 ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
16480 if (Value.isInvalid())
16481 return ExprError();
16482
16483 ObjCDictionaryElement Element = {
16484 Key.get(), Value.get(), SourceLocation(), NumExpansions
16485 };
16486
16487 // If any unexpanded parameter packs remain, we still have a
16488 // pack expansion.
16489 // FIXME: Can this really happen?
16490 if (Key.get()->containsUnexpandedParameterPack() ||
16491 Value.get()->containsUnexpandedParameterPack())
16492 Element.EllipsisLoc = OrigElement.EllipsisLoc;
16493
16494 Elements.push_back(Element);
16495 }
16496
16497 // FIXME: Retain a pack expansion if RetainExpansion is true.
16498
16499 // We've finished with this pack expansion.
16500 continue;
16501 }
16502
16503 // Transform and check key.
16504 ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
16505 if (Key.isInvalid())
16506 return ExprError();
16507
16508 if (Key.get() != OrigElement.Key)
16509 ArgChanged = true;
16510
16511 // Transform and check value.
16513 = getDerived().TransformExpr(OrigElement.Value);
16514 if (Value.isInvalid())
16515 return ExprError();
16516
16517 if (Value.get() != OrigElement.Value)
16518 ArgChanged = true;
16519
16520 ObjCDictionaryElement Element = {Key.get(), Value.get(), SourceLocation(),
16521 std::nullopt};
16522 Elements.push_back(Element);
16523 }
16524
16525 if (!getDerived().AlwaysRebuild() && !ArgChanged)
16526 return SemaRef.MaybeBindToTemporary(E);
16527
16528 return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
16529 Elements);
16530}
16531
16532template<typename Derived>
16534TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) {
16535 TypeSourceInfo *EncodedTypeInfo
16536 = getDerived().TransformType(E->getEncodedTypeSourceInfo());
16537 if (!EncodedTypeInfo)
16538 return ExprError();
16539
16540 if (!getDerived().AlwaysRebuild() &&
16541 EncodedTypeInfo == E->getEncodedTypeSourceInfo())
16542 return E;
16543
16544 return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
16545 EncodedTypeInfo,
16546 E->getRParenLoc());
16547}
16548
16549template<typename Derived>
16550ExprResult TreeTransform<Derived>::
16551TransformObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
16552 // This is a kind of implicit conversion, and it needs to get dropped
16553 // and recomputed for the same general reasons that ImplicitCastExprs
16554 // do, as well a more specific one: this expression is only valid when
16555 // it appears *immediately* as an argument expression.
16556 return getDerived().TransformExpr(E->getSubExpr());
16557}
16558
16559template<typename Derived>
16560ExprResult TreeTransform<Derived>::
16561TransformObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
16562 TypeSourceInfo *TSInfo
16563 = getDerived().TransformType(E->getTypeInfoAsWritten());
16564 if (!TSInfo)
16565 return ExprError();
16566
16567 ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
16568 if (Result.isInvalid())
16569 return ExprError();
16570
16571 if (!getDerived().AlwaysRebuild() &&
16572 TSInfo == E->getTypeInfoAsWritten() &&
16573 Result.get() == E->getSubExpr())
16574 return E;
16575
16576 return SemaRef.ObjC().BuildObjCBridgedCast(
16577 E->getLParenLoc(), E->getBridgeKind(), E->getBridgeKeywordLoc(), TSInfo,
16578 Result.get());
16579}
16580
16581template <typename Derived>
16582ExprResult TreeTransform<Derived>::TransformObjCAvailabilityCheckExpr(
16583 ObjCAvailabilityCheckExpr *E) {
16584 return E;
16585}
16586
16587template<typename Derived>
16589TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
16590 // Transform arguments.
16591 bool ArgChanged = false;
16593 Args.reserve(E->getNumArgs());
16594 if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
16595 &ArgChanged))
16596 return ExprError();
16597
16598 if (E->getReceiverKind() == ObjCMessageExpr::Class) {
16599 // Class message: transform the receiver type.
16600 TypeSourceInfo *ReceiverTypeInfo
16601 = getDerived().TransformType(E->getClassReceiverTypeInfo());
16602 if (!ReceiverTypeInfo)
16603 return ExprError();
16604
16605 // If nothing changed, just retain the existing message send.
16606 if (!getDerived().AlwaysRebuild() &&
16607 ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
16608 return SemaRef.MaybeBindToTemporary(E);
16609
16610 // Build a new class message send.
16612 E->getSelectorLocs(SelLocs);
16613 return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
16614 E->getSelector(),
16615 SelLocs,
16616 E->getMethodDecl(),
16617 E->getLeftLoc(),
16618 Args,
16619 E->getRightLoc());
16620 }
16621 else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
16622 E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
16623 if (!E->getMethodDecl())
16624 return ExprError();
16625
16626 // Build a new class message send to 'super'.
16628 E->getSelectorLocs(SelLocs);
16629 return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
16630 E->getSelector(),
16631 SelLocs,
16632 E->getReceiverType(),
16633 E->getMethodDecl(),
16634 E->getLeftLoc(),
16635 Args,
16636 E->getRightLoc());
16637 }
16638
16639 // Instance message: transform the receiver
16640 assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
16641 "Only class and instance messages may be instantiated");
16642 ExprResult Receiver
16643 = getDerived().TransformExpr(E->getInstanceReceiver());
16644 if (Receiver.isInvalid())
16645 return ExprError();
16646
16647 // If nothing changed, just retain the existing message send.
16648 if (!getDerived().AlwaysRebuild() &&
16649 Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
16650 return SemaRef.MaybeBindToTemporary(E);
16651
16652 // Build a new instance message send.
16654 E->getSelectorLocs(SelLocs);
16655 return getDerived().RebuildObjCMessageExpr(Receiver.get(),
16656 E->getSelector(),
16657 SelLocs,
16658 E->getMethodDecl(),
16659 E->getLeftLoc(),
16660 Args,
16661 E->getRightLoc());
16662}
16663
16664template<typename Derived>
16666TreeTransform<Derived>::TransformObjCSelectorExpr(ObjCSelectorExpr *E) {
16667 return E;
16668}
16669
16670template<typename Derived>
16672TreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) {
16673 return E;
16674}
16675
16676template<typename Derived>
16678TreeTransform<Derived>::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
16679 // Transform the base expression.
16680 ExprResult Base = getDerived().TransformExpr(E->getBase());
16681 if (Base.isInvalid())
16682 return ExprError();
16683
16684 // We don't need to transform the ivar; it will never change.
16685
16686 // If nothing changed, just retain the existing expression.
16687 if (!getDerived().AlwaysRebuild() &&
16688 Base.get() == E->getBase())
16689 return E;
16690
16691 return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
16692 E->getLocation(),
16693 E->isArrow(), E->isFreeIvar());
16694}
16695
16696template<typename Derived>
16698TreeTransform<Derived>::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
16699 // 'super' and types never change. Property never changes. Just
16700 // retain the existing expression.
16701 if (!E->isObjectReceiver())
16702 return E;
16703
16704 // Transform the base expression.
16705 ExprResult Base = getDerived().TransformExpr(E->getBase());
16706 if (Base.isInvalid())
16707 return ExprError();
16708
16709 // We don't need to transform the property; it will never change.
16710
16711 // If nothing changed, just retain the existing expression.
16712 if (!getDerived().AlwaysRebuild() &&
16713 Base.get() == E->getBase())
16714 return E;
16715
16716 if (E->isExplicitProperty())
16717 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
16718 E->getExplicitProperty(),
16719 E->getLocation());
16720
16721 return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
16722 SemaRef.Context.PseudoObjectTy,
16723 E->getImplicitPropertyGetter(),
16724 E->getImplicitPropertySetter(),
16725 E->getLocation());
16726}
16727
16728template<typename Derived>
16730TreeTransform<Derived>::TransformObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
16731 // Transform the base expression.
16732 ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
16733 if (Base.isInvalid())
16734 return ExprError();
16735
16736 // Transform the key expression.
16737 ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
16738 if (Key.isInvalid())
16739 return ExprError();
16740
16741 // If nothing changed, just retain the existing expression.
16742 if (!getDerived().AlwaysRebuild() &&
16743 Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
16744 return E;
16745
16746 return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
16747 Base.get(), Key.get(),
16748 E->getAtIndexMethodDecl(),
16749 E->setAtIndexMethodDecl());
16750}
16751
16752template<typename Derived>
16754TreeTransform<Derived>::TransformObjCIsaExpr(ObjCIsaExpr *E) {
16755 // Transform the base expression.
16756 ExprResult Base = getDerived().TransformExpr(E->getBase());
16757 if (Base.isInvalid())
16758 return ExprError();
16759
16760 // If nothing changed, just retain the existing expression.
16761 if (!getDerived().AlwaysRebuild() &&
16762 Base.get() == E->getBase())
16763 return E;
16764
16765 return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
16766 E->getOpLoc(),
16767 E->isArrow());
16768}
16769
16770template<typename Derived>
16772TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) {
16773 bool ArgumentChanged = false;
16774 SmallVector<Expr*, 8> SubExprs;
16775 SubExprs.reserve(E->getNumSubExprs());
16776 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
16777 SubExprs, &ArgumentChanged))
16778 return ExprError();
16779
16780 if (!getDerived().AlwaysRebuild() &&
16781 !ArgumentChanged)
16782 return E;
16783
16784 return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
16785 SubExprs,
16786 E->getRParenLoc());
16787}
16788
16789template<typename Derived>
16791TreeTransform<Derived>::TransformConvertVectorExpr(ConvertVectorExpr *E) {
16792 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
16793 if (SrcExpr.isInvalid())
16794 return ExprError();
16795
16796 TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
16797 if (!Type)
16798 return ExprError();
16799
16800 if (!getDerived().AlwaysRebuild() &&
16801 Type == E->getTypeSourceInfo() &&
16802 SrcExpr.get() == E->getSrcExpr())
16803 return E;
16804
16805 return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
16806 SrcExpr.get(), Type,
16807 E->getRParenLoc());
16808}
16809
16810template<typename Derived>
16812TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) {
16813 BlockDecl *oldBlock = E->getBlockDecl();
16814
16815 SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
16816 BlockScopeInfo *blockScope = SemaRef.getCurBlock();
16817
16818 blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
16819 blockScope->TheDecl->setBlockMissingReturnType(
16820 oldBlock->blockMissingReturnType());
16821
16823 SmallVector<QualType, 4> paramTypes;
16824
16825 const FunctionProtoType *exprFunctionType = E->getFunctionType();
16826
16827 // Parameter substitution.
16828 Sema::ExtParameterInfoBuilder extParamInfos;
16829 if (getDerived().TransformFunctionTypeParams(
16830 E->getCaretLocation(), oldBlock->parameters(), nullptr,
16831 exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
16832 extParamInfos)) {
16833 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
16834 return ExprError();
16835 }
16836
16837 QualType exprResultType =
16838 getDerived().TransformType(exprFunctionType->getReturnType());
16839
16840 auto epi = exprFunctionType->getExtProtoInfo();
16841 epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
16842
16843 QualType functionType =
16844 getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
16845 blockScope->FunctionType = functionType;
16846
16847 // Set the parameters on the block decl.
16848 if (!params.empty())
16849 blockScope->TheDecl->setParams(params);
16850
16851 if (!oldBlock->blockMissingReturnType()) {
16852 blockScope->HasImplicitReturnType = false;
16853 blockScope->ReturnType = exprResultType;
16854 }
16855
16856 // Transform the body
16857 StmtResult body = getDerived().TransformStmt(E->getBody());
16858 if (body.isInvalid()) {
16859 getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
16860 return ExprError();
16861 }
16862
16863#ifndef NDEBUG
16864 // In builds with assertions, make sure that we captured everything we
16865 // captured before.
16866 if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
16867 for (const auto &I : oldBlock->captures()) {
16868 VarDecl *oldCapture = I.getVariable();
16869
16870 // Ignore parameter packs.
16871 if (oldCapture->isParameterPack())
16872 continue;
16873
16874 VarDecl *newCapture =
16875 cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
16876 oldCapture));
16877 assert(blockScope->CaptureMap.count(newCapture));
16878 }
16879
16880 // The this pointer may not be captured by the instantiated block, even when
16881 // it's captured by the original block, if the expression causing the
16882 // capture is in the discarded branch of a constexpr if statement.
16883 assert((!blockScope->isCXXThisCaptured() || oldBlock->capturesCXXThis()) &&
16884 "this pointer isn't captured in the old block");
16885 }
16886#endif
16887
16888 return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
16889 /*Scope=*/nullptr);
16890}
16891
16892template<typename Derived>
16894TreeTransform<Derived>::TransformAsTypeExpr(AsTypeExpr *E) {
16895 ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
16896 if (SrcExpr.isInvalid())
16897 return ExprError();
16898
16899 QualType Type = getDerived().TransformType(E->getType());
16900
16901 return SemaRef.BuildAsTypeExpr(SrcExpr.get(), Type, E->getBuiltinLoc(),
16902 E->getRParenLoc());
16903}
16904
16905template<typename Derived>
16907TreeTransform<Derived>::TransformAtomicExpr(AtomicExpr *E) {
16908 bool ArgumentChanged = false;
16909 SmallVector<Expr*, 8> SubExprs;
16910 SubExprs.reserve(E->getNumSubExprs());
16911 if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
16912 SubExprs, &ArgumentChanged))
16913 return ExprError();
16914
16915 if (!getDerived().AlwaysRebuild() &&
16916 !ArgumentChanged)
16917 return E;
16918
16919 return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
16920 E->getOp(), E->getRParenLoc());
16921}
16922
16923//===----------------------------------------------------------------------===//
16924// Type reconstruction
16925//===----------------------------------------------------------------------===//
16926
16927template<typename Derived>
16930 return SemaRef.BuildPointerType(PointeeType, Star,
16931 getDerived().getBaseEntity());
16932}
16933
16934template<typename Derived>
16937 return SemaRef.BuildBlockPointerType(PointeeType, Star,
16938 getDerived().getBaseEntity());
16939}
16940
16941template<typename Derived>
16944 bool WrittenAsLValue,
16945 SourceLocation Sigil) {
16946 return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
16947 Sigil, getDerived().getBaseEntity());
16948}
16949
16950template<typename Derived>
16953 QualType ClassType,
16954 SourceLocation Sigil) {
16955 return SemaRef.BuildMemberPointerType(PointeeType, ClassType, Sigil,
16956 getDerived().getBaseEntity());
16957}
16958
16959template<typename Derived>
16961 const ObjCTypeParamDecl *Decl,
16962 SourceLocation ProtocolLAngleLoc,
16964 ArrayRef<SourceLocation> ProtocolLocs,
16965 SourceLocation ProtocolRAngleLoc) {
16966 return SemaRef.ObjC().BuildObjCTypeParamType(
16967 Decl, ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
16968 /*FailOnError=*/true);
16969}
16970
16971template<typename Derived>
16973 QualType BaseType,
16975 SourceLocation TypeArgsLAngleLoc,
16977 SourceLocation TypeArgsRAngleLoc,
16978 SourceLocation ProtocolLAngleLoc,
16980 ArrayRef<SourceLocation> ProtocolLocs,
16981 SourceLocation ProtocolRAngleLoc) {
16982 return SemaRef.ObjC().BuildObjCObjectType(
16983 BaseType, Loc, TypeArgsLAngleLoc, TypeArgs, TypeArgsRAngleLoc,
16984 ProtocolLAngleLoc, Protocols, ProtocolLocs, ProtocolRAngleLoc,
16985 /*FailOnError=*/true,
16986 /*Rebuilding=*/true);
16987}
16988
16989template<typename Derived>
16991 QualType PointeeType,
16993 return SemaRef.Context.getObjCObjectPointerType(PointeeType);
16994}
16995
16996template <typename Derived>
16998 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt *Size,
16999 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17000 if (SizeExpr || !Size)
17001 return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
17002 IndexTypeQuals, BracketsRange,
17003 getDerived().getBaseEntity());
17004
17005 QualType Types[] = {
17009 };
17010 QualType SizeType;
17011 for (const auto &T : Types)
17012 if (Size->getBitWidth() == SemaRef.Context.getIntWidth(T)) {
17013 SizeType = T;
17014 break;
17015 }
17016
17017 // Note that we can return a VariableArrayType here in the case where
17018 // the element type was a dependent VariableArrayType.
17019 IntegerLiteral *ArraySize
17020 = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
17021 /*FIXME*/BracketsRange.getBegin());
17022 return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
17023 IndexTypeQuals, BracketsRange,
17024 getDerived().getBaseEntity());
17025}
17026
17027template <typename Derived>
17029 QualType ElementType, ArraySizeModifier SizeMod, const llvm::APInt &Size,
17030 Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange) {
17031 return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, SizeExpr,
17032 IndexTypeQuals, BracketsRange);
17033}
17034
17035template <typename Derived>
17037 QualType ElementType, ArraySizeModifier SizeMod, unsigned IndexTypeQuals,
17038 SourceRange BracketsRange) {
17039 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
17040 IndexTypeQuals, BracketsRange);
17041}
17042
17043template <typename Derived>
17045 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17046 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17047 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17048 SizeExpr,
17049 IndexTypeQuals, BracketsRange);
17050}
17051
17052template <typename Derived>
17054 QualType ElementType, ArraySizeModifier SizeMod, Expr *SizeExpr,
17055 unsigned IndexTypeQuals, SourceRange BracketsRange) {
17056 return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
17057 SizeExpr,
17058 IndexTypeQuals, BracketsRange);
17059}
17060
17061template <typename Derived>
17063 QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
17064 return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
17065 AttributeLoc);
17066}
17067
17068template <typename Derived>
17070 unsigned NumElements,
17071 VectorKind VecKind) {
17072 // FIXME: semantic checking!
17073 return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
17074}
17075
17076template <typename Derived>
17078 QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
17079 VectorKind VecKind) {
17080 return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
17081}
17082
17083template<typename Derived>
17085 unsigned NumElements,
17086 SourceLocation AttributeLoc) {
17087 llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17088 NumElements, true);
17089 IntegerLiteral *VectorSize
17090 = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
17091 AttributeLoc);
17092 return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
17093}
17094
17095template<typename Derived>
17098 Expr *SizeExpr,
17099 SourceLocation AttributeLoc) {
17100 return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
17101}
17102
17103template <typename Derived>
17105 QualType ElementType, unsigned NumRows, unsigned NumColumns) {
17106 return SemaRef.Context.getConstantMatrixType(ElementType, NumRows,
17107 NumColumns);
17108}
17109
17110template <typename Derived>
17112 QualType ElementType, Expr *RowExpr, Expr *ColumnExpr,
17113 SourceLocation AttributeLoc) {
17114 return SemaRef.BuildMatrixType(ElementType, RowExpr, ColumnExpr,
17115 AttributeLoc);
17116}
17117
17118template <typename Derived>
17122 return SemaRef.BuildFunctionType(T, ParamTypes,
17123 getDerived().getBaseLocation(),
17124 getDerived().getBaseEntity(),
17125 EPI);
17126}
17127
17128template<typename Derived>
17130 return SemaRef.Context.getFunctionNoProtoType(T);
17131}
17132
17133template<typename Derived>
17135 Decl *D) {
17136 assert(D && "no decl found");
17137 if (D->isInvalidDecl()) return QualType();
17138
17139 // FIXME: Doesn't account for ObjCInterfaceDecl!
17140 if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
17141 // A valid resolved using typename pack expansion decl can have multiple
17142 // UsingDecls, but they must each have exactly one type, and it must be
17143 // the same type in every case. But we must have at least one expansion!
17144 if (UPD->expansions().empty()) {
17145 getSema().Diag(Loc, diag::err_using_pack_expansion_empty)
17146 << UPD->isCXXClassMember() << UPD;
17147 return QualType();
17148 }
17149
17150 // We might still have some unresolved types. Try to pick a resolved type
17151 // if we can. The final instantiation will check that the remaining
17152 // unresolved types instantiate to the type we pick.
17153 QualType FallbackT;
17154 QualType T;
17155 for (auto *E : UPD->expansions()) {
17156 QualType ThisT = RebuildUnresolvedUsingType(Loc, E);
17157 if (ThisT.isNull())
17158 continue;
17159 else if (ThisT->getAs<UnresolvedUsingType>())
17160 FallbackT = ThisT;
17161 else if (T.isNull())
17162 T = ThisT;
17163 else
17164 assert(getSema().Context.hasSameType(ThisT, T) &&
17165 "mismatched resolved types in using pack expansion");
17166 }
17167 return T.isNull() ? FallbackT : T;
17168 } else if (auto *Using = dyn_cast<UsingDecl>(D)) {
17169 assert(Using->hasTypename() &&
17170 "UnresolvedUsingTypenameDecl transformed to non-typename using");
17171
17172 // A valid resolved using typename decl points to exactly one type decl.
17173 assert(++Using->shadow_begin() == Using->shadow_end());
17174
17175 UsingShadowDecl *Shadow = *Using->shadow_begin();
17176 if (SemaRef.DiagnoseUseOfDecl(Shadow->getTargetDecl(), Loc))
17177 return QualType();
17178 return SemaRef.Context.getUsingType(
17179 Shadow, SemaRef.Context.getTypeDeclType(
17180 cast<TypeDecl>(Shadow->getTargetDecl())));
17181 } else {
17182 assert(isa<UnresolvedUsingTypenameDecl>(D) &&
17183 "UnresolvedUsingTypenameDecl transformed to non-using decl");
17184 return SemaRef.Context.getTypeDeclType(
17185 cast<UnresolvedUsingTypenameDecl>(D));
17186 }
17187}
17188
17189template <typename Derived>
17191 TypeOfKind Kind) {
17192 return SemaRef.BuildTypeofExprType(E, Kind);
17193}
17194
17195template<typename Derived>
17197 TypeOfKind Kind) {
17198 return SemaRef.Context.getTypeOfType(Underlying, Kind);
17199}
17200
17201template <typename Derived>
17203 return SemaRef.BuildDecltypeType(E);
17204}
17205
17206template <typename Derived>
17208 QualType Pattern, Expr *IndexExpr, SourceLocation Loc,
17209 SourceLocation EllipsisLoc, bool FullySubstituted,
17210 ArrayRef<QualType> Expansions) {
17211 return SemaRef.BuildPackIndexingType(Pattern, IndexExpr, Loc, EllipsisLoc,
17212 FullySubstituted, Expansions);
17213}
17214
17215template<typename Derived>
17219 return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
17220}
17221
17222template<typename Derived>
17224 TemplateName Template,
17225 SourceLocation TemplateNameLoc,
17226 TemplateArgumentListInfo &TemplateArgs) {
17227 return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
17228}
17229
17230template<typename Derived>
17232 SourceLocation KWLoc) {
17233 return SemaRef.BuildAtomicType(ValueType, KWLoc);
17234}
17235
17236template<typename Derived>
17238 SourceLocation KWLoc,
17239 bool isReadPipe) {
17240 return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
17241 : SemaRef.BuildWritePipeType(ValueType, KWLoc);
17242}
17243
17244template <typename Derived>
17246 unsigned NumBits,
17248 llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
17249 NumBits, true);
17250 IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP,
17251 SemaRef.Context.IntTy, Loc);
17252 return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc);
17253}
17254
17255template <typename Derived>
17257 bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) {
17258 return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc);
17259}
17260
17261template<typename Derived>
17264 bool TemplateKW,
17265 TemplateDecl *Template) {
17266 return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
17267 TemplateName(Template));
17268}
17269
17270template<typename Derived>
17273 SourceLocation TemplateKWLoc,
17274 const IdentifierInfo &Name,
17275 SourceLocation NameLoc,
17276 QualType ObjectType,
17277 NamedDecl *FirstQualifierInScope,
17278 bool AllowInjectedClassName) {
17280 TemplateName.setIdentifier(&Name, NameLoc);
17281 Sema::TemplateTy Template;
17282 getSema().ActOnTemplateName(/*Scope=*/nullptr, SS, TemplateKWLoc,
17283 TemplateName, ParsedType::make(ObjectType),
17284 /*EnteringContext=*/false, Template,
17285 AllowInjectedClassName);
17286 return Template.get();
17287}
17288
17289template<typename Derived>
17292 SourceLocation TemplateKWLoc,
17293 OverloadedOperatorKind Operator,
17294 SourceLocation NameLoc,
17295 QualType ObjectType,
17296 bool AllowInjectedClassName) {
17297 UnqualifiedId Name;
17298 // FIXME: Bogus location information.
17299 SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
17300 Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
17301 Sema::TemplateTy Template;
17302 getSema().ActOnTemplateName(
17303 /*Scope=*/nullptr, SS, TemplateKWLoc, Name, ParsedType::make(ObjectType),
17304 /*EnteringContext=*/false, Template, AllowInjectedClassName);
17305 return Template.get();
17306}
17307
17308template <typename Derived>
17311 bool RequiresADL, const UnresolvedSetImpl &Functions, Expr *First,
17312 Expr *Second) {
17313 bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
17314
17315 if (First->getObjectKind() == OK_ObjCProperty) {
17318 return SemaRef.PseudoObject().checkAssignment(/*Scope=*/nullptr, OpLoc,
17319 Opc, First, Second);
17321 if (Result.isInvalid())
17322 return ExprError();
17323 First = Result.get();
17324 }
17325
17326 if (Second && Second->getObjectKind() == OK_ObjCProperty) {
17327 ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
17328 if (Result.isInvalid())
17329 return ExprError();
17330 Second = Result.get();
17331 }
17332
17333 // Determine whether this should be a builtin operation.
17334 if (Op == OO_Subscript) {
17335 if (!First->getType()->isOverloadableType() &&
17336 !Second->getType()->isOverloadableType())
17337 return getSema().CreateBuiltinArraySubscriptExpr(First, CalleeLoc, Second,
17338 OpLoc);
17339 } else if (Op == OO_Arrow) {
17340 // It is possible that the type refers to a RecoveryExpr created earlier
17341 // in the tree transformation.
17342 if (First->getType()->isDependentType())
17343 return ExprError();
17344 // -> is never a builtin operation.
17345 return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
17346 } else if (Second == nullptr || isPostIncDec) {
17347 if (!First->getType()->isOverloadableType() ||
17348 (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
17349 // The argument is not of overloadable type, or this is an expression
17350 // of the form &Class::member, so try to create a built-in unary
17351 // operation.
17353 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17354
17355 return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
17356 }
17357 } else {
17358 if (!First->isTypeDependent() && !Second->isTypeDependent() &&
17359 !First->getType()->isOverloadableType() &&
17360 !Second->getType()->isOverloadableType()) {
17361 // Neither of the arguments is type-dependent or has an overloadable
17362 // type, so try to create a built-in binary operation.
17365 = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
17366 if (Result.isInvalid())
17367 return ExprError();
17368
17369 return Result;
17370 }
17371 }
17372
17373 // Create the overloaded operator invocation for unary operators.
17374 if (!Second || isPostIncDec) {
17376 = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
17377 return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
17378 RequiresADL);
17379 }
17380
17381 // Create the overloaded operator invocation for binary operators.
17383 ExprResult Result = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions,
17384 First, Second, RequiresADL);
17385 if (Result.isInvalid())
17386 return ExprError();
17387
17388 return Result;
17389}
17390
17391template<typename Derived>
17394 SourceLocation OperatorLoc,
17395 bool isArrow,
17396 CXXScopeSpec &SS,
17397 TypeSourceInfo *ScopeType,
17398 SourceLocation CCLoc,
17399 SourceLocation TildeLoc,
17400 PseudoDestructorTypeStorage Destroyed) {
17401 QualType BaseType = Base->getType();
17402 if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
17403 (!isArrow && !BaseType->getAs<RecordType>()) ||
17404 (isArrow && BaseType->getAs<PointerType>() &&
17405 !BaseType->castAs<PointerType>()->getPointeeType()
17406 ->template getAs<RecordType>())){
17407 // This pseudo-destructor expression is still a pseudo-destructor.
17408 return SemaRef.BuildPseudoDestructorExpr(
17409 Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
17410 CCLoc, TildeLoc, Destroyed);
17411 }
17412
17413 TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
17415 SemaRef.Context.getCanonicalType(DestroyedType->getType())));
17416 DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
17417 NameInfo.setNamedTypeInfo(DestroyedType);
17418
17419 // The scope type is now known to be a valid nested name specifier
17420 // component. Tack it on to the end of the nested name specifier.
17421 if (ScopeType) {
17422 if (!ScopeType->getType()->getAs<TagType>()) {
17423 getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
17424 diag::err_expected_class_or_namespace)
17425 << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
17426 return ExprError();
17427 }
17428 SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(),
17429 CCLoc);
17430 }
17431
17432 SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
17433 return getSema().BuildMemberReferenceExpr(Base, BaseType,
17434 OperatorLoc, isArrow,
17435 SS, TemplateKWLoc,
17436 /*FIXME: FirstQualifier*/ nullptr,
17437 NameInfo,
17438 /*TemplateArgs*/ nullptr,
17439 /*S*/nullptr);
17440}
17441
17442template<typename Derived>
17445 SourceLocation Loc = S->getBeginLoc();
17446 CapturedDecl *CD = S->getCapturedDecl();
17447 unsigned NumParams = CD->getNumParams();
17448 unsigned ContextParamPos = CD->getContextParamPosition();
17450 for (unsigned I = 0; I < NumParams; ++I) {
17451 if (I != ContextParamPos) {
17452 Params.push_back(
17453 std::make_pair(
17454 CD->getParam(I)->getName(),
17455 getDerived().TransformType(CD->getParam(I)->getType())));
17456 } else {
17457 Params.push_back(std::make_pair(StringRef(), QualType()));
17458 }
17459 }
17460 getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
17461 S->getCapturedRegionKind(), Params);
17462 StmtResult Body;
17463 {
17464 Sema::CompoundScopeRAII CompoundScope(getSema());
17465 Body = getDerived().TransformStmt(S->getCapturedStmt());
17466 }
17467
17468 if (Body.isInvalid()) {
17469 getSema().ActOnCapturedRegionError();
17470 return StmtError();
17471 }
17472
17473 return getSema().ActOnCapturedRegionEnd(Body.get());
17474}
17475
17476template <typename Derived>
17478TreeTransform<Derived>::TransformSYCLKernelCallStmt(SYCLKernelCallStmt *S) {
17479 // SYCLKernelCallStmt nodes are inserted upon completion of a (non-template)
17480 // function definition or instantiation of a function template specialization
17481 // and will therefore never appear in a dependent context.
17482 llvm_unreachable("SYCL kernel call statement cannot appear in dependent "
17483 "context");
17484}
17485
17486template <typename Derived>
17487ExprResult TreeTransform<Derived>::TransformHLSLOutArgExpr(HLSLOutArgExpr *E) {
17488 // We can transform the base expression and allow argument resolution to fill
17489 // in the rest.
17490 return getDerived().TransformExpr(E->getArgLValue());
17491}
17492
17493} // end namespace clang
17494
17495#endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
MatchType Type
const Decl * D
Expr * E
unsigned OldSize
static Decl::Kind getKind(const Decl *D)
Definition: DeclBase.cpp:1181
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:3060
unsigned Iter
Definition: HTMLLogger.cpp:153
#define X(type, name)
Definition: Value.h:144
llvm::MachO::Target Target
Definition: MachO.h:51
llvm::MachO::Record Record
Definition: MachO.h:31
This file defines OpenMP AST classes for clauses.
Defines some OpenMP-specific enums and functions.
uint32_t Id
Definition: SemaARM.cpp:1125
SourceRange Range
Definition: SemaObjC.cpp:758
SourceLocation Loc
Definition: SemaObjC.cpp:759
This file declares semantic analysis for Objective-C.
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 expressions involving.
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.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
static QualType getPointeeType(const MemRegion *R)
SourceLocation Begin
std::string Label
QualType getUsingType(const UsingShadowDecl *Found, QualType Underlying) const
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1141
unsigned getIntWidth(QualType T) 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:684
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
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.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Definition: ASTContext.h:2723
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Definition: ASTContext.h:2739
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 getSubstTemplateTypeParmType(QualType Replacement, Decl *AssociatedDecl, unsigned Index, std::optional< unsigned > PackIndex, SubstTemplateTypeParmTypeFlag Flag=SubstTemplateTypeParmTypeFlag::None) const
Retrieve a substitution-result type.
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:1703
IdentifierTable & Idents
Definition: ASTContext.h:680
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:1170
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:1169
CanQualType PseudoObjectTy
Definition: ASTContext.h:1191
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:2296
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.
QualType getPackExpansionType(QualType Pattern, std::optional< unsigned > NumExpansions, bool ExpectPackInType=true) const
Form a pack expansion type with the given pattern.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
CanQualType UnsignedInt128Ty
Definition: ASTContext.h:1171
CanQualType BuiltinFnTy
Definition: ASTContext.h:1190
CanQualType UnsignedCharTy
Definition: ASTContext.h:1170
CanQualType UnsignedIntTy
Definition: ASTContext.h:1170
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:1171
CanQualType UnsignedShortTy
Definition: ASTContext.h:1170
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 getHLSLAttributedResourceType(QualType Wrapped, QualType Contained, const HLSLAttributedResourceType::Attributes &Attrs)
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 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:2853
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2666
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2642
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2650
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2658
Attr - This represents one attribute.
Definition: Attr.h:43
attr::Kind getKind() const
Definition: Attr.h:89
Represents an attribute applied to a statement.
Definition: Stmt.h:2107
Represents a C++11 auto or C++14 decltype(auto) type, possibly constrained by a type-constraint.
Definition: Type.h:6562
ArrayRef< TemplateArgument > getTypeConstraintArguments() const
Definition: Type.h:6572
ConceptDecl * getTypeConstraintConcept() const
Definition: Type.h:6577
AutoTypeKeyword getKeyword() const
Definition: Type.h:6593
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Definition: Expr.cpp:2195
bool isAssignmentOp() const
Definition: Expr.h:4048
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:2157
void setIsVariadic(bool value)
Definition: Decl.h:4572
Represents a C++2a __builtin_bit_cast(T, v) expression.
Definition: ExprCXX.h:5296
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.h:5315
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.h:5314
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1491
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:28
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1546
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1714
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1689
bool isStdInitListInitialization() const
Whether this constructor call was written as list-initialization, but was interpreted as forming a st...
Definition: ExprCXX.h:1639
SourceLocation getEndLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:568
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: ExprCXX.cpp:562
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1628
unsigned getNumArgs() const
Return the number of arguments to the constructor call.
Definition: ExprCXX.h:1686
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2592
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param, Expr *RewrittenExpr, DeclContext *UsedContext)
Definition: ExprCXX.cpp:1018
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1737
Abstract class common to all of the C++ "named"/"keyword" casts.
Definition: ExprCXX.h:372
Represents a C++ struct/union/class.
Definition: DeclCXX.h:258
unsigned getLambdaDependencyKind() const
Definition: DeclCXX.h:1871
An expression "T()" which creates an rvalue of a non-class type T.
Definition: ExprCXX.h:2182
Represents a C++ nested-name-specifier or a global scope specifier.
Definition: DeclSpec.h:74
char * location_data() const
Retrieve the data associated with the source-location information.
Definition: DeclSpec.h:236
SourceRange getRange() const
Definition: DeclSpec.h:80
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier '::'.
Definition: DeclSpec.cpp:101
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
Definition: DeclSpec.cpp:149
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:95
unsigned location_size() const
Retrieve the size of the data associated with source-location information.
Definition: DeclSpec.h:240
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into '__super' nested-name-specifier.
Definition: DeclSpec.cpp:111
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:51
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
Definition: DeclSpec.cpp:129
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:3557
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:1498
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4772
unsigned getNumParams() const
Definition: Decl.h:4814
unsigned getContextParamPosition() const
Definition: Decl.h:4843
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4816
This captures a statement into a function.
Definition: Stmt.h:3784
Expr * getSubExpr()
Definition: Expr.h:3597
SourceLocation getBegin() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:1628
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:87
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:422
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1375
reference front() const
Definition: DeclBase.h:1398
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1442
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1868
void addDecl(Decl *D)
Add the declaration D into this context.
Definition: DeclBase.cpp:1782
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:1265
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Definition: Stmt.h:1519
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
SourceLocation getEndLoc() const LLVM_READONLY
Definition: DeclBase.h:438
bool isInvalidDecl() const
Definition: DeclBase.h:591
SourceLocation getLocation() const
Definition: DeclBase.h:442
DeclContext * getDeclContext()
Definition: DeclBase.h:451
AccessSpecifier getAccess() const
Definition: DeclBase.h:510
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:434
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:781
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:768
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1904
QualType getDeducedType() const
Get the type deduced for this placeholder type, or null if it has not been deduced.
Definition: Type.h:6549
bool isDeduced() const
Definition: Type.h:6550
A qualified reference to a name whose declaration cannot yet be resolved.
Definition: ExprCXX.h:3323
Represents a dependent template name that cannot be resolved prior to template instantiation.
Definition: TemplateName.h:548
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2504
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2528
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2524
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2520
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2492
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2548
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2488
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2540
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2556
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2532
Represents a template specialization type whose template cannot be resolved, e.g.
Definition: Type.h:7082
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:868
Wrap a function effect's condition expression in another struct so that FunctionProtoType's TrailingO...
Definition: Type.h:4829
Expr * getCondition() const
Definition: Type.h:4836
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2351
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2363
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2355
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2393
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2369
Represents a type that was referred to using an elaborated type keyword, e.g., struct S,...
Definition: Type.h:6949
RAII object that enters a new expression evaluation context.
Represents an enum.
Definition: Decl.h:3861
TypeSourceInfo * getTypeInfoAsWritten() const
getTypeInfoAsWritten - Returns the type source info for the type that this expression is casting to.
Definition: Expr.h:3821
This represents one expression.
Definition: Expr.h:110
bool isGLValue() const
Definition: Expr.h:280
bool isValueDependent() const
Determines whether the value of this expression depends on.
Definition: Expr.h:175
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
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition: Expr.cpp:276
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:981
Represents a member of a struct/union/class.
Definition: Decl.h:3033
Represents a function declaration or definition.
Definition: Decl.h:1935
QualType getReturnType() const
Definition: Decl.h:2720
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:2649
QualType getCallResultType() const
Determine the type of an expression that calls this function.
Definition: Decl.h:2756
Represents an abstract function effect, using just an enumeration describing its kind.
Definition: Type.h:4722
StringRef name() const
The description printed in diagnostics, e.g. 'nonblocking'.
Definition: Type.cpp:5221
Kind oppositeKind() const
Return the opposite kind, for effects which have opposites.
Definition: Type.cpp:5207
ArrayRef< EffectConditionExpr > conditions() const
Definition: Type.h:4943
Represents a K&R-style 'int foo()' function, which has no information available about its arguments.
Definition: Type.h:4687
Represents a prototype with parameter type info, e.g.
Definition: Type.h:5108
QualType desugar() const
Definition: Type.h:5652
param_type_iterator param_type_begin() const
Definition: Type.h:5521
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present,...
Definition: Type.h:5559
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
Definition: Type.h:5501
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:5372
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:5368
unsigned getNumParams() const
Definition: TypeLoc.h:1532
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1484
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1480
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1496
SourceRange getExceptionSpecRange() const
Definition: TypeLoc.h:1512
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1539
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1523
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1504
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1488
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1518
TypeLoc getReturnLoc() const
Definition: TypeLoc.h:1541
SourceLocation getLocalRangeBegin() const
Definition: TypeLoc.h:1476
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1492
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1500
Interesting information about a specific parameter that can't simply be reflected in parameter's type...
Definition: Type.h:4348
QualType getReturnType() const
Definition: Type.h:4649
AssociationTy< false > Association
Definition: Expr.h:6197
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:3724
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:5841
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:515
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:979
Represents the declaration of a label.
Definition: Decl.h:503
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:1954
const LambdaCapture * capture_iterator
An iterator that walks over the captures of the lambda, both implicit and explicit.
Definition: ExprCXX.h:2019
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:605
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition: Lookup.h:475
bool empty() const
Return true if no decls were found.
Definition: Lookup.h:362
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Definition: SemaLookup.cpp:484
SourceLocation getNameLoc() const
Gets the location of the identifier.
Definition: Lookup.h:664
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition: Lookup.h:575
DeclarationName getLookupName() const
Gets the name to look up.
Definition: Lookup.h:265
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Definition: ExprCXX.h:4732
This represents a decl that may have a name.
Definition: Decl.h:253
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Definition: Decl.h:466
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:274
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:280
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:319
Represents a C++ namespace alias.
Definition: DeclCXX.h:3182
Represent a C++ namespace.
Definition: Decl.h:551
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
This represents clauses with a list of expressions that are mappable.
This represents '#pragma omp metadirective' directive.
Definition: StmtOpenMP.h:6064
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1951
@ SuperInstance
The receiver is the instance of the superclass object.
Definition: ExprObjC.h:955
@ Instance
The receiver is an object instance.
Definition: ExprObjC.h:949
@ SuperClass
The receiver is a superclass.
Definition: ExprObjC.h:952
@ Class
The receiver is a class.
Definition: ExprObjC.h:946
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:2418
@ Identifier
A field in a dependent type, known only by its name.
Definition: Expr.h:2422
@ Field
A field.
Definition: Expr.h:2420
@ Base
An implicit indirection through a C++ base class, when the field found is in a base class.
Definition: Expr.h:2425
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:1173
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:1223
static OpenACCAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCAttachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCAutoClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
This is the base type for all OpenACC Clauses.
Definition: OpenACCClause.h:24
static OpenACCCollapseClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, bool HasForce, Expr *LoopCount, SourceLocation EndLoc)
static OpenACCCopyClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyInClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsReadOnly, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCopyOutClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsZero, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCCreateClause * Create(const ASTContext &C, OpenACCClauseKind Spelling, SourceLocation BeginLoc, SourceLocation LParenLoc, bool IsZero, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDefaultAsyncClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDefaultClause * Create(const ASTContext &C, OpenACCDefaultClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
static OpenACCDeleteClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDetachClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceNumClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCDevicePtrClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCDeviceTypeClause * Create(const ASTContext &C, OpenACCClauseKind K, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< DeviceTypeArgument > Archs, SourceLocation EndLoc)
static OpenACCFinalizeClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCFirstPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCHostClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCIfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCIfPresentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCIndependentClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCNoCreateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, 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 OpenACCPresentClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCPrivateClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCSelfClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc)
static OpenACCSeqClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation EndLoc)
static OpenACCTileClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > SizeExprs, SourceLocation EndLoc)
static OpenACCUseDeviceClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, ArrayRef< Expr * > VarList, SourceLocation EndLoc)
static OpenACCVectorClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCVectorLengthClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
static OpenACCWaitClause * Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation EndLoc)
static OpenACCWorkerClause * Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *IntExpr, SourceLocation EndLoc)
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Definition: ExprCXX.h:2983
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:3135
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3117
SourceLocation getNameLoc() const
Gets the location of the name.
Definition: ExprCXX.h:3096
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3109
NestedNameSpecifierLoc getQualifierLoc() const
Fetches the nested-name qualifier with source-location information, if one was given.
Definition: ExprCXX.h:3105
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3137
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:3082
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3143
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:3093
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3125
bool hasTemplateKeyword() const
Determines whether the name was preceded by the template keyword.
Definition: ExprCXX.h:3132
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:4180
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2614
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2610
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2626
Represents a pack expansion of types.
Definition: Type.h:7147
std::optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:7172
ParenExpr - This represents a parenthesized expression, e.g.
Definition: Expr.h:2170
SourceLocation getLParen() const
Get the location of the left parentheses '('.
Definition: Expr.h:2195
SourceLocation getRParen() const
Get the location of the right parentheses ')'.
Definition: Expr.h:2199
Represents a parameter to a function.
Definition: Decl.h:1725
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1785
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1758
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:2918
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1775
void setSigilLoc(SourceLocation Loc)
Definition: TypeLoc.h:1310
TypeLoc getPointeeLoc() const
Definition: TypeLoc.h:1314
SourceLocation getSigilLoc() const
Definition: TypeLoc.h:1306
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:3199
QualType getPointeeType() const
Definition: Type.h:3209
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2566
const IdentifierInfo * getIdentifier() const
Definition: ExprCXX.h:2586
SourceLocation getLocation() const
Definition: ExprCXX.h:2590
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2582
A (possibly-)qualified type.
Definition: Type.h:929
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:996
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
Definition: Type.h:7937
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Definition: Type.h:7977
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:8031
Qualifiers getLocalQualifiers() const
Retrieve the set of qualifiers local to this particular QualType instance, not including any qualifie...
Definition: Type.h:7969
Represents a template name as written in source code.
Definition: TemplateName.h:491
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:324
void removeObjCLifetime()
Definition: Type.h:544
bool hasRestrict() const
Definition: Type.h:470
static Qualifiers fromCVRMask(unsigned CVR)
Definition: Type.h:428
bool hasObjCLifetime() const
Definition: Type.h:537
bool empty() const
Definition: Type.h:640
LangAS getAddressSpace() const
Definition: Type.h:564
Represents a struct/union/class.
Definition: Decl.h:4162
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:6078
Base for LValueReferenceType and RValueReferenceType.
Definition: Type.h:3440
QualType getPointeeTypeAsWritten() const
Definition: Type.h:3456
Represents the body of a requires-expression.
Definition: DeclCXX.h:2086
static RequiresExprBodyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc)
Definition: DeclCXX.cpp:2313
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Definition: ExprConcepts.h:502
static RequiresExpr * Create(ASTContext &C, SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation RBraceLoc)
static ResolvedUnexpandedPackExpr * Create(ASTContext &C, SourceLocation BeginLoc, QualType T, unsigned NumExprs)
Definition: ExprCXX.cpp:1991
static SEHFinallyStmt * Create(const ASTContext &C, SourceLocation FinallyLoc, Stmt *Block)
Definition: Stmt.cpp:1283
Represents a __leave statement.
Definition: Stmt.h:3745
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:60
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.
StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)
Definition: SemaObjC.cpp:36
StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)
FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.
Definition: SemaObjC.cpp:198
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
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 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: SemaObjC.cpp:485
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.
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition: SemaObjC.cpp:325
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition: SemaObjC.cpp:223
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition: SemaObjC.cpp:218
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition: SemaObjC.cpp:243
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: SemaObjC.cpp:712
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition: SemaObjC.cpp:287
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition: SemaObjC.cpp:207
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition: SemaObjC.cpp:334
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.
ArrayRef< Expr * > getQueueIdExprs() const
Definition: SemaOpenACC.h:338
OpenACCDirectiveKind getDirectiveKind() const
Definition: SemaOpenACC.h:260
void setLParenLoc(SourceLocation EndLoc)
Definition: SemaOpenACC.h:467
void setConditionDetails(Expr *ConditionExpr)
Definition: SemaOpenACC.h:476
void setCollapseDetails(bool IsForce, Expr *LoopCount)
Definition: SemaOpenACC.h:642
OpenACCClauseKind getClauseKind() const
Definition: SemaOpenACC.h:262
SourceLocation getLParenLoc() const
Definition: SemaOpenACC.h:266
SourceLocation getBeginLoc() const
Definition: SemaOpenACC.h:264
void setDefaultDetails(OpenACCDefaultClauseKind DefKind)
Definition: SemaOpenACC.h:470
SourceLocation getQueuesLoc() const
Definition: SemaOpenACC.h:318
void setVarListDetails(ArrayRef< Expr * > VarList, bool IsReadOnly, bool IsZero)
Definition: SemaOpenACC.h:536
void setWaitDetails(Expr *DevNum, SourceLocation QueuesLoc, llvm::SmallVector< Expr * > &&IntExprs)
Definition: SemaOpenACC.h:628
void setEndLoc(SourceLocation EndLoc)
Definition: SemaOpenACC.h:468
void setIntExprDetails(ArrayRef< Expr * > IntExprs)
Definition: SemaOpenACC.h:490
OpenACCDefaultClauseKind getDefaultClauseKind() const
Definition: SemaOpenACC.h:270
void ActOnWhileStmt(SourceLocation WhileLoc)
ExprResult ActOnOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
void ActOnDoStmt(SourceLocation DoLoc)
void ActOnRangeForStmtBegin(SourceLocation ForLoc, const Stmt *OldRangeFor, const Stmt *RangeFor)
StmtResult ActOnEndStmtDirective(OpenACCDirectiveKind K, SourceLocation StartLoc, SourceLocation DirLoc, SourceLocation LParenLoc, SourceLocation MiscLoc, ArrayRef< Expr * > Exprs, OpenACCAtomicKind AK, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult AssocStmt)
Called after the directive has been completely parsed, including the declaration group or associated ...
void ActOnForStmtEnd(SourceLocation ForLoc, StmtResult Body)
void ActOnForStmtBegin(SourceLocation ForLoc, const Stmt *First, const Stmt *Second, const Stmt *Third)
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 * ActOnOpenMPHoldsClause(Expr *E, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'holds' 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 * ActOnOpenMPToClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'to' 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 * 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 * ActOnOpenMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-form 'permutation' clause after parsing its arguments.
OMPClause * ActOnOpenMPNontemporalClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'nontemporal' clause.
OMPClause * ActOnOpenMPFromClause(ArrayRef< OpenMPMotionModifierKind > MotionModifiers, ArrayRef< SourceLocation > MotionModifiersLoc, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperId, SourceLocation ColonLoc, ArrayRef< Expr * > VarList, const OMPVarListLocTy &Locs, ArrayRef< Expr * > UnresolvedMappers={})
Called on well-formed 'from' clause.
OMPClause * ActOnOpenMPBindClause(OpenMPBindClauseKind Kind, SourceLocation KindLoc, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on a well-formed 'bind' clause.
OMPClause * ActOnOpenMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'thread_limit' 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 * ActOnOpenMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'num_teams' 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)
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 * ActOnOpenMPTaskReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'task_reduction' clause.
OMPClause * ActOnOpenMPOrderClause(OpenMPOrderClauseModifier Modifier, OpenMPOrderClauseKind Kind, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation MLoc, SourceLocation KindLoc, SourceLocation EndLoc)
Called on well-formed 'order' 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={})
Called on well-formed 'reduction' 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.
OMPClause * ActOnOpenMPInReductionClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr * > UnresolvedReductions={})
Called on well-formed 'in_reduction' clause.
OMPClause * ActOnOpenMPFlushClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'flush' pseudo clause.
StmtResult ActOnOpenMPExecutableDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
OMPClause * ActOnOpenMPMessageClause(Expr *MS, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'message' 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 ActOnOpenMPInformationalDirective(OpenMPDirectiveKind Kind, const DeclarationNameInfo &DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Process an OpenMP informational directive.
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 * ActOnOpenMPAllocateClause(Expr *Allocator, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation ColonLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'allocate' clause.
OMPClause * ActOnOpenMPFinalClause(Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'final' 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={})
Called on well-formed 'map' 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 * ActOnOpenMPExclusiveClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Called on well-formed 'exclusive' clause.
OMPClause * ActOnOpenMPIfClause(OpenMPDirectiveKind NameModifier, Expr *Condition, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation NameModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Called on well-formed 'if' clause.
ExprResult checkAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
Expr * recreateSyntacticForm(PseudoObjectExpr *E)
Given a pseudo-object expression, recreate what it looks like syntactically without the attendant Opa...
ExprResult checkRValue(Expr *E)
ExprResult BuildUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, TypeSourceInfo *TSI)
Definition: SemaSYCL.cpp:143
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:13243
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
Definition: Sema.h:8062
A RAII object to enter scope of a compound statement.
Definition: Sema.h:918
A helper class for building up ExtParameterInfos.
Definition: Sema.h:12646
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:12665
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:12653
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Definition: Sema.h:13613
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:466
QualType BuildParenType(QualType T)
Build a paren type including T.
Definition: SemaType.cpp:1675
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
Definition: SemaType.cpp:6396
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:4481
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
Definition: Sema.h:9004
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:9012
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:9007
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:6499
ExprResult ActOnConstantExpression(ExprResult Res)
Definition: SemaExpr.cpp:19678
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)
static std::enable_if_t< std::is_base_of_v< Attr, AttrInfo >, SourceLocation > getAttrLoc(const AttrInfo &AL)
A helper function to provide Attribute Location for the Attr types AND the ParsedAttr.
Definition: Sema.h:4415
QualType BuildVectorType(QualType T, Expr *VecSize, SourceLocation AttrLoc)
Definition: SemaType.cpp:2328
StmtResult BuildAttributedStmt(SourceLocation AttrsLoc, ArrayRef< const Attr * > Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:651
SemaOpenMP & OpenMP()
Definition: Sema.h:1128
@ IER_DoesNotExist
The symbol does not exist.
Definition: Sema.h:8479
@ IER_Dependent
The name is a dependent name, so the results will differ from one instantiation to the next.
Definition: Sema.h:8483
@ IER_Error
An error occurred.
Definition: Sema.h:8486
@ IER_Exists
The symbol exists.
Definition: Sema.h:8476
void ActOnStartStmtExpr()
Definition: SemaExpr.cpp:15864
ExprResult BuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, sema::LambdaScopeInfo *LSI)
Complete a lambda-expression having processed and attached the lambda body.
void ActOnStmtExprError()
Definition: SemaExpr.cpp:15870
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false, ArrayRef< const Expr * > StopAt={})
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
Definition: SemaExpr.cpp:20195
std::optional< FunctionEffectMode > ActOnEffectExpression(Expr *CondExpr, StringRef AttributeName)
Try to parse the conditional expression attached to an effect attribute (e.g.
Definition: SemaType.cpp:7626
VarDecl * buildCoroutinePromise(SourceLocation Loc)
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:20411
ConditionKind
Definition: Sema.h:7355
@ 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:394
StmtResult ActOnGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, LabelDecl *TheDecl)
Definition: SemaStmt.cpp:3219
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:500
QualType BuildExtVectorType(QualType T, Expr *ArraySize, SourceLocation AttrLoc)
Build an ext-vector type.
Definition: SemaType.cpp:2394
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation EqualOrColonLoc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:3503
ExprResult BuildStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc, unsigned TemplateDepth)
Definition: SemaExpr.cpp:15883
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:1153
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16526
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression (C++ 5.3.5), as in:
ASTContext & Context
Definition: Sema.h:911
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:2634
ExprResult PerformMemberExprBaseConversion(Expr *Base, bool IsArrow)
Perform conversions on the LHS of a member access expression.
DiagnosticsEngine & getDiagnostics() const
Definition: Sema.h:531
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.
SemaObjC & ObjC()
Definition: Sema.h:1113
ExprResult BuildPackIndexingExpr(Expr *PackExpression, SourceLocation EllipsisLoc, Expr *IndexExpr, SourceLocation RSquareLoc, ArrayRef< Expr * > ExpandedExprs={}, bool FullySubstituted=false)
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
ASTContext & getASTContext() const
Definition: Sema.h:534
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:15801
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:4405
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:692
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedIdentKind IK)
Definition: SemaExpr.cpp:3499
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
Definition: SemaExpr.cpp:7068
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Definition: SemaExpr.cpp:15851
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
Definition: SemaExpr.cpp:7923
QualType BuildCountAttributedArrayOrPointerType(QualType WrappedTy, Expr *CountExpr, bool CountInBytes, bool OrNull)
Definition: SemaType.cpp:9617
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)
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:16982
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
Definition: SemaExpr.cpp:2217
QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc)
Build a bit-precise integer type.
Definition: SemaType.cpp:1941
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:16139
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:1684
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
Definition: SemaType.cpp:1581
StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Definition: SemaStmt.cpp:1308
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Definition: Sema.cpp:82
const LangOptions & getLangOpts() const
Definition: Sema.h:527
StmtResult ActOnWhileStmt(SourceLocation WhileLoc, SourceLocation LParenLoc, ConditionResult Cond, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:1792
SemaOpenACC & OpenACC()
Definition: Sema.h:1118
@ ReuseLambdaContextDecl
Definition: Sema.h:6535
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:16807
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc, bool ListInitialization)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
Definition: SemaExpr.cpp:15953
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
Definition: Sema.cpp:2407
ExprResult TemporaryMaterializationConversion(Expr *E)
If E is a prvalue denoting an unmaterialized temporary, materialize it as an xvalue.
Definition: SemaInit.cpp:7602
ExprResult ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ConvertVectorExpr - Handle __builtin_convertvector.
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:738
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:16957
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:3355
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:942
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
Definition: SemaDecl.cpp:14906
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:1858
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:13237
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
Definition: SemaExpr.cpp:3202
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
Definition: Sema.cpp:2362
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Definition: Sema.h:1046
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.
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
Definition: SemaExpr.cpp:20039
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen)
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
Definition: SemaExpr.cpp:2909
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
Definition: SemaStmt.cpp:2255
StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc, Expr *DestExp)
Definition: SemaStmt.cpp:3234
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
Definition: SemaExpr.cpp:4122
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Definition: SemaExpr.cpp:20995
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:3845
@ NTK_TypeAliasTemplate
Definition: Sema.h:3853
TryCaptureKind
Definition: Sema.h:6597
@ TryCapture_Implicit
Definition: Sema.h:6598
@ TryCapture_ExplicitByVal
Definition: Sema.h:6599
@ TryCapture_ExplicitByRef
Definition: Sema.h:6600
ExprResult BuildAsTypeExpr(Expr *E, QualType DestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Create a new AsTypeExpr node (bitcast) from the arguments.
Definition: SemaExpr.cpp:6724
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:8795
QualType BuildPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc, bool FullySubstituted=false, ArrayRef< QualType > Expansions={})
Definition: SemaType.cpp:9739
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.
concepts::ExprRequirement * BuildExprRequirement(Expr *E, bool IsSatisfied, SourceLocation NoexceptLoc, concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement)
QualType BuildAtomicType(QualType T, SourceLocation Loc)
Definition: SemaType.cpp:10021
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:13900
bool diagnoseConflictingFunctionEffect(const FunctionEffectsRef &FX, const FunctionEffectWithCondition &EC, SourceLocation NewAttrLoc)
Warn and return true if adding a function effect to a set would create a conflict.
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:216
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
Definition: SemaStmt.cpp:3885
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:1805
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:2683
StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, SourceLocation WhileLoc, SourceLocation CondLParen, Expr *Cond, SourceLocation CondRParen)
Definition: SemaStmt.cpp:1822
StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc)
Definition: SemaStmt.cpp:1184
ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, bool IsAddressOfOperand)
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:9707
QualType BuildUnaryTransformType(QualType BaseType, UTTKind UKind, SourceLocation Loc)
Definition: SemaType.cpp:9965
StmtResult ActOnSEHExceptBlock(SourceLocation Loc, Expr *FilterExpr, Stmt *Block)
Definition: SemaStmt.cpp:4443
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
Definition: SemaExpr.cpp:4630
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
Definition: SemaStmt.cpp:76
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,...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
Definition: Sema.h:7931
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:2049
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Definition: SemaExpr.cpp:5595
QualType BuildReadPipeType(QualType T, SourceLocation Loc)
Build a Read-only Pipe type.
Definition: SemaType.cpp:1933
concepts::NestedRequirement * BuildNestedRequirement(Expr *E)
QualType BuildWritePipeType(QualType T, SourceLocation Loc)
Build a Write-only Pipe type.
Definition: SemaType.cpp:1937
@ BFRK_Rebuild
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:10775
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:583
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:16325
QualType BuildTypeofExprType(Expr *E, TypeOfKind Kind)
Definition: SemaType.cpp:9594
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:20061
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
Definition: SemaCast.cpp:296
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:18109
QualType BuildMatrixType(QualType T, Expr *NumRows, Expr *NumColumns, SourceLocation AttrLoc)
Definition: SemaType.cpp:2448
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:21192
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
Definition: SemaExpr.cpp:15369
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
Definition: SemaExpr.cpp:2982
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
Definition: SemaStmt.cpp:962
ExprResult BuildInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:7268
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
Definition: SemaExpr.cpp:16177
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
Definition: SemaExpr.cpp:4843
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:14792
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:6451
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
Definition: SemaType.cpp:2752
static ConditionResult ConditionError()
Definition: Sema.h:7342
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
Definition: SemaStmt.cpp:451
SemaPseudoObject & PseudoObject()
Definition: Sema.h:1138
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:608
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:4292
StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, SourceLocation ColonLoc, Stmt *SubStmt, Scope *CurScope)
Definition: SemaStmt.cpp:588
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
Definition: SemaExpr.cpp:17936
StmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprResult LHS, SourceLocation DotDotDotLoc, ExprResult RHS, SourceLocation ColonLoc)
Definition: SemaStmt.cpp:552
QualType BuildMemberPointerType(QualType T, QualType Class, SourceLocation Loc, DeclarationName Entity)
Build a member pointer type T Class::*.
Definition: SemaType.cpp:2683
QualType BuildBlockPointerType(QualType T, SourceLocation Loc, DeclarationName Entity)
Build a block pointer type.
Definition: SemaType.cpp:2735
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
FinishCXXForRangeStmt - Attach the body to a C++0x for-range statement.
Definition: SemaStmt.cpp:3201
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
Definition: Sema.h:8282
ExprResult CreateBuiltinMatrixSubscriptExpr(Expr *Base, Expr *RowIdx, Expr *ColumnIdx, SourceLocation RBLoc)
Definition: SemaExpr.cpp:5020
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={})
Definition: ExprCXX.cpp:1693
static bool MayBeDependent(SourceLocIdentKind Kind)
Definition: Expr.h:4870
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.
bool isInvalid() const
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
Definition: Stmt.h:84
SourceLocation getEndLoc() const LLVM_READONLY
Definition: Stmt.cpp:358
StmtClass
Definition: Stmt.h:86
@ NoStmtClass
Definition: Stmt.h:87
StmtClass getStmtClass() const
Definition: Stmt.h:1380
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:334
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:346
A structure for storing an already-substituted template template parameter pack.
Definition: TemplateName.h:149
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:865
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3578
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:398
Represents a C++ template name within the type system.
Definition: TemplateName.h:220
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:1719
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1695
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1736
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1703
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1732
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1711
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:6667
Wrapper for template type parameters.
Definition: TypeLoc.h:759
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.
StmtResult RebuildOpenACCDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
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.
StmtResult RebuildOMPInformationalDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP informational directive.
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.
StmtResult RebuildOpenACCSetConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, TypeSourceInfo *EncodeTypeInfo, SourceLocation RParenLoc)
Build a new Objective-C @encode expression.
StmtResult RebuildOpenACCCombinedConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
StmtResult SkipLambdaBody(LambdaExpr *E, Stmt *Body)
Alternative implementation of TransformLambdaBody that skips transforming the body.
StmtResult RebuildOpenACCExitDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildOpenACCShutdownConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
OMPClause * RebuildOMPAllocateClause(Expr *Allocate, Expr *Alignment, OpenMPAllocateClauseModifier FirstModifier, SourceLocation FirstModifierLoc, OpenMPAllocateClauseModifier SecondModifier, SourceLocation SecondModifierLoc, ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc)
Build a new OpenMP 'allocate' clause.
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.
StmtResult RebuildOpenACCEnterDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
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)
OMPClause * RebuildOMPThreadLimitClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'thread_limit' clause.
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.
StmtResult RebuildOpenACCWaitConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef< Expr * > QueueIdExprs, SourceLocation RParenLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
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 RebuildOpenACCUpdateConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *Object, Stmt *Body)
Build a new Objective-C @synchronized statement.
ExprResult RebuildOpenACCAsteriskSizeExpr(SourceLocation AsteriskLoc)
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.
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.
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.
StmtResult RebuildOpenACCLoopConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult Loop)
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.
OMPClause * RebuildOMPNumTeamsClause(ArrayRef< Expr * > VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'num_teams' clause.
ExprResult RebuildImplicitValueInitExpr(QualType T)
Build a new value-initialized expression.
ExprResult RebuildResolvedUnexpandedPackExpr(SourceLocation BeginLoc, QualType T, ArrayRef< Expr * > Exprs)
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...
StmtResult RebuildOpenACCHostDataConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
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.
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)
ExprResult RebuildLambdaExpr(SourceLocation StartLoc, SourceLocation EndLoc, LambdaScopeInfo *LSI)
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 RebuildPackIndexingExpr(SourceLocation EllipsisLoc, SourceLocation RSquareLoc, Expr *PackIdExpression, Expr *IndexExpr, ArrayRef< Expr * > ExpandedExprs, bool FullySubstituted=false)
StmtResult RebuildOpenACCInitConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses)
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.
StmtResult TransformOMPInformationalDirective(OMPExecutableDirective *S)
This is mostly the same as above, but allows 'informational' class directives when rebuilding the stm...
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.
StmtResult RebuildOpenACCComputeConstruct(OpenACCDirectiveKind K, SourceLocation BeginLoc, SourceLocation DirLoc, SourceLocation EndLoc, ArrayRef< OpenACCClause * > Clauses, StmtResult StrBlock)
ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E)
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.
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.
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 * RebuildOMPPermutationClause(ArrayRef< Expr * > PermExprs, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'permutation' clause.
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)
StmtResult RebuildOpenACCAtomicConstruct(SourceLocation BeginLoc, SourceLocation DirLoc, OpenACCAtomicKind AtKind, SourceLocation EndLoc, StmtResult AssociatedStmt)
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.
StmtResult RebuildOMPExecutableDirective(OpenMPDirectiveKind Kind, DeclarationNameInfo DirName, OpenMPDirectiveKind CancelRegion, ArrayRef< OMPClause * > Clauses, Stmt *AStmt, SourceLocation StartLoc, SourceLocation EndLoc)
Build a new OpenMP executable directive.
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.
OMPClause * RebuildOMPHoldsClause(Expr *A, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP 'holds' clause.
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:756
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
Definition: TypeLoc.h:2716
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:192
A container of type source information.
Definition: Type.h:7908
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:7919
static TagTypeKind getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword)
Converts an elaborated type keyword into a TagTypeKind.
Definition: Type.cpp:3211
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:6907
The base class of the type hierarchy.
Definition: Type.h:1828
bool isPointerType() const
Definition: Type.h:8192
const T * castAs() const
Member-template castAs<specific type>.
Definition: Type.h:8810
bool isReferenceType() const
Definition: Type.h:8210
bool isEnumeralType() const
Definition: Type.h:8296
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
Definition: Type.cpp:738
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type.
Definition: Type.h:2812
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:2707
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:2361
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition: Type.h:8661
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
Definition: Type.cpp:5046
bool isFunctionType() const
Definition: Type.h:8188
bool isObjCObjectPointerType() const
Definition: Type.h:8334
const T * getAs() const
Member-template getAs<specific type>'.
Definition: Type.h:8741
bool isRecordType() const
Definition: Type.h:8292
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3427
Wrapper for source info for typedefs.
Definition: TypeLoc.h:694
TypedefNameDecl * getTypedefNameDecl() const
Definition: TypeLoc.h:696
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition: Expr.h:2232
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:1416
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:1028
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:3203
CXXRecordDecl * getNamingClass()
Gets the 'naming class' (in the sense of C++0x [class.access.base]p5) of the lookup.
Definition: ExprCXX.h:3277
bool requiresADL() const
True if this declaration should be extended by argument-dependent lookup.
Definition: ExprCXX.h:3272
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, UnresolvedSetIterator Begin, UnresolvedSetIterator End, bool KnownDependent, bool KnownInstantiationDependent)
Definition: ExprCXX.cpp:419
A set of unresolved declarations.
Definition: UnresolvedSet.h:62
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:5673
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Definition: DeclCXX.h:3382
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
Definition: DeclCXX.h:3446
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:671
QualType getType() const
Definition: Decl.h:682
bool isParameterPack() const
Determine whether this value is actually a function parameter pack, init-capture pack,...
Definition: Decl.cpp:5419
Represents a variable declaration or definition.
Definition: Decl.h:886
@ CInit
C-style initialization with assignment.
Definition: Decl.h:891
@ CallInit
Call-style initialization (C++98)
Definition: Decl.h:894
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1123
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
bool ContainsUnexpandedParameterPack
Whether this contains an unexpanded parameter pack.
Definition: ScopeInfo.h:728
CXXRecordDecl * Lambda
The class that describes the lambda.
Definition: ScopeInfo.h:871
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
Definition: ScopeInfo.h:874
@ AttributedType
The l-value was considered opaque, so the alignment was determined from a type, but that type was an ...
@ 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:820
bool Comp(InterpState &S, CodePtr OpPC)
1) Pops the value from the stack.
Definition: Interp.h:921
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
Definition: Descriptor.h:29
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.
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
OpenACCDirectiveKind
Definition: OpenACCKinds.h:25
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:42
@ CPlusPlus23
Definition: LangStandard.h:60
OpenACCAtomicKind
Definition: OpenACCKinds.h:169
AutoTypeKeyword
Which keyword(s) were used to create an AutoType.
Definition: Type.h:1778
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:25
OpenMPDefaultmapClauseModifier
OpenMP modifiers for 'defaultmap' clause.
Definition: OpenMPKinds.h:119
OpenMPOrderClauseModifier
OpenMP modifiers for 'order' clause.
Definition: OpenMPKinds.h:172
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:1538
@ 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:161
OpenMPAtClauseKind
OpenMP attributes for 'at' clause.
Definition: OpenMPKinds.h:136
@ 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:187
BinaryOperatorKind
@ Invalid
Represents an invalid clause, for the purposes of parsing.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
TypeOfKind
The kind of 'typeof' expression we're after.
Definition: Type.h:910
OpenMPScheduleClauseModifier
OpenMP modifiers for 'schedule' clause.
Definition: OpenMPKinds.h:39
OpenMPDistScheduleClauseKind
OpenMP attributes for 'dist_schedule' clause.
Definition: OpenMPKinds.h:104
OpenMPDoacrossClauseModifier
OpenMP dependence types for 'doacross' clause.
Definition: OpenMPKinds.h:220
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:51
ExprResult ExprEmpty()
Definition: Ownership.h:271
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl *, ResolvedUnexpandedPackExpr * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:238
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:201
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:3575
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
OpenMPLastprivateModifier
OpenMP 'lastprivate' clause modifier.
Definition: OpenMPKinds.h:158
OpenMPGrainsizeClauseModifier
Definition: OpenMPKinds.h:207
OpenMPNumTasksClauseModifier
Definition: OpenMPKinds.h:213
UnaryOperatorKind
ActionResult< Expr * > ExprResult
Definition: Ownership.h:248
TagTypeKind
The kind of a tag type.
Definition: Type.h:6877
bool transformOMPMappableExprListClause(TreeTransform< Derived > &TT, OMPMappableExprListClause< T > *C, llvm::SmallVectorImpl< Expr * > &Vars, CXXScopeSpec &MapperIdScopeSpec, DeclarationNameInfo &MapperIdInfo, llvm::SmallVectorImpl< Expr * > &UnresolvedMappers)
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:1492
OpenMPSeverityClauseKind
OpenMP attributes for 'severity' clause.
Definition: OpenMPKinds.h:143
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:249
OpenMPDefaultmapClauseKind
OpenMP attributes for 'defaultmap' clause.
Definition: OpenMPKinds.h:111
OpenMPAllocateClauseModifier
OpenMP modifiers for 'allocate' clause.
Definition: OpenMPKinds.h:227
OpenMPLinearClauseKind
OpenMP attributes for 'linear' clause.
Definition: OpenMPKinds.h:63
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:135
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:139
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
Definition: Ownership.h:229
const FunctionProtoType * T
VectorKind
Definition: Type.h:3994
OpenMPDeviceClauseModifier
OpenMP modifiers for 'device' clause.
Definition: OpenMPKinds.h:48
SourceLocIdentKind
Definition: Expr.h:4797
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:6852
@ 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:165
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:1975
OpenMPScheduleClauseKind
OpenMP attributes for 'schedule' clause.
Definition: OpenMPKinds.h:31
static QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T)
MutableArrayRef< Expr * > MultiExprArg
Definition: Ownership.h:258
OpenMPMapClauseKind
OpenMP mapping kind for 'map' clause.
Definition: OpenMPKinds.h:71
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Definition: ASTConcept.h:89
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.
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
Definition: Type.h:4846
EffectConditionExpr Cond
Definition: Type.h:4848
Holds information about the various types of exception specification.
Definition: Type.h:5165
FunctionDecl * SourceTemplate
The function template whose exception specification this is instantiated from, for EST_Uninstantiated...
Definition: Type.h:5181
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:5167
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:5170
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Definition: Type.h:5173
Extra information about a function prototype.
Definition: Type.h:5193
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:5200
FunctionEffectsRef FunctionEffects
Definition: Type.h:5203
const ExtParameterInfo * ExtParameterInfos
Definition: Type.h:5201
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:12723
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:2813
Location information for a TemplateArgument.
Definition: TemplateBase.h:472